MenuBar.cc 33.2 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_);
Jan Möbius's avatar
Jan Möbius committed
240
  renderingOptionsMenu->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_renderingOptions.png") );
241
  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

Mike Kremer's avatar
Mike Kremer committed
287
  QAction* navigationSwitchAction = new QAction( tr("First-person Navigation"), viewMenu_ );
288
  navigationSwitchAction->setCheckable( true );
Jan Möbius's avatar
Jan Möbius committed
289
  navigationSwitchAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"core_firstPersonMode.png") );
Mike Kremer's avatar
Mike Kremer committed
290 291
  navigationSwitchAction->setStatusTip( tr("Switch between normal and first-person navigation mode."));
  navigationSwitchAction->setWhatsThis( tr("Switch between normal and first-person navigation mode."));
292 293 294 295 296 297 298
  navigationSwitchAction->setChecked( false );

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

  viewMenu_->addSeparator();

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

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


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

320
  QAction* viewAllAction = new QAction( tr("View all"), viewMenu_ );
321 322
  viewAllAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewall.png") );
  viewAllAction->setCheckable( false );
323 324 325 326
  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."));
327 328
  connect( viewAllAction,SIGNAL( triggered() ), this, SLOT( slotGlobalViewAll() ) );
  viewMenu_->addAction( viewAllAction);
Jan Möbius's avatar
 
Jan Möbius committed
329

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

332
  QAction* snapShotAction = new QAction( tr("Viewer Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
333 334
  snapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewerSnapshot.png") );
  snapShotAction->setCheckable( false );
335 336 337
  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
338 339
  connect( snapShotAction,SIGNAL( triggered() ), this, SLOT( viewerSnapshotDialog() ) );
  viewMenu_->addAction( snapShotAction);
Dirk Wilden's avatar
Dirk Wilden committed
340

341
  QAction* appSnapShotAction = new QAction( tr("Application Snapshot"), viewMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
342 343
  appSnapShotAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"snapshot.png") );
  appSnapShotAction->setCheckable( false );
344 345 346
  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
347 348 349
  connect( appSnapShotAction,SIGNAL( triggered() ), this, SLOT( applicationSnapshotDialog() ) );
  viewMenu_->addAction( appSnapShotAction);

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

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

361
  QAction* wheelSwitchAction = new QAction( tr("Show / hide wheels"), viewMenu_ );
362
  wheelSwitchAction->setCheckable( true );
363 364 365 366
  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."));
367 368 369
  if(OpenFlipper::Options::showWheelsAtStartup()) {
	  wheelSwitchAction->setChecked(true);
  }
370 371 372
  connect( wheelSwitchAction,SIGNAL( toggled(bool) ), this, SLOT( slotSwitchWheels(bool) ) );
  viewMenu_->addAction( wheelSwitchAction);

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

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

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

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

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

398
  QAction* sceneGraphAction = new QAction( tr("Show SceneGraph ") ,toolsMenu_ );
399 400
  sceneGraphAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png") );
  sceneGraphAction->setCheckable( false );
401 402 403 404
  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>" ) );
405 406 407
  QObject::connect( sceneGraphAction, SIGNAL( triggered() ),
                    this,             SLOT( slotShowSceneGraphDialog() ) );
  toolsMenu_->addAction( sceneGraphAction);
Jan Möbius's avatar
 
Jan Möbius committed
408

409 410
  toolsMenu_->addSeparator();

411
  QAction* startVideoCaptureAction =  new QAction( tr("Start Video Capture ") ,toolsMenu_ );
Dirk Wilden's avatar
Dirk Wilden committed
412 413
  startVideoCaptureAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"recordVideo.png") );
  startVideoCaptureAction->setCheckable( false );
414 415
  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
416 417 418
  toolsMenu_->addAction( startVideoCaptureAction );
  connect(startVideoCaptureAction, SIGNAL(triggered()), this, SLOT(startVideoCaptureDialog()) );

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

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

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

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

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

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

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

  helpMenu_->addSeparator();

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

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

480

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

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

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

510
  //=============================================================================================================================
511

512
  enabledCount  = 0;
513 514
  disabledCount = 0;

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

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

  //=============================================================================================================================
540

541 542
  enabledCount  = 0;
  disabledCount = 0;
543

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

  //=============================================================================================================================
569

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


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

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

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

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

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

618 619
}

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

Jan Möbius's avatar
Jan Möbius committed
623 624 625 626
    disconnect( drawGroup_ , SIGNAL( triggered( QAction * ) ),
                this       , SLOT( slotGlobalDrawMenu( QAction * ) ) );
    delete( drawGroup_ );
    drawGroup_ = 0;
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

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

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

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

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

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

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

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

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

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

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

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

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

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

706

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