From: adv Date: Fri, 27 Sep 2013 12:23:23 +0000 (+0000) Subject: HYDRO shapes are merged to drawing of Wires and Faces instead of drawing Faces only. X-Git-Tag: BR_hydro_v_0_3~102 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6b5a988d51713fab265b393b9f1811f725b5f8f;p=modules%2Fhydro.git HYDRO shapes are merged to drawing of Wires and Faces instead of drawing Faces only. --- diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 33ceeda2..1a69cfb9 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -56,7 +56,8 @@ HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext myBorderColor( Qt::black ), myHighlightColor( Qt::white ), myIsToUpdate( false ), - myIsVisible( true ) + myIsVisible( true ), + myDisplayMode( AIS_WireFrame ) { } @@ -70,7 +71,7 @@ HYDROGUI_Shape::~HYDROGUI_Shape() void HYDROGUI_Shape::display( const bool theIsUpdateViewer ) { - if ( myContext.IsNull() || myShape.IsNull() ) + if ( myContext.IsNull() || myShape.IsNull() || !isVisible() ) return; myContext->Display( myShape, theIsUpdateViewer ); @@ -118,7 +119,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) } } - if ( myShape.IsNull() ) + if ( myShape.IsNull() || !isVisible() ) return; myContext->Display( myShape, theIsUpdateViewer ); @@ -163,6 +164,17 @@ bool HYDROGUI_Shape::isHighlighted() const void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire, const bool theToDisplay, const bool theIsUpdateViewer ) +{ + myTopoShape = theWire; + myDisplayMode = AIS_WireFrame; + + buildShape(); + updateShape( theToDisplay, theIsUpdateViewer ); +} + +void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire, + const bool theToDisplay, + const bool theIsUpdateViewer ) { BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True ); aFaceBuilder.Build(); @@ -177,7 +189,9 @@ void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace, const bool theToDisplay, const bool theIsUpdateViewer ) { - myFace = theFace; + myTopoShape = theFace; + myDisplayMode = AIS_Shaded; + buildShape(); updateShape( theToDisplay, theIsUpdateViewer ); } @@ -223,38 +237,45 @@ void HYDROGUI_Shape::buildShape() // Erase previously created shape erase(); - if( myFace.IsNull() ) + if ( myTopoShape.IsNull() ) return; - myShape = new AIS_Shape( myFace ); + myShape = new AIS_Shape( myTopoShape ); if ( !myObject.IsNull() ) myShape->SetOwner( myObject ); myShape->SetTransparency( 0 ); - myShape->SetDisplayMode( AIS_Shaded ); + myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode ); - // Init default params for shape + // Init default params for shape const Handle(AIS_Drawer)& anAttributes = myShape->Attributes(); if ( !anAttributes.IsNull() ) { - Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect(); - if ( !anIsoAspect.IsNull() ) - anIsoAspect->SetNumber( 0 ); - - anIsoAspect = anAttributes->VIsoAspect(); - if ( !anIsoAspect.IsNull() ) - anIsoAspect->SetNumber( 0 ); - - Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect(); - if ( !aShadingAspect.IsNull() ) + if ( myDisplayMode == AIS_Shaded ) { - Graphic3d_MaterialAspect aMatAspect; - aMatAspect.SetAmbient( 1 ); - aMatAspect.SetDiffuse( 0 ); - - aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect ); - aShadingAspect->Aspect()->SetBackMaterial( aMatAspect ); + Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect(); + if ( !anIsoAspect.IsNull() ) + anIsoAspect->SetNumber( 0 ); + + anIsoAspect = anAttributes->VIsoAspect(); + if ( !anIsoAspect.IsNull() ) + anIsoAspect->SetNumber( 0 ); + + Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect(); + if ( !aShadingAspect.IsNull() ) + { + Graphic3d_MaterialAspect aMatAspect; + aMatAspect.SetAmbient( 1 ); + aMatAspect.SetDiffuse( 0 ); + + aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect ); + aShadingAspect->Aspect()->SetBackMaterial( aMatAspect ); + } + } + else if ( myDisplayMode == AIS_WireFrame ) + { + anAttributes->SetWireDraw( true ); } } } @@ -268,24 +289,30 @@ void HYDROGUI_Shape::updateShape( const bool theToDisplay, const Handle(AIS_Drawer)& anAttributes = myShape->Attributes(); if ( !anAttributes.IsNull() ) { - // Coloring face filling - Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect(); - if ( !aShadingAspect.IsNull() ) + if ( myDisplayMode == AIS_Shaded ) + { + // Coloring face filling + Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect(); + if ( !aShadingAspect.IsNull() ) + { + Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), + getQuantityColorVal( myFillingColor.green() ), + getQuantityColorVal( myFillingColor.blue() ), + Quantity_TOC_RGB ); + + aShadingAspect->SetColor( aFillingColor ); + aShadingAspect->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) ); + } + } + else if ( myDisplayMode == AIS_WireFrame ) { - Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), - getQuantityColorVal( myFillingColor.green() ), - getQuantityColorVal( myFillingColor.blue() ), - Quantity_TOC_RGB ); - - aShadingAspect->SetColor( aFillingColor ); - aShadingAspect->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) ); } // Coloring borders colorShapeBorder( getActiveColor() ); } - if ( !theToDisplay || myContext.IsNull() ) + if ( !theToDisplay || !isVisible() || myContext.IsNull() ) return; myContext->Display( myShape, theIsUpdateViewer ); @@ -310,25 +337,29 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor ) if ( anAttributes.IsNull() ) return; - if ( theColor.alpha() == 0 ) + Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), + getQuantityColorVal( theColor.green() ), + getQuantityColorVal( theColor.blue() ), + Quantity_TOC_RGB ); + if ( myDisplayMode == AIS_Shaded ) { - anAttributes->SetFaceBoundaryDraw( false ); - } - else - { - Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), - getQuantityColorVal( theColor.green() ), - getQuantityColorVal( theColor.blue() ), - Quantity_TOC_RGB ); - - anAttributes->SetFaceBoundaryDraw( true ); - - Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect(); - if ( !aBoundaryAspect.IsNull() ) + if ( theColor.alpha() == 0 ) + { + anAttributes->SetFaceBoundaryDraw( false ); + } + else { - aBoundaryAspect->SetColor( aBorderColor ); + anAttributes->SetFaceBoundaryDraw( true ); + + Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect(); + if ( !aBoundaryAspect.IsNull() ) + aBoundaryAspect->SetColor( aBorderColor ); } } + else if ( myDisplayMode == AIS_WireFrame ) + { + myShape->SetColor( aBorderColor ); + } } diff --git a/src/HYDROGUI/HYDROGUI_Shape.h b/src/HYDROGUI/HYDROGUI_Shape.h index 6572c80d..7e67eb08 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.h +++ b/src/HYDROGUI/HYDROGUI_Shape.h @@ -62,6 +62,10 @@ public: const bool theToDisplay = true, const bool theIsUpdateViewer = true ); + virtual void setFace( const TopoDS_Wire& theWire, + const bool theToDisplay = true, + const bool theIsUpdateViewer = true ); + virtual void setFace( const TopoDS_Face& theFace, const bool theToDisplay = true, const bool theIsUpdateViewer = true ); @@ -98,7 +102,8 @@ private: bool myIsVisible; bool myIsHighlight; - TopoDS_Face myFace; + TopoDS_Shape myTopoShape; + int myDisplayMode; QColor myFillingColor; QColor myBorderColor; diff --git a/src/HYDROGUI/HYDROGUI_ZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ZoneOp.cxx index 5825105e..216904b6 100644 --- a/src/HYDROGUI/HYDROGUI_ZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZoneOp.cxx @@ -306,7 +306,7 @@ void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName ) myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false ); myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false ); - myPreviewPrs->setWire( aWire ); + myPreviewPrs->setFace( aWire ); } void HYDROGUI_ZoneOp::onLastViewClosed( SUIT_ViewManager* theViewManager )