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