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
32 #include "SALOME_InteractiveObject.hxx" // INCLUDES "using namespace std"
33 #ifndef _Handle_SALOME_InteractiveObject_HeaderFile
34 #include "Handle_SALOME_InteractiveObject.hxx"
37 #include <vtkLODActor.h> // INCLUDES "stdio.h"
38 #include <vtkProperty.h>
40 // to overcome the conflict between std::ostream and io::ostream
41 // the following variable must be defined:
42 // VTK_USE_ANSI_STDLIB
52 class VTKViewer_Transform;
53 class VTKViewer_GeometryFilter;
54 class VTKViewer_TransformFilter;
55 class VTKViewer_PassThroughFilter;
57 extern int SALOME_POINT_SIZE;
60 #define SALOME_OBJECT_EXPORT __declspec (dllexport)
62 #define SALOME_OBJECT_EXPORT
65 #include <VTKViewer_Actor.h>
67 class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor {
69 static SALOME_Actor* New();
71 vtkTypeMacro(SALOME_Actor,vtkLODActor);
73 virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
74 virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; }
75 virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
77 virtual const char* getName() { return myName.c_str(); }
78 virtual void setName(const char* theName){
79 if(hasIO()) myIO->setName(theName);
83 // To generate highlight automaticaly
84 virtual bool hasHighlight() { return false; }
85 virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
86 virtual bool isHighlighted() { return myIsHighlighted; }
88 virtual void SetOpacity(float theOpacity);
89 virtual float GetOpacity();
91 virtual void SetColor(float r,float g,float b);
92 virtual void GetColor(float& r,float& g,float& b);
93 void SetColor(const float theRGB[3]){
94 SetColor(theRGB[0],theRGB[1],theRGB[2]);
97 vtkSetObjectMacro(PreviewProperty,vtkProperty);
99 virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
102 // Used to obtain all dependent actors
103 virtual void GetChildActors(vtkActorCollection*) {};
105 virtual void AddToRender(vtkRenderer* theRenderer);
106 virtual void RemoveFromRender(vtkRenderer* theRenderer);
109 // For selection mapping purpose
110 virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
111 virtual float* GetNodeCoord(int theObjID);
113 virtual int GetElemObjId(int theVtkID) { return theVtkID;}
114 virtual vtkCell* GetElemCell(int theObjID);
116 virtual int GetObjDimension( const int theObjId );
118 virtual void SetMapper(vtkMapper* theMapper);
119 virtual vtkDataSet* GetInput();
122 virtual void SetTransform(VTKViewer_Transform* theTransform);
123 virtual unsigned long int GetMTime();
125 virtual void SetRepresentation(int theMode);
126 virtual int GetRepresentation();
128 virtual int getDisplayMode();
129 virtual void setDisplayMode(int theMode);
131 // Infinitive means actor without size (point for example),
132 // which is not taken into account in calculation of boundaries of the scene
133 void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
134 virtual bool IsInfinitive();
136 void SetResolveCoincidentTopology(bool theIsResolve);
137 void SetPolygonOffsetParameters(float factor, float units);
138 void GetPolygonOffsetParameters(float& factor, float& units);
140 virtual void Render(vtkRenderer *, vtkMapper *);
142 virtual float GetShrinkFactor() { return 1.0;}
144 virtual bool IsShrunkable() { return false;}
145 virtual bool IsShrunk() { return false;}
147 virtual void SetShrink() {}
148 virtual void UnShrink() {}
150 virtual bool IsSetCamera() const { return false; }
151 virtual bool IsResizable() const { return false; }
152 virtual void SetSize( const float ) {}
153 virtual void SetCamera( vtkCamera* ) {}
156 bool myIsResolveCoincidentTopology;
157 float myPolygonOffsetFactor;
158 float myPolygonOffsetUnits;
160 Handle(SALOME_InteractiveObject) myIO;
163 vtkProperty *PreviewProperty;
164 bool myIsPreselected;
167 bool myIsHighlighted;
172 VTKViewer_GeometryFilter *myGeomFilter;
173 VTKViewer_TransformFilter *myTransformFilter;
174 std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
176 int myRepresentation;
177 vtkProperty *myProperty;
179 void InitPipeLine(vtkMapper* theMapper);
186 #endif // SALOME_ACTOR_H