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