Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
[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
35 #include <AIS_Shape.hxx>
36 #include <BRep_Builder.hxx>
37 #include <BRepBuilderAPI_MakeFace.hxx>
38 #include <Graphic3d_AspectFillArea3d.hxx>
39 #include <Prs3d_IsoAspect.hxx>
40 #include <Prs3d_ShadingAspect.hxx>
41 #include <TopoDS.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Wire.hxx>
44 #include <TopExp_Explorer.hxx>
45
46 HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
47                                 const Handle(HYDROData_Entity)&       theObject,
48                                 const int                             theZLayer )
49 : myContext( theContext ),
50   myObject( theObject ),
51   myZLayer( theZLayer ),
52   myIsHighlight( false ),
53   myFillingColor( Qt::transparent ),
54   myBorderColor( Qt::black ),
55   myHighlightColor( Qt::white ),
56   myIsToUpdate( false ),
57   myIsVisible( true ),
58   myDisplayMode( AIS_Shaded ),
59   mySelectionMode( AIS_Shape::SelectionMode( TopAbs_SHAPE ) )
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   eraseShape( 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( Qt::darkBlue ) );
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   }
304  
305   if ( myShape.IsNull() || !isVisible() )
306     return;
307
308   displayShape( isUpdateViewer );
309
310   if (isDeactivateSelection)
311     myContext->Deactivate(myShape);
312 }
313
314 void HYDROGUI_Shape::setVisible( const bool theState,
315                                  const bool theIsUpdateViewer )
316 {
317   myIsVisible = theState;
318
319   if ( myShape.IsNull() )
320     return;
321
322   if ( ( myIsVisible && myContext->IsDisplayed( myShape ) ) ||
323        ( !myIsVisible && !myContext->IsDisplayed( myShape ) ) )
324     return;
325
326   if ( myIsVisible ) {
327     displayShape( theIsUpdateViewer );
328   }
329   else
330     eraseShape( theIsUpdateViewer );
331 }
332
333 void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
334 {
335   if ( myIsHighlight == theIsHighlight )
336     return;
337
338   myIsHighlight = theIsHighlight;
339
340   if ( myContext.IsNull() || myShape.IsNull() )
341     return;
342
343   colorShapeBorder( getActiveColor() );
344   displayShape( isUpdateViewer );
345 }
346
347 bool HYDROGUI_Shape::isHighlighted() const
348 {
349   return myIsHighlight;
350 }
351
352 void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire,
353                               const bool         theToDisplay,
354                               const bool         theIsUpdateViewer )
355 {
356   myTopoShape = theWire;
357   // To avoid that hilight presentation is equal to "normal" object presentation.
358   // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
359   myDisplayMode = AIS_Shaded;
360
361   buildShape();
362   updateShape( theToDisplay, theIsUpdateViewer );
363 }
364
365 void HYDROGUI_Shape::setFaces( const TopoDS_Compound& theWires,
366                                const bool             theToDisplay,
367                                const bool             theIsUpdateViewer )
368 {
369   TopExp_Explorer anExp( theWires, TopAbs_WIRE );
370   TopoDS_Compound aCompound;
371   BRep_Builder aBuilder;
372     aBuilder.MakeCompound( aCompound );
373
374   for ( ; anExp.More(); anExp.Next() ) {
375     TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
376     if ( aWire.IsNull() ) {
377       continue;
378     }
379
380     BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
381     aMakeFace.Build();
382     if( aMakeFace.IsDone() ) {
383       aBuilder.Add( aCompound, aMakeFace.Face() );
384     }
385   }
386
387   myTopoShape = aCompound;
388   myDisplayMode = AIS_Shaded;
389
390   buildShape();
391   updateShape( theToDisplay, theIsUpdateViewer );
392 }
393
394 void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
395                               const bool         theToDisplay,
396                               const bool         theIsUpdateViewer,
397                               const QString&     theTextureFileName )
398 {
399   BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True );
400   aFaceBuilder.Build();
401   if( aFaceBuilder.IsDone() )
402   {
403     TopoDS_Face aFace = aFaceBuilder.Face();
404     setFace( aFace, theToDisplay, theIsUpdateViewer, theTextureFileName );
405   }
406 }
407
408 void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
409                               const bool         theToDisplay,
410                               const bool         theIsUpdateViewer,
411                               const QString&     theTextureFileName )
412 {
413   myTopoShape = theFace;
414   myDisplayMode = theTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
415   //Note: AIS_Shaded+2 is the same as AIS_ExactHLR
416   //TODO: it would be more suitable to use TexturedShape mode from GEOM_AISShape
417
418   buildShape();
419   updateShape( theToDisplay, theIsUpdateViewer );
420 }
421
422 void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
423                                const bool          theToDisplay,
424                                const bool          theIsUpdateViewer )
425 {
426   myTopoShape = theShape;
427   myDisplayMode = AIS_Shaded;
428
429   buildShape();
430   updateShape( theToDisplay, theIsUpdateViewer );
431 }
432
433 void HYDROGUI_Shape::setFillingColor( const QColor& theColor,
434                                       const bool    theToDisplay,
435                                       const bool    theIsUpdateViewer )
436 {
437   myFillingColor = theColor;
438   updateShape( theToDisplay, theIsUpdateViewer );
439 }
440
441 QColor HYDROGUI_Shape::getFillingColor() const
442 {
443   return myFillingColor;
444 }
445
446 void HYDROGUI_Shape::setBorderColor( const QColor& theColor,
447                                      const bool    theToDisplay,
448                                      const bool    theIsUpdateViewer )
449
450   myBorderColor = theColor;
451   updateShape( theToDisplay, theIsUpdateViewer );
452 }
453
454 QColor HYDROGUI_Shape::getBorderColor() const
455 {
456   return myBorderColor;
457 }
458
459 void HYDROGUI_Shape::setHighlightColor( const QColor& theColor )
460 {
461   myHighlightColor = theColor;
462 }
463
464 QColor HYDROGUI_Shape::getHighlightColor() const
465 {
466   return myHighlightColor;
467 }
468
469 void HYDROGUI_Shape::setZLayer( const int theZLayer )
470 {
471   if ( myZLayer == theZLayer )
472     return;
473
474   myZLayer = theZLayer;
475   if ( !myShape.IsNull() && isVisible() && !myContext.IsNull() && myZLayer >= 0 )
476     myContext->SetZLayer( myShape, myZLayer );
477 }
478
479 Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const
480 {
481   if( myTopoShape.IsNull() ) {
482     return Handle_AIS_InteractiveObject();
483   }
484
485   TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
486   bool IsWireEdgeCompound = aShapeType==TopAbs_COMPOUND;
487   if (IsWireEdgeCompound) {
488     TopoDS_Iterator itr(myTopoShape);
489     while (itr.More() && IsWireEdgeCompound) {
490       if (itr.Value().ShapeType() != TopAbs_WIRE && itr.Value().ShapeType() != TopAbs_EDGE)
491         IsWireEdgeCompound = false;
492       itr.Next();
493     }
494   }
495
496   if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) {
497     return new HYDROGUI_Polyline( myTopoShape );
498   } else {
499     return new AIS_Shape( myTopoShape );
500   }
501 }
502
503 void HYDROGUI_Shape::buildShape()
504 {
505   // Erase previously created shape
506   erase();
507
508   myShape = createShape();
509   if( myShape.IsNull() )
510     return;
511
512   Handle_AIS_Shape anAISShape = Handle_AIS_Shape::DownCast( myShape );
513   if( !anAISShape.IsNull() )
514     anAISShape ->SetHLRAngleAndDeviation( 0.001 );
515
516   if ( !myObject.IsNull() )
517     myShape->SetOwner( myObject );
518
519   myShape->SetTransparency( 0 );
520   myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
521   myShape->SetSelectionMode( (Standard_Integer)mySelectionMode );
522
523     // Init default params for shape
524   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
525   if ( !anAttributes.IsNull() )
526   {
527     Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
528     if ( !anIsoAspect.IsNull() ) {
529       anIsoAspect->SetNumber( 0 );
530       anAttributes->SetUIsoAspect( anIsoAspect );
531     }
532       
533     anIsoAspect = anAttributes->VIsoAspect();
534     if ( !anIsoAspect.IsNull() ) {
535       anIsoAspect->SetNumber( 0 );
536       anAttributes->SetVIsoAspect( anIsoAspect );
537     }
538
539     if ( myDisplayMode == AIS_Shaded )
540     {
541       Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
542       if ( !aShadingAspect.IsNull() )
543       {
544         Graphic3d_MaterialAspect aMatAspect( Graphic3d_NOM_PLASTIC );
545         //aMatAspect.SetAmbient( 1 );
546         //aMatAspect.SetDiffuse( 0 );
547
548         aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect );
549         aShadingAspect->Aspect()->SetBackMaterial( aMatAspect );
550       }
551     }
552     else if ( myDisplayMode == AIS_WireFrame )
553     {
554       anAttributes->SetWireDraw( true );
555     }
556   }
557 }
558
559 void HYDROGUI_Shape::updateShape( const bool theToDisplay,
560                                   const bool theIsUpdateViewer )
561 {
562   if ( myShape.IsNull() )
563     return;
564
565   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
566   if ( !anAttributes.IsNull() )
567   {
568     if ( myDisplayMode == AIS_Shaded )
569     {
570       // Coloring face filling
571       Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
572       if ( !aShadingAspect.IsNull() )
573       {
574         Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
575                                       getQuantityColorVal( myFillingColor.green() ),
576                                       getQuantityColorVal( myFillingColor.blue() ),
577                                       Quantity_TOC_RGB );
578
579         aShadingAspect->SetColor( aFillingColor );
580         aShadingAspect->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
581       }
582     }
583     else if ( myDisplayMode == AIS_WireFrame )
584     {
585     }
586
587     // Coloring borders
588     colorShapeBorder( getActiveColor() );
589   }
590
591   if ( !theToDisplay || !isVisible() || myContext.IsNull() )
592     return;
593   
594   displayShape( theIsUpdateViewer );
595 }
596
597 void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer )
598 {
599   if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
600     myContext->CloseLocalContext();
601
602   if ( mySelectionMode > 0 )
603     // Display object in local context with selection
604     myContext->Display( myShape, myDisplayMode, mySelectionMode, Standard_False, Standard_False );
605   else
606   {
607     if ( !myContext->HasOpenedContext() )
608       // Ordinary display of object published in the Object Browser
609       myContext->Display( myShape, Standard_False );
610     else
611       // Display object in local context without selection
612       myContext->Display( myShape, myDisplayMode, -1, Standard_False, Standard_False );
613   }
614   
615   if ( mySelectionMode > 0 )
616   {
617     myContext->OpenLocalContext();
618     myContext->Activate( myShape, mySelectionMode, Standard_True );
619   }
620
621   if ( myZLayer >= 0 )
622     myContext->SetZLayer( myShape, myZLayer );
623
624   if ( theIsUpdateViewer ) {
625     myContext->UpdateCurrentViewer();
626   }
627 }
628
629 void HYDROGUI_Shape::eraseShape( const bool theIsUpdateViewer )
630 {
631   if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
632     myContext->CloseLocalContext();
633
634   myContext->Erase( myShape, theIsUpdateViewer );
635 }
636
637 QColor HYDROGUI_Shape::getActiveColor() const
638 {
639   return isHighlighted() ? myHighlightColor : myBorderColor;
640 }
641
642 double HYDROGUI_Shape::getQuantityColorVal( const int theColorVal )
643 {
644   return theColorVal == 0 ? 0 : ( (double)theColorVal / 255 );
645 }
646
647 void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
648 {
649   if ( myShape.IsNull() )
650     return;
651
652   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
653   if ( anAttributes.IsNull() )
654     return;
655
656   Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
657                                getQuantityColorVal( theColor.green() ),
658                                getQuantityColorVal( theColor.blue() ),
659                                Quantity_TOC_RGB );
660   
661   if( !myTopoShape.IsNull() )
662   {
663     if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
664     {
665       myShape->SetColor( aBorderColor );
666     }
667     else if ( myDisplayMode == AIS_Shaded )
668     {
669       if ( theColor.alpha() == 0 )
670       {
671         anAttributes->SetFaceBoundaryDraw( false );
672       }
673       else
674       {
675         anAttributes->SetFaceBoundaryDraw( true );
676   
677         Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
678         if ( !aBoundaryAspect.IsNull() )
679         {
680           aBoundaryAspect->SetColor( aBorderColor );
681           anAttributes->SetFaceBoundaryAspect( aBoundaryAspect );
682         }
683         Handle(Prs3d_LineAspect) aWireAspect = anAttributes->WireAspect();
684         if ( !aWireAspect.IsNull() )
685         {
686           aWireAspect->SetColor( aBorderColor );
687           anAttributes->SetWireAspect( aWireAspect );
688         }
689       }
690     }
691     else if ( myDisplayMode == AIS_WireFrame )
692     {
693       myShape->SetColor( aBorderColor );
694     }
695   }
696 }
697
698 void HYDROGUI_Shape::setDisplayMode( int theDisplayMode )
699 {
700   myDisplayMode = theDisplayMode;
701 }
702
703 void HYDROGUI_Shape::setSelectionMode( int theSelectionMode )
704 {
705   mySelectionMode = theSelectionMode;
706 }