]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
fix bathymetry points style = 4x4 rectangles (changes in occt 7.4)
authorPaul RASCLE <paul.rascle@openfields.fr>
Thu, 17 Sep 2020 22:22:52 +0000 (00:22 +0200)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:08:09 +0000 (17:08 +0100)
src/HYDROGUI/HYDROGUI_BathymetryOp.cxx
src/HYDROGUI/HYDROGUI_BathymetryPrs.cxx
src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx
src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx

index b0d6eff7baaaeefb08c8d1d20685e69296fd706b..3c6cc3172e7715345c3a0d5eda7883bd72eb113e 100644 (file)
@@ -33,6 +33,9 @@
 #include <QPushButton>
 #include <QApplication>
 
+#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<Handle(HYDROGUI_BathymetryPrs)> baths = getShownBathymetries( module() );
   bool isUpdateCS = false;
 
index eeb490123ca757d51e7eb4cfabb858fa4b4f3401..9b2c66a6045359269696e45bb057407113c2a91f 100644 (file)
 
 #include <QImage>
 
+#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();
 
index a6896f367e9ae2d157e03fee6ef1e87ac9ea4130..3f550f1989878f5c45c2b4bb5c48bcff3a7060d3 100644 (file)
@@ -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<HYDROGUI_BathymetryOp*>( theOtherOp );
   return ( aBathOp != 0 );
 }
@@ -102,11 +106,13 @@ void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive )
   QList<Handle(HYDROGUI_BathymetryPrs)> 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 );
     }
index 105d13290396cecd1a89e71b9ecc5a2705915bd9..226561b534eb4b78249deac53da35d5aa05a5a3d 100644 (file)
@@ -20,6 +20,7 @@
 #include <HYDROGUI_OCCDisplayer.h>
 #include <HYDROGUI_BathymetryPrs.h>
 #include <HYDROData_Bathymetry.h>
+#include <HYDROGUI_Tool.h>
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_ColorScale.hxx>
@@ -30,6 +31,9 @@
 #include <QTime>
 #include <utilities.h>
 
+#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<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeBathymetry::createShape() const
 {
+  DEBTRACE("createShape");
   QList<Handle(AIS_InteractiveObject)> shapes;
 
   Handle(AIS_InteractiveObject) aPntCloud;
@@ -96,6 +101,7 @@ QList<Handle(AIS_InteractiveObject)> 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<int> HYDROGUI_ShapeBathymetry::selected() const
 {
+  DEBTRACE("selected");
   QVector<int> 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;