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;
DrawModes::DrawMode drawModes() const
Get the collected draw modes.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
std::string name() const
Returns: name of node (needs not be unique)
void setActive(unsigned int _active, int _id)
set the active renderer
bool containsAtomicDrawMode(const DrawMode &_atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
bool dataType(DataType _type) const
pick any of the prior targets (should be implemented for all nodes)
void snapshotBaseFileName(const QString &_fname)
QString name() const
return the name of the object. The name defaults to NONAME if unset.
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
void setActive(unsigned int _active, int _viewerId)
set the active post processor for viewer
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
bool visible()
Is node visible (status == Active)?
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
size_t available()
number of available renderers
ChildIter find(BaseNode *_node)
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
void traverse(BaseNode *_node, Action &_action)
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.