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




//=============================================================================
//
//  CLASS Core
//
//=============================================================================

/**
 * \file Core.hh
 * This File contains the header of the frameworks system core
*/

#ifndef MVIEWWIDGET_HH
#define MVIEWWIDGET_HH


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

63
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
Jan Möbius's avatar
 
Jan Möbius committed
64
65
66
67
68
69
70
71
72
73

// QT INCLUDES
#include <qvariant.h>
#include <qmainwindow.h>
#include <QToolBox>
#include <QStackedWidget>
#include <QSplashScreen>

#include <QDockWidget>
#include <QVector>
74
#include <QProgressDialog>
Jan Möbius's avatar
 
Jan Möbius committed
75
76
77
78
79
80
81
82
83
84
85
86

#include <QtScript/QScriptEngine>
#include <QtScript/QtScript>

#include "OpenFlipper/INIFile/INIFile.hh"

#include "OpenFlipper/Logging/Logging.hh"
#include "OpenFlipper/Scripting/Scripting.hh"

// Prototypes for scripting
#include "OpenFlipper/Scripting/scriptPrototypes/prototypeVec3d.hh"
#include "OpenFlipper/Scripting/scriptPrototypes/prototypeMatrix4x4.hh"
87
#include "OpenFlipper/Scripting/scriptPrototypes/prototypeDataType.hh"
Jan Möbius's avatar
 
Jan Möbius committed
88
89
#include <OpenFlipper/Scripting/scriptWrappers/vec3dWrapper.hh>
#include <OpenFlipper/Scripting/scriptWrappers/matrix4x4Wrapper.hh>
90
#include <OpenFlipper/Scripting/scriptWrappers/DataTypeWrapper.hh>
Jan Möbius's avatar
 
Jan Möbius committed
91
92
93
94
95
// #include <OpenFlipper/Scripting/scriptWrappers/ObjectIdWrapper.hh>

// Required Interface definition ( Some variables were defined there )
#include "OpenFlipper/BasePlugin/BaseInterface.hh"
#include "OpenFlipper/BasePlugin/FileInterface.hh"
96
#include "OpenFlipper/BasePlugin/TypeInterface.hh"
Jan Möbius's avatar
 
Jan Möbius committed
97
#include "OpenFlipper/BasePlugin/MenuInterface.hh"
98
#include "OpenFlipper/BasePlugin/InformationInterface.hh"
99
#include "OpenFlipper/BasePlugin/SelectionInterface.hh" // -> for SelectionInterface::PrimitiveType
Jan Möbius's avatar
 
Jan Möbius committed
100
101
102
103
#include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"

#include <OpenFlipper/widgets/coreWidget/CoreWidget.hh>

104
105
106
// Process manager widget
#include <OpenFlipper/widgets/processManagerWidget/processManagerWidget.hh>

Jan Möbius's avatar
 
Jan Möbius committed
107
108
#include <OpenFlipper/common/GlobalOptions.hh>

Dirk Wilden's avatar
Dirk Wilden committed
109
110
#include <OpenFlipper/Core/PluginInfo.hh>

111
112
#include <ACG/Scenegraph/CoordsysNode.hh>

113
114
#include <OpenFlipper/threads/JobInfo.hh>

115
#include <OpenFlipper/common/FileTypes.hh>
116
#include <OpenFlipper/common/InformationPlugins.hh>
117

Jan Möbius's avatar
 
Jan Möbius committed
118
119
120
//== CLASS DEFINITION =========================================================


121
122
123
124
125
126
struct dataTypes {
  QString name;
  DataType type;
  TypeInterface* plugin;
};

Jan Möbius's avatar
 
Jan Möbius committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/** Core Widget of the Application
 */
class Core : public QObject
{
  Q_OBJECT

public:

  /// constructor
  Core();

  void init();

  /// destructor
  ~Core();

  /// Synchronise two viewers
  bool add_sync_host(const QString& _name);


private slots:

  /// Handle Mouse events when in Identifier mode
  void slotMouseEventIdentify( QMouseEvent* _event );
Jan Möbius's avatar
Mike:    
Jan Möbius committed
151
152
153
  
