From eb27f5330fc75a57eb3cb8783f02482c1ffd183e Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 18 Sep 2020 00:22:52 +0200 Subject: [PATCH] fix bathymetry points style = 4x4 rectangles (changes in occt 7.4) --- src/HYDROGUI/HYDROGUI_BathymetryOp.cxx | 5 ++ src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx | 52 ++++++++++++++----- .../HYDROGUI_BathymetrySelectionOp.cxx | 8 ++- src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx | 11 ++++ 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx index b0d6eff7..3c6cc317 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx @@ -33,6 +33,9 @@ #include #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + HYDROGUI_BathymetryLimitsDlg::HYDROGUI_BathymetryLimitsDlg( QWidget* theParent ) : QDialog( theParent ) { @@ -126,6 +129,7 @@ OCCViewer_ViewWindow* HYDROGUI_BathymetryOp::activeViewWindow() const void HYDROGUI_BathymetryOp::activate( bool isActivate ) { + DEBTRACE("activate " << isActivate); if( myIsActivate==isActivate ) return; @@ -231,6 +235,7 @@ void HYDROGUI_BathymetryOp::activate( bool isActivate ) void HYDROGUI_BathymetryOp::onSelectionChanged() { + DEBTRACE("onSelectionChanged"); QList baths = getShownBathymetries( module() ); bool isUpdateCS = false; diff --git a/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx b/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx index eeb49012..9b2c66a6 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx @@ -32,11 +32,15 @@ #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + const int BATH_HIGHLIGHT_MODE = 10; HYDROGUI_BathymetryPrs::HYDROGUI_BathymetryPrs( const HYDROGUI_ShapeBathymetry* theShape ) : myShape( theShape ) { + DEBTRACE("HYDROGUI_BathymetryPrs"); SetHilightMode( BATH_HIGHLIGHT_MODE ); SetAutoHilight( Standard_True ); } @@ -81,16 +85,16 @@ void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d) const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode ) { + DEBTRACE("Compute " << theMode); thePresentation->Clear(); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); - if( theMode==BATH_HIGHLIGHT_MODE ) + if( theMode==BATH_HIGHLIGHT_MODE ) // highlight ==> draw bounding box { if( myBound.IsVoid() ) UpdateBound(); - - if( myBound.IsVoid() || + if( myBound.IsVoid() || myBound.IsOpenXmin() || myBound.IsOpenXmax() || myBound.IsOpenYmin() || myBound.IsOpenYmax() || myBound.IsOpenZmin() || myBound.IsOpenZmax() ) @@ -99,11 +103,11 @@ 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(Prs3d_LineAspect) aWireAspect = new Prs3d_LineAspect( Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0 ); - aGroup->SetPrimitivesAspect( aWireAspect->Aspect() ); + 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 ); @@ -132,17 +136,39 @@ void HYDROGUI_BathymetryPrs::Compute( const Handle(PrsMgr_PresentationManager3d) } else { - Handle(Graphic3d_AspectMarker3d) anAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_USERDEFINED, Quantity_NOC_WHITE, 1.0 ); - QImage qtMark( 4, 4, QImage::Format_RGB888 ); - Handle(Image_PixMap) aMark = HYDROGUI_Tool::Pixmap( qtMark ); - Handle(Graphic3d_MarkerImage) gMark = new Graphic3d_MarkerImage(aMark); - anAspect->SetMarkerImage(gMark); + DEBTRACE("non highlight mode"); // display the nodes as points with color (HYDROGUI_ShapeBathymetry::UpdateWithColorScale) AIS_PointCloud::Compute( thePresentationManager, thePresentation, theMode ); - aGroup->SetGroupPrimitivesAspect( anAspect ); + + QImage qtMark( 4, 4, QImage::Format_RGB888 ); // points marks as 4x4 rectangles + Handle(Image_PixMap) aMark = HYDROGUI_Tool::Pixmap( qtMark ); + DEBTRACE("pnt dims " << aMark->SizeX() << " " << aMark->SizeY()); + Handle(Graphic3d_MarkerImage) gMark = new Graphic3d_MarkerImage(aMark); + Handle(Graphic3d_AspectMarker3d) anAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_USERDEFINED, Quantity_NOC_WHITE, 1.0 ); + anAspect->SetMarkerImage(gMark); + + DEBTRACE("nb groups " << thePresentation->NumberOfGroups()); // find the group corresponding to the points, change the aspect + const Graphic3d_SequenceOfGroup& grps = thePresentation->Groups(); + Graphic3d_SequenceOfGroup::Iterator anIter( grps ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(Graphic3d_Group) aGrp = anIter.Value(); + DEBTRACE("grp type: " << aGrp->get_type_name()); + Handle(Graphic3d_Aspects) asp = aGrp->Aspects(); + if (!asp.IsNull()) + { + DEBTRACE("aspect: " << asp->get_type_name()); + 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( !myTextIndices.empty() && !points.IsNull() ) + 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(); diff --git a/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx index a6896f36..3f550f19 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx @@ -34,6 +34,7 @@ HYDROGUI_BathymetrySelectionOp::HYDROGUI_BathymetrySelectionOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ), myIsActive( false ) { + DEBTRACE("HYDROGUI_BathymetrySelectionOp"); } HYDROGUI_BathymetrySelectionOp::~HYDROGUI_BathymetrySelectionOp() @@ -42,11 +43,13 @@ HYDROGUI_BathymetrySelectionOp::~HYDROGUI_BathymetrySelectionOp() void HYDROGUI_BathymetrySelectionOp::startOperation() { + DEBTRACE("startOperation"); activateSelection( true ); } void HYDROGUI_BathymetrySelectionOp::abortOperation() { + DEBTRACE("abortOperation"); activateSelection( false ); module()->action( BathymetrySelectionId )->setChecked( false ); @@ -55,6 +58,7 @@ void HYDROGUI_BathymetrySelectionOp::abortOperation() bool HYDROGUI_BathymetrySelectionOp::isValid( SUIT_Operation* theOtherOp ) const { + DEBTRACE("isValid"); HYDROGUI_BathymetryOp* aBathOp = dynamic_cast( theOtherOp ); return ( aBathOp != 0 ); } @@ -102,11 +106,13 @@ void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive ) QList baths = getShownBathymetries( module() ); if( isActive ) { - const int aSelectionMode = 1; + const int aSelectionMode = 1; // 2 AIS_PointCloud selection bounding box //ctx->Deactivate( Standard_True ); //ctx->OpenLocalContext( Standard_True ); foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) { + DEBTRACE("bathy name: " << bath->GetShape()->getObject()->GetName().toStdString()); + ctx->Deactivate(bath); ctx->Activate( bath, aSelectionMode, Standard_True ); bath->SetAutoHilight( Standard_False ); } diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx index 105d1329..226561b5 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,9 @@ #include #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + HYDROGUI_ShapeBathymetry::HYDROGUI_ShapeBathymetry( HYDROGUI_OCCDisplayer* theDisplayer, const Handle(AIS_InteractiveContext)& theContext, const Handle(HYDROData_Bathymetry)& theBathymetry, @@ -67,6 +71,7 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate QList HYDROGUI_ShapeBathymetry::createShape() const { + DEBTRACE("createShape"); QList shapes; Handle(AIS_InteractiveObject) aPntCloud; @@ -96,6 +101,7 @@ QList HYDROGUI_ShapeBathymetry::createShape() con void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale)& theColorScale ) { + DEBTRACE("UpdateWithColorScale"); if (!myCoords || getAISObjects().isEmpty()) return; @@ -227,22 +233,26 @@ void HYDROGUI_ShapeBathymetry::RescaleByVisible( OCCViewer_ViewWindow* theWindow QVector HYDROGUI_ShapeBathymetry::selected() const { + DEBTRACE("selected"); QVector selected; 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() ); return selected; } @@ -303,6 +313,7 @@ void HYDROGUI_ShapeBathymetry::Build() void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn, bool isUpdateCurrentViewer ) { + DEBTRACE("TextLabels " << isOn << " " << isUpdateCurrentViewer); if( getAISObjects().isEmpty() ) return; -- 2.39.2