#include "HYDROGUI_Prs.h"
#include "HYDROGUI_PrsImageDriver.h"
#include "HYDROGUI_PrsPolylineDriver.h"
+#include "HYDROGUI_PrsZoneDriver.h"
#include "HYDROGUI_Tool.h"
#include <GraphicsView_Viewer.h>
#include <GraphicsView_ViewPort.h>
HYDROGUI_Displayer::HYDROGUI_Displayer( HYDROGUI_Module* theModule )
-: myModule( theModule )
+: HYDROGUI_AbstractDisplayer( theModule )
{
}
void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
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;
}
}
-void HYDROGUI_Displayer::UpdateAll( const int theViewerId,
- const bool theIsInit,
- const bool theIsForced )
-{
- if( theIsInit )
- EraseAll( theViewerId );
- DisplayAll( theViewerId, theIsForced );
-}
-
void HYDROGUI_Displayer::EraseAll( const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
}
}
-void HYDROGUI_Displayer::DisplayAll( const int theViewerId,
- const bool theIsForced )
-{
- HYDROData_SequenceOfObjects aSeq;
- HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
- Update( aSeq, theViewerId, theIsForced );
-}
-
-void HYDROGUI_Displayer::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_Object)& 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 );
-}
-
void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
if( !aViewPort )
return;
- HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel();
+ HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)module()->dataModel();
if( aModel )
{
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 );
+ anObjectList.removeAll( aPrs );
delete aPrs;
}
}
void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId,
- const bool theIsForced )
+ const bool theIsForced,
+ const bool theDoFitAll)
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
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;
if( aPrs )
{
- bool anIsVisible = anObj->IsVisible( (size_t)aViewer );
+ bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj );
aPrs->setVisible( anIsVisible );
}
}
aViewPort->onBoundingRectChanged(); // specific of HYDRO module
- aViewPort->fitAll();
+ if ( theDoFitAll )
+ {
+ aViewPort->fitAll();
+ }
}
void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
{
if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
{
- Handle(HYDROData_Object) anObject = aPrs->getObject();
+ Handle(HYDROData_Entity) anObject = aPrs->getObject();
if( !anObject.IsNull() && anObject->IsRemoved() )
{
aViewPort->removeItem( 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();
{
case KIND_IMAGE:
aDriver = new HYDROGUI_PrsImageDriver();
- myPrsDriversMap[ aKind ] = aDriver;
break;
- case KIND_POLYLINE:
+ case KIND_POLYLINEXY:
aDriver = new HYDROGUI_PrsPolylineDriver();
- myPrsDriversMap[ aKind ] = aDriver;
+ break;
+ case KIND_ZONE:
+ aDriver = new HYDROGUI_PrsZoneDriver();
break;
default:
break;
}
+
+ if ( aDriver )
+ myPrsDriversMap[ aKind ] = aDriver;
}
+
return aDriver;
}
+
+QString HYDROGUI_Displayer::GetType() const
+{
+ return GraphicsView_Viewer::Type();
+}