CoreWidget.cc 35.3 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2
3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
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
*                           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/>.                                       *
*                                                                            *
33
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
34

35
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36
37
38
39
40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
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
58
59
60



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


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

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

// -------------------- OpenFlipper Includes
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/common/RecentFiles.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
Jan Möbius's avatar
   
Jan Möbius committed
61
#include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
Dirk Wilden's avatar
Dirk Wilden committed
62
63
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
Jan Möbius's avatar
 
Jan Möbius committed
64

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

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
67
68
#include <OpenFlipper/widgets/glWidget/CursorPainter.hh>

Matthias Möller's avatar
doc    
Matthias Möller committed
69
70
71
72
// -------------------- Qt event Includes
#include <QEvent>
#include <QWhatsThisClickedEvent>

Jan Möbius's avatar
 
Jan Möbius committed
73
74
75
#define WIDGET_HEIGHT 800
#define WIDGET_WIDTH  800

Jan Möbius's avatar
Jan Möbius committed
76
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
77

78
79
80
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
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_;
}

108
109
110
111
void PickMode::cursor(const QCursor _cursor) {
  cursor_ = _cursor;
}

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
QCursor PickMode::cursor() const{
  return cursor_;
}

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

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









132
/** \brief Constructor for the Core Widget
Jan Möbius's avatar
Jan Möbius committed
133
 *
Jan Möbius's avatar
 
Jan Möbius committed
134
135
*/
CoreWidget::
Dirk Wilden's avatar
Dirk Wilden committed
136
CoreWidget( QVector<ViewMode*>& _viewModes,
Dirk Wilden's avatar
Dirk Wilden committed
137
138
            std::vector<PluginInfo>& _plugins,
            QList< SlotInfo >& _coreSlots ) :
Jan Möbius's avatar
 
Jan Möbius committed
139
  QMainWindow(),
Dirk Wilden's avatar
Dirk Wilden committed
140
  coreSlots_(_coreSlots),
Dirk Wilden's avatar
Dirk Wilden committed
141
  shiftPressed_(false),
Dirk Wilden's avatar
Dirk Wilden committed
142
  fullscreenState_(0),
Jan Möbius's avatar
 
Jan Möbius committed
143
144
  viewModes_(_viewModes),
  viewModeButton_(0),
145
  viewModeMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
146
  splitter_(0),
147
  logWidget_(0),
Jan Möbius's avatar
 
Jan Möbius committed
148
  recentFilesMenu_(0),
149
  helpMenu_(0),
150
151
152
  windowMenu_(0),
  AC_ShowViewModeControls_(0),
  AC_ShowToolbox_(0),
153
  pickToolBarExternal_(0),
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
154
  cursorPainter_(0),
155
  sceneGraphDialog_(0),
156
157
158
  fileMenu_(0),
  viewMenu_(0),
  toolsMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
159
  fileMenuEnd_(0),
160
161
162
  stereoButton_(0),
  moveButton_(0),
  pickButton_(0),
Dirk Wilden's avatar
Dirk Wilden committed
163
  questionButton_(0),
164
  globalDrawMenu_(0),
165
166
  rendererMenu_(0),
  postprocessorMenu_(0),
167
  drawGroup_(0),
168
169
  rendererGroup_(0),
  postProcessorGroup_(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),
178
  coordSysMenu_(0),
179
  snapshotName_(""),
Dirk Wilden's avatar
Dirk Wilden committed
180
  snapshotCounter_(0),
Jan Möbius's avatar
 
Jan Möbius committed
181
  stackMenu_(0),
182
  helpWidget_(0),
183
  stereoSettingsWidget_(0),
Jan Möbius's avatar
Jan Möbius committed
184
  aboutWidget_(0),
185
  optionsWidget_(0),
186
  plugins_(_plugins),
187
188
189
190
191
192
  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
