1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
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>
13 #include <StdSelect_FaceFilter.hxx>
14 #include <TopoDS_Shape.hxx>
23 class ModuleBase_Operation;
24 class ModuleBase_IViewWindow;
26 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
31 PartSet_Module(ModuleBase_IWorkshop* theWshop);
32 virtual ~PartSet_Module();
34 /// Reads description of features from XML file
35 //virtual void createFeatures();
37 /// Called on creation of menu item in desktop
38 //virtual void featureCreated(QAction* theFeature);
40 //std::string featureFile(const std::string&);
42 /// Creates an operation and send it to loop
43 /// \param theCmdId the operation name
44 //virtual void launchOperation(const QString& theCmdId);
46 /// Updates current operation preview, if it has it.
47 /// \param theCmdId the operation name
48 //void updateCurrentPreview(const std::string& theCmdId);
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);
55 //XGUI_Workshop* xWorkshop() const;
58 /// Returns list of selection modes for the given object for sketch operation
59 //static QIntList sketchSelectionModes(ObjectPtr theFeature);
61 /// Call back forlast tuning of property panel before operation performance
62 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
64 QStringList sketchOperationIdList() const;
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);
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);
82 /// SLOT, to fit all current viewer
83 //void onFitAllView();
85 //void onRestartOperation(std::string theName, ObjectPtr theFeature);
87 /// SLOT, to switch on/off the multi selection in the viewer
88 /// \param theEnabled the enabled state
89 //void onMultiSelectionEnabled(bool theEnabled);
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);
96 /// SLOT, to set selection
97 /// \param theFeatures a list of features to be selected
98 //void onSetSelection(const QList<ObjectPtr>& theFeatures);
100 /// SLOT, Defines Sketch editing mode
101 /// \param thePln - plane of current sketch
102 //void setSketchingMode(const gp_Pln& thePln);
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);
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);
114 /// Called when sketch is launched
115 //void onSketchLaunched();
118 /// Called when previous operation is finished
119 virtual void onOperationComitted(ModuleBase_Operation* theOperation);
121 virtual void onOperationAborted(ModuleBase_Operation* theOperation);
123 virtual void onOperationStarted(ModuleBase_Operation* theOperation);
125 virtual void onOperationStopped(ModuleBase_Operation* theOperation);
127 /// Called when previous operation is finished
128 virtual void onSelectionChanged();
130 /// Called on selection changed event
131 //virtual void onSelectionChanged();
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);
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);
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);
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);
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);
156 /// Launches the operation from current highlighting
157 void launchEditing();
160 /// Register validators for this module
161 virtual void registerValidators();
163 /// Returns new instance of operation object (used in createOperation for customization)
164 //virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
166 //! Edits the feature
167 //void editFeature(FeaturePtr theFeature);
169 //gp_Pln getSketchPlane(FeaturePtr theSketch) const;
172 void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
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);
180 /// Breaks sequense of automatically resterted operations
181 void breakOperationSequence();
183 //XGUI_Workshop* myWorkshop;
184 //PartSet_Listener* myListener;
186 //std::map<std::string, std::string> myFeaturesInFiles;
188 //Handle(StdSelect_FaceFilter) myPlaneFilter;
189 //Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
190 QString myLastOperationId;
191 FeaturePtr myLastFeature;
196 // Automatical restarting mode flag
197 bool myRestartingMode;
199 double myCurX, myCurY;
200 CompositeFeaturePtr myCurrentSketch;
201 QList<FeaturePtr> myEditingFeatures;