CoreWidget.cc 37.5 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
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
*                                                                            *
*                              OpenFlipper                                   *
*      Copyright (C) 2001-2010 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/>.                                       *
*                                                                            *
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
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),
92
93
94
  windowMenu_(0),
  AC_ShowViewModeControls_(0),
  AC_ShowToolbox_(0),
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
95
  cursorPainter_(0),
96
  sceneGraphDialog_(0),
97
98
99
  fileMenu_(0),
  viewMenu_(0),
  toolsMenu_(0),
Jan Möbius's avatar
 
Jan Möbius committed
100
  fileMenuEnd_(0),
101
102
103
  stereoButton_(0),
  moveButton_(0),
  pickButton_(0),
Dirk Wilden's avatar
Dirk Wilden committed
104
  questionButton_(0),
105
106
107
  globalDrawMenu_(0),
  drawGroup_(0),
  viewGroup_(0),
108
  perspectiveProjectionAction_(0),
109
110
  activeDrawModes_(0),
  availableGlobalDrawModes_(0),
Jan Möbius's avatar
 
Jan Möbius committed
111
  contextMenu_(0),
Jan Möbius's avatar
Jan Möbius committed
112
  contextSelectionMenu_(0),
113
114
  drawGroupViewer_(0),
  viewerDrawMenu_(0),
115
  coordSysMenu_(0),
116
  snapshotName_(""),
Dirk Wilden's avatar
Dirk Wilden committed
117
  snapshotCounter_(0),
Jan Möbius's avatar
 
Jan Möbius committed
118
  stackMenu_(0),
119
  helpWidget_(0),
120
  stereoSettingsWidget_(0),
Jan Möbius's avatar
Jan Möbius committed
121
  aboutWidget_(0),
122
  optionsWidget_(0),
123
  plugins_(_plugins),
124
125
126
127
128
129
  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
130
131
{
  setupStatusBar();
Jan Möbius's avatar
Jan Möbius committed
132

Dirk Wilden's avatar
Dirk Wilden committed
133
134
  defaultIconSize_ = iconSize();

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
135
136
137
138
139
  toolSplitter_ = new QSplitter(Qt::Horizontal,this);

  setCentralWidget(toolSplitter_);

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

142
143
  QGLFormat format = QGLFormat::defaultFormat();

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

  // Construct GL context & widget
155
156
157
  baseLayout_ = new QtMultiViewLayout;
  baseLayout_->setContentsMargins(0,0,0,0);

158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  // ===============================================================================
  // 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);
175
  PluginFunctions::shareGLWidget (glWidget_);
176

Jan Möbius's avatar
   
Jan Möbius committed
177
  glView_ = new QtGLGraphicsView(stackedWidget_);
178
  glScene_ = new QtGLGraphicsScene (&examiner_widgets_, baseLayout_);
Jan Möbius's avatar
   
Jan Möbius committed
179

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

Jan Möbius's avatar
   
Jan Möbius committed
183
184
185
186
  glView_->setViewport(glWidget_);
  glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  glView_->setScene(glScene_);

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
187
188
  // 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
189
  cursorPainter_->setForceNative (OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
190
  cursorPainter_->setEnabled (stereoActive_);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
191
  glScene_->setCursorPainter (cursorPainter_);
192

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

207
  slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
208
209
  tempLogWidget = new QWidget;

210
211
  logWidget_ = new LoggerWidget(splitter_);
  logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
212
  logWidget_->resize( splitter_->width() ,240);
Jan Möbius's avatar
Jan Möbius committed
213

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

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

Jan Möbius's avatar
Jan Möbius committed
219
  if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
220
221
    slidingLogger_->attachWidget (logWidget_);
    splitter_->insertWidget (1, tempLogWidget);
222
    wsizes[0] = 1;
Jan Möbius's avatar
 
Jan Möbius committed
223
224
    wsizes[1] = 0;
    splitter_->setSizes(wsizes);
Jan Möbius's avatar
Jan Möbius committed
225
    loggerState_ = OpenFlipper::Options::InScene;
226
    baseLayout_->setContentsMargins (0, 0, 0, 16);
Jan Möbius's avatar
Jan Möbius committed
227
228
229
230
231
232
233
234
235
236
237
  } 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
238
  }
