1 // File: PartSet_OperationFeatureBase.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_OperationFeatureBase.h>
7 #include <PartSet_Tools.h>
8 #include <PartSet_OperationSketch.h>
10 #include <SketchPlugin_Feature.h>
11 #include <SketchPlugin_Point.h>
12 #include <SketchPlugin_Line.h>
13 #include <SketchPlugin_Circle.h>
14 #include <SketchPlugin_Arc.h>
15 #include <SketchPlugin_ConstraintDistance.h>
16 #include <SketchPlugin_ConstraintLength.h>
17 #include <SketchPlugin_ConstraintRadius.h>
18 #include <SketchPlugin_ConstraintParallel.h>
19 #include <SketchPlugin_ConstraintPerpendicular.h>
20 #include <SketchPlugin_ConstraintCoincidence.h>
22 #include <GeomAPI_Pnt2d.h>
24 #include <ModuleBase_OperationDescription.h>
25 #include <ModuleBase_WidgetPoint2D.h>
26 #include <ModuleBase_WidgetValueFeature.h>
27 #include "ModuleBase_IPropertyPanel.h"
29 #include <XGUI_Constants.h>
31 #include <V3d_View.hxx>
32 #include <TopoDS_Vertex.hxx>
34 #include <BRep_Tool.hxx>
41 #include <QMouseEvent>
45 PartSet_OperationFeatureBase::PartSet_OperationFeatureBase(const QString& theId,
47 FeaturePtr theFeature)
48 : PartSet_OperationSketchBase(theId, theParent),
53 PartSet_OperationFeatureBase::~PartSet_OperationFeatureBase()
57 FeaturePtr PartSet_OperationFeatureBase::sketch() const
62 void PartSet_OperationFeatureBase::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
63 const std::list<ModuleBase_ViewerPrs>& theSelected,
64 const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
66 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
67 double aX = aPoint.X(), anY = aPoint.Y();
69 if (theSelected.empty()) {
70 PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
72 ModuleBase_ViewerPrs aPrs = theSelected.front();
73 const TopoDS_Shape& aShape = aPrs.shape();
74 if (!aShape.IsNull()) {
75 if (aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected
76 const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
77 if (!aVertex.IsNull()) {
78 aPoint = BRep_Tool::Pnt(aVertex);
79 PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
80 ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
81 PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY);
83 } else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
84 PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
89 if (!theSelected.empty()) {
90 ModuleBase_ViewerPrs aPrs = theSelected.front();
91 aFeature = aPrs.object();
93 aFeature = feature(); // for the widget distance only
96 bool isApplyed = setWidgetValue(aFeature, aX, anY);
99 myPropertyPanel->activateNextWidget();
104 /*bool PartSet_OperationFeatureBase::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
106 ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
109 ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
110 aValue->setObject(theFeature);
111 aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
112 bool isApplyed = aActiveWgt->setValue(aValue);
115 myIsModified = (myIsModified || isApplyed);