MenuBar.cc 27 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
  QAction* animation = renderingOptionsMenu->addAction("Animation");
Jan Möbius's avatar
   
Jan Möbius committed
242

243
244
245
246
247
  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
248
    else
249
250
      disabledCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
251

252
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
253
    animation->setChecked(Qt::PartiallyChecked);
254
255
256
257
  else if ( enabledCount == 4 )
    animation->setChecked( Qt::Checked );
  else
    animation->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
258

259
260
261
262
  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
263
264


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

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

269
270
271
272
273
  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
274
    else
275
276
      disabledCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
277

278
  backfaceCulling->setCheckable( true );  
279
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
280
    backfaceCulling->setChecked(Qt::PartiallyChecked);
281
282
283
284
  else if ( enabledCount == 4 )
    backfaceCulling->setChecked( Qt::Checked );
  else
    backfaceCulling->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
285

286
287
288
289
290
291
292
  backfaceCulling->setToolTip("Enable backface culling");
  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
293

294
  enabledCount  = 0;
Jan Möbius's avatar
   
Jan Möbius committed
295
  disabledCount = 0;
296
297
298
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
      enabledCount++;
Jan Möbius's avatar
   
Jan Möbius committed
299
    else
300
301
      disabledCount++;
  }
Jan Möbius's avatar
   
Jan Möbius committed
302

303
  twoSidedLighting->setCheckable( true );
304
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
305
    twoSidedLighting->setChecked(Qt::PartiallyChecked);
306
307
308
309
  else if ( enabledCount == 4 )
    twoSidedLighting->setChecked( Qt::Checked );
  else
    twoSidedLighting->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
310

311
312
313
  twoSidedLighting->setToolTip("Enable two-sided lighting");
  twoSidedLighting->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
  connect(twoSidedLighting, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
  
  //======================

  QAction* multisampling = renderingOptionsMenu->addAction("Multisampling");

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

  multisampling->setCheckable( true );
  if ( enabledCount != 0 && disabledCount != 0 )
    multisampling->setChecked(Qt::PartiallyChecked);
  else if ( enabledCount == 4 )
    multisampling->setChecked( Qt::Checked );
  else
    multisampling->setChecked( Qt::Unchecked );

  multisampling->setToolTip("Enable Multisampling");
// TODO:Icon for multisampling  
//   multisampling->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
  connect(multisampling, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) );  
Jan Möbius's avatar
   
Jan Möbius committed
340

341
342
343
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
344

345
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
346

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

349
350
351
  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
352
  homeAction->setStatusTip("Restore <b>home</b> view.");
353
354
355
356
  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
357
358


359
360
361
  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
362
  setHomeAction->setStatusTip("Set <b>home</b> view");
363
364
365
366
  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
367

368
369
370
  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
371
  viewAllAction->setStatusTip("View all.");
372
373
374
375
376
  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
377

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

Dirk Wilden's avatar
Dirk Wilden committed
380
381
382
  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
383
  snapShotAction->setStatusTip("Take a snapshot from all viewers.");
Dirk Wilden's avatar
Dirk Wilden committed
384
385
386
387
  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
388

Dirk Wilden's avatar
Dirk Wilden committed
389
  QAction* appSnapShotAction = new QAction( "Application Snapshot", viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
390
391
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
392
  appSnapShotAction->setStatusTip("Take a snapshot from OpenFlipper.");
Dirk Wilden's avatar
Dirk Wilden committed
393
394
395
396
397
  appSnapShotAction->setWhatsThis( "Snapshot<br><br>"
                               "Take a snapshot from OpenFlipper.");
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

398
399
400
  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
401
  perspectiveProjectionAction_->setStatusTip(   "Switch to perspective projection mode.");
402
403
404
405
  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
406

Dirk Wilden's avatar
Dirk Wilden committed
407
408
  viewMenu_->addSeparator();

409
410
411
412
413
  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. "
414
							   " Use wheels to rotate and scale scene.");
415
416
417
  if(OpenFlipper::Options::showWheelsAtStartup()) {
	  wheelSwitchAction->setChecked(true);
  }
418
419
420
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

Dirk Wilden's avatar
Dirk Wilden committed
421
422
423
424
425
426
427
  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) ) );

428
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
429

430
431
432
433
434
435
436
  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
437

438
439
440
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
441