  /// Handle Mouse events when in Light mode
  void slotMouseEventLight( QMouseEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
154
155
156
157
158
159
160
161

protected:

    //===========================================================================
    /** @name Signals send to Plugins
    * @{ */
   //===========================================================================
signals:
Jan Möbius's avatar
Jan Möbius committed
162
   /// Signal send to plugins when whole scene is cleared
Jan Möbius's avatar
Jan Möbius committed
163
   void allCleared();
164

Jan Möbius's avatar
 
Jan Möbius committed
165
   /// When this Signal is emitted all Plugins are informed that the object list changed
166
   void signalObjectUpdated(int);
Jan Möbius's avatar
 
Jan Möbius committed
167

Dirk Wilden's avatar
Dirk Wilden committed
168
   /// When this Signal is emitted all Plugins are informed that some type of update was performed on an object
169
   void signalObjectUpdated(int, const UpdateType&);
Dirk Wilden's avatar
Dirk Wilden committed
170
   
Jan Möbius's avatar
 
Jan Möbius committed
171
172
173
174
175
176
   /// When this Signal is emitted when a Wheel Event occures
   void PluginWheelEvent(QWheelEvent * , const std::string & );

   /// When this Signal is emitted when a Mouse Event occures
   void PluginMouseEvent(QMouseEvent* );

Jan Möbius's avatar
Mike:    
Jan Möbius committed
177
178
   /// Emitted when an light event occurs
   void PluginMouseEventLight( QMouseEvent* );
Jan Möbius's avatar
 
Jan Möbius committed
179

180
181
   /// This signal is emitted if the object has been changed (source/target)
   void objectSelectionChanged( int );
182

183
184
   /// This signal is emitted if one of the viewers updated its view
   void pluginViewChanged();
Jan Möbius's avatar
 
Jan Möbius committed
185

186
187
188
   /// This signal is emitted after the scene has been drawn
   void pluginSceneDrawn();

Dirk Wilden's avatar
Dirk Wilden committed
189
190
191
   /// The texture with the given name and filename has been added
   void addTexture( QString, QString , uint, int );

Jan Möbius's avatar
 
Jan Möbius committed
192
193
194
   /// The texture with the given name and filename has been added
   void addTexture( QString, QString , uint );

195
196
197
   /// The texture with the given name and filename has been added
   void addMultiTexture( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );

Jan Möbius's avatar
 
Jan Möbius committed
198
199
200
201
202
203
204
205
206
   /// Tell the plugins to update the given texture
   void updateTexture( QString , int );

   /// Update all textures in the plugins
   void updateAllTextures( );

   /// This Signal is send to the plugins if a texture has been updated
   void updatedTextures( QString , int );

Dirk Wilden's avatar
Dirk Wilden committed
207
208
209
   /// A texture mode should be changed
   void setTextureMode(QString _textureName ,QString _mode, int _id);

Jan Möbius's avatar
 
Jan Möbius committed
210
211
212
   /// A texture mode should be changed
   void setTextureMode(QString _textureName ,QString _mode);

Dirk Wilden's avatar
Dirk Wilden committed
213
214
215
   /// Switch Texture Plugins to a given Mode
   void switchTexture( QString, int );

Jan Möbius's avatar
 
Jan Möbius committed
216
217
218
   /// Switch Texture Plugins to a given Mode
   void switchTexture( QString );

219
220
221
222
223
224
   /// Change the image for a given texture
   void textureChangeImage( QString _textureName , QImage& _image );

   /// Change the image for a given texture
   void textureChangeImage( QString _textureName , QImage& _image , int _id );

225
226
227
228
229
   ///fetch texture image
   void textureGetImage( QString _textureName , QImage& _image );

   ///fetch texture image
   void textureGetImage( QString _textureName , QImage& _image , int _id );
230
231
232
233

   /// get the texture index
   void textureIndex( QString _textureName, int _id, int& _index);
   
234
235
236
   /// get the texture index property name
   void textureIndexPropertyName( int _id, QString& _propertyName);
   
237
238
   /// get the texture name
   void textureName( int _id, int _textureIndex, QString& _textureName);
239
240
241
   
   /// get the texture's filename
   void textureFilename( int _id, QString _textureName, QString& _textureFilename);
242

243
244
245
246
247
   ///get current texture
   void getCurrentTexture( int _id, QString& _textureName );

   /// get a multi-texture's sub textures
   void getSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );
248
249
250
251
252
253
254
255
256
257
258
259
260
   
   /// SelectionInterface: This signal is emitted when a new toolbutton should be added
   void addSelectionEnvironment(QString _modeName, QString _description, QIcon _icon, QString& _handleName);
   
   /// SelectionInterface: This signal is emitted when a data type should be registered for a selection mode
   void registerType(QString _handleName, DataType _type);
   
   /// SelectionInterface: This signal is emitted when a selection plugin should handle a new primitive type
   void addPrimitiveType(QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType& _typeHandle);
   
   /// SelectionInterface: This signal is emitted when a custom selection mode is added
   void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QIcon _icon,
                               SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier);
261
262
263
   void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QIcon _icon,
                               SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier,
                               DataType _objectTypeRestriction);
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
   
   /// SelectionInterface: This signal is used to add non-interactive operations for a specific primitive type
   void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type);
   
   /// SelectionInterface: This signal is emitted when a non-interactive operation has been performed
   void selectionOperation(QString _operation);
  
   /// SelectionInterface: This signal is emitted when standard toggle selection is required
   void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
   
   /// SelectionInterface: This signal is emitted when standard lasso selection is required
   void showLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
   
   /// SelectionInterface: This signal is emitted when standard volume lasso selection is required
   void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
   
   /// SelectionInterface: This signal is emitted when standard surface lasso selection is required
   void showSurfaceLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
   
   /// SelectionInterface: This signal is emitted when standard sphere selection is required
   void showSphereSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
   
   /// SelectionInterface: This signal is emitted when standard closest boundary selection is required
   void showClosestBoundarySelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
   
   /// SelectionInterface: This signal is emitted when standard flood fill selection is required
   void showFloodFillSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
291
292
293

   /// SelectionInterface: This signal is emitted when standard connected components selection is required
   void showComponentsSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
294
295
  
   /// SelectionInterface: This signal is emitted when standard toggle selection has been performed
