MenuBar.cc 43.5 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2
3
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
4
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
33
34
35
36
37
38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40
41
42
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
43
44
45
46
47
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
48
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62



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


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

#include "CoreWidget.hh"

63
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
64
65
66



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

69
  if (!menus_.contains(_name))
Jan Möbius's avatar
Jan Möbius committed
70
71
    return;

72
  if (_name == FILEMENU) {
Jan Möbius's avatar
Jan Möbius committed
73
    fileMenu_->insertSeparator(fileMenuEnd_);
74
75
76
77
78
79
80
81
82
83
    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
84
  }
85

Jan Möbius's avatar
Jan Möbius committed
86
}
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
void CoreWidget::slotAddMenubarActions( std::vector<QAction*> _actions , QString _name ) {

  if (!menus_.contains(_name))
    return;

  if (_name == FILEMENU) {
    fileMenu_->insertSeparator(fileMenuEnd_);
    for (std::vector<QAction*>::iterator it = _actions.begin(); it != _actions.end(); ++it )
        fileMenu_->insertAction(fileMenuEnd_, *it);
  } 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_);

    for (std::vector<QAction*>::iterator it = _actions.begin(); it != _actions.end(); ++it )
        menus_[_name]->addAction(*it);
  } else {
      for (std::vector<QAction*>::iterator it = _actions.begin(); it != _actions.end(); ++it )
          menus_[_name]->addAction(*it);
  }

}

Jan Möbius's avatar
Jan Möbius committed
112
113
114
115
//=============================================================================

void CoreWidget::slotGetMenubarMenu (QString _name, QMenu *& _menu, bool _create)
{
116
	//if menu already exists, return it
Jan Möbius's avatar
Jan Möbius committed
117
118
  if (menus_.contains (_name))
    _menu = menus_[_name];
119
  //otherwise create a new one
Jan Möbius's avatar
Jan Möbius committed
120
121
122
123
  else if (_create)
  {
    _menu = new QMenu(_name);
    menus_[_name] = _menu;
124
125
126
    //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
127
    menuBar()->insertAction(helpMenu_->menuAction() ,_menu->menuAction ());
128
129
130
  }
  //otherwise no menu was found
  else
Jan Möbius's avatar
Jan Möbius committed
131
    _menu = NULL;
Jan Möbius's avatar
 
Jan Möbius committed
132
133
134
135
136
}


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

137
bool CoreWidget::eventFilter(QObject *_obj, QEvent *_event)
Jan Möbius's avatar
 
Jan Möbius committed
138
{
139
140
141
142
143
144
145
146
147
148
149
	//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
150

151
152
//=============================================================================

Jan Möbius's avatar
Jan Möbius committed
153
154
155
156
157
158
void CoreWidget::showReducedMenuBar(bool reduced) {
    for (std::vector<QAction*>::iterator it = extended_actions.begin(); it != extended_actions.end(); ++it) {
        (*it)->setVisible(!reduced);
    }
}

159
160
void CoreWidget::setupMenuBar()
{
Jan Möbius's avatar
   
Jan Möbius committed
161

Jan Möbius's avatar
 
Jan Möbius committed
162
163
164
  // ======================================================================
  // File Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
165
  fileMenu_ = new QMenu( FILEMENU );
166
  menuBar()->addMenu( fileMenu_ );
Jan Möbius's avatar
Jan Möbius committed
167
  menus_[tr("File")] = fileMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
168

Jan Möbius's avatar
 
Jan Möbius committed
169
  //Clear all
Jan Möbius's avatar
Jan Möbius committed
170
  QAction* AC_clear_all = new QAction(tr("Clear All"), this);;
Jan Möbius's avatar
 
Jan Möbius committed
171
  AC_clear_all->setStatusTip(tr("Clear all Objects"));
172
  AC_clear_all->setWhatsThis(tr("Close all open Objects"));
173
  AC_clear_all->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-clear.png"));
Jan Möbius's avatar
 
Jan Möbius committed
174
175
  connect(AC_clear_all, SIGNAL(triggered()), this, SIGNAL(clearAll()));
  fileMenu_->addAction(AC_clear_all);
176

Jan Möbius's avatar
 
Jan Möbius committed
177
  fileMenu_->addSeparator();
178
179

  //Load object
Jan Möbius's avatar
Jan Möbius committed
180
  QAction* AC_Load = new QAction(tr("Load Object"), this);
Jan Möbius's avatar
 
Jan Möbius committed
181
  AC_Load->setStatusTip(tr("Load an object"));
182
  AC_Load->setWhatsThis(tr("Load a new object"));
183
  AC_Load->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open.png"));
Jan Möbius's avatar
 
Jan Möbius committed
184
185
  connect(AC_Load, SIGNAL(triggered()), this, SIGNAL(loadMenu()));
  fileMenu_->addAction(AC_Load);
186

Jan Möbius's avatar
 
Jan Möbius committed
187
  //Add empty object
Jan Möbius's avatar
Jan Möbius committed
188
  QAction* AC_AddEmpty = new QAction(tr("Add Empty Object"), this);
Jan Möbius's avatar
 
Jan Möbius committed
189
  AC_AddEmpty->setStatusTip(tr("Add an empty object"));
190
  AC_AddEmpty->setWhatsThis(tr("Creates a new empty object of a given type"));
191
  AC_AddEmpty->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"add-empty-object.png"));
