if( theObject.IsNull() )
return;
- // Compute the new global Z range from the added presentation and the old global Z range.
- double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
- double* aRange = theShape->getInternalZRange();
- bool anIsUpdate = false;
- if ( aRange[0] < aGlobalRange[0] )
+ if( theShape && theShape->needScalarBar() )
{
- aGlobalRange[0] = aRange[0];
- anIsUpdate = true;
- }
- if ( aRange[1] > aGlobalRange[1] )
- {
- aGlobalRange[1] = aRange[1];
- anIsUpdate = true;
- }
+ // Compute the new global Z range from the added presentation and the old global Z range.
+ double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
+ double* aRange = theShape->getInternalZRange();
+ bool anIsUpdate = false;
+ if ( aRange[0] < aGlobalRange[0] )
+ {
+ aGlobalRange[0] = aRange[0];
+ anIsUpdate = true;
+ }
+ if ( aRange[1] > aGlobalRange[1] )
+ {
+ aGlobalRange[1] = aRange[1];
+ anIsUpdate = true;
+ }
- //if ( anIsUpdate )
- //{
- updateVTKZRange( theViewId, aGlobalRange );
- //}
+ //if ( anIsUpdate )
+ //{
+ updateVTKZRange( theViewId, aGlobalRange );
+ //}
+ }
ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
aViewShapes.append( theShape );
for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
{
aShape = aViewShapes.at( i );
- if ( aShape )
+ if ( aShape && aShape->needScalarBar() )
{
aShape->setZRange( theRange );
}
SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
if ( aVTKViewer )
{
- getVTKDisplayer()->DeleteScalarBar( anId );
+ getVTKDisplayer()->EraseScalarBar( anId, true );
removeViewShapes( (size_t)aVTKViewer );
}
}
virtual ~HYDROGUI_VTKPrs();
virtual void compute();
+ virtual bool needScalarBar() { return false; }
static double InvalidZValue() { return HYDROData_AltitudeObject::GetInvalidAltitude(); }
HYDROGUI_VTKPrsBathymetry( const Handle(HYDROData_Bathymetry)& theObject );
virtual ~HYDROGUI_VTKPrsBathymetry();
- virtual void compute();
+ virtual void compute();
+ virtual bool needScalarBar() { return true; }
//! Get the range of colored
void setLookupTable( vtkScalarsToColors* theTable ) { myLookupTable = theTable; }
{
aViewer->EraseAll( true );
module()->removeViewVTKPrs( (size_t)aViewer );
+ EraseScalarBar( theViewerId );
}
}
-void HYDROGUI_VTKPrsDisplayer::DeleteScalarBar( const int theViewerId )
+void HYDROGUI_VTKPrsDisplayer::EraseScalarBar( const int theViewerId, const bool theIsDelete )
{
SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
if( aViewer )
}
}
}
- myScalarBars.remove( (size_t)aViewer );
+ if ( theIsDelete )
+ {
+ myScalarBars.remove( (size_t)aViewer );
+ }
}
}
}
int anInvalidZ = HYDROGUI_VTKPrs::InvalidZValue();
bool isChanged = false;
+ bool isScalarBarNeeded = false;
HYDROGUI_VTKPrs* aPrs;
for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
{
{
if ( anIsVisible )
{
-
- // Extend the global Z range if necessary
- double* aGlobalRange = GetZRange( (size_t)aViewer );
- double* aRange = aPrs->getInternalZRange();
- bool anIsUpdate = false;
- if ( aRange[0] < aGlobalRange[0] || ValuesEquals( aGlobalRange[0], anInvalidZ ) )
- {
- aGlobalRange[0] = aRange[0];
- anIsUpdate = true;
- }
- if ( aRange[1] > aGlobalRange[1] || ValuesEquals( aGlobalRange[1], anInvalidZ ) )
- {
- aGlobalRange[1] = aRange[1];
- anIsUpdate = true;
- }
-
- if ( anIsUpdate )
+ if ( aPrs->needScalarBar() )
{
- module()->updateVTKZRange( (size_t)aViewer, aGlobalRange );
+ // Extend the global Z range if necessary
+ double* aGlobalRange = GetZRange( (size_t)aViewer );
+ double* aRange = aPrs->getInternalZRange();
+ bool anIsUpdate = false;
+ if ( aRange[0] < aGlobalRange[0] || ValuesEquals( aGlobalRange[0], anInvalidZ ) )
+ {
+ aGlobalRange[0] = aRange[0];
+ anIsUpdate = true;
+ }
+ if ( aRange[1] > aGlobalRange[1] || ValuesEquals( aGlobalRange[1], anInvalidZ ) )
+ {
+ aGlobalRange[1] = aRange[1];
+ anIsUpdate = true;
+ }
+
+ if ( anIsUpdate )
+ {
+ module()->updateVTKZRange( (size_t)aViewer, aGlobalRange );
+ }
}
aViewer->Display( aPrs );
+ isScalarBarNeeded = isScalarBarNeeded || aPrs->needScalarBar();
}
else
if ( aView )
{
- if ( isChanged && aScalarBar )
+ if ( isChanged && isScalarBarNeeded && aScalarBar )
{
// Show colors legend bar
aView->getRenderer()->AddActor2D( aScalarBar );
* \brief Delete scalar bar for the given viewer id.
* \param theViewerId viewer identifier
*/
- void DeleteScalarBar( const int theViewerId );
+ void EraseScalarBar( const int theViewerId, const bool theIsDelete = false );
protected:
/**
thePrs = new HYDROGUI_VTKPrsShape( theObj );
HYDROGUI_VTKPrsShape* aPrsShape = (HYDROGUI_VTKPrsShape*)thePrs;
- // Update global colors table during compute if necessary
- aPrsShape->setLookupTable( myScalarBar->GetLookupTable() );
aPrsShape->compute();
return true;