//
#include <HYDROGUI_BathymetryPrs.h>
+#include <HYDROGUI_ShapeBathymetry.h>
#include <HYDROGUI_Tool.h>
#include <Prs3d_Root.hxx>
#include <Graphic3d_MarkerImage.hxx>
#include <TColStd_HPackedMapOfInteger.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
+#include <unistd.h>
#include <QImage>
+#include <QVector>
#define _DEVDEBUG_
#include "HYDRO_trace.hxx"
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();
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
+ 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");
// 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 );
-//// }
-// }
+ 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
const Handle(SelectMgr_EntityOwner)& theOwner )
{
DEBTRACE("AddPoint");
- Handle(AIS_PointCloudOwner) anOwner = Handle(AIS_PointCloudOwner)::DownCast( theOwner );
+ Handle(HYDROGUI_BathymetryPointOwner) anOwner = Handle(HYDROGUI_BathymetryPointOwner)::DownCast( theOwner );
if( anOwner.IsNull() )
return;
-// gp_Pnt p = GetPoint( anOwner->GetIndex() );
-// thePoints->AddVertex( p );
+ DEBTRACE("index " << anOwner->GetIndex());
+ gp_Pnt p = GetPoint( anOwner->GetIndex() );
+ DEBTRACE("p: " << p.X() << " " << p.Y() << " " << p.Z());
+ thePoints->AddVertex( p );
}
void HYDROGUI_BathymetryPrs::HilightOwnerWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
return;
Handle(SelectMgr_EntityOwner) owner = theOwners.First();
Handle(AIS_PointCloudOwner) anOwner = Handle(AIS_PointCloudOwner)::DownCast( owner );
- if (anOwner.IsNull())
- return;
- DEBTRACE("immediateMode: " << thePM->IsImmediateModeOn()); // semble sans effet
- const Handle(TColStd_HPackedMapOfInteger)& aSMap = anOwner->SelectedPoints();
- DEBTRACE("selectedPoints.Extent() :" << aSMap->Map().Extent());
- const Handle(TColStd_HPackedMapOfInteger)& aDMap = anOwner->DetectedPoints();
- DEBTRACE("detectedPoints.Extent() :" << aDMap->Map().Extent());
+ if (!anOwner.IsNull())
+ {
+ DEBTRACE("immediateMode: " << thePM->IsImmediateModeOn()); // semble sans effet
+ const Handle(TColStd_HPackedMapOfInteger)& aSMap = anOwner->SelectedPoints();
+ DEBTRACE("selectedPoints.Extent() :" << aSMap->Map().Extent());
+ const Handle(TColStd_HPackedMapOfInteger)& aDMap = anOwner->DetectedPoints();
+ DEBTRACE("detectedPoints.Extent() :" << aDMap->Map().Extent());
+ }
+ Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( thePM );
+ aSelectPrs->SetZLayer( Graphic3d_ZLayerId_Topmost );
+ aSelectPrs->Clear();
-// 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();
+ //mySelectedPoints.clear();
+ mySelectedPoints.reserve(theOwners.Size());
+ Handle(Graphic3d_ArrayOfPoints) points = new Graphic3d_ArrayOfPoints( theOwners.Size() );
+ for( int i=theOwners.Lower(); i<=theOwners.Upper(); i++ )
+ {
+ AddPoint( points, theOwners.Value( i ) );
+ Handle(HYDROGUI_BathymetryPointOwner) anOwner = Handle(HYDROGUI_BathymetryPointOwner)::DownCast( theOwners.Value( i ) );
+ if (!anOwner.IsNull())
+ mySelectedPoints.append(anOwner->GetIndex());
+ }
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aSelectPrs );
+ //Handle(Graphic3d_Group) aGroup = aSelectPrs->NewGroup();
+ Handle(Graphic3d_AspectMarker3d) anAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_X, Quantity_NOC_WHITE, 1.0 );
+ aGroup->SetGroupPrimitivesAspect( anAspect );
+ aGroup->AddPrimitiveArray( points );
+
+ aSelectPrs->SetDisplayPriority(5);
+ aSelectPrs->Display();
+ //sleep(5);
}
void HYDROGUI_BathymetryPrs::ClearSelected()
#include <HYDROGUI_Operations.h>
#include <OCCViewer_ViewManager.h>
#include <LightApp_Application.h>
+#include <SUIT_Selector.h>
#include <QAction>
#include <QApplication>
+#include <QString>
+#include <QList>
+#include <LightApp_SelectionMgr.h>
#define _DEVDEBUG_
#include "HYDRO_trace.hxx"
QList<Handle(HYDROGUI_BathymetryPrs)> baths = getShownBathymetries( module() );
if( isActive )
{
+// QList<SUIT_Selector*> aSelectorList;
+// QString aViewType = OCCViewer_Viewer::Type();
+// LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr();
+// aSelectionMgr->selectors(aViewType, aSelectorList);
+// QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
+// for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
+// {
+// SUIT_Selector* aSelector = *anIter;
+// aSelector->setEnabled( false );
+// }
+
const int aSelectionMode = 1; // Cf. AIS_PointCloud 0=selection by points ?
//ctx->Deactivate( Standard_True );
//ctx->OpenLocalContext( Standard_True );
{
DEBTRACE("bathy name: " << bath->GetShape()->getObject()->GetName().toStdString());
ctx->Deactivate(bath);
+ ctx->RemoveFilters();
//ctx->Activate( bath, aSelectionMode, Standard_True );
- ctx->SetSelectionModeActive (bath, aSelectionMode, Standard_True, AIS_SelectionModesConcurrency_Single, Standard_False);
+ ctx->SetSelectionModeActive (bath, aSelectionMode, Standard_True, AIS_SelectionModesConcurrency_Multiple, Standard_False);
+ ctx->SetSelectionModeActive (bath, 0, Standard_True, AIS_SelectionModesConcurrency_Multiple, Standard_False);
bath->SetAutoHilight( Standard_False ); // True bloque le passage dans hilightSelected...
// DEBTRACE("immediateMode: " << ctx->MainPrsMgr()->IsImmediateModeOn());
// if (!ctx->MainPrsMgr()->IsImmediateModeOn())
{
DEBTRACE("selected");
QVector<int> selected;
- selected.reserve( myCoords->Size() );
- Handle(AIS_InteractiveObject) obj = getAISObjects().first();
+ // HYDROGUI_BathymetryPrs::ClearSelected() called before: Nothing left...
+// selected.reserve( myCoords->Size() );
+//
+// Handle(AIS_InteractiveObject) obj = getAISObjects().first();
+//
+// Handle(AIS_InteractiveContext) c = getContext();
+// int cnt = 0;
+// if( !c.IsNull() )
+// {
+// for( c->InitSelected(); c->MoreSelected(); c->NextSelected() )
+// {
+// cnt++;
+// Handle(HYDROGUI_BathymetryPointOwner) anOwner =
+// Handle(HYDROGUI_BathymetryPointOwner)::DownCast( c->SelectedOwner() );
+// if( !anOwner.IsNull() && anOwner->Selectable()==obj )
+// selected.append( anOwner->GetIndex() );
+// }
+// }
+// DEBTRACE("selected " << cnt << " " << selected.size() );
- Handle(AIS_InteractiveContext) c = getContext();
- int cnt = 0;
- if( !c.IsNull() )
- {
- for( c->InitSelected(); c->MoreSelected(); c->NextSelected() )
- {
- cnt++;
- Handle(HYDROGUI_BathymetryPointOwner) anOwner =
- Handle(HYDROGUI_BathymetryPointOwner)::DownCast( c->SelectedOwner() );
- if( !anOwner.IsNull() && anOwner->Selectable()==obj )
- selected.append( anOwner->GetIndex() );
- }
- }
- DEBTRACE("selected " << cnt << " " << selected.size() );
+ Handle(HYDROGUI_BathymetryPrs) aPntCloud = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObjects()[0] );
+ if (!aPntCloud.IsNull())
+ selected = aPntCloud->getSelectedPoints();
+ DEBTRACE("selected " << selected.size());
return selected;
}