Jan Möbius's avatar
 
Jan Möbius committed
192
193
  connect(AC_AddEmpty, SIGNAL(triggered()), this, SIGNAL(addEmptyObjectMenu()));
  fileMenu_->addAction(AC_AddEmpty);
Jan Möbius's avatar
Jan Möbius committed
194
195
  extended_actions.push_back(AC_AddEmpty);
  extended_actions.push_back(fileMenu_->addSeparator());
196

Jan Möbius's avatar
 
Jan Möbius committed
197
  //Save object
198
  QAction* AC_Save = new QAction(tr("Save Objects"), this);
Dirk Wilden's avatar
Dirk Wilden committed
199
//   AC_Save->setShortcut (Qt::CTRL + Qt::Key_S);
200
201
  AC_Save->setStatusTip(tr("Save current objects"));
  AC_Save->setWhatsThis(tr("Save current objects"));
202
  AC_Save->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save.png"));
Jan Möbius's avatar
 
Jan Möbius committed
203
204
  connect(AC_Save, SIGNAL(triggered()), this, SIGNAL(saveMenu()));
  fileMenu_->addAction(AC_Save);
Jan Möbius's avatar
Jan Möbius committed
205
  extended_actions.push_back(AC_Save);
206

Jan Möbius's avatar
 
Jan Möbius committed
207
  //Save object to
208
209
210
  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"));
211
  AC_Save_to->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save-as.png"));
Jan Möbius's avatar
 
Jan Möbius committed
212
213
  connect(AC_Save_to, SIGNAL(triggered()), this, SIGNAL(saveToMenu()));
  fileMenu_->addAction(AC_Save_to);
214

Jan Möbius's avatar
Jan Möbius committed
215
  extended_actions.push_back(fileMenu_->addSeparator());
216

Jan Möbius's avatar
 
Jan Möbius committed
217
  //Load ini
Jan Möbius's avatar
Jan Möbius committed
218
  QAction* AC_load_ini = new QAction(tr("Load Settings"), this);
Jan Möbius's avatar
 
Jan Möbius committed
219
  AC_load_ini->setStatusTip(tr("Load Settings from INI file"));
220
  AC_load_ini->setWhatsThis(tr("Load a previous settings from file (objects,colors,...)"));
221
  AC_load_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"load-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
222
223
  connect(AC_load_ini, SIGNAL(triggered()), this, SIGNAL(loadIniMenu()));
  fileMenu_->addAction(AC_load_ini);
Jan Möbius's avatar
Jan Möbius committed
224
  extended_actions.push_back(AC_load_ini);
225

Jan Möbius's avatar
 
Jan Möbius committed
226
  //Save ini
Jan Möbius's avatar
Jan Möbius committed
227
  QAction* AC_save_ini = new QAction(tr("Save Settings"), this);
Jan Möbius's avatar
 
Jan Möbius committed
228
  AC_save_ini->setStatusTip(tr("Save current settings to INI file"));
