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

Method UpdateQuad

Rendering/Core/vtkTextMapper.cxx:395–478  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

393
394//------------------------------------------------------------------------------
395void 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 {

Callers 1

RenderOverlayMethod · 0.95

Calls 10

stringClass · 0.50
GetMTimeMethod · 0.45
GetDimensionsMethod · 0.45
GetTCoordsMethod · 0.45
GetPointDataMethod · 0.45
ResetMethod · 0.45
InsertNextValueMethod · 0.45
ModifiedMethod · 0.45
GetBoundingBoxMethod · 0.45
InsertNextPointMethod · 0.45

Tested by

no test coverage detected