296
   void toggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
297
298
299
300
301
302
303
304
305
306
307
   
   /// SelectionInterface: This signal is emitted when standard lasso selection has been performed
   void lassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
   
   /// SelectionInterface: This signal is emitted when standard volume lasso selection has been performed
   void volumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
   
   /// SelectionInterface: This signal is emitted when standard surface lasso selection has been performed
   void surfaceLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
   
   /// SelectionInterface: This signal is emitted when standard sphere selection has been performed
308
   void sphereSelection(QMouseEvent* _event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect);
309
310
   
   /// SelectionInterface: This signal is emitted when standard closest boundary selection has been performed
311
   void closestBoundarySelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
312
313
   
   /// SelectionInterface: This signal is emitted when standard flood fill selection has been performed
314
   void floodFillSelection(QMouseEvent* _event, double _maxAngle, SelectionInterface::PrimitiveType _currentType, bool _deselect);
315
   
316
317
318
   /// SelectionInterface: This signal is emitted when standard connected components selection has been performed
   void componentsSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);

319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
   /// SelectionInterface: This signal is emitted when a custom selection operation has been performed
   void customSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, QString _customIdentifier, bool _deselect);
  
   /// SelectionInterface: This signal is emitted when the active (selected) data types should be fetched
   void getActiveDataTypes(SelectionInterface::TypeList& _types);
   
   /// SelectionInterface: This signal is emitted when the active (selected) primitive type should be fetched
   void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
   
   /// SelectionInterface: This signal is emitted if the current target restriction state is requested
   void targetObjectsOnly(bool& _targetsOnly);
   
   /// SelectionInterface: This signal is emitted when a selection should be loaded from a file
   void loadSelection(const INIFile& _file);
   
   /// SelectionInterface: This signal is emitted when a selection should be written into a file
   void saveSelection(INIFile& _file);
   
   /// SelectionInterface: This signal is emitted when a type selection plugin wants to listen to a key event
   void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers);
   
   /// SelectionInterface: This signal is emitted when a key shortcut has been pressed
   void keyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
342

Jan Möbius's avatar
 
Jan Möbius committed
343
344
345
346
347
348
349
350
351
352
353
354
   /// If an ini File is opened, this signal is send to Plugins capable of handling ini files
   void iniLoad( INIFile&, int );

   /// This signal is used to tell the plugins to save the data of _id to the given file
   void iniSave( INIFile& _ini ,int _id );

   /// This signal is used to tell the plugins to save their current status
   void iniSaveOptions(  INIFile& _ini );

   /// This signal is used to tell the plugins to load their new status
   void iniLoadOptions(  INIFile& _ini );

355
356
357
   /// This signal is used to tell the plugins to load their new status after objects are loaded
   void iniLoadOptionsLast(  INIFile& _ini );

358
359
360
   /// This signal is emitted before the core deletes its data and exits
   void saveOnExit( INIFile& _ini );

361
362
363
364
365
366
367
368
369
370
371
   /// Tell backup-plugin to create a backup
   void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
   void createBackup( IdList _objectids, QString _name, std::vector<UpdateType> _types);

   /// Tell backup-plugin to undo/redo
   void undo(int _objectid);
   void redo(int _objectid);
   void undo();
   void redo();

   /// Backup Plugin tells other Plugins that a restore will happen
372
   void aboutToRestore(int _objectId);
Jan Möbius's avatar
Jan Möbius committed
373
   
374
   /// Backup Plugin tells other Plugins that a restore has happened
375
   void restored( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
376
377
378
379

   /// Tell the plugins that a file has been opened ( -> Database)
   void openedFile( int _id );

Dirk Wilden's avatar
Dirk Wilden committed
380
381
382
   /// Tell the plugins that an empty object has been added
   void emptyObjectAdded( int _id);

Jan Möbius's avatar
 
Jan Möbius committed
383
384
385
   /// Called after all plugins are loaded
   void pluginsInitialized();

386
387
388
   /// Tell plugins that the visibility of an object has changed
   void visibilityChanged(int _id);

Jan Möbius's avatar
Jan Möbius committed
389
390
391
   /// Tell plugins that object properties such as object names have been changed
   void objectPropertiesChanged( int _id );

392
393
394
   /// Called after an object has been deleted
   void objectDeleted( int );

Jan Möbius's avatar
 
Jan Möbius committed
395
396
397
398
399
400
401
402
403
404
405
   /** @} */

   //===========================================================================
    /** @name Slots called by the plugins
    * @{ */
   //===========================================================================
   private slots :

      /** Called by the plugins if they changed something in the object list (deleted, added,...)
       * @param _identifier Id of the object
       */
406
      void slotObjectUpdated(int _identifier, const UpdateType& _type = UPDATE_ALL);
Jan Möbius's avatar
 
Jan Möbius committed
407

408
      /// Called when a plugin changes the visibility of an object
409
      void slotVisibilityChanged(int _id);
410

Jan Möbius's avatar
Jan Möbius committed
411
412
413
      /// Called by plugins if object properties like names have changed
      void slotObjectPropertiesChanged( int _id );

Jan Möbius's avatar
 
Jan Möbius committed
414
      /// Called by Plugins if they changed the active object
415
      void slotObjectSelectionChanged( int _id);
Jan Möbius's avatar
 
Jan Möbius committed
416
417

      /// Add a new picking mode to the examiner_widget_
Jan Möbius's avatar
Jan Möbius committed
418
      void slotAddPickMode( const std::string& _mode );
Jan Möbius's avatar
 
Jan Möbius committed
419
420

      /// Add a new and invisible picking mode to the examiner_widget_
Jan Möbius's avatar
Jan Möbius committed
421
      void slotAddHiddenPickMode( const std::string& _mode );
Jan Möbius's avatar
 
Jan Möbius committed
422

Dirk Wilden's avatar
Dirk Wilden committed
423
424
425
      /// Called by a plugin if it creates a texture
      void slotAddTexture( QString _textureName , QString _filename , uint _dimension , int _id );

Jan Möbius's avatar
 
Jan Möbius committed
426
427
428
      /// Called by a plugin if it creates a texture
      void slotAddTexture( QString _textureName , QString _filename , uint _dimension );

429
430
431
      /// Called by a plugin if it creates a multitexture
      void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );

Jan Möbius's avatar
 
Jan Möbius committed
432
433
434
435
436
437
438
439
440
      /// Tell the plugins to update the given texture
      void slotUpdateTexture( QString _name , int _identifier);

      /// Update all textures in the plugins
      void slotUpdateAllTextures( );

      /// A Texture has been updated
      void slotTextureUpdated( QString _textureName , int _identifier );

Dirk Wilden's avatar
Dirk Wilden committed
441
442
443
      /// A texture mode should be changed
      void slotSetTextureMode(QString _textureName ,QString _mode, int _id);

Jan Möbius's avatar
 
Jan Möbius committed
444
445
446
      /// A texture mode should be changed
      void slotSetTextureMode(QString _textureName ,QString _mode);

Dirk Wilden's avatar
Dirk Wilden committed
447
448
449
      /// Tells Plugins to switch to the given Texture
      void slotSwitchTexture( QString _textureName, int _id );

Jan Möbius's avatar
 
Jan Möbius committed
450
451
452
      /// Tells Plugins to switch to the given Texture
      void slotSwitchTexture( QString _textureName );

453
454
455
456
457
458
      ///Called by plugins if texture image should be changed
      void slotTextureChangeImage( QString _textureName , QImage& _image );

      ///Called by plugins if texture image should be changed
      void slotTextureChangeImage( QString _textureName , QImage& _image , int _id );

459
460
461
462
463
464
      ///Called by plugins if texture image should be fetched
      void slotTextureGetImage( QString _textureName , QImage& _image );

      ///Called by plugins if texture image should be fetched
      void slotTextureGetImage( QString _textureName , QImage& _image , int _id );
      
465
466
467
      ///Called by plugins if texture index should be fetched
      void slotTextureIndex( QString _textureName, int _id, int& _index);
      
468
469
470
      ///Called by plugins if texture index property name should be fetched
      void slotTextureIndexPropertyName( int _id, QString& _propertyName);
      
471
472
473
      ///Called by plugins if texture name should be fetched
      void slotTextureName( int _id, int _textureIndex, QString& _textureName);
      
474
475
476
      ///Called by plugins if texture name should be fetched
      void slotTextureFilename( int _id, QString _textureName, QString& _textureFilename);
      
477
478
479
480
481
482
      ///Called by plugins if current texture should be retrieved
      void slotGetCurrentTexture( int _id, QString& _textureName );

      ///Called by plugins if a multi-texture's sub textures should be fetched
      void slotGetSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );

Jan Möbius's avatar
 
Jan Möbius committed
483
484
485
      /// A plugin wants to load a given file
      void slotLoad(QString _filename, DataType _type, int& _id);

Dirk Wilden's avatar
Dirk Wilden committed
486
487
488
      /// the load widget wants to load a given file
      void slotLoad(QString _filename, int _pluginID);
      
Jan Möbius's avatar
 
Jan Möbius committed
489
      /// Called when a file has been opened
490
      void slotFileOpened ( int _id );
Jan Möbius's avatar
 
Jan Möbius committed
491
492
493

      /// Called when an empty object has been Added
      void slotEmptyObjectAdded ( int _id );
494
495
496
497
498
499
500
501
502
503
504
505
506
  
      /// SelectionInterface: Called when a new selection type button should be added to the toolbar
      void slotAddSelectionEnvironment(QString _modeName, QString _description, QIcon _icon, QString& _handleName);

      /// SelectionInterface: Called when a data type is added for a specific selection type
      void slotRegisterType(QString _handleName, DataType _type);

      /// SelectionInterface: Called when a new, non-standard primitive type should be handled
      void slotAddPrimitiveType(QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType& _typeHandle);

      /// SelectionInterface: Add new selection mode for specified type
      void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QIcon _icon,
                                      SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier);
