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