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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <HYDROGUI_Shape.h>
20 #include <HYDROGUI_Tool.h>
21 #include <HYDROGUI_Polyline.h>
22 #include <HYDROGUI_AISShape.h>
24 #include <HYDROData_Channel.h>
25 #include <HYDROData_Document.h>
26 #include <HYDROData_DummyObject3D.h>
27 #include <HYDROData_ImmersibleZone.h>
28 #include <HYDROData_BCPolygon.h>
29 #include <HYDROData_Obstacle.h>
30 #include <HYDROData_PolylineXY.h>
31 #include <HYDROData_Polyline3D.h>
32 #include <HYDROData_Profile.h>
33 #include <HYDROData_ShapesGroup.h>
34 #include <HYDROData_Stream.h>
35 #include <HYDROData_Zone.h>
36 #include <HYDROData_LandCoverMap.h>
38 #include <BRep_Builder.hxx>
39 #include <BRepBuilderAPI_MakeFace.hxx>
40 #include <Prs3d_IsoAspect.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Wire.hxx>
44 #include <TopExp_Explorer.hxx>
47 #include <SUIT_ResourceMgr.h>
48 #include <SUIT_Session.h>
51 #include "HYDRO_trace.hxx"
53 HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
54 const Handle(HYDROData_Entity)& theObject,
56 : myContext( theContext ),
57 myObject( theObject ),
58 myZLayer( theZLayer ),
59 myIsHighlight( false ),
60 myFillingColor( Qt::transparent ),
61 myBorderColor( Qt::black ),
62 myHighlightColor( Qt::white ),
63 myIsToUpdate( false ),
65 myDisplayMode( AIS_Shaded ),
66 mySelectionMode( AIS_Shape::SelectionMode( TopAbs_SHAPE ) )
70 HYDROGUI_Shape::~HYDROGUI_Shape()
75 Handle(AIS_InteractiveContext) HYDROGUI_Shape::getContext() const
80 Handle(HYDROData_Entity) HYDROGUI_Shape::getObject() const
85 TopoDS_Shape HYDROGUI_Shape::getTopoShape() const
90 bool HYDROGUI_Shape::getIsToUpdate() const
95 void HYDROGUI_Shape::setIsToUpdate( bool theState )
97 myIsToUpdate = theState;
100 bool HYDROGUI_Shape::isVisible() const
105 QList<Handle(AIS_InteractiveObject)> HYDROGUI_Shape::getAISObjects() const
110 void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
112 if ( myContext.IsNull() || myShapes.empty() || !isVisible() )
115 displayShape( theIsUpdateViewer );
118 void HYDROGUI_Shape::erase( const bool theIsUpdateViewer )
120 if ( myContext.IsNull() || myShapes.empty() )
123 eraseShape( theIsUpdateViewer );
126 void HYDROGUI_Shape::update( bool isUpdateViewer,
127 bool isDeactivateSelection )
130 DEBTRACE("update " << isUpdateViewer << " " << isDeactivateSelection);
131 setIsToUpdate( false );
133 if ( myContext.IsNull() )
136 // Try to retrieve information from object
137 if ( !myObject.IsNull() )
139 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document();
141 if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ImmersibleZone) ) )
143 Handle(HYDROData_ImmersibleZone) aZoneObj =
144 Handle(HYDROData_ImmersibleZone)::DownCast( myObject );
146 TopoDS_Shape aZoneShape = aZoneObj->GetTopShape();
147 if ( !aZoneShape.IsNull() ) {
148 if ( aZoneShape.ShapeType() == TopAbs_FACE ) {
149 TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
150 setFace( aZoneFace, false, false, "" );
152 myTopoShape = aZoneShape;
153 //TODO: myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
154 myDisplayMode = AIS_Shaded;
157 updateShape( false, false );
161 QColor aFillingColor = aZoneObj->GetFillingColor();
162 QColor aBorderColor = aZoneObj->GetBorderColor();
164 setFillingColor( aFillingColor, false, false );
165 setBorderColor( aBorderColor, false, false );
167 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_PolylineXY) ) )
169 Handle(HYDROData_PolylineXY) aPolyline =
170 Handle(HYDROData_PolylineXY)::DownCast( myObject );
172 TopoDS_Shape aPolylineShape = aPolyline->GetShape();
174 if ( !aPolylineShape.IsNull() )
176 if ( aPolylineShape.ShapeType() == TopAbs_WIRE )
178 TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
179 setWire( aPolylineWire, false, false );
183 myTopoShape = aPolylineShape;
184 // Set shading mode to avoid that hilight presentation is equal to "normal" object presentation.
185 // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
186 myDisplayMode = AIS_Shaded;
189 updateShape( false, false );
193 //QColor aWireColor = aPolyline->GetWireColor();
194 std::vector<QColor> aSectColors;
195 //TODO backward comp. with old aWireColor??
196 int nbSec = aPolyline->NbSections();
197 for (int i = 0; i < nbSec; i++)
200 aPolyline->GetSectionColor(i, aColor);
201 aSectColors.push_back(aColor);
205 //setBorderColor( aWireColor, false, false );
207 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
209 if( !myTopoShape.IsNull() )
211 Handle(HYDROGUI_Polyline) aPShape = Handle(HYDROGUI_Polyline)::DownCast( aShape );
212 bool WireOrCmp = myTopoShape.ShapeType() == TopAbs_WIRE || myTopoShape.ShapeType() == TopAbs_COMPOUND;
213 if ( !aPShape.IsNull() && WireOrCmp)
215 TopTools_IndexedMapOfShape MW;
216 TopExp::MapShapes(myTopoShape, TopAbs_WIRE, MW);
217 if (MW.Extent() == nbSec)
219 for (int i=0;i<nbSec;i++)
221 const TopoDS_Shape& CW = MW(i+1);
222 Quantity_Color aFColor( getQuantityColorVal( aSectColors[i].red() ),
223 getQuantityColorVal( aSectColors[i].green() ),
224 getQuantityColorVal( aSectColors[i].blue() ),
226 aPShape->myShapeToColor.Add(CW, aFColor);
233 //if ( theToDisplay && isVisible() && !myContext.IsNull() )
234 // displayShape( false );
236 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
238 Handle(HYDROData_Polyline3D) aPolyline =
239 Handle(HYDROData_Polyline3D)::DownCast( myObject );
241 TopoDS_Shape aPolylineShape = aPolyline->GetShape3D();
243 if ( !aPolylineShape.IsNull() ) {
244 if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) {
245 TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
246 setWire( aPolylineWire, false, false );
248 myTopoShape = aPolylineShape;
249 // Set shading mode to avoid that hilight presentation is equal to "normal" object presentation.
250 // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
251 myDisplayMode = AIS_Shaded;
254 updateShape( false, false );
258 QColor aWireColor = aPolyline->GetBorderColor();
259 setBorderColor( aWireColor, false, false );
261 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
263 Handle(HYDROData_Zone) aZone =
264 Handle(HYDROData_Zone)::DownCast( myObject );
266 TopoDS_Face aZoneFace = TopoDS::Face( aZone->GetShape() );
268 setFace( aZoneFace, false, false, "" );
269 if( aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN )
271 // Red color for a zone with bathymetry conflict
272 setFillingColor( Qt::red );
276 // Set the filling color for zone
277 setFillingColor( aZone->GetColor( Qt::darkBlue ) );
280 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) )
282 Handle(HYDROData_Profile) aProfile =
283 Handle(HYDROData_Profile)::DownCast( myObject );
285 TopoDS_Wire aProfileWire;
287 if ( aProfile->IsValid() ) {
288 TopoDS_Shape aProfileShape = aProfile->GetShape3D();
290 if ( !aProfileShape.IsNull() &&
291 aProfileShape.ShapeType() == TopAbs_WIRE ) {
292 aProfileWire = TopoDS::Wire( aProfileShape );
296 setWire( aProfileWire, false, false );
298 QColor aWireColor = aProfile->GetBorderColor();
299 setBorderColor( aWireColor, false, false );
301 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) ||
302 myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) ||
303 myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
305 Handle(HYDROData_Object) aGeomObject =
306 Handle(HYDROData_Object)::DownCast( myObject );
308 TopoDS_Shape anObjShape = aGeomObject->GetTopShape();
310 setShape( anObjShape, false, false );
312 QColor aFillingColor = aGeomObject->GetFillingColor();
313 QColor aBorderColor = aGeomObject->GetBorderColor();
315 setFillingColor( aFillingColor, false, false );
316 setBorderColor( aBorderColor, false, false );
318 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_DummyObject3D) ) )
320 Handle(HYDROData_DummyObject3D) anObject3D =
321 Handle(HYDROData_DummyObject3D)::DownCast( myObject );
322 TopoDS_Shape aShape3D = anObject3D->GetShape();
324 setShape( aShape3D, false, false );
326 QColor aFillingColor = anObject3D->GetFillingColor();
327 QColor aBorderColor = anObject3D->GetBorderColor();
329 setFillingColor( aFillingColor, false, false );
330 setBorderColor( aBorderColor, false, false );
332 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ShapesGroup) ) )
334 Handle(HYDROData_ShapesGroup) aShapesGroup =
335 Handle(HYDROData_ShapesGroup)::DownCast( myObject );
337 TopTools_SequenceOfShape aShapes;
338 aShapesGroup->GetShapes( aShapes );
340 TopoDS_Compound aCompound;
341 BRep_Builder aCompoundBuilder;
342 aCompoundBuilder.MakeCompound( aCompound );
344 for ( int i = 1, n = aShapes.Length(); i <= n; ++i )
346 const TopoDS_Shape& aShape = aShapes.Value( i );
347 aCompoundBuilder.Add( aCompound, aShape );
350 setShape( aCompound, false, false );
352 else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_BCPolygon) ) )
354 Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( myObject );
356 TopoDS_Shape aBCShape = aBCObj->GetTopShape();
357 if ( !aBCShape.IsNull() )
359 if ( aBCShape.ShapeType() == TopAbs_FACE )
361 TopoDS_Face aBCFace = TopoDS::Face( aBCShape );
362 setFace( aBCFace, false, false, "" );
366 myTopoShape = aBCShape;
367 myDisplayMode = AIS_Shaded;
369 updateShape( false, false );
373 QColor aFillingColor = aBCObj->GetFillingColor();
374 QColor aBorderColor = aBCObj->GetBorderColor();
375 aFillingColor.setAlpha(175);
377 setFillingColor( aFillingColor, false, false );
378 setBorderColor( aBorderColor, false, false );
383 if ( myShapes.empty() || !isVisible() )
386 displayShape( isUpdateViewer );
388 if (isDeactivateSelection)
389 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
390 myContext->Deactivate( aShape );
393 void HYDROGUI_Shape::setVisible( const bool theState,
394 const bool theIsUpdateViewer )
396 DEBTRACE("setVisible")
397 myIsVisible = theState;
399 if ( myShapes.empty() )
402 if ( ( myIsVisible && myContext->IsDisplayed( myShapes[0] ) ) ||
403 ( !myIsVisible && !myContext->IsDisplayed( myShapes[0] ) ) )
407 displayShape( theIsUpdateViewer );
410 eraseShape( theIsUpdateViewer );
413 void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
415 DEBTRACE("highlight " << theIsHighlight << " " << isUpdateViewer);
416 if ( myIsHighlight == theIsHighlight )
419 myIsHighlight = theIsHighlight;
421 if ( myContext.IsNull() || myShapes.empty() )
424 colorShapeBorder( getActiveColor() );
425 displayShape( isUpdateViewer );
428 bool HYDROGUI_Shape::isHighlighted() const
430 DEBTRACE("isHighlighted " << myIsHighlight);
431 return myIsHighlight;
434 void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire,
435 const bool theToDisplay,
436 const bool theIsUpdateViewer )
438 myTopoShape = theWire;
439 // To avoid that hilight presentation is equal to "normal" object presentation.
440 // Note that hilight presentation is always to be on top ( i.e. in the top Z layer ).
441 myDisplayMode = AIS_Shaded;
444 updateShape( theToDisplay, theIsUpdateViewer );
447 void HYDROGUI_Shape::setFaces( const TopoDS_Compound& theWires,
448 const bool theToDisplay,
449 const bool theIsUpdateViewer )
451 TopExp_Explorer anExp( theWires, TopAbs_WIRE );
452 TopoDS_Compound aCompound;
453 BRep_Builder aBuilder;
454 aBuilder.MakeCompound( aCompound );
456 for ( ; anExp.More(); anExp.Next() ) {
457 TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
458 if ( aWire.IsNull() ) {
462 BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
464 if( aMakeFace.IsDone() ) {
465 aBuilder.Add( aCompound, aMakeFace.Face() );
469 myTopoShape = aCompound;
470 myDisplayMode = AIS_Shaded;
473 updateShape( theToDisplay, theIsUpdateViewer );
476 void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
477 const bool theToDisplay,
478 const bool theIsUpdateViewer,
479 const QString& theTextureFileName )
481 BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True );
482 aFaceBuilder.Build();
483 if( aFaceBuilder.IsDone() )
485 TopoDS_Face aFace = aFaceBuilder.Face();
486 setFace( aFace, theToDisplay, theIsUpdateViewer, theTextureFileName );
490 void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
491 const bool theToDisplay,
492 const bool theIsUpdateViewer,
493 const QString& theTextureFileName )
495 myTopoShape = theFace;
496 myDisplayMode = theTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
497 //Note: AIS_Shaded+2 is the same as AIS_ExactHLR
498 //TODO: it would be more suitable to use TexturedShape mode from GEOM_AISShape
501 updateShape( theToDisplay, theIsUpdateViewer );
504 void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
505 const bool theToDisplay,
506 const bool theIsUpdateViewer,
507 const int theDisplayMode )
509 myTopoShape = theShape;
510 myDisplayMode = theDisplayMode;
513 updateShape( theToDisplay, theIsUpdateViewer );
516 void HYDROGUI_Shape::setFillingColor( const QColor& theColor,
517 const bool theToDisplay,
518 const bool theIsUpdateViewer )
520 myFillingColor = theColor;
521 updateShape( theToDisplay, theIsUpdateViewer );
524 QColor HYDROGUI_Shape::getFillingColor() const
526 return myFillingColor;
529 void HYDROGUI_Shape::setBorderColor( const QColor& theColor,
530 const bool theToDisplay,
531 const bool theIsUpdateViewer )
533 myBorderColor = theColor;
534 updateShape( theToDisplay, theIsUpdateViewer );
537 QColor HYDROGUI_Shape::getBorderColor() const
539 return myBorderColor;
542 void HYDROGUI_Shape::setHighlightColor( const QColor& theColor )
544 myHighlightColor = theColor;
547 QColor HYDROGUI_Shape::getHighlightColor() const
549 return myHighlightColor;
552 void HYDROGUI_Shape::setZLayer( const int theZLayer )
554 if ( myZLayer == theZLayer )
557 myZLayer = theZLayer;
558 if( isVisible() && !myContext.IsNull() && myZLayer >= 0 )
559 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
560 myContext->SetZLayer( aShape, myZLayer );
563 QList<Handle(AIS_InteractiveObject)> HYDROGUI_Shape::createShape() const
565 QList<Handle(AIS_InteractiveObject)> shapes;
566 if( myTopoShape.IsNull() ) {
570 TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
571 bool IsWireEdgeCompound = aShapeType==TopAbs_COMPOUND;
572 if (IsWireEdgeCompound) {
573 TopoDS_Iterator itr(myTopoShape);
574 while (itr.More() && IsWireEdgeCompound) {
575 if (itr.Value().ShapeType() != TopAbs_WIRE && itr.Value().ShapeType() != TopAbs_EDGE)
576 IsWireEdgeCompound = false;
581 if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound)
583 SUIT_ResourceMgr* aResMgr = 0;
584 SUIT_Session* aSession = SUIT_Session::session();
586 aResMgr = SUIT_Session::session()->resourceMgr();
591 if( myShapes.length()>1 )
593 Handle(HYDROGUI_Arrow) arrow = Handle(HYDROGUI_Arrow)::DownCast( myShapes[1] );
594 if( !arrow.IsNull() )
596 aType = arrow->GetType();
597 aSize = arrow->GetSize();
600 if( aResMgr && ( aType<0 || aSize < 0 ) )
602 aResMgr->value( "polyline", "arrow_type", aType );
603 aResMgr->value( "polyline", "arrow_size", aSize );
606 shapes.append( HYDROGUI_Polyline::createPresentations( myTopoShape, aType, aSize ) );
610 shapes.append( new HYDROGUI_AISShape( myTopoShape ) );
615 void HYDROGUI_Shape::buildShape()
617 // Erase previously created shape
620 myShapes = createShape();
621 if( myShapes.empty() )
624 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
626 Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( aShape );
627 if( !anAISShape.IsNull() )
628 anAISShape ->SetHLRAngleAndDeviation( 0.001 );
630 if ( !myObject.IsNull() )
631 aShape->SetOwner( myObject );
633 if ( !myObject.IsNull() && !myObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) )
634 aShape->SetTransparency( 0 );
635 aShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
637 // Init default params for shape
638 const Handle(Prs3d_Drawer)& anAttributes = aShape->Attributes();
639 if ( !anAttributes.IsNull() )
641 Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
642 if ( !anIsoAspect.IsNull() ) {
643 anIsoAspect->SetNumber( 0 );
644 anAttributes->SetUIsoAspect( anIsoAspect );
647 anIsoAspect = anAttributes->VIsoAspect();
648 if ( !anIsoAspect.IsNull() )
650 anIsoAspect->SetNumber( 0 );
651 anAttributes->SetVIsoAspect( anIsoAspect );
654 if ( myDisplayMode == AIS_Shaded )
656 aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
658 else if ( myDisplayMode == AIS_WireFrame )
660 anAttributes->SetWireDraw( true );
666 void HYDROGUI_Shape::updateShape( const bool theToDisplay,
667 const bool theIsUpdateViewer )
669 DEBTRACE("updateShape " << theToDisplay << " " << theIsUpdateViewer);
670 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
672 const Handle(Prs3d_Drawer)& anAttributes = aShape->Attributes();
673 if ( !anAttributes.IsNull() )
675 if ( myDisplayMode == AIS_Shaded && myFillingColor.isValid() )
677 Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ),
678 getQuantityColorVal( myFillingColor.green() ),
679 getQuantityColorVal( myFillingColor.blue() ),
682 aShape->SetColor( aFillingColor );
683 aShape->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
685 else if ( myDisplayMode == AIS_WireFrame )
693 colorShapeBorder( myBorderColor );
694 if ( !theToDisplay || !isVisible() || myContext.IsNull() )
697 displayShape( theIsUpdateViewer );
700 void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer )
702 DEBTRACE("displayShape " << theIsUpdateViewer << " " << mySelectionMode << " AIScontext " << myContext.get());
703 // if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
704 // myContext->CloseLocalContext();
706 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
708 if ( mySelectionMode >= 0 )
709 // Display object in local context with selection
710 //myContext->Display( aShape, myDisplayMode, mySelectionMode, Standard_False, Standard_False );
711 myContext->Display( aShape, Standard_False );
714 // if ( !myContext->HasOpenedContext() )
715 // Ordinary display of object published in the Object Browser
716 // myContext->Display( aShape, Standard_False );
718 // Display object in local context without selection
719 myContext->Display( aShape, myDisplayMode, -1, Standard_False, Standard_False );
723 if ( mySelectionMode >= 0 )
725 //myContext->Deactivate(); //OpenLocalContext();
726 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
727 myContext->Activate( aShape, mySelectionMode, Standard_True );
732 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
733 myContext->SetZLayer( aShape, myZLayer );
736 if ( theIsUpdateViewer ) {
737 myContext->UpdateCurrentViewer();
741 void HYDROGUI_Shape::eraseShape( const bool theIsUpdateViewer )
743 // if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
744 // myContext->CloseLocalContext();
746 foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
747 myContext->Erase( aShape, Standard_False );
749 if( theIsUpdateViewer )
750 myContext->UpdateCurrentViewer();
753 QColor HYDROGUI_Shape::getActiveColor() const
755 return isHighlighted() ? myHighlightColor : myBorderColor;
758 double HYDROGUI_Shape::getQuantityColorVal( const int theColorVal )
760 return theColorVal == 0 ? 0 : ( (double)theColorVal / 255 );
763 void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
765 foreach( Handle(AIS_InteractiveObject) aShape1, myShapes )
767 const Handle(Prs3d_Drawer)& anAttributes = aShape1->Attributes();
768 if ( anAttributes.IsNull() )
771 Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ),
772 getQuantityColorVal( theColor.green() ),
773 getQuantityColorVal( theColor.blue() ),
776 if( !myTopoShape.IsNull() )
778 if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
780 aShape1->SetColor( aBorderColor );
782 else if ( myDisplayMode == AIS_Shaded )
784 Handle(HYDROGUI_AISShape) aShape = Handle(HYDROGUI_AISShape)::DownCast( aShape1 );
785 if( !aShape.IsNull() )
786 aShape->SetBorderColor( aBorderColor );
788 else if ( myDisplayMode == AIS_WireFrame )
790 aShape1->SetColor( aBorderColor );
796 void HYDROGUI_Shape::setDisplayMode( int theDisplayMode )
798 myDisplayMode = theDisplayMode;
801 void HYDROGUI_Shape::setSelectionMode( int theSelectionMode )
803 mySelectionMode = theSelectionMode;