193
{
Matthias Möller's avatar
doc    
Matthias Möller committed
194

Jan Möbius's avatar
 
Jan Möbius committed
195
  setupStatusBar();
Jan Möbius's avatar
Jan Möbius committed
196

Dirk Wilden's avatar
Dirk Wilden committed
197
198
  defaultIconSize_ = iconSize();

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
199
200
201
202
203
  toolSplitter_ = new QSplitter(Qt::Horizontal,this);

  setCentralWidget(toolSplitter_);

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

206
207
  QGLFormat format = QGLFormat::defaultFormat();

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

  // Construct GL context & widget
219
220
221
  baseLayout_ = new QtMultiViewLayout;
  baseLayout_->setContentsMargins(0,0,0,0);

222
223
224
  // ===============================================================================
  // Test context capabilities ...
  // If we get stereo buffers, we use them .. which might disable multisampling
225
  // If we don't have stereo, we disable it to not interfere with multisampling
226
227
228
229
230
231
232
233
234
235
236
237
238
  // ===============================================================================
  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;

  glWidget_ = new QGLWidget(format,0);
239
  PluginFunctions::shareGLWidget (glWidget_);
240

Jan Möbius's avatar
   
Jan Möbius committed
241
  glView_ = new QtGLGraphicsView(stackedWidget_);
242
  glScene_ = new QtGLGraphicsScene (&examiner_widgets_, baseLayout_);
Jan Möbius's avatar
   
Jan Möbius committed
243

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

Jan Möbius's avatar
   
Jan Möbius committed
247
248
249
  glView_->setViewport(glWidget_);
  glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  glView_->setScene(glScene_);
250
  glView_->setFrameStyle(QFrame::NoFrame);
Jan Möbius's avatar
   
Jan Möbius committed
251

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
252
253
  // 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
254
  cursorPainter_->setForceNative (OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
255
  cursorPainter_->setEnabled (stereoActive_);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
256
  glScene_->setCursorPainter (cursorPainter_);
257

Jan Möbius's avatar
   
Jan Möbius committed
258
259
260
261
262
263
264
265
266
267
  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
268
269
270
  // ======================================================================
  // Set up the logging window
  // ======================================================================
271

272
  slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
273

274
275
  logWidget_ = new LoggerWidget(splitter_);
  logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
276
  logWidget_->resize( splitter_->width() ,240);
Jan Möbius's avatar
Jan Möbius committed
277

278
  originalLoggerSize_ = 0;
Jan Möbius's avatar
Jan Möbius committed
279
  loggerState_ = OpenFlipper::Options::Normal;
280

281
282
283
284
285
  QList<int> wsizes(splitter_->sizes());
  // Set initial values to have a usable state
  wsizes[0] = 480;
  wsizes[1] = 240;
  splitter_->setSizes(wsizes);
286

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

289
    slidingLogger_->attachWidget (logWidget_);
290
    showLoggerInSplitView(false);
Jan Möbius's avatar
Jan Möbius committed
291
    loggerState_ = OpenFlipper::Options::InScene;
292

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

295
    showLoggerInSplitView(false);
Jan Möbius's avatar
Jan Möbius committed
296
297
    loggerState_ = OpenFlipper::Options::Hidden;
  } else {
298
299

    showLoggerInSplitView(true);
Jan Möbius's avatar
 
Jan Möbius committed
300
  }
Jan Möbius's avatar
Jan Möbius committed
301

302

Jan Möbius's avatar
 
Jan Möbius committed
303
304
305
  // ======================================================================
  // Create examiner
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
306

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

Jan Möbius's avatar
   
Jan Möbius committed
309
310
    glViewer* examinerWidget = new glViewer(glScene_,
					    glWidget_,
311
                                            PluginFunctions::viewerProperties(0),
312
					    centerWidget_);
Jan Möbius's avatar
Jan Möbius committed
313

Jan Möbius's avatar
Jan Möbius committed
314
315
316
    examiner_widgets_.push_back(examinerWidget);

    examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
Jan Möbius's avatar
Jan Möbius committed
317

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

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

Jan Möbius's avatar
Jan Möbius committed
322
323
324
  } else {


Jan Möbius's avatar
   
Jan Möbius committed
325
326
327
328
    // Create examiners
    for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
      glViewer* newWidget = new glViewer(glScene_,
					 glWidget_,
329
                                         PluginFunctions::viewerProperties(i),
330
					 centerWidget_);
Dirk Wilden's avatar
Dirk Wilden committed
331

Jan Möbius's avatar
Jan Möbius committed
332
      examiner_widgets_.push_back(newWidget);
333
334
335
336
337
338
339
340
341
342

      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 );

343
      connect (&PluginFunctions::viewerProperties(i), SIGNAL( drawModeChanged(int)), this, SIGNAL(drawModeChanged(int)));
Jan Möbius's avatar
Jan Möbius committed
344
345
346
347
348
    }

    // Initialize all examiners
    for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
      examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
349
      cursorPainter_->registerViewer (examiner_widgets_[i]);
Jan Möbius's avatar
Jan Möbius committed
350
351
    }

Jan Möbius's avatar
Jan Möbius committed
352
353
354
355
    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
356
357
  }

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

Jan Möbius's avatar
   
Jan Möbius committed
361
  centerWidget_->setLayout(baseLayout_);
362
363


Jan Möbius's avatar
 
Jan Möbius committed
364
365
366
  // ======================================================================
  // Setup dragging for examiner widget
  // ======================================================================
367
368
369
370
371
372
373
374
  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* )));
375
376
    connect (examiner_widgets_[i], SIGNAL(signalMakeActive ()),
             this, SLOT(slotActivateExaminer()));
377
378
379

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


Jan Möbius's avatar
 
Jan Möbius committed
383
384
385
  // ======================================================================
  // Create main Toolbar
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
386

Jan Möbius's avatar
Jan Möbius committed
387
388
389
  mainToolbar_ = new QToolBar(tr("Main Toolbar"));
  mainToolbar_->setWindowTitle(tr("Main Toolbar"));
  mainToolbar_->setObjectName(tr("MainToolbar"));
390
  slotAddToolbar(mainToolbar_);
Jan Möbius's avatar
Jan Möbius committed
391

Jan Möbius's avatar
 
Jan Möbius committed
392
393
394
  // ======================================================================
  // Get Toolbar from examiner and integrate it into main window
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
395

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

397
  // Create the toolbar
Jan Möbius's avatar
Jan Möbius committed
398
  viewerToolbar_ = new QToolBar( tr("Viewer Toolbar" ), this );
399
  viewerToolbar_->setOrientation(Qt::Vertical);
Jan Möbius's avatar
 
Jan Möbius committed
400
401
  viewerToolbar_->setAllowedAreas(Qt::AllToolBarAreas);
  viewerToolbar_->setIconSize(QSize(20,20));
Jan Möbius's avatar
Jan Möbius committed
402
  viewerToolbar_->setObjectName(tr("ViewerToolbar"));
403

Jan Möbius's avatar
Jan Möbius committed
404
  slotAddToolbar(viewerToolbar_);
Jan Möbius's avatar
Jan Möbius committed
405

406
407
408
409
  moveButton_ = new QToolButton( viewerToolbar_ );
  moveButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"transform-move.png") );
  moveButton_->setMinimumSize( 16, 16 );
  moveButton_->setMaximumSize( 32, 32 );
Jan Möbius's avatar
Jan Möbius committed
410
411
  moveButton_->setToolTip( tr("Switch to <b>move</b> mode.") );
  moveButton_->setWhatsThis(tr(
412
413
414
                  "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
415
                  "<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" ));
416
417

  connect( moveButton_,SIGNAL( clicked() ), this, SLOT( setExamineMode() ) );
418
/*
419
  connect( this, SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
420
            this, SLOT(   slotActionModeChanged(Viewer::ActionMode) ) );*/
421

Jan Möbius's avatar
Jan Möbius committed
422
  viewerToolbar_->addWidget( moveButton_ )->setText(tr("Move"));