229
  AC_save_ini->setWhatsThis(tr("Save settings to file (objects,colors,...)"));
230
  AC_save_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"save-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
231
232
  connect(AC_save_ini, SIGNAL(triggered()), this, SIGNAL(saveIniMenu()));
  fileMenu_->addAction(AC_save_ini);
Jan Möbius's avatar
Jan Möbius committed
233
  extended_actions.push_back(AC_save_ini);
234

Jan Möbius's avatar
Jan Möbius committed
235
  extended_actions.push_back(fileMenu_->addSeparator());
236
237

  //Options
Jan Möbius's avatar
Jan Möbius committed
238
  QAction* AC_Options = new QAction(tr("Options"), this);
239
  AC_Options->setStatusTip(tr("Edit OpenFlipper Options"));
240
  AC_Options->setWhatsThis(tr("Edit OpenFlipper Options"));
241
  AC_Options->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"options.png"));
242
243
  connect(AC_Options, SIGNAL(triggered()), this, SLOT(showOptionsWidget()));
  fileMenu_->addAction(AC_Options);
244
245

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

Jan Möbius's avatar
 
Jan Möbius committed
248
  //Recent files
Jan Möbius's avatar
Jan Möbius committed
249
  recentFilesMenu_ = new QMenu(tr("Recent Files"));
250
  recentFilesMenu_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open-recent.png"));
251
  recentFilesMenu_->setWhatsThis(tr("Open recent files"));
Jan Möbius's avatar
 
Jan Möbius committed
252
253
  connect(recentFilesMenu_,SIGNAL(triggered(QAction*)),this,SIGNAL(recentOpen(QAction*)));
  fileMenu_->addMenu(recentFilesMenu_);
254

Jan Möbius's avatar
 
Jan Möbius committed
255
  fileMenu_->addSeparator();
256

Jan Möbius's avatar
 
Jan Möbius committed
257
  //Main Application exit menu entry
Jan Möbius's avatar
Jan Möbius committed
258
  QAction* AC_exit = new QAction(tr("Exit"), this);;
Jan Möbius's avatar
 
Jan Möbius committed
259
260
  AC_exit->setShortcut (Qt::CTRL + Qt::Key_Q);
  AC_exit->setStatusTip(tr("Exit Application"));
261
  recentFilesMenu_->setWhatsThis(tr("Close OpenFlipper"));
262
  AC_exit->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"application-exit.png"));
Jan Möbius's avatar
 
Jan Möbius committed
263
264
265
  connect(AC_exit, SIGNAL(triggered()), this, SIGNAL(exit()));
  fileMenu_->addAction(AC_exit);

266
267
268
  // ======================================================================
  // View Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
269
  viewMenu_ = new QMenu( VIEWMENU );
270
  menuBar()->addMenu(viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
271
  menus_[tr("View")] = viewMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
272

273
  slotUpdateGlobalDrawMenu();
Jan Möbius's avatar
Jan Möbius committed
274
275
  extended_actions.push_back(
          viewMenu_->addMenu(globalDrawMenu_));
Jan Möbius's avatar
   
Jan Möbius committed
276

277
278
279
  //============================================================================================================
  // Rendering options Menu
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
280

281
  QMenu* renderingOptionsMenu = new QMenu(tr("Global Rendering Options"),viewMenu_);
Jan Möbius's avatar
Jan Möbius committed
282
  renderingOptionsMenu->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_renderingOptions.png") );
Jan Möbius's avatar
Jan Möbius committed
283
284
  extended_actions.push_back(
          viewMenu_->addMenu(renderingOptionsMenu));
Jan Möbius's avatar
   
Jan Möbius committed
285

286
  orthogonalProjectionAction_ = new QAction( tr("Switch Viewers to Orthogonal Projection"), renderingOptionsMenu );;
287
288
  orthogonalProjectionAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
  orthogonalProjectionAction_->setCheckable( false );
289
290
291
  orthogonalProjectionAction_->setToolTip(   tr("Switch to orthogonal projection mode."));
  orthogonalProjectionAction_->setWhatsThis( tr("Switch projection mode<br><br>"
      "Switch to <b>orthogonal</b> projection mode."));
292
293
  connect( orthogonalProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalOrthographicProjection() ) );
  renderingOptionsMenu->addAction( orthogonalProjectionAction_);
