]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
bug #251: incorrect rotation in VTK
authorasl <asl@opencascade.com>
Thu, 19 Dec 2013 11:10:27 +0000 (11:10 +0000)
committerasl <asl@opencascade.com>
Thu, 19 Dec 2013 11:10:27 +0000 (11:10 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/GEOM_Actor_patched.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Actor.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Actor.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx

index 95163188aec5d43ccbf66608903c2c774b392956..9fa01059f1e6c3685e043d9c13b1122d2c482ecc 100644 (file)
@@ -79,6 +79,7 @@ set(PROJECT_HEADERS
     HYDROGUI_ImportProfilesOp.h
     HYDROGUI_GeoreferencementDlg.h
     HYDROGUI_GeoreferencementOp.h
+    HYDROGUI_Actor.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -159,6 +160,7 @@ set(PROJECT_SOURCES
     HYDROGUI_ImportProfilesOp.cxx
     HYDROGUI_GeoreferencementDlg.cxx
     HYDROGUI_GeoreferencementOp.cxx
+    HYDROGUI_Actor.cxx
 )
 
 add_definitions(
diff --git a/src/HYDROGUI/GEOM_Actor_patched.h b/src/HYDROGUI/GEOM_Actor_patched.h
new file mode 100644 (file)
index 0000000..efa756d
--- /dev/null
@@ -0,0 +1,281 @@
+// Copyright (C) 2007-2013  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
+//
+// 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
+//
+
+//  GEOM OBJECT : interactive object for Geometry entities visualization
+//  File   : GEOM_Actor.h
+//  Author : Christophe ATTANASIO
+//  Module : GEOM
+//
+#ifndef GEOM_ACTOR_H
+#define GEOM_ACTOR_H
+
+#include "GEOM_OBJECT_defs.hxx"
+#include "GEOM_SmartPtr.h"
+
+#include <SALOME_Actor.h>
+
+#include <TopoDS_Shape.hxx>
+#include <vtkSmartPointer.h>
+
+class vtkCamera;
+
+class GEOM_VertexSource;
+typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
+
+class GEOM_EdgeSource;
+typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
+
+class GEOM_WireframeFace;
+typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
+
+class GEOM_ShadingFace;
+typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
+
+class vtkRenderer;
+
+class vtkAppendPolyData;
+typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
+
+class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
+{
+public:
+  vtkTypeMacro(GEOM_Actor,SALOME_Actor);
+  static GEOM_Actor* New();
+
+  void SetShape(const TopoDS_Shape& theShape,
+                float theDeflection,
+                bool theIsVector = false);
+
+  void SetDeflection(float theDeflection);
+  float GetDeflection() const{ return myDeflection;}
+
+  void AddToRender(vtkRenderer* theRenderer);
+  void RemoveFromRender(vtkRenderer* theRenderer);
+
+  enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
+
+/*   void SetDisplayMode(EDisplayMode theMode);  */
+/*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
+
+  void SetSelected(bool theIsSelected);
+  bool IsSelected() const { return myIsSelected;}
+
+  // OLD METHODS
+  // Properties
+  void SetHighlightProperty(vtkProperty* Prop);
+  void SetWireframeProperty(vtkProperty* Prop);
+  void SetShadingProperty(vtkProperty* Prop);
+
+  vtkProperty* GetWireframeProperty();
+  vtkProperty* GetShadingProperty();
+  vtkProperty* GetIsolatedEdgeProperty();
+  vtkProperty* GetVertexProperty();
+  vtkProperty* GetSharedEdgeProperty();
+  vtkProperty* GetFaceEdgeProperty();
+
+  void setDeflection(double adef);
+  virtual void setDisplayMode(int thenewmode);
+
+  // Description:
+  // This causes the actor to be rendered. It, in turn, will render the actor's
+  // property and then mapper.
+  virtual void Render(vtkRenderer *, vtkMapper *);
+  // Description:
+  // Release any graphics resources that are being consumed by this actor.
+  // The parameter window could be used to determine which graphic
+  // resources to release.
+  void ReleaseGraphicsResources(vtkWindow *);
+  const TopoDS_Shape& getTopo();
+  void setInputShape(const TopoDS_Shape& ashape, double adef1,
+                     int imode, bool isVector = false);
+  double getDeflection();
+  double isVector();
+
+  // SubShape
+  void SubShapeOn();
+  void SubShapeOff();
+
+  // Highlight
+  virtual void highlight(bool theHighlight);
+  virtual bool hasHighlight() { return true; }
+
+  void ShallowCopy(vtkProp *prop);
+
+  // Opacity
+  void SetOpacity(double opa);
+  double GetOpacity();
+
+  // Color (same to all sub-actors/display modes)
+  void SetColor(double r,  double g,  double b);
+  void GetColor(double& r, double& g, double& b);
+  // Color of points
+  void SetPointColor(double r, double g, double b);
+  // Color of standalone edges, wires, vectors
+  void SetIsolatedEdgeColor(double r, double g, double b);
+  // Color of shared edges
+  void SetSharedEdgeColor(double r, double g, double b);
+  // Color of free edges
+  void SetFreeEdgeColor(double r, double g, double b);
+  // Color of edges in shading+edges display mode
+  void SetEdgesInShadingColor(double r, double g, double b);
+  // Color of iso-lines
+  void SetIsosColor(double r, double g, double b);
+
+
+  // Material
+  void SetMaterial(std::vector<vtkProperty*> theProps);
+  vtkProperty* GetFrontMaterial();
+  vtkProperty* GetBackMaterial();
+  virtual bool IsInfinitive();
+
+  // overloaded functions
+  //! To map current selection to VTK representation
+  virtual
+  void
+  Highlight(bool theHighlight);
+
+  //----------------------------------------------------------------------------
+  //! To process prehighlight (called from #SVTK_InteractorStyle)
+  virtual
+  bool
+  PreHighlight(vtkInteractorStyle* theInteractorStyle,
+               SVTK_SelectionEvent* theSelectionEvent,
+               bool theIsHighlight);
+
+  //! To process highlight (called from #SVTK_InteractorStyle)
+  virtual
+  bool
+  Highlight(vtkInteractorStyle* theInteractorStyle,
+            SVTK_SelectionEvent* theSelectionEvent,
+            bool theIsHighlight);
+
+  //! Visibility management
+  virtual
+  void
+  SetVisibility( int );
+
+  //! IsoLines management
+  // theNb[0] - number of U lines
+  // theNb[1] - number of V lines
+  virtual
+  void
+  SetNbIsos(const int theNb[2]);
+
+  virtual
+  void
+  GetNbIsos(int &theNbU,int &theNbV);
+  
+  virtual 
+  void SetIsosWidth(const int width);
+
+  int GetIsosWidth() const;
+
+  virtual void SetWidth(const int width);
+
+  int GetWidth() const;
+  
+  //! Vector mode management
+  virtual
+  void
+  SetVectorMode(const bool theMode);
+
+  virtual
+  bool
+  GetVectorMode();
+  
+  void
+  StoreIsoNumbers();
+
+  void
+  RestoreIsoNumbers();
+  
+  void
+  ResetIsoNumbers();
+
+protected:
+  void SetModified();
+
+  void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
+
+  GEOM_Actor();
+  ~GEOM_Actor();
+
+private:
+  TopoDS_Shape myShape;
+  int myNbIsos[2];
+  bool isOnlyVertex;
+
+  float myDeflection;
+  bool myIsForced;
+
+  //  EDisplayMode myDisplayMode;
+  bool myIsSelected;
+  bool myVectorMode;
+
+protected:
+  PDeviceActor myVertexActor;
+  PVertexSource myVertexSource;
+
+  PDeviceActor myIsolatedEdgeActor;
+  PEdgeSource myIsolatedEdgeSource;
+
+  PDeviceActor myOneFaceEdgeActor;
+  PEdgeSource myOneFaceEdgeSource;
+
+  PDeviceActor mySharedEdgeActor;
+  PEdgeSource mySharedEdgeSource;
+
+  PDeviceActor myWireframeFaceActor;
+  PWFaceSource myWireframeFaceSource;
+
+  PDeviceActor myShadingFaceActor;
+  PSFaceSource myShadingFaceSource;
+
+  PDeviceActor myHighlightActor;
+
+private:
+  vtkSmartPointer<vtkProperty>  myHighlightProp;
+  vtkSmartPointer<vtkProperty>  myPreHighlightProp;
+  vtkSmartPointer<vtkProperty>  myShadingFaceProp;
+  vtkSmartPointer<vtkProperty>  myShadingBackFaceProp;
+
+  PAppendFilter myAppendFilter;
+
+protected:
+  PPolyGeomPainterDataMapper myPolyDataMapper;
+
+private:
+  virtual void SetMapper(vtkMapper*);
+
+  GEOM_Actor(const GEOM_Actor&);
+  void operator=(const GEOM_Actor&);
+
+  double myEdgesInWireframeColor[3];
+  double myEdgesInShadingColor[3];
+  double myIsolatedEdgeColor[3];
+  double mySharedEdgeColor[3];
+  double myOneFaceEdgeColor[3];
+};
+
+#endif //GEOM_ACTOR_H
+
+
diff --git a/src/HYDROGUI/HYDROGUI_Actor.cxx b/src/HYDROGUI/HYDROGUI_Actor.cxx
new file mode 100644 (file)
index 0000000..4848a0b
--- /dev/null
@@ -0,0 +1,60 @@
+
+#include <HYDROGUI_Actor.h>
+#include <GEOM_PainterPolyDataMapper.h>
+#include <GEOM_DeviceActor.h>
+#include <GEOM_VertexSource.h>
+#include <GEOM_EdgeSource.h>
+#include <GEOM_WireframeFace.h>
+#include <GEOM_ShadingFace.h>
+
+HYDROGUI_Actor* HYDROGUI_Actor::New()
+{
+  HYDROGUI_Actor* anObject = new HYDROGUI_Actor(); 
+  anObject->SetMapper( anObject->myPolyDataMapper.Get()); 
+  return anObject; 
+}
+
+void HYDROGUI_Actor::SetMapper( vtkMapper* theMapper )
+{ 
+  SALOME_Actor::SetMapper(theMapper); 
+}
+
+/*double* HYDROGUI_Actor::GetBounds()
+{
+  double* aBounds = GEOM_Actor::GetBounds();
+  return aBounds;
+}*/
+
+void HYDROGUI_Actor::SetTransform( VTKViewer_Transform* theTransform )
+{
+  SALOME_Actor::SetTransform( theTransform );
+  myVertexActor       ->GetDeviceActor()->SetTransform( theTransform );
+  myIsolatedEdgeActor ->GetDeviceActor()->SetTransform( theTransform );
+  myOneFaceEdgeActor  ->GetDeviceActor()->SetTransform( theTransform );
+  mySharedEdgeActor   ->GetDeviceActor()->SetTransform( theTransform );
+  myWireframeFaceActor->GetDeviceActor()->SetTransform( theTransform );
+  myShadingFaceActor  ->GetDeviceActor()->SetTransform( theTransform );
+  myHighlightActor    ->GetDeviceActor()->SetTransform( theTransform );
+}
+
+void HYDROGUI_Actor::SetShape( const TopoDS_Shape& theShape,
+                               float theDeflection,
+                               bool theIsVector )
+{
+  GEOM_Actor::SetShape( theShape, theDeflection, theIsVector ); 
+
+  if( myIsolatedEdgeSource->IsEmpty() )
+    myIsolatedEdgeActor->GetDeviceActor()->SetInfinitive( true );
+
+  if( myOneFaceEdgeSource->IsEmpty() )
+    myOneFaceEdgeActor->GetDeviceActor()->SetInfinitive( true );
+
+  if( mySharedEdgeSource->IsEmpty() )
+    mySharedEdgeActor->GetDeviceActor()->SetInfinitive( true );
+
+  if( myWireframeFaceSource->IsEmpty() )
+    myWireframeFaceActor->GetDeviceActor()->SetInfinitive( true );
+
+  if( myShadingFaceSource->IsEmpty() )
+    myShadingFaceActor->GetDeviceActor()->SetInfinitive( true );
+}
diff --git a/src/HYDROGUI/HYDROGUI_Actor.h b/src/HYDROGUI/HYDROGUI_Actor.h
new file mode 100644 (file)
index 0000000..19d6eb5
--- /dev/null
@@ -0,0 +1,23 @@
+
+#ifndef HYDROGUI_ACTOR_H
+#define HYDROGUI_ACTOR_H
+
+#include <GEOM_Actor_patched.h>
+
+class HYDROGUI_Actor : public GEOM_Actor
+{
+public:
+  vtkTypeMacro( HYDROGUI_Actor, GEOM_Actor );
+  static HYDROGUI_Actor* New();
+
+  void SetMapper( vtkMapper* theMapper );
+
+  //virtual double* GetBounds();
+  virtual void SetTransform( VTKViewer_Transform* theTransform );
+
+  void SetShape(const TopoDS_Shape& theShape,
+                float theDeflection,
+                bool theIsVector = false);
+};
+
+#endif
index 3a841ee33cbc9c67aabb2437ab98256d1321a0a6..c1a20685c7c094d8a0af5bf2e0d06d90e54adb07 100644 (file)
@@ -55,7 +55,7 @@
 
 #include <Precision.hxx>
 
-#include <GEOM_Actor.h>
+#include <HYDROGUI_Actor.h>
 #include <vtkScalarBarActor.h>
 
 #include <QString>
@@ -94,12 +94,15 @@ void HYDROGUI_VTKPrsShape::compute()
 
     if ( !myTopoShape.IsNull() )
     {
-      GEOM_Actor* anActor = GEOM_Actor::New();
+      HYDROGUI_Actor* anActor = HYDROGUI_Actor::New();
       anActor->SetShape( myTopoShape, VTK_MIN_DEFLECTION );
       anActor->setDisplayMode( myDisplayMode );
       anActor->setIO( getIO() );
       AddObject( anActor );
 
+      //double bounds[6];
+      //anActor->GetBounds( bounds );
+
       anActor->Delete();
     }
   }