From 914202f7f571ceca774790c37297b95c14bc07ed Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 1 Sep 2014 20:09:48 +0400 Subject: [PATCH] Selection of planar faces provided for sketcher --- src/PartSet/PartSet_Module.cpp | 11 ++++++ src/PartSet/PartSet_OperationSketch.cpp | 11 ++---- src/PartSet/PartSet_OperationSketchBase.cpp | 10 +++++ src/XGUI/XGUI_Displayer.cpp | 44 +++++++++++++++------ src/XGUI/XGUI_Displayer.h | 8 ++++ 5 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ec21e0266..993d46757 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -49,6 +49,9 @@ #include #include +#include +#include + #include #include #include @@ -347,6 +350,7 @@ void PartSet_Module::onSetSelection(const QList& theFeatures) void PartSet_Module::onCloseLocalContext() { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->deactivateObjectsOutOfContext(); aDisplayer->closeLocalContexts(); } @@ -519,6 +523,13 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPreviewOp->getSelectionModes(theFeature); aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer); + + // If this is a Sketcher then activate objects (planar faces) outside of context + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp) { + Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane); + aDisplayer->activateObjectsOutOfContext(aModes, aFilter); + } } } diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index ece230157..acd79461d 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -115,13 +115,7 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi if (theSelected.size() == 1) { ObjectPtr aObject = theSelected.front().object(); if (aObject) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); - if (aFeature) { - QStringList aNested = this->nestedFeatures(); - if ((!aNested.isEmpty()) && aNested.contains(QString(aFeature->getKind().c_str()))) { - restartOperation(PartSet_OperationFeatureEdit::Type(), aObject); - } - } + restartOperation(PartSet_OperationFeatureEdit::Type(), aObject); } } } @@ -263,4 +257,5 @@ bool PartSet_OperationSketch::isValid(ModuleBase_IOperation* theOperation) const { PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(theOperation); return aPreviewOp != NULL; -} \ No newline at end of file +} + diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index d90de1d29..9272c8c9e 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -124,5 +124,15 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature) { + FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature); + if (aFeature) { + QStringList aNested = this->nestedFeatures(); + if (!aNested.isEmpty()) { + if (aNested.contains(QString(aFeature->getKind().c_str()))) + emit launchOperation(theType, theFeature); + else + return; + } + } emit launchOperation(theType, theFeature); } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 7d397b196..26def2f04 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -20,7 +20,6 @@ #include #include #include - #include #include @@ -169,17 +168,10 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list // Open local context if there is no one if (!aContext->HasOpenedContext()) { aContext->ClearCurrents(false); - aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); - //aContext->OpenLocalContext(); - //aContext->NotUseDisplayedObjects(); + //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); + aContext->OpenLocalContext(); + aContext->NotUseDisplayedObjects(); } - //!!! Test - //aContext->UseDisplayedObjects(); - //std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); - //for (; anIt != aLast; anIt++) { - // aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt)); - //} - //!!! Test end // display or redisplay presentation Handle(AIS_InteractiveObject) anAIS; if (isVisible(theResult)) { @@ -338,6 +330,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer) { + AISContext()->ClearSelected(false); closeAllContexts(true); } @@ -405,3 +398,32 @@ void XGUI_Displayer::erase(boost::shared_ptr theAIS, const bo } } +void XGUI_Displayer::activateObjectsOutOfContext(const std::list& theModes, + Handle(SelectMgr_Filter) theFilter) +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + // Open local context if there is no one + if (!aContext->HasOpenedContext()) + return; + + aContext->UseDisplayedObjects(); + std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); + for (; anIt != aLast; anIt++) { + aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt)); + } + + if (!theFilter.IsNull()) + aContext->AddFilter(theFilter); +} + + +void XGUI_Displayer::deactivateObjectsOutOfContext() +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + // Open local context if there is no one + if (!aContext->HasOpenedContext()) + return; + + aContext->RemoveFilters(); + aContext->NotUseDisplayedObjects(); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index ef3a3308d..5c54857d0 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -124,6 +124,14 @@ class XGUI_EXPORT XGUI_Displayer void activate(ObjectPtr theFeature); + /// Activates in local context displayed outside of the context. + /// \param theModes - selection modes to activate + /// \param theFilter - filter for selection + void activateObjectsOutOfContext(const std::list& theModes, + Handle(SelectMgr_Filter) theFilter); + + void deactivateObjectsOutOfContext(); + protected: /// Deactivate local selection /// \param isUpdateViewer the state wether the viewer should be updated immediatelly -- 2.39.2