开发环境:
- Windows 11 家庭中文版
- Microsoft Visual Studio Community 2019
- VTK-9.3.0.rc0
- vtk-example
- 参考代码
- 目的:学习与总结
demo解决问题:renderWindow中创建一个夹角测量控件,通过三个点确定一个夹角
- 典型的控件类继承关系:vtkObject > vtkInteractorObsever > vtkAbstractWidget > vtkAngleWidget
- 交互对象设置:
angleWidget->SetInteractor(renderWindowInteractor);
- 控件使能:
renderWindowInteractor->Start();
之前angleWidget->On();
- vtkRenderWindow 与vtkRenderWindowInteractor详解
prj name: AngleWidget
#include <vtkAngleWidget.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
int main(int, char*[])
{
vtkNew<vtkNamedColors> colors;
// A renderer and render window
vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("AngleWidget");
// An interactor
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
vtkNew<vtkAngleWidget> angleWidget;
angleWidget->SetInteractor(renderWindowInteractor);
angleWidget->CreateDefaultRepresentation();
// Render
renderer->SetBackground(colors->GetColor3d("MidnightBlue").GetData());
renderWindow->Render();
renderWindowInteractor->Initialize();
renderWindow->Render();
angleWidget->On();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}