MenuBar.cc 33.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57




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


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

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

61
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
62
63
64



Jan Möbius's avatar
Jan Möbius committed
65
66
67
68
69
70
71
72
73
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
74
  }
Jan Möbius's avatar
Jan Möbius committed
75
76
77
  else
    menus_[_name]->addAction (_action);
}
78

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

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
92
93
94
95
}


//=============================================================================
Jan Möbius's avatar
 
Jan Möbius committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
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
116
117
118

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

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

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

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

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

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

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

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

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

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

Jan Möbius's avatar
 
Jan Möbius committed
167
  //Save object to
Jan Möbius's avatar
Jan Möbius committed
168
  QAction* AC_Save_to = new QAction(tr("Save Object To"), this);
Jan Möbius's avatar
 
Jan Möbius committed
169
  AC_Save_to->setStatusTip(tr("Save current Object(s) To"));
170
  AC_Save_to->setWhatsThis(tr("Saves all currently selected objects under a new name"));
171
  AC_Save_to->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-save-as.png"));
Jan Möbius's avatar
 
Jan Möbius committed
172
173
  connect(AC_Save_to, SIGNAL(triggered()), this, SIGNAL(saveToMenu()));
  fileMenu_->addAction(AC_Save_to);
174

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

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

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

  fileMenu_->addSeparator();

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

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

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

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

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

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

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

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

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

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

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

252
  // =====================
253

254
  globalAnimationAction_ = renderingOptionsMenu->addAction(tr("Animation"));
255
256
257
  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
258

259
  //======================
Jan Möbius's avatar
 
Jan Möbius committed
260

261
  globalBackfaceCullingAction_ = renderingOptionsMenu->addAction(tr("Backface Culling"));
262
  globalBackfaceCullingAction_->setCheckable( true );
263
264
  globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
  connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) );
265
266
267

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

268
  globalTwosidedLightingAction_ = renderingOptionsMenu->addAction(tr("Two-sided Lighting"));
269
270
271
  globalTwosidedLightingAction_->setCheckable( true );
  globalTwosidedLightingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
  connect(globalTwosidedLightingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
272

273
274
  //======================

275
  globalMultisamplingAction_ = renderingOptionsMenu->addAction(tr("Multisampling"));
276
  globalMultisamplingAction_->setCheckable( true );
277
// TODO:Icon for multisampling
278
//   globalMultisamplingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
279
  connect(globalMultisamplingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) );
Jan Möbius's avatar
 
Jan Möbius committed
280

281
282
283
  //============================================================================================================
  // Other toplevel actions
  //============================================================================================================
Jan Möbius's avatar
 
Jan Möbius committed
284

285
  viewMenu_->addSeparator();
Jan Möbius's avatar
 
Jan Möbius committed
286

287
288
289
290
291
292
293
294
295
296
297
  QAction* navigationSwitchAction = new QAction( tr("Ego-shooter Navigation"), viewMenu_ );
  navigationSwitchAction->setCheckable( true );
  navigationSwitchAction->setStatusTip( tr("Switch between normal and ego-shooter navigation mode."));
  navigationSwitchAction->setWhatsThis( tr("Switch between normal and ego-shooter navigation mode."));
  navigationSwitchAction->setChecked( false );

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

  viewMenu_->addSeparator();

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

300
  QAction* homeAction = new QAction(tr("Restore Home View"),viewMenu_);
301
302
  homeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"go-home.png") );
  homeAction->setCheckable( false );
303
304
305
  homeAction->setStatusTip( tr("Restore <b>home</b> view."));
  homeAction->setWhatsThis( tr("Restore home view<br><br>"
                               "Resets the view to the home view"));
306
307
  viewMenu_->addAction( homeAction );
  connect( homeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalHomeView() ) );
Jan Möbius's avatar
 
Jan Möbius committed
308
309


310
  QAction* setHomeAction = new QAction( tr("Set Home View") , viewMenu_ );
311
312
  setHomeAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"set-home.png") );
  setHomeAction->setCheckable( false );
313
314
315
  setHomeAction->setStatusTip( tr("Set <b>home</b> view"));
  setHomeAction->setWhatsThis( tr("Store home view<br><br>"
                                  "Stores the current view as the home view"));
316
317
  viewMenu_->addAction( setHomeAction);
  connect( setHomeAction,SIGNAL( triggered() ), this, SLOT( slotGlobalSetHomeView() ) );
