Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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/ or email : webmaster.salome@opencascade.com
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 SUIT_Application;
32 class CAM_Study;
33 class CAM_DataModel;
34 class CAM_Application;
35 class QtxActionMenuMgr;
36 class QtxActionToolMgr;
37
38 #ifdef WIN32
39 #pragma warning( disable: 4251 )
40 #endif
41
42 /*! 
43  * Class provide support of tool and menu managers.
44  */
45 class CAM_EXPORT CAM_Module : public QObject
46 {
47   Q_OBJECT
48
49 public:
50   CAM_Module();
51   CAM_Module( const QString& );
52   virtual ~CAM_Module();
53
54   virtual void           initialize( CAM_Application* );
55
56   QString                moduleName() const;
57   QPixmap                moduleIcon() const;
58
59   CAM_DataModel*         dataModel() const;
60   CAM_Application*       application() const;
61
62   virtual QString        iconName() const;
63
64   virtual void           contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
65   virtual void           updateCommandsStatus() {};
66
67   virtual void           putInfo( const QString&, const int = -1 );
68
69   bool                   isActiveModule() const;
70
71   /** @name Set Menu Shown*/
72   //@{
73   virtual void           setMenuShown( const bool );
74   void                   setMenuShown( QAction*, const bool );
75   void                   setMenuShown( const int, const bool );
76   //@}
77
78   /** @name Set Tool Shown*/
79   //@{
80   virtual void           setToolShown( const bool );
81   void                   setToolShown( QAction*, const bool );
82   void                   setToolShown( const int, const bool );
83   //@}
84
85 public slots:
86   virtual bool           activateModule( SUIT_Study* );
87   virtual bool           deactivateModule( SUIT_Study* );
88
89   virtual void           connectToStudy( CAM_Study* );
90
91   virtual void           studyClosed( SUIT_Study* );
92   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
93
94   virtual void           onApplicationClosed( SUIT_Application* );
95
96 private slots:
97   void                   onInfoChanged( QString );
98
99 protected: 
100   virtual CAM_DataModel* createDataModel();
101
102   virtual void           setModuleName( const QString& );
103   virtual void           setModuleIcon( const QPixmap& );
104
105   QtxActionMenuMgr*      menuMgr() const;
106   QtxActionToolMgr*      toolMgr() const;
107
108   /** @name Create tool methods.*/
109   //@{
110   int                    createTool( const QString& );
111   int                    createTool( const int, const int, const int = -1 );
112   int                    createTool( const int, const QString&, const int = -1 );
113   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
114   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
115   //@}
116
117   /** @name Create menu methods.*/
118   //@{
119   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false );
120   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
121   int                    createMenu( const int, const int, const int = -1, const int = -1 );
122   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
123   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
124   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
125   //@}
126
127   static QAction*        separator();
128
129   /**Action ids methods.*/
130   //@{
131   QAction*               action( const int ) const;
132   int                    actionId( const QAction* ) const;
133   //@}
134
135   int                    registerAction( const int, QAction* );
136   bool                   unregisterAction( const int );
137   bool                   unregisterAction( QAction* );
138   QAction*               createAction( const int, const QString&, const QIconSet&, const QString&,
139                                        const QString&, const int, QObject* = 0,
140                                        const bool = false, QObject* = 0, const char* = 0 );
141
142 private:
143   CAM_Application*       myApp;
144   QString                myName;
145   QPixmap                myIcon;
146   QString                myInfo;
147   CAM_DataModel*         myDataModel;
148   QMap<int, QAction*>    myActionMap;
149
150   friend class CAM_Application;
151 };
152
153 #ifdef WIN32
154 #pragma warning( default: 4251 )
155 #endif
156
157 extern "C"
158 {
159   typedef CAM_Module* (*GET_MODULE_FUNC)();
160 }
161
162 #define GET_MODULE_NAME "createModule"
163
164 #endif