1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
7 #include "SHAPER_SHAPERGUI.h"
8 #include "SHAPERGUI_SalomeViewer.h"
10 #include <LightApp_Module.h>
11 #include <XGUI_SalomeConnector.h>
13 #include <ModuleBase_ActionInfo.h>
15 #include <QStringList>
19 class SHAPERGUI_OCCSelector;
20 class OCCViewer_Viewer;
25 * An implementation of SALOME connector class for implementation of
26 * XGUI functionality as a module of SALOME
28 class SHAPERGUI_EXPORT SHAPERGUI : public LightApp_Module, public XGUI_SalomeConnector
35 //----- LightAPP_Module interface ---------------
37 /// \brief Initializing of the module
38 /// \param theApp application instance
39 virtual void initialize(CAM_Application* theApp);
41 /// \brief Definition of module standard windows
42 virtual void windows(QMap<int, int>& theWndMap) const;
44 /// \brief Definition of module viewer
45 virtual void viewManagers(QStringList& theList) const;
47 /// \brief The method is called on selection changed event
48 virtual void selectionChanged();
50 //--- XGUI connector interface -----
52 virtual QAction* addFeature(const QString& theWBName, const QString& theId,
53 const QString& theTitle, const QString& theTip, const QIcon& theIcon,
54 const QKeySequence& theKeys = QKeySequence(),
55 bool isCheckable = false, const bool isAddSeparator = false,
56 bool isMenuAction = true, bool isToolAction = true);
58 //! Add feature (QAction) in the \a theWBName toolbar with given \a theInfo about action
59 virtual QAction* addFeature(const QString& theWBName,
60 const ActionInfo& theInfo, const bool isAddSeparator,
61 bool isMenuAction = true, bool isToolAction = true);
63 /// Add a nested feature
64 /// \param theWBName a workbench name
65 /// \param theInfo the action parameters
66 /// \param theNestedActions a list of nested actions
67 virtual QAction* addFeatureOfNested(const QString& theWBName,
68 const ActionInfo& theInfo,
69 const QList<QAction*>& theNestedActions,
70 bool isMenuAction = true, bool isToolAction = true);
72 //! Returns true if the feature action is a nested action, in other words,
73 //! it is created by addNestedFeature().
74 //! \param theAction - an action of a feature
75 //! returns boolean result
76 virtual bool isFeatureOfNested(const QAction* theAction);
78 virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
79 const QString& theTip, const QIcon& theIcon,
80 const QKeySequence& theKeys, bool isCheckable,
81 const char* theMenuSourceText,
82 const int theMenuPosition = 10);
84 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
85 const int theMenuPosition = 10);
87 /// Add an action to a tool bar
88 /// \param theAction an ation to add
89 /// \param theToolBarTitle a name of tool bar
90 virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
92 /// Creates menu/tool bar actions for loaded features stored in the menu manager
93 virtual void createFeatureActions();
95 virtual QMainWindow* desktop() const;
97 virtual QString commandId(const QAction* theCmd) const;
99 virtual QAction* command(const QString& theId) const;
101 //! Stores XML information for the feature kind
102 //! \param theFeatureId a feature kind
103 //! \param theMessage a container of the feature XML properties
104 virtual void setFeatureInfo(const QString& theFeatureId,
105 const std::shared_ptr<Config_FeatureMessage>& theMessage);
107 //! Returns XML information for the feature kind
108 //! \param theFeatureId a feature kind
109 //! \return theMessage a container of the feature XML properties
110 virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId);
112 //! Returns interface to Salome viewer
113 virtual ModuleBase_IViewer* viewer() const
115 return myProxyViewer;
118 //! Returns list of defined actions (just by SHAPER module)
119 virtual QList<QAction*> commandList() const;
121 //! Returns list of Ids of defined actions (just by SHAPER module)
122 virtual QStringList commandIdList() const;
124 /// Redefinition of virtual function.
125 /// \param theClient name of pop-up client
126 /// \param theMenu popup menu instance
127 /// \param theTitle menu title.
128 virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
130 /// Redefinition of virtual function for preferences creation.
131 virtual void createPreferences();
133 /// Redefinition of virtual function for preferences changed event.
134 virtual void preferencesChanged(const QString& theSection, const QString& theParam);
136 /// \return Workshop class instance
137 XGUI_Workshop* workshop() const { return myWorkshop; }
139 /// \brief Set flag about opened document state
140 void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
142 /// Register current modules of SALOME
143 void inspectSalomeModules();
146 /// \brief The method is redefined to connect to the study viewer before the data
147 /// model is filled by opened file. This file open will flush redisplay signals for,
148 /// objects which should be visualized
149 virtual void connectToStudy(CAM_Study* theStudy);
151 /// \brief The method is called on the module activation
152 /// \param theStudy current study
153 virtual bool activateModule(SUIT_Study* theStudy);
155 /// \brief The method is called on the module activation
156 /// \param theStudy current study
157 virtual bool deactivateModule(SUIT_Study* theStudy);
160 /// Redefinition of virtual function
161 /// \param theMgr view manager
162 virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
164 /// Redefinition of virtual function
165 /// \param theMgr view manager
166 virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
168 /// Set preferences to default
169 void onDefaultPreferences();
171 /// Obtains the current application and updates its actions
172 void onUpdateCommandStatus();
175 /// Create data model
176 CAM_DataModel* createDataModel();
178 /// Create popup menu manager
179 virtual QtxPopupMgr* popupMgr();
181 /// Abort all operations
182 virtual bool abortAllOperations();
185 /// Create selector for OCC Viewer
186 /// \param theMgr view manager
187 SHAPERGUI_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
189 /// List of registered actions
190 QStringList myActionsList;
192 /// Reference to workshop
193 XGUI_Workshop* myWorkshop;
195 /// OCC viewer selector instance
196 SHAPERGUI_OCCSelector* mySelector;
198 /// Proxy viewer for connection to OCC Viewer in SALOME
199 SHAPERGUI_SalomeViewer* myProxyViewer;
201 /// Map of feature kind to a container of XML properties for the feature
202 QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
204 /// Flag of opened document state
207 // the next parameters should be restored after this module deactivation
209 /// The application value of the preferences parameter
210 bool myIsStorePositions;
212 /// The application value
213 bool myIsEditEnabled;
216 QtxPopupMgr* myPopupMgr;