From 72ad214819b1216de72d3f9fa82d4278edbb1072 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 21 May 2014 11:02:41 +0400 Subject: [PATCH] refs #30 - Sketch base GUI: create, draw lines According to the document, the start position of line should be changed by the mouse cursor move. --- src/PartSet/PartSet_OperationSketchLine.cpp | 26 +++++++++++++++++---- src/PartSet/PartSet_OperationSketchLine.h | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index dc67cae98..36c969305 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -147,9 +147,7 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3 break; case SM_SecondPoint: { setLinePoint(feature(), aX, anY, LINE_ATTR_END); - commit(); - emit featureConstructed(feature(), FM_Deactivation); - emit launchOperation(PartSet_OperationSketchLine::Type(), feature()); + myPointSelectionMode = SM_DonePoint; } break; default: @@ -161,12 +159,26 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V { switch (myPointSelectionMode) { + case SM_FirstPoint: { + double aX, anY; + gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); + PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY); + setLinePoint(feature(), aX, anY, LINE_ATTR_START); + setLinePoint(feature(), aX, anY, LINE_ATTR_END); + } + break; case SM_SecondPoint: { gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); setLinePoint(aPoint, theView, LINE_ATTR_END); } break; + case SM_DonePoint: + { + commit(); + emit featureConstructed(feature(), FM_Deactivation); + emit launchOperation(PartSet_OperationSketchLine::Type(), feature()); + } default: break; } @@ -176,7 +188,13 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey) { switch (theKey) { case Qt::Key_Return: { - abort(); + if (myPointSelectionMode == SM_DonePoint) + { + commit(); + emit featureConstructed(feature(), FM_Deactivation); + } + else + abort(); emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr()); } break; diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index e6cabaa88..09c33f6f4 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -128,7 +128,7 @@ protected: protected: ///< Structure to lists the possible types of point selection modes - enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint}; + enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_DonePoint}; private: boost::shared_ptr mySketch; ///< the sketch feature -- 2.39.2