| 618 | } |
| 619 | |
| 620 | void vtkLabeledTreeMapDataMapper::SetFontSizeRange(int maxSize, int minSize, int delta) |
| 621 | { |
| 622 | if (maxSize < minSize) |
| 623 | { |
| 624 | vtkErrorMacro(<< "maxSize is smaller than minSize"); |
| 625 | return; |
| 626 | } |
| 627 | if (delta < 1) |
| 628 | { |
| 629 | vtkErrorMacro(<< "delta must be positive"); |
| 630 | return; |
| 631 | } |
| 632 | |
| 633 | int nLevels = (maxSize - minSize) / delta; |
| 634 | int i, s; |
| 635 | |
| 636 | if ((maxSize - (nLevels * delta)) > minSize) |
| 637 | { |
| 638 | ++nLevels; |
| 639 | } |
| 640 | |
| 641 | if (this->MaxFontLevel != nLevels) |
| 642 | { |
| 643 | if (this->MaxFontLevel) |
| 644 | { |
| 645 | delete[] this->FontHeights; |
| 646 | for (i = 0; i <= this->MaxFontLevel; i++) |
| 647 | { |
| 648 | delete[] this->FontWidths[i]; |
| 649 | this->HLabelProperties[i]->Delete(); |
| 650 | } |
| 651 | delete[] this->FontWidths; |
| 652 | delete[] this->HLabelProperties; |
| 653 | } |
| 654 | this->MaxFontLevel = nLevels; |
| 655 | this->FontHeights = new int[this->MaxFontLevel + 1]; |
| 656 | this->FontWidths = new int*[this->MaxFontLevel + 1]; |
| 657 | this->HLabelProperties = new vtkTextProperty*[this->MaxFontLevel + 1]; |
| 658 | for (i = 0; i <= this->MaxFontLevel; i++) |
| 659 | { |
| 660 | this->FontWidths[i] = new int[95]; |
| 661 | this->HLabelProperties[i] = vtkTextProperty::New(); |
| 662 | this->HLabelProperties[i]->SetFontSize(12); |
| 663 | this->HLabelProperties[i]->SetBold(1); |
| 664 | this->HLabelProperties[i]->SetItalic(1); |
| 665 | this->HLabelProperties[i]->SetShadow(1); |
| 666 | this->HLabelProperties[i]->SetFontFamilyToArial(); |
| 667 | this->HLabelProperties[i]->SetJustificationToCentered(); |
| 668 | this->HLabelProperties[i]->SetVerticalJustificationToCentered(); |
| 669 | this->HLabelProperties[i]->SetColor(1, 1, 1); |
| 670 | } |
| 671 | } |
| 672 | for (i = 0, s = maxSize; i < this->MaxFontLevel; i++, s -= delta) |
| 673 | { |
| 674 | this->HLabelProperties[i]->SetFontSize(s); |
| 675 | } |
| 676 | this->HLabelProperties[i]->SetFontSize(minSize); |
| 677 |
no test coverage detected