//
#include <HYDROGUI_BathymetryPrs.h>
-#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
+#include <Prs3d_Text.hxx>
+#include <Prs3d_TextAspect.hxx>
#include <Select3D_SensitiveBox.hxx>
-#include <Graphic3d_Group.hxx>
+#include <Select3D_SensitivePoint.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
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();
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() );
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,
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 );
+ 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<int>& 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;
}