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

35
36
37
38
39
40
41
/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
71
#define WIDGET_HEIGHT 800
#define WIDGET_WIDTH  800

Jan Möbius's avatar
Jan Möbius committed
72
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
73

Jan Möbius's avatar
Jan Möbius committed
74
75
/** \brief Constuctor for the Core Widget
 *
Jan Möbius's avatar
 
Jan Möbius committed
76
77
*/
CoreWidget::
Dirk Wilden's avatar
Dirk Wilden committed
78
CoreWidget( QVector<ViewMode*>& _viewModes,
Dirk Wilden's avatar
Dirk Wilden committed
79
80
            std::vector<PluginInfo>& _plugins,
            QList< SlotInfo >& _coreSlots ) :
Jan Möbius's avatar
 
Jan Möbius committed
81
  QMainWindow(),
Dirk Wilden's avatar
Dirk Wilden committed
82
  coreSlots_(_coreSlots),
Dirk Wilden's avatar
Dirk Wilden committed
83
  shiftPressed_(false),
Dirk Wilden's avatar
Dirk Wilden committed
84
  fullscreenState_(0),
Jan Möbius's avatar
 
Jan Möbius committed
85
86
  viewModes_(_viewModes),
  viewModeButton_(0),
87
  viewModeMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
88
  splitter_(0),
89
  logWidget_(0),
Jan Möbius's avatar
 
Jan Möbius committed
90
  recentFilesMenu_(0),
91
  helpMenu_(0),
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
92
  cursorPainter_(0),
93
  sceneGraphDialog_(0),
94
95
96
  fileMenu_(0),
  viewMenu_(0),
  toolsMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
97
  fileMenuEnd_(0),
98
99
100
101
  stereoButton_(0),
  moveButton_(0),
  lightButton_(0),
  pickButton_(0),
Dirk Wilden's avatar
Dirk Wilden committed
102
  questionButton_(0),
103
104
105
  globalDrawMenu_(0),
  drawGroup_(0),
  viewGroup_(0),
106
  perspectiveProjectionAction_(0),
107
108
  activeDrawModes_(0),
  availableGlobalDrawModes_(0),
Jan Möbius's avatar
 
Jan Möbius committed
109
  contextMenu_(0),
Jan Möbius's avatar
Jan Möbius committed
110
  contextSelectionMenu_(0),
111
112
  drawGroupViewer_(0),
  viewerDrawMenu_(0),
113
  coordSysMenu_(0),
Dirk Wilden's avatar
Dirk Wilden committed
114
115
  snapshotName_("snap.png"),
  snapshotCounter_(0),
Jan Möbius's avatar
 
Jan Möbius committed
116
  stackMenu_(0),
117
  helpWidget_(0),
118
  stereoSettingsWidget_(0),
Jan Möbius's avatar
Jan Möbius committed
119
  aboutWidget_(0),
120
  optionsWidget_(0),
121
  plugins_(_plugins),
122
123
124
125
126
127
  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
128
129
{
  setupStatusBar();
Jan Möbius's avatar
Jan Möbius committed
130

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
131
132
133
134
135
  toolSplitter_ = new QSplitter(Qt::Horizontal,this);

  setCentralWidget(toolSplitter_);

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

138
139
  QGLFormat format = QGLFormat::defaultFormat();

140
141
142
  #ifdef ARCH_DARWIN
  format.setStereo(false);
  #else
Jan Möbius's avatar
   
Jan Möbius committed
143
  format.setStereo( OpenFlipper::Options::stereo() );
144
  #endif
Jan Möbius's avatar
   
Jan Möbius committed
145
  format.setAlpha(true);
146
  format.setStencil(true);
147
148
  format.setSampleBuffers(true);
  QGLFormat::setDefaultFormat(format);
Jan Möbius's avatar
   
Jan Möbius committed
149
150

  // Construct GL context & widget
151
152
153
  baseLayout_ = new QtMultiViewLayout;
  baseLayout_->setContentsMargins(0,0,0,0);

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
  // ===============================================================================
  // Test context capabilities ...
  // If we get stereo buffers, we use them .. which might disable multisampling
  // If we dont have stereo, we disable it to not interfere with multisampling
  // ===============================================================================
  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);
