CoreWidget.cc 35.7 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>

Jan Möbius's avatar
Jan Möbius committed
69
70
#include <ACG/Scenegraph/SceneGraphAnalysis.hh>

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

Jan Möbius's avatar
 
Jan Möbius committed
75
76
77
#define WIDGET_HEIGHT 800
#define WIDGET_WIDTH  800

Jan Möbius's avatar
Jan Möbius committed
78
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
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
108
109
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_;
}

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

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

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

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









134
/** \brief Constructor for the Core Widget
Jan Möbius's avatar
Jan Möbius committed
135
 *
Jan Möbius's avatar
 
Jan Möbius committed
136
137
*/
CoreWidget::
Dirk Wilden's avatar
Dirk Wilden committed
138
CoreWidget( QVector<ViewMode*>& _viewModes,
Dirk Wilden's avatar
Dirk Wilden committed
139
140
            std::vector<PluginInfo>& _plugins,
            QList< SlotInfo >& _coreSlots ) :
Jan Möbius's avatar
 
Jan Möbius committed
141
  QMainWindow(),
Dirk Wilden's avatar
Dirk Wilden committed
142
  coreSlots_(_coreSlots),
Dirk Wilden's avatar
Dirk Wilden committed
143
  shiftPressed_(false),
Dirk Wilden's avatar
Dirk Wilden committed
144
  fullscreenState_(0),
Jan Möbius's avatar
 
Jan Möbius committed
145
146
  viewModes_(_viewModes),
  viewModeButton_(0),
147
  viewModeMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
148
  splitter_(0),
149
  logWidget_(0),
Jan Möbius's avatar
 
Jan Möbius committed
150
  recentFilesMenu_(0),
151
  helpMenu_(0),
152
153
154
  windowMenu_(0),
  AC_ShowViewModeControls_(0),
  AC_ShowToolbox_(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
168
  rendererMenu_(0),
  postprocessorMenu_(0),
169
  drawGroup_(0),
170
171
  rendererGroup_(0),
  postProcessorGroup_(0),
172
  viewGroup_(0),
173
  perspectiveProjectionAction_(0),
174
175
  activeDrawModes_(0),
  availableGlobalDrawModes_(0),
Jan Möbius's avatar
 
Jan Möbius committed
176
  contextMenu_(0),
Jan Möbius's avatar
Jan Möbius committed
177
  contextSelectionMenu_(0),
178
179
  drawGroupViewer_(0),
  viewerDrawMenu_(0),
180
  coordSysMenu_(0),
181
  snapshotName_(""),
Dirk Wilden's avatar
Dirk Wilden committed
182
  snapshotCounter_(0),
Jan Möbius's avatar
 
Jan Möbius committed
183
  stackMenu_(0),
184
  helpWidget_(0),
185
  stereoSettingsWidget_(0),
Jan Möbius's avatar
Jan Möbius committed
186
  aboutWidget_(0),
187
  optionsWidget_(0),
188
  plugins_(_plugins),
189
190
191
192
193
194
  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
195
{
Matthias Möller's avatar
doc    
Matthias Möller committed
196

Jan Möbius's avatar
 
Jan Möbius committed
197
  setupStatusBar();
Jan Möbius's avatar
Jan Möbius committed
198

Dirk Wilden's avatar
Dirk Wilden committed
199
200
  defaultIconSize_ = iconSize();

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

  setCentralWidget(toolSplitter_);

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

208
209
  QGLFormat format = QGLFormat::defaultFormat();

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

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

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

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

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

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

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

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

274
  slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
275

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

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

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

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

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

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

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

    showLoggerInSplitView(true);
Jan Möbius's avatar
 
Jan Möbius committed
302
  }
Jan Möbius's avatar
Jan Möbius committed
303

304

Jan Möbius's avatar
 
Jan Möbius committed
305
306
307
  // ======================================================================
  // Create examiner
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
308

Jan Möbius's avatar
Jan Möbius committed
309
310
311
312
313
  // 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
314
  if ( !OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() ) {
Jan Möbius's avatar
Jan Möbius committed
315

Jan Möbius's avatar
   
Jan Möbius committed
316
317
    glViewer* examinerWidget = new glViewer(glScene_,
					    glWidget_,
318
                                            PluginFunctions::viewerProperties(0),
319
					    centerWidget_);
Jan Möbius's avatar
Jan Möbius committed
320

Jan Möbius's avatar
Jan Möbius committed
321
322
    examiner_widgets_.push_back(examinerWidget);

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

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

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

Jan Möbius's avatar
Jan Möbius committed
329
330
331
  } else {


Jan Möbius's avatar
   
Jan Möbius committed
332
333
334
335
    // Create examiners
    for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
      glViewer* newWidget = new glViewer(glScene_,
					 glWidget_,
336
                                         PluginFunctions::viewerProperties(i),
337
					 centerWidget_);
Dirk Wilden's avatar
Dirk Wilden committed
338

Jan Möbius's avatar
Jan Möbius committed
339
      examiner_widgets_.push_back(newWidget);
340
341
342
343
344
345
346
347
348
349

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

350
      connect (&PluginFunctions::viewerProperties(i), SIGNAL( drawModeChanged(int)), this, SIGNAL(drawModeChanged(int)));
Jan Möbius's avatar
Jan Möbius committed
351
352
353
354
    }

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

Jan Möbius's avatar
Jan Möbius committed
359
360
361
362
    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
363
364
  }

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

