Core.hh 61 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2
3
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40
41
42
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
43
44
45
46
47
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
48
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69




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

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

#ifndef MVIEWWIDGET_HH
#define MVIEWWIDGET_HH


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

70
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
Jan Möbius's avatar
 
Jan Möbius committed
71
72

// QT INCLUDES
73
74
#include <QVariant>
#include <QMainWindow>
Jan Möbius's avatar
 
Jan Möbius committed
75
76
77
78
79
80
#include <QToolBox>
#include <QStackedWidget>
#include <QSplashScreen>

#include <QDockWidget>
#include <QVector>
81
#include <QProgressDialog>
Jan Möbius's avatar
 
Jan Möbius committed
82
83
84
85
86
87
88
89
90
91
92

#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"
Jan Möbius's avatar
Jan Möbius committed
93
#include "OpenFlipper/Scripting/scriptPrototypes/prototypeVec4d.hh"
Jan Möbius's avatar
 
Jan Möbius committed
94
#include "OpenFlipper/Scripting/scriptPrototypes/prototypeMatrix4x4.hh"
95
#include "OpenFlipper/Scripting/scriptPrototypes/prototypeDataType.hh"
Jan Möbius's avatar
 
Jan Möbius committed
96
#include <OpenFlipper/Scripting/scriptWrappers/vec3dWrapper.hh>
Jan Möbius's avatar
Jan Möbius committed
97
#include <OpenFlipper/Scripting/scriptWrappers/vec4dWrapper.hh>
Jan Möbius's avatar
 
Jan Möbius committed
98
#include <OpenFlipper/Scripting/scriptWrappers/matrix4x4Wrapper.hh>
99
#include <OpenFlipper/Scripting/scriptWrappers/DataTypeWrapper.hh>
Jan Möbius's avatar
 
Jan Möbius committed
100
101
102
103
104
// #include <OpenFlipper/Scripting/scriptWrappers/ObjectIdWrapper.hh>

// Required Interface definition ( Some variables were defined there )
#include "OpenFlipper/BasePlugin/BaseInterface.hh"
#include "OpenFlipper/BasePlugin/FileInterface.hh"
105
#include "OpenFlipper/BasePlugin/TypeInterface.hh"
Jan Möbius's avatar
 
Jan Möbius committed
106
#include "OpenFlipper/BasePlugin/MenuInterface.hh"
107
#include "OpenFlipper/BasePlugin/InformationInterface.hh"
108
#include "OpenFlipper/BasePlugin/SelectionInterface.hh" // -> for SelectionInterface::PrimitiveType
Jan Möbius's avatar
 
Jan Möbius committed
109
110
111
112
#include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"

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

113
114
115
// Process manager widget
#include <OpenFlipper/widgets/processManagerWidget/processManagerWidget.hh>

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

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

120
121
#include <ACG/Scenegraph/CoordsysNode.hh>

122
123
#include <OpenFlipper/threads/JobInfo.hh>

124
#include <OpenFlipper/common/FileTypes.hh>
125
#include <OpenFlipper/common/InformationPlugins.hh>
126
#include "SpinBoxEventFilter.hh"
127

Jan Möbius's avatar
 
Jan Möbius committed
128
129
130
//== CLASS DEFINITION =========================================================


131
132
133
134
135
136
struct dataTypes {
  QString name;
  DataType type;
  TypeInterface* plugin;
};

Jan Möbius's avatar
 
