------------------------------------------------------------------------------
| 393 | |
| 394 | //------------------------------------------------------------------------------ |
| 395 | void vtkTextMapper::UpdateQuad(vtkActor2D* actor, int dpi) |
| 396 | { |
| 397 | vtkDebugMacro(<< "UpdateQuad called"); |
| 398 | |
| 399 | // Update texture coordinates: |
| 400 | if (this->Image->GetMTime() > this->TCoordsTime) |
| 401 | { |
| 402 | int dims[3]; |
| 403 | this->Image->GetDimensions(dims); |
| 404 | |
| 405 | // The coordinates are calculated to be centered on a texel and |
| 406 | // trim the padding from the image. (padding is often added to |
| 407 | // create textures that have power-of-two dimensions) |
| 408 | float tw = static_cast<float>(this->TextDims[0]); |
| 409 | float th = static_cast<float>(this->TextDims[1]); |
| 410 | float iw = static_cast<float>(dims[0]); |
| 411 | float ih = static_cast<float>(dims[1]); |
| 412 | float tcXMin = 0; |
| 413 | float tcYMin = 0; |
| 414 | float tcXMax = tw / iw; |
| 415 | float tcYMax = th / ih; |
| 416 | if (vtkFloatArray* tc = |
| 417 | vtkArrayDownCast<vtkFloatArray>(this->PolyData->GetPointData()->GetTCoords())) |
| 418 | { |
| 419 | vtkDebugMacro(<< "Setting tcoords: xmin, xmax, ymin, ymax: " << tcXMin << ", " << tcXMax |
| 420 | << ", " << tcYMin << ", " << tcYMax); |
| 421 | tc->Reset(); |
| 422 | tc->InsertNextValue(tcXMin); |
| 423 | tc->InsertNextValue(tcYMin); |
| 424 | |
| 425 | tc->InsertNextValue(tcXMin); |
| 426 | tc->InsertNextValue(tcYMax); |
| 427 | |
| 428 | tc->InsertNextValue(tcXMax); |
| 429 | tc->InsertNextValue(tcYMax); |
| 430 | |
| 431 | tc->InsertNextValue(tcXMax); |
| 432 | tc->InsertNextValue(tcYMin); |
| 433 | tc->Modified(); |
| 434 | |
| 435 | this->TCoordsTime.Modified(); |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | vtkErrorMacro(<< "Invalid texture coordinate array type."); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | if (this->CoordsTime < actor->GetMTime() || this->CoordsTime < this->TextProperty->GetMTime() || |
| 444 | this->CoordsTime < this->TCoordsTime) |
| 445 | { |
| 446 | int text_bbox[4]; |
| 447 | vtkTextRenderer* tren = vtkTextRenderer::GetInstance(); |
| 448 | if (tren) |
| 449 | { |
| 450 | if (!tren->GetBoundingBox( |
| 451 | this->TextProperty, this->Input ? this->Input : std::string(), text_bbox, dpi)) |
| 452 | { |
no test coverage detected