74 scenePos = QPoint (f.x(), f.y());
99 QString nodeName = QString(_node->
name().c_str());
100 QAction* typeEntry =
new QAction( nodeName ,_menu );
101 _menu->addAction( typeEntry );
103 _menu->addSeparator();
121 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
123 QAction* typeEntry =
new QAction(tr(
"Viewer Settings"),_menu);
124 _menu->addAction( typeEntry );
125 typeEntry->setDisabled(
true);
126 _menu->addSeparator();
128 QAction* orthogonalCoordsys = 0;
130 orthogonalCoordsys =
new QAction( tr(
"Switch to Orthogonal coordinate system"), _menu );
131 orthogonalCoordsys->setIcon( QIcon(iconPath+
"orthogonal.png") );
133 orthogonalCoordsys =
new QAction( tr(
"Switch to Perspective coordinate system"), _menu );
134 orthogonalCoordsys->setIcon( QIcon(iconPath+
"perspective.png") );
137 _menu->addAction(orthogonalCoordsys);
150 QMenu* renderingOptionsMenu =
new QMenu(tr(
"Rendering Options"),_menu);
151 renderingOptionsMenu->setIcon( QIcon(iconPath+
"core_renderingOptions.png") );
152 _menu->addMenu(renderingOptionsMenu);
154 QAction* projectionAction = 0;
156 projectionAction =
new QAction( tr(
"Switch to Orthogonal Projection"), renderingOptionsMenu );
157 projectionAction->setIcon( QIcon(iconPath+
"orthogonal.png") );
158 projectionAction->setToolTip( tr(
"Switch to perspective orthogonal mode."));
160 projectionAction =
new QAction( tr(
"Switch to Perspective Projection"), renderingOptionsMenu );
161 projectionAction->setIcon( QIcon(iconPath+
"perspective.png") );
162 projectionAction->setToolTip( tr(
"Switch to perspective projection mode."));
165 projectionAction->setCheckable(
false );
166 projectionAction->setToolTip( tr(
"Switch between <b>perspective</b> and "
167 "<b>parrallel</b> projection mode."));
168 projectionAction->setWhatsThis( tr(
"Switch projection modes<br><br>"
169 "Switch between <b>perspective</b> and "
170 "<b>parrallel</b> projection mode."));
172 renderingOptionsMenu->addAction( projectionAction );
175 QAction* animation = renderingOptionsMenu->addAction(tr(
"Animation"));
177 animation->setToolTip(tr(
"Animate rotation of objects"));
178 animation->setCheckable(
true );
179 animation->setIcon( QIcon(iconPath+
"animation.png") );
186 QAction* backfaceCulling = renderingOptionsMenu->addAction(tr(
"Backface Culling"));
187 backfaceCulling->setToolTip(tr(
"Enable backface culling"));
188 backfaceCulling->setCheckable(
true );
189 backfaceCulling->setIcon( QIcon(iconPath+
"backFaceCulling.png") );
195 QAction* twoSidedLighting = renderingOptionsMenu->addAction(tr(
"Two-sided Lighting"));
196 twoSidedLighting->setToolTip(tr(
"Enable two-sided lighting"));
197 twoSidedLighting->setCheckable(
true );
198 twoSidedLighting->setIcon( QIcon(iconPath+
"twosidedLighting.png") );
204 QAction* multisampling = renderingOptionsMenu->addAction(tr(
"Multisampling"));
205 multisampling->setToolTip(tr(
"Enable Multisampling"));
206 multisampling->setCheckable(
true );
207 multisampling->setIcon( QIcon(iconPath+
"multiSampling.png") );
213 QAction* mipmapping = renderingOptionsMenu->addAction(tr(
"Mipmapping"));
214 mipmapping->setToolTip(tr(
"Enable Mipmapping"));
215 mipmapping->setCheckable(
true );
216 mipmapping->setIcon( QIcon(iconPath+
"mipmapping.png") );
224 if ( renderManager().available() > 1 ) {
225 QMenu* rendererMenu =
new QMenu(tr(
"Renderers"),_menu);
226 rendererMenu->setIcon(QIcon(iconPath+
"renderers.png"));
228 _menu->addMenu(rendererMenu);
231 QActionGroup* groupRenderer =
new QActionGroup(
this );
232 groupRenderer->setExclusive(
true );
241 QAction* showRendererDialog =
new QAction(tr(
"Show renderer manager"),
this);
243 rendererMenu->addAction(showRendererDialog);
245 QAction* showRendererObjectWidget =
new QAction(tr(
"Show render objects"),
this);
247 rendererMenu->addAction(showRendererObjectWidget);
249 rendererMenu->addSeparator();
251 for (
unsigned int i = 0 ; i < renderManager().
available() ; ++i) {
254 QAction * action =
new QAction( renderManager()[i]->name, groupRenderer );
255 action->setCheckable(
true );
259 action->setChecked(
true);
262 action->setData(QVariant(i));
266 rendererMenu->addActions( groupRenderer->actions() );
269 connect( groupRenderer , SIGNAL( triggered( QAction * ) ),
278 QMenu* viewingDirectionMenu =
new QMenu( tr(
"Viewing Direction"), _menu);
279 viewingDirectionMenu->setIcon(QIcon(iconPath+
"core_viewingDirection.png"));
280 _menu->addMenu(viewingDirectionMenu);
282 QActionGroup* dirGroup =
new QActionGroup(
this);
286 viewAction =
new QAction( tr(
"Free View"), viewingDirectionMenu );
287 viewAction->setIcon( QIcon(iconPath+
"orthogonal.png") );
288 viewAction->setCheckable(
true );
289 viewAction->setData( PluginFunctions::VIEW_FREE );
291 viewingDirectionMenu->addAction( viewAction );
292 dirGroup->addAction(viewAction);
293 viewingDirectionMenu->addSeparator();
295 viewAction =
new QAction( tr(
"Top View"), viewingDirectionMenu );
296 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_top.png") );
297 viewAction->setCheckable(
true );
298 viewAction->setData( PluginFunctions::VIEW_TOP );
300 viewingDirectionMenu->addAction( viewAction );
301 dirGroup->addAction(viewAction);
303 viewAction =
new QAction( tr(
"Bottom View"), viewingDirectionMenu );
304 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_bottom.png") );
305 viewAction->setCheckable(
true );
306 viewAction->setData( PluginFunctions::VIEW_BOTTOM );
308 viewingDirectionMenu->addAction( viewAction );
309 dirGroup->addAction(viewAction);
311 viewAction =
new QAction( tr(
"Left View"), viewingDirectionMenu );
312 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_left.png") );
313 viewAction->setCheckable(
true );
314 viewAction->setData( PluginFunctions::VIEW_LEFT );
316 viewingDirectionMenu->addAction( viewAction );
317 dirGroup->addAction(viewAction);
319 viewAction =
new QAction( tr(
"Right View"), viewingDirectionMenu );
320 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_right.png") );
321 viewAction->setCheckable(
true );
322 viewAction->setData( PluginFunctions::VIEW_RIGHT );
324 viewingDirectionMenu->addAction( viewAction );
325 dirGroup->addAction(viewAction);
327 viewAction =
new QAction( tr(
"Front View"), viewingDirectionMenu );
328 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_front.png") );
329 viewAction->setCheckable(
true );
330 viewAction->setData( PluginFunctions::VIEW_FRONT );
332 viewingDirectionMenu->addAction( viewAction );
333 dirGroup->addAction(viewAction);
335 viewAction =
new QAction( tr(
"Back View"), viewingDirectionMenu );
336 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_back.png") );
337 viewAction->setCheckable(
true );
338 viewAction->setData( PluginFunctions::VIEW_BACK );
340 viewingDirectionMenu->addAction( viewAction );
341 dirGroup->addAction(viewAction);
343 viewingDirectionMenu->addSeparator();
350 QAction* lockAction = viewingDirectionMenu->addAction(
"Lock rotation");
351 lockAction->setCheckable(
true );
352 lockAction->setIcon( QIcon(iconPath+
"lock_rotation.png") );
353 lockAction->setToolTip(tr(
"Lock rotation in current examiner"));
355 viewingDirectionMenu->addAction( lockAction );
357 connect( lockAction, SIGNAL(triggered(
bool)),
this, SLOT(
slotLockRotation(
bool) ) );
363 _menu->addSeparator();
371 QAction* showPostProcessorDialog =
new QAction(tr(
"Show post processor manager"),
this);
372 showPostProcessorDialog->setIcon(QIcon(iconPath+
"postprocessors.png"));
373 connect(showPostProcessorDialog,SIGNAL(triggered()),
this,SLOT(slotShowPostProcessorManager()));
374 _menu->addAction(showPostProcessorDialog);
376 _menu->addSeparator();
380 QAction* homeAction =
new QAction(tr(
"Restore home view"),_menu);
381 homeAction->setIcon( QIcon(iconPath+
"go-home.png") );
382 homeAction->setCheckable(
false );
383 homeAction->setToolTip(tr(
"Restore <b>home</b> view."));
384 homeAction->setWhatsThis( tr(
"Restore home view<br><br>"
385 "Resets the view to the home view"));
386 _menu->addAction( homeAction );
389 QAction* setHomeAction =
new QAction( tr(
"Set Home View") , _menu );
390 setHomeAction->setIcon( QIcon(iconPath+
"set-home.png") );
391 setHomeAction->setCheckable(
false );
392 setHomeAction->setToolTip(tr(
"Set <b>home</b> view"));
393 setHomeAction->setWhatsThis( tr(
"Store home view<br><br>"
394 "Stores the current view as the home view"));
395 _menu->addAction( setHomeAction);
398 QAction* viewAllAction =
new QAction( tr(
"View all"), _menu );
399 viewAllAction->setIcon( QIcon(iconPath+
"viewall.png") );
400 viewAllAction->setCheckable(
false );
401 viewAllAction->setToolTip(tr(
"View all."));
402 viewAllAction->setWhatsThis( tr(
"View all<br><br>"
403 "Move the objects in the scene so that"
404 " the whole scene is visible."));
406 _menu->addAction( viewAllAction);
409 _menu->addSeparator();
413 QAction* copyView = _menu->addAction(tr(
"Copy View"));
414 copyView->setToolTip(tr(
"Copy current view, window size and toolbar size to clipboard. Hold Ctrl to generate C/C++/JavaScipt-Style string."));
415 copyView->setIcon( QIcon(iconPath+
"edit-copy.png") );
416 connect(copyView, SIGNAL(triggered()),
this, SLOT(
slotCopyView()) );
420 QAction* pasteView = _menu->addAction(tr(
"Paste View"));
421 pasteView->setToolTip(tr(
"Paste current view from clipboard"));
422 pasteView->setIcon( QIcon(iconPath+
"edit-paste.png") );
423 connect(pasteView, SIGNAL(triggered()),
this , SLOT(
slotPasteView( ) ) );
427 QAction* pasteViewAndWindow = _menu->addAction(tr(
"Paste View and Window Size"));
428 pasteViewAndWindow->setToolTip(tr(
"Paste current view, window size and the toolbox size from clipboard"));
429 pasteViewAndWindow->setIcon( QIcon(iconPath+
"edit-paste.png") );
434 QAction* snapshot_examiner = _menu->addAction(tr(
"Examiner Snapshot"));
435 snapshot_examiner->setToolTip(tr(
"Take a snapshot of the current examiner"));
436 snapshot_examiner->setIcon( QIcon(iconPath+
"snapshot.png") );
441 QAction* snapshot_viewer = _menu->addAction(tr(
"Viewer Snapshot"));
442 snapshot_viewer->setToolTip(tr(
"Take a snapshot of the whole viewer"));
443 snapshot_viewer->setIcon( QIcon(iconPath+
"snapshot.png") );
465 _menu->addSeparator();
467 QAction* action = _menu->addAction(tr(
"Set Background Color"));
468 action->setToolTip(tr(
"Set the background color for the current viewer"));
469 action->setStatusTip(tr(
"Set the background color for the current viewer"));
470 action->setWhatsThis(tr(
"Set the background color for the current viewer"));
471 action->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"BackgroundColor.png") );
488 _menu->addSeparator();
509 QAction* typeEntry =
new QAction(
typeName(_object->
dataType())+QString(
": ")+_object->
name() ,_menu);
511 _menu->addAction( typeEntry );
513 _menu->addSeparator( );
519 _menu->addSeparator();
533 QMap< QString , QAction* > menuMap;
534 QMap< QString , QAction* > actionMap;
548 emit log(
LOGERR,tr(
"Cant get object for objectContextMenu"));
565 actionMap[
contextMenus_[i].action->text() ] = contextMenus_[i].action;
567 menuMap[ contextMenus_[i].action->text() ] = contextMenus_[i].action;
575 QList< QAction *> allActions;
577 allActions.push_back(contextMenus_[i].action);
579 allActions = menu->actions();
582 while ( !allActions.empty() ) {
583 QList< QAction *> tmpList;
586 for (
int j = 0 ; j < allActions.size(); ++j ) {
587 allActions[j]->setData( QVariant( _id ) );
588 if ( allActions[j]->menu() != 0 )
589 tmpList << allActions[j]->menu()->actions();
592 allActions = tmpList;
600 if (
viewModes_[i]->name == OpenFlipper::Options::currentViewMode()) {
608 emit log(
LOGERR, tr(
"Unable to find view mode %1.").arg(OpenFlipper::Options::currentViewMode()) );
615 QMapIterator<QString, QAction*> it(menuMap);
617 QStringList visible =
viewModes_[id]->visibleContextMenus;
618 if (visible.contains(
"ALL_THAT_EXIST")) {
624 visible.replaceInStrings(QRegExp(
".*>"),
"");
627 visible.replaceInStrings(
"&",
"");
629 while (it.hasNext()) {
632 for (
int i = 0 ; i < visible.size(); ++i ) {
633 if ( it.key().contains(visible[i]) ) {
634 _menu->addAction( it.value() );
639 _menu->addSeparator();
642 QMapIterator<QString, QAction*> it2(actionMap);
644 while (it2.hasNext()) {
647 for (
int i = 0 ; i < visible.size(); ++i ) {
648 if ( it2.key().contains(visible[i]) ) {
649 _menu->addAction( it2.value() );
678 COORDSYSCONTEXT ,BACKGROUNDCONTEXT ,OBJECTCONTEXT, NODECONTEXT
679 } context = BACKGROUNDCONTEXT;
682 unsigned int node_idx, target_idx;
690 context = OBJECTCONTEXT;
693 if ( node != 0 && ( node->
name() ==
"Core Coordsys Node") )
694 context = COORDSYSCONTEXT;
696 context = NODECONTEXT;
707 case BACKGROUNDCONTEXT:
715 case COORDSYSCONTEXT:
729 std::cerr <<
"Todo : slotSnapShotName only sets name for current viewer" << std::endl;
733 fname.replace(
'%',
'$');
734 fname = QFileDialog::getSaveFileName ( 0,
735 tr(
"Save snapshot name"),
738 if (!fname.isEmpty())
740 fname.replace(
'$',
'%');
744 QFileInfo fileInfo(fname);
748 QString msg=tr(
"next snapshot: ");
749 statusBar()->showMessage(msg);
776 for ( uint i = 0 ; i < plugins_.size(); ++i ) {
777 if ( plugins_[i].plugin == sender() ) {
785 for ( uint i = 0 ; i < plugins_.size(); ++i ) {
786 if ( plugins_[i].name ==
"Scripting" ) {
794 std::cerr <<
"Unknown sender plugin when adding Context Menu!" << std::endl;
799 plugins_[id].contextMenus.push_back( std::pair< QString,QAction* >( plugins_[
id].name +
"->" + _entry->text(), _entry) );
802 if ( !
viewModes_[0]->visibleContextMenus.contains(plugins_[
id].name +
"->" + _entry->text()) ){
803 viewModes_[0]->visibleContextMenus << plugins_[id].name +
"->" + _entry->text();
807 setViewMode( OpenFlipper::Options::currentViewMode() );
830 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
854 std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
859 for (
unsigned int i = 0; i < availDrawModeIds.size(); ++i )
862 std::string descr =
id.description();
867 checkableAction->setText(descr.c_str());
868 checkableAction->setDefaultWidget(checkBox);
869 connect(checkBox, SIGNAL(toggled(
bool) ), checkableAction, SLOT(trigger() ) );
882 std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
884 for (
unsigned int i = 0; i < availDrawModeIds.size(); ++i )
886 QString descr = QString( availDrawModeIds[i].description().c_str() );
888 if ( descr == _action->text() ) {
889 mode = availDrawModeIds[i];
894 if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
905 unsigned int mode = _action->data().toUInt();
910 unsigned int mode = _action->data().toUInt();
914 QString defaultRendererName = renderManager()[mode]->name;
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
void updatePopupMenuObject(QMenu *_menu, BaseObjectData *_object)
Update popup Menu when an object has been clicked on.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
void slotContextSetHomeView()
Set the active viewers home position.
void updateContextMenuBackground()
tells the plugins to update their context menu when the background is picked
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void slotSetContextBackgroundColor()
Set Background Color for one viewer.
void slotLocalChangeBackFaceCulling(bool _backFaceCulling)
Set backface culling for active viewer.
void slotLocalChangeMultisampling(bool _multisampling)
Set multisampling for active viewer.
bool visible()
Is node visible (status == Active)?
void viewerSnapshotDialog()
Create a snapshot of the whole app with fileDialog.
DrawModes::DrawMode drawModes() const
Get the collected draw modes.
void setActive(unsigned int _active, int _viewerId)
set the active post processor for viewer
QActionGroup * drawGroupViewer_
DrawGroup for per Viewer Draw Modes.
bool containsAtomicDrawMode(DrawMode _atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
void slotPostProcessorMenu(QAction *_action)
Called when a different post processor has been chosen.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void slotShowRenderObjectWidget()
Shows the widget containing the current render objects.
pick any of the prior targets (should be implemented for all nodes)
void updateContextMenuNode(int)
tells the plugins to update their context menu when a node is picked
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void slotShowRenderManager()
shows the widget for the rendermanager
void slotCustomContextMenu(const QPoint &_point)
This slot is called by the examiner widgets gl area when a context menu is requested.
void slotUpdateViewerDrawMenu()
Creates a draw Menu for the currently active Viewer.
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
void slotUpdateGlobalDrawMenu()
Setup and update the global draw menu.
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
void snapshotBaseFileName(const QString &_fname)
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
bool dataType(DataType _type) const
unsigned int available()
number of available renderers
void slotSetViewingDirection(QAction *_action)
Change the viewing direction from context-menu.
void slotExaminerSnapshot()
Create a snapshot of the last active examiner.
void updatePopupMenuNode(QMenu *_menu, ACG::SceneGraph::BaseNode *_node)
Update context Menu when an arbitrary node has been clicked on.
The Menu will be shown when the background was picked.
void slotContextViewAll()
Change view on active viewer to view complete scene.
void updatePopupMenuCoordsysNode(QMenu *_menu, const int _part)
Update context Menu when Coordsys node has been clicked on.
ACG::SceneGraph::CoordsysNode::ProjectionMode getCoordsysProjection()
Toggle coordsys projection mode of the active viewer.
void setViewMode(QString _mode, bool _expandAll=false)
Set the view Mode to the given Mode.
std::string name() const
Returns: name of node (needs not be unique)
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
ContextMenuType type
Type of the context Menu ( Context for what type .. Background,Object,Node)
void slotLockRotation(bool _lock)
Lock rotation in current examiner widget.
ACG::SceneGraph::DrawModes::DrawMode availableGlobalDrawModes_
This variable holds the global draw menu.
void updatePopupMenuBackground(QMenu *_menu, const QPoint &_point)
Update context Menu when background has been clicked on.
QAction * action
The context item.
QMenu * contextMenu_
context Menu for the gl area
void slotLocalChangeTwoSidedLighting(bool _lighting)
Set two-sided lighting for active viewer.
void slotAddContextItem(QAction *_entry, ContextMenuType _type)
called by plugins to add a new context menu item
QWidget * viewerDrawMenuWidget_
owns all the checkboxes of viewerDrawMenu_
The Menu will be shown when an object was picked.
void updateContextMenu(int)
tells the plugins to update their context menu when an object is picked
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
void setActive(unsigned int _active, int _id)
set the active renderer
The Menu will be shown when a node was picked.
void slotAddContextItemToViewMode(QAction *_entry)
called by slotAddContextItem to add the item to the view mode
DataType contextType
Type of objects for which the context Menu should be visible.
void slotContextSwitchProjection()
Toggle projection mode of the active viewer.
void slotPasteView()
Paste the view to the last active examiner.
void slotContextSwitchCoordsysProjection()
Toggle coordsys projection mode of the active viewer.
QMenu * contextSelectionMenu_
Context Menu containing all selection elements.
QVector< ViewMode * > & viewModes_
List of currently available viewModes.
std::vector< MenuInfo > contextMenus_
All real context menu entries.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void slotPasteViewAndWindow()
Paste the view, the window and toolbox size to the last active examiner.
void slotViewerDrawMenu(QAction *_action)
Called when a coordsys drawMode has been changed.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void traverse(BaseNode *_node, Action &_action)
bool getPickedObject(const unsigned int _node_idx, BaseObjectData *&_object)
Get the picked mesh.
void slotContextHomeView()
Set the active viewer to home position.
void slotHideContextMenu()
Hide the context menu.
void slotLocalChangeAnimation(bool _animation)
Set the animation mode for active viewer.
bool addContextMenus(QMenu *_menu, ContextMenuType _type, int _id=-1)
void slotSnapshotName()
Set the snapShot name for all examiners.
void slotRenderMenu(QAction *_action)
Called when a different renderer has been chosen.
ChildIter find(BaseNode *_node)
QMenu * viewerDrawMenu_
Draw Menu for per Viewer Draw Modes.
void updatePopupMenu(const QPoint &_point)
check current context and initialize context menu according to this context.
void slotLocalChangeMipmapping(bool _mipmapping)
Set mipmapping for active viewer.
std::vector< glViewer * > examiner_widgets_
Examiner Widget.
void slotCopyView()
Copy view from the last active examiner.