Jan Möbius committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/** 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
161
162
163
  
  /// Handle Mouse events when in Light mode
  void slotMouseEventLight( QMouseEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
164
165
166
167
168
169
170
171

protected:

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

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

Dirk Wilden's avatar
Dirk Wilden committed
178
   /// When this Signal is emitted all Plugins are informed that some type of update was performed on an object
179
   void signalObjectUpdated(int, const UpdateType&);
Dirk Wilden's avatar
Dirk Wilden committed
180
   
Jan Möbius's avatar
 
Jan Möbius committed
181
182
183
184
185
186
   /// 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
187
188
   /// Emitted when an light event occurs
   void PluginMouseEventLight( QMouseEvent* );
Jan Möbius's avatar
 
Jan Möbius committed
189

190
191
   /// This signal is emitted if the object has been changed (source/target)
   void objectSelectionChanged( int );
192

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

196
197
198
   /// This signal is emitted after the scene has been drawn
   void pluginSceneDrawn();

Dirk Wilden's avatar
Dirk Wilden committed
199
200
201
   /// 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
202
203
204
   /// The texture with the given name and filename has been added
   void addTexture( QString, QString , uint );

205
206
207
   /// 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
208
209
210
211
212
213
214
215
216
   /// 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
217
218
219
   /// A texture mode should be changed
   void setTextureMode(QString _textureName ,QString _mode, int _id);

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

Dirk Wilden's avatar
Dirk Wilden committed
223
224
225
   /// Switch Texture Plugins to a given Mode
   void switchTexture( QString, int );

Jan Möbius's avatar
 
Jan Möbius committed
226
227
228
   /// Switch Texture Plugins to a given Mode
   void switchTexture( QString );

229
230
231
232
233
234
   /// 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 );

235
236
237
238
239
   ///fetch texture image
   void textureGetImage( QString _textureName , QImage& _image );

   ///fetch texture image
   void textureGetImage( QString _textureName , QImage& _image , int _id );
240
241
242
243

   /// get the texture index
   void textureIndex( QString _textureName, int _id, int& _index);
   
244
245
246
   /// get the texture index property name
   void textureIndexPropertyName( int _id, QString& _propertyName);
   
247
248
   /// get the texture name
   void textureName( int _id, int _textureIndex, QString& _textureName);
249
250
251
   
   /// get the texture's filename
   void textureFilename( int _id, QString _textureName, QString& _textureFilename);
252

253
254
255
256
257
   ///get current texture
   void getCurrentTexture( int _id, QString& _textureName );

   /// get a multi-texture's sub textures
   void getSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );
258
259
   
   /// SelectionInterface: This signal is emitted when a new toolbutton should be added
Jan Möbius's avatar
Jan Möbius committed
260
   void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
261
262
263
264
265
   
   /// 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
Jan Möbius's avatar
Jan Möbius committed
266
   void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
267
268
   
   /// SelectionInterface: This signal is emitted when a custom selection mode is added
Jan Möbius's avatar
Jan Möbius committed
269
   void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
270
                               SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier);
Jan Möbius's avatar
Jan Möbius committed
271
   void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
272
273
                               SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier,
                               DataType _objectTypeRestriction);
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
   
   /// 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);
301
302
303

   /// SelectionInterface: This signal is emitted when standard connected components selection is required
   void showComponentsSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
304
305
  
   /// SelectionInterface: This signal is emitted when standard toggle selection has been performed
306
   void toggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
307
308
309
310
311
312
313
314
315
316
317
   
   /// 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
318
   void sphereSelection(QMouseEvent* _event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect);
319
320
   
   /// SelectionInterface: This signal is emitted when standard closest boundary selection has been performed
321
   void closestBoundarySelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
322
323
   
   /// SelectionInterface: This signal is emitted when standard flood fill selection has been performed
324
   void floodFillSelection(QMouseEvent* _event, double _maxAngle, SelectionInterface::PrimitiveType _currentType, bool _deselect);
325
   
326
327
328
   /// SelectionInterface: This signal is emitted when standard connected components selection has been performed
   void componentsSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
   /// 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);
352

Jan Möbius's avatar
 
Jan Möbius committed
353
354
355
356
357
358
359
360
361
362
363
364
   /// 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 );

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

368
369
370
   /// This signal is emitted before the core deletes its data and exits
   void saveOnExit( INIFile& _ini );

371
372
373
374
375
376
377
378
379
380
381
   /// 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
382
   void aboutToRestore(int _objectId);
Jan Möbius's avatar
Jan Möbius committed
383
   
384
   /// Backup Plugin tells other Plugins that a restore has happened
385
   void restored( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
386
387
388
389

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

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

Jan Möbius's avatar
 
Jan Möbius committed
393
394
395
   /// Called after all plugins are loaded
   void pluginsInitialized();

396
397
398
   /// Tell plugins that the visibility of an object has changed
   void visibilityChanged(int _id);

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

402
403
404
   /// Called after an object has been deleted
   void objectDeleted( int );

Jan Möbius's avatar
 
Jan Möbius committed
405
406
407
408
409
410
411
412
   /** @} */

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

