MenuBar.cc 42 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
*                           www.openflipper.org                              *
*                                                                            *
*--------------------------------------------------------------------------- *
*  This file is part of OpenFlipper.                                         *
*                                                                            *
*  OpenFlipper is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU Lesser General Public License as            *
*  published by the Free Software Foundation, either version 3 of            *
*  the License, or (at your option) any later version with the               *
*  following exceptions:                                                     *
*                                                                            *
*  If other files instantiate templates or use macros                        *
*  or inline functions from this file, or you compile this file and          *
*  link it with other files to produce an executable, this file does         *
*  not by itself cause the resulting executable to be covered by the         *
*  GNU Lesser General Public License. This exception does not however        *
*  invalidate any other reasons why the executable file might be             *
*  covered by the GNU Lesser General Public License.                         *
*                                                                            *
*  OpenFlipper is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU Lesser General Public License for more details.                       *
*                                                                            *
*  You should have received a copy of the GNU LesserGeneral Public           *
*  License along with OpenFlipper. If not,                                   *
*  see <http://www.gnu.org/licenses/>.                                       *
*                                                                            *
33 34 35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36 37 38 39 40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55



//=============================================================================
//
//  CLASS CoreWidget - IMPLEMENTATION
//
//=============================================================================


//== INCLUDES =================================================================

#include "CoreWidget.hh"
#include <OpenFlipper/common/GlobalOptions.hh>
Jan Möbius's avatar
Jan Möbius committed
56
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
Jan Möbius's avatar
Jan Möbius committed
57
#include <OpenFlipper/BasePlugin/MenuInterface.hh>
58
#include <OpenFlipper/common/RendererInfo.hh>
Jan Möbius's avatar
 
Jan Möbius committed
59

60
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
61 62 63



Jan Möbius's avatar
Jan Möbius committed
64 65
void CoreWidget::slotAddMenubarAction( QAction* _action , QString _name ) {

66
  if (!menus_.contains(_name))
Jan Möbius's avatar
Jan Möbius committed
67 68
    return;

69
  if (_name == FILEMENU) {
Jan Möbius's avatar
Jan Möbius committed
70
    fileMenu_->insertSeparator(fileMenuEnd_);
71 72 73 74 75 76 77 78 79 80
    fileMenu_->insertAction(fileMenuEnd_, _action);
  } else if (_name == ALGORITHMMENU) {

    // We insert the algorithms menu if it is not available yet
    if ( menuBar()->actions().contains(helpMenu_->menuAction()) )
      menuBar()->insertMenu(helpMenu_->menuAction(), algorithmMenu_);

    menus_[_name]->addAction(_action);
  } else {
    menus_[_name]->addAction(_action);
Jan Möbius's avatar
 
Jan Möbius committed
81
  }
82

Jan Möbius's avatar
Jan Möbius committed
83
}
84

Jan Möbius's avatar
Jan Möbius committed
85 86 87 88
//=============================================================================

void CoreWidget::slotGetMenubarMenu (QString _name, QMenu *& _menu, bool _create)
{
89
	//if menu already exists, return it
Jan Möbius's avatar
Jan Möbius committed
90 91
  if (menus_.contains (_name))
    _menu = menus_[_name];
92
  //otherwise create a new one
Jan Möbius's avatar
Jan Möbius committed
93 94 95 96
  else if (_create)
  {
    _menu = new QMenu(_name);
    menus_[_name] = _menu;
97 98 99
    //we have to install an event filter to get event information (e.g. what this)
    _menu->installEventFilter(this);
    //guarantee that helpMenu_ is always at the end of all menus
Jan Möbius's avatar
Jan Möbius committed
100
    menuBar()->insertAction(helpMenu_->menuAction() ,_menu->menuAction ());
101 102 103
  }
  //otherwise no menu was found
  else
Jan Möbius's avatar
Jan Möbius committed
104
    _menu = NULL;
Jan Möbius's avatar
 
Jan Möbius committed
105 106 107 108 109
}


//=============================================================================

110
bool CoreWidget::eventFilter(QObject *_obj, QEvent *_event)
Jan Möbius's avatar
 
Jan Möbius committed
111
{
112 113 114 115 116 117 118 119 120 121 122
	//WhatsThisClicked event for hyperlinks in 'whats this' boxes
		if( _event->type() == QEvent::WhatsThisClicked )
		{
			QWhatsThisClickedEvent *wtcEvent = static_cast<QWhatsThisClickedEvent*>(_event);
			QWhatsThis::hideText();
			this->showHelpBrowser(wtcEvent->href());
			return true;
		}

		return _obj->event(_event);
}
Jan Möbius's avatar
 
Jan Möbius committed
123

124 125 126 127
//=============================================================================

