Salome HOME
628623f115d4efcaece3e0895f3b09663b7c1ad4
[modules/gui.git] / src / CAM / CAM_Module.h
1 //  Copyright (C) 2007-2008  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 #ifndef CAM_MODULE_H
23 #define CAM_MODULE_H
24
25 #include "CAM.h"
26
27 #include <QObject>
28 #include <QPixmap>
29 #include <QString>
30 #include <QMap>
31
32 class QAction;
33 class QMenu;
34 class QIcon;
35
36 class QtxActionMenuMgr;
37 class QtxActionToolMgr;
38 class SUIT_Study;
39 class SUIT_Application;
40 class CAM_Study;
41 class CAM_DataModel;
42 class CAM_Application;
43
44 #ifdef WIN32
45 #pragma warning( disable: 4251 )
46 #endif
47
48 class CAM_EXPORT CAM_Module : public QObject
49 {
50   Q_OBJECT
51
52 public:
53   CAM_Module();
54   CAM_Module( const QString& );
55   virtual ~CAM_Module();
56
57   virtual void           initialize( CAM_Application* );
58
59   QString                name() const;
60   QString                moduleName() const;
61   virtual QPixmap        moduleIcon() const;
62   virtual QString        iconName() const;
63
64   CAM_DataModel*         dataModel() const;
65   CAM_Application*       application() const;
66
67   virtual void           contextMenuPopup( const QString&, QMenu*, QString& ) {};
68   virtual void           updateCommandsStatus() {};
69
70   virtual void           putInfo( const QString&, const int = -1 );
71
72   bool                   isActiveModule() const;
73
74   virtual void           setMenuShown( const bool );
75   void                   setMenuShown( QAction*, const bool );
76   void                   setMenuShown( const int, const bool );
77
78   virtual void           setToolShown( const bool );
79   void                   setToolShown( QAction*, const bool );
80   void                   setToolShown( const int, const bool );
81
82 public slots:
83   virtual bool           activateModule( SUIT_Study* );
84   virtual bool           deactivateModule( SUIT_Study* );
85
86   virtual void           connectToStudy( CAM_Study* );
87
88   virtual void           studyClosed( SUIT_Study* );
89   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
90
91   virtual void           onApplicationClosed( SUIT_Application* );
92
93 private slots:
94   void                   onInfoChanged( QString );
95
96 protected: 
97   virtual bool           isSelectionCompatible();
98
99   virtual CAM_DataModel* createDataModel();
100
101   void                   setName( const QString& );
102   virtual void           setModuleName( const QString& );
103
104   QtxActionMenuMgr*      menuMgr() const;
105   QtxActionToolMgr*      toolMgr() const;
106
107   int                    createTool( const QString& );
108   int                    createTool( const int, const int, const int = -1 );
109   int                    createTool( const int, const QString&, const int = -1 );
110   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
111   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
112
113   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
114   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
115   int                    createMenu( const int, const int, const int = -1, const int = -1 );
116   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
117   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
118   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
119
120   static QAction*        separator();
121
122   QAction*               action( const int ) const;
123   int                    actionId( const QAction* ) const;
124
125   int                    registerAction( const int, QAction* );
126   bool                   unregisterAction( const int );
127   bool                   unregisterAction( QAction* );
128   QAction*               createAction( const int, const QString&, const QIcon&, 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;             //!< parent application object
134   QString                myName;            //!< module title (user name)
135   QPixmap                myIcon;            //!< module icon
136   QString                myInfo;            //!< latest info message
137   CAM_DataModel*         myDataModel;       //!< data model
138   QMap<int, QAction*>    myActionMap;       //!< menu actions
139
140   friend class CAM_Application;
141 };
142
143 #ifdef WIN32
144 #pragma warning( default: 4251 )
145 #endif
146
147 extern "C"
148 {
149   typedef CAM_Module* (*GET_MODULE_FUNC)();
150 }
151
152 #define GET_MODULE_NAME "createModule"
153
154 #endif