X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationEditLine.cpp;h=f0049b007d46a956a908173655af8fda6266e2f6;hb=1d7a043abfadf964bf38802e8adb5a4773fec900;hp=1085f2d334f5c78ed88c801624abd1d20f2efe7b;hpb=24f1f22de48301869843dad2130f75a2c3947387;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index 1085f2d33..f0049b007 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include #include #include @@ -56,44 +58,66 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V if (!(theEvent->buttons() & Qt::LeftButton)) return; gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); - myCurPressed = aPoint; + myCurPoint.setPoint(aPoint); } -void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected) { if (!(theEvent->buttons() & Qt::LeftButton)) return; - - double aCurX, aCurY; - PartSet_Tools::ConvertTo2D(myCurPressed, mySketch, aCurX, aCurY); - - double aX, anY; gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); - PartSet_Tools::ConvertTo2D(aPoint, mySketch, aX, anY); - double aDeltaX = aX - aCurX; - double aDeltaY = anY - aCurY; - - moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_START); - moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_END); - myCurPressed = aPoint; + if (myCurPoint.myIsInitialized) { + double aCurX, aCurY; + PartSet_Tools::ConvertTo2D(myCurPoint.myPoint, mySketch, theView, aCurX, aCurY); + + double aX, anY; + PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, aX, anY); + + double aDeltaX = aX - aCurX; + double aDeltaY = anY - aCurY; + + moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_START); + moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_END); + + /*std::list::const_iterator anIt = theSelected.begin(), aLast = theSelected.end(); + for (; anIt != aLast; anIt++) { + boost::shared_ptr aFeature = (*anIt).feature(); + if (!aFeature) + continue; + moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_START); + moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_END); + }*/ + } + myCurPoint.setPoint(aPoint); } -void PartSet_OperationEditLine::setSelected(boost::shared_ptr theFeature, - const TopoDS_Shape& theShape) +void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected) { - if (theFeature == feature()) + boost::shared_ptr aFeature; + if (!theSelected.empty()) + aFeature = theSelected.front().feature(); + + if (aFeature == feature()) return; - + commit(); - - if (theFeature) - emit launchOperation(PartSet_OperationEditLine::Type(), theFeature); + if (aFeature) + emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); } void PartSet_OperationEditLine::startOperation() { // do nothing in order to do not create a new feature + emit selectionEnabled(false); + myCurPoint.clear(); +} + +void PartSet_OperationEditLine::stopOperation() +{ + emit selectionEnabled(true); } boost::shared_ptr PartSet_OperationEditLine::createFeature() @@ -102,10 +126,14 @@ boost::shared_ptr PartSet_OperationEditLine::createFeature() return boost::shared_ptr(); } -void PartSet_OperationEditLine::moveLinePoint(double theDeltaX, double theDeltaY, +void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr theFeature, + double theDeltaX, double theDeltaY, const std::string& theAttribute) { - boost::shared_ptr aData = feature()->data(); + if (!theFeature) + return; + + boost::shared_ptr aData = theFeature->data(); boost::shared_ptr aPoint = boost::dynamic_pointer_cast(aData->attribute(theAttribute));