]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3231: Show all objects of offset on selection
authorvsv <vsv@opencascade.com>
Fri, 26 Jun 2020 10:20:01 +0000 (13:20 +0300)
committervsv <vsv@opencascade.com>
Fri, 26 Jun 2020 10:20:01 +0000 (13:20 +0300)
src/SketcherPrs/SketcherPrs_Offset.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp

index c90f2d40416916466e7f7453a516c087a5ca5fb2..a9d3ffbd3f798db7b6f0800e0264a74285becce0 100644 (file)
@@ -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<std::shared_ptr<ModelAPI_Result> > 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);
 }
index 2de9b6c82617b8f9785a69587131f0a18484e5fd..91a1dedee7a1d859ce84f46a7491d74d7dd13881 100644 (file)
@@ -95,6 +95,11 @@ ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName
 std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject)
 {
   ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theObject);
+  if (!aRes.get()) {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+    if (aFeature.get())
+      aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFeature->firstResult());
+  }
   if (aRes.get() != NULL && aRes->data()->isValid()) {
     /// essential check as it is called in openGl thread
     return aRes->shape();