Jan Möbius's avatar
Jan Möbius committed
413
      /// Called by the plugins if they changed something in the object list (deleted, added, or other property changes)
414
      void slotObjectUpdated(int _identifier, const UpdateType& _type = UPDATE_ALL);
Jan Möbius's avatar
 
Jan Möbius committed
415

416
      /// Called when a plugin changes the visibility of an object
417
      void slotVisibilityChanged(int _id);
418

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

Jan Möbius's avatar
 
Jan Möbius committed
422
      /// Called by Plugins if they changed the active object
423
      void slotObjectSelectionChanged( int _id);
Jan Möbius's avatar
 
Jan Möbius committed
424
425

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

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

Dirk Wilden's avatar
Dirk Wilden committed
431
432
433
      /// 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
434
435
436
      /// Called by a plugin if it creates a texture
      void slotAddTexture( QString _textureName , QString _filename , uint _dimension );

437
438
      /// Called by a plugin if it creates a multitexture
      void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );
439
      void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int* _textureId );
440

Jan Möbius's avatar
 
Jan Möbius committed
441
442
443
444
445
446
447
448
449
      /// 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
450
451
452
      /// A texture mode should be changed
      void slotSetTextureMode(QString _textureName ,QString _mode, int _id);

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

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

Jan Möbius's avatar
 
Jan Möbius committed
459
460
461
      /// Tells Plugins to switch to the given Texture
      void slotSwitchTexture( QString _textureName );

462
463
464
465
466
467
      ///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 );

468
469
470
471
472
473
      ///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 );
      
474
475
476
      ///Called by plugins if texture index should be fetched
      void slotTextureIndex( QString _textureName, int _id, int& _index);
      
477
478
479
      ///Called by plugins if texture index property name should be fetched
      void slotTextureIndexPropertyName( int _id, QString& _propertyName);
      
480
481
482
      ///Called by plugins if texture name should be fetched
      void slotTextureName( int _id, int _textureIndex, QString& _textureName);
      
483
484
485
      ///Called by plugins if texture name should be fetched
      void slotTextureFilename( int _id, QString _textureName, QString& _textureFilename);
      
486
487
488
489
490
491
      ///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
492
493
494
      /// A plugin wants to load a given file
      void slotLoad(QString _filename, DataType _type, int& _id);

Dirk Wilden's avatar
Dirk Wilden committed
495
      /// the load widget wants to load a given file
Matthias Möller's avatar
Matthias Möller committed
496
      void slotLoad(QStringList _filenames, IdList _pluginIDs);
Dirk Wilden's avatar
Dirk Wilden committed
497
      
Jan Möbius's avatar
 
Jan Möbius committed
498
      /// Called when a file has been opened
499
      void slotFileOpened ( int _id );
Jan Möbius's avatar
 
Jan Möbius committed
500
501
502

      /// Called when an empty object has been Added
      void slotEmptyObjectAdded ( int _id );
503
504
  
      /// SelectionInterface: Called when a new selection type button should be added to the toolbar
Jan Möbius's avatar
Jan Möbius committed
505
      void slotAddSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
506
507
508
509
510

      /// 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
Jan Möbius's avatar
Jan Möbius committed
511
      void slotAddPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
512

Jan Möbius's avatar
Jan Möbius committed
513
514
515
516
517
518
519
520
521
      /** \brief SelectionInterface: Add new selection mode for specified type
       *
       * @param _handleName             Handle of the selection mode
       * @param _modeName               User visible name of the selection mode
       * @param _description            Description of the mode
       * @param _icon                   Icon displayed in the selection toolbar
       * @param _associatedTypes        primitive types supported by this mode
       * @param _customIdentifier       Identifier of this mode
       */
Jan Möbius's avatar
Jan Möbius committed
522
      void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
523
                                      SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier);
Jan Möbius's avatar
Jan Möbius committed
524
525
526
527
528
529
530
531
532
533
534

      /** \brief  SelectionInterface: Add new selection mode for specified type
       *
       * @param _handleName             Handle of the selection mode
       * @param _modeName               User visible name of the selection mode
       * @param _description            Description of the mode
       * @param _icon                   Icon displayed in the selection toolbar
       * @param _associatedTypes        primitive types supported by this mode
       * @param _customIdentifier       Identifier of this mode
       * @param _objectTypeRestriction  Object types supported by this mode
       */