171
  PluginFunctions::shareGLWidget (glWidget_);
172

Jan Möbius's avatar
   
Jan Möbius committed
173
  glView_ = new QtGLGraphicsView(stackedWidget_);
174
  glScene_ = new QtGLGraphicsScene (&examiner_widgets_, baseLayout_);
Jan Möbius's avatar
   
Jan Möbius committed
175

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

Jan Möbius's avatar
   
Jan Möbius committed
179
180
181
182
  glView_->setViewport(glWidget_);
  glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  glView_->setScene(glScene_);

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
183
184
  // gl widget as parent to make sure that the CursorPainter will be deleted before
  cursorPainter_ = new CursorPainter (glWidget_);
185
186
  cursorPainter_->setForceNative (!OpenFlipper::Options::glMouse ());
  cursorPainter_->setEnabled (stereoActive_);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
187
  glScene_->setCursorPainter (cursorPainter_);
188

Jan Möbius's avatar
   
Jan Möbius committed
189
190
191
192
193
194
195
196
197
198
  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
199
200
201
  // ======================================================================
  // Set up the logging window
  // ======================================================================
202

203
  slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
204
205
  tempLogWidget = new QWidget;

206
207
208
  logWidget_ = new LoggerWidget(splitter_);
  logWidget_->setReadOnly(true);
  logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
209
  logWidget_->resize( splitter_->width() ,240);
210
  logWidget_->setLineWrapMode( QTextEdit::NoWrap );
Jan Möbius's avatar
Jan Möbius committed
211

212
  originalLoggerSize_ = 0;
Jan Möbius's avatar
Jan Möbius committed
213
  loggerState_ = OpenFlipper::Options::Normal;
214

Jan Möbius's avatar
 
Jan Möbius committed
215
  QList<int> wsizes( splitter_->sizes() );
216

Jan Möbius's avatar
Jan Möbius committed
217
  if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
218
219
    slidingLogger_->attachWidget (logWidget_);
    splitter_->insertWidget (1, tempLogWidget);
220
    wsizes[0] = 1;
Jan Möbius's avatar
 
Jan Möbius committed
221
222
    wsizes[1] = 0;
    splitter_->setSizes(wsizes);
Jan Möbius's avatar
Jan Möbius committed
223
    loggerState_ = OpenFlipper::Options::InScene;
224
    baseLayout_->setContentsMargins (0, 0, 0, 16);
Jan Möbius's avatar
Jan Möbius committed
225
226
227
228
229
230
231
232
233
234
235
  } else if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden) {
    splitter_->insertWidget (1, tempLogWidget);
    wsizes[0] = 1;
    wsizes[1] = 0;
    splitter_->setSizes(wsizes);
    loggerState_ = OpenFlipper::Options::Hidden;
  } else {
    // Set initial values to have a usable state
    wsizes[0] = 480;
    wsizes[1] = 240;
    splitter_->setSizes(wsizes);
Jan Möbius's avatar
 
Jan Möbius committed
236
  }
Jan Möbius's avatar
Jan Möbius committed
237

238

Jan Möbius's avatar
 
