+ if (!theFeature)
+ return;
+ // use the last point of the previous feature as the first of the new one
+ boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ myInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+}
+
+void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<XGUI_ViewerPrs>& theSelected)
+{
+ gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
+
+ if (!theSelected.empty()) {
+ XGUI_ViewerPrs aPrs = theSelected.front();
+ const TopoDS_Shape& aShape = aPrs.shape();
+ if (!aShape.IsNull()) {
+ if (aShape.ShapeType() == TopAbs_VERTEX) {
+ const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+ if (!aVertex.IsNull())
+ aPoint = BRep_Tool::Pnt(aVertex);
+ }
+ else if (aShape.ShapeType() == TopAbs_EDGE) {
+ boost::shared_ptr<ModelAPI_Feature> aFeature = aPrs.feature();
+ if (!aFeature)
+ return;
+ double X0, X1, X2, X3;
+ double Y0, Y1, Y2, Y3;
+ getLinePoint(aFeature, LINE_ATTR_START, X2, Y2);
+ getLinePoint(aFeature, LINE_ATTR_END, X3, Y3);
+
+ if (myPointSelectionMode == SM_SecondPoint) {
+ getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
+ PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, X1, Y1);
+
+ double aX, anY;
+ PartSet_Tools::IntersectLines(X0, Y0, X1, Y1, X2, Y2, X3, Y3, aX, anY);
+
+ setLinePoint(aX, anY, LINE_ATTR_END);
+ commit();
+ emit featureConstructed(feature(), FM_Deactivation);
+ emit launchOperation(PartSet_OperationSketchLine::Type(), feature());
+ return;
+ }
+
+ }
+ }
+ }
+