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
00093 #include <OpenFlipper/Core/PluginInfo.hh>
00094
00095 #include <ACG/QtWidgets/QtSceneGraphWidget.hh>
00096
00097 #include <OpenFlipper/INIFile/INIFile.hh>
00098 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
00099
00104 struct ViewMode{
00105
00107 QString name;
00108
00111 QString icon;
00112
00114 bool custom;
00115
00117 QStringList visibleToolboxes;
00118
00120 QStringList visibleToolbars;
00121
00123 QStringList visibleContextMenus;
00124 };
00125
00126 class StackWidgetInfo {
00127 public:
00128 StackWidgetInfo(bool _editable,QString _name,QWidget* _widget);
00129
00130 bool editable;
00131 QString name;
00132 QWidget* widget;
00133 };
00134
00137 struct MenuInfo {
00139 QAction* action;
00140
00142 DataType contextType;
00143
00145 ContextMenuType type;
00146 };
00147
00150 class CoreWidget : public QMainWindow
00151 {
00152 Q_OBJECT
00153
00154 public:
00155
00157 CoreWidget( QVector<ViewMode*>& _viewModes, std::vector<PluginInfo>& _plugins, QList< SlotInfo >& _coreSlots );
00158
00160 ~CoreWidget();
00161
00162 signals:
00163 void clearAll();
00164 void loadMenu();
00165 void addEmptyObjectMenu();
00166 void saveMenu();
00167 void saveToMenu();
00168 void loadIniMenu();
00169 void saveIniMenu();
00170 void recentOpen(QAction*);
00171 void exit();
00172
00173 void loadPlugin();
00174 void showPlugins();
00175
00176 private slots:
00177
00179 void closeEvent ( QCloseEvent * event );
00180
00181
00184
00185
00186 signals :
00187 void log(Logtype _type, QString _message);
00188 void log(QString _message);
00189
00192
00195
00196
00197 protected :
00198
00200 virtual void keyPressEvent (QKeyEvent* _e);
00201 virtual void keyReleaseEvent(QKeyEvent* _e);
00202
00203
00204
00205
00206 signals :
00207
00211 void PluginKeyEvent(QKeyEvent* );
00212
00216 void PluginKeyReleaseEvent(QKeyEvent* );
00217
00219 void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description,
00220 bool _multiUse = false);
00221
00223 void call( QString _expression , bool& _success );
00224
00225 private:
00227 typedef std::multimap< std::pair< int, Qt::KeyboardModifiers > , std::pair< QObject*, int > > KeyMap;
00228
00229 typedef std::multimap< std::pair< QObject*, int >, std::pair< int, Qt::KeyboardModifiers > > InverseKeyMap;
00230
00231 typedef std::pair< KeyMap::iterator, KeyMap::iterator > KeyRange;
00232
00235 void registerCoreKeys();
00236
00241 void coreKeyPressEvent();
00242
00244 void coreKeyPressEvent (QKeyEvent* _e);
00245 void coreKeyReleaseEvent(QKeyEvent* _e);
00246
00247 KeyBinding getKeyBinding(QObject* _plugin, int _keyIndex );
00248 QString getRPCName(QObject* _plugin );
00249
00251 std::vector<KeyBinding> coreKeys_;
00252
00254 KeyMap keys_;
00255
00257 InverseKeyMap invKeys_;
00258
00260 QList< SlotInfo >& coreSlots_;
00261
00262 private slots:
00268 void slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description,
00269 bool _multiUse = false);
00270
00271 public slots:
00276 void slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
00277
00283 void slotRegisterSlotKeyBindings();
00284
00285 public:
00287 void loadKeyBindings(INIFile& _ini);
00288
00290 void saveKeyBindings(INIFile& _ini);
00291
00292 private:
00294 bool shiftPressed_;
00295
00298
00301
00302
00303 public:
00304
00306 void setupMenuBar();
00307
00310
00313
00314
00315 signals:
00316 void startVideoCapture(QString _baseName, int _fps, bool _captureViewers);
00317 void stopVideoCapture();
00318
00319 void resizeViewers(int _width, int _height);
00320 void resizeApplication(int _width, int _height);
00321
00322 private slots:
00323 void startVideoCaptureDialog();
00324
00327
00330
00331
00332 public:
00333
00335 void addRecent(QString _filename, DataType _type);
00336
00338 void updateRecent();
00339
00342
00345
00346
00347 public :
00349 void toggleFullscreen();
00350
00352 void setFullscreen(bool _state );
00353
00355 void toggleLogger();
00356
00358 void showLogger(OpenFlipper::Options::LoggerState _state);
00359
00361 void toggleToolbox();
00362
00364 void showToolbox( bool _state );
00365
00367 void setGlCursor ( bool _state );
00368
00369 private:
00370 OpenFlipper::Options::LoggerState loggerState_;
00371
00372 uint fullscreenState_;
00373
00376
00379
00380
00381 private:
00383 QVector<QWidget*> toolWidgets_;
00384
00385 public:
00387 QVector<ViewMode*>& viewModes_;
00388
00389 private:
00390
00391 QPushButton* viewModeButton_;
00392
00394 QMenu* viewModeMenu_;
00395
00396 public slots:
00397
00399 void initViewModes( );
00400
00402 void slotAddViewModeToolboxes(QString _mode, QStringList _usedWidgets);
00403
00405 void slotAddViewModeToolboxes(QString _mode, bool _custom, QStringList _usedWidgets);
00406
00408 void slotAddViewModeToolbars(QString _mode, QStringList _usedToolbars);
00409
00411 void slotAddViewModeToolbars(QString _mode, bool _custom, QStringList _usedToolbars);
00412
00414 void slotAddViewModeComplete(QString _mode , bool _custom, QStringList _toolboxes, QStringList _toolbars);
00415
00417 void slotSetViewModeIcon(QString _mode, QString _iconName);
00418
00420 void slotSetViewModeIcon(QString _mode, bool _custom, QString _iconName);
00421
00423 void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
00424
00425 private slots:
00427 void slotRemoveViewMode(QString _name);
00428
00430 void slotSetViewMode( QAction* action);
00431
00432
00434 void slotViewModeDialog();
00435
00437 void slotViewChangeDialog();
00438
00440 public slots :
00441 void setViewMode( QString _mode );
00442
00447
00450
00451
00452 public :
00453
00455 std::vector< glViewer* > examiner_widgets_;
00456
00458 QSplitter* splitter_;
00459
00461 LoggerWidget* logWidget_;
00462
00464 int originalLoggerSize_;
00465
00467 QMenu* recentFilesMenu_;
00468
00470 QMenu* helpMenu_;
00471
00473 QGLWidget* glWidget_;
00474
00476 QtGLGraphicsScene* glScene_;
00477
00479 QtGLGraphicsView* glView_;
00480
00482 QGraphicsWidget* centerWidget_;
00483
00485 QtMultiViewLayout* baseLayout_;
00486
00488 QtSlideWindow* slidingLogger_;
00489
00491 QWidget* tempLogWidget;
00492
00494 QWidget* toolBoxArea_;
00495
00497 QPushButton* vmChangeButton_;
00498
00500 QSplitter* toolSplitter_;
00501
00503 SideArea* toolBox_;
00504
00506 QScrollArea* toolBoxScroll_;
00507
00509 QtPickToolbar* pickToolbar_;
00510
00512 CursorPainter* cursorPainter_;
00513
00514
00515
00516 ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_;
00517
00520 private slots:
00521
00524 void slotShowSceneGraphDialog();
00525
00526
00529 void slotActivateExaminer ();
00530
00531
00536 void slotLog(Logtype _type, QString _message);
00537
00540 void sceneRectChanged(const QRectF &rect);
00541
00542
00545
00546 private slots :
00547
00548 void slotAddMenubarAction( QAction* _action , QString _name );
00549 void slotGetMenubarMenu (QString _name, QMenu *& _menu, bool _create);
00550
00551 private:
00552
00554 QMenu *fileMenu_;
00555
00557 QMenu *viewMenu_;
00558
00560 QMenu *toolsMenu_;
00561
00563 QAction* fileMenuEnd_;
00564
00566 QMap<QString, QMenu *> menus_;
00567
00570
00573
00574 private:
00575 QToolBar* viewerToolbar_;
00576
00577 int toolbarCount_;
00578
00579 QToolButton* stereoButton_;
00580 QToolButton* moveButton_;
00581 QToolButton* lightButton_;
00582 QToolButton* pickButton_;
00583 QToolButton* questionButton_;
00584
00585 QComboBox* viewerLayoutBox_;
00586
00589
00592
00593
00594 public slots:
00596 void slotUpdateGlobalDrawMenu();
00597
00598
00600 void setViewerLayout(int _idx);
00601
00602 private slots:
00604 void nextViewerLayout();
00605
00607 void slotGlobalDrawMenu(QAction * _action);
00608
00610 void slotViewMenuAboutToShow();
00611
00612 private:
00614 QMenu* globalDrawMenu_;
00615
00616 QActionGroup * drawGroup_;
00617
00619 QActionGroup* viewGroup_;
00620
00621 QAction* perspectiveProjectionAction_;
00622 QAction* orthogonalProjectionAction_;
00623
00625 QAction* globalAnimationAction_;
00626
00628 QAction* globalBackfaceCullingAction_;
00629
00631 QAction* globalTwosidedLightingAction_;
00632
00634 QAction* globalMultisamplingAction_;
00635
00636 int activeDrawModes_;
00637
00638 int availableGlobalDrawModes_;
00639
00642
00645
00646
00647 signals :
00649 void updateContextMenu(int);
00650
00652 void updateContextMenuNode(int);
00653
00655 void updateContextMenuBackground();
00656
00657
00658 private slots:
00660 void slotCustomContextMenu( const QPoint& _point );
00661
00663 void slotAddContextItem(QAction* _entry, ContextMenuType _type);
00664
00666 void slotAddContextItem( QAction* _entry , DataType _dataType ,ContextMenuType type_);
00667
00669 void slotPasteView( );
00670
00672 void slotCopyView( );
00673
00675 void slotViewerDrawMenu( QAction * _action );
00676
00678 void slotUpdateViewerDrawMenu();
00679
00681 void slotSnapshot();
00682
00684 void slotSwitchWheels(bool _state);
00685
00687 void slotSwitchNavigation(bool _egomode);
00688
00690 void slotSnapshotName();
00691
00693 void slotCoordSysVisibility(bool _visible);
00694
00695 private :
00700 void updatePopupMenu(const QPoint& _point);
00701
00702 void updatePopupMenuCoordsysNode(QMenu* _menu , const int _part);
00703 void updatePopupMenuObject(QMenu* _menu , BaseObjectData* _object );
00704 void updatePopupMenuBackground(QMenu* _menu , const QPoint& _point);
00705 void updatePopupMenuNode(QMenu* _menu , ACG::SceneGraph::BaseNode* _node);
00706
00707 bool addContextMenus( QMenu* _menu , ContextMenuType _type, int _id = -1);
00708
00709 private :
00711 QMenu* contextMenu_;
00712
00714 QMenu* contextSelectionMenu_;
00715
00717 std::vector< MenuInfo > contextMenus_;
00718
00720 QActionGroup* drawGroupViewer_;
00721
00723 QMenu* viewerDrawMenu_;
00724
00727 QMenu* coordSysMenu_;
00728
00731
00734
00735
00736 private:
00737
00738 QString snapshotName_;
00739 int snapshotCounter_;
00740
00741 public slots:
00742
00744 void viewerSnapshotDialog();
00745
00747 void viewerSnapshot();
00748
00750 void applicationSnapshotDialog();
00751
00753 void applicationSnapshot();
00754
00756 void applicationSnapshotName(QString _name);
00757
00758
00761
00764
00765
00766 private slots:
00767 void slotGetStackWidget( QString _name, QWidget*& _widget );
00768 void slotAddStackWidget( QString _name, QWidget* _widget );
00769 void slotUpdateStackWidget( QString _name, QWidget* _widget );
00770
00771 void slotViewMenuAction( QAction * _action);
00772
00773 void slotUpdateStackMenu();
00774
00775
00776 private :
00778 QMenu* stackMenu_;
00779
00780 std::vector< StackWidgetInfo > stackWidgetList_;
00781
00782 public :
00784 QStackedWidget* stackedWidget_;
00785
00788
00791
00792
00793 public slots:
00795 void showHelpBrowser();
00796
00797 private:
00799 HelpWidget* helpWidget_;
00800
00803
00806
00807
00808 public slots:
00810 void showAboutWidget();
00811
00812 private:
00814 AboutWidget* aboutWidget_;
00815
00818
00821
00822
00823 public slots:
00825 void showOptionsWidget();
00826
00827 signals:
00828 void applyOptions();
00829 void saveOptions();
00830
00831 private:
00832
00834 OptionsWidget* optionsWidget_;
00835
00838
00841
00842 private slots:
00844 void slotAddToolbar(QToolBar* _toolbar);
00845
00847 void slotRemoveToolbar(QToolBar* _toolbar);
00848
00850 void getToolBar( QString _name, QToolBar*& _toolbar);
00851
00852 private :
00853 QToolBar* mainToolbar_;
00854
00855 std::vector< QToolBar* > toolbars_;
00856
00859
00862
00863 public slots:
00864 void statusMessage(QString _message, int _timeout = 0);
00865
00866 void clearStatusMessage();
00867
00868 void setStatus( ApplicationStatus::applicationStatus _status);
00869
00870 private:
00871 void setupStatusBar();
00872
00873 private :
00874 ColorStatusBar* statusBar_;
00875
00876 QLabel* statusIcon_;
00877
00880
00883
00884 private slots:
00885 void startDrag( QMouseEvent* _event );
00886
00887 void dragEnterEvent(QDragEnterEvent* _event);
00888
00889 void dropEvent( QDropEvent* _event );
00890
00893 private :
00894
00895 std::vector<PluginInfo>& plugins_;
00896
00897
00898
00901
00902
00903 private slots:
00904
00906 void slotToggleStereoMode();
00907
00909 void slotSetGlobalBackgroundColor();
00910
00912 void slotSetContextBackgroundColor();
00913
00914
00915
00917 void slotContextHomeView();
00918
00920 void slotGlobalHomeView();
00921
00922
00923
00925 void slotContextSetHomeView();
00926
00928 void slotGlobalSetHomeView();
00929
00930
00931
00933 void slotContextViewAll();
00934
00936 void slotGlobalViewAll();
00937
00938
00940 void slotContextSwitchProjection();
00941
00943 void slotGlobalPerspectiveProjection();
00944
00946 void slotGlobalOrthographicProjection();
00947
00948
00950 void slotSetViewingDirection(QAction* _action);
00951
00952
00954 void slotGlobalChangeAnimation(bool _animation);
00955
00957 void slotLocalChangeAnimation(bool _animation);
00958
00959
00960
00962 void slotGlobalChangeBackFaceCulling(bool _backFaceCulling);
00963
00965 void slotLocalChangeBackFaceCulling(bool _backFaceCulling);
00966
00967
00968
00970 void slotGlobalChangeTwoSidedLighting(bool _lighting);
00971
00973 void slotLocalChangeTwoSidedLighting(bool _lighting);
00974
00975
00976
00978 void slotGlobalChangeMultisampling(bool _lighting);
00979
00981 void slotLocalChangeMultisampling(bool _lighting);
00982
00984 void moveBack();
00985
00987 void moveForward();
00988
00990 void strafeLeft();
00991
00993 void strafeRight();
00994
00995 private :
00996 bool stereoActive_;
00997
01000
01003
01004
01005 public slots:
01006
01007 bool examineMode() { return(actionMode_ == Viewer::ExamineMode ); };
01008 bool pickingMode() { return(actionMode_ == Viewer::PickingMode ); };
01009 bool lightMode() { return(actionMode_ == Viewer::LightMode ); };
01010 bool questionMode(){ return(actionMode_ == Viewer::QuestionMode ); };
01011
01015 void setExamineMode() { setActionMode(Viewer::ExamineMode ); };
01016 void setPickingMode() { setActionMode(Viewer::PickingMode ); };
01017 void setLightMode() { setActionMode(Viewer::LightMode ); };
01018 void setQuestionMode(){ setActionMode(Viewer::QuestionMode ); };
01019
01020 void setActionMode(const Viewer::ActionMode _am);
01021 void getActionMode(Viewer::ActionMode& _am);
01022
01023 public:
01024 Viewer::ActionMode actionMode() { return actionMode_; };
01025 Viewer::ActionMode lastActionMode() { return lastActionMode_; };
01026
01027 private :
01028 Viewer::ActionMode actionMode_, lastActionMode_;
01029
01032
01035
01036
01037 public:
01038
01045 void addPickMode(const std::string& _name,
01046 bool _mouse_tracking = false,
01047 int _pos = -1,
01048 bool _visible = true,
01049 QCursor _cursor = Qt::ArrowCursor );
01050
01053 void clearPickModes();
01054
01057 const std::string& pickMode() const;
01058
01062 void pickMode( int _id );
01063
01064 public slots:
01065
01069 void setPickMode(const std::string _name);
01070
01071
01072 void getPickMode(std::string& _name);
01073
01074 public slots:
01075
01081 void setPickModeCursor(const std::string& _name, QCursor _cursor);
01082
01088 void setPickModeMouseTracking(const std::string& _name, bool _mouseTracking);
01089
01097 void setPickModeToolbar( const std::string _mode , QToolBar * _toolbar );
01098
01105 void removePickModeToolbar( const std::string _mode );
01106
01107 void actionPickMenu( QAction * _action );
01108
01109 signals:
01112 void signalPickModeChanged(const std::string&);
01113
01114 private:
01115
01116 QMenu* pickMenu_;
01117
01120 struct PickMode
01121 {
01123 PickMode(const std::string& _n, bool _t, bool _v, QCursor _c, QToolBar *_tb = NULL) :
01124 name(_n), tracking(_t), visible(_v), cursor(_c), toolbar(_tb) {}
01125
01127 std::string name;
01128
01131 bool tracking;
01132
01135 bool visible;
01136
01139 QCursor cursor;
01140
01143 QToolBar * toolbar;
01144 };
01145
01148 std::vector<PickMode> pick_modes_;
01149
01152 std::string pick_mode_name_;
01153
01156 int pick_mode_idx_;
01157
01158
01160 void updatePickMenu();
01161
01162 private slots:
01163
01164 void hidePopupMenus();
01167 };
01168
01169
01170
01171 #endif // COREWIDGET_HH defined
01172
01173