Centering image in VTK window

六眼飞鱼酱① 提交于 2020-01-05 03:35:29

问题


I'm using vtkTexturedActor2D and vtkImageMapper to display a 2D image. I can use

actor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay();
actor.this.Actor.SetPosition(0.5, 0.9);

to place the image in the center of the window, but it's not center-aligned. The corner of the image is placed in the center. How can I center-align the image so that the center of the image is at the center of the window?


回答1:


I had this same problem.

This seems to solve it:

  float height, width;
  this->d_actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
  this->d_actor->GetPositionCoordinate()->SetViewport(this); // Without this was getting weird results
  height = this->d_actor->GetHeight();
  width = this->d_actor->GetWidth();
  this->d_actor->GetPositionCoordinate()->SetValue(.5 - width/2.0, .5 - height/2.0);


来源:https://stackoverflow.com/questions/15394359/centering-image-in-vtk-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!