MenuBar.cc 24.8 KB
Newer Older
Jan Möbius's avatar
 
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  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.
15
//
Jan Möbius's avatar
 
Jan Möbius committed
16
17
18
19
//  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.
20
//
Jan Möbius's avatar
 
Jan Möbius committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================




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


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

// -------------------- mview
#include "CoreWidget.hh"
#include <OpenFlipper/common/GlobalOptions.hh>
Jan Möbius's avatar
Jan Möbius committed
47
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
Jan Möbius's avatar
 
Jan Möbius committed
48

49
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
50
51
52



Jan Möbius's avatar
   
Jan Möbius committed
53
void CoreWidget::slotAddMenubarAction( QAction* _action , MenuActionType _type ) {
54

Jan Möbius's avatar
 
Jan Möbius committed
55
  switch (_type) {
56
    case TOPLEVELMENU :
Jan Möbius's avatar
 
Jan Möbius committed
57
      // Add it to the menubar as a top level Menu
Jan Möbius's avatar
   
Jan Möbius committed
58
      menuBar()->insertAction(helpMenu_->menuAction() ,_action);
Jan Möbius's avatar
 
Jan Möbius committed
59
60
61
      break;
    case FILEMENU :
      fileMenu_->insertSeparator(fileMenuEnd_);
Jan Möbius's avatar
   
Jan Möbius committed
62
      fileMenu_->insertAction( fileMenuEnd_ , _action );
Jan Möbius's avatar
 
Jan Möbius committed
63
64
      break;
    case VIEWMENU :
Jan Möbius's avatar
   
Jan Möbius committed
65
      viewMenu_->addAction( _action );
66
      break;
Jan Möbius's avatar
   
Jan Möbius committed
67
68
    case TOOLSMENU:
      toolsMenu_->addAction( _action );
Jan Möbius's avatar
 
Jan Möbius committed
69
  }
70

Jan Möbius's avatar
 
Jan Möbius committed
71
72
73
74
75
76
77
78
79
80
81
82
83
}


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


void CoreWidget::setupMenuBar()
{
  // ======================================================================
  // File Menu
  // ======================================================================
  fileMenu_ = new QMenu(tr("&File"));
  menuBar()->addMenu(fileMenu_ );
Jan Möbius's avatar
   
Jan Möbius committed
84

Jan Möbius's avatar
 
Jan Möbius committed
85
86
87
88
  //Clear all
  QAction* AC_clear_all = new QAction(tr("&Clear All"), this);;
  AC_clear_all->setStatusTip(tr("Clear all Objects"));
  AC_clear_all->setWhatsThis("Close all open Objects");
89
  AC_clear_all->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-clear.png"));
Jan Möbius's avatar
 
Jan Möbius committed
90
91
  connect(AC_clear_all, SIGNAL(triggered()), this, SIGNAL(clearAll()));
  fileMenu_->addAction(AC_clear_all);
92

Jan Möbius's avatar
 
Jan Möbius committed
93
  fileMenu_->addSeparator();
94
95

  //Load object
Jan Möbius's avatar
 
Jan Möbius committed
96
  QAction* AC_Load = new QAction(tr("&Load Object"), this);
Dirk Wilden's avatar
Dirk Wilden committed
97
//   AC_Load->setShortcut (Qt::CTRL + Qt::Key_O);
Jan Möbius's avatar
 
Jan Möbius committed
98
99
  AC_Load->setStatusTip(tr("Load an object"));
  AC_Load->setWhatsThis("Load a new object");
100
  AC_Load->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open.png"));
101

Jan Möbius's avatar
 
Jan Möbius committed
102
103
  connect(AC_Load, SIGNAL(triggered()), this, SIGNAL(loadMenu()));
  fileMenu_->addAction(AC_Load);
104

Jan Möbius's avatar
 
Jan Möbius committed
105
106
107
108
  //Add empty object
  QAction* AC_AddEmpty = new QAction(tr("&Add Empty Object"), this);
  AC_AddEmpty->setStatusTip(tr("Add an empty object"));
  AC_AddEmpty->setWhatsThis("Creates a new empty object of a given type");
109
  AC_AddEmpty->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"add-empty-object.png"));
Jan Möbius's avatar
 
Jan Möbius committed
110
111
  connect(AC_AddEmpty, SIGNAL(triggered()), this, SIGNAL(addEmptyObjectMenu()));
  fileMenu_->addAction(AC_AddEmpty);
112

Jan Möbius's avatar
 
