Salome HOME
Issue #1383 Preview button: compilation correction on Linux
[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);
56
57   //! Add feature (QAction) in the \a theWBName toolbar with given \a theInfo about action
58   virtual QAction* addFeature(const QString& theWBName,
59                               const ActionInfo& theInfo);
60
61   /// Add a nested feature
62   /// \param theWBName a workbench name
63   /// \param theInfo the action  parameters
64   /// \param theNestedActions a list of nested actions
65   virtual QAction* addFeatureOfNested(const QString& theWBName,
66                                     const ActionInfo& theInfo,
67                                     const QList<QAction*>& theNestedActions);
68
69   //! Returns true if the feature action is a nested action, in other words,
70   //! it is created by addNestedFeature().
71   //! \param theAction - an action of a feature
72   //! returns boolean result
73   virtual bool isFeatureOfNested(const QAction* theAction);
74
75   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
76                                      const QString& theTip, const QIcon& theIcon,
77                                      const QKeySequence& theKeys, bool isCheckable,
78                                      const char* theMenuSourceText,
79                                      const int theMenuPosition = 10);
80
81   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
82                                        const int theMenuPosition = 10);
83
84   /// Add an action to a tool bar
85   /// \param theAction an ation to add
86   /// \param theToolBarTitle a name of tool bar
87   virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
88     
89   virtual QMainWindow* desktop() const;
90
91   virtual QString commandId(const QAction* theCmd) const;
92
93   virtual QAction* command(const QString& theId) 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   //! Returns list of Ids of defined actions (just by SHAPER module)
116   virtual QStringList commandIdList() const;
117
118   /// Redefinition of virtual function. 
119   /// \param theClient name of pop-up client
120   /// \param theMenu popup menu instance
121   /// \param theTitle menu title.
122   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
123
124   /// Redefinition of virtual function for preferences creation. 
125   virtual void createPreferences();
126
127   /// Redefinition of virtual function for preferences changed event. 
128   virtual void preferencesChanged(const QString& theSection, const QString& theParam);
129   
130   /// \return Workshop class instance
131   XGUI_Workshop* workshop() const { return myWorkshop; }
132
133   /// \brief Set flag about opened document state
134   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
135
136   /// Register current modules of SALOME
137   void inspectSalomeModules();
138
139  public slots:
140   /// \brief The method is redefined to connect to the study viewer before the data
141   /// model is filled by opened file. This file open will flush redisplay signals for,
142   /// objects which should be visualized
143   virtual void connectToStudy(CAM_Study* theStudy);
144
145    /// \brief The method is called on the module activation
146    /// \param theStudy current study
147   virtual bool activateModule(SUIT_Study* theStudy);
148
149    /// \brief The method is called on the module activation
150    /// \param theStudy current study
151   virtual bool deactivateModule(SUIT_Study* theStudy);
152
153  protected slots:
154    /// Redefinition of virtual function
155    /// \param theMgr view manager
156   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
157
158    /// Redefinition of virtual function
159    /// \param theMgr view manager
160   virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
161
162   /// Set preferences to default
163   void onDefaultPreferences();
164
165   /// Obtains the current application and updates its actions
166   void onUpdateCommandStatus();
167
168  protected:
169    /// Create data model
170   CAM_DataModel* createDataModel();
171
172   /// Create popup menu manager
173   virtual QtxPopupMgr* popupMgr();
174
175   /// Abort all operations
176   virtual bool abortAllOperations();
177
178  private:
179    /// Create selector for OCC Viewer
180    /// \param theMgr view manager
181   SHAPERGUI_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
182
183   /// List of registered actions
184   QStringList myActionsList;
185
186   /// Reference to workshop
187   XGUI_Workshop* myWorkshop;
188
189   /// OCC viewer selector instance
190   SHAPERGUI_OCCSelector* mySelector;
191
192   /// Proxy viewer for connection to OCC Viewer in SALOME
193   SHAPERGUI_SalomeViewer* myProxyViewer;
194
195   /// Map of feature kind to a container of XML properties for the feature
196   QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
197
198   /// Flag of opened document state
199   bool myIsOpened;
200
201   // the next parameters should be restored after this module deactivation
202
203   /// The application value of the preferences parameter
204   bool myIsStorePositions; 
205
206   /// The application value
207   bool myIsEditEnabled;    
208
209   /// Popup manager
210   QtxPopupMgr* myPopupMgr;
211 };
212
213 #endif