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