1 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_Actor.h
25 // Author : Nicolas REJNERI
29 #ifndef SALOME_ACTOR_H
30 #define SALOME_ACTOR_H
34 #include <vtkLODActor.h>
35 #include <vtkProperty.h>
42 #include "SALOME_InteractiveObject.hxx"
44 class SALOME_Transform;
45 class SALOME_GeometryFilter;
46 class SALOME_TransformFilter;
47 class SALOME_PassThroughFilter;
49 extern int SALOME_POINT_SIZE;
51 class SALOME_Actor : public vtkLODActor{
53 static SALOME_Actor* New();
55 vtkTypeMacro(SALOME_Actor,vtkLODActor);
57 virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
58 virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; }
59 virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
61 virtual const char* getName() { return myName.c_str(); }
62 virtual void setName(const char* theName){
63 if(hasIO()) myIO->setName(theName);
67 // To generate highlight automaticaly
68 virtual bool hasHighlight() { return false; }
69 virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
70 virtual bool isHighlighted() { return myIsHighlighted; }
72 virtual void SetOpacity(float theOpacity);
73 virtual float GetOpacity();
75 virtual void SetColor(float r,float g,float b);
76 virtual void GetColor(float& r,float& g,float& b);
77 void SetColor(const float theRGB[3]){
78 SetColor(theRGB[0],theRGB[1],theRGB[2]);
81 vtkSetObjectMacro(PreviewProperty,vtkProperty);
83 virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
86 // Used to obtain all dependent actors
87 virtual void GetChildActors(vtkActorCollection*) {};
89 virtual void AddToRender(vtkRenderer* theRenderer);
90 virtual void RemoveFromRender(vtkRenderer* theRenderer);
93 // For selection mapping purpose
94 virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
95 virtual float* GetNodeCoord(int theObjID);
97 virtual int GetElemObjId(int theVtkID) { return theVtkID;}
98 virtual vtkCell* GetElemCell(int theObjID);
100 virtual int GetObjDimension( const int theObjId );
102 virtual void SetMapper(vtkMapper* theMapper);
103 virtual vtkDataSet* GetInput();
106 virtual void SetTransform(SALOME_Transform* theTransform);
107 virtual unsigned long int GetMTime();
109 virtual void SetRepresentation(int theMode);
110 virtual int GetRepresentation();
112 virtual int getDisplayMode();
113 virtual void setDisplayMode(int theMode);
115 // Infinitive means actor without size (point for example),
116 // which is not taken into account in calculation of boundaries of the scene
117 void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
118 virtual bool IsInfinitive();
120 void SetResolveCoincidentTopology(bool theIsResolve);
121 void SetPolygonOffsetParameters(float factor, float units);
122 void GetPolygonOffsetParameters(float& factor, float& units);
124 virtual void Render(vtkRenderer *, vtkMapper *);
126 virtual float GetShrinkFactor() { return 1.0;}
128 virtual bool IsShrunkable() { return false;}
129 virtual bool IsShrunk() { return false;}
131 virtual void SetShrink() {}
132 virtual void UnShrink() {}
134 virtual bool IsSetCamera() const { return false; }
135 virtual bool IsResizable() const { return false; }
136 virtual void SetSize( const float ) {}
137 virtual void SetCamera( vtkCamera* ) {}
140 bool myIsResolveCoincidentTopology;
141 float myPolygonOffsetFactor;
142 float myPolygonOffsetUnits;
144 Handle(SALOME_InteractiveObject) myIO;
147 vtkProperty *PreviewProperty;
148 bool myIsPreselected;
151 bool myIsHighlighted;
156 SALOME_GeometryFilter *myGeomFilter;
157 SALOME_TransformFilter *myTransformFilter;
158 std::vector<SALOME_PassThroughFilter*> myPassFilter;
160 int myRepresentation;
161 vtkProperty *myProperty;
163 void InitPipeLine(vtkMapper* theMapper);
170 #endif // SALOME_ACTOR_H