* Syntactic sugar to get the size of text instead of the entire bounding box.
virtual void GetSize(vtkViewport* vport, double size[2]);

所以通常的用法是,我们使用vtkTextActor对象,调用GetSize函数,给它传入一个renderer (vtkRenderer继承了vtkViewport),和一个数组或指针,最后得到的第二个参数就有width和height的信息。
width: size[0]
height: size[1]


QRect rect = MainWindow::g_Instance->Getui().qvtkWidget->geometry();
double size[2];
textActor->GetSize( MainWindow::g_Instance->GetRenderer(), size );
printf( "size: %lf, %lf\n", size[0], size[1] );
textActor->SetPosition( rect.width() / 2.0 - size[0] / 2.0, 10 + size[1] );

Categories: C plus plus

Leave a Reply

Your email address will not be published. Required fields are marked *