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

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




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

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

#ifndef MVIEWWIDGET_HH
#define MVIEWWIDGET_HH


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


#include "OpenFlipper/common/Types.hh"

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

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

#include <QDockWidget>
#include <QVector>
77
#include <QProgressDialog>
Jan Möbius's avatar
 
Jan Möbius committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

#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"
#include <OpenFlipper/Scripting/scriptWrappers/vec3dWrapper.hh>
#include <OpenFlipper/Scripting/scriptWrappers/matrix4x4Wrapper.hh>
// #include <OpenFlipper/Scripting/scriptWrappers/ObjectIdWrapper.hh>

// Required Interface definition ( Some variables were defined there )
#include "OpenFlipper/BasePlugin/BaseInterface.hh"
#include "OpenFlipper/BasePlugin/FileInterface.hh"
#include "OpenFlipper/BasePlugin/MenuInterface.hh"
#include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"

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

#include <OpenFlipper/common/GlobalOptions.hh>

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

106
#include <ACG/Scenegraph/CoordsysNode.hh>
107
#include <ACG/Scenegraph/GridNode.hh>
108

109 110
#include <OpenFlipper/threads/JobInfo.hh>

Jan Möbius's avatar
 
Jan Möbius committed
111 112 113
//== CLASS DEFINITION =========================================================

struct fileTypes {
Dirk Wilden's avatar
Dirk Wilden committed
114
  QString name;
Jan Möbius's avatar
 
Jan Möbius committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
  DataType type;
  QString loadFilters;
  QString saveFilters;
  FileInterface* plugin;
};

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

protected:

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

Jan Möbius's avatar
 
Jan Möbius committed
156
   /// When this Signal is emitted all Plugins are informed that the object list changed
157
   void signalObjectUpdated(int);
Jan Möbius's avatar
 
Jan Möbius committed
158 159 160 161 162 163 164 165 166 167

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

   /// Emitted when an identify event occurs
   void PluginMouseEventIdentify( QMouseEvent* );

168 169
   /// This signal is emitted if the object has been changed (source/target)
   void objectSelectionChanged( int );
170

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

Dirk Wilden's avatar
Dirk Wilden committed
174 175 176
   /// 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
177 178 179
   /// The texture with the given name and filename has been added
   void addTexture( QString, QString , uint );

180 181 182
   /// 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
183 184 185 186 187 188 189 190 191
   /// 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
192 193 194
   /// A texture mode should be changed
   void setTextureMode(QString _textureName ,QString _mode, int _id);

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

Dirk Wilden's avatar
Dirk Wilden committed
198 199 200
   /// Switch Texture Plugins to a given Mode
   void switchTexture( QString, int );

Jan Möbius's avatar
 
Jan Möbius committed
201 202 203
   /// Switch Texture Plugins to a given Mode
   void switchTexture( QString );

204 205 206 207 208 209
   /// 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 );

Jan Möbius's avatar
 
Jan Möbius committed
210 211 212 213 214 215 216 217 218 219 220 221
   /// 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 );

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

225 226 227
   /// This signal is emitted before the core deletes its data and exits
   void saveOnExit( INIFile& _ini );

Jan Möbius's avatar
 
Jan Möbius committed
228 229 230 231 232 233
   /// Tell plugins to create a backup
   void createBackup( int _id , QString _name , int nextBackupId_);

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

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

Jan Möbius's avatar
 
Jan Möbius committed
237 238 239
   /// Called after all plugins are loaded
   void pluginsInitialized();

240 241 242
   /// Tell plugins that the visibility of an object has changed
   void visibilityChanged(int _id);

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

246 247 248
   /// Called after an object has been deleted
   void objectDeleted( int );

Jan Möbius's avatar
 
Jan Möbius committed
249 250 251 252 253 254 255 256 257 258 259
   /** @} */

   //===========================================================================
    /** @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
       */
260
      void slotObjectUpdated(int _identifier);
Jan Möbius's avatar
 
Jan Möbius committed
261

262
      /// Called when a plugin changes the visibility of an object
263
      void slotVisibilityChanged(int _id);
264

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

Jan Möbius's avatar
 
Jan Möbius committed
268
      /// Called by Plugins if they changed the active object
269
      void slotObjectSelectionChanged( int _id);
Jan Möbius's avatar
 
Jan Möbius committed
270 271 272 273 274 275 276

      /// Add a new picking mode to the examiner_widget_
      void slotAddPickMode( const std::string _mode );

      /// Add a new and invisible picking mode to the examiner_widget_
      void slotAddHiddenPickMode( const std::string _mode );

Dirk Wilden's avatar
Dirk Wilden committed
277 278 279
      /// 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
280 281 282
      /// Called by a plugin if it creates a texture
      void slotAddTexture( QString _textureName , QString _filename , uint _dimension );

283 284 285
      /// 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
286 287 288 289 290 291 292 293 294
      /// 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
295 296 297
      /// A texture mode should be changed
      void slotSetTextureMode(QString _textureName ,QString _mode, int _id);

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

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

Jan Möbius's avatar
 
Jan Möbius committed
304 305 306
      /// Tells Plugins to switch to the given Texture
      void slotSwitchTexture( QString _textureName );

307 308 309 310 311 312
      ///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 );

Jan Möbius's avatar
 
Jan Möbius committed
313 314 315 316 317 318
      /// Called if a backup is requested by the plugins
      void backupRequest( int _id , QString _name );

      /// A plugin wants to load a given file
      void slotLoad(QString _filename, DataType _type, int& _id);

Dirk Wilden's avatar
Dirk Wilden committed
319 320 321
      /// the load widget wants to load a given file
      void slotLoad(QString _filename, int _pluginID);
      
Jan Möbius's avatar
 
Jan Möbius committed
322 323 324 325 326 327
      /// Called when a file has been opened
      void slotObjectOpened ( int _id );

      /// Called when an empty object has been Added
      void slotEmptyObjectAdded ( int _id );

Jan Möbius's avatar
Jan Möbius committed
328 329 330 331 332 333 334
      /** \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
335 336
      void slotGetAllFilters ( QStringList& _list);

337 338 339
      /// Called when a plugin wants to delete an object
      void slotDeleteObject( int _id );

340 341 342
      /// Called when a plugin wants to delete all objects
      void slotDeleteAllObjects( );

Dirk Wilden's avatar
Dirk Wilden committed
343 344 345
      /// Get a Pointer to the Plugin with given _name (if it is loaded)
//       void slotGetPlugin(QString _name, QObject* & _plugin );

Jan Möbius's avatar
 
Jan Möbius committed
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
   /** @} */

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

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

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

    /// exit the current application
    void exitApplication();

363 364 365
    /// set fullscreen mode
    void fullscreen( bool _state );

Jan Möbius's avatar
Jan Möbius committed
366 367
    /// Change the logging window state
    void loggerState(int _state);
Jan Möbius's avatar
 
Jan Möbius committed
368

369 370
    /// Show or hide toolbox
    void showToolbox( bool _state );
Jan Möbius's avatar
 
Jan Möbius committed
371

372 373
    /// Switch the multiView Mode
    void multiViewMode( int _mode );
Jan Möbius's avatar
 
Jan Möbius committed
374

375 376 377 378 379 380
    /// Enable or disable framerate restriction
    void restrictFrameRate( bool _enable );

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

381 382
    /// set the baseFilename for snapshots (a counter is automatically increased when
    /// snapshot() is called)
Jan Möbius's avatar
Jan Möbius committed
383
    void snapshotBaseFileName(const QString& _fname, unsigned int _viewerId = 0);
384

385 386 387 388
    /** 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.
    */
Jan Möbius's avatar
Jan Möbius committed
389
    void snapshot(unsigned int _viewerId = 0);
390

Dirk Wilden's avatar
Dirk Wilden committed
391 392 393 394 395 396
    /// 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
397 398 399
    /// Take a snapshot from all viewers
    void viewerSnapshot();

Dirk Wilden's avatar
 
Dirk Wilden committed
400
    /// resize the examinerViewer
401 402 403 404
    void resizeViewers(int _width, int _height );

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

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

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

412 413 414 415 416 417
   //===========================================================================
    /** @name Scripting functions for controlling view modes
    * @{ */
   //===========================================================================

public slots:
418
    /** \brief Scripting function to set toolboxes in a view mode
419

420
      @param _modeName Name of the View Mode
421 422
      @param _toolboxList ; seperated list of toolboxes in the view mode
    */