Jan Möbius's avatar
   
Jan Möbius committed
368
  centerWidget_->setLayout(baseLayout_);
369
370


Jan Möbius's avatar
 
Jan Möbius committed
371
372
373
  // ======================================================================
  // Setup dragging for examiner widget
  // ======================================================================
374
375
376
377
378
379
380
381
  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* )));
382
383
    connect (examiner_widgets_[i], SIGNAL(signalMakeActive ()),
             this, SLOT(slotActivateExaminer()));
384
385
386

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


Jan Möbius's avatar
 
Jan Möbius committed
390
391
392
  // ======================================================================
  // Create main Toolbar
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
393

Jan Möbius's avatar
Jan Möbius committed
394
395
396
  mainToolbar_ = new QToolBar(tr("Main Toolbar"));
  mainToolbar_->setWindowTitle(tr("Main Toolbar"));
  mainToolbar_->setObjectName(tr("MainToolbar"));
397
  slotAddToolbar(mainToolbar_);
Jan Möbius's avatar
Jan Möbius committed
398

Jan Möbius's avatar
 
Jan Möbius committed
399
400
401
  // ======================================================================
  // Get Toolbar from examiner and integrate it into main window
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
402

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

404
  // Create the toolbar
Jan Möbius's avatar
Jan Möbius committed
405
  viewerToolbar_ = new QToolBar( tr("Viewer Toolbar" ), this );
406
  viewerToolbar_->setOrientation(Qt::Vertical);
Jan Möbius's avatar
 
Jan Möbius committed
407
408
  viewerToolbar_->setAllowedAreas(Qt::AllToolBarAreas);
  viewerToolbar_->setIconSize(QSize(20,20));
Jan Möbius's avatar
Jan Möbius committed
409
  viewerToolbar_->setObjectName(tr("ViewerToolbar"));
410

Jan Möbius's avatar
Jan Möbius committed
411
  slotAddToolbar(viewerToolbar_);
Jan Möbius's avatar
Jan Möbius committed
412

413
414
415
416
  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
417
418
  moveButton_->setToolTip( tr("Switch to <b>move</b> mode.") );
  moveButton_->setWhatsThis(tr(
419
420
421
                  "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
422
                  "<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" ));
423
424

  connect( moveButton_,SIGNAL( clicked() ), this, SLOT( setExamineMode() ) );
425
/*
426
  connect( this, SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
427
            this, SLOT(   slotActionModeChanged(Viewer::ActionMode) ) );*/
428

Jan Möbius's avatar
Jan Möbius committed
429
  viewerToolbar_->addWidget( moveButton_ )->setText(tr("Move"));
430
431
  moveButton_->setDown(true);

432
  
433
434
435
436
  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
437
438
  pickButton_->setToolTip(tr("Switch to <b>picking</b> mode."));
  pickButton_->setWhatsThis(tr(
439
440
441
                  "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
442
                  "context menu in the viewer."));
443
  connect( pickButton_,SIGNAL( clicked() ), this, SLOT( setPickingMode() ) );
Jan Möbius's avatar
Jan Möbius committed
444
  viewerToolbar_->addWidget( pickButton_)->setText(tr("Pick"));
445
446
447
448
449
450


  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
451
452
  questionButton_->setToolTip(tr("Switch to <b>identification</b> mode."));
  questionButton_->setWhatsThis(tr(
453
454
455
456
                  "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
457
                  "object."));
458
  connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
Jan Möbius's avatar
Jan Möbius committed
459
  viewerToolbar_->addWidget( questionButton_)->setText(tr("Question"));