Jan Möbius committed
239
240
241
  // ======================================================================
  // Create examiner
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
242
243
244

  if ( !OpenFlipper::Options::multiView() ) {

Jan Möbius's avatar
   
Jan Möbius committed
245
246
    glViewer* examinerWidget = new glViewer(glScene_,
					    glWidget_,
247
                                            PluginFunctions::viewerProperties(0),
248
					    centerWidget_);
Jan Möbius's avatar
Jan Möbius committed
249

Jan Möbius's avatar
Jan Möbius committed
250
251
252
    examiner_widgets_.push_back(examinerWidget);

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

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

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

Jan Möbius's avatar
Jan Möbius committed
258
259
260
  } else {


Jan Möbius's avatar
   
Jan Möbius committed
261
262
263
264
    // Create examiners
    for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
      glViewer* newWidget = new glViewer(glScene_,
					 glWidget_,
265
                                         PluginFunctions::viewerProperties(i),
266
					 centerWidget_);
Dirk Wilden's avatar
Dirk Wilden committed
267

Jan Möbius's avatar
Jan Möbius committed
268
      examiner_widgets_.push_back(newWidget);
269
270
271
272
273
274
275
276
277
278

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

Jan Möbius's avatar
Jan Möbius committed
279
280
281
282
283
    }

    // 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
284
      cursorPainter_->registerViewer (examiner_widgets_[i]);
Jan Möbius's avatar
Jan Möbius committed
285
286
    }

Jan Möbius's avatar
Jan Möbius committed
287
288
289
290
    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
291
292
  }

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

Jan Möbius's avatar
   
Jan Möbius committed
296
  centerWidget_->setLayout(baseLayout_);
297
298


Jan Möbius's avatar
 
Jan Möbius committed
299
300
301
  // ======================================================================
  // Setup dragging for examiner widget
  // ======================================================================
302
303
304
305
306
307
308
309
  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* )));
310
311
    connect (examiner_widgets_[i], SIGNAL(signalMakeActive ()),
             this, SLOT(slotActivateExaminer()));
312
313
314

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


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

Jan Möbius's avatar
Jan Möbius committed
322
323
324
  mainToolbar_ = new QToolBar(tr("Main Toolbar"));
  mainToolbar_->setWindowTitle(tr("Main Toolbar"));
  mainToolbar_->setObjectName(tr("MainToolbar"));
325
  slotAddToolbar(mainToolbar_);
Jan Möbius's avatar
Jan Möbius committed
326

Jan Möbius's avatar
 
Jan Möbius committed
327
328
329
  // ======================================================================
  // Get Toolbar from examiner and integrate it into main window
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
330

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

332
  // Create the toolbar
Jan Möbius's avatar
Jan Möbius committed
333
  viewerToolbar_ = new QToolBar( tr("Viewer Toolbar" ), this );
334
  viewerToolbar_->setOrientation(Qt::Vertical);
Jan Möbius's avatar
 
Jan Möbius committed
335
336
  viewerToolbar_->setAllowedAreas(Qt::AllToolBarAreas);
  viewerToolbar_->setIconSize(QSize(20,20));
Jan Möbius's avatar
Jan Möbius committed
337
  viewerToolbar_->setObjectName(tr("ViewerToolbar"));
338

Jan Möbius's avatar
Jan Möbius committed
339
  slotAddToolbar(viewerToolbar_);
Jan Möbius's avatar
Jan Möbius committed
340

341
342
343
344
  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
345
346
  moveButton_->setToolTip( tr("Switch to <b>move</b> mode.") );
  moveButton_->setWhatsThis(tr(
347
348
349
                  "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
350
                  "<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" ));
351
352

  connect( moveButton_,SIGNAL( clicked() ), this, SLOT( setExamineMode() ) );
353
/*
354
  connect( this, SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
355
            this, SLOT(   slotActionModeChanged(Viewer::ActionMode) ) );*/
356

Jan Möbius's avatar
Jan Möbius committed
357
  viewerToolbar_->addWidget( moveButton_ )->setText(tr("Move"));
358
359
360
361
362
363
364
  moveButton_->setDown(true);


  lightButton_ = new QToolButton( viewerToolbar_ );
  lightButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"light-mode.png") );
  lightButton_->setMinimumSize( 16, 16 );
  lightButton_->setMaximumSize( 32, 32 );
Jan Möbius's avatar
Jan Möbius committed
365
366
  lightButton_->setToolTip(tr("Switch to <b>light</b> mode."));
  lightButton_->setWhatsThis(tr(
367
                  "Switch to <b>light</b> mode.<br>"
Jan Möbius's avatar
Jan Möbius committed
368
                  "Rotate lights using left mouse button."));