423 424 425 426 427 428 429 430
    void addViewModeToolboxes(QString _modeName, QString _toolboxList);
    
    /** \brief Scripting function to set toolbars in a view mode
    
    @param _modeName Name of the View Mode
    @param _toolboxList ; seperated list of toolbars in the view mode
    */
    void addViewModeToolbars(QString _modeName, QString _toolbarList);
431

Jan Möbius's avatar
 
Jan Möbius committed
432 433 434 435 436 437 438 439 440 441 442 443 444
    /** @} */

   //===========================================================================
    /** @name Basic functions
    * @{ */
   //===========================================================================
private:
  /** Load a new Object ( this may also be an ini file )
   *  @param _filename Filename of the data
   *  @return id of object otherwise -1
   */
  int loadObject ( QString _filename );

445 446 447 448 449
  /** 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
450 451 452

 public :

Jan Möbius's avatar
Jan Möbius committed
453 454 455 456 457 458
  /** \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.
459 460 461 462
  *
  * @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
463
  */
464
  void commandLineOpen(const char* _filename, bool _asPolyMesh );
Jan Möbius's avatar
 
Jan Möbius committed
465

466 467 468 469 470 471 472 473 474 475
  /** \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
476 477
  void commandLineScript(const char* _filename );

478 479
  private slots:

480 481 482
  /** Executed after loading core completly
  *
  */
Jan Möbius's avatar
Jan Möbius committed
483
  void slotExecuteAfterStartup();
484 485

  private:
486 487
    std::vector< std::pair < std::string , bool >  > commandLineFileNames_;
    std::vector< std::string > commandLineScriptNames_;
488 489 490

  public:

Jan Möbius's avatar
 
Jan Möbius committed
491 492 493 494 495 496 497 498 499 500
  /** Add an empty Object of the given Type
  * @return id of the new object or -1 if unsupported
  */
  int addEmptyObject( DataType _type );

  /** Load object of the given Type with given filename
   * @return id of the new object or -1 if unsupported
   */
  int loadObject( DataType _type, QString _filename);

501
  /** @} */
Jan Möbius's avatar
 
Jan Möbius committed
502

503
  //===========================================================================
Jan Möbius's avatar
Jan Möbius committed
504 505 506 507 508 509 510 511 512 513
  /** @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
514 515
  public slots:

Jan Möbius's avatar
Jan Möbius committed
516
    /// Start video capturing
Dirk Wilden's avatar
Dirk Wilden committed
517
    void startVideoCapture(QString _baseName, int _fps, bool _captureViewers);
Jan Möbius's avatar
Jan Möbius committed
518 519

    /// Stop video capturing
Dirk Wilden's avatar
Dirk Wilden committed
520
    void stopVideoCapture();
Jan Möbius's avatar
Jan Möbius committed
521 522 523 524 525

  private:
    QTimer videoTimer_;
    QTime  lastVideoTime_;

Dirk Wilden's avatar
Dirk Wilden committed
526 527
    int captureType_;

528 529
    bool capture_;

530 531 532
    int lastWidth_;
    int lastHeight_;

Jan Möbius's avatar
Jan Möbius committed
533 534
  /** @} */
  //===========================================================================
535 536 537 538 539 540 541 542 543 544
    /** @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
545 546
    
    void saveObject( int _id, QString _filename, int _pluginID );
547

548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
    /** 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 );

    /// 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
571

572 573 574
    /// Get object id from filename
    int getObjectId(QString _filename);

Jan Möbius's avatar
 
Jan Möbius committed
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
  /** @} */

  //===========================================================================
    /** @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);

      /// Slot adding empty object from Menu
      void slotAddEmptyObjectMenu();

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

595 596 597
      /// Slot copying an object
      void slotCopyObject( int _oldId , int& _newId );

Jan Möbius's avatar
 
Jan Möbius committed
598 599 600 601 602
      /// Exit Application
      void slotExit();

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

Jan Möbius's avatar
Jan Möbius committed
604
   public slots:
Jan Möbius's avatar
Jan Möbius committed
605

Jan Möbius's avatar
Jan Möbius committed
606 607
    /// Add a Toolbox from a plugin or from scripting
     void addToolbox(QString _name ,QWidget* _widget);
Jan Möbius's avatar
 
Jan Möbius committed
608 609 610 611 612 613 614 615 616 617

   private :

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

   private:
      /// Scenegraphs root node
Dirk Wilden's avatar
Dirk Wilden committed
618 619
      SeparatorNode* root_node_scenegraph_;

Jan Möbius's avatar
Jan Möbius committed
620 621 622 623 624 625 626 627 628
      /// 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
629

630 631 632
      /// Node for coordsys Material
      ACG::SceneGraph::MaterialNode* coordsysMaterialNode_;

633 634
      /// Node for the coordinate system
      ACG::SceneGraph::CoordsysNode* coordsysNode_;
Jan Möbius's avatar
 
Jan Möbius committed
635

636
      /// Node for the grid
637
//       ACG::SceneGraph::GridNode* gridNode_;
638

Jan Möbius's avatar
 
Jan Möbius committed
639 640 641 642 643 644 645 646 647 648
   /** @} */

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

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