460

461
462
463
464
465
466
467
468
  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: "
469
                  "<ul> "
470
				  "<li>Single viewer</li>"
Jan Möbius's avatar
Jan Möbius committed
471
          "<li>Double viewer</li>"
472
473
				  "<li>Multiple viewers (grid)</li>"
				  "<li>Multiple viewers (hsplit)</li>"
Jan Möbius's avatar
Jan Möbius committed
474
				  "</ul>"));
475

476
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"singleviewmode.png"), "");
Jan Möbius's avatar
Jan Möbius committed
477
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"doubleviewmode.png"), "");
478
479
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode1.png"), "");
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode2.png"), "");
480

481
  viewerLayoutBox_->setIconSize(QSize(22,22));
482

483
  connect( viewerLayoutBox_,SIGNAL( activated(int) ), this, SLOT( setViewerLayout(int) ) );
484

485
  viewerToolbar_->addWidget( viewerLayoutBox_ );
486

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


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

Jan Möbius's avatar
 
Jan Möbius committed
514
515
  // Remember logger size
  wsizes = splitter_->sizes();
516
517
518
519
520
521

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

Jan Möbius's avatar
 
Jan Möbius committed
523
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
524
  // Create ToolBox area
Jan Möbius's avatar
Jan Möbius committed
525
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
526
527
528

  toolBoxArea_ = new QWidget (toolSplitter_);

529
  viewModeControlBox_ = new QGroupBox (tr("ViewMode"));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
530
531
532

  QHBoxLayout *hLayout = new QHBoxLayout;

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

Jan Möbius's avatar
Jan Möbius committed
536
537
  hLayout->addWidget(vmChangeButton_);
  hLayout->addWidget(vmEditButton);
538
  viewModeControlBox_->setLayout (hLayout);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
539

Jan Möbius's avatar
Jan Möbius committed
540
541
  connect(vmChangeButton_, SIGNAL(clicked()), this, SLOT(slotViewChangeDialog()));
  connect(vmEditButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
542
543
544
545
546
547
548
549

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

  QVBoxLayout *vLayout = new QVBoxLayout;
550
  vLayout->addWidget(viewModeControlBox_);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
551
  vLayout->addWidget(toolBoxScroll_);
552
553
554
  
  if ( OpenFlipperSettings().value("Core/Gui/TaskSwitcher/Hide",false).toBool() )
    viewModeControlBox_->hide();
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
555
556
557
558
559

  toolBoxArea_->setLayout (vLayout);

  wsizes = toolSplitter_->sizes();

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

563
564
565
566
567
    // Set relative sizes of windows
    wsizes[0] = 480;
    wsizes[1] = 240;
    toolSplitter_->setSizes(wsizes);  
  } else {
568

569
570
571
572
573
574
575
576
577
578
    // 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
579
580
581
  // ======================================================================
  // Context menu setup
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
582

Jan Möbius's avatar
Jan Möbius committed
583
584
585
586
  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
587

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

Jan Möbius's avatar
 
Jan Möbius committed
591
  setupMenuBar();
Jan Möbius's avatar
Jan Möbius committed
592

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

595
  registerCoreKeys();
Dirk Wilden's avatar
Dirk Wilden committed
596

597
  setExamineMode();
598
599
600

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

601
602
603
604
  // Create stereo settings widget
  stereoSettingsWidget_ = new StereoSettingsWidget(this);
  // Make it look like a dialog
  stereoSettingsWidget_->setWindowFlags(Qt::Popup);
605
606
  // Connect combo boxes and sliders to local slots
  connect(stereoSettingsWidget_->stereoOpengl, SIGNAL(clicked()),
607
          this, SLOT(slotApplyStereoSettings()));
608
609
610
611
612
  connect(stereoSettingsWidget_->stereoAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));

613
614
  connect(stereoSettingsWidget_->focalDistance, SIGNAL(sliderReleased()),
          this, SLOT(slotApplyStereoSettings()));
615
616
617
618
619
620
  connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
          this, SLOT(slotApplyStereoSettings()));

  // Close button
  connect(stereoSettingsWidget_->closeButton, SIGNAL(clicked()),
          stereoSettingsWidget_, SLOT(hide()));
621
622
623
624
625
626


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

627
  helpWidget_ = new HelpWidget(this,homePage_,false);
Matthias Möller's avatar
doc    
Matthias Möller committed
628
629
  connect(this, SIGNAL(changeHelpSite(QUrl)), helpWidget_, SLOT(activateLink(QUrl)));
  helpWidget_->hide();
