#include "HYDROGUI_Tool.h"
#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
HYDROGUI_AbstractDisplayer::HYDROGUI_AbstractDisplayer( HYDROGUI_Module* theModule )
: myModule( theModule )
// Now dig in the data model
HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay;
+ SUIT_ViewModel* aViewer = module()->getViewManager( theViewerId )->getViewModel();
for( int i = 1, n = theObjs.Length(); i <= n; i++ )
{
const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
- if( anObj.IsNull() )
- anObjectsToErase.Append( anObj );
- else
+
+ if( module()->isObjectVisible( (size_t)aViewer, anObj ) )
+ {
anObjectsToDisplay.Append( anObj );
+ }
+ else
+ {
+ anObjectsToErase.Append( anObj );
+ }
}
if( anObjectsToErase.Length() )
#include "HYDROGUI_VTKPrsBathymetry.h"
#include <HYDROData_Entity.h>
+#include <HYDROData_Tool.h>
#include <SALOME_Actor.h>
#include <gp_XYZ.hxx>
+#include <vtkDoubleArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
+#include <vtkPointData.h>
#include <vtkPolyDataMapper.h>
#include <vtkVertex.h>
+#include <vtkLookupTable.h>
#include <QString>
+#define NB_COLORS 32
+#define Z_MIN -100
+#define Z_MAX 1
+#define HUE_START 0.69
+#define HUE_END 0.41
+#define SATURATION_START 1.0
+#define SATURATION_END 0.4
+
//=======================================================================
// name : HYDROGUI_VTKPrsBathymetry
// Purpose : Constructor
vtkPolyData* aVertexGrid = vtkPolyData::New();
aVertexGrid->Allocate( aNbPoints );
+ vtkDoubleArray* aZValues = vtkDoubleArray::New();
+ aZValues->Allocate( aNbPoints );
+
vtkVertex* aVertex = vtkVertex::New();
+ int aZ;
+ int anInvalidZ = aBathymetry->GetInvalidAltitude();
for (int i = 0; i < aNbPoints; i++ )
{
anAltPnt = anAltPoints.at( i );
- aPoints->InsertPoint( i, anAltPnt.X(), anAltPnt.Y(), anAltPnt.Z() );
+ aZ = anAltPnt.Z();
+ if ( ValuesLessEquals( aZ, anInvalidZ ) )
+ {
+ aZ = Z_MAX;
+ }
+ else
+ {
+ aZ = -aZ;
+ }
+ aPoints->InsertPoint( i, anAltPnt.X(), anAltPnt.Y(), aZ );
aVertex->GetPointIds()->SetId( 0, i );
aVertexGrid->InsertNextCell( aVertex->GetCellType(), aVertex->GetPointIds());
+ aZValues->InsertNextValue( aZ );
}
aVertex->Delete();
aVertexGrid->SetPoints( aPoints );
+ aVertexGrid->GetPointData()->SetScalars( aZValues );
+
+ vtkLookupTable* aLut = vtkLookupTable::New();
+ aLut->SetHueRange( HUE_START, HUE_END );
+ aLut->SetSaturationRange( SATURATION_START, SATURATION_END );
+ aLut->SetTableRange( Z_MIN, Z_MAX );
+ aLut->SetValueRange( 1.0, 1.0 );
+ aLut->SetAlphaRange( 1.0, 1.0 );
+ aLut->SetNumberOfColors( NB_COLORS );
+ aLut->Build();
+
vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
+ aMapper->SetScalarRange( Z_MIN, Z_MAX );
+ aMapper->ScalarVisibilityOn();
+ aMapper->SetScalarModeToUsePointData();
+ aMapper->SetLookupTable( aLut );
aMapper->SetInputData( aVertexGrid );
+
SALOME_Actor* anActor = SALOME_Actor::New();
anActor->SetMapper( aMapper );
anActor->setIO( getIO() );
- //anActor->setName( aBathymetry->GetName().toLatin1() );
AddObject( anActor );
- //anActor.AddPosition(0, 0, 6);
- //anActor.GetProperty().SetDiffuseColor(1, 1, 1);
}
}
}
{
aViewer->Erase( aPrs, true );
}
- module()->removeObjectVTKPrs( (size_t)aViewer, anObj );
+ if ( anObj->IsRemoved() )
+ {
+ module()->removeObjectVTKPrs( (size_t)aViewer, anObj );
+ }
}
}
}
Handle(HYDROData_Entity) anObj = theObjs.Value( i );
if( !anObj.IsNull() )
{
- bool anIsVisible = module()->isObjectVisible( (size_t)(aViewer->getViewManager()->getViewModel()), anObj );
+ bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj );
aPrs = module()->getObjectVTKPrs( (size_t)aViewer, anObj );
bool anIsInserted = ( aPrs != 0 );
{
if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted )
{
- module()->setObjectVTKPrs( theViewerId, anObj, aPrs );
- aViewer->Display( aPrs );
- isChanged = true;
+ module()->setObjectVTKPrs( (size_t)aViewer, anObj, aPrs );
}
}
}
- if( aPrs && !anIsVisible )
+ if( aPrs )
{
- aViewer->Erase( aPrs );
+ if ( anIsVisible )
+ {
+ aViewer->Display( aPrs );
+ }
+ else
+ {
+ aViewer->Erase( aPrs );
+ }
isChanged = true;
}
}