Dirk Wilden's avatar
Dirk Wilden committed
649 650 651
   /// Read Options that needs the GUI to be set up completely
   void readGUIOptions(INIFile& _ini);

652 653 654
   /// Read recent files from ini-file
   void readRecentFiles(QString _filename);

Jan Möbius's avatar
 
Jan Möbius committed
655 656 657 658 659 660
   /// Get and set Application options from ini file
   void readApplicationOptions(INIFile& _ini);

   /// Write Application options to ini file
   void writeApplicationOptions(INIFile& _ini);

661 662 663
   /// Restore key assignments from configs files
   void restoreKeyBindings();

Jan Möbius's avatar
 
Jan Möbius committed
664 665
  public slots:

Dirk Wilden's avatar
Dirk Wilden committed
666 667 668
   /// Save the current options to the standard ini file
   void saveOptions();

669 670 671
   /// after ini-files have been loaded and core is up or if options have been changed -> apply Options
   void applyOptions();

672 673 674 675 676
   /** \brief Load information from an ini file
    *
    * This function will open an ini file and load the information in it.
    *
    * @param _filename Name of the ini file
677
    * @param _coreSettings      Load core settings from the file
678
    * @param _perPluginSettings Load per plugin settings from the file
679
    * @param _loadObjects       Load objects defined in the ini file
680 681
    *
    */
682 683 684 685
   void openIniFile( QString _filename,
                     bool    _coreSettings ,
                     bool    _perPluginSettings,
                     bool    _loadObjects );
Jan Möbius's avatar
 
Jan Möbius committed
686 687 688 689 690 691 692 693 694 695 696 697

   /// Open an obj file and load everything in it ( Application/File Options )
   void openObjFile(QString _filename);

   /// Preprocesses obj file to find out which data type it stores
   void preprocessObjFile(QString _filename);

  private:

   /** \brief Write current status to ini file (Application and File Options)
    *
    *  Writes the complete status to an ini file ( All open objects and their Information )
Jan Möbius's avatar
Jan Möbius committed
698 699 700 701
    *
    * @param _filename filename of the ini file to write with full path
    * @param _relativePaths This defines if the paths to the objects should be made relative
    * @param _targetOnly Select if we want all open objects or only the ones which are selected as target.
702 703 704
    * @param _saveSystemSettings Choose if you also want to save system settings into the ini file.
    * @param _savePluginSettings Choose if you want to save per Plugin global settings into the ini file.
    * @param _saveObjectInfo If you want to store information about all open objects this has to be true
Jan Möbius's avatar
 
Jan Möbius committed
705
    */
706 707 708 709 710 711
   void writeIniFile( QString _filename,
                      bool    _relativePaths,
                      bool    _targetOnly,
                      bool    _saveSystemSettings,
                      bool    _savePluginSettings ,
                      bool    _saveObjectInfo );
Jan Möbius's avatar
 
Jan Möbius committed
712 713 714 715 716

   /** \brief Write current status to obj file (Application and File Options)
    *
    *  Writes the complete status to an obj file ( All open objects and their Information )
    */
717
   void writeObjFile(QString _filename, bool _relativePaths, bool _targetOnly);
Jan Möbius's avatar
 
