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