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 <QStringList>
17 class NewGeom_OCCSelector;
18 class OCCViewer_Viewer;
22 * An implementation of SALOME connector class for implementation of
23 * XGUI functionality as a module of SALOME
25 class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector
30 virtual ~NewGeom_Module();
32 //----- LightAPP_Module interface ---------------
34 /// \brief Initializing of the module
35 /// \param theApp application instance
36 virtual void initialize(CAM_Application* theApp);
38 /// \brief Definition of module standard windows
39 virtual void windows(QMap<int, int>& theWndMap) const;
41 /// \brief Definition of module viewer
42 virtual void viewManagers(QStringList& theList) const;
44 /// \brief The method is called on selection changed event
45 virtual void selectionChanged();
47 //--- XGUI connector interface -----
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);
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);
60 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
61 const int theMenuPosition = 10);
63 virtual QMainWindow* desktop() const;
65 virtual QString commandId(const QAction* theCmd) const;
67 virtual QAction* command(const QString& theId) const;
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);
74 //! Returns list of nested actions according to the given command ID
75 virtual QStringList nestedActions(const QString& theId) const;
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);
82 //! Returns the document kind of the action by the given command ID
83 virtual QString documentKind(const QString& theId) const;
85 //! Returns interface to Salome viewer
86 virtual ModuleBase_IViewer* viewer() const
91 //! Returns list of defined actions (just by NewGeom module)
92 virtual QList<QAction*> commandList() const;
94 //! Returns list of Ids of defined actions (just by NewGeom module)
95 virtual QStringList commandIdList() const;
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);
103 /// Redefinition of virtual function for preferences creation.
104 virtual void createPreferences();
106 /// Redefinition of virtual function for preferences changed event.
107 virtual void preferencesChanged(const QString& theSection, const QString& theParam);
109 /// \return Workshop class instance
110 XGUI_Workshop* workshop() const { return myWorkshop; }
112 /// \brief Set flag about opened document state
113 void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
115 /// Register current modules of SALOME
116 void inspectSalomeModules();
119 /// \brief The method is called on the module activation
120 /// \param theStudy current study
121 virtual bool activateModule(SUIT_Study* theStudy);
123 /// \brief The method is called on the module activation
124 /// \param theStudy current study
125 virtual bool deactivateModule(SUIT_Study* theStudy);
128 /// Redefinition of virtual function
129 /// \param theMgr view manager
130 virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
132 /// Redefinition of virtual function
133 /// \param theMgr view manager
134 virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
136 /// Set preferences to default
137 void onDefaultPreferences();
139 /// Obtains the current application and updates its actions
140 void onUpdateCommandStatus();
143 /// Create data model
144 CAM_DataModel* createDataModel();
146 /// Create popup menu manager
147 virtual QtxPopupMgr* popupMgr();
150 /// Create selector for OCC Viewer
151 /// \param theMgr view manager
152 NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
154 /// List of registered actions
155 QStringList myActionsList;
157 /// Reference to workshop
158 XGUI_Workshop* myWorkshop;
160 /// OCC viewer selector instance
161 NewGeom_OCCSelector* mySelector;
163 /// Proxy viewer for connection to OCC Viewer in SALOME
164 NewGeom_SalomeViewer* myProxyViewer;
166 /// Map of nested actions [ActionID: list of nested actions Id]
167 QMap<QString, QStringList> myNestedActions;
169 /// Map of document types
170 QMap<QString, QString> myDocumentType;
172 /// Flag of opened document state
175 // the next parameters should be restored after this module deactivation
177 /// The application value of the preferences parameter
178 bool myIsStorePositions;
180 /// The application value
181 bool myIsEditEnabled;
184 QtxPopupMgr* myPopupMgr;