void CoreWidget::setupMenuBar()
{
Jan Möbius's avatar
 
Jan Möbius committed
128

Jan Möbius's avatar
 
Jan Möbius committed
129 130 131
  // ======================================================================
  // File Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
132
  fileMenu_ = new QMenu( FILEMENU );
133
  menuBar()->addMenu( fileMenu_ );
Jan Möbius's avatar
Jan Möbius committed
134
  menus_[tr("File")] = fileMenu_;
Jan Möbius's avatar
 
Jan Möbius committed
135

Jan Möbius's avatar
 
Jan Möbius committed
136
  //Clear all
Jan Möbius's avatar
Jan Möbius committed
137
  QAction* AC_clear_all = new QAction(tr("Clear All"), this);;
Jan Möbius's avatar
 
Jan Möbius committed
138
  AC_clear_all->setStatusTip(tr("Clear all Objects"));
139
  AC_clear_all->setWhatsThis(tr("Close all open Objects"));
140
  AC_clear_all->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-clear.png"));
Jan Möbius's avatar
 
Jan Möbius committed
141 142
  connect(AC_clear_all, SIGNAL(triggered()), this, SIGNAL(clearAll()));
  fileMenu_->addAction(AC_clear_all);
143

Jan Möbius's avatar
 
Jan Möbius committed
144
  fileMenu_->addSeparator();
145 146

  //Load object
Jan Möbius's avatar
Jan Möbius committed
147
  QAction* AC_Load = new QAction(tr("Load Object"), this);
Jan Möbius's avatar
 
Jan Möbius committed
148
  AC_Load->setStatusTip(tr("Load an object"));
149
  AC_Load->setWhatsThis(tr("Load a new object"));
150
  AC_Load->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open.png"));
Jan Möbius's avatar
 
Jan Möbius committed
151 152
  connect(AC_Load, SIGNAL(triggered()), this, SIGNAL(loadMenu()));
  fileMenu_->addAction(AC_Load);
153

Jan Möbius's avatar
 
Jan Möbius committed
154
  //Add empty object
Jan Möbius's avatar
Jan Möbius committed
155
  QAction* AC_AddEmpty = new QAction(tr("Add Empty Object"), this);
Jan Möbius's avatar
 
Jan Möbius committed
156
  AC_AddEmpty->setStatusTip(tr("Add an empty object"));
157
  AC_AddEmpty->setWhatsThis(tr("Creates a new empty object of a given type"));
158
  AC_AddEmpty->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"add-empty-object.png"));
Jan Möbius's avatar
 
Jan Möbius committed
159 160
  connect(AC_AddEmpty, SIGNAL(triggered()), this, SIGNAL(addEmptyObjectMenu()));
  fileMenu_->addAction(AC_AddEmpty);
161

Jan Möbius's avatar
 
Jan Möbius committed
162
  fileMenu_->addSeparator();
163

Jan Möbius's avatar
 
Jan Möbius committed
164
  //Save object
165
  QAction* AC_Save = new QAction(tr("Save Objects"), this);
Dirk Wilden's avatar
Dirk Wilden committed
166
//   AC_Save->setShortcut (Qt::CTRL + Qt::Key_S);
167 168
  AC_Save->setStatusTip(tr("Save current objects"));
  AC_Save->setWhatsThis(tr("Save current objects"));
169
  AC_Save->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save.png"));
Jan Möbius's avatar
 
Jan Möbius committed
170 171
  connect(AC_Save, SIGNAL(triggered()), this, SIGNAL(saveMenu()));
  fileMenu_->addAction(AC_Save);
172

Jan Möbius's avatar
 
Jan Möbius committed
173
  //Save object to
174 175 176
  QAction* AC_Save_to = new QAction(tr("Save Objects to"), this);
  AC_Save_to->setStatusTip(tr("Save current Object(s) to"));
  AC_Save_to->setWhatsThis(tr("Save current Object(s) under a new name"));
177
  AC_Save_to->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save-as.png"));
Jan Möbius's avatar
 
Jan Möbius committed
178 179
  connect(AC_Save_to, SIGNAL(triggered()), this, SIGNAL(saveToMenu()));
  fileMenu_->addAction(AC_Save_to);
180

Jan Möbius's avatar
 
Jan Möbius committed
181
  fileMenu_->addSeparator();
182

Jan Möbius's avatar
 
Jan Möbius committed
183
  //Load ini
Jan Möbius's avatar
Jan Möbius committed
184
  QAction* AC_load_ini = new QAction(tr("Load Settings"), this);
Jan Möbius's avatar
 
Jan Möbius committed
185
  AC_load_ini->setStatusTip(tr("Load Settings from INI file"));
186
  AC_load_ini->setWhatsThis(tr("Load a previous settings from file (objects,colors,...)"));
187
  AC_load_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"load-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
188 189
  connect(AC_load_ini, SIGNAL(triggered()), this, SIGNAL(loadIniMenu()));
  fileMenu_->addAction(AC_load_ini);
190

Jan Möbius's avatar
 
Jan Möbius committed
191
  //Save ini
Jan Möbius's avatar
Jan Möbius committed
192
  QAction* AC_save_ini = new QAction(tr("Save Settings"), this);
Jan Möbius's avatar
 
Jan Möbius committed
193
  AC_save_ini->setStatusTip(tr("Save current settings to INI file"));
194
  AC_save_ini->setWhatsThis(tr("Save settings to file (objects,colors,...)"));
195
  AC_save_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"save-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
196 197
  connect(AC_save_ini, SIGNAL(triggered()), this, SIGNAL(saveIniMenu()));
  fileMenu_->addAction(AC_save_ini);
198 199 200 201

  fileMenu_->addSeparator();

  //Options
Jan Möbius's avatar
Jan Möbius committed
202
  QAction* AC_Options = new QAction(tr("Options"), this);
203
  AC_Options->setStatusTip(tr("Edit OpenFlipper Options"));
204
  AC_Options->setWhatsThis(tr("Edit OpenFlipper Options"));
205
  AC_Options->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"options.png"));
206 207
  connect(AC_Options, SIGNAL(triggered()), this, SLOT(showOptionsWidget()));
  fileMenu_->addAction(AC_Options);
208 209

  //Remember entry of menu (required for adding File Menu entries from plugins)
Jan Möbius's avatar
 
Jan Möbius committed
210
  fileMenuEnd_ = fileMenu_->addSeparator();
