------------------------------------------------------------------------------
| 281 | |
| 282 | //------------------------------------------------------------------------------ |
| 283 | void vtkOpenGLGL2PSHelperImpl::DrawString(const std::string& str, vtkTextProperty* tprop, |
| 284 | double pos[3], double backgroundDepth, vtkRenderer* ren) |
| 285 | { |
| 286 | if (str.empty()) |
| 287 | { |
| 288 | return; |
| 289 | } |
| 290 | |
| 291 | vtkTextRenderer* tren(vtkTextRenderer::GetInstance()); |
| 292 | if (tren == nullptr) |
| 293 | { |
| 294 | vtkErrorMacro("vtkTextRenderer unavailable."); |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | int dpi = this->RenderWindow->GetDPI(); |
| 299 | |
| 300 | // Draw the background if needed: |
| 301 | if (tprop->GetBackgroundOpacity() > 0.) |
| 302 | { |
| 303 | vtkTextRenderer::Metrics metrics; |
| 304 | if (tren->GetMetrics(tprop, str, metrics, dpi)) |
| 305 | { |
| 306 | double bgPos[3] = { pos[0], pos[1], backgroundDepth }; |
| 307 | |
| 308 | GL2PSvertex bgVerts[5]; |
| 309 | |
| 310 | double bgColor[4]; |
| 311 | tprop->GetBackgroundColor(bgColor); |
| 312 | bgColor[3] = tprop->GetBackgroundOpacity(); |
| 313 | std::copy(bgColor, bgColor + 4, bgVerts[0].rgba); |
| 314 | std::copy(bgColor, bgColor + 4, bgVerts[1].rgba); |
| 315 | std::copy(bgColor, bgColor + 4, bgVerts[2].rgba); |
| 316 | std::copy(bgColor, bgColor + 4, bgVerts[3].rgba); |
| 317 | std::copy(bgColor, bgColor + 4, bgVerts[4].rgba); |
| 318 | |
| 319 | bgVerts[0].xyz[0] = static_cast<float>(bgPos[0] + metrics.TopLeft[0]); |
| 320 | bgVerts[0].xyz[1] = static_cast<float>(bgPos[1] + metrics.TopLeft[1]); |
| 321 | bgVerts[0].xyz[2] = static_cast<float>(bgPos[2]); |
| 322 | bgVerts[1].xyz[0] = static_cast<float>(bgPos[0] + metrics.BottomLeft[0]); |
| 323 | bgVerts[1].xyz[1] = static_cast<float>(bgPos[1] + metrics.BottomLeft[1]); |
| 324 | bgVerts[1].xyz[2] = static_cast<float>(bgPos[2]); |
| 325 | bgVerts[2].xyz[0] = static_cast<float>(bgPos[0] + metrics.BottomRight[0]); |
| 326 | bgVerts[2].xyz[1] = static_cast<float>(bgPos[1] + metrics.BottomRight[1]); |
| 327 | bgVerts[2].xyz[2] = static_cast<float>(bgPos[2]); |
| 328 | bgVerts[3].xyz[0] = static_cast<float>(bgPos[0] + metrics.TopRight[0]); |
| 329 | bgVerts[3].xyz[1] = static_cast<float>(bgPos[1] + metrics.TopRight[1]); |
| 330 | bgVerts[3].xyz[2] = static_cast<float>(bgPos[2]); |
| 331 | bgVerts[4].xyz[0] = bgVerts[0].xyz[0]; |
| 332 | bgVerts[4].xyz[1] = bgVerts[0].xyz[1]; |
| 333 | bgVerts[4].xyz[2] = bgVerts[0].xyz[2]; |
| 334 | |
| 335 | gl2psAddPolyPrimitive(GL2PS_TRIANGLE, 3, bgVerts, 0, 0, 0, 0xffff, 0, 0, 0, 0, 0); |
| 336 | gl2psAddPolyPrimitive(GL2PS_TRIANGLE, 3, bgVerts + 2, 0, 0, 0, 0xffff, 0, 0, 0, 0, 0); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // Is this mathtext? |
nothing calls this directly
no test coverage detected