Jan Möbius committed
113
  fileMenu_->addSeparator();
114

Jan Möbius's avatar
 
Jan Möbius committed
115
116
  //Save object
  QAction* AC_Save = new QAction(tr("&Save Object"), this);
Dirk Wilden's avatar
Dirk Wilden committed
117
//   AC_Save->setShortcut (Qt::CTRL + Qt::Key_S);
Dirk Wilden's avatar
Dirk Wilden committed
118
  AC_Save->setStatusTip(tr("Save currently selected objects"));
Jan Möbius's avatar
 
Jan Möbius committed
119
  AC_Save->setWhatsThis("Saves all currently selected objects");
120
  AC_Save->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save.png"));
Jan Möbius's avatar
 
Jan Möbius committed
121
122
  connect(AC_Save, SIGNAL(triggered()), this, SIGNAL(saveMenu()));
  fileMenu_->addAction(AC_Save);
123

Jan Möbius's avatar
 
Jan Möbius committed
124
125
126
127
  //Save object to
  QAction* AC_Save_to = new QAction(tr("&Save Object To"), this);
  AC_Save_to->setStatusTip(tr("Save current Object(s) To"));
  AC_Save_to->setWhatsThis("Saves all currently selected objects under a new name");
128
  AC_Save_to->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save-as.png"));
Jan Möbius's avatar
 
Jan Möbius committed
129
130
  connect(AC_Save_to, SIGNAL(triggered()), this, SIGNAL(saveToMenu()));
  fileMenu_->addAction(AC_Save_to);
131

Jan Möbius's avatar
 
Jan Möbius committed
132
  fileMenu_->addSeparator();
133

Jan Möbius's avatar
 
Jan Möbius committed
134
135
136
137
  //Load ini
  QAction* AC_load_ini = new QAction(tr("&Load Settings"), this);
  AC_load_ini->setStatusTip(tr("Load Settings from INI file"));
  AC_load_ini->setWhatsThis("Load a previous settings from file (objects,colors,...)");
138
  AC_load_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"load-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
139
140
  connect(AC_load_ini, SIGNAL(triggered()), this, SIGNAL(loadIniMenu()));
  fileMenu_->addAction(AC_load_ini);
141

Jan Möbius's avatar
 
Jan Möbius committed
142
143
144
145
  //Save ini
  QAction* AC_save_ini = new QAction(tr("&Save Settings"), this);
  AC_save_ini->setStatusTip(tr("Save current settings to INI file"));
  AC_save_ini->setWhatsThis("Save settings to file (objects,colors,...)");
146
  AC_save_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"save-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
147
148
  connect(AC_save_ini, SIGNAL(triggered()), this, SIGNAL(saveIniMenu()));
  fileMenu_->addAction(AC_save_ini);
149
150
151
152
153
154
155

  fileMenu_->addSeparator();

  //Options
  QAction* AC_Options = new QAction(tr("&Options"), this);
  AC_Options->setStatusTip(tr("Edit OpenFlipper Options"));
  AC_Options->setWhatsThis("Edit OpenFlipper Options");
156
  AC_Options->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"options.png"));
157
158
  connect(AC_Options, SIGNAL(triggered()), this, SLOT(showOptionsWidget()));
  fileMenu_->addAction(AC_Options);
159
160

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

Jan Möbius's avatar
 
Jan Möbius committed
163
164
  //Recent files
  recentFilesMenu_ = new QMenu(tr("&Recent Files"));
165
  recentFilesMenu_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open-recent.png"));
Jan Möbius's avatar
 
Jan Möbius committed
166
167
168
  recentFilesMenu_->setWhatsThis("Open recent files");
  connect(recentFilesMenu_,SIGNAL(triggered(QAction*)),this,SIGNAL(recentOpen(QAction*)));
  fileMenu_->addMenu(recentFilesMenu_);
169

Jan Möbius's avatar
 
Jan Möbius committed
170
  fileMenu_->addSeparator();
171

Jan Möbius's avatar
 
Jan Möbius committed
172
173
174
175
176
  //Main Application exit menu entry
  QAction* AC_exit = new QAction(tr("&Exit"), this);;
  AC_exit->setShortcut (Qt::CTRL + Qt::Key_Q);
  AC_exit->setStatusTip(tr("Exit Application"));
  recentFilesMenu_->setWhatsThis("Close OpenFlipper");
177
  AC_exit->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"application-exit.png"));
Jan Möbius's avatar
 