Jan Möbius's avatar
   
Jan Möbius committed
294

295
296
297
298
299
300
301
302
303
  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_);

304
  // =====================
305

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

310
  //======================
Jan Möbius's avatar
   
Jan Möbius committed
311

312
  globalBackfaceCullingAction_ = renderingOptionsMenu->addAction(tr("Global Backface Culling"));
313
  globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
314
  connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleBackFaceCulling() ) );
315
316
317

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

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

322
323
  //======================

324
325
326
327
328
329
330
331
332
  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
333

334
335
336
337
338
339
340
  //============================================================================================================
  // Global renderer menu
  //============================================================================================================

  slotUpdateRendererMenu();

  //============================================================================================================
341
  // Other toplevel actions
342
343
  //============================================================================================================

344
  viewMenu_->addSeparator();
345

346
  //============================================================================================================
347
  // Post processor Manager
348
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
349

350
351
352
353
354
355
  QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
  QAction* showPostProcessorDialog = new QAction(tr("Show post processor manager"),this);
  showPostProcessorDialog->setIcon(QIcon(iconPath+"postprocessors.png"));
  connect(showPostProcessorDialog,SIGNAL(triggered()),this,SLOT(slotShowPostProcessorManager()));
  viewMenu_->addAction(showPostProcessorDialog);

356
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
357

358
359
360
  //====================================================================================================


Mike Kremer's avatar
Mike Kremer committed
361
  QAction* navigationSwitchAction = new QAction( tr("First-person Navigation"), viewMenu_ );
362
  navigationSwitchAction->setCheckable( true );
Jan Möbius's avatar
Jan Möbius committed
363
  navigationSwitchAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_firstPersonMode.png") );
Mike Kremer's avatar
Mike Kremer committed
364
365
  navigationSwitchAction->setStatusTip( tr("Switch between normal and first-person navigation mode."));
  navigationSwitchAction->setWhatsThis( tr("Switch between normal and first-person navigation mode."));
366
367
368
369
  navigationSwitchAction->setChecked( false );

  connect( navigationSwitchAction, SIGNAL( toggled(bool) ), this, SLOT( slotSwitchNavigation(bool) ) );
  viewMenu_->addAction( navigationSwitchAction);
Jan Möbius's avatar
Jan Möbius committed
370
  extended_actions.push_back(navigationSwitchAction);
371
372
373

  viewMenu_->addSeparator();

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

376
  QAction* homeAction = new QAction(tr("Restore Home View"),viewMenu_);
377
378
  homeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"go-home.png") );
  homeAction->setCheckable( false );
379
380
381
  homeAction->setStatusTip( tr("Restore <b>home</b> view."));
  homeAction->setWhatsThis( tr("Restore home view<br><br>"
                               "Resets the view to the home view"));
382
383
  viewMenu_->addAction( homeAction );
  connect( homeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalHomeView() ) );
Jan Möbius's avatar
   
Jan Möbius committed
384
385


386
  QAction* setHomeAction = new QAction( tr("Set Home View") , viewMenu_ );
387
388
  setHomeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"set-home.png") );
  setHomeAction->setCheckable( false );
389
390
391
  setHomeAction->setStatusTip( tr("Set <b>home</b> view"));
  setHomeAction->setWhatsThis( tr("Store home view<br><br>"
                                  "Stores the current view as the home view"));
392
393
  viewMenu_->addAction( setHomeAction);
  connect( setHomeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalSetHomeView() ) );
Jan Möbius's avatar
   
Jan Möbius committed
394

395
  QAction* viewAllAction = new QAction( tr("View all"), viewMenu_ );
396
397
  viewAllAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewall.png") );
  viewAllAction->setCheckable( false );
398
399
400
401
  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."));
402
403
  connect( viewAllAction,SIGNAL( triggered() ), this, SLOT( slotGlobalViewAll() ) );
  viewMenu_->addAction( viewAllAction);
Jan Möbius's avatar
   
Jan Möbius committed
404