369
370

  connect( lightButton_,SIGNAL( clicked() ), this, SLOT( setLightMode() ) );
Jan Möbius's avatar
Jan Möbius committed
371
  viewerToolbar_->addWidget( lightButton_)->setText(tr("Light"));
372
373
374
375
376
377


  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
378
379
  pickButton_->setToolTip(tr("Switch to <b>picking</b> mode."));
  pickButton_->setWhatsThis(tr(
380
381
382
                  "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
383
                  "context menu in the viewer."));
384
  connect( pickButton_,SIGNAL( clicked() ), this, SLOT( setPickingMode() ) );
Jan Möbius's avatar
Jan Möbius committed
385
  viewerToolbar_->addWidget( pickButton_)->setText(tr("Pick"));
386
387
388
389
390
391


  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
392
393
  questionButton_->setToolTip(tr("Switch to <b>identification</b> mode."));
  questionButton_->setWhatsThis(tr(
394
395
396
397
                  "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
398
                  "object."));
399
  connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
Jan Möbius's avatar
Jan Möbius committed
400
  viewerToolbar_->addWidget( questionButton_)->setText(tr("Question"));
401

402
403
404
405
406
407
408
409
  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: "
410
                  "<ul> "
411
412
413
				  "<li>Single viewer</li>"
				  "<li>Multiple viewers (grid)</li>"
				  "<li>Multiple viewers (hsplit)</li>"
Jan Möbius's avatar
Jan Möbius committed
414
				  "</ul>"));
415

416
417
418
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"singleviewmode.png"), "");
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode1.png"), "");
  viewerLayoutBox_->addItem(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"multiviewmode2.png"), "");
419

420
  viewerLayoutBox_->setIconSize(QSize(22,22));
421

422
  connect( viewerLayoutBox_,SIGNAL( activated(int) ), this, SLOT( setViewerLayout(int) ) );
423

424
  viewerToolbar_->addWidget( viewerLayoutBox_ );
425

426
427
428
429
430
431
432
433
434
  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
435
    stereoButton_->setToolTip(tr( "Toggle stereo viewing"));
436
437
    // We want a custom context menu
    stereoButton_->setContextMenuPolicy(Qt::CustomContextMenu);
Jan Möbius's avatar
Jan Möbius committed
438
    stereoButton_->setWhatsThis(tr(
439
440
441
442
                  "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
443
                  "display/projection system."));
444
445
446
    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
447
    viewerToolbar_->addWidget( stereoButton_ )->setText( tr("Stereo"));
448
  }
449
450


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

Jan Möbius's avatar
 
Jan Möbius committed
453
454
455
  // Remember logger size
  wsizes = splitter_->sizes();
  originalLoggerSize_  = wsizes[1];
Jan Möbius's avatar
Jan Möbius committed
456

Jan Möbius's avatar
 
Jan Möbius committed
457
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
458
  // Create ToolBox area
Jan Möbius's avatar
Jan Möbius committed
459
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
460
461
462

  toolBoxArea_ = new QWidget (toolSplitter_);

Jan Möbius's avatar
Jan Möbius committed
463
  QGroupBox *gb = new QGroupBox (tr("ViewMode"));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
464
465
466

  QHBoxLayout *hLayout = new QHBoxLayout;

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

Jan Möbius's avatar
Jan Möbius committed
470
471
  hLayout->addWidget(vmChangeButton_);
  hLayout->addWidget(vmEditButton);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
472
473
  gb->setLayout (hLayout);

Jan Möbius's avatar
Jan Möbius committed
474
475
  connect(vmChangeButton_, SIGNAL(clicked()), this, SLOT(slotViewChangeDialog()));
  connect(vmEditButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494

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

  QVBoxLayout *vLayout = new QVBoxLayout;
  vLayout->addWidget(gb);
  vLayout->addWidget(toolBoxScroll_);

  toolBoxArea_->setLayout (vLayout);

  wsizes = toolSplitter_->sizes();

  wsizes[0] = 480;
  wsizes[1] = 240;
  toolSplitter_->setSizes(wsizes);

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
495
496
497
498
499
  // ======================================================================
  // Create pick ToolBar
  // ======================================================================

  pickToolbar_ = new QtPickToolbar (this, centerWidget_);
Jan Möbius's avatar
Jan Möbius committed
500

Jan Möbius's avatar
 
Jan Möbius committed
501
502
503
  // ======================================================================
  // Context menu setup
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
504

Jan Möbius's avatar
Jan Möbius committed
505
506
507
508
  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
509

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

Jan Möbius's avatar
 
Jan Möbius committed
513
  setupMenuBar();
Jan Möbius's avatar
Jan Möbius committed
514

Jan Möbius's avatar
 
Jan Möbius committed
515
  updateRecent();
Jan Möbius's avatar
Jan Möbius committed
516

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

519
  registerCoreKeys();
Dirk Wilden's avatar
Dirk Wilden committed
520

521
  setExamineMode();
522
523
524

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

525
526
527
528
  // Create stereo settings widget
  stereoSettingsWidget_ = new StereoSettingsWidget(this);
  // Make it look like a dialog
  stereoSettingsWidget_->setWindowFlags(Qt::Popup);
529
530
  // Connect combo boxes and sliders to local slots
  connect(stereoSettingsWidget_->stereoOpengl, SIGNAL(clicked()),
531
          this, SLOT(slotApplyStereoSettings()));
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
  connect(stereoSettingsWidget_->stereoAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoPhilips, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));

  connect(stereoSettingsWidget_->focalDistance, SIGNAL(valueChanged(int)),
          this, SLOT(slotApplyStereoSettings(int)));
  connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
          this, SLOT(slotApplyStereoSettings()));

  connect(stereoSettingsWidget_->headerContentType, SIGNAL(currentIndexChanged(int)),
          this, SLOT(slotApplyStereoSettings(int)));
  connect(stereoSettingsWidget_->headerFactor, SIGNAL(valueChanged(int)),
          this, SLOT(slotApplyStereoSettings(int)));
  connect(stereoSettingsWidget_->headerOffsetCC, SIGNAL(valueChanged(int)),
          this, SLOT(slotApplyStereoSettings(int)));
  connect(stereoSettingsWidget_->headerSelect, SIGNAL(currentIndexChanged(int)),
          this, SLOT(slotApplyStereoSettings(int)));

  // Close button
  connect(stereoSettingsWidget_->closeButton, SIGNAL(clicked()),
          stereoSettingsWidget_, SLOT(hide()));
Jan Möbius's avatar
 
Jan Möbius committed
556
557
558
559
560
561
562
}


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


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

Jan Möbius's avatar
 
Jan Möbius committed
564
565
566
567
568
569
570
571
}

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

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

Dirk Wilden's avatar
Dirk Wilden committed
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
  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++)
        for ( uint j = 0 ; j < plugins_[p].toolbars.size(); ++j )
          plugins_[p].toolbars[j].second->hide();

      //hide main toolbar
      mainToolbar_->hide();

      //hide viewer toolbar
      viewerToolbar_->hide();

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

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

      //remove viewer frame
      glView_->setFrameStyle(QFrame::NoFrame);

      break;

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

      //show toolbars
      setViewMode( OpenFlipper::Options::defaultToolboxMode() );

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

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

      //add viewer frame
      glView_->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
  }

  fullscreenState_ = (fullscreenState_ + 1) % 3;
627
628
629

  OpenFlipper::Options::fullScreen( bool( windowState() & Qt::WindowFullScreen) );

Jan Möbius's avatar
 
Jan Möbius committed
630
631
632
633
634
  show();
}

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

