Salome HOME
PAL9391
[modules/gui.git] / src / SalomeApp / SalomeApp_Module.h
1 // File:      SalomeApp_Module.h
2 // Created:   10/25/2004 11:33:06 AM
3 // Author:    Sergey LITONIN
4 // Copyright (C) CEA 2004
5
6 #ifndef SALOMEAPP_MODULE_H
7 #define SALOMEAPP_MODULE_H
8
9 #include "SalomeApp.h"
10 #include "SalomeApp_Selection.h"
11
12 #include <CAM_Module.h>
13
14 #include <string>
15
16 class QDockWindow;
17
18 class CAM_Study;
19
20 class QtxPopupMgr;
21
22 class SUIT_Operation;
23 class SUIT_Convertor;
24 class SUIT_ViewModel;
25 class SUIT_DataObject;
26
27 class SalomeApp_DataModel;
28 class SalomeApp_Application;
29 class SalomeApp_Preferences;
30 class SalomeApp_SelectionManager;
31 class SalomeApp_Operation;
32 class SalomeApp_SwitchOp;
33 class SalomeApp_Displayer;
34
35 /*!
36  * \brief Base class for all salome modules
37 */
38 class SALOMEAPP_EXPORT SalomeApp_Module : public CAM_Module
39 {
40   Q_OBJECT
41
42 public:
43   SalomeApp_Module( const QString& );
44   virtual ~SalomeApp_Module();
45
46   virtual void                        initialize( CAM_Application* );
47   virtual void                        windows( QMap<int, int>& ) const;
48   virtual void                        viewManagers( QStringList& ) const;
49   virtual SalomeApp_Displayer*        displayer();
50
51   /*! engineIOR() should be a pure virtual method, to avoid logical errors!\n
52    * Implementation in derived classes can return the following values:\n
53    * module`s engine IOR - means that this is a standard SALOME module with a CORBA engine
54    * \li "" (empty string)   - means that this is a light module, default engine should be used for interaction with SALOMEDS persistence
55    * \li "-1"                - means that this is a light module, SALOMEDS persistence is not used at all\n
56    */
57   virtual QString                     engineIOR() const = 0;
58
59   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
60
61   virtual void                        createPreferences();
62   
63   /*! Convenient shortcuts*/
64  
65   SalomeApp_Application*              getApp() const;
66
67   virtual void                        update( const int );
68   // Update viewer or/and object browser etc. in accordance with update flags
69   // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
70   // for their own purposes
71     
72   void                                updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
73   // Update object bropwser ( for updating model or whole object browser use update() method
74   // can be used )
75   
76   virtual void                        selectionChanged();
77   virtual void                        preferencesChanged( const QString&, const QString& );
78
79   virtual void                        studyActivated() {};
80
81 public slots:
82   virtual bool                        activateModule( SUIT_Study* );
83   virtual bool                        deactivateModule( SUIT_Study* );
84
85   void                                MenuItem();
86
87 protected slots:
88   virtual void                        onModelSaved();
89   virtual void                        onModelOpened();
90   virtual void                        onModelClosed();
91   virtual void                        onOperationStopped( SUIT_Operation* );
92   virtual void                        onOperationDestroyed();
93   virtual void                        onShowHide();
94
95 protected:
96   QtxPopupMgr*                        popupMgr();
97   SalomeApp_Preferences*              preferences() const;
98
99   virtual CAM_DataModel*              createDataModel();
100   virtual SalomeApp_Selection*        createSelection() const;
101   virtual void                        updateControls();
102
103   /*! Module stores operations in map. This method starts operation by id.
104    *  If operation isn't in map, then it will be created by createOperation method
105    *  and will be inserted to map
106    */
107   void                                startOperation( const int );
108
109   /*! Create operation by its id. You must not call this method, it will be called automatically
110    *  by startOperation. Please redefine this method in current module
111    */
112   virtual SalomeApp_Operation*        createOperation( const int ) const;
113
114   int                                 addPreference( const QString& label );
115   int                                 addPreference( const QString& label, const int pId, const int = -1,
116                                                      const QString& section = QString::null,
117                                                      const QString& param = QString::null );
118   QVariant                            preferenceProperty( const int, const QString& ) const;
119   void                                setPreferenceProperty( const int, const QString&, const QVariant& );
120
121 private:
122   typedef QMap<int,SalomeApp_Operation*> MapOfOperation;
123   
124 private:
125   QtxPopupMgr*          myPopupMgr;
126   MapOfOperation        myOperations;
127   SalomeApp_SwitchOp*   mySwitchOp;
128   int                   myDisplay, myErase, myDisplayOnly;
129 };
130
131 #endif