这篇文章中就要给我的四视图增加文字显示了,这个东西就是在我摄像机上面的,不会随着图像变化而变化,感觉这个是不是就是在3D中的那种HUD呢。
电梯
1 效果展示
2 vtkTextActor
3 实现代码
3.1 头文件
3.2 源文件实现
3.2.1 新建变量,赋值,设置属性
3.2.2 加入到渲染器中
☞ 源码
1 效果展示
如下图所示,在每个图的左上角和左下角有文字显示,左上角显示的病人的基本信息,左下角显示的是当前切面。
2 vtkTextActor
实现文字显示,主要将用到vtkTextActor,这里还是把参考链接附上
for (auto i=0;i<4;i++) { textActor[i] = vtkSmartPointer<vtkTextActor>::New(); textActor[i]->SetDisplayPosition(5, 5); textActor[i]->GetTextProperty()->SetFontSize(14); textActor[i]->GetTextProperty()->SetFontFamily(VTK_FONT_FILE); textActor[i]->GetTextProperty()->SetFontFile(QString("./Fonts/simhei.ttf").toUtf8()); } textActor[0]->SetInput(QString::fromUtf8("矢状").toUtf8()); textActor[0]->GetTextProperty()->SetColor(0, 1, 0); textActor[1]->SetInput(QString::fromUtf8("冠状").toUtf8()); textActor[1]->GetTextProperty()->SetColor(0, 0, 1); textActor[2]->SetInput(QString::fromUtf8("轴向").toUtf8()); textActor[2]->GetTextProperty()->SetColor(1, 0, 0); textActor[3]->SetInput(QString::fromUtf8("3D").toUtf8()); textActor[3]->GetTextProperty()->SetColor(1, 1, 0); for (auto i=0;i<4;i++) { peopleInforTextActor[i] = vtkSmartPointer<vtkTextActor>::New(); peopleInforTextActor[i]->GetTextProperty()->SetFontSize(14); peopleInforTextActor[i]->GetTextProperty()->SetFontFamily(VTK_FONT_FILE); peopleInforTextActor[i]->GetTextProperty()->SetFontFile(QString("./Fonts/simhei.ttf").toUtf8()); peopleInforTextActor[i]->SetInput(reader->GetPatientName()); } peopleInforTextActor[0]->GetTextProperty()->SetColor(0, 1, 0); peopleInforTextActor[0]->SetDisplayPosition(5,ui->widget_1->height()-20); peopleInforTextActor[1]->GetTextProperty()->SetColor(0, 0, 1); peopleInforTextActor[1]->SetDisplayPosition(5,ui->widget_2->height()-20); peopleInforTextActor[2]->GetTextProperty()->SetColor(1, 0, 0); peopleInforTextActor[2]->SetDisplayPosition(5,ui->widget_3->height()-20); peopleInforTextActor[3]->GetTextProperty()->SetColor(1, 1, 0); peopleInforTextActor[3]->SetDisplayPosition(5,ui->widget_4->height()-20);