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

Method DrawInteriorLines

Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx:1106–1175  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1104
1105//------------------------------------------------------------------------------
1106bool vtkMatplotlibMathTextUtilities::DrawInteriorLines(
1107 vtkImageData* image, int bbox[4], vtkTextProperty* tprop)
1108{
1109 if (!image)
1110 {
1111 vtkErrorMacro("Invalid image.");
1112 return false;
1113 }
1114
1115 // Define line offsets to take line width into account
1116 int extraLinesMin = 0;
1117 int extraLinesMax = 0;
1118 int width = tprop->GetInteriorLinesWidth();
1119 double* doubleColor = tprop->GetInteriorLinesColor();
1120 unsigned char color[3] = { static_cast<unsigned char>(doubleColor[0] * 255),
1121 static_cast<unsigned char>(doubleColor[1] * 255),
1122 static_cast<unsigned char>(doubleColor[2] * 255) };
1123
1124 // Draw horizontal lines
1125 for (std::size_t lineIdx = 0; lineIdx < this->HorizontalLinesPosition.size(); ++lineIdx)
1126 {
1127 // Clamp line width to remain in bounds
1128 extraLinesMin = ((this->HorizontalLinesPosition[lineIdx] - (width / 2)) >= 0)
1129 ? (-width / 2)
1130 : (-this->HorizontalLinesPosition[lineIdx]);
1131 extraLinesMax = ((this->HorizontalLinesPosition[lineIdx] + (width / 2)) <= (bbox[3] - bbox[2]))
1132 ? ((width + 1) / 2)
1133 : ((bbox[3] - bbox[2]) - this->HorizontalLinesPosition[lineIdx]);
1134
1135 for (int extraLineIdx = extraLinesMin; extraLineIdx < extraLinesMax; ++extraLineIdx)
1136 {
1137 for (int colIdx = bbox[0]; colIdx <= bbox[1]; ++colIdx)
1138 {
1139 unsigned char* ptr = static_cast<unsigned char*>(image->GetScalarPointer(
1140 colIdx, bbox[2] + this->HorizontalLinesPosition[lineIdx] + extraLineIdx, 0));
1141 ptr[0] = color[0];
1142 ptr[1] = color[1];
1143 ptr[2] = color[2];
1144 ptr[3] = 255;
1145 }
1146 }
1147 }
1148
1149 // Draw vertical lines
1150 for (std::size_t lineIdx = 0; lineIdx < this->VerticalLinesPosition.size(); ++lineIdx)
1151 {
1152 // Clamp line width to remain in bounds
1153 extraLinesMin = ((this->VerticalLinesPosition[lineIdx] - (width / 2)) >= 0)
1154 ? (-width / 2)
1155 : (-this->VerticalLinesPosition[lineIdx]);
1156 extraLinesMax = ((this->VerticalLinesPosition[lineIdx] + (width / 2)) <= (bbox[1] - bbox[0]))
1157 ? ((width + 1) / 2)
1158 : ((bbox[1] - bbox[0]) - this->VerticalLinesPosition[lineIdx]);
1159
1160 for (int extraLineIdx = extraLinesMin; extraLineIdx < extraLinesMax; ++extraLineIdx)
1161 {
1162 for (int rowIdx = bbox[2]; rowIdx <= bbox[3]; ++rowIdx)
1163 {

Callers 1

RenderStringMethod · 0.95

Calls 2

GetScalarPointerMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected