Salome HOME
8896eb23bdb186c6993221cc8fae39ba790e84ca
[modules/gui.git] / src / CAM / CAM_Module.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef CAM_MODULE_H
20 #define CAM_MODULE_H
21
22 #include "CAM.h"
23
24 #include <qpixmap.h>
25 #include <qobject.h>
26 #include <qpopupmenu.h>
27 #include <qstring.h>
28
29 class QAction;
30 class SUIT_Study;
31 class CAM_Study;
32 class CAM_DataModel;
33 class CAM_Application;
34 class QtxActionMenuMgr;
35 class QtxActionToolMgr;
36
37 #ifdef WIN32
38 #pragma warning( disable: 4251 )
39 #endif
40
41 /*! 
42  * Class provide support of tool and menu managers.
43  */
44 class CAM_EXPORT CAM_Module : public QObject
45 {
46   Q_OBJECT
47
48 public:
49   CAM_Module();
50   CAM_Module( const QString& );
51   virtual ~CAM_Module();
52
53   virtual void           initialize( CAM_Application* );
54
55   QString                moduleName() const;
56   QPixmap                moduleIcon() const;
57
58   CAM_DataModel*         dataModel() const;
59   CAM_Application*       application() const;
60
61   virtual QString        iconName() const;
62
63   virtual void           contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
64   virtual void           updateCommandsStatus() {};
65
66   /** @name Set Menu Shown*/
67   //@{
68   virtual void           setMenuShown( const bool );
69   void                   setMenuShown( QAction*, const bool );
70   void                   setMenuShown( const int, const bool );
71   //@}
72
73   /** @name Set Tool Shown*/
74   //@{
75   virtual void           setToolShown( const bool );
76   void                   setToolShown( QAction*, const bool );
77   void                   setToolShown( const int, const bool );
78   //@}
79
80 public slots:
81   virtual bool           activateModule( SUIT_Study* );
82   virtual bool           deactivateModule( SUIT_Study* );
83
84   virtual void           connectToStudy( CAM_Study* );
85
86   virtual void           studyClosed( SUIT_Study* );
87   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
88
89 protected: 
90   virtual CAM_DataModel* createDataModel();
91
92   virtual void           setModuleName( const QString& );
93   virtual void           setModuleIcon( const QPixmap& );
94
95   QtxActionMenuMgr*      menuMgr() const;
96   QtxActionToolMgr*      toolMgr() const;
97
98   /** @name Create tool methods.*/
99   //@{
100   int                    createTool( const QString& );
101   int                    createTool( const int, const int, const int = -1 );
102   int                    createTool( const int, const QString&, const int = -1 );
103   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
104   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
105   //@}
106
107   /** @name Create menu methods.*/
108   //@{
109   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false );
110   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
111   int                    createMenu( const int, const int, const int = -1, const int = -1 );
112   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
113   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
114   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
115   //@}
116
117   static QAction*        separator();
118
119   /**Action ids methods.*/
120   //@{
121   QAction*               action( const int ) const;
122   int                    actionId( const QAction* ) const;
123   //@}
124
125   int                    registerAction( const int, QAction* );
126   bool                   unregisterAction( const int );
127   bool                   unregisterAction( QAction* );
128   QAction*               createAction( const int, const QString&, const QIconSet&, const QString&,
129                                        const QString&, const int, QObject* = 0,
130                                        const bool = false, QObject* = 0, const char* = 0 );
131
132 private:
133   CAM_Application*       myApp;
134   QString                myName;
135   QPixmap                myIcon;
136   CAM_DataModel*         myDataModel;
137   QMap<int, QAction*>    myActionMap;
138
139   friend class CAM_Application;
140 };
141
142 #ifdef WIN32
143 #pragma warning( default: 4251 )
144 #endif
145
146 extern "C" {
147   typedef CAM_Module* (*GET_MODULE_FUNC)();
148 }
149
150 #define GET_MODULE_NAME "createModule"
151
152 #endif