211

Jan Möbius's avatar
 
Jan Möbius committed
212
  //Recent files
Jan Möbius's avatar
Jan Möbius committed
213
  recentFilesMenu_ = new QMenu(tr("Recent Files"));
214
  recentFilesMenu_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open-recent.png"));
215
  recentFilesMenu_->setWhatsThis(tr("Open recent files"));
Jan Möbius's avatar
 
Jan Möbius committed
216 217
  connect(recentFilesMenu_,SIGNAL(triggered(QAction*)),this,SIGNAL(recentOpen(QAction*)));
  fileMenu_->addMenu(recentFilesMenu_);
218

Jan Möbius's avatar
 
Jan Möbius committed
219
  fileMenu_->addSeparator();
220

Jan Möbius's avatar
 
Jan Möbius committed
221
  //Main Application exit menu entry
Jan Möbius's avatar
Jan Möbius committed
222
  QAction* AC_exit = new QAction(tr("Exit"), this);;
Jan Möbius's avatar
 
Jan Möbius committed
223 224
  AC_exit->setShortcut (Qt::CTRL + Qt::Key_Q);
  AC_exit->setStatusTip(tr("Exit Application"));
225
  recentFilesMenu_->setWhatsThis(tr("Close OpenFlipper"));
226
  AC_exit->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"application-exit.png"));
Jan Möbius's avatar
 
Jan Möbius committed
227 228 229
  connect(AC_exit, SIGNAL(triggered()), this, SIGNAL(exit()));
  fileMenu_->addAction(AC_exit);

230 231 232
  // ======================================================================
  // View Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
233
  viewMenu_ = new QMenu( VIEWMENU );
234
  menuBar()->addMenu(viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
235
  menus_[tr("View")] = viewMenu_;
Jan Möbius's avatar
 
Jan Möbius committed
236

237 238
  slotUpdateGlobalDrawMenu();
  viewMenu_->addMenu(globalDrawMenu_);
Jan Möbius's avatar
 
Jan Möbius committed
239

240 241 242
  //============================================================================================================
  // Rendering options Menu
  //============================================================================================================
Jan Möbius's avatar
 
Jan Möbius committed
243

244
  QMenu* renderingOptionsMenu = new QMenu(tr("Global Rendering Options"),viewMenu_);
Jan Möbius's avatar
Jan Möbius committed
245
  renderingOptionsMenu->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_renderingOptions.png") );
246
  viewMenu_->addMenu(renderingOptionsMenu);
Jan Möbius's avatar
 
Jan Möbius committed
247

248
  orthogonalProjectionAction_ = new QAction( tr("Switch Viewers to Orthogonal Projection"), renderingOptionsMenu );;
249 250
  orthogonalProjectionAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
  orthogonalProjectionAction_->setCheckable( false );
251 252 253
  orthogonalProjectionAction_->setToolTip(   tr("Switch to orthogonal projection mode."));
  orthogonalProjectionAction_->setWhatsThis( tr("Switch projection mode<br><br>"
      "Switch to <b>orthogonal</b> projection mode."));
254 255
  connect( orthogonalProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalOrthographicProjection() ) );
  renderingOptionsMenu->addAction( orthogonalProjectionAction_);
Jan Möbius's avatar
 
Jan Möbius committed
256

257 258 259 260 261 262 263 264 265
  perspectiveProjectionAction_ = new QAction( tr("Switch Viewers to Perspective Projection"), viewMenu_ );;
  perspectiveProjectionAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"perspective.png") );
  perspectiveProjectionAction_->setCheckable( false );
  perspectiveProjectionAction_->setStatusTip( tr("Switch to perspective projection mode."));
  perspectiveProjectionAction_->setWhatsThis( tr("Switch projection mode<br><br>"
                                                 "Switch to <b>perspective</b> projection mode."));
  connect( perspectiveProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalPerspectiveProjection() ) );
  renderingOptionsMenu->addAction( perspectiveProjectionAction_);

266
  // =====================
267

268
  globalAnimationAction_ = renderingOptionsMenu->addAction(tr("Global Animation"));
269
  globalAnimationAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") );
270
  connect(globalAnimationAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleAnimation() ) );
Jan Möbius's avatar
 
Jan Möbius committed
271

272
  //======================
Jan Möbius's avatar
 
Jan Möbius committed
273

274
  globalBackfaceCullingAction_ = renderingOptionsMenu->addAction(tr("Global Backface Culling"));
275
  globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
276
  connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleBackFaceCulling() ) );
277 278 279

  //======================

280
  globalTwosidedLightingAction_ = renderingOptionsMenu->addAction(tr("Global Two-sided Lighting"));
281
  globalTwosidedLightingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
282
  connect(globalTwosidedLightingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleTwoSidedLighting() ) );
283

284 285
  //======================

286 287 288 289 290 291 292 293 294
  globalMultisamplingAction_ = renderingOptionsMenu->addAction(tr("Global Multisampling"));
  globalMultisamplingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multisampling.png") );
  connect(globalMultisamplingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleMultisampling()) );
  //======================

  globalMipmappingAction_ = renderingOptionsMenu->addAction(tr("Global Mipmapping"));
  globalMipmappingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"mipmapping.png") );
  connect(globalMipmappingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleMipmapping()) );
  
Jan Möbius's avatar
 
Jan Möbius committed
295

296 297 298 299 300 301 302 303 304 305 306 307
  //============================================================================================================
  // Global renderer menu
  //============================================================================================================

  slotUpdateRendererMenu();

  //============================================================================================================
  // Global post processor menu
  //============================================================================================================

  slotUpdatePostProcessorMenu();