Jan Möbius committed
178
179
180
  connect(AC_exit, SIGNAL(triggered()), this, SIGNAL(exit()));
  fileMenu_->addAction(AC_exit);

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

182
183
184
185
186
  // ======================================================================
  // View Menu
  // ======================================================================
  viewMenu_ = new QMenu(tr("&View"));
  menuBar()->addMenu(viewMenu_ );
Jan Möbius's avatar
   
Jan Möbius committed
187

188
189
  slotUpdateGlobalDrawMenu();
  viewMenu_->addMenu(globalDrawMenu_);
Jan Möbius's avatar
   
Jan Möbius committed
190

191
192
193
  //============================================================================================================
  // Rendering options Menu
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
194

195
196
197
  QMenu* renderingOptionsMenu = new QMenu("Rendering Options",viewMenu_);
  renderingOptionsMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"renderingOptions.png"));
  viewMenu_->addMenu(renderingOptionsMenu);
Jan Möbius's avatar
   
Jan Möbius committed
198

199
200
201
202
203
  orthogonalProjectionAction_ = new QAction( "Switch Viewers to Orthogonal Projection", renderingOptionsMenu );;
  orthogonalProjectionAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
  orthogonalProjectionAction_->setCheckable( false );
  orthogonalProjectionAction_->setToolTip(   "Switch to orthogonal projection mode.");
  orthogonalProjectionAction_->setWhatsThis( "Switch projection mode<br><br>"
Jan Möbius's avatar
   
Jan Möbius committed
204
      "Switch to <b>orthogonal</b> projection mode.");
205
206
  connect( orthogonalProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalOrthographicProjection() ) );
  renderingOptionsMenu->addAction( orthogonalProjectionAction_);
Jan Möbius's avatar
   
Jan Möbius committed
207

208
  QAction* animation = renderingOptionsMenu->addAction("Animation");
Jan Möbius's avatar
   
Jan Möbius committed
209

210
211
212
213
214
  uint enabledCount = 0;
  uint disabledCount = 0;
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).animation() )
      enabledCount++;
Jan Möbius's avatar
   
Jan Möbius committed
215
    else
216
217
      disabledCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
218

219
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
220
    animation->setChecked(Qt::PartiallyChecked);
221
222
223
224
  else if ( enabledCount == 4 )
    animation->setChecked( Qt::Checked );
  else
    animation->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
225

226
227
228
229
  animation->setToolTip("Animate rotation of objects");
  animation->setCheckable( true );
  animation->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") );
  connect(animation, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeAnimation(bool) ) );
Jan Möbius's avatar
   
Jan Möbius committed
230
231


232
  //======================
Jan Möbius's avatar
   
Jan Möbius committed
233

234
  QAction* backfaceCulling = renderingOptionsMenu->addAction("Backface Culling");
Jan Möbius's avatar
   
Jan Möbius committed
235

236
237
238
239
240
  enabledCount  = 0;
  disabledCount = 0;
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
      enabledCount++;
Jan Möbius's avatar
   
Jan Möbius committed
241
    else
242
243
      disabledCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
244

245
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
246
    backfaceCulling->setChecked(Qt::PartiallyChecked);
247
248
249
250
  else if ( enabledCount == 4 )
    backfaceCulling->setChecked( Qt::Checked );
  else
    backfaceCulling->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
251

252
253
254
255
256
257
258
259
  backfaceCulling->setToolTip("Enable backface culling");
  backfaceCulling->setCheckable( true );
  backfaceCulling->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
  connect(backfaceCulling, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) );

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

  QAction* twoSidedLighting = renderingOptionsMenu->addAction("Two-sided Lighting");
Jan Möbius's avatar
   
Jan Möbius committed
260

261
  enabledCount  = 0;
Jan Möbius's avatar
   
Jan Möbius committed
262
  disabledCount = 0;
263
264
265
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
      enabledCount++;
Jan Möbius's avatar
   
Jan Möbius committed
266
    else
267
268
      disabledCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
269

270
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
271
    twoSidedLighting->setChecked(Qt::PartiallyChecked);
272
273
274
275
  else if ( enabledCount == 4 )
    twoSidedLighting->setChecked( Qt::Checked );
  else
    twoSidedLighting->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
276

277
278
279
280
281
  twoSidedLighting->setToolTip("Enable two-sided lighting");
  twoSidedLighting->setCheckable( true );
  twoSidedLighting->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
  twoSidedLighting->setChecked( PluginFunctions::viewerProperties().twoSidedLighting() );
  connect(twoSidedLighting, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
Jan Möbius's avatar
   
Jan Möbius committed
282

283
284
285
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
286

287
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
288

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

291
292
293
  QAction* homeAction = new QAction("Restore Home View",viewMenu_);
  homeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"go-home.png") );
  homeAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
294
  homeAction->setStatusTip("Restore <b>home</b> view.");
295
296
297
298
  homeAction->setWhatsThis( "Restore home view<br><br>"
                            "Resets the view to the home view");
  viewMenu_->addAction( homeAction );
  connect( homeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalHomeView() ) );
Jan Möbius's avatar
   
Jan Möbius committed
299
300


301
302
303
  QAction* setHomeAction = new QAction( "Set Home View" , viewMenu_ );
  setHomeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"set-home.png") );
  setHomeAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
304
  setHomeAction->setStatusTip("Set <b>home</b> view");
305
306
307
308
  setHomeAction->setWhatsThis( "Store home view<br><br>"
                               "Stores the current view as the home view");
  viewMenu_->addAction( setHomeAction);
  connect( setHomeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalSetHomeView() ) );
Jan Möbius's avatar
   
Jan Möbius committed
309

310
311
312
  QAction* viewAllAction = new QAction( "View all", viewMenu_ );
  viewAllAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewall.png") );
  viewAllAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
313
  viewAllAction->setStatusTip("View all.");
314
315
316
317
318
  viewAllAction->setWhatsThis( "View all<br><br>"
                               "Move the objects in the scene so that"
                               " the whole scene is visible.");
  connect( viewAllAction,SIGNAL( triggered() ), this, SLOT( slotGlobalViewAll() ) );
  viewMenu_->addAction( viewAllAction);
Jan Möbius's avatar
   
Jan Möbius committed
319

Dirk Wilden's avatar
Dirk Wilden committed
320
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
321

Dirk Wilden's avatar
Dirk Wilden committed
322
323
324
  QAction* snapShotAction = new QAction( "Viewer Snapshot", viewMenu_ );
  snapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewerSnapshot.png") );
  snapShotAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
325
  snapShotAction->setStatusTip("Take a snapshot from all viewers.");
Dirk Wilden's avatar
Dirk Wilden committed
326
327
328
329
  snapShotAction->setWhatsThis( "Viewer Snapshot<br><br>"
                               "Take a snapshot of all viewers at once.");
  connect( snapShotAction,SIGNAL( triggered() ), this, SLOT( viewerSnapshotDialog() ) );
  viewMenu_->addAction( snapShotAction);
Dirk Wilden's avatar
Dirk Wilden committed
330

Dirk Wilden's avatar
Dirk Wilden committed
331
  QAction* appSnapShotAction = new QAction( "Application Snapshot", viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
332
333
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
334
  appSnapShotAction->setStatusTip("Take a snapshot from OpenFlipper.");
Dirk Wilden's avatar
Dirk Wilden committed
335
336
337
338
339
  appSnapShotAction->setWhatsThis( "Snapshot<br><br>"
                               "Take a snapshot from OpenFlipper.");
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

340
341
342
  perspectiveProjectionAction_ = new QAction( "Switch Viewers to Perspective Projection", viewMenu_ );;
  perspectiveProjectionAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"perspective.png") );
  perspectiveProjectionAction_->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
343
  perspectiveProjectionAction_->setStatusTip(   "Switch to perspective projection mode.");
344
345
346
347
  perspectiveProjectionAction_->setWhatsThis( "Switch projection mode<br><br>"
                                              "Switch to <b>perspective</b> projection mode.");
  connect( perspectiveProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalPerspectiveProjection() ) );
  viewMenu_->addAction( perspectiveProjectionAction_);
Jan Möbius's avatar
   
Jan Möbius committed
348

Dirk Wilden's avatar
Dirk Wilden committed
349
350
  viewMenu_->addSeparator();

351
352
353
354
355
356
  QAction* wheelSwitchAction = new QAction( "Show / hide wheels", viewMenu_ );
  wheelSwitchAction->setCheckable( true );
  wheelSwitchAction->setStatusTip("Show / hide navigation wheels in viewer widget.");
  wheelSwitchAction->setWhatsThis( "Show / hide navigation wheels in viewer widget.<br><br>"
                               " These wheels appear in the corners of the viewports. "
							   " Use wheels to rotate scene.");
357
358
359
  if(OpenFlipper::Options::showWheelsAtStartup()) {
	  wheelSwitchAction->setChecked(true);
  }
360
361
362
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

Dirk Wilden's avatar
Dirk Wilden committed
363
364
365
366
367
368
369
  QAction* coordSys = viewMenu_->addAction("Coordinate Systems");
  coordSys->setCheckable(true);
  coordSys->setChecked(true);
  coordSys->setStatusTip("Toggle visibility of the coordinate systems");
//   coordSys->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  connect(coordSys, SIGNAL(triggered(bool)), this, SLOT( slotCoordSysVisibility(bool) ) );

370
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
371

372
373
374
375
376
377
378
  QAction* setGlobalBackgroundColor = new QAction(tr("&Set Background Color"), this);;
  setGlobalBackgroundColor->setToolTip(tr("Set Background Color for all viewers"));
  setGlobalBackgroundColor->setStatusTip(tr("Set Background Color for all viewers"));
  setGlobalBackgroundColor->setWhatsThis("Set Background Color for all viewers");
  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
379

380
381
382
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
383

384
385
  toolsMenu_ = new QMenu(tr("&Tools"));
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
   
Jan Möbius committed
386

387
388
389
390
391
392
393
394
395
396
  QAction* sceneGraphAction = new QAction( "Show SceneGraph " ,toolsMenu_ );
  sceneGraphAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png") );
  sceneGraphAction->setCheckable( false );
  sceneGraphAction->setToolTip("Show scene graph viewer.");
  sceneGraphAction->setWhatsThis( "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>" );
  QObject::connect( sceneGraphAction, SIGNAL( triggered() ),
                    this,             SLOT( slotShowSceneGraphDialog() ) );
  toolsMenu_->addAction( sceneGraphAction);
Jan Möbius's avatar
   
Jan Möbius committed
397

398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
  toolsMenu_->addSeparator();

  startVideoCaptureAction_ =  new QAction( "Start Video Capture " ,toolsMenu_ );
  startVideoCaptureAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"recordVideo.png") );
  startVideoCaptureAction_->setCheckable( false );
  startVideoCaptureAction_->setToolTip( "Start video capturing." );
  startVideoCaptureAction_->setWhatsThis( "Start to capture a video sequence of the user actions");
  toolsMenu_->addAction( startVideoCaptureAction_ );

  stopVideoCaptureAction_ =  new QAction( "Stop Video Capture " ,toolsMenu_ );
  stopVideoCaptureAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"stopVideoCapture.png") );
  stopVideoCaptureAction_->setCheckable( false );
  stopVideoCaptureAction_->setToolTip( "Stop video capturing." );
  stopVideoCaptureAction_->setWhatsThis( "Stop Video capturing");

  toolsMenu_->addAction( stopVideoCaptureAction_);


Jan Möbius's avatar
 
Jan Möbius committed
416
417
418
419
420
  // ======================================================================
  // help Menu
  // ======================================================================
  helpMenu_ = new QMenu(tr("&Help"));
  menuBar()->addMenu(helpMenu_);
421

Jan Möbius's avatar
 
Jan Möbius committed
422
  //Open Help Browser
423
424
  QAction* AC_HelpBrowser = new QAction(tr("&Help"), this);
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
425
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
Jan Möbius's avatar
 
Jan Möbius committed
426
  AC_HelpBrowser->setWhatsThis("Open the <b>Help Browser</b>");
427
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
 
Jan Möbius committed
428
  helpMenu_->addAction(AC_HelpBrowser);
429

Jan Möbius's avatar
 
Jan Möbius committed
430
431
432
433
434
  //Switch to whats this mode
  QAction* AC_Whats_this = QWhatsThis::createAction ( this );
  AC_Whats_this->setStatusTip(tr("Enter What's this Mode"));
  AC_Whats_this->setWhatsThis("Get information about a specific Button/Widget/...");
  helpMenu_->addAction(AC_Whats_this);
435

Jan Möbius's avatar
 
Jan Möbius committed
436
  helpMenu_->addSeparator();
437

Dirk Wilden's avatar
Dirk Wilden committed
438
439
440
441
  //show plugins
  QAction* AC_Plugins = new QAction(tr("&Plugins"), this);
  AC_Plugins->setStatusTip(tr("Show loaded plugins"));
  AC_Plugins->setWhatsThis("Show loaded plugins");
442
  AC_Plugins->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"network-connect.png"));
