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