File: vtkDefaultPainter.cxx

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,972 kB
  • sloc: cpp: 1,442,790; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 68; objc: 17
file content (361 lines) | stat: -rw-r--r-- 10,415 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkDefaultPainter.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkDefaultPainter.h"

#include "vtkActor.h"
#include "vtkClipPlanesPainter.h"
#include "vtkCoincidentTopologyResolutionPainter.h"
#include "vtkCompositePainter.h"
#include "vtkDisplayListPainter.h"
#include "vtkGarbageCollector.h"
#include "vtkLightingPainter.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
#include "vtkProperty.h"
#include "vtkRepresentationPainter.h"
#include "vtkScalarsToColorsPainter.h"

vtkStandardNewMacro(vtkDefaultPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, DefaultPainterDelegate, vtkPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, ScalarsToColorsPainter,
  vtkScalarsToColorsPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, ClipPlanesPainter,
  vtkClipPlanesPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, DisplayListPainter,
  vtkDisplayListPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, CompositePainter, vtkCompositePainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, CoincidentTopologyResolutionPainter,
  vtkCoincidentTopologyResolutionPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, LightingPainter, vtkLightingPainter);
vtkCxxSetObjectMacro(vtkDefaultPainter, RepresentationPainter, vtkRepresentationPainter);
//-----------------------------------------------------------------------------
vtkDefaultPainter::vtkDefaultPainter()
{
  this->ScalarsToColorsPainter = 0;
  this->ClipPlanesPainter = 0;
  this->DisplayListPainter = 0;
  this->CompositePainter = 0;
  this->CoincidentTopologyResolutionPainter = 0;
  this->LightingPainter = 0;
  this->RepresentationPainter = 0;
  this->DefaultPainterDelegate = 0;

  vtkScalarsToColorsPainter* scp = vtkScalarsToColorsPainter::New();
  this->SetScalarsToColorsPainter(scp);
  scp->Delete();

  vtkClipPlanesPainter* cp = vtkClipPlanesPainter::New();
  this->SetClipPlanesPainter(cp);
  cp->Delete();

  vtkDisplayListPainter* dlp = vtkDisplayListPainter::New();
  this->SetDisplayListPainter(dlp);
  dlp->Delete();

  vtkCompositePainter* cpp = vtkCompositePainter::New();
  this->SetCompositePainter(cpp);
  cpp->Delete();

  vtkCoincidentTopologyResolutionPainter* ctrp =
    vtkCoincidentTopologyResolutionPainter::New();
  this->SetCoincidentTopologyResolutionPainter(ctrp);
  ctrp->Delete();

  vtkLightingPainter* lp = vtkLightingPainter::New();
  this->SetLightingPainter(lp);
  lp->Delete();

  vtkRepresentationPainter* vp = vtkRepresentationPainter::New();
  this->SetRepresentationPainter(vp);
  vp->Delete();
}

//-----------------------------------------------------------------------------
vtkDefaultPainter::~vtkDefaultPainter()
{
  this->SetScalarsToColorsPainter(0);
  this->SetClipPlanesPainter(0);
  this->SetDisplayListPainter(0);
  this->SetCompositePainter(0);
  this->SetCoincidentTopologyResolutionPainter(0);
  this->SetLightingPainter(0);
  this->SetRepresentationPainter(0);
  this->SetDefaultPainterDelegate(0);
}

//-----------------------------------------------------------------------------
void vtkDefaultPainter::BuildPainterChain()
{
  vtkPainter* headPainter = 0;
  vtkPainter* prevPainter = 0;
  vtkPainter* painter = 0;

  painter = this->GetScalarsToColorsPainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  painter = this->GetClipPlanesPainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  painter = this->GetDisplayListPainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  // We are always putting in the composite painter since it does not have any
  // significant overhead for non-composite datasets.
  painter = this->GetCompositePainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  painter = this->GetLightingPainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  painter = this->GetRepresentationPainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  painter = this->GetCoincidentTopologyResolutionPainter();
  if (painter)
    {
    if (prevPainter)
      {
      prevPainter->SetDelegatePainter(painter);
      }
    prevPainter = painter;
    headPainter = (headPainter)? headPainter : painter;
    }

  // this will set in internal delegate painter.
  this->Superclass::SetDelegatePainter(headPainter);
  if (prevPainter)
    {
    prevPainter->SetDelegatePainter(this->DefaultPainterDelegate);
    }
}
//-----------------------------------------------------------------------------
void vtkDefaultPainter::Render(vtkRenderer* renderer, vtkActor* actor,
                               unsigned long typeflags, bool forceCompileOnly)
{
  if (this->ChainBuildTime < this->MTime)
    {
    this->BuildPainterChain();
    this->ChainBuildTime.Modified();
    }
  this->Superclass::Render(renderer, actor, typeflags,forceCompileOnly);
}

