這篇文章中就要給我的四視圖增加文字顯示了,這個東西就是在我錄影機上面的,不會随着圖像變化而變化,感覺這個是不是就是在3D中的那種HUD呢。
電梯
1 效果展示
2 vtkTextActor
3 實作代碼
3.1 頭檔案
3.2 源檔案實作
3.2.1 建立變量,指派,設定屬性
3.2.2 加入到渲染器中
☞ 源碼
如下圖所示,在每個圖的左上角和左下角有文字顯示,左上角顯示的病人的基本資訊,左下角顯示的是目前切面。
實作文字顯示,主要将用到vtkTextActor,這裡還是把參考連結附上
https://vtk.org/doc/nightly/html/classvtkTextActor.html
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);