1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkGraphMapper.cxx
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16 Copyright 2008 Sandia Corporation.
17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18 the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
20 #include "vtkGraphMapper.h"
21
22 #include "vtkActor.h"
23 #include "vtkActor2D.h"
24 #include "vtkMapArrayValues.h"
25 #include "vtkCamera.h"
26 #include "vtkCellArray.h"
27 #include "vtkCellData.h"
28 #include "vtkDirectedGraph.h"
29 #include "vtkExecutive.h"
30 #include "vtkFollower.h"
31 #include "vtkGarbageCollector.h"
32 #include "vtkGlyph3D.h"
33 #include "vtkGraphToPolyData.h"
34 #include "vtkIconGlyphFilter.h"
35 #include "vtkImageData.h"
36 #include "vtkInformation.h"
37 #include "vtkLookupTableWithEnabling.h"
38 #include "vtkMath.h"
39 #include "vtkObjectFactory.h"
40 #include "vtkPlaneSource.h"
41 #include "vtkPointData.h"
42 #include "vtkPolyData.h"
43 #include "vtkPolyDataMapper.h"
44 #include "vtkPolyDataMapper2D.h"
45 #include "vtkProperty.h"
46 #include "vtkRenderer.h"
47 #include "vtkTexture.h"
48 #include "vtkTexturedActor2D.h"
49 #include "vtkTransformCoordinateSystems.h"
50 #include "vtkUndirectedGraph.h"
51 #include "vtkVertexGlyphFilter.h"
52
53 vtkStandardNewMacro(vtkGraphMapper);
54
55 #define VTK_CREATE(type,name) \
56 vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
57
58 //----------------------------------------------------------------------------
vtkGraphMapper()59 vtkGraphMapper::vtkGraphMapper()
60 {
61 this->GraphToPoly = vtkSmartPointer<vtkGraphToPolyData>::New();
62 this->VertexGlyph = vtkSmartPointer<vtkVertexGlyphFilter>::New();
63 this->IconTypeToIndex = vtkSmartPointer<vtkMapArrayValues>::New();
64 this->CircleGlyph = vtkSmartPointer<vtkGlyph3D>::New();
65 this->CircleOutlineGlyph = vtkSmartPointer<vtkGlyph3D>::New();
66 this->IconGlyph = vtkSmartPointer<vtkIconGlyphFilter>::New();
67 this->IconTransform = vtkSmartPointer<vtkTransformCoordinateSystems>::New();
68 this->EdgeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
69 this->VertexMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
70 this->OutlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
71 this->IconMapper = vtkSmartPointer<vtkPolyDataMapper2D>::New();
72 this->EdgeActor = vtkSmartPointer<vtkActor>::New();
73 this->VertexActor = vtkSmartPointer<vtkActor>::New();
74 this->OutlineActor = vtkSmartPointer<vtkActor>::New();
75 this->IconActor = vtkSmartPointer<vtkTexturedActor2D>::New();
76 this->VertexLookupTable = vtkLookupTableWithEnabling::New();
77 this->EdgeLookupTable = vtkLookupTableWithEnabling::New();
78 this->VertexColorArrayNameInternal = 0;
79 this->EdgeColorArrayNameInternal = 0;
80 this->EnabledEdgesArrayName = 0;
81 this->EnabledVerticesArrayName = 0;
82 this->VertexPointSize = 5;
83 this->EdgeLineWidth = 1;
84 this->ScaledGlyphs = false;
85 this->ScalingArrayName = 0;
86
87 this->VertexMapper->SetScalarModeToUsePointData();
88 this->VertexMapper->SetLookupTable(this->VertexLookupTable);
89 this->VertexMapper->SetScalarVisibility(false);
90 this->VertexMapper->ImmediateModeRenderingOn();
91 this->VertexActor->PickableOff();
92 this->VertexActor->GetProperty()->SetPointSize(this->GetVertexPointSize());
93 this->OutlineActor->PickableOff();
94 this->OutlineActor->GetProperty()->SetPointSize(this->GetVertexPointSize()+2);
95 this->OutlineActor->SetPosition(0, 0, -0.001);
96 this->OutlineActor->GetProperty()->SetRepresentationToWireframe();
97 this->OutlineMapper->SetScalarVisibility(false);
98 this->OutlineMapper->ImmediateModeRenderingOn();
99 this->EdgeMapper->SetScalarModeToUseCellData();
100 this->EdgeMapper->SetLookupTable(this->EdgeLookupTable);
101 this->EdgeMapper->SetScalarVisibility(false);
102 this->EdgeMapper->ImmediateModeRenderingOn();
103 this->EdgeActor->SetPosition(0, 0, -0.003);
104 this->EdgeActor->GetProperty()->SetLineWidth(this->GetEdgeLineWidth());
105
106 this->IconTransform->SetInputCoordinateSystemToWorld();
107 this->IconTransform->SetOutputCoordinateSystemToDisplay();
108 this->IconTransform->SetInputConnection(this->VertexGlyph->GetOutputPort());
109
110 this->IconTypeToIndex->SetInputConnection(this->IconTransform->GetOutputPort());
111 this->IconTypeToIndex->SetFieldType(vtkMapArrayValues::POINT_DATA);
112 this->IconTypeToIndex->SetOutputArrayType(VTK_INT);
113 this->IconTypeToIndex->SetPassArray(0);
114 this->IconTypeToIndex->SetFillValue(-1);
115
116 this->IconGlyph->SetInputConnection(this->IconTypeToIndex->GetOutputPort());
117 this->IconGlyph->SetUseIconSize(true);
118 this->IconMapper->SetInputConnection(this->IconGlyph->GetOutputPort());
119 this->IconMapper->ScalarVisibilityOff();
120
121 this->IconActor->SetMapper(this->IconMapper);
122 this->IconArrayNameInternal = 0;
123
124 this->VertexMapper->SetInputConnection(this->VertexGlyph->GetOutputPort());
125 this->OutlineMapper->SetInputConnection(this->VertexGlyph->GetOutputPort());
126
127 this->VertexActor->SetMapper(this->VertexMapper);
128 this->OutlineActor->SetMapper(this->OutlineMapper);
129 this->EdgeMapper->SetInputConnection(this->GraphToPoly->GetOutputPort());
130 this->EdgeActor->SetMapper(this->EdgeMapper);
131
132 // Set default parameters
133 this->SetVertexColorArrayName("VertexDegree");
134 this->ColorVerticesOff();
135 this->SetEdgeColorArrayName("weight");
136 this->ColorEdgesOff();
137 this->SetEnabledEdgesArrayName("weight");
138 this->SetEnabledVerticesArrayName("VertexDegree");
139 this->EnableEdgesByArray = 0;
140 this->EnableVerticesByArray = 0;
141 this->IconVisibilityOff();
142 }
143
144 //----------------------------------------------------------------------------
~vtkGraphMapper()145 vtkGraphMapper::~vtkGraphMapper()
146 {
147 // Delete internally created objects.
148 // Note: All of the smartpointer objects
149 // will be deleted for us
150
151 this->SetVertexColorArrayNameInternal(0);
152 this->SetEdgeColorArrayNameInternal(0);
153 this->SetEnabledEdgesArrayName(0);
154 this->SetEnabledVerticesArrayName(0);
155 this->SetIconArrayNameInternal(0);
156 this->VertexLookupTable->Delete();
157 this->VertexLookupTable = 0;
158 this->EdgeLookupTable->Delete();
159 this->EdgeLookupTable = 0;
160 if(this->ScalingArrayName!=0)
161 {
162 delete[] this->ScalingArrayName;
163 }
164 }
165
166 //----------------------------------------------------------------------------
SetIconArrayName(const char * name)167 void vtkGraphMapper::SetIconArrayName(const char* name)
168 {
169 this->SetIconArrayNameInternal(name);
170 this->IconGlyph->SetInputArrayToProcess(0,0,0,
171 vtkDataObject::FIELD_ASSOCIATION_POINTS,name);
172 this->IconTypeToIndex->SetInputArrayName(name);
173 }
174
175 //----------------------------------------------------------------------------
GetIconArrayName()176 const char* vtkGraphMapper::GetIconArrayName()
177 {
178 return this->GetIconArrayNameInternal();
179 }
180
181 //----------------------------------------------------------------------------
SetScaledGlyphs(bool arg)182 void vtkGraphMapper::SetScaledGlyphs(bool arg)
183 {
184 if (arg)
185 {
186 if (this->ScalingArrayName)
187 {
188 vtkPolyData *circle = this->CreateCircle(true);
189 this->CircleGlyph->SetSourceData(circle);
190 circle->Delete();
191 this->CircleGlyph->SetInputConnection(this->VertexGlyph->GetOutputPort());
192 this->CircleGlyph->SetScaling(1);
193 //this->CircleGlyph->SetScaleFactor(.1); // Total hack
194 this->CircleGlyph->SetInputArrayToProcess(0,0,0,
195 vtkDataObject::FIELD_ASSOCIATION_POINTS, this->ScalingArrayName);
196 this->VertexMapper->SetInputConnection(this->CircleGlyph->GetOutputPort());
197
198 vtkPolyData *outline = this->CreateCircle(false);
199 this->CircleOutlineGlyph->SetSourceData(outline);
200 outline->Delete();
201 this->CircleOutlineGlyph->SetInputConnection(this->VertexGlyph->GetOutputPort());
202 this->CircleOutlineGlyph->SetScaling(1);
203 //this->CircleOutlineGlyph->SetScaleFactor(.1); // Total hack
204 this->CircleOutlineGlyph->SetInputArrayToProcess(0,0,0,
205 vtkDataObject::FIELD_ASSOCIATION_POINTS, this->ScalingArrayName);
206 this->OutlineMapper->SetInputConnection(this->CircleOutlineGlyph->GetOutputPort());
207 this->OutlineActor->SetPosition(0, 0, 0.001);
208 this->OutlineActor->GetProperty()->SetLineWidth(2);
209 }
210 else
211 {
212 vtkErrorMacro("No scaling array name set");
213 }
214 }
215 else
216 {
217 this->VertexMapper->SetInputConnection(this->VertexGlyph->GetOutputPort());
218 this->OutlineActor->SetPosition(0, 0, -0.001);
219 this->OutlineMapper->SetInputConnection(this->VertexGlyph->GetOutputPort());
220 }
221 }
222
223
224 //----------------------------------------------------------------------------
225 // Helper method
CreateCircle(bool filled)226 vtkPolyData* vtkGraphMapper::CreateCircle(bool filled)
227 {
228 int circleRes = 16;
229 vtkIdType ptIds[17];
230 double x[3], theta;
231
232 // Allocate storage
233 vtkPolyData *poly = vtkPolyData::New();
234 VTK_CREATE(vtkPoints,pts);
235 VTK_CREATE(vtkCellArray, circle);
236 VTK_CREATE(vtkCellArray, outline);
237
238 // generate points around the circle
239 x[2] = 0.0;
240 theta = 2.0 * vtkMath::Pi() / circleRes;
241 for (int i=0; i<circleRes; i++)
242 {
243 x[0] = 0.5 * cos(i*theta);
244 x[1] = 0.5 * sin(i*theta);
245 ptIds[i] = pts->InsertNextPoint(x);
246 }
247 circle->InsertNextCell(circleRes,ptIds);
248
249 // Outline
250 ptIds[circleRes] = ptIds[0];
251 outline->InsertNextCell(circleRes+1,ptIds);
252
253 // Set up polydata
254 poly->SetPoints(pts);
255 if (filled)
256 {
257 poly->SetPolys(circle);
258 }
259 else
260 {
261 poly->SetLines(outline);
262 }
263
264 return poly;
265 }
266
267
268 //----------------------------------------------------------------------------
SetVertexColorArrayName(const char * name)269 void vtkGraphMapper::SetVertexColorArrayName(const char* name)
270 {
271 this->SetVertexColorArrayNameInternal(name);
272 this->VertexMapper->SetScalarModeToUsePointFieldData();
273 this->VertexMapper->SelectColorArray(name);
274 }
275
276 //----------------------------------------------------------------------------
GetVertexColorArrayName()277 const char* vtkGraphMapper::GetVertexColorArrayName()
278 {
279 return this->GetVertexColorArrayNameInternal();
280 }
281
282 //----------------------------------------------------------------------------
SetColorVertices(bool vis)283 void vtkGraphMapper::SetColorVertices(bool vis)
284 {
285 this->VertexMapper->SetScalarVisibility(vis);
286 }
287
288 //----------------------------------------------------------------------------
GetColorVertices()289 bool vtkGraphMapper::GetColorVertices()
290 {
291 return this->VertexMapper->GetScalarVisibility() ? true : false;
292 }
293
294 //----------------------------------------------------------------------------
ColorVerticesOn()295 void vtkGraphMapper::ColorVerticesOn()
296 {
297 this->VertexMapper->SetScalarVisibility(true);
298 }
299
300 //----------------------------------------------------------------------------
ColorVerticesOff()301 void vtkGraphMapper::ColorVerticesOff()
302 {
303 this->VertexMapper->SetScalarVisibility(false);
304 }
305
306 //----------------------------------------------------------------------------
SetIconVisibility(bool vis)307 void vtkGraphMapper::SetIconVisibility(bool vis)
308 {
309 this->IconActor->SetVisibility(vis);
310 }
311
312 //----------------------------------------------------------------------------
GetIconVisibility()313 bool vtkGraphMapper::GetIconVisibility()
314 {
315 return this->IconActor->GetVisibility() ? true : false;
316 }
317
318 //----------------------------------------------------------------------------
SetEdgeColorArrayName(const char * name)319 void vtkGraphMapper::SetEdgeColorArrayName(const char* name)
320 {
321 this->SetEdgeColorArrayNameInternal(name);
322 this->EdgeMapper->SetScalarModeToUseCellFieldData();
323 this->EdgeMapper->SelectColorArray(name);
324 }
325
326 //----------------------------------------------------------------------------
GetEdgeColorArrayName()327 const char* vtkGraphMapper::GetEdgeColorArrayName()
328 {
329 return this->GetEdgeColorArrayNameInternal();
330 }
331
332 //----------------------------------------------------------------------------
SetColorEdges(bool vis)333 void vtkGraphMapper::SetColorEdges(bool vis)
334 {
335 this->EdgeMapper->SetScalarVisibility(vis);
336 }
337
338 //----------------------------------------------------------------------------
GetColorEdges()339 bool vtkGraphMapper::GetColorEdges()
340 {
341 return this->EdgeMapper->GetScalarVisibility() ? true : false;
342 }
343
344 //----------------------------------------------------------------------------
ColorEdgesOn()345 void vtkGraphMapper::ColorEdgesOn()
346 {
347 this->EdgeMapper->SetScalarVisibility(true);
348 }
349
350 //----------------------------------------------------------------------------
ColorEdgesOff()351 void vtkGraphMapper::ColorEdgesOff()
352 {
353 this->EdgeMapper->SetScalarVisibility(false);
354 }
355
356 //----------------------------------------------------------------------------
SetVertexPointSize(float size)357 void vtkGraphMapper::SetVertexPointSize(float size)
358 {
359 this->VertexPointSize = size;
360 this->VertexActor->GetProperty()->SetPointSize(this->GetVertexPointSize());
361 this->OutlineActor->GetProperty()->SetPointSize(this->GetVertexPointSize()+2);
362 }
363
364 //----------------------------------------------------------------------------
SetEdgeLineWidth(float width)365 void vtkGraphMapper::SetEdgeLineWidth(float width)
366 {
367 this->EdgeLineWidth = width;
368 this->EdgeActor->GetProperty()->SetLineWidth(this->GetEdgeLineWidth());
369 }
370
371 //----------------------------------------------------------------------------
AddIconType(char * type,int index)372 void vtkGraphMapper::AddIconType(char *type, int index)
373 {
374 this->IconTypeToIndex->AddToMap(type, index);
375 }
376
377 //----------------------------------------------------------------------------
ClearIconTypes()378 void vtkGraphMapper::ClearIconTypes()
379 {
380 this->IconTypeToIndex->ClearMap();
381 }
382
383 //----------------------------------------------------------------------------
SetEdgeVisibility(bool vis)384 void vtkGraphMapper::SetEdgeVisibility(bool vis)
385 {
386 this->EdgeActor->SetVisibility(vis);
387 }
388
389 //----------------------------------------------------------------------------
GetEdgeVisibility()390 bool vtkGraphMapper::GetEdgeVisibility()
391 {
392 return this->EdgeActor->GetVisibility() ? true : false;
393 }
394
395 //----------------------------------------------------------------------------
SetIconSize(int * size)396 void vtkGraphMapper::SetIconSize(int *size)
397 {
398 this->IconGlyph->SetIconSize(size);
399 }
400
401 //----------------------------------------------------------------------------
SetIconAlignment(int alignment)402 void vtkGraphMapper::SetIconAlignment(int alignment)
403 {
404 this->IconGlyph->SetGravity(alignment);
405 }
406
407 //----------------------------------------------------------------------------
GetIconSize()408 int *vtkGraphMapper::GetIconSize()
409 {
410 return this->IconGlyph->GetIconSize();
411 }
412
413 //----------------------------------------------------------------------------
SetIconTexture(vtkTexture * texture)414 void vtkGraphMapper::SetIconTexture(vtkTexture *texture)
415 {
416 this->IconActor->SetTexture(texture);
417 }
418
419 //----------------------------------------------------------------------------
GetIconTexture()420 vtkTexture *vtkGraphMapper::GetIconTexture()
421 {
422 return this->IconActor->GetTexture();
423 }
424
425 //----------------------------------------------------------------------------
SetInputData(vtkGraph * input)426 void vtkGraphMapper::SetInputData(vtkGraph *input)
427 {
428 this->SetInputDataInternal(0, input);
429 }
430
431 //----------------------------------------------------------------------------
GetInput()432 vtkGraph *vtkGraphMapper::GetInput()
433 {
434 vtkGraph *inputGraph =
435 vtkGraph::SafeDownCast(this->Superclass::GetInputAsDataSet());
436 return inputGraph;
437 }
438
439 //----------------------------------------------------------------------------
ReleaseGraphicsResources(vtkWindow * renWin)440 void vtkGraphMapper::ReleaseGraphicsResources( vtkWindow *renWin )
441 {
442 if (this->EdgeMapper)
443 {
444 this->EdgeMapper->ReleaseGraphicsResources( renWin );
445 }
446 }
447
448 //----------------------------------------------------------------------------
449 // Receives from Actor -> maps data to primitives
450 //
Render(vtkRenderer * ren,vtkActor * vtkNotUsed (act))451 void vtkGraphMapper::Render(vtkRenderer *ren, vtkActor * vtkNotUsed(act))
452 {
453 // make sure that we've been properly initialized
454 if ( !this->GetExecutive()->GetInputData(0, 0) )
455 {
456 vtkErrorMacro(<< "No input!\n");
457 return;
458 }
459
460 // Update the pipeline up until the graph to poly data
461 vtkGraph *input = vtkGraph::SafeDownCast(this->GetExecutive()->GetInputData(0, 0));
462 if (!input)
463 {
464 vtkErrorMacro(<< "Input is not a graph!\n");
465 return;
466 }
467 vtkGraph *graph = 0;
468 if (vtkDirectedGraph::SafeDownCast(input))
469 {
470 graph = vtkDirectedGraph::New();
471 }
472 else
473 {
474 graph = vtkUndirectedGraph::New();
475 }
476 graph->ShallowCopy(input);
477
478 this->GraphToPoly->SetInputData(graph);
479 this->VertexGlyph->SetInputData(graph);
480 graph->Delete();
481 this->GraphToPoly->Update();
482 this->VertexGlyph->Update();
483 vtkPolyData* edgePd = this->GraphToPoly->GetOutput();
484 vtkPolyData* vertPd = this->VertexGlyph->GetOutput();
485
486 // Try to find the range the user-specified color array.
487 // If we cannot find that array, use the scalar range.
488 double range[2];
489 vtkDataArray* arr = 0;
490 if (this->GetColorEdges())
491 {
492 if (this->GetEdgeColorArrayName())
493 {
494 arr = edgePd->GetCellData()->GetArray(this->GetEdgeColorArrayName());
495 }
496 if (!arr)
497 {
498 arr = edgePd->GetCellData()->GetScalars();
499 }
500 if (arr)
501 {
502 arr->GetRange(range);
503 this->EdgeMapper->SetScalarRange(range[0], range[1]);
504 }
505 }
506
507 arr = 0;
508 if (this->EnableEdgesByArray && this->EnabledEdgesArrayName)
509 {
510 vtkLookupTableWithEnabling::SafeDownCast(this->EdgeLookupTable)->SetEnabledArray(
511 edgePd->GetCellData()->GetArray(this->GetEnabledEdgesArrayName()));
512 }
513 else
514 {
515 vtkLookupTableWithEnabling::SafeDownCast(this->EdgeLookupTable)->SetEnabledArray(0);
516 }
517
518 // Do the same thing for the vertex array.
519 arr = 0;
520 if (this->GetColorVertices())
521 {
522 if (this->GetVertexColorArrayName())
523 {
524 arr = vertPd->GetPointData()->GetArray(this->GetVertexColorArrayName());
525 }
526 if (!arr)
527 {
528 arr = vertPd->GetPointData()->GetScalars();
529 }
530 if (arr)
531 {
532 arr->GetRange(range);
533 this->VertexMapper->SetScalarRange(range[0], range[1]);
534 }
535 }
536
537 arr = 0;
538 if (this->EnableVerticesByArray && this->EnabledVerticesArrayName)
539 {
540 vtkLookupTableWithEnabling::SafeDownCast(this->VertexLookupTable)->SetEnabledArray(
541 vertPd->GetPointData()->GetArray(this->GetEnabledVerticesArrayName()));
542 }
543 else
544 {
545 vtkLookupTableWithEnabling::SafeDownCast(this->VertexLookupTable)->SetEnabledArray(0);
546 }
547
548 if (this->IconActor->GetTexture() &&
549 this->IconActor->GetTexture()->GetInput() &&
550 this->IconActor->GetVisibility())
551 {
552 this->IconTransform->SetViewport(ren);
553 this->IconActor->GetTexture()->MapColorScalarsThroughLookupTableOff();
554 this->IconActor->GetTexture()->GetInputAlgorithm()->Update();
555 int *dim = this->IconActor->GetTexture()->GetInput()->GetDimensions();
556 this->IconGlyph->SetIconSheetSize(dim);
557 // Override the array for vtkIconGlyphFilter to process if we have
558 // a map of icon types.
559 if(this->IconTypeToIndex->GetMapSize())
560 {
561 this->IconGlyph->SetInputArrayToProcess(0,0,0,
562 vtkDataObject::FIELD_ASSOCIATION_POINTS,
563 this->IconTypeToIndex->GetOutputArrayName());
564 }
565 }
566 if (this->EdgeActor->GetVisibility())
567 {
568 this->EdgeActor->RenderOpaqueGeometry(ren);
569 }
570 if (this->OutlineActor->GetVisibility())
571 {
572 this->OutlineActor->RenderOpaqueGeometry(ren);
573 }
574 this->VertexActor->RenderOpaqueGeometry(ren);
575 if (this->IconActor->GetVisibility())
576 {
577 this->IconActor->RenderOpaqueGeometry(ren);
578 }
579
580 if (this->EdgeActor->GetVisibility())
581 {
582 this->EdgeActor->RenderTranslucentPolygonalGeometry(ren);
583 }
584 this->VertexActor->RenderTranslucentPolygonalGeometry(ren);
585 if (this->OutlineActor->GetVisibility())
586 {
587 this->OutlineActor->RenderTranslucentPolygonalGeometry(ren);
588 }
589 if (this->IconActor->GetVisibility())
590 {
591 this->IconActor->RenderTranslucentPolygonalGeometry(ren);
592 }
593 if(this->IconActor->GetVisibility())
594 {
595 this->IconActor->RenderOverlay(ren);
596 }
597 this->TimeToDraw = this->EdgeMapper->GetTimeToDraw() +
598 this->VertexMapper->GetTimeToDraw() +
599 this->OutlineMapper->GetTimeToDraw() +
600 this->IconMapper->GetTimeToDraw();
601 }
602
603 //----------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)604 void vtkGraphMapper::PrintSelf(ostream& os, vtkIndent indent)
605 {
606 this->Superclass::PrintSelf(os,indent);
607
608 if ( this->CircleGlyph )
609 {
610 os << indent << "CircleGlyph: (" << this->CircleGlyph << ")\n";
611 }
612 else
613 {
614 os << indent << "CircleGlyph: (none)\n";
615 }
616 if ( this->CircleOutlineGlyph )
617 {
618 os << indent << "CircleOutlineGlyph: (" << this->CircleOutlineGlyph << ")\n";
619 }
620 else
621 {
622 os << indent << "CircleOutlineGlyph: (none)\n";
623 }
624 if ( this->EdgeMapper )
625 {
626 os << indent << "EdgeMapper: (" << this->EdgeMapper << ")\n";
627 }
628 else
629 {
630 os << indent << "EdgeMapper: (none)\n";
631 }
632 if ( this->VertexMapper )
633 {
634 os << indent << "VertexMapper: (" << this->VertexMapper << ")\n";
635 }
636 else
637 {
638 os << indent << "VertexMapper: (none)\n";
639 }
640 if ( this->OutlineMapper )
641 {
642 os << indent << "OutlineMapper: (" << this->OutlineMapper << ")\n";
643 }
644 else
645 {
646 os << indent << "OutlineMapper: (none)\n";
647 }
648 if ( this->EdgeActor )
649 {
650 os << indent << "EdgeActor: (" << this->EdgeActor << ")\n";
651 }
652 else
653 {
654 os << indent << "EdgeActor: (none)\n";
655 }
656 if ( this->VertexActor )
657 {
658 os << indent << "VertexActor: (" << this->VertexActor << ")\n";
659 }
660 else
661 {
662 os << indent << "VertexActor: (none)\n";
663 }
664 if ( this->OutlineActor )
665 {
666 os << indent << "OutlineActor: (" << this->OutlineActor << ")\n";
667 }
668 else
669 {
670 os << indent << "OutlineActor: (none)\n";
671 }
672
673 if ( this->GraphToPoly )
674 {
675 os << indent << "GraphToPoly: (" << this->GraphToPoly << ")\n";
676 }
677 else
678 {
679 os << indent << "GraphToPoly: (none)\n";
680 }
681
682 if ( this->VertexLookupTable )
683 {
684 os << indent << "VertexLookupTable: (" << this->VertexLookupTable << ")\n";
685 }
686 else
687 {
688 os << indent << "VertexLookupTable: (none)\n";
689 }
690
691 if ( this->EdgeLookupTable )
692 {
693 os << indent << "EdgeLookupTable: (" << this->EdgeLookupTable << ")\n";
694 }
695 else
696 {
697 os << indent << "EdgeLookupTable: (none)\n";
698 }
699
700 os << indent << "VertexPointSize: " << this->VertexPointSize << endl;
701 os << indent << "EdgeLineWidth: " << this->EdgeLineWidth << endl;
702 os << indent << "ScaledGlyphs: " << this->ScaledGlyphs << endl;
703 os << indent << "ScalingArrayName: " << (this->ScalingArrayName ? "" : "(null)") << endl;
704 os << indent << "EnableEdgesByArray: " << this->EnableEdgesByArray << endl;
705 os << indent << "EnableVerticesByArray: " << this->EnableVerticesByArray << endl;
706 os << indent << "EnabledEdgesArrayName: " << (this->EnabledEdgesArrayName ? "" : "(null)") << endl;
707 os << indent << "EnabledVerticesArrayName: " << (this->EnabledVerticesArrayName ? "" : "(null)") << endl;
708
709 }
710
711 //----------------------------------------------------------------------------
GetMTime()712 unsigned long vtkGraphMapper::GetMTime()
713 {
714 unsigned long mTime=this->vtkMapper::GetMTime();
715 unsigned long time;
716
717 if ( this->LookupTable != NULL )
718 {
719 time = this->LookupTable->GetMTime();
720 mTime = ( time > mTime ? time : mTime );
721 }
722
723 return mTime;
724 }
725
726 //----------------------------------------------------------------------------
FillInputPortInformation(int vtkNotUsed (port),vtkInformation * info)727 int vtkGraphMapper::FillInputPortInformation(
728 int vtkNotUsed(port), vtkInformation* info)
729 {
730 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkGraph");
731 return 1;
732 }
733
734 //----------------------------------------------------------------------------
GetBounds()735 double *vtkGraphMapper::GetBounds()
736 {
737 vtkGraph *graph = vtkGraph::SafeDownCast(this->GetExecutive()->GetInputData(0, 0));
738 if (!graph)
739 {
740 vtkMath::UninitializeBounds(this->Bounds);
741 return this->Bounds;
742 }
743 if (!this->Static)
744 {
745 this->Update();
746 graph = vtkGraph::SafeDownCast(this->GetExecutive()->GetInputData(0, 0));
747 }
748 if (!graph)
749 {
750 vtkMath::UninitializeBounds(this->Bounds);
751 return this->Bounds;
752 }
753 graph->GetBounds(this->Bounds);
754 return this->Bounds;
755 }
756
757 #if 1
758 //----------------------------------------------------------------------------
ReportReferences(vtkGarbageCollector * collector)759 void vtkGraphMapper::ReportReferences(vtkGarbageCollector* collector)
760 {
761 this->Superclass::ReportReferences(collector);
762 // These filters share our input and are therefore involved in a
763 // reference loop.
764 //vtkGarbageCollectorReport(collector, this->GraphToPoly,
765 // "GraphToPoly");
766 }
767
768 #endif
769