442
443
  toolsMenu_ = new QMenu(tr("&Tools"));
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
444
  menus_[tr("&Tools")] = toolsMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
445

446
447
448
449
450
451
452
453
454
455
  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
456

457
458
  toolsMenu_->addSeparator();

Dirk Wilden's avatar
Dirk Wilden committed
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
  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()) );
475

Jan Möbius's avatar
   
Jan Möbius committed
476
477
478
479
480
  // ======================================================================
  // help Menu
  // ======================================================================
  helpMenu_ = new QMenu(tr("&Help"));
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
481
  menus_[tr("&Help")] = helpMenu_;
482

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

Jan Möbius's avatar
   
Jan Möbius committed
491
492
493
494
495
  //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);
496

Jan Möbius's avatar
   
Jan Möbius committed
497
  helpMenu_->addSeparator();
498

Dirk Wilden's avatar
Dirk Wilden committed
499
500
501
502
  //show plugins
  QAction* AC_Plugins = new QAction(tr("&Plugins"), this);
  AC_Plugins->setStatusTip(tr("Show loaded plugins"));
  AC_Plugins->setWhatsThis("Show loaded plugins");
503
  AC_Plugins->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"network-connect.png"));
Dirk Wilden's avatar
Dirk Wilden committed
504
505
506
507
508
  connect(AC_Plugins, SIGNAL(triggered()), this, SIGNAL(showPlugins()));
  helpMenu_->addAction(AC_Plugins);

  helpMenu_->addSeparator();

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

Jan Möbius's avatar
   
Jan Möbius committed
517
518
519
520
521
522
523
524
525
  // 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);
526

Jan Möbius's avatar
   
Jan Möbius committed
527
528
}

529
530
531
532
void CoreWidget::slotUpdateMenuBar() {
  
}

533
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
   
Jan Möbius committed
534

535
536
  uint perspectiveCount = 0;
  uint orthogonalCount = 0;
Jan Möbius's avatar
   
Jan Möbius committed
537

538
539
540
541
542
543
  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
544
545

  if ( perspectiveCount == 4 )
546
547
548
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
549

550
551
552
553
  if ( orthogonalCount == 4 )
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
554

555
556
}

Jan Möbius's avatar
Jan Möbius committed
557
558
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
559

Jan Möbius's avatar
Jan Möbius committed
560
561
562
563
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
   
Jan Möbius committed
564

Jan Möbius's avatar
Jan Möbius committed
565
  }
Jan Möbius's avatar
   
Jan Möbius committed
566

Jan Möbius's avatar
Jan Möbius committed
567
568
569
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
   
Jan Möbius committed
570

Jan Möbius's avatar
Jan Möbius committed
571
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
   
Jan Möbius committed
572
573
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
574
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
575

Jan Möbius's avatar
Jan Möbius committed
576
577
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
Jan Möbius's avatar
   
Jan Möbius committed
578
    globalDrawMenu_  = new QMenu("Set Global DrawMode");
Jan Möbius's avatar
Jan Möbius committed
579
580
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
   
Jan Möbius committed
581

Jan Möbius's avatar
Jan Möbius committed
582
583
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
   
Jan Möbius committed
584
585

  // Collect available draw Modes
Jan Möbius's avatar
Jan Möbius committed
586
587
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
588
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
   
Jan Möbius committed
589

Jan Möbius's avatar
Jan Möbius committed
590
591
592
593
594
  // 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
595

Jan Möbius's avatar
Jan Möbius committed
596
597
  // Convert to ids
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
598
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
   
Jan Möbius committed
599

Jan Möbius's avatar
Jan Möbius committed
600
  globalDrawMenu_->clear();
Jan Möbius's avatar
   
Jan Möbius committed
601

Jan Möbius's avatar
Jan Möbius committed
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
  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
617

Jan Möbius's avatar
Jan Möbius committed
618
619
620
621
622
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
  unsigned int mode = 0;
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
623
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
Jan Möbius committed
624
625
626
627
628
629
630
631
632
  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
633

Jan Möbius's avatar
Jan Möbius committed
634
635
636
637
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
   
Jan Möbius committed
638

Jan Möbius's avatar
Jan Möbius committed
639
640
641
642
  PluginFunctions::setDrawMode( activeDrawModes_ );
  slotUpdateGlobalDrawMenu();
}

643

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