Jan Möbius's avatar
Jan Möbius committed
535
      void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
536
537
                                      SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier,
                                      DataType _objectTypeRestriction);
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
      
      /// 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);

566
567
568
      /// SelectionInterface: Provide connected components selection operation for specific selection mode
      void slotShowComponentsSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);

569
      /// SelectionInterface: Called when toggle selection operation has been performed
570
      void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
571
572
573
574
575
576
577
578
579
580
581

      /// 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
582
      void slotSphereSelection(QMouseEvent* _event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect);
583
584

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

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

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

593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
      /// 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
616

Jan Möbius's avatar
Jan Möbius committed
617
618
619
620
621
622
623
      /** \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
624
625
      void slotGetAllFilters ( QStringList& _list);

626

627
628
      /// Called when a plugin wants to delete all objects
      void slotDeleteAllObjects( );
629
630
631
      
      /// Called to create inter plugin connections
      void slotCrossPluginConnect( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot);
632

633
634
635
      /// 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
636
637
638
      /// 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
639
      /// Get a Pointer to the Plugin with given _name (if it is loaded)
Jan Möbius's avatar
Jan Möbius committed
640
      //  void slotGetPlugin(QString _name, QObject* & _plugin );
Dirk Wilden's avatar
Dirk Wilden committed
641

Jan Möbius's avatar
 
Jan Möbius committed
642
643
644
645
646
647
648
649
650
651
652
   /** @} */

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

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

653
654
655
    /// Called when a plugin wants to lock or unlock scenegraph updates
    void  blockScenegraphUpdates(bool _block);

656
657
658
    /// process events during script execution to keep the ui alive
    void updateUI();

Jan Möbius's avatar
 
Jan Möbius committed
659
660
661
    /// Clear all data objects
    void clearAll();

662
663
664
    /// Called to delete an object
    void deleteObject( int _id );

665
666
667
668
    void setObjectComment(int objId, QString key, QString comment);
    void clearObjectComment(int objId, QString key);
    void clearAllComments(int objId);

669
670
    /// set fullscreen mode
    void fullscreen( bool _state );
671
672
673
    
    /// Show or Hide the viewmode control widget.
    void showViewModeControls( bool _show );
674

Jan Möbius's avatar
Jan Möbius committed
675
676
    /// Change the logging window state
    void loggerState(int _state);
677
678
679
    
    /// Enable or disable OpenMesh error logging
    void enableOpenMeshErrorLog(bool _state);
Jan Möbius's avatar
 
Jan Möbius committed
680

681
682
    /// Show or hide toolbox
    void showToolbox( bool _state );
Jan Möbius's avatar
 
Jan Möbius committed
683

684
685
686
    /// Show or hide Status Bar
    void showStatusBar( bool _state );

687
688
    /// Switch the multiView Mode
    void multiViewMode( int _mode );
Jan Möbius's avatar
 
Jan Möbius committed
689

690
691
692
693
694
695
    /// Enable or disable framerate restriction
    void restrictFrameRate( bool _enable );

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

696
697
    /// set the baseFilename for snapshots (a counter is automatically increased when
    /// snapshot() is called)
698
    void snapshotBaseFileName(QString _fname, unsigned int _viewerId = 0);
699
700
    
    /// Set the file type for snapshots.
701
    void snapshotFileType(QString _type, unsigned int _viewerId = 0);
702
703
704
    
    /// Set the start index for the snapshot counter
    void snapshotCounterStart(const int _counter, unsigned int _viewerId = 0);
705

706
707
708
    /** 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.
709
      The id of the current viewer is 0 (default).
710
    */
711
    void snapshot(unsigned int _viewerId = 0, int _width = 0, int _height = 0, bool _alpha = false, bool _hideCoordsys = false, int _numSamples = 1);
712

Dirk Wilden's avatar
Dirk Wilden committed
713
714
715
716
717
718
    /// 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
719
720
721
    /// Take a snapshot from all viewers
    void viewerSnapshot();

