Core.hh

Go to the documentation of this file.
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8694 $                                                         *
00038  *   $Author: wilden $                                                      *
00039  *   $Date: 2010-03-09 18:49:22 +0100 (Di, 09. Mär 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS Core
00049 //
00050 //=============================================================================
00051 
00057 #ifndef MVIEWWIDGET_HH
00058 #define MVIEWWIDGET_HH
00059 
00060 
00061 //== INCLUDES =================================================================
00062 
00063 #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
00064 
00065 // QT INCLUDES
00066 #include <qvariant.h>
00067 #include <qmainwindow.h>
00068 #include <QToolBox>
00069 #include <QStackedWidget>
00070 #include <QSplashScreen>
00071 
00072 #include <QDockWidget>
00073 #include <QVector>
00074 #include <QProgressDialog>
00075 
00076 #include <QtScript/QScriptEngine>
00077 #include <QtScript/QtScript>
00078 
00079 #include "OpenFlipper/INIFile/INIFile.hh"
00080 
00081 #include "OpenFlipper/Logging/Logging.hh"
00082 #include "OpenFlipper/Scripting/Scripting.hh"
00083 
00084 // Prototypes for scripting
00085 #include "OpenFlipper/Scripting/scriptPrototypes/prototypeVec3d.hh"
00086 #include "OpenFlipper/Scripting/scriptPrototypes/prototypeMatrix4x4.hh"
00087 #include "OpenFlipper/Scripting/scriptPrototypes/prototypeDataType.hh"
00088 #include <OpenFlipper/Scripting/scriptWrappers/vec3dWrapper.hh>
00089 #include <OpenFlipper/Scripting/scriptWrappers/matrix4x4Wrapper.hh>
00090 #include <OpenFlipper/Scripting/scriptWrappers/DataTypeWrapper.hh>
00091 // #include <OpenFlipper/Scripting/scriptWrappers/ObjectIdWrapper.hh>
00092 
00093 // Required Interface definition ( Some variables were defined there )
00094 #include "OpenFlipper/BasePlugin/BaseInterface.hh"
00095 #include "OpenFlipper/BasePlugin/FileInterface.hh"
00096 #include "OpenFlipper/BasePlugin/TypeInterface.hh"
00097 #include "OpenFlipper/BasePlugin/MenuInterface.hh"
00098 #include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"
00099 
00100 #include <OpenFlipper/widgets/coreWidget/CoreWidget.hh>
00101 
00102 // Process manager widget
00103 #include <OpenFlipper/widgets/processManagerWidget/processManagerWidget.hh>
00104 
00105 #include <OpenFlipper/common/GlobalOptions.hh>
00106 
00107 #include <OpenFlipper/Core/PluginInfo.hh>
00108 
00109 #include <ACG/Scenegraph/CoordsysNode.hh>
00110 #include <ACG/Scenegraph/GridNode.hh>
00111 
00112 #include <OpenFlipper/threads/JobInfo.hh>
00113 
00114 //== CLASS DEFINITION =========================================================
00115 
00116 struct fileTypes {
00117   QString name;
00118   DataType type;
00119   QString loadFilters;
00120   QString saveFilters;
00121   FileInterface* plugin;
00122   QObject* object;
00123 };
00124 
00125 struct dataTypes {
00126   QString name;
00127   DataType type;
00128   TypeInterface* plugin;
00129 };
00130 
00133 class Core : public QObject
00134 {
00135   Q_OBJECT
00136 
00137 public:
00138 
00140   Core();
00141 
00142   void init();
00143 
00145   ~Core();
00146 
00148   bool add_sync_host(const QString& _name);
00149 
00150 
00151 private slots:
00152 
00154   void slotMouseEventIdentify( QMouseEvent* _event );
00155 
00156 protected:
00157 
00158     //===========================================================================
00161    //===========================================================================
00162 signals:
00164    void allCleared();
00165 
00167    void signalObjectUpdated(int);
00168 
00170    void signalObjectUpdated(int, const UpdateType);
00171    
00173    void PluginWheelEvent(QWheelEvent * , const std::string & );
00174 
00176    void PluginMouseEvent(QMouseEvent* );
00177 
00179    void PluginMouseEventIdentify( QMouseEvent* );
00180 
00182    void objectSelectionChanged( int );
00183 
00185    void pluginViewChanged();
00186 
00188    void addTexture( QString, QString , uint, int );
00189 
00191    void addTexture( QString, QString , uint );
00192 
00194    void addMultiTexture( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );
00195 
00197    void updateTexture( QString , int );
00198 
00200    void updateAllTextures( );
00201 
00203    void updatedTextures( QString , int );
00204 
00206    void setTextureMode(QString _textureName ,QString _mode, int _id);
00207 
00209    void setTextureMode(QString _textureName ,QString _mode);
00210 
00212    void switchTexture( QString, int );
00213 
00215    void switchTexture( QString );
00216 
00218    void textureChangeImage( QString _textureName , QImage& _image );
00219 
00221    void textureChangeImage( QString _textureName , QImage& _image , int _id );
00222 
00224    void iniLoad( INIFile&, int );
00225 
00227    void iniSave( INIFile& _ini ,int _id );
00228 
00230    void iniSaveOptions(  INIFile& _ini );
00231 
00233    void iniLoadOptions(  INIFile& _ini );
00234 
00236    void iniLoadOptionsLast(  INIFile& _ini );
00237 
00239    void saveOnExit( INIFile& _ini );
00240 
00242    void createBackup( int _id , QString _name , int nextBackupId_);
00243 
00245    void openedFile( int _id );
00246 
00248    void emptyObjectAdded( int _id);
00249 
00251    void pluginsInitialized();
00252 
00254    void visibilityChanged(int _id);
00255 
00257    void objectPropertiesChanged( int _id );
00258 
00260    void objectDeleted( int );
00261 
00264    //===========================================================================
00267    //===========================================================================
00268    private slots :
00269 
00273       void slotObjectUpdated(int _identifier, const UpdateType _type = UPDATE_ALL);
00274 
00276       void slotVisibilityChanged(int _id);
00277 
00279       void slotObjectPropertiesChanged( int _id );
00280 
00282       void slotObjectSelectionChanged( int _id);
00283 
00285       void slotAddPickMode( const std::string _mode );
00286 
00288       void slotAddHiddenPickMode( const std::string _mode );
00289 
00291       void slotAddTexture( QString _textureName , QString _filename , uint _dimension , int _id );
00292 
00294       void slotAddTexture( QString _textureName , QString _filename , uint _dimension );
00295 
00297       void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );
00298 
00300       void slotUpdateTexture( QString _name , int _identifier);
00301 
00303       void slotUpdateAllTextures( );
00304 
00306       void slotTextureUpdated( QString _textureName , int _identifier );
00307 
00309       void slotSetTextureMode(QString _textureName ,QString _mode, int _id);
00310 
00312       void slotSetTextureMode(QString _textureName ,QString _mode);
00313 
00315       void slotSwitchTexture( QString _textureName, int _id );
00316 
00318       void slotSwitchTexture( QString _textureName );
00319 
00321       void slotTextureChangeImage( QString _textureName , QImage& _image );
00322 
00324       void slotTextureChangeImage( QString _textureName , QImage& _image , int _id );
00325 
00327       void backupRequest( int _id , QString _name );
00328 
00330       void slotLoad(QString _filename, DataType _type, int& _id);
00331 
00333       void slotLoad(QString _filename, int _pluginID);
00334       
00336       void slotObjectOpened ( int _id );
00337 
00339       void slotEmptyObjectAdded ( int _id );
00340 
00348       void slotGetAllFilters ( QStringList& _list);
00349 
00351       void slotDeleteObject( int _id );
00352 
00354       void slotDeleteAllObjects( );
00355 
00357 //       void slotGetPlugin(QString _name, QObject* & _plugin );
00358 
00361     //===========================================================================
00364    //===========================================================================
00365 public slots:
00366 
00368     void updateView();
00369 
00371     void clearAll();
00372 
00374     void exitApplication();
00375 
00377     void fullscreen( bool _state );
00378 
00380     void loggerState(int _state);
00381 
00383     void showToolbox( bool _state );
00384 
00386     void multiViewMode( int _mode );
00387 
00389     void restrictFrameRate( bool _enable );
00390 
00392     void setMaxFrameRate( int _rate );
00393 
00396     void snapshotBaseFileName(const QString& _fname, unsigned int _viewerId = 0);
00397 
00402     void snapshot(unsigned int _viewerId = 0);
00403 
00405     void applicationSnapshot();
00406 
00408     void applicationSnapshotName(QString _name);
00409 
00411     void viewerSnapshot();
00412 
00414     void resizeViewers(int _width, int _height );
00415 
00417     void resizeApplication(int _width, int _height );
00418 
00420     void writeVersionNumbers(QString _filename);
00421 
00423     QList<int> objectList (QString _selection, QStringList _types);
00424 
00425    //===========================================================================
00428    //===========================================================================
00429 
00430 public slots:
00436     void addViewModeToolboxes(QString _modeName, QString _toolboxList);
00437     
00443     void addViewModeToolbars(QString _modeName, QString _toolbarList);
00444 
00447    //===========================================================================
00450    //===========================================================================
00451 private slots:
00460   int loadObject ( QString _filename );
00461 
00466   void resetScenegraph( bool _resetTrackBall );
00467 
00468  public :
00469 
00481   void commandLineOpen(const char* _filename, bool _asPolyMesh );
00482 
00493   void commandLineScript(const char* _filename );
00494 
00495   private slots:
00496 
00503   void slotExecuteAfterStartup();
00504 
00505   private:
00507     std::vector< std::pair < std::string , bool >  > commandLineFileNames_;
00508     
00510     std::vector< std::string > commandLineScriptNames_;
00511 
00512   public:
00513 
00517   int addEmptyObject( DataType _type );
00518 
00526   int loadObject( DataType _type, QString _filename);
00527 
00530   //===========================================================================
00533   //===========================================================================
00534   private slots:
00536     void viewUpdated();
00537 
00539     void captureVideo();
00540 
00541   public slots:
00542 
00544     void startVideoCapture(QString _baseName, int _fps, bool _captureViewers);
00545 
00547     void stopVideoCapture();
00548 
00549   private:
00550     QTimer videoTimer_;
00551     QTime  lastVideoTime_;
00552 
00553     int captureType_;
00554 
00555     bool capture_;
00556 
00557     int lastWidth_;
00558     int lastHeight_;
00559 
00561   //===========================================================================
00564   //===========================================================================
00565 
00566   public slots:
00567 
00571     bool saveObject( int _id, QString _filename );
00572     
00573     void saveObject( int _id, QString _filename, int _pluginID );
00574 
00579     bool saveObjectTo( int _id, QString _filename );
00580 
00582     void saveAllObjects();
00583 
00585     void saveAllObjectsTo();
00586 
00588     void saveSettings();
00589 
00591     void loadObject();
00592 
00594     void loadSettings();
00595 
00597     void loadSettings(QString _filename);
00598 
00600     int getObjectId(QString _filename);
00601 
00604   //===========================================================================
00607   //===========================================================================
00608    private slots :
00609 
00611       void slotMouseEvent( QMouseEvent* _event );
00612 
00614       void slotWheelEvent( QWheelEvent * _event, const std::string & _mode);
00615 
00620       void slotAddEmptyObjectMenu();
00621 
00623       void slotAddEmptyObject( DataType _type , int& _id );
00624 
00626       void slotCopyObject( int _oldId , int& _newId );
00627 
00629       void slotExit();
00630 
00632       void slotRecentOpen(QAction* _action);
00633 
00634    public slots:
00635 
00637      void addToolbox(QString _name ,QWidget* _widget);
00638 
00639    private :
00640 
00641    //===========================================================================
00644    //===========================================================================
00645 
00646    private:
00648       SeparatorNode* root_node_scenegraph_;
00649 
00651       SeparatorNode* core_nodes_;
00652       
00653       
00655       SeparatorNode* dataSeparatorNode_;
00656       
00658       SeparatorNode*  dataRootNode_;
00659 
00661       ACG::SceneGraph::MaterialNode* coordsysMaterialNode_;
00662 
00664       ACG::SceneGraph::CoordsysNode* coordsysNode_;
00665 
00667 //       ACG::SceneGraph::GridNode* gridNode_;
00668 
00671    //===========================================================================
00674    //===========================================================================
00675 
00677    void setupOptions();
00678 
00680    void readGUIOptions(INIFile& _ini);
00681 
00683    void readRecentFiles(QString _filename);
00684 
00686    void readApplicationOptions(INIFile& _ini);
00687 
00689    void writeApplicationOptions(INIFile& _ini);
00690 
00692    void restoreKeyBindings();
00693 
00694   public slots:
00695 
00697    void saveOptions();
00698 
00700    void applyOptions();
00701 
00712    void openIniFile( QString _filename,
00713                      bool    _coreSettings ,
00714                      bool    _perPluginSettings,
00715                      bool    _loadObjects );
00716 
00717   private:
00718 
00730    void writeIniFile( QString _filename,
00731                       bool    _relativePaths,
00732                       bool    _targetOnly,
00733                       bool    _saveSystemSettings,
00734                       bool    _savePluginSettings ,
00735                       bool    _saveObjectInfo );
00736 
00741    void writeObjFile(QString _filename, bool _relativePaths, bool _targetOnly);
00742 
00744    void writeOnExit();
00745 
00749   //===========================================================================
00752   //===========================================================================
00753 
00754   signals:
00756     void log(Logtype _type , QString _message );
00757 
00759     void log(QString _message );
00760 
00762     void scriptLog(QString _message);
00763 
00765     void externalLog(Logtype _type , QString _message);
00766 
00767   private slots:
00768 
00770     void slotLog(Logtype _type, QString _message);
00771 
00773     void slotLogToFile(Logtype _type, QString _message);
00774 
00775   private:
00777     QTextStream* logStream_;
00778 
00780     QFile* logFile_;
00781 
00782   public :
00783     void scriptLogFunction( QString _output);
00784 
00788   //===========================================================================
00791   //===========================================================================
00792 
00793   private :
00795     bool checkSlot(QObject* _plugin , const char* _slotSignature);
00796 
00798     bool checkSignal(QObject* _plugin , const char* _signalSignature);
00799 
00802   //===========================================================================
00805   //===========================================================================
00806 
00807   private:
00809     std::vector<PluginInfo> plugins;
00810 
00812     int toolboxindex_;
00813 
00815     void loadPlugin(QString filename, bool silent);
00816 
00818     void loadPlugins();
00819   private slots:
00821     void slotShowPlugins();
00822 
00824     void unloadPlugin(QString name);
00825 
00827     void slotLoadPlugin();
00828 
00832   //===========================================================================
00835   //===========================================================================
00836 
00837   signals:
00838 
00839     void scriptInfo( QString _pluginName , QString _functionName  );
00840 
00841     void executeScript( QString _script );
00842 
00843     void executeFileScript( QString _filename );
00844 
00845     void setSlotDescription(QString     _slotName,   QString     _slotDescription,
00846                             QStringList _parameters, QStringList _descriptions);
00847 
00848   public slots:
00856     void createWidget(QString _objectName, QString _uiFilename);
00857 
00859     void setViewMode(QString _viewMode);
00860 
00862     void setViewModeIcon(QString _mode, QString _iconName);
00863 
00864   private :
00866     QScriptEngine scriptEngine_;
00867 
00869     std::vector<ScriptingWrapper*> scriptingWrappers_;
00870 
00872     QStringList scriptingFunctions_;
00873 
00875     prototypeVec3d vec3dPrototype_;
00876     
00878     prototypeDataType DataTypePrototype_;
00879 
00881     prototypeMatrix4x4 matrix4x4Prototype_;
00882 
00883 
00884   private slots:
00885     void slotScriptInfo( QString _pluginName , QString _functionName  );
00886 
00887     void slotExecuteScript( QString _script );
00888 
00889     void slotGetScriptingEngine( QScriptEngine*& _engine  );
00890 
00891     void slotGetAllAvailableFunctions( QStringList& _functions  );
00892 
00894     void slotSetSlotDescription(QString     _slotName,   QString _slotDescription,
00895                                 QStringList _parameters, QStringList _descriptions);
00897     void slotGetDescription(QString _function, QString& _fnDescription,
00898                                 QStringList& _parameters, QStringList& _descriptions );
00899 
00900   private:
00901 
00902     QList< SlotInfo > coreSlots_;
00903 
00904     void setDescriptions();
00905 
00908   //===========================================================================
00911   //===========================================================================
00912   private slots:
00913     void slotPluginExists( QString _pluginName , bool& _exists );
00914 
00915 
00916     void slotFunctionExists( QString _pluginName , QString _functionName , bool& _exists  );
00917 
00924     void slotCall( QString _pluginName , QString _functionName , bool& _success  );
00925 
00931     void slotCall( QString _expression , bool& _success  );
00932 
00943     void slotGetValue(QString _expression, QVariant& _result );
00944 
00947   //===========================================================================
00950   //===========================================================================
00951 
00952   private slots:
00953 
00955     void checkScenegraphDirty();
00956 
00957   private:
00958 
00960     QTimer *scenegraphCheckTimer_;
00961 
00963     QTime *redrawTime_;
00964 
00968   //===========================================================================
00971   //===========================================================================
00972   
00973   private:
00974     
00975     QList< JobInfo* >  currentJobs;
00976     
00977     ProcessManagerWidget* processManager_;
00978     
00980     bool getJob(QString _jobId, int& _index);
00981     
00982   private slots:
00983 
00985     void slotStartJob( QString _jobId, QString _description , int _min , int _max,bool _blocking );
00986     
00988     void slotSetJobState(QString _jobId, int _value );
00989     
00991     void slotSetJobName(QString _jobId, QString _name );
00992     
00994     void slotSetJobDescription(QString _jobId, QString _text );
00995     
00997     void slotCancelJob(QString _jobId );
00998     
01000     void slotFinishJob(QString _jobId );
01001     
01003     void slotJobCancelRequested(QString _jobId);
01004     
01005   signals:
01006     
01007     void jobCanceled( QString _jobId );
01008     
01011   //===========================================================================
01014   //===========================================================================
01015 
01016   private slots:
01017     
01019     void newObject(int _objectId);
01020     
01022     void deletedObject(int _objectId);    
01023     
01026   private :
01027 
01029   int nextBackupId_;
01030 
01032   std::vector<PluginLogger*> loggers_;
01033 
01035   std::vector<fileTypes> supportedTypes_;
01036   
01038   std::vector<dataTypes> supportedDataTypes_;
01039 
01040   private :
01042     BaseObject* objectRoot_;
01043 
01045     CoreWidget* coreWidget_;
01046 
01048     QSplashScreen* splash_;
01049 
01051     QString splashMessage_;
01052 
01054     QVector<ViewMode*> viewModes_;
01055 
01057     QTimer* redrawTimer_;
01058 
01059 
01060 };
01061 
01063 QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine);
01064 
01065 //=============================================================================
01066 #endif // MVIEWWIDGET_HH defined
01067 //=============================================================================
01068 

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .