Salome HOME
Updated copyright comment
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
1 // Copyright (C) 2014-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ModuleBase_ResultPrs.h"
21 #include "ModuleBase_IViewer.h"
22
23 #include <GeomAPI_PlanarEdges.h>
24 #include <GeomAPI_Edge.h>
25
26 #include <ModelAPI_Events.h>
27 #include <ModelAPI_Tools.h>
28 #include <ModelAPI_ResultConstruction.h>
29 #include <ModelAPI_ResultBody.h>
30 #include <ModelAPI_AttributeIntArray.h>
31
32 #include "ModuleBase_Tools.h"
33 #include "ModuleBase_BRepOwner.h"
34
35 #include <Events_InfoMessage.h>
36 #include <Events_Loop.h>
37 #include <Config_PropManager.h>
38
39 #include <AIS_ColoredDrawer.hxx>
40 #include <AIS_InteractiveContext.hxx>
41 #include <AIS_Selection.hxx>
42 #include <BOPTools_AlgoTools3D.hxx>
43 #include <BRep_Builder.hxx>
44 #include <Graphic3d_AspectMarker3d.hxx>
45 #include <Prs3d_Drawer.hxx>
46 #include <Prs3d.hxx>
47 #include <Prs3d_PointAspect.hxx>
48 #include <Prs3d_IsoAspect.hxx>
49 #include <Prs3d_ShadingAspect.hxx>
50 #include <Prs3d_PlaneAspect.hxx>
51 #include <SelectMgr_SequenceOfOwner.hxx>
52 #include <SelectMgr_EntityOwner.hxx>
53 #include <SelectMgr_SelectionManager.hxx>
54 #include <StdPrs_WFShape.hxx>
55 #include <StdPrs_ShadedShape.hxx>
56 #include <StdSelect_BRepSelectionTool.hxx>
57 #include <TColStd_ListIteratorOfListOfInteger.hxx>
58 #include <TopExp_Explorer.hxx>
59 #include <TopoDS.hxx>
60 #include <TopoDS_Builder.hxx>
61 #include <TopoDS_Edge.hxx>
62 #include <BRepMesh_IncrementalMesh.hxx>
63 #include <Standard_Version.hxx>
64 #include <Prs3d_Arrow.hxx>
65 #include <GeomAdaptor_Curve.hxx>
66 #include <TopExp.hxx>
67 #include <GCPnts_AbscissaPoint.hxx>
68
69 #if OCC_VERSION_HEX > 0x070400
70 #include <StdPrs_ToolTriangulatedShape.hxx>
71 #endif
72
73 //*******************************************************************************************
74
75 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape);
76
77
78
79 //********************************************************************
80 ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
81   : ViewerData_AISShape(TopoDS_Shape()),
82     myResult(theResult),
83     myIsSubstituted(false),
84     myTransparency(1),
85     myAdditionalSelectionPriority(0)
86 {
87
88   GeomShapePtr aShapePtr = ModelAPI_Tools::shape(theResult);
89   TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
90   // Workaround for Sketch subshapes which has no discrete representation
91   // until sketch faces are built and displayed.
92   // Thus, perform discretization of such edges.
93   if (theResult->groupName() == ModelAPI_ResultConstruction::group() &&
94     aShape.ShapeType() == TopAbs_EDGE) {
95     GeomEdgePtr anEdgePtr = GeomEdgePtr(new GeomAPI_Edge(aShapePtr));
96     if (anEdgePtr->isCircle() || anEdgePtr->isArc()) {
97       TopoDS_Edge anEdge = TopoDS::Edge(aShape);
98       TopLoc_Location aLoc;
99       Handle(Poly_Polygon3D) aPoly3D = BRep_Tool::Polygon3D(anEdge, aLoc);
100       if (aPoly3D.IsNull()) {
101         double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
102         BRepMesh_IncrementalMesh(aShape, aDeflection);
103       }
104     }
105   }
106   Set(aShape);
107
108   // VSV: bos22744: The AutoHilight mode is swithced off because it produces different
109   // behaviour of selection for simple shape and compound. For example when selection mode
110   // is Vertex the shape is selected by vertex, but compound is selected by whole shape
111   //ResultBodyPtr aResOwner = ModelAPI_Tools::bodyOwner(myResult);
112   //SetAutoHilight(aResOwner.get() == NULL);
113
114   // Set own free boundaries aspect in order to have free
115   // and unfree boundaries with different colors
116   Handle(Prs3d_Drawer) aDrawer = Attributes();
117   aDrawer->SetUnFreeBoundaryAspect(
118     new Prs3d_LineAspect(Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1));
119   aDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1));
120   aDrawer->SetFaceBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1));
121
122   Quantity_Color aColor;
123   Color(aColor);
124
125   std::vector<int> aIsoValues;
126   bool isIsoVisible;
127   ModelAPI_Tools::getIsoLines(myResult, isIsoVisible, aIsoValues);
128   if (isIsoVisible) {
129     if (aIsoValues.size() == 0) {
130       aIsoValues.push_back(1);
131       aIsoValues.push_back(1);
132     }
133   }
134   else {
135     aIsoValues.push_back(0);
136     aIsoValues.push_back(0);
137   }
138   myUIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[0]);
139   myVIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[1]);
140   aDrawer->SetUIsoAspect(myUIsoAspect);
141   aDrawer->SetVIsoAspect(myVIsoAspect);
142
143   if (aDrawer->HasOwnPointAspect())
144     aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
145   else
146     aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
147
148   aDrawer = DynamicHilightAttributes();
149   if (aDrawer.IsNull()) {
150     if (!ModuleBase_IViewer::DefaultHighlightDrawer.IsNull()) {
151       aDrawer = new Prs3d_Drawer(*ModuleBase_IViewer::DefaultHighlightDrawer);
152       aDrawer->SetUIsoAspect(myUIsoAspect);
153       aDrawer->SetVIsoAspect(myVIsoAspect);
154       SetDynamicHilightAttributes(aDrawer);
155     }
156   }
157
158   myHiddenSubShapesDrawer = new AIS_ColoredDrawer(myDrawer);
159   Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
160   aShadingAspect->SetMaterial(Graphic3d_NOM_BRASS); //default value of context material
161   aShadingAspect->Aspect()->SetEdgeColor(Quantity_NOC_BLACK);
162   myHiddenSubShapesDrawer->SetShadingAspect(aShadingAspect);
163
164   ModuleBase_Tools::setPointBallHighlighting(this);
165
166   // Define colors for wireframe mode
167   setEdgesDefaultColor();
168
169   ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), DynamicHilightAttributes());
170   ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
171   Attributes()->UpdatePreviousDeviationCoefficient();
172 }
173
174 //********************************************************************
175 void ModuleBase_ResultPrs::setAdditionalSelectionPriority(const int thePriority)
176 {
177   myAdditionalSelectionPriority = thePriority;
178 }
179
180 //********************************************************************
181 void ModuleBase_ResultPrs::SetColor (const Quantity_Color& theColor)
182 {
183   ViewerData_AISShape::SetColor(theColor);
184   myHiddenSubShapesDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
185   setEdgesDefaultColor();
186   myUIsoAspect->SetColor(theColor);
187   myVIsoAspect->SetColor(theColor);
188 }
189
190 void ModuleBase_ResultPrs::setEdgesDefaultColor()
191 {
192   if (myResult.get()) {
193     AttributeIntArrayPtr aColorAttr = myResult->data()->intArray(ModelAPI_Result::COLOR_ID());
194     bool aHasColor = aColorAttr.get() && aColorAttr->isInitialized();
195
196     Handle(Prs3d_Drawer) aDrawer = Attributes();
197     aDrawer->SetFaceBoundaryDraw(Standard_True);
198     aDrawer->FaceBoundaryAspect()->SetColor(Quantity_NOC_BLACK);
199
200     if (!aHasColor) {
201       aDrawer->UnFreeBoundaryAspect()->SetColor(Quantity_NOC_YELLOW);
202       aDrawer->FreeBoundaryAspect()->SetColor(Quantity_NOC_GREEN);
203       aDrawer->WireAspect()->SetColor(Quantity_NOC_RED);
204
205       aDrawer->SetUnFreeBoundaryDraw(Standard_True);
206       aDrawer->SetFreeBoundaryDraw(Standard_True);
207       aDrawer->SetWireDraw(Standard_True);
208     }
209   }
210 }
211
212
213 //********************************************************************
214 void ModuleBase_ResultPrs::setSubShapeHidden(const TopoDS_ListOfShape& theShapes)
215 {
216   TopoDS_Compound aCompound;
217   BRep_Builder aBBuilder;
218   aBBuilder.MakeCompound (aCompound);
219
220   myHiddenSubShapes = theShapes;
221   collectSubShapes(aBBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
222   myVisibleCompound = aCompound;
223
224   aBBuilder.MakeCompound (aCompound);
225   TopoDS_ListOfShape::Iterator aIt(myHiddenSubShapes);
226   for (; aIt.More(); aIt.Next()) {
227     aBBuilder.Add(aCompound, aIt.Value());
228   }
229   myHiddenCompound = aCompound;
230 }
231
232 //********************************************************************
233 bool ModuleBase_ResultPrs::isSubShapeHidden(const TopoDS_Shape& theShape)
234 {
235   if (theShape.IsNull() || theShape.ShapeType() != TopAbs_FACE) // only face shape can be hidden
236     return false;
237
238   // orientation of parameter shape(come from selection) may be wrong, check isEqual() to be sure
239   TopoDS_ListOfShape::Iterator aShapeIt(myHiddenSubShapes);
240   for (; aShapeIt.More(); aShapeIt.Next()) {
241     if (theShape.IsSame(aShapeIt.Value()))
242       return true;
243   }
244
245   return true;
246 }
247
248 //********************************************************************
249 bool ModuleBase_ResultPrs::hasSubShapeVisible(
250   const TopoDS_ListOfShape& theShapesToSkip)
251 {
252   TopoDS_Compound aCompound;
253   BRep_Builder aBuilder;
254   aBuilder.MakeCompound (aCompound);
255   TopoDS_ListOfShape aShapesToSkip;
256   TopoDS_ListOfShape aHiddenCopy(myHiddenSubShapes);
257   aShapesToSkip.Append(aHiddenCopy);
258   for (TopoDS_ListOfShape::Iterator anIt(theShapesToSkip); anIt.More(); anIt.Next())
259     aShapesToSkip.Append(anIt.Value());
260
261   collectSubShapes(aBuilder, aCompound, myOriginalShape, aShapesToSkip);
262   return !BOPTools_AlgoTools3D::IsEmptyShape(aCompound);
263 }
264
265 //********************************************************************
266 bool ModuleBase_ResultPrs::setHiddenSubShapeTransparency(double theTransparency)
267 {
268   if (myTransparency == theTransparency || theTransparency > 1 || theTransparency < 0)
269     return false;
270
271   myTransparency = theTransparency;
272   myHiddenSubShapesDrawer->ShadingAspect()->SetTransparency (theTransparency, myCurrentFacingModel);
273   return true;
274 }
275
276 //********************************************************************
277 void ModuleBase_ResultPrs::Compute(
278           const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
279           const Handle(Prs3d_Presentation)& thePresentation,
280           const Standard_Integer theMode)
281 {
282   std::shared_ptr<GeomAPI_Shape> aShapePtr = myResult->shape();
283   bool aReadyToDisplay = aShapePtr.get();
284   if (aReadyToDisplay) {
285     myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
286     if (myHiddenSubShapes.IsEmpty() || myOriginalShape.ShapeType() > TopAbs_FACE ) {
287       if (!myOriginalShape.IsNull()) {
288         Set(myOriginalShape);
289         myIsSubstituted = false;
290       }
291     }
292     else { // convert shape into SHELL
293       bool isEmptyShape = BOPTools_AlgoTools3D::IsEmptyShape(myVisibleCompound);
294       Set(myVisibleCompound);
295       myIsSubstituted = true;
296       if (isEmptyShape)
297         aReadyToDisplay = false;
298     }
299   }
300   // change deviation coefficient to provide more precise circle
301   try {
302     AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
303   }
304   catch (...) {
305     return;
306   }
307   if (myResult.get() && ModelAPI_Tools::isShowEdgesDirection(myResult))
308   {
309     TopExp_Explorer Exp(myshape, TopAbs_EDGE);
310     for (; Exp.More(); Exp.Next()) {
311       TopoDS_Edge anEdgeE = TopoDS::Edge(Exp.Current());
312       if (anEdgeE.IsNull())
313         continue;
314
315       // draw curve direction (issue 0021087)
316       anEdgeE.Orientation(TopAbs_FORWARD);
317
318       TopoDS_Vertex aV1, aV2;
319       TopExp::Vertices(anEdgeE, aV1, aV2);
320       gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
321       gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
322
323       double fp, lp;
324       gp_Vec aDirVec;
325       Handle(Geom_Curve) C = BRep_Tool::Curve(anEdgeE, fp, lp);
326
327       if (C.IsNull()) continue;
328
329       if (anEdgeE.Orientation() == TopAbs_FORWARD)
330         C->D1(lp, aP2, aDirVec);
331       else {
332         C->D1(fp, aP1, aDirVec);
333         aP2 = aP1;
334       }
335       GeomAdaptor_Curve aAdC;
336       aAdC.Load(C, fp, lp);
337       Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp);
338
339       if (aDist > gp::Resolution()) {
340         gp_Dir aDir;
341         if (anEdgeE.Orientation() == TopAbs_FORWARD)
342           aDir = aDirVec;
343         else
344           aDir = -aDirVec;
345
346         Prs3d_Arrow::Draw(thePresentation->CurrentGroup(), aP2, aDir, M_PI / 180.*5., aDist / 10.);
347       }
348     }
349   }
350
351   // visualize hidden sub-shapes transparent
352   if (myResult.get()) {
353     if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty())
354     {
355       StdPrs_ShadedShape::Add(thePresentation, myHiddenCompound, myHiddenSubShapesDrawer);
356       aReadyToDisplay = true;
357     }
358
359     if (!aReadyToDisplay) {
360       Events_InfoMessage("ModuleBase_ResultPrs",
361         "An empty AIS presentation: ModuleBase_ResultPrs").send();
362       static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
363       ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
364     }
365   }
366 }
367
368 //********************************************************************
369 void ModuleBase_ResultPrs::collectSubShapes(BRep_Builder& theBuilder,
370   TopoDS_Shape& theCompound, const TopoDS_Shape& theShape,
371   const TopoDS_ListOfShape& theHiddenSubShapes)
372 {
373   switch (theShape.ShapeType()) {
374     case TopAbs_COMPSOLID:
375     case TopAbs_COMPOUND: {
376       for (TopoDS_Iterator aChildIter (theShape); aChildIter.More(); aChildIter.Next())
377         collectSubShapes(theBuilder, theCompound, aChildIter.Value(), theHiddenSubShapes);
378     }
379     break;
380     case TopAbs_SOLID:
381     case TopAbs_SHELL: {
382       for (TopExp_Explorer anExp (theShape, TopAbs_FACE); anExp.More(); anExp.Next()) {
383         collectSubShapes(theBuilder, theCompound, anExp.Current(), theHiddenSubShapes);
384       }
385     }
386     break;
387     case TopAbs_WIRE: {
388       for (TopExp_Explorer anExp (theShape, TopAbs_EDGE); anExp.More(); anExp.Next()) {
389         collectSubShapes(theBuilder, theCompound, anExp.Current(), theHiddenSubShapes);
390       }
391     }
392     break;
393     case TopAbs_FACE: {
394       if (theHiddenSubShapes.Contains(theShape))
395         return; // remove hidden shape
396       theBuilder.Add(theCompound, theShape);
397     }
398     break;
399     case TopAbs_EDGE:
400     case TopAbs_VERTEX: {
401       theBuilder.Add(theCompound, theShape);
402     }
403     default:
404       break;
405   }
406 }
407
408 //********************************************************************
409 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
410                                             const Standard_Integer theMode)
411 {
412   if (appendVertexSelection(aSelection, theMode))
413     return;
414
415   if (theMode > TopAbs_SHAPE) {
416     // In order to avoid using custom selection modes
417     if (theMode == ModuleBase_ResultPrs::Sel_Result) {
418       AIS_Shape::ComputeSelection(aSelection, TopAbs_COMPOUND);
419     }
420     return;
421   }
422
423   // TODO: OCCT issue should be created for the COMPOUND processing
424   // before it is fixed, the next workaround in necessary
425   if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) {
426     const TopoDS_Shape& aShape = Shape();
427     TopExp_Explorer aCompExp(aShape, TopAbs_COMPOUND);
428     // do not activate in compound mode shapes which do not contain compounds
429     if (!aCompExp.More())
430       return;
431   }
432
433   // bug 2110: if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
434   //  // Limit selection area only by actual object (Shape)
435   //  ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
436   //  if (aCompSolid.get()) {
437   //    std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aCompSolid);
438   //    if (aShapePtr.get()) {
439   //      TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
440   //   int aPriority = StdSelect_BRepSelectionTool::GetStandardPriority(aShape, TopAbs_COMPSOLID);
441   //     /// It is important to have priority for the shape of comp solid result less than priority
442   //      /// for the presentation shape which is a sub-result.
443   //      /// Reason is to select the sub-objects before: #1592
444   //      aPriority = aPriority - 1;
445   //      double aDeflection = Prs3d::GetDeflection(aShape, myDrawer);
446
447   //      Handle(ModuleBase_BRepOwner) aOwner = new ModuleBase_BRepOwner(aShape, aPriority);
448   //      StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection,
449   //        aDeflection, myDrawer->HLRAngle(), 9, 500);
450
451   //      for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
452   //        Handle(SelectMgr_EntityOwner) anOwner =
453   //          Handle(SelectMgr_EntityOwner)
454   //          ::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
455   //        anOwner->Set(this);
456   //      }
457   //      return;
458   //    }
459   //  }
460   //}
461   AIS_Shape::ComputeSelection(aSelection, theMode);
462
463   if (myAdditionalSelectionPriority > 0) {
464     NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> anEntities = aSelection->Entities();
465     for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIt(anEntities);
466          anIt.More();
467          anIt.Next()) {
468       Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value();
469       Handle(SelectBasics_EntityOwner) aBasicsOwner = anEntity->BaseSensitive()->OwnerId();
470       if (!aBasicsOwner.IsNull())
471         aBasicsOwner->SetPriority(aBasicsOwner->Priority() + myAdditionalSelectionPriority);
472     }
473   }
474 }
475
476 //********************************************************************
477 bool ModuleBase_ResultPrs::appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
478                                                  const Standard_Integer /*theMode*/)
479 {
480   if (Shape().ShapeType() == TopAbs_VERTEX) {
481     const TopoDS_Shape& aShape = Shape();
482
483     int aPriority = StdSelect_BRepSelectionTool::GetStandardPriority(aShape, TopAbs_VERTEX);
484 #if OCC_VERSION_HEX > 0x070400
485     double aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection(aShape, myDrawer);
486 #else
487     double aDeflection = Prs3d::GetDeflection(aShape, myDrawer);
488 #endif
489     /// The cause of this method is the last parameter of BRep owner setting into True.
490     /// That means that owner should behave like it comes from decomposition. (In this case, OCCT
491     /// visualizes it in Ring style) OCCT version is 7.0.0 with path for SHAPER module.
492     Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(aShape, aPriority, Standard_True);
493     StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection,
494                                                   aDeflection, myDrawer->DeviationAngle(), 9, 500);
495
496
497     NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> anEntities = aSelection->Entities();
498     for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIt(anEntities);
499          anIt.More();
500          anIt.Next()) {
501       Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value();
502       Handle(SelectMgr_EntityOwner) anOwner = anEntity->BaseSensitive()->OwnerId();
503       anOwner->SetSelectable(this);
504     }
505
506     return true;
507   }
508   return false;
509 }
510
511 //********************************************************************
512 void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
513                                            const SelectMgr_SequenceOfOwner& theOwners)
514 {
515   Handle(SelectMgr_EntityOwner) anOwner;
516   Handle(ModuleBase_BRepOwner) aCompOwner;
517   for (int i = 1; i <= theOwners.Length(); i++) {
518     anOwner = theOwners.Value(i);
519     aCompOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner);
520     if (aCompOwner.IsNull()) {
521       thePM->Color(anOwner->Selectable(), GetContext()->SelectionStyle());
522     }
523     else {
524       TopoDS_Shape aShape = aCompOwner->Shape();
525       Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM );
526       aSelectionPrs->Clear();
527
528       StdPrs_WFShape::Add(aSelectionPrs, aShape, myDrawer);
529
530       aSelectionPrs->SetDisplayPriority(9);
531       aSelectionPrs->Highlight(GetContext()->SelectionStyle());
532       aSelectionPrs->Display();
533       thePM->Color(this, GetContext()->SelectionStyle());
534     }
535   }
536 }
537
538 //********************************************************************
539 void ModuleBase_ResultPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
540                                                  const Handle(Prs3d_Drawer)& theStyle,
541                                                  const Handle(SelectMgr_EntityOwner)& theOwner)
542 {
543   Handle(StdSelect_BRepOwner) aOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
544   if (aOwner.IsNull())
545     return;
546
547   TopoDS_Shape aShape = aOwner->Shape();
548   if (!aShape.IsNull()) {
549     thePM->Color(this, theStyle);
550
551     Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
552     aHilightPrs->Clear();
553
554     StdPrs_WFShape::Add(aHilightPrs, aShape, myDrawer);
555     aHilightPrs->Highlight(theStyle);
556
557     if (thePM->IsImmediateModeOn())
558       thePM->AddToImmediateList(aHilightPrs);
559   }
560 }
561
562
563 //********************************************************************
564 void ModuleBase_ResultPrs::updateIsoLines()
565 {
566   std::vector<int> aIsoValues;
567   bool isIsoVisible;
568   ModelAPI_Tools::getIsoLines(myResult, isIsoVisible, aIsoValues);
569   if (isIsoVisible) {
570     if (aIsoValues.size() == 0) {
571       aIsoValues.push_back(1);
572       aIsoValues.push_back(1);
573     }
574   }
575   else {
576     if (aIsoValues.size() == 0) {
577       aIsoValues.push_back(0);
578       aIsoValues.push_back(0);
579     }
580     else {
581       aIsoValues[0] = 0;
582       aIsoValues[1] = 0;
583     }
584   }
585   myUIsoAspect->SetNumber(aIsoValues[0]);
586   myVIsoAspect->SetNumber(aIsoValues[1]);
587 }