635
636
637
638
639
640
641
642
643
644
645
/** 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
646
647
  fullscreenState_ = (uint) _state;

648
649
650
651
652
653
654
  OpenFlipper::Options::fullScreen( bool( windowState() & Qt::WindowFullScreen) );

  show();
}

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

Jan Möbius's avatar
 
Jan Möbius committed
655
656
657
658
/** Hide or show logger
  */
void
CoreWidget::toggleLogger() {
Jan Möbius's avatar
Jan Möbius committed
659
660
661
662
663
664
665
666
667
668
669
670
671

  switch (OpenFlipper::Options::loggerState ())
  {
    case OpenFlipper::Options::InScene:
      OpenFlipper::Options::loggerState(OpenFlipper::Options::Normal);
      break;
    case OpenFlipper::Options::Normal:
      OpenFlipper::Options::loggerState(OpenFlipper::Options::Hidden);
      break;
    case OpenFlipper::Options::Hidden:
      OpenFlipper::Options::loggerState(OpenFlipper::Options::InScene);
      break;
  }
Jan Möbius's avatar
Jan Möbius committed
672

673
  // Hide/Show Logger
Jan Möbius's avatar
Jan Möbius committed
674
  showLogger( OpenFlipper::Options::loggerState() );
675
676
677
678
679
}

/** Hide or show logger
  */
void
Jan Möbius's avatar
Jan Möbius committed
680
CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
Jan Möbius's avatar
 
Jan Möbius committed
681
  //Hide Logger
Jan Möbius's avatar
Jan Möbius committed
682
683
684
  if (_state == loggerState_)
    return;

685
686
687
  qreal left, top, right, bottom;
  baseLayout_->getContentsMargins (&left, &top, &right, &bottom);

Jan Möbius's avatar
Jan Möbius committed
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
  switch (_state)
  {
    case OpenFlipper::Options::InScene:
      {
        QList<int> wsizes( splitter_->sizes() );

        // Remember old size
        if (loggerState_ == OpenFlipper::Options::Normal)
          originalLoggerSize_  = wsizes[1];

	if ( originalLoggerSize_ == 0)
          originalLoggerSize_ = 240;

        splitter_->insertWidget (1, tempLogWidget);
        wsizes[0] = wsizes[0]+wsizes[1];
        wsizes[1] = 0;
        splitter_->setSizes(wsizes);
        logWidget_->resize (logWidget_->width (), originalLoggerSize_);
        slidingLogger_->attachWidget (logWidget_);
707
        baseLayout_->setContentsMargins (left, top, right, 16);
Jan Möbius's avatar
Jan Möbius committed
708
709
710
711
712
713
714
715
716
717
718
719
720
721
      }
      break;
    case OpenFlipper::Options::Normal:
      {
        if ( originalLoggerSize_ == 0)
          originalLoggerSize_ = 240;

        QList<int> wsizes( splitter_->sizes() );

        if (loggerState_ == OpenFlipper::Options::InScene)
          originalLoggerSize_ = logWidget_->height ();

        slidingLogger_->detachWidget ();
        splitter_->insertWidget (1, logWidget_);
722
        logWidget_->show ();
Jan Möbius's avatar
Jan Möbius committed
723
724
725
726

        wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
        wsizes[1] = originalLoggerSize_;
        splitter_->setSizes(wsizes);
727
        baseLayout_->setContentsMargins (left, top, right, 0);
Jan Möbius's avatar
Jan Möbius committed
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
      }
      break;
    case OpenFlipper::Options::Hidden:
      {
        QList<int> wsizes( splitter_->sizes() );

        // Remember old size
        if (loggerState_ == OpenFlipper::Options::Normal)
          originalLoggerSize_  = wsizes[1];

	if (loggerState_ == OpenFlipper::Options::InScene)
	{
	  slidingLogger_->detachWidget ();
	  originalLoggerSize_ = logWidget_->height ();
	}

        splitter_->insertWidget (1, tempLogWidget);
        wsizes[0] = wsizes[0]+wsizes[1];
        wsizes[1] = 0;
        splitter_->setSizes(wsizes);
748
        baseLayout_->setContentsMargins (left, top, right, 0);
Jan Möbius's avatar
Jan Möbius committed
749
750
751
752
753
754
      }
      break;
  }
  loggerState_ = _state;

