Salome HOME
DCQ: prepare V2.0.0
[modules/kernel.git] / src / OBJECT / SALOME_Actor.h
1 //  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_Actor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef SALOME_ACTOR_H
30 #define SALOME_ACTOR_H
31
32 // SALOME Includes
33 #include "VTKViewer_Common.h"
34 #include "SALOME_InteractiveObject.hxx"
35
36 #include <vector>
37
38 class SALOME_Transform;
39 class SALOME_GeometryFilter;
40 class SALOME_TransformFilter;
41 class SALOME_PassThroughFilter;
42
43 extern int SALOME_POINT_SIZE;
44
45 class SALOME_Actor : public vtkLODActor{
46  protected:
47   //constructor should be protected due to first implementation of this class
48   //it was abstract class
49   SALOME_Actor();
50   ~SALOME_Actor();
51  public:
52   static SALOME_Actor* New();
53
54   vtkTypeMacro(SALOME_Actor,vtkLODActor);
55
56   virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
57   virtual Handle_SALOME_InteractiveObject getIO() { return myIO; } 
58   virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
59
60   virtual Standard_CString getName()     { return myName; }
61   virtual void setName(Standard_CString aName){
62     myName = aName;
63     if(hasIO()) myIO->setName(aName);
64   }
65
66   virtual int getDisplayMode() { return myDisplayMode; }
67   virtual void setDisplayMode(int mode) { myDisplayMode = mode; }
68
69   virtual bool hasHighlight() { return false; }  
70   virtual void highlight(Standard_Boolean highlight) { ishighlighted = highlight; }  
71   virtual Standard_Boolean isHighlighted() { return ishighlighted; }
72
73   virtual void SetOpacity(float opa) { m_opacity = opa; }
74   virtual float GetOpacity() { return m_opacity; }
75
76   virtual void SetColor(float r,float g,float b) {};
77   virtual void GetColor(float& r,float& g,float& b) {};
78
79   vtkSetObjectMacro(PreviewProperty,vtkProperty);
80
81   virtual void SetPreSelected(Standard_Boolean presel = Standard_False)   { ispreselected = presel; }
82
83   // Used to obtain all dependent actors
84   virtual void GetChildActors(vtkActorCollection*) {};
85   
86   virtual void AddToRender(vtkRenderer* theRenderer); 
87   virtual void RemoveFromRender(vtkRenderer* theRenderer);
88
89   typedef std::vector<int> TVectorId;
90   virtual int GetObjId(int theVtkID) { return -1;}
91   virtual TVectorId GetVtkId(int theObjID) { return TVectorId();}
92
93   virtual int GetObjDimension( const int theObjId );
94
95   virtual void SetMapper(vtkMapper* theMapper); 
96   virtual vtkPolyData* GetPolyDataInput(); 
97
98   virtual void SetTransform(SALOME_Transform* theTransform); 
99   virtual unsigned long int GetMTime();
100
101   virtual void SetRepresentation(int theMode);
102   virtual int GetRepresentation();
103
104   // Infinitive means actor without size (point for example
105   // which is not taken into account in calculation of boundaries of the scene
106   virtual bool IsInfinitive() { return myIsInfinite; }
107     
108  protected:
109   vtkProperty         *PreviewProperty;
110   Standard_Boolean    ispreselected;
111
112   Handle(SALOME_InteractiveObject) myIO;
113   Standard_CString myName;
114
115   float   m_opacity;
116   Standard_Boolean    ishighlighted;
117   int myDisplayMode;
118   bool myIsInfinite;
119
120   bool myStoreMapping;
121   SALOME_GeometryFilter *myGeomFilter;
122   SALOME_TransformFilter *myTransformFilter;
123   std::vector<SALOME_PassThroughFilter*> myPassFilter;
124
125   int myRepresentation;
126   vtkProperty *myProperty;
127 };
128
129 #endif // SALOME_ACTOR_H