X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_OCCDisplayer.cxx;h=39810702fbeaccabbfdbc72d8898469c6b6a041b;hb=a1431f03eac1d1aed4203d0568d987c41ce939b3;hp=d1655f3c411ba05c8726579c0b87e5d4a8951283;hpb=41d3a5f489e8ec606523394f435e356fc607719b;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index d1655f3c..39810702 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -35,10 +35,8 @@ #include #include -#include - HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule ) -: myModule( theModule ) +: HYDROGUI_AbstractDisplayer( theModule ) { } @@ -49,7 +47,7 @@ HYDROGUI_OCCDisplayer::~HYDROGUI_OCCDisplayer() void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs, const int theViewerId ) { - OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId ); + OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); if( !aViewer ) return; @@ -59,7 +57,7 @@ void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theO if( anObj.IsNull() ) continue; - HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj ); + HYDROGUI_Shape* anObjShape = module()->getObjectShape( (size_t)aViewer, anObj ); if ( !anObjShape ) continue; @@ -67,62 +65,19 @@ void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theO } } -void HYDROGUI_OCCDisplayer::UpdateAll( const int theViewerId, - const bool theIsInit, - const bool theIsForced ) -{ - if ( theIsInit ) - EraseAll( theViewerId ); - - DisplayAll( theViewerId, theIsForced ); -} - void HYDROGUI_OCCDisplayer::EraseAll( const int theViewerId ) { - OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId ); + OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); if( !aViewer ) return; - myModule->removeViewShapes( (size_t)aViewer ); -} - -void HYDROGUI_OCCDisplayer::DisplayAll( const int theViewerId, - const bool theIsForced ) -{ - HYDROData_SequenceOfObjects aSeq; - HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq ); - Update( aSeq, theViewerId, theIsForced ); -} - -void HYDROGUI_OCCDisplayer::Update( const HYDROData_SequenceOfObjects& theObjs, - const int theViewerId, - const bool theIsForced ) -{ - // First of all, kill all bad presentations - purgeObjects( theViewerId ); - - // Now dig in the data model - HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay; - - 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 - anObjectsToDisplay.Append( anObj ); - } - - if( anObjectsToErase.Length() ) - Erase( anObjectsToErase, theViewerId ); - if( anObjectsToDisplay.Length() ) - Display( anObjectsToDisplay, theViewerId, theIsForced ); + module()->removeViewShapes( (size_t)aViewer ); } void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs, const int theViewerId ) { - OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId ); + OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); if( !aViewer ) return; @@ -132,8 +87,9 @@ void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs, if( anObj.IsNull() ) continue; - myModule->removeObjectShape( (size_t)aViewer, anObj ); + module()->removeObjectShape( (size_t)aViewer, anObj ); } + aViewer->update(); } HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int theViewerId, @@ -144,25 +100,21 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int if ( theContext.IsNull() || theObject.IsNull() ) return aResShape; - ObjectKind anObjectKind = theObject->GetKind(); - if ( anObjectKind != KIND_IMAGE && - anObjectKind != KIND_POLYLINE && - anObjectKind != KIND_IMMERSIBLE_ZONE && - anObjectKind != KIND_REGION && - anObjectKind != KIND_ZONE ) + if ( !HYDROGUI_Tool::IsObjectHasPresentation( theObject, OCCViewer_Viewer::Type() ) ) return aResShape; aResShape = new HYDROGUI_Shape( theContext, theObject ); - myModule->setObjectShape( theViewerId, theObject, aResShape ); + module()->setObjectShape( theViewerId, theObject, aResShape ); return aResShape; } void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, const int theViewerId, - const bool theIsForced ) + const bool theIsForced, + const bool theDoFitAll ) { - OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId ); + OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); if( !aViewer ) return; @@ -176,7 +128,7 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, if ( anObj.IsNull() || anObj->IsRemoved() ) continue; - HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj ); + HYDROGUI_Shape* anObjShape = module()->getObjectShape( (size_t)aViewer, anObj ); if ( !anObjShape || anObjShape->getIsToUpdate() || theIsForced ) { @@ -189,28 +141,30 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, if ( anObjShape ) { - bool anIsVisible = myModule->isObjectVisible( (size_t)aViewer, anObj ); + bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj ); anObjShape->setVisible( anIsVisible, false ); } } - OCCViewer_ViewManager* aViewManager - = ::qobject_cast( aViewer->getViewManager() ); - if ( aViewManager ) + if ( theDoFitAll ) { - OCCViewer_ViewWindow* aViewWindow = - ::qobject_cast( aViewManager->getActiveView() ); - if ( aViewWindow ) + OCCViewer_ViewManager* aViewManager + = ::qobject_cast( aViewer->getViewManager() ); + if ( aViewManager ) { - //RKV: QApplication::processEvents(); //Process the draw events for viewer - aViewWindow->onFitAll(); + OCCViewer_ViewWindow* aViewWindow = + ::qobject_cast( aViewManager->getActiveView() ); + if ( aViewWindow ) + { + aViewWindow->onFitAll(); + } } } } void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId ) { - OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId ); + OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); if( !aViewer ) return; @@ -231,8 +185,11 @@ void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId ) Handle(HYDROData_Entity) anOwnerObj = Handle(HYDROData_Entity)::DownCast( aPrsObj->GetOwner() ); if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() ) - myModule->removeObjectShape( (size_t)aViewer, anOwnerObj ); + module()->removeObjectShape( (size_t)aViewer, anOwnerObj ); } } - +QString HYDROGUI_OCCDisplayer::GetType() const +{ + return OCCViewer_Viewer::Type(); +}