Jan Möbius's avatar
Jan Möbius committed
239

240

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

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

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

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

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

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

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

Jan Möbius's avatar
Jan Möbius committed
260
261
262
  } else {


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

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

      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
281
282
283
284
285
    }

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

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

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

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


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

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


Jan Möbius's avatar
 
Jan Möbius committed
320
321
322
  // ======================================================================
  // Create main Toolbar
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
323

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

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

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

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

Jan Möbius's avatar
Jan Möbius committed
341
  slotAddToolbar(viewerToolbar_);
Jan Möbius's avatar
Jan Möbius committed
342

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

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

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

362
  
363
364
365
366
  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
367
368
  pickButton_->setToolTip(tr("Switch to <b>picking</b> mode."));
  pickButton_->setWhatsThis(tr(
369
370
371
                  "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
372
                  "context menu in the viewer."));
373
  connect( pickButton_,SIGNAL( clicked() ), this, SLOT( setPickingMode() ) );
Jan Möbius's avatar
Jan Möbius committed
374
  viewerToolbar_->addWidget( pickButton_)->setText(tr("Pick"));
375
376
377
378
379
380


  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
381
382
  questionButton_->setToolTip(tr("Switch to <b>identification</b> mode."));
  questionButton_->setWhatsThis(tr(
383
384
385
386
                  "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
387
                  "object."));
388
  connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
Jan Möbius's avatar
Jan Möbius committed
389
  viewerToolbar_->addWidget( questionButton_)->setText(tr("Question"));
390

391
392
393
394
395
396
397
398
  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: "
399
                  "<ul> "
400
401
402
				  "<li>Single viewer</li>"
				  "<li>Multiple viewers (grid)</li>"
				  "<li>Multiple viewers (hsplit)</li>"
Jan Möbius's avatar
Jan Möbius committed
403
				  "</ul>"));
404

405
406
407
  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"), "");
408

409
  viewerLayoutBox_->setIconSize(QSize(22,22));
410

411
  connect( viewerLayoutBox_,SIGNAL( activated(int) ), this, SLOT( setViewerLayout(int) ) );
412

413
  viewerToolbar_->addWidget( viewerLayoutBox_ );
414

415
416
417
418
419
420
421
422
423
  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
424
    stereoButton_->setToolTip(tr( "Toggle stereo viewing"));
425
426
    // We want a custom context menu
    stereoButton_->setContextMenuPolicy(Qt::CustomContextMenu);
Jan Möbius's avatar
Jan Möbius committed
427
    stereoButton_->setWhatsThis(tr(
428
429
430
431
                  "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
432
                  "display/projection system."));
433
434
435
    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
436
    viewerToolbar_->addWidget( stereoButton_ )->setText( tr("Stereo"));
437
  }
438
439


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

Jan Möbius's avatar
 
Jan Möbius committed
442
443
444
  // Remember logger size
  wsizes = splitter_->sizes();
  originalLoggerSize_  = wsizes[1];
Jan Möbius's avatar
Jan Möbius committed
445

Jan Möbius's avatar
 
Jan Möbius committed
446
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
447
  // Create ToolBox area
Jan Möbius's avatar
Jan Möbius committed
448
  // ======================================================================
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
449
450
451

  toolBoxArea_ = new QWidget (toolSplitter_);

452
  viewModeControlBox_ = new QGroupBox (tr("ViewMode"));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
453
454
455

  QHBoxLayout *hLayout = new QHBoxLayout;

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

Jan Möbius's avatar
Jan Möbius committed
459
460
  hLayout->addWidget(vmChangeButton_);
  hLayout->addWidget(vmEditButton);
461
  viewModeControlBox_->setLayout (hLayout);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
462

