Salome HOME
refs #1330: draft preferences implementation for polyline arrow
[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 #include <HYDROGUI_AISShape.h>
23
24 #include <HYDROData_Channel.h>
25 #include <HYDROData_Document.h>
26 #include <HYDROData_DummyObject3D.h>
27 #include <HYDROData_ImmersibleZone.h>
28 #include <HYDROData_Obstacle.h>
29 #include <HYDROData_PolylineXY.h>
30 #include <HYDROData_Polyline3D.h>
31 #include <HYDROData_Profile.h>
32 #include <HYDROData_ShapesGroup.h>
33 #include <HYDROData_Stream.h>
34 #include <HYDROData_Zone.h>
35 #include <HYDROData_LandCoverMap.h>
36
37 #include <BRep_Builder.hxx>
38 #include <BRepBuilderAPI_MakeFace.hxx>
39 #include <Prs3d_IsoAspect.hxx>
40 #include <TopoDS.hxx>
41 #include <TopoDS_Face.hxx>
42 #include <TopoDS_Wire.hxx>
43 #include <TopExp_Explorer.hxx>
44
45 HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
46                                 const Handle(HYDROData_Entity)&       theObject,
47                                 const int                             theZLayer )
48 : myContext( theContext ),
49   myObject( theObject ),
50   myZLayer( theZLayer ),
51   myIsHighlight( false ),
52   myFillingColor( Qt::transparent ),
53   myBorderColor( Qt::black ),
54   myHighlightColor( Qt::white ),
55   myIsToUpdate( false ),
56   myIsVisible( true ),
57   myDisplayMode( AIS_Shaded ),
58   mySelectionMode( AIS_Shape::SelectionMode( TopAbs_SHAPE ) )
59 {
60 }
61
62 HYDROGUI_Shape::~HYDROGUI_Shape()
63 {
64   erase( false );
65 }
66
67 Handle(AIS_InteractiveContext) HYDROGUI_Shape::getContext() const
68 {
69   return myContext;
70 }
71
72 Handle(HYDROData_Entity) HYDROGUI_Shape::getObject() const
73 {
74   return myObject;
75 }
76
77 TopoDS_Shape HYDROGUI_Shape::getTopoShape() const
78 {
79   return myTopoShape;
80 }
81
82 bool HYDROGUI_Shape::getIsToUpdate() const
83 {
84   return myIsToUpdate;
85 }
86
87 void HYDROGUI_Shape::setIsToUpdate( bool theState )
88 {
89   myIsToUpdate = theState;
90 }
91
92 bool HYDROGUI_Shape::isVisible() const
93 {
94   return myIsVisible;
95 }
96
97 QList<Handle(AIS_InteractiveObject)> HYDROGUI_Shape::getAISObjects() const
98 {
99   return myShapes;
100 }
101
102 void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
103 {
104   if ( myContext.IsNull() || myShapes.empty() || !isVisible() )
105     return;
106
107   displayShape( theIsUpdateViewer );
108 }
109
110 void HYDROGUI_Shape::erase( const bool theIsUpdateViewer )
111 {
112   if ( myContext.IsNull() || myShapes.empty() )
113     return;
114
115   eraseShape( theIsUpdateViewer );
116 }
117
118 void HYDROGUI_Shape::update( bool isUpdateViewer,
119                              bool isDeactivateSelection )
120
121 {
122   setIsToUpdate( false );
123
124   if ( myContext.IsNull() )
125     return;
126
127   // Try to retrieve information from object
128   if ( !myObject.IsNull() )
129   {
130     Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myObject->Label() );
131   
132     if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ImmersibleZone) ) )
133     {
134       Handle(HYDROData_ImmersibleZone) aZoneObj =
135         Handle(HYDROData_ImmersibleZone)::DownCast( myObject );
136
137       TopoDS_Shape aZoneShape = aZoneObj->GetTopShape();
138       if ( !aZoneShape.IsNull() ) {
139         if ( aZoneShape.ShapeType() == TopAbs_FACE ) {
140           TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
141           setFace( aZoneFace, false, false, "" );
142         } else {
143           myTopoShape = aZoneShape;
144           //TODO: myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
145           myDisplayMode = AIS_Shaded;
146
147           buildShape();
148           updateShape( false, false );
149         }
150       }
151
152       QColor aFillingColor = aZoneObj->GetFillingColor();
153       QColor aBorderColor = aZoneObj->GetBorderColor();
154
155       setFillingColor( aFillingColor, false, false );
156       setBorderColor( aBorderColor, false, false );
157     }
158     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_PolylineXY) ) )
159     {
160       Handle(HYDROData_PolylineXY) aPolyline =
161         Handle(HYDROData_PolylineXY)::DownCast( myObject );
162
163       TopoDS_Shape aPolylineShape = aPolyline->GetShape();
164
165       if ( !aPolylineShape.IsNull() )
166       {
167         if ( aPolylineShape.ShapeType() == TopAbs_WIRE )
168         {
169           TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
170           setWire( aPolylineWire, false, false );  
171         }
172         else
173         {
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 ( myShapes.empty() || !isVisible() )
306     return;
307
308   displayShape( isUpdateViewer );
309
310   if (isDeactivateSelection)
311     foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
312       myContext->Deactivate( aShape );
313 }
314
315 void HYDROGUI_Shape::setVisible( const bool theState,
316                                  const bool theIsUpdateViewer )
317 {
318   myIsVisible = theState;
319
320   if ( myShapes.empty() )
321     return;
322
323   if ( ( myIsVisible && myContext->IsDisplayed( myShapes[0] ) ) ||
324        ( !myIsVisible && !myContext->IsDisplayed( myShapes[0] ) ) )
325     return;
326
327   if ( myIsVisible ) {
328     displayShape( theIsUpdateViewer );
329   }
330   else
331     eraseShape( theIsUpdateViewer );
332 }
333
334 void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
335 {
336   if ( myIsHighlight == theIsHighlight )
337     return;
338
339   myIsHighlight = theIsHighlight;
340
341   if ( myContext.IsNull() || myShapes.empty() )
342     return;
343
344   colorShapeBorder( getActiveColor() );
345   displayShape( isUpdateViewer );
346 }
347
348 bool HYDROGUI_Shape::isHighlighted() const
349 {
350   return myIsHighlight;
351 }
352
353 void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire,
354                               const bool         theToDisplay,
355                               const bool         theIsUpdateViewer )
356 {
357   myTopoShape = theWire;
358   // To avoid that hilight presentation is equal to "normal" object presentation.
359   // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
360   myDisplayMode = AIS_Shaded;
361
362   buildShape();
363   updateShape( theToDisplay, theIsUpdateViewer );
364 }
365
366 void HYDROGUI_Shape::setFaces( const TopoDS_Compound& theWires,
367                                const bool             theToDisplay,
368                                const bool             theIsUpdateViewer )
369 {
370   TopExp_Explorer anExp( theWires, TopAbs_WIRE );
371   TopoDS_Compound aCompound;
372   BRep_Builder aBuilder;
373     aBuilder.MakeCompound( aCompound );
374
375   for ( ; anExp.More(); anExp.Next() ) {
376     TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
377     if ( aWire.IsNull() ) {
378       continue;
379     }
380
381     BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
382     aMakeFace.Build();
383     if( aMakeFace.IsDone() ) {
384       aBuilder.Add( aCompound, aMakeFace.Face() );
385     }
386   }
387
388   myTopoShape = aCompound;
389   myDisplayMode = AIS_Shaded;
390
391   buildShape();
392   updateShape( theToDisplay, theIsUpdateViewer );
393 }
394
395 void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
396                               const bool         theToDisplay,
397                               const bool         theIsUpdateViewer,
398                               const QString&     theTextureFileName )
399 {
400   BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True );
401   aFaceBuilder.Build();
402   if( aFaceBuilder.IsDone() )
403   {
404     TopoDS_Face aFace = aFaceBuilder.Face();
405     setFace( aFace, theToDisplay, theIsUpdateViewer, theTextureFileName );
406   }
407 }
408
409 void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
410                               const bool         theToDisplay,
411                               const bool         theIsUpdateViewer,
412                               const QString&     theTextureFileName )
413 {
414   myTopoShape = theFace;
415   myDisplayMode = theTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
416   //Note: AIS_Shaded+2 is the same as AIS_ExactHLR
417   //TODO: it would be more suitable to use TexturedShape mode from GEOM_AISShape
418
419   buildShape();
420   updateShape( theToDisplay, theIsUpdateViewer );
421 }
422
423 void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
424                                const bool          theToDisplay,
425                                const bool          theIsUpdateViewer,
426                                const int           theDisplayMode )
427 {
428   myTopoShape = theShape;
429   myDisplayMode = theDisplayMode;
430
431   buildShape();
432   updateShape( theToDisplay, theIsUpdateViewer );
433 }
434
435 void HYDROGUI_Shape::setFillingColor( const QColor& theColor,
436                                       const bool    theToDisplay,
437                                       const bool    theIsUpdateViewer )
438 {
439   myFillingColor = theColor;
440   updateShape( theToDisplay, theIsUpdateViewer );
441 }
442
443 QColor HYDROGUI_Shape::getFillingColor() const
444 {
445   return myFillingColor;
446 }
447
448 void HYDROGUI_Shape::setBorderColor( const QColor& theColor,
449                                      const bool    theToDisplay,
450                                      const bool    theIsUpdateViewer )
451
452   myBorderColor = theColor;
453   updateShape( theToDisplay, theIsUpdateViewer );
454 }
455
456 QColor HYDROGUI_Shape::getBorderColor() const
457 {
458   return myBorderColor;
459 }
460
461 void HYDROGUI_Shape::setHighlightColor( const QColor& theColor )
462 {
463   myHighlightColor = theColor;
464 }
465
466 QColor HYDROGUI_Shape::getHighlightColor() const
467 {
468   return myHighlightColor;
469 }
470
471 void HYDROGUI_Shape::setZLayer( const int theZLayer )
472 {
473   if ( myZLayer == theZLayer )
474     return;
475
476   myZLayer = theZLayer;
477   if( isVisible() && !myContext.IsNull() && myZLayer >= 0 )
478     foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
479       myContext->SetZLayer( aShape, myZLayer );
480 }
481
482 QList<Handle(AIS_InteractiveObject)> HYDROGUI_Shape::createShape() const
483 {
484   QList<Handle(AIS_InteractiveObject)> shapes;
485   if( myTopoShape.IsNull() ) {
486     return shapes;
487   }
488
489   TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
490   bool IsWireEdgeCompound = aShapeType==TopAbs_COMPOUND;
491   if (IsWireEdgeCompound) {
492     TopoDS_Iterator itr(myTopoShape);
493     while (itr.More() && IsWireEdgeCompound) {
494       if (itr.Value().ShapeType() != TopAbs_WIRE && itr.Value().ShapeType() != TopAbs_EDGE)
495         IsWireEdgeCompound = false;
496       itr.Next();
497     }
498   }
499
500   if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound)
501   {
502     shapes.append( HYDROGUI_Polyline::createPresentations( myTopoShape ) );
503   }
504   else
505   {
506     shapes.append( new HYDROGUI_AISShape( myTopoShape ) );
507   }
508   return shapes;
509 }
510
511 void HYDROGUI_Shape::buildShape()
512 {
513   // Erase previously created shape
514   erase(false);
515
516   myShapes = createShape();
517   if( myShapes.empty() )
518     return;
519
520   foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
521   {
522     Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( aShape );
523     if( !anAISShape.IsNull() )
524       anAISShape ->SetHLRAngleAndDeviation( 0.001 );
525
526     if ( !myObject.IsNull() )
527       aShape->SetOwner( myObject );
528
529     if ( !myObject.IsNull() && !myObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) )
530       aShape->SetTransparency( 0 );
531     aShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
532
533     // Init default params for shape
534     const Handle(Prs3d_Drawer)& anAttributes = aShape->Attributes();
535     if ( !anAttributes.IsNull() )
536     {
537       Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
538       if ( !anIsoAspect.IsNull() ) {
539         anIsoAspect->SetNumber( 0 );
540         anAttributes->SetUIsoAspect( anIsoAspect );
541       }
542       
543       anIsoAspect = anAttributes->VIsoAspect();
544       if ( !anIsoAspect.IsNull() )
545       {
546         anIsoAspect->SetNumber( 0 );
547         anAttributes->SetVIsoAspect( anIsoAspect );
548       }
549
550       if ( myDisplayMode == AIS_Shaded )
551       {
552         aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
553       }
554       else if ( myDisplayMode == AIS_WireFrame )
555       {
556         anAttributes->SetWireDraw( true );
557       }
558     }
559   }
560 }
561
562 void HYDROGUI_Shape::updateShape( const bool theToDisplay,
563                                   const bool theIsUpdateViewer )
564 {
565   foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
566   {
567     const Handle(Prs3d_Drawer)& anAttributes = aShape->Attributes();
568     if ( !anAttributes.IsNull() )
569     {
570       if ( myDisplayMode == AIS_Shaded && myFillingColor.isValid() )
571       {
572         Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
573                                       getQuantityColorVal( myFillingColor.green() ),
574                                       getQuantityColorVal( myFillingColor.blue() ),
575                                       Quantity_TOC_RGB );
576   
577         aShape->SetColor( aFillingColor );
578         aShape->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
579       }
580       else if ( myDisplayMode == AIS_WireFrame )
581       {
582       }
583   
584       // Coloring borders
585     }
586   }
587   
588   colorShapeBorder( myBorderColor );
589   if ( !theToDisplay || !isVisible() || myContext.IsNull() )
590     return;
591   
592   displayShape( theIsUpdateViewer );
593 }
594
595 void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer )
596 {
597   if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
598     myContext->CloseLocalContext();
599
600   foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
601   {
602     if ( mySelectionMode > 0 )
603       // Display object in local context with selection
604       myContext->Display( aShape, 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( aShape, Standard_False );
610       else
611         // Display object in local context without selection
612         myContext->Display( aShape, myDisplayMode, -1, Standard_False, Standard_False );
613     }
614   }
615   
616   if ( mySelectionMode > 0 )
617   {
618     myContext->OpenLocalContext();
619     foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
620       myContext->Activate( aShape, mySelectionMode, Standard_True );
621   }
622
623   if ( myZLayer >= 0 )
624   {
625     foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
626       myContext->SetZLayer( aShape, myZLayer );
627   }
628
629   if ( theIsUpdateViewer ) {
630     myContext->UpdateCurrentViewer();
631   }
632 }
633
634 void HYDROGUI_Shape::eraseShape( const bool theIsUpdateViewer )
635 {
636   if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
637     myContext->CloseLocalContext();
638
639   foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
640     myContext->Erase( aShape, Standard_False );
641
642   if( theIsUpdateViewer )
643     myContext->UpdateCurrentViewer();
644 }
645
646 QColor HYDROGUI_Shape::getActiveColor() const
647 {
648   return isHighlighted() ? myHighlightColor : myBorderColor;
649 }
650
651 double HYDROGUI_Shape::getQuantityColorVal( const int theColorVal )
652 {
653   return theColorVal == 0 ? 0 : ( (double)theColorVal / 255 );
654 }
655
656 void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
657 {
658   foreach( Handle(AIS_InteractiveObject) aShape1, myShapes )
659   {
660     const Handle(Prs3d_Drawer)& anAttributes = aShape1->Attributes();
661     if ( anAttributes.IsNull() )
662       continue;
663
664     Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
665                                  getQuantityColorVal( theColor.green() ),
666                                  getQuantityColorVal( theColor.blue() ),
667                                  Quantity_TOC_RGB );
668   
669     if( !myTopoShape.IsNull() )
670     {
671       if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
672       {
673         aShape1->SetColor( aBorderColor );
674       }
675       else if ( myDisplayMode == AIS_Shaded )
676       {
677         Handle(HYDROGUI_AISShape) aShape = Handle(HYDROGUI_AISShape)::DownCast( aShape1 );
678         if( !aShape.IsNull() )
679           aShape->SetBorderColor( aBorderColor );
680       }
681       else if ( myDisplayMode == AIS_WireFrame )
682       {
683         aShape1->SetColor( aBorderColor );
684       }
685     }
686   }
687 }
688
689 void HYDROGUI_Shape::setDisplayMode( int theDisplayMode )
690 {
691   myDisplayMode = theDisplayMode;
692 }
693
694 void HYDROGUI_Shape::setSelectionMode( int theSelectionMode )
695 {
696   mySelectionMode = theSelectionMode;
697 }