X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_Shape.cxx;h=7739a90ed91925faf577af9c7c5c45b407847c7e;hb=f34b90e9e4e02ba65419134d5d37a2e42aecfabf;hp=06c4a6f5b1da47f6ce3fc19ae1598d5df2c23951;hpb=2d99821157e770385d7af917b2d22d6aa3cacb7e;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 06c4a6f5..7739a90e 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -47,6 +49,7 @@ #include #include #include +#include #include #include @@ -109,13 +112,15 @@ void HYDROGUI_Shape::erase( const bool theIsUpdateViewer ) myContext->Erase( myShape, theIsUpdateViewer ); } -void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) +void HYDROGUI_Shape::update( const bool theIsUpdateViewer, + const bool theIsDisplayOnTop ) { setIsToUpdate( false ); if ( myContext.IsNull() ) return; + bool isDeactivateSelection = false; // Try to retrieve information from object if ( !myObject.IsNull() ) { @@ -295,6 +300,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) setTextureFileName( aTextureFileName, false, false ); setFace( aWire, false, false ); + isDeactivateSelection = true; } else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) ) { @@ -338,7 +344,6 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) { Handle(HYDROData_DummyObject3D) anObject3D = Handle(HYDROData_DummyObject3D)::DownCast( myObject ); - TopoDS_Shape aShape3D = anObject3D->GetShape(); setShape( aShape3D, false, false ); @@ -349,12 +354,45 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) setFillingColor( aFillingColor, false, false ); setBorderColor( aBorderColor, false, false ); } + else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ShapesGroup) ) ) + { + Handle(HYDROData_ShapesGroup) aShapesGroup = + Handle(HYDROData_ShapesGroup)::DownCast( myObject ); + + TopTools_SequenceOfShape aShapes; + aShapesGroup->GetShapes( aShapes ); + + TopoDS_Compound aCompound; + BRep_Builder aCompoundBuilder; + aCompoundBuilder.MakeCompound( aCompound ); + + for ( int i = 1, n = aShapes.Length(); i <= n; ++i ) + { + const TopoDS_Shape& aShape = aShapes.Value( i ); + aCompoundBuilder.Add( aCompound, aShape ); + } + + setShape( aCompound, false, false ); + } } if ( myShape.IsNull() || !isVisible() ) return; myContext->Display( myShape, theIsUpdateViewer ); + + if ( theIsDisplayOnTop ) { + // Display the shape on the top Z layer + Standard_Integer aNewLayerId = -1; + if ( myContext->CurrentViewer() && + myContext->CurrentViewer()->AddZLayer( aNewLayerId ) && + aNewLayerId > 0 ) { + myContext->SetZLayer( myShape, aNewLayerId ); + } + } + + if (isDeactivateSelection) + myContext->Deactivate(myShape); } void HYDROGUI_Shape::setVisible( const bool theState, @@ -374,7 +412,7 @@ void HYDROGUI_Shape::setVisible( const bool theState, myContext->Erase( myShape, theIsUpdateViewer ); } -void HYDROGUI_Shape::highlight( bool theIsHighlight ) +void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer ) { if ( myIsHighlight == theIsHighlight ) return; @@ -385,7 +423,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight ) return; colorShapeBorder( getActiveColor() ); - myContext->Display( myShape ); + myContext->Display( myShape, isUpdateViewer ); } bool HYDROGUI_Shape::isHighlighted() const @@ -541,6 +579,8 @@ void HYDROGUI_Shape::buildShape() myShape = new AIS_Shape( myTopoShape ); } + myShape->SetHLRAngleAndDeviation( 0.001 ); + if ( !myObject.IsNull() ) myShape->SetOwner( myObject ); @@ -580,9 +620,9 @@ void HYDROGUI_Shape::buildShape() Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect(); if ( !aShadingAspect.IsNull() ) { - Graphic3d_MaterialAspect aMatAspect; - aMatAspect.SetAmbient( 1 ); - aMatAspect.SetDiffuse( 0 ); + Graphic3d_MaterialAspect aMatAspect( Graphic3d_NOM_PLASTIC ); + //aMatAspect.SetAmbient( 1 ); + //aMatAspect.SetDiffuse( 0 ); aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect ); aShadingAspect->Aspect()->SetBackMaterial( aMatAspect ); @@ -668,7 +708,10 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor ) Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect(); if ( !aBoundaryAspect.IsNull() ) + { aBoundaryAspect->SetColor( aBorderColor ); + anAttributes->SetFaceBoundaryAspect( aBoundaryAspect ); + } } } else if ( myDisplayMode == AIS_WireFrame )