Dirk Wilden's avatar
Dirk Wilden committed
443
444
445
446
447
  connect(AC_Plugins, SIGNAL(triggered()), this, SIGNAL(showPlugins()));
  helpMenu_->addAction(AC_Plugins);

  helpMenu_->addSeparator();

Jan Möbius's avatar
 
Jan Möbius committed
448
449
450
  //About Action
  QAction* AC_About = new QAction(tr("&About"), this);
  AC_About->setStatusTip(tr("About OpenFlipper"));
451
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
Jan Möbius's avatar
 
Jan Möbius committed
452
  AC_About->setWhatsThis("This entry shows information about <b>OpenFlipper</b>");
Jan Möbius's avatar
Jan Möbius committed
453
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
 
Jan Möbius committed
454
  helpMenu_->addAction(AC_About);
455

Jan Möbius's avatar
 
Jan Möbius committed
456
457
458
459
460
461
462
463
464
  // 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);
465

Jan Möbius's avatar
 
Jan Möbius committed
466
467
}

468
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
   
Jan Möbius committed
469

470
471
  uint perspectiveCount = 0;
  uint orthogonalCount = 0;
Jan Möbius's avatar
   
Jan Möbius committed
472

473
474
475
476
477
478
  for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i ) {
    if ( examiner_widgets_[ i ]->projectionMode() == glViewer::PERSPECTIVE_PROJECTION )
      perspectiveCount++;
    else
      orthogonalCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
479
480

  if ( perspectiveCount == 4 )
481
482
483
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
484

485
486
487
488
  if ( orthogonalCount == 4 )
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
489

490
491
}

Jan Möbius's avatar
Jan Möbius committed
492
493
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
494

Jan Möbius's avatar
Jan Möbius committed
495
496
497
498
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
   
Jan Möbius committed
499

Jan Möbius's avatar
Jan Möbius committed
500
  }
Jan Möbius's avatar
   
Jan Möbius committed
501

Jan Möbius's avatar
Jan Möbius committed
502
503
504
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
   
Jan Möbius committed
505

Jan Möbius's avatar
Jan Möbius committed
506
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
   
Jan Möbius committed
507
508
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
509
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
510

Jan Möbius's avatar
Jan Möbius committed
511
512
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
Jan Möbius's avatar
   
Jan Möbius committed
513
    globalDrawMenu_  = new QMenu("Set Global DrawMode");
Jan Möbius's avatar
Jan Möbius committed
514
515
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
   
Jan Möbius committed
516

Jan Möbius's avatar
Jan Möbius committed
517
518
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
   
Jan Möbius committed
519
520

  // Collect available draw Modes
Jan Möbius's avatar
Jan Möbius committed
521
522
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
523
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
   
Jan Möbius committed
524

Jan Möbius's avatar
Jan Möbius committed
525
526
527
528
529
  // Get currently active drawModes (first viewer only )
  // TODO: create combination from all viewers!
  activeDrawModes_ = INT_MAX;
  for ( int i = 0 ; i < PluginFunctions::viewers(); ++i )
    activeDrawModes_ &= PluginFunctions::drawMode(i);
Jan Möbius's avatar
   
Jan Möbius committed
530

Jan Möbius's avatar
Jan Möbius committed
531
532
  // Convert to ids
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
533
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
   
Jan Möbius committed
534

Jan Möbius's avatar
Jan Möbius committed
535
  globalDrawMenu_->clear();
Jan Möbius's avatar
   
Jan Möbius committed
536

Jan Möbius's avatar
Jan Möbius committed
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
    unsigned int id    = availDrawModeIds[i];
    std::string  descr = ACG::SceneGraph::DrawModes::description( id );

    QAction * action = new QAction( descr.c_str(), drawGroup_ );
    action->setCheckable( true );
    action->setChecked( ACG::SceneGraph::DrawModes::containsId( activeDrawModes_, id ) );
  }

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

}

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

Jan Möbius's avatar
Jan Möbius committed
553
554
555
556
557
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
  unsigned int mode = 0;
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
558
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
Jan Möbius committed
559
560
561
562
563
564
565
566
567
  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
  {
    QString descr = QString( ACG::SceneGraph::DrawModes::description( availDrawModeIds[i] ).c_str() );

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

Jan Möbius's avatar
Jan Möbius committed
569
570
571
572
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
   
Jan Möbius committed
573

Jan Möbius's avatar
Jan Möbius committed
574
575
576
577
  PluginFunctions::setDrawMode( activeDrawModes_ );
  slotUpdateGlobalDrawMenu();
}

578

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