X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationEditLine.cpp;h=5486ffff028ff7ddc4aa93668172e25c2163746d;hb=e53354ef01af8360be76548c42fb15d46a471e0d;hp=5f7c7ebcaeb43ba48d9859ae80a7f4e9a1b1ae75;hpb=103633b49d995fe6001e226ccdcc8ca48b9cb4e6;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index 5f7c7ebca..5486ffff0 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -48,9 +48,11 @@ std::list PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr theFeature) +void PartSet_OperationEditLine::init(boost::shared_ptr theFeature, + const std::list& thePresentations) { setFeature(theFeature); + myFeatures = thePresentations; } void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView) @@ -58,7 +60,7 @@ 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) @@ -66,45 +68,71 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie if (!(theEvent->buttons() & Qt::LeftButton)) return; - double aCurX, aCurY; - PartSet_Tools::ConvertTo2D(myCurPressed, mySketch, theView, aCurX, aCurY); - - double aX, anY; gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); - PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, 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 = myFeatures.begin(), aLast = myFeatures.end(); + for (; anIt != aLast; anIt++) { + boost::shared_ptr aFeature = (*anIt).feature(); + if (!aFeature || aFeature == feature()) + continue; + moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_START); + moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_END); + } + } + myCurPoint.setPoint(aPoint); } void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, const std::list& theSelected) { - boost::shared_ptr aFeature; - if (!theSelected.empty()) - aFeature = theSelected.front().feature(); - - if (aFeature == feature()) - return; + std::list aFeatures = myFeatures; + if (myFeatures.size() == 1) { + boost::shared_ptr aFeature; + if (!theSelected.empty()) + aFeature = theSelected.front().feature(); + + if (aFeature == feature()) + return; - commit(); - if (aFeature) - emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); + commit(); + if (aFeature) + emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); + } + else { + commit(); + std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + for (; anIt != aLast; anIt++) { + boost::shared_ptr aFeature = (*anIt).feature(); + if (aFeature) + emit featureConstructed(aFeature, FM_Deactivation); + } + } } void PartSet_OperationEditLine::startOperation() { // do nothing in order to do not create a new feature emit multiSelectionEnabled(false); + myCurPoint.clear(); } void PartSet_OperationEditLine::stopOperation() { emit multiSelectionEnabled(true); + myFeatures.clear(); } boost::shared_ptr PartSet_OperationEditLine::createFeature() @@ -113,10 +141,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));