Salome HOME
Update comments
[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 public slots:
45   virtual bool           activateModule( SUIT_Study* );
46   virtual bool           deactivateModule( SUIT_Study* );
47
48   virtual void           studyClosed( SUIT_Study* );
49   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
50
51 protected: 
52   virtual CAM_DataModel* createDataModel();
53
54   virtual void           setModuleName( const QString& );
55   virtual void           setModuleIcon( const QPixmap& );
56
57   QtxActionMenuMgr*      menuMgr() const;
58   QtxActionToolMgr*      toolMgr() const;
59
60   /** @name Create tool methods.*/
61   //@{
62   int                    createTool( const QString& );
63   int                    createTool( const int, const int, const int = -1 );
64   int                    createTool( const int, const QString&, const int = -1 );
65   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
66   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
67   //@}
68
69   /** @name Create menu methods.*/
70   //@{
71   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
72   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
73   int                    createMenu( const int, const int, const int = -1, const int = -1 );
74   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
75   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
76   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
77   //@}
78
79   /** @name Set Menu Shown*/
80   //@{
81   void                   setMenuShown( const bool );
82   void                   setMenuShown( QAction*, const bool );
83   void                   setMenuShown( const int, const bool );
84   //@}
85
86   /** @name Set Tool Shown*/
87   //@{
88   void                   setToolShown( const bool );
89   void                   setToolShown( QAction*, const bool );
90   void                   setToolShown( const int, const bool );
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