507
508
509
      void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QIcon _icon,
                                      SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier,
                                      DataType _objectTypeRestriction);
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
      
      /// SelectionInterface: Called in order to add non-interactive operations for a specific primitive type
      void slotAddSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type);
       
      /// SelectionInterface: Called when a non-interactive operation has been performed
      void slotSelectionOperation(QString _operation);

      /// SelectionInterface: Provide toggle selection operation for specific selection mode
      void slotShowToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

      /// SelectionInterface: Provide lasso selection operation for specific selection mode
      void slotShowLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

      /// SelectionInterface: Provide volume lasso selection operation for specific selection mode
      void slotShowVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
      
      /// SelectionInterface: Provide surface lasso selection operation for specific selection mode
      void slotShowSurfaceLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

      /// SelectionInterface: Provide sphere selection operation for specific selection mode
      void slotShowSphereSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

      /// SelectionInterface: Provide closest boundary selection operation for specific selection mode
      void slotShowClosestBoundarySelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

      /// SelectionInterface: Provide flood fill selection operation for specific selection mode
      void slotShowFloodFillSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

538
539
540
      /// SelectionInterface: Provide connected components selection operation for specific selection mode
      void slotShowComponentsSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

541
      /// SelectionInterface: Called when toggle selection operation has been performed
542
      void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
543
544
545
546
547
548
549
550
551
552
553

      /// SelectionInterface: Called when lasso selection operation has been performed
      void slotLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);

      /// SelectionInterface: Called when volume lasso selection operation has been performed
      void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
      
      /// SelectionInterface: Called when surface lasso selection operation has been performed
      void slotSurfaceLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);

      /// SelectionInterface: Called when sphere selection operation has been performed
554
      void slotSphereSelection(QMouseEvent* _event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect);
555
556

      /// SelectionInterface: Called when closest boundary selection operation has been performed
557
      void slotClosestBoundarySelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
558
559

      /// SelectionInterface: Called when flood fill selection operation has been performed
560
      void slotFloodFillSelection(QMouseEvent* _event, double _maxAngle, SelectionInterface::PrimitiveType _currentType, bool _deselect);
561

562
563
564
      /// SelectionInterface: Called when connected components selection operation has been performed
      void slotComponentsSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);

565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
      /// SelectionInterface: Called when custom selection operation has been performed
      void slotCustomSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, QString _customIdentifier, bool _deselect);

      /// SelectionInterface: Called when active (selected) data types should be fetched
      void slotGetActiveDataTypes(SelectionInterface::TypeList& _types);

      /// SelectionInterface: Called when active primitive type should be fetched
      void slotGetActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
      
      /// SelectionInterface: Called when target restriction state should be fetched
      void slotTargetObjectsOnly(bool& _targetsOnly);
      
      /// SelectionInterface: Called when a selection should be loaded from a file
      void slotLoadSelection(const INIFile& _file);
      
      /// SelectionInterface: Called when a selection should be stored into a file
      void slotSaveSelection(INIFile& _file);
      
      /// SelectionInterface: Called when a key shortcut is to be registered
      void slotRegisterKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers);
      
      /// SelectionInterface: Called when a key event occurred
      void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers);
Jan Möbius's avatar
 
Jan Möbius committed
588

Jan Möbius's avatar
Jan Möbius committed
589
590
591
592
593
594
595
      /** \brief Called when a plugin requests a list of file-filters
      *
      * This function collects all available load filters from the file Plugins.
      * It is normally called via the Load/Save interface ( LoadSaveInterface ).
      *
      * @param _list Returns a list of all available file load filters
      */ 
Jan Möbius's avatar
 
Jan Möbius committed
596
597
      void slotGetAllFilters ( QStringList& _list);

598

599
600
      /// Called when a plugin wants to delete all objects
      void slotDeleteAllObjects( );
601
602
603
      
      /// Called to create inter plugin connections
      void slotCrossPluginConnect( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot);
604

605
606
607
      /// called to switch the renderer for a specific viewer
      void slotSetRenderer(unsigned int _viewer, QString _rendererName);

Jan Möbius's avatar
Jan Möbius committed
608
609
610
      /// called to get the currently active renderer renderer for a specific viewer
      void slotGetCurrentRenderer(unsigned int _viewer, QString& _rendererName);

Dirk Wilden's avatar
Dirk Wilden committed
611
      /// Get a Pointer to the Plugin with given _name (if it is loaded)
Jan Möbius's avatar
Jan Möbius committed
612
      //  void slotGetPlugin(QString _name, QObject* & _plugin );
Dirk Wilden's avatar
Dirk Wilden committed
613

Jan Möbius's avatar
 
Jan Möbius committed
614
615
616
617
618
619
620
621
622
623
624
625
626
627
   /** @} */

    //===========================================================================
    /** @name scriptable slots
    * @{ */
   //===========================================================================
public slots:

    /// Called when a  plugin requests an update in the viewer
    void updateView();

    /// Clear all data objects
    void clearAll();

628
629
630
    /// Called to delete an object
    void deleteObject( int _id );

Jan Möbius's avatar
 
Jan Möbius committed
631
632
633
    /// exit the current application
    void exitApplication();

634
635
    /// set fullscreen mode
    void fullscreen( bool _state );
636
637
638
    
    /// Show or Hide the viewmode control widget.
    void showViewModeControls( bool _show );
639

Jan Möbius's avatar
Jan Möbius committed
640
641
    /// Change the logging window state
    void loggerState(int _state);
642
643
644
    
    /// Enable or disable OpenMesh error logging
    void enableOpenMeshErrorLog(bool _state);
