------------------------------------------------------------------------------
| 359 | |
| 360 | //------------------------------------------------------------------------------ |
| 361 | int 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; |
no test coverage detected