MenuBar.cc 30.6 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
54
55
56
57
58
59
60
61
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
62
  }
Jan Möbius's avatar
Jan Möbius committed
63
64
65
  else
    menus_[_name]->addAction (_action);
}
66

Jan Möbius's avatar
Jan Möbius committed
67
68
69
70
71
72
73
74
75
76
77
78
79
//=============================================================================

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
80
81
82
83
}


//=============================================================================
Jan Möbius's avatar
   
Jan Möbius committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
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
104
105
106

void CoreWidget::setupMenuBar()
{
Jan Möbius's avatar
   
Jan Möbius committed
107
108
109

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

Jan Möbius's avatar
 
Jan Möbius committed
110
111
112
113
114
  // ======================================================================
  // File Menu
  // ======================================================================
  fileMenu_ = new QMenu(tr("&File"));
  menuBar()->addMenu(fileMenu_ );
Jan Möbius's avatar
Jan Möbius committed
115
  menus_[tr("&File")] = fileMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
116

Jan Möbius's avatar
 
Jan Möbius committed
117
118
119
120
  //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");
121
  AC_clear_all->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-clear.png"));
Jan Möbius's avatar
 
Jan Möbius committed
122
123
  connect(AC_clear_all, SIGNAL(triggered()), this, SIGNAL(clearAll()));
  fileMenu_->addAction(AC_clear_all);
124

Jan Möbius's avatar
 
Jan Möbius committed
125
  fileMenu_->addSeparator();
126
127

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

Jan Möbius's avatar
 
Jan Möbius committed
134
135
  connect(AC_Load, SIGNAL(triggered()), this, SIGNAL(loadMenu()));
  fileMenu_->addAction(AC_Load);
136

Jan Möbius's avatar
 
Jan Möbius committed
137
138
139
140
  //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");
141
  AC_AddEmpty->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"add-empty-object.png"));
Jan Möbius's avatar
 
Jan Möbius committed
142
143
  connect(AC_AddEmpty, SIGNAL(triggered()), this, SIGNAL(addEmptyObjectMenu()));
  fileMenu_->addAction(AC_AddEmpty);
144

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

Jan Möbius's avatar
 
Jan Möbius committed
147
148
  //Save object
  QAction* AC_Save = new QAction(tr("&Save Object"), this);
Dirk Wilden's avatar
Dirk Wilden committed
149
//   AC_Save->setShortcut (Qt::CTRL + Qt::Key_S);
Dirk Wilden's avatar
Dirk Wilden committed
150
  AC_Save->setStatusTip(tr("Save currently selected objects"));
Jan Möbius's avatar
 
Jan Möbius committed
151
  AC_Save->setWhatsThis("Saves all currently selected objects");
152
  AC_Save->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save.png"));
Jan Möbius's avatar
 
Jan Möbius committed
153
154
  connect(AC_Save, SIGNAL(triggered()), this, SIGNAL(saveMenu()));
  fileMenu_->addAction(AC_Save);
155

Jan Möbius's avatar
 
Jan Möbius committed
156
157
158
159
  //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");
160
  AC_Save_to->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save-as.png"));
Jan Möbius's avatar
 
Jan Möbius committed
161
162
  connect(AC_Save_to, SIGNAL(triggered()), this, SIGNAL(saveToMenu()));
  fileMenu_->addAction(AC_Save_to);
163

Jan Möbius's avatar
 
Jan Möbius committed
164
  fileMenu_->addSeparator();
165

Jan Möbius's avatar
 
Jan Möbius committed
166
167
168
169
  //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,...)");
170
  AC_load_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"load-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
171
172
  connect(AC_load_ini, SIGNAL(triggered()), this, SIGNAL(loadIniMenu()));
  fileMenu_->addAction(AC_load_ini);
173

Jan Möbius's avatar
 
Jan Möbius committed
174
175
176
177
  //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,...)");
178
  AC_save_ini->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"save-settings.png"));
Jan Möbius's avatar
 
Jan Möbius committed
179
180
  connect(AC_save_ini, SIGNAL(triggered()), this, SIGNAL(saveIniMenu()));
  fileMenu_->addAction(AC_save_ini);
181
182
183
184
185
186
187

  fileMenu_->addSeparator();

  //Options
  QAction* AC_Options = new QAction(tr("&Options"), this);
  AC_Options->setStatusTip(tr("Edit OpenFlipper Options"));
  AC_Options->setWhatsThis("Edit OpenFlipper Options");
188
  AC_Options->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"options.png"));
189
190
  connect(AC_Options, SIGNAL(triggered()), this, SLOT(showOptionsWidget()));
  fileMenu_->addAction(AC_Options);
191
192

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

Jan Möbius's avatar
 
Jan Möbius committed
195
196
  //Recent files
  recentFilesMenu_ = new QMenu(tr("&Recent Files"));
197
  recentFilesMenu_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-open-recent.png"));
Jan Möbius's avatar
 
Jan Möbius committed
198
199
200
  recentFilesMenu_->setWhatsThis("Open recent files");
  connect(recentFilesMenu_,SIGNAL(triggered(QAction*)),this,SIGNAL(recentOpen(QAction*)));
  fileMenu_->addMenu(recentFilesMenu_);
201

Jan Möbius's avatar
 
Jan Möbius committed
202
  fileMenu_->addSeparator();
203

Jan Möbius's avatar
 
Jan Möbius committed
204
205
206
207
208
  //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");
209
  AC_exit->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"application-exit.png"));
Jan Möbius's avatar
 
Jan Möbius committed
210
211
212
  connect(AC_exit, SIGNAL(triggered()), this, SIGNAL(exit()));
  fileMenu_->addAction(AC_exit);

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

214
215
216
217
218
  // ======================================================================
  // View Menu
  // ======================================================================
  viewMenu_ = new QMenu(tr("&View"));
  menuBar()->addMenu(viewMenu_ );
Jan Möbius's avatar
Jan Möbius committed
219
  menus_[tr("&View")] = viewMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
220

221
222
  slotUpdateGlobalDrawMenu();
  viewMenu_->addMenu(globalDrawMenu_);
Jan Möbius's avatar
   
Jan Möbius committed
223

224
225
226
  //============================================================================================================
  // Rendering options Menu
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
227

228
229
230
  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
231

232
233
234
235
236
  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
237
      "Switch to <b>orthogonal</b> projection mode.");
238
239
  connect( orthogonalProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalOrthographicProjection() ) );
  renderingOptionsMenu->addAction( orthogonalProjectionAction_);
Jan Möbius's avatar
   
Jan Möbius committed
240

241
242
243
244
245
246
  // =====================
  
  globalAnimationAction_ = renderingOptionsMenu->addAction("Animation");
  globalAnimationAction_->setCheckable( true );
  globalAnimationAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") );
  connect(globalAnimationAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeAnimation(bool) ) );
Jan Möbius's avatar
   
Jan Möbius committed
247

248
  //======================
Jan Möbius's avatar
   
Jan Möbius committed
249

250
251
252
253
  globalBackfaceCullingAction_ = renderingOptionsMenu->addAction("Backface Culling");
  globalBackfaceCullingAction_->setCheckable( true );  
  globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
  connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) );
254
255
256

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

257
258
259
260
  globalTwosidedLightingAction_ = renderingOptionsMenu->addAction("Two-sided Lighting");
  globalTwosidedLightingAction_->setCheckable( true );
  globalTwosidedLightingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
  connect(globalTwosidedLightingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
261
262
263
  
  //======================

264
265
  globalMultisamplingAction_ = renderingOptionsMenu->addAction("Multisampling");
  globalMultisamplingAction_->setCheckable( true );
266
// TODO:Icon for multisampling  
267
268
//   globalMultisamplingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
  connect(globalMultisamplingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) );  
Jan Möbius's avatar
   
Jan Möbius committed
269

270
271
272
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
273

274
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
275

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

278
279
280
  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
281
  homeAction->setStatusTip("Restore <b>home</b> view.");
282
283
284
285
  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
286
287


288
289
290
  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
291
  setHomeAction->setStatusTip("Set <b>home</b> view");
292
293
294
295
  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
296

297
298
299
  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
300
  viewAllAction->setStatusTip("View all.");
301
302
303
304
305
  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
306

Dirk Wilden's avatar
Dirk Wilden committed
307
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
308

Dirk Wilden's avatar
Dirk Wilden committed
309
310
311
  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
312
  snapShotAction->setStatusTip("Take a snapshot from all viewers.");
Dirk Wilden's avatar
Dirk Wilden committed
313
314
315
316
  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
317

Dirk Wilden's avatar
Dirk Wilden committed
318
  QAction* appSnapShotAction = new QAction( "Application Snapshot", viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
319
320
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
321
  appSnapShotAction->setStatusTip("Take a snapshot from OpenFlipper.");
Dirk Wilden's avatar
Dirk Wilden committed
322
323
324
325
326
  appSnapShotAction->setWhatsThis( "Snapshot<br><br>"
                               "Take a snapshot from OpenFlipper.");
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

327
328
329
  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
330
  perspectiveProjectionAction_->setStatusTip(   "Switch to perspective projection mode.");
331
332
333
334
  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
335

Dirk Wilden's avatar
Dirk Wilden committed
336
337
  viewMenu_->addSeparator();

338
339
340
341
342
  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. "
343
							   " Use wheels to rotate and scale scene.");
344
345
346
  if(OpenFlipper::Options::showWheelsAtStartup()) {
	  wheelSwitchAction->setChecked(true);
  }
347
348
349
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

Dirk Wilden's avatar
Dirk Wilden committed
350
351
352
353
  QAction* coordSys = viewMenu_->addAction("Coordinate Systems");
  coordSys->setCheckable(true);
  coordSys->setChecked(true);
  coordSys->setStatusTip("Toggle visibility of the coordinate systems");
354
  coordSys->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"coordsys.png") );
Dirk Wilden's avatar
Dirk Wilden committed
355
356
  connect(coordSys, SIGNAL(triggered(bool)), this, SLOT( slotCoordSysVisibility(bool) ) );

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

359
360
361
362
363
364
365
  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
366

367
368
369
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
370

371
372
  toolsMenu_ = new QMenu(tr("&Tools"));
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
373
  menus_[tr("&Tools")] = toolsMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
374

375
376
377
378
379
380
381
382
383
384
  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
385

386
387
  toolsMenu_->addSeparator();

Dirk Wilden's avatar
Dirk Wilden committed
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
  QAction* 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 );
  connect(startVideoCaptureAction, SIGNAL(triggered()), this, SLOT(startVideoCaptureDialog()) );

  QAction* 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);
  connect(stopVideoCaptureAction, SIGNAL(triggered()), this, SIGNAL(stopVideoCapture()) );
404

Jan Möbius's avatar
 
Jan Möbius committed
405
406
407
408
409
  // ======================================================================
  // help Menu
  // ======================================================================
  helpMenu_ = new QMenu(tr("&Help"));
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
410
  menus_[tr("&Help")] = helpMenu_;
411

Jan Möbius's avatar
 
Jan Möbius committed
412
  //Open Help Browser
413
414
  QAction* AC_HelpBrowser = new QAction(tr("&Help"), this);
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
415
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
Jan Möbius's avatar
 
Jan Möbius committed
416
  AC_HelpBrowser->setWhatsThis("Open the <b>Help Browser</b>");
417
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
 
Jan Möbius committed
418
  helpMenu_->addAction(AC_HelpBrowser);
419

Jan Möbius's avatar
 
Jan Möbius committed
420
421
422
423
424
  //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);
425

Jan Möbius's avatar
 
Jan Möbius committed
426
  helpMenu_->addSeparator();
427

Dirk Wilden's avatar
Dirk Wilden committed
428
429
430
431
  //show plugins
  QAction* AC_Plugins = new QAction(tr("&Plugins"), this);
  AC_Plugins->setStatusTip(tr("Show loaded plugins"));
  AC_Plugins->setWhatsThis("Show loaded plugins");
432
  AC_Plugins->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"network-connect.png"));
Dirk Wilden's avatar
Dirk Wilden committed
433
434
435
436
437
  connect(AC_Plugins, SIGNAL(triggered()), this, SIGNAL(showPlugins()));
  helpMenu_->addAction(AC_Plugins);

  helpMenu_->addSeparator();

Jan Möbius's avatar
 
Jan Möbius committed
438
439
440
  //About Action
  QAction* AC_About = new QAction(tr("&About"), this);
  AC_About->setStatusTip(tr("About OpenFlipper"));
441
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
Jan Möbius's avatar
 
Jan Möbius committed
442
  AC_About->setWhatsThis("This entry shows information about <b>OpenFlipper</b>");
Jan Möbius's avatar
Jan Möbius committed
443
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
 
Jan Möbius committed
444
  helpMenu_->addAction(AC_About);
445

Jan Möbius's avatar
 
Jan Möbius committed
446
447
448
449
450
451
452
453
454
455
456
  // 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);
}

457

458
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
   
Jan Möbius committed
459

