MenuBar.cc 39.5 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
66
67
68
69
70
71
72
void CoreWidget::slotAddMenubarAction( QAction* _action , QString _name ) {

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

  if (_name == FILEMENU)
  {
    fileMenu_->insertSeparator(fileMenuEnd_);
    fileMenu_->insertAction( fileMenuEnd_ , _action );
Jan Möbius's avatar
 
Jan Möbius committed
73
  }
Jan Möbius's avatar
Jan Möbius committed
74
75
76
  else
    menus_[_name]->addAction (_action);
}
77

Jan Möbius's avatar
Jan Möbius committed
78
79
80
81
82
83
84
85
86
87
88
89
90
//=============================================================================

void CoreWidget::slotGetMenubarMenu (QString _name, QMenu *& _menu, bool _create)
{
  if (menus_.contains (_name))
    _menu = menus_[_name];
  else if (_create)
  {
    _menu = new QMenu(_name);
    menus_[_name] = _menu;
    menuBar()->insertAction(helpMenu_->menuAction() ,_menu->menuAction ());
  } else
    _menu = NULL;
Jan Möbius's avatar
 
Jan Möbius committed
91
92
93
94
}


//=============================================================================
Jan Möbius's avatar
   
Jan Möbius committed
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
bool CoreWidget::eventFilter(QObject *obj, QEvent *event)
 {
     if (obj == menuBar() ) {
       emit log(LOGERR,"Alt filter menubar " + QString::number(int(event->type())));
         if (event->type() == QEvent::ShortcutOverride) {
             QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
             if ( (keyEvent->key() == Qt::Key_Alt ||
                   keyEvent->key() == Qt::Key_Meta ) &&
                   keyEvent->modifiers() == Qt::AltModifier )
                   emit log(LOGERR,"Alt key press");
             return obj->eventFilter(obj, event);
         } else {
             return obj->eventFilter(obj, event);
         }
     } else {
         // pass the event on to the parent class
         return QMainWindow::eventFilter(obj, event);
     }
 }*/
Jan Möbius's avatar
 
Jan Möbius committed
115
116
117

void CoreWidget::setupMenuBar()
{
Jan Möbius's avatar
   
Jan Möbius committed
118
119
120

 // menuBar()->installEventFilter(this);

Jan Möbius's avatar
 
Jan Möbius committed
121
122
123
  // ======================================================================
  // File Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
124
  fileMenu_ = new QMenu( FILEMENU );
Jan Möbius's avatar
 
Jan Möbius committed
125
  menuBar()->addMenu(fileMenu_ );
Jan Möbius's avatar
Jan Möbius committed
126
  menus_[tr("File")] = fileMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
127

Jan Möbius's avatar
 
Jan Möbius committed
128
  //Clear all
Jan Möbius's avatar
Jan Möbius committed
129
  QAction* AC_clear_all = new QAction(tr("Clear All"), this);;
Jan Möbius's avatar
 
Jan Möbius committed
130
  AC_clear_all->setStatusTip(tr("Clear all Objects"));
131
  AC_clear_all->setWhatsThis(tr("Close all open Objects"));
132
  AC_clear_all->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-clear.png"));
Jan Möbius's avatar
 
Jan Möbius committed
133
134
  connect(AC_clear_all, SIGNAL(triggered()), this, SIGNAL(clearAll()));
  fileMenu_->addAction(AC_clear_all);
135

Jan Möbius's avatar
 
Jan Möbius committed
136
  fileMenu_->addSeparator();
137
138

  //Load object
Jan Möbius's avatar
Jan Möbius committed
139
  QAction* AC_Load = new QAction(tr("Load Object"), this);
Jan Möbius's avatar
 
Jan Möbius committed
140
  AC_Load->setStatusTip(tr("Load an object"));
141
  AC_Load->setWhatsThis(tr("Load a new object"));
142
  AC_Load->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open.png"));
143

Jan Möbius's avatar
 
Jan Möbius committed
144
145
  connect(AC_Load, SIGNAL(triggered()), this, SIGNAL(loadMenu()));
  fileMenu_->addAction(AC_Load);
146

Jan Möbius's avatar
 
Jan Möbius committed
147
  //Add empty object
Jan Möbius's avatar
Jan Möbius committed
148
  QAction* AC_AddEmpty = new QAction(tr("Add Empty Object"), this);
Jan Möbius's avatar
 
Jan Möbius committed
149
  AC_AddEmpty->setStatusTip(tr("Add an empty object"));
150
  AC_AddEmpty->setWhatsThis(tr("Creates a new empty object of a given type"));
151
  AC_AddEmpty->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"add-empty-object.png"));