423
424
  moveButton_->setDown(true);

425
  
426
427
428
429
  pickButton_ = new QToolButton( viewerToolbar_ );
  pickButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"pick.png") );
  pickButton_->setMinimumSize( 16, 16 );
  pickButton_->setMaximumSize( 32, 32 );
Jan Möbius's avatar
Jan Möbius committed
430
431
  pickButton_->setToolTip(tr("Switch to <b>picking</b> mode."));
  pickButton_->setWhatsThis(tr(
432
433
434
                  "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
435
                  "context menu in the viewer."));
436
  connect( pickButton_,SIGNAL( clicked() ), this, SLOT( setPickingMode() ) );
Jan Möbius's avatar
Jan Möbius committed
437
  viewerToolbar_->addWidget( pickButton_)->setText(tr("Pick"));
438
439
440
441
442
443


  questionButton_ = new QToolButton( viewerToolbar_ );
  questionButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png") );
  questionButton_->setMinimumSize( 16, 16 );
  questionButton_->setMaximumSize( 32, 32 );
Jan Möbius's avatar
Jan Möbius committed
444
445
  questionButton_->setToolTip(tr("Switch to <b>identification</b> mode."));
  questionButton_->setWhatsThis(tr(
446
447
448
449
                  "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
450
                  "object."));
451
  connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
Jan Möbius's avatar
Jan Möbius committed
452
  viewerToolbar_->addWidget( questionButton_)->setText(tr("Question"));
453

454
455
456
457
458
459
460
461
  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: "
462
                  "<ul> "
463
				  "<li>Single viewer</li>"
Jan Möbius's avatar
Jan Möbius committed
464
          "<li>Double viewer</li>"
465
466
				  "<li>Multiple viewers (grid)</li>"
				  "<li>Multiple viewers (hsplit)</li>"
Jan Möbius's avatar
Jan Möbius committed
467
				  "</ul>"));
468

469
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"singleviewmode.png"), "");
Jan Möbius's avatar
Jan Möbius committed
470
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"doubleviewmode.png"), "");
471
472
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode1.png"), "");
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode2.png"), "");
473

474
  viewerLayoutBox_->setIconSize(QSize(22,22));
475

476
  connect( viewerLayoutBox_,SIGNAL( activated(int) ), this, SLOT( setViewerLayout(int) ) );
477

478
  viewerToolbar_->addWidget( viewerLayoutBox_ );
479

480
481
482
483
484
485
486
487
488
  viewerToolbar_->addSeparator();

  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
489
    stereoButton_->setToolTip(tr( "Toggle stereo viewing"));
490
491
    // We want a custom context menu
    stereoButton_->setContextMenuPolicy(Qt::CustomContextMenu);
Jan Möbius's avatar
Jan Möbius committed
492
    stereoButton_->setWhatsThis(tr(
493
494
495
496
                  "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
497
                  "display/projection system."));
498
499
500
    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
501
    viewerToolbar_->addWidget( stereoButton_ )->setText( tr("Stereo"));
502
  }
503
504


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

Jan Möbius's avatar
 
Jan Möbius committed
507
508
  // Remember logger size
  wsizes = splitter_->sizes();
509
510
511
512
513
514

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

Jan Möbius's avatar
 
Jan Möbius committed
516
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
517
  // Create ToolBox area
Jan Möbius's avatar
Jan Möbius committed
518
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
519
520
521

  toolBoxArea_ = new QWidget (toolSplitter_);

522
  viewModeControlBox_ = new QGroupBox (tr("ViewMode"));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
523
524
525

  QHBoxLayout *hLayout = new QHBoxLayout;

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

Jan Möbius's avatar
Jan Möbius committed
529
530
  hLayout->addWidget(vmChangeButton_);
  hLayout->addWidget(vmEditButton);
531
  viewModeControlBox_->setLayout (hLayout);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
532

Jan Möbius's avatar
Jan Möbius committed
533
534
  connect(vmChangeButton_, SIGNAL(clicked()), this, SLOT(slotViewChangeDialog()));
  connect(vmEditButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
535
536
537
538
539
540
541
542

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

  QVBoxLayout *vLayout = new QVBoxLayout;
543
  vLayout->addWidget(viewModeControlBox_);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
544
  vLayout->addWidget(toolBoxScroll_);
545
546
547
  
  if ( OpenFlipperSettings().value("Core/Gui/TaskSwitcher/Hide",false).toBool() )
    viewModeControlBox_->hide();
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
548
549
550
551
552

  toolBoxArea_->setLayout (vLayout);

  wsizes = toolSplitter_->sizes();

553
  // 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
554
  if ( OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight", true).toBool() ) {
555

556
557
558
559
560
    // Set relative sizes of windows
    wsizes[0] = 480;
    wsizes[1] = 240;
    toolSplitter_->setSizes(wsizes);  
  } else {
561

562
563
564
565
566
567
568
569
570
571
    // 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
572
573
574
  // ======================================================================
  // Context menu setup
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
575

Jan Möbius's avatar
Jan Möbius committed
576
577
578
579
  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
580

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

Jan Möbius's avatar
 
Jan Möbius committed
584
  setupMenuBar();
Jan Möbius's avatar
Jan Möbius committed
585

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

588
  registerCoreKeys();
Dirk Wilden's avatar
Dirk Wilden committed
589

590
  setExamineMode();
591
592
593

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

594
595
596
597
  // Create stereo settings widget
  stereoSettingsWidget_ = new StereoSettingsWidget(this);
  // Make it look like a dialog
  stereoSettingsWidget_->setWindowFlags(Qt::Popup);
598
599
  // Connect combo boxes and sliders to local slots
  connect(stereoSettingsWidget_->stereoOpengl, SIGNAL(clicked()),
600
          this, SLOT(slotApplyStereoSettings()));
601
602
603
604
605
  connect(stereoSettingsWidget_->stereoAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));

606
607
  connect(stereoSettingsWidget_->focalDistance, SIGNAL(sliderReleased()),
          this, SLOT(slotApplyStereoSettings()));
608
609
610
611
612
613
  connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
          this, SLOT(slotApplyStereoSettings()));

  // Close button
  connect(stereoSettingsWidget_->closeButton, SIGNAL(clicked()),
          stereoSettingsWidget_, SLOT(hide()));
614
615
616
617
618
619


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

Matthias Möller's avatar
doc    
Matthias Möller committed
620
621
622
  helpWidget_ = new HelpWidget(this);
  connect(this, SIGNAL(changeHelpSite(QUrl)), helpWidget_, SLOT(activateLink(QUrl)));
  helpWidget_->hide();
623

Jan Möbius's avatar
 
Jan Möbius committed
624
625
626
627
628
629
630
}


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


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

Jan Möbius's avatar
 
Jan Möbius committed
632
633
634
635
636
637
638
639
}

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

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