460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
  uint enabledCount  = 0;
  uint disabledCount = 0;
  
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).animation() )
      enabledCount++;
    else
      disabledCount++;
  }

  if ( enabledCount != 0 && disabledCount != 0 ) {
    globalAnimationAction_->setChecked(Qt::PartiallyChecked);
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));  
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));  
    globalAnimationAction_->setText(tr("Disable animation"));  
  } else if ( enabledCount == 4 ) {
    globalAnimationAction_->setChecked( Qt::Checked );
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));  
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));  
    globalAnimationAction_->setText(tr("Disable animation"));  
  } else {
    globalAnimationAction_->setChecked( Qt::Unchecked );
    globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));  
    globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));  
    globalAnimationAction_->setText(tr("Enable animation"));  
  }
  
  //=============================================================================================================================
  
  enabledCount  = 0;
  disabledCount = 0;  
  
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
      enabledCount++;
    else
      disabledCount++;
  }
  
  if ( enabledCount != 0 && disabledCount != 0 ) {
    globalBackfaceCullingAction_->setChecked(Qt::PartiallyChecked);
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));  
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));  
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));  
  } else if ( enabledCount == 4 ) {
    globalBackfaceCullingAction_->setChecked( Qt::Checked );
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));  
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));  
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));  
  } else {
    globalBackfaceCullingAction_->setChecked( Qt::Unchecked );
    globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));  
    globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));  
    globalBackfaceCullingAction_->setText(tr("Enable backface culling"));  
  }

  //=============================================================================================================================
  
  enabledCount  = 0;
  disabledCount = 0;
  
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
      enabledCount++;
    else
      disabledCount++;
  }

  if ( enabledCount != 0 && disabledCount != 0 ) {
    globalTwosidedLightingAction_->setChecked(Qt::PartiallyChecked);
    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"));  
  } else if ( enabledCount == 4 ) {
    globalTwosidedLightingAction_->setChecked( Qt::Checked );
    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"));  
  } else {
    globalTwosidedLightingAction_->setChecked( Qt::Unchecked );
    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"));      
  }

  //=============================================================================================================================
  
  enabledCount  = 0;
  disabledCount = 0;
  
  
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).multisampling() )
      enabledCount++;
    else
      disabledCount++;
  }

  if ( enabledCount != 0 && disabledCount != 0 ) {
    globalMultisamplingAction_->setChecked(Qt::PartiallyChecked);
    globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));  
    globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));  
    globalMultisamplingAction_->setText(tr("Disable Multisampling"));
  } else if ( enabledCount == 4 ) {
    globalMultisamplingAction_->setChecked( Qt::Checked );
    globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));      
    globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));      
    globalMultisamplingAction_->setText(tr("Disable Multisampling"));
  } else {
    globalMultisamplingAction_->setChecked( Qt::Unchecked );
    globalMultisamplingAction_->setToolTip(tr("Enable Multisampling for all viewers"));  
    globalMultisamplingAction_->setStatusTip(tr("Enable Multisampling for all viewers"));  
    globalMultisamplingAction_->setText(tr("&Enable Multisampling"));
  }
  
575
576
  uint perspectiveCount = 0;
  uint orthogonalCount = 0;
Jan Möbius's avatar
   
Jan Möbius committed
577

578
579
580
581
582
583
  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
584
585

  if ( perspectiveCount == 4 )
586
587
588
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
589

590
591
592
593
  if ( orthogonalCount == 4 )
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
594

595
596
}

Jan Möbius's avatar
Jan Möbius committed
597
598
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
599

Jan Möbius's avatar
Jan Möbius committed
600
601
602
603
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
   
Jan Möbius committed
604

Jan Möbius's avatar
Jan Möbius committed
605
  }
Jan Möbius's avatar
   
Jan Möbius committed
606

Jan Möbius's avatar
Jan Möbius committed
607
608
609
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
   
Jan Möbius committed
610

Jan Möbius's avatar
Jan Möbius committed
611
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
   
Jan Möbius committed
612
613
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
614
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
615

Jan Möbius's avatar
Jan Möbius committed
616
617
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
Jan Möbius's avatar
   
Jan Möbius committed
618
    globalDrawMenu_  = new QMenu("Set Global DrawMode");
Jan Möbius's avatar
Jan Möbius committed
619
620
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
   
Jan Möbius committed
621

Jan Möbius's avatar
Jan Möbius committed
622
623
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
   
Jan Möbius committed
624
625

  // Collect available draw Modes
Jan Möbius's avatar
Jan Möbius committed
626
627
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
628
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
   
Jan Möbius committed
629

Jan Möbius's avatar
Jan Möbius committed
630
631
632
633
634
  // 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
635

Jan Möbius's avatar
Jan Möbius committed
636
637
  // Convert to ids
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
638
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
   
Jan Möbius committed
639

Jan Möbius's avatar
Jan Möbius committed
640
  globalDrawMenu_->clear();
Jan Möbius's avatar
   
Jan Möbius committed
641

Jan Möbius's avatar
Jan Möbius committed
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
  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
657

Jan Möbius's avatar
Jan Möbius committed
658
659
660
661
662
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
  unsigned int mode = 0;
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
663
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
Jan Möbius committed
664
665
666
667
668
669
670
671
672
  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
673

Jan Möbius's avatar
Jan Möbius committed
674
675
676
677
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
   
Jan Möbius committed
678

Jan Möbius's avatar
Jan Möbius committed
679
680
681
682
  PluginFunctions::setDrawMode( activeDrawModes_ );
  slotUpdateGlobalDrawMenu();
}

683

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