Jan Möbius's avatar
 
Jan Möbius committed
152
153
  connect(AC_AddEmpty, SIGNAL(triggered()), this, SIGNAL(addEmptyObjectMenu()));
  fileMenu_->addAction(AC_AddEmpty);
154

Jan Möbius's avatar
 
Jan Möbius committed
155
  fileMenu_->addSeparator();
156

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

Jan Möbius's avatar
 
Jan Möbius committed
166
  //Save object to
167
168
169
  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"));
170
  AC_Save_to->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save-as.png"));
Jan Möbius's avatar
 
Jan Möbius committed
171
172
  connect(AC_Save_to, SIGNAL(triggered()), this, SIGNAL(saveToMenu()));
  fileMenu_->addAction(AC_Save_to);
173

Jan Möbius's avatar
 
Jan Möbius committed
174
  fileMenu_->addSeparator();
175

Jan Möbius's avatar
 
Jan Möbius committed
176
  //Load ini
Jan Möbius's avatar
Jan Möbius committed
177
  QAction* AC_load_ini = new QAction(tr("Load Settings"), this);
Jan Möbius's avatar
 
Jan Möbius committed
178
  AC_load_ini->setStatusTip(tr("Load Settings from INI file"));
179
  AC_load_ini->setWhatsThis(tr("Load a previous settings from file (objects,colors,...)"));
180
  AC_load_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"load-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
181
182
  connect(AC_load_ini, SIGNAL(triggered()), this, SIGNAL(loadIniMenu()));
  fileMenu_->addAction(AC_load_ini);
183

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

  fileMenu_->addSeparator();

  //Options
Jan Möbius's avatar
Jan Möbius committed
195
  QAction* AC_Options = new QAction(tr("Options"), this);
196
  AC_Options->setStatusTip(tr("Edit OpenFlipper Options"));
197
  AC_Options->setWhatsThis(tr("Edit OpenFlipper Options"));
198
  AC_Options->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"options.png"));
199
200
  connect(AC_Options, SIGNAL(triggered()), this, SLOT(showOptionsWidget()));
  fileMenu_->addAction(AC_Options);
201
202

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

Jan Möbius's avatar
 
Jan Möbius committed
205
  //Recent files
Jan Möbius's avatar
Jan Möbius committed
206
  recentFilesMenu_ = new QMenu(tr("Recent Files"));
207
  recentFilesMenu_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open-recent.png"));
208
  recentFilesMenu_->setWhatsThis(tr("Open recent files"));
Jan Möbius's avatar
 
Jan Möbius committed
209
210
  connect(recentFilesMenu_,SIGNAL(triggered(QAction*)),this,SIGNAL(recentOpen(QAction*)));
  fileMenu_->addMenu(recentFilesMenu_);
211

Jan Möbius's avatar
 
Jan Möbius committed
212
  fileMenu_->addSeparator();
213

Jan Möbius's avatar
 
Jan Möbius committed
214
  //Main Application exit menu entry
Jan Möbius's avatar
Jan Möbius committed
215
  QAction* AC_exit = new QAction(tr("Exit"), this);;
Jan Möbius's avatar
 
Jan Möbius committed
216
217
  AC_exit->setShortcut (Qt::CTRL + Qt::Key_Q);
  AC_exit->setStatusTip(tr("Exit Application"));
218
  recentFilesMenu_->setWhatsThis(tr("Close OpenFlipper"));
219
  AC_exit->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"application-exit.png"));
Jan Möbius's avatar
 
Jan Möbius committed
220
221
222
  connect(AC_exit, SIGNAL(triggered()), this, SIGNAL(exit()));
  fileMenu_->addAction(AC_exit);

Jan Möbius's avatar
   
Jan Möbius committed
223

224
225
226
  // ======================================================================
  // View Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
227
  viewMenu_ = new QMenu( VIEWMENU );
228
  menuBar()->addMenu(viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
229
  menus_[tr("View")] = viewMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
230

231
232
  slotUpdateGlobalDrawMenu();
  viewMenu_->addMenu(globalDrawMenu_);
Jan Möbius's avatar
   
Jan Möbius committed
233

234
235
236
  //============================================================================================================
  // Rendering options Menu
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
237

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

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

251
252
253
254
255
256
257
258
259
  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_);

260
  // =====================
261

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

266
  //======================
Jan Möbius's avatar
   
Jan Möbius committed
267

268
  globalBackfaceCullingAction_ = renderingOptionsMenu->addAction(tr("Global Backface Culling"));
