很高兴在雪易的CSDN遇见你
前言
本文分享VTK中的光标设置相关内容技术,希望对各位小伙伴有所帮助!
感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!
你的点赞就是我的动力(^U^)ノ~YO
目录
前言
1. VTK中的光标样式
2. vtkCursor2D及其应用
3. vtkCursor3D及其应用
结论:
1. VTK中的光标样式
vtk中的光标样式在vtkRenderWindow中进行宏定义,见下面代码
#define VTK_CURSOR_DEFAULT 0
#define VTK_CURSOR_ARROW 1
#define VTK_CURSOR_SIZENE 2
#define VTK_CURSOR_SIZENW 3
#define VTK_CURSOR_SIZESW 4
#define VTK_CURSOR_SIZESE 5
#define VTK_CURSOR_SIZENS 6
#define VTK_CURSOR_SIZEWE 7
#define VTK_CURSOR_SIZEALL 8
#define VTK_CURSOR_HAND 9
#define VTK_CURSOR_CROSSHAIR 10
VTK_CURSOR_DEFAULT | N/A |
VTK_CURSOR_ARROW | |
VTK_CURSOR_SIZENE | |
VTK_CURSOR_SIZENW | |
VTK_CURSOR_SIZESW | |
VTK_CURSOR_SIZESE | |
VTK_CURSOR_SIZENS | |
VTK_CURSOR_SIZEWE | |
VTK_CURSOR_SIZEALL | |
VTK_CURSOR_HAND | |
VTK_CURSOR_CROSSHAIR |
主要应用在 vtkAbstractWidget及其子类中,使用方法如下:
this->RequestCursorShape(VTK_CURSOR_SIZEWE);
this->RequestCursorShape(VTK_CURSOR_HAND);
//其中RequestCursorShape在vtkInteractorObserver中定义
CursorShape设置实例Visualization/CursorShape
// Create a sphere
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->Update();
// Create a mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(sphereSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
// Create a renderer, render window, and interactor
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// Add the actor to the scene
renderer->AddActor(actor);
renderer->SetBackground(1,1,1); // Background color white
// Render and interact
renderWindow->Render();
//This must occur after the above Render() call or it does not work
renderWindow->SetCurrentCursor(VTK_CURSOR_HAND);
renderWindowInteractor->Start();
2. vtkCursor2D及其应用
vtkSmartPointer<vtkCursor2D> cursor =
vtkSmartPointer<vtkCursor2D>::New();
cursor->SetModelBounds(-10,10,-10,10,0,0);
cursor->AllOn();
cursor->SetFocalPoint (5.0, 5.0, 0.0);
cursor->OutlineOn();
cursor->Update();
vtkSmartPointer<vtkPolyDataMapper> cursorMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
cursorMapper->SetInputConnection(cursor->GetOutputPort());
vtkSmartPointer<vtkActor> cursorActor =
vtkSmartPointer<vtkActor>::New();
cursorActor->GetProperty()->SetColor(1,0,0);
cursorActor->SetMapper(cursorMapper);
renderer->AddActor(cursorActor);
3. vtkCursor3D及其应用
vtkSmartPointer<vtkCursor3D> cursor =
vtkSmartPointer<vtkCursor3D>::New();
cursor->SetModelBounds(-10,10,-10,10,-10,10);
cursor->AllOn();
cursor->OutlineOff();
cursor->Update();
vtkSmartPointer<vtkPolyDataMapper> cursorMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
cursorMapper->SetInputConnection(cursor->GetOutputPort());
vtkSmartPointer<vtkActor> cursorActor =
vtkSmartPointer<vtkActor>::New();
cursorActor->GetProperty()->SetColor(1,0,0);
cursorActor->SetMapper(cursorMapper);
renderer->AddActor(cursorActor);
结论:
感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!
你的赞赏是我的最最最最大的动力(^U^)ノ~YO