Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into BR_v14_rc
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Shape.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include <HYDROGUI_Shape.h>
20 #include <HYDROGUI_Tool.h>
21 #include <HYDROGUI_Polyline.h>
22
23 #include <HYDROData_Channel.h>
24 #include <HYDROData_Document.h>
25 #include <HYDROData_DummyObject3D.h>
26 #include <HYDROData_ImmersibleZone.h>
27 #include <HYDROData_Obstacle.h>
28 #include <HYDROData_PolylineXY.h>
29 #include <HYDROData_Polyline3D.h>
30 #include <HYDROData_Profile.h>
31 #include <HYDROData_ShapesGroup.h>
32 #include <HYDROData_Stream.h>
33 #include <HYDROData_Zone.h>
34 #include <HYDROData_LandCover.h>
35
36 #include <AIS_Shape.hxx>
37 #include <BRep_Builder.hxx>
38 #include <BRepBuilderAPI_MakeFace.hxx>
39 #include <Graphic3d_AspectFillArea3d.hxx>
40 #include <Prs3d_IsoAspect.hxx>
41 #include <Prs3d_ShadingAspect.hxx>
42 #include <TopoDS.hxx>
43 #include <TopoDS_Face.hxx>
44 #include <TopoDS_Wire.hxx>
45 #include <TopExp_Explorer.hxx>
46
47 HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
48                                 const Handle(HYDROData_Entity)&       theObject,
49                                 const int                             theZLayer )
50 : myContext( theContext ),
51   myObject( theObject ),
52   myZLayer( theZLayer ),
53   myIsHighlight( false ),
54   myFillingColor( Qt::transparent ),
55   myBorderColor( Qt::black ),
56   myHighlightColor( Qt::white ),
57   myIsToUpdate( false ),
58   myIsVisible( true ),
59   myDisplayMode( AIS_Shaded )
60 {
61 }
62
63 HYDROGUI_Shape::~HYDROGUI_Shape()
64 {
65   erase( false );
66
67   if ( !myShape.IsNull() )
68     myShape.Nullify();
69 }
70
71 Handle(AIS_InteractiveContext) HYDROGUI_Shape::getContext() const
72 {
73   return myContext;
74 }
75
76 Handle(HYDROData_Entity) HYDROGUI_Shape::getObject() const
77 {
78   return myObject;
79 }
80
81 TopoDS_Shape HYDROGUI_Shape::getTopoShape() const
82 {
83   return myTopoShape;
84 }
85
86 bool HYDROGUI_Shape::getIsToUpdate() const
87 {
88   return myIsToUpdate;
89 }
90
91 void HYDROGUI_Shape::setIsToUpdate( bool theState )
92 {
93   myIsToUpdate = theState;
94 }
95
96 bool HYDROGUI_Shape::isVisible() const
97 {
98   return myIsVisible;
99 }
100
101 Handle(AIS_InteractiveObject) HYDROGUI_Shape::getAISObject() const
102 {
103   return myShape;
104 }
105
106 void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
107 {
108   if ( myContext.IsNull() || myShape.IsNull() || !isVisible() )
109     return;
110
111   displayShape( theIsUpdateViewer );
112 }
113
114 void HYDROGUI_Shape::erase( const bool theIsUpdateViewer )
115 {
116   if ( myContext.IsNull() || myShape.IsNull() )
117     return;
118
119   myContext->Erase( myShape, theIsUpdateViewer );
120 }
121
122 void HYDROGUI_Shape::update( bool isUpdateViewer,
123                              bool isDeactivateSelection )
124
125 {
126   setIsToUpdate( false );
127
128   if ( myContext.IsNull() )
129     return;
130
131   // Try to retrieve information from object
132   if ( !myObject.IsNull() )
133   {
134     Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myObject->Label() );
135   
136     if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ImmersibleZone) ) )
137     {
138       Handle(HYDROData_ImmersibleZone) aZoneObj =
139         Handle(HYDROData_ImmersibleZone)::DownCast( myObject );
140
141       TopoDS_Shape aZoneShape = aZoneObj->GetTopShape();
142       if ( !aZoneShape.IsNull() ) {
143         if ( aZoneShape.ShapeType() == TopAbs_FACE ) {
144           TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
145           setFace( aZoneFace, false, false, "" );
146         } else {
147           myTopoShape = aZoneShape;
148           //TODO: myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
149           myDisplayMode = AIS_Shaded;
150
151           buildShape();
152           updateShape( false, false );
153         }
154       }
155
156       QColor aFillingColor = aZoneObj->GetFillingColor();
157       QColor aBorderColor = aZoneObj->GetBorderColor();
158
159       setFillingColor( aFillingColor, false, false );
160       setBorderColor( aBorderColor, false, false );
161     }
162     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_PolylineXY) ) )
163     {
164       Handle(HYDROData_PolylineXY) aPolyline =
165         Handle(HYDROData_PolylineXY)::DownCast( myObject );
166
167       TopoDS_Shape aPolylineShape = aPolyline->GetShape();
168
169       if ( !aPolylineShape.IsNull() ) {
170         if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) {
171           TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
172           setWire( aPolylineWire, false, false );  
173         } else {
174           myTopoShape = aPolylineShape;
175           // Set shading mode to avoid that hilight presentation is equal to "normal" object presentation.
176           // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
177           myDisplayMode = AIS_Shaded;
178
179           buildShape();
180           updateShape( false, false );
181         }
182       }
183
184       QColor aWireColor = aPolyline->GetWireColor();
185       setBorderColor( aWireColor, false, false );
186     }
187     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
188     {
189       Handle(HYDROData_Polyline3D) aPolyline =
190         Handle(HYDROData_Polyline3D)::DownCast( myObject );
191
192       TopoDS_Shape aPolylineShape = aPolyline->GetShape3D();
193
194       if ( !aPolylineShape.IsNull() ) {
195         if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) {
196           TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
197           setWire( aPolylineWire, false, false );  
198         } else {
199           myTopoShape = aPolylineShape;
200           // Set shading mode to avoid that hilight presentation is equal to "normal" object presentation.
201           // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
202           myDisplayMode = AIS_Shaded;
203
204           buildShape();
205           updateShape( false, false );
206         }
207       }
208
209       QColor aWireColor = aPolyline->GetBorderColor();
210       setBorderColor( aWireColor, false, false );
211     }
212     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
213     {
214       Handle(HYDROData_Zone) aZone =
215         Handle(HYDROData_Zone)::DownCast( myObject );
216
217       TopoDS_Face aZoneFace = TopoDS::Face( aZone->GetShape() );
218
219       setFace( aZoneFace, false, false, "" );
220       if (aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN )
221       {
222         // Red color for a zone with bathymetry conflict
223         setFillingColor( Qt::red );
224       }
225       else
226       {
227                 // Set the filling color for zone
228                 setFillingColor( aZone->GetColor(HYDROData_ImmersibleZone::DefaultFillingColor()) );
229       }
230     }
231     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) )
232     {
233       Handle(HYDROData_Profile) aProfile =
234         Handle(HYDROData_Profile)::DownCast( myObject );
235
236       TopoDS_Wire aProfileWire;
237
238       if ( aProfile->IsValid() ) {
239         TopoDS_Shape aProfileShape = aProfile->GetShape3D();
240
241         if ( !aProfileShape.IsNull() && 
242              aProfileShape.ShapeType() == TopAbs_WIRE ) {
243           aProfileWire = TopoDS::Wire( aProfileShape );
244         }
245       }
246
247       setWire( aProfileWire, false, false );  
248
249       QColor aWireColor = aProfile->GetBorderColor();
250       setBorderColor( aWireColor, false, false );
251     }
252     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) ||
253               myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) ||
254               myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
255     {
256       Handle(HYDROData_Object) aGeomObject =
257         Handle(HYDROData_Object)::DownCast( myObject );
258
259       TopoDS_Shape anObjShape = aGeomObject->GetTopShape();
260
261       setShape( anObjShape, false, false );
262
263       QColor aFillingColor = aGeomObject->GetFillingColor();
264       QColor aBorderColor = aGeomObject->GetBorderColor();
265
266       setFillingColor( aFillingColor, false, false );
267       setBorderColor( aBorderColor, false, false );
268     }
269     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_DummyObject3D) ) )
270     {
271       Handle(HYDROData_DummyObject3D) anObject3D =
272         Handle(HYDROData_DummyObject3D)::DownCast( myObject );
273       TopoDS_Shape aShape3D = anObject3D->GetShape();
274
275       setShape( aShape3D, false, false );
276
277       QColor aFillingColor = anObject3D->GetFillingColor();
278       QColor aBorderColor = anObject3D->GetBorderColor();
279
280       setFillingColor( aFillingColor, false, false );
281       setBorderColor( aBorderColor, false, false );
282     }
283     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ShapesGroup) ) )
284     {
285       Handle(HYDROData_ShapesGroup) aShapesGroup =
286         Handle(HYDROData_ShapesGroup)::DownCast( myObject );
287
288       TopTools_SequenceOfShape aShapes;
289       aShapesGroup->GetShapes( aShapes );
290
291       TopoDS_Compound aCompound;
292       BRep_Builder aCompoundBuilder;
293       aCompoundBuilder.MakeCompound( aCompound );
294
295       for ( int i = 1, n = aShapes.Length(); i <= n; ++i )
296       {
297         const TopoDS_Shape& aShape = aShapes.Value( i );
298         aCompoundBuilder.Add( aCompound, aShape );
299       }
300
301       setShape( aCompound, false, false );  
302     }
303     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) )
304     {
305       Handle(HYDROData_LandCover) aLandCoverObj =
306         Handle(HYDROData_LandCover)::DownCast( myObject );
307
308       TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape();
309       if ( !aLandCoverShape.IsNull() ) {
310         setShape( aLandCoverShape, false, false );
311       }
312
313       QColor aFillingColor = aLandCoverObj->GetFillingColor();
314       QColor aBorderColor = aLandCoverObj->GetBorderColor();
315
316       setFillingColor( aFillingColor, false, false );
317       setBorderColor( aBorderColor, false, false );
318     }
319   }
320  
321   if ( myShape.IsNull() || !isVisible() )
322     return;
323
324   displayShape( isUpdateViewer );
325
326   if (isDeactivateSelection)
327     myContext->Deactivate(myShape);
328 }
329
330 void HYDROGUI_Shape::setVisible( const bool theState,
331                                  const bool theIsUpdateViewer )
332 {
333   myIsVisible = theState;
334
335   if ( myShape.IsNull() )
336     return;
337
338   if ( ( myIsVisible && myContext->IsDisplayed( myShape ) ) ||
339        ( !myIsVisible && !myContext->IsDisplayed( myShape ) ) )
340     return;
341
342   if ( myIsVisible ) {
343     displayShape( theIsUpdateViewer );
344   }
345   else
346     myContext->Erase( myShape, theIsUpdateViewer );
347 }
348
349 void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
350 {
351   if ( myIsHighlight == theIsHighlight )
352     return;
353
354   myIsHighlight = theIsHighlight;
355
356   if ( myContext.IsNull() || myShape.IsNull() )
357     return;
358
359   colorShapeBorder( getActiveColor() );
360   displayShape( isUpdateViewer );
361 }
362
363 bool HYDROGUI_Shape::isHighlighted() const
364 {
365   return myIsHighlight;
366 }
367
368 void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire,
369                               const bool         theToDisplay,
370                               const bool         theIsUpdateViewer )
371 {
372   myTopoShape = theWire;
373   // To avoid that hilight presentation is equal to "normal" object presentation.
374   // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
375   myDisplayMode = AIS_Shaded;
376
377   buildShape();
378   updateShape( theToDisplay, theIsUpdateViewer );
379 }
380
381 void HYDROGUI_Shape::setFaces( const TopoDS_Compound& theWires,
382                                const bool             theToDisplay,
383                                const bool             theIsUpdateViewer )
384 {
385   TopExp_Explorer anExp( theWires, TopAbs_WIRE );
386   TopoDS_Compound aCompound;
387   BRep_Builder aBuilder;
388     aBuilder.MakeCompound( aCompound );
389
390   for ( ; anExp.More(); anExp.Next() ) {
391     TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
392     if ( aWire.IsNull() ) {
393       continue;
394     }
395
396     BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
397     aMakeFace.Build();
398     if( aMakeFace.IsDone() ) {
399       aBuilder.Add( aCompound, aMakeFace.Face() );
400     }
401   }
402
403   myTopoShape = aCompound;
404   myDisplayMode = AIS_Shaded;
405
406   buildShape();
407   updateShape( theToDisplay, theIsUpdateViewer );
408 }
409
410 void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
411                               const bool         theToDisplay,
412                               const bool         theIsUpdateViewer,
413                               const QString&     theTextureFileName )
414 {
415   BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True );
416   aFaceBuilder.Build();
417   if( aFaceBuilder.IsDone() )
418   {
419     TopoDS_Face aFace = aFaceBuilder.Face();
420     setFace( aFace, theToDisplay, theIsUpdateViewer, theTextureFileName );
421   }
422 }
423
424 void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
425                               const bool         theToDisplay,
426                               const bool         theIsUpdateViewer,
427                               const QString&     theTextureFileName )
428 {
429   myTopoShape = theFace;
430   myDisplayMode = theTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
431   //Note: AIS_Shaded+2 is the same as AIS_ExactHLR
432   //TODO: it would be more suitable to use TexturedShape mode from GEOM_AISShape
433
434   buildShape();
435   updateShape( theToDisplay, theIsUpdateViewer );
436 }
437
438 void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
439                                const bool          theToDisplay,
440                                const bool          theIsUpdateViewer )
441 {
442   myTopoShape = theShape;
443   myDisplayMode = AIS_Shaded;
444
445   buildShape();
446   updateShape( theToDisplay, theIsUpdateViewer );
447 }
448
449 void HYDROGUI_Shape::setFillingColor( const QColor& theColor,
450                                       const bool    theToDisplay,
451                                       const bool    theIsUpdateViewer )
452 {
453   myFillingColor = theColor;
454   updateShape( theToDisplay, theIsUpdateViewer );
455 }
456
457 QColor HYDROGUI_Shape::getFillingColor() const
458 {
459   return myFillingColor;
460 }
461
462 void HYDROGUI_Shape::setBorderColor( const QColor& theColor,
463                                      const bool    theToDisplay,
464                                      const bool    theIsUpdateViewer )
465
466   myBorderColor = theColor;
467   updateShape( theToDisplay, theIsUpdateViewer );
468 }
469
470 QColor HYDROGUI_Shape::getBorderColor() const
471 {
472   return myBorderColor;
473 }
474
475 void HYDROGUI_Shape::setHighlightColor( const QColor& theColor )
476 {
477   myHighlightColor = theColor;
478 }
479
480 QColor HYDROGUI_Shape::getHighlightColor() const
481 {
482   return myHighlightColor;
483 }
484
485 void HYDROGUI_Shape::setZLayer( const int theZLayer )
486 {
487   if ( myZLayer == theZLayer )
488     return;
489
490   myZLayer = theZLayer;
491   if ( !myShape.IsNull() && isVisible() && !myContext.IsNull() && myZLayer >= 0 )
492     myContext->SetZLayer( myShape, myZLayer );
493 }
494
495 Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const
496 {
497   if( myTopoShape.IsNull() ) {
498     return Handle_AIS_InteractiveObject();
499   }
500
501   TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
502   bool IsWireEdgeCompound = aShapeType==TopAbs_COMPOUND;
503   if (IsWireEdgeCompound) {
504     TopoDS_Iterator itr(myTopoShape);
505     while (itr.More() && IsWireEdgeCompound) {
506       if (itr.Value().ShapeType() != TopAbs_WIRE && itr.Value().ShapeType() != TopAbs_EDGE)
507         IsWireEdgeCompound = false;
508       itr.Next();
509     }
510   }
511
512   if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) {
513     return new HYDROGUI_Polyline( myTopoShape );
514   } else {
515     return new AIS_Shape( myTopoShape );
516   }
517 }
518
519 void HYDROGUI_Shape::buildShape()
520 {
521   // Erase previously created shape
522   erase();
523
524   myShape = createShape();
525   if( myShape.IsNull() )
526     return;
527
528   Handle_AIS_Shape anAISShape = Handle_AIS_Shape::DownCast( myShape );
529   if( !anAISShape.IsNull() )
530     anAISShape ->SetHLRAngleAndDeviation( 0.001 );
531
532   if ( !myObject.IsNull() )
533     myShape->SetOwner( myObject );
534
535   myShape->SetTransparency( 0 );
536   myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
537
538     // Init default params for shape
539   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
540   if ( !anAttributes.IsNull() )
541   {
542     Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
543     if ( !anIsoAspect.IsNull() ) {
544       anIsoAspect->SetNumber( 0 );
545       anAttributes->SetUIsoAspect( anIsoAspect );
546     }
547       
548     anIsoAspect = anAttributes->VIsoAspect();
549     if ( !anIsoAspect.IsNull() ) {
550       anIsoAspect->SetNumber( 0 );
551       anAttributes->SetVIsoAspect( anIsoAspect );
552     }
553
554     if ( myDisplayMode == AIS_Shaded )
555     {
556       Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
557       if ( !aShadingAspect.IsNull() )
558       {
559         Graphic3d_MaterialAspect aMatAspect( Graphic3d_NOM_PLASTIC );
560         //aMatAspect.SetAmbient( 1 );
561         //aMatAspect.SetDiffuse( 0 );
562
563         aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect );
564         aShadingAspect->Aspect()->SetBackMaterial( aMatAspect );
565       }
566     }
567     else if ( myDisplayMode == AIS_WireFrame )
568     {
569       anAttributes->SetWireDraw( true );
570     }
571   }
572 }
573
574 void HYDROGUI_Shape::updateShape( const bool theToDisplay,
575                                   const bool theIsUpdateViewer )
576 {
577   if ( myShape.IsNull() )
578     return;
579
580   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
581   if ( !anAttributes.IsNull() )
582   {
583     if ( myDisplayMode == AIS_Shaded )
584     {
585       // Coloring face filling
586       Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
587       if ( !aShadingAspect.IsNull() )
588       {
589         Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
590                                       getQuantityColorVal( myFillingColor.green() ),
591                                       getQuantityColorVal( myFillingColor.blue() ),
592                                       Quantity_TOC_RGB );
593
594         aShadingAspect->SetColor( aFillingColor );
595         aShadingAspect->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
596       }
597     }
598     else if ( myDisplayMode == AIS_WireFrame )
599     {
600     }
601
602     // Coloring borders
603     colorShapeBorder( getActiveColor() );
604   }
605
606   if ( !theToDisplay || !isVisible() || myContext.IsNull() )
607     return;
608   
609   displayShape( theIsUpdateViewer );
610 }
611
612 void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer )
613 {
614   myContext->Display( myShape, Standard_False );
615
616   if ( myZLayer >= 0 )
617     myContext->SetZLayer( myShape, myZLayer );
618
619   if ( theIsUpdateViewer ) {
620     myContext->UpdateCurrentViewer();
621   }
622 }
623
624 QColor HYDROGUI_Shape::getActiveColor() const
625 {
626   return isHighlighted() ? myHighlightColor : myBorderColor;
627 }
628
629 double HYDROGUI_Shape::getQuantityColorVal( const int theColorVal )
630 {
631   return theColorVal == 0 ? 0 : ( (double)theColorVal / 255 );
632 }
633
634 void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
635 {
636   if ( myShape.IsNull() )
637     return;
638
639   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
640   if ( anAttributes.IsNull() )
641     return;
642
643   Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
644                                getQuantityColorVal( theColor.green() ),
645                                getQuantityColorVal( theColor.blue() ),
646                                Quantity_TOC_RGB );
647   
648   if( !myTopoShape.IsNull() )
649   {
650     if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
651     {
652       myShape->SetColor( aBorderColor );
653     }
654     else if ( myDisplayMode == AIS_Shaded )
655     {
656       if ( theColor.alpha() == 0 )
657       {
658         anAttributes->SetFaceBoundaryDraw( false );
659       }
660       else
661       {
662         anAttributes->SetFaceBoundaryDraw( true );
663   
664         Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
665         if ( !aBoundaryAspect.IsNull() )
666         {
667           aBoundaryAspect->SetColor( aBorderColor );
668           anAttributes->SetFaceBoundaryAspect( aBoundaryAspect );
669         }
670         Handle(Prs3d_LineAspect) aWireAspect = anAttributes->WireAspect();
671         if ( !aWireAspect.IsNull() )
672         {
673           aWireAspect->SetColor( aBorderColor );
674           anAttributes->SetWireAspect( aWireAspect );
675         }
676       }
677     }
678     else if ( myDisplayMode == AIS_WireFrame )
679     {
680       myShape->SetColor( aBorderColor );
681     }
682   }
683 }
684
685 void HYDROGUI_Shape::setDisplayMode( int theDisplayMode )
686 {
687   myDisplayMode = theDisplayMode;
688 }