#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
-#include <QApplication>
-
HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
-: myModule( theModule )
+: HYDROGUI_AbstractDisplayer( theModule )
{
}
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;
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;
- HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj );
+ HYDROGUI_Shape* anObjShape = module()->getObjectShape( (size_t)aViewer, anObj );
if ( !anObjShape )
continue;
}
}
-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_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 );
+ 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;
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;
- myModule->removeObjectShape( (size_t)aViewer, anObj );
+ module()->removeObjectShape( (size_t)aViewer, anObj );
}
}
HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int theViewerId,
const Handle(AIS_InteractiveContext)& theContext,
- const Handle(HYDROData_Object)& theObject )
+ const Handle(HYDROData_Entity)& theObject )
{
HYDROGUI_Shape* aResShape = NULL;
if ( theContext.IsNull() || theObject.IsNull() )
ObjectKind anObjectKind = theObject->GetKind();
if ( anObjectKind != KIND_IMAGE &&
- anObjectKind != KIND_POLYLINE &&
- anObjectKind != KIND_ZONE )
+ anObjectKind != KIND_POLYLINEXY &&
+ anObjectKind != KIND_IMMERSIBLE_ZONE &&
+ anObjectKind != KIND_REGION &&
+ anObjectKind != KIND_ZONE &&
+ anObjectKind != KIND_OBSTACLE &&
+ anObjectKind != KIND_PROFILE )
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;
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() || 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 )
{
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<OCCViewer_ViewManager*>( aViewer->getViewManager() );
- if ( aViewManager )
+ if ( theDoFitAll )
{
- OCCViewer_ViewWindow* aViewWindow =
- ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
- if ( aViewWindow )
+ OCCViewer_ViewManager* aViewManager
+ = ::qobject_cast<OCCViewer_ViewManager*>( aViewer->getViewManager() );
+ if ( aViewManager )
{
- QApplication::processEvents(); //Process the draw events for viewer
- aViewWindow->onFitAll();
+ OCCViewer_ViewWindow* aViewWindow =
+ ::qobject_cast<OCCViewer_ViewWindow*>( 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;
if ( aPrsObj.IsNull() )
continue;
- Handle(HYDROData_Object) anOwnerObj =
- Handle(HYDROData_Object)::DownCast( aPrsObj->GetOwner() );
+ 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();
+}