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