CoreWidget.cc 37.6 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
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
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
41

42
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
43 44 45 46 47
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
48
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65



//=============================================================================
//
//  CLASS MViewWidget - IMPLEMENTATION
//
//=============================================================================


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

// -------------------- mview
#include "CoreWidget.hh"

// -------------------- OpenFlipper Includes
#include <OpenFlipper/common/RecentFiles.hh>
Jan Möbius's avatar
 
Jan Möbius committed
66
#include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
Jan Möbius's avatar
 
Jan Möbius committed
67

Dirk Wilden's avatar
Dirk Wilden committed
68 69
#include <OpenFlipper/widgets/videoCaptureDialog/VideoCaptureDialog.hh>

Jan Möbius's avatar
Jan Möbius committed
70
#include <ACG/Scenegraph/SceneGraphAnalysis.hh>
71
#include <ACG/GL/ShaderCache.hh>
Jan Möbius's avatar
Jan Möbius committed
72

Matthias Möller's avatar
doc  
Matthias Möller committed
73
// -------------------- Qt event Includes
Hans-Christian Ebke's avatar
Hans-Christian Ebke committed
74
#include <QGLFormat>
75
#include "common/glew_wrappers.hh"
Matthias Möller's avatar
doc  
Matthias Möller committed
76

Jan Möbius's avatar
 
Jan Möbius committed
77 78 79
#define WIDGET_HEIGHT 800
#define WIDGET_WIDTH  800

Jan Möbius's avatar
Jan Möbius committed
80
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
PickMode::PickMode(const std::string& _n, const bool _t, const bool _v, QCursor _c, QToolBar *_tb ) :
      name_(_n),
      tracking_(_t),
      visible_(_v),
      cursor_(_c),
      toolbar_(_tb)
{

}

void PickMode::visible(const bool _visible) {
  visible_ = _visible;
}

bool PickMode::visible() const  {
  return visible_;
}

std::string PickMode::name() const {
  return name_;
}

void PickMode::tracking(bool _tracking) {
  tracking_ = _tracking;
}

bool PickMode::tracking() const {
  return tracking_;
}

112 113 114 115
void PickMode::cursor(const QCursor _cursor) {
  cursor_ = _cursor;
}

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
QCursor PickMode::cursor() const{
  return cursor_;
}

void PickMode::toolbar(QToolBar* _toolbar) {
  toolbar_ = _toolbar;
}

QToolBar * PickMode::toolbar() const {
  return toolbar_;
}









136
/** \brief Constructor for the Core Widget
Jan Möbius's avatar
Jan Möbius committed
137
 *
Jan Möbius's avatar
 
Jan Möbius committed
138 139
*/
CoreWidget::
Dirk Wilden's avatar
Dirk Wilden committed
140
CoreWidget( QVector<ViewMode*>& _viewModes,
Dirk Wilden's avatar
Dirk Wilden committed
141 142
            std::vector<PluginInfo>& _plugins,
            QList< SlotInfo >& _coreSlots ) :
Jan Möbius's avatar
 
Jan Möbius committed
143
  QMainWindow(),
Dirk Wilden's avatar
Dirk Wilden committed
144
  coreSlots_(_coreSlots),
Dirk Wilden's avatar
Dirk Wilden committed
145
  shiftPressed_(false),
Jan Möbius's avatar
 
Jan Möbius committed
146 147
  viewModes_(_viewModes),
  viewModeButton_(0),
148
  viewModeMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
149
  splitter_(0),
150
  logWidget_(0),
Jan Möbius's avatar
 
Jan Möbius committed
151
  recentFilesMenu_(0),
152
  helpMenu_(0),
153 154
  windowMenu_(0),
  AC_ShowViewModeControls_(0),
155
  pickToolBarExternal_(0),
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
156
  cursorPainter_(0),
157
  sceneGraphDialog_(0),
158 159 160
  fileMenu_(0),
  viewMenu_(0),
  toolsMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
161
  fileMenuEnd_(0),
162 163 164
  stereoButton_(0),
  moveButton_(0),
  pickButton_(0),
Dirk Wilden's avatar
Dirk Wilden committed
165
  questionButton_(0),
166
  globalDrawMenu_(0),
167
  rendererMenu_(0),
168
  drawGroup_(0),
169
  rendererGroup_(0),
170
  viewGroup_(0),
171
  perspectiveProjectionAction_(0),
172 173
  activeDrawModes_(0),
  availableGlobalDrawModes_(0),
Jan Möbius's avatar
 
Jan Möbius committed
174
  contextMenu_(0),
Jan Möbius's avatar
Jan Möbius committed
175
  contextSelectionMenu_(0),
176 177
  drawGroupViewer_(0),
  viewerDrawMenu_(0),
Matthias Möller's avatar
Matthias Möller committed
178
  viewerDrawMenuWidget_(0),
179
  coordSysMenu_(0),
180
  snapshotName_(""),
Dirk Wilden's avatar
Dirk Wilden committed
181
  snapshotCounter_(0),
Jan Möbius's avatar
 
Jan Möbius committed
182
  stackMenu_(0),
183
  helpWidget_(0),
184
  postProcessorDialog_(0),
Jan Möbius's avatar
Jan Möbius committed
185
  rendererDialog_(0),
Jan Möbius's avatar
Jan Möbius committed
186
  rendererObjectWidget_(0),
187
  stereoSettingsWidget_(0),
Jan Möbius's avatar
Jan Möbius committed
188
  aboutWidget_(0),
189
  optionsWidget_(0),
190
  plugins_(_plugins),
191 192 193 194 195 196
  stereoActive_(false),
  actionMode_(Viewer::PickingMode),
  lastActionMode_(Viewer::ExamineMode),
  pickMenu_(0),
  pick_mode_name_(""),
  pick_mode_idx_(-1)
Jan Möbius's avatar
 
