-// VISU OBJECT : interactive object for VISU entities implementation
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// VISU OBJECT : interactive object for VISU entities implementation
// File : VISU_MeshAct.hxx
// Author : Laurent CORNABE with the help of Nicolas REJNERI
// Module : VISU
// $Header$
-
+//
#include "VISU_ScalarMapAct.h"
#include "VISU_LookupTable.hxx"
#include "VISU_ScalarBarActor.hxx"
#include "VISU_DeformedShapePL.hxx"
#include "VISU_PipeLineUtils.hxx"
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <SALOME_ExtractGeometry.h>
+#include <SALOME_ExtractPolyDataGeometry.h>
+
#include <vtkObjectFactory.h>
#include <vtkRenderer.h>
#include <vtkProperty.h>
if(theInteractor)
theInteractor->AddObserver(vtkCommand::CharEvent,
- myEventCallbackCommand,
- 0.0);
+ myEventCallbackCommand,
+ 0.0);
myInteractor = theInteractor;
}
//----------------------------------------------------------------------------
void
DoMapperShallowCopy( vtkMapper* theMapper,
- bool theIsCopyInput )
+ bool theIsCopyInput )
{
Superclass::DoMapperShallowCopy( theMapper, theIsCopyInput );
static
void
ProcessEvents(vtkObject* theObject,
- unsigned long theEvent,
- void* theClientData,
- void* theCallData)
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData)
{
if ( VISU_PointsDeviceActor* self = reinterpret_cast<VISU_PointsDeviceActor*>( theClientData ) )
self->OnInteractorEvent( theEvent );
switch( myInteractor->GetKeyCode() ) {
case 'M' :
case 'm' : {
- if ( !GetVisibility() )
- return;
+ if ( !GetVisibility() )
+ return;
- static vtkFloatingPointType anIncrement = 2;
- vtkFloatingPointType aMagnification = GetPointSpriteMapper()->GetPointSpriteMagnification();
- vtkFloatingPointType coefficient = myInteractor->GetShiftKey() ? anIncrement : 1 / anIncrement;
+ static vtkFloatingPointType anIncrement = 2;
+ vtkFloatingPointType aMagnification = GetPointSpriteMapper()->GetPointSpriteMagnification();
+ vtkFloatingPointType coefficient = myInteractor->GetShiftKey() ? anIncrement : 1 / anIncrement;
- GetPointSpriteMapper()->SetPointSpriteMagnification( aMagnification * coefficient );
+ GetPointSpriteMapper()->SetPointSpriteMagnification( aMagnification * coefficient );
- myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
- break;
+ myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
+ break;
}
default:
- return;
+ return;
}
break;
}
myEdgeActor->SetUserMatrix(aMatrix);
myEdgeActor->GetProperty()->SetColor(255.,255.,255.);
- myPointsActor = VISU_PointsDeviceActor::New();
+ myPointsActor = SVTK_DeviceActor::New();
+ myPointsActor->SetRepresentation(SVTK::Representation::Points);
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) {
+ //----------------------------------------------------------------------------
+ int aQuadraticAngle = aResourceMgr->integerValue( "VISU", "max_angle", 2);
+ mySurfaceActor->SetQuadraticArcAngle(aQuadraticAngle);
+ myEdgeActor->SetQuadraticArcAngle(aQuadraticAngle);
+
+ int anElem0DSize = aResourceMgr->integerValue( "VISU", "elem0d_size", 5);
+ mySurfaceActor->GetProperty()->SetPointSize(anElem0DSize);
+ }
}
//----------------------------------------------------------------------------
myScalarBar->Delete();
myPointsActor->Delete();
+ myPointSpriteActor->Delete();
mySurfaceActor->Delete();
myEdgeActor->Delete();
VISU_ScalarMapAct
::ShallowCopyPL(VISU_PipeLine* thePipeLine)
{
- VISU_Actor::ShallowCopyPL( thePipeLine );
+ VISU_DataSetActor::ShallowCopyPL( thePipeLine );
myEdgeActor->GetMapper()->ScalarVisibilityOff();
- myPointsActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false );
+ myPointSpriteActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false );
+ VISU::CopyMapper( myPointsActor->GetMapper(), thePipeLine->GetMapper(), false );
VISU::CopyMapper( mySurfaceActor->GetMapper(), thePipeLine->GetMapper(), false );
}
{
Superclass::SetMapperInput( theDataSet );
- myPointsActor->SetInput( theDataSet );
+// myPointsActor->SetInput( theDataSet );
+// mySurfaceActor->SetInput( theDataSet );
+// myEdgeActor->SetInput( theDataSet );
- mySurfaceActor->SetInput( theDataSet );
- 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);
}
+//----------------------------------------------------------------------------
+vtkProperty*
+VISU_ScalarMapAct
+::GetEdgeProperty()
+{
+ return myEdgeActor->GetProperty();
+}
+
//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
mySurfaceActor->UnShrink();
}
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed)
+{
+ Superclass::SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed);
+
+ mySurfaceActor->SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed);
+}
+
+void
+VISU_ScalarMapAct
+::SetFeatureEdgesAngle(vtkFloatingPointType theValue)
+{
+ Superclass::SetFeatureEdgesAngle(theValue);
+
+ mySurfaceActor->SetFeatureEdgesAngle(theValue);
+}
+
+void
+VISU_ScalarMapAct
+::SetFeatureEdgesFlags(bool theIsFeatureEdges,
+ bool theIsBoundaryEdges,
+ bool theIsManifoldEdges,
+ bool theIsNonManifoldEdges)
+{
+ Superclass::SetFeatureEdgesFlags(theIsFeatureEdges,
+ theIsBoundaryEdges,
+ theIsManifoldEdges,
+ theIsNonManifoldEdges);
+
+ mySurfaceActor->SetFeatureEdgesFlags(theIsFeatureEdges,
+ theIsBoundaryEdges,
+ theIsManifoldEdges,
+ theIsNonManifoldEdges);
+}
+
+void
+VISU_ScalarMapAct
+::SetFeatureEdgesColoring(bool theIsColoring)
+{
+ Superclass::SetFeatureEdgesColoring(theIsColoring);
+
+ mySurfaceActor->SetFeatureEdgesColoring(theIsColoring);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
+{
+ if(theIsFeatureEdgesEnabled && myRepresentation == VTK_POINTS)
+ return;
+
+ Superclass::SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled);
+
+ mySurfaceActor->SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled);
+}
+
//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::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());
- myPointsActor->DeepCopy( anActor->myPointsActor );
+ myPointSpriteActor->DeepCopy( anActor->myPointSpriteActor );
SetShading(anActor->IsShading());
}
}
{
Superclass::AddToRender(theRenderer);
- myPointsActor->SetInteractor( myInteractor );
+ 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)
{
myBarVisibility = theMode;
if(myScalarBar)
- myScalarBar->SetVisibility(myBarVisibility);
+ myScalarBar->SetVisibility(myBarVisibility && GetVisibility());
}
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());
case Surfaceframe:
mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+ mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
+#if (VTK_XVERSION < 0x050100)
myEdgeActor->RenderTranslucentGeometry(ren);
+#else
+ myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
break;
case Points:
- myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
- myPointsActor->RenderTranslucentGeometry(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);
+#else
+ myPointsActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
+ }
break;
default:
mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+ mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
}
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
{
unsigned long int aSize = Superclass::GetMemorySize();
- aSize += myPointsActor->GetMemorySize();
+ aSize += myPointSpriteActor->GetMemorySize();
return aSize;
}
//----------------------------------------------------------------------------
+
+VISU_Actor::EQuadratic2DRepresentation
+VISU_ScalarMapAct
+::GetQuadratic2DRepresentation() const
+{
+ bool mode = (mySurfaceActor->GetQuadraticArcMode() && myEdgeActor->GetQuadraticArcMode());
+ if(mode){
+ return VISU_Actor::eArcs;
+ }
+ else
+ return VISU_Actor::eLines;
+}
+
+void VISU_ScalarMapAct::SetQuadratic2DRepresentation( VISU_Actor::EQuadratic2DRepresentation theMode )
+{
+ Superclass::SetQuadratic2DRepresentation( theMode );
+ switch(theMode) {
+ case VISU_Actor::eArcs:
+ mySurfaceActor->SetQuadraticArcMode(true);
+ myEdgeActor->SetQuadraticArcMode(true);
+ break;
+ case VISU_Actor::eLines:
+ mySurfaceActor->SetQuadraticArcMode(false);
+ myEdgeActor->SetQuadraticArcMode(false);
+ break;
+ default:
+ break;
+ }
+}
+
+void VISU_ScalarMapAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
+{
+ 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;
+}
+
+/**
+ * Set size of the 0D elements.
+ */
+void VISU_ScalarMapAct::Set0DElemSize(vtkFloatingPointType theValue) {
+ mySurfaceActor->GetProperty()->SetPointSize(theValue);
+}
+
+/**
+ * Get size of the 0D elements.
+ */
+vtkFloatingPointType VISU_ScalarMapAct::Get0DElemSize() {
+ return mySurfaceActor->GetProperty()->GetPointSize();
+}
+