]> SALOME platform Git repositories - modules/shaper.git/blob - src/SHAPERGUI/SHAPERGUI.h
Salome HOME
Issue #1015: The validate icon must be greyed and inactive instead of red and active
[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
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, const bool isAddSeparator);
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   /// Creates menu/tool bar actions for loaded features stored in the menu manager
90   virtual void createFeatureActions();
91
92   virtual QMainWindow* desktop() const;
93
94   //! Stores XML information for the feature kind
95   //! \param theFeatureId a feature kind
96   //! \param theMessage a container of the feature XML properties
97   virtual void setFeatureInfo(const QString& theFeatureId,
98                               const std::shared_ptr<Config_FeatureMessage>& theMessage);
99
100   //! Returns XML information for the feature kind
101   //! \param theFeatureId a feature kind
102   //! \return theMessage a container of the feature XML properties
103   virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId);
104
105   //! Returns interface to Salome viewer
106   virtual ModuleBase_IViewer* viewer() const
107   {
108     return myProxyViewer;
109   }
110
111   //! Returns list of defined actions (just by SHAPER module)
112   virtual QList<QAction*> commandList() const;
113
114   /// Redefinition of virtual function. 
115   /// \param theClient name of pop-up client
116   /// \param theMenu popup menu instance
117   /// \param theTitle menu title.
118   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
119
120   /// Redefinition of virtual function for preferences creation. 
121   virtual void createPreferences();
122
123   /// Redefinition of virtual function for preferences changed event. 
124   virtual void preferencesChanged(const QString& theSection, const QString& theParam);
125
126   //! Shows the given text in status bar as a permanent text
127   //! \theInfo a string value
128   //! \theMsecs interval of msec milliseconds when the message will be hidden, if -1, it stays.
129   //            If 0, default value is used, it is 3000
130   virtual void putInfo(const QString& theInfo, const int theMSecs = 0);
131
132   /// \return Workshop class instance
133   XGUI_Workshop* workshop() const { return myWorkshop; }
134
135   /// \brief Set flag about opened document state
136   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
137
138   /// Register current modules of SALOME
139   void inspectSalomeModules();
140
141  public slots:
142   /// \brief The method is redefined to connect to the study viewer before the data
143   /// model is filled by opened file. This file open will flush redisplay signals for,
144   /// objects which should be visualized
145   virtual void connectToStudy(CAM_Study* theStudy);
146
147    /// \brief The method is called on the module activation
148    /// \param theStudy current study
149   virtual bool activateModule(SUIT_Study* theStudy);
150
151    /// \brief The method is called on the module activation
152    /// \param theStudy current study
153   virtual bool deactivateModule(SUIT_Study* theStudy);
154
155  protected slots:
156    /// Redefinition of virtual function
157    /// \param theMgr view manager
158   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
159
160    /// Redefinition of virtual function
161    /// \param theMgr view manager
162   virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
163
164   /// Set preferences to default
165   void onDefaultPreferences();
166
167   /// Obtains the current application and updates its actions
168   void onUpdateCommandStatus();
169
170  protected:
171    /// Create data model
172   CAM_DataModel* createDataModel();
173
174   /// Create popup menu manager
175   virtual QtxPopupMgr* popupMgr();
176
177   /// Abort all operations
178   virtual bool abortAllOperations();
179
180  private:
181    /// Create selector for OCC Viewer
182    /// \param theMgr view manager
183   SHAPERGUI_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
184
185   /// List of registered actions
186   QStringList myActionsList;
187
188   /// List of registered nested actions
189   QStringList myNestedActionsList;
190
191   /// Reference to workshop
192   XGUI_Workshop* myWorkshop;
193
194   /// OCC viewer selector instance
195   SHAPERGUI_OCCSelector* mySelector;
196
197   /// Proxy viewer for connection to OCC Viewer in SALOME
198   SHAPERGUI_SalomeViewer* myProxyViewer;
199
200   /// Map of feature kind to a container of XML properties for the feature
201   QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
202
203   /// Flag of opened document state
204   bool myIsOpened;
205
206   // the next parameters should be restored after this module deactivation
207
208   /// The application value of the preferences parameter
209   bool myIsStorePositions; 
210
211   /// The application value
212   bool myIsEditEnabled;    
213
214   /// Popup manager
215   QtxPopupMgr* myPopupMgr;
216 };
217
218 #endif