Jan Möbius's avatar
Jan Möbius committed
463
464
  connect(vmChangeButton_, SIGNAL(clicked()), this, SLOT(slotViewChangeDialog()));
  connect(vmEditButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
465
466
467
468
469
470
471
472

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

  QVBoxLayout *vLayout = new QVBoxLayout;
473
  vLayout->addWidget(viewModeControlBox_);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
474
  vLayout->addWidget(toolBoxScroll_);
475
476
477
  
  if ( OpenFlipperSettings().value("Core/Gui/TaskSwitcher/Hide",false).toBool() )
    viewModeControlBox_->hide();
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
478
479
480
481
482

  toolBoxArea_->setLayout (vLayout);

  wsizes = toolSplitter_->sizes();

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

486
487
488
489
490
    // Set relative sizes of windows
    wsizes[0] = 480;
    wsizes[1] = 240;
    toolSplitter_->setSizes(wsizes);  
  } else {
491

492
493
494
495
496
497
498
499
500
501
    // 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
Dennis:    
Jan Möbius committed
502

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
503
504
505
506
507
  // ======================================================================
  // Create pick ToolBar
  // ======================================================================

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

Jan Möbius's avatar
 
Jan Möbius committed
509
510
511
  // ======================================================================
  // Context menu setup
  // ======================================================================
Jan Möbius's avatar
Jan Möbius committed
512

Jan Möbius's avatar
Jan Möbius committed
513
514
515
516
  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
517

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

Jan Möbius's avatar
 
Jan Möbius committed
521
  setupMenuBar();
Jan Möbius's avatar
Jan Möbius committed
522

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

525
  registerCoreKeys();
Dirk Wilden's avatar
Dirk Wilden committed
526

527
  setExamineMode();
528
529
530

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

531
532
533
534
  // Create stereo settings widget
  stereoSettingsWidget_ = new StereoSettingsWidget(this);
  // Make it look like a dialog
  stereoSettingsWidget_->setWindowFlags(Qt::Popup);
535
536
  // Connect combo boxes and sliders to local slots
  connect(stereoSettingsWidget_->stereoOpengl, SIGNAL(clicked()),
537
          this, SLOT(slotApplyStereoSettings()));
538
539
540
541
542
543
544
  connect(stereoSettingsWidget_->stereoAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->stereoPhilips, SIGNAL(clicked()),
          this, SLOT(slotApplyStereoSettings()));

545
546
  connect(stereoSettingsWidget_->focalDistance, SIGNAL(sliderReleased()),
          this, SLOT(slotApplyStereoSettings()));
547
548
549
550
551
  connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
          this, SLOT(slotApplyStereoSettings()));

  connect(stereoSettingsWidget_->headerContentType, SIGNAL(currentIndexChanged(int)),
          this, SLOT(slotApplyStereoSettings(int)));
552
553
554
555
  connect(stereoSettingsWidget_->headerFactor, SIGNAL(sliderReleased()),
          this, SLOT(slotApplyStereoSettings()));
  connect(stereoSettingsWidget_->headerOffsetCC, SIGNAL(sliderReleased()),
          this, SLOT(slotApplyStereoSettings()));
556
557
558
559
560
561
  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
562
563
564
565
566
567
568
}


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


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

Jan Möbius's avatar
 
Jan Möbius committed
570
571
572
573
574
575
576
577
}

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

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

Dirk Wilden's avatar
Dirk Wilden committed
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
  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
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
620
      setViewMode( OpenFlipper::Options::currentViewMode() );
Dirk Wilden's avatar
Dirk Wilden committed
621
622
623
624
625
626
627
628
629
630
631
632

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

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

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

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

Jan Möbius's avatar
 
Jan Möbius committed
636
637
638
639
640
  show();
}

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

641
642
643
644
645
646
647
648
649
650
651
/** 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
652
653
  fullscreenState_ = (uint) _state;

Jan Möbius's avatar
Jan Möbius committed
654
  OpenFlipperSettings().setValue("Core/Gui/fullscreen", bool( windowState() & Qt::WindowFullScreen) );
655
656
657
658

  show();
}

659
660
661
662
663
664
665
666
667
668
//-----------------------------------------------------------------------------

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);
    
669
670
671
672
673
    // Update The Checkbox in the Menu
    AC_ShowViewModeControls_->blockSignals(true);
    AC_ShowViewModeControls_->setChecked( _show  );
    AC_ShowViewModeControls_->blockSignals(false);
    
674
675
676
677
678
679
680
681
682
683
684
    if ( _show ) {
      viewModeControlBox_->show();
    } else {
      viewModeControlBox_->hide();
    }
    
  }
  
}


685
686
//-----------------------------------------------------------------------------

Jan Möbius's avatar
 
Jan Möbius committed
687
688
689
690
/** Hide or show logger
  */
void
CoreWidget::toggleLogger() {
Jan Möbius's avatar
Jan Möbius committed
691
692
693
694
695
696
697
698
699
700
701
702
703

  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
704

705
  // Hide/Show Logger
Jan Möbius's avatar
Jan Möbius committed
706
  showLogger( OpenFlipper::Options::loggerState() );
707
708
709
710
711
}

/** Hide or show logger
  */
void
Jan Möbius's avatar
Jan Möbius committed
712
CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
Jan Möbius's avatar
 
Jan Möbius committed
713
  //Hide Logger
Jan Möbius's avatar
Jan Möbius committed
714
715
716
  if (_state == loggerState_)
    return;

717
718
719
  qreal left, top, right, bottom;
  baseLayout_->getContentsMargins (&left, &top, &right, &bottom);

Jan Möbius's avatar
Jan Möbius committed
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
  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_);
739
        baseLayout_->setContentsMargins (left, top, right, 16);
Jan Möbius's avatar
Jan Möbius committed
740
741
742
743
744
745
746
747
748
749
750
751
752
753
      }
      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_);
754
        logWidget_->show ();
Jan Möbius's avatar
Jan Möbius committed
755
756
757
758

        wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
        wsizes[1] = originalLoggerSize_;
        splitter_->setSizes(wsizes);
759
        baseLayout_->setContentsMargins (left, top, right, 0);
Jan Möbius's avatar
Jan Möbius committed
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
      }
      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);
780
        baseLayout_->setContentsMargins (left, top, right, 0);
Jan Möbius's avatar
Jan Möbius committed
781
782
783
784
785
786
      }
      break;
  }
  loggerState_ = _state;

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

Jan Möbius's avatar
 
Jan Möbius committed
790
791
    // Remember old size
    originalLoggerSize_  = wsizes[1];
Jan Möbius's avatar
Jan Möbius committed
792

793
794
795
    int height = logWidget_->height ();

    splitter_->insertWidget (1, tempLogWidget);
Jan Möbius's avatar
 
Jan Möbius committed
796
797
798
    wsizes[0] = wsizes[0]+wsizes[1];
    wsizes[1] = 0;
    splitter_->setSizes(wsizes);
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
    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
815
  } else {
Jan Möbius's avatar
Jan Möbius committed
816

817
818
819
820
821
822
823
824
825
826
    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
827
  }
Jan Möbius's avatar
Jan Möbius committed
828
  */
Jan Möbius's avatar
 
Jan Möbius committed
829
830
831
832
833
834
835
836
}

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

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

Jan Möbius's avatar
 
Jan Möbius committed
838
  //toggle
Jan Möbius's avatar
Jan Möbius committed
839
  showToolbox( OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool() );
840
841
842
843
844
845
846
847
848
849
}

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

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

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

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

    //hide ViewMode Selection Widget
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
855
    toolBoxArea_->setVisible(false);
Jan Möbius's avatar
 
Jan Möbius committed
856
857
858

  }else{
    //reset last ViewMode
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
859
    if (OpenFlipper::Options::currentViewMode().trimmed() == "")
Jan Möbius's avatar
 
Jan Möbius committed
860
861
      setViewMode("All");
    else
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
862
      setViewMode( OpenFlipper::Options::currentViewMode() );
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
863
    toolBoxArea_->setVisible(true);
Jan Möbius's avatar
 
Jan Möbius committed
864
865
  }
}
Jan Möbius's avatar
Jan Möbius committed
866

867
868
//=============================================================================