Jan Möbius's avatar
 
Jan Möbius committed
645

646
647
    /// Show or hide toolbox
    void showToolbox( bool _state );
Jan Möbius's avatar
 
Jan Möbius committed
648

649
650
651
    /// Show or hide Status Bar
    void showStatusBar( bool _state );

652
653
    /// Switch the multiView Mode
    void multiViewMode( int _mode );
Jan Möbius's avatar
 
Jan Möbius committed
654

655
656
657
658
659
660
    /// Enable or disable framerate restriction
    void restrictFrameRate( bool _enable );

    /// set the maximal framerate ( automatically enables framerate restriction )
    void setMaxFrameRate( int _rate );

661
662
    /// set the baseFilename for snapshots (a counter is automatically increased when
    /// snapshot() is called)
663
    void snapshotBaseFileName(QString _fname, unsigned int _viewerId = 0);
664
665
    
    /// Set the file type for snapshots.
666
    void snapshotFileType(QString _type, unsigned int _viewerId = 0);
667
668
669
    
    /// Set the start index for the snapshot counter
    void snapshotCounterStart(const int _counter, unsigned int _viewerId = 0);
670

671
672
673
    /** Trigger a snapshot and increase the snapshot counter.
      Save snapshot to file determined by snapshotBaseFileName() and
      the current snapshot counter. The \a back buffer will be saved.
674
      The id of the current viewer is 0 (default).
675
    */
676
    void snapshot(unsigned int _viewerId = 0, int _width = 0, int _height = 0, bool _alpha = false, bool _hideCoordsys = false);
677

Dirk Wilden's avatar
Dirk Wilden committed
678
679
680
681
682
683
    /// Take a snapshot from the whole app
    void applicationSnapshot();

    /// Set the baseName for the application snapshot
    void applicationSnapshotName(QString _name);

Dirk Wilden's avatar
Dirk Wilden committed
684
685
686
    /// Take a snapshot from all viewers
    void viewerSnapshot();

Dirk Wilden's avatar
   
Dirk Wilden committed
687
    /// resize the examinerViewer
688
689
690
691
    void resizeViewers(int _width, int _height );

    /// resize the whole Application
    void resizeApplication(int _width, int _height );
Dirk Wilden's avatar
   
Dirk Wilden committed
692

Dirk Wilden's avatar
Dirk Wilden committed
693
694
695
    /// write the current versions of all plugins to ini file
    void writeVersionNumbers(QString _filename);

Jan Möbius's avatar
Dennis:    
Jan Möbius committed
696
697
698
    /// return the list of available object that has the given selection and type
    QList<int> objectList (QString _selection, QStringList _types);

699
700
701
702
703
704
   //===========================================================================
    /** @name Scripting functions for controlling view modes
    * @{ */
   //===========================================================================

public slots:
705
    /** \brief Scripting function to set toolboxes in a view mode
Jan Möbius's avatar
Jan Möbius committed
706
707
708
     *
     * @param _modeName Name of the View Mode
     * @param _toolboxList ; separated list of toolboxes in the view mode
709
    */
710
711
712
    void addViewModeToolboxes(QString _modeName, QString _toolboxList);
    
    /** \brief Scripting function to set toolbars in a view mode
Jan Möbius's avatar
Jan Möbius committed
713
714
715
716
     *
     * @param _modeName Name of the View Mode
     * @param _toolbarList ; separated list of toolbars in the view mode
     *
717
718
    */
    void addViewModeToolbars(QString _modeName, QString _toolbarList);
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
719
720
    
    /** \brief Scripting function to set context menus in a view mode
Jan Möbius's avatar
Jan Möbius committed
721
722
723
     *
     * @param _modeName Name of the View Mode
     * @param _contextMenuList ; separated list of context menus in the view mode
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
724
725
    */
    void addViewModeContextMenus(QString _modeName, QString _contextMenuList);
726
727
    
    /** \brief Scripting function to set an icon for a view mode
Jan Möbius's avatar
Jan Möbius committed
728
729
     * @param _modeName Name of the View Mode
     * @param _iconName Name of the Icon File. Will be taken from OpenFlippers Icon directory
730
731
    */
    void addViewModeIcon(QString _modeName, QString _iconName);    
732
733
    
    /** \brief Scripting function to set the side of the main window on which the toolbox should be displayed
Jan Möbius's avatar
Jan Möbius committed
734
735
     *
     * @param _side The desired side (either "left" or "right")
736
737
    */
    void setToolBoxSide(QString _side);
738

Jan Möbius's avatar
Jan Möbius committed
739
740
741
742
    /** \brief Scripting function to activate or deactivate a toolbox
     *
     * @param _toolBoxName Name of the toolbox to manipulate
     * @param _active      Activate or deactivate
Dirk Wilden's avatar
Dirk Wilden committed
743
744
745
    */
    void setToolBoxActive(QString _toolBoxName, bool _active);
    
Jan Möbius's avatar
 
Jan Möbius committed
746
747
748
749
750
751
    /** @} */

   //===========================================================================
    /** @name Basic functions
    * @{ */
   //===========================================================================
