• VTK 标注类Widget 文字标注 vtkCaptionWidget


    目录

    Part1: 简介

    Part2: 效果

     Part3: example


    Part1: 简介

    vtkCaptionWidget:用一个带线框及箭头的文本信息来标注某一对象;

    可视化程序中,经常会对某个对象做一些标注说明;

    如,在医学图像诊断中,常常会手动标注出被诊断为肿瘤的区域或者其他病变区域,并用文字进行标注。

    Part2: 效果

    vtkCaptionWidget 如下表所示

     也可以给它加个中心点

     Part3: example

    1. #include "vtkSmartPointer.h"
    2. #include "vtkObjectFactory.h"
    3. #include "vtkRenderWindow.h"
    4. #include "vtkGenericRenderWindowInteractor.h"
    5. #include "vtkRenderer.h"
    6. #include "vtkActor.h"
    7. #include "vtkDICOMImageReader.h"
    8. #include "vtkImageViewer2.h"
    9. #include "vtkInteractorStyleImage.h"
    10. /
    11. #include
    12. #include
    13. #include
    14. #include
    15. #include
    16. #include
    17. #include
    18. #include
    19. #include
    20. #include
    21. #include
    22. #include
    23. #include
    24. #include
    25. #include
    26. #include
    27. #include
    28. #include ///
    29. #include
    30. #include
    31. #include
    32. #include
    33. #include
    34. int main(int argc, char* argv[])
    35. {
    36. auto reader = vtkSmartPointer::New();
    37. reader->SetDirectoryName("D:/dicom");
    38. reader->Update();
    39. auto imageViewer = vtkSmartPointer::New();
    40. imageViewer->SetInputConnection(reader->GetOutputPort());
    41. auto interactor = vtkSmartPointer::New();
    42. interactor->SetRenderWindow(imageViewer->GetRenderWindow());
    43. imageViewer->SetupInteractor(interactor);
    44. imageViewer->SetSize(400, 400);
    45. imageViewer->SetColorLevel(211);
    46. imageViewer->SetColorWindow(2470);
    47. imageViewer->SetSliceOrientationToXY();
    48. imageViewer->GetRenderer()->SetBackground(0, 0, 0);
    49. vtkSmartPointer captionWidget =
    50. vtkSmartPointer::New();
    51. captionWidget->SetInteractor(interactor);
    52. captionWidget->GetCaptionActor2D();
    53. vtkSmartPointer captionRepresentation =
    54. vtkSmartPointer::New();
    55. captionRepresentation->GetCaptionActor2D()->SetCaption("VTK Caption Test");
    56. captionRepresentation->SetHandleSize(20);
    57. //captionRepresentation->GetCaptionActor2D()->SetBorder(false);
    58. captionRepresentation->GetCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(1, 0, 0);
    59. captionRepresentation->GetCaptionActor2D()->GetTextActor()->GetTextProperty()->SetVerticalJustificationToCentered();
    60. double pos[3] = { 100,100, 10};
    61. captionRepresentation->SetAnchorPosition(pos);
    62. //captionWidget->SetCaptionActor2D(captionRepresentation->GetCaptionActor2D());
    63. captionWidget->SetRepresentation(captionRepresentation);
    64. captionWidget->On();
    65. imageViewer->Render();
    66. imageViewer->GetRenderer()->ResetCamera();
    67. imageViewer->Render();
    68. //memcpy(style->bound, captionWidget->GetRepresentation()->GetBounds(), sizeof(double) * 6);
    69. interactor->Start();
    70. return EXIT_SUCCESS;
    71. }

  • 相关阅读:
    squid代理服务器
    Linux SSH连接远程服务器(免密登录、scp和sftp传输文件)
    Python | Leetcode Python题解之第50题Pow(x,n)
    Vue——vue-particles粒子背景
    spring-创建Webservice服务
    C/C++新手看过来----新手问题汇总分析
    Python教程:迭代器的正确使用方法
    [附源码]计算机毕业设计JAVA校园新闻管理系统
    性能优化:JIT即时编译与AOT提前编译
    Doris启停脚本
  • 原文地址:https://blog.csdn.net/q610098308/article/details/133904711