X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_BathymetryPrs.cxx;h=63d04939820a11689b5c9ff7dc527804ebbec7fa;hb=6074577ddf7ed43a22093a51d50d53b99adaea5e;hp=2bcc235db51e1122cf10b639a2c62d34b3c66ed7;hpb=2cf9e838e652ae811d9b3931914771ad1836c6b8;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx b/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx index 2bcc235d..63d04939 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx @@ -17,56 +17,72 @@ // #include -#include #include #include -#include -#include +#include +#include #include -#include +#include #include +#include const int BATH_HIGHLIGHT_MODE = 10; -HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs() +HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs( const HYDROGUI_ShapeBathymetry* theShape ) + : myShape( theShape ) { SetHilightMode( BATH_HIGHLIGHT_MODE ); + SetAutoHilight( Standard_True ); } HYDROGUI_BathymetryPrs::~HYDROGUI_BathymetryPrs() { } -void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords, - const Handle(Quantity_HArray1OfColor)& theColors ) +HYDROGUI_ShapeBathymetry* HYDROGUI_BathymetryPrs::GetShape() const +{ + return const_cast( myShape ); +} + +void HYDROGUI_BathymetryPrs::UpdateBound() { + Handle(Graphic3d_ArrayOfPoints) points = GetPoints(); myBound.SetVoid(); - if( !theCoords.IsNull() ) + if( !points.IsNull() ) { - int aLower = theCoords->Lower(); - int anUpper = theCoords->Upper(); + int aLower = 1; + int anUpper = points->VertexNumber(); for( int i = aLower; i <= anUpper; i++ ) { + gp_Pnt p = points->Vertice( i ); if( i==aLower ) - myBound.Set( theCoords->Value( i ) ); + myBound.Set( p ); else - { - gp_Pnt aPnt = theCoords->Value( i ); - myBound.Update( aPnt.X(), aPnt.Y(), aPnt.Z() ); - } + myBound.Update( p.X(), p.Y(), p.Z() ); } } +} + +void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords, + const Handle(Quantity_HArray1OfColor)& theColors ) +{ AIS_PointCloud::SetPoints( theCoords, theColors ); + UpdateBound(); } void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode ) { + thePresentation->Clear(); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); + if( theMode==BATH_HIGHLIGHT_MODE ) { - thePresentation->Clear(); + if( myBound.IsVoid() ) + UpdateBound(); + if( myBound.IsVoid() || myBound.IsOpenXmin() || myBound.IsOpenXmax() || myBound.IsOpenYmin() || myBound.IsOpenYmax() || @@ -76,7 +92,6 @@ void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d) Standard_Real xmin, xmax, ymin, ymax, zmin, zmax; myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax ); - Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 ); aGroup->SetPrimitivesAspect( aWireAspect->Aspect() ); @@ -109,7 +124,23 @@ void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d) aGroup->AddPrimitiveArray( aLines ); } else + { AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode ); + + Handle(Graphic3d_ArrayOfPoints) points = GetPoints(); + if( !myTextIndices.empty() && !points.IsNull() ) + { + char aBuf[1024]; + Handle(Prs3d_TextAspect) anAspect = new Prs3d_TextAspect(); + + foreach( int index, myTextIndices ) + { + gp_Pnt p = points->Vertice( index ); + sprintf( aBuf, "%.2f", p.Z() ); + Prs3d_Text::Draw( aGroup, anAspect, aBuf, p ); + } + } + } } void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection, @@ -117,6 +148,9 @@ void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection) { if( theMode == 0 ) { + if( myBound.IsVoid() ) + UpdateBound(); + if( myBound.IsVoid() || myBound.IsOpenXmin() || myBound.IsOpenXmax() || myBound.IsOpenYmin() || myBound.IsOpenYmax() || @@ -127,4 +161,120 @@ void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection) Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound ); theSelection->Add( aSensitiveBox ); } + if( theMode == 1 ) + { + Handle(Graphic3d_ArrayOfPoints) points = GetPoints(); + int n = points.IsNull() ? 0 : points->VertexNumber(); + for( int i=1; i<=n; i++ ) + { + gp_Pnt p = points->Vertice( i ); + Handle(HYDROGUI_BathymetryPointOwner) anOwner = new HYDROGUI_BathymetryPointOwner( this, i ); + Handle(Select3D_SensitivePoint) aSensitivePoint = new Select3D_SensitivePoint( anOwner, p ); + theSelection->Add( aSensitivePoint ); + } + } +} + +int HYDROGUI_BathymetryPrs::NbPoints() const +{ + Handle(Graphic3d_ArrayOfPoints) points = GetPoints(); + int n = points.IsNull() ? 0 : points->VertexNumber(); + return n; +} + +gp_Pnt HYDROGUI_BathymetryPrs::GetPoint( int theIndex ) const +{ + Handle(Graphic3d_ArrayOfPoints) points = GetPoints(); + if( points.IsNull() ) + return gp_Pnt(); + else + return points->Vertice( theIndex ); +} + +void HYDROGUI_BathymetryPrs::AddPoint( const Handle(Graphic3d_ArrayOfPoints)& thePoints, + const Handle(SelectMgr_EntityOwner)& theOwner ) +{ + Handle(HYDROGUI_BathymetryPointOwner) anOwner = Handle(HYDROGUI_BathymetryPointOwner)::DownCast( theOwner ); + if( anOwner.IsNull() ) + return; + gp_Pnt p = GetPoint( anOwner->GetIndex() ); + thePoints->AddVertex( p ); +} + +void HYDROGUI_BathymetryPrs::HilightOwnerWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theColor, + const Handle(SelectMgr_EntityOwner)& theOwner ) +{ + Handle(Prs3d_Presentation) aHilightPrs = GetHilightPresentation( thePM ); + aHilightPrs->SetZLayer( Graphic3d_ZLayerId_Topmost ); + aHilightPrs->Clear(); + Handle(Graphic3d_ArrayOfPoints) points = new Graphic3d_ArrayOfPoints( 1 ); + AddPoint( points, theOwner ); + + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aHilightPrs ); + Handle(Graphic3d_AspectMarker3d) anAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_X, Quantity_NOC_WHITE, 1.0 ); + aGroup->SetGroupPrimitivesAspect( anAspect ); + aGroup->AddPrimitiveArray( points ); + + if( thePM->IsImmediateModeOn() ) + thePM->AddToImmediateList( aHilightPrs ); +} + +void HYDROGUI_BathymetryPrs::HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePM, + const SelectMgr_SequenceOfOwner& theOwners ) +{ + Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( thePM ); + aSelectPrs->SetZLayer( Graphic3d_ZLayerId_Topmost ); + aSelectPrs->Clear(); + + Handle(Graphic3d_ArrayOfPoints) points = new Graphic3d_ArrayOfPoints( theOwners.Size() ); + for( int i=theOwners.Lower(); i<=theOwners.Upper(); i++ ) + AddPoint( points, theOwners.Value( i ) ); + + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aSelectPrs ); + Handle(Graphic3d_AspectMarker3d) anAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_X, Quantity_NOC_WHITE, 1.0 ); + aGroup->SetGroupPrimitivesAspect( anAspect ); + aGroup->AddPrimitiveArray( points ); + + aSelectPrs->SetDisplayPriority(9); + aSelectPrs->Display(); +} + +void HYDROGUI_BathymetryPrs::ClearSelected() +{ + Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( NULL ); + if( !aSelectPrs.IsNull() ) + aSelectPrs->Clear(); +} + +void HYDROGUI_BathymetryPrs::SetTextLabels( const QList& theTextIndices ) +{ + myTextIndices = theTextIndices; +} + + + + + + + +HYDROGUI_BathymetryPointOwner::HYDROGUI_BathymetryPointOwner + ( const Handle(HYDROGUI_BathymetryPrs)& theBathymetry, int theIndex ) + : SelectMgr_EntityOwner( Handle(SelectMgr_SelectableObject)::DownCast( theBathymetry ), 0 ), + myIndex( theIndex ) +{ +} + +HYDROGUI_BathymetryPointOwner::~HYDROGUI_BathymetryPointOwner() +{ +} + +Standard_Boolean HYDROGUI_BathymetryPointOwner::IsAutoHilight() const +{ + return Standard_False; +} + +int HYDROGUI_BathymetryPointOwner::GetIndex() const +{ + return myIndex; }