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

Method SetCameraShaderParameters

Rendering/OpenGL2/vtkOpenGLPolyDataMapper2D.cxx:434–516  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

432
433//------------------------------------------------------------------------------
434void vtkOpenGLPolyDataMapper2D::SetCameraShaderParameters(
435 vtkOpenGLHelper& cellBO, vtkViewport* viewport, vtkActor2D* actor)
436{
437 vtkShaderProgram* program = cellBO.Program;
438
439 if (!program)
440 {
441 vtkErrorWithObjectMacro(this, " got null shader program, cannot set parameters.");
442 return;
443 }
444
445 // Get the position of the actor
446 int size[2];
447 size[0] = viewport->GetSize()[0];
448 size[1] = viewport->GetSize()[1];
449
450 double* vport = viewport->GetViewport();
451 int* actorPos = actor->GetPositionCoordinate()->GetComputedViewportValue(viewport);
452
453 // get window info
454 double* tileViewPort = viewport->GetVTKWindow()->GetTileViewport();
455 double visVP[4];
456 visVP[0] = (vport[0] >= tileViewPort[0]) ? vport[0] : tileViewPort[0];
457 visVP[1] = (vport[1] >= tileViewPort[1]) ? vport[1] : tileViewPort[1];
458 visVP[2] = (vport[2] <= tileViewPort[2]) ? vport[2] : tileViewPort[2];
459 visVP[3] = (vport[3] <= tileViewPort[3]) ? vport[3] : tileViewPort[3];
460 if (visVP[0] >= visVP[2])
461 {
462 return;
463 }
464 if (visVP[1] >= visVP[3])
465 {
466 return;
467 }
468 size[0] = static_cast<int>(std::round(size[0] * (visVP[2] - visVP[0]) / (vport[2] - vport[0])));
469 size[1] = static_cast<int>(std::round(size[1] * (visVP[3] - visVP[1]) / (vport[3] - vport[1])));
470
471 const int* winSize = viewport->GetVTKWindow()->GetSize();
472
473 int xoff = static_cast<int>(actorPos[0] - (visVP[0] - vport[0]) * winSize[0]);
474 int yoff = static_cast<int>(actorPos[1] - (visVP[1] - vport[1]) * winSize[1]);
475
476 // set ortho projection
477 float left = -xoff;
478 float right = -xoff + size[0];
479 float bottom = -yoff;
480 float top = -yoff + size[1];
481
482 // it's an error to call glOrtho with
483 // either left==right or top==bottom
484 if (left == right)
485 {
486 right = left + 1.0;
487 }
488 if (bottom == top)
489 {
490 top = bottom + 1.0;
491 }

Callers 1

UpdateShadersMethod · 0.95

Calls 11

GetViewportMethod · 0.80
GetVTKWindowMethod · 0.80
DeleteMethod · 0.65
roundFunction · 0.50
NewFunction · 0.50
GetSizeMethod · 0.45
SetElementMethod · 0.45
GetPropertyMethod · 0.45
TransposeMethod · 0.45
SetUniformMatrixMethod · 0.45

Tested by

no test coverage detected