Dirk Wilden's avatar
   
Dirk Wilden committed
722
    /// resize the examinerViewer
723
724
725
726
    void resizeViewers(int _width, int _height );

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

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

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

734
735
736
737
738
739
    /// Block the scenegraph updates
    void blockSceneGraphUpdates();

    /// Unblock the scenegraph updates
    void unblockSceneGraphUpdates();

740
    void setView(QString view);
741
    void setViewAndWindowGeometry(QString view);
742

Jan Möbius's avatar
Jan Möbius committed
743
744
    /** @} */

745
746
747
748
749
750
   //===========================================================================
    /** @name Scripting functions for controlling view modes
    * @{ */
   //===========================================================================

public slots:
751
    /** \brief Scripting function to set toolboxes in a view mode
Jan Möbius's avatar
Jan Möbius committed
752
753
754
     *
     * @param _modeName Name of the View Mode
     * @param _toolboxList ; separated list of toolboxes in the view mode
755
    */
756
757
758
    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
759
760
761
762
     *
     * @param _modeName Name of the View Mode
     * @param _toolbarList ; separated list of toolbars in the view mode
     *
763
764
    */
    void addViewModeToolbars(QString _modeName, QString _toolbarList);
Jan Möbius's avatar
Marlin:    
Jan Möbius committed
765
766
    
    /** \brief Scripting function to set context menus in a view mode
Jan Möbius's avatar
Jan Möbius committed
767
768
769
     *
     * @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
770
771
    */
    void addViewModeContextMenus(QString _modeName, QString _contextMenuList);
772
773
    
    /** \brief Scripting function to set an icon for a view mode
Jan Möbius's avatar
Jan Möbius committed
774
775
     * @param _modeName Name of the View Mode
     * @param _iconName Name of the Icon File. Will be taken from OpenFlippers Icon directory
776
777
    */
    void addViewModeIcon(QString _modeName, QString _iconName);    
778
779
    
    /** \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
780
781
     *
     * @param _side The desired side (either "left" or "right")
782
783
    */
    void setToolBoxSide(QString _side);
784

Jan Möbius's avatar
Jan Möbius committed
785
786
787
788
    /** \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
789
790
    */
    void setToolBoxActive(QString _toolBoxName, bool _active);
Jan Möbius's avatar
Jan Möbius committed
791

Jan Möbius's avatar
 
Jan Möbius committed
792
793
794
795
796
797
    /** @} */

   //===========================================================================
    /** @name Basic functions
    * @{ */
   //===========================================================================
798
public slots:
Jan Möbius's avatar
Jan Möbius committed
799
800
801
802
803
  /** \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
804
805
806
807
   *  @param _filename Filename of the data
   *  @return id of object otherwise -1
   */
  int loadObject ( QString _filename );
808
809
  
private slots:
Matthias Möller's avatar
Matthias Möller committed
810
811
  void loadObjectFinished(QString _filename);

812
813
814
815
816
  /** 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
817
818
819

 public :

Jan Möbius's avatar
Jan Möbius committed
820
821
822
823
824
825
  /** \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.
826
827
828
829
  *
  * @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
830
  */
831
  void commandLineOpen(const char* _filename, bool _asPolyMesh );
Jan Möbius's avatar
 
Jan Möbius committed
832

833
834
835
836
837
838
839
840
841
842
  /** \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
843
844
  void commandLineScript(const char* _filename );

845
846
  private slots:

Jan Möbius's avatar
Jan Möbius committed
847
  /** \brief Executed after loading core completly to load files from commandline
848
  *
Jan Möbius's avatar
Jan Möbius committed
849
850
851
  * 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.
852
  */
Jan Möbius's avatar
Jan Möbius committed
853
  void slotExecuteAfterStartup();
854
855

  private:
Jan Möbius's avatar
Jan Möbius committed
856
    /// Vector storing filenames from commandline to be opened after application startup (objects)
857
    std::vector< std::pair < std::string , bool >  > commandLineFileNames_;
Jan Möbius's avatar
Jan Möbius committed
858
859
    
    /// Vector storing filenames from commandline to be opened after application startup (script files)
860
    std::vector< std::string > commandLineScriptNames_;
861
862
863