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