269
  globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
270
  connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalToggleBackFaceCulling() ) );
271
272
273

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

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

278
279
  //======================

280
281
282
283
284
285
286
287
288
  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
289

290
291
292
293
294
295
296
297
298
299
300
301
  //============================================================================================================
  // Global renderer menu
  //============================================================================================================

  slotUpdateRendererMenu();

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

  slotUpdatePostProcessorMenu();

302
303
304
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
305

306
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
307

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

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

  viewMenu_->addSeparator();

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

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


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

341
  QAction* viewAllAction = new QAction( tr("View all"), viewMenu_ );
342
343
  viewAllAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewall.png") );
  viewAllAction->setCheckable( false );
344
345
346
347
  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."));
348
349
  connect( viewAllAction,SIGNAL( triggered() ), this, SLOT( slotGlobalViewAll() ) );
  viewMenu_->addAction( viewAllAction);
Jan Möbius's avatar
   
Jan Möbius committed
350

Dirk Wilden's avatar
Dirk Wilden committed
351
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
352

353
  QAction* snapShotAction = new QAction( tr("Viewer Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
354
355
  snapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewerSnapshot.png") );
  snapShotAction->setCheckable( false );
356
357
358
  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
359
360
  connect( snapShotAction,SIGNAL( triggered() ), this, SLOT( viewerSnapshotDialog() ) );
  viewMenu_->addAction( snapShotAction);
Dirk Wilden's avatar
Dirk Wilden committed
361

362
  QAction* appSnapShotAction = new QAction( tr("Application Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
363
364
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
365
366
367
  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
368
369
370
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

Dirk Wilden's avatar
Dirk Wilden committed
371
372
  viewMenu_->addSeparator();

373
  QAction* wheelSwitchAction = new QAction( tr("Show / hide wheels"), viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
374
  wheelSwitchAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_wheels.png") );
375
  wheelSwitchAction->setCheckable( true );
376
377
378
379
  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
380
381
382
383
                                      
  if(OpenFlipperSettings().value("Core/Gui/glViewer/showControlWheels").toBool() ) 
    wheelSwitchAction->setChecked(true);

384
385
386
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

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

394
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
395

Jan Möbius's avatar
Jan Möbius committed
396
  QAction* setGlobalBackgroundColor = new QAction(tr("Set Background Color"), this);;
397
398
  setGlobalBackgroundColor->setToolTip(tr("Set Background Color for all viewers"));
  setGlobalBackgroundColor->setStatusTip(tr("Set Background Color for all viewers"));
399
  setGlobalBackgroundColor->setWhatsThis(tr("Set Background Color for all viewers"));
400
401
402
  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
403

404
405
406
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
407

Jan Möbius's avatar
Jan Möbius committed
408
  toolsMenu_ = new QMenu( TOOLSMENU );
409
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
410
  menus_[tr("Tools")] = toolsMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
411

412
  QAction* sceneGraphAction = new QAction( tr("Show SceneGraph ") ,toolsMenu_ );
413
414
  sceneGraphAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png") );
  sceneGraphAction->setCheckable( false );
415
416
417
418
  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>" ) );
419
420
421
  QObject::connect( sceneGraphAction, SIGNAL( triggered() ),
                    this,             SLOT( slotShowSceneGraphDialog() ) );
  toolsMenu_->addAction( sceneGraphAction);
Jan Möbius's avatar
   
Jan Möbius committed
422

423
424
  toolsMenu_->addSeparator();

425
  QAction* startVideoCaptureAction =  new QAction( tr("Start Video Capture ") ,toolsMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
426
427
  startVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"recordVideo.png") );
  startVideoCaptureAction->setCheckable( false );
428
429
  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
430
431
432
  toolsMenu_->addAction( startVideoCaptureAction );
  connect(startVideoCaptureAction, SIGNAL(triggered()), this, SLOT(startVideoCaptureDialog()) );

433
  QAction* stopVideoCaptureAction =  new QAction( tr("Stop Video Capture ") ,toolsMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
434
435
  stopVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"stopVideoCapture.png") );
  stopVideoCaptureAction->setCheckable( false );
436
437
  stopVideoCaptureAction->setToolTip( tr("Stop video capturing." ));
  stopVideoCaptureAction->setWhatsThis( tr("Stop Video capturing" ));
Dirk Wilden's avatar
Dirk Wilden committed
438
439
440

  toolsMenu_->addAction( stopVideoCaptureAction);
  connect(stopVideoCaptureAction, SIGNAL(triggered()), this, SIGNAL(stopVideoCapture()) );
Jan Möbius's avatar
Jan Möbius committed
441
442
443
444
445
446
447
448
449
450
  
  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);
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
  
  // ======================================================================
  // 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
  AC_ShowToolbox_ = new QAction(tr("Show Toolboxes"), this);
  AC_ShowToolbox_->setStatusTip(tr("Show or Hide the Toolbox Widget"));
  //   AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
  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( toggled( bool )), this, SLOT(showToolbox(bool)));
  windowMenu_->addAction(AC_ShowToolbox_);
  
480

Jan Möbius's avatar
 
Jan Möbius committed
481
482
483
  // ======================================================================
  // help Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
484
  helpMenu_ = new QMenu(tr("Help"));
Jan Möbius's avatar
 
Jan Möbius committed
485
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
486
  menus_[tr("Help")] = helpMenu_;
487

Jan Möbius's avatar
 
Jan Möbius committed
488
  //Open Help Browser
Jan Möbius's avatar
Jan Möbius committed
489
  QAction* AC_HelpBrowser = new QAction(tr("Help"), this);
490
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
491
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
492
  AC_HelpBrowser->setWhatsThis(tr("Open the <b>Help Browser</b>"));
493
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
 
Jan Möbius committed
494
  helpMenu_->addAction(AC_HelpBrowser);
495

Jan Möbius's avatar
 
Jan Möbius committed
496
497
498
  //Switch to whats this mode
  QAction* AC_Whats_this = QWhatsThis::createAction ( this );
  AC_Whats_this->setStatusTip(tr("Enter What's this Mode"));
499
  AC_Whats_this->setWhatsThis(tr("Get information about a specific Button/Widget/..."));
Jan Möbius's avatar
 
Jan Möbius committed
500
  helpMenu_->addAction(AC_Whats_this);
501

Jan Möbius's avatar
 
Jan Möbius committed
502
  helpMenu_->addSeparator();
503

Jan Möbius's avatar
 
Jan Möbius committed
504
  //About Action
Jan Möbius's avatar
Jan Möbius committed
505
  QAction* AC_About = new QAction(tr("About"), this);
Jan Möbius's avatar
 
Jan Möbius committed
506
  AC_About->setStatusTip(tr("About OpenFlipper"));
507
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
508
  AC_About->setWhatsThis(tr("This entry shows information about <b>OpenFlipper</b>"));
Jan Möbius's avatar
Jan Möbius committed
509
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
 
Jan Möbius committed
510
  helpMenu_->addAction(AC_About);
511

Jan Möbius's avatar
 
Jan Möbius committed
512
513
514
515
516
517
518
519
520
521
522
  // 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);
}

523

524
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
   
Jan Möbius committed
525

526
  uint enabledCount  = 0;
527

528
529
530
531
532
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).animation() )
      enabledCount++;
  }

533
  if ( enabledCount != 0 ) {
534
535
536
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setText(tr("Disable animation"));
537
  } else {
538
539
540
    globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setText(tr("Enable animation"));
541
  }
542

543
  //=============================================================================================================================
544

545
  enabledCount  = 0;
546

547
548
549
550
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
      enabledCount++;
  }
551

552
  if ( enabledCount != 0 ) {
553
554
555
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
556
  } else {
557
558
559
    globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Enable backface culling"));
560
561
562
  }

  //=============================================================================================================================
563

564
  enabledCount  = 0;
565

566
567
568
569
570
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
      enabledCount++;
  }

571
  if ( enabledCount != 0 ) {
572
573
574
    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"));
575
  } else {
576
577
578
    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"));
579
580
581
  }

  //=============================================================================================================================
582

583
  enabledCount  = 0;
584

585
586
587
588
589
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).multisampling() )
      enabledCount++;
  }

590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
  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"));
613
  } else {
614
615
616
    globalMipmappingAction_->setToolTip(tr("Enable mipmapping for all viewers"));
    globalMipmappingAction_->setStatusTip(tr("Enable mipmapping for all viewers"));
    globalMipmappingAction_->setText(tr("Enable mipmapping"));
617
  }
618

619
620
  //=============================================================================================================================
    
621
622
  int perspectiveCount = 0;
  int orthogonalCount = 0;
Jan Möbius's avatar
   
Jan Möbius committed
623

624
625
626
627
628
629
  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i ) {
    if ( examiner_widgets_[ i ]->projectionMode() == glViewer::PERSPECTIVE_PROJECTION )
      perspectiveCount++;
    else
      orthogonalCount++;
  }
