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

Method PlaceWidgetExtended

Rendering/VR/vtkVRPanelRepresentation.cxx:444–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444void vtkVRPanelRepresentation::PlaceWidgetExtended(
445 const double* bds, const double* normal, const double* upvec, double scale)
446{
447 this->TextActor->GetUserMatrix()->Identity();
448 this->TextActor->SetOrientation(0, 0, 0);
449 this->LastScale = scale;
450
451 // grab the bounding box of the text
452 // so we can position and scale to that
453 int tbounds[4];
454 this->TextActor->GetBoundingBox(tbounds);
455 int maxdim = tbounds[1] - tbounds[0];
456 maxdim = std::max(tbounds[3] - tbounds[2], maxdim);
457 // should always be at least 50 pixels
458 // for any reasonable string.
459 maxdim = maxdim > 50 ? maxdim : 50.0;
460
461 // make the normal ortho to upvec
462 vtkVector3d nup(upvec);
463 nup.Normalize();
464 vtkVector3d nvpn(normal);
465 nvpn.Normalize();
466 vtkVector3d nvright = nup.Cross(nvpn);
467 nvright.Normalize();
468 nvpn = nvright.Cross(nup);
469
470 double basis[16];
471 basis[0] = nvright[0];
472 basis[4] = nvright[1];
473 basis[8] = nvright[2];
474 basis[12] = 0;
475 basis[1] = nup[0];
476 basis[5] = nup[1];
477 basis[9] = nup[2];
478 basis[13] = 0;
479 basis[2] = nvpn[0];
480 basis[6] = nvpn[1];
481 basis[10] = nvpn[2];
482 basis[14] = 0;
483 basis[3] = 0;
484 basis[7] = 0;
485 basis[11] = 0;
486 basis[15] = 1;
487
488 vtkNew<vtkTransform> basisT;
489 basisT->SetMatrix(basis);
490 this->TextActor->SetOrientation(basisT->GetOrientation());
491
492 if (this->CoordinateSystem == World)
493 {
494 // center the planel and default size to 400cm
495 this->TextActor->SetScale(0.4 * scale / maxdim, 0.4 * scale / maxdim, 0.4 * scale / maxdim);
496 this->TextActor->SetPosition(
497 0.5 * (bds[0] + bds[1]), 0.5 * (bds[2] + bds[3]), 0.5 * (bds[4] + bds[5]));
498 }
499
500 if (this->CoordinateSystem == LeftController || this->CoordinateSystem == RightController)
501 {

Callers

nothing calls this directly

Calls 11

GetUserMatrixMethod · 0.80
maxFunction · 0.50
IdentityMethod · 0.45
SetOrientationMethod · 0.45
GetBoundingBoxMethod · 0.45
NormalizeMethod · 0.45
CrossMethod · 0.45
SetMatrixMethod · 0.45
GetOrientationMethod · 0.45
SetScaleMethod · 0.45
SetPositionMethod · 0.45

Tested by

no test coverage detected