68 scenePos = QPoint (f.x(), f.y());
93 QString nodeName = QString(_node->
name().c_str());
94 QAction* typeEntry =
new QAction( nodeName ,_menu );
95 _menu->addAction( typeEntry );
97 _menu->addSeparator();
115 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
117 QAction* typeEntry =
new QAction(tr(
"Viewer Settings"),_menu);
118 _menu->addAction( typeEntry );
119 typeEntry->setDisabled(
true);
120 _menu->addSeparator();
122 QAction* orthogonalCoordsys = 0;
124 orthogonalCoordsys =
new QAction( tr(
"Switch to Orthogonal coordinate system"), _menu );
125 orthogonalCoordsys->setIcon( QIcon(iconPath+
"orthogonal.png") );
127 orthogonalCoordsys =
new QAction( tr(
"Switch to Perspective coordinate system"), _menu );
128 orthogonalCoordsys->setIcon( QIcon(iconPath+
"perspective.png") );
131 _menu->addAction(orthogonalCoordsys);
144 QMenu* renderingOptionsMenu =
new QMenu(tr(
"Rendering Options"),_menu);
145 renderingOptionsMenu->setIcon( QIcon(iconPath+
"core_renderingOptions.png") );
146 _menu->addMenu(renderingOptionsMenu);
148 QAction* projectionAction = 0;
150 projectionAction =
new QAction( tr(
"Switch to Orthogonal Projection"), renderingOptionsMenu );
151 projectionAction->setIcon( QIcon(iconPath+
"orthogonal.png") );
152 projectionAction->setToolTip( tr(
"Switch to perspective orthogonal mode."));
154 projectionAction =
new QAction( tr(
"Switch to Perspective Projection"), renderingOptionsMenu );
155 projectionAction->setIcon( QIcon(iconPath+
"perspective.png") );
156 projectionAction->setToolTip( tr(
"Switch to perspective projection mode."));
159 projectionAction->setCheckable(
false );
160 projectionAction->setToolTip( tr(
"Switch between <b>perspective</b> and " 161 "<b>parrallel</b> projection mode."));
162 projectionAction->setWhatsThis( tr(
"Switch projection modes<br><br>" 163 "Switch between <b>perspective</b> and " 164 "<b>parrallel</b> projection mode."));
166 renderingOptionsMenu->addAction( projectionAction );
169 QAction* animation = renderingOptionsMenu->addAction(tr(
"Animation"));
171 animation->setToolTip(tr(
"Animate rotation of objects"));
172 animation->setCheckable(
true );
173 animation->setIcon( QIcon(iconPath+
"animation.png") );
180 QAction* backfaceCulling = renderingOptionsMenu->addAction(tr(
"Backface Culling"));
181 backfaceCulling->setToolTip(tr(
"Enable backface culling"));
182 backfaceCulling->setCheckable(
true );
183 backfaceCulling->setIcon( QIcon(iconPath+
"backFaceCulling.png") );
189 QAction* twoSidedLighting = renderingOptionsMenu->addAction(tr(
"Two-sided Lighting"));
190 twoSidedLighting->setToolTip(tr(
"Enable two-sided lighting"));
191 twoSidedLighting->setCheckable(
true );
192 twoSidedLighting->setIcon( QIcon(iconPath+
"twosidedLighting.png") );
198 QAction* multisampling = renderingOptionsMenu->addAction(tr(
"Multisampling"));
199 multisampling->setToolTip(tr(
"Enable Multisampling"));
200 multisampling->setCheckable(
true );
201 multisampling->setIcon( QIcon(iconPath+
"multiSampling.png") );
207 QAction* mipmapping = renderingOptionsMenu->addAction(tr(
"Mipmapping"));
208 mipmapping->setToolTip(tr(
"Enable Mipmapping"));
209 mipmapping->setCheckable(
true );
210 mipmapping->setIcon( QIcon(iconPath+
"mipmapping.png") );
218 if ( renderManager().available() > 1 ) {
219 QMenu* rendererMenu =
new QMenu(tr(
"Renderers"),_menu);
220 rendererMenu->setIcon(QIcon(iconPath+
"renderers.png"));
222 _menu->addMenu(rendererMenu);
225 QActionGroup* groupRenderer =
new QActionGroup(
this );
226 groupRenderer->setExclusive(
true );
235 QAction* showRendererDialog =
new QAction(tr(
"Show renderer manager"),
this);
237 rendererMenu->addAction(showRendererDialog);
239 QAction* showRendererObjectWidget =
new QAction(tr(
"Show render objects"),
this);
241 rendererMenu->addAction(showRendererObjectWidget);
243 rendererMenu->addSeparator();
245 for (
unsigned int i = 0 ; i < renderManager().
available() ; ++i) {
248 QAction * action =
new QAction( renderManager()[i]->name, groupRenderer );
249 action->setCheckable(
true );
253 action->setChecked(
true);
256 action->setData(QVariant(i));
260 rendererMenu->addActions( groupRenderer->actions() );
263 connect( groupRenderer , SIGNAL( triggered( QAction * ) ),
272 QMenu* viewingDirectionMenu =
new QMenu( tr(
"Viewing Direction"), _menu);
273 viewingDirectionMenu->setIcon(QIcon(iconPath+
"core_viewingDirection.png"));
274 _menu->addMenu(viewingDirectionMenu);
276 QActionGroup* dirGroup =
new QActionGroup(
this);
280 viewAction =
new QAction( tr(
"Free View"), viewingDirectionMenu );
281 viewAction->setIcon( QIcon(iconPath+
"orthogonal.png") );
282 viewAction->setCheckable(
true );
283 viewAction->setData( PluginFunctions::VIEW_FREE );
285 viewingDirectionMenu->addAction( viewAction );
286 dirGroup->addAction(viewAction);
287 viewingDirectionMenu->addSeparator();
289 viewAction =
new QAction( tr(
"Top View"), viewingDirectionMenu );
290 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_top.png") );
291 viewAction->setCheckable(
true );
292 viewAction->setData( PluginFunctions::VIEW_TOP );
294 viewingDirectionMenu->addAction( viewAction );
295 dirGroup->addAction(viewAction);
297 viewAction =
new QAction( tr(
"Bottom View"), viewingDirectionMenu );
298 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_bottom.png") );
299 viewAction->setCheckable(
true );
300 viewAction->setData( PluginFunctions::VIEW_BOTTOM );
302 viewingDirectionMenu->addAction( viewAction );
303 dirGroup->addAction(viewAction);
305 viewAction =
new QAction( tr(
"Left View"), viewingDirectionMenu );
306 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_left.png") );
307 viewAction->setCheckable(
true );
308 viewAction->setData( PluginFunctions::VIEW_LEFT );
310 viewingDirectionMenu->addAction( viewAction );
311 dirGroup->addAction(viewAction);
313 viewAction =
new QAction( tr(
"Right View"), viewingDirectionMenu );
314 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_right.png") );
315 viewAction->setCheckable(
true );
316 viewAction->setData( PluginFunctions::VIEW_RIGHT );
318 viewingDirectionMenu->addAction( viewAction );
319 dirGroup->addAction(viewAction);
321 viewAction =
new QAction( tr(
"Front View"), viewingDirectionMenu );
322 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_front.png") );
323 viewAction->setCheckable(
true );
324 viewAction->setData( PluginFunctions::VIEW_FRONT );
326 viewingDirectionMenu->addAction( viewAction );
327 dirGroup->addAction(viewAction);
329 viewAction =
new QAction( tr(
"Back View"), viewingDirectionMenu );
330 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_back.png") );
331 viewAction->setCheckable(
true );
332 viewAction->setData( PluginFunctions::VIEW_BACK );
334 viewingDirectionMenu->addAction( viewAction );
335 dirGroup->addAction(viewAction);
337 viewingDirectionMenu->addSeparator();
344 QAction* lockAction = viewingDirectionMenu->addAction(
"Lock rotation");
345 lockAction->setCheckable(
true );
346 lockAction->setIcon( QIcon(iconPath+
"lock_rotation.png") );
347 lockAction->setToolTip(tr(
"Lock rotation in current examiner"));
349 viewingDirectionMenu->addAction( lockAction );
351 connect( lockAction, SIGNAL(triggered(
bool)),
this, SLOT(
slotLockRotation(
bool) ) );
357 _menu->addSeparator();
365 QAction* showPostProcessorDialog =
new QAction(tr(
"Show post processor manager"),
this);
366 showPostProcessorDialog->setIcon(QIcon(iconPath+
"postprocessors.png"));
367 connect(showPostProcessorDialog,SIGNAL(triggered()),
this,SLOT(slotShowPostProcessorManager()));
368 _menu->addAction(showPostProcessorDialog);
370 _menu->addSeparator();
374 QAction* homeAction =
new QAction(tr(
"Restore home view"),_menu);
375 homeAction->setIcon( QIcon(iconPath+
"go-home.png") );
376 homeAction->setCheckable(
false );
377 homeAction->setToolTip(tr(
"Restore <b>home</b> view."));
378 homeAction->setWhatsThis( tr(
"Restore home view<br><br>" 379 "Resets the view to the home view"));
380 _menu->addAction( homeAction );
383 QAction* setHomeAction =
new QAction( tr(
"Set Home View") , _menu );
384 setHomeAction->setIcon( QIcon(iconPath+
"set-home.png") );
385 setHomeAction->setCheckable(
false );
386 setHomeAction->setToolTip(tr(
"Set <b>home</b> view"));
387 setHomeAction->setWhatsThis( tr(
"Store home view<br><br>" 388 "Stores the current view as the home view"));
389 _menu->addAction( setHomeAction);
392 QAction* viewAllAction =
new QAction( tr(
"View all"), _menu );
393 viewAllAction->setIcon( QIcon(iconPath+
"viewall.png") );
394 viewAllAction->setCheckable(
false );
395 viewAllAction->setToolTip(tr(
"View all."));
396 viewAllAction->setWhatsThis( tr(
"View all<br><br>" 397 "Move the objects in the scene so that" 398 " the whole scene is visible."));
400 _menu->addAction( viewAllAction);
403 _menu->addSeparator();
407 QAction* copyView = _menu->addAction(tr(
"Copy View"));
408 copyView->setToolTip(tr(
"Copy current view, window size and toolbar size to clipboard. Hold Ctrl to generate C/C++/JavaScipt-Style string."));
409 copyView->setIcon( QIcon(iconPath+
"edit-copy.png") );
410 connect(copyView, SIGNAL(triggered()),
this, SLOT(
slotCopyView()) );
414 QAction* pasteView = _menu->addAction(tr(
"Paste View"));
415 pasteView->setToolTip(tr(
"Paste current view from clipboard"));
416 pasteView->setIcon( QIcon(iconPath+
"edit-paste.png") );
417 connect(pasteView, SIGNAL(triggered()),
this , SLOT(
slotPasteView( ) ) );
421 QAction* pasteViewAndWindow = _menu->addAction(tr(
"Paste View and Window Size"));
422 pasteViewAndWindow->setToolTip(tr(
"Paste current view, window size and the toolbox size from clipboard"));
423 pasteViewAndWindow->setIcon( QIcon(iconPath+
"edit-paste.png") );
428 QAction* snapshot_examiner = _menu->addAction(tr(
"Examiner Snapshot"));
429 snapshot_examiner->setToolTip(tr(
"Take a snapshot of the current examiner"));
430 snapshot_examiner->setIcon( QIcon(iconPath+
"snapshot.png") );
435 QAction* snapshot_viewer = _menu->addAction(tr(
"Viewer Snapshot"));
436 snapshot_viewer->setToolTip(tr(
"Take a snapshot of the whole viewer"));
437 snapshot_viewer->setIcon( QIcon(iconPath+
"snapshot.png") );
459 _menu->addSeparator();
461 QAction* action = _menu->addAction(tr(
"Set Background Color"));
462 action->setToolTip(tr(
"Set the background color for the current viewer"));
463 action->setStatusTip(tr(
"Set the background color for the current viewer"));
464 action->setWhatsThis(tr(
"Set the background color for the current viewer"));
465 action->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"BackgroundColor.png") );
482 _menu->addSeparator();
503 QAction* typeEntry =
new QAction(
typeName(_object->
dataType())+QString(
": ")+_object->
name() ,_menu);
505 _menu->addAction( typeEntry );
507 _menu->addSeparator( );
513 _menu->addSeparator();
527 QMap< QString , QAction* > menuMap;
528 QMap< QString , QAction* > actionMap;
542 emit log(
LOGERR,tr(
"Cant get object for objectContextMenu"));
559 actionMap[
contextMenus_[i].action->text() ] = contextMenus_[i].action;
561 menuMap[ contextMenus_[i].action->text() ] = contextMenus_[i].action;
569 QList< QAction *> allActions;
571 allActions.push_back(contextMenus_[i].action);
573 allActions = menu->actions();
576 while ( !allActions.empty() ) {
577 QList< QAction *> tmpList;
580 for (
int j = 0 ; j < allActions.size(); ++j ) {
581 allActions[j]->setData( QVariant( _id ) );
582 if ( allActions[j]->menu() != 0 )
583 tmpList << allActions[j]->menu()->actions();
586 allActions = tmpList;
594 if (
viewModes_[i]->name == OpenFlipper::Options::currentViewMode()) {
602 emit log(
LOGERR, tr(
"Unable to find view mode %1.").arg(OpenFlipper::Options::currentViewMode()) );
609 QMapIterator<QString, QAction*> it(menuMap);
611 QStringList visible =
viewModes_[id]->visibleContextMenus;
612 if (visible.contains(
"ALL_THAT_EXIST")) {
618 visible.replaceInStrings(QRegExp(
".*>"),
"");
621 visible.replaceInStrings(
"&",
"");
623 while (it.hasNext()) {
626 for (
int i = 0 ; i < visible.size(); ++i ) {
627 if ( it.key().contains(visible[i]) ) {
628 _menu->addAction( it.value() );
633 _menu->addSeparator();
636 QMapIterator<QString, QAction*> it2(actionMap);
638 while (it2.hasNext()) {
641 for (
int i = 0 ; i < visible.size(); ++i ) {
642 if ( it2.key().contains(visible[i]) ) {
643 _menu->addAction( it2.value() );
672 COORDSYSCONTEXT ,BACKGROUNDCONTEXT ,OBJECTCONTEXT, NODECONTEXT
673 } context = BACKGROUNDCONTEXT;
676 size_t node_idx, target_idx;
684 context = OBJECTCONTEXT;
687 if ( node != 0 && ( node->
name() ==
"Core Coordsys Node") )
688 context = COORDSYSCONTEXT;
690 context = NODECONTEXT;
701 case BACKGROUNDCONTEXT:
709 case COORDSYSCONTEXT:
723 std::cerr <<
"Todo : slotSnapShotName only sets name for current viewer" << std::endl;
727 fname.replace(
'%',
'$');
728 fname = QFileDialog::getSaveFileName ( 0,
729 tr(
"Save snapshot name"),
732 if (!fname.isEmpty())
734 fname.replace(
'$',
'%');
738 QFileInfo fileInfo(fname);
742 QString msg=tr(
"next snapshot: ");
743 statusBar()->showMessage(msg);
770 for ( uint i = 0 ; i <
plugins().size(); ++i ) {
771 if (
plugins()[i].plugin == sender() ) {
779 for ( uint i = 0 ; i <
plugins().size(); ++i ) {
780 if (
plugins()[i].name ==
"Scripting" ) {
788 std::cerr <<
"Unknown sender plugin when adding Context Menu!" << std::endl;
793 plugins()[id].contextMenus.push_back( std::pair< QString,QAction* >(
plugins()[
id].name +
"->" + _entry->text(), _entry) );
796 if ( !
viewModes_[0]->visibleContextMenus.contains(
plugins()[
id].name +
"->" + _entry->text()) ){
797 viewModes_[0]->visibleContextMenus <<
plugins()[id].name +
"->" + _entry->text();
801 setViewMode( OpenFlipper::Options::currentViewMode() );
824 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
848 std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
853 for (
unsigned int i = 0; i < availDrawModeIds.size(); ++i )
856 std::string descr =
id.description();
861 checkableAction->setText(descr.c_str());
862 checkableAction->setDefaultWidget(checkBox);
863 connect(checkBox, SIGNAL(toggled(
bool) ), checkableAction, SLOT(trigger() ) );
876 std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
878 for (
unsigned int i = 0; i < availDrawModeIds.size(); ++i )
880 QString descr = QString( availDrawModeIds[i].description().c_str() );
882 if ( descr == _action->text() ) {
883 mode = availDrawModeIds[i];
888 if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
899 unsigned int mode = _action->data().toUInt();
904 unsigned int mode = _action->data().toUInt();
908 QString defaultRendererName = renderManager()[mode]->name;
void setViewMode(QString _mode, bool _expandAll=false)
Set the view Mode to the given Mode.
void updatePopupMenuObject(QMenu *_menu, BaseObjectData *_object)
Update popup Menu when an object has been clicked on.
void updatePopupMenuNode(QMenu *_menu, ACG::SceneGraph::BaseNode *_node)
Update context Menu when an arbitrary node has been clicked on.
size_t available()
number of available renderers
void slotAddContextItem(QAction *_entry, ContextMenuType _type)
called by plugins to add a new context menu item
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
void slotShowRenderObjectWidget()
Shows the widget containing the current render objects.
void slotLocalChangeMultisampling(bool _multisampling)
Set multisampling for active viewer.
void slotCopyView()
Copy view from the last active examiner.
void updatePopupMenuBackground(QMenu *_menu, const QPoint &_point)
Update context Menu when background has been clicked on.
void viewerSnapshotDialog()
Create a snapshot of the whole app with fileDialog.
void slotSnapshotName()
Set the snapShot name for all examiners.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
pick any of the prior targets (should be implemented for all nodes)
void slotContextSwitchProjection()
Toggle projection mode of the active viewer.
void slotUpdateViewerDrawMenu()
Creates a draw Menu for the currently active Viewer.
std::vector< MenuInfo > contextMenus_
All real context menu entries.
void slotLockRotation(bool _lock)
Lock rotation in current examiner widget.
void updatePopupMenuCoordsysNode(QMenu *_menu, const int _part)
Update context Menu when Coordsys node has been clicked on.
void updateContextMenuNode(int)
tells the plugins to update their context menu when a node is picked
QActionGroup * drawGroupViewer_
DrawGroup for per Viewer Draw Modes.
ACG::SceneGraph::CoordsysNode::ProjectionMode getCoordsysProjection()
Toggle coordsys projection mode of the active viewer.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
void slotLocalChangeTwoSidedLighting(bool _lighting)
Set two-sided lighting for active viewer.
void slotUpdateGlobalDrawMenu()
Setup and update the global draw menu.
void slotLocalChangeBackFaceCulling(bool _backFaceCulling)
Set backface culling for active viewer.
bool addContextMenus(QMenu *_menu, ContextMenuType _type, int _id=-1)
DrawModes::DrawMode drawModes() const
Get the collected draw modes.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void slotRenderMenu(QAction *_action)
Called when a different renderer has been chosen.
void slotExaminerSnapshot()
Create a snapshot of the last active examiner.
The Menu will be shown when the background was picked.
bool dataType(DataType _type) const
void updateContextMenuBackground()
tells the plugins to update their context menu when the background is picked
std::vector< PluginInfo > & plugins()
Convenient way to access plugin list.
void slotSetContextBackgroundColor()
Set Background Color for one viewer.
void slotHideContextMenu()
Hide the context menu.
QAction * action
The context item.
void setActive(unsigned int _active, int _viewerId)
set the active post processor for viewer
void slotPasteView()
Paste the view to the last active examiner.
QMenu * viewerDrawMenu_
Draw Menu for per Viewer Draw Modes.
QMenu * contextSelectionMenu_
Context Menu containing all selection elements.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
void slotContextSwitchCoordsysProjection()
Toggle coordsys projection mode of the active viewer.
std::string name() const
Returns: name of node (needs not be unique)
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
QMenu * contextMenu_
context Menu for the gl area
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void slotContextSetHomeView()
Set the active viewers home position.
void slotAddContextItemToViewMode(QAction *_entry)
called by slotAddContextItem to add the item to the view mode
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void updatePopupMenu(const QPoint &_point)
check current context and initialize context menu according to this context.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
void slotSetViewingDirection(QAction *_action)
Change the viewing direction from context-menu.
void slotLocalChangeMipmapping(bool _mipmapping)
Set mipmapping for active viewer.
void slotPasteViewAndWindow()
Paste the view, the window and toolbox size to the last active examiner.
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
void slotContextHomeView()
Set the active viewer to home position.
ChildIter find(BaseNode *_node)
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
void slotLocalChangeAnimation(bool _animation)
Set the animation mode for active viewer.
The Menu will be shown when a node was picked.
void setActive(unsigned int _active, int _id)
set the active renderer
QWidget * viewerDrawMenuWidget_
owns all the checkboxes of viewerDrawMenu_
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
void slotContextViewAll()
Change view on active viewer to view complete scene.
void slotShowRenderManager()
shows the widget for the rendermanager
void slotPostProcessorMenu(QAction *_action)
Called when a different post processor has been chosen.
void traverse(BaseNode *_node, Action &_action)
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
std::vector< glViewer *> examiner_widgets_
Examiner Widget.
bool visible()
Is node visible (status == Active)?
ACG::SceneGraph::DrawModes::DrawMode availableGlobalDrawModes_
This variable holds the global draw menu.
void slotViewerDrawMenu(QAction *_action)
Called when a coordsys drawMode has been changed.
void updateContextMenu(int)
tells the plugins to update their context menu when an object is picked
DataType contextType
Type of objects for which the context Menu should be visible.
QVector< ViewMode * > & viewModes_
List of currently available viewModes.
bool containsAtomicDrawMode(const DrawMode &_atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
The Menu will be shown when an object was picked.
void snapshotBaseFileName(const QString &_fname)
ContextMenuType type
Type of the context Menu ( Context for what type .. Background,Object,Node)
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
void slotCustomContextMenu(const QPoint &_point)
This slot is called by the examiner widgets gl area when a context menu is requested.