Jan Möbius's avatar
 
Jan Möbius committed
318

319
  QAction* viewAllAction = new QAction( tr("View all"), viewMenu_ );
320
321
  viewAllAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewall.png") );
  viewAllAction->setCheckable( false );
322
323
324
325
  viewAllAction->setStatusTip( tr("View all.") );
  viewAllAction->setWhatsThis( tr("View all<br><br>"
                                  "Move the objects in the scene so that"
                                  " the whole scene is visible."));
326
327
  connect( viewAllAction,SIGNAL( triggered() ), this, SLOT( slotGlobalViewAll() ) );
  viewMenu_->addAction( viewAllAction);
Jan Möbius's avatar
 
Jan Möbius committed
328

Dirk Wilden's avatar
Dirk Wilden committed
329
  viewMenu_->addSeparator();
Dirk Wilden's avatar
Dirk Wilden committed
330

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

340
  QAction* appSnapShotAction = new QAction( tr("Application Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
341
342
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
343
344
345
  appSnapShotAction->setStatusTip( tr("Take a snapshot from OpenFlipper."));
  appSnapShotAction->setWhatsThis( tr("Snapshot<br><br>"
                                      "Take a snapshot from OpenFlipper."));
Dirk Wilden's avatar
Dirk Wilden committed
346
347
348
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

349
  perspectiveProjectionAction_ = new QAction( tr("Switch Viewers to Perspective Projection"), viewMenu_ );;
350
351
  perspectiveProjectionAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"perspective.png") );
  perspectiveProjectionAction_->setCheckable( false );
352
353
354
  perspectiveProjectionAction_->setStatusTip( tr("Switch to perspective projection mode."));
  perspectiveProjectionAction_->setWhatsThis( tr("Switch projection mode<br><br>"
                                                 "Switch to <b>perspective</b> projection mode."));
355
356
  connect( perspectiveProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalPerspectiveProjection() ) );
  viewMenu_->addAction( perspectiveProjectionAction_);
Jan Möbius's avatar
 
Jan Möbius committed
357

Dirk Wilden's avatar
Dirk Wilden committed
358
359
  viewMenu_->addSeparator();

360
  QAction* wheelSwitchAction = new QAction( tr("Show / hide wheels"), viewMenu_ );
361
  wheelSwitchAction->setCheckable( true );
362
363
364
365
  wheelSwitchAction->setStatusTip( tr("Show / hide navigation wheels in viewer widget."));
  wheelSwitchAction->setWhatsThis( tr("Show / hide navigation wheels in viewer widget.<br><br>"
                                      " These wheels appear in the corners of the viewports. "
                                      " Use wheels to rotate and scale scene."));
366
367
368
  if(OpenFlipper::Options::showWheelsAtStartup()) {
	  wheelSwitchAction->setChecked(true);
  }
369
370
371
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

372
  QAction* coordSys = viewMenu_->addAction(tr("Coordinate Systems"));
Dirk Wilden's avatar
Dirk Wilden committed
373
374
  coordSys->setCheckable(true);
  coordSys->setChecked(true);
375
  coordSys->setStatusTip(tr("Toggle visibility of the coordinate systems"));
376
  coordSys->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"coordsys.png") );
Dirk Wilden's avatar
Dirk Wilden committed
377
378
  connect(coordSys, SIGNAL(triggered(bool)), this, SLOT( slotCoordSysVisibility(bool) ) );

379
  viewMenu_->addSeparator();
Jan Möbius's avatar
 
Jan Möbius committed
380

Jan Möbius's avatar
Jan Möbius committed
381
  QAction* setGlobalBackgroundColor = new QAction(tr("Set Background Color"), this);;
382
383
  setGlobalBackgroundColor->setToolTip(tr("Set Background Color for all viewers"));
  setGlobalBackgroundColor->setStatusTip(tr("Set Background Color for all viewers"));
384
  setGlobalBackgroundColor->setWhatsThis(tr("Set Background Color for all viewers"));
385
386
387
  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
388

389
390
391
  //===========================================================================================================================
  // Tools Menu
  //===========================================================================================================================
Jan Möbius's avatar
 
Jan Möbius committed
392

Jan Möbius's avatar
Jan Möbius committed
393
  toolsMenu_ = new QMenu( TOOLSMENU );
394
  menuBar()->addMenu(toolsMenu_ );
