#include <HYDROGUI_BathymetryBoundsOp.h>
#include <HYDROGUI_Tool.h>
#include <HYDROGUI_UpdateFlags.h>
+#include <HYDROGUI_Module.h>
HYDROGUI_BathymetryBoundsOp::HYDROGUI_BathymetryBoundsOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
{
bool isOK = myBath->CreateBoundaryPolyline();
theUpdateFlags = 0;
- if( isOK )
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ if( isOK ) {
+ module()->setIsToUpdate( myBath );
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+ }
else
theErrorMsg = tr( "CANNOT_CREATE_BOUNDARY_POLYLINE" );
return isOK;
if ( !aPanel )
return false;
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
return true;
}
if( !myIsEdit )
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ module()->setIsToUpdate( myEditedObject );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
commitDocOperation();
- module()->update( UF_Model | UF_Viewer | UF_OCCViewer );
+ module()->update( UF_Model | UF_Viewer | UF_OCCViewer | UF_VTKViewer );
commit();
}
bool HYDROGUI_GeoreferencementOp::processApply( int& theUpdateFlags,
QString& theErrorMsg )
{
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
return store( theErrorMsg );
}
if( !myIsEdit )
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ module()->setIsToUpdate( aZoneObj );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
// Check operation status
if ( anIsOk ) {
anObject->Update();
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ module()->setIsToUpdate( anObject );
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
}
}
}
// Set operation status
anIsOk = true;
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;;
+ module()->setIsToUpdate( anObstacle );
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
} else {
theErrorMsg = tr( "BAD_IMPORTED_OBSTACLE_FILE" ).arg( aFileName );
}
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
#include <HYDROData_Profile.h>
abort();
}
- theUpdateFlags = UF_Model;
+ theUpdateFlags = UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
return aRes;
}
}
}
+void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
+ const bool theState )
+{
+ if( !theObject.IsNull() )
+ {
+ // Process OCC shapes
+ ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
+ while( aShapesMapIter != myShapesMap.end() )
+ {
+ const ListOfShapes& aShapesList = aShapesMapIter.value();
+ foreach ( HYDROGUI_Shape* aShape, aShapesList )
+ {
+ if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+ {
+ aShape->setIsToUpdate( theState );
+ }
+ }
+ aShapesMapIter++;
+ }
+ // Process VTK shapes
+ ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
+ while( aVTKPrsMapIter != myVTKPrsMap.end() )
+ {
+ const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
+ foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
+ {
+ if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+ {
+ aShape->setIsToUpdate( theState );
+ }
+ }
+ aVTKPrsMapIter++;
+ }
+ }
+}
+
/////////////////// OCC SHAPES PROCESSING
HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
const Handle(HYDROData_Entity)& theObject ) const
void setObjectVisible( const int theViewId,
const Handle(HYDROData_Entity)& theObject,
const bool theState );
-
+ /**
+ * Set IsToUpdate flag for all presentations of the given object to recompute them during
+ * the next viewer(s) updating.
+ * @param theObject the data model object
+ * @param theState the flag to set for object's presentations, it's true by default.
+ */
+ void setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
+ const bool theState = true );
HYDROGUI_Shape* getObjectShape( const int theViewId,
const Handle(HYDROData_Entity)& theObject ) const;
void setObjectShape( const int theViewId,
void removeViewVTKPrs( const int theViewId );
void removeObjectVTKPrs( const int theViewId,
const Handle(HYDROData_Entity)& theObject );
+
/**
* Update global imposed range of Z values for the given VTK viewer id
*/
module()->setObjectVisible( aViewId, aProfile, false );
module()->setObjectVisible( aViewId, aResult, true );
}
+ module()->setIsToUpdate( aResult );
- theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
// Update the wire of polyline
aPolylineObj->Update();
+ module()->setIsToUpdate( aPolylineObj );
// the viewer should be release from the widget before the module update it
// because it has an opened local context and updated presentation should not be displayed in it
// the polyline should be rebuild in all viewers, where it is displayed
theUpdateFlags |= UF_Viewer | UF_GV_Forced;
theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags |= UF_VTKViewer;
size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
if ( anActiveViewId == 0 )
// And now we update our edited object
aProfileObj->Update();
+ module()->setIsToUpdate( aProfileObj );
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
aPolyObject->SetWireColor( aFirstColor );
}
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ module()->setIsToUpdate( myEditedObject );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
}
+ module()->setIsToUpdate( myEditedObject );
+
// Set update flags
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
commitDocOperation();
- module()->update( UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced );
+ module()->update( UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer );
commit();
}
return;
theObject->Update();
+ module()->setIsToUpdate( theObject );
}
//=======================================================================
void HYDROGUI_VTKPrs::compute()
{
+ setIsToUpdate( false );
}
//=======================================================================
#include <SALOME_InteractiveObject.hxx>
#include <SVTK_Prs.h>
+#include <vtkActorCollection.h>
class vtkMapper;
+template <class ActorType> ActorType* getActor(SVTK_Prs* thePrs);
+
+/**
+ * Get a VTK actor of the given presentation. Create a new one if there is no actor yet.
+ */
+template <class ActorType>
+ActorType* getActor(SVTK_Prs* thePrs)
+{
+ ActorType* anActor = 0;
+ vtkActorCollection* aContent = thePrs->GetObjects();
+ if ( aContent )
+ {
+ // Remove old actor because of the problem of GEOM_Actor updating.
+ //anActor = dynamic_cast<ActorType*>( aContent->GetLastActor() );
+ aContent->RemoveAllItems();
+ }
+ if ( !anActor )
+ {
+ anActor = ActorType::New();
+ thePrs->AddObject( anActor );
+ anActor->Delete();
+ }
+ return anActor;
+}
+
+
/*
Class : HYDROGUI_VTKPrs
Description : Base class for all HYDRO presentation in VTK viewer
//================================================================
void HYDROGUI_VTKPrsBathymetry::compute()
{
+ HYDROGUI_VTKPrs::compute();
+
if ( !getObject().IsNull() )
{
Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
myMapper->SetInputData( aVertexGrid );
- SALOME_Actor* anActor = SALOME_Actor::New();
+ SALOME_Actor* anActor = getActor<SALOME_Actor>(this);
anActor->SetMapper( myMapper.GetPointer() );
anActor->setIO( getIO() );
AddObject( anActor );
- anActor->Delete();
aVertexGrid->Delete();
aZValues->Delete();
}
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 )
//================================================================
void HYDROGUI_VTKPrsShape::compute()
{
+ HYDROGUI_VTKPrs::compute();
+
if ( !getObject().IsNull() )
{
buildShape();
if ( !myTopoShape.IsNull() )
{
- HYDROGUI_Actor* anActor = HYDROGUI_Actor::New();
+ HYDROGUI_Actor* anActor = getActor<HYDROGUI_Actor>(this);
anActor->SetShape( myTopoShape, VTK_MIN_DEFLECTION );
anActor->setDisplayMode( myDisplayMode );
anActor->setIO( getIO() );
- AddObject( anActor );
-
- //double bounds[6];
- //anActor->GetBounds( bounds );
-
- anActor->Delete();
}
}
}