Salome HOME
36bae93af0388832b9f80a025dd97bdaed2fb0cf
[modules/shaper.git] / src / NewGeom / NewGeom_Module.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3
4 #ifndef NewGeom_Module_H
5 #define NewGeom_Module_H
6
7 #include "NewGeom.h"
8 #include "NewGeom_SalomeViewer.h"
9
10 #include <LightApp_Module.h>
11 #include <XGUI_SalomeConnector.h>
12
13 #include <ModuleBase_ActionInfo.h>
14
15 #include <QStringList>
16 #include <QMap>
17
18 class XGUI_Workshop;
19 class NewGeom_OCCSelector;
20 class OCCViewer_Viewer;
21
22 /** 
23  * \ingroup Salome
24  * An implementation of SALOME connector class for implementation of
25  * XGUI functionality as a module of SALOME
26  */
27 class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector
28 {
29 Q_OBJECT
30  public:
31   NewGeom_Module();
32   virtual ~NewGeom_Module();
33
34   //----- LightAPP_Module interface ---------------
35
36   /// \brief Initializing of the module
37   /// \param theApp application instance
38   virtual void initialize(CAM_Application* theApp);
39
40   /// \brief Definition of module standard windows
41   virtual void windows(QMap<int, int>& theWndMap) const;
42
43   /// \brief Definition of module viewer 
44   virtual void viewManagers(QStringList& theList) const;
45
46   /// \brief The method is called on selection changed event
47   virtual void selectionChanged();
48
49   //--- XGUI connector interface -----
50
51   virtual QAction* addFeature(const QString& theWBName, const QString& theId,
52                               const QString& theTitle, const QString& theTip, const QIcon& theIcon,
53                               const QKeySequence& theKeys = QKeySequence(),
54                               bool isCheckable = false);
55
56   virtual QAction* addFeature(const QString& theWBName,
57                                 const ActionInfo& theInfo);
58
59
60   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
61                                      const QString& theTip, const QIcon& theIcon,
62                                      const QKeySequence& theKeys, bool isCheckable,
63                                      const char* theMenuSourceText,
64                                      const int theMenuPosition = 10);
65
66   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
67                                        const int theMenuPosition = 10);
68
69   virtual QMainWindow* desktop() const;
70
71   virtual QString commandId(const QAction* theCmd) const;
72
73   virtual QAction* command(const QString& theId) const;
74
75   //! Set nested actions dependent on command Id
76   //! \param theId - the command ID
77   //! \param theActions - the list of nested actions
78   virtual void setNestedActions(const QString& theId, const QStringList& theActions);
79
80   //! Returns list of nested actions according to the given command ID
81   virtual QStringList nestedActions(const QString& theId) const;
82
83   //! Set the document kind of the action by the given command Id
84   //! \param theId - the command ID
85   //! \param theKind - the document kind
86   virtual void setDocumentKind(const QString& theId, const QString& theKind);
87
88   //! Returns the document kind of the action by the given command ID
89   virtual QString documentKind(const QString& theId) const;
90
91   //! Returns interface to Salome viewer
92   virtual ModuleBase_IViewer* viewer() const
93   {
94     return myProxyViewer;
95   }
96
97   //! Returns list of defined actions (just by NewGeom module)
98   virtual QList<QAction*> commandList() const;
99
100   //! Returns list of Ids of defined actions (just by NewGeom module)
101   virtual QStringList commandIdList() const;
102
103   /// Redefinition of virtual function. 
104   /// \param theClient name of pop-up client
105   /// \param theMenu popup menu instance
106   /// \param theTitle menu title.
107   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
108
109   /// Redefinition of virtual function for preferences creation. 
110   virtual void createPreferences();
111
112   /// Redefinition of virtual function for preferences changed event. 
113   virtual void preferencesChanged(const QString& theSection, const QString& theParam);
114   
115   /// \return Workshop class instance
116   XGUI_Workshop* workshop() const { return myWorkshop; }
117
118   /// \brief Set flag about opened document state
119   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
120
121   /// Register current modules of SALOME
122   void inspectSalomeModules();
123
124  public slots:
125    /// \brief The method is called on the module activation
126    /// \param theStudy current study
127   virtual bool activateModule(SUIT_Study* theStudy);
128
129    /// \brief The method is called on the module activation
130    /// \param theStudy current study
131   virtual bool deactivateModule(SUIT_Study* theStudy);
132
133  protected slots:
134    /// Redefinition of virtual function
135    /// \param theMgr view manager
136   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
137
138    /// Redefinition of virtual function
139    /// \param theMgr view manager
140   virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
141
142   /// Set preferences to default
143   void onDefaultPreferences();
144
145   /// Obtains the current application and updates its actions
146   void onUpdateCommandStatus();
147
148  protected:
149    /// Create data model
150   CAM_DataModel* createDataModel();
151
152   /// Create popup menu manager
153   virtual QtxPopupMgr* popupMgr();
154
155  private:
156    /// Create selector for OCC Viewer
157    /// \param theMgr view manager
158   NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
159
160   /// List of registered actions
161   QStringList myActionsList;
162
163   /// Reference to workshop
164   XGUI_Workshop* myWorkshop;
165
166   /// OCC viewer selector instance
167   NewGeom_OCCSelector* mySelector;
168
169   /// Proxy viewer for connection to OCC Viewer in SALOME
170   NewGeom_SalomeViewer* myProxyViewer;
171
172   /// Map of nested actions [ActionID: list of nested actions Id]
173   QMap<QString, QStringList> myNestedActions;
174
175   /// Map of document types
176   QMap<QString, QString> myDocumentType;
177
178   /// Flag of opened document state
179   bool myIsOpened;
180
181   // the next parameters should be restored after this module deactivation
182
183   /// The application value of the preferences parameter
184   bool myIsStorePositions; 
185
186   /// The application value
187   bool myIsEditEnabled;    
188
189   /// Popup manager
190   QtxPopupMgr* myPopupMgr;
191 };
192
193 #endif