Dirk Wilden's avatar
Dirk Wilden committed
405
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
406

407
  QAction* snapShotAction = new QAction( tr("Viewer Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
408
409
  snapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewerSnapshot.png") );
  snapShotAction->setCheckable( false );
410
411
412
  snapShotAction->setStatusTip( tr("Take a snapshot from all viewers."));
  snapShotAction->setWhatsThis( tr("Viewer Snapshot<br><br>"
                                   "Take a snapshot of all viewers at once."));
413
  snapShotAction->setShortcut (Qt::Key_F2);
Dirk Wilden's avatar
Dirk Wilden committed
414
415
  connect( snapShotAction,SIGNAL( triggered() ), this, SLOT( viewerSnapshotDialog() ) );
  viewMenu_->addAction( snapShotAction);
Dirk Wilden's avatar
Dirk Wilden committed
416

417
  QAction* appSnapShotAction = new QAction( tr("Application Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
418
419
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
420
421
422
  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
423
424
425
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

Dirk Wilden's avatar
Dirk Wilden committed
426
427
  viewMenu_->addSeparator();

428
  QAction* wheelSwitchAction = new QAction( tr("Show / hide wheels"), viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
429
  wheelSwitchAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_wheels.png") );
430
  wheelSwitchAction->setCheckable( true );
431
432
433
434
  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
435
436
437
438
                                      
  if(OpenFlipperSettings().value("Core/Gui/glViewer/showControlWheels").toBool() ) 
    wheelSwitchAction->setChecked(true);

439
440
441
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

442
  QAction* coordSys = viewMenu_->addAction(tr("Coordinate Systems"));
Dirk Wilden's avatar
Dirk Wilden committed
443
444
  coordSys->setCheckable(true);
  coordSys->setChecked(true);
445
  coordSys->setStatusTip(tr("Toggle visibility of the coordinate systems"));
446
  coordSys->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"coordsys.png") );
Dirk Wilden's avatar
Dirk Wilden committed
447
448
  connect(coordSys, SIGNAL(triggered(bool)), this, SLOT( slotCoordSysVisibility(bool) ) );

449
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
450

Jan Möbius's avatar
Jan Möbius committed
451
  QAction* setGlobalBackgroundColor = new QAction(tr("Set Background Color"), this);;
452
453
  setGlobalBackgroundColor->setToolTip(tr("Set Background Color for all viewers"));
  setGlobalBackgroundColor->setStatusTip(tr("Set Background Color for all viewers"));
454
  setGlobalBackgroundColor->setWhatsThis(tr("Set Background Color for all viewers"));
455
456
457
  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
458

459
460
461
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
462

Jan Möbius's avatar
Jan Möbius committed
463
  toolsMenu_ = new QMenu( TOOLSMENU );
464
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
465
  menus_[tr("Tools")] = toolsMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
466

467
  QAction* sceneGraphAction = new QAction( tr("Show SceneGraph ") ,toolsMenu_ );
468
469
  sceneGraphAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png") );
  sceneGraphAction->setCheckable( false );
470
471
472
473
  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>" ) );
474
475
476
  QObject::connect( sceneGraphAction, SIGNAL( triggered() ),
                    this,             SLOT( slotShowSceneGraphDialog() ) );
  toolsMenu_->addAction( sceneGraphAction);
Jan Möbius's avatar
Jan Möbius committed
477
  extended_actions.push_back(sceneGraphAction);
Jan Möbius's avatar
   
Jan Möbius committed
478

479
480
  toolsMenu_->addSeparator();

481
  QAction* startVideoCaptureAction =  new QAction( tr("Start Video Capture ") ,toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
482
  startVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"video-start.png") );
Dirk Wilden's avatar
Dirk Wilden committed
483
  startVideoCaptureAction->setCheckable( false );
484
485
  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
486
487
488
  toolsMenu_->addAction( startVideoCaptureAction );
  connect(startVideoCaptureAction, SIGNAL(triggered()), this, SLOT(startVideoCaptureDialog()) );

489
  QAction* stopVideoCaptureAction =  new QAction( tr("Stop Video Capture ") ,toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
490
  stopVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"video-stop.png") );
Dirk Wilden's avatar
Dirk Wilden committed
491
  stopVideoCaptureAction->setCheckable( false );
492
493
  stopVideoCaptureAction->setToolTip( tr("Stop video capturing." ));
  stopVideoCaptureAction->setWhatsThis( tr("Stop Video capturing" ));
Dirk Wilden's avatar
Dirk Wilden committed
494
495
496

  toolsMenu_->addAction( stopVideoCaptureAction);
  connect(stopVideoCaptureAction, SIGNAL(triggered()), this, SIGNAL(stopVideoCapture()) );
Jan Möbius's avatar
Jan Möbius committed
497
  
Jan Möbius's avatar
Jan Möbius committed
498
499
500
  extended_actions.push_back(startVideoCaptureAction);
  extended_actions.push_back(stopVideoCaptureAction);

Jan Möbius's avatar
Jan Möbius committed
501
502
503
504
505
506
507
508
509
  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);
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
  
  // ======================================================================
  // 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_);