Dirk Wilden's avatar
Dirk Wilden committed
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
  switch (fullscreenState_){

    case 0:
      //switch to fullscreen
      setWindowState( windowState() | Qt::WindowFullScreen);
      break;

    case 1:

      //fullscreen without toolbars
      if ( ! (windowState() & Qt::WindowFullScreen) )
        setWindowState( windowState() | Qt::WindowFullScreen);

      //hide plugin toolbars
      for (uint p=0; p < plugins_.size(); p++)
656
657
658
659
        for ( uint j = 0 ; j < plugins_[p].toolbars.size(); ++j ) {
          if ( ! plugins_[p].toolbars[j].second->isFloating() )
            plugins_[p].toolbars[j].second->hide();
        }
Dirk Wilden's avatar
Dirk Wilden committed
660
661

      //hide main toolbar
662
663
      if ( ! mainToolbar_->isFloating() )
        mainToolbar_->hide();
Dirk Wilden's avatar
Dirk Wilden committed
664
665

      //hide viewer toolbar
666
667
      if ( ! viewerToolbar_->isFloating() )
        viewerToolbar_->hide();
Dirk Wilden's avatar
Dirk Wilden committed
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682

      //hide the menubar
      menuBar()->hide();

      //hide the statusbar
      statusBar()->hide();

      break;

    default:
      //disable fullscreen
      if ( windowState() & Qt::WindowFullScreen )
        setWindowState( windowState() ^  Qt::WindowFullScreen);

      //show toolbars
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
683
      setViewMode( OpenFlipper::Options::currentViewMode() );
Dirk Wilden's avatar
Dirk Wilden committed
684
685
686
687
688
689
690

      //show the menubar
      menuBar()->show();

      //show the statusbar
      statusBar()->show();

Jan Möbius's avatar
Jan Möbius committed
691
692
      break;

Dirk Wilden's avatar
Dirk Wilden committed
693
694
695
  }

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

Jan Möbius's avatar
 
Jan Möbius committed
699
700
701
702
703
  show();
}

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

704
705
706
707
708
709
710
711
712
713
714
/** 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);
  }

Dirk Wilden's avatar
Dirk Wilden committed
715
716
  fullscreenState_ = (uint) _state;

Jan Möbius's avatar
Jan Möbius committed
717
  OpenFlipperSettings().setValue("Core/Gui/fullscreen", bool( windowState() & Qt::WindowFullScreen) );
718
719
720
721

  show();
}

722
723
724
725
726
727
728
729
730
731
//-----------------------------------------------------------------------------

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);
    
732
733
734
735
736
    // Update The Checkbox in the Menu
    AC_ShowViewModeControls_->blockSignals(true);
    AC_ShowViewModeControls_->setChecked( _show  );
    AC_ShowViewModeControls_->blockSignals(false);
    
737
738
739
740
741
742
743
744
745
746
    if ( _show ) {
      viewModeControlBox_->show();
    } else {
      viewModeControlBox_->hide();
    }
    
  }
  
}

Jan Möbius's avatar
 
Jan Möbius committed
747
748
749
750
751
752
//-----------------------------------------------------------------------------

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

Jan Möbius's avatar
 
Jan Möbius committed
754
  //toggle
Jan Möbius's avatar
Jan Möbius committed
755
  showToolbox( OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool() );
756
757
758
759
760
761
762
763
764
765
}

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

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

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

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

    //hide ViewMode Selection Widget
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
771
    toolBoxArea_->setVisible(false);
Jan Möbius's avatar
 
Jan Möbius committed
772
773
774

  }else{
    //reset last ViewMode
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
775
    if (OpenFlipper::Options::currentViewMode().trimmed() == "")
Jan Möbius's avatar
 
Jan Möbius committed
776
777
      setViewMode("All");
    else
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
778
      setViewMode( OpenFlipper::Options::currentViewMode() );
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
779
    toolBoxArea_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
780
781
  }
}
Jan Möbius's avatar
Jan Möbius committed
782

783

784
785
//=============================================================================

786
void CoreWidget::setToolBoxOrientationOnTheRight(bool _toolBoxRight) {
787
  QList<int> wsizes;
Jan Möbius's avatar
Jan Möbius committed
788
  
789
790
  // Is toolbox currently on the right hand side?
  bool currentstate = toolSplitter_->widget(1) == toolBoxArea_;
Jan Möbius's avatar
Jan Möbius committed
791
792
  
  if ( _toolBoxRight != currentstate ) {
793
    
Jan Möbius's avatar
Jan Möbius committed
794
795
796
797
798
799
800
801
802
803
804
    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_);
    }
805
    
Jan Möbius's avatar
Jan Möbius committed
806
    // Store new setting
Jan Möbius's avatar
Jan Möbius committed
807
    OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight",_toolBoxRight);
808
    
Jan Möbius's avatar
Jan Möbius committed
809
810
    // remove the windowstates definition for the toolboxes, as it changed anyway.
    QSettings windowStates(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
811
                            OpenFlipper::Options::dirSeparator() +  "WindowStates.dat", QSettings::IniFormat);
Jan Möbius's avatar
Jan Möbius committed
812
813
    
    windowStates.value("Core/ToolSplitter");
814
815
816
    
  }
  
Jan Möbius's avatar
Jan Möbius committed
817

818
819
820
821
822
    
  toolSplitter_->refresh();
}
      

Jan Möbius's avatar
 
Jan Möbius committed
823
824
//=============================================================================

Jan Möbius's avatar
Jan Möbius committed
825
826
void
CoreWidget::addRecent(QString _filename, DataType _type)
Jan Möbius's avatar
 
Jan Möbius committed
827
{
828
829
  //dont add objects to recentMenu while loadind Settings
  if ( OpenFlipper::Options::loadingSettings() ) return;
Jan Möbius's avatar
Jan Möbius committed
830

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

Jan Möbius's avatar
 
Jan Möbius committed
833
  updateRecent();
Jan Möbius's avatar
Jan Möbius committed
834
835
836
837
838
839
840

}

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

void
CoreWidget::updateRecent()
Jan Möbius's avatar
 
Jan Möbius committed
841
842
843
{
  if ( recentFilesMenu_ == NULL)
    return;
Jan Möbius's avatar
Jan Möbius committed
844

Jan Möbius's avatar
 
Jan Möbius committed
845
846
  recentFilesMenu_->clear();

847
848
  QStringList recentFiles = OpenFlipperSettings().value("Core/File/RecentFiles", QStringList()).toStringList();
  QStringList recentTypes = OpenFlipperSettings().value("Core/File/RecentTypes", QStringList()).toStringList();
849

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

852
    QFileInfo fi(recentFiles[i]);
853

854
855
856
857
    QAction* newAction = 0;

    if (fi.suffix() == "ini") {
      newAction = recentFilesMenu_->addAction(QIcon(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator()+"Settings-Icon.png"), recentFiles[i]);
858
      newAction->setData( QVariant( QString("Unknown") ) );
859
860
861
862
    } else {
      newAction = recentFilesMenu_->addAction(typeIcon( typeId(recentTypes[i]) ), recentFiles[i]);
      newAction->setData( QVariant( recentTypes[i]) );
    }
863

Jan Möbius's avatar
 
Jan Möbius committed
864
865
  }

Jan Möbius's avatar
Jan Möbius committed
866
867
868
}

void
Jan Möbius's avatar
 
Jan Möbius committed
869
870
871
CoreWidget::closeEvent ( QCloseEvent * /* event */ ) {
  emit exit();
}
872
873

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

