]> SALOME platform Git repositories - modules/gui.git/blob - src/CAM/CAM_Module.h
Salome HOME
ce051a993105ed54c133916de82aec7e3cfd1b78
[modules/gui.git] / src / CAM / CAM_Module.h
1 #ifndef CAM_MODULE_H
2 #define CAM_MODULE_H
3
4 #include "CAM.h"
5
6 #include <qpixmap.h>
7 #include <qobject.h>
8 #include <qpopupmenu.h>
9 #include <qstring.h>
10
11 class QAction;
12 class SUIT_Study;
13 class CAM_Study;
14 class CAM_DataModel;
15 class CAM_Application;
16 class QtxActionMenuMgr;
17 class QtxActionToolMgr;
18
19 #ifdef WIN32
20 #pragma warning( disable: 4251 )
21 #endif
22
23 /*! 
24  * Class provide support of tool and menu managers.
25  */
26 class CAM_EXPORT CAM_Module : public QObject
27 {
28   Q_OBJECT
29
30 public:
31   CAM_Module();
32   CAM_Module( const QString& );
33   virtual ~CAM_Module();
34
35   virtual void           initialize( CAM_Application* );
36
37   QString                moduleName() const;
38   QPixmap                moduleIcon() const;
39
40   CAM_DataModel*         dataModel() const;
41   CAM_Application*       application() const;
42
43   virtual QString        iconName() const;
44
45   virtual void           contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
46   virtual void           updateCommandsStatus() {};
47
48   /** @name Set Menu Shown*/
49   //@{
50   void                   setMenuShown( const bool );
51   void                   setMenuShown( QAction*, const bool );
52   void                   setMenuShown( const int, const bool );
53   //@}
54
55   /** @name Set Tool Shown*/
56   //@{
57   void                   setToolShown( const bool );
58   void                   setToolShown( QAction*, const bool );
59   void                   setToolShown( const int, const bool );
60   //@}
61
62 public slots:
63   virtual bool           activateModule( SUIT_Study* );
64   virtual bool           deactivateModule( SUIT_Study* );
65
66   virtual void           connectToStudy( CAM_Study* );
67
68   virtual void           studyClosed( SUIT_Study* );
69   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
70
71 protected: 
72   virtual CAM_DataModel* createDataModel();
73
74   virtual void           setModuleName( const QString& );
75   virtual void           setModuleIcon( const QPixmap& );
76
77   QtxActionMenuMgr*      menuMgr() const;
78   QtxActionToolMgr*      toolMgr() const;
79
80   /** @name Create tool methods.*/
81   //@{
82   int                    createTool( const QString& );
83   int                    createTool( const int, const int, const int = -1 );
84   int                    createTool( const int, const QString&, const int = -1 );
85   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
86   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
87   //@}
88
89   /** @name Create menu methods.*/
90   //@{
91   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
92   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
93   int                    createMenu( const int, const int, const int = -1, const int = -1 );
94   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
95   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
96   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
97   //@}
98
99   static QAction*        separator();
100
101   /**Action ids methods.*/
102   //@{
103   QAction*               action( const int ) const;
104   int                    actionId( const QAction* ) const;
105   //@}
106
107   int                    registerAction( const int, QAction* );
108   QAction*               createAction( const int, const QString&, const QIconSet&, const QString&,
109                                        const QString&, const int, QObject* = 0,
110                                        const bool = false, QObject* = 0, const char* = 0 );
111
112 private:
113   CAM_Application*       myApp;
114   QString                myName;
115   QPixmap                myIcon;
116   CAM_DataModel*         myDataModel;
117   QMap<int, QAction*>    myActionMap;
118
119   friend class CAM_Application;
120 };
121
122 #ifdef WIN32
123 #pragma warning( default: 4251 )
124 #endif
125
126 extern "C" {
127   typedef CAM_Module* (*GET_MODULE_FUNC)();
128 }
129
130 #define GET_MODULE_NAME "createModule"
131
132 #endif