308 309 310
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
 
Jan Möbius committed
311

312
  viewMenu_->addSeparator();
Jan Möbius's avatar
 
Jan Möbius committed
313

Mike Kremer's avatar
Mike Kremer committed
314
  QAction* navigationSwitchAction = new QAction( tr("First-person Navigation"), viewMenu_ );
315
  navigationSwitchAction->setCheckable( true );
Jan Möbius's avatar
Jan Möbius committed
316
  navigationSwitchAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_firstPersonMode.png") );
Mike Kremer's avatar
Mike Kremer committed
317 318
  navigationSwitchAction->setStatusTip( tr("Switch between normal and first-person navigation mode."));
  navigationSwitchAction->setWhatsThis( tr("Switch between normal and first-person navigation mode."));
319 320 321 322 323 324 325
  navigationSwitchAction->setChecked( false );

  connect( navigationSwitchAction, SIGNAL( toggled(bool) ), this, SLOT( slotSwitchNavigation(bool) ) );
  viewMenu_->addAction( navigationSwitchAction);

  viewMenu_->addSeparator();

326
  connect( viewMenu_,SIGNAL( aboutToShow() ), this, SLOT( slotViewMenuAboutToShow() ) );
Jan Möbius's avatar
 
Jan Möbius committed
327

328
  QAction* homeAction = new QAction(tr("Restore Home View"),viewMenu_);
329 330
  homeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"go-home.png") );
  homeAction->setCheckable( false );
331 332 333
  homeAction->setStatusTip( tr("Restore <b>home</b> view."));
  homeAction->setWhatsThis( tr("Restore home view<br><br>"
                               "Resets the view to the home view"));
334 335
  viewMenu_->addAction( homeAction );
  connect( homeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalHomeView() ) );
Jan Möbius's avatar
 
Jan Möbius committed
336 337


338
  QAction* setHomeAction = new QAction( tr("Set Home View") , viewMenu_ );
339 340
  setHomeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"set-home.png") );
  setHomeAction->setCheckable( false );
341 342 343
  setHomeAction->setStatusTip( tr("Set <b>home</b> view"));
  setHomeAction->setWhatsThis( tr("Store home view<br><br>"
                                  "Stores the current view as the home view"));
344 345
  viewMenu_->addAction( setHomeAction);
  connect( setHomeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalSetHomeView() ) );
Jan Möbius's avatar
 
Jan Möbius committed
346

347
  QAction* viewAllAction = new QAction( tr("View all"), viewMenu_ );
348 349
  viewAllAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewall.png") );
  viewAllAction->setCheckable( false );
350 351 352 353
  viewAllAction->setStatusTip( tr("View all.") );
  viewAllAction->setWhatsThis( tr("View all<br><br>"
                                  "Move the objects in the scene so that"
                                  " the whole scene is visible."));
354 355
  connect( viewAllAction,SIGNAL( triggered() ), this, SLOT( slotGlobalViewAll() ) );
  viewMenu_->addAction( viewAllAction);
Jan Möbius's avatar
 
Jan Möbius committed
356

Dirk Wilden's avatar
Dirk Wilden committed
357
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
358