Jan Möbius committed
197
{
Matthias Möller's avatar
doc  
Matthias Möller committed
198

Jan Möbius's avatar
 
Jan Möbius committed
199
  setupStatusBar();
Jan Möbius's avatar
Jan Möbius committed
200

Dirk Wilden's avatar
Dirk Wilden committed
201 202
  defaultIconSize_ = iconSize();

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
203 204 205 206 207
  toolSplitter_ = new QSplitter(Qt::Horizontal,this);

  setCentralWidget(toolSplitter_);

  splitter_ = new QSplitter(Qt::Vertical,toolSplitter_);
Jan Möbius's avatar
 
Jan Möbius committed
208
  stackedWidget_ = new QStackedWidget(splitter_);
Jan Möbius's avatar
Jan Möbius committed
209

210 211
  QGLFormat format = QGLFormat::defaultFormat();

212 213 214
  #ifdef ARCH_DARWIN
  format.setStereo(false);
  #else
Jan Möbius's avatar
 
Jan Möbius committed
215
  format.setStereo( OpenFlipper::Options::stereo() );
216
  #endif
Jan Möbius's avatar
 
Jan Möbius committed
217
  format.setAlpha(true);
218
  format.setStencil(true);
219 220
  format.setSampleBuffers(true);
  QGLFormat::setDefaultFormat(format);
Jan Möbius's avatar
 
Jan Möbius committed
221 222

  // Construct GL context & widget
223 224 225
  baseLayout_ = new QtMultiViewLayout;
  baseLayout_->setContentsMargins(0,0,0,0);

226 227 228
  // ===============================================================================
  // Test context capabilities ...
  // If we get stereo buffers, we use them .. which might disable multisampling
229
  // If we don't have stereo, we disable it to not interfere with multisampling
230 231 232 233 234 235 236 237 238 239 240 241
  // ===============================================================================
  QGLWidget* test = new QGLWidget(format);
  if ( ! test->format().stereo() ) {
    //     std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
    format.setStereo(false);
    QGLFormat::setDefaultFormat(format);
  }/* else {
    std::cerr << "Stereo found ok" << std::endl;
  }*/

  delete test;

242 243 244 245
  // force the compatibility profile since OpenFlipper does not work with the
  // Core profile
  format.setProfile(QGLFormat::CompatibilityProfile);

246 247 248 249 250 251
#if QT_VERSION >= 0x050000
  // request the highest OpenGL version
  // QT 5 should gracefully provide the next highest available version
  format.setVersion(4,3);
#endif

252
  glWidget_ = new QGLWidget(format,0);
253
  glWidget_->makeCurrent();
254
  PluginFunctions::shareGLWidget (glWidget_);
255

Jan Möbius's avatar
 
Jan Möbius committed
256
  glView_ = new QtGLGraphicsView(stackedWidget_);
257
  glScene_ = new QtGLGraphicsScene (&examiner_widgets_, baseLayout_);
Jan Möbius's avatar
 
Jan Möbius committed
258

Jan Möbius's avatar
Jan Möbius committed
259
  // is stereo possible, use it?
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
260
  OpenFlipper::Options::glStereo(glWidget_->format().stereo());
Jan Möbius's avatar
Jan Möbius committed
261

Jan Möbius's avatar
 
Jan Möbius committed
262 263 264
  glView_->setViewport(glWidget_);
  glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  glView_->setScene(glScene_);
265
  glView_->setFrameStyle(QFrame::NoFrame);
Jan Möbius's avatar
 
Jan Möbius committed
266

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
267 268
  // gl widget as parent to make sure that the CursorPainter will be deleted before
  cursorPainter_ = new CursorPainter (glWidget_);
Jan Möbius's avatar
Jan Möbius committed
269
  cursorPainter_->setForceNative (OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
270
  cursorPainter_->setEnabled (stereoActive_);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
271
  glScene_->setCursorPainter (cursorPainter_);
272

Jan Möbius's avatar
 
Jan Möbius committed
273 274 275 276 277 278 279 280 281 282
  centerWidget_ = new QGraphicsWidget;
  glScene_->addItem(centerWidget_);
  centerWidget_->setGeometry (glScene_->sceneRect ());

  connect ( glView_, SIGNAL( sceneRectChanged( const QRectF & ) ),
            this, SLOT( sceneRectChanged( const QRectF & ) ) );

  stackedWidget_->addWidget(glView_);
  stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", glView_ ) );

Jan Möbius's avatar
 
Jan Möbius committed
283 284 285
  // ======================================================================
  // Set up the logging window
  // ======================================================================
286

287
  slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
288

289 290
  logWidget_ = new LoggerWidget(splitter_);
  logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
291
  logWidget_->resize( splitter_->width() ,240);
Jan Möbius's avatar
Jan Möbius committed
292

293
  originalLoggerSize_ = 0;
Jan Möbius's avatar
Jan Möbius committed
294
  loggerState_ = OpenFlipper::Options::Normal;
295

296 297 298 299 300
  QList<int> wsizes(splitter_->sizes());
  // Set initial values to have a usable state
  wsizes[0] = 480;
  wsizes[1] = 240;
  splitter_->setSizes(wsizes);
301

Jan Möbius's avatar
Jan Möbius committed
302
  if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
303

304
    slidingLogger_->attachWidget (logWidget_);
305
    showLoggerInSplitView(false);
Jan Möbius's avatar
Jan Möbius committed
306
    loggerState_ = OpenFlipper::Options::InScene;
307

Jan Möbius's avatar
Jan Möbius committed
308
  } else if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden) {
309

310
    showLoggerInSplitView(false);
Jan Möbius's avatar
Jan Möbius committed
311 312
    loggerState_ = OpenFlipper::Options::Hidden;
  } else {
313 314

    showLoggerInSplitView(true);
Jan Möbius's avatar
 
Jan Möbius committed
315
  }
Jan Möbius's avatar
Jan Möbius committed
316

317

Jan Möbius's avatar
 
Jan Möbius committed
318 319 320
  // ======================================================================
  // Create examiner
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
321

322 323
  initOpenGLFunctions();

Jan Möbius's avatar
Jan Möbius committed
324 325 326 327 328
  // First we analyze the scenegraph
  unsigned int maxPases = 1;
  ACG::Vec3d bbmin,bbmax;
  ACG::SceneGraph::analyzeSceneGraph(PluginFunctions::getSceneGraphRootNode(),maxPases,bbmin,bbmax);