Jan Möbius's avatar
Jan Möbius committed
528
  extended_actions.push_back(AC_ShowViewModeControls_);
529
530
  
  // Show or Hide the View Mode Controls
531
532
  QAction* AC_ShowToolbox = new QAction(tr("Show Toolboxes"), this);
  AC_ShowToolbox->setStatusTip(tr("Show or Hide the Toolbox Widget"));
533
  //   AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
  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);
Jan Möbius's avatar
Jan Möbius committed
560
  extended_actions.push_back(AC_ShowMenuBar);
561
562
563
564
565
566
567
568
569
570
571

  // 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);

572
573
574
575
576
577
578
579
580
  // Enable or Disable Fullscreen Mode
  QAction* AC_Fullscreen = new QAction(tr("Fullscreen"), this);
  AC_Fullscreen->setStatusTip(tr("Enable or Disable the Fullscreen"));
  AC_Fullscreen->setWhatsThis(tr("Enable or Disable the Fullscreen"));
  AC_Fullscreen->setCheckable(true);
  AC_Fullscreen->setChecked( OpenFlipperSettings().value("Core/Gui/fullscreen", false ).toBool() );
  connect(AC_Fullscreen,SIGNAL(triggered()),this,SLOT(toggleFullscreen()));
  connect(this,SIGNAL(fullScreenChanged(bool)),AC_Fullscreen,SLOT(setChecked(bool)));
  windowMenu_->addAction(AC_Fullscreen);
581

582
583
584
585
586
587
  // ======================================================================
  // Algorithms Menu
  // ======================================================================
  algorithmMenu_ = new QMenu( ALGORITHMMENU );
  menus_[tr("Algorithms")] = algorithmMenu_;

Jan Möbius's avatar
 
Jan Möbius committed
588
589
590
  // ======================================================================
  // help Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
591
  helpMenu_ = new QMenu(tr("Help"));
Jan Möbius's avatar
 
Jan Möbius committed
592
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
593
  menus_[tr("Help")] = helpMenu_;
594

Jan Möbius's avatar
 
Jan Möbius committed
595
  //Open Help Browser
Jan Möbius's avatar
Jan Möbius committed
596
  QAction* AC_HelpBrowser = new QAction(tr("Help"), this);
597
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
598
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
599
  AC_HelpBrowser->setWhatsThis(tr("Open the <b>Help Browser</b>"));
600
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
 
Jan Möbius committed
601
  helpMenu_->addAction(AC_HelpBrowser);
602

Jan Möbius's avatar
 
Jan Möbius committed
603
604
605
  //Switch to whats this mode
  QAction* AC_Whats_this = QWhatsThis::createAction ( this );
  AC_Whats_this->setStatusTip(tr("Enter What's this Mode"));
606
  AC_Whats_this->setWhatsThis(tr("Get information about a specific Button/Widget/..."));
Jan Möbius's avatar
 
Jan Möbius committed
607
  helpMenu_->addAction(AC_Whats_this);
608

Jan Möbius's avatar
 
Jan Möbius committed
609
  helpMenu_->addSeparator();
610

Jan Möbius's avatar
 
Jan Möbius committed
611
  //About Action
Jan Möbius's avatar
Jan Möbius committed
612
  QAction* AC_About = new QAction(tr("About"), this);
Jan Möbius's avatar
 
Jan Möbius committed
613
  AC_About->setStatusTip(tr("About OpenFlipper"));
614
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
615
  AC_About->setWhatsThis(tr("This entry shows information about <b>OpenFlipper</b>"));
Jan Möbius's avatar
Jan Möbius committed
616
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
 
Jan Möbius committed
617
  helpMenu_->addAction(AC_About);
618

Jan Möbius's avatar
 
Jan Möbius committed
619
620
621
622
623
624
625
626
627
  // 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);
628
629
630
631
632
633
634
635


  // 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);
636
  algorithmMenu_->installEventFilter(this);
637
  helpMenu_->installEventFilter(this);
Jan Möbius's avatar
 
Jan Möbius committed
638
639
}

640

641
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
   
Jan Möbius committed
642

643
  uint enabledCount  = 0;
644

645
646
647
648
649
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).animation() )
      enabledCount++;
  }

650
  if ( enabledCount != 0 ) {
651
652
653
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setText(tr("Disable animation"));
654
  } else {
655
656
657
    globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setText(tr("Enable animation"));
658
  }
659

660
  //=============================================================================================================================
661

662
  enabledCount  = 0;
663

664
665
666
667
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
      enabledCount++;
  }
668

669
  if ( enabledCount != 0 ) {
670
671
672
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
673
  } else {
674
675
676
    globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Enable backface culling"));
677
678
679
  }

  //=============================================================================================================================
680

681
  enabledCount  = 0;
682

683
684
685
686
687
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
      enabledCount++;
  }

688
  if ( enabledCount != 0 ) {
689
690
691
    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"));
692
  } else {
693
694
695
    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"));
696
697
698
  }

  //=============================================================================================================================
699

700
  enabledCount  = 0;
701

702
703
704
705
706
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).multisampling() )
      enabledCount++;
  }

707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
  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"));
730
  } else {
731
732
733
    globalMipmappingAction_->setToolTip(tr("Enable mipmapping for all viewers"));
    globalMipmappingAction_->setStatusTip(tr("Enable mipmapping for all viewers"));
    globalMipmappingAction_->setText(tr("Enable mipmapping"));
734
  }
735

736
737
  //=============================================================================================================================
    
738
739
  int perspectiveCount = 0;
  int orthogonalCount = 0;
Jan Möbius's avatar
   
Jan Möbius committed
740

741
742
743
744
745
746
  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i ) {
    if ( examiner_widgets_[ i ]->projectionMode() == glViewer::PERSPECTIVE_PROJECTION )
      perspectiveCount++;
    else
      orthogonalCount++;
  }
747
748
  
  if ( perspectiveCount == PluginFunctions::viewers() )
749
750
751
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
752

753
  if ( orthogonalCount == PluginFunctions::viewers() )
754
755
756
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
757

758
759
}

760
761
762
763
764
void CoreWidget::slotUpdateRendererMenu() {

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

765
766
    QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();

767
    rendererMenu_ = new QMenu(tr("Global Renderer"),viewMenu_);
768
    rendererMenu_->setIcon(QIcon(iconPath+"renderers.png"));
Jan Möbius's avatar
Jan Möbius committed
769
    extended_actions.push_back(viewMenu_->addMenu(rendererMenu_));
770

771

772
773
774
775
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
    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();

819
820
821
822
823
824
825
  // Add render objects action
  QAction* showRendererObjectWidget = new QAction(tr("Show render objects"), this);
  connect(showRendererObjectWidget, SIGNAL(triggered()), this, SLOT(slotShowRenderObjectWidget()));
  rendererMenu_->addAction(showRendererObjectWidget);

  rendererMenu_->addSeparator();

826
827
828
829
830
831
832
833
834
835
  // 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 * ) ) );


}

Jan Möbius's avatar
Jan Möbius committed
836
837
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
838

Jan Möbius's avatar
Jan Möbius committed
839
840
841
842
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
   
Jan Möbius committed
843

Jan Möbius's avatar
Jan Möbius committed
844
  }
Jan Möbius's avatar
   