359
  QAction* snapShotAction = new QAction( tr("Viewer Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
360 361
  snapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewerSnapshot.png") );
  snapShotAction->setCheckable( false );
362 363 364
  snapShotAction->setStatusTip( tr("Take a snapshot from all viewers."));
  snapShotAction->setWhatsThis( tr("Viewer Snapshot<br><br>"
                                   "Take a snapshot of all viewers at once."));
Dirk Wilden's avatar
Dirk Wilden committed
365 366
  connect( snapShotAction,SIGNAL( triggered() ), this, SLOT( viewerSnapshotDialog() ) );
  viewMenu_->addAction( snapShotAction);
Dirk Wilden's avatar
Dirk Wilden committed
367

368
  QAction* appSnapShotAction = new QAction( tr("Application Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
369 370
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
371 372 373
  appSnapShotAction->setStatusTip( tr("Take a snapshot from OpenFlipper."));
  appSnapShotAction->setWhatsThis( tr("Snapshot<br><br>"
                                      "Take a snapshot from OpenFlipper."));
Dirk Wilden's avatar
Dirk Wilden committed
374 375 376
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

Dirk Wilden's avatar
Dirk Wilden committed
377 378
  viewMenu_->addSeparator();

379
  QAction* wheelSwitchAction = new QAction( tr("Show / hide wheels"), viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
380
  wheelSwitchAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_wheels.png") );
381
  wheelSwitchAction->setCheckable( true );
382 383 384 385
  wheelSwitchAction->setStatusTip( tr("Show / hide navigation wheels in viewer widget."));
  wheelSwitchAction->setWhatsThis( tr("Show / hide navigation wheels in viewer widget.<br><br>"
                                      " These wheels appear in the corners of the viewports. "
                                      " Use wheels to rotate and scale scene."));
Jan Möbius's avatar
Jan Möbius committed
386 387 388 389
                                      
  if(OpenFlipperSettings().value("Core/Gui/glViewer/showControlWheels").toBool() ) 
    wheelSwitchAction->setChecked(true);

390 391 392
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

393
  QAction* coordSys = viewMenu_->addAction(tr("Coordinate Systems"));
Dirk Wilden's avatar
Dirk Wilden committed
394 395
  coordSys->setCheckable(true);
  coordSys->setChecked(true);
396
  coordSys->setStatusTip(tr("Toggle visibility of the coordinate systems"));
397
  coordSys->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"coordsys.png") );
Dirk Wilden's avatar
Dirk Wilden committed
398 399
  connect(coordSys, SIGNAL(triggered(bool)), this, SLOT( slotCoordSysVisibility(bool) ) );

400
  viewMenu_->addSeparator();
Jan Möbius's avatar
 
Jan Möbius committed
401

Jan Möbius's avatar
Jan Möbius committed
402
  QAction* setGlobalBackgroundColor = new QAction(tr("Set Background Color"), this);;
403 404
  setGlobalBackgroundColor->setToolTip(tr("Set Background Color for all viewers"));
  setGlobalBackgroundColor->setStatusTip(tr("Set Background Color for all viewers"));
405
  setGlobalBackgroundColor->setWhatsThis(tr("Set Background Color for all viewers"));
406 407 408
  setGlobalBackgroundColor->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"BackgroundColor.png") );
  connect(setGlobalBackgroundColor, SIGNAL(triggered()), this, SLOT(slotSetGlobalBackgroundColor()));
  viewMenu_->addAction(setGlobalBackgroundColor);
Jan Möbius's avatar
 
Jan Möbius committed
409

410 411 412
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
 
Jan Möbius committed
413

Jan Möbius's avatar
Jan Möbius committed
414
  toolsMenu_ = new QMenu( TOOLSMENU );
415
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
416
  menus_[tr("Tools")] = toolsMenu_;
Jan Möbius's avatar
 
Jan Möbius committed
417

418
  QAction* sceneGraphAction = new QAction( tr("Show SceneGraph ") ,toolsMenu_ );
419 420
  sceneGraphAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png") );
  sceneGraphAction->setCheckable( false );
421 422 423 424
  sceneGraphAction->setToolTip( tr("Show scene graph viewer.") );
  sceneGraphAction->setWhatsThis( tr("Toggle scene graph viewer<br><br>"
                                     "The scene graph viewer enables you to examine the "
                                     "displayed scene graph and to modify certain nodes.<br><br>" ) );
425 426 427
  QObject::connect( sceneGraphAction, SIGNAL( triggered() ),
                    this,             SLOT( slotShowSceneGraphDialog() ) );
  toolsMenu_->addAction( sceneGraphAction);
Jan Möbius's avatar
 
Jan Möbius committed
428

429 430
  toolsMenu_->addSeparator();

431
  QAction* startVideoCaptureAction =  new QAction( tr("Start Video Capture ") ,toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
432
  startVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"video-start.png") );
Dirk Wilden's avatar
Dirk Wilden committed
433
  startVideoCaptureAction->setCheckable( false );
434 435
  startVideoCaptureAction->setToolTip( tr("Start video capturing.") );
  startVideoCaptureAction->setWhatsThis( tr("Start to capture a video sequence of the user actions")) ;
Dirk Wilden's avatar
Dirk Wilden committed
436 437 438
  toolsMenu_->addAction( startVideoCaptureAction );
  connect(startVideoCaptureAction, SIGNAL(triggered()), this, SLOT(startVideoCaptureDialog()) );

439
  QAction* stopVideoCaptureAction =  new QAction( tr("Stop Video Capture ") ,toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
440
  stopVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"video-stop.png") );
Dirk Wilden's avatar
Dirk Wilden committed
441
  stopVideoCaptureAction->setCheckable( false );
442 443
  stopVideoCaptureAction->setToolTip( tr("Stop video capturing." ));
  stopVideoCaptureAction->setWhatsThis( tr("Stop Video capturing" ));
Dirk Wilden's avatar
Dirk Wilden committed
444 445 446

  toolsMenu_->addAction( stopVideoCaptureAction);
  connect(stopVideoCaptureAction, SIGNAL(triggered()), this, SIGNAL(stopVideoCapture()) );
Jan Möbius's avatar
Jan Möbius committed
447 448 449 450 451 452 453 454 455 456
  
  toolsMenu_->addSeparator();
  
  //show plugins
  QAction* AC_Plugins = new QAction(tr("Plugins"), this);
  AC_Plugins->setStatusTip(tr("Show loaded plugins"));
  AC_Plugins->setWhatsThis(tr("Show loaded plugins"));
  AC_Plugins->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"network-connect.png"));
  connect(AC_Plugins, SIGNAL(triggered()), this, SIGNAL(showPlugins()));
  toolsMenu_->addAction(AC_Plugins);
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
  
  // ======================================================================
  // Window Menu
  // ======================================================================
  windowMenu_ = new QMenu(tr("Windows"));
  menuBar()->addMenu(windowMenu_);
  menus_[tr("Windows")] = windowMenu_;
  
  
  // Show or Hide the View Mode Controls
  AC_ShowViewModeControls_ = new QAction(tr("Show View Mode Controls"), this);
  AC_ShowViewModeControls_->setStatusTip(tr("Show or Hide View Mode Control Widget"));
  //   AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
  AC_ShowViewModeControls_->setWhatsThis(tr("Show or Hide View Mode Control Widget"));
  AC_ShowViewModeControls_->setCheckable(true);
  AC_ShowViewModeControls_->setChecked( ! OpenFlipperSettings().value("Core/Gui/TaskSwitcher/Hide",false).toBool()  );
  connect(AC_ShowViewModeControls_, SIGNAL(toggled( bool )), this, SLOT(showViewModeControls(bool)));
  windowMenu_->addAction(AC_ShowViewModeControls_);
  
  // Show or Hide the View Mode Controls
477 478
  QAction* AC_ShowToolbox = new QAction(tr("Show Toolboxes"), this);
  AC_ShowToolbox->setStatusTip(tr("Show or Hide the Toolbox Widget"));