Jan Möbius's avatar
Jan Möbius committed
329
  if ( !OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() ) {
Jan Möbius's avatar
Jan Möbius committed
330

Jan Möbius's avatar
 
Jan Möbius committed
331
    glViewer* examinerWidget = new glViewer(glScene_,
Jan Möbius's avatar
Jan Möbius committed
332 333 334
					                                  glWidget_,
					                                  PluginFunctions::viewerProperties(0),
					                                  centerWidget_);
Jan Möbius's avatar
Jan Möbius committed
335

Jan Möbius's avatar
Jan Möbius committed
336 337
    examiner_widgets_.push_back(examinerWidget);

Jan Möbius's avatar
Jan Möbius committed
338
    examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode(), maxPases,bbmin,bbmax );
Jan Möbius's avatar
Jan Möbius committed
339

Jan Möbius's avatar
Jan Möbius committed
340
    baseLayout_->addItem(examinerWidget, 0);
Jan Möbius's avatar
Jan Möbius committed
341

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
342 343
    cursorPainter_->registerViewer (examinerWidget);

Jan Möbius's avatar
Jan Möbius committed
344 345 346
  } else {


Jan Möbius's avatar
 
Jan Möbius committed
347 348 349
    // Create examiners
    for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
      glViewer* newWidget = new glViewer(glScene_,
Jan Möbius's avatar
Jan Möbius committed
350
					                               glWidget_,
351
                                         PluginFunctions::viewerProperties(i),
Jan Möbius's avatar
Jan Möbius committed
352
                                         centerWidget_);
Dirk Wilden's avatar
Dirk Wilden committed
353

Jan Möbius's avatar
Jan Möbius committed
354
      examiner_widgets_.push_back(newWidget);
355 356 357 358 359 360 361 362 363 364

      connect (&PluginFunctions::viewerProperties(i), SIGNAL( getPickMode(std::string&) ),
               this,                                   SLOT( getPickMode(std::string&) ),Qt::DirectConnection );
      connect (&PluginFunctions::viewerProperties(i), SIGNAL( setPickMode(const std::string) ),
               this,                                   SLOT( setPickMode(const std::string) ),Qt::DirectConnection );
      connect (&PluginFunctions::viewerProperties(i), SIGNAL( getActionMode(Viewer::ActionMode&) ),
               this,                                   SLOT( getActionMode(Viewer::ActionMode&) ),Qt::DirectConnection );
      connect (&PluginFunctions::viewerProperties(i), SIGNAL( setActionMode(const Viewer::ActionMode) ),
               this,                                   SLOT( setActionMode(const Viewer::ActionMode)), Qt::DirectConnection );

365
      connect (&PluginFunctions::viewerProperties(i), SIGNAL( drawModeChanged(int)), this, SIGNAL(drawModeChanged(int)));
Jan Möbius's avatar
Jan Möbius committed
366 367 368 369
    }

    // Initialize all examiners
    for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
Jan Möbius's avatar
Jan Möbius committed
370
      examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode(), maxPases,bbmin,bbmax );
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
371
      cursorPainter_->registerViewer (examiner_widgets_[i]);
Jan Möbius's avatar
Jan Möbius committed
372 373
    }

Jan Möbius's avatar
Jan Möbius committed
374 375 376 377
    baseLayout_->addItem(examiner_widgets_[0],0);
    baseLayout_->addItem(examiner_widgets_[1],1);
    baseLayout_->addItem(examiner_widgets_[2],2);
    baseLayout_->addItem(examiner_widgets_[3],3);
Jan Möbius's avatar
Jan Möbius committed
378 379
  }

Jan Möbius's avatar
 
Jan Möbius committed
380 381 382
  // Make examiner available to the plugins ( defined in PluginFunctions.hh)
  PluginFunctions::setViewers( examiner_widgets_ );

Jan Möbius's avatar
 
Jan Möbius committed
383
  centerWidget_->setLayout(baseLayout_);
384 385


386
  ACG::ShaderCache::getInstance()->setTimeCheck(OpenFlipperSettings().value("Core/File/ReloadShaders",false).toBool());
387
  ACG::ShaderCache::getInstance()->setDebugOutputDir(OpenFlipperSettings().value("Core/File/ShaderOutputDir","").toString().toUtf8());
388

Jan Möbius's avatar
 
Jan Möbius committed
389 390 391
  // ======================================================================
  // Setup dragging for examiner widget
  // ======================================================================
392 393 394 395 396 397 398 399
  for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {

    connect( examiner_widgets_[i], SIGNAL(startDragEvent( QMouseEvent*)),
             this, SLOT(startDrag(QMouseEvent* )));
    connect( examiner_widgets_[i], SIGNAL(dragEnterEvent( QDragEnterEvent*)),
            this, SLOT(dragEnterEvent(QDragEnterEvent* )));
    connect( examiner_widgets_[i], SIGNAL(dropEvent( QDropEvent*)),
            this, SLOT(dropEvent(QDropEvent* )));
400 401
    connect (examiner_widgets_[i], SIGNAL(signalMakeActive ()),
             this, SLOT(slotActivateExaminer()));
402 403 404

    connect (examiner_widgets_[i], SIGNAL(statusMessage(QString, int)),
             statusBar_, SLOT(showMessage(const QString&, int)));
Jan Möbius's avatar
Jan Möbius committed
405 406 407
  }


Jan Möbius's avatar
 
Jan Möbius committed
408 409 410
  // ======================================================================
  // Create main Toolbar
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
411

Jan Möbius's avatar
Jan Möbius committed
412 413 414
  mainToolbar_ = new QToolBar(tr("Main Toolbar"));
  mainToolbar_->setWindowTitle(tr("Main Toolbar"));
  mainToolbar_->setObjectName(tr("MainToolbar"));
415
  slotAddToolbar(mainToolbar_);
Jan Möbius's avatar
Jan Möbius committed
416

Jan Möbius's avatar
 
Jan Möbius committed
417 418 419
  // ======================================================================
  // Get Toolbar from examiner and integrate it into main window
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
420

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

