00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00057 #ifndef MVIEWWIDGET_HH
00058 #define MVIEWWIDGET_HH
00059
00060
00061
00062
00063
00064 #include "OpenFlipper/common/Types.hh"
00065
00066 #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
00067
00068
00069 #include <qvariant.h>
00070 #include <qmainwindow.h>
00071 #include <QToolBox>
00072 #include <QStackedWidget>
00073 #include <QSplashScreen>
00074
00075 #include <QDockWidget>
00076 #include <QVector>
00077 #include <QProgressDialog>
00078
00079 #include <QtScript/QScriptEngine>
00080 #include <QtScript/QtScript>
00081
00082 #include "OpenFlipper/INIFile/INIFile.hh"
00083
00084 #include "OpenFlipper/Logging/Logging.hh"
00085 #include "OpenFlipper/Scripting/Scripting.hh"
00086
00087
00088 #include "OpenFlipper/Scripting/scriptPrototypes/prototypeVec3d.hh"
00089 #include "OpenFlipper/Scripting/scriptPrototypes/prototypeMatrix4x4.hh"
00090 #include <OpenFlipper/Scripting/scriptWrappers/vec3dWrapper.hh>
00091 #include <OpenFlipper/Scripting/scriptWrappers/matrix4x4Wrapper.hh>
00092
00093
00094
00095 #include "OpenFlipper/BasePlugin/BaseInterface.hh"
00096 #include "OpenFlipper/BasePlugin/FileInterface.hh"
00097 #include "OpenFlipper/BasePlugin/MenuInterface.hh"
00098 #include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"
00099
00100 #include <OpenFlipper/widgets/coreWidget/CoreWidget.hh>
00101
00102 #include <OpenFlipper/common/GlobalOptions.hh>
00103
00104 #include <OpenFlipper/Core/PluginInfo.hh>
00105
00106 #include <ACG/Scenegraph/CoordsysNode.hh>
00107 #include <ACG/Scenegraph/GridNode.hh>
00108
00109 #include <OpenFlipper/threads/JobInfo.hh>
00110
00111
00112
00113 struct fileTypes {
00114 DataType type;
00115 QString loadFilters;
00116 QString saveFilters;
00117 FileInterface* plugin;
00118 };
00119
00122 class Core : public QObject
00123 {
00124 Q_OBJECT
00125
00126 public:
00127
00129 Core();
00130
00131 void init();
00132
00134 ~Core();
00135
00137 bool add_sync_host(const QString& _name);
00138
00139
00140 private slots:
00141
00143 void slotMouseEventIdentify( QMouseEvent* _event );
00144
00145 protected:
00146
00147
00150
00151 signals:
00153 void allCleared();
00154
00156 void signalObjectUpdated(int);
00157
00159 void PluginWheelEvent(QWheelEvent * , const std::string & );
00160
00162 void PluginMouseEvent(QMouseEvent* );
00163
00165 void PluginMouseEventIdentify( QMouseEvent* );
00166
00168 void objectSelectionChanged( int );
00169
00171 void pluginViewChanged();
00172
00174 void addTexture( QString, QString , uint, int );
00175
00177 void addTexture( QString, QString , uint );
00178
00180 void addMultiTexture( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );
00181
00183 void updateTexture( QString , int );
00184
00186 void updateAllTextures( );
00187
00189 void updatedTextures( QString , int );
00190
00192 void setTextureMode(QString _textureName ,QString _mode, int _id);
00193
00195 void setTextureMode(QString _textureName ,QString _mode);
00196
00198 void switchTexture( QString, int );
00199
00201 void switchTexture( QString );
00202
00204 void textureChangeImage( QString _textureName , QImage& _image );
00205
00207 void textureChangeImage( QString _textureName , QImage& _image , int _id );
00208
00210 void iniLoad( INIFile&, int );
00211
00213 void iniSave( INIFile& _ini ,int _id );
00214
00216 void iniSaveOptions( INIFile& _ini );
00217
00219 void iniLoadOptions( INIFile& _ini );
00220
00222 void iniLoadOptionsLast( INIFile& _ini );
00223
00225 void saveOnExit( INIFile& _ini );
00226
00228 void createBackup( int _id , QString _name , int nextBackupId_);
00229
00231 void openedFile( int _id );
00232
00234 void emptyObjectAdded( int _id);
00235
00237 void pluginsInitialized();
00238
00240 void visibilityChanged(int _id);
00241
00243 void objectPropertiesChanged( int _id );
00244
00246 void objectDeleted( int );
00247
00250
00253
00254 private slots :
00255
00259 void slotObjectUpdated(int _identifier);
00260
00262 void slotVisibilityChanged(int _id);
00263
00265 void slotObjectPropertiesChanged( int _id );
00266
00268 void slotObjectSelectionChanged( int _id);
00269
00271 void slotAddPickMode( const std::string _mode );
00272
00274 void slotAddHiddenPickMode( const std::string _mode );
00275
00277 void slotAddTexture( QString _textureName , QString _filename , uint _dimension , int _id );
00278
00280 void slotAddTexture( QString _textureName , QString _filename , uint _dimension );
00281
00283 void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );
00284
00286 void slotUpdateTexture( QString _name , int _identifier);
00287
00289 void slotUpdateAllTextures( );
00290
00292 void slotTextureUpdated( QString _textureName , int _identifier );
00293
00295 void slotSetTextureMode(QString _textureName ,QString _mode, int _id);
00296
00298 void slotSetTextureMode(QString _textureName ,QString _mode);
00299
00301 void slotSwitchTexture( QString _textureName, int _id );
00302
00304 void slotSwitchTexture( QString _textureName );
00305
00307 void slotTextureChangeImage( QString _textureName , QImage& _image );
00308
00310 void slotTextureChangeImage( QString _textureName , QImage& _image , int _id );
00311
00313 void backupRequest( int _id , QString _name );
00314
00316 void slotLoad(QString _filename, DataType _type, int& _id);
00317
00319 void slotObjectOpened ( int _id );
00320
00322 void slotEmptyObjectAdded ( int _id );
00323
00325 void slotGetAllFilters ( QStringList& _list);
00326
00328 void slotDeleteObject( int _id );
00329
00331 void slotDeleteAllObjects( );
00332
00334
00335
00338
00341
00342 public slots:
00343
00345 void updateView();
00346
00348 void clearAll();
00349
00351 void exitApplication();
00352
00354 void fullscreen( bool _state );
00355
00357 void loggerState(int _state);
00358
00360 void showToolbox( bool _state );
00361
00363 void multiViewMode( int _mode );
00364
00366 void restrictFrameRate( bool _enable );
00367
00369 void setMaxFrameRate( int _rate );
00370
00373 void snapshotBaseFileName(const QString& _fname, unsigned int _viewerId = 0);
00374
00379 void snapshot(unsigned int _viewerId = 0);
00380
00382 void applicationSnapshot();
00383
00385 void applicationSnapshotName(QString _name);
00386
00388 void viewerSnapshot();
00389
00391 void resizeViewers(int _width, int _height );
00392
00394 void resizeApplication(int _width, int _height );
00395
00397 void writeVersionNumbers(QString _filename);
00398
00400 QList<int> objectList (QString _selection, QStringList _types);
00401
00402
00405
00406
00407 public slots:
00413 void addViewModeToolboxes(QString _modeName, QString _toolboxList);
00414
00420 void addViewModeToolbars(QString _modeName, QString _toolbarList);
00421
00424
00427
00428 private:
00433 int loadObject ( QString _filename );
00434
00439 void resetScenegraph( bool _resetTrackBall );
00440
00441 public :
00442
00444 void commandLineOpen(const char* _filename, bool asPolyMesh );
00445
00447 void commandLineScript(const char* _filename );
00448
00449 private slots:
00450
00452 void slotExecuteAfterStartup();
00453
00454 private:
00455 std::vector< std::pair < std::string , bool > > commandLineFileNames_;
00456 std::vector< std::string > commandLineScriptNames_;
00457
00458 public:
00459
00463 int addEmptyObject( DataType _type );
00464
00468 int loadObject( DataType _type, QString _filename);
00469
00472
00475
00476 private slots:
00478 void viewUpdated();
00479
00481 void captureVideo();
00482
00483 public slots:
00484
00486 void startVideoCapture(QString _baseName, int _fps, bool _captureViewers);
00487
00489 void stopVideoCapture();
00490
00491 private:
00492 QTimer videoTimer_;
00493 QTime lastVideoTime_;
00494
00495 int captureType_;
00496
00497 bool capture_;
00498
00499 int lastWidth_;
00500 int lastHeight_;
00501
00503
00506
00507
00508 public slots:
00509
00513 bool saveObject( int _id, QString _filename );
00514
00519 bool saveObjectTo( int _id, QString _filename );
00520
00522 void saveAllObjects();
00523
00525 void saveAllObjectsTo();
00526
00528 void saveSettings();
00529
00531 void loadObject();
00532
00534 void loadSettings();
00535
00537 void loadSettings(QString _filename);
00538
00540 int getObjectId(QString _filename);
00541
00544
00547
00548 private slots :
00549
00551 void slotMouseEvent( QMouseEvent* _event );
00552
00554 void slotWheelEvent( QWheelEvent * _event, const std::string & _mode);
00555
00557 void slotAddEmptyObjectMenu();
00558
00560 void slotAddEmptyObject( DataType _type , int& _id );
00561
00563 void slotCopyObject( int _oldId , int& _newId );
00564
00566 void slotExit();
00567
00569 void slotRecentOpen(QAction* _action);
00570
00571 public slots:
00572
00574 void addToolbox(QString _name ,QWidget* _widget);
00575
00576 private :
00577
00578
00581
00582
00583 private:
00585 SeparatorNode* root_node_scenegraph_;
00586
00588 SeparatorNode* core_nodes_;
00589
00590
00592 SeparatorNode* dataSeparatorNode_;
00593
00595 SeparatorNode* dataRootNode_;
00596
00598 ACG::SceneGraph::MaterialNode* coordsysMaterialNode_;
00599
00601 ACG::SceneGraph::CoordsysNode* coordsysNode_;
00602
00604
00605
00608
00611
00612
00614 void setupOptions();
00615
00617 void readGUIOptions(INIFile& _ini);
00618
00620 void readRecentFiles(QString _filename);
00621
00623 void readApplicationOptions(INIFile& _ini);
00624
00626 void writeApplicationOptions(INIFile& _ini);
00627
00629 void restoreKeyBindings();
00630
00631 public slots:
00632
00634 void saveOptions();
00635
00637 void applyOptions();
00638
00649 void openIniFile( QString _filename,
00650 bool _coreSettings ,
00651 bool _perPluginSettings,
00652 bool _loadObjects );
00653
00655 void openObjFile(QString _filename);
00656
00658 void preprocessObjFile(QString _filename);
00659
00660 private:
00661
00673 void writeIniFile( QString _filename,
00674 bool _relativePaths,
00675 bool _targetOnly,
00676 bool _saveSystemSettings,
00677 bool _savePluginSettings ,
00678 bool _saveObjectInfo );
00679
00684 void writeObjFile(QString _filename, bool _relativePaths, bool _targetOnly);
00685
00687 void writeOnExit();
00688
00691
00694
00695
00696 signals:
00698 void log(Logtype _type , QString _message );
00699
00701 void log(QString _message );
00702
00704 void scriptLog(QString _message);
00705
00707 void externalLog(Logtype _type , QString _message);
00708
00709 private slots:
00710
00712 void slotLog(Logtype _type, QString _message);
00713
00715 void slotLogToFile(Logtype _type, QString _message);
00716
00717 private:
00719 QTextStream* logStream_;
00720
00722 QFile* logFile_;
00723
00724 public :
00725 void scriptLogFunction( QString _output);
00726
00730
00733
00734
00735 private :
00737 bool checkSlot(QObject* _plugin , const char* _slotSignature);
00738
00740 bool checkSignal(QObject* _plugin , const char* _signalSignature);
00741
00744
00747
00748
00749 private:
00751 std::vector<PluginInfo> plugins;
00752
00754 QStringList dontLoadPlugins_;
00755
00757 int toolboxindex_;
00758
00760 void loadPlugin(QString filename, bool silent);
00761
00763 void loadPlugins();
00764 private slots:
00766 void slotShowPlugins();
00767
00769 void unloadPlugin(QString name);
00770
00772 void dontLoadPlugins(QStringList _plugins);
00773
00775 void slotLoadPlugin();
00776
00780
00783
00784
00785 signals:
00786
00787 void scriptInfo( QString _pluginName , QString _functionName );
00788
00789 void executeScript( QString _script );
00790
00791 void executeFileScript( QString _filename );
00792
00793 void setSlotDescription(QString _slotName, QString _slotDescription,
00794 QStringList _parameters, QStringList _descriptions);
00795
00796 public slots:
00804 void createWidget(QString _objectName, QString _uiFilename);
00805
00807 void setViewMode(QString _viewMode);
00808
00809 private :
00811 QScriptEngine scriptEngine_;
00812
00814 std::vector<ScriptingWrapper*> scriptingWrappers_;
00815
00817 QStringList scriptingFunctions_;
00818
00820 prototypeVec3d vec3dPrototype_;
00821
00823 prototypeMatrix4x4 matrix4x4Prototype_;
00824
00825
00826 private slots:
00827 void slotScriptInfo( QString _pluginName , QString _functionName );
00828
00829 void slotExecuteScript( QString _script );
00830
00831 void slotGetScriptingEngine( QScriptEngine*& _engine );
00832
00833 void slotGetAllAvailableFunctions( QStringList& _functions );
00834
00836 void slotSetSlotDescription(QString _slotName, QString _slotDescription,
00837 QStringList _parameters, QStringList _descriptions);
00839 void slotGetDescription(QString _function, QString& _fnDescription,
00840 QStringList& _parameters, QStringList& _descriptions );
00841
00842 private:
00843
00844 QList< SlotInfo > coreSlots_;
00845
00846 void setDescriptions();
00847
00850
00853
00854 private slots:
00855 void slotPluginExists( QString _pluginName , bool& _exists );
00856
00857
00858 void slotFunctionExists( QString _pluginName , QString _functionName , bool& _exists );
00859
00866 void slotCall( QString _pluginName , QString _functionName , bool& _success );
00867
00873 void slotCall( QString _expression , bool& _success );
00874
00885 void slotGetValue(QString _expression, QVariant& _result );
00886
00889
00892
00893
00894 private slots:
00895
00897 void checkScenegraphDirty();
00898
00899 private:
00900
00902 QTimer *scenegraphCheckTimer_;
00903
00905 QTime *redrawTime_;
00906
00910
00913
00914
00915 private:
00916
00917 QList< JobInfo* > currentJobs;
00918
00920 bool getJob(QString _jobId, int& _index);
00921
00922 private slots:
00923
00925 void slotStartJob( QString _jobId, QString _description , int _min , int _max,bool _blocking );
00926
00928 void slotSetJobState(QString _jobId, int _value );
00929
00931 void slotCancelJob(QString _jobId );
00932
00934 void slotFinishJob(QString _jobId );
00935
00937 void slotJobCancelButtons();
00938
00939 signals:
00940
00941 void jobCanceled( QString _jobId );
00942
00945 private :
00946
00948 int nextBackupId_;
00949
00951 std::vector<PluginLogger*> loggers_;
00952
00954 std::vector<fileTypes> supportedTypes_;
00955
00957
00958
00959 private :
00961 BaseObject* objectRoot_;
00962
00964 CoreWidget* coreWidget_;
00965
00967 QSplashScreen* splash_;
00968
00970 QString splashMessage_;
00971
00973 QVector<ViewMode*> viewModes_;
00974
00976 QTimer* redrawTimer_;
00977
00978
00979 };
00980
00982 QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine);
00983
00984
00985 #endif // MVIEWWIDGET_HH defined
00986
00987