X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKViewer%2FVTKViewer_Actor.h;h=77e54f2450d71a4559fa1b2f03b4c6b93d6009ec;hb=1c889394b028b786898a995d38c07c8f3d564837;hp=a58306d9c3d9f3b4a1f4d1bd330c9b3d4a2c573c;hpb=2e750f9ded92337bc3c44e9d7388180974cc4a43;p=modules%2Fgui.git diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h index a58306d9c..77e54f245 100755 --- a/src/VTKViewer/VTKViewer_Actor.h +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -1,120 +1,340 @@ +// Copyright (C) 2007-2008 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 +// Module : SALOME +// $Header$ +// #ifndef VTKVIEVER_ACTOR_H #define VTKVIEVER_ACTOR_H #include "VTKViewer.h" -#include -#include -#include -#include -#include - +#include #include +#include + 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; -class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor +#ifdef WIN32 +#pragma warning ( disable:4251 ) +#endif + +/*! \class vtkLODActor + * \brief For more information see VTK documentation + */ +class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor { -public: + public: static VTKViewer_Actor* New(); - - vtkTypeMacro( VTKViewer_Actor, vtkLODActor ); - - virtual const char* getName() { return myName.c_str(); } - virtual void setName(const char* theName){ myName = theName;} - - // To generate highlight automaticaly - virtual bool hasHighlight() { return false; } - virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; } - 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); - - + 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]); + + //---------------------------------------------------------------------------- // 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), - // which is not taken into account in calculation of boundaries of the scene - void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; } - virtual bool IsInfinitive(); + //! 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); - - virtual void Render(vtkRenderer *, vtkMapper *); - -protected: + //! 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); + + //! 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(); + + //! 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); + + protected: + //---------------------------------------------------------------------------- bool myIsResolveCoincidentTopology; - float myPolygonOffsetFactor; - float myPolygonOffsetUnits; + vtkFloatingPointType myPolygonOffsetFactor; + vtkFloatingPointType myPolygonOffsetUnits; std::string myName; - vtkProperty *PreviewProperty; - bool myIsPreselected; - - float myOpacity; - bool myIsHighlighted; + vtkFloatingPointType myOpacity; int myDisplayMode; bool myIsInfinite; bool myStoreMapping; VTKViewer_GeometryFilter *myGeomFilter; VTKViewer_TransformFilter *myTransformFilter; - std::vector myPassFilter; + std::vector myPassFilter; int myRepresentation; vtkProperty *myProperty; - 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