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

Method ComputeRectangle

Rendering/Core/vtkTextActor.cxx:749–845  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

747
748//------------------------------------------------------------------------------
749void vtkTextActor::ComputeRectangle(vtkViewport* viewport)
750{
751 int dims[2] = { 0, 0 };
752 int anchorOffset[2] = { 0, 0 };
753
754 this->RectanglePoints->Reset();
755 if (this->ImageData)
756 {
757 int p2dims[3];
758 this->ImageData->GetDimensions(p2dims);
759 int text_bbox[4];
760 if (!this->GetImageBoundingBox(this->ScaledTextProperty, viewport, text_bbox))
761 {
762 vtkErrorMacro("Cannot compute bounding box.");
763 return;
764 }
765 dims[0] = (text_bbox[1] - text_bbox[0] + 1);
766 dims[1] = (text_bbox[3] - text_bbox[2] + 1);
767 anchorOffset[0] = text_bbox[0];
768 anchorOffset[1] = text_bbox[2];
769
770 // compute TCoords.
771 vtkFloatArray* tc =
772 vtkArrayDownCast<vtkFloatArray>(this->Rectangle->GetPointData()->GetTCoords());
773 float tcXMax, tcYMax;
774 // Add a fudge factor to the texture coordinates to prevent the top
775 // row of pixels from being truncated on some systems.
776 tcXMax = std::min(1.0f, (dims[0] + 0.001f) / static_cast<float>(p2dims[0]));
777 tcYMax = std::min(1.0f, (dims[1] + 0.001f) / static_cast<float>(p2dims[1]));
778 tc->InsertComponent(0, 0, 0.0);
779 tc->InsertComponent(0, 1, 0.0);
780
781 tc->InsertComponent(1, 0, 0.0);
782 tc->InsertComponent(1, 1, tcYMax);
783
784 tc->InsertComponent(2, 0, tcXMax);
785 tc->InsertComponent(2, 1, tcYMax);
786
787 tc->InsertComponent(3, 0, tcXMax);
788 tc->InsertComponent(3, 1, 0.0);
789 tc->Modified();
790 }
791
792 double xo = 0.0, yo = 0.0;
793
794 // When TextScaleMode is PROP, we justify text based on the rectangle
795 // formed by Position & Position2 coordinates
796 if ((this->TextScaleMode == TEXT_SCALE_MODE_PROP) || this->UseBorderAlign)
797 {
798 double position1[3], position2[3];
799 this->PositionCoordinate->GetValue(position1);
800 this->Position2Coordinate->GetValue(position2);
801 this->SpecifiedToDisplay(position1, viewport, this->PositionCoordinate->GetCoordinateSystem());
802 this->SpecifiedToDisplay(position2, viewport, this->Position2Coordinate->GetCoordinateSystem());
803 double maxWidth = position2[0] - position1[0];
804 double maxHeight = position2[1] - position1[1];
805 switch (this->TextProperty->GetJustification())
806 {

Callers 1

UpdateRectangleMethod · 0.95

Calls 13

GetImageBoundingBoxMethod · 0.95
SpecifiedToDisplayMethod · 0.95
GetCoordinateSystemMethod · 0.80
minFunction · 0.50
ResetMethod · 0.45
GetDimensionsMethod · 0.45
GetTCoordsMethod · 0.45
GetPointDataMethod · 0.45
InsertComponentMethod · 0.45
ModifiedMethod · 0.45
GetValueMethod · 0.45
SetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected