1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 #ifndef NewGeom_Module_H
5 #define NewGeom_Module_H
8 #include "NewGeom_SalomeViewer.h"
10 #include <LightApp_Module.h>
11 #include <XGUI_SalomeConnector.h>
13 #include <ModuleBase_ActionInfo.h>
15 #include <QStringList>
19 class NewGeom_OCCSelector;
20 class OCCViewer_Viewer;
24 * An implementation of SALOME connector class for implementation of
25 * XGUI functionality as a module of SALOME
27 class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector
32 virtual ~NewGeom_Module();
34 //----- LightAPP_Module interface ---------------
36 /// \brief Initializing of the module
37 /// \param theApp application instance
38 virtual void initialize(CAM_Application* theApp);
40 /// \brief Definition of module standard windows
41 virtual void windows(QMap<int, int>& theWndMap) const;
43 /// \brief Definition of module viewer
44 virtual void viewManagers(QStringList& theList) const;
46 /// \brief The method is called on selection changed event
47 virtual void selectionChanged();
49 //--- XGUI connector interface -----
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);
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);
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);
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);
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);
80 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
81 const int theMenuPosition = 10);
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 );
88 virtual QMainWindow* desktop() const;
90 virtual QString commandId(const QAction* theCmd) const;
92 virtual QAction* command(const QString& theId) const;
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);
99 //! Returns list of nested actions according to the given command ID
100 virtual QStringList nestedActions(const QString& theId) const;
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);
107 //! Returns the document kind of the action by the given command ID
108 virtual QString documentKind(const QString& theId) const;
110 //! Returns interface to Salome viewer
111 virtual ModuleBase_IViewer* viewer() const
113 return myProxyViewer;
116 //! Returns list of defined actions (just by NewGeom module)
117 virtual QList<QAction*> commandList() const;
119 //! Returns list of Ids of defined actions (just by NewGeom module)
120 virtual QStringList commandIdList() const;
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);
128 /// Redefinition of virtual function for preferences creation.
129 virtual void createPreferences();
131 /// Redefinition of virtual function for preferences changed event.
132 virtual void preferencesChanged(const QString& theSection, const QString& theParam);
134 /// \return Workshop class instance
135 XGUI_Workshop* workshop() const { return myWorkshop; }
137 /// \brief Set flag about opened document state
138 void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
140 /// Register current modules of SALOME
141 void inspectSalomeModules();
144 /// \brief The method is called on the module activation
145 /// \param theStudy current study
146 virtual bool activateModule(SUIT_Study* theStudy);
148 /// \brief The method is called on the module activation
149 /// \param theStudy current study
150 virtual bool deactivateModule(SUIT_Study* theStudy);
153 /// Redefinition of virtual function
154 /// \param theMgr view manager
155 virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
157 /// Redefinition of virtual function
158 /// \param theMgr view manager
159 virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
161 /// Set preferences to default
162 void onDefaultPreferences();
164 /// Obtains the current application and updates its actions
165 void onUpdateCommandStatus();
168 /// Create data model
169 CAM_DataModel* createDataModel();
171 /// Create popup menu manager
172 virtual QtxPopupMgr* popupMgr();
174 /// Abort all operations
175 virtual bool abortAllOperations();
178 /// Create selector for OCC Viewer
179 /// \param theMgr view manager
180 NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
182 /// List of registered actions
183 QStringList myActionsList;
185 /// Reference to workshop
186 XGUI_Workshop* myWorkshop;
188 /// OCC viewer selector instance
189 NewGeom_OCCSelector* mySelector;
191 /// Proxy viewer for connection to OCC Viewer in SALOME
192 NewGeom_SalomeViewer* myProxyViewer;
194 /// Map of nested actions [ActionID: list of nested actions Id]
195 QMap<QString, QStringList> myNestedActions;
197 /// Map of document types
198 QMap<QString, QString> myDocumentType;
200 /// Flag of opened document state
203 // the next parameters should be restored after this module deactivation
205 /// The application value of the preferences parameter
206 bool myIsStorePositions;
208 /// The application value
209 bool myIsEditEnabled;
212 QtxPopupMgr* myPopupMgr;