Salome HOME
a3a188ad0347ff9a10f376b7bc06d3f382f84928
[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 <ModuleBase_IModule.h>
7 #include <ModuleBase_Definitions.h>
8 #include <ModuleBase_ViewerFilters.h>
9 #include <XGUI_Command.h>
10 #include <ModelAPI_Feature.h>
11 #include <StdSelect_FaceFilter.hxx>
12
13 #include <QMap>
14 #include <QObject>
15
16 #include <string>
17
18 #include <boost/shared_ptr.hpp>
19
20 class PartSet_Listener;
21 class ModelAPI_Feature;
22 class XGUI_ViewerPrs;
23 class XGUI_Workshop;
24 class ModuleBase_Operation;
25 class GeomAPI_AISObject;
26
27 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
28 {
29 Q_OBJECT
30
31  public:
32   PartSet_Module(ModuleBase_IWorkshop* theWshop);
33   virtual ~PartSet_Module();
34
35   /// Reads description of features from XML file 
36   virtual void createFeatures();
37
38   /// Called on creation of menu item in desktop
39   virtual void featureCreated(QAction* theFeature);
40
41   std::string featureFile(const std::string&);
42
43   /// Creates an operation and send it to loop
44   /// \param theCmdId the operation name
45   //virtual void launchOperation(const QString& theCmdId);
46
47   /// Updates current operation preview, if it has it.
48   /// \param theCmdId the operation name
49   void updateCurrentPreview(const std::string& theCmdId);
50
51   /// Creates custom widgets for property panel
52   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
53                                       Config_WidgetAPI* theWidgetApi,
54                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
55
56   XGUI_Workshop* xWorkshop() const;
57
58
59   /// Returns list of selection modes for the given object for sketch operation
60   static QIntList sketchSelectionModes(ObjectPtr theFeature);
61
62  public slots:
63   void onFeatureTriggered();
64   /// SLOT, that is called after the operation is started. Connect on the focus activated signal
65   void onOperationStarted(ModuleBase_Operation* theOperation);
66   /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
67   /// by the operation start
68   void onOperationStopped(ModuleBase_Operation* theOperation);
69   /// SLOT, that is called afetr the popup menu action clicked.
70   void onContextMenuCommand(const QString& theId, bool isChecked);
71
72   /// SLOT, to apply to the current viewer the operation
73   /// \param theX the X projection value
74   /// \param theY the Y projection value
75   /// \param theZ the Z projection value
76   void onPlaneSelected(double theX, double theY, double theZ);
77
78   /// SLOT, to fit all current viewer
79   void onFitAllView();
80
81   void onRestartOperation(std::string theName, ObjectPtr theFeature);
82
83   /// SLOT, to switch on/off the multi selection in the viewer
84   /// \param theEnabled the enabled state
85   void onMultiSelectionEnabled(bool theEnabled);
86
87   /// SLOT, to stop or start selection mode for the features
88   /// \param theFeatures a list of features to be disabled
89   /// \param theToStop the boolean state whether it it stopped or non stopped
90   void onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop);
91
92   /// SLOT, to set selection
93   /// \param theFeatures a list of features to be selected
94   void onSetSelection(const QList<ObjectPtr>& theFeatures);
95
96   /// SLOT, Defines Sketch editing mode
97   /// \param thePln - plane of current sketch
98   void setSketchingMode(const gp_Pln& thePln);
99
100   /// SLOT, to visualize the feature in another local context mode
101   /// \param theFeature the feature to be put in another local context mode
102   /// \param theMode the mode appeared on the feature
103   void onFeatureConstructed(ObjectPtr theFeature, int theMode);
104
105   /// Slot which reacts to the point 2d set to the feature. Creates a constraint
106   /// \param the feature
107   /// \param the attribute of the feature
108   void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
109
110   /// Called when sketch is launched
111   void onSketchLaunched();
112
113 protected slots:
114   /// Called on selection changed event
115   virtual void onSelectionChanged();
116
117   /// SLOT, that is called by mouse press in the viewer.
118   /// The mouse released point is sent to the current operation to be processed.
119   /// \param theEvent the mouse event
120   virtual void onMousePressed(QMouseEvent* theEvent);
121
122   /// SLOT, that is called by mouse release in the viewer.
123   /// The mouse released point is sent to the current operation to be processed.
124   /// \param theEvent the mouse event
125   virtual void onMouseReleased(QMouseEvent* theEvent);
126   
127   /// SLOT, that is called by mouse move in the viewer.
128   /// The mouse moved point is sent to the current operation to be processed.
129   /// \param theEvent the mouse event
130   virtual void onMouseMoved(QMouseEvent* theEvent);
131
132   /// SLOT, that is called by the mouse double click in the viewer.
133   /// \param theEvent the mouse event
134   virtual void onMouseDoubleClick(QMouseEvent* theEvent);
135
136   /// SLOT, that is called by the key in the viewer is clicked.
137   /// \param theEvent the mouse event
138   virtual void onKeyRelease(QKeyEvent* theEvent);
139
140  protected:
141   /// Creates a new operation
142   /// \param theCmdId the operation name
143   /// \param theFeatureKind a kind of feature to get the feature xml description
144   ModuleBase_Operation* createOperation(const std::string& theCmdId,
145                                         const std::string& theFeatureKind = "");
146
147
148  protected:
149   //! Edits the feature
150   void editFeature(FeaturePtr theFeature);
151
152   gp_Pln getSketchPlane(FeaturePtr theSketch) const;
153
154  private:
155   //XGUI_Workshop* myWorkshop;
156   PartSet_Listener* myListener;
157
158   std::map<std::string, std::string> myFeaturesInFiles;
159
160   Handle(StdSelect_FaceFilter) myPlaneFilter;
161   Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
162 };
163
164 #endif