MCPcopy Create free account
hub / github.com/Kitware/VTK / PlaceAxes

Method PlaceAxes

Rendering/Annotation/vtkPieChartActor.cxx:361–625  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

359
360//------------------------------------------------------------------------------
361int vtkPieChartActor::PlaceAxes(vtkViewport* viewport, const int* vtkNotUsed(size))
362{
363 vtkIdType i, j;
364 vtkDataObject* input = this->GetInput();
365 vtkFieldData* field = input->GetFieldData();
366 double v = 0.0;
367
368 this->Initialize();
369
370 if (!field)
371 {
372 return 0;
373 }
374
375 // Retrieve the appropriate data array
376 vtkDataArray* da = field->GetArray(this->ArrayNumber);
377 if (!da)
378 {
379 return 0;
380 }
381
382 // Determine the number of independent variables
383 this->N = da->GetNumberOfTuples();
384 if (this->N <= 0 || this->N >= VTK_ID_MAX)
385 {
386 this->N = 0;
387 vtkErrorMacro(<< "No field data to plot");
388 return 0;
389 }
390
391 // We need to loop over the field to determine the total
392 this->Total = 0.0;
393 this->Fractions = new double[this->N];
394 for (i = 0; i < this->N; i++)
395 {
396 v = fabs(da->GetComponent(i, this->ComponentNumber));
397 this->Fractions[i] = v;
398 this->Total += v;
399 }
400 if (this->Total > 0.0)
401 {
402 double total = 0.0;
403 for (i = 0; i < this->N; i++)
404 {
405 total += this->Fractions[i];
406 this->Fractions[i] = total / this->Total;
407 }
408 }
409
410 // Get the location of the corners of the box
411 double* p1 = this->PositionCoordinate->GetComputedDoubleViewportValue(viewport);
412 double* p2 = this->Position2Coordinate->GetComputedDoubleViewportValue(viewport);
413 this->P1[0] = (p1[0] < p2[0] ? p1[0] : p2[0]);
414 this->P1[1] = (p1[1] < p2[1] ? p1[1] : p2[1]);
415 this->P2[0] = (p1[0] > p2[0] ? p1[0] : p2[0]);
416 this->P2[1] = (p1[1] > p2[1] ? p1[1] : p2[1]);
417 p1 = this->P1;
418 p2 = this->P2;

Callers 1

BuildPlotMethod · 0.95

Calls 15

GetInputMethod · 0.95
InitializeMethod · 0.95
GetPieceLabelMethod · 0.95
PiFunction · 0.85
AllocateEstimateMethod · 0.80
SetLinesMethod · 0.80
InsertCellPointMethod · 0.80
SetFontSizeMethod · 0.80
SetPolysMethod · 0.80
SetScalarsMethod · 0.80
GetEntryColorMethod · 0.80

Tested by

no test coverage detected