2013-03-13 45 views
1

我正在使用vtkTexturedActor2D和vtkImageMapper顯示2D圖像。我可以使用在VTK窗口中居中圖像

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

將圖像放置在窗口的中心,但它不是中心對齊的。圖像的角落位於中心。我如何居中對齊圖像,使圖像的中心位於窗口的中心?

+0

難道你不知道你的形象的高度和寬度,所以你可以計算的,從而使中心集中放置角落? – drescherjm 2013-03-18 01:49:02

+0

您是否在渲染窗口更新之前嘗試了渲染器 - > ResetCamera()? – 2013-04-24 11:46:36

回答

1

我有這個相同的問題。

這似乎解決它:

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);