Jan Möbius committed
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746

   /// Called if app is closed and writes all information to ini file
   void writeOnExit();

   /** @} */

  //===========================================================================
  /** @name Logging
  * @{ */
  //===========================================================================

  signals:
    /// Logg with OUT,WARN or ERR as type
    void log(Logtype _type , QString _message );

    /// Default logging as OUT
    void log(QString _message );

    /// Logging signal for ScriptEngine
    void scriptLog(QString _message);

    /// This signal is emitted to send log data to a plugin
    void externalLog(Logtype _type , QString _message);

  private slots:

    /// Console logger
    void slotLog(Logtype _type, QString _message);

Dirk Wilden's avatar
Dirk Wilden committed
747 748 749 750 751 752 753 754 755 756
    /// log to file
    void slotLogToFile(Logtype _type, QString _message);

  private:
    ///stream for logging to file
    QTextStream* logStream_;

    ///logfile
    QFile* logFile_;

Jan Möbius's avatar
 
Jan Möbius committed
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
  public :
    void scriptLogFunction( QString _output);

  /** @} */


  //===========================================================================
  /** @name Signal and Slot processing for Plugins
  * @{ */
  //===========================================================================

  private :
    /// Check if a plugin has a slot
    bool checkSlot(QObject* _plugin , const char* _slotSignature);

    /// Check if a plugin has a signal
    bool checkSignal(QObject* _plugin , const char* _signalSignature);

  /** @} */

  //===========================================================================
    /** @name Plugin Management
      * @{ */
  //===========================================================================

  private:
    /// List of all loaded plugins
Dirk Wilden's avatar
Dirk Wilden committed
784
    std::vector<PluginInfo> plugins;
Jan Möbius's avatar
 
Jan Möbius committed
785 786 787 788 789 790 791 792 793 794 795 796 797

    /// List of Plugins that should not be loaded
    QStringList dontLoadPlugins_;

    /// Index of Plugins toolbox widget
    int toolboxindex_;

    /// Function for loading Plugins
    void loadPlugin(QString filename, bool silent);

    /// Load all plugins from default plugin directory and from INI-File
    void loadPlugins();
  private slots:
Dirk Wilden's avatar
Dirk Wilden committed
798 799
    /// Show Plugins Dialog
    void slotShowPlugins();
Jan Möbius's avatar
 
Jan Möbius committed
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825

    /// Function for unloading Plugins
    void unloadPlugin(QString name);

    /// Dont Load the given _plugins on next startup
    void dontLoadPlugins(QStringList _plugins);

    /// Load Plugins from menu
    void slotLoadPlugin();

  /** @} */


  //===========================================================================
    /** @name Scripting support
      * @{ */
  //===========================================================================

  signals:

    void scriptInfo( QString _pluginName , QString _functionName  );

    void executeScript( QString _script );

    void executeFileScript( QString _filename );

826 827
    void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                            QStringList _parameters, QStringList _descriptions);
828 829 830 831 832 833 834 835 836 837 838

  public slots:
    /** \brief Create an script object from a ui file
     *
     * This function will load an ui file, set up a qwidget from that and makes it available
     * under _objectName for scripting.
     * @param _objectName The name in scripting environment used for the new object
     * @param _uiFilename ui file to load
     */
    void createWidget(QString _objectName, QString _uiFilename);

839 840 841
    /// Set the active ViewMode
    void setViewMode(QString _viewMode);

Dirk Wilden's avatar
Dirk Wilden committed
842 843 844
    /// Set the icon of a viewMode
    void setViewModeIcon(QString _mode, QString _iconName);

Jan Möbius's avatar
 
Jan Möbius committed
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870
  private :
    /// Core scripting engine
    QScriptEngine scriptEngine_;

    /// Wrappers for plugin scripting
    std::vector<ScriptingWrapper*> scriptingWrappers_;

    /// List of all registered scripting functions
    QStringList scriptingFunctions_;

    /// Prototype for the Vector type
    prototypeVec3d vec3dPrototype_;

    /// Prototype for the Vector type
    prototypeMatrix4x4 matrix4x4Prototype_;


  private slots:
    void slotScriptInfo( QString _pluginName , QString _functionName  );

    void slotExecuteScript( QString _script );

    void slotGetScriptingEngine( QScriptEngine*& _engine  );

    void slotGetAllAvailableFunctions( QStringList& _functions  );

871 872 873 874 875 876 877 878 879 880
    /// set a description for one of the plugin's public slots
    void slotSetSlotDescription(QString     _slotName,   QString _slotDescription,
                                QStringList _parameters, QStringList _descriptions);
    /// get available descriptions for a given public slot
    void slotGetDescription(QString _function, QString& _fnDescription,
                                QStringList& _parameters, QStringList& _descriptions );

  private:

    QList< SlotInfo > coreSlots_;