630

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


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


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

Jan Möbius's avatar
 
Jan Möbius committed
639
640
641
642
643
644
645
646
}

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

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

Dirk Wilden's avatar
Dirk Wilden committed
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
  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++)
663
664
665
666
        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
667
668

      //hide main toolbar
669
670
      if ( ! mainToolbar_->isFloating() )
        mainToolbar_->hide();
Dirk Wilden's avatar
Dirk Wilden committed
671
672

      //hide viewer toolbar
673
674
      if ( ! viewerToolbar_->isFloating() )
        viewerToolbar_->hide();
Dirk Wilden's avatar
Dirk Wilden committed
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689

      //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
690
      setViewMode( OpenFlipper::Options::currentViewMode() );
Dirk Wilden's avatar
Dirk Wilden committed
691
692
693
694
695
696
697

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

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

Jan Möbius's avatar
Jan Möbius committed
698
699
      break;

Dirk Wilden's avatar
Dirk Wilden committed
700
701
702
  }

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

Jan Möbius's avatar
 
Jan Möbius committed
706
707
708
709
710
  show();
}

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

711
712
713
714
715
716
717
718
719
720
721
/** 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
722
723
  fullscreenState_ = (uint) _state;

Jan Möbius's avatar
Jan Möbius committed
724
  OpenFlipperSettings().setValue("Core/Gui/fullscreen", bool( windowState() & Qt::WindowFullScreen) );
725
726
727
728

  show();
}

729
730
731
732
733
734
735
736
737
738
//-----------------------------------------------------------------------------

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);
    
739
740
741
742
743
    // Update The Checkbox in the Menu
    AC_ShowViewModeControls_->blockSignals(true);
    AC_ShowViewModeControls_->setChecked( _show  );
    AC_ShowViewModeControls_->blockSignals(false);
    
744
745
746
747
748
749
750
751
752
753
    if ( _show ) {
      viewModeControlBox_->show();
    } else {
      viewModeControlBox_->hide();
    }
    
  }
  
}

Jan Möbius's avatar
 
Jan Möbius committed
754
755
756
757
758
759
//-----------------------------------------------------------------------------

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

Jan Möbius's avatar
 
Jan Möbius committed
761
  //toggle
Jan Möbius's avatar
Jan Möbius committed
762
  showToolbox( OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool() );
763
764
765
766
767
768
769
770
771
772
}

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

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

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

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

    //hide ViewMode Selection Widget
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
778
    toolBoxArea_->setVisible(false);
Jan Möbius's avatar
 
Jan Möbius committed
779
780
781

  }else{
    //reset last ViewMode
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
782
    if (OpenFlipper::Options::currentViewMode().trimmed() == "")
Jan Möbius's avatar
 
Jan Möbius committed
783
784
      setViewMode("All");
    else
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
785
      setViewMode( OpenFlipper::Options::currentViewMode() );
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
786
    toolBoxArea_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
787
788
  }
}
Jan Möbius's avatar
Jan Möbius committed
789

790

791
792
//=============================================================================

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

825
826
827
828
829
    
  toolSplitter_->refresh();
}
      

Jan Möbius's avatar
 
Jan Möbius committed
830
831
//=============================================================================

Jan Möbius's avatar
Jan Möbius committed
832
833
void
CoreWidget::addRecent(QString _filename, DataType _type)
Jan Möbius's avatar
 
Jan Möbius committed
834
{
835
836
  //dont add objects to recentMenu while loadind Settings
  if ( OpenFlipper::Options::loadingSettings() ) return;
Jan Möbius's avatar
Jan Möbius committed
837

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

Jan Möbius's avatar
 
Jan Möbius committed
840
  updateRecent();
Jan Möbius's avatar
Jan Möbius committed
841
842
843
844
845
846
847

}

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

void
CoreWidget::updateRecent()
Jan Möbius's avatar
 
Jan Möbius committed
848
849
850
{
  if ( recentFilesMenu_ == NULL)
    return;
Jan Möbius's avatar
Jan Möbius committed
851

Jan Möbius's avatar
 
Jan Möbius committed
852
853
  recentFilesMenu_->clear();

854
855
  QStringList recentFiles = OpenFlipperSettings().value("Core/File/RecentFiles", QStringList()).toStringList();
  QStringList recentTypes = OpenFlipperSettings().value("Core/File/RecentTypes", QStringList()).toStringList();
856

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

859
    QFileInfo fi(recentFiles[i]);
860

861
862
863
864
    QAction* newAction = 0;

    if (fi.suffix() == "ini") {
      newAction = recentFilesMenu_->addAction(QIcon(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator()+"Settings-Icon.png"), recentFiles[i]);
865
      newAction->setData( QVariant( QString("Unknown") ) );
866
867
868
869
    } else {
      newAction = recentFilesMenu_->addAction(typeIcon( typeId(recentTypes[i]) ), recentFiles[i]);
      newAction->setData( QVariant( recentTypes[i]) );
    }
870

Jan Möbius's avatar
 
Jan Möbius committed
871
872
  }

Jan Möbius's avatar
Jan Möbius committed
873
874
875
}

void
Jan Möbius's avatar
 
Jan Möbius committed
876
877
878
CoreWidget::closeEvent ( QCloseEvent * /* event */ ) {
  emit exit();
}
879
880

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

