]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
PAL 13374 - EDF PAL 274:VISU easily visualize element edges
authorepa <epa@opencascade.com>
Wed, 25 Oct 2006 08:29:48 +0000 (08:29 +0000)
committerepa <epa@opencascade.com>
Wed, 25 Oct 2006 08:29:48 +0000 (08:29 +0000)
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_MeshAct.cxx
src/OBJECT/VISU_MeshAct.h
src/OBJECT/VISU_ScalarMapAct.cxx
src/OBJECT/VISU_ScalarMapAct.h
src/VISUGUI/VisuGUI.cxx

index 3651a0a2a5eba3341e43073bf304087c7e4102a5..9e48b3299432f93433447a7b428bd9bfe0bfdc97 100644 (file)
@@ -32,6 +32,7 @@
 #include "SALOME_Actor.h"
 #include "VISU_ActorFactory.h"
 #include "VISU_BoostSignals.h"
+#include "SVTK_DeviceActor.h"
 
 #include <string>
 #include <vtkSmartPointer.h>
@@ -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;
index 17a8072d4f138241a696ff659704d5d6cbff10f3..31873bcda1d83022fb977f3e9733cb1edf097476 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include "VISU_MeshAct.h"
-#include "SVTK_DeviceActor.h"
 
 #include <vtkObjectFactory.h>
 #include <vtkRenderer.h>
index bc358e6be37aa15e4f1d42aadbcf4d6dae9942c5..0f0476153154670b0e4d90083a1184965d16be6b 100644 (file)
 #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 
 {
index e9ce7e184fc283863a2acd8d028457c61e2fd6a8..bf3d9ef81f904c80beb72d7e7b009e02d04dfa56 100644 (file)
 #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()
@@ -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;
+}
+
index 0b6a4839f7cb47074275a37b2088a51195682995..ea6ebaf842d868932d04b4e7a2bc46f9fc0cb4c0 100644 (file)
@@ -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
index 7d94a704685840bba08532d1f52895db3d0c7a4d..9b13dce3179283cd180ef73e2ad398e7a573aaaf 100644 (file)
@@ -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<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" );
@@ -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,