#include <Graphic3d_ArrayOfPoints.hxx>
#include <Image_PixMap.hxx>
#include <Graphic3d_MarkerImage.hxx>
+#include <TColStd_HPackedMapOfInteger.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
#include <QImage>
void HYDROGUI_BathymetryPrs::UpdateBound()
{
+ DEBTRACE("UpdateBound");
Handle(Graphic3d_ArrayOfPoints) points = GetPoints();
myBound.SetVoid();
if( !points.IsNull() )
}
void HYDROGUI_BathymetryPrs::SetPoints( const Handle(TColgp_HArray1OfPnt)& theCoords,
- const Handle(Quantity_HArray1OfColor)& theColors )
+ const Handle(Quantity_HArray1OfColor)& theColors,
+ const Handle(TColgp_HArray1OfDir)& theNormals )
{
- AIS_PointCloud::SetPoints( theCoords, theColors );
- UpdateBound();
+ AIS_PointCloud::SetPoints( theCoords, theColors, theNormals );
+ //UpdateBound();
}
void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Standard_Integer theMode )
{
DEBTRACE("Compute " << theMode);
- thePresentation->Clear();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
+// thePresentation->Clear();
+// Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
- if( theMode==BATH_HIGHLIGHT_MODE ) // highlight ==> draw bounding box
+ if( theMode== BATH_HIGHLIGHT_MODE ) // highlight ==> draw bounding box
{
- if( myBound.IsVoid() )
- UpdateBound();
-
- if( myBound.IsVoid() ||
- myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
- myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
- myBound.IsOpenZmin() || myBound.IsOpenZmax() )
- return;
-
- Standard_Real xmin, xmax, ymin, ymax, zmin, zmax;
- myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax );
-
- Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_DASH, 4.0 );
- aGroup->SetPrimitivesAspect( aWireAspect->Aspect() ); // use Aspect_TOL_DASH to find the group by the aspect style
-
- Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 );
-
- aLines->AddBound( 5 );
- aLines->AddVertex( xmin, ymin, zmin );
- aLines->AddVertex( xmax, ymin, zmin );
- aLines->AddVertex( xmax, ymax, zmin );
- aLines->AddVertex( xmin, ymax, zmin );
- aLines->AddVertex( xmin, ymin, zmin );
- aLines->AddBound( 5 );
- aLines->AddVertex( xmin, ymin, zmax );
- aLines->AddVertex( xmax, ymin, zmax );
- aLines->AddVertex( xmax, ymax, zmax );
- aLines->AddVertex( xmin, ymax, zmax );
- aLines->AddVertex( xmin, ymin, zmax );
- aLines->AddBound( 2 );
- aLines->AddVertex( xmin, ymin, zmin );
- aLines->AddVertex( xmin, ymin, zmax );
- aLines->AddBound( 2 );
- aLines->AddVertex( xmax, ymin, zmin );
- aLines->AddVertex( xmax, ymin, zmax );
- aLines->AddBound( 2 );
- aLines->AddVertex( xmax, ymax, zmin );
- aLines->AddVertex( xmax, ymax, zmax );
- aLines->AddBound( 2 );
- aLines->AddVertex( xmin, ymax, zmin );
- aLines->AddVertex( xmin, ymax, zmax );
- aGroup->AddPrimitiveArray( aLines );
+ AIS_PointCloud::Compute( thePresentationManager, thePresentation, AIS_PointCloud::DM_BndBox );
+// if( myBound.IsVoid() )
+// UpdateBound();
+//
+// if( myBound.IsVoid() ||
+// myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
+// myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
+// myBound.IsOpenZmin() || myBound.IsOpenZmax() )
+// return;
+//
+// Standard_Real xmin, xmax, ymin, ymax, zmin, zmax;
+// myBound.Get( xmin, ymin, zmin, xmax, ymax, zmax );
+//
+// Handle(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_DASH, 4.0 );
+// aGroup->SetPrimitivesAspect( aWireAspect->Aspect() ); // use Aspect_TOL_DASH to find the group by the aspect style
+//
+// Handle(Graphic3d_ArrayOfPolylines) aLines = new Graphic3d_ArrayOfPolylines( 18, 6 );
+//
+// aLines->AddBound( 5 );
+// aLines->AddVertex( xmin, ymin, zmin );
+// aLines->AddVertex( xmax, ymin, zmin );
+// aLines->AddVertex( xmax, ymax, zmin );
+// aLines->AddVertex( xmin, ymax, zmin );
+// aLines->AddVertex( xmin, ymin, zmin );
+// aLines->AddBound( 5 );
+// aLines->AddVertex( xmin, ymin, zmax );
+// aLines->AddVertex( xmax, ymin, zmax );
+// aLines->AddVertex( xmax, ymax, zmax );
+// aLines->AddVertex( xmin, ymax, zmax );
+// aLines->AddVertex( xmin, ymin, zmax );
+// aLines->AddBound( 2 );
+// aLines->AddVertex( xmin, ymin, zmin );
+// aLines->AddVertex( xmin, ymin, zmax );
+// aLines->AddBound( 2 );
+// aLines->AddVertex( xmax, ymin, zmin );
+// aLines->AddVertex( xmax, ymin, zmax );
+// aLines->AddBound( 2 );
+// aLines->AddVertex( xmax, ymax, zmin );
+// aLines->AddVertex( xmax, ymax, zmax );
+// aLines->AddBound( 2 );
+// aLines->AddVertex( xmin, ymax, zmin );
+// aLines->AddVertex( xmin, ymax, zmax );
+// aGroup->AddPrimitiveArray( aLines );
}
- else
+ else if (theMode == 0)
{
DEBTRACE("non highlight mode"); // display the nodes as points with color (HYDROGUI_ShapeBathymetry::UpdateWithColorScale)
- AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode );
+ AIS_PointCloud::Compute( thePresentationManager, thePresentation, AIS_PointCloud::DM_Points );
QImage qtMark( 4, 4, QImage::Format_RGB888 ); // points marks as 4x4 rectangles
Handle(Image_PixMap) aMark = HYDROGUI_Tool::Pixmap( qtMark );
if (!asp.IsNull())
{
DEBTRACE("aspect: " << asp->get_type_name());
+ DEBTRACE("asp->LineType() " << asp->LineType());
if (asp->LineType() != Aspect_TOL_DASH) // find the group which does not correspond to the bounding box
aGrp->SetGroupPrimitivesAspect( anAspect );
}
}
-
- Handle(Graphic3d_ArrayOfPoints) points = GetPoints();
- if (!points.IsNull())
- DEBTRACE("nb points " << points->ItemNumber());
-
- if( !myTextIndices.empty() && !points.IsNull() ) // points selected ==> altitude labels
- {
- DEBTRACE("myTextIndices.size() " << myTextIndices.size());
- 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 );
- }
- }
+//
+// Handle(Graphic3d_ArrayOfPoints) points = GetPoints();
+// if (!points.IsNull())
+// DEBTRACE("nb points " << points->ItemNumber());
+//
+// if( !myTextIndices.empty() && !points.IsNull() ) // points selected ==> altitude labels
+// {
+// DEBTRACE("myTextIndices.size() " << myTextIndices.size());
+// 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 );
+// }
+// }
}
+ else
+ DEBTRACE("Do nothing");
}
void HYDROGUI_BathymetryPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode )
{
- if( theMode == 0 )
- {
- if( myBound.IsVoid() )
- UpdateBound();
-
- if( myBound.IsVoid() ||
- myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
- myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
- myBound.IsOpenZmin() || myBound.IsOpenZmax() )
- return;
-
- Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this );
- Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound );
- theSelection->Add( aSensitiveBox );
- }
- if( theMode == 1 )
+ DEBTRACE("ComputeSelection " << theMode);
+ switch (theMode)
{
- Handle(Graphic3d_ArrayOfPoints) points = GetPoints();
- int n = points.IsNull() ? 0 : points->VertexNumber();
- for( int i=1; i<=n; i++ )
+ case 0:
{
- 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 );
+ DEBTRACE("Bounding box selection");
+ AIS_PointCloud::ComputeSelection( theSelection, SM_BndBox);
+ break;
+ }
+ case 1:
+ {
+ DEBTRACE("Subset of points detection");
+ AIS_PointCloud::ComputeSelection( theSelection, SM_SubsetOfPoints );
+ break;
+ }
+ default:
+ {
+ DEBTRACE("Do Nothing");
+ return;
}
}
+
+// if( theMode == 0 )
+// {
+// if( myBound.IsVoid() )
+// UpdateBound();
+//
+// if( myBound.IsVoid() ||
+// myBound.IsOpenXmin() || myBound.IsOpenXmax() ||
+// myBound.IsOpenYmin() || myBound.IsOpenYmax() ||
+// myBound.IsOpenZmin() || myBound.IsOpenZmax() )
+// return;
+//
+// Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner( this );
+// Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, myBound );
+// theSelection->Add( aSensitiveBox );
+// }
+// if( theMode == 1 )
+// {
+// AIS_PointCloud::ComputeSelection(theSelection, theMode);
+//// 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
void HYDROGUI_BathymetryPrs::AddPoint( const Handle(Graphic3d_ArrayOfPoints)& thePoints,
const Handle(SelectMgr_EntityOwner)& theOwner )
{
+ DEBTRACE("AddPoint");
Handle(HYDROGUI_BathymetryPointOwner) anOwner = Handle(HYDROGUI_BathymetryPointOwner)::DownCast( theOwner );
if( anOwner.IsNull() )
return;
}
void HYDROGUI_BathymetryPrs::HilightOwnerWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
- const Handle(Graphic3d_HighlightStyle)& theColor,
+ const Handle(Prs3d_Drawer)& theColor,
const Handle(SelectMgr_EntityOwner)& theOwner )
{
+ DEBTRACE("HilightOwnerWithColor");
Handle(Prs3d_Presentation) aHilightPrs = GetHilightPresentation( thePM );
aHilightPrs->SetZLayer( Graphic3d_ZLayerId_Topmost );
aHilightPrs->Clear();
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 ) );
+ DEBTRACE("HilightSelected " << theOwners.Size());
+ if (theOwners.Size() == 0)
+ return;
+ Handle(SelectMgr_EntityOwner) owner = theOwners.First();
+ Handle(AIS_PointCloudOwner) anOwner = Handle(AIS_PointCloudOwner)::DownCast( owner );
+ if (anOwner.IsNull())
+ return;
+ Handle(TColStd_HPackedMapOfInteger) thePointsH = anOwner->SelectedPoints();
+ TColStd_PackedMapOfInteger thePoints = thePointsH->Map();
+ DEBTRACE("thePoints.Extent() :" << thePoints.Extent());
+ Handle(TColStd_HPackedMapOfInteger) thePointsDH = anOwner->DetectedPoints();
+ TColStd_PackedMapOfInteger thePointsD = thePointsDH->Map();
+ DEBTRACE("thePointsD.Extent() :" << thePointsD.Extent());
- 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();
+// 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()
{
+ DEBTRACE("ClearSelected");
Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( NULL );
if( !aSelectPrs.IsNull() )
aSelectPrs->Clear();
void HYDROGUI_BathymetryPrs::SetTextLabels( const QVector<int>& theTextIndices )
{
+ DEBTRACE("SetTextLabels");
myTextIndices = theTextIndices;
}