881

882 883
    void setDescriptions();

Jan Möbius's avatar
 
Jan Möbius committed
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
  /** @} */

  //===========================================================================
    /** @name RPC ( Remote procedure Call) support
      * @{ */
  //===========================================================================
  private slots:
    void slotPluginExists( QString _pluginName , bool& _exists );


    void slotFunctionExists( QString _pluginName , QString _functionName , bool& _exists  );

    /** This slot executes a function of a plugin.
     * If it does not exist, _success will be false
     * @param _pluginName Plugin where the function is implemented
     * @param _functionName name of the function ( Standard name, no parameters allowed!)
     * @param _success successfull execution?
     */
    void slotCall( QString _pluginName , QString _functionName , bool& _success  );

    /** This slot executes the given expression.
     * No checks are performed if the remote function is available.
     * @param _expression command to execute
     * @param _success successfull execution?
     */
    void slotCall( QString _expression , bool& _success  );

    /** This slot executes the given expression and returns the result
     *  No checks are performed if the remote function is available.
     *  if an error occurs the result contains an invalid QVariant
     *
     * ex. getValue("databaseplugin.tableExists(\"meshes\")", result) )
     *     result.toBool() == true
     *
     * @param _expression command to execute
     * @param _result The return value of the command
     */
    void slotGetValue(QString _expression, QVariant& _result );

  /** @} */

925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
  //===========================================================================
    /** @name Scenegraph redraw handling
      * @{ */
  //===========================================================================

  private slots:

    /// Called to check if the scenegraph needs to be redrawn
    void checkScenegraphDirty();

  private:

    /// Timer that starts scenegraph check
    QTimer *scenegraphCheckTimer_;

    /// Holds the time since last redraw
    QTime *redrawTime_;
Jan Möbius's avatar
 
Jan Möbius committed
942

943
  /** @} */
944 945 946 947 948 949 950 951 952
  
  
  //===========================================================================
  /** @name Process Interface and Controls
  * @{ */
  //===========================================================================
  
  private:
    
953 954 955 956 957
    QList< JobInfo* >  currentJobs;
    
    /// Find a job in the jobslist
    bool getJob(QString _jobId, int& _index);
    
958 959
  private slots:

960 961
    /// A job has been started by a plugin
    void slotStartJob( QString _jobId, QString _description , int _min , int _max,bool _blocking );
962
    
963
    /// A job state has been updated by a plugin
964 965
    void slotSetJobState(QString _jobId, int _value );
    
966
    /// A job state has been canceled by a plugin
967 968
    void slotCancelJob(QString _jobId );
    
969
    /// A job state has been finished by a plugin
970 971
    void slotFinishJob(QString _jobId );
    
972 973 974
    /// Called by dialogs if cancel button is pressed
    void slotJobCancelButtons();
    
975 976 977 978 979
  signals:
    
    void jobCanceled( QString _jobId );
    
  /** @} */
980

Jan Möbius's avatar
 
Jan Möbius committed
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
  private :

  /// Id for the next backup
  int nextBackupId_;

  /// Logger interfaces between plugins and core logger
  std::vector<PluginLogger*> loggers_;

  /// File-Plugins
  std::vector<fileTypes> supportedTypes_;

  /// addEmpty Widget
//   addEmptyWidget* addEmptyWidget_;

  private :
    ///Pointer to the data rootNode;
    BaseObject* objectRoot_;

    /// The main applications widget ( only created in gui mode )
    CoreWidget* coreWidget_;

    /// SplashScreen, only used in gui mode
    QSplashScreen* splash_;

    /// Last Splash message;
    QString splashMessage_;

    /// List of available draw modes
    QVector<ViewMode*> viewModes_;
1010 1011 1012

    /// If enabled, this timer will block screen refresh if done more then 30 times per second.
    QTimer* redrawTimer_;
1013 1014


Jan Möbius's avatar
 
Jan Möbius committed
1015 1016 1017 1018 1019 1020 1021 1022 1023
};

/// Special print function for core logger
QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine);

//=============================================================================
#endif // MVIEWWIDGET_HH defined
//=============================================================================