Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / src / OBJECT / SALOME_Actor.cxx
1 using namespace std;
2 //  File      : SALOME_Actor.cxx
3 //  Created   : Wed Feb 20 17:24:59 2002
4 //  Author    : Nicolas REJNERI
5 //  Project   : SALOME
6 //  Module    : OBJECT
7 //  Copyright : Open CASCADE 2002
8 //  $Header$
9
10 /*!
11   \class SALOME_Actor SALOME_Actor.h
12   \brief Abstract class of SALOME Objects in VTK.
13 */
14
15 #include "SALOME_Actor.h"
16
17 // SALOME Includes
18 #include "utilities.h"
19
20 // VTK Includes
21 #include <vtkObjectFactory.h>
22 #include <vtkMergePoints.h>
23
24
25 void SALOME_Actor::ShallowCopy(vtkProp *prop)
26 {
27   // Now do superclass
28   this->vtkActor::ShallowCopy(prop);
29 }
30
31 void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper )
32 {
33   if (this->Mapper == NULL) {
34     MESSAGE ("No mapper for actor.")
35     return;
36   }
37   
38   vtkMapper *bestMapper;
39   bestMapper = this->Mapper;
40
41   /* render the property */
42   if (!this->Property) {
43     // force creation of a property
44     this->GetProperty();
45   }
46
47   this->Property->Render(this, ren);
48   if (this->BackfaceProperty) {
49     this->BackfaceProperty->BackfaceRender(this, ren);
50     this->Device->SetBackfaceProperty(this->BackfaceProperty);
51   }
52   this->Device->SetProperty(this->Property);
53   
54   
55   /* render the texture */
56   if (this->Texture) {
57     this->Texture->Render(ren);
58   }
59   
60   
61   // Store information on time it takes to render.
62   // We might want to estimate time from the number of polygons in mapper.
63   this->Device->Render(ren,bestMapper);
64   this->EstimatedRenderTime = bestMapper->GetTimeToDraw();
65 }
66
67 int SALOME_Actor::RenderOpaqueGeometry(vtkViewport *vp)
68 {
69   int renderedSomething = 0; 
70   vtkRenderer      *ren = (vtkRenderer *)vp;
71
72   if ( ! this->Mapper ) {
73     return 0;
74   }
75
76   // make sure we have a property
77   if (!this->Property) {
78     // force creation of a property
79     this->GetProperty();
80   }
81
82   // is this actor opaque ?
83   if (this->GetIsOpaque()) {
84     this->Property->Render(this, ren);
85     
86     // render the backface property
87     if (this->BackfaceProperty) {
88       this->BackfaceProperty->BackfaceRender(this, ren);
89     }
90     
91     // render the texture 
92     if (this->Texture) {
93       this->Texture->Render(ren);
94     }
95     this->Render(ren,this->Mapper);
96     
97     renderedSomething = 1;
98   }
99   
100   return renderedSomething; 
101 }
102
103 void SALOME_Actor::ReleaseGraphicsResources(vtkWindow *renWin)
104 {
105   vtkActor::ReleaseGraphicsResources(renWin);
106   this->Mapper->ReleaseGraphicsResources(renWin);
107 }
108
109 // void SALOME_Actor::ApplyScaling ( vtkMapper*  newMapper, bool recover = false )
110 // {
111 //   if ( recover && m_Isometric )
112 //     {
113 //       SetMapper ( m_Isometric );
114 //       m_Isometric = NULL;
115 //     }
116 //   else
117 //     if ( m_Isometric == NULL )
118 //       {
119 //       m_Isometric = GetMapper();
120 //       SetMapper(newMapper);
121 //       }
122 // }
123
124 void SALOME_Actor::SetMapper ( vtkMapper*  newMapper )
125 {
126   if ( m_Initial == NULL && Mapper != NULL )
127     {
128       m_Initial = GetMapper();
129     }
130   vtkLODActor::SetMapper(newMapper);
131 }
132
133 SALOME_Actor::SALOME_Actor()
134 {
135   m_Initial = NULL;
136   PreviewProperty = NULL;
137 }
138 SALOME_Actor::~SALOME_Actor()
139 {
140   if ( m_Initial != NULL )
141      m_Initial->Delete();
142   if ( PreviewProperty != NULL )
143      PreviewProperty->Delete();
144 }