MenuBar.cc 26.1 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
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
279
    backfaceCulling->setChecked(Qt::PartiallyChecked);
280
281
282
283
  else if ( enabledCount == 4 )
    backfaceCulling->setChecked( Qt::Checked );
  else
    backfaceCulling->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
284

285
286
287
288
289
290
291
292
  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
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
  if ( enabledCount != 0 && disabledCount != 0 )
Jan Möbius's avatar
   
Jan Möbius committed
304
    twoSidedLighting->setChecked(Qt::PartiallyChecked);
305
306
307
308
  else if ( enabledCount == 4 )
    twoSidedLighting->setChecked( Qt::Checked );
  else
    twoSidedLighting->setChecked( Qt::Unchecked );
Jan Möbius's avatar
   
Jan Möbius committed
309

310
311
312
313
314
  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
315

316
317
318
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
319

320
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
321

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

324
325
326
  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
327
  homeAction->setStatusTip("Restore <b>home</b> view.");
328
329
330
331
  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
332
333


334
335
336
  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
337
  setHomeAction->setStatusTip("Set <b>home</b> view");
338
339
340
341
  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
342

343
344
345
  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
346
  viewAllAction->setStatusTip("View all.");
347
348
349
350
351
  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
352

Dirk Wilden's avatar
Dirk Wilden committed
353
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
354

Dirk Wilden's avatar
Dirk Wilden committed
355
356
357
  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
358
  snapShotAction->setStatusTip("Take a snapshot from all viewers.");
Dirk Wilden's avatar
Dirk Wilden committed
359
360
361
362
  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
363

Dirk Wilden's avatar
Dirk Wilden committed
364
  QAction* appSnapShotAction = new QAction( "Application Snapshot", viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
365
366
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
Dirk Wilden's avatar
Dirk Wilden committed
367
  appSnapShotAction->setStatusTip("Take a snapshot from OpenFlipper.");
Dirk Wilden's avatar
Dirk Wilden committed
368
369
370
371
372
  appSnapShotAction->setWhatsThis( "Snapshot<br><br>"
                               "Take a snapshot from OpenFlipper.");
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

373
374
375
  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
376
  perspectiveProjectionAction_->setStatusTip(   "Switch to perspective projection mode.");
377
378
379
380
  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
381

Dirk Wilden's avatar
Dirk Wilden committed
382
383
  viewMenu_->addSeparator();

384
385
386
387
388
  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. "
389
							   " Use wheels to rotate and scale scene.");
390
391
392
  if(OpenFlipper::Options::showWheelsAtStartup()) {
	  wheelSwitchAction->setChecked(true);
  }
393
394
395
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

Dirk Wilden's avatar
Dirk Wilden committed
396
397
398
399
400
401
402
  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) ) );

403
  viewMenu_->addSeparator();
Jan Möbius's avatar
   
Jan Möbius committed
404

405
406
407
408
409
410
411
  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
412

413
414
415
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
   
Jan Möbius committed
416

417
418
  toolsMenu_ = new QMenu(tr("&Tools"));
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
419
  menus_[tr("&Tools")] = toolsMenu_;
Jan Möbius's avatar
   
Jan Möbius committed
420

421
422
423
424
425
426
427
428
429
430
  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
431

432
433
  toolsMenu_->addSeparator();

Dirk Wilden's avatar
Dirk Wilden committed
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
  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()) );
450

Jan Möbius's avatar
   
Jan Möbius committed
451
452
453
454
455
  // ======================================================================
  // help Menu
  // ======================================================================
  helpMenu_ = new QMenu(tr("&Help"));
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
456
  menus_[tr("&Help")] = helpMenu_;
457

Jan Möbius's avatar
   
Jan Möbius committed
458
  //Open Help Browser
459
460
  QAction* AC_HelpBrowser = new QAction(tr("&Help"), this);
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
461
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
Jan Möbius's avatar
   
Jan Möbius committed
462
  AC_HelpBrowser->setWhatsThis("Open the <b>Help Browser</b>");
463
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
   
Jan Möbius committed
464
  helpMenu_->addAction(AC_HelpBrowser);
465

Jan Möbius's avatar
   
Jan Möbius committed
466
467
468
469
470
  //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);
471

Jan Möbius's avatar
   
Jan Möbius committed
472
  helpMenu_->addSeparator();
473

Dirk Wilden's avatar
Dirk Wilden committed
474
475
476
477
  //show plugins
  QAction* AC_Plugins = new QAction(tr("&Plugins"), this);
  AC_Plugins->setStatusTip(tr("Show loaded plugins"));
  AC_Plugins->setWhatsThis("Show loaded plugins");
478
  AC_Plugins->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"network-connect.png"));
Dirk Wilden's avatar
Dirk Wilden committed
479
480
481
482
483
  connect(AC_Plugins, SIGNAL(triggered()), this, SIGNAL(showPlugins()));
  helpMenu_->addAction(AC_Plugins);

  helpMenu_->addSeparator();

Jan Möbius's avatar
   
Jan Möbius committed
484
485
486
  //About Action
  QAction* AC_About = new QAction(tr("&About"), this);
  AC_About->setStatusTip(tr("About OpenFlipper"));
487
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
Jan Möbius's avatar
   
Jan Möbius committed
488
  AC_About->setWhatsThis("This entry shows information about <b>OpenFlipper</b>");
Jan Möbius's avatar
Jan Möbius committed
489
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
   
Jan Möbius committed
490
  helpMenu_->addAction(AC_About);
491

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

Jan Möbius's avatar
   
Jan Möbius committed
502
503
}

504
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
   
Jan Möbius committed
505

506
507
  uint perspectiveCount = 0;
  uint orthogonalCount = 0;
Jan Möbius's avatar
   
Jan Möbius committed
508

509
510
511
512
513
514
  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
515
516

  if ( perspectiveCount == 4 )
517
518
519
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
520

521
522
523
524
  if ( orthogonalCount == 4 )
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
   
Jan Möbius committed
525

526
527
}

Jan Möbius's avatar
Jan Möbius committed
528
529
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
530

Jan Möbius's avatar
Jan Möbius committed
531
532
533
534
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
   
Jan Möbius committed
535

Jan Möbius's avatar
Jan Möbius committed
536
  }
Jan Möbius's avatar
   
Jan Möbius committed
537

Jan Möbius's avatar
Jan Möbius committed
538
539
540
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
   
Jan Möbius committed
541

Jan Möbius's avatar
Jan Möbius committed
542
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
   
Jan Möbius committed
543
544
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
545
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
   
Jan Möbius committed
546

Jan Möbius's avatar
Jan Möbius committed
547
548
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
Jan Möbius's avatar
   
Jan Möbius committed
549
    globalDrawMenu_  = new QMenu("Set Global DrawMode");
Jan Möbius's avatar
Jan Möbius committed
550
551
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
   
Jan Möbius committed
552

Jan Möbius's avatar
Jan Möbius committed
553
554
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
   
Jan Möbius committed
555
556

  // Collect available draw Modes
Jan Möbius's avatar
Jan Möbius committed
557
558
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
559
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
   
Jan Möbius committed
560

Jan Möbius's avatar
Jan Möbius committed
561
562
563
564
565
  // 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
566

Jan Möbius's avatar
Jan Möbius committed
567
568
  // Convert to ids
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
569
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
   
Jan Möbius committed
570

Jan Möbius's avatar
Jan Möbius committed
571
  globalDrawMenu_->clear();
Jan Möbius's avatar
   
Jan Möbius committed
572

Jan Möbius's avatar
Jan Möbius committed
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
  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
588

Jan Möbius's avatar
Jan Möbius committed
589
590
591
592
593
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
  unsigned int mode = 0;
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
594
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
Jan Möbius committed
595
596
597
598
599
600
601
602
603
  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
604

Jan Möbius's avatar
Jan Möbius committed
605
606
607
608
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
   
Jan Möbius committed
609

Jan Möbius's avatar
Jan Möbius committed
610
611
612
613
  PluginFunctions::setDrawMode( activeDrawModes_ );
  slotUpdateGlobalDrawMenu();
}

614

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