869
void CoreWidget::setToolBoxOrientationOnTheRight(bool _toolBoxRight) {
870
  QList<int> wsizes;
Jan Möbius's avatar
Jan Möbius committed
871
  
872
873
  // Is toolbox currently on the right hand side?
  bool currentstate = toolSplitter_->widget(1) == toolBoxArea_;
Jan Möbius's avatar
Jan Möbius committed
874
875
  
  if ( _toolBoxRight != currentstate ) {
876
    
Jan Möbius's avatar
Jan Möbius committed
877
878
879
880
881
882
883
884
885
886
887
    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_);
    }
888
    
Jan Möbius's avatar
Jan Möbius committed
889
    // Store new setting
Jan Möbius's avatar
Jan Möbius committed
890
    OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight",_toolBoxRight);
891
    
Jan Möbius's avatar
Jan Möbius committed
892
893
    // remove the windowstates definition for the toolboxes, as it changed anyway.
    QSettings windowStates(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
894
                            OpenFlipper::Options::dirSeparator() +  "WindowStates.dat", QSettings::IniFormat);
Jan Möbius's avatar
Jan Möbius committed
895
896
    
    windowStates.value("Core/ToolSplitter");
897
898
899
    
  }
  
Jan Möbius's avatar
Jan Möbius committed
900

901
902
903
904
905
    
  toolSplitter_->refresh();
}
      

Jan Möbius's avatar
 
Jan Möbius committed
906
907
//=============================================================================

Jan Möbius's avatar
Jan Möbius committed
908
909
void
CoreWidget::addRecent(QString _filename, DataType _type)
Jan Möbius's avatar
 
Jan Möbius committed
910
{
911
912
  //dont add objects to recentMenu while loadind Settings
  if ( OpenFlipper::Options::loadingSettings() ) return;
Jan Möbius's avatar
Jan Möbius committed
913

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

Jan Möbius's avatar
 
Jan Möbius committed
916
  updateRecent();
Jan Möbius's avatar
Jan Möbius committed
917
918
919
920
921
922
923

}

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

void
CoreWidget::updateRecent()
Jan Möbius's avatar
 
Jan Möbius committed
924
925
926
{
  if ( recentFilesMenu_ == NULL)
    return;
Jan Möbius's avatar
Jan Möbius committed
927

Jan Möbius's avatar
 
Jan Möbius committed
928
929
  recentFilesMenu_->clear();

930
931
  QStringList recentFiles = OpenFlipperSettings().value("Core/File/RecentFiles", QStringList()).toStringList();
  QStringList recentTypes = OpenFlipperSettings().value("Core/File/RecentTypes", QStringList()).toStringList();
932

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

935
    QFileInfo fi(recentFiles[i]);
936
937

    if (fi.suffix() == "ini")
938
      recentFilesMenu_->addAction(QIcon(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator()+"Settings-Icon.png"), recentFiles[i]);
939
    else
940
      recentFilesMenu_->addAction(typeIcon( typeId(recentTypes[i]) ), recentFiles[i]);
941

Jan Möbius's avatar
 
Jan Möbius committed
942
943
  }

Jan Möbius's avatar
Jan Möbius committed
944
945
946
}

void
Jan Möbius's avatar
 
Jan Möbius committed
947
948
949
CoreWidget::closeEvent ( QCloseEvent * /* event */ ) {
  emit exit();
}
950
951

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

953
954
  if ( OpenFlipper::Options::nogui() )
    return;
Jan Möbius's avatar
Jan Möbius committed
955