752
public slots:
Jan Möbius's avatar
Jan Möbius committed
753
754
755
756
757
  /** \brief Load a new Object ( this may also be an ini or ofs file )
   *
   * This function tries to get the type of data to be loaded from the filename 
   * and then load the file.
   *
Jan Möbius's avatar
 
Jan Möbius committed
758
759
760
761
   *  @param _filename Filename of the data
   *  @return id of object otherwise -1
   */
  int loadObject ( QString _filename );
762
763
  
private slots:
764
765
766
767
768
  /** Do a reset of the scenegraph (bounding box update,...)
   *
   * @param _resetTrackBall Should the rotation center of the trackball be reset to the scene center?
   */
  void resetScenegraph( bool _resetTrackBall );
Jan Möbius's avatar
 
Jan Möbius committed
769
770
771

 public :

Jan Möbius's avatar
Jan Möbius committed
772
773
774
775
776
777
  /** \brief Load an object from the commandline on application start
  *
  * This function is called before the event queue is executed. The filename and parameters
  * are stored. After the event queue is started, all files in this list will be opened.
  * This is necessary as the event queue has to run to schedule the events emitted 
  * during open operations.
778
779
780
781
  *
  * @param _filename filename of the file to be opened. If it does not contain a full path,
  *                  the current path will be prepended.
  * @param _asPolyMesh Load as a polymesh ( yes/no)
Jan Möbius's avatar
Jan Möbius committed
782
  */
783
  void commandLineOpen(const char* _filename, bool _asPolyMesh );
Jan Möbius's avatar
 
Jan Möbius committed
784

785
786
787
788
789
790
791
792
793
794
  /** \brief Load a script from the commandline on application start
  *
  * This function is called before the event queue is executed. The filename 
  * is stored. After the event queue is started, all files in this list will be opened.
  * This is necessary as the event queue has to run to schedule the events emitted 
  * during open operations.
  *
  * @param _filename filename of the script to be opened. If it does not contain a full path,
  *                  the current path will be prepended.
  */
Jan Möbius's avatar
 
Jan Möbius committed
795
796
  void commandLineScript(const char* _filename );

797
798
  private slots:

Jan Möbius's avatar
Jan Möbius committed
799
  /** \brief Executed after loading core completly to load files from commandline
800
  *
Jan Möbius's avatar
Jan Möbius committed
801
802
803
  * This slot is automatically called after application startup. All files from the commandline
  * will be loaded by this slot. This is required as the core and the event queue need to be running
  * to emit the required signals to the plugins.
804
  */
Jan Möbius's avatar
Jan Möbius committed
805
  void slotExecuteAfterStartup();
806
807

  private:
Jan Möbius's avatar
Jan Möbius committed
808
    /// Vector storing filenames from commandline to be opened after application startup (objects)
809
    std::vector< std::pair < std::string , bool >  > commandLineFileNames_;
Jan Möbius's avatar
Jan Möbius committed
810
811
    
    /// Vector storing filenames from commandline to be opened after application startup (script files)
812
    std::vector< std::string > commandLineScriptNames_;
813
814
815

  public:

Jan Möbius's avatar
 
Jan Möbius committed
816
817
818
819
820
  /** Add an empty Object of the given Type
  * @return id of the new object or -1 if unsupported
  */
  int addEmptyObject( DataType _type );

Jan Möbius's avatar
Jan Möbius committed
821
822
823
824
825
  /** \brief Load object of the given Type with given filename
   *
   * This function should not be used anymore. \n
   * The extension is now used to check for the plugin handling the given types.
   *
Jan Möbius's avatar
 
Jan Möbius committed
826
827
828
829
   * @return id of the new object or -1 if unsupported
   */
  int loadObject( DataType _type, QString _filename);

830
  /** @} */
Jan Möbius's avatar
 
Jan Möbius committed
831

832
  //===========================================================================
Jan Möbius's avatar
Jan Möbius committed
833
834
835
836
837
838
839
840
841
842
  /** @name  Video Stream creation
  * @{ */
  //===========================================================================
  private slots:
    /// Slot called everytime the view is updated
    void viewUpdated();

    /// Function called for every frame when capturing video
    void captureVideo();

Dirk Wilden's avatar
Dirk Wilden committed
843
844
  public slots:

Jan Möbius's avatar
Jan Möbius committed
845
    /// Start video capturing
Dirk Wilden's avatar
Dirk Wilden committed
846
    void startVideoCapture(QString _baseName, int _fps, bool _captureViewers);
Jan Möbius's avatar
Jan Möbius committed
847
848

    /// Stop video capturing
Dirk Wilden's avatar
Dirk Wilden committed
849
    void stopVideoCapture();
Jan Möbius's avatar
Jan Möbius committed
850
851
852
853
854

  private:
    QTimer videoTimer_;
    QTime  lastVideoTime_;

Dirk Wilden's avatar
Dirk Wilden committed
855
856
    int captureType_;

857
858
    bool capture_;

859
860
861
    int lastWidth_;
    int lastHeight_;

Jan Möbius's avatar
Jan Möbius committed
862
863
  /** @} */
  //===========================================================================
864
865
866
867
868
869
870
871
872
873
    /** @name Load / Save slots
    * @{ */
  //===========================================================================

  public slots:

    /** Save object with given id
      * @param _id id of the object
      */
    bool saveObject( int _id, QString _filename );
