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
00055 #ifndef COREWIDGET_HH
00056 #define COREWIDGET_HH
00057
00058
00059
00060
00061 #include "OpenFlipper/common/Types.hh"
00062 #include <OpenFlipper/common/GlobalOptions.hh>
00063 #include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
00064 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
00065 #include <OpenFlipper/BasePlugin/MenuInterface.hh>
00066 #include <OpenFlipper/BasePlugin/ViewInterface.hh>
00067 #include <OpenFlipper/BasePlugin/StatusbarInterface.hh>
00068
00069 #include <OpenFlipper/widgets/coreWidget/SideArea.hh>
00070 #include <OpenFlipper/widgets/coreWidget/ColorStatusBar.hh>
00071
00072 #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
00073 #include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh>
00074 #include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh>
00075 #include <OpenFlipper/widgets/glWidget/QtMultiViewLayout.hh>
00076 #include <OpenFlipper/widgets/glWidget/QtSlideWindow.hh>
00077 #include <OpenFlipper/widgets/glWidget/QtPickToolbar.hh>
00078
00079
00080 #include <QMainWindow>
00081 #include <QStackedWidget>
00082 #include <QTextEdit>
00083 #include <QToolBar>
00084 #include <QStatusBar>
00085
00086 #include <QDockWidget>
00087
00088 #include <OpenFlipper/widgets/aboutWidget/aboutWidget.hh>
00089 #include <OpenFlipper/widgets/loggerWidget/loggerWidget.hh>
00090 #include <OpenFlipper/widgets/optionsWidget/optionsWidget.hh>
00091 #include <OpenFlipper/widgets/helpWidget/helpWidget.hh>
00092 #include <OpenFlipper/widgets/stereoSettingsWidget/stereoSettingsWidget.hh>
00093
00094 #include <OpenFlipper/Core/PluginInfo.hh>
00095
00096 #include <ACG/QtWidgets/QtSceneGraphWidget.hh>
00097
00098 #include <ACG/Scenegraph/DrawModes.hh>
00099
00100 #include <OpenFlipper/INIFile/INIFile.hh>
00101 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
00102
00107 struct ViewMode{
00108
00110 QString name;
00111
00114 QString icon;
00115
00117 bool custom;
00118
00120 QStringList visibleToolboxes;
00121
00123 QStringList visibleToolbars;
00124
00126 QStringList visibleContextMenus;
00127 };
00128
00129 class StackWidgetInfo {
00130 public:
00131 StackWidgetInfo(bool _editable,QString _name,QWidget* _widget);
00132
00133 bool editable;
00134 QString name;
00135 QWidget* widget;
00136 };
00137
00140 struct MenuInfo {
00142 QAction* action;
00143
00145 DataType contextType;
00146
00148 ContextMenuType type;
00149 };
00150
00153 class CoreWidget : public QMainWindow
00154 {
00155 Q_OBJECT
00156
00157 public:
00158
00160 CoreWidget( QVector<ViewMode*>& _viewModes, std::vector<PluginInfo>& _plugins, QList< SlotInfo >& _coreSlots );
00161
00163 ~CoreWidget();
00164
00165 signals:
00166 void clearAll();
00167 void loadMenu();
00168 void addEmptyObjectMenu();
00169 void saveMenu();
00170 void saveToMenu();
00171 void loadIniMenu();
00172 void saveIniMenu();
00173 void recentOpen(QAction*);
00174 void exit();
00175
00176 void loadPlugin();
00177 void showPlugins();
00178
00179 private slots:
00180
00182 void closeEvent ( QCloseEvent * event );
00183
00184
00187
00188
00189 signals :
00190 void log(Logtype _type, QString _message);
00191 void log(QString _message);
00192
00195
00198
00199
00200 protected :
00201
00203 virtual void keyPressEvent (QKeyEvent* _e);
00204 virtual void keyReleaseEvent(QKeyEvent* _e);
00205
00206
00207
00208
00209 signals :
00210
00214 void PluginKeyEvent(QKeyEvent* );
00215
00219 void PluginKeyReleaseEvent(QKeyEvent* );
00220
00222 void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description,
00223 bool _multiUse = false);
00224
00226 void call( QString _expression , bool& _success );
00227
00228 private:
00230 typedef std::multimap< std::pair< int, Qt::KeyboardModifiers > , std::pair< QObject*, int > > KeyMap;
00231
00232 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
00233
00234 typedef std::pair< KeyMap::iterator, KeyMap::iterator > KeyRange;
00235
00238 void registerCoreKeys();
00239
00244 void coreKeyPressEvent();
00245
00247 void coreKeyPressEvent (QKeyEvent* _e);
00248 void coreKeyReleaseEvent(QKeyEvent* _e);
00249
00250 KeyBinding getKeyBinding(QObject* _plugin, int _keyIndex );
00251 QString getRPCName(QObject* _plugin );
00252
00254 std::vector<KeyBinding> coreKeys_;
00255
00257 KeyMap keys_;
00258
00260 InverseKeyMap invKeys_;
00261
00263 QList< SlotInfo >& coreSlots_;
00264
00265 private slots:
00271 void slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description,
00272 bool _multiUse = false);
00273
00274 public slots:
00279 void slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
00280
00286 void slotRegisterSlotKeyBindings();
00287
00288 public:
00290 void loadKeyBindings(INIFile& _ini);
00291
00293 void saveKeyBindings(INIFile& _ini);
00294
00295 private:
00297 bool shiftPressed_;
00298
00301
00304
00305
00306 public:
00307
00309 void setupMenuBar();
00310
00313
00316
00317
00318 signals:
00319 void startVideoCapture(QString _baseName, int _fps, bool _captureViewers);
00320 void stopVideoCapture();
00321
00322 void resizeViewers(int _width, int _height);
00323 void resizeApplication(int _width, int _height);
00324
00325 private slots:
00326 void startVideoCaptureDialog();
00327
00330
00333
00334
00335 public:
00336
00338 void addRecent(QString _filename, DataType _type);
00339
00341 void updateRecent();
00342
00345
00348
00349
00350 public :
00352 void toggleFullscreen();
00353
00355 void setFullscreen(bool _state );
00356
00358 void toggleLogger();
00359
00361 void showLogger(OpenFlipper::Options::LoggerState _state);
00362
00364 void toggleToolbox();
00365
00367 void showToolbox( bool _state );
00368
00370 void setForceNativeCursor ( bool _state );
00371
00372 QSize defaultIconSize();
00373
00374 private:
00375 OpenFlipper::Options::LoggerState loggerState_;
00376
00377 uint fullscreenState_;
00378
00379 QSize defaultIconSize_;
00380
00383
00386
00387
00388 private:
00390 QVector<QWidget*> toolWidgets_;
00391
00392 public:
00394 QVector<ViewMode*>& viewModes_;
00395
00396 private:
00397
00398 QPushButton* viewModeButton_;
00399
00401 QMenu* viewModeMenu_;
00402
00403 public slots:
00404
00406 void initViewModes( );
00407
00409 void slotAddViewModeToolboxes(QString _mode, QStringList _usedWidgets);
00410
00412 void slotAddViewModeToolboxes(QString _mode, bool _custom, QStringList _usedWidgets);
00413
00415 void slotAddViewModeToolbars(QString _mode, QStringList _usedToolbars);
00416
00418 void slotAddViewModeToolbars(QString _mode, bool _custom, QStringList _usedToolbars);
00419
00421 void slotAddViewModeComplete(QString _mode , bool _custom, QStringList _toolboxes, QStringList _toolbars);
00422
00424 void slotSetViewModeIcon(QString _mode, QString _iconName);
00425
00427 void slotSetViewModeIcon(QString _mode, bool _custom, QString _iconName);
00428
00430 void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
00431
00432 private slots:
00434 void slotRemoveViewMode(QString _name);
00435
00437 void slotSetViewMode( QAction* action);
00438
00439
00441 void slotViewModeDialog();
00442
00444 void slotViewChangeDialog();
00445
00447 public slots :
00448 void setViewMode( QString _mode );
00449
00454
00457
00458
00459 public :
00460
00462 std::vector< glViewer* > examiner_widgets_;
00463
00465 QSplitter* splitter_;
00466
00468 LoggerWidget* logWidget_;
00469
00471 int originalLoggerSize_;
00472
00474 QMenu* recentFilesMenu_;
00475
00477 QMenu* helpMenu_;
00478
00480 QGLWidget* glWidget_;
00481
00483 QtGLGraphicsScene* glScene_;
00484
00486 QtGLGraphicsView* glView_;
00487
00489 QGraphicsWidget* centerWidget_;
00490
00492 QtMultiViewLayout* baseLayout_;
00493
00495 QtSlideWindow* slidingLogger_;
00496
00498 QWidget* tempLogWidget;
00499
00501 QWidget* toolBoxArea_;
00502
00504 QPushButton* vmChangeButton_;
00505
00507 QSplitter* toolSplitter_;
00508
00510 SideArea* toolBox_;
00511
00513 QScrollArea* toolBoxScroll_;
00514
00516 QtPickToolbar* pickToolbar_;
00517
00519 CursorPainter* cursorPainter_;
00520
00521
00522
00523 ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_;
00524
00527 private slots:
00528
00531 void slotShowSceneGraphDialog();
00532
00533
00536 void slotActivateExaminer ();
00537
00538
00543 void slotLog(Logtype _type, QString _message);
00544
00547 void sceneRectChanged(const QRectF &rect);
00548
00549
00552
00553 private slots :
00554
00555 void slotAddMenubarAction( QAction* _action , QString _name );
00556 void slotGetMenubarMenu (QString _name, QMenu *& _menu, bool _create);
00557
00558 private:
00559
00561 QMenu *fileMenu_;
00562
00564 QMenu *viewMenu_;
00565
00567 QMenu *toolsMenu_;
00568
00570 QAction* fileMenuEnd_;
00571
00573 QMap<QString, QMenu *> menus_;
00574
00577
00580
00581 private:
00582 QToolBar* viewerToolbar_;
00583
00584 int toolbarCount_;
00585
00586 QToolButton* stereoButton_;
00587 QToolButton* moveButton_;
00588 QToolButton* lightButton_;
00589 QToolButton* pickButton_;
00590 QToolButton* questionButton_;
00591
00592 QComboBox* viewerLayoutBox_;
00593
00596
00599
00600
00601 public slots:
00603 void slotUpdateGlobalDrawMenu();
00604
00605
00607 void setViewerLayout(int _idx);
00608
00609 private slots:
00611 void nextViewerLayout();
00612
00614 void slotGlobalDrawMenu(QAction * _action);
00615
00617 void slotViewMenuAboutToShow();
00618
00619 private:
00621 QMenu* globalDrawMenu_;
00622
00623 QActionGroup * drawGroup_;
00624
00626 QActionGroup* viewGroup_;
00627
00628 QAction* perspectiveProjectionAction_;
00629 QAction* orthogonalProjectionAction_;
00630
00632 QAction* globalAnimationAction_;
00633
00635 QAction* globalBackfaceCullingAction_;
00636
00638 QAction* globalTwosidedLightingAction_;
00639
00641 QAction* globalMultisamplingAction_;
00642
00643 ACG::SceneGraph::DrawModes::DrawMode activeDrawModes_;
00644
00645 ACG::SceneGraph::DrawModes::DrawMode availableGlobalDrawModes_;
00646
00649
00652
00653
00654 signals :
00656 void updateContextMenu(int);
00657
00659 void updateContextMenuNode(int);
00660
00662 void updateContextMenuBackground();
00663
00664
00665 private slots:
00667 void slotCustomContextMenu( const QPoint& _point );
00668
00670 void slotAddContextItem(QAction* _entry, ContextMenuType _type);
00671
00673 void slotAddContextItem( QAction* _entry , DataType _dataType ,ContextMenuType type_);
00674
00676 void slotPasteView( );
00677
00679 void slotCopyView( );
00680
00682 void slotViewerDrawMenu( QAction * _action );
00683
00685 void slotUpdateViewerDrawMenu();
00686
00688 void slotSnapshot();
00689
00691 void slotSwitchWheels(bool _state);
00692
00694 void slotSwitchNavigation(bool _egomode);
00695
00697 void slotSnapshotName();
00698
00700 void slotCoordSysVisibility(bool _visible);
00701
00702 private :
00707 void updatePopupMenu(const QPoint& _point);
00708
00709 void updatePopupMenuCoordsysNode(QMenu* _menu , const int _part);
00710 void updatePopupMenuObject(QMenu* _menu , BaseObjectData* _object );
00711 void updatePopupMenuBackground(QMenu* _menu , const QPoint& _point);
00712 void updatePopupMenuNode(QMenu* _menu , ACG::SceneGraph::BaseNode* _node);
00713
00714 bool addContextMenus( QMenu* _menu , ContextMenuType _type, int _id = -1);
00715
00716 private :
00718 QMenu* contextMenu_;
00719
00721 QMenu* contextSelectionMenu_;
00722
00724 std::vector< MenuInfo > contextMenus_;
00725
00727 QActionGroup* drawGroupViewer_;
00728
00730 QMenu* viewerDrawMenu_;
00731
00734 QMenu* coordSysMenu_;
00735
00738
00741
00742
00743 private:
00744
00745 QString snapshotName_;
00746 int snapshotCounter_;
00747
00748 public slots:
00749
00751 void viewerSnapshotDialog();
00752
00754 void viewerSnapshot();
00755
00757 void applicationSnapshotDialog();
00758
00760 void applicationSnapshot();
00761
00763 void applicationSnapshotName(QString _name);
00764
00765
00768
00771
00772
00773 private slots:
00774 void slotGetStackWidget( QString _name, QWidget*& _widget );
00775 void slotAddStackWidget( QString _name, QWidget* _widget );
00776 void slotUpdateStackWidget( QString _name, QWidget* _widget );
00777
00778 void slotViewMenuAction( QAction * _action);
00779
00780 void slotUpdateStackMenu();
00781
00782
00783 private :
00785 QMenu* stackMenu_;
00786
00787 std::vector< StackWidgetInfo > stackWidgetList_;
00788
00789 public :
00791 QStackedWidget* stackedWidget_;
00792
00795
00798
00799
00800 public slots:
00802 void showHelpBrowser();
00803
00804 private:
00806 HelpWidget* helpWidget_;
00807
00810
00813
00814
00815 public slots:
00817 void stereoButtonContextMenu(const QPoint& _pos);
00818
00822 void slotApplyStereoSettings(int _tmpParam = 0);
00823
00824
00825 private:
00827 StereoSettingsWidget* stereoSettingsWidget_;
00828
00831
00834
00835
00836 public slots:
00838 void showAboutWidget();
00839
00840 private:
00842 AboutWidget* aboutWidget_;
00843
00846
00849
00850
00851 public slots:
00853 void showOptionsWidget();
00854
00855 signals:
00856 void applyOptions();
00857 void saveOptions();
00858
00859 private:
00860
00862 OptionsWidget* optionsWidget_;
00863
00866
00869
00870 private slots:
00872 void slotAddToolbar(QToolBar* _toolbar);
00873
00875 void slotRemoveToolbar(QToolBar* _toolbar);
00876
00878 void getToolBar( QString _name, QToolBar*& _toolbar);
00879
00880 private :
00881 QToolBar* mainToolbar_;
00882
00883 std::vector< QToolBar* > toolbars_;
00884
00887
00890
00891 public slots:
00892 void statusMessage(QString _message, int _timeout = 0);
00893
00894 void clearStatusMessage();
00895
00896 void setStatus( ApplicationStatus::applicationStatus _status);
00897
00898 void addWidgetToStatusbar(QWidget* _widget);
00899
00900 private:
00901 void setupStatusBar();
00902
00903 private :
00904 ColorStatusBar* statusBar_;
00905
00906 QLabel* statusIcon_;
00907
00910
00913
00914
00915 signals:
00916 void dragOpenFile(QString _filename);
00917
00918 private slots:
00919 void startDrag( QMouseEvent* _event );
00920
00921 void dragEnterEvent(QDragEnterEvent* _event);
00922
00923 void dropEvent( QDropEvent* _event );
00924
00927 private :
00928
00929 std::vector<PluginInfo>& plugins_;
00930
00931
00932
00935
00936
00937 private slots:
00938
00940 void slotToggleStereoMode();
00941
00943 void slotSetGlobalBackgroundColor();
00944
00946 void slotSetContextBackgroundColor();
00947
00948
00949
00951 void slotContextHomeView();
00952
00954 void slotGlobalHomeView();
00955
00956
00957
00959 void slotContextSetHomeView();
00960
00962 void slotGlobalSetHomeView();
00963
00964
00965
00967 void slotContextViewAll();
00968
00970 void slotGlobalViewAll();
00971
00972
00974 void slotContextSwitchProjection();
00975
00977 void slotGlobalPerspectiveProjection();
00978
00980 void slotGlobalOrthographicProjection();
00981
00982
00984 void slotSetViewingDirection(QAction* _action);
00985
00986
00988 void slotGlobalChangeAnimation(bool _animation);
00989
00991 void slotLocalChangeAnimation(bool _animation);
00992
00993
00994
00996 void slotGlobalChangeBackFaceCulling(bool _backFaceCulling);
00997
00999 void slotLocalChangeBackFaceCulling(bool _backFaceCulling);
01000
01001
01002
01004 void slotGlobalChangeTwoSidedLighting(bool _lighting);
01005
01007 void slotLocalChangeTwoSidedLighting(bool _lighting);
01008
01009
01010
01012 void slotGlobalChangeMultisampling(bool _lighting);
01013
01015 void slotLocalChangeMultisampling(bool _lighting);
01016
01018 void moveBack();
01019
01021 void moveForward();
01022
01024 void strafeLeft();
01025
01027 void strafeRight();
01028
01029 private :
01030 bool stereoActive_;
01031
01034
01037
01038
01039 public slots:
01040
01041 bool examineMode() { return(actionMode_ == Viewer::ExamineMode ); };
01042 bool pickingMode() { return(actionMode_ == Viewer::PickingMode ); };
01043 bool lightMode() { return(actionMode_ == Viewer::LightMode ); };
01044 bool questionMode(){ return(actionMode_ == Viewer::QuestionMode ); };
01045
01049 void setExamineMode() { setActionMode(Viewer::ExamineMode ); };
01050 void setPickingMode() { setActionMode(Viewer::PickingMode ); };
01051 void setLightMode() { setActionMode(Viewer::LightMode ); };
01052 void setQuestionMode(){ setActionMode(Viewer::QuestionMode ); };
01053
01054 void setActionMode(const Viewer::ActionMode _am);
01055 void getActionMode(Viewer::ActionMode& _am);
01056
01057 public:
01058 Viewer::ActionMode actionMode() { return actionMode_; };
01059 Viewer::ActionMode lastActionMode() { return lastActionMode_; };
01060
01061 private :
01062 Viewer::ActionMode actionMode_, lastActionMode_;
01063
01066
01069
01070
01071 public:
01072
01079 void addPickMode(const std::string& _name,
01080 bool _mouse_tracking = false,
01081 int _pos = -1,
01082 bool _visible = true,
01083 QCursor _cursor = Qt::ArrowCursor );
01084
01087 void clearPickModes();
01088
01091 const std::string& pickMode() const;
01092
01096 void pickMode( int _id );
01097
01098 public slots:
01099
01103 void setPickMode(const std::string _name);
01104
01105
01106 void getPickMode(std::string& _name);
01107
01108 public slots:
01109
01115 void setPickModeCursor(const std::string& _name, QCursor _cursor);
01116
01122 void setPickModeMouseTracking(const std::string& _name, bool _mouseTracking);
01123
01131 void setPickModeToolbar( const std::string _mode , QToolBar * _toolbar );
01132
01139 void removePickModeToolbar( const std::string _mode );
01140
01141 void actionPickMenu( QAction * _action );
01142
01143 signals:
01146 void signalPickModeChanged(const std::string&);
01147
01148 private:
01149
01150 QMenu* pickMenu_;
01151
01154 struct PickMode
01155 {
01157 PickMode(const std::string& _n, bool _t, bool _v, QCursor _c, QToolBar *_tb = NULL) :
01158 name(_n), tracking(_t), visible(_v), cursor(_c), toolbar(_tb) {}
01159
01161 std::string name;
01162
01165 bool tracking;
01166
01169 bool visible;
01170
01173 QCursor cursor;
01174
01177 QToolBar * toolbar;
01178 };
01179
01182 std::vector<PickMode> pick_modes_;
01183
01186 std::string pick_mode_name_;
01187
01190 int pick_mode_idx_;
01191
01192
01194 void updatePickMenu();
01195
01196 private slots:
01197
01198 void hidePopupMenus();
01201 };
01202
01203
01204
01205 #endif // COREWIDGET_HH defined
01206
01207