Salome HOME
Merge from V6_main 11/02/2013
[modules/gui.git] / src / VTKViewer / VTKViewer_Actor.h
index ad050d3216331974bac23e8cbc310757a4257a9e..5225cd6b4df8317ed9374f103d02b5a6fd4a374f 100755 (executable)
+// 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
+//
+// 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
+//
+
+//  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//  File   : SALOME_Actor.h
+//  Author : Nicolas REJNERI
+
 #ifndef VTKVIEVER_ACTOR_H
 #define VTKVIEVER_ACTOR_H
 
 #include "VTKViewer.h"
 
+#include <string>
+#include <vector>
+
 #include <vtkLODActor.h>
 #include <vtkProperty.h>
-#include <vtkShrinkFilter.h>
-#include <vtkDataSetMapper.h>
-#include <vtkUnstructuredGrid.h>
-
-#include <vector>
 
 class vtkCell;
+class vtkPointPicker;
+class vtkCellPicker;
 class vtkDataSet;
-class vtkPolyData;
+class vtkCamera;
+class vtkProperty;
+class vtkRenderer;
+class vtkPassThroughFilter;
 
 class VTKViewer_Transform;
 class VTKViewer_GeometryFilter;
 class VTKViewer_TransformFilter;
-class VTKViewer_PassThroughFilter;
 
-#define VTKViewer_POINT_SIZE 3
+extern int VTKViewer_POINT_SIZE;
+extern int VTKViewer_LINE_WIDTH;
+
+namespace VTKViewer
+{
+  namespace Representation
+  {
+    typedef int Type;
+    const Type Points = VTK_POINTS;
+    const Type Wireframe = VTK_WIREFRAME;
+    const Type Surface = VTK_SURFACE;
+    const Type Insideframe = Surface + 1;
+    const Type SurfaceWithEdges = Insideframe + 1;
+  }
+}
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
 /*! \class vtkLODActor
  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
  */
