X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_Displayer.cxx;h=c28de63f9e4b7cf0926fc03c70b5148b00a24961;hb=de7cf9bb0a7a41d6487013c87f4a54d0664cd303;hp=66cb4c11a4897933cb77be78251815dabb8193b7;hpb=ea51c1575cfdc7e3ad0b8cc1db55d9d83626b12d;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_Displayer.cxx b/src/HYDROGUI/HYDROGUI_Displayer.cxx index 66cb4c11..c28de63f 100644 --- a/src/HYDROGUI/HYDROGUI_Displayer.cxx +++ b/src/HYDROGUI/HYDROGUI_Displayer.cxx @@ -26,6 +26,8 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Prs.h" #include "HYDROGUI_PrsImageDriver.h" +#include "HYDROGUI_PrsPolylineDriver.h" +#include "HYDROGUI_PrsZoneDriver.h" #include "HYDROGUI_Tool.h" #include @@ -54,7 +56,7 @@ void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); for( int i = 1, n = theObjs.Length(); i <= n; i++ ) { - Handle(HYDROData_Object) anObj = theObjs.Value( i ); + Handle(HYDROData_Entity) anObj = theObjs.Value( i ); if( anObj.IsNull() ) continue; @@ -82,13 +84,13 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId ) if( !aViewPort ) return; - GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() ); + GraphicsView_ObjectListIterator anIter( HYDROGUI_Tool::GetPrsList( aViewPort ) ); while( anIter.hasNext() ) { if( GraphicsView_Object* anObject = anIter.next() ) { aViewPort->removeItem( anObject ); - //delete anObject; // ouv: to do + delete anObject; } } } @@ -96,13 +98,9 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId ) void HYDROGUI_Displayer::DisplayAll( const int theViewerId, const bool theIsForced ) { - HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel(); - if( aModel ) - { - HYDROData_SequenceOfObjects aSeq; - HYDROGUI_Tool::GetPrsSubObjects( aModel, theViewerId, aSeq ); - Update( aSeq, theViewerId, theIsForced ); - } + HYDROData_SequenceOfObjects aSeq; + HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq ); + Update( aSeq, theViewerId, theIsForced ); } void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs, @@ -117,7 +115,7 @@ void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs, for( int i = 1, n = theObjs.Length(); i <= n; i++ ) { - const Handle(HYDROData_Object)& anObj = theObjs.Value( i ); + const Handle(HYDROData_Entity)& anObj = theObjs.Value( i ); if( anObj.IsNull() ) anObjectsToErase.Append( anObj ); else @@ -144,15 +142,15 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs, HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel(); if( aModel ) { - GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); + GraphicsView_ObjectList anObjectList = HYDROGUI_Tool::GetPrsList( aViewPort ); for( int i = 1, n = theObjs.Length(); i <= n; i++ ) { // the object may be null or dead - const Handle(HYDROData_Object)& anObj = theObjs.Value( i ); + const Handle(HYDROData_Entity)& anObj = theObjs.Value( i ); if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) ) { aViewPort->removeItem( aPrs ); - //delete aPrs; // ouv: to do + delete aPrs; } } } @@ -174,7 +172,7 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs, GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); for( int i = 1, n = theObjs.Length(); i <= n; i++ ) { - Handle(HYDROData_Object) anObj = theObjs.Value( i ); + Handle(HYDROData_Entity) anObj = theObjs.Value( i ); if( anObj.IsNull() ) continue; @@ -192,11 +190,12 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs, if( aPrs ) { - bool isVisible = true; // anObj->IsVisible() - aPrs->setVisible( true ); + bool anIsVisible = myModule->isObjectVisible( (size_t)aViewer, anObj ); + aPrs->setVisible( anIsVisible ); } } + aViewPort->onBoundingRectChanged(); // specific of HYDRO module aViewPort->fitAll(); } @@ -210,23 +209,22 @@ void HYDROGUI_Displayer::purgeObjects( const int theViewerId ) if( !aViewPort ) return; - GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() ); + GraphicsView_ObjectListIterator anIter( HYDROGUI_Tool::GetPrsList( aViewPort ) ); while( anIter.hasNext() ) { - GraphicsView_Object* tmp = anIter.next(); - if( HYDROGUI_Prs* aPrs = dynamic_cast( tmp ) ) + if( HYDROGUI_Prs* aPrs = dynamic_cast( anIter.next() ) ) { - Handle(HYDROData_Object) anObject = aPrs->getObject(); - if( anObject.IsNull() ) + Handle(HYDROData_Entity) anObject = aPrs->getObject(); + if( !anObject.IsNull() && anObject->IsRemoved() ) { aViewPort->removeItem( aPrs ); - //delete aPrs; // ouv: to do + delete aPrs; } } } } -HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Object)& theObj ) +HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Entity)& theObj ) { HYDROGUI_PrsDriver* aDriver = NULL; ObjectKind aKind = theObj->GetKind(); @@ -239,11 +237,20 @@ HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Object { case KIND_IMAGE: aDriver = new HYDROGUI_PrsImageDriver(); - myPrsDriversMap[ aKind ] = aDriver; + break; + case KIND_POLYLINE: + aDriver = new HYDROGUI_PrsPolylineDriver(); + break; + case KIND_ZONE: + aDriver = new HYDROGUI_PrsZoneDriver(); break; default: break; } + + if ( aDriver ) + myPrsDriversMap[ aKind ] = aDriver; } + return aDriver; }