875
876
  if ( OpenFlipper::Options::nogui() )
    return;
Jan Möbius's avatar
Jan Möbius committed
877

878
  if ( optionsWidget_ == 0 ) {
Dirk Wilden's avatar
Dirk Wilden committed
879
    optionsWidget_ = new OptionsWidget(plugins_, coreKeys_, invKeys_, 0);
880
    connect(optionsWidget_,SIGNAL(applyOptions()),this,SIGNAL(applyOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
881
    connect(optionsWidget_,SIGNAL(saveOptions()),this,SIGNAL(saveOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
882
883
    connect(optionsWidget_,SIGNAL(addKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)),
            this,          SLOT(slotAddKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)));
884
885

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

Jan Möbius's avatar
Jan Möbius committed
888
  //show the optionsWidget centered
Dirk Wilden's avatar
Dirk Wilden committed
889
  QPoint center;
Jan Möbius's avatar
Jan Möbius committed
890
  center.setX( x() + width() / 2 );
Dirk Wilden's avatar
Dirk Wilden committed
891
892
  center.setY( y() + height() / 2 );

Dirk Wilden's avatar
Dirk Wilden committed
893
894
  optionsWidget_->setGeometry(center.x() - optionsWidget_->width() / 2,
                              center.y() - optionsWidget_->height()/ 2, optionsWidget_->width(), optionsWidget_->height());
Dirk Wilden's avatar
Dirk Wilden committed
895

896
  optionsWidget_->show();
Jan Möbius's avatar
Jan Möbius committed
897

898
}
Jan Möbius's avatar
Jan Möbius committed
899

900
void CoreWidget::nextViewerLayout() {
901

Jan Möbius's avatar
Jan Möbius committed
902
903
904
905
906
  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
907
              baseLayout_->setMode(QtMultiViewLayout::DoubleView);
Jan Möbius's avatar
Jan Möbius committed
908
909
910
911

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(1);
              break;
Jan Möbius's avatar
Jan Möbius committed
912
913
914
915
916
917
918
      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
919
920
921
922
923
      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
924
              viewerLayoutBox_->setCurrentIndex(3);
Jan Möbius's avatar
Jan Möbius committed
925
926
927
928
929
930
931
932
933
934
              break;
      case QtMultiViewLayout::HSplit:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
              baseLayout_->setMode(QtMultiViewLayout::SingleView);

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(0);
              break;
      }
  }
935
936
937
938
}