882
883
  if ( OpenFlipper::Options::nogui() )
    return;
Jan Möbius's avatar
Jan Möbius committed
884

885
  if ( optionsWidget_ == 0 ) {
Dirk Wilden's avatar
Dirk Wilden committed
886
    optionsWidget_ = new OptionsWidget(plugins_, coreKeys_, invKeys_, 0);
887
    connect(optionsWidget_,SIGNAL(applyOptions()),this,SIGNAL(applyOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
888
    connect(optionsWidget_,SIGNAL(saveOptions()),this,SIGNAL(saveOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
889
890
    connect(optionsWidget_,SIGNAL(addKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)),
            this,          SLOT(slotAddKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)));
891
892

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

Jan Möbius's avatar
Jan Möbius committed
895
  //show the optionsWidget centered
Dirk Wilden's avatar
Dirk Wilden committed
896
  QPoint center;
Jan Möbius's avatar
Jan Möbius committed
897
  center.setX( x() + width() / 2 );
Dirk Wilden's avatar
Dirk Wilden committed
898
899
  center.setY( y() + height() / 2 );

Dirk Wilden's avatar
Dirk Wilden committed
900
901
  optionsWidget_->setGeometry(center.x() - optionsWidget_->width() / 2,
                              center.y() - optionsWidget_->height()/ 2, optionsWidget_->width(), optionsWidget_->height());
Dirk Wilden's avatar
Dirk Wilden committed
902

903
  optionsWidget_->show();
Jan Möbius's avatar
Jan Möbius committed
904

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

907
void CoreWidget::nextViewerLayout() {
908

Jan Möbius's avatar
Jan Möbius committed
909
910
911
912
913
  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
914
              baseLayout_->setMode(QtMultiViewLayout::DoubleView);
Jan Möbius's avatar
Jan Möbius committed
915
916
917
918

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

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(0);
              break;
      }
  }
942
943
944
945
}


void
946
CoreWidget::setViewerLayout(int _idx) {
947

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

950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
    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!"));
    }
970
971

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

974
}
Jan Möbius's avatar
 
Jan Möbius committed
975

976
977
978
979
980
981
982
983
984
985
986
987
988
989
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*)),
990
                examiner_widgets_[i], SLOT(updateGL()));
991
992
993
994
      }

    }

995
    sceneGraphDialog_->setGeneratorMap(PluginFunctions::getSceneGraphGeneratorList() );
996
997
998
999
    sceneGraphDialog_->show();
  }
}

Jan Möbius's avatar
   
Jan Möbius committed
1000
1001
1002
//-----------------------------------------------------------------------------

void
1003
CoreWidget::sceneRectChanged(const QRectF &rect)
Jan Möbius's avatar
   
Jan Möbius committed
1004
{
1005
1006
  centerWidget_->setGeometry (rect);
  slidingLogger_->updateGeometry ();
Jan Möbius's avatar
   
Jan Möbius committed
1007
1008
}

Dirk Wilden's avatar
Dirk Wilden committed
1009
1010
1011
1012
1013
1014
//-----------------------------------------------------------------------------

void
CoreWidget::startVideoCaptureDialog(){

  VideoCaptureDialog* dialog = new VideoCaptureDialog();
1015
  dialog->setModal(false);
Dirk Wilden's avatar
Dirk Wilden committed
1016
1017

  connect(dialog, SIGNAL(startVideoCapture(QString,int,bool)), this, SIGNAL(startVideoCapture(QString,int,bool)) );
1018
1019
1020
  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
1021
1022
  dialog->show();
}
Jan Möbius's avatar
   
Jan Möbius committed
1023