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 *** Modified by OPEN CASCADE
16 =========================================================================*/
17 #include "VISU_XYPlotActor.hxx"
19 #include "vtkAppendPolyData.h"
20 #include "vtkAxisActor2D.h"
21 #include "vtkCellArray.h"
22 #include "vtkDataObjectCollection.h"
23 #include "vtkDataSetCollection.h"
24 #include "vtkFieldData.h"
25 #include "vtkDoubleArray.h"
26 #include "vtkGlyph2D.h"
27 #include "vtkGlyphSource2D.h"
28 #include "vtkIntArray.h"
29 #include "vtkLegendBoxActor.h"
31 #include "vtkObjectFactory.h"
33 #include "vtkPlanes.h"
34 #include "vtkPointData.h"
35 #include "vtkPolyData.h"
36 #include "vtkPolyDataMapper2D.h"
37 #include "vtkProperty2D.h"
38 #include "vtkTextMapper.h"
39 #include "vtkTextProperty.h"
40 #include "vtkViewport.h"
41 #include "vtkTransformPolyDataFilter.h" // RKV
42 #include "vtkTransform.h" // RKV
44 #define VTK_MAX_PLOTS 50
46 #if !defined(VTK_XVERSION)
47 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
52 vtkCxxRevisionMacro(VISU_XYPlotActor, "$Revision$");
53 vtkStandardNewMacro(VISU_XYPlotActor);
55 vtkCxxSetObjectMacro(VISU_XYPlotActor,TitleTextProperty,vtkTextProperty);
56 vtkCxxSetObjectMacro(VISU_XYPlotActor,AxisLabelTextProperty,vtkTextProperty);
57 vtkCxxSetObjectMacro(VISU_XYPlotActor,AxisTitleTextProperty,vtkTextProperty);
59 //----------------------------------------------------------------------------
61 VISU_XYPlotActor::VISU_XYPlotActor()
63 this->PositionCoordinate->SetCoordinateSystemToNormalizedViewport();
64 this->PositionCoordinate->SetValue(0.25,0.25);
65 this->Position2Coordinate->SetValue(0.5, 0.5);
67 this->InputList = vtkDataSetCollection::New();
68 this->SelectedInputScalars = NULL;
69 this->SelectedInputScalarsComponent = vtkIntArray::New();
70 this->DataObjectInputList = vtkDataObjectCollection::New();
73 this->XTitle = new char[7];
74 sprintf(this->XTitle,"%s","X Axis");
75 this->YTitle = new char[7];
76 sprintf(this->YTitle,"%s","Y Axis");
78 this->XValues = VTK_XYPLOT_INDEX;
79 this->PlotLocation = VISU_XYPLOT_BOTTOM; // RKV
81 this->NumberOfXLabels = 5;
82 this->NumberOfYLabels = 5;
84 this->TitleTextProperty = vtkTextProperty::New();
85 this->TitleTextProperty->SetBold(1);
86 this->TitleTextProperty->SetItalic(1);
87 this->TitleTextProperty->SetShadow(1);
88 this->TitleTextProperty->SetFontFamilyToArial();
90 this->AxisLabelTextProperty = vtkTextProperty::New();
91 this->AxisLabelTextProperty->ShallowCopy(this->TitleTextProperty);
93 this->AxisTitleTextProperty = vtkTextProperty::New();
94 this->AxisTitleTextProperty->ShallowCopy(this->AxisLabelTextProperty);
96 this->LabelFormat = new char[8];
97 sprintf(this->LabelFormat,"%s","%-#6.3g");
101 this->XRange[0] = 0.0;
102 this->XRange[1] = 0.0;
103 this->YRange[0] = 0.0;
104 this->YRange[1] = 0.0;
108 this->PlotPoints = 0;
109 this->PlotCurveLines = 0;
110 this->PlotCurvePoints = 0;
111 this->ExchangeAxes = 0;
112 this->ReverseXAxis = 0;
113 this->ReverseYAxis = 0;
115 this->TitleMapper = vtkTextMapper::New();
116 this->TitleActor = vtkActor2D::New();
117 this->TitleActor->SetMapper(this->TitleMapper);
118 this->TitleActor->GetPositionCoordinate()->SetCoordinateSystemToViewport();
120 this->XAxis = vtkAxisActor2D::New();
121 this->XAxis->GetPositionCoordinate()->SetCoordinateSystemToViewport();
122 this->XAxis->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
123 this->XAxis->SetProperty(this->GetProperty());
125 this->YAxis = vtkAxisActor2D::New();
126 this->YAxis->GetPositionCoordinate()->SetCoordinateSystemToViewport();
127 this->YAxis->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
128 this->YAxis->SetProperty(this->GetProperty());
130 this->NumberOfInputs = 0;
131 this->PlotData = NULL;
132 this->PlotGlyph = NULL;
133 this->PlotAppend = NULL;
134 this->PlotTransform = NULL; // RKV
135 this->PlotMapper = NULL;
136 this->PlotActor = NULL;
138 this->ViewportCoordinate[0] = 0.0;
139 this->ViewportCoordinate[1] = 0.0;
140 this->PlotCoordinate[0] = 0.0;
141 this->PlotCoordinate[1] = 0.0;
143 this->DataObjectPlotMode = VTK_XYPLOT_COLUMN;
144 this->XComponent = vtkIntArray::New();
145 this->XComponent->SetNumberOfValues(VTK_MAX_PLOTS);
146 this->YComponent = vtkIntArray::New();
147 this->YComponent->SetNumberOfValues(VTK_MAX_PLOTS);
149 this->LinesOn = vtkIntArray::New();
150 this->LinesOn->SetNumberOfValues(VTK_MAX_PLOTS);
151 this->PointsOn = vtkIntArray::New();
152 this->PointsOn->SetNumberOfValues(VTK_MAX_PLOTS);
153 for (int i=0; i<VTK_MAX_PLOTS; i++)
155 this->XComponent->SetValue(i,0);
156 this->YComponent->SetValue(i,0);
157 this->LinesOn->SetValue(i,this->PlotLines);
158 this->PointsOn->SetValue(i,this->PlotPoints);
162 this->LegendPosition[0] = 0.85;
163 this->LegendPosition[1] = 0.75;
164 this->LegendPosition2[0] = 0.15;
165 this->LegendPosition2[1] = 0.20;
166 this->LegendActor = vtkLegendBoxActor::New();
167 this->LegendActor->GetPositionCoordinate()->SetCoordinateSystemToViewport();
168 this->LegendActor->GetPosition2Coordinate()->SetCoordinateSystemToViewport();
169 this->LegendActor->GetPosition2Coordinate()->SetReferenceCoordinate(NULL);
170 this->LegendActor->BorderOff();
171 this->LegendActor->SetNumberOfEntries(VTK_MAX_PLOTS); //initial allocation
172 this->GlyphSource = vtkGlyphSource2D::New();
173 this->GlyphSource->SetGlyphTypeToNone();
174 this->GlyphSource->DashOn();
175 this->GlyphSource->FilledOff();
176 this->GlyphSize = 0.020;
178 this->ClipPlanes = vtkPlanes::New();
179 vtkPoints *pts = vtkPoints::New();
180 pts->SetNumberOfPoints(4);
181 this->ClipPlanes->SetPoints(pts);
183 vtkDoubleArray *n = vtkDoubleArray::New();
184 n->SetNumberOfComponents(3);
185 n->SetNumberOfTuples(4);
186 this->ClipPlanes->SetNormals(n);
189 this->CachedSize[0] = 0;
190 this->CachedSize[1] = 0;
193 //----------------------------------------------------------------------------
194 VISU_XYPlotActor::~VISU_XYPlotActor()
196 // Get rid of the list of array names.
197 int num = this->InputList->GetNumberOfItems();
198 if (this->SelectedInputScalars)
200 for (int i = 0; i < num; ++i)
202 if (this->SelectedInputScalars[i])
204 delete [] this->SelectedInputScalars[i];
205 this->SelectedInputScalars[i] = NULL;
208 delete [] this->SelectedInputScalars;
209 this->SelectedInputScalars = NULL;
211 this->SelectedInputScalarsComponent->Delete();
212 this->SelectedInputScalarsComponent = NULL;
214 // Now we can get rid of the inputs.
215 this->InputList->Delete();
216 this->InputList = NULL;
218 this->DataObjectInputList->Delete();
219 this->DataObjectInputList = NULL;
221 this->TitleMapper->Delete();
222 this->TitleMapper = NULL;
223 this->TitleActor->Delete();
224 this->TitleActor = NULL;
229 this->SetLabelFormat(0);
231 this->XAxis->Delete();
232 this->YAxis->Delete();
234 this->InitializeEntries();
236 this->LegendActor->Delete();
237 this->GlyphSource->Delete();
238 this->ClipPlanes->Delete();
240 this->XComponent->Delete();
241 this->YComponent->Delete();
243 this->LinesOn->Delete();
244 this->PointsOn->Delete();
246 this->SetTitleTextProperty(NULL);
247 this->SetAxisLabelTextProperty(NULL);
248 this->SetAxisTitleTextProperty(NULL);
251 //----------------------------------------------------------------------------
252 void VISU_XYPlotActor::InitializeEntries()
254 if ( this->NumberOfInputs > 0 )
256 for (int i=0; i<this->NumberOfInputs; i++)
258 this->PlotData[i]->Delete();
259 this->PlotGlyph[i]->Delete();
260 this->PlotAppend[i]->Delete();
261 this->PlotTransform[i]->Delete(); // RKV
262 this->PlotMapper[i]->Delete();
263 this->PlotActor[i]->Delete();
265 delete [] this->PlotData; this->PlotData = NULL;
266 delete [] this->PlotGlyph; this->PlotGlyph = NULL;
267 delete [] this->PlotAppend; this->PlotAppend = NULL;
268 delete [] this->PlotTransform; this->PlotTransform = NULL; // RKV
269 delete [] this->PlotMapper; this->PlotMapper = NULL;
270 delete [] this->PlotActor; this->PlotActor = NULL;
271 this->NumberOfInputs = 0;
272 }//if entries have been defined
275 //----------------------------------------------------------------------------
276 // Add a dataset and array to the list of data to plot.
277 void VISU_XYPlotActor::AddInput(vtkDataSet *ds, const char *arrayName, int component)
282 // I cannot change the input list, because the user has direct
283 // access to the collection. I cannot store the index of the array,
284 // because the index might change from render to render ...
285 // I have to store the list of string array names.
287 // I believe idx starts at 1 and goes to "NumberOfItems".
288 idx = this->InputList->IsItemPresent(ds);
290 { // Return if arrays are the same.
291 if (arrayName == NULL && this->SelectedInputScalars[idx-1] == NULL &&
292 component == this->SelectedInputScalarsComponent->GetValue(idx-1))
296 if (arrayName != NULL && this->SelectedInputScalars[idx-1] != NULL &&
297 strcmp(arrayName, this->SelectedInputScalars[idx-1]) == 0 &&
298 component == this->SelectedInputScalarsComponent->GetValue(idx-1))
304 // The input/array/component must be a unique combination. Add it to our input list.
306 // Now reallocate the list of strings and add the new value.
307 num = this->InputList->GetNumberOfItems();
308 newNames = new char*[num+1];
309 for (idx = 0; idx < num; ++idx)
311 newNames[idx] = this->SelectedInputScalars[idx];
313 if (arrayName == NULL)
315 newNames[num] = NULL;
319 newNames[num] = new char[strlen(arrayName)+1];
320 strcpy(newNames[num],arrayName);
322 delete [] this->SelectedInputScalars;
323 this->SelectedInputScalars = newNames;
325 // Save the component in the int array.
326 this->SelectedInputScalarsComponent->InsertValue(num, component);
328 // Add the data set to the collection
329 this->InputList->AddItem(ds);
331 // In case of multiple use of a XYPlotActor the NumberOfEntries could be set
332 // to n. Then when a call to SetEntryString(n+1, bla) was done the string was lost
333 // Need to update the number of entries for the legend actor
334 this->LegendActor->SetNumberOfEntries(this->LegendActor->GetNumberOfEntries()+1);
339 //----------------------------------------------------------------------------
340 void VISU_XYPlotActor::RemoveAllInputs()
344 num = this->InputList->GetNumberOfItems();
345 this->InputList->RemoveAllItems();
347 for (idx = 0; idx < num; ++idx)
349 if (this->SelectedInputScalars[idx])
351 delete [] this->SelectedInputScalars[idx];
352 this->SelectedInputScalars[idx] = NULL;
355 this->SelectedInputScalarsComponent->Reset();
357 this->DataObjectInputList->RemoveAllItems();
360 //----------------------------------------------------------------------------
361 // Remove a dataset from the list of data to plot.
362 void VISU_XYPlotActor::RemoveInput(vtkDataSet *ds, const char *arrayName, int component)
368 // This is my own find routine, because the array names have to match also.
369 num = this->InputList->GetNumberOfItems();
370 vtkCollectionSimpleIterator dsit;
371 this->InputList->InitTraversal(dsit);
372 for (idx = 0; idx < num && found == -1; ++idx)
374 input = this->InputList->GetNextDataSet(dsit);
377 if (arrayName == NULL && this->SelectedInputScalars[idx] == NULL &&
378 component == this->SelectedInputScalarsComponent->GetValue(idx))
382 if (arrayName != NULL && this->SelectedInputScalars[idx] != NULL &&
383 strcmp(arrayName, this->SelectedInputScalars[idx]) == 0 &&
384 component == this->SelectedInputScalarsComponent->GetValue(idx))
397 // Collections index their items starting at 1.
398 this->InputList->RemoveItem(found);
400 // Do not bother reallocating the SelectedInputScalars
401 // string array to make it smaller.
402 if (this->SelectedInputScalars[found])
404 delete [] this->SelectedInputScalars[found];
405 this->SelectedInputScalars[found] = NULL;
407 for (idx = found+1; idx < num; ++idx)
409 this->SelectedInputScalars[idx-1] = this->SelectedInputScalars[idx];
410 this->SelectedInputScalarsComponent->SetValue(idx-1,
411 this->SelectedInputScalarsComponent->GetValue(idx));
413 // Reseting the last item is not really necessary,
414 // but to be clean we do it anyway.
415 this->SelectedInputScalarsComponent->SetValue(num-1, -1);
416 this->SelectedInputScalars[num-1] = NULL;
419 //----------------------------------------------------------------------------
420 // Add a data object to the list of data to plot.
421 void VISU_XYPlotActor::AddDataObjectInput(vtkDataObject *in)
423 if ( ! this->DataObjectInputList->IsItemPresent(in) )
426 this->DataObjectInputList->AddItem(in);
430 //----------------------------------------------------------------------------
431 // Remove a data object from the list of data to plot.
432 void VISU_XYPlotActor::RemoveDataObjectInput(vtkDataObject *in)
434 if ( this->DataObjectInputList->IsItemPresent(in) )
437 this->DataObjectInputList->RemoveItem(in);
441 //----------------------------------------------------------------------------
442 // Plot scalar data for each input dataset.
443 int VISU_XYPlotActor::RenderOverlay(vtkViewport *viewport)
445 int renderedSomething = 0;
447 // Make sure input is up to date.
448 if ( this->InputList->GetNumberOfItems() < 1 &&
449 this->DataObjectInputList->GetNumberOfItems() < 1 )
451 vtkErrorMacro(<< "Nothing to plot!");
455 renderedSomething += this->XAxis->RenderOverlay(viewport);
456 renderedSomething += this->YAxis->RenderOverlay(viewport);
459 renderedSomething += this->TitleActor->RenderOverlay(viewport);
461 for (int i=0; i < this->NumberOfInputs; i++)
463 renderedSomething += this->PlotActor[i]->RenderOverlay(viewport);
467 renderedSomething += this->LegendActor->RenderOverlay(viewport);
470 return renderedSomething;
473 //----------------------------------------------------------------------------
474 // Plot scalar data for each input dataset.
475 int VISU_XYPlotActor::RenderOpaqueGeometry(vtkViewport *viewport)
477 unsigned long mtime, dsMtime;
480 int numDS, numDO, renderedSomething=0;
483 // Make sure input is up to date.
484 numDS = this->InputList->GetNumberOfItems();
485 numDO = this->DataObjectInputList->GetNumberOfItems();
488 vtkDebugMacro(<<"Plotting input data sets");
489 vtkCollectionSimpleIterator dsit;
490 for (mtime=0, this->InputList->InitTraversal(dsit);
491 (ds = this->InputList->GetNextDataSet(dsit)); )
494 dsMtime = ds->GetMTime();
495 if ( dsMtime > mtime )
501 else if ( numDO > 0 )
503 vtkDebugMacro(<<"Plotting input data objects");
504 vtkCollectionSimpleIterator doit;
505 for (mtime=0, this->DataObjectInputList->InitTraversal(doit);
506 (dobj = this->DataObjectInputList->GetNextDataObject(doit)); )
509 dsMtime = dobj->GetMTime();
510 if ( dsMtime > mtime )
518 vtkErrorMacro(<< "Nothing to plot!");
522 if (this->Title && this->Title[0] && !this->TitleTextProperty)
524 vtkErrorMacro(<< "Need a title text property to render plot title");
528 // Check modified time to see whether we have to rebuild.
529 // Pay attention that GetMTime() has been redefined (see below)
531 int *size=viewport->GetSize();
532 if (mtime > this->BuildTime ||
533 size[0] != this->CachedSize[0] || size[1] != this->CachedSize[1] ||
534 this->GetMTime() > this->BuildTime ||
535 (this->Title && this->Title[0] &&
536 this->TitleTextProperty->GetMTime() > this->BuildTime) ||
537 (this->AxisLabelTextProperty &&
538 this->AxisLabelTextProperty->GetMTime() > this->BuildTime) ||
539 (this->AxisTitleTextProperty &&
540 this->AxisTitleTextProperty->GetMTime() > this->BuildTime))
542 double range[2], yrange[2], xRange[2], yRange[2], interval, *lengths=NULL;
543 int pos[2], pos2[2], numTicks;
545 int num = ( numDS > 0 ? numDS : numDO );
547 vtkDebugMacro(<<"Rebuilding plot");
548 this->CachedSize[0] = size[0];
549 this->CachedSize[1] = size[1];
552 if ((this->PlotLocation == VISU_XYPLOT_RIGHT) || (this->PlotLocation == VISU_XYPLOT_LEFT))
553 this->ReverseYAxis = 1;
555 this->ReverseYAxis = 0;
559 vtkDebugMacro(<<"Rebuilding legend");
562 int legPos[2], legPos2[2];
563 int *p1 = this->PositionCoordinate->GetComputedViewportValue(viewport);
564 int *p2 = this->Position2Coordinate->GetComputedViewportValue(viewport);
565 legPos[0] = (int)(p1[0] + this->LegendPosition[0]*(p2[0]-p1[0]));
566 legPos2[0] = (int)(legPos[0] + this->LegendPosition2[0]*(p2[0]-p1[0]));
567 legPos[1] = (int)(p1[1] + this->LegendPosition[1]*(p2[1]-p1[1]));
568 legPos2[1] = (int)(legPos[1] + this->LegendPosition2[1]*(p2[1]-p1[1]));
570 this->LegendActor->GetPositionCoordinate()->SetValue(
571 (double)legPos[0], (double)legPos[1]);
572 this->LegendActor->GetPosition2Coordinate()->SetValue(
573 (double)legPos2[0], (double)legPos2[1]);
574 this->LegendActor->SetNumberOfEntries(num);
575 for (int i=0; i<num; i++)
577 if ( ! this->LegendActor->GetEntrySymbol(i) )
579 this->LegendActor->SetEntrySymbol(i,this->GlyphSource->GetOutput());
581 if ( ! this->LegendActor->GetEntryString(i) )
583 static char legendString[12];
584 sprintf(legendString, "%s%d", "Curve ", i);
585 this->LegendActor->SetEntryString(i,legendString);
589 this->LegendActor->SetPadding(2);
590 this->LegendActor->GetProperty()->DeepCopy(this->GetProperty());
591 this->LegendActor->ScalarVisibilityOff();
595 // Perform shallow copy here since each individual axis can be
596 // accessed through the class API (i.e. each individual axis text prop
597 // can be changed). Therefore, we can not just assign pointers otherwise
598 // each individual axis text prop would point to the same text prop.
600 if (this->AxisLabelTextProperty &&
601 this->AxisLabelTextProperty->GetMTime() > this->BuildTime)
603 if (this->XAxis->GetTitleTextProperty())
605 this->XAxis->GetLabelTextProperty()->ShallowCopy(
606 this->AxisLabelTextProperty);
608 if (this->YAxis->GetTitleTextProperty())
610 this->YAxis->GetLabelTextProperty()->ShallowCopy(
611 this->AxisLabelTextProperty);
615 if (this->AxisTitleTextProperty &&
616 this->AxisTitleTextProperty->GetMTime() > this->BuildTime)
618 if (this->XAxis->GetTitleTextProperty())
620 this->XAxis->GetTitleTextProperty()->ShallowCopy(
621 this->AxisTitleTextProperty);
623 if (this->YAxis->GetTitleTextProperty())
625 this->YAxis->GetTitleTextProperty()->ShallowCopy(
626 this->AxisTitleTextProperty);
631 vtkDebugMacro(<<"Rebuilding x-axis");
633 this->XAxis->SetTitle(this->XTitle);
634 this->XAxis->SetNumberOfLabels(this->NumberOfXLabels);
635 this->XAxis->SetProperty(this->GetProperty());
637 vtkDebugMacro(<<"xrange = (" << range[0] << ", " << range[1] << ")"); // RKV
638 lengths = new double[num];
639 if ( numDS > 0 ) //plotting data sets
641 this->ComputeXRange(range, lengths);
645 this->ComputeDORange(range, yrange, lengths);
647 if ( this->XRange[0] < this->XRange[1] )
649 range[0] = this->XRange[0];
650 range[1] = this->XRange[1];
653 /* RKV vtkAxisActor2D::ComputeRange(range, xRange, this->NumberOfXLabels,
656 vtkDebugMacro(<<"XRange = (" << XRange[0] << ", " << XRange[1] << ")");
657 vtkDebugMacro(<<"xrange = (" << range[0] << ", " << range[1] << ")");
658 xRange[0] = range[0];
659 xRange[1] = range[1];
661 if ( !this->ExchangeAxes )
663 this->XComputedRange[0] = xRange[0];
664 this->XComputedRange[1] = xRange[1];
665 if ( this->ReverseXAxis )
667 this->XAxis->SetRange(range[1],range[0]);
671 this->XAxis->SetRange(range[0],range[1]);
676 this->XComputedRange[1] = xRange[0];
677 this->XComputedRange[0] = xRange[1];
678 if ( this->ReverseYAxis )
680 this->XAxis->SetRange(range[0],range[1]);
684 this->XAxis->SetRange(range[1],range[0]);
689 vtkDebugMacro(<<"Rebuilding y-axis");
690 this->YAxis->SetTitle(this->YTitle);
691 this->YAxis->SetNumberOfLabels(this->NumberOfYLabels);
693 vtkDebugMacro(<<"yrange = (" << yrange[0] << ", " << yrange[1] << ")"); // RKV
694 if ( this->YRange[0] >= this->YRange[1] )
696 if ( numDS > 0 ) //plotting data sets
698 this->ComputeYRange(yrange);
703 yrange[0] = this->YRange[0];
704 yrange[1] = this->YRange[1];
706 /* RKV vtkAxisActor2D::ComputeRange(yrange, yRange, this->NumberOfYLabels,
710 vtkDebugMacro(<<"YRange = (" << YRange[0] << ", " << YRange[1] << ")");
711 vtkDebugMacro(<<"yrange = (" << yrange[0] << ", " << yrange[1] << ")");
712 yRange[0] = yrange[0];
713 yRange[1] = yrange[1];
716 if ( !this->ExchangeAxes )
718 this->YComputedRange[0] = yRange[0];
719 this->YComputedRange[1] = yRange[1];
720 if ( this->ReverseYAxis )
722 this->YAxis->SetRange(yrange[0],yrange[1]);
726 this->YAxis->SetRange(yrange[1],yrange[0]);
731 this->YComputedRange[1] = yRange[0];
732 this->YComputedRange[0] = yRange[1];
733 if ( this->ReverseXAxis )
735 this->YAxis->SetRange(yrange[1],yrange[0]);
739 this->YAxis->SetRange(yrange[0],yrange[1]);
744 this->PlaceAxes(viewport, size, pos, pos2);
747 if (this->Title != NULL && this->Title[0])
749 this->TitleMapper->SetInput(this->Title);
750 if (this->TitleTextProperty->GetMTime() > this->BuildTime)
752 this->TitleMapper->GetTextProperty()->ShallowCopy(
753 this->TitleTextProperty);
757 #if (VTK_XVERSION < 0x050100)
758 //VSV: Function is not supported in VTK 5.2 and high
759 vtkAxisActor2D::SetFontSize(viewport,
766 this->TitleActor->GetPositionCoordinate()->SetValue(
767 pos[0] + 0.5 * (pos2[0] - pos[0]) - stringSize[0] / 2.0,
768 pos2[1] - stringSize[1] / 2.0);
770 this->TitleActor->SetProperty(this->GetProperty());
773 vtkDebugMacro(<<"Creating Plot Data");
774 // Okay, now create the plot data and set up the pipeline
775 this->CreatePlotData(pos, pos2, xRange, yRange, lengths, numDS, numDO);
778 this->BuildTime.Modified();
780 }//if need to rebuild the plot
782 vtkDebugMacro(<<"Rendering Axes");
783 renderedSomething += this->XAxis->RenderOpaqueGeometry(viewport);
784 renderedSomething += this->YAxis->RenderOpaqueGeometry(viewport);
785 for (int i=0; i < this->NumberOfInputs; i++)
787 vtkDebugMacro(<<"Rendering plotactors");
788 renderedSomething += this->PlotActor[i]->RenderOpaqueGeometry(viewport);
792 vtkDebugMacro(<<"Rendering titleactors");
793 renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport);
797 vtkDebugMacro(<<"Rendering legendeactors");
798 renderedSomething += this->LegendActor->RenderOpaqueGeometry(viewport);
801 return renderedSomething;
804 //----------------------------------------------------------------------------
805 const char *VISU_XYPlotActor::GetXValuesAsString()
807 switch (this->XValues)
809 case VTK_XYPLOT_INDEX:
811 case VTK_XYPLOT_ARC_LENGTH:
813 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
814 return "NormalizedArcLength";
820 //----------------------------------------------------------------------------
821 const char *VISU_XYPlotActor::GetDataObjectPlotModeAsString()
823 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
829 return "Plot Columns";
833 //----------------------------------------------------------------------------
834 // Release any graphics resources that are being consumed by this actor.
835 // The parameter window could be used to determine which graphic
836 // resources to release.
837 void VISU_XYPlotActor::ReleaseGraphicsResources(vtkWindow *win)
839 this->TitleActor->ReleaseGraphicsResources(win);
840 this->XAxis->ReleaseGraphicsResources(win);
841 this->YAxis->ReleaseGraphicsResources(win);
842 for (int i=0; i < this->NumberOfInputs; i++)
844 this->PlotActor[i]->ReleaseGraphicsResources(win);
846 this->LegendActor->ReleaseGraphicsResources(win);
849 //----------------------------------------------------------------------------
850 unsigned long VISU_XYPlotActor::GetMTime()
852 unsigned long mtime, mtime2;
853 mtime = this->vtkActor2D::GetMTime();
857 mtime2 = this->LegendActor->GetMTime();
867 //----------------------------------------------------------------------------
868 void VISU_XYPlotActor::PrintSelf(ostream& os, vtkIndent indent)
870 vtkIndent i2 = indent.GetNextIndent();
876 this->Superclass::PrintSelf(os,indent);
878 vtkCollectionSimpleIterator dsit;
879 this->InputList->InitTraversal(dsit);
880 num = this->InputList->GetNumberOfItems();
881 os << indent << "DataSetInputs: " << endl;
882 for (idx = 0; idx < num; ++idx)
884 input = this->InputList->GetNextDataSet(dsit);
885 array = this->SelectedInputScalars[idx];
886 component = this->SelectedInputScalarsComponent->GetValue((vtkIdType)idx);
889 os << i2 << "(" << input << ") Default Scalars, Component = " << component << endl;
893 os << i2 << "(" << input << ") " << array << ", Component = " << component << endl;
897 os << indent << "Input DataObjects:\n";
898 this->DataObjectInputList->PrintSelf(os,indent.GetNextIndent());
900 if (this->TitleTextProperty)
902 os << indent << "Title Text Property:\n";
903 this->TitleTextProperty->PrintSelf(os,indent.GetNextIndent());
907 os << indent << "Title Text Property: (none)\n";
910 if (this->AxisTitleTextProperty)
912 os << indent << "Axis Title Text Property:\n";
913 this->AxisTitleTextProperty->PrintSelf(os,indent.GetNextIndent());
917 os << indent << "Axis Title Text Property: (none)\n";
920 if (this->AxisLabelTextProperty)
922 os << indent << "Axis Label Text Property:\n";
923 this->AxisLabelTextProperty->PrintSelf(os,indent.GetNextIndent());
927 os << indent << "Axis Label Text Property: (none)\n";
930 os << indent << "Data Object Plot Mode: " << this->GetDataObjectPlotModeAsString() << endl;
932 os << indent << "Title: " << (this->Title ? this->Title : "(none)") << "\n";
933 os << indent << "X Title: "
934 << (this->XTitle ? this->XTitle : "(none)") << "\n";
935 os << indent << "Y Title: "
936 << (this->YTitle ? this->YTitle : "(none)") << "\n";
938 os << indent << "X Values: " << this->GetXValuesAsString() << endl;
939 os << indent << "Log X Values: " << (this->Logx ? "On\n" : "Off\n");
941 os << indent << "Plot global-points: " << (this->PlotPoints ? "On\n" : "Off\n");
942 os << indent << "Plot global-lines: " << (this->PlotLines ? "On\n" : "Off\n");
943 os << indent << "Plot per-curve points: " << (this->PlotCurvePoints ? "On\n" : "Off\n");
944 os << indent << "Plot per-curve lines: " << (this->PlotCurveLines ? "On\n" : "Off\n");
945 os << indent << "Exchange Axes: " << (this->ExchangeAxes ? "On\n" : "Off\n");
946 os << indent << "Reverse X Axis: " << (this->ReverseXAxis ? "On\n" : "Off\n");
947 os << indent << "Reverse Y Axis: " << (this->ReverseYAxis ? "On\n" : "Off\n");
949 os << indent << "Number Of X Labels: " << this->NumberOfXLabels << "\n";
950 os << indent << "Number Of Y Labels: " << this->NumberOfYLabels << "\n";
952 os << indent << "Label Format: " << this->LabelFormat << "\n";
953 os << indent << "Border: " << this->Border << "\n";
955 os << indent << "X Range: ";
956 if ( this->XRange[0] >= this->XRange[1] )
958 os << indent << "(Automatically Computed)\n";
962 os << "(" << this->XRange[0] << ", " << this->XRange[1] << ")\n";
965 os << indent << "Y Range: ";
966 if ( this->XRange[0] >= this->YRange[1] )
968 os << indent << "(Automatically Computed)\n";
972 os << "(" << this->YRange[0] << ", " << this->YRange[1] << ")\n";
975 os << indent << "Viewport Coordinate: ("
976 << this->ViewportCoordinate[0] << ", "
977 << this->ViewportCoordinate[1] << ")\n";
979 os << indent << "Plot Coordinate: ("
980 << this->PlotCoordinate[0] << ", "
981 << this->PlotCoordinate[1] << ")\n";
983 os << indent << "Legend: " << (this->Legend ? "On\n" : "Off\n");
984 os << indent << "Legend Position: ("
985 << this->LegendPosition[0] << ", "
986 << this->LegendPosition[1] << ")\n";
987 os << indent << "Legend Position2: ("
988 << this->LegendPosition2[0] << ", "
989 << this->LegendPosition2[1] << ")\n";
991 os << indent << "Glyph Size: " << this->GlyphSize << endl;
993 os << indent << "Legend Actor:";
994 this->LegendActor->PrintSelf( os << endl, i2);
995 os << indent << "Glyph Source:";
996 this->GlyphSource->PrintSelf( os << endl, i2);
999 //----------------------------------------------------------------------------
1000 void VISU_XYPlotActor::ComputeXRange(double range[2], double *lengths)
1003 vtkIdType numPts, ptId, maxNum;
1004 double maxLength=0.0, xPrev[3], x[3];
1007 range[0] = VTK_DOUBLE_MAX, range[1] = VTK_DOUBLE_MIN;
1009 vtkCollectionSimpleIterator dsit;
1010 for ( dsNum=0, maxNum=0, this->InputList->InitTraversal(dsit);
1011 (ds = this->InputList->GetNextDataSet(dsit)); dsNum++)
1013 numPts = ds->GetNumberOfPoints();
1015 if ( this->XValues != VTK_XYPLOT_INDEX )
1017 ds->GetPoint(0, xPrev);
1018 for ( lengths[dsNum]=0.0, ptId=0; ptId < numPts; ptId++ )
1020 ds->GetPoint(ptId, x);
1021 switch (this->XValues)
1023 case VTK_XYPLOT_VALUE:
1024 if (this->GetLogx() == 0)
1026 if ( x[this->XComponent->GetValue(dsNum)] < range[0] )
1028 range[0] = x[this->XComponent->GetValue(dsNum)];
1030 if ( x[this->XComponent->GetValue(dsNum)] > range[1] )
1032 range[1] = x[this->XComponent->GetValue(dsNum)];
1037 //ensure range strictly > 0 for log
1038 if ( (x[this->XComponent->GetValue(dsNum)]) < range[0] &&
1039 (x[this->XComponent->GetValue(dsNum)] > 0))
1041 range[0] = x[this->XComponent->GetValue(dsNum)];
1043 if ( (x[this->XComponent->GetValue(dsNum)] > range[1]) &&
1044 (x[this->XComponent->GetValue(dsNum)] > 0))
1046 range[1] = x[this->XComponent->GetValue(dsNum)];
1051 lengths[dsNum] += sqrt(vtkMath::Distance2BetweenPoints(x,xPrev));
1052 xPrev[0] = x[0]; xPrev[1] = x[1]; xPrev[2] = x[2];
1055 if ( lengths[dsNum] > maxLength )
1057 maxLength = lengths[dsNum];
1059 }//if need to visit all points
1061 else //if ( this->XValues == VTK_XYPLOT_INDEX )
1063 if ( numPts > maxNum )
1068 }//over all datasets
1070 // determine the range
1071 switch (this->XValues)
1073 case VTK_XYPLOT_ARC_LENGTH:
1075 range[1] = maxLength;
1077 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1081 case VTK_XYPLOT_INDEX:
1083 range[1] = (double)(maxNum - 1);
1085 case VTK_XYPLOT_VALUE:
1086 if (this->GetLogx() == 1)
1088 if (range[0] > range[1])
1095 range[0] = log10(range[0]);
1096 range[1] = log10(range[1]);
1099 break; //range computed in for loop above
1101 vtkErrorMacro(<< "Unkown X-Value option.");
1106 //----------------------------------------------------------------------------
1107 void VISU_XYPlotActor::ComputeYRange(double range[2])
1110 vtkDataArray *scalars;
1115 range[0]=VTK_DOUBLE_MAX, range[1]=VTK_DOUBLE_MIN;
1117 vtkCollectionSimpleIterator dsit;
1118 for ( this->InputList->InitTraversal(dsit), count = 0;
1119 (ds = this->InputList->GetNextDataSet(dsit)); ++count)
1121 scalars = ds->GetPointData()->GetScalars(this->SelectedInputScalars[count]);
1122 component = this->SelectedInputScalarsComponent->GetValue(count);
1125 vtkErrorMacro(<<"No scalar data to plot!");
1128 if ( component < 0 || component >= scalars->GetNumberOfComponents())
1130 vtkErrorMacro(<<"Bad component!");
1134 scalars->GetRange(sRange, component);
1135 if ( sRange[0] < range[0] )
1137 range[0] = sRange[0];
1140 if ( sRange[1] > range[1] )
1142 range[1] = sRange[1];
1144 }//over all datasets
1147 //----------------------------------------------------------------------------
1148 void VISU_XYPlotActor::ComputeDORange(double xrange[2], double yrange[2],
1152 vtkDataObject *dobj;
1153 vtkFieldData *field;
1154 int doNum, numColumns;
1155 vtkIdType numTuples, numRows, num, ptId, maxNum;
1156 double maxLength=0.0, x, y, xPrev = 0.0;
1157 vtkDataArray *array;
1159 xrange[0] = yrange[0] = VTK_DOUBLE_MAX;
1160 xrange[1] = yrange[1] = -VTK_DOUBLE_MAX;
1161 vtkCollectionSimpleIterator doit;
1162 for ( doNum=0, maxNum=0, this->DataObjectInputList->InitTraversal(doit);
1163 (dobj = this->DataObjectInputList->GetNextDataObject(doit)); doNum++)
1165 lengths[doNum] = 0.0;
1166 field = dobj->GetFieldData();
1167 numColumns = field->GetNumberOfComponents(); //number of "columns"
1168 for (numRows = VTK_LARGE_ID, i=0; i<field->GetNumberOfArrays(); i++)
1170 array = field->GetArray(i);
1171 numTuples = array->GetNumberOfTuples();
1172 if ( numTuples < numRows )
1174 numRows = numTuples;
1178 num = (this->DataObjectPlotMode == VTK_XYPLOT_ROW ?
1179 numColumns : numRows);
1181 if ( this->XValues != VTK_XYPLOT_INDEX )
1183 // gather the information to form a plot
1184 for ( ptId=0; ptId < num; ptId++ )
1186 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
1188 x = field->GetComponent(this->XComponent->GetValue(doNum), ptId);
1190 else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
1192 x = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
1199 switch (this->XValues)
1201 case VTK_XYPLOT_VALUE:
1202 if (this->GetLogx() == 0)
1204 if ( x < xrange[0] )
1208 if ( x > xrange[1] )
1213 else //ensure positive values
1215 if ( (x < xrange[0]) && (x > 0) )
1219 if ( x > xrange[1] && (x > 0) )
1226 lengths[doNum] += fabs(x-xPrev);
1230 if ( lengths[doNum] > maxLength )
1232 maxLength = lengths[doNum];
1234 }//if all data has to be visited
1236 else //if (this->XValues == VTK_XYPLOT_INDEX)
1245 for ( ptId=0; ptId < num; ptId++ )
1247 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
1249 y = field->GetComponent(this->YComponent->GetValue(doNum), ptId);
1251 else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
1253 y = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
1255 if ( y < yrange[0] )
1259 if ( y > yrange[1] )
1263 }//over all y values
1264 }//over all dataobjects
1266 // determine the range
1267 switch (this->XValues)
1269 case VTK_XYPLOT_ARC_LENGTH:
1271 xrange[1] = maxLength;
1273 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1277 case VTK_XYPLOT_INDEX:
1279 xrange[1] = (double)(maxNum - 1);
1281 case VTK_XYPLOT_VALUE:
1282 if (this->GetLogx() == 1)
1284 xrange[0] = log10(xrange[0]);
1285 xrange[1] = log10(xrange[1]);
1289 vtkErrorMacro(<< "Unknown X-Value option");
1294 //----------------------------------------------------------------------------
1295 /* RKV void VISU_XYPlotActor::CreatePlotData(int *pos, int *pos2, double xRange[2],
1296 double yRange[2], double *lengths,
1297 int numDS, int numDO) */
1299 void VISU_XYPlotActor::CreatePlotData(int *pos, int *pos2Extern, double xRange[2],
1300 double yRange[2], double *lengths,
1301 int numDS, int numDO)
1304 double xyz[3]; xyz[2] = 0.0;
1305 int i, numLinePts, dsNum, doNum, num;
1306 vtkIdType numPts, ptId, id;
1307 double length, x[3], xPrev[3];
1308 vtkDataArray *scalars;
1311 vtkCellArray *lines;
1313 int clippingRequired = 0;
1315 // Allocate resources for the polygonal plots
1317 num = (numDS > numDO ? numDS : numDO);
1318 this->InitializeEntries();
1319 this->NumberOfInputs = num;
1320 this->PlotData = new vtkPolyData* [num];
1321 this->PlotGlyph = new vtkGlyph2D* [num];
1322 this->PlotAppend = new vtkAppendPolyData* [num];
1323 this->PlotTransform = new vtkTransformPolyDataFilter* [num]; // RKV
1324 this->PlotMapper = new vtkPolyDataMapper2D* [num];
1325 this->PlotActor = new vtkActor2D* [num];
1328 // Prepare the transformation of the curve according to the plot location
1329 vtkTransform *tf = vtkTransform::New();
1330 tf->Translate(pos[0], pos[1], 0);
1331 if ((this->PlotLocation == VISU_XYPLOT_LEFT) || (this->PlotLocation == VISU_XYPLOT_RIGHT))
1333 tf->Translate(-pos[0], -pos[1], 0);
1335 // Compute the position2 to build the curve before the transformation
1337 vtkDebugMacro(<< "pos = (" << pos[0] << ", " << pos[1] << ")");
1338 vtkDebugMacro(<< "pos2 = (" << pos2Extern[0] << ", " << pos2Extern[1] << ")");
1339 if ((this->PlotLocation == VISU_XYPLOT_LEFT) || (this->PlotLocation == VISU_XYPLOT_RIGHT))
1341 pos2[0] = pos[0] + pos2Extern[1] - pos[1];
1342 pos2[1] = pos[1] + pos[0] - pos2Extern[0];
1346 pos2[0] = pos2Extern[0];
1347 pos2[1] = pos2Extern[1];
1351 for (i=0; i<num; i++)
1353 this->PlotData[i] = vtkPolyData::New();
1354 this->PlotGlyph[i] = vtkGlyph2D::New();
1355 this->PlotGlyph[i]->SetInput(this->PlotData[i]);
1356 this->PlotGlyph[i]->SetScaleModeToDataScalingOff();
1357 this->PlotAppend[i] = vtkAppendPolyData::New();
1358 this->PlotAppend[i]->AddInput(this->PlotData[i]);
1359 if ( this->LegendActor->GetEntrySymbol(i) != NULL &&
1360 this->LegendActor->GetEntrySymbol(i) != this->GlyphSource->GetOutput() )
1362 this->PlotGlyph[i]->SetSource(this->LegendActor->GetEntrySymbol(i));
1363 this->PlotGlyph[i]->SetScaleFactor(this->ComputeGlyphScale(i,pos,pos2));
1364 this->PlotAppend[i]->AddInput(this->PlotGlyph[i]->GetOutput());
1366 this->PlotMapper[i] = vtkPolyDataMapper2D::New();
1369 // Insert a transformation filter into the pipeline to
1370 // take into account a plot location.
1371 this->PlotTransform[i] = vtkTransformPolyDataFilter::New();
1372 this->PlotTransform[i]->SetInput(this->PlotAppend[i]->GetOutput());
1373 this->PlotTransform[i]->SetTransform(tf);
1374 this->PlotMapper[i]->SetInput(this->PlotTransform[i]->GetOutput());
1377 // RKV this->PlotMapper[i]->SetInput(this->PlotAppend[i]->GetOutput());
1378 this->PlotMapper[i]->ScalarVisibilityOff();
1379 this->PlotActor[i] = vtkActor2D::New();
1380 this->PlotActor[i]->SetMapper(this->PlotMapper[i]);
1381 this->PlotActor[i]->GetProperty()->DeepCopy(this->GetProperty());
1382 if ( this->LegendActor->GetEntryColor(i)[0] < 0.0 )
1384 this->PlotActor[i]->GetProperty()->SetColor(
1385 this->GetProperty()->GetColor());
1389 this->PlotActor[i]->GetProperty()->SetColor(
1390 this->LegendActor->GetEntryColor(i));
1394 tf->Delete(); // RKV
1396 // Prepare to receive data
1397 this->GenerateClipPlanes(pos,pos2);
1398 for (i=0; i<this->NumberOfInputs; i++)
1400 lines = vtkCellArray::New();
1401 pts = vtkPoints::New();
1403 lines->Allocate(10,10);
1404 pts->Allocate(10,10);
1405 this->PlotData[i]->SetPoints(pts);
1406 this->PlotData[i]->SetVerts(lines);
1407 this->PlotData[i]->SetLines(lines);
1413 // Okay, for each input generate plot data. Depending on the input
1414 // we use either dataset or data object.
1418 vtkCollectionSimpleIterator dsit;
1419 for ( dsNum=0, this->InputList->InitTraversal(dsit);
1420 (ds = this->InputList->GetNextDataSet(dsit)); dsNum++ )
1422 clippingRequired = 0;
1423 numPts = ds->GetNumberOfPoints();
1424 scalars = ds->GetPointData()->GetScalars(this->SelectedInputScalars[dsNum]);
1429 component = this->SelectedInputScalarsComponent->GetValue(dsNum);
1430 if ( component < 0 || component >= scalars->GetNumberOfComponents())
1435 pts = this->PlotData[dsNum]->GetPoints();
1436 lines = this->PlotData[dsNum]->GetLines();
1437 lines->InsertNextCell(0); //update the count later
1439 ds->GetPoint(0, xPrev);
1440 for ( numLinePts=0, length=0.0, ptId=0; ptId < numPts; ptId++ )
1442 xyz[1] = scalars->GetComponent(ptId, component);
1443 ds->GetPoint(ptId, x);
1444 switch (this->XValues)
1446 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1447 length += sqrt(vtkMath::Distance2BetweenPoints(x,xPrev));
1448 xyz[0] = length / lengths[dsNum];
1449 xPrev[0] = x[0]; xPrev[1] = x[1]; xPrev[2] = x[2];
1451 case VTK_XYPLOT_INDEX:
1452 xyz[0] = (double)ptId;
1454 case VTK_XYPLOT_ARC_LENGTH:
1455 length += sqrt(vtkMath::Distance2BetweenPoints(x,xPrev));
1457 xPrev[0] = x[0]; xPrev[1] = x[1]; xPrev[2] = x[2];
1459 case VTK_XYPLOT_VALUE:
1460 xyz[0] = x[this->XComponent->GetValue(dsNum)];
1463 vtkErrorMacro(<< "Unknown X-Component option");
1466 if ( this->GetLogx() == 1 )
1470 xyz[0] = log10(xyz[0]);
1471 // normalize and position
1472 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1473 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1475 clippingRequired = 1;
1479 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1480 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1481 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1482 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1483 id = pts->InsertNextPoint(xyz);
1484 lines->InsertCellPoint(id);
1489 // normalize and position
1490 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1491 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1493 clippingRequired = 1;
1497 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1498 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1499 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1500 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1501 id = pts->InsertNextPoint(xyz);
1502 lines->InsertCellPoint(id);
1504 }//for all input points
1506 lines->UpdateCellCount(numLinePts);
1507 if ( clippingRequired )
1509 this->ClipPlotData(pos,pos2,this->PlotData[dsNum]);
1511 }//loop over all input data sets
1512 }//if plotting datasets
1514 else //plot data from data objects
1516 vtkDataObject *dobj;
1518 vtkIdType numRows, numTuples;
1519 vtkDataArray *array;
1520 vtkFieldData *field;
1521 vtkCollectionSimpleIterator doit;
1522 for ( doNum=0, this->DataObjectInputList->InitTraversal(doit);
1523 (dobj = this->DataObjectInputList->GetNextDataObject(doit));
1526 // determine the shape of the field
1527 field = dobj->GetFieldData();
1528 numColumns = field->GetNumberOfComponents(); //number of "columns"
1529 for (numRows = VTK_LARGE_ID, i=0; i<field->GetNumberOfArrays(); i++)
1531 array = field->GetArray(i);
1532 numTuples = array->GetNumberOfTuples();
1533 if ( numTuples < numRows )
1535 numRows = numTuples;
1539 pts = this->PlotData[doNum]->GetPoints();
1540 lines = this->PlotData[doNum]->GetLines();
1541 lines->InsertNextCell(0); //update the count later
1543 numPts = (this->DataObjectPlotMode == VTK_XYPLOT_ROW ?
1544 numColumns : numRows);
1546 // gather the information to form a plot
1547 for ( numLinePts=0, length=0.0, ptId=0; ptId < numPts; ptId++ )
1549 if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
1551 x[0] = field->GetComponent(this->XComponent->GetValue(doNum),ptId);
1552 xyz[1] = field->GetComponent(this->YComponent->GetValue(doNum),ptId);
1554 else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
1556 x[0] = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
1557 xyz[1] = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
1560 switch (this->XValues)
1562 case VTK_XYPLOT_NORMALIZED_ARC_LENGTH:
1563 length += fabs(x[0]-xPrev[0]);
1564 xyz[0] = length / lengths[doNum];
1567 case VTK_XYPLOT_INDEX:
1568 xyz[0] = (double)ptId;
1570 case VTK_XYPLOT_ARC_LENGTH:
1571 length += fabs(x[0]-xPrev[0]);
1575 case VTK_XYPLOT_VALUE:
1579 vtkErrorMacro(<< "Unknown X-Value option");
1582 if ( this->GetLogx() == 1 )
1586 xyz[0] = log10(xyz[0]);
1587 // normalize and position
1588 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1589 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1591 clippingRequired = 1;
1594 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1595 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1596 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1597 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1598 id = pts->InsertNextPoint(xyz);
1599 lines->InsertCellPoint(id);
1604 // normalize and position
1605 if ( xyz[0] < xRange[0] || xyz[0] > xRange[1] ||
1606 xyz[1] < yRange[0] || xyz[1] > yRange[1] )
1608 clippingRequired = 1;
1611 xyz[0] = fabs( xRange[1] - xRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[0] : pos[0] +
1612 (xyz[0]-xRange[0])/(xRange[1]-xRange[0])*(pos2[0]-pos[0]);
1613 xyz[1] = fabs( yRange[1] - yRange[0] ) < 1.0 / VTK_LARGE_FLOAT ? pos[1] : pos[1] +
1614 (xyz[1]-yRange[0])/(yRange[1]-yRange[0])*(pos2[1]-pos[1]);
1615 id = pts->InsertNextPoint(xyz);
1616 lines->InsertCellPoint(id);
1618 }//for all input points
1620 lines->UpdateCellCount(numLinePts);
1621 if ( clippingRequired )
1623 this->ClipPlotData(pos,pos2,this->PlotData[doNum]);
1625 }//loop over all input data sets
1628 // Remove points/lines as directed by the user
1629 for ( i = 0; i < num; i++)
1631 if (!this->PlotCurveLines)
1633 if ( !this->PlotLines )
1635 this->PlotData[i]->SetLines(NULL);
1640 if ( this->GetPlotLines(i) == 0)
1642 this->PlotData[i]->SetLines(NULL);
1646 if (!this->PlotCurvePoints)
1648 if ( !this->PlotPoints || (this->LegendActor->GetEntrySymbol(i) &&
1649 this->LegendActor->GetEntrySymbol(i) !=
1650 this->GlyphSource->GetOutput()))
1652 this->PlotData[i]->SetVerts(NULL);
1657 if ( this->GetPlotPoints(i) == 0 ||
1658 (this->LegendActor->GetEntrySymbol(i) &&
1659 this->LegendActor->GetEntrySymbol(i) !=
1660 this->GlyphSource->GetOutput()))
1662 this->PlotData[i]->SetVerts(NULL);
1668 //----------------------------------------------------------------------------
1669 // Position the axes taking into account the expected padding due to labels
1670 // and titles. We want the result to fit in the box specified. This method
1671 // knows something about how the vtkAxisActor2D functions, so it may have
1672 // to change if that class changes dramatically.
1674 void VISU_XYPlotActor::PlaceAxes(vtkViewport *viewport, int *size,
1675 int pos[2], int pos2[2])
1677 int titleSizeX[2], titleSizeY[2], labelSizeX[2], labelSizeY[2];
1678 double labelFactorX, labelFactorY;
1679 double fontFactorX, fontFactorY;
1680 double tickOffsetX, tickOffsetY;
1681 double tickLengthX, tickLengthY;
1683 vtkAxisActor2D *axisX;
1684 vtkAxisActor2D *axisY;
1686 char str1[512], str2[512];
1688 if (this->ExchangeAxes)
1690 axisX = this->YAxis;
1691 axisY = this->XAxis;
1695 axisX = this->XAxis;
1696 axisY = this->YAxis;
1700 // Take into account a location of the plot.
1701 if ((this->PlotLocation == VISU_XYPLOT_LEFT) || (this->PlotLocation == VISU_XYPLOT_RIGHT))
1703 vtkAxisActor2D *axisBid;
1711 fontFactorY = axisY->GetFontFactor();
1712 fontFactorX = axisX->GetFontFactor();
1714 labelFactorY = axisY->GetLabelFactor();
1715 labelFactorX = axisX->GetLabelFactor();
1717 // Create a dummy text mapper for getting font sizes
1718 vtkTextMapper *textMapper = vtkTextMapper::New();
1719 vtkTextProperty *tprop = textMapper->GetTextProperty();
1721 // Get the location of the corners of the box
1722 int *p1 = this->PositionCoordinate->GetComputedViewportValue(viewport);
1723 int *p2 = this->Position2Coordinate->GetComputedViewportValue(viewport);
1725 // Estimate the padding around the X and Y axes
1726 tprop->ShallowCopy(axisX->GetTitleTextProperty());
1727 textMapper->SetInput(axisX->GetTitle());
1729 #if (VTK_XVERSION < 0x050100)
1730 //VSV: Function is not supported in VTK 5.2 and high
1731 vtkAxisActor2D::SetFontSize(
1732 viewport, textMapper, size, fontFactorX, titleSizeX);
1735 tprop->ShallowCopy(axisY->GetTitleTextProperty());
1736 textMapper->SetInput(axisY->GetTitle());
1738 #if (VTK_XVERSION < 0x050100)
1739 //VSV: Function is not supported in VTK 5.2 and high
1740 vtkAxisActor2D::SetFontSize(
1741 viewport, textMapper, size, fontFactorY, titleSizeY);
1744 // At this point the thing to do would be to actually ask the Y axis
1745 // actor to return the largest label.
1746 // In the meantime, let's try with the min and max
1747 sprintf(str1, axisY->GetLabelFormat(), axisY->GetAdjustedRange()[0]);
1748 sprintf(str2, axisY->GetLabelFormat(), axisY->GetAdjustedRange()[1]);
1749 tprop->ShallowCopy(axisY->GetLabelTextProperty());
1750 textMapper->SetInput(strlen(str1) > strlen(str2) ? str1 : str2);
1752 #if (VTK_XVERSION < 0x050100)
1753 //VSV: Function is not supported in VTK 5.2 and high
1754 vtkAxisActor2D::SetFontSize(
1755 viewport, textMapper, size, labelFactorY * fontFactorY, labelSizeY);
1758 // We do only care of the height of the label in the X axis, so let's
1759 // use the min for example
1760 sprintf(str1, axisX->GetLabelFormat(), axisX->GetAdjustedRange()[0]);
1761 tprop->ShallowCopy(axisX->GetLabelTextProperty());
1762 textMapper->SetInput(str1);
1764 #if (VTK_XVERSION < 0x050100)
1765 //VSV: Function is not supported in VTK 5.2 and high
1766 vtkAxisActor2D::SetFontSize(
1767 viewport, textMapper, size, labelFactorX * fontFactorX, labelSizeX);
1770 tickOffsetX = axisX->GetTickOffset();
1771 tickOffsetY = axisY->GetTickOffset();
1772 tickLengthX = axisX->GetTickLength();
1773 tickLengthY = axisY->GetTickLength();
1775 // Okay, estimate the size
1776 /* RKV pos[0] = (int)(p1[0] + titleSizeY[0] + 2.0 * tickOffsetY + tickLengthY +
1777 labelSizeY[0] + this->Border);
1779 pos[1] = (int)(p1[1] + titleSizeX[1] + 2.0 * tickOffsetX + tickLengthX +
1780 labelSizeX[1] + this->Border);
1782 pos2[0] = (int)(p2[0] - labelSizeY[0] / 2 - tickOffsetY - this->Border);
1784 pos2[1] = (int)(p2[1] - labelSizeX[1] / 2 - tickOffsetX - this->Border);
1787 pos[0] = (int)(p1[0]);
1789 pos[1] = (int)(p1[1]);
1791 pos2[0] = (int)(p2[0]);
1793 pos2[1] = (int)(p2[1]);
1796 // Now specify the location of the axes
1797 axisX->GetPositionCoordinate()->SetValue(
1798 (double)pos[0], (double)pos[1]);
1799 axisX->GetPosition2Coordinate()->SetValue(
1800 (double)pos2[0], (double)pos[1]);
1801 axisY->GetPositionCoordinate()->SetValue(
1802 (double)pos[0], (double)pos2[1]);
1803 axisY->GetPosition2Coordinate()->SetValue(
1804 (double)pos[0], (double)pos[1]);
1806 textMapper->Delete();
1809 //----------------------------------------------------------------------------
1810 void VISU_XYPlotActor::ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v)
1814 // XAxis, YAxis are in viewport coordinates already
1815 p0 = this->XAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1816 p1 = this->XAxis->GetPosition2Coordinate()->GetComputedViewportValue(viewport);
1817 p2 = this->YAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1819 u = ((u - p0[0]) / (double)(p1[0] - p0[0]))
1820 *(this->XComputedRange[1] - this->XComputedRange[0])
1821 + this->XComputedRange[0];
1822 v = ((v - p0[1]) / (double)(p2[1] - p0[1]))
1823 *(this->YComputedRange[1] - this->YComputedRange[0])
1824 + this->YComputedRange[0];
1827 //----------------------------------------------------------------------------
1828 void VISU_XYPlotActor::PlotToViewportCoordinate(vtkViewport *viewport,
1829 double &u, double &v)
1833 // XAxis, YAxis are in viewport coordinates already
1834 p0 = this->XAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1835 p1 = this->XAxis->GetPosition2Coordinate()->GetComputedViewportValue(viewport);
1836 p2 = this->YAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1838 u = (((u - this->XComputedRange[0])
1839 / (this->XComputedRange[1] - this->XComputedRange[0]))
1840 * (double)(p1[0] - p0[0])) + p0[0];
1841 v = (((v - this->YComputedRange[0])
1842 / (this->YComputedRange[1] - this->YComputedRange[0]))
1843 * (double)(p2[1] - p0[1])) + p0[1];
1846 //----------------------------------------------------------------------------
1847 void VISU_XYPlotActor::ViewportToPlotCoordinate(vtkViewport *viewport)
1849 this->ViewportToPlotCoordinate(viewport,
1850 this->ViewportCoordinate[0],
1851 this->ViewportCoordinate[1]);
1854 //----------------------------------------------------------------------------
1855 void VISU_XYPlotActor::PlotToViewportCoordinate(vtkViewport *viewport)
1857 this->PlotToViewportCoordinate(viewport,
1858 this->PlotCoordinate[0],
1859 this->PlotCoordinate[1]);
1862 //----------------------------------------------------------------------------
1863 int VISU_XYPlotActor::IsInPlot(vtkViewport *viewport, double u, double v)
1867 // Bounds of the plot are based on the axes...
1868 p0 = this->XAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1869 p1 = this->XAxis->GetPosition2Coordinate()->GetComputedViewportValue(viewport);
1870 p2 = this->YAxis->GetPositionCoordinate()->GetComputedViewportValue(viewport);
1872 if (u >= p0[0] && u <= p1[0] && v >= p0[1] && v <= p2[1])
1880 //----------------------------------------------------------------------------
1881 void VISU_XYPlotActor::SetPlotLines(int i, int isOn)
1883 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1884 int val = this->LinesOn->GetValue(i);
1888 this->LinesOn->SetValue(i, isOn);
1892 //----------------------------------------------------------------------------
1893 int VISU_XYPlotActor::GetPlotLines(int i)
1895 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1896 return this->LinesOn->GetValue(i);
1899 //----------------------------------------------------------------------------
1900 void VISU_XYPlotActor::SetPlotPoints(int i, int isOn)
1902 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1903 int val = this->PointsOn->GetValue(i);
1907 this->PointsOn->SetValue(i, isOn);
1911 //----------------------------------------------------------------------------
1912 int VISU_XYPlotActor::GetPlotPoints(int i)
1914 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
1915 return this->PointsOn->GetValue(i);
1918 //----------------------------------------------------------------------------
1919 void VISU_XYPlotActor::SetPlotColor(int i, double r, double g, double b)
1921 this->LegendActor->SetEntryColor(i, r, g, b);
1924 //----------------------------------------------------------------------------
1925 double *VISU_XYPlotActor::GetPlotColor(int i)
1927 return this->LegendActor->GetEntryColor(i);
1930 //----------------------------------------------------------------------------
1931 void VISU_XYPlotActor::SetPlotSymbol(int i,vtkPolyData *input)
1933 this->LegendActor->SetEntrySymbol(i, input);
1936 //----------------------------------------------------------------------------
1937 vtkPolyData *VISU_XYPlotActor::GetPlotSymbol(int i)
1939 return this->LegendActor->GetEntrySymbol(i);
1942 //----------------------------------------------------------------------------
1943 void VISU_XYPlotActor::SetPlotLabel(int i, const char *label)
1945 this->LegendActor->SetEntryString(i, label);
1948 //----------------------------------------------------------------------------
1949 const char *VISU_XYPlotActor::GetPlotLabel(int i)
1951 return this->LegendActor->GetEntryString(i);
1954 //----------------------------------------------------------------------------
1955 void VISU_XYPlotActor::GenerateClipPlanes(int *pos, int *pos2)
1958 vtkPoints *pts=this->ClipPlanes->GetPoints();
1959 vtkDataArray *normals=this->ClipPlanes->GetNormals();
1966 normals->SetTuple(0,n);
1967 x[0] = (double)0.5*(pos[0]+pos2[0]);
1968 x[1] = (double)pos[1];
1974 normals->SetTuple(1,n);
1975 x[0] = (double)pos2[0];
1976 x[1] = (double)0.5*(pos[1]+pos2[1]);
1982 normals->SetTuple(2,n);
1983 x[0] = (double)0.5*(pos[0]+pos2[0]);
1984 x[1] = (double)pos2[1];
1990 normals->SetTuple(3,n);
1991 x[0] = (double)pos[0];
1992 x[1] = (double)0.5*(pos[1]+pos2[1]);
1996 //----------------------------------------------------------------------------
1997 double VISU_XYPlotActor::ComputeGlyphScale(int i, int *pos, int *pos2)
1999 vtkPolyData *pd=this->LegendActor->GetEntrySymbol(i);
2001 double length=pd->GetLength();
2002 double sf = this->GlyphSize * sqrt((double)(pos[0]-pos2[0])*(pos[0]-pos2[0]) +
2003 (pos[1]-pos2[1])*(pos[1]-pos2[1])) / length;
2008 //----------------------------------------------------------------------------
2009 //This assumes that there are multiple polylines
2010 void VISU_XYPlotActor::ClipPlotData(int *pos, int *pos2, vtkPolyData *pd)
2012 vtkPoints *points=pd->GetPoints();
2013 vtkPoints *newPoints;
2014 vtkCellArray *lines=pd->GetLines();
2015 vtkCellArray *newLines, *newVerts;
2016 vtkIdType numPts=pd->GetNumberOfPoints();
2018 vtkIdType newPts[2];
2022 double x1[3], x2[3], px[3], n[3], xint[3], t;
2023 double p1[2], p2[2];
2025 p1[0] = (double)pos[0]; p1[1] = (double)pos[1];
2026 p2[0] = (double)pos2[0]; p2[1] = (double)pos2[1];
2028 newPoints = vtkPoints::New();
2029 newPoints->Allocate(numPts);
2030 newVerts = vtkCellArray::New();
2031 newVerts->Allocate(lines->GetSize());
2032 newLines = vtkCellArray::New();
2033 newLines->Allocate(2*lines->GetSize());
2034 int *pointMap = new int [numPts];
2035 for (i=0; i<numPts; i++)
2040 //Loop over polyverts eliminating those that are outside
2041 for ( lines->InitTraversal(); lines->GetNextCell(npts,pts); )
2043 //loop over verts keeping only those that are not clipped
2044 for (i=0; i<npts; i++)
2046 points->GetPoint(pts[i], x1);
2048 if (x1[0] >= p1[0] && x1[0] <= p2[0] && x1[1] >= p1[1] && x1[1] <= p2[1] )
2050 id = newPoints->InsertNextPoint(x1);
2053 newVerts->InsertNextCell(1,newPts);
2058 //Loop over polylines clipping each line segment
2059 for ( lines->InitTraversal(); lines->GetNextCell(npts,pts); )
2061 //loop over line segment making up the polyline
2062 for (i=0; i<(npts-1); i++)
2064 points->GetPoint(pts[i], x1);
2065 points->GetPoint(pts[i+1], x2);
2067 //intersect each segment with the four planes
2068 if ( (x1[0] < p1[0] && x2[0] < p1[0]) || (x1[0] > p2[0] && x2[0] > p2[0]) ||
2069 (x1[1] < p1[1] && x2[1] < p1[1]) || (x1[1] > p2[1] && x2[1] > p2[1]) )
2071 ;//trivial rejection
2073 else if (x1[0] >= p1[0] && x2[0] >= p1[0] && x1[0] <= p2[0] && x2[0] <= p2[0] &&
2074 x1[1] >= p1[1] && x2[1] >= p1[1] && x1[1] <= p2[1] && x2[1] <= p2[1] )
2075 {//trivial acceptance
2076 newPts[0] = pointMap[pts[i]];
2077 newPts[1] = pointMap[pts[i+1]];
2078 newLines->InsertNextCell(2,newPts);
2082 if (x1[0] >= p1[0] && x1[0] <= p2[0] && x1[1] >= p1[1] && x1[1] <= p2[1] )
2084 newPts[0] = pointMap[pts[i]];
2088 newPts[0] = pointMap[pts[i+1]];
2092 this->ClipPlanes->GetPoints()->GetPoint(j, px);
2093 this->ClipPlanes->GetNormals()->GetTuple(j, n);
2094 if ( vtkPlane::IntersectWithLine(x1,x2,n,px,t,xint) && t >= 0 && t <= 1.0 )
2096 newPts[1] = newPoints->InsertNextPoint(xint);
2100 newLines->InsertNextCell(2,newPts);
2107 pd->SetPoints(newPoints);
2108 pd->SetVerts(newVerts);
2109 pd->SetLines(newLines);
2111 newPoints->Delete();
2117 //----------------------------------------------------------------------------
2118 void VISU_XYPlotActor::SetDataObjectXComponent(int i, int comp)
2120 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2121 int val=this->XComponent->GetValue(i);
2125 this->XComponent->SetValue(i,comp);
2129 //----------------------------------------------------------------------------
2130 int VISU_XYPlotActor::GetDataObjectXComponent(int i)
2132 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2133 return this->XComponent->GetValue(i);
2136 //----------------------------------------------------------------------------
2137 void VISU_XYPlotActor::SetDataObjectYComponent(int i, int comp)
2139 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2140 int val=this->YComponent->GetValue(i);
2144 this->YComponent->SetValue(i,comp);
2148 //----------------------------------------------------------------------------
2149 int VISU_XYPlotActor::GetDataObjectYComponent(int i)
2151 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2152 return this->YComponent->GetValue(i);
2155 //----------------------------------------------------------------------------
2156 void VISU_XYPlotActor::SetPointComponent(int i, int comp)
2158 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2159 int val = this->XComponent->GetValue(i);
2163 this->XComponent->SetValue(i,comp);
2167 //----------------------------------------------------------------------------
2168 int VISU_XYPlotActor::GetPointComponent(int i)
2170 i = ( i < 0 ? 0 : (i >=VTK_MAX_PLOTS ? VTK_MAX_PLOTS-1 : i));
2171 return this->XComponent->GetValue(i);
2174 //----------------------------------------------------------------------------
2175 double *VISU_XYPlotActor::TransformPoint(int pos[2], int pos2[2],
2176 double x[3], double xNew[3])
2178 // First worry about exchanging axes
2179 if ( this->ExchangeAxes )
2181 double sx = (x[0]-pos[0]) / (pos2[0]-pos[0]);
2182 double sy = (x[1]-pos[1]) / (pos2[1]-pos[1]);
2183 xNew[0] = sy*(pos2[0]-pos[0]) + pos[0];
2184 xNew[1] = sx*(pos2[1]-pos[1]) + pos[1];
2194 // Okay, now swap the axes around if reverse is on
2195 if ( this->ReverseXAxis )
2197 xNew[0] = pos[0] + (pos2[0]-xNew[0]);
2199 if ( this->ReverseYAxis )
2201 xNew[1] = pos[1] + (pos2[1]-xNew[1]);
2207 //----------------------------------------------------------------------------
2208 void VISU_XYPlotActor::SetLabelFormat(const char* _arg)
2210 if (this->LabelFormat == NULL && _arg == NULL)
2215 if (this->LabelFormat && _arg && (!strcmp(this->LabelFormat,_arg)))
2220 if (this->LabelFormat)
2222 delete [] this->LabelFormat;
2227 this->LabelFormat = new char[strlen(_arg)+1];
2228 strcpy(this->LabelFormat,_arg);
2232 this->LabelFormat = NULL;
2235 this->XAxis->SetLabelFormat(this->LabelFormat);
2236 this->YAxis->SetLabelFormat(this->LabelFormat);
2241 //----------------------------------------------------------------------------
2242 void VISU_XYPlotActor::PrintAsCSV(ostream &os)
2244 vtkDataArray *scalars;
2246 vtkCollectionSimpleIterator dsit;
2248 int dsNum,component;
2249 for ( dsNum=0, this->InputList->InitTraversal(dsit);
2250 (ds = this->InputList->GetNextDataSet(dsit)); dsNum++ )
2252 vtkIdType numPts = ds->GetNumberOfPoints();
2253 scalars = ds->GetPointData()->GetScalars(this->SelectedInputScalars[dsNum]);
2254 component = this->SelectedInputScalarsComponent->GetValue(dsNum);
2255 for ( vtkIdType ptId=0; ptId < numPts; ptId++ )
2257 s = scalars->GetComponent(ptId, component);