1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <QtWidgets/QApplication> #include <vtkRenderer.h> #include <vtkRenderWindowInteractor.h> #include <vtkRenderWindow.h> #include <vtkSmartPointer.h> #include <vtkProperty.h> #include <vtkCubeAxesActor2D.h> #include <vtkInteractorStyleTrackballCamera.h> #include <vtkCubeAxesActor.h> #include "vtkAutoInit.h" VTK_MODULE_INIT(vtkRenderingOpenGL2); VTK_MODULE_INIT(vtkInteractionStyle); VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2); VTK_MODULE_INIT(vtkRenderingFreeType); int main(int, char* []) { vtkSmartPointer<vtkRenderer> render = vtkSmartPointer<vtkRenderer>::New(); vtkSmartPointer<vtkCubeAxesActor> cubeAxesActor = vtkSmartPointer<vtkCubeAxesActor>::New(); cubeAxesActor->SetCamera(render->GetActiveCamera()); cubeAxesActor->SetXAxisRange(0, 1000); cubeAxesActor->SetYAxisRange(0, 1000); cubeAxesActor->SetZAxisRange(0, 1000); cubeAxesActor->SetScreenSize(6); cubeAxesActor->DrawXGridlinesOn(); cubeAxesActor->DrawYGridlinesOn(); cubeAxesActor->DrawZGridlinesOn(); cubeAxesActor->SetGridLineLocation(2); cubeAxesActor->XAxisMinorTickVisibilityOff(); cubeAxesActor->YAxisMinorTickVisibilityOff(); cubeAxesActor->ZAxisMinorTickVisibilityOff(); render->AddActor(cubeAxesActor); render->ResetCamera(); render->ResetCameraClippingRange(); vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New(); renWin->AddRenderer(render); renWin->SetSize(600, 600); vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor> ::New(); iren->SetRenderWindow(renWin); vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New(); iren->SetInteractorStyle(style); renWin->Render(); iren->Start(); return 0; } |