X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_VTKPrsDisplayer.cxx;h=d4317fcd46887b389b71c6fd9b411d4635e2820e;hb=a1431f03eac1d1aed4203d0568d987c41ce939b3;hp=909012353d23fffc6ad6de8103e0a11e6de9a561;hpb=a558c58ccc19713db2b13ada4d0f32dff61d0deb;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx index 90901235..d4317fcd 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx @@ -26,6 +26,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_VTKPrs.h" #include "HYDROGUI_VTKPrsBathymetryDriver.h" +#include "HYDROGUI_VTKPrsShapeDriver.h" #include "HYDROGUI_Tool.h" #include "HYDROData_Tool.h" @@ -39,6 +40,7 @@ #include #include +#include #include #include @@ -52,13 +54,13 @@ //#define SATURATION_START 1.0 //#define SATURATION_END 0.4 -#define HUE_START 0.0 -#define HUE_END 0.7 +#define HUE_START 0.7 +#define HUE_END 0.0 #define SATURATION_START 1.0 #define SATURATION_END 1.0 HYDROGUI_VTKPrsDisplayer::HYDROGUI_VTKPrsDisplayer( HYDROGUI_Module* theModule ) -: HYDROGUI_AbstractDisplayer( theModule ), myDriver( NULL ) +: HYDROGUI_AbstractDisplayer( theModule ), myDriver( NULL ), myShapeDriver( NULL ) { } @@ -95,26 +97,34 @@ 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 ) { - SVTK_ViewWindow* aView = dynamic_cast( - aViewer->getViewManager()->getActiveView() ); - if ( aView ) + if ( myScalarBars.contains( (size_t)aViewer ) ) { - if ( myScalarBars.contains( (size_t)aViewer ) ) + SUIT_ViewManager* aViewMgr = dynamic_cast( aViewer->getViewManager() ); + if ( aViewMgr && aViewMgr->getViewsCount() > 0 ) { - vtkScalarBarActor* aScalarBar = myScalarBars[ (size_t)aViewer ]; - if ( aView->getRenderer()->HasViewProp( aScalarBar ) ) + SVTK_ViewWindow* aView = dynamic_cast( aViewMgr->getActiveView() ); + if ( aView ) { - aView->getRenderer()->RemoveActor2D( aScalarBar ); + vtkScalarBarActor* aScalarBar = myScalarBars[ (size_t)aViewer ]; + if ( aView->getRenderer()->HasViewProp( aScalarBar ) ) + { + aView->getRenderer()->RemoveActor2D( aScalarBar ); + } } } + if ( theIsDelete ) + { + myScalarBars.remove( (size_t)aViewer ); + } } } } @@ -177,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++ ) { @@ -189,6 +200,12 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb bool anIsInserted = ( aPrs != 0 ); if( anIsVisible && ( !aPrs || aPrs->getIsToUpdate() || theIsForced ) ) { + // Erase the presentation in the view because of the problem with GEOM_Actor upadting on second SetShape. + if ( aPrs ) + { + aViewer->Erase( aPrs, true ); + } + // Update the presentation if( HYDROGUI_VTKPrsDriver* aDriver = getDriver( (size_t)aViewer, anObj ) ) { if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted ) @@ -202,28 +219,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 @@ -237,7 +257,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 ); @@ -251,7 +271,7 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb } else if ( isChanged ) { - aView->Repaint(); + aView->Repaint( true ); } } } @@ -300,6 +320,14 @@ HYDROGUI_VTKPrsDriver* HYDROGUI_VTKPrsDisplayer::getDriver( const int theViewId, } aDriver = myDriver; } + else + { + if ( !myShapeDriver ) + { + myShapeDriver = new HYDROGUI_VTKPrsShapeDriver( myScalarBars[ theViewId ] ); + } + aDriver = myShapeDriver; + } return aDriver; } @@ -335,6 +363,9 @@ void HYDROGUI_VTKPrsDisplayer::createScalarBar( const int theViewId ) aTable->Build(); vtkSmartPointer aScalarBar = vtkScalarBarActor::New(); aScalarBar->SetLookupTable( aTable ); + aScalarBar->SetNumberOfLabels( NB_COLORS * 0.75 ); + aScalarBar->SetWidth( aScalarBar->GetWidth() / 1.5 ); + aScalarBar->SetTextureGridWidth( aScalarBar->GetTextureGridWidth() * 4. ); aTable->Delete(); myScalarBars.insert( theViewId, aScalarBar ); }