956
  if ( optionsWidget_ == 0 ) {
Dirk Wilden's avatar
Dirk Wilden committed
957
    optionsWidget_ = new OptionsWidget(plugins_, coreKeys_, invKeys_, 0);
958
    connect(optionsWidget_,SIGNAL(applyOptions()),this,SIGNAL(applyOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
959
    connect(optionsWidget_,SIGNAL(saveOptions()),this,SIGNAL(saveOptions()));
Dirk Wilden's avatar
Dirk Wilden committed
960
961
    connect(optionsWidget_,SIGNAL(addKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)),
            this,          SLOT(slotAddKeyMapping(int,Qt::KeyboardModifiers,QObject*,int)));
962
963

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

Jan Möbius's avatar
Jan Möbius committed
966
  //show the optionsWidget centered
Dirk Wilden's avatar
Dirk Wilden committed
967
  QPoint center;
Jan Möbius's avatar
Jan Möbius committed
968
  center.setX( x() + width() / 2 );
Dirk Wilden's avatar
Dirk Wilden committed
969
970
  center.setY( y() + height() / 2 );

Dirk Wilden's avatar
Dirk Wilden committed
971
972
  optionsWidget_->setGeometry(center.x() - optionsWidget_->width() / 2,
                              center.y() - optionsWidget_->height()/ 2, optionsWidget_->width(), optionsWidget_->height());
Dirk Wilden's avatar
Dirk Wilden committed
973

974
  optionsWidget_->show();
Jan Möbius's avatar
Jan Möbius committed
975

976
}
Jan Möbius's avatar
Jan Möbius committed
977

978
void CoreWidget::nextViewerLayout() {
979

Jan Möbius's avatar
Jan Möbius committed
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
  if ( OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() ) {

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

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(1);
              break;
      case QtMultiViewLayout::Grid:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
              baseLayout_->setMode(QtMultiViewLayout::HSplit);

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(2);
              break;
      case QtMultiViewLayout::HSplit:
              baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
              baseLayout_->setMode(QtMultiViewLayout::SingleView);

              // Update combo box in the toolbar
              viewerLayoutBox_->setCurrentIndex(0);
              break;
      }
  }
1006
1007
1008
1009
}


void
1010
CoreWidget::setViewerLayout(int _idx) {
1011

Jan Möbius's avatar
Jan Möbius committed
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
  if ( OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() ) {

  switch (_idx) {
    case 0:
            baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
            baseLayout_->setMode(QtMultiViewLayout::SingleView);
            break;
    case 1:
            baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
            baseLayout_->setMode(QtMultiViewLayout::Grid);
            break;
    case 2:
            baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
            baseLayout_->setMode(QtMultiViewLayout::HSplit);
            break;
  }
1028
1029

    viewerLayoutBox_->setCurrentIndex(_idx);
Jan Möbius's avatar
Jan Möbius committed
1030
  }
1031
}
Jan Möbius's avatar
 
Jan Möbius committed
1032

1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
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*)),
1047
                examiner_widgets_[i], SLOT(updateGL()));
1048
1049
1050
1051
      }

    }

1052
    sceneGraphDialog_->setGeneratorMap(PluginFunctions::getSceneGraphGeneratorList() );
1053
1054
1055
1056
    sceneGraphDialog_->show();
  }
}

Jan Möbius's avatar
   
Jan Möbius committed
1057
1058
1059
1060
1061
1062
//-----------------------------------------------------------------------------

void
CoreWidget::sceneRectChanged(const QRectF &rect)
{
  centerWidget_->setGeometry (rect);
1063
  slidingLogger_->updateGeometry ();
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
1064
  pickToolbar_->updateGeometry ();
Jan Möbius's avatar
   
Jan Möbius committed
1065
1066
}

Dirk Wilden's avatar
Dirk Wilden committed
1067
1068
1069
1070
1071
1072
//-----------------------------------------------------------------------------

void
CoreWidget::startVideoCaptureDialog(){

  VideoCaptureDialog* dialog = new VideoCaptureDialog();
1073
  dialog->setModal(false);
Dirk Wilden's avatar
Dirk Wilden committed
1074
1075

  connect(dialog, SIGNAL(startVideoCapture(QString,int,bool)), this, SIGNAL(startVideoCapture(QString,int,bool)) );
1076
1077
1078
  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
1079
1080
  dialog->show();
}
Jan Möbius's avatar
   
Jan Möbius committed
1081

1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
//-----------------------------------------------------------------------------

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;
    }
  }
}
1100

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
1101
1102
1103
//-----------------------------------------------------------------------------

/// Use native or gl painted cursor
1104
void CoreWidget::setForceNativeCursor ( bool _state )
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
1105
{
1106
  cursorPainter_->setForceNative (_state);
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
1107
}
1108

Jan Möbius's avatar
 
Jan Möbius committed
1109
//=============================================================================
1110