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