91 QString nodeName = QString(_node->
name().c_str());
92 QAction* typeEntry =
new QAction( nodeName ,_menu );
93 _menu->addAction( typeEntry );
95 _menu->addSeparator();
113 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
115 QAction* typeEntry =
new QAction(tr(
"Viewer Settings"),_menu);
116 _menu->addAction( typeEntry );
117 typeEntry->setDisabled(
true);
118 _menu->addSeparator();
120 QAction* orthogonalCoordsys = 0;
122 orthogonalCoordsys =
new QAction( tr(
"Switch to Orthogonal coordinate system"), _menu );
123 orthogonalCoordsys->setIcon( QIcon(iconPath+
"orthogonal.png") );
125 orthogonalCoordsys =
new QAction( tr(
"Switch to Perspective coordinate system"), _menu );
126 orthogonalCoordsys->setIcon( QIcon(iconPath+
"perspective.png") );
129 _menu->addAction(orthogonalCoordsys);
142 QMenu* renderingOptionsMenu =
new QMenu(tr(
"Rendering Options"),_menu);
143 renderingOptionsMenu->setIcon( QIcon(iconPath+
"core_renderingOptions.png") );
144 _menu->addMenu(renderingOptionsMenu);
146 QAction* projectionAction = 0;
148 projectionAction =
new QAction( tr(
"Switch to Orthogonal Projection"), renderingOptionsMenu );
149 projectionAction->setIcon( QIcon(iconPath+
"orthogonal.png") );
150 projectionAction->setToolTip( tr(
"Switch to perspective orthogonal mode."));
152 projectionAction =
new QAction( tr(
"Switch to Perspective Projection"), renderingOptionsMenu );
153 projectionAction->setIcon( QIcon(iconPath+
"perspective.png") );
154 projectionAction->setToolTip( tr(
"Switch to perspective projection mode."));
157 projectionAction->setCheckable(
false );
158 projectionAction->setToolTip( tr(
"Switch between <b>perspective</b> and "
159 "<b>parrallel</b> projection mode."));
160 projectionAction->setWhatsThis( tr(
"Switch projection modes<br><br>"
161 "Switch between <b>perspective</b> and "
162 "<b>parrallel</b> projection mode."));
164 renderingOptionsMenu->addAction( projectionAction );
167 QAction* animation = renderingOptionsMenu->addAction(tr(
"Animation"));
169 animation->setToolTip(tr(
"Animate rotation of objects"));
170 animation->setCheckable(
true );
171 animation->setIcon( QIcon(iconPath+
"animation.png") );
178 QAction* backfaceCulling = renderingOptionsMenu->addAction(tr(
"Backface Culling"));
179 backfaceCulling->setToolTip(tr(
"Enable backface culling"));
180 backfaceCulling->setCheckable(
true );
181 backfaceCulling->setIcon( QIcon(iconPath+
"backFaceCulling.png") );
187 QAction* twoSidedLighting = renderingOptionsMenu->addAction(tr(
"Two-sided Lighting"));
188 twoSidedLighting->setToolTip(tr(
"Enable two-sided lighting"));
189 twoSidedLighting->setCheckable(
true );
190 twoSidedLighting->setIcon( QIcon(iconPath+
"twosidedLighting.png") );
196 QAction* multisampling = renderingOptionsMenu->addAction(tr(
"Multisampling"));
197 multisampling->setToolTip(tr(
"Enable Multisampling"));
198 multisampling->setCheckable(
true );
199 multisampling->setIcon( QIcon(iconPath+
"multiSampling.png") );
205 QAction* mipmapping = renderingOptionsMenu->addAction(tr(
"Mipmapping"));
206 mipmapping->setToolTip(tr(
"Enable Mipmapping"));
207 mipmapping->setCheckable(
true );
208 mipmapping->setIcon( QIcon(iconPath+
"mipmapping.png") );
216 if ( renderManager().available() > 1 ) {
217 QMenu* rendererMenu =
new QMenu(tr(
"Renderers"),_menu);
218 rendererMenu->setIcon(QIcon(iconPath+
"renderers.png"));
220 _menu->addMenu(rendererMenu);
223 QActionGroup* groupRenderer =
new QActionGroup(
this );
224 groupRenderer->setExclusive(
true );
233 QAction* showRendererDialog =
new QAction(tr(
"Show renderer manager"),
this);
235 rendererMenu->addAction(showRendererDialog);
237 QAction* showRendererObjectWidget =
new QAction(tr(
"Show render objects"),
this);
239 rendererMenu->addAction(showRendererObjectWidget);
241 rendererMenu->addSeparator();
243 for (
unsigned int i = 0 ; i < renderManager().
available() ; ++i) {
246 QAction * action =
new QAction( renderManager()[i]->name, groupRenderer );
247 action->setCheckable(
true );
251 action->setChecked(
true);
254 action->setData(QVariant(i));
258 rendererMenu->addActions( groupRenderer->actions() );
261 connect( groupRenderer , SIGNAL( triggered( QAction * ) ),
270 QMenu* viewingDirectionMenu =
new QMenu( tr(
"Viewing Direction"), _menu);
271 viewingDirectionMenu->setIcon(QIcon(iconPath+
"core_viewingDirection.png"));
272 _menu->addMenu(viewingDirectionMenu);
274 QActionGroup* dirGroup =
new QActionGroup(
this);
278 viewAction =
new QAction( tr(
"Free View"), viewingDirectionMenu );
279 viewAction->setIcon( QIcon(iconPath+
"orthogonal.png") );
280 viewAction->setCheckable(
true );
281 viewAction->setData( PluginFunctions::VIEW_FREE );
283 viewingDirectionMenu->addAction( viewAction );
284 dirGroup->addAction(viewAction);
285 viewingDirectionMenu->addSeparator();
287 viewAction =
new QAction( tr(
"Top View"), viewingDirectionMenu );
288 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_top.png") );
289 viewAction->setCheckable(
true );
290 viewAction->setData( PluginFunctions::VIEW_TOP );
292 viewingDirectionMenu->addAction( viewAction );
293 dirGroup->addAction(viewAction);
295 viewAction =
new QAction( tr(
"Bottom View"), viewingDirectionMenu );
296 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_bottom.png") );
297 viewAction->setCheckable(
true );
298 viewAction->setData( PluginFunctions::VIEW_BOTTOM );
300 viewingDirectionMenu->addAction( viewAction );
301 dirGroup->addAction(viewAction);
303 viewAction =
new QAction( tr(
"Left View"), viewingDirectionMenu );
304 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_left.png") );
305 viewAction->setCheckable(
true );
306 viewAction->setData( PluginFunctions::VIEW_LEFT );
308 viewingDirectionMenu->addAction( viewAction );
309 dirGroup->addAction(viewAction);
311 viewAction =
new QAction( tr(
"Right View"), viewingDirectionMenu );
312 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_right.png") );
313 viewAction->setCheckable(
true );
314 viewAction->setData( PluginFunctions::VIEW_RIGHT );
316 viewingDirectionMenu->addAction( viewAction );
317 dirGroup->addAction(viewAction);
319 viewAction =
new QAction( tr(
"Front View"), viewingDirectionMenu );
320 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_front.png") );
321 viewAction->setCheckable(
true );
322 viewAction->setData( PluginFunctions::VIEW_FRONT );
324 viewingDirectionMenu->addAction( viewAction );
325 dirGroup->addAction(viewAction);
327 viewAction =
new QAction( tr(
"Back View"), viewingDirectionMenu );
328 viewAction->setIcon( QIcon(iconPath+
"viewcontrol_back.png") );
329 viewAction->setCheckable(
true );
330 viewAction->setData( PluginFunctions::VIEW_BACK );
332 viewingDirectionMenu->addAction( viewAction );
333 dirGroup->addAction(viewAction);
335 viewingDirectionMenu->addSeparator();
342 QAction* lockAction = viewingDirectionMenu->addAction(
"Lock rotation");
343 lockAction->setCheckable(
true );
344 lockAction->setIcon( QIcon(iconPath+
"lock_rotation.png") );
345 lockAction->setToolTip(tr(
"Lock rotation in current examiner"));
347 viewingDirectionMenu->addAction( lockAction );
349 connect( lockAction, SIGNAL(triggered(
bool)),
this, SLOT(
slotLockRotation(
bool) ) );
355 _menu->addSeparator();
363 QAction* showPostProcessorDialog =
new QAction(tr(
"Show post processor manager"),
this);
364 showPostProcessorDialog->setIcon(QIcon(iconPath+
"postprocessors.png"));
365 connect(showPostProcessorDialog,SIGNAL(triggered()),
this,SLOT(slotShowPostProcessorManager()));
366 _menu->addAction(showPostProcessorDialog);
368 _menu->addSeparator();
372 QAction* homeAction =
new QAction(tr(
"Restore home view"),_menu);
373 homeAction->setIcon( QIcon(iconPath+
"go-home.png") );
374 homeAction->setCheckable(
false );
375 homeAction->setToolTip(tr(
"Restore <b>home</b> view."));
376 homeAction->setWhatsThis( tr(
"Restore home view<br><br>"
377 "Resets the view to the home view"));
378 _menu->addAction( homeAction );
381 QAction* setHomeAction =
new QAction( tr(
"Set Home View") , _menu );
382 setHomeAction->setIcon( QIcon(iconPath+
"set-home.png") );
383 setHomeAction->setCheckable(
false );
384 setHomeAction->setToolTip(tr(
"Set <b>home</b> view"));
385 setHomeAction->setWhatsThis( tr(
"Store home view<br><br>"
386 "Stores the current view as the home view"));
387 _menu->addAction( setHomeAction);
390 QAction* viewAllAction =
new QAction( tr(
"View all"), _menu );
391 viewAllAction->setIcon( QIcon(iconPath+
"viewall.png") );
392 viewAllAction->setCheckable(
false );
393 viewAllAction->setToolTip(tr(
"View all."));
394 viewAllAction->setWhatsThis( tr(
"View all<br><br>"
395 "Move the objects in the scene so that"
396 " the whole scene is visible."));
398 _menu->addAction( viewAllAction);
401 _menu->addSeparator();
405 QAction* copyView = _menu->addAction(tr(
"Copy View"));
406 copyView->setToolTip(tr(
"Copy current view, window size and toolbar size to clipboard. Hold Ctrl to generate C/C++/JavaScipt-Style string."));
407 copyView->setIcon( QIcon(iconPath+
"edit-copy.png") );
408 connect(copyView, SIGNAL(triggered()),
this, SLOT(
slotCopyView()) );
412 QAction* pasteView = _menu->addAction(tr(
"Paste View"));
413 pasteView->setToolTip(tr(
"Paste current view from clipboard"));
414 pasteView->setIcon( QIcon(iconPath+
"edit-paste.png") );
415 connect(pasteView, SIGNAL(triggered()),
this , SLOT(
slotPasteView( ) ) );
419 QAction* pasteViewAndWindow = _menu->addAction(tr(
"Paste View and Window Size"));
420 pasteViewAndWindow->setToolTip(tr(
"Paste current view, window size and the toolbox size from clipboard"));
421 pasteViewAndWindow->setIcon( QIcon(iconPath+
"edit-paste.png") );
426 QAction* snapshot_examiner = _menu->addAction(tr(
"Examiner Snapshot"));
427 snapshot_examiner->setToolTip(tr(
"Take a snapshot of the current examiner"));
428 snapshot_examiner->setIcon( QIcon(iconPath+
"snapshot.png") );
433 QAction* snapshot_viewer = _menu->addAction(tr(
"Viewer Snapshot"));
434 snapshot_viewer->setToolTip(tr(
"Take a snapshot of the whole viewer"));
435 snapshot_viewer->setIcon( QIcon(iconPath+
"snapshot.png") );
457 _menu->addSeparator();
459 QAction* action = _menu->addAction(tr(
"Set Background Color"));
460 action->setToolTip(tr(
"Set the background color for the current viewer"));
461 action->setStatusTip(tr(
"Set the background color for the current viewer"));
462 action->setWhatsThis(tr(
"Set the background color for the current viewer"));
463 action->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"BackgroundColor.png") );
480 _menu->addSeparator();
501 QAction* typeEntry =
new QAction(
typeName(_object->
dataType())+QString(
": ")+_object->
name() ,_menu);
503 _menu->addAction( typeEntry );
505 _menu->addSeparator( );
511 _menu->addSeparator();
525 QMap< QString , QAction* > menuMap;
526 QMap< QString , QAction* > actionMap;
540 emit log(
LOGERR,tr(
"Cant get object for objectContextMenu"));
567 QList< QAction *> allActions;
571 allActions = menu->actions();
574 while ( !allActions.empty() ) {
575 QList< QAction *> tmpList;
578 for (
int j = 0 ; j < allActions.size(); ++j ) {
579 allActions[j]->setData( QVariant( _id ) );
580 if ( allActions[j]->menu() != 0 )
581 tmpList << allActions[j]->menu()->actions();
584 allActions = tmpList;
592 if (
viewModes_[i]->name == OpenFlipper::Options::currentViewMode()) {
600 emit log(
LOGERR, tr(
"Unable to find view mode %1.").arg(OpenFlipper::Options::currentViewMode()) );
607 QMapIterator<QString, QAction*> it(menuMap);
609 QStringList visible =
viewModes_[id]->visibleContextMenus;
610 if (visible.contains(
"ALL_THAT_EXIST")) {
616 visible.replaceInStrings(QRegularExpression(
".*>"),
"");
619 visible.replaceInStrings(
"&",
"");
621 while (it.hasNext()) {
624 for (
int i = 0 ; i < visible.size(); ++i ) {
625 if ( it.key().contains(visible[i]) ) {
626 _menu->addAction( it.value() );
631 _menu->addSeparator();
634 QMapIterator<QString, QAction*> it2(actionMap);
636 while (it2.hasNext()) {
639 for (
int i = 0 ; i < visible.size(); ++i ) {
640 if ( it2.key().contains(visible[i]) ) {
641 _menu->addAction( it2.value() );
670 COORDSYSCONTEXT ,BACKGROUNDCONTEXT ,OBJECTCONTEXT, NODECONTEXT
671 } context = BACKGROUNDCONTEXT;
674 size_t node_idx, target_idx;
682 context = OBJECTCONTEXT;
685 if ( node != 0 && ( node->
name() ==
"Core Coordsys Node") )
686 context = COORDSYSCONTEXT;
688 context = NODECONTEXT;
699 case BACKGROUNDCONTEXT:
707 case COORDSYSCONTEXT:
721 std::cerr <<
"Todo : slotSnapShotName only sets name for current viewer" << std::endl;
725 fname.replace(
'%',
'$');
726 fname = QFileDialog::getSaveFileName ( 0,
727 tr(
"Save snapshot name"),
730 if (!fname.isEmpty())
732 fname.replace(
'$',
'%');
736 QFileInfo fileInfo(fname);
740 QString msg=tr(
"next snapshot: ");
741 statusBar()->showMessage(msg);
768 for ( uint i = 0 ; i <
plugins().size(); ++i ) {
769 if (
plugins()[i].plugin == sender() ) {
777 for ( uint i = 0 ; i <
plugins().size(); ++i ) {
778 if (
plugins()[i].name ==
"Scripting" ) {
786 std::cerr <<
"Unknown sender plugin when adding Context Menu!" << std::endl;
791 plugins()[id].contextMenus.push_back( std::pair< QString,QAction* >(
plugins()[
id].name +
"->" + _entry->text(), _entry) );
794 if ( !
viewModes_[0]->visibleContextMenus.contains(
plugins()[
id].name +
"->" + _entry->text()) ){
795 viewModes_[0]->visibleContextMenus <<
plugins()[id].name +
"->" + _entry->text();
799 setViewMode( OpenFlipper::Options::currentViewMode() );
822 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
846 std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
851 for (
unsigned int i = 0; i < availDrawModeIds.size(); ++i )
859 checkableAction->setText(descr.c_str());
860 checkableAction->setDefaultWidget(checkBox);
861 connect(checkBox, SIGNAL(toggled(
bool) ), checkableAction, SLOT(trigger() ) );
874 std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
876 for (
unsigned int i = 0; i < availDrawModeIds.size(); ++i )
878 QString descr = QString( availDrawModeIds[i].description().c_str() );
880 if ( descr == _action->text() ) {
881 mode = availDrawModeIds[i];
886 if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
897 unsigned int mode = _action->data().toUInt();
902 unsigned int mode = _action->data().toUInt();
906 QString defaultRendererName = renderManager()[mode]->name;
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
std::string name() const
Returns: name of node (needs not be unique)
bool visible()
Is node visible (status == Active)?
ChildIter find(BaseNode *_node)
DrawModes::DrawMode drawModes() const
Get the collected draw modes.
@ PERSPECTIVE_PROJECTION
perspective
std::string description() const
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
bool containsAtomicDrawMode(const DrawMode &_atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
bool dataType(DataType _type) const
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void setActive(unsigned int _active, int _viewerId)
set the active post processor for viewer
void setActive(unsigned int _active, int _id)
set the active renderer
size_t available()
number of available renderers
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
void snapshotBaseFileName(const QString &_fname)
@ PERSPECTIVE_PROJECTION
perspective
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
void traverse(BaseNode *_node, Action &_action)
@ PICK_ANYTHING
pick any of the prior targets (should be implemented for all nodes)
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
QPoint adjustForDevicePixelRatio(const QPoint &point)
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
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.
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node