/*
755
  if ( !_state ) {
Jan Möbius's avatar
 
Jan Möbius committed
756
    QList<int> wsizes( splitter_->sizes() );
Jan Möbius's avatar
Jan Möbius committed
757

Jan Möbius's avatar
 
Jan Möbius committed
758
759
    // Remember old size
    originalLoggerSize_  = wsizes[1];
Jan Möbius's avatar
Jan Möbius committed
760

761
762
763
    int height = logWidget_->height ();

    splitter_->insertWidget (1, tempLogWidget);
Jan Möbius's avatar
 
Jan Möbius committed
764
765
766
    wsizes[0] = wsizes[0]+wsizes[1];
    wsizes[1] = 0;
    splitter_->setSizes(wsizes);
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
    logWidget_->resize (logWidget_->width (), height);
    slidingLogger_->attachWidget (logWidget_);

  } else if (splitter_->widget (1) == logWidget_) {

    if ( originalLoggerSize_ == 0)
        originalLoggerSize_ = 240;

    QList<int> wsizes( splitter_->sizes() );

    if (wsizes[0] == 0)
      wsizes[0] = height();

    wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
    wsizes[1] = originalLoggerSize_;
    splitter_->setSizes(wsizes);
Jan Möbius's avatar
 
Jan Möbius committed
783
  } else {
Jan Möbius's avatar
Jan Möbius committed
784

785
786
787
788
789
790
791
792
793
794
    QList<int> wsizes( splitter_->sizes() );

    int height = logWidget_->height ();

    slidingLogger_->detachWidget ();
    splitter_->insertWidget (1, logWidget_);

    wsizes[0] = wsizes[0]+wsizes[1] - height;
    wsizes[1] = height;
    splitter_->setSizes(wsizes);
Jan Möbius's avatar
 
Jan Möbius committed
795
  }
Jan Möbius's avatar
Jan Möbius committed
796
  */
Jan Möbius's avatar
 
Jan Möbius committed
797
798
799
800
801
802
803
804
}

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

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

Jan Möbius's avatar
 
Jan Möbius committed
806
  //toggle
807
808
809
810
811
812
813
814
815
816
817
818
  showToolbox( OpenFlipper::Options::hideToolbox() );
}

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

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

  //toggle
  OpenFlipper::Options::hideToolbox( !_state );
Jan Möbius's avatar
 
Jan Möbius committed
819

Jan Möbius's avatar
Jan Möbius committed
820
  if ( OpenFlipper::Options::hideToolbox() ){
Jan Möbius's avatar
 
Jan Möbius committed
821
822

    //hide ViewMode Selection Widget
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
823
    toolBoxArea_->setVisible(false);
Jan Möbius's avatar
 
Jan Möbius committed
824
825
826
827
828
829
830

  }else{
    //reset last ViewMode
    if (OpenFlipper::Options::defaultToolboxMode().trimmed() == "")
      setViewMode("All");
    else
      setViewMode( OpenFlipper::Options::defaultToolboxMode() );
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
831
    toolBoxArea_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
832
833
  }
}
Jan Möbius's avatar
Jan Möbius committed
834

Jan Möbius's avatar
 
Jan Möbius committed
835
836
//=============================================================================

Jan Möbius's avatar
Jan Möbius committed
837
838
void
CoreWidget::addRecent(QString _filename, DataType _type)
Jan Möbius's avatar
 
Jan Möbius committed
839
{
840
841
  //dont add objects to recentMenu while loadind Settings
  if ( OpenFlipper::Options::loadingSettings() ) return;
Jan Möbius's avatar
Jan Möbius committed
842

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

Jan Möbius's avatar
 
Jan Möbius committed
845
  updateRecent();
Jan Möbius's avatar
Jan Möbius committed
846
847
848
849
850
851
852

}

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

void
CoreWidget::updateRecent()
Jan Möbius's avatar
 
Jan Möbius committed
853
854
855
{
  if ( recentFilesMenu_ == NULL)
    return;
Jan Möbius's avatar
Jan Möbius committed
856

Jan Möbius's avatar
 
Jan Möbius committed
857
858
859
860
861
  recentFilesMenu_->clear();

  QVector< OpenFlipper::Options::RecentFile > recentFiles = OpenFlipper::Options::recentFiles();
  for (int i = 0 ; i < recentFiles.size() ; ++i ) {
    QString path = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
862
863

    QFileInfo fi(recentFiles[i].filename);
864
865
866
867
868

    if (fi.suffix() == "ini")
      path += "Settings-Icon.png";
    else
      path += typeIcon( recentFiles[i].type );
869

Jan Möbius's avatar
Jan Möbius committed
870
    recentFilesMenu_->addAction(QIcon(path), recentFiles[i].filename);
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
909
910
911
912

	if (OpenFlipper::Options::multiView()) {

		switch (baseLayout_->mode()) {
		case QtMultiViewLayout::SingleView:
913
                        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
914
			baseLayout_->setMode(QtMultiViewLayout::Grid);
915
916

			// Update combo box in the toolbar
917
			viewerLayoutBox_->setCurrentIndex(1);
918
919
			break;
		case QtMultiViewLayout::Grid:
920
                        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
921
			baseLayout_->setMode(QtMultiViewLayout::HSplit);
922
923

			// Update combo box in the toolbar
924
			viewerLayoutBox_->setCurrentIndex(2);
925
926
			break;
		case QtMultiViewLayout::HSplit:
927
                        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
928
			baseLayout_->setMode(QtMultiViewLayout::SingleView);
929
930

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


void
939
CoreWidget::setViewerLayout(int _idx) {
940
941
942
943
944

	if (OpenFlipper::Options::multiView()) {

		switch (_idx) {
		case 0:
945
                        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
946
947
948
			baseLayout_->setMode(QtMultiViewLayout::SingleView);
			break;
		case 1:
949
                        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
950
951
952
			baseLayout_->setMode(QtMultiViewLayout::Grid);
			break;
		case 2:
953
                        baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
954
955
956
			baseLayout_->setMode(QtMultiViewLayout::HSplit);
			break;
		}
957
958

    viewerLayoutBox_->setCurrentIndex(_idx);
959
960
	}
}
Jan Möbius's avatar
 
Jan Möbius committed
961

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

    }

    sceneGraphDialog_->show();
  }
}

Jan Möbius's avatar
   
Jan Möbius committed
985
986
987
988
989
990
//-----------------------------------------------------------------------------

void
CoreWidget::sceneRectChanged(const QRectF &rect)
{
  centerWidget_->setGeometry (rect);
991
  slidingLogger_->updateGeometry ();
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
992
  pickToolbar_->updateGeometry ();
Jan Möbius's avatar
   
Jan Möbius committed
993
994
}

Dirk Wilden's avatar
Dirk Wilden committed
995
996
997
998
999
1000
//-----------------------------------------------------------------------------

void
CoreWidget::startVideoCaptureDialog(){

  VideoCaptureDialog* dialog = new VideoCaptureDialog();
1001
  dialog->setModal(false);
Dirk Wilden's avatar
Dirk Wilden committed
1002
1003

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

1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
//-----------------------------------------------------------------------------

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

  if (!examiner)
    return;

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

    if (examiner == examiner_widgets_[i])
    {
      PluginFunctions::setActiveExaminer (i);
      break;
    }
  }
}
1028

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
1029
1030
1031
1032
1033
//-----------------------------------------------------------------------------

/// Use native or gl painted cursor
void CoreWidget::setGlCursor ( bool _state )
{
1034
  cursorPainter_->setForceNative (!_state);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
1035
}
1036

Jan Möbius's avatar
 
Jan Möbius committed
1037
//=============================================================================
1038