From e3747dc4d7f06cf1699c793becbe64f0627562ae Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 26 Jun 2020 13:20:01 +0300 Subject: [PATCH] Issue #3231: Show all objects of offset on selection --- src/SketcherPrs/SketcherPrs_Offset.cpp | 34 ++++++++++++++++++++------ src/SketcherPrs/SketcherPrs_Tools.cpp | 5 ++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/SketcherPrs/SketcherPrs_Offset.cpp b/src/SketcherPrs/SketcherPrs_Offset.cpp index c90f2d404..a9d3ffbd3 100644 --- a/src/SketcherPrs/SketcherPrs_Offset.cpp +++ b/src/SketcherPrs/SketcherPrs_Offset.cpp @@ -47,8 +47,12 @@ bool SketcherPrs_Offset::IsReadyToDisplay(ModelAPI_Feature* theConstraint, AttributeDoublePtr aValueAttr = theConstraint->real(SketchPlugin_Offset::VALUE_ID()); if (aValueAttr->isInitialized()) { - AttributeRefListPtr aSelectedEdges = theConstraint->reflist(SketchPlugin_Offset::EDGES_ID()); + AttributeRefListPtr aSelectedEdges = theConstraint->reflist(SketchPlugin_Offset::ENTITY_A()); aReadyToDisplay = (aSelectedEdges->list().size() > 0); + if (aReadyToDisplay) { + AttributeRefListPtr aOffcetEdges = theConstraint->reflist(SketchPlugin_Offset::ENTITY_B()); + aReadyToDisplay = (aOffcetEdges->list().size() > 0); + } } return aReadyToDisplay; } @@ -63,13 +67,13 @@ bool SketcherPrs_Offset::updateIfReadyToDisplay(double theStep, bool withColor) // Set points of the presentation SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); - AttributeRefListPtr aSelectedEdges = myConstraint->reflist(SketchPlugin_Offset::EDGES_ID()); + AttributeRefListPtr aSelectedEdges = myConstraint->reflist(SketchPlugin_Offset::ENTITY_A()); int aNb = aSelectedEdges->size(); - //std::list > aResList = myConstraint->results(); - //int aRNb = aResList.size(); + AttributeRefListPtr aOffcetEdges = myConstraint->reflist(SketchPlugin_Offset::ENTITY_B()); + int aOffNb = aOffcetEdges->size(); - myPntArray = new Graphic3d_ArrayOfPoints(aNb, withColor); + myPntArray = new Graphic3d_ArrayOfPoints(aNb + aOffNb, withColor); int i; ObjectPtr aObj; gp_Pnt aP1; @@ -81,20 +85,34 @@ bool SketcherPrs_Offset::updateIfReadyToDisplay(double theStep, bool withColor) aP1 = aMgr->getPosition(aObj, this, theStep); myPntArray->SetVertice(i + 1, aP1); } + for (i = aNb; i < aNb + aOffNb; i++) { + aObj = aOffcetEdges->object(i - aNb); + if (SketcherPrs_Tools::getShape(aObj).get() == NULL) + continue; + aP1 = aMgr->getPosition(aObj, this, theStep); + myPntArray->SetVertice(i + 1, aP1); + } return true; } void SketcherPrs_Offset::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - AttributeRefListPtr aSelectedEdges = myConstraint->reflist(SketchPlugin_Offset::EDGES_ID()); + AttributeRefListPtr aSelectedEdges = myConstraint->reflist(SketchPlugin_Offset::ENTITY_A()); if (aSelectedEdges.get() == NULL) return; + AttributeRefListPtr aOffcetEdges = myConstraint->reflist(SketchPlugin_Offset::ENTITY_B()); + if (aOffcetEdges.get() == NULL) + return; - int aNb = aSelectedEdges->size(); - if (aNb == 0) + if (aSelectedEdges->size() == 0) + return; + + if (aOffcetEdges->size() == 0) return; // Draw source objects drawListOfShapes(aSelectedEdges, thePrs, theColor); + // Draw offcet objects + drawListOfShapes(aOffcetEdges, thePrs, theColor); } diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 2de9b6c82..91a1dedee 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -95,6 +95,11 @@ ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName std::shared_ptr getShape(ObjectPtr theObject) { ResultConstructionPtr aRes = std::dynamic_pointer_cast(theObject); + if (!aRes.get()) { + FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); + if (aFeature.get()) + aRes = std::dynamic_pointer_cast(aFeature->firstResult()); + } if (aRes.get() != NULL && aRes->data()->isValid()) { /// essential check as it is called in openGl thread return aRes->shape(); -- 2.39.2