630
631
  
  if ( perspectiveCount == PluginFunctions::viewers() )
632
633
634
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
635

636
  if ( orthogonalCount == PluginFunctions::viewers() )
637
638
639
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
640

641
642
}

643
644
645
646
647
void CoreWidget::slotUpdateRendererMenu() {

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

648
649
    QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();

650
    rendererMenu_ = new QMenu(tr("Global Renderer"),viewMenu_);
651
    rendererMenu_->setIcon(QIcon(iconPath+"renderers.png"));
652
653
    viewMenu_->addMenu(rendererMenu_);

654

655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
    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 ) {

718
719
    QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();

720
    postprocessorMenu_ = new QMenu(tr("Global Post Processor"),viewMenu_);
721
    postprocessorMenu_->setIcon(QIcon(iconPath+"postprocessors.png"));
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
772
773
774
775
776
777
    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
778
779
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
780

Jan Möbius's avatar
Jan Möbius committed
781
782
783
784
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
   
Jan Möbius committed
785

Jan Möbius's avatar
Jan Möbius committed
786
  }
Jan Möbius's avatar
   
Jan Möbius committed
787

Jan Möbius's avatar
Jan Möbius committed
788
789
790
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
   
Jan Möbius committed
791

Jan Möbius's avatar
Jan Möbius committed
792
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
   
Jan Möbius committed
793
794
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
795
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
796

Jan Möbius's avatar
Jan Möbius committed
797
798
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
799
    globalDrawMenu_  = new QMenu(tr("Set Global DrawMode"));
Jan Möbius's avatar
Jan Möbius committed
800
801
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
   
Jan Möbius committed
802

Jan Möbius's avatar
Jan Möbius committed
803
804
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
   
Jan Möbius committed
805
806

  // Collect available draw Modes
807
  // Single pass action, draw modes independent from multipass rendering
Jan Möbius's avatar
Jan Möbius committed
808
809
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
810
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
   
Jan Möbius committed
811

Jan Möbius's avatar
Jan Möbius committed
812
813
  // Get currently active drawModes (first viewer only )
  // TODO: create combination from all viewers!
Jan Möbius's avatar
Jan Möbius committed
814
815
  activeDrawModes_ = PluginFunctions::drawMode(0);
  for ( int i = 1 ; i < PluginFunctions::viewers(); ++i )
Jan Möbius's avatar
Jan Möbius committed
816
    activeDrawModes_ &= PluginFunctions::drawMode(i);
Jan Möbius's avatar
   
Jan Möbius committed
817

Jan Möbius's avatar
Jan Möbius committed
818
  // Convert to ids
Jan Möbius's avatar
Jan Möbius committed
819
820
  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
  availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes() ;
Jan Möbius's avatar
   
Jan Möbius committed
821

Jan Möbius's avatar
Jan Möbius committed
822
  globalDrawMenu_->clear();
Jan Möbius's avatar
   
Jan Möbius committed
823

Jan Möbius's avatar
Jan Möbius committed
824
825
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
Jan Möbius's avatar
Jan Möbius committed
826
827
    ACG::SceneGraph::DrawModes::DrawMode id    = availDrawModeIds[i];
    std::string  descr =  id.description();
Jan Möbius's avatar
Jan Möbius committed
828
829
830

    QAction * action = new QAction( descr.c_str(), drawGroup_ );
    action->setCheckable( true );
Jan Möbius's avatar
Jan Möbius committed
831
    action->setChecked( activeDrawModes_.containsAtomicDrawMode(id) );
Jan Möbius's avatar
Jan Möbius committed
832
833
834
835
836
837
  }

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

}

838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
void CoreWidget::slotGlobalRendererMenu(QAction * _action) {

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

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

}

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
858
void CoreWidget::slotGlobalDrawMenu(QAction * _action) {
Jan Möbius's avatar
   
Jan Möbius committed
859

Jan Möbius's avatar
Jan Möbius committed
860
861
862
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
Jan Möbius's avatar
Jan Möbius committed
863
864
865
  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
866
867
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
Jan Möbius's avatar
Jan Möbius committed
868
    QString descr = QString( ( availDrawModeIds[i].description() ).c_str() );
Jan Möbius's avatar
Jan Möbius committed
869
870
871
872
873
874

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

Jan Möbius's avatar
Jan Möbius committed
876
877
878
879
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
   
Jan Möbius committed
880

Jan Möbius's avatar
Jan Möbius committed
881
882
883
884
  PluginFunctions::setDrawMode( activeDrawModes_ );
  slotUpdateGlobalDrawMenu();
}

885

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