422
  // Create the toolbar
Jan Möbius's avatar
Jan Möbius committed
423
  viewerToolbar_ = new QToolBar( tr("Viewer Toolbar" ), this );
424
  viewerToolbar_->setOrientation(Qt::Vertical);
Jan Möbius's avatar
 
Jan Möbius committed
425 426
  viewerToolbar_->setAllowedAreas(Qt::AllToolBarAreas);
  viewerToolbar_->setIconSize(QSize(20,20));
Jan Möbius's avatar
Jan Möbius committed
427
  viewerToolbar_->setObjectName(tr("ViewerToolbar"));
428

Jan Möbius's avatar
Jan Möbius committed
429
  slotAddToolbar(viewerToolbar_);
Jan Möbius's avatar
Jan Möbius committed
430

431 432 433 434
  moveButton_ = new QToolButton( viewerToolbar_ );
  moveButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"transform-move.png") );
  moveButton_->setMinimumSize( 16, 16 );
  moveButton_->setMaximumSize( 32, 32 );
435
  moveButton_->setCheckable(true);
Jan Möbius's avatar
Jan Möbius committed
436 437
  moveButton_->setToolTip( tr("Switch to <b>move</b> mode.") );
  moveButton_->setWhatsThis(tr(
438 439 440
                  "Switch to <b>move</b> mode.<br>"
                  "<ul><li><b>Rotate</b> using <b>left</b> mouse button.</li>"
                  "<li><b>Translate</b> using <b>middle</b> mouse button.</li>"
Jan Möbius's avatar
Jan Möbius committed
441
                  "<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" ));
442 443

  connect( moveButton_,SIGNAL( clicked() ), this, SLOT( setExamineMode() ) );
444
/*
445
  connect( this, SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
446
            this, SLOT(   slotActionModeChanged(Viewer::ActionMode) ) );*/
447

Jan Möbius's avatar
Jan Möbius committed
448
  viewerToolbar_->addWidget( moveButton_ )->setText(tr("Move"));
449
  moveButton_->setChecked(true);
450

451
  
452 453 454 455
  pickButton_ = new QToolButton( viewerToolbar_ );
  pickButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"pick.png") );
  pickButton_->setMinimumSize( 16, 16 );
  pickButton_->setMaximumSize( 32, 32 );
456
  pickButton_->setCheckable(true);
Jan Möbius's avatar
Jan Möbius committed
457 458
  pickButton_->setToolTip(tr("Switch to <b>picking</b> mode."));
  pickButton_->setWhatsThis(tr(
459 460 461
                  "Switch to <b>picking</b> mode.<br>"
                  "Use picking functions like flipping edges.<br>"
                  "To change the mode use the right click<br>"
Jan Möbius's avatar
Jan Möbius committed
462
                  "context menu in the viewer."));
463
  connect( pickButton_,SIGNAL( clicked() ), this, SLOT( setPickingMode() ) );
Jan Möbius's avatar
Jan Möbius committed
464
  viewerToolbar_->addWidget( pickButton_)->setText(tr("Pick"));
465 466 467 468 469 470


  questionButton_ = new QToolButton( viewerToolbar_ );
  questionButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png") );
  questionButton_->setMinimumSize( 16, 16 );
  questionButton_->setMaximumSize( 32, 32 );
471
  questionButton_->setCheckable(true);
Jan Möbius's avatar
Jan Möbius committed
472 473
  questionButton_->setToolTip(tr("Switch to <b>identification</b> mode."));
  questionButton_->setWhatsThis(tr(
474 475 476 477
                  "Switch to <b>identification</b> mode.<br>"
                  "Use identification mode to get information "
                  "about objects. Click on an object and see "
                  "the log output for information about the "
Jan Möbius's avatar
Jan Möbius committed
478
                  "object."));
479
  connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
Jan Möbius's avatar
Jan Möbius committed
480
  viewerToolbar_->addWidget( questionButton_)->setText(tr("Question"));
481

482 483 484 485 486 487 488 489
  viewerLayoutBox_ = new QComboBox( viewerToolbar_ );
  viewerLayoutBox_->setMinimumSize( 32, 16 );
  viewerLayoutBox_->setMaximumSize( 64, 32 );
  viewerLayoutBox_->setToolTip(tr("Switch <b>viewer layout</b>."));
  viewerLayoutBox_->setWhatsThis(tr(
                  "Switch <b>viewer layout</b>.<br>"
                  "Select the desired viewer layout. "
                  "Possible layouts are: "
490
                  "<ul> "
491
				  "<li>Single viewer</li>"
Jan Möbius's avatar
Jan Möbius committed
492
          "<li>Double viewer</li>"
493 494
				  "<li>Multiple viewers (grid)</li>"
				  "<li>Multiple viewers (hsplit)</li>"
Jan Möbius's avatar
Jan Möbius committed
495
				  "</ul>"));
496

497
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"singleviewmode.png"), "");
Jan Möbius's avatar
Jan Möbius committed
498
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"doubleviewmode.png"), "");
499 500
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode1.png"), "");
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode2.png"), "");
501

502
  viewerLayoutBox_->setIconSize(QSize(22,22));
503

504
  connect( viewerLayoutBox_,SIGNAL( activated(int) ), this, SLOT( setViewerLayout(int) ) );
505

Jan Möbius's avatar
Jan Möbius committed
506
  extended_actions.push_back(viewerToolbar_->addWidget( viewerLayoutBox_ ));
507

Jan Möbius's avatar
Jan Möbius committed
508
  extended_actions.push_back(viewerToolbar_->addSeparator());
509 510 511 512 513 514 515 516

  if (OpenFlipper::Options::stereo())
  {
    stereoButton_ = new QToolButton( viewerToolbar_ );
    stereoButton_->setIcon(  QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"mono.png")  );
    stereoButton_->setMinimumSize( 16, 16 );
    stereoButton_->setMaximumSize( 32, 32 );
    stereoButton_->setCheckable( true );
Jan Möbius's avatar
Jan Möbius committed
517
    stereoButton_->setToolTip(tr( "Toggle stereo viewing"));
