From 41de4f29b4e60b4c733ebd5452296e9849b3e60b Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 20 May 2014 07:56:43 +0400 Subject: [PATCH] refs #30 - Sketch base GUI: create, draw lines Restore selection after operation edit. --- src/PartSet/PartSet_Module.cpp | 10 ++++++---- src/PartSet/PartSet_Module.h | 6 ++++-- src/PartSet/PartSet_OperationEditLine.cpp | 24 +++++++++-------------- src/PartSet/PartSet_OperationSketchBase.h | 4 +++- src/XGUI/XGUI_Displayer.cpp | 3 --- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 198cfbe64..5214dd6e1 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -195,7 +195,8 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled) aViewer->enableMultiselection(theEnabled); } -void PartSet_Module::onStopSelection(const std::list& theFeatures, const bool isStop) +void PartSet_Module::onStopSelection(const std::list& theFeatures, const bool isStop, + const bool isToSelect) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); aDisplayer->StopSelection(theFeatures, isStop, false); @@ -206,7 +207,8 @@ void PartSet_Module::onStopSelection(const std::list& theFeature activateFeature((*anIt).feature(), false); } } - aDisplayer->SetSelected(theFeatures, false); + if (isToSelect) + aDisplayer->SetSelected(theFeatures, false); aDisplayer->UpdateViewer(); } @@ -267,8 +269,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, SLOT(onMultiSelectionEnabled(bool))); - connect(aPreviewOp, SIGNAL(stopSelection(const std::list&, const bool)), - this, SLOT(onStopSelection(const std::list&, const bool))); + connect(aPreviewOp, SIGNAL(stopSelection(const std::list&, const bool, const bool)), + this, SLOT(onStopSelection(const std::list&, const bool, const bool))); PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); if (aSketchOp) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index cba0367e6..bfb57de78 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -92,10 +92,12 @@ public slots: /// \param theEnabled the enabled state void onMultiSelectionEnabled(bool theEnabled); - /// SLOT, to stop or start selection for the features + /// SLOT, to stop or start selection mode for the features /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped - void onStopSelection(const std::list& theFeatures, const bool isStop); + /// \param isToSelect the boolean state whether the features should be selected + void onStopSelection(const std::list& theFeatures, const bool isStop, + const bool isToSelect); /// SLOT, to visualize the feature in another local context mode /// \param theFeature the feature to be put in another local context mode diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index 2c39948d7..941195a56 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -42,10 +42,7 @@ bool PartSet_OperationEditLine::isGranted() const std::list PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr theFeature) const { - std::list aModes; - aModes.push_back(-1); - return aModes; - //return PartSet_OperationSketchBase::getSelectionModes(theFeature); + return PartSet_OperationSketchBase::getSelectionModes(theFeature); } void PartSet_OperationEditLine::init(boost::shared_ptr theFeature, @@ -100,16 +97,12 @@ void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_ { std::list aFeatures = myFeatures; if (myFeatures.size() == 1) { - boost::shared_ptr aFeature; - if (!theSelected.empty()) - aFeature = theSelected.front().feature(); - - if (aFeature == feature()) + if (theSelected.empty()) return; - - commit(); - if (aFeature) - emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); + + boost::shared_ptr aFeature = theSelected.front().feature(); + commit(); + emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); } else { commit(); @@ -126,14 +119,15 @@ void PartSet_OperationEditLine::startOperation() { // do nothing in order to do not create a new feature emit multiSelectionEnabled(false); - emit stopSelection(myFeatures, true); + emit stopSelection(myFeatures, true, false); myCurPoint.clear(); } void PartSet_OperationEditLine::stopOperation() { emit multiSelectionEnabled(true); - emit stopSelection(myFeatures, false); + bool isSelectFeatures = myFeatures.size() > 1; + emit stopSelection(myFeatures, false, isSelectFeatures); myFeatures.clear(); } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 4fb941df9..d8154f86c 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -103,7 +103,9 @@ signals: /// signal to enable/disable selection in the viewer /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped - void stopSelection(const std::list& theFeatures, const bool theToStop); + /// \param isToSelect the boolean state whether the features should be selected + void stopSelection(const std::list& theFeatures, const bool theToStop, + const bool isToSelect); /// signal to enable/disable usual selection in the viewer /// \param theEnabled the boolean state diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index d597eda0c..73515eae7 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -181,9 +181,6 @@ void XGUI_Displayer::StopSelection(const std::list& theFeatures, continue; if (isStop) { - aContext->ClearSelected(); - aContext->Deactivate(anAIS); - QColor aColor(Qt::white); anAIS->SetColor(Quantity_Color(aColor.red()/255., aColor.green()/255., aColor.blue()/255., Quantity_TOC_RGB)); anAIS->Redisplay(); -- 2.39.2