Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3
4 #ifndef SHAPERGUI_H
5 #define SHAPERGUI_H
6
7 #include "SHAPER_SHAPERGUI.h"
8 #include "SHAPERGUI_SalomeViewer.h"
9
10 #include <LightApp_Module.h>
11 #include <XGUI_SalomeConnector.h>
12
13 #include <ModuleBase_ActionInfo.h>
14
15 #include <QStringList>
16 #include <QMap>
17
18 class XGUI_Workshop;
19 class SHAPERGUI_OCCSelector;
20 class OCCViewer_Viewer;
21 class CAM_Study;
22
23 /** 
24  * \ingroup Salome
25  * An implementation of SALOME connector class for implementation of
26  * XGUI functionality as a module of SALOME
27  */
28 class SHAPERGUI_EXPORT SHAPERGUI : public LightApp_Module, public XGUI_SalomeConnector
29 {
30 Q_OBJECT
31  public:
32   SHAPERGUI();
33   virtual ~SHAPERGUI();
34
35   //----- LightAPP_Module interface ---------------
36
37   /// \brief Initializing of the module
38   /// \param theApp application instance
39   virtual void initialize(CAM_Application* theApp);
40
41   /// \brief Definition of module standard windows
42   virtual void windows(QMap<int, int>& theWndMap) const;
43
44   /// \brief Definition of module viewer
45   virtual void viewManagers(QStringList& theList) const;
46
47   /// \brief The method is called on selection changed event
48   virtual void selectionChanged();
49
50   //--- XGUI connector interface -----
51
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                               const QString& theStatusTip);
57
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
62   /// Add a nested feature
63   /// \param theWBName a workbench name
64   /// \param theInfo the action  parameters
65   /// \param theNestedActions a list of nested actions
66   virtual QAction* addFeatureOfNested(const QString& theWBName,
67                                     const ActionInfo& theInfo,
68                                     const QList<QAction*>& theNestedActions);
69
70   //! Returns true if the feature action is a nested action, in other words,
71   //! it is created by addNestedFeature().
72   //! \param theAction - an action of a feature
73   //! returns boolean result
74   virtual bool isFeatureOfNested(const QAction* theAction);
75
76   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
77                                      const QString& theTip, const QIcon& theIcon,
78                                      const QKeySequence& theKeys, bool isCheckable,
79                                      const char* theMenuSourceText,
80                                      const int theMenuPosition = 10);
81
82   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
83                                        const int theMenuPosition = 10);
84
85   /// Add an action to a tool bar
86   /// \param theAction an ation to add
87   /// \param theToolBarTitle a name of tool bar
88   virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
89
90   /// Creates menu/tool bar actions for loaded features stored in the menu manager
91   virtual void createFeatureActions();
92
93   virtual QMainWindow* desktop() const;
94
95   //! Stores XML information for the feature kind
96   //! \param theFeatureId a feature kind
97   //! \param theMessage a container of the feature XML properties
98   virtual void setFeatureInfo(const QString& theFeatureId,
99                               const std::shared_ptr<Config_FeatureMessage>& theMessage);
100
101   //! Returns XML information for the feature kind
102   //! \param theFeatureId a feature kind
103   //! \return theMessage a container of the feature XML properties
104   virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId);
105
106   //! Returns interface to Salome viewer
107   virtual ModuleBase_IViewer* viewer() const
108   {
109     return myProxyViewer;
110   }
111
112   //! Returns list of defined actions (just by SHAPER module)
113   virtual QList<QAction*> commandList() const;
114
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);
120
121   /// Redefinition of virtual function for preferences creation.
122   virtual void createPreferences();
123
124   /// Redefinition of virtual function for preferences changed event.
125   virtual void preferencesChanged(const QString& theSection, const QString& theParam);
126
127   //! Shows the given text in status bar as a permanent text
128   //! \theInfo a string value
129   //! \theMsecs interval of msec milliseconds when the message will be hidden, if -1, it stays.
130   //            If 0, default value is used, it is 3000
131   virtual void putInfo(const QString& theInfo, const int theMSecs = 0);
132
133   /// \return Workshop class instance
134   XGUI_Workshop* workshop() const { return myWorkshop; }
135
136   /// \brief Set flag about opened document state
137   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
138
139   /// Register current modules of SALOME
140   void inspectSalomeModules();
141
142  public slots:
143   /// \brief The method is redefined to connect to the study viewer before the data
144   /// model is filled by opened file. This file open will flush redisplay signals for,
145   /// objects which should be visualized
146   virtual void connectToStudy(CAM_Study* theStudy);
147
148    /// \brief The method is called on the module activation
149    /// \param theStudy current study
150   virtual bool activateModule(SUIT_Study* theStudy);
151
152    /// \brief The method is called on the module activation
153    /// \param theStudy current study
154   virtual bool deactivateModule(SUIT_Study* theStudy);
155
156  protected slots:
157    /// Redefinition of virtual function
158    /// \param theMgr view manager
159   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
160
161    /// Redefinition of virtual function
162    /// \param theMgr view manager
163   virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
164
165   /// Set preferences to default
166   void onDefaultPreferences();
167
168   /// Obtains the current application and updates its actions
169   void onUpdateCommandStatus();
170
171  protected:
172    /// Create data model
173   CAM_DataModel* createDataModel();
174
175   /// Create popup menu manager
176   virtual QtxPopupMgr* popupMgr();
177
178   /// Abort all operations
179   virtual bool abortAllOperations();
180
181  private:
182    /// Create selector for OCC Viewer
183    /// \param theMgr view manager
184   SHAPERGUI_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
185
186   /// List of registered actions
187   QStringList myActionsList;
188
189   /// List of registered nested actions
190   QStringList myNestedActionsList;
191
192   /// Reference to workshop
193   XGUI_Workshop* myWorkshop;
194
195   /// OCC viewer selector instance
196   SHAPERGUI_OCCSelector* mySelector;
197
198   /// Proxy viewer for connection to OCC Viewer in SALOME
199   SHAPERGUI_SalomeViewer* myProxyViewer;
200
201   /// Map of feature kind to a container of XML properties for the feature
202   QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
203
204   /// Flag of opened document state
205   bool myIsOpened;
206
207   // the next parameters should be restored after this module deactivation
208
209   /// The application value of the preferences parameter
210   bool myIsStorePositions;
211
212   /// The application value
213   bool myIsEditEnabled;
214
215   /// Popup manager
216   QtxPopupMgr* myPopupMgr;
217 };
218
219 #endif