From dbc30f224f34fa601eda446e51ff8ead2f1832e4 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 23 May 2014 14:24:00 +0400 Subject: [PATCH] Shift selection to edit some lines. --- src/PartSet/PartSet_OperationEditLine.cpp | 22 ++++++++++++++++++---- src/PartSet/PartSet_OperationEditLine.h | 1 + src/PartSet/PartSet_OperationSketch.cpp | 8 +++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index df852732c..d69aab8e0 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -35,7 +35,7 @@ using namespace std; PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId, QObject* theParent, boost::shared_ptr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature) +: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) { } @@ -94,12 +94,20 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V aFeature = theHighlighted.front().feature(); if (aFeature && aFeature == feature()) { // continue the feature edit - blockSelection(true); } else { + XGUI_ViewerPrs aFeaturePrs = myFeatures.front(); commit(); emit featureConstructed(feature(), FM_Deactivation); - if (aFeature) { + + bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); + if(aHasShift && !theHighlighted.empty()) { + std::list aSelected; + aSelected.push_back(aFeaturePrs); + aSelected.push_back(theHighlighted.front()); + emit setSelection(aSelected); + } + else if (aFeature) { emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); } } @@ -113,6 +121,7 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView); + blockSelection(true); if (myCurPoint.myIsInitialized) { double aCurX, aCurY; PartSet_Tools::ConvertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY); @@ -165,7 +174,8 @@ void PartSet_OperationEditLine::startOperation() // do nothing in order to do not create a new feature emit multiSelectionEnabled(false); - blockSelection(true); + if (myFeatures.size() > 1) + blockSelection(true); myCurPoint.clear(); } @@ -181,6 +191,10 @@ void PartSet_OperationEditLine::stopOperation() void PartSet_OperationEditLine::blockSelection(bool isBlocked, const bool isRestoreSelection) { + if (myIsBlockedSelection == isBlocked) + return; + + myIsBlockedSelection = isBlocked; if (isBlocked) { emit setSelection(std::list()); emit stopSelection(myFeatures, true); diff --git a/src/PartSet/PartSet_OperationEditLine.h b/src/PartSet/PartSet_OperationEditLine.h index 219d23b2c..d42d0e545 100644 --- a/src/PartSet/PartSet_OperationEditLine.h +++ b/src/PartSet/PartSet_OperationEditLine.h @@ -142,6 +142,7 @@ private: std::list myFeatures; ///< the features to apply the edit operation Point myCurPoint; ///< the current 3D point clicked or moved gp_Pnt myCurPressed; ///< the current 3D point clicked or moved + bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal }; #endif diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 5aff76e1c..eb65c3659 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -63,7 +63,7 @@ boost::shared_ptr PartSet_OperationSketch::sketch() const } void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& /*theSelected*/, + const std::list& theSelected, const std::list& theHighlighted) { if (!hasSketchPlane()) { @@ -75,6 +75,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie } } else { + // if shift button is pressed and there are some already selected objects, the operation should + // not be started. We just want to combine some selected objects. + bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); + if (aHasShift && theSelected.size() > 0) + return; + if (theHighlighted.size() == 1) { boost::shared_ptr aFeature = theHighlighted.front().feature(); if (aFeature) -- 2.39.2