| 686 | } |
| 687 | |
| 688 | int vtkLabeledTreeMapDataMapper::AnalyseLabel( |
| 689 | char* string, int level, float* blimitsDC, float* textPosWC, vtkTextProperty** tprop) |
| 690 | { |
| 691 | float sizes[2], tPosDC[2], delta, flimits[4]; |
| 692 | int fsize, trueLevel, oDir; // oDir is the text orientation |
| 693 | // Calculate the size of the box in DC |
| 694 | sizes[0] = blimitsDC[1] - blimitsDC[0]; |
| 695 | sizes[1] = blimitsDC[3] - blimitsDC[2]; |
| 696 | trueLevel = level - this->StartLevel; |
| 697 | if (trueLevel < 0) |
| 698 | { |
| 699 | vtkErrorMacro(<< "Invalid level."); |
| 700 | trueLevel = 0; |
| 701 | } |
| 702 | trueLevel = (trueLevel > this->MaxFontLevel) ? this->MaxFontLevel : trueLevel; |
| 703 | fsize = this->GetStringSize(string, trueLevel); |
| 704 | |
| 705 | // Horizontal label. |
| 706 | // (Vertical labels don't work due to issues with vtkTextActor.) |
| 707 | oDir = 0; |
| 708 | *tprop = this->HLabelProperties[trueLevel]; |
| 709 | |
| 710 | // Is this level dynamic or static? |
| 711 | if (level >= this->DynamicLevel) |
| 712 | { |
| 713 | |
| 714 | // See if the text will not even fit in the box |
| 715 | if (sizes[!oDir] < this->FontHeights[trueLevel]) |
| 716 | { |
| 717 | // Text will not fit |
| 718 | return 1; |
| 719 | } |
| 720 | |
| 721 | if (sizes[oDir] < fsize) |
| 722 | { |
| 723 | // Text will not fit |
| 724 | return 1; |
| 725 | } |
| 726 | } |
| 727 | // Calculate the bounding box of the text |
| 728 | // Determine where to place the text |
| 729 | tPosDC[0] = 0.5 * (blimitsDC[0] + blimitsDC[1]); |
| 730 | tPosDC[1] = 0.5 * (blimitsDC[2] + blimitsDC[3]); |
| 731 | // Compute mask for this level |
| 732 | delta = 0.5 * 1.05 * (!oDir ? fsize : this->FontHeights[trueLevel]); |
| 733 | flimits[0] = tPosDC[0] - delta; |
| 734 | flimits[1] = tPosDC[0] + delta; |
| 735 | delta = 0.5 * 1.05 * (oDir ? fsize : this->FontHeights[trueLevel]); |
| 736 | flimits[2] = tPosDC[1] - delta; |
| 737 | flimits[3] = tPosDC[1] + delta; |
| 738 | |
| 739 | // If the label is not to be centered based on the clipped form of the |
| 740 | // vertex's box see if it has been clipped away |
| 741 | if (!this->ClipTextMode) |
| 742 | { |
| 743 | // The 'flimits' variable contains the bounding box of the label |
| 744 | // in coordinates relative to (0, 0) in the window -- that is, the |
| 745 | // lower left corner of the window. These next few lines test to |
no test coverage detected