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;
21 * An implementation of SALOME connector class for implementation of
22 * XGUI functionality as a module of SALOME
24 class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector
29 virtual ~NewGeom_Module();
31 //----- LightAPP_Module interface ---------------
33 /// \brief Initializing of the module
34 /// \param theApp application instance
35 virtual void initialize(CAM_Application* theApp);
37 /// \brief Definition of module standard windows
38 virtual void windows(QMap<int, int>& theWndMap) const;
40 /// \brief Definition of module viewer
41 virtual void viewManagers(QStringList& theList) const;
43 /// \brief The method is called on selection changed event
44 virtual void selectionChanged();
46 //--- XGUI connector interface -----
48 virtual QAction* addFeature(const QString& theWBName, const QString& theId,
49 const QString& theTitle, const QString& theTip, const QIcon& theIcon,
50 const QKeySequence& theKeys = QKeySequence(),
51 bool isCheckable = false);
53 virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
54 const QString& theTip, const QIcon& theIcon,
55 const QKeySequence& theKeys, bool isCheckable,
56 const char* theMenuSourceText,
57 const int theMenuPosition = 10);
59 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
60 const int theMenuPosition = 10);
62 virtual QMainWindow* desktop() const;
64 virtual QString commandId(const QAction* theCmd) const;
66 virtual QAction* command(const QString& theId) const;
68 //! Set nested actions dependent on command Id
69 //! \param theId - the command ID
70 //! \param theActions - the list of nested actions
71 virtual void setNestedActions(const QString& theId, const QStringList& theActions);
73 //! Returns list of nested actions according to the given command ID
74 virtual QStringList nestedActions(const QString& theId) const;
76 //! Set the document kind of the action by the given command Id
77 //! \param theId - the command ID
78 //! \param theKind - the document kind
79 virtual void setDocumentKind(const QString& theId, const QString& theKind);
81 //! Returns the document kind of the action by the given command ID
82 virtual QString documentKind(const QString& theId) const;
84 //! Returns interface to Salome viewer
85 virtual ModuleBase_IViewer* viewer() const
90 //! Returns list of defined actions (just by NewGeom module)
91 virtual QList<QAction*> commandList() const;
93 //! Returns list of Ids of defined actions (just by NewGeom module)
94 virtual QStringList commandIdList() const;
96 /// Redefinition of virtual function.
97 /// \param theClient name of pop-up client
98 /// \param theMenu popup menu instance
99 /// \param theTitle menu title.
100 virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
102 /// Redefinition of virtual function for preferences creation.
103 virtual void createPreferences();
105 /// Redefinition of virtual function for preferences changed event.
106 virtual void preferencesChanged(const QString& theSection, const QString& theParam);
108 /// \return Workshop class instance
109 XGUI_Workshop* workshop() const { return myWorkshop; }
111 /// \brief Set flag about opened document state
112 void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
114 /// Register current modules of SALOME
115 void inspectSalomeModules();
118 /// \brief The method is called on the module activation
119 /// \param theStudy current study
120 virtual bool activateModule(SUIT_Study* theStudy);
122 /// \brief The method is called on the module activation
123 /// \param theStudy current study
124 virtual bool deactivateModule(SUIT_Study* theStudy);
127 /// Redefinition of virtual function
128 /// \param theMgr view manager
129 virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
131 /// Redefinition of virtual function
132 /// \param theMgr view manager
133 virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
135 /// Set preferences to default
136 void onDefaultPreferences();
138 /// Obtains the current application and updates its actions
139 void onUpdateCommandStatus();
142 /// Create data model
143 CAM_DataModel* createDataModel();
145 /// Create popup menu manager
146 virtual QtxPopupMgr* popupMgr();
149 /// Create selector for OCC Viewer
150 /// \param theMgr view manager
151 NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
153 /// List of registered actions
154 QStringList myActionsList;
156 /// Reference to workshop
157 XGUI_Workshop* myWorkshop;
159 /// OCC viewer selector instance
160 NewGeom_OCCSelector* mySelector;
162 /// Proxy viewer for connection to OCC Viewer in SALOME
163 NewGeom_SalomeViewer* myProxyViewer;
165 /// Map of nested actions [ActionID: list of nested actions Id]
166 QMap<QString, QStringList> myNestedActions;
168 /// Map of document types
169 QMap<QString, QString> myDocumentType;
171 /// Flag of opened document state
174 // the next parameters should be restored after this module deactivation
176 /// The application value of the preferences parameter
177 bool myIsStorePositions;
179 /// The application value
180 bool myIsEditEnabled;
183 QtxPopupMgr* myPopupMgr;