Jan Möbius's avatar
Jan Möbius committed
395
  menus_[tr("Tools")] = toolsMenu_;
Jan Möbius's avatar
 
Jan Möbius committed
396

397
  QAction* sceneGraphAction = new QAction( tr("Show SceneGraph ") ,toolsMenu_ );
398
399
  sceneGraphAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png") );
  sceneGraphAction->setCheckable( false );
400
401
402
403
  sceneGraphAction->setToolTip( tr("Show scene graph viewer.") );
  sceneGraphAction->setWhatsThis( tr("Toggle scene graph viewer<br><br>"
                                     "The scene graph viewer enables you to examine the "
                                     "displayed scene graph and to modify certain nodes.<br><br>" ) );
404
405
406
  QObject::connect( sceneGraphAction, SIGNAL( triggered() ),
                    this,             SLOT( slotShowSceneGraphDialog() ) );
  toolsMenu_->addAction( sceneGraphAction);
Jan Möbius's avatar
 
Jan Möbius committed
407

408
409
  toolsMenu_->addSeparator();

410
  QAction* startVideoCaptureAction =  new QAction( tr("Start Video Capture ") ,toolsMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
411
412
  startVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"recordVideo.png") );
  startVideoCaptureAction->setCheckable( false );
413
414
  startVideoCaptureAction->setToolTip( tr("Start video capturing.") );
  startVideoCaptureAction->setWhatsThis( tr("Start to capture a video sequence of the user actions")) ;
Dirk Wilden's avatar
Dirk Wilden committed
415
416
417
  toolsMenu_->addAction( startVideoCaptureAction );
  connect(startVideoCaptureAction, SIGNAL(triggered()), this, SLOT(startVideoCaptureDialog()) );

418
  QAction* stopVideoCaptureAction =  new QAction( tr("Stop Video Capture ") ,toolsMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
419
420
  stopVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"stopVideoCapture.png") );
  stopVideoCaptureAction->setCheckable( false );
421
422
  stopVideoCaptureAction->setToolTip( tr("Stop video capturing." ));
  stopVideoCaptureAction->setWhatsThis( tr("Stop Video capturing" ));
Dirk Wilden's avatar
Dirk Wilden committed
423
424
425

  toolsMenu_->addAction( stopVideoCaptureAction);
  connect(stopVideoCaptureAction, SIGNAL(triggered()), this, SIGNAL(stopVideoCapture()) );
426

Jan Möbius's avatar
 
Jan Möbius committed
427
428
429
  // ======================================================================
  // help Menu
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
430
  helpMenu_ = new QMenu(tr("Help"));
Jan Möbius's avatar
 
Jan Möbius committed
431
  menuBar()->addMenu(helpMenu_);
Jan Möbius's avatar
Jan Möbius committed
432
  menus_[tr("Help")] = helpMenu_;
433

Jan Möbius's avatar
 
Jan Möbius committed
434
  //Open Help Browser
Jan Möbius's avatar
Jan Möbius committed
435
  QAction* AC_HelpBrowser = new QAction(tr("Help"), this);
436
  AC_HelpBrowser->setStatusTip(tr("Open Help Browser with Documentation"));
437
  AC_HelpBrowser->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-browser.png"));
438
  AC_HelpBrowser->setWhatsThis(tr("Open the <b>Help Browser</b>"));
439
  connect(AC_HelpBrowser, SIGNAL(triggered()), this, SLOT(showHelpBrowser()));
Jan Möbius's avatar
 
Jan Möbius committed
440
  helpMenu_->addAction(AC_HelpBrowser);
441

Jan Möbius's avatar
 
Jan Möbius committed
442
443
444
  //Switch to whats this mode
  QAction* AC_Whats_this = QWhatsThis::createAction ( this );
  AC_Whats_this->setStatusTip(tr("Enter What's this Mode"));
445
  AC_Whats_this->setWhatsThis(tr("Get information about a specific Button/Widget/..."));
Jan Möbius's avatar
 
Jan Möbius committed
446
  helpMenu_->addAction(AC_Whats_this);
447

Jan Möbius's avatar
 
Jan Möbius committed
448
  helpMenu_->addSeparator();
449

Dirk Wilden's avatar
Dirk Wilden committed
450
  //show plugins
Jan Möbius's avatar
Jan Möbius committed
451
  QAction* AC_Plugins = new QAction(tr("Plugins"), this);
Dirk Wilden's avatar
Dirk Wilden committed
452
  AC_Plugins->setStatusTip(tr("Show loaded plugins"));
453
  AC_Plugins->setWhatsThis(tr("Show loaded plugins"));
454
  AC_Plugins->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"network-connect.png"));
Dirk Wilden's avatar
Dirk Wilden committed
455
456
457
458
459
  connect(AC_Plugins, SIGNAL(triggered()), this, SIGNAL(showPlugins()));
  helpMenu_->addAction(AC_Plugins);

  helpMenu_->addSeparator();

Jan Möbius's avatar
 
Jan Möbius committed
460
  //About Action
Jan Möbius's avatar
Jan Möbius committed
461
  QAction* AC_About = new QAction(tr("About"), this);
Jan Möbius's avatar
 
Jan Möbius committed
462
  AC_About->setStatusTip(tr("About OpenFlipper"));
463
  AC_About->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"));
464
  AC_About->setWhatsThis(tr("This entry shows information about <b>OpenFlipper</b>"));
Jan Möbius's avatar
Jan Möbius committed
465
  connect(AC_About, SIGNAL(triggered()), this, SLOT(showAboutWidget()));
Jan Möbius's avatar
 
Jan Möbius committed
466
  helpMenu_->addAction(AC_About);
467

Jan Möbius's avatar
 
Jan Möbius committed
468
469
470
471
472
473
474
475
476
477
478
  // 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);
}

479

480
void CoreWidget::slotViewMenuAboutToShow() {
Jan Möbius's avatar
 
Jan Möbius committed
481

482
483
  uint enabledCount  = 0;
  uint disabledCount = 0;
484

485
486
487
488
489
490
491
492
493
  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);
494
495
496
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setText(tr("Disable animation"));
497
498
  } else if ( enabledCount == 4 ) {
    globalAnimationAction_->setChecked( Qt::Checked );
499
500
501
    globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
    globalAnimationAction_->setText(tr("Disable animation"));
502
503
  } else {
    globalAnimationAction_->setChecked( Qt::Unchecked );
504
505
506
    globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));
    globalAnimationAction_->setText(tr("Enable animation"));
507
  }
508

509
  //=============================================================================================================================
510

511
  enabledCount  = 0;
512
513
  disabledCount = 0;

514
515
516
517
518
519
  for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
    if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
      enabledCount++;
    else
      disabledCount++;
  }
520

521
522
  if ( enabledCount != 0 && disabledCount != 0 ) {
    globalBackfaceCullingAction_->setChecked(Qt::PartiallyChecked);
523
524
525
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
526
527
  } else if ( enabledCount == 4 ) {
    globalBackfaceCullingAction_->setChecked( Qt::Checked );
528
529
530
    globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
531
532
  } else {
    globalBackfaceCullingAction_->setChecked( Qt::Unchecked );
533
534
535
    globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));
    globalBackfaceCullingAction_->setText(tr("Enable backface culling"));
536
537
538
  }

  //=============================================================================================================================
539

540
541
  enabledCount  = 0;
  disabledCount = 0;
542

543
544
545
546
547
548
549
550
551
  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);
552
553
554
    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"));
555
556
  } else if ( enabledCount == 4 ) {
    globalTwosidedLightingAction_->setChecked( Qt::Checked );
557
558
559
    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"));
560
561
  } else {
    globalTwosidedLightingAction_->setChecked( Qt::Unchecked );
562
563
564
    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"));
565
566
567
  }

  //=============================================================================================================================
568

569
570
  enabledCount  = 0;
  disabledCount = 0;
571
572


573
574
575
576
577
578
579
580
581
  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);
582
583
    globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));
    globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));
584
585
586
    globalMultisamplingAction_->setText(tr("Disable Multisampling"));
  } else if ( enabledCount == 4 ) {
    globalMultisamplingAction_->setChecked( Qt::Checked );
587
588
    globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));
    globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));
589
590
591
    globalMultisamplingAction_->setText(tr("Disable Multisampling"));
  } else {
    globalMultisamplingAction_->setChecked( Qt::Unchecked );
592
593
    globalMultisamplingAction_->setToolTip(tr("Enable Multisampling for all viewers"));
    globalMultisamplingAction_->setStatusTip(tr("Enable Multisampling for all viewers"));
Jan Möbius's avatar
Jan Möbius committed
594
    globalMultisamplingAction_->setText(tr("Enable Multisampling"));
595
  }
596

597
598
  uint perspectiveCount = 0;
  uint orthogonalCount = 0;
Jan Möbius's avatar
 
Jan Möbius committed
599

600
601
602
603
604
605
  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
606
607

  if ( perspectiveCount == 4 )
608
609
610
    perspectiveProjectionAction_->setVisible(false);
  else
    perspectiveProjectionAction_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
611

612
613
614
615
  if ( orthogonalCount == 4 )
    orthogonalProjectionAction_->setVisible(false);
  else
    orthogonalProjectionAction_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
616

617
618
}

Jan Möbius's avatar
Jan Möbius committed
619
620
void CoreWidget::slotUpdateGlobalDrawMenu() {
  if ( drawGroup_ ) {
Jan Möbius's avatar
 
Jan Möbius committed
621

Jan Möbius's avatar
Jan Möbius committed
622
623
624
625
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
Jan Möbius's avatar
 
Jan Möbius committed
626

Jan Möbius's avatar
Jan Möbius committed
627
  }
Jan Möbius's avatar
 
Jan Möbius committed
628

Jan Möbius's avatar
Jan Möbius committed
629
630
631
  // Recreate drawGroup
  drawGroup_ = new QActionGroup( this );
  drawGroup_->setExclusive( false );
Jan Möbius's avatar
 
Jan Möbius committed
632

Jan Möbius's avatar
Jan Möbius committed
633
  connect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
Jan Möbius's avatar
 
Jan Möbius committed
634
635
           this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );

Jan Möbius's avatar
Jan Möbius committed
636
  if ( !globalDrawMenu_ ) {
Jan Möbius's avatar
 
Jan Möbius committed
637

Jan Möbius's avatar
Jan Möbius committed
638
639
    QIcon icon;
    icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
640
    globalDrawMenu_  = new QMenu(tr("Set Global DrawMode"));
Jan Möbius's avatar
Jan Möbius committed
641
642
    globalDrawMenu_->setTearOffEnabled(true);
    globalDrawMenu_->setIcon(icon);
Jan Möbius's avatar
 
Jan Möbius committed
643

Jan Möbius's avatar
Jan Möbius committed
644
645
    connect(globalDrawMenu_,SIGNAL(aboutToShow () ) , this, SLOT(slotUpdateGlobalDrawMenu() ) );
  }
Jan Möbius's avatar
 
Jan Möbius committed
646
647

  // Collect available draw Modes
Jan Möbius's avatar
Jan Möbius committed
648
649
  ACG::SceneGraph::CollectDrawModesAction actionAvailable;
  ACG::SceneGraph::traverse( PluginFunctions::getRootNode() , actionAvailable);
Jan Möbius's avatar
Jan Möbius committed
650
  availableGlobalDrawModes_ = actionAvailable.drawModes();
Jan Möbius's avatar
 
Jan Möbius committed
651

Jan Möbius's avatar
Jan Möbius committed
652
653
654
655
656
  // 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
657

Jan Möbius's avatar
Jan Möbius committed
658
659
  // Convert to ids
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
660
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
 
Jan Möbius committed
661

Jan Möbius's avatar
Jan Möbius committed
662
  globalDrawMenu_->clear();
Jan Möbius's avatar
 
Jan Möbius committed
663

Jan Möbius's avatar
Jan Möbius committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
  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
679

Jan Möbius's avatar
Jan Möbius committed
680
681
682
683
684
  //======================================================================================
  // Get the mode toggled
  //======================================================================================
  unsigned int mode = 0;
  std::vector< unsigned int > availDrawModeIds;
Jan Möbius's avatar
Jan Möbius committed
685
  availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
Jan Möbius's avatar
Jan Möbius committed
686
687
688
689
690
691
692
693
694
  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
695

Jan Möbius's avatar
Jan Möbius committed
696
697
698
699
  if ( qApp->keyboardModifiers() & Qt::ShiftModifier )
    activeDrawModes_ = ( activeDrawModes_ ^ mode);
  else
    activeDrawModes_ = mode ;
Jan Möbius's avatar
 
Jan Möbius committed
700

Jan Möbius's avatar
Jan Möbius committed
701
702
703
704
  PluginFunctions::setDrawMode( activeDrawModes_ );
  slotUpdateGlobalDrawMenu();
}

705

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