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