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