Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / LightApp / LightApp_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 // File:      LightApp_Module.h
20 // Created:   6/20/2005 16:25:06 AM
21 // Author:    OCC team
22 // Copyright (C) CEA 2005
23
24 #ifndef LIGHTAPP_MODULE_H
25 #define LIGHTAPP_MODULE_H
26
27 #include "LightApp.h"
28 #include <CAM_Module.h>
29
30 class LightApp_Application;
31 class LightApp_Preferences;
32 class LightApp_Selection;
33 class LightApp_Operation;
34 class LightApp_SwitchOp;
35 class LightApp_ShowHideOp;
36 class LightApp_Displayer;
37
38 class SUIT_Study;
39 class SUIT_DataObject;
40 class SUIT_Operation;
41 class SUIT_ViewManager;
42 class CAM_Application;
43
44 class QtxPopupMgr;
45
46 class QString;
47 class QVariant;
48
49 #ifdef WIN32
50 #pragma warning ( disable:4251 )
51 #endif
52
53 /*!
54   \class LightApp_Module
55   Base class for all light modules
56 */
57
58 class LIGHTAPP_EXPORT LightApp_Module : public CAM_Module
59 {
60   Q_OBJECT
61
62 public:
63   LightApp_Module( const QString& );
64   virtual ~LightApp_Module();
65
66   virtual void                        initialize( CAM_Application* );
67   virtual void                        windows( QMap<int, int>& ) const;
68   virtual void                        viewManagers( QStringList& ) const;
69
70   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
71
72   virtual void                        createPreferences();
73
74   LightApp_Application*               getApp() const;
75
76   virtual void                        update( const int );
77   // Update viewer or/and object browser etc. in accordance with update flags
78   // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
79   // for their own purposes
80
81   virtual void                        updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
82   // Update object bropwser ( for updating model or whole object browser use update() method
83   // can be used )
84
85   virtual void                        selectionChanged();
86   virtual void                        preferencesChanged( const QString&, const QString& );
87
88   virtual void                        studyActivated() {};
89
90   virtual LightApp_Displayer*         displayer();
91   virtual LightApp_Selection*         createSelection() const;
92
93 public slots:
94   virtual bool                        activateModule( SUIT_Study* );
95   virtual bool                        deactivateModule( SUIT_Study* );
96
97   void                                MenuItem();
98
99 protected slots:
100   virtual void                        onModelSaved();
101   virtual void                        onModelOpened();
102   virtual void                        onModelClosed();
103
104   virtual void                        onOperationStopped( SUIT_Operation* );
105   virtual void                        onOperationDestroyed();
106   virtual void                        onShowHide();
107   virtual void                        onViewManagerAdded( SUIT_ViewManager* );
108   virtual void                        onViewManagerRemoved( SUIT_ViewManager* );
109
110 protected:
111   virtual QtxPopupMgr*                popupMgr();
112   LightApp_Preferences*               preferences() const;
113
114   virtual CAM_DataModel*              createDataModel();
115
116   int                                 addPreference( const QString& label );
117   int                                 addPreference( const QString& label, const int pId, const int = -1,
118                                                      const QString& section = QString::null,
119                                                      const QString& param = QString::null );
120   QVariant                            preferenceProperty( const int, const QString& ) const;
121   void                                setPreferenceProperty( const int, const QString&, const QVariant& );
122
123   /*! Module stores operations in map. This method starts operation by id.
124    *  If operation isn't in map, then it will be created by createOperation method
125    *  and will be inserted to map
126    */
127   void                                startOperation( const int );
128   /*! Create operation by its id. You must not call this method, it will be called automatically
129    *  by startOperation. Please redefine this method in current module
130    */
131   virtual LightApp_Operation*         createOperation( const int ) const;
132
133   virtual void                        updateControls();
134
135 private:
136   typedef QMap<int,LightApp_Operation*> MapOfOperation;
137
138 private:
139   QtxPopupMgr*          myPopupMgr;
140   MapOfOperation        myOperations;
141   LightApp_SwitchOp*    mySwitchOp;
142
143 protected:
144   int                   myDisplay, myErase, myDisplayOnly, myEraseAll;
145 };
146
147 #ifdef WIN32
148 #pragma warning ( default:4251 )
149 #endif
150
151 #endif