Dirk Wilden's avatar
Dirk Wilden committed
874
875
    
    void saveObject( int _id, QString _filename, int _pluginID );
876
877
    
    void saveObjects( IdList _ids, QString _filename, int _pluginID );
878

879
880
881
882
883
884
    /** Show dialog for saving an object to a new location
      * @param _id id of the object
      * @param _filename current filename of the object
      */
    bool saveObjectTo( int _id, QString _filename );

885
886
    bool saveObjectsTo( IdList _ids, QString _filename );
      
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
    /// Slot for saving objects from Menu
    void saveAllObjects();

    /// Slot for saving objects to a new location
    void saveAllObjectsTo();

    /// Save current status to a settings file
    void saveSettings();

    /// Open Load Widget
    void loadObject();

    /// Load status from file
    void loadSettings();

    /// Load status from file
    void loadSettings(QString _filename);
Jan Möbius's avatar
 
Jan Möbius committed
904

905
906
907
    /// Get object id from filename
    int getObjectId(QString _filename);

Jan Möbius's avatar
 
Jan Möbius committed
908
909
910
911
912
913
914
915
916
917
918
919
920
921
  /** @} */

  //===========================================================================
    /** @name Basic slots
    * @{ */
  //===========================================================================
   private slots :

      /// Gets called by examiner widget when mouse is moved in picking mode
      void slotMouseEvent( QMouseEvent* _event );

      /// Gets called by examiner widget when Wheel is moved in picking mode
      void slotWheelEvent( QWheelEvent * _event, const std::string & _mode);

922
923
924
925
      /** \brief Open the add Empty dialog
      *
      * This slot shows the addEmpty dialog which is used to add empty objects of supported dataTypes
      */
Jan Möbius's avatar
 
Jan Möbius committed
926
927
      void slotAddEmptyObjectMenu();

928
      /// Slot adding empty object of a given type
Jan Möbius's avatar
 
Jan Möbius committed
929
930
      void slotAddEmptyObject( DataType _type , int& _id );

931
932
933
      /// Slot copying an object
      void slotCopyObject( int _oldId , int& _newId );

Jan Möbius's avatar
 
Jan Möbius committed
934
935
936
937
938
      /// Exit Application
      void slotExit();

      /// Open Recent file
      void slotRecentOpen(QAction* _action);
Jan Möbius's avatar
Jan Möbius committed
939

940
941
942
      /// Slot for generating type specific backups
      void slotGenerateBackup( int _id, QString _name, UpdateType _type );

Jan Möbius's avatar
Jan Möbius committed
943
   public slots:
Jan Möbius's avatar
Jan Möbius committed
944

Jan Möbius's avatar
Jan Möbius committed
945
946
    /// Add a Toolbox from a plugin or from scripting
     void addToolbox(QString _name ,QWidget* _widget);
Jan Möbius's avatar
 
Jan Möbius committed
947

Dirk Wilden's avatar
Dirk Wilden committed
948
949
950
    /// Add a Toolbox from a plugin or from scripting (with icon)
     void addToolbox(QString _name ,QWidget* _widget, QIcon* _icon);

951
952
953
     /**
      * Get a toolbox.
      *
954
      * @param _pluginName The plugin which the requested toolbox belongs to.
955
      * @param _toolboxName The name of the requested toolbox.
956
      * @return A pointer to the requested toolbox widget if it was found, nullptr, otherwise.
957
958
959
      */
     QWidget *getToolbox(QString _pluginName, QString _toolboxName);

Jan Möbius's avatar
 
Jan Möbius committed
960
961
962
963
964
965
966
967
968
   private :

   //===========================================================================
    /** @name Scenegraph
    * @{ */
   //===========================================================================

   private:
      /// Scenegraphs root node
Dirk Wilden's avatar
Dirk Wilden committed
969
      SeparatorNode* root_node_scenegraph_;
970
971
972
      
      /// Seperator node for global nodes
      SeparatorNode* root_node_scenegraph_global_;
Dirk Wilden's avatar
Dirk Wilden committed
973

Jan Möbius's avatar
Jan Möbius committed
974
975
976
977
978
979
980
981
982
      /// Separator Node holding all core scenegraph nodes
      SeparatorNode* core_nodes_;
      
      
      ///Toplevel Nodes for data objects
      SeparatorNode* dataSeparatorNode_;
      
      /// Root Node for data objects
      SeparatorNode*  dataRootNode_;
Jan Möbius's avatar
Jan Möbius committed
983

984
985
986
      /// Node for coordsys Material
      ACG::SceneGraph::MaterialNode* coordsysMaterialNode_;

987
988
      /// Node for the coordinate system
      ACG::SceneGraph::CoordsysNode* coordsysNode_;
Jan Möbius's avatar
 
Jan Möbius committed
989
990
991
992
993
994
995
996
997
998
999

   /** @} */

   //===========================================================================
    /** @name IniFile and Options Handling
    * @{ */
   //===========================================================================

   /// Get all ini files and set basic paths and options
   void setupOptions();

Dirk Wilden's avatar
Dirk Wilden committed
1000
   /// Read Options that needs the GUI to be set up completely