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