void
939
CoreWidget::setViewerLayout(int _idx) {
940

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

  switch (_idx) {
    case 0:
Jan Möbius's avatar
Jan Möbius committed
945
946
947
      baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
      baseLayout_->setMode(QtMultiViewLayout::SingleView);
      break;
Jan Möbius's avatar
Jan Möbius committed
948
    case 1:
Jan Möbius's avatar
Jan Möbius committed
949
950
951
      baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
      baseLayout_->setMode(QtMultiViewLayout::DoubleView);
      break;
Jan Möbius's avatar
Jan Möbius committed
952
    case 2:
Jan Möbius's avatar
Jan Möbius committed
953
954
955
956
957
958
959
      baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
      baseLayout_->setMode(QtMultiViewLayout::Grid);
      break;
    case 3:
      baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
      baseLayout_->setMode(QtMultiViewLayout::HSplit);
      break;
Jan Möbius's avatar
Jan Möbius committed
960
  }
961
962

    viewerLayoutBox_->setCurrentIndex(_idx);
Jan Möbius's avatar
Jan Möbius committed
963
  }
964
}
Jan Möbius's avatar
 
Jan Möbius committed
965

966
967
968
969
970
971
972
973
974
975
976
977
978
979
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*)),
980
                examiner_widgets_[i], SLOT(updateGL()));
981
982
983
984
      }

    }

985
    sceneGraphDialog_->setGeneratorMap(PluginFunctions::getSceneGraphGeneratorList() );
986
987
988
989
    sceneGraphDialog_->show();
  }
}

Jan Möbius's avatar
   
Jan Möbius committed
990
991
992
//-----------------------------------------------------------------------------

void
993
CoreWidget::sceneRectChanged(const QRectF &rect)
Jan Möbius's avatar
   
Jan Möbius committed
994
{
995
996
  centerWidget_->setGeometry (rect);
  slidingLogger_->updateGeometry ();
Jan Möbius's avatar
   
Jan Möbius committed
997
998
}

Dirk Wilden's avatar
Dirk Wilden committed
999
1000
1001
1002
1003
1004
//-----------------------------------------------------------------------------

void
CoreWidget::startVideoCaptureDialog(){

  VideoCaptureDialog* dialog = new VideoCaptureDialog();
1005
  dialog->setModal(false);
Dirk Wilden's avatar
Dirk Wilden committed
1006
1007

  connect(dialog, SIGNAL(startVideoCapture(QString,int,bool)), this, SIGNAL(startVideoCapture(QString,int,bool)) );
1008
1009
1010
  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
1011
1012
  dialog->show();
}
Jan Möbius's avatar
   
Jan Möbius committed
1013

1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
//-----------------------------------------------------------------------------

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

  if (!examiner)
    return;

  for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {