Salome HOME
#1318 Collinear and coinciding point constraints : the cash should be cleared before...
[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 class CAM_Study;
22
23 /** 
24  * \ingroup Salome
25  * An implementation of SALOME connector class for implementation of
26  * XGUI functionality as a module of SALOME
27  */
28 class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector
29 {
30 Q_OBJECT
31  public:
32   NewGeom_Module();
33   virtual ~NewGeom_Module();
34
35   //----- LightAPP_Module interface ---------------
36
37   /// \brief Initializing of the module
38   /// \param theApp application instance
39   virtual void initialize(CAM_Application* theApp);
40
41   /// \brief Definition of module standard windows
42   virtual void windows(QMap<int, int>& theWndMap) const;
43
44   /// \brief Definition of module viewer 
45   virtual void viewManagers(QStringList& theList) const;
46
47   /// \brief The method is called on selection changed event
48   virtual void selectionChanged();
49
50   //--- XGUI connector interface -----
51
52   virtual QAction* addFeature(const QString& theWBName, const QString& theId,
53                               const QString& theTitle, const QString& theTip, const QIcon& theIcon,
54                               const QKeySequence& theKeys = QKeySequence(),
55                               bool isCheckable = false);
56
57   //! Add feature (QAction) in the \a theWBName toolbar with given \a theInfo about action
58   virtual QAction* addFeature(const QString& theWBName,
59                               const ActionInfo& theInfo);
60
61   /// Add a nested feature
62   /// \param theWBName a workbench name
63   /// \param theInfo the action  parameters
64   /// \param theNestedActions a list of nested actions
65   virtual QAction* addFeatureOfNested(const QString& theWBName,
66                                     const ActionInfo& theInfo,
67                                     const QList<QAction*>& theNestedActions);
68
69   //! Returns true if the feature action is a nested action, in other words,
70   //! it is created by addNestedFeature().
71   //! \param theAction - an action of a feature
72   //! returns boolean result
73   virtual bool isFeatureOfNested(const QAction* theAction);
74
75   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
76                                      const QString& theTip, const QIcon& theIcon,
77                                      const QKeySequence& theKeys, bool isCheckable,
78                                      const char* theMenuSourceText,
79                                      const int theMenuPosition = 10);
80
81   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
82                                        const int theMenuPosition = 10);
83
84   /// Add an action to a tool bar
85   /// \param theAction an ation to add
86   /// \param theToolBarTitle a name of tool bar
87   virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
88     
89   virtual QMainWindow* desktop() const;
90
91   virtual QString commandId(const QAction* theCmd) const;
92
93   virtual QAction* command(const QString& theId) const;
94
95   //! Set nested actions dependent on command Id
96   //! \param theId - the command ID
97   //! \param theActions - the list of nested actions
98   virtual void setNestedActions(const QString& theId, const QStringList& theActions);
99
100   //! Returns list of nested actions according to the given command ID
101   virtual QStringList nestedActions(const QString& theId) const;
102
103   //! Set the document kind of the action by the given command Id
104   //! \param theId - the command ID
105   //! \param theKind - the document kind
106   virtual void setDocumentKind(const QString& theId, const QString& theKind);
107
108   //! Returns the document kind of the action by the given command ID
109   virtual QString documentKind(const QString& theId) const;
110
111   //! Returns interface to Salome viewer
112   virtual ModuleBase_IViewer* viewer() const
113   {
114     return myProxyViewer;
115   }
116
117   //! Returns list of defined actions (just by NewGeom module)
118   virtual QList<QAction*> commandList() const;
119
120   //! Returns list of Ids of defined actions (just by NewGeom module)
121   virtual QStringList commandIdList() const;
122
123   /// Redefinition of virtual function. 
124   /// \param theClient name of pop-up client
125   /// \param theMenu popup menu instance
126   /// \param theTitle menu title.
127   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
128
129   /// Redefinition of virtual function for preferences creation. 
130   virtual void createPreferences();
131
132   /// Redefinition of virtual function for preferences changed event. 
133   virtual void preferencesChanged(const QString& theSection, const QString& theParam);
134   
135   /// \return Workshop class instance
136   XGUI_Workshop* workshop() const { return myWorkshop; }
137
138   /// \brief Set flag about opened document state
139   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
140
141   /// Register current modules of SALOME
142   void inspectSalomeModules();
143
144  public slots:
145   /// \brief The method is redefined to connect to the study viewer before the data
146   /// model is filled by opened file. This file open will flush redisplay signals for,
147   /// objects which should be visualized
148   virtual void connectToStudy(CAM_Study* theStudy);
149
150    /// \brief The method is called on the module activation
151    /// \param theStudy current study
152   virtual bool activateModule(SUIT_Study* theStudy);
153
154    /// \brief The method is called on the module activation
155    /// \param theStudy current study
156   virtual bool deactivateModule(SUIT_Study* theStudy);
157
158  protected slots:
159    /// Redefinition of virtual function
160    /// \param theMgr view manager
161   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
162
163    /// Redefinition of virtual function
164    /// \param theMgr view manager
165   virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
166
167   /// Set preferences to default
168   void onDefaultPreferences();
169
170   /// Obtains the current application and updates its actions
171   void onUpdateCommandStatus();
172
173  protected:
174    /// Create data model
175   CAM_DataModel* createDataModel();
176
177   /// Create popup menu manager
178   virtual QtxPopupMgr* popupMgr();
179
180   /// Abort all operations
181   virtual bool abortAllOperations();
182
183  private:
184    /// Create selector for OCC Viewer
185    /// \param theMgr view manager
186   NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
187
188   /// List of registered actions
189   QStringList myActionsList;
190
191   /// Reference to workshop
192   XGUI_Workshop* myWorkshop;
193
194   /// OCC viewer selector instance
195   NewGeom_OCCSelector* mySelector;
196
197   /// Proxy viewer for connection to OCC Viewer in SALOME
198   NewGeom_SalomeViewer* myProxyViewer;
199
200   /// Map of nested actions [ActionID: list of nested actions Id]
201   QMap<QString, QStringList> myNestedActions;
202
203   /// Map of document types
204   QMap<QString, QString> myDocumentType;
205
206   /// Flag of opened document state
207   bool myIsOpened;
208
209   // the next parameters should be restored after this module deactivation
210
211   /// The application value of the preferences parameter
212   bool myIsStorePositions; 
213
214   /// The application value
215   bool myIsEditEnabled;    
216
217   /// Popup manager
218   QtxPopupMgr* myPopupMgr;
219 };
220
221 #endif