1 /*=========================================================================
3 Program: Visualization Toolkit
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
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.
14 =========================================================================*/
15 #include "VISU_XYPlotActor.hxx"
17 #include "vtkAppendPolyData.h"
18 #include "vtkAxisActor2D.h"
19 #include "vtkCellArray.h"
20 #include "vtkDataObjectCollection.h"
21 #include "vtkDataSetCollection.h"
22 #include "vtkFieldData.h"
23 #include "vtkDoubleArray.h"
24 #include "vtkGlyph2D.h"
25 #include "vtkGlyphSource2D.h"
26 #include "vtkIntArray.h"
27 #include "vtkLegendBoxActor.h"
29 #include "vtkObjectFactory.h"
31 #include "vtkPlanes.h"
32 #include "vtkPointData.h"
33 #include "vtkPolyData.h"
34 #include "vtkPolyDataMapper2D.h"
35 #include "vtkProperty2D.h"
36 #include "vtkTextMapper.h"
37 #include "vtkTextProperty.h"
38 #include "vtkViewport.h"
39 #include "vtkTransformPolyDataFilter.h" // RKV
40 #include "vtkTransform.h" // RKV
42 #define VTK_MAX_PLOTS 50
44 #if !defined(VTK_XVERSION)
45 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
50 vtkCxxRevisionMacro(VISU_XYPlotActor, "$Revision$");
51 vtkStandardNewMacro(VISU_XYPlotActor);
53 vtkCxxSetObjectMacro(VISU_XYPlotActor,TitleTextProperty,vtkTextProperty);
54 vtkCxxSetObjectMacro(VISU_XYPlotActor,AxisLabelTextProperty,vtkTextProperty);
55 vtkCxxSetObjectMacro(VISU_XYPlotActor,AxisTitleTextProperty,vtkTextProperty);
57 //----------------------------------------------------------------------------
59 VISU_XYPlotActor::VISU_XYPlotActor()
61 this->PositionCoordinate->SetCoordinateSystemToNormalizedViewport();
62 this->PositionCoordinate->SetValue(0.25,0.25);
63 this->Position2Coordinate->SetValue(0.5, 0.5);
65 this->InputList = vtkDataSetCollection::New();
66 this->SelectedInputScalars = NULL;
67 this->SelectedInputScalarsComponent = vtkIntArray::New();
68 this->DataObjectInputList = vtkDataObjectCollection::New();
71 this->XTitle = new char[7];
72 sprintf(this->XTitle,"%s","X Axis");
73 this->YTitle = new char[7];
74 sprintf(this->YTitle,"%s","Y Axis");
76 this->XValues = VTK_XYPLOT_INDEX;
77 this->PlotLocation = VISU_XYPLOT_BOTTOM; // RKV
79 this->NumberOfXLabels = 5;
80 this->NumberOfYLabels = 5;
82 this->TitleTextProperty = vtkTextProperty::New();
83 this->TitleTextProperty->SetBold(1);
84 this->TitleTextProperty->SetItalic(1);
85 this->TitleTextProperty->SetShadow(1);
86 this->TitleTextProperty->SetFontFamilyToArial();
88 this->AxisLabelTextProperty = vtkTextProperty::New();
89 this->AxisLabelTextProperty->ShallowCopy(this->TitleTextProperty);
91 this->AxisTitleTextProperty = vtkTextProperty::New();
92 this->AxisTitleTextProperty->ShallowCopy(this->AxisLabelTextProperty);
94 this->LabelFormat = new char[8];
95 sprintf(this->LabelFormat,"%s","%-#6.3g");
99 this->XRange[0] = 0.0;
100 this->XRange[1] = 0.0;
101 this->YRange[0] = 0.0;
102 this->YRange[1] = 0.0;
106 this->PlotPoints = 0;
107 this->PlotCurveLines = 0;
108 this->PlotCurvePoints = 0;
109 this->ExchangeAxes = 0;
110 this->ReverseXAxis = 0;
111 this->ReverseYAxis = 0;
113 this->TitleMapper = vtkTextMapper::New();
114 this->TitleActor = vtkActor2D::New();
115 this->TitleActor->SetMapper(this->TitleMapper);
116 this->TitleActor->GetPositionCoordinate()->SetCoordinateSystemToViewport();
118 this->XAxis = vtkAxisActor2D::New();
119 this->XAxis->GetPositionCoordinate()->SetCoordinateSystemToViewport();
120 this->XAxis->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
121 this->XAxis->SetProperty(this->GetProperty());
123 this->YAxis = vtkAxisActor2D::New();
124 this->YAxis->GetPositionCoordinate()->SetCoordinateSystemToViewport();
125 this->YAxis->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
126 this->YAxis->SetProperty(this->GetProperty());
128 this->NumberOfInputs = 0;
129 this->PlotData = NULL;
130 this->PlotGlyph = NULL;
131 this->PlotAppend = NULL;
132 this->PlotTransform = NULL; // RKV
133 this->PlotMapper = NULL;
134 this->PlotActor = NULL;
136 this->ViewportCoordinate[0] = 0.0;
137 this->ViewportCoordinate[1] = 0.0;
138 this->PlotCoordinate[0] = 0.0;
139 this->PlotCoordinate[1] = 0.0;
141 this->DataObjectPlotMode = VTK_XYPLOT_COLUMN;
142 this->XComponent = vtkIntArray::New();
143 this->XComponent->SetNumberOfValues(VTK_MAX_PLOTS);
144 this->YComponent = vtkIntArray::New();
145 this->YComponent->SetNumberOfValues(VTK_MAX_PLOTS);
147 this->LinesOn = vtkIntArray::New();
148 this->LinesOn->SetNumberOfValues(VTK_MAX_PLOTS);
149 this->PointsOn = vtkIntArray::New();
150 this->PointsOn->SetNumberOfValues(VTK_MAX_PLOTS);
151 for (int i=0; i<VTK_MAX_PLOTS; i++)
153 this->XComponent->SetValue(i,0);
154 this->YComponent->SetValue(i,0);
155 this->LinesOn->SetValue(i,this->PlotLines);
156 this->PointsOn->SetValue(i,this->PlotPoints);
160 this->LegendPosition[0] = 0.85;
161 this->LegendPosition[1] = 0.75;
162 this->LegendPosition2[0] = 0.15;
163 this->LegendPosition2[1] = 0.20;
164 this->LegendActor = vtkLegendBoxActor::New();
165 this->LegendActor->GetPositionCoordinate()->SetCoordinateSystemToViewport();
166 this->LegendActor->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
167 this->LegendActor->GetPosition2Coordinate()->SetReferenceCoordinate(NULL);
168 this->LegendActor->BorderOff();
169 this->LegendActor->SetNumberOfEntries(VTK_MAX_PLOTS); //initial allocation
170 this->GlyphSource = vtkGlyphSource2D::New();
171 this->GlyphSource->SetGlyphTypeToNone();
172 this->GlyphSource->DashOn();
173 this->GlyphSource->FilledOff();
174 this->GlyphSize = 0.020;
176 this->ClipPlanes = vtkPlanes::New();
177 vtkPoints *pts = vtkPoints::New();
178 pts->SetNumberOfPoints(4);
179 this->ClipPlanes->SetPoints(pts);
181 vtkDoubleArray *n = vtkDoubleArray::New();
182 n->SetNumberOfComponents(3);
183 n->SetNumberOfTuples(4);
184 this->ClipPlanes->SetNormals(n);
187 this->CachedSize[0] = 0;
188 this->CachedSize[1] = 0;
191 //----------------------------------------------------------------------------
192 VISU_XYPlotActor::~VISU_XYPlotActor()
194 // Get rid of the list of array names.
195 int num = this->InputList->GetNumberOfItems();
196 if (this->SelectedInputScalars)
198 for (int i = 0; i < num; ++i)
200 if (this->SelectedInputScalars[i])
202 delete [] this->SelectedInputScalars[i];
203 this->SelectedInputScalars[i] = NULL;
206 delete [] this->SelectedInputScalars;
207 this->SelectedInputScalars = NULL;
209 this->SelectedInputScalarsComponent->Delete();
210 this->SelectedInputScalarsComponent = NULL;
212 // Now we can get rid of the inputs.
213 this->InputList->Delete();
214 this->InputList = NULL;
216 this->DataObjectInputList->Delete();
217 this->DataObjectInputList = NULL;
219 this->TitleMapper->Delete();
220 this->TitleMapper = NULL;
221 this->TitleActor->Delete();
222 this->TitleActor = NULL;
227 this->SetLabelFormat(0);
229 this->XAxis->Delete();
230 this->YAxis->Delete();
232 this->InitializeEntries();
234 this->LegendActor->Delete();
235 this->GlyphSource->Delete();
236 this->ClipPlanes->Delete();
238 this->XComponent->Delete();
239 this->YComponent->Delete();
241 this->LinesOn->Delete();
242 this->PointsOn->Delete();
244 this->SetTitleTextProperty(NULL);
245 this->SetAxisLabelTextProperty(NULL);
246 this->SetAxisTitleTextProperty(NULL);
249 //----------------------------------------------------------------------------
250 void VISU_XYPlotActor::InitializeEntries()
252 if ( this->NumberOfInputs > 0 )
254 for (int i=0; i<this->NumberOfInputs; i++)
256 this->PlotData[i]->Delete();
257 this->PlotGlyph[i]->Delete();
258 this->PlotAppend[i]->Delete();
259 this->PlotTransform[i]->Delete(); // RKV
260 this->PlotMapper[i]->Delete();
261 this->PlotActor[i]->Delete();
263 delete [] this->PlotData; this->PlotData = NULL;
264 delete [] this->PlotGlyph; this->PlotGlyph = NULL;
265 delete [] this->PlotAppend; this->PlotAppend = NULL;
266 delete [] this->PlotTransform; this->PlotTransform = NULL; // RKV
267 delete [] this->PlotMapper; this->PlotMapper = NULL;
268 delete [] this->PlotActor; this->PlotActor = NULL;
269 this->NumberOfInputs = 0;
270 }//if entries have been defined
273 //----------------------------------------------------------------------------
274 // Add a dataset and array to the list of data to plot.
275 void VISU_XYPlotActor::AddInput(vtkDataSet *ds, const char *arrayName, int component)
280 // I cannot change the input list, because the user has direct
281 // access to the collection. I cannot store the index of the array,
282 // because the index might change from render to render ...
283 // I have to store the list of string array names.
285 // I believe idx starts at 1 and goes to "NumberOfItems".
286 idx = this->InputList->IsItemPresent(ds);
288 { // Return if arrays are the same.
289 if (arrayName == NULL && this->SelectedInputScalars[idx-1] == NULL &&
290 component == this->SelectedInputScalarsComponent->GetValue(idx-1))
294 if (arrayName != NULL && this->SelectedInputScalars[idx-1] != NULL &&
295 strcmp(arrayName, this->SelectedInputScalars[idx-1]) == 0 &&
296 component == this->SelectedInputScalarsComponent->GetValue(idx-1))
302 // The input/array/component must be a unique combination. Add it to our input list.
304 // Now reallocate the list of strings and add the new value.
305 num = this->InputList->GetNumberOfItems();
306 newNames = new char*[num+1];
307 for (idx = 0; idx < num; ++idx)
309 newNames[idx] = this->SelectedInputScalars[idx];
311 if (arrayName == NULL)
313 newNames[num] = NULL;
317 newNames[num] = new char[strlen(arrayName)+1];
318 strcpy(newNames[num],arrayName);
320 delete [] this->SelectedInputScalars;
321 this->SelectedInputScalars = newNames;
323 // Save the component in the int array.
324 this->SelectedInputScalarsComponent->InsertValue(num, component);
326 // Add the data set to the collection
327 this->InputList->AddItem(ds);
329 // In case of multiple use of a XYPlotActor the NumberOfEntries could be set
330 // to n. Then when a call to SetEntryString(n+1, bla) was done the string was lost
331 // Need to update the number of entries for the legend actor
332 this->LegendActor->SetNumberOfEntries(this->LegendActor->GetNumberOfEntries()+1);
337 //----------------------------------------------------------------------------
338 void VISU_XYPlotActor::RemoveAllInputs()
342 num = this->InputList->GetNumberOfItems();
343 this->InputList->RemoveAllItems();
345 for (idx = 0; idx < num; ++idx)
347 if (this->SelectedInputScalars[idx])
349 delete [] this->SelectedInputScalars[idx];
350 this->SelectedInputScalars[idx] = NULL;
353 this->SelectedInputScalarsComponent->Reset();
355 this->DataObjectInputList->RemoveAllItems();
358 //----------------------------------------------------------------------------
359 // Remove a dataset from the list of data to plot.
360 void VISU_XYPlotActor::RemoveInput(vtkDataSet *ds, const char *arrayName, int component)
366 // This is my own find routine, because the array names have to match also.
367 num = this->InputList->GetNumberOfItems();
368 vtkCollectionSimpleIterator dsit;
369 this->InputList->InitTraversal(dsit);
370 for (idx = 0; idx < num && found == -1; ++idx)
372 input = this->InputList->GetNextDataSet(dsit);
375 if (arrayName == NULL && this->SelectedInputScalars[idx] == NULL &&
376 component == this->SelectedInputScalarsComponent->GetValue(idx))
380 if (arrayName != NULL && this->SelectedInputScalars[idx] != NULL &&
381 strcmp(arrayName, this->SelectedInputScalars[idx]) == 0 &&
382 component == this->SelectedInputScalarsComponent->GetValue(idx))
395 // Collections index their items starting at 1.
396 this->InputList->RemoveItem(found);
398 // Do not bother reallocating the SelectedInputScalars
399 // string array to make it smaller.
400 if (this->SelectedInputScalars[found])
402 delete [] this->SelectedInputScalars[found];
403 this->SelectedInputScalars[found] = NULL;
405 for (idx = found+1; idx < num; ++idx)
407 this->SelectedInputScalars[idx-1] = this->SelectedInputScalars[idx];
408 this->SelectedInputScalarsComponent->SetValue(idx-1,
409 this->SelectedInputScalarsComponent->GetValue(idx));
411 // Reseting the last item is not really necessary,
412 // but to be clean we do it anyway.
413 this->SelectedInputScalarsComponent->SetValue(num-1, -1);
414 this->SelectedInputScalars[num-1] = NULL;
417 //----------------------------------------------------------------------------
418 // Add a data object to the list of data to plot.
419 void VISU_XYPlotActor::AddDataObjectInput(vtkDataObject *in)
421 if ( ! this->DataObjectInputList->IsItemPresent(in) )
424 this->DataObjectInputList->AddItem(in);
428 //----------------------------------------------------------------------------
429 // Remove a data object from the list of data to plot.
430 void VISU_XYPlotActor::RemoveDataObjectInput(vtkDataObject *in)
432 if ( this->DataObjectInputList->IsItemPresent(in) )
435 this->DataObjectInputList->RemoveItem(in);
439 //----------------------------------------------------------------------------
440 // Plot scalar data for each input dataset.
441 int VISU_XYPlotActor::RenderOverlay(vtkViewport *viewport)
443 int renderedSomething = 0;
445 // Make sure input is up to date.
446 if ( this->InputList->GetNumberOfItems() < 1 &&
447 this->DataObjectInputList->GetNumberOfItems() < 1 )
449 vtkErrorMacro(<< "Nothing to plot!");
453 renderedSomething += this->XAxis->RenderOverlay(viewport);
454 renderedSomething += this->YAxis->RenderOverlay(viewport);
457 renderedSomething += this->TitleActor->RenderOverlay(viewport);
459 for (int i=0; i < this->NumberOfInputs; i++)
461 renderedSomething += this->PlotActor[i]->RenderOverlay(viewport);
465 renderedSomething += this->LegendActor->RenderOverlay(viewport);
468 return renderedSomething;
471 //----------------------------------------------------------------------------
472 // Plot scalar data for each input dataset.
473 int VISU_XYPlotActor::RenderOpaqueGeometry(vtkViewport *viewport)
475 unsigned long mtime, dsMtime;
478 int numDS, numDO, renderedSomething=0;
481 // Make sure input is up to date.
482 numDS = this->InputList->GetNumberOfItems();
483 numDO = this->DataObjectInputList->GetNumberOfItems();
486 vtkDebugMacro(<<"Plotting input data sets");
487 vtkCollectionSimpleIterator dsit;
488 for (mtime=0, this->InputList->InitTraversal(dsit);
489 (ds = this->InputList->GetNextDataSet(dsit)); )
492 dsMtime = ds->GetMTime();
493 if ( dsMtime > mtime )
499 else if ( numDO > 0 )
501 vtkDebugMacro(<<"Plotting input data objects");
502 vtkCollectionSimpleIterator doit;
503 for (mtime=0, this->DataObjectInputList->InitTraversal(doit);
504 (dobj = this->DataObjectInputList->GetNextDataObject(doit)); )
507 dsMtime = dobj->GetMTime();
508 if ( dsMtime > mtime )
516 vtkErrorMacro(<< "Nothing to plot!");
520 if (this->Title && this->Title[0] && !this->TitleTextProperty)
522 vtkErrorMacro(<< "Need a title text property to render plot title");
526 // Check modified time to see whether we have to rebuild.
527 // Pay attention that GetMTime() has been redefined (see below)
529 int *size=viewport->GetSize();
530 if (mtime > this->BuildTime ||
531 size[0] != this->CachedSize[0] || size[1] != this->CachedSize[1] ||
532 this->GetMTime() > this->BuildTime ||
533 (this->Title && this->Title[0] &&
534 this->TitleTextProperty->GetMTime() > this->BuildTime) ||
535 (this->AxisLabelTextProperty &&
536 this->AxisLabelTextProperty->GetMTime() > this->BuildTime) ||
537 (this->AxisTitleTextProperty &&
538 this->AxisTitleTextProperty->GetMTime() > this->BuildTime))
540 double range[2], yrange[2], xRange[2], yRange[2], interval, *lengths=NULL;
541 int pos[2], pos2[2], numTicks;
543 int num = ( numDS > 0 ? numDS : numDO );
545 vtkDebugMacro(<<"Rebuilding plot");
546 this->CachedSize[0] = size[0];
547 this->CachedSize[1] = size[1];
550 if ((this->PlotLocation == VISU_XYPLOT_RIGHT) || (this->PlotLocation == VISU_XYPLOT_LEFT))
551 this->ReverseYAxis = 1;
553 this->ReverseYAxis = 0;
557 vtkDebugMacro(<<"Rebuilding legend");
560 int legPos[2], legPos2[2];
561 int *p1 = this->PositionCoordinate->GetComputedViewportValue(viewport);
562 int *p2 = this->Position2Coordinate->GetComputedViewportValue(viewport);
563 legPos[0] = (int)(p1[0] + this->LegendPosition[0]*(p2[0]-p1[0]));
564 legPos2[0] = (int)(legPos[0] + this->LegendPosition2[0]*(p2[0]-p1[0]));
565 legPos[1] = (int)(p1[1] + this->LegendPosition[1]*(p2[1]-p1[1]));
566 legPos2[1] = (int)(legPos[1] + this->LegendPosition2[1]*(p2[1]-p1[1]));
568 this->LegendActor->GetPositionCoordinate()->SetValue(
569 (double)legPos[0], (double)legPos[1]);
570 this->LegendActor->GetPosition2Coordinate()->SetValue(
571 (double)legPos2[0], (double)legPos2[1]);
572 this->LegendActor->SetNumberOfEntries(num);
573 for (int i=0; i<num; i++)
575 if ( ! this->LegendActor->GetEntrySymbol(i) )
577 this->LegendActor->SetEntrySymbol(i,this->GlyphSource->GetOutput());
579 if ( ! this->LegendActor->GetEntryString(i) )
581 static char legendString[12];
582 sprintf(legendString, "%s%d", "Curve ", i);
583 this->LegendActor->SetEntryString(i,legendString);
587 this->LegendActor->SetPadding(2);
588 this->LegendActor->GetProperty()->DeepCopy(this->GetProperty());
589 this->LegendActor->ScalarVisibilityOff();
593 // Perform shallow copy here since each individual axis can be
594 // accessed through the class API (i.e. each individual axis text prop
595 // can be changed). Therefore, we can not just assign pointers otherwise
596 // each individual axis text prop would point to the same text prop.
598 if (this->AxisLabelTextProperty &&
599 this->AxisLabelTextProperty->GetMTime() > this->BuildTime)
601 if (this->XAxis->GetTitleTextProperty())
603 this->XAxis->GetLabelTextProperty()->ShallowCopy(
604 this->AxisLabelTextProperty);
606 if (this->YAxis->GetTitleTextProperty())
608 this->YAxis->GetLabelTextProperty()->ShallowCopy(
609 this->AxisLabelTextProperty);
613 if (this->AxisTitleTextProperty &&
614 this->AxisTitleTextProperty->GetMTime() > this->BuildTime)
616 if (this->XAxis->GetTitleTextProperty())
618 this->XAxis->GetTitleTextProperty()->ShallowCopy(
619 this->AxisTitleTextProperty);
621 if (this->YAxis->GetTitleTextProperty())
623 this->YAxis->GetTitleTextProperty()->ShallowCopy(
624 this->AxisTitleTextProperty);
629 vtkDebugMacro(<<"Rebuilding x-axis");
631 this->XAxis->SetTitle(this->XTitle);
632 this->XAxis->SetNumberOfLabels(this->NumberOfXLabels);
633 this->XAxis->SetProperty(this->GetProperty());
635 vtkDebugMacro(<<"xrange = (" << range[0] << ", " << range[1] << ")"); // RKV
636 lengths = new double[num];
637 if ( numDS > 0 ) //plotting data sets
639 this->ComputeXRange(range, lengths);
643 this->ComputeDORange(range, yrange, lengths);
645 if ( this->XRange[0] < this->XRange[1] )
647 range[0] = this->XRange[0];
648 range[1] = this->XRange[1];
651 /* RKV vtkAxisActor2D::ComputeRange(range, xRange, this->NumberOfXLabels,
654 vtkDebugMacro(<<"XRange = (" << XRange[0] << ", " << XRange[1] << ")");
655 vtkDebugMacro(<<"xrange = (" << range[0] << ", " << range[1] << ")");
656 xRange[0] = range[0];
657 xRange[1] = range[1];
659 if ( !this->ExchangeAxes )
661 this->XComputedRange[0] = xRange[0];
662 this->XComputedRange[1] = xRange[1];
663 if ( this->ReverseXAxis )
665 this->XAxis->SetRange(range[1],range[0]);
669 this->XAxis->SetRange(range[0],range[1]);
674 this->XComputedRange[1] = xRange[0];
675 this->XComputedRange[0] = xRange[1];
676 if ( this->ReverseYAxis )
678 this->XAxis->SetRange(range[0],range[1]);
682 this->XAxis->SetRange(range[1],range[0]);
687 vtkDebugMacro(<<"Rebuilding y-axis");
688 this->YAxis->SetTitle(this->YTitle);
689 this->YAxis->SetNumberOfLabels(this->NumberOfYLabels);
691 vtkDebugMacro(<<"yrange = (" << yrange[0] << ", " << yrange[1] << ")"); // RKV
692 if ( this->YRange[0] >= this->YRange[1] )
694 if ( numDS > 0 ) //plotting data sets
696 this->ComputeYRange(yrange);
701 yrange[0] = this->YRange[0];
702 yrange[1] = this->YRange[1];
704 /* RKV vtkAxisActor2D::ComputeRange(yrange, yRange, this->NumberOfYLabels,
708 vtkDebugMacro(<<"YRange = (" << YRange[0] << ", " << YRange[1] << ")");
709 vtkDebugMacro(<<"yrange = (" << yrange[0] << ", " << yrange[1] << ")");
710 yRange[0] = yrange[0];
711 yRange[1] = yrange[1];
714 if ( !this->ExchangeAxes )
716 this->YComputedRange[0] = yRange[0];
717 this->YComputedRange[1] = yRange[1];
718 if ( this->ReverseYAxis )
720 this->YAxis->SetRange(yrange[0],yrange[1]);
724 this->YAxis->SetRange(yrange[1],yrange[0]);
729 this->YComputedRange[1] = yRange[0];
730 this->YComputedRange[0] = yRange[1];
731 if ( this->ReverseXAxis )
733 this->YAxis->SetRange(yrange[1],yrange[0]);
737 this->YAxis->SetRange(yrange[0],yrange[1]);
742 this->PlaceAxes(viewport, size, pos, pos2);
745 if (this->Title != NULL && this->Title[0])
747 this->TitleMapper->SetInput(this->Title);
748 if (this->TitleTextProperty->GetMTime() > this->BuildTime)
750 this->TitleMapper->GetTextProperty()->ShallowCopy(
751 this->TitleTextProperty);
755 #if (VTK_XVERSION < 0x050100)
756 //VSV: Function is not supported in VTK 5.2 and high
757 vtkAxisActor2D::SetFontSize(viewport,
764 this->TitleActor->GetPositionCoordinate()->SetValue(
765 pos[0] + 0.5 * (pos2[0] - pos[0]) - stringSize[0] / 2.0,
766 pos2[1] - stringSize[1] / 2.0);
768 this->TitleActor->SetProperty(this->GetProperty());
771 vtkDebugMacro(<<"Creating Plot Data");
772 // Okay, now create the plot data and set up the pipeline
773 this->CreatePlotData(pos, pos2, xRange, yRange, lengths, numDS, numDO);
776 this->BuildTime.Modified();
778 }//if need to rebuild the plot
780 vtkDebugMacro(<<"Rendering Axes");
781 renderedSomething += this->XAxis->RenderOpaqueGeometry(viewport);
782 renderedSomething += this->YAxis->RenderOpaqueGeometry(viewport);
783 for (int i=0; i < this->NumberOfInputs; i++)
785 vtkDebugMacro(<<"Rendering plotactors");
786 renderedSomething += this->PlotActor[i]->RenderOpaqueGeometry(viewport);
790 vtkDebugMacro(<<"Rendering titleactors");
791 renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport);
795 vtkDebugMacro(<<"Rendering legendeactors");
796 renderedSomething += this->LegendActor->RenderOpaqueGeometry(viewport);
799 return renderedSomething;
802 //----------------------------------------------------------------------------
803 const char *VISU_XYPlotActor::GetXValuesAsString()
805 switch (this->XValues)
807 case VTK_XYPLOT_INDEX:
809 case VTK_XYPLOT_ARC_LENGTH:
811 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
812 return "NormalizedArcLength";
818 //----------------------------------------------------------------------------
819 const char *VISU_XYPlotActor::GetDataObjectPlotModeAsString()
821 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
827 return "Plot Columns";
831 //----------------------------------------------------------------------------
832 // Release any graphics resources that are being consumed by this actor.
833 // The parameter window could be used to determine which graphic
834 // resources to release.
835 void VISU_XYPlotActor::ReleaseGraphicsResources(vtkWindow *win)
837 this->TitleActor->ReleaseGraphicsResources(win);
838 this->XAxis->ReleaseGraphicsResources(win);
839 this->YAxis->ReleaseGraphicsResources(win);
840 for (int i=0; i < this->NumberOfInputs; i++)
842 this->PlotActor[i]->ReleaseGraphicsResources(win);
844 this->LegendActor->ReleaseGraphicsResources(win);
847 //----------------------------------------------------------------------------
848 unsigned long VISU_XYPlotActor::GetMTime()
850 unsigned long mtime, mtime2;
851 mtime = this->vtkActor2D::GetMTime();
855 mtime2 = this->LegendActor->GetMTime();
865 //----------------------------------------------------------------------------
866 void VISU_XYPlotActor::PrintSelf(ostream& os, vtkIndent indent)
868 vtkIndent i2 = indent.GetNextIndent();
874 this->Superclass::PrintSelf(os,indent);
876 vtkCollectionSimpleIterator dsit;
877 this->InputList->InitTraversal(dsit);
878 num = this->InputList->GetNumberOfItems();
879 os << indent << "DataSetInputs: " << endl;
880 for (idx = 0; idx < num; ++idx)
882 input = this->InputList->GetNextDataSet(dsit);
883 array = this->SelectedInputScalars[idx];
884 component = this->SelectedInputScalarsComponent->GetValue((vtkIdType)idx);
887 os << i2 << "(" << input << ") Default Scalars, Component = " << component << endl;
891 os << i2 << "(" << input << ") " << array << ", Component = " << component << endl;
895 os << indent << "Input DataObjects:\n";
896 this->DataObjectInputList->PrintSelf(os,indent.GetNextIndent());
898 if (this->TitleTextProperty)
900 os << indent << "Title Text Property:\n";
901 this->TitleTextProperty->PrintSelf(os,indent.GetNextIndent());
905 os << indent << "Title Text Property: (none)\n";
908 if (this->AxisTitleTextProperty)
910 os << indent << "Axis Title Text Property:\n";
911 this->AxisTitleTextProperty->PrintSelf(os,indent.GetNextIndent());
915 os << indent << "Axis Title Text Property: (none)\n";
918 if (this->AxisLabelTextProperty)
920 os << indent << "Axis Label Text Property:\n";
921 this->AxisLabelTextProperty->PrintSelf(os,indent.GetNextIndent());
925 os << indent << "Axis Label Text Property: (none)\n";
928 os << indent << "Data Object Plot Mode: " << this->GetDataObjectPlotModeAsString() << endl;
930 os << indent << "Title: " << (this->Title ? this->Title : "(none)") << "\n";
931 os << indent << "X Title: "
932 << (this->XTitle ? this->XTitle : "(none)") << "\n";
933 os << indent << "Y Title: "
934 << (this->YTitle ? this->YTitle : "(none)") << "\n";
936 os << indent << "X Values: " << this->GetXValuesAsString() << endl;
937 os << indent << "Log X Values: " << (this->Logx ? "On\n" : "Off\n");
939 os << indent << "Plot global-points: " << (this->PlotPoints ? "On\n" : "Off\n");
940 os << indent << "Plot global-lines: " << (this->PlotLines ? "On\n" : "Off\n");
941 os << indent << "Plot per-curve points: " << (this->PlotCurvePoints ? "On\n" : "Off\n");
942 os << indent << "Plot per-curve lines: " << (this->PlotCurveLines ? "On\n" : "Off\n");
943 os << indent << "Exchange Axes: " << (this->ExchangeAxes ? "On\n" : "Off\n");
944 os << indent << "Reverse X Axis: " << (this->ReverseXAxis ? "On\n" : "Off\n");
945 os << indent << "Reverse Y Axis: " << (this->ReverseYAxis ? "On\n" : "Off\n");
947 os << indent << "Number Of X Labels: " << this->NumberOfXLabels << "\n";
948 os << indent << "Number Of Y Labels: " << this->NumberOfYLabels << "\n";
950 os << indent << "Label Format: " << this->LabelFormat << "\n";
951 os << indent << "Border: " << this->Border << "\n";
953 os << indent << "X Range: ";
954 if ( this->XRange[0] >= this->XRange[1] )
956 os << indent << "(Automatically Computed)\n";
960 os << "(" << this->XRange[0] << ", " << this->XRange[1] << ")\n";
963 os << indent << "Y Range: ";
964 if ( this->XRange[0] >= this->YRange[1] )
966 os << indent << "(Automatically Computed)\n";
970 os << "(" << this->YRange[0] << ", " << this->YRange[1] << ")\n";
973 os << indent << "Viewport Coordinate: ("
974 << this->ViewportCoordinate[0] << ", "
975 << this->ViewportCoordinate[1] << ")\n";
977 os << indent << "Plot Coordinate: ("
978 << this->PlotCoordinate[0] << ", "
979 << this->PlotCoordinate[1] << ")\n";
981 os << indent << "Legend: " << (this->Legend ? "On\n" : "Off\n");
982 os << indent << "Legend Position: ("
983 << this->LegendPosition[0] << ", "
984 << this->LegendPosition[1] << ")\n";
985 os << indent << "Legend Position2: ("
986 << this->LegendPosition2[0] << ", "
987 << this->LegendPosition2[1] << ")\n";
989 os << indent << "Glyph Size: " << this->GlyphSize << endl;
991 os << indent << "Legend Actor:";
992 this->LegendActor->PrintSelf( os << endl, i2);
993 os << indent << "Glyph Source:";
994 this->GlyphSource->PrintSelf( os << endl, i2);
997 //----------------------------------------------------------------------------
998 void VISU_XYPlotActor::ComputeXRange(double range[2], double *lengths)
1001 vtkIdType numPts, ptId, maxNum;
1002 double maxLength=0.0, xPrev[3], x[3];
1005 range[0] = VTK_DOUBLE_MAX, range[1] = VTK_DOUBLE_MIN;
1007 vtkCollectionSimpleIterator dsit;
1008 for ( dsNum=0, maxNum=0, this->InputList->InitTraversal(dsit);
1009 (ds = this->InputList->GetNextDataSet(dsit)); dsNum++)
1011 numPts = ds->GetNumberOfPoints();
1013 if ( this->XValues != VTK_XYPLOT_INDEX )
1015 ds->GetPoint(0, xPrev);
1016 for ( lengths[dsNum]=0.0, ptId=0; ptId < numPts; ptId++ )
1018 ds->GetPoint(ptId, x);
1019 switch (this->XValues)
1021 case VTK_XYPLOT_VALUE:
1022 if (this->GetLogx() == 0)
1024 if ( x[this->XComponent->GetValue(dsNum)] < range[0] )
1026 range[0] = x[this->XComponent->GetValue(dsNum)];
1028 if ( x[this->XComponent->GetValue(dsNum)] > range[1] )
1030 range[1] = x[this->XComponent->GetValue(dsNum)];
1035 //ensure range strictly > 0 for log
1036 if ( (x[this->XComponent->GetValue(dsNum)]) < range[0] &&
1037 (x[this->XComponent->GetValue(dsNum)] > 0))
1039 range[0] = x[this->XComponent->GetValue(dsNum)];
1041 if ( (x[this->XComponent->GetValue(dsNum)] > range[1]) &&
1042 (x[this->XComponent->GetValue(dsNum)] > 0))
1044 range[1] = x[this->XComponent->GetValue(dsNum)];
1049 lengths[dsNum] += sqrt(vtkMath::Distance2BetweenPoints(x,xPrev));
1050 xPrev[0] = x[0]; xPrev[1] = x[1]; xPrev[2] = x[2];
1053 if ( lengths[dsNum] > maxLength )
1055 maxLength = lengths[dsNum];
1057 }//if need to visit all points
1059 else //if ( this->XValues == VTK_XYPLOT_INDEX )
1061 if ( numPts > maxNum )
1066 }//over all datasets
1068 // determine the range
1069 switch (this->XValues)
1071 case VTK_XYPLOT_ARC_LENGTH:
1073 range[1] = maxLength;
1075 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1079 case VTK_XYPLOT_INDEX:
1081 range[1] = (double)(maxNum - 1);
1083 case VTK_XYPLOT_VALUE:
1084 if (this->GetLogx() == 1)
1086 if (range[0] > range[1])
1093 range[0] = log10(range[0]);
1094 range[1] = log10(range[1]);
1097 break; //range computed in for loop above
1099 vtkErrorMacro(<< "Unkown X-Value option.");
1104 //----------------------------------------------------------------------------
1105 void VISU_XYPlotActor::ComputeYRange(double range[2])
1108 vtkDataArray *scalars;
1113 range[0]=VTK_DOUBLE_MAX, range[1]=VTK_DOUBLE_MIN;
1115 vtkCollectionSimpleIterator dsit;
1116 for ( this->InputList->InitTraversal(dsit), count = 0;
1117 (ds = this->InputList->GetNextDataSet(dsit)); ++count)
1119 scalars = ds->GetPointData()->GetScalars(this->SelectedInputScalars[count]);
1120 component = this->SelectedInputScalarsComponent->GetValue(count);
1123 vtkErrorMacro(<<"No scalar data to plot!");
1126 if ( component < 0 || component >= scalars->GetNumberOfComponents())
1128 vtkErrorMacro(<<"Bad component!");
1132 scalars->GetRange(sRange, component);
1133 if ( sRange[0] < range[0] )
1135 range[0] = sRange[0];
1138 if ( sRange[1] > range[1] )
1140 range[1] = sRange[1];
1142 }//over all datasets
1145 //----------------------------------------------------------------------------
1146 void VISU_XYPlotActor::ComputeDORange(double xrange[2], double yrange[2],
1150 vtkDataObject *dobj;
1151 vtkFieldData *field;
1152 int doNum, numColumns;
1153 vtkIdType numTuples, numRows, num, ptId, maxNum;
1154 double maxLength=0.0, x, y, xPrev = 0.0;
1155 vtkDataArray *array;
1157 xrange[0] = yrange[0] = VTK_DOUBLE_MAX;
1158 xrange[1] = yrange[1] = -VTK_DOUBLE_MAX;
1159 vtkCollectionSimpleIterator doit;
1160 for ( doNum=0, maxNum=0, this->DataObjectInputList->InitTraversal(doit);
1161 (dobj = this->DataObjectInputList->GetNextDataObject(doit)); doNum++)
1163 lengths[doNum] = 0.0;
1164 field = dobj->GetFieldData();
1165 numColumns = field->GetNumberOfComponents(); //number of "columns"
1166 for (numRows = VTK_LARGE_ID, i=0; i<field->GetNumberOfArrays(); i++)
1168 array = field->GetArray(i);
1169 numTuples = array->GetNumberOfTuples();
1170 if ( numTuples < numRows )
1172 numRows = numTuples;
1176 num = (this->DataObjectPlotMode == VTK_XYPLOT_ROW ?
1177 numColumns : numRows);
1179 if ( this->XValues != VTK_XYPLOT_INDEX )
1181 // gather the information to form a plot
1182 for ( ptId=0; ptId < num; ptId++ )
1184 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
1186 x = field->GetComponent(this->XComponent->GetValue(doNum), ptId);
1188 else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
1190 x = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
1197 switch (this->XValues)
1199 case VTK_XYPLOT_VALUE:
1200 if (this->GetLogx() == 0)
1202 if ( x < xrange[0] )
1206 if ( x > xrange[1] )
1211 else //ensure positive values
1213 if ( (x < xrange[0]) && (x > 0) )
1217 if ( x > xrange[1] && (x > 0) )
1224 lengths[doNum] += fabs(x-xPrev);
1228 if ( lengths[doNum] > maxLength )
1230 maxLength = lengths[doNum];
1232 }//if all data has to be visited
1234 else //if (this->XValues == VTK_XYPLOT_INDEX)
1243 for ( ptId=0; ptId < num; ptId++ )
1245 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
1247 y = field->GetComponent(this->YComponent->GetValue(doNum), ptId);
1249 else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
1251 y = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
1253 if ( y < yrange[0] )
1257 if ( y > yrange[1] )
1261 }//over all y values
1262 }//over all dataobjects
1264 // determine the range
1265 switch (this->XValues)
1267 case VTK_XYPLOT_ARC_LENGTH:
1269 xrange[1] = maxLength;
1271 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1275 case VTK_XYPLOT_INDEX:
1277 xrange[1] = (double)(maxNum - 1);
1279 case VTK_XYPLOT_VALUE:
1280 if (this->GetLogx() == 1)
1282 xrange[0] = log10(xrange[0]);
1283 xrange[1] = log10(xrange[1]);
1287 vtkErrorMacro(<< "Unknown X-Value option");
1292 //----------------------------------------------------------------------------
1293 /* RKV void VISU_XYPlotActor::CreatePlotData(int *pos, int *pos2, double xRange[2],
1294 double yRange[2], double *lengths,
1295 int numDS, int numDO) */
1297 void VISU_XYPlotActor::CreatePlotData(int *pos, int *pos2Extern, double xRange[2],
1298 double yRange[2], double *lengths,
1299 int numDS, int numDO)
1302 double xyz[3]; xyz[2] = 0.0;
1303 int i, numLinePts, dsNum, doNum, num;
1304 vtkIdType numPts, ptId, id;
1305 double length, x[3], xPrev[3];
1306 vtkDataArray *scalars;
1309 vtkCellArray *lines;
1311 int clippingRequired = 0;
1313 // Allocate resources for the polygonal plots
1315 num = (numDS > numDO ? numDS : numDO);
1316 this->InitializeEntries();
1317 this->NumberOfInputs = num;
1318 this->PlotData = new vtkPolyData* [num];
1319 this->PlotGlyph = new vtkGlyph2D* [num];
1320 this->PlotAppend = new vtkAppendPolyData* [num];
1321 this->PlotTransform = new vtkTransformPolyDataFilter* [num]; // RKV
1322 this->PlotMapper = new vtkPolyDataMapper2D* [num];
1323 this->PlotActor = new vtkActor2D* [num];
1326 // Prepare the transformation of the curve according to the plot location
1327 vtkTransform *tf = vtkTransform::New();
1328 tf->Translate(pos[0], pos[1], 0);
1329 if ((this->PlotLocation == VISU_XYPLOT_LEFT) || (this->PlotLocation == VISU_XYPLOT_RIGHT))
1331 tf->Translate(-pos[0], -pos[1], 0);
1333 // Compute the position2 to build the curve before the transformation
1335 vtkDebugMacro(<< "pos = (" << pos[0] << ", " << pos[1] << ")");
1336 vtkDebugMacro(<< "pos2 = (" << pos2Extern[0] << ", " << pos2Extern[1] << ")");
1337 if ((this->PlotLocation == VISU_XYPLOT_LEFT) || (this->PlotLocation == VISU_XYPLOT_RIGHT))
1339 pos2[0] = pos[0] + pos2Extern[1] - pos[1];
1340 pos2[1] = pos[1] + pos[0] - pos2Extern[0];
1344 pos2[0] = pos2Extern[0];
1345 pos2[1] = pos2Extern[1];
1349 for (i=0; i<num; i++)
1351 this->PlotData[i] = vtkPolyData::New();
1352 this->PlotGlyph[i] = vtkGlyph2D::New();
1353 this->PlotGlyph[i]->SetInput(this->PlotData[i]);
1354 this->PlotGlyph[i]->SetScaleModeToDataScalingOff();
1355 this->PlotAppend[i] = vtkAppendPolyData::New();
1356 this->PlotAppend[i]->AddInput(this->PlotData[i]);
1357 if ( this->LegendActor->GetEntrySymbol(i) != NULL &&
1358 this->LegendActor->GetEntrySymbol(i) != this->GlyphSource->GetOutput() )
1360 this->PlotGlyph[i]->SetSource(this->LegendActor->GetEntrySymbol(i));
1361 this->PlotGlyph[i]->SetScaleFactor(this->ComputeGlyphScale(i,pos,pos2));
1362 this->PlotAppend[i]->AddInput(this->PlotGlyph[i]->GetOutput());
1364 this->PlotMapper[i] = vtkPolyDataMapper2D::New();
1367 // Insert a transformation filter into the pipeline to
1368 // take into account a plot location.
1369 this->PlotTransform[i] = vtkTransformPolyDataFilter::New();
1370 this->PlotTransform[i]->SetInput(this->PlotAppend[i]->GetOutput());
1371 this->PlotTransform[i]->SetTransform(tf);
1372 this->PlotMapper[i]->SetInput(this->PlotTransform[i]->GetOutput());
1375 // RKV this->PlotMapper[i]->SetInput(this->PlotAppend[i]->GetOutput());
1376 this->PlotMapper[i]->ScalarVisibilityOff();
1377 this->PlotActor[i] = vtkActor2D::New();
1378 this->PlotActor[i]->SetMapper(this->PlotMapper[i]);
1379 this->PlotActor[i]->GetProperty()->DeepCopy(this->GetProperty());
1380 if ( this->LegendActor->GetEntryColor(i)[0] < 0.0 )
1382 this->PlotActor[i]->GetProperty()->SetColor(
1383 this->GetProperty()->GetColor());
1387 this->PlotActor[i]->GetProperty()->SetColor(
1388 this->LegendActor->GetEntryColor(i));
1392 tf->Delete(); // RKV
1394 // Prepare to receive data
1395 this->GenerateClipPlanes(pos,pos2);
1396 for (i=0; i<this->NumberOfInputs; i++)
1398 lines = vtkCellArray::New();
1399 pts = vtkPoints::New();
1401 lines->Allocate(10,10);
1402 pts->Allocate(10,10);
1403 this->PlotData[i]->SetPoints(pts);
1404 this->PlotData[i]->SetVerts(lines);
1405 this->PlotData[i]->SetLines(lines);
1411 // Okay, for each input generate plot data. Depending on the input
1412 // we use either dataset or data object.
1416 vtkCollectionSimpleIterator dsit;
1417 for ( dsNum=0, this->InputList->InitTraversal(dsit);
1418 (ds = this->InputList->GetNextDataSet(dsit)); dsNum++ )
1420 clippingRequired = 0;
1421 numPts = ds->GetNumberOfPoints();
1422 scalars = ds->GetPointData()->GetScalars(this->SelectedInputScalars[dsNum]);
1427 component = this->SelectedInputScalarsComponent->GetValue(dsNum);
1428 if ( component < 0 || component >= scalars->GetNumberOfComponents())
1433 pts = this->PlotData[dsNum]->GetPoints();
1434 lines = this->PlotData[dsNum]->GetLines();
1435 lines->InsertNextCell(0); //update the count later
1437 ds->GetPoint(0, xPrev);
1438 for ( numLinePts=0, length=0.0, ptId=0; ptId < numPts; ptId++ )
1440 xyz[1] = scalars->GetComponent(ptId, component);
1441 ds->GetPoint(ptId, x);
1442 switch (this->XValues)
1444 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1445 length += sqrt(vtkMath::Distance2BetweenPoints(x,xPrev));
1446 xyz[0] = length / lengths[dsNum];
1447 xPrev[0] = x[0]; xPrev[1] = x[1]; xPrev[2] = x[2];
1449 case VTK_XYPLOT_INDEX:
1450 xyz[0] = (double)ptId;
1452 case VTK_XYPLOT_ARC_LENGTH:
1453 length += sqrt(vtkMath::Distance2BetweenPoints(x,xPrev));
1455 xPrev[0] = x[0]; xPrev[1] = x[1]; xPrev[2] = x[2];
1457 case VTK_XYPLOT_VALUE:
1458 xyz[0] = x[this->XComponent->GetValue(dsNum)];
1461 vtkErrorMacro(<< "Unknown X-Component option");
1464 if ( this->GetLogx() == 1 )
1468 xyz[0] = log10(xyz[0]);
1469 // normalize and position
1470 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1471 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1473 clippingRequired = 1;
1477 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1478 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1479 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1480 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1481 id = pts->InsertNextPoint(xyz);
1482 lines->InsertCellPoint(id);
1487 // normalize and position
1488 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1489 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1491 clippingRequired = 1;
1495 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1496 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1497 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1498 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1499 id = pts->InsertNextPoint(xyz);
1500 lines->InsertCellPoint(id);
1502 }//for all input points
1504 lines->UpdateCellCount(numLinePts);
1505 if ( clippingRequired )
1507 this->ClipPlotData(pos,pos2,this->PlotData[dsNum]);
1509 }//loop over all input data sets
1510 }//if plotting datasets
1512 else //plot data from data objects
1514 vtkDataObject *dobj;
1516 vtkIdType numRows, numTuples;
1517 vtkDataArray *array;
1518 vtkFieldData *field;
1519 vtkCollectionSimpleIterator doit;
1520 for ( doNum=0, this->DataObjectInputList->InitTraversal(doit);
1521 (dobj = this->DataObjectInputList->GetNextDataObject(doit));
1524 // determine the shape of the field
1525 field = dobj->GetFieldData();
1526 numColumns = field->GetNumberOfComponents(); //number of "columns"
1527 for (numRows = VTK_LARGE_ID, i=0; i<field->GetNumberOfArrays(); i++)
1529 array = field->GetArray(i);
1530 numTuples = array->GetNumberOfTuples();
1531 if ( numTuples < numRows )
1533 numRows = numTuples;
1537 pts = this->PlotData[doNum]->GetPoints();
1538 lines = this->PlotData[doNum]->GetLines();
1539 lines->InsertNextCell(0); //update the count later
1541 numPts = (this->DataObjectPlotMode == VTK_XYPLOT_ROW ?
1542 numColumns : numRows);
1544 // gather the information to form a plot
1545 for ( numLinePts=0, length=0.0, ptId=0; ptId < numPts; ptId++ )
1547 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
1549 x[0] = field->GetComponent(this->XComponent->GetValue(doNum),ptId);
1550 xyz[1] = field->GetComponent(this->YComponent->GetValue(doNum),ptId);
1552 else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
1554 x[0] = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
1555 xyz[1] = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
1558 switch (this->XValues)
1560 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1561 length += fabs(x[0]-xPrev[0]);
1562 xyz[0] = length / lengths[doNum];
1565 case VTK_XYPLOT_INDEX:
1566 xyz[0] = (double)ptId;
1568 case VTK_XYPLOT_ARC_LENGTH:
1569 length += fabs(x[0]-xPrev[0]);
1573 case VTK_XYPLOT_VALUE:
1577 vtkErrorMacro(<< "Unknown X-Value option");
1580 if ( this->GetLogx() == 1 )
1584 xyz[0] = log10(xyz[0]);
1585 // normalize and position
1586 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1587 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1589 clippingRequired = 1;
1592 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1593 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1594 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1595 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1596 id = pts->InsertNextPoint(xyz);
1597 lines->InsertCellPoint(id);
1602 // normalize and position
1603 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1604 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1606 clippingRequired = 1;
1609 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1610 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1611 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1612 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1613 id = pts->InsertNextPoint(xyz);
1614 lines->InsertCellPoint(id);
1616 }//for all input points
1618 lines->UpdateCellCount(numLinePts);
1619 if ( clippingRequired )
1621 this->ClipPlotData(pos,pos2,this->PlotData[doNum]);
1623 }//loop over all input data sets
1626 // Remove points/lines as directed by the user
1627 for ( i = 0; i < num; i++)
1629 if (!this->PlotCurveLines)
1631 if ( !this->PlotLines )
1633 this->PlotData[i]->SetLines(NULL);
1638 if ( this->GetPlotLines(i) == 0)
1640 this->PlotData[i]->SetLines(NULL);
1644 if (!this->PlotCurvePoints)
1646 if ( !this->PlotPoints || (this->LegendActor->GetEntrySymbol(i) &&
1647 this->LegendActor->GetEntrySymbol(i) !=
1648 this->GlyphSource->GetOutput()))
1650 this->PlotData[i]->SetVerts(NULL);
1655 if ( this->GetPlotPoints(i) == 0 ||
1656 (this->LegendActor->GetEntrySymbol(i) &&
1657 this->LegendActor->GetEntrySymbol(i) !=
1658 this->GlyphSource->GetOutput()))
1660 this->PlotData[i]->SetVerts(NULL);
1666 //----------------------------------------------------------------------------
1667 // Position the axes taking into account the expected padding due to labels
1668 // and titles. We want the result to fit in the box specified. This method
1669 // knows something about how the vtkAxisActor2D functions, so it may have
1670 // to change if that class changes dramatically.
1672 void VISU_XYPlotActor::PlaceAxes(vtkViewport *viewport, int *size,
1673 int pos[2], int pos2[2])
1675 int titleSizeX[2], titleSizeY[2], labelSizeX[2], labelSizeY[2];
1676 double labelFactorX, labelFactorY;
1677 double fontFactorX, fontFactorY;
1678 double tickOffsetX, tickOffsetY;
1679 double tickLengthX, tickLengthY;
1681 vtkAxisActor2D *axisX;
1682 vtkAxisActor2D *axisY;
1684 char str1[512], str2[512];
1686 if (this->ExchangeAxes)
1688 axisX = this->YAxis;
1689 axisY = this->XAxis;
1693 axisX = this->XAxis;
1694 axisY = this->YAxis;
1698 // Take into account a location of the plot.
1699 if ((this->PlotLocation == VISU_XYPLOT_LEFT) || (this->PlotLocation == VISU_XYPLOT_RIGHT))
1701 vtkAxisActor2D *axisBid;
1709 fontFactorY = axisY->GetFontFactor();
1710 fontFactorX = axisX->GetFontFactor();
1712 labelFactorY = axisY->GetLabelFactor();
1713 labelFactorX = axisX->GetLabelFactor();
1715 // Create a dummy text mapper for getting font sizes
1716 vtkTextMapper *textMapper = vtkTextMapper::New();
1717 vtkTextProperty *tprop = textMapper->GetTextProperty();
1719 // Get the location of the corners of the box
1720 int *p1 = this->PositionCoordinate->GetComputedViewportValue(viewport);
1721 int *p2 = this->Position2Coordinate->GetComputedViewportValue(viewport);
1723 // Estimate the padding around the X and Y axes
1724 tprop->ShallowCopy(axisX->GetTitleTextProperty());
1725 textMapper->SetInput(axisX->GetTitle());
1727 #if (VTK_XVERSION < 0x050100)
1728 //VSV: Function is not supported in VTK 5.2 and high
1729 vtkAxisActor2D::SetFontSize(
1730 viewport, textMapper, size, fontFactorX, titleSizeX);
1733 tprop->ShallowCopy(axisY->GetTitleTextProperty());
1734 textMapper->SetInput(axisY->GetTitle());
1736 #if (VTK_XVERSION < 0x050100)
1737 //VSV: Function is not supported in VTK 5.2 and high
1738 vtkAxisActor2D::SetFontSize(
1739 viewport, textMapper, size, fontFactorY, titleSizeY);
1742 // At this point the thing to do would be to actually ask the Y axis
1743 // actor to return the largest label.
1744 // In the meantime, let's try with the min and max
1745 sprintf(str1, axisY->GetLabelFormat(), axisY->GetAdjustedRange()[0]);
1746 sprintf(str2, axisY->GetLabelFormat(), axisY->GetAdjustedRange()[1]);
1747 tprop->ShallowCopy(axisY->GetLabelTextProperty());
1748 textMapper->SetInput(strlen(str1) > strlen(str2) ? str1 : str2);
1750 #if (VTK_XVERSION < 0x050100)
1751 //VSV: Function is not supported in VTK 5.2 and high
1752 vtkAxisActor2D::SetFontSize(
1753 viewport, textMapper, size, labelFactorY * fontFactorY, labelSizeY);
1756 // We do only care of the height of the label in the X axis, so let's
1757 // use the min for example
1758 sprintf(str1, axisX->GetLabelFormat(), axisX->GetAdjustedRange()[0]);
1759 tprop->ShallowCopy(axisX->GetLabelTextProperty());
1760 textMapper->SetInput(str1);
1762 #if (VTK_XVERSION < 0x050100)
1763 //VSV: Function is not supported in VTK 5.2 and high
1764 vtkAxisActor2D::SetFontSize(
1765 viewport, textMapper, size, labelFactorX * fontFactorX, labelSizeX);
1768 tickOffsetX = axisX->GetTickOffset();
1769 tickOffsetY = axisY->GetTickOffset();
1770 tickLengthX = axisX->GetTickLength();
1771 tickLengthY = axisY->GetTickLength();
1773 // Okay, estimate the size
1774 /* RKV pos[0] = (int)(p1[0] + titleSizeY[0] + 2.0 * tickOffsetY + tickLengthY +
1775 labelSizeY[0] + this->Border);
1777 pos[1] = (int)(p1[1] + titleSizeX[1] + 2.0 * tickOffsetX + tickLengthX +
1778 labelSizeX[1] + this->Border);
1780 pos2[0] = (int)(p2[0] - labelSizeY[0] / 2 - tickOffsetY - this->Border);
1782 pos2[1] = (int)(p2[1] - labelSizeX[1] / 2 - tickOffsetX - this->Border);
1785 pos[0] = (int)(p1[0]);
1787 pos[1] = (int)(p1[1]);
1789 pos2[0] = (int)(p2[0]);
1791 pos2[1] = (int)(p2[1]);
1794 // Now specify the location of the axes
1795 axisX->GetPositionCoordinate()->SetValue(
1796 (double)pos[0], (double)pos[1]);
1797 axisX->GetPosition2Coordinate()->SetValue(
1798 (double)pos2[0], (double)pos[1]);
1799 axisY->GetPositionCoordinate()->SetValue(
1800 (double)pos[0], (double)pos2[1]);
1801 axisY->GetPosition2Coordinate()->SetValue(
1802 (double)pos[0], (double)pos[1]);
1804 textMapper->Delete();
1807 //----------------------------------------------------------------------------
1808 void VISU_XYPlotActor::ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v)
1812 // XAxis, YAxis are in viewport coordinates already
1813 p0 = this->XAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1814 p1 = this->XAxis->GetPosition2Coordinate()->GetComputedViewportValue(viewport);
1815 p2 = this->YAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1817 u = ((u - p0[0]) / (double)(p1[0] - p0[0]))
1818 *(this->XComputedRange[1] - this->XComputedRange[0])
1819 + this->XComputedRange[0];
1820 v = ((v - p0[1]) / (double)(p2[1] - p0[1]))
1821 *(this->YComputedRange[1] - this->YComputedRange[0])
1822 + this->YComputedRange[0];
1825 //----------------------------------------------------------------------------
1826 void VISU_XYPlotActor::PlotToViewportCoordinate(vtkViewport *viewport,
1827 double &u, double &v)
1831 // XAxis, YAxis are in viewport coordinates already
1832 p0 = this->XAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1833 p1 = this->XAxis->GetPosition2Coordinate()->GetComputedViewportValue(viewport);
1834 p2 = this->YAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1836 u = (((u - this->XComputedRange[0])
1837 / (this->XComputedRange[1] - this->XComputedRange[0]))
1838 * (double)(p1[0] - p0[0])) + p0[0];
1839 v = (((v - this->YComputedRange[0])
1840 / (this->YComputedRange[1] - this->YComputedRange[0]))
1841 * (double)(p2[1] - p0[1])) + p0[1];
1844 //----------------------------------------------------------------------------
1845 void VISU_XYPlotActor::ViewportToPlotCoordinate(vtkViewport *viewport)
1847 this->ViewportToPlotCoordinate(viewport,
1848 this->ViewportCoordinate[0],
1849 this->ViewportCoordinate[1]);
1852 //----------------------------------------------------------------------------
1853 void VISU_XYPlotActor::PlotToViewportCoordinate(vtkViewport *viewport)
1855 this->PlotToViewportCoordinate(viewport,
1856 this->PlotCoordinate[0],
1857 this->PlotCoordinate[1]);
1860 //----------------------------------------------------------------------------
1861 int VISU_XYPlotActor::IsInPlot(vtkViewport *viewport, double u, double v)
1865 // Bounds of the plot are based on the axes...
1866 p0 = this->XAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1867 p1 = this->XAxis->GetPosition2Coordinate()->GetComputedViewportValue(viewport);
1868 p2 = this->YAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1870 if (u >= p0[0] && u <= p1[0] && v >= p0[1] && v <= p2[1])
1878 //----------------------------------------------------------------------------
1879 void VISU_XYPlotActor::SetPlotLines(int i, int isOn)
1881 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1882 int val = this->LinesOn->GetValue(i);
1886 this->LinesOn->SetValue(i, isOn);
1890 //----------------------------------------------------------------------------
1891 int VISU_XYPlotActor::GetPlotLines(int i)
1893 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1894 return this->LinesOn->GetValue(i);
1897 //----------------------------------------------------------------------------
1898 void VISU_XYPlotActor::SetPlotPoints(int i, int isOn)
1900 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1901 int val = this->PointsOn->GetValue(i);
1905 this->PointsOn->SetValue(i, isOn);
1909 //----------------------------------------------------------------------------
1910 int VISU_XYPlotActor::GetPlotPoints(int i)
1912 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1913 return this->PointsOn->GetValue(i);
1916 //----------------------------------------------------------------------------
1917 void VISU_XYPlotActor::SetPlotColor(int i, double r, double g, double b)
1919 this->LegendActor->SetEntryColor(i, r, g, b);
1922 //----------------------------------------------------------------------------
1923 double *VISU_XYPlotActor::GetPlotColor(int i)
1925 return this->LegendActor->GetEntryColor(i);
1928 //----------------------------------------------------------------------------
1929 void VISU_XYPlotActor::SetPlotSymbol(int i,vtkPolyData *input)
1931 this->LegendActor->SetEntrySymbol(i, input);
1934 //----------------------------------------------------------------------------
1935 vtkPolyData *VISU_XYPlotActor::GetPlotSymbol(int i)
1937 return this->LegendActor->GetEntrySymbol(i);
1940 //----------------------------------------------------------------------------
1941 void VISU_XYPlotActor::SetPlotLabel(int i, const char *label)
1943 this->LegendActor->SetEntryString(i, label);
1946 //----------------------------------------------------------------------------
1947 const char *VISU_XYPlotActor::GetPlotLabel(int i)
1949 return this->LegendActor->GetEntryString(i);
1952 //----------------------------------------------------------------------------
1953 void VISU_XYPlotActor::GenerateClipPlanes(int *pos, int *pos2)
1956 vtkPoints *pts=this->ClipPlanes->GetPoints();
1957 vtkDataArray *normals=this->ClipPlanes->GetNormals();
1964 normals->SetTuple(0,n);
1965 x[0] = (double)0.5*(pos[0]+pos2[0]);
1966 x[1] = (double)pos[1];
1972 normals->SetTuple(1,n);
1973 x[0] = (double)pos2[0];
1974 x[1] = (double)0.5*(pos[1]+pos2[1]);
1980 normals->SetTuple(2,n);
1981 x[0] = (double)0.5*(pos[0]+pos2[0]);
1982 x[1] = (double)pos2[1];
1988 normals->SetTuple(3,n);
1989 x[0] = (double)pos[0];
1990 x[1] = (double)0.5*(pos[1]+pos2[1]);
1994 //----------------------------------------------------------------------------
1995 double VISU_XYPlotActor::ComputeGlyphScale(int i, int *pos, int *pos2)
1997 vtkPolyData *pd=this->LegendActor->GetEntrySymbol(i);
1999 double length=pd->GetLength();
2000 double sf = this->GlyphSize * sqrt((double)(pos[0]-pos2[0])*(pos[0]-pos2[0]) +
2001 (pos[1]-pos2[1])*(pos[1]-pos2[1])) / length;
2006 //----------------------------------------------------------------------------
2007 //This assumes that there are multiple polylines
2008 void VISU_XYPlotActor::ClipPlotData(int *pos, int *pos2, vtkPolyData *pd)
2010 vtkPoints *points=pd->GetPoints();
2011 vtkPoints *newPoints;
2012 vtkCellArray *lines=pd->GetLines();
2013 vtkCellArray *newLines, *newVerts;
2014 vtkIdType numPts=pd->GetNumberOfPoints();
2016 vtkIdType newPts[2];
2020 double x1[3], x2[3], px[3], n[3], xint[3], t;
2021 double p1[2], p2[2];
2023 p1[0] = (double)pos[0]; p1[1] = (double)pos[1];
2024 p2[0] = (double)pos2[0]; p2[1] = (double)pos2[1];
2026 newPoints = vtkPoints::New();
2027 newPoints->Allocate(numPts);
2028 newVerts = vtkCellArray::New();
2029 newVerts->Allocate(lines->GetSize());
2030 newLines = vtkCellArray::New();
2031 newLines->Allocate(2*lines->GetSize());
2032 int *pointMap = new int [numPts];
2033 for (i=0; i<numPts; i++)
2038 //Loop over polyverts eliminating those that are outside
2039 for ( lines->InitTraversal(); lines->GetNextCell(npts,pts); )
2041 //loop over verts keeping only those that are not clipped
2042 for (i=0; i<npts; i++)
2044 points->GetPoint(pts[i], x1);
2046 if (x1[0] >= p1[0] && x1[0] <= p2[0] && x1[1] >= p1[1] && x1[1] <= p2[1] )
2048 id = newPoints->InsertNextPoint(x1);
2051 newVerts->InsertNextCell(1,newPts);
2056 //Loop over polylines clipping each line segment
2057 for ( lines->InitTraversal(); lines->GetNextCell(npts,pts); )
2059 //loop over line segment making up the polyline
2060 for (i=0; i<(npts-1); i++)
2062 points->GetPoint(pts[i], x1);
2063 points->GetPoint(pts[i+1], x2);
2065 //intersect each segment with the four planes
2066 if ( (x1[0] < p1[0] && x2[0] < p1[0]) || (x1[0] > p2[0] && x2[0] > p2[0]) ||
2067 (x1[1] < p1[1] && x2[1] < p1[1]) || (x1[1] > p2[1] && x2[1] > p2[1]) )
2069 ;//trivial rejection
2071 else if (x1[0] >= p1[0] && x2[0] >= p1[0] && x1[0] <= p2[0] && x2[0] <= p2[0] &&
2072 x1[1] >= p1[1] && x2[1] >= p1[1] && x1[1] <= p2[1] && x2[1] <= p2[1] )
2073 {//trivial acceptance
2074 newPts[0] = pointMap[pts[i]];
2075 newPts[1] = pointMap[pts[i+1]];
2076 newLines->InsertNextCell(2,newPts);
2080 if (x1[0] >= p1[0] && x1[0] <= p2[0] && x1[1] >= p1[1] && x1[1] <= p2[1] )
2082 newPts[0] = pointMap[pts[i]];
2086 newPts[0] = pointMap[pts[i+1]];
2090 this->ClipPlanes->GetPoints()->GetPoint(j, px);
2091 this->ClipPlanes->GetNormals()->GetTuple(j, n);
2092 if ( vtkPlane::IntersectWithLine(x1,x2,n,px,t,xint) && t >= 0 && t <= 1.0 )
2094 newPts[1] = newPoints->InsertNextPoint(xint);
2098 newLines->InsertNextCell(2,newPts);
2105 pd->SetPoints(newPoints);
2106 pd->SetVerts(newVerts);
2107 pd->SetLines(newLines);
2109 newPoints->Delete();
2115 //----------------------------------------------------------------------------
2116 void VISU_XYPlotActor::SetDataObjectXComponent(int i, int comp)
2118 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2119 int val=this->XComponent->GetValue(i);
2123 this->XComponent->SetValue(i,comp);
2127 //----------------------------------------------------------------------------
2128 int VISU_XYPlotActor::GetDataObjectXComponent(int i)
2130 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2131 return this->XComponent->GetValue(i);
2134 //----------------------------------------------------------------------------
2135 void VISU_XYPlotActor::SetDataObjectYComponent(int i, int comp)
2137 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2138 int val=this->YComponent->GetValue(i);
2142 this->YComponent->SetValue(i,comp);
2146 //----------------------------------------------------------------------------
2147 int VISU_XYPlotActor::GetDataObjectYComponent(int i)
2149 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2150 return this->YComponent->GetValue(i);
2153 //----------------------------------------------------------------------------
2154 void VISU_XYPlotActor::SetPointComponent(int i, int comp)
2156 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2157 int val = this->XComponent->GetValue(i);
2161 this->XComponent->SetValue(i,comp);
2165 //----------------------------------------------------------------------------
2166 int VISU_XYPlotActor::GetPointComponent(int i)
2168 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2169 return this->XComponent->GetValue(i);
2172 //----------------------------------------------------------------------------
2173 double *VISU_XYPlotActor::TransformPoint(int pos[2], int pos2[2],
2174 double x[3], double xNew[3])
2176 // First worry about exchanging axes
2177 if ( this->ExchangeAxes )
2179 double sx = (x[0]-pos[0]) / (pos2[0]-pos[0]);
2180 double sy = (x[1]-pos[1]) / (pos2[1]-pos[1]);
2181 xNew[0] = sy*(pos2[0]-pos[0]) + pos[0];
2182 xNew[1] = sx*(pos2[1]-pos[1]) + pos[1];
2192 // Okay, now swap the axes around if reverse is on
2193 if ( this->ReverseXAxis )
2195 xNew[0] = pos[0] + (pos2[0]-xNew[0]);
2197 if ( this->ReverseYAxis )
2199 xNew[1] = pos[1] + (pos2[1]-xNew[1]);
2205 //----------------------------------------------------------------------------
2206 void VISU_XYPlotActor::SetLabelFormat(const char* _arg)
2208 if (this->LabelFormat == NULL && _arg == NULL)
2213 if (this->LabelFormat && _arg && (!strcmp(this->LabelFormat,_arg)))
2218 if (this->LabelFormat)
2220 delete [] this->LabelFormat;
2225 this->LabelFormat = new char[strlen(_arg)+1];
2226 strcpy(this->LabelFormat,_arg);
2230 this->LabelFormat = NULL;
2233 this->XAxis->SetLabelFormat(this->LabelFormat);
2234 this->YAxis->SetLabelFormat(this->LabelFormat);
2239 //----------------------------------------------------------------------------
2240 void VISU_XYPlotActor::PrintAsCSV(ostream &os)
2242 vtkDataArray *scalars;
2244 vtkCollectionSimpleIterator dsit;
2246 int dsNum,component;
2247 for ( dsNum=0, this->InputList->InitTraversal(dsit);
2248 (ds = this->InputList->GetNextDataSet(dsit)); dsNum++ )
2250 vtkIdType numPts = ds->GetNumberOfPoints();
2251 scalars = ds->GetPointData()->GetScalars(this->SelectedInputScalars[dsNum]);
2252 component = this->SelectedInputScalarsComponent->GetValue(dsNum);
2253 for ( vtkIdType ptId=0; ptId < numPts; ptId++ )
2255 s = scalars->GetComponent(ptId, component);