17 #include "vtkCamera.h"
19 #include "vtkCollection.h"
20 #include "vtkCollectionIterator.h"
21 #include "vtkCommand.h"
23 #include "vtkLightCollection.h"
24 #include "vtkObjectFactory.h"
25 #include "vtkRenderWindow.h"
26 #include "vtkRenderWindowInteractor.h"
27 #include "vtkRenderer.h"
63 this->
OnButtonDown(1, this->Interactor->GetShiftKey(), this->Interactor->GetControlKey());
69 this->
OnButtonDown(2, this->Interactor->GetShiftKey(), this->Interactor->GetControlKey());
75 this->
OnButtonDown(3, this->Interactor->GetShiftKey(), this->Interactor->GetControlKey());
88 this->FindPokedRenderer(
89 this->Interactor->GetEventPosition()[0], this->Interactor->GetEventPosition()[1]);
90 if (this->CurrentRenderer ==
NULL)
100 this->InvokeEvent(vtkCommand::StartInteractionEvent);
105 this->Interactor->GetEventPosition()[1], this->CurrentRenderer, this->Interactor);
117 if (manipulator->GetButton() == button && manipulator->GetShift() == shift &&
118 manipulator->GetControl() == control)
152 this->Interactor->GetEventPosition()[1], this->CurrentRenderer, this->Interactor);
154 this->InvokeEvent(vtkCommand::EndInteractionEvent);
170 this->FindPokedRenderer(
171 this->Interactor->GetEventPosition()[0], this->Interactor->GetEventPosition()[1]);
177 this->Interactor->GetEventPosition()[1], this->CurrentRenderer, this->Interactor);
178 this->InvokeEvent(vtkCommand::InteractionEvent);
185 vtkRenderWindowInteractor* rwi = this->Interactor;
187 switch (rwi->GetKeyCode())
202 if (!this->CurrentRenderer)
209 vtkLightCollection* lights = this->CurrentRenderer->GetLights();
210 vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
212 lights->InitTraversal();
213 light = lights->GetNextItem();
218 light->SetPosition(camera->GetPosition());
219 light->SetFocalPoint(camera->GetFocalPoint());
230 manipulator->
OnKeyDown(this->Interactor);
242 manipulator->
OnKeyUp(this->Interactor);
248 if (this->Interactor->GetControlKey())
251 fact, this->Interactor->GetEventPosition(), this->CurrentRenderer);
255 this->Superclass::Dolly(fact);
262 vtkCamera* cam = renderer->GetActiveCamera();
263 if (cam->GetParallelProjection())
265 int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
267 int* aSize = renderer->GetRenderWindow()->GetSize();
275 cam->SetParallelScale(cam->GetParallelScale() / fact);
281 double viewFocus[4], originalViewFocus[3], cameraPos[3], newCameraPos[3];
282 double newFocalPoint[4], norm[3];
285 cam->GetPosition(cameraPos);
286 cam->GetFocalPoint(viewFocus);
287 cam->GetFocalPoint(originalViewFocus);
288 cam->GetViewPlaneNormal(norm);
290 vtkPVInteractorStyle::ComputeWorldToDisplay(
291 renderer, viewFocus[0], viewFocus[1], viewFocus[2], viewFocus);
293 vtkPVInteractorStyle::ComputeDisplayToWorld(
294 renderer,
double(
position[0]),
double(
position[1]), viewFocus[2], newFocalPoint);
296 cam->SetFocalPoint(newFocalPoint);
302 cam->GetPosition(newCameraPos);
305 newPoint[0] = originalViewFocus[0] + newCameraPos[0] - cameraPos[0];
306 newPoint[1] = originalViewFocus[1] + newCameraPos[1] - cameraPos[1];
307 newPoint[2] = originalViewFocus[2] + newCameraPos[2] - cameraPos[2];
309 cam->SetFocalPoint(newPoint);
315 vtkRenderer* renderer,
int toX,
int toY,
int fromX,
int fromY)
317 vtkCamera* cam = renderer->GetActiveCamera();
318 double viewFocus[4], focalDepth, viewPoint[3];
319 double newPickPoint[4], oldPickPoint[4], motionVector[3];
320 cam->GetFocalPoint(viewFocus);
322 vtkPVInteractorStyle::ComputeWorldToDisplay(
323 renderer, viewFocus[0], viewFocus[1], viewFocus[2], viewFocus);
324 focalDepth = viewFocus[2];
326 vtkPVInteractorStyle::ComputeDisplayToWorld(
327 renderer,
double(toX),
double(toY), focalDepth, newPickPoint);
328 vtkPVInteractorStyle::ComputeDisplayToWorld(
329 renderer,
double(fromX),
double(fromY), focalDepth, oldPickPoint);
332 motionVector[0] = oldPickPoint[0] - newPickPoint[0];
333 motionVector[1] = oldPickPoint[1] - newPickPoint[1];
334 motionVector[2] = oldPickPoint[2] - newPickPoint[2];
336 cam->GetFocalPoint(viewFocus);
337 cam->GetPosition(viewPoint);
339 motionVector[0] + viewFocus[0], motionVector[1] + viewFocus[1], motionVector[2] + viewFocus[2]);
342 motionVector[0] + viewPoint[0], motionVector[1] + viewPoint[1], motionVector[2] + viewPoint[2]);
348 this->Superclass::PrintSelf(os, indent);
virtual void OnButtonUp(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren)
virtual void OnMouseMove(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren)
virtual void OnButtonDown(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren)
virtual void StartInteraction()
virtual void OnKeyDown(vtkRenderWindowInteractor *iren)
virtual void EndInteraction()
virtual void OnKeyUp(vtkRenderWindowInteractor *iren)
void RemoveAllManipulators()
void OnMiddleButtonUp() override
static void TranslateCamera(vtkRenderer *renderer, int toX, int toY, int fromX, int fromY)
void OnButtonDown(int button, int shift, int control)
void Dolly(double factor) override
~vtkPVInteractorStyle() override
void PrintSelf(ostream &os, vtkIndent indent) override
void OnLeftButtonUp() override
static void DollyToPosition(double fact, int *position, vtkRenderer *renderer)
virtual vtkCameraManipulator * FindManipulator(int button, int shift, int control)
void OnButtonUp(int button)
void OnMiddleButtonDown() override
vtkCameraManipulator * CurrentManipulator
void OnMouseMove() override
double CenterOfRotation[3]
void OnKeyDown() override
vtkCollection * CameraManipulators
void OnRightButtonUp() override
void AddManipulator(vtkCameraManipulator *m)
void OnLeftButtonDown() override
void OnRightButtonDown() override
QTextStream & endl(QTextStream &stream)
constexpr Rgbaf light(0.66f, 0.66f, 0.66f, 1.00f)
vtkStandardNewMacro(vtkPVInteractorStyle)