//-----------------------------------------------------------------------------
void vtkDefaultPainter::ReleaseGraphicsResources(vtkWindow *window)
{
  if (this->DefaultPainterDelegate)
    {
    this->DefaultPainterDelegate->ReleaseGraphicsResources(window);
    }
  if (this->ScalarsToColorsPainter)
    {
    this->ScalarsToColorsPainter->ReleaseGraphicsResources(window);
    }
  this->Superclass::ReleaseGraphicsResources(window);
}

//-----------------------------------------------------------------------------
void vtkDefaultPainter::SetDelegatePainter(vtkPainter* painter)
{
  this->SetDefaultPainterDelegate(painter);
}

//-----------------------------------------------------------------------------
void vtkDefaultPainter::ReportReferences(vtkGarbageCollector* collector)
{
  this->Superclass::ReportReferences(collector);
  vtkGarbageCollectorReport(collector, this->ScalarsToColorsPainter,
    "ScalarsToColors Painter");
  vtkGarbageCollectorReport(collector, this->DisplayListPainter,
    "DisplayListPainter");
  vtkGarbageCollectorReport(collector, this->ClipPlanesPainter,
    "ClipPlanes Painter");
  vtkGarbageCollectorReport(collector, this->CompositePainter,
    "Composite Painter");
  vtkGarbageCollectorReport(collector,
    this->CoincidentTopologyResolutionPainter,
    "CoincidentTopologyResolution Painter");
  vtkGarbageCollectorReport(collector, this->LightingPainter,
    "Lighting Painter");
  vtkGarbageCollectorReport(collector, this->RepresentationPainter,
    "Wireframe Painter");
  vtkGarbageCollectorReport(collector, this->DefaultPainterDelegate,
    "DefaultPainter Delegate");
}

//-------------------------------------------------------------------------
void vtkDefaultPainter::UpdateBounds(double bounds[6])
{
  // need the superclass to start with the first painter in the chain
  vtkPainter *painter = this->Superclass::GetDelegatePainter();

  if( painter )
    {
    // delegate the task of updating the bounds
    painter->UpdateBounds(bounds);
    }
  else
    {
    // no painter in the chain. let's build the chain if needed.
    if (this->ChainBuildTime < this->MTime)
      {
      // build the chain of painters
      this->BuildPainterChain();
      this->ChainBuildTime.Modified();
      }

    // try again to get the first painter in the chain
    painter = this->Superclass::GetDelegatePainter();

    if( painter )
      {
      //delegate the task of updating the bounds
      painter->UpdateBounds(bounds);
      }
    }
}

//-----------------------------------------------------------------------------
void vtkDefaultPainter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);

  os << indent << "ScalarsToColorsPainter: " ;
  if (this->ScalarsToColorsPainter)
    {
    os << endl ;
    this->ScalarsToColorsPainter->PrintSelf(os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }

  os << indent << "ClipPlanesPainter: " ;
  if (this->ClipPlanesPainter)
    {
    os << endl ;
    this->ClipPlanesPainter->PrintSelf(os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }

   os << indent << "DisplayListPainter: " ;
  if (this->DisplayListPainter)
    {
    os << endl;
    this->DisplayListPainter->PrintSelf(
      os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }

  os << indent << "CompositePainter: ";
  if (this->CompositePainter)
    {
    os << endl;
    this->CompositePainter->PrintSelf(os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }

  os << indent << "CoincidentTopologyResolutionPainter: " ;
  if (this->CoincidentTopologyResolutionPainter)
    {
    os << endl;
    this->CoincidentTopologyResolutionPainter->PrintSelf(
      os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }

  os << indent << "LightingPainter: " ;
  if (this->LightingPainter)
    {
    os << endl ;
    this->LightingPainter->PrintSelf(os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }

  os << indent << "RepresentationPainter: " ;
  if (this->RepresentationPainter)
    {
    os << endl ;
    this->RepresentationPainter->PrintSelf(os, indent.GetNextIndent());
    }
  else
    {
    os << "(none)" << endl;
    }
}