| 477 | } |
| 478 | |
| 479 | void vtkLabeledTreeMapDataMapper::LabelTree(vtkTree* tree, vtkFloatArray* boxInfo, |
| 480 | vtkDataArray* numericData, vtkStringArray* stringData, int activeComp, int numComps) |
| 481 | { |
| 482 | |
| 483 | float blimits[4], blimitsDC[4], textPosWC[3]; |
| 484 | char string[1024]; |
| 485 | int results; |
| 486 | vtkTextProperty* tprop = nullptr; |
| 487 | vtkIdType vertex, level, root = tree->GetRoot(); |
| 488 | if (root < 0) |
| 489 | { |
| 490 | vtkErrorMacro(<< "Input Tree does not have a root."); |
| 491 | return; |
| 492 | } |
| 493 | |
| 494 | this->NumberOfLabels = 0; |
| 495 | vtkTreeDFSIterator* dfs = vtkTreeDFSIterator::New(); |
| 496 | dfs->SetTree(tree); |
| 497 | while (dfs->HasNext()) |
| 498 | { |
| 499 | // Are we suppose to display this vertex? |
| 500 | vertex = dfs->Next(); |
| 501 | level = tree->GetLevel(vertex); |
| 502 | |
| 503 | if (level >= this->StartLevel && (this->EndLevel == -1 || level <= this->EndLevel)) |
| 504 | { |
| 505 | boxInfo->GetTypedTuple(vertex, blimits); // Get the extents of the vertex |
| 506 | if (this->ConvertToDC(blimits, blimitsDC)) |
| 507 | { |
| 508 | continue; |
| 509 | } |
| 510 | |
| 511 | this->GetVertexLabel( |
| 512 | vertex, numericData, stringData, activeComp, numComps, string, sizeof(string)); |
| 513 | results = this->AnalyseLabel(string, level, blimitsDC, textPosWC, &tprop); |
| 514 | if (results == 1) |
| 515 | { |
| 516 | // Label doesn't fit in its box - don't both processing children |
| 517 | continue; |
| 518 | } |
| 519 | } |
| 520 | else |
| 521 | { |
| 522 | // results == 2 from AnalyseLabel means that the label can't be |
| 523 | // displayed due to reasons other than size - well in this |
| 524 | // case we can't display due to the level limit we |
| 525 | // also have to deactivate the mask for this level |
| 526 | this->LabelMasks[level][0] = -1.0; |
| 527 | results = 2; |
| 528 | } |
| 529 | |
| 530 | if (!results) |
| 531 | { |
| 532 | if (!this->TextMappers[this->NumberOfLabels]) |
| 533 | { |
| 534 | this->TextMappers[this->NumberOfLabels] = vtkTextMapper::New(); |
| 535 | } |
| 536 | this->TextMappers[this->NumberOfLabels]->SetInput(string); |
no test coverage detected