479
  //   AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
  AC_ShowToolbox->setWhatsThis(tr("Show or Hide the Toolbox Widget"));
  AC_ShowToolbox->setCheckable(true);
  AC_ShowToolbox->setChecked( ! OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool()  );
  connect(AC_ShowToolbox, SIGNAL( triggered()), this, SLOT(toggleToolbox()));
  connect(this,SIGNAL(toolBoxVisChanged(bool)),AC_ShowToolbox,SLOT(setChecked(bool)));
  windowMenu_->addAction(AC_ShowToolbox);

  // Show or Hide the Status bar
  QAction* AC_ShowStatusBar = new QAction(tr("Show Statusbar"), this);
  AC_ShowStatusBar->setStatusTip(tr("Show or Hide the Statusbar"));
  AC_ShowStatusBar->setWhatsThis(tr("Show or Hide the Statusbar"));
  AC_ShowStatusBar->setCheckable(true);
  AC_ShowStatusBar->setChecked( !OpenFlipperSettings().value("Core/Gui/StatusBar/hidden",false).toBool());
  connect(AC_ShowStatusBar,SIGNAL(triggered()),this,SLOT(toggleStatusBar()));
  connect(this,SIGNAL(statusBarVisChanged(bool)),AC_ShowStatusBar,SLOT(setChecked(bool)));
  windowMenu_->addAction(AC_ShowStatusBar);

  // Show or Hide the Menu bar
  QAction* AC_ShowMenuBar = new QAction(tr("Show Menubar"), this);
  AC_ShowMenuBar->setStatusTip(tr("Show or Hide the Menubar"));
  AC_ShowMenuBar->setWhatsThis(tr("Show or Hide the Menubar"));
  AC_ShowMenuBar->setCheckable(true);
  AC_ShowMenuBar->setChecked( !OpenFlipperSettings().value("Core/Gui/MenuBar/hidden",false).toBool());
  connect(AC_ShowMenuBar,SIGNAL(triggered()),this,SLOT(toggleMenuBar()));
  connect(this,SIGNAL(menuBarVisChanged(bool)),AC_ShowMenuBar,SLOT(setChecked(bool)));
  windowMenu_->addAction(AC_ShowMenuBar);

  // Show or Hide the Tool bar
  QAction* AC_ShowToolBar = new QAction(tr("Show Toolbar"), this);
  AC_ShowToolBar->setStatusTip(tr("Show or Hide the Toolbar"));
  AC_ShowToolBar->setWhatsThis(tr("Show or Hide the Toolbar"));
  AC_ShowToolBar->setCheckable(true);
  AC_ShowToolBar->setChecked( !OpenFlipperSettings().value("Core/Gui/ToolBar/hidden",false).toBool());
  connect(AC_ShowToolBar,SIGNAL(triggered()),this,SLOT(toggleToolBar()));
  connect(this,SIGNAL(toolBarVisChanged(bool)),AC_ShowToolBar,SLOT(setChecked(bool)));
  windowMenu_->addAction(AC_ShowToolBar);

517
  
518

519 520 521 522 523 524
  // ======================================================================
  // Algorithms Menu
  // ======================================================================
  algorithmMenu_ = new QMenu( ALGORITHMMENU );
  menus_[tr("Algorithms")] = algorithmMenu_;

Jan Möbius's avatar
 
Jan Möbius committed
525 526 527
  // ======================================================================
  // help Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
528
  helpMenu_ = new QMenu(tr("Help"));
Jan Möbius's avatar
 
Jan Möbius committed
529
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
530
  menus_[tr("Help")] = helpMenu_;
531

Jan Möbius's avatar
 
Jan Möbius committed
532
  //Open Help Browser
Jan Möbius's avatar
Jan Möbius committed
533
  QAction* AC_HelpBrowser = new QAction(tr("Help"), this);
534
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
535
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
536
  AC_HelpBrowser->setWhatsThis(tr("Open the <b>Help Browser</b>"));
537
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
 
Jan Möbius committed
538
  helpMenu_->addAction(AC_HelpBrowser);
539

Jan Möbius's avatar
 
Jan Möbius committed
540 541 542
  //Switch to whats this mode
  QAction* AC_Whats_this = QWhatsThis::createAction ( this );
  AC_Whats_this->setStatusTip(tr("Enter What's this Mode"));
543
  AC_Whats_this->setWhatsThis(tr("Get information about a specific Button/Widget/..."));
Jan Möbius's avatar
 
Jan Möbius committed
544
  helpMenu_->addAction(AC_Whats_this);
545

Jan Möbius's avatar
 
Jan Möbius committed
546
  helpMenu_->addSeparator();
547

Jan Möbius's avatar
 
Jan Möbius committed
548
  //About Action
Jan Möbius's avatar
Jan Möbius committed
549
  QAction* AC_About = new QAction(tr("About"), this);
Jan Möbius's avatar
 
Jan Möbius committed
550
  AC_About->setStatusTip(tr("About OpenFlipper"));
551
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
552
  AC_About->setWhatsThis(tr("This entry shows information about <b>OpenFlipper</b>"));
Jan Möbius's avatar
Jan Möbius committed
553
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
 
Jan Möbius committed
554
  helpMenu_->addAction(AC_About);
555

Jan Möbius's avatar
 
