]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into SolveSpace
[modules/shaper.git] / src / PartSet / PartSet_Module.h
1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
3
4 #include "PartSet.h"
5
6 #include <XGUI_Module.h>
7 #include <XGUI_Command.h>
8
9 #include <QMap>
10 #include <QObject>
11
12 #include <string>
13
14 #include <boost/shared_ptr.hpp>
15
16 class QMouseEvent;
17 class QKeyEvent;
18 class PartSet_Listener;
19 class ModelAPI_Feature;
20 class XGUI_ViewerPrs;
21
22 class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module
23 {
24 Q_OBJECT
25
26 public:
27   PartSet_Module(XGUI_Workshop* theWshop);
28   virtual ~PartSet_Module();
29
30   /// Returns the module workshop
31   /// \returns a workshop instance
32   XGUI_Workshop* workshop() const;
33
34   virtual void createFeatures();
35   virtual void featureCreated(QAction* theFeature);
36   virtual QStringList nestedFeatures(QString theFeature);
37   std::string featureFile(const std::string&);
38
39   /// Creates an operation and send it to loop
40   /// \param theCmdId the operation name
41   virtual void launchOperation(const QString& theCmdId);
42
43   /// Displays or erase the current operation preview, if it has it.
44   /// \param theFeature the feature instance to be displayed
45   /// \param isDisplay the state whether the presentation should be displayed or erased
46   /// \param isUpdateViewer the flag whether the viewer should be updated
47   void visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFeature, bool isDisplay,
48                         const bool isUpdateViewer = true);
49
50   /// Activates the feature in the displayer
51   /// \param theFeature the feature instance to be displayed
52   /// \param isUpdateViewer the flag whether the viewer should be updated
53   void activateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature,
54                        const bool isUpdateViewer);
55
56   /// Updates current operation preview, if it has it.
57   /// \param theCmdId the operation name
58   void updateCurrentPreview(const std::string& theCmdId);
59
60 public slots:
61   void onFeatureTriggered();
62   /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
63   /// by the operation start
64   void onOperationStopped(ModuleBase_Operation* theOperation);
65   /// SLOT, that is called afetr the popup menu action clicked.
66   void onContextMenuCommand(const QString& theId, bool isChecked);
67   /// SLOT, that is called by mouse press in the viewer.
68   /// The mouse released point is sent to the current operation to be processed.
69   /// \param theEvent the mouse event
70   void onMousePressed(QMouseEvent* theEvent);
71   /// SLOT, that is called by mouse release in the viewer.
72   /// The mouse released point is sent to the current operation to be processed.
73   /// \param theEvent the mouse event
74   void onMouseReleased(QMouseEvent* theEvent);
75   /// SLOT, that is called by mouse move in the viewer.
76   /// The mouse moved point is sent to the current operation to be processed.
77   /// \param theEvent the mouse event
78   void onMouseMoved(QMouseEvent* theEvent);
79
80   /// SLOT, that is called by the key in the viewer is clicked.
81   /// \param theEvent the mouse event
82   void onKeyRelease(QKeyEvent*);
83
84   /// SLOT, to apply to the current viewer the operation
85   /// \param theX the X projection value
86   /// \param theY the Y projection value
87   /// \param theZ the Z projection value
88   void onPlaneSelected(double theX, double theY, double theZ);
89
90   void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
91
92   /// SLOT, to switch on/off the multi selection in the viewer
93   /// \param theEnabled the enabled state
94   void onMultiSelectionEnabled(bool theEnabled);
95
96   /// SLOT, to stop or start selection mode for the features
97   /// \param theFeatures a list of features to be disabled
98   /// \param theToStop the boolean state whether it it stopped or non stopped
99   void onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop);
100
101   /// SLOT, to set selection
102   /// \param theFeatures a list of features to be selected
103   void onSetSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
104
105   /// SLOT, to close the viewer local context
106   void onCloseLocalContext();
107
108   /// SLOT, to visualize the feature in another local context mode
109   /// \param theFeature the feature to be put in another local context mode
110   /// \param theMode the mode appeared on the feature
111   void onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
112                             int theMode);
113 protected:
114   /// Creates a new operation
115   /// \param theCmdId the operation name
116   ModuleBase_Operation* createOperation(const std::string& theCmdId);
117
118   /// Sends the operation
119   /// \param theOperation the operation
120   void sendOperation(ModuleBase_Operation* theOperation);
121
122 protected:
123   //! Edits the feature
124   void editFeature(FeaturePtr theFeature);
125
126 private:
127   XGUI_Workshop* myWorkshop;
128   PartSet_Listener* myListener;
129
130   std::map<std::string, std::string> myFeaturesInFiles;
131 };
132
133 #endif