]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
Merge branch 'Dev_0.6' of newgeom:newgeom into Dev_0.6
[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 <ModelAPI_CompositeFeature.h>
12
13 #include <StdSelect_FaceFilter.hxx>
14 #include <TopoDS_Shape.hxx>
15
16 #include <QMap>
17 #include <QObject>
18
19 #include <string>
20
21 #include <memory>
22
23 class ModuleBase_Operation;
24 class ModuleBase_IViewWindow;
25
26 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
27 {
28 Q_OBJECT
29
30  public:
31   PartSet_Module(ModuleBase_IWorkshop* theWshop);
32   virtual ~PartSet_Module();
33
34   /// Reads description of features from XML file 
35   //virtual void createFeatures();
36
37   /// Called on creation of menu item in desktop
38   //virtual void featureCreated(QAction* theFeature);
39
40   //std::string featureFile(const std::string&);
41
42   /// Creates an operation and send it to loop
43   /// \param theCmdId the operation name
44   //virtual void launchOperation(const QString& theCmdId);
45
46   /// Updates current operation preview, if it has it.
47   /// \param theCmdId the operation name
48   //void updateCurrentPreview(const std::string& theCmdId);
49
50   /// Creates custom widgets for property panel
51   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
52                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,
53                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
54
55   //XGUI_Workshop* xWorkshop() const;
56
57
58   /// Returns list of selection modes for the given object for sketch operation
59   //static QIntList sketchSelectionModes(ObjectPtr theFeature);
60
61   /// Call back forlast tuning of property panel before operation performance
62   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
63
64   QStringList sketchOperationIdList() const;
65
66  public slots:
67   //void onFeatureTriggered();
68   /// SLOT, that is called after the operation is started. Connect on the focus activated signal
69   //void onOperationStarted(ModuleBase_Operation* theOperation);
70   /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
71   /// by the operation start
72   //void onOperationStopped(ModuleBase_Operation* theOperation);
73   /// SLOT, that is called afetr the popup menu action clicked.
74   //void onContextMenuCommand(const QString& theId, bool isChecked);
75
76   /// SLOT, to apply to the current viewer the operation
77   /// \param theX the X projection value
78   /// \param theY the Y projection value
79   /// \param theZ the Z projection value
80   //void onPlaneSelected(double theX, double theY, double theZ);
81
82   /// SLOT, to fit all current viewer
83   //void onFitAllView();
84
85   //void onRestartOperation(std::string theName, ObjectPtr theFeature);
86
87   /// SLOT, to switch on/off the multi selection in the viewer
88   /// \param theEnabled the enabled state
89   //void onMultiSelectionEnabled(bool theEnabled);
90
91   /// SLOT, to stop or start selection mode for the features
92   /// \param theFeatures a list of features to be disabled
93   /// \param theToStop the boolean state whether it it stopped or non stopped
94   //void onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop);
95
96   /// SLOT, to set selection
97   /// \param theFeatures a list of features to be selected
98   //void onSetSelection(const QList<ObjectPtr>& theFeatures);
99
100   /// SLOT, Defines Sketch editing mode
101   /// \param thePln - plane of current sketch
102   //void setSketchingMode(const gp_Pln& thePln);
103
104   /// SLOT, to visualize the feature in another local context mode
105   /// \param theFeature the feature to be put in another local context mode
106   /// \param theMode the mode appeared on the feature
107   //void onFeatureConstructed(ObjectPtr theFeature, int theMode);
108
109   /// Slot which reacts to the point 2d set to the feature. Creates a constraint
110   /// \param the feature
111   /// \param the attribute of the feature
112   //void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
113
114   /// Called when sketch is launched
115   //void onSketchLaunched();
116
117 protected slots:
118   /// Called when previous operation is finished
119   virtual void onOperationComitted(ModuleBase_Operation* theOperation);
120
121   virtual void onOperationAborted(ModuleBase_Operation* theOperation);
122
123   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
124
125   virtual void onOperationStopped(ModuleBase_Operation* theOperation);
126
127   /// Called when previous operation is finished
128   virtual void onSelectionChanged();
129
130   /// Called on selection changed event
131   //virtual void onSelectionChanged();
132
133   /// SLOT, that is called by mouse press in the viewer.
134   /// The mouse released point is sent to the current operation to be processed.
135   /// \param theEvent the mouse event
136   void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
137
138   /// SLOT, that is called by mouse release in the viewer.
139   /// The mouse released point is sent to the current operation to be processed.
140   /// \param theEvent the mouse event
141   virtual void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
142   
143   /// SLOT, that is called by mouse move in the viewer.
144   /// The mouse moved point is sent to the current operation to be processed.
145   /// \param theEvent the mouse event
146   virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
147
148   /// SLOT, that is called by the mouse double click in the viewer.
149   /// \param theEvent the mouse event
150   //virtual void onMouseDoubleClick(QMouseEvent* theEvent);
151
152   /// SLOT, that is called by the key in the viewer is clicked.
153   /// \param theEvent the mouse event
154   //virtual void onKeyRelease(QKeyEvent* theEvent);
155
156   /// Launches the operation from current highlighting
157   void launchEditing();
158
159  protected:
160   /// Register validators for this module
161   virtual void registerValidators();
162
163   /// Returns new instance of operation object (used in createOperation for customization)
164   //virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
165
166   //! Edits the feature
167   //void editFeature(FeaturePtr theFeature);
168
169   //gp_Pln getSketchPlane(FeaturePtr theSketch) const;
170
171  private slots:
172    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
173
174  private:
175    /// Converts mouse position to 2d coordinates. 
176    /// Member myCurrentSketch has to be correctly defined
177   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
178                   double& theX, double& theY);
179
180   /// Breaks sequense of automatically resterted operations
181   void breakOperationSequence();
182
183   //XGUI_Workshop* myWorkshop;
184   //PartSet_Listener* myListener;
185
186   //std::map<std::string, std::string> myFeaturesInFiles;
187
188   //Handle(StdSelect_FaceFilter) myPlaneFilter;
189   //Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
190    QString myLastOperationId;
191    FeaturePtr myLastFeature;
192
193    bool myIsDragging;
194    bool myDragDone;
195
196    // Automatical restarting mode flag
197    bool myRestartingMode;
198
199    double myCurX, myCurY;
200    CompositeFeaturePtr myCurrentSketch;
201    QList<FeaturePtr> myEditingFeatures;
202 };
203
204 #endif