#include "SALOME_Actor.h"
#include "VISU_ActorFactory.h"
#include "VISU_BoostSignals.h"
+#include "SVTK_DeviceActor.h"
#include <string>
#include <vtkSmartPointer.h>
#define VTKOCC_EXPORT VTK_EXPORT
#endif
+namespace SVTK
+{
+ namespace Representation
+ {
+ const Type Surfaceframe = Insideframe + 1;
+ }
+}
+
namespace VISU
{
class Prs3d_i;
// $Header$
#include "VISU_MeshAct.h"
-#include "SVTK_DeviceActor.h"
#include <vtkObjectFactory.h>
#include <vtkRenderer.h>
#define VISU_MeshAct_HeaderFile
#include "VISU_Actor.h"
-#include "SVTK_DeviceActor.h"
-
-namespace SVTK
-{
- namespace Representation
- {
- const Type Surfaceframe = Insideframe + 1;
- }
-}
class VTKOCC_EXPORT VISU_MeshAct : public VISU_Actor
{
#include "VISU_ScalarMapAct.h"
#include "VISU_LookupTable.hxx"
#include "VISU_ScalarBarActor.hxx"
+#include "VISU_PipeLine.hxx"
#include <vtkObjectFactory.h>
#include <vtkRenderer.h>
#include <vtkProperty.h>
+#include <vtkMatrix4x4.h>
+#include <vtkMapper.h>
+#include <vtkDataSetMapper.h>
vtkStandardNewMacro(VISU_ScalarMapAct);
+static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
VISU_ScalarMapAct
::VISU_ScalarMapAct()
aProperty->SetSpecular(0.0);
myProperty->DeepCopy(aProperty);
+
+ vtkMatrix4x4 *m;
+ m = vtkMatrix4x4::New();
+
+ mySurfaceActor= SVTK_DeviceActor::New();
+ mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
+ mySurfaceActor->SetProperty(myProperty);
+ mySurfaceActor->SetUserMatrix(m);
+
+ myEdgeActor = SVTK_DeviceActor::New();
+ myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
+ myEdgeActor->SetUserMatrix(m);
+ myEdgeActor->GetProperty()->SetColor(255.,255.,255.);
+
+ m->Delete();
}
VISU_ScalarMapAct
::~VISU_ScalarMapAct()
{
myScalarBar->Delete();
+ mySurfaceActor->Delete();
+ myEdgeActor->Delete();
+}
+
+void
+VISU_ScalarMapAct
+::ShallowCopyPL(VISU_PipeLine* thePipeLine)
+{
+ VISU_Actor::ShallowCopyPL(thePipeLine);
+
+ myEdgeActor->GetMapper()->ScalarVisibilityOff();
+
+ vtkDataSet* aDatsSet = mySurfaceActor->GetDataSetMapper()->GetInput();
+ mySurfaceActor->GetMapper()->ShallowCopy(thePipeLine->GetMapper());
+ // To restore mapper input from pipeline
+ mySurfaceActor->GetDataSetMapper()->SetInput(aDatsSet);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetMapperInput(vtkDataSet* theDataSet)
+{
+ Superclass::SetMapperInput(theDataSet);
+
+ mySurfaceActor->SetInput(theDataSet);
+ myEdgeActor->SetInput(theDataSet);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetTransform(VTKViewer_Transform* theTransform)
+{
+ Superclass::SetTransform(theTransform);
+
+ mySurfaceActor->SetTransform(theTransform);
+ myEdgeActor->SetTransform(theTransform);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetShrinkable(bool theIsShrinkable)
+{
+ Superclass::SetShrinkable(theIsShrinkable);
+
+ mySurfaceActor->SetShrinkable(theIsShrinkable);
+}
+
+void
+VISU_ScalarMapAct
+::SetShrinkFactor(vtkFloatingPointType theValue)
+{
+ Superclass::SetShrinkFactor(theValue);
+
+ mySurfaceActor->SetShrinkFactor(theValue);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetShrink()
+{
+ if(myRepresentation == VTK_POINTS)
+ return;
+
+ Superclass::SetShrink();
+
+ mySurfaceActor->SetShrink();
+}
+
+void
+VISU_ScalarMapAct
+::UnShrink()
+{
+ Superclass::UnShrink();
+
+ mySurfaceActor->UnShrink();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetOpacity(vtkFloatingPointType theValue)
+{
+ mySurfaceActor->GetProperty()->SetOpacity(theValue);
+}
+
+vtkFloatingPointType
+VISU_ScalarMapAct
+::GetOpacity()
+{
+ return mySurfaceActor->GetProperty()->GetOpacity();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::SetLineWidth(vtkFloatingPointType theLineWidth)
+{
+ mySurfaceActor->GetProperty()->SetLineWidth(theLineWidth);
+}
+
+vtkFloatingPointType
+VISU_ScalarMapAct::GetLineWidth()
+{
+ return mySurfaceActor->GetProperty()->GetLineWidth();
}
void
::SetRepresentation(int theMode)
{
bool anIsShanding = IsShading();
+
Superclass::SetRepresentation(theMode);
+ if(theMode == SVTK::Representation::Surfaceframe)
+ mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
+ else
+ mySurfaceActor->SetRepresentation(theMode);
+
SetShading(anIsShanding);
}
VISU_ScalarMapAct
::SetShading(bool theOn)
{
- vtkProperty* aProperty = GetProperty();
+ vtkProperty* aProperty = mySurfaceActor->GetProperty();
if (theOn)
{
{
aProperty->SetAmbient(1.0);
aProperty->SetDiffuse(0.0);
- }
+ }
}
bool
VISU_ScalarMapAct
::IsShading()
{
- vtkProperty* aProperty = GetProperty();
+ vtkProperty* aProperty = mySurfaceActor->GetProperty();
- return (aProperty->GetAmbient() == 0 && aProperty->GetDiffuse() == 1);
+ return (fabs(aProperty->GetAmbient()) < EPS && fabs(aProperty->GetDiffuse() - 1.) < EPS);
}
+
+int
+VISU_ScalarMapAct
+::RenderOpaqueGeometry(vtkViewport *ren)
+{
+ GetMatrix(myEdgeActor->GetUserMatrix());
+ GetMatrix(mySurfaceActor->GetUserMatrix());
+
+ using namespace SVTK::Representation;
+ if( GetRepresentation() == Surfaceframe ){
+ mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
+ mySurfaceActor->RenderOpaqueGeometry(ren);
+
+ myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
+ myEdgeActor->RenderOpaqueGeometry(ren);
+ }
+ else{
+ mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+ mySurfaceActor->RenderOpaqueGeometry(ren);
+ }
+ return 1;
+}
+
+int
+VISU_ScalarMapAct
+::RenderTranslucentGeometry(vtkViewport *ren)
+{
+ GetMatrix(myEdgeActor->GetUserMatrix());
+ GetMatrix(mySurfaceActor->GetUserMatrix());
+
+ using namespace SVTK::Representation;
+ if( GetRepresentation() == Surfaceframe ){
+ mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+ mySurfaceActor->RenderTranslucentGeometry(ren);
+
+ myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
+ myEdgeActor->RenderTranslucentGeometry(ren);
+ }
+ else{
+ mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+ mySurfaceActor->RenderTranslucentGeometry(ren);
+ }
+ return 1;
+}
+
~VISU_ScalarMapAct();
+ virtual
+ void
+ ShallowCopyPL(VISU_PipeLine* thePipeLine);
+
+ //! Apply view transformation
+ virtual
+ void
+ SetTransform(VTKViewer_Transform* theTransform);
+
+ virtual
+ void
+ SetShrinkable(bool theIsShrinkable);
+
+ virtual
+ void
+ SetShrinkFactor(vtkFloatingPointType theFactor = 0.8);
+
+ virtual
+ void
+ SetShrink();
+
+ virtual
+ void
+ UnShrink();
+
+ virtual
+ void
+ SetOpacity(vtkFloatingPointType theValue);
+
+ virtual
+ vtkFloatingPointType
+ GetOpacity();
+
+ virtual
+ void
+ SetLineWidth(vtkFloatingPointType theLineWidth);
+
+ virtual
+ vtkFloatingPointType
+ GetLineWidth();
+
virtual
void
AddToRender(vtkRenderer* theRenderer);
+ virtual
+ int
+ RenderOpaqueGeometry(vtkViewport *ren);
+
+ virtual
+ int
+ RenderTranslucentGeometry(vtkViewport *ren);
+
virtual
void
RemoveFromRender(vtkRenderer* theRenderer);
protected:
VISU_ScalarMapAct();
+
+ virtual
+ void
+ SetMapperInput(vtkDataSet* theDataSet);
+
bool myBarVisibility;
VISU_ScalarBarActor* myScalarBar;
+ SVTK_DeviceActor* mySurfaceActor;
+ SVTK_DeviceActor* myEdgeActor;
};
#endif
// 3D presentations commands
QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
- QString aSurfFrameType = " and $type in {'VISU::TMESH'}";
+ QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
" 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
mesh_indices.append( 2 );
QStringList modes1 = mesh_modes;
- modes1.remove( "Surfaceframe" );
+ modes1.remove( "Insideframe" );
QValueList<QVariant> indices1 = mesh_indices;
- indices1.remove( 4 );
+ indices1.remove( 3 );
QStringList modes2 = modes1;
- modes2.remove( "Insideframe" );
+ modes2.remove( "Surfaceframe" );
QValueList<QVariant> indices2 = indices1;
- indices2.remove( 3 );
+ indices2.remove( 4 );
QStringList modes3 = modes2;
modes3.remove( "Surface" );
addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "mesh_shrink" );
int scalar_map_represent = addPreference( tr( "VISU_SCALAR_MAP" ), representGr, LightApp_Preferences::Selector, "VISU", "scalar_map_represent" );
- setPreferenceProperty( scalar_map_represent, "strings", modes1 );
- setPreferenceProperty( scalar_map_represent, "indexes", indices1 );
+ setPreferenceProperty( scalar_map_represent, "strings", mesh_modes );
+ setPreferenceProperty( scalar_map_represent, "indexes", mesh_indices );
addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_map_shrink" );
int iso_surfaces_represent = addPreference( tr( "VISU_ISO_SURFACES" ), representGr, LightApp_Preferences::Selector, "VISU", "iso_surfaces_represent" );
addPreference( "", representGr, LightApp_Preferences::Space );
int deformed_shape_represent = addPreference( tr( "VISU_DEFORMED_SHAPE" ), representGr, LightApp_Preferences::Selector, "VISU", "deformed_shape_represent" );
- setPreferenceProperty( deformed_shape_represent, "strings", modes1 );
- setPreferenceProperty( deformed_shape_represent, "indexes", indices1 );
+ setPreferenceProperty( deformed_shape_represent, "strings", mesh_modes );
+ setPreferenceProperty( deformed_shape_represent, "indexes", mesh_indices );
addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "deformed_shape_shrink" );
int vectors_represent = addPreference( tr( "VISU_VECTORS" ), representGr, LightApp_Preferences::Selector, "VISU", "vectors_represent" );
addPreference( "", representGr, LightApp_Preferences::Space );
int scalar_def_represent = addPreference( tr( "VISU_SCALAR_MAP_ON_DEFORMED_SHAPE" ), representGr, LightApp_Preferences::Selector, "VISU", "scalar_def_represent" );
- setPreferenceProperty( scalar_def_represent, "strings", modes2 );
- setPreferenceProperty( scalar_def_represent, "indexes", indices2 );
+ setPreferenceProperty( scalar_def_represent, "strings", modes1 );
+ setPreferenceProperty( scalar_def_represent, "indexes", indices1 );
addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_def_shrink" );
addPreference( tr( "VISU_USE_SHADING" ), representGr,