-class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
+class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor 
 {
-public:
-  /*!Create new instance of actor.*/
+ public:
   static VTKViewer_Actor* New();
-
-  vtkTypeMacro( VTKViewer_Actor, vtkLODActor );
-
-  /*!Get name of the actor*/
-  virtual const char* getName() { return myName.c_str(); }
-  /*!Set name of the actor*/
-  virtual void setName(const char* theName){ myName = theName;}
-
-  //! To generate highlight automaticaly
-  virtual bool hasHighlight() { return false; }
-  //! Sets highlight.
-  virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
-  //! Check highlight.
-  virtual bool isHighlighted() { return myIsHighlighted; }
   
-  virtual void SetOpacity(float theOpacity);
-  virtual float GetOpacity();
-
-  virtual void SetColor(float r,float g,float b);
-  virtual void GetColor(float& r,float& g,float& b);
-  void SetColor(const float theRGB[3]){ SetColor(theRGB[0],theRGB[1],theRGB[2]); }
-
-  vtkSetObjectMacro(PreviewProperty,vtkProperty);
-
-  virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
-
-  //! Used to obtain all dependent actors
-  virtual void GetChildActors(vtkActorCollection*) {};
-  
-  virtual void AddToRender(vtkRenderer* theRenderer); 
-  virtual void RemoveFromRender(vtkRenderer* theRenderer);
-
-
-  /** @name For selection mapping purpose */
-  //@{
-  virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
-  virtual float* GetNodeCoord(int theObjID);
-
-  virtual int GetElemObjId(int theVtkID) { return theVtkID;}
-  virtual vtkCell* GetElemCell(int theObjID);
-  //@}
-
-  virtual int GetObjDimension( const int theObjId );
-
-  virtual void SetMapper(vtkMapper* theMapper); 
-  virtual vtkDataSet* GetInput(); 
-
-  virtual void SetTransform(VTKViewer_Transform* theTransform); 
-  virtual unsigned long int GetMTime();
-
-  virtual void SetRepresentation(int theMode);
-  virtual int GetRepresentation();
-
-  virtual int getDisplayMode();
-  virtual void setDisplayMode(int theMode);
-
-  /*! Infinitive means actor without size (point for example), \n
-   * which is not taken into account in calculation of boundaries of the scene
-   */
-  void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
-  virtual bool IsInfinitive();
+  vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
+
+  //----------------------------------------------------------------------------
+  //! Get its name
+  virtual 
+  const char* 
+  getName();
+
+  //! Name the #VTKViewer_Actor
+  virtual
+  void
+  setName(const char* theName);
+
+  //----------------------------------------------------------------------------
+  //! Change opacity
+  virtual
+  void
+  SetOpacity(vtkFloatingPointType theOpacity);
+
+  //! Get current opacity
+  virtual
+  vtkFloatingPointType 
+  GetOpacity();
+
+  //! Change color
+  virtual
+  void
+  SetColor(vtkFloatingPointType r,
+           vtkFloatingPointType g,
+           vtkFloatingPointType b);
+
+  //! Get current color
+  virtual
+  void
+  GetColor(vtkFloatingPointType& r,
+           vtkFloatingPointType& g,
+           vtkFloatingPointType& b);
+
+  //! Change color
+  virtual
+  void
+  SetColor(const vtkFloatingPointType theRGB[3]);
+
+  //! Change material\r
+  virtual\r
+  void\r
+  SetMaterial(std::vector<vtkProperty*> theProps);
+
+  //! Get current front material\r
+  virtual\r
+  vtkProperty* \r
+  GetFrontMaterial();\r
+\r
+  //! Get current back material\r
+  virtual\r
+  vtkProperty* \r
+  GetBackMaterial();
+
+  //----------------------------------------------------------------------------
+  // For selection mapping purpose
+  //! Maps VTK index of a node to corresponding object index
+  virtual
+  int 
+  GetNodeObjId(int theVtkID);
+
+  //! Get coordinates of a node for given object index
+  virtual
+  vtkFloatingPointType*
+  GetNodeCoord(int theObjID);
+
+  //! Maps VTK index of a cell to corresponding object index
+  virtual 
+  int
+  GetElemObjId(int theVtkID);
+
+  //! Get corresponding #vtkCell for given object index
+  virtual
+  vtkCell* 
+  GetElemCell(int theObjID);
+
+  //----------------------------------------------------------------------------
+  //! Get dimension of corresponding mesh element
+  virtual
+  int
+  GetObjDimension( const int theObjId );
+
+  //! To insert some additional filters and then sets the given #vtkMapper
+  virtual
+  void
+  SetMapper(vtkMapper* theMapper); 
+
+  //! Allows to get initial #vtkDataSet
+  virtual
+  vtkDataSet* 
+  GetInput(); 
+
+  //! Apply view transformation
+  virtual
+  void
+  SetTransform(VTKViewer_Transform* theTransform); 
+
+  //! To calculatate last modified time
+  virtual
+  unsigned long int
+  GetMTime();
+
+  //----------------------------------------------------------------------------
+  //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
+  virtual
+  void
+  SetRepresentation(int theMode);
+
+  //! Get current representation mode
+  virtual
+  int
+  GetRepresentation();
+
+  //! Get current display mode (obsolete)
+  virtual
+  int
+  getDisplayMode();
+
+  //! Set display mode (obsolete)
+  virtual
+  void
+  setDisplayMode(int theMode);
+
+  //----------------------------------------------------------------------------
+  //! Set infinive flag
+  /*!
+    Infinitive means actor without size (point for example),
+    which is not taken into account in calculation of boundaries of the scene
+  */
+  void
+  SetInfinitive(bool theIsInfinite);
+
+  //! Get infinive flag
+  virtual
+  bool
+  IsInfinitive();
     
-  void SetResolveCoincidentTopology(bool theIsResolve);
-  void SetPolygonOffsetParameters(float factor, float units);
-  void GetPolygonOffsetParameters(float& factor, float& units);
+  //! To calcualte current bounding box
+  virtual
+  vtkFloatingPointType* 
+  GetBounds();
+
+  //! To calcualte current bounding box
+  void
+  GetBounds(vtkFloatingPointType bounds[6]);
+
+  //----------------------------------------------------------------------------
+  virtual
+  bool
+  IsSetCamera() const;
+
+  virtual
+  bool
+  IsResizable() const;
+
+  virtual
+  void
+  SetSize( const vtkFloatingPointType );
+
+  virtual
+  void 
+  SetCamera( vtkCamera* );
+
+  //----------------------------------------------------------------------------
+  //! Set ResolveCoincidentTopology flag
+  void
+  SetResolveCoincidentTopology(bool theIsResolve);
+
+  //! Set ResolveCoincidentTopology parameters
+  void
+  SetPolygonOffsetParameters(vtkFloatingPointType factor, 
+                             vtkFloatingPointType units);
+
+  //! Get current ResolveCoincidentTopology parameters
+  void
+  GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
+                             vtkFloatingPointType& units);
+
+  virtual
+  void
+  Render(vtkRenderer *, vtkMapper *);
+
+  //----------------------------------------------------------------------------
+  //! Get current shrink factor
+  virtual
+  vtkFloatingPointType
+  GetShrinkFactor();
+
+  //! Is the actor is shrunkable
+  virtual
+  bool
+  IsShrunkable();
+
+  //! Is the actor is shrunk
+  virtual
+  bool
+  IsShrunk();
+
+  //! Insert shrink filter into pipeline
+  virtual
+  void
+  SetShrink();
+
+  //! Remove shrink filter from pipeline
+  virtual
+  void
+  UnShrink();
+
+  //----------------------------------------------------------------------------
+  //! To publish the actor an all its internal devices
+  virtual
+  void
+  AddToRender(vtkRenderer* theRendere); 
+
+  //! To remove the actor an all its internal devices
+  virtual
+  void
+  RemoveFromRender(vtkRenderer* theRendere);
 
-  virtual void Render(vtkRenderer *, vtkMapper *);
-
-protected:
-  /*!resolve coincedent topology flag*/
+  //! Used to obtain all dependent actors
+  virtual
+  void
+  GetChildActors(vtkActorCollection*);
+
+  //----------------------------------------------------------------------------
+  //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not
+  virtual
+  bool
+  hasHighlight(); 
+
+  //! Ask, if the VTKViewer_Actor is already highlighted
+  virtual
+  bool
+  isHighlighted();
+
+  //! Ask, if the VTKViewer_Actor is already preselected
+  virtual
+  bool
+  isPreselected();
+
+  //! Set preselection mode
+  virtual
+  void
+  SetPreSelected(bool thePreselect = false);
+
+  //----------------------------------------------------------------------------
+  //! Just to update visibility of the highlight devices
+  virtual
+  void
+  highlight(bool theHighlight);  
+
+  void
+  SetPreviewProperty(vtkProperty* theProperty);
+
+  //----------------------------------------------------------------------------
+  //! Setting for displaying quadratic elements
+  virtual void SetQuadraticArcMode(bool theFlag);
+  virtual bool GetQuadraticArcMode() const;
+
+  virtual void   SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle);
+  virtual vtkFloatingPointType GetQuadraticArcAngle() const;
+
+  //----------------------------------------------------------------------------
+  //! Return pointer to the dataset, which used to calculation of the bounding box of the actor
+  virtual vtkDataSet* GetHighlightedDataSet();
+
+ protected:
+  //----------------------------------------------------------------------------
   bool myIsResolveCoincidentTopology;
-  /*!polygon offset factor*/
-  float myPolygonOffsetFactor;
-  /*!polygon offset units*/
-  float myPolygonOffsetUnits;
+  vtkFloatingPointType myPolygonOffsetFactor;
+  vtkFloatingPointType myPolygonOffsetUnits;
 
-  /*!Actor name.*/
   std::string myName;
 
-  /*!preview property*/
-  vtkProperty *PreviewProperty;
-  /*!preselected flag*/
-  bool myIsPreselected;
-
-  /*!opacity*/
-  float myOpacity;
-  /*!highlighted flag*/
-  bool myIsHighlighted;
-  /*!display mode*/
+  vtkFloatingPointType myOpacity;
   int myDisplayMode;
-  /*!infinite flag*/
   bool myIsInfinite;
 
-  /*!store mapping flag*/
   bool myStoreMapping;
-  /*!geometry filter*/
   VTKViewer_GeometryFilter *myGeomFilter;
-  /*!transform filter*/
   VTKViewer_TransformFilter *myTransformFilter;
-  /*!vector of passive filters(siz filters used)*/
-  std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
+  std::vector<vtkPassThroughFilter*> myPassFilter;
 
-  /*!presentation mode*/
   int myRepresentation;
-  /*!property*/
   vtkProperty *myProperty;
 
-  //! Main method, which calculate output.
-  void InitPipeLine(vtkMapper* theMapper); 
+  void
+  InitPipeLine(vtkMapper* theMapper); 
 
   VTKViewer_Actor();
   ~VTKViewer_Actor();
+
+ protected:
+  vtkProperty *PreviewProperty;
+  bool myIsPreselected;
+  bool myIsHighlighted;
 };
 
+#ifdef WIN32
+#pragma warning ( default:4251 )
 #endif
+
+#endif // VTKVIEVER_ACTOR_H