]> SALOME platform Git repositories - modules/visu.git/blobdiff - src/OBJECT/VISU_MeshAct.cxx
Salome HOME
Update copyright information
[modules/visu.git] / src / OBJECT / VISU_MeshAct.cxx
index 2c3050dd51f23160010c3669db1371e10dace150..a39c49dd365484a5051e83c1d3c034b844913f11 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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-2007  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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU OBJECT : interactive object for VISU entities implementation
 //  File   : VISU_MeshAct.cxx
 //  Author : 
@@ -27,6 +28,9 @@
 //
 #include "VISU_MeshAct.h"
 
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
 #include <vtkObjectFactory.h>
 #include <vtkRenderer.h>
 #include <vtkTexture.h>
@@ -50,19 +54,33 @@ VISU_MeshAct
   m = vtkMatrix4x4::New();
 
   mySurfaceActor = SVTK_DeviceActor::New();
-  mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
+  mySurfaceActor->SetRepresentation(VTKViewer::Representation::Surface);
   mySurfaceActor->SetUserMatrix(m);
+  mySurfaceActor->SetCoincident3DAllowed(true);
 
   myEdgeActor = SVTK_DeviceActor::New();
-  myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
+  myEdgeActor->SetRepresentation(VTKViewer::Representation::Wireframe);
   myEdgeActor->SetUserMatrix(m);
+  myEdgeActor->SetCoincident3DAllowed(true);
 
   myNodeActor = SVTK_DeviceActor::New();
-  myNodeActor->SetRepresentation(SVTK::Representation::Points);
+  myNodeActor->SetRepresentation(VTKViewer::Representation::Points);
   myNodeActor->SetUserMatrix(m);
 
   m->Delete();
-  SetRepresentation(SVTK::Representation::Surface);
+  SetRepresentation(VTKViewer::Representation::Surface);
+
+  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);
+    GetSurfaceProperty()->SetPointSize(anElem0DSize);
+  }  
 }
 
 VISU_MeshAct
@@ -233,19 +251,19 @@ VISU_MeshAct
 void
 VISU_MeshAct
 ::SetFeatureEdgesFlags(bool theIsFeatureEdges,
-                      bool theIsBoundaryEdges,
-                      bool theIsManifoldEdges,
-                      bool theIsNonManifoldEdges)
+                       bool theIsBoundaryEdges,
+                       bool theIsManifoldEdges,
+                       bool theIsNonManifoldEdges)
 {
   Superclass::SetFeatureEdgesFlags(theIsFeatureEdges,
-                                  theIsBoundaryEdges,
-                                  theIsManifoldEdges,
-                                  theIsNonManifoldEdges);
+                                   theIsBoundaryEdges,
+                                   theIsManifoldEdges,
+                                   theIsNonManifoldEdges);
 
   mySurfaceActor->SetFeatureEdgesFlags(theIsFeatureEdges,
-                                      theIsBoundaryEdges,
-                                      theIsManifoldEdges,
-                                      theIsNonManifoldEdges);
+                                       theIsBoundaryEdges,
+                                       theIsManifoldEdges,
+                                       theIsNonManifoldEdges);
 }
 
 void
@@ -277,10 +295,10 @@ VISU_MeshAct
 {
   Superclass::SetRepresentation(theMode);
 
-  if(theMode == SVTK::Representation::Insideframe)
-    myEdgeActor->SetRepresentation(SVTK::Representation::Insideframe);
+  if(theMode == VTKViewer::Representation::Insideframe)
+    myEdgeActor->SetRepresentation(VTKViewer::Representation::Insideframe);
   else
-    myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
+    myEdgeActor->SetRepresentation(VTKViewer::Representation::Wireframe);
 }
 
 //----------------------------------------------------------------------------
@@ -323,7 +341,7 @@ VISU_MeshAct
   GetMatrix(myEdgeActor->GetUserMatrix());
   GetMatrix(mySurfaceActor->GetUserMatrix());
 
-  using namespace SVTK::Representation;
+  using namespace VTKViewer::Representation;
   switch(GetRepresentation()){
   case Points : 
     myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
@@ -335,6 +353,7 @@ VISU_MeshAct
     myEdgeActor->RenderOpaqueGeometry(ren);
     break;
   case Surface : 
+  case FeatureEdges :
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
     mySurfaceActor->RenderOpaqueGeometry(ren);
     break;
@@ -345,48 +364,137 @@ VISU_MeshAct
     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
     myEdgeActor->RenderOpaqueGeometry(ren);
     break;
-  case FeatureEdges :
-    mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
-    mySurfaceActor->RenderOpaqueGeometry(ren);
-    break;
   }
   return 1;
 }
 
 int
 VISU_MeshAct
+#if (VTK_XVERSION < 0x050100)
 ::RenderTranslucentGeometry(vtkViewport *ren)
+#else
+::RenderTranslucentPolygonalGeometry(vtkViewport *ren)
+#endif
 {
   GetMatrix(myNodeActor->GetUserMatrix());
   GetMatrix(myEdgeActor->GetUserMatrix());
   GetMatrix(mySurfaceActor->GetUserMatrix());
 
-  using namespace SVTK::Representation;
+  using namespace VTKViewer::Representation;
   switch(GetRepresentation()){
   case Points : 
     myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     myNodeActor->RenderTranslucentGeometry(ren);
+#else
+    myNodeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   case Wireframe : 
   case Insideframe : 
     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     myEdgeActor->RenderTranslucentGeometry(ren);
+#else
+    myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   case Surface : 
+  case FeatureEdges :
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   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);
-    break;
-  case FeatureEdges :
-    mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
-    mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   }
   return 1;
 }
+
+#if (VTK_XVERSION >= 0x050100)
+int
+VISU_MeshAct
+::HasTranslucentPolygonalGeometry()
+{
+  int result = 0; 
+
+  using namespace VTKViewer::Representation;
+  switch ( GetRepresentation() ) {
+  case Points:
+    result |= myNodeActor->HasTranslucentPolygonalGeometry();
+    break;
+  case Wireframe: 
+  case Insideframe: 
+    result |= myEdgeActor->HasTranslucentPolygonalGeometry();
+    break;
+  case Surface:
+  case FeatureEdges:
+    result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
+    break;
+  case Surfaceframe:
+    result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
+    result |= myEdgeActor->HasTranslucentPolygonalGeometry();
+    break;
+  default:
+    break;
+  }
+
+  return result;
+}
+#endif
+
+VISU_Actor::EQuadratic2DRepresentation 
+VISU_MeshAct::GetQuadratic2DRepresentation() const
+{
+  bool mode = (mySurfaceActor->GetQuadraticArcMode() && myEdgeActor->GetQuadraticArcMode());
+  if(mode){
+    return VISU_Actor::eArcs;
+  }
+  else
+    return VISU_Actor::eLines;
+}
+
+void VISU_MeshAct::SetQuadratic2DRepresentation( 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_MeshAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
+{
+  Superclass::SetMarkerStd( theMarkerType, theMarkerScale );
+  myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
+}
+
+void VISU_MeshAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
+{
+  Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture );
+  myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
+}