#include <vtkImageData.h>
+//============================================================================
+class VISU_PointsDeviceActor: public VISU_GaussDeviceActorBase
+{
+ public:
+ vtkTypeMacro(VISU_PointsDeviceActor, VISU_GaussDeviceActorBase);
+
+ static
+ VISU_PointsDeviceActor*
+ New();
+
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetInput(vtkDataSet* theDataSet)
+ {
+ myGeomFilter->SetInput( theDataSet );
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ SetInteractor(vtkRenderWindowInteractor* theInteractor)
+ {
+ if(theInteractor == myInteractor)
+ return;
+
+ if(myInteractor)
+ myInteractor->RemoveObserver(myEventCallbackCommand);
+
+ if(theInteractor)
+ theInteractor->AddObserver(vtkCommand::CharEvent,
+ myEventCallbackCommand,
+ 0.0);
+
+ myInteractor = theInteractor;
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ DoMapperShallowCopy( vtkMapper* theMapper,
+ bool theIsCopyInput )
+ {
+ Superclass::DoMapperShallowCopy( theMapper, theIsCopyInput );
+
+ vtkDataSet* aDataSet = theMapper->GetInput();
+ vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
+
+ GetPointSpriteMapper()->SetAverageCellSize( aScaleFactor );
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ DeepCopy( VISU_PointsDeviceActor *theActor )
+ {
+ VISU::CopyPointSpriteDataMapper( GetPointSpriteMapper(), theActor->GetPointSpriteMapper(), false );
+ }
+
+ protected:
+ //----------------------------------------------------------------------------
+ VISU_PointsDeviceActor():
+ myGeomFilter( VTKViewer_GeometryFilter::New() ),
+ myEventCallbackCommand( vtkCallbackCommand::New() ),
+ myInteractor( NULL )
+ {
+ myGeomFilter->SetInside(true);
+
+ VISU_OpenGLPointSpriteMapper* aMapper = VISU_OpenGLPointSpriteMapper::New();
+ aMapper->SetInput( myGeomFilter->GetOutput() );
+
+ std::string aRootDir( getenv( "VISU_ROOT_DIR") );
+ std::string aMainTexture = aRootDir + "/share/salome/resources/visu/sprite_texture.bmp";
+ std::string anAlphaTexture = aRootDir + "/share/salome/resources/visu/sprite_alpha.bmp";
+ VISU::TTextureValue aTextureValue = VISU::GetTexture( aMainTexture, anAlphaTexture );
+ aMapper->SetImageData( aTextureValue.GetPointer() );
+
+ aMapper->SetUseLookupTableScalarRange(true);
+ aMapper->SetColorModeToMapScalars();
+ aMapper->SetScalarVisibility(true);
+
+ SetPointSpriteMapper( aMapper );
+
+ aMapper->Delete();
+
+ myEventCallbackCommand->SetClientData( this );
+ myEventCallbackCommand->SetCallback( VISU_PointsDeviceActor::ProcessEvents );
+ }
+
+
+ //----------------------------------------------------------------------------
+ ~VISU_PointsDeviceActor()
+ {
+ SetInteractor( NULL );
+ myGeomFilter->Delete();
+ myEventCallbackCommand->Delete();
+ }
+
+
+ //----------------------------------------------------------------------------
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData)
+ {
+ if ( VISU_PointsDeviceActor* self = reinterpret_cast<VISU_PointsDeviceActor*>( theClientData ) )
+ self->OnInteractorEvent( theEvent );
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ OnInteractorEvent(unsigned long theEvent)
+ {
+ switch ( theEvent ) {
+ case vtkCommand::CharEvent: {
+ switch( myInteractor->GetKeyCode() ) {
+ case 'M' :
+ case 'm' : {
+ if ( !GetVisibility() )
+ return;
+
+ static vtkFloatingPointType anIncrement = 2;
+ vtkFloatingPointType aMagnification = GetPointSpriteMapper()->GetPointSpriteMagnification();
+ vtkFloatingPointType coefficient = myInteractor->GetShiftKey() ? anIncrement : 1 / anIncrement;
+
+ GetPointSpriteMapper()->SetPointSpriteMagnification( aMagnification * coefficient );
+
+ myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
+ break;
+ }
+ default:
+ return;
+ }
+ break;
+ }
+ default:
+ return;
+ }
+ }
+
+
+ //----------------------------------------------------------------------------
+ vtkCallbackCommand* myEventCallbackCommand;
+ vtkRenderWindowInteractor* myInteractor;
+ VTKViewer_GeometryFilter* myGeomFilter;
+
+ private:
+ VISU_PointsDeviceActor(const VISU_PointsDeviceActor&); // Not implemented
+ void operator=(const VISU_PointsDeviceActor&); // Not implemented
+};
+
+vtkStandardNewMacro(VISU_PointsDeviceActor);
+
//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_ScalarMapAct);
static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
myPointsActor->SetProperty(aProperty);
myPointsActor->SetUserMatrix(aMatrix);
+ myPointSpriteActor = VISU_PointsDeviceActor::New();
+ myPointSpriteActor->SetProperty(aProperty);
+ myPointSpriteActor->SetUserMatrix(aMatrix);
+
aMatrix->Delete();
+ myIsPointSpriteMode = false;
+
SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
//Quadratic 2D elements representation
if(aResourceMgr) {
myScalarBar->Delete();
myPointsActor->Delete();
+ myPointSpriteActor->Delete();
mySurfaceActor->Delete();
myEdgeActor->Delete();
myEdgeActor->GetMapper()->ScalarVisibilityOff();
+ myPointSpriteActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false );
+
VISU::CopyMapper( myPointsActor->GetMapper(), thePipeLine->GetMapper(), false );
VISU::CopyMapper( mySurfaceActor->GetMapper(), thePipeLine->GetMapper(), false );
}
// myEdgeActor->SetInput( theDataSet );
if (theDataSet->IsA("vtkPolyData")) {
+ myPointSpriteActor->SetInput( myPolyDataExtractor->GetOutput() );
myPointsActor->SetInput( myPolyDataExtractor->GetOutput() );
mySurfaceActor->SetInput( myPolyDataExtractor->GetOutput() );
myEdgeActor->SetInput( myPolyDataExtractor->GetOutput() );
} else {
+ myPointSpriteActor->SetInput( myExtractor->GetOutput() );
myPointsActor->SetInput( myExtractor->GetOutput() );
mySurfaceActor->SetInput( myExtractor->GetOutput() );
myEdgeActor->SetInput( myExtractor->GetOutput() );
Superclass::SetTransform(theTransform);
myPointsActor->SetTransform(theTransform);
+ myPointSpriteActor->SetTransform(theTransform);
mySurfaceActor->SetTransform(theTransform);
myEdgeActor->SetTransform(theTransform);
::SetOpacity(vtkFloatingPointType theValue)
{
mySurfaceActor->GetProperty()->SetOpacity(theValue);
+
+ vtkFloatingPointType aPointSpriteOpacity = theValue > 0.0 ? 1.0 : 0.0;
+ myPointSpriteActor->GetPointSpriteMapper()->SetPointSpriteOpacity(aPointSpriteOpacity);
}
vtkFloatingPointType
if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
Superclass::DeepCopy(theActor);
SetBarVisibility(anActor->GetBarVisibility());
+ myPointSpriteActor->DeepCopy( anActor->myPointSpriteActor );
SetShading(anActor->IsShading());
}
}
{
Superclass::AddToRender(theRenderer);
+ myPointSpriteActor->SetInteractor( myInteractor );
+
if(myScalarBar)
theRenderer->AddActor2D(myScalarBar);
}
theRenderer->RemoveActor(myScalarBar);
if ( vtkWindow* aWindow = theRenderer->GetRenderWindow() ) {
+ myPointSpriteActor->ReleaseGraphicsResources( aWindow );
myPointsActor->ReleaseGraphicsResources( aWindow );
mySurfaceActor->ReleaseGraphicsResources( aWindow );
myEdgeActor->ReleaseGraphicsResources( aWindow );
{
Superclass::SetVisibility( theMode );
+ myPointSpriteActor->SetVisibility( theMode );
myPointsActor->SetVisibility( theMode );
if(myScalarBar)
else
mySurfaceActor->SetRepresentation(theMode);
+ myPointSpriteActor->SetProperty( mySurfaceActor->GetProperty() );
myPointsActor->SetProperty( mySurfaceActor->GetProperty() );
SetShading(anIsShanding);
GetMatrix(myEdgeActor->GetUserMatrix());
GetMatrix(mySurfaceActor->GetUserMatrix());
GetMatrix(myPointsActor->GetUserMatrix());
+ GetMatrix(myPointSpriteActor->GetUserMatrix());
using namespace SVTK::Representation;
switch ( GetRepresentation() ) {
break;
case Points:
- myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
- myPointsActor->RenderOpaqueGeometry(ren);
+ if( myIsPointSpriteMode ) {
+ myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+ myPointSpriteActor->RenderOpaqueGeometry(ren);
+ } else {
+ myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+ myPointsActor->RenderOpaqueGeometry(ren);
+ }
break;
default:
int
VISU_ScalarMapAct
+#if (VTK_XVERSION < 0x050100)
::RenderTranslucentGeometry(vtkViewport *ren)
+#else
+::RenderTranslucentPolygonalGeometry(vtkViewport *ren)
+#endif
{
GetMatrix(myEdgeActor->GetUserMatrix());
GetMatrix(mySurfaceActor->GetUserMatrix());
break;
case Points:
- myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+ if( myIsPointSpriteMode ) {
+ myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
+ myPointSpriteActor->RenderTranslucentGeometry(ren);
+#else
+ myPointSpriteActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
+ } else {
+ myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
#if (VTK_XVERSION < 0x050100)
- myPointsActor->RenderTranslucentGeometry(ren);
+ myPointsActor->RenderTranslucentGeometry(ren);
#else
- myPointsActor->RenderTranslucentPolygonalGeometry(ren);
+ myPointsActor->RenderTranslucentPolygonalGeometry(ren);
#endif
+ }
break;
default:
return 1;
}
+//----------------------------------------------------------------------------
+#if (VTK_XVERSION >= 0x050100)
+int
+VISU_ScalarMapAct
+::HasTranslucentPolygonalGeometry()
+{
+ int result = 0;
+
+ using namespace SVTK::Representation;
+ switch ( GetRepresentation() ) {
+ case Surfaceframe:
+ result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
+ result |= myEdgeActor->HasTranslucentPolygonalGeometry();
+ break;
+ case Points:
+ if( myIsPointSpriteMode )
+ result |= myPointSpriteActor->HasTranslucentPolygonalGeometry();
+ else
+ result |= myPointsActor->HasTranslucentPolygonalGeometry();
+ break;
+ default:
+ result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
+ }
+
+ return result;
+}
+#endif
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_ScalarMapAct
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ aSize += myPointSpriteActor->GetMemorySize();
+
+ return aSize;
+}
+
//----------------------------------------------------------------------------
VISU_Actor::EQuadratic2DRepresentation
{
Superclass::SetMarkerStd( theMarkerType, theMarkerScale );
myPointsActor->SetMarkerStd( theMarkerType, theMarkerScale );
+
+ myIsPointSpriteMode = theMarkerType == VTK::MT_POINT_SPRITE;
}
void VISU_ScalarMapAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
{
Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture );
myPointsActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
+
+ myIsPointSpriteMode = false;
}
/**