Salome HOME
Has functionality from SalomeApp without dependency from CORBA
[modules/gui.git] / src / LightApp / LightApp_Module.h
1 // File:      LightApp_Module.h
2 // Created:   6/20/2005 16:25:06 AM
3 // Author:    OCC team
4 // Copyright (C) CEA 2005
5
6 #ifndef LIGHTAPP_MODULE_H
7 #define LIGHTAPP_MODULE_H
8
9 #include "LightApp.h"
10 #include <CAM_Module.h>
11
12 class LightApp_Application;
13 class LightApp_Preferences;
14 class LightApp_Selection;
15 class LightApp_Operation;
16 class LightApp_SwitchOp;
17 class LightApp_Displayer;
18
19 class SUIT_Study;
20 class SUIT_DataObject;
21 class SUIT_Operation;
22 class CAM_Application;
23
24 class QtxPopupMgr;
25
26 class QString;
27 class QVariant;
28
29 /*
30   Class : LightApp_Module
31   Description : Base class for all light modules
32 */
33
34 class LIGHTAPP_EXPORT LightApp_Module : public CAM_Module
35 {
36   Q_OBJECT
37
38 public:
39   LightApp_Module( const QString& );
40   virtual ~LightApp_Module();
41
42   virtual void                        initialize( CAM_Application* );
43   virtual void                        windows( QMap<int, int>& ) const;
44   virtual void                        viewManagers( QStringList& ) const;
45
46   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
47
48   virtual void                        createPreferences();
49
50   LightApp_Application*               getApp() const;
51
52   virtual void                        update( const int );
53   // Update viewer or/and object browser etc. in accordance with update flags
54   // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
55   // for their own purposes
56
57   virtual void                        updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
58   // Update object bropwser ( for updating model or whole object browser use update() method
59   // can be used )
60
61   virtual void                        selectionChanged();
62   virtual void                        preferencesChanged( const QString&, const QString& );
63
64   virtual void                        studyActivated() {};
65
66   virtual LightApp_Displayer*         displayer();
67
68 public slots:
69   virtual bool                        activateModule( SUIT_Study* );
70   virtual bool                        deactivateModule( SUIT_Study* );
71
72   void                                MenuItem();
73
74 protected slots:
75   virtual void                        onModelSaved();
76   virtual void                        onModelOpened();
77   virtual void                        onModelClosed();
78
79   virtual void                        onOperationStopped( SUIT_Operation* );
80   virtual void                        onOperationDestroyed();
81   virtual void                        onShowHide();
82
83 protected:
84   virtual QtxPopupMgr*                popupMgr();
85   LightApp_Preferences*               preferences() const;
86
87   virtual CAM_DataModel*              createDataModel();
88   virtual LightApp_Selection*         createSelection() const;
89
90   int                                 addPreference( const QString& label );
91   int                                 addPreference( const QString& label, const int pId, const int = -1,
92                                                      const QString& section = QString::null,
93                                                      const QString& param = QString::null );
94   QVariant                            preferenceProperty( const int, const QString& ) const;
95   void                                setPreferenceProperty( const int, const QString&, const QVariant& );
96
97   /*! Module stores operations in map. This method starts operation by id.
98    *  If operation isn't in map, then it will be created by createOperation method
99    *  and will be inserted to map
100    */
101   void                                startOperation( const int );
102   /*! Create operation by its id. You must not call this method, it will be called automatically
103    *  by startOperation. Please redefine this method in current module
104    */
105   virtual LightApp_Operation*         createOperation( const int ) const;
106
107   virtual void                        updateControls();
108
109 private:
110   typedef QMap<int,LightApp_Operation*> MapOfOperation;
111
112 private:
113   QtxPopupMgr*          myPopupMgr;
114   MapOfOperation        myOperations;
115   LightApp_SwitchOp*    mySwitchOp;
116   int                   myDisplay, myErase, myDisplayOnly;
117 };
118
119 #endif