Jan Möbius committed
556 557 558 559 560 561 562 563 564
  // Add Menu entries to the main Toolbar
  mainToolbar_->addAction(AC_Load);
  mainToolbar_->addAction(AC_AddEmpty);
  mainToolbar_->addSeparator();
  mainToolbar_->addAction(AC_Save);
  mainToolbar_->addAction(AC_Save_to);
  mainToolbar_->addSeparator();
  mainToolbar_->addAction(AC_load_ini);
  mainToolbar_->addAction(AC_save_ini);
565 566 567 568 569 570 571 572


  // install event filters for what is this event
  // todo: why doesn't go any event through CoreWidget::event from menus? i don't get it
  fileMenu_->installEventFilter(this);
  viewMenu_->installEventFilter(this);
  toolsMenu_->installEventFilter(this);
  windowMenu_->installEventFilter(this);
573
  algorithmMenu_->installEventFilter(this);
574
  helpMenu_->installEventFilter(this);
Jan Möbius's avatar
 
Jan Möbius committed
575 576
}

577

578
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
 
Jan Möbius committed
579

580
  uint enabledCount  = 0;
581

582 583 584 585 586
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).animation() )
      enabledCount++;
  }

587
  if ( enabledCount != 0 ) {
588 589 590
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setText(tr("Disable animation"));
591
  } else {
592 593 594
    globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setText(tr("Enable animation"));
595
  }
596

597
  //=============================================================================================================================
598

599
  enabledCount  = 0;
600

601 602 603 604
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
      enabledCount++;
  }
605

606
  if ( enabledCount != 0 ) {
607 608 609
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
610
  } else {
611 612 613
    globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Enable backface culling"));
614 615 616
  }

  //=============================================================================================================================
617

618
  enabledCount  = 0;
619

620 621 622 623 624
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
      enabledCount++;
  }

625
  if ( enabledCount != 0 ) {
626 627 628
    globalTwosidedLightingAction_->setToolTip(tr("Disable two-sided lighting for all viewers"));
    globalTwosidedLightingAction_->setStatusTip(tr("Disable two-sided lighting for all viewers"));
    globalTwosidedLightingAction_->setText(tr("Disable two-sided lighting"));
629
  } else {
630 631 632
    globalTwosidedLightingAction_->setToolTip(tr("Enable two-sided lighting for all viewers"));
    globalTwosidedLightingAction_->setStatusTip(tr("Enable two-sided lighting for all viewers"));
    globalTwosidedLightingAction_->setText(tr("Enable two-sided lighting"));
633 634 635
  }

  //=============================================================================================================================
636

637
  enabledCount  = 0;
638

639 640 641 642 643
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).multisampling() )
      enabledCount++;
  }

644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
  if ( enabledCount != 0 ) {
    globalMultisamplingAction_->setToolTip(tr("Disable multisampling for all viewers"));
    globalMultisamplingAction_->setStatusTip(tr("Disable multisampling for all viewers"));
    globalMultisamplingAction_->setText(tr("Disable multisampling"));
  } else {
    globalMultisamplingAction_->setToolTip(tr("Enable multisampling for all viewers"));
    globalMultisamplingAction_->setStatusTip(tr("Enable multisampling for all viewers"));
    globalMultisamplingAction_->setText(tr("Enable multisampling"));
  }
  
  //=============================================================================================================================

  enabledCount  = 0;

  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).mipmapping() )
      enabledCount++;
  }

  if ( enabledCount != 0 ) {
    globalMipmappingAction_->setToolTip(tr("Disable mipmapping for all viewers"));
    globalMipmappingAction_->setStatusTip(tr("Disable mipmapping for all viewers"));
    globalMipmappingAction_->setText(tr("Disable mipmapping"));
667
  } else {
668 669 670
    globalMipmappingAction_->setToolTip(tr("Enable mipmapping for all viewers"));
    globalMipmappingAction_->setStatusTip(tr("Enable mipmapping for all viewers"));
    globalMipmappingAction_->setText(tr("Enable mipmapping"));
671
  }
672

673 674
  //=============================================================================================================================
    
675 676
  int perspectiveCount = 0;
  int orthogonalCount = 0;
Jan Möbius's avatar
 
Jan Möbius committed
677

678 679 680 681 682 683
  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i ) {
    if ( examiner_widgets_[ i ]->projectionMode() == glViewer::PERSPECTIVE_PROJECTION )
      perspectiveCount++;
    else
      orthogonalCount++;
  }
684 685
  
  if ( perspectiveCount == PluginFunctions::viewers() )
686 687 688
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
689

690
  if ( orthogonalCount == PluginFunctions::viewers() )
691 692 693
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
694

695 696
}

697 698 699 700 701
void CoreWidget::slotUpdateRendererMenu() {

  // Add the menu if it does not exist yet
  if ( rendererMenu_ == 0 ) {

702 703
    QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();

704
    rendererMenu_ = new QMenu(tr("Global Renderer"),viewMenu_);
705
    rendererMenu_->setIcon(QIcon(iconPath+"renderers.png"));
706 707
    viewMenu_->addMenu(rendererMenu_);

708

709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
    connect(rendererMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateRendererMenu() ) );
  }

  // delete the old renerer group if it exists
  if ( rendererGroup_ ) {

    disconnect( rendererGroup_ , SIGNAL( triggered( QAction * ) ),
        this           , SLOT( slotGlobalRendererMenu( QAction * ) ) );

    delete( rendererGroup_ );
    rendererGroup_ = 0;

  }

  // Recreate actionGroup
  rendererGroup_ = new QActionGroup( this );
  rendererGroup_->setExclusive( true );

//  // Add the options for all active renderers
//  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i) {
//
//    //Get the options action for the currently active renderer
//    if( renderManager()[ renderManager().activeId( i )]->optionsAction != 0 ) {
//      rendererMenu_->addAction(renderManager()[ renderManager().activeId(i) ]->optionsAction );
//    }
//  }

//  rendererMenu_->addSeparator();

  // Add the renderers
  for ( unsigned int i = 0 ; i < renderManager().available() ; ++i) {

    // Add a new Action with the renderer name
    QAction * action = new QAction( renderManager()[i]->name, rendererGroup_ );
    action->setCheckable( true );

    // Check if this processor is currently active
    if ( renderManager().activeId(PluginFunctions::activeExaminer() ) == i )
      action->setChecked(true);

    // Remember the id for the processor
    action->setData(QVariant(i));
  }

  // Remove old data
  rendererMenu_->clear();

  // Add all new actions from the group to the menu
  rendererMenu_->addActions( rendererGroup_->actions() );

  // Connect signal of group to our managing slot
  connect( rendererGroup_ , SIGNAL( triggered( QAction * ) ),
      this          , SLOT( slotGlobalRendererMenu( QAction * ) ) );


}

void CoreWidget::slotUpdatePostProcessorMenu() {


  // Add the menu if it does not exist yet
  if ( postprocessorMenu_ == 0 ) {

772 773
    QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();

774
    postprocessorMenu_ = new QMenu(tr("Global Post Processor"),viewMenu_);
775
    postprocessorMenu_->setIcon(QIcon(iconPath+"postprocessors.png"));
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
    viewMenu_->addMenu(postprocessorMenu_);

    connect(postprocessorMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdatePostProcessorMenu() ) );
  }

  // delete the old post processor group if it exists
  if ( postProcessorGroup_ ) {

    disconnect( postProcessorGroup_ , SIGNAL( triggered( QAction * ) ),
        this           , SLOT( slotGlobalPostProcessorMenu( QAction * ) ) );

    delete( postProcessorGroup_ );
    postProcessorGroup_ = 0;

  }

  // Recreate actionGroup
  postProcessorGroup_ = new QActionGroup( this );
  postProcessorGroup_->setExclusive( true );

//  // Get the options action for the currently active postprocessor
//  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i)
//    if( postProcessorManager()[ postProcessorManager().activeId( i )]->optionsAction != 0 ) {
//      postprocessorMenu_->addAction(postProcessorManager()[ postProcessorManager().activeId( i ) ]->optionsAction );
//    }

//  postprocessorMenu_->addSeparator();


  // Now add the post processors
  for ( unsigned int i = 0 ; i < postProcessorManager().available() ; ++i) {

    // Add a new Action with the postprocessors name
    QAction * action = new QAction( postProcessorManager()[i]->name, postProcessorGroup_ );
    action->setCheckable( true );

    // Check if this processor is currently active
    if ( postProcessorManager().activeId(PluginFunctions::activeExaminer() ) == i )
      action->setChecked(true);

    // Remember the id for the processor
    action->setData(QVariant(i));
  }

  // Remove old data
  postprocessorMenu_->clear();

  // Add all new actions from the group to the menu
  postprocessorMenu_->addActions( postProcessorGroup_->actions() );

  // Connect signal of group to our managing slot
  connect( postProcessorGroup_ , SIGNAL( triggered( QAction * ) ),
      this          , SLOT( slotGlobalPostProcessorMenu( QAction * ) ) );

}

Jan Möbius's avatar
Jan Möbius committed
832 833
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
 
Jan Möbius committed
834

Jan Möbius's avatar
Jan Möbius committed
835 836 837 838
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
 
Jan Möbius committed
839

Jan Möbius's avatar
Jan Möbius committed
840
  }
Jan Möbius's avatar
 
Jan Möbius committed
841

Jan Möbius's avatar
Jan Möbius committed
842 843 844
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
 
Jan Möbius committed
845

Jan Möbius's avatar
Jan Möbius committed
846
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
 
Jan Möbius committed
847 848
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
849
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
 
Jan Möbius committed
850

Jan Möbius's avatar
Jan Möbius committed
851 852
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
853
    globalDrawMenu_  = new QMenu(tr("Set Global DrawMode"));
Jan Möbius's avatar
Jan Möbius committed
854 855
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
 
Jan Möbius committed
856

Jan Möbius's avatar
Jan Möbius committed
857 858
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
 
Jan Möbius committed
859 860

  // Collect available draw Modes
861
  // Single pass action, draw modes independent from multipass rendering
Jan Möbius's avatar
Jan Möbius committed
862 863
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
864
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
 
Jan Möbius committed
865

866
  // Get currently active drawModes
Jan Möbius's avatar
Jan Möbius committed
867 868
  activeDrawModes_ = PluginFunctions::drawMode(0);
  for ( int i = 1 ; i < PluginFunctions::viewers(); ++i )
Jan Möbius's avatar
Jan Möbius committed
869
    activeDrawModes_ &= PluginFunctions::drawMode(i);
Jan Möbius's avatar
 
Jan Möbius committed
870

Jan Möbius's avatar
Jan Möbius committed
871
  // Convert to ids
Jan Möbius's avatar
Jan Möbius committed
872 873
  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
  availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes() ;
Jan Möbius's avatar
 
Jan Möbius committed
874

Jan Möbius's avatar
Jan Möbius committed
875
  globalDrawMenu_->clear();
Jan Möbius's avatar
 
Jan Möbius committed
876

Jan Möbius's avatar
Jan Möbius committed
877 878
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
Jan Möbius's avatar
Jan Möbius committed
879 880
    ACG::SceneGraph