Jan Möbius committed
845

Jan Möbius's avatar
Jan Möbius committed
846
847
848
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
   
Jan Möbius committed
849

Jan Möbius's avatar
Jan Möbius committed
850
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
   
Jan Möbius committed
851
852
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
853
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
854

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

Jan Möbius's avatar
Jan Möbius committed
861
862
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
   
Jan Möbius committed
863
864

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

870
  // Get currently active drawModes
Jan Möbius's avatar
Jan Möbius committed
871
872
  activeDrawModes_ = PluginFunctions::drawMode(0);
  for ( int i = 1 ; i < PluginFunctions::viewers(); ++i )
Jan Möbius's avatar
Jan Möbius committed
873
    activeDrawModes_ &= PluginFunctions::drawMode(i);
Jan Möbius's avatar
   
Jan Möbius committed
874

Jan Möbius's avatar
Jan Möbius committed
875
  // Convert to ids
Jan Möbius's avatar
Jan Möbius committed
876
877
  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
  availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes() ;
Jan Möbius's avatar
   
Jan Möbius committed
878

Jan Möbius's avatar
Jan Möbius committed
879
  globalDrawMenu_->clear();
Jan Möbius's avatar
   
Jan Möbius committed
880

Jan Möbius's avatar
Jan Möbius committed
881
882
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
Jan Möbius's avatar
Jan Möbius committed
883
884
    ACG::SceneGraph::DrawModes::DrawMode id    = availDrawModeIds[i];
    std::string  descr =  id.description();
Jan Möbius's avatar
Jan Möbius committed
885
886
887

    QAction * action = new QAction( descr.c_str(), drawGroup_ );
    action->setCheckable( true );
Jan Möbius's avatar
Jan Möbius committed
888
    action->setChecked( activeDrawModes_.containsAtomicDrawMode(id) );
Jan Möbius's avatar
Jan Möbius committed
889
890
891
892
893
894
  }

  globalDrawMenu_->addActions( drawGroup_->actions() );

}

895
896
897
898
void CoreWidget::slotGlobalRendererMenu(QAction * _action) {

  unsigned int mode = _action->data().toUInt();

899
900
  QString defaultRendererName = renderManager()[mode]->name;

901
902
  // Set renderer for all viewers
  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i)
903
  {
904
    renderManager().setActive(mode,i);
905
906
907
    QString defaultRendererKey  = "Viewer" + QString::number(i)+"/DefaultRenderer";
    OpenFlipperSettings().setValue(defaultRendererKey,defaultRendererName);
  }
908
909
910
911
912
913
914
915
916
917
918
919
920

}

void CoreWidget::slotGlobalPostProcessorMenu(QAction * _action) {

  unsigned int mode = _action->data().toUInt();

  // Set postprocessor for all viewers
  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i)
    postProcessorManager().setActive(mode,i);

}

Jan Möbius's avatar
Jan Möbius committed
921
void CoreWidget::slotGlobalDrawMenu(QAction * _action) {
Jan Möbius's avatar
   
Jan Möbius committed
922

Jan Möbius's avatar
Jan Möbius committed
923
924
925
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
Jan Möbius's avatar
Jan Möbius committed
926
927
928
  ACG::SceneGraph::DrawModes::DrawMode mode(ACG::SceneGraph::DrawModes::NONE);
  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
  availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes();
Jan Möbius's avatar
Jan Möbius committed
929
930
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
Jan Möbius's avatar
Jan Möbius committed
931
    QString descr = QString( ( availDrawModeIds[i].description() ).c_str() );
Jan Möbius's avatar
Jan Möbius committed
932
933
934
935
936
937

    if ( descr == _action->text() ) {
      mode = availDrawModeIds[i];
      break;
    }
  }
Jan Möbius's avatar
   
Jan Möbius committed
938

Jan Möbius's avatar
Jan Möbius committed
939
940
941
942
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
   
Jan Möbius committed
943

Jan Möbius's avatar
Jan Möbius committed
944
945
946
  PluginFunctions::setDrawMode( activeDrawModes_ );
}

947

Jan Möbius's avatar
 
Jan Möbius committed
948
//=============================================================================