18#include <vtkAxesActor.h>
20#include <vtkCellPicker.h>
21#include <vtkCommand.h>
22#include <vtkGenericOpenGLRenderWindow.h>
23#include <vtkInteractorStyleRubberBandZoom.h>
24#include <vtkInteractorStyleSwitch.h>
27#include <vtkOrientationMarkerWidget.h>
28#include <vtkPNGWriter.h>
29#include <vtkRenderWindow.h>
30#include <vtkRenderWindowInteractor.h>
31#include <vtkRenderer.h>
32#include <vtkSmartPointer.h>
33#include <vtkWindowToImageFilter.h>
38#include <QInputDialog>
53 vtkNew<vtkRenderer> ren;
56 vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
57 vtkWidget->setRenderWindow(renderWindow);
58 vtkWidget->renderWindow()->AddRenderer(ren);
65 vtkSmartPointer<vtkCellPicker> picker =
66 vtkSmartPointer<vtkCellPicker>::New();
68 renderWindow->GetInteractor()->SetPicker(picker);
72 ren->SetBackground(0.0, 0.0, 0.0);
75 vtkSmartPointer<vtkAxesActor> axesActor =
76 vtkSmartPointer<vtkAxesActor>::New();
112 vtkWidget->renderWindow()->Render();
118 vtkCamera* cam =
_vtkRender->GetActiveCamera();
119 double* fp = cam->GetFocalPoint();
120 double* p = cam->GetPosition();
121 double dist = std::sqrt(vtkMath::Distance2BetweenPoints(p, fp));
122 cam->SetPosition(fp[0] + (x * dist), fp[1] + (y * dist),
125 if (x != 0 || y != 0)
127 cam->SetViewUp(0.0, 0.0, 1.0);
131 cam->SetViewUp(0.0, 1.0, 0.0);
153 vtkSmartPointer<vtkInteractorStyleRubberBandZoom>::New();
154 vtkWidget->renderWindow()->GetInteractor()->SetInteractorStyle(
157 cursor.setShape(Qt::CrossCursor);
158 vtkWidget->setCursor(cursor);
162 vtkWidget->renderWindow()->GetInteractor()->SetInteractorStyle(
165 cursor.setShape(Qt::ArrowCursor);
166 vtkWidget->setCursor(cursor);
178 _vtkRender->GetActiveCamera()->SetParallelProjection(checked);
185 QString filename = QFileDialog::getSaveFileName(
186 this, tr(
"Save screenshot"),
187 settings.value(
"lastScreenshotDir").toString(),
"PNG file (*.png)");
188 if (filename.count() > 4)
191 int magnification = QInputDialog::getInt(
192 this, tr(
"Screenshot magnification"),
193 tr(
"Enter a magnification factor for the resulting image."), 2, 1,
198 settings.setValue(
"lastScreenshotDir", dir.absolutePath());
206 vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
207 vtkSmartPointer<vtkWindowToImageFilter>::New();
208 windowToImageFilter->SetInput(vtkWidget->renderWindow());
211 windowToImageFilter->SetScale(magnification);
213 windowToImageFilter->SetInputBufferTypeToRGBA();
214 windowToImageFilter->Update();
216 vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
217 writer->SetFileName(filename.toStdString().c_str());
218 writer->SetInputData(windowToImageFilter->GetOutput());
226 this->setCursor(QCursor(shape));
Definition of the Point class.
Definition of the VtkCustomInteractorStyle class.
Definition of the VtkPickCallback class.
void setHighlightActor(bool on)
static VtkCustomInteractorStyle * New()
static VtkPickCallback * New()