518 519
    // We want a custom context menu
    stereoButton_->setContextMenuPolicy(Qt::CustomContextMenu);
Jan Möbius's avatar
Jan Möbius committed
520
    stereoButton_->setWhatsThis(tr(
521 522 523 524
                  "Toggle stereo mode<br><br>"
                  "Use this button to switch between stereo "
                  "and mono view. To use this feature you need "
                  "a stereo capable graphics card and a stereo "
Jan Möbius's avatar
Jan Möbius committed
525
                  "display/projection system."));
526 527 528
    connect( stereoButton_, SIGNAL( clicked() ), this , SLOT( slotToggleStereoMode() ) );
    // Custom context menu
    connect( stereoButton_, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(stereoButtonContextMenu(const QPoint &)));
Jan Möbius's avatar
Jan Möbius committed
529 530 531
    QAction *stereoAction = viewerToolbar_->addWidget( stereoButton_ );
    stereoAction->setText( tr("Stereo"));
    extended_actions.push_back(stereoAction);
532
  }
533 534


535
  addToolBar(Qt::TopToolBarArea,viewerToolbar_);
Jan Möbius's avatar
Jan Möbius committed
536

Jan Möbius's avatar
 
Jan Möbius committed
537 538
  // Remember logger size
  wsizes = splitter_->sizes();
539 540 541 542 543 544

  if(wsizes.size() > 1) {
    originalLoggerSize_  = wsizes[1];
  } else {
    originalLoggerSize_ = 240;
  }
Jan Möbius's avatar
Jan Möbius committed
545

Jan Möbius's avatar
 
Jan Möbius committed
546
  // ======================================================================
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
547
  // Create ToolBox area
Jan Möbius's avatar
Jan Möbius committed
548
  // ======================================================================
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
549 550 551

  toolBoxArea_ = new QWidget (toolSplitter_);

552
  viewModeControlBox_ = new QGroupBox (tr("ViewMode"));
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
553 554 555

  QHBoxLayout *hLayout = new QHBoxLayout;

Jan Möbius's avatar
Jan Möbius committed
556 557
  vmChangeButton_ = new QPushButton(tr("Change View Mode"));
  QPushButton* vmEditButton   = new QPushButton(tr("Edit View Modes"));
558

Jan Möbius's avatar
Jan Möbius committed
559 560
  hLayout->addWidget(vmChangeButton_);
  hLayout->addWidget(vmEditButton);
561
  viewModeControlBox_->setLayout (hLayout);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
562

Jan Möbius's avatar
Jan Möbius committed
563 564
  connect(vmChangeButton_, SIGNAL(clicked()), this, SLOT(slotViewChangeDialog()));
  connect(vmEditButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
565 566 567 568 569 570 571 572

  toolBoxScroll_ = new QScrollArea ();
  toolBox_ = new SideArea ();
  toolBoxScroll_->setWidget (toolBox_);
  toolBoxScroll_->setWidgetResizable (true);
  toolBoxScroll_->setFrameStyle (QFrame::StyledPanel);

  QVBoxLayout *vLayout = new QVBoxLayout;
573
  vLayout->addWidget(viewModeControlBox_);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
574
  vLayout->addWidget(toolBoxScroll_);
575
  
Jan Möbius's avatar
Jan Möbius committed
576
  if ( OpenFlipperSettings().value("Core/Gui/TaskSwitcher/Hide",false).toBool() ) {
577
    viewModeControlBox_->hide();
Jan Möbius's avatar
Jan Möbius committed
578 579 580
    if (viewModeButton_)
        viewModeButton_->setVisible(false);
  }
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
581 582 583 584 585

  toolBoxArea_->setLayout (vLayout);

  wsizes = toolSplitter_->sizes();

586
  // if the toolbox should be on the right, use the defaults. Otherwise, we have to reorder them.
Jan Möbius's avatar
Jan Möbius committed
587
  if ( OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight", true).toBool() ) {
588

589 590 591 592 593
    // Set relative sizes of windows
    wsizes[0] = 480;
    wsizes[1] = 240;
    toolSplitter_->setSizes(wsizes);  
  } else {
594

595 596 597 598 599 600 601 602 603 604
    // Show tool box on the left side of the main window
    toolSplitter_->insertWidget(0, toolBoxArea_);
    toolSplitter_->insertWidget(1, splitter_);

    // Default sizes are swaped when toolbox is on the left.
    wsizes[0] = 240;
    wsizes[1] = 480;
    toolSplitter_->setSizes(wsizes);
  }
  
Jan Möbius's avatar
 
Jan Möbius committed
605 606 607
  // ======================================================================
  // Context menu setup
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
608

Jan Möbius's avatar
Jan Möbius committed
609 610 611 612
  for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
    connect( examiner_widgets_[i] , SIGNAL(signalCustomContextMenuRequested( const QPoint&) ) ,
             this                 , SLOT( slotCustomContextMenu( const QPoint&) ) );
  }
Jan Möbius's avatar
Jan Möbius committed
613

Dirk Wilden's avatar
 
Dirk Wilden committed
614
  contextMenu_ = new QMenu(this);
Jan Möbius's avatar
Jan Möbius committed
615
  contextSelectionMenu_ = new QMenu(tr("Selection"),0);
Jan Möbius's avatar
Jan Möbius committed
616

Jan Möbius's avatar
 
Jan Möbius committed
617
  setupMenuBar();
Jan Möbius's avatar
Jan Möbius committed
618

Jan Möbius's avatar
Jan Möbius committed
619
  statusBar_->showMessage(tr("Ready"), 5000);
Dirk Wilden's avatar
Dirk Wilden committed
620

621
  registerCoreKeys();
Dirk Wilden's avatar
Dirk Wilden committed
622

623
  setExamineMode();
624 625 626

  setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );

627 628 629 630
  // Create stereo settings widget
  stereoSettingsWidget_ = new StereoSettingsWidget(this);
  // Make it look like a dialog
  stereoSettingsWidget_->setWindowFlags(Qt::Popup);
631 632
  // Connect combo boxes and sliders to local slots
  connect(stereoSettingsWidget_->stereoOpengl, SIGNAL(clicked()),
633
          this, SLOT(slotApplyStereoSettings()));
