From: rkv Date: Tue, 17 Dec 2013 08:06:09 +0000 (+0000) Subject: Fix for the Feature #229: Showing objects in VTK: Scalar bar is used for bathymetries... X-Git-Tag: BR_hydro_v_0_6~71 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=575fad0fb31108a6daa332a6610254b7e57d4caf;p=modules%2Fhydro.git Fix for the Feature #229: Showing objects in VTK: Scalar bar is used for bathymetries only. --- diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 7c9c45f8..1ffbf5aa 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -901,25 +901,28 @@ void HYDROGUI_Module::setObjectVTKPrs( const int theViewId 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 ); @@ -978,7 +981,7 @@ void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] ) for ( int i = 0, n = aViewShapes.length(); i < n; ++i ) { aShape = aViewShapes.at( i ); - if ( aShape ) + if ( aShape && aShape->needScalarBar() ) { aShape->setZRange( theRange ); } @@ -1102,7 +1105,7 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager ) SVTK_Viewer* aVTKViewer = getVTKViewer( anId ); if ( aVTKViewer ) { - getVTKDisplayer()->DeleteScalarBar( anId ); + getVTKDisplayer()->EraseScalarBar( anId, true ); removeViewShapes( (size_t)aVTKViewer ); } } diff --git a/src/HYDROGUI/HYDROGUI_VTKPrs.h b/src/HYDROGUI/HYDROGUI_VTKPrs.h index d6a8b206..558d7ba5 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrs.h +++ b/src/HYDROGUI/HYDROGUI_VTKPrs.h @@ -42,6 +42,7 @@ public: virtual ~HYDROGUI_VTKPrs(); virtual void compute(); + virtual bool needScalarBar() { return false; } static double InvalidZValue() { return HYDROData_AltitudeObject::GetInvalidAltitude(); } diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h index 25e357d5..8b8cd54f 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h +++ b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h @@ -42,7 +42,8 @@ public: 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; } diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx index 8b373317..a75f52a9 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx @@ -97,10 +97,11 @@ void HYDROGUI_VTKPrsDisplayer::EraseAll( const int theViewerId ) { 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 ) @@ -120,7 +121,10 @@ void HYDROGUI_VTKPrsDisplayer::DeleteScalarBar( const int theViewerId ) } } } - myScalarBars.remove( (size_t)aViewer ); + if ( theIsDelete ) + { + myScalarBars.remove( (size_t)aViewer ); + } } } } @@ -183,6 +187,7 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb int anInvalidZ = HYDROGUI_VTKPrs::InvalidZValue(); bool isChanged = false; + bool isScalarBarNeeded = false; HYDROGUI_VTKPrs* aPrs; for ( int i = 1, n = theObjs.Length(); i <= n; i++ ) { @@ -208,28 +213,31 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb { 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 @@ -243,7 +251,7 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb if ( aView ) { - if ( isChanged && aScalarBar ) + if ( isChanged && isScalarBarNeeded && aScalarBar ) { // Show colors legend bar aView->getRenderer()->AddActor2D( aScalarBar ); diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h index abcdfd46..66e2f751 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h +++ b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h @@ -75,7 +75,7 @@ public: * \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: /** diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsShapeDriver.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsShapeDriver.cxx index cb8d03f9..b5cb2393 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsShapeDriver.cxx +++ b/src/HYDROGUI/HYDROGUI_VTKPrsShapeDriver.cxx @@ -47,8 +47,6 @@ bool HYDROGUI_VTKPrsShapeDriver::Update( const Handle(HYDROData_Entity)& theObj, 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;