From: epa Date: Wed, 25 Oct 2006 08:29:48 +0000 (+0000) Subject: PAL 13374 - EDF PAL 274:VISU easily visualize element edges X-Git-Tag: V3_2_3pre1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=787a31216e2f049b9008ce0b5ec80806b47c3bd7;p=modules%2Fvisu.git PAL 13374 - EDF PAL 274:VISU easily visualize element edges --- diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 3651a0a2..9e48b329 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -32,6 +32,7 @@ #include "SALOME_Actor.h" #include "VISU_ActorFactory.h" #include "VISU_BoostSignals.h" +#include "SVTK_DeviceActor.h" #include #include @@ -51,6 +52,14 @@ class VISU_PipeLine; #define VTKOCC_EXPORT VTK_EXPORT #endif +namespace SVTK +{ + namespace Representation + { + const Type Surfaceframe = Insideframe + 1; + } +} + namespace VISU { class Prs3d_i; diff --git a/src/OBJECT/VISU_MeshAct.cxx b/src/OBJECT/VISU_MeshAct.cxx index 17a8072d..31873bcd 100644 --- a/src/OBJECT/VISU_MeshAct.cxx +++ b/src/OBJECT/VISU_MeshAct.cxx @@ -27,7 +27,6 @@ // $Header$ #include "VISU_MeshAct.h" -#include "SVTK_DeviceActor.h" #include #include diff --git a/src/OBJECT/VISU_MeshAct.h b/src/OBJECT/VISU_MeshAct.h index bc358e6b..0f047615 100644 --- a/src/OBJECT/VISU_MeshAct.h +++ b/src/OBJECT/VISU_MeshAct.h @@ -30,15 +30,6 @@ #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 { diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index e9ce7e18..bf3d9ef8 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -29,12 +29,17 @@ #include "VISU_ScalarMapAct.h" #include "VISU_LookupTable.hxx" #include "VISU_ScalarBarActor.hxx" +#include "VISU_PipeLine.hxx" #include #include #include +#include +#include +#include vtkStandardNewMacro(VISU_ScalarMapAct); +static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT; VISU_ScalarMapAct ::VISU_ScalarMapAct() @@ -50,12 +55,135 @@ 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 @@ -116,7 +244,13 @@ VISU_ScalarMapAct ::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); } @@ -125,7 +259,7 @@ void VISU_ScalarMapAct ::SetShading(bool theOn) { - vtkProperty* aProperty = GetProperty(); + vtkProperty* aProperty = mySurfaceActor->GetProperty(); if (theOn) { @@ -136,14 +270,59 @@ VISU_ScalarMapAct { 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; +} + diff --git a/src/OBJECT/VISU_ScalarMapAct.h b/src/OBJECT/VISU_ScalarMapAct.h index 0b6a4839..ea6ebaf8 100644 --- a/src/OBJECT/VISU_ScalarMapAct.h +++ b/src/OBJECT/VISU_ScalarMapAct.h @@ -44,10 +44,59 @@ class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor ~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); @@ -82,8 +131,15 @@ class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor protected: VISU_ScalarMapAct(); + + virtual + void + SetMapperInput(vtkDataSet* theDataSet); + bool myBarVisibility; VISU_ScalarBarActor* myScalarBar; + SVTK_DeviceActor* mySurfaceActor; + SVTK_DeviceActor* myEdgeActor; }; #endif diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 7d94a704..9b13dce3 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2529,7 +2529,7 @@ createPopupMenus() // 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' " @@ -3121,14 +3121,14 @@ void VisuGUI::createPreferences() mesh_indices.append( 2 ); QStringList modes1 = mesh_modes; - modes1.remove( "Surfaceframe" ); + modes1.remove( "Insideframe" ); QValueList indices1 = mesh_indices; - indices1.remove( 4 ); + indices1.remove( 3 ); QStringList modes2 = modes1; - modes2.remove( "Insideframe" ); + modes2.remove( "Surfaceframe" ); QValueList indices2 = indices1; - indices2.remove( 3 ); + indices2.remove( 4 ); QStringList modes3 = modes2; modes3.remove( "Surface" ); @@ -3142,8 +3142,8 @@ void VisuGUI::createPreferences() 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" ); @@ -3162,8 +3162,8 @@ void VisuGUI::createPreferences() 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" ); @@ -3182,8 +3182,8 @@ void VisuGUI::createPreferences() 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,