Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[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 /*!
50   \class LightApp_Module
51   Base class for all light modules
52 */
53
54 class LIGHTAPP_EXPORT LightApp_Module : public CAM_Module
55 {
56   Q_OBJECT
57
58 public:
59   LightApp_Module( const QString& );
60   virtual ~LightApp_Module();
61
62   virtual void                        initialize( CAM_Application* );
63   virtual void                        windows( QMap<int, int>& ) const;
64   virtual void                        viewManagers( QStringList& ) const;
65
66   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
67
68   virtual void                        createPreferences();
69
70   LightApp_Application*               getApp() const;
71
72   virtual void                        update( const int );
73   // Update viewer or/and object browser etc. in accordance with update flags
74   // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
75   // for their own purposes
76
77   virtual void                        updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
78   // Update object bropwser ( for updating model or whole object browser use update() method
79   // can be used )
80
81   virtual void                        selectionChanged();
82   virtual void                        preferencesChanged( const QString&, const QString& );
83
84   virtual void                        studyActivated() {};
85
86   virtual LightApp_Displayer*         displayer();
87
88 public slots:
89   virtual bool                        activateModule( SUIT_Study* );
90   virtual bool                        deactivateModule( SUIT_Study* );
91
92   void                                MenuItem();
93
94 protected slots:
95   virtual void                        onModelSaved();
96   virtual void                        onModelOpened();
97   virtual void                        onModelClosed();
98
99   virtual void                        onOperationStopped( SUIT_Operation* );
100   virtual void                        onOperationDestroyed();
101   virtual void                        onShowHide();
102   virtual void                        onViewManagerAdded( SUIT_ViewManager* );
103   virtual void                        onViewManagerRemoved( SUIT_ViewManager* );
104
105 protected:
106   virtual QtxPopupMgr*                popupMgr();
107   LightApp_Preferences*               preferences() const;
108
109   virtual CAM_DataModel*              createDataModel();
110   virtual LightApp_Selection*         createSelection() const;
111
112   int                                 addPreference( const QString& label );
113   int                                 addPreference( const QString& label, const int pId, const int = -1,
114                                                      const QString& section = QString::null,
115                                                      const QString& param = QString::null );
116   QVariant                            preferenceProperty( const int, const QString& ) const;
117   void                                setPreferenceProperty( const int, const QString&, const QVariant& );
118
119   /*! Module stores operations in map. This method starts operation by id.
120    *  If operation isn't in map, then it will be created by createOperation method
121    *  and will be inserted to map
122    */
123   void                                startOperation( const int );
124   /*! Create operation by its id. You must not call this method, it will be called automatically
125    *  by startOperation. Please redefine this method in current module
126    */
127   virtual LightApp_Operation*         createOperation( const int ) const;
128
129   virtual void                        updateControls();
130
131 private:
132   typedef QMap<int,LightApp_Operation*> MapOfOperation;
133
134 private:
135   QtxPopupMgr*          myPopupMgr;
136   MapOfOperation        myOperations;
137   LightApp_SwitchOp*    mySwitchOp;
138
139 protected:
140   int                   myDisplay, myErase, myDisplayOnly, myEraseAll;
141 };
142
143 #endif