ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkPVTrackballMoveActor.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkPVTrackballMoveActor.cxx
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
16 
18 #include "vtkMath.h"
19 #include "vtkObjectFactory.h"
20 #include "vtkRenderWindow.h"
21 #include "vtkRenderWindowInteractor.h"
22 #include "vtkRenderer.h"
23 
25 
26 //-------------------------------------------------------------------------
28 {
29 }
30 
31 //-------------------------------------------------------------------------
33 {
34 }
35 
36 //-------------------------------------------------------------------------
37 void vtkPVTrackballMoveActor::OnButtonDown(int, int, vtkRenderer*, vtkRenderWindowInteractor*)
38 {
39 }
40 
41 //-------------------------------------------------------------------------
42 void vtkPVTrackballMoveActor::OnButtonUp(int, int, vtkRenderer*, vtkRenderWindowInteractor*)
43 {
44 }
45 
46 //-------------------------------------------------------------------------
48  int x, int y, vtkRenderer* ren, vtkRenderWindowInteractor* rwi)
49 {
50  if (ren == NULL || !this->GetGUIHelper())
51  {
52  return;
53  }
54 
55  // These are different because y is flipped.
56 
57  double bounds[6];
58  // Get bounds
59  if (this->GetGUIHelper()->GetActiveSourceBounds(bounds))
60  {
61  double center[4];
62  double dpoint1[3];
63  double startpoint[4];
64  double endpoint[4];
65  int cc;
66 
67  // Calculate center of bounds.
68  for (cc = 0; cc < 3; cc++)
69  {
70  center[cc] = (bounds[cc * 2] + bounds[cc * 2 + 1]) / 2;
71  }
72  center[3] = 1;
73 
74  // Convert the center of bounds to display coordinate
75  ren->SetWorldPoint(center);
76  ren->WorldToDisplay();
77  ren->GetDisplayPoint(dpoint1);
78 
79  // Convert start point to world coordinate
80  ren->SetDisplayPoint(
81  rwi->GetLastEventPosition()[0], rwi->GetLastEventPosition()[1], dpoint1[2]);
82  ren->DisplayToWorld();
83  ren->GetWorldPoint(startpoint);
84 
85  // Convert end point to world coordinate
86  ren->SetDisplayPoint(x, y, dpoint1[2]);
87  ren->DisplayToWorld();
88  ren->GetWorldPoint(endpoint);
89 
90  for (cc = 0; cc < 3; cc++)
91  {
92  startpoint[cc] /= startpoint[3];
93  endpoint[cc] /= endpoint[3];
94  }
95 
96  double move[3];
97  if (this->GetGUIHelper()->GetActiveActorTranslate(move))
98  {
99  for (cc = 0; cc < 3; cc++)
100  {
101  move[cc] += endpoint[cc] - startpoint[cc];
102  }
103 
104  this->GetGUIHelper()->SetActiveActorTranslate(move);
105  }
106 
107  rwi->Render();
108  }
109 }
110 
111 //-------------------------------------------------------------------------
112 void vtkPVTrackballMoveActor::PrintSelf(ostream& os, vtkIndent indent)
113 {
114  this->Superclass::PrintSelf(os, indent);
115 }
#define NULL
void OnButtonUp(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren) override
void PrintSelf(ostream &os, vtkIndent indent) override
void OnMouseMove(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren) override
void OnButtonDown(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren) override
normal_z y
normal_z x
vtkStandardNewMacro(vtkPVTrackballMoveActor)