634 635 636 637 638
  connect(stereoSettingsWidget_->stereoAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));

639 640
  connect(stereoSettingsWidget_->focalDistance, SIGNAL(sliderReleased()),
          this, SLOT(slotApplyStereoSettings()));
641 642 643 644 645 646
  connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
          this, SLOT(slotApplyStereoSettings()));

  // Close button
  connect(stereoSettingsWidget_->closeButton, SIGNAL(clicked()),
          stereoSettingsWidget_, SLOT(hide()));
647 648 649 650 651 652


  // ======================================================================
  // Help Browser start up
  // ======================================================================

653
  helpWidget_ = new HelpWidget(this,homePage_,false);
Matthias Möller's avatar
doc  
Matthias Möller committed
654 655
  connect(this, SIGNAL(changeHelpSite(QUrl)), helpWidget_, SLOT(activateLink(QUrl)));
  helpWidget_->hide();
656

Jan Möbius's avatar
Jan Möbius committed
657 658 659 660

  // Add the core license information about used libraries
  addCoreLicenseInfo();

Jan Möbius's avatar
 
Jan Möbius committed
661 662 663 664 665 666 667
}


//-----------------------------------------------------------------------------


CoreWidget::~CoreWidget() {
Jan Möbius's avatar
Jan Möbius committed
668

Jan Möbius's avatar
 
Jan Möbius committed
669 670 671 672 673 674 675 676
}

//-----------------------------------------------------------------------------

/** Set viewer to Fullscreen Mode and back
  */
void
CoreWidget::toggleFullscreen() {
Jan Möbius's avatar
Jan Möbius committed
677

678
  bool fullScreen = OpenFlipperSettings().value("Core/Gui/fullscreen", false ).toBool();
Dirk Wilden's avatar
Dirk Wilden committed
679

680
  setFullscreen( !fullScreen );
Jan Möbius's avatar
 
Jan Möbius committed
681 682 683 684
}

//-----------------------------------------------------------------------------

685 686 687 688 689 690 691 692 693 694 695
/** Enable or disable Fullscreen Mode
  */
void
CoreWidget::setFullscreen(bool _state ) {
  if ( _state )
    setWindowState( windowState() | Qt::WindowFullScreen);
  else {
    if ( windowState() & Qt::WindowFullScreen )
      setWindowState( windowState() ^  Qt::WindowFullScreen);
  }

Jan Möbius's avatar
Jan Möbius committed
696
  OpenFlipperSettings().setValue("Core/Gui/fullscreen", bool( windowState() & Qt::WindowFullScreen) );
697 698

  show();
699 700

  emit fullScreenChanged( _state );
701 702
}

703 704 705 706 707 708 709 710 711 712
//-----------------------------------------------------------------------------

void 
CoreWidget::showViewModeControls(bool _show) {
  // Only change if the actual setting has changed!
  if ( OpenFlipper::Options::gui() && ( !_show != OpenFlipperSettings().value("Core/Gui/TaskSwitcher/Hide",false).toBool() ) ) {
  
    // Update setting in Conf storage
    OpenFlipperSettings().setValue("Core/Gui/TaskSwitcher/Hide",!_show);
    
713 714 715 716 717
    // Update The Checkbox in the Menu
    AC_ShowViewModeControls_->blockSignals(true);
    AC_ShowViewModeControls_->setChecked( _show  );
    AC_ShowViewModeControls_->blockSignals(false);
    
718 719
    if ( _show ) {
      viewModeControlBox_->show();
Jan Möbius's avatar
Jan Möbius committed
720
      viewModeButton_->setVisible(true);
721 722
    } else {
      viewModeControlBox_->hide();
Jan Möbius's avatar
Jan Möbius committed
723
      viewModeButton_->setVisible(false);
724 725 726 727 728 729
    }
    
  }
  
}

Jan Möbius's avatar
 
Jan Möbius committed
730 731 732 733 734 735
//-----------------------------------------------------------------------------

/** Hide or show toolbox
  */
void
CoreWidget::toggleToolbox() {
Jan Möbius's avatar
Jan Möbius committed
736

Jan Möbius's avatar
 
Jan Möbius committed
737
  //toggle
Jan Möbius's avatar
Jan Möbius committed
738
  showToolbox( OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool() );
739

740 741 742 743 744 745 746 747 748 749
}

//-----------------------------------------------------------------------------

/** Hide or show toolbox
  */
void
CoreWidget::showToolbox( bool _state ) {

  //toggle
Jan Möbius's avatar
Jan Möbius committed
750
  OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/hidden",!_state);
Jan Möbius's avatar
 
Jan Möbius committed
751

Jan Möbius's avatar
Jan Möbius committed
752
  if ( OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool() ){
Jan Möbius's avatar
 
Jan Möbius committed
753 754

    //hide ViewMode Selection Widget
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
755
    toolBoxArea_->setVisible(false);
Jan Möbius's avatar
 
Jan Möbius committed
756 757

  }else{
758
    //show last view mode
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
759
    toolBoxArea_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
760
  }
761
  emit toolBoxVisChanged(_state);
Jan Möbius's avatar
 
Jan Möbius committed
762
}
763
//-----------------------------------------------------------------------------
764
void CoreWidget::showMenuBar( bool _state )
765
{
766 767 768 769 770
  OpenFlipperSettings().setValue("Core/Gui/MenuBar/hidden",!_state);

  if ( _state ){

    //hide ViewMode Selection Widget
771
    menuBar()->show();
772 773 774

  }else{
    //show last view mode
775
    menuBar()->hide();
776 777
  }
  emit menuBarVisChanged(_state);
778 779
}
//-----------------------------------------------------------------------------
780 781
/// Show or hide toolbar
void CoreWidget::showToolBar( bool _state )
782
{
783 784
  OpenFlipperSettings().setValue("Core/Gui/Toolbar/hidden",!_state);
  if ( !_state )
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804
  {
    //hide main toolbar
    if ( ! mainToolbar_->isFloating() )
      mainToolbar_->hide();

    //hide viewer toolbar
    if ( ! viewerToolbar_->isFloating() )
      viewerToolbar_->hide();

    for (uint p=0; p < plugins_.size(); p++)
      for ( uint j = 0 ; j < plugins_[p].toolbars.size(); ++j ) {
        if ( ! plugins_[p].toolbars[j].second->isFloating() )
          plugins_[p].toolbars[j].second->hide();
      }
  }
  else
  {
    //show toolbars
    setViewMode( OpenFlipper::Options::currentViewMode() );
  }
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
  emit toolBarVisChanged(_state);
}
//-----------------------------------------------------------------------------
/// Hide or show menubar
void CoreWidget::toggleMenuBar()
{
  bool hidden = OpenFlipperSettings().value("Core/Gui/MenuBar/hidden",false).toBool();
  showMenuBar( hidden );
}

//-----------------------------------------------------------------------------
/// Hide or show current toolbar
void CoreWidget::toggleToolBar()
{
  bool hidden = OpenFlipperSettings().value("Core/Gui/Toolbar/hidden",false).toBool();
  showToolBar( hidden );
821
}
Jan Möbius's avatar
Jan Möbius committed
822

823

824 825
//=============================================================================

826
void CoreWidget::setToolBoxOrientationOnTheRight(bool _toolBoxRight) {
827
  QList<int> wsizes;
Jan Möbius's avatar
Jan Möbius committed
828
  
829 830
  // Is toolbox currently on the right hand side?
  bool currentstate = toolSplitter_->widget(1) == toolBoxArea_;
Jan Möbius's avatar
Jan Möbius committed
831 832
  
  if ( _toolBoxRight != currentstate ) {
833
    
Jan Möbius's avatar
Jan Möbius committed
834 835 836 837 838 839 840 841 842 843 844
    if(_toolBoxRight ) {
      
      // Show tool box on the right side of the main window
      toolSplitter_->insertWidget(0, splitter_);
      toolSplitter_->insertWidget(1, toolBoxArea_);
    } else {
      
      // Show tool box on the left side of the main window
      toolSplitter_->insertWidget(0, toolBoxArea_);
      toolSplitter_->insertWidget(1, splitter_);
    }
845
    
Jan Möbius's avatar
Jan Möbius committed
846
    // Store new setting
Jan Möbius's avatar
Jan Möbius committed
847
    OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight",_toolBoxRight);
848
    
Jan Möbius's avatar
Jan Möbius committed
849 850
    // remove the windowstates definition for the toolboxes, as it changed anyway.
    QSettings windowStates(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
851
                            OpenFlipper::Options::dirSeparator() +  "WindowStates.dat", QSettings::IniFormat);
Jan Möbius's avatar
Jan Möbius committed
852 853
    
    windowStates.value("Core/ToolSplitter");
854 855 856
    
  }
  
Jan Möbius's avatar
Jan Möbius committed
857

858 859 860 861 862
    
  toolSplitter_->refresh();
}
      

Jan Möbius's avatar
 
Jan Möbius committed
863 864
//=============================================================================

Jan Möbius's avatar
Jan Möbius committed
865 866
void
CoreWidget::addRecent(QString _filename, DataType _type)
Jan Möbius's avatar
 
Jan Möbius committed
867
{
868
  //dont add objects to recentMenu while loadind Settings
869
  if ( OpenFlipper::Options::sceneGraphUpdatesBlocked() ) return;
Jan Möbius's avatar
Jan Möbius committed
870

Jan Möbius's avatar
 
Jan Möbius committed
871
  OpenFlipper::Options::addRecentFile(_filename, _type);
Jan Möbius's avatar
Jan Möbius committed
872

Jan Möbius's avatar
 
Jan Möbius committed
873
  updateRecent();
Jan Möbius's avatar
Jan Möbius committed
874 875 876 877 878 879 880

}

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

void
CoreWidget::updateRecent()
Jan Möbius's avatar
 
Jan Möbius committed
881 882 883
{
  if ( recentFilesMenu_ == NULL)
    return;
Jan Möbius's avatar
Jan Möbius committed
884

Jan Möbius's avatar
 
Jan Möbius committed
885 886
  recentFilesMenu_->clear();

887 888
  QStringList recentFiles = OpenFlipperSettings().value("Core/File/RecentFiles", QStringList()).toStringList();
  QStringList recentTypes = OpenFlipperSettings().value("Core/File/RecentTypes", QStringList()).toStringList();
889

Jan Möbius's avatar
 
Jan Möbius committed
890
  for (int i = 0 ; i < recentFiles.size() ; ++i ) {
891

892
    QFileInfo fi(recentFiles[i]);
893

894 895 896 897
    QAction* newAction = 0;

    if (fi.suffix() == "ini") {
      newAction = recentFilesMenu_->addAction(QIcon(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator()+"Settings-Icon.png"), recentFiles[i]);
898
      newAction->setData( QVariant( QString("Unknown") ) );
899 900 901 902
    } else {
      newAction = recentFilesMenu_->addAction(typeIcon( typeId(recentTypes[i]) ), recentFiles[i]);
      newAction->setData( QVariant( recentTypes[i]) );
    }
903

Jan Möbius's avatar
 
Jan Möbius committed
904 905
  }

Jan Möbius's avatar
Jan Möbius committed
906 907 908
}

void
Jan Möbius's avatar
 
Jan Möbius committed
909 910 911
CoreWidget::closeEvent ( QCloseEvent * /* event */ ) {
  emit exit();
}
912 913

void CoreWidget::showOptionsWidget() {
Jan Möbius's avatar
Jan Möbius committed
914

915 916
  if ( OpenFlipper::Options::nogui() )
    return;
Jan Möbius's avatar
Jan Möbius committed
917

918
  if ( optionsWidget_ == 0 ) {
Dirk Wilden's avatar
Dirk Wilden committed
919
    optionsWidget_ = new OptionsWidget(plugins_, coreKeys_, invKeys_, 0);
920
    connect(optionsWidget_,SIGNAL(applyOptions()),this,SIGNAL(applyOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
921
    connect(optionsWidget_,SIGNAL(saveOptions()),this,SIGNAL(saveOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
922 923
    connect(optionsWidget_,SIGNAL(addKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)),
            this,          SLOT(slotAddKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)));
924 925

    optionsWidget_->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
926
  }
Dirk Wilden's avatar
Dirk Wilden committed
927

Jan Möbius's avatar
Jan Möbius committed
928
  //show the optionsWidget centered
Dirk Wilden's avatar
Dirk Wilden committed
929
  QPoint center;
Jan Möbius's avatar
Jan Möbius committed
930
  center.setX( x() + width() / 2 );
Dirk Wilden's avatar
Dirk Wilden committed
931 932
  center.setY( y() + height() / 2 );

Dirk Wilden's avatar
Dirk Wilden committed
933 934
  optionsWidget_->setGeometry(center.x() - optionsWidget_->width() / 2,
                              center.y() - optionsWidget_->height()/ 2, optionsWidget_->width(), optionsWidget_->height());
Dirk Wilden's avatar
Dirk Wilden committed
935

936
  optionsWidget_->show();
Jan Möbius's avatar
Jan Möbius committed
937

938
}
Jan Möbius's avatar
Jan Möbius committed
939

940
void CoreWidget::nextViewerLayout() {
941

Jan Möbius's avatar
Jan Möbius committed
942 943 944 945 946
  if ( OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() ) {

    switch (baseLayout_->mode()) {
      case QtMultiViewLayout::SingleView:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
Jan Möbius's avatar
Jan Möbius committed
947
              baseLayout_->setMode(QtMultiViewLayout::DoubleView);
Jan Möbius's avatar
Jan Möbius committed
948 949 950 951

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(1);
              break;
Jan Möbius's avatar
Jan Möbius committed
952 953 954 955 956 957 958
      case QtMultiViewLayout::DoubleView:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
              baseLayout_->setMode(QtMultiViewLayout::Grid);

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(2);
              break;
Jan Möbius's avatar
Jan Möbius committed
959 960 961 962 963
      case QtMultiViewLayout::Grid:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
              baseLayout_->setMode(QtMultiViewLayout::HSplit);

              // Update combo box in the toolbar
Jan Möbius's avatar
Jan Möbius committed
964
              viewerLayoutBox_->setCurrentIndex(3);
Jan Möbius's avatar
Jan Möbius committed
965 966 967 968 969 970 971 972 973 974
              break;
      case QtMultiViewLayout::HSplit:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
              baseLayout_->setMode(QtMultiViewLayout::SingleView);

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(0);
              break;
      }
  }
975 976 977 978
}


void
979
CoreWidget::setViewerLayout(int _idx) {
980

Jan Möbius's avatar
Jan Möbius committed
981 982
  if ( OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() ) {

983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
    switch (_idx) {
      case 0:
        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
        baseLayout_->setMode(QtMultiViewLayout::SingleView);
        break;
      case 1:
        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
        baseLayout_->setMode(QtMultiViewLayout::DoubleView);
        break;
      case 2:
        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
        baseLayout_->setMode(QtMultiViewLayout::Grid);
        break;
      case 3:
        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
        baseLayout_->setMode(QtMultiViewLayout::HSplit);
        break;
      default:
        emit log(LOGERR,tr("Requested illegal multiview mode!"));
Jan Möbius's avatar
Jan Möbius committed
1002
        break;
1003
    }
1004 1005

    viewerLayoutBox_->setCurrentIndex(_idx);
Jan Möbius's avatar
Jan Möbius committed
1006
  }
1007

1008
}
Jan Möbius's avatar
 
Jan Möbius committed
1009

1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
void
CoreWidget::slotShowSceneGraphDialog()
{
  if ( PluginFunctions::getSceneGraphRootNode() )
  {
    if (!sceneGraphDialog_)
    {
      sceneGraphDialog_ = new ACG::QtWidgets::QtSceneGraphDialog( this, PluginFunctions::getSceneGraphRootNode() );

      for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
        connect(examiner_widgets_[i], SIGNAL(signalSceneGraphChanged(ACG::SceneGraph::BaseNode*)),
                sceneGraphDialog_,    SLOT(update(ACG::SceneGraph::BaseNode*)));

        connect(sceneGraphDialog_, SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
1024
                examiner_widgets_[i], SLOT(updateGL()));
1025 1026 1027 1028
      }

    }

1029
    sceneGraphDialog_->setGeneratorMap(PluginFunctions::getSceneGraphGeneratorList() );
1030 1031 1032 1033
    sceneGraphDialog_->show();
  }
}

Jan Möbius's avatar
 
Jan Möbius committed
1034 1035 1036
//-----------------------------------------------------------------------------

void
1037
CoreWidget::sceneRectChanged(const QRectF &rect)
Jan Möbius's avatar
 
Jan Möbius committed
1038
{
1039 1040
  centerWidget_->setGeometry (rect);
  slidingLogger_->updateGeometry ();
Jan Möbius's avatar
 
Jan Möbius committed
1041 1042
}

Dirk Wilden's avatar
Dirk Wilden committed
1043 1044 1045 1046 1047 1048
//-----------------------------------------------------------------------------

void
CoreWidget::startVideoCaptureDialog(){

  VideoCaptureDialog* dialog = new VideoCaptureDialog();
1049
  dialog->setModal(false);
Dirk Wilden's avatar
Dirk Wilden committed
1050 1051

  connect(dialog, SIGNAL(startVideoCapture(QString,int,bool)), this, SIGNAL(startVideoCapture(QString,int,bool)) );
1052 1053 1054
  connect(dialog, SIGNAL(resizeViewers(int,int)), this, SIGNAL(resizeViewers(int,int)) );
  connect(dialog, SIGNAL(resizeApplication(int,int)), this, SIGNAL(resizeApplication(int,int)) );

Dirk Wilden's avatar
Dirk Wilden committed
1055 1056
  dialog->show();
}
Jan Möbius's avatar
 
Jan Möbius committed
1057

1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
//-----------------------------------------------------------------------------

void CoreWidget::slotActivateExaminer()
{
  glViewer* examiner = dynamic_cast<glViewer*>(QObject::sende