Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TrackballTransControl.cpp
1 #include "TrackballTransControl.hh"
2 
3 using namespace BIAS;
4 using namespace BIAS;
5 
6 using namespace std;
7 
9 {
10  TransNode_ = NULL;
11 }
12 
14 {}
15 
16 bool TrackballTransControl::RightMouseMoved(int x1, int x2, int y1, int y2)
17 {
18  // Zoom out
19  if (y1 - y2 > 0)
20  {
21  MoveInViewingDirection(-Stepsize_);
22  }
23  // Zoom in
24  else if(y1 - y2 < 0)
25  {
26  MoveInViewingDirection(Stepsize_);
27  }
28  else
29  {
30  return false;
31  }
32  return true;
33 }
34 
36 {
37  Vector3<double> nodeC;
38  Vector3<double> direction;
39  Vector3<double> viewdir;
40 
41  GetViewDirection(controlledObject_,viewdir);
42  GetMoveinViewDirection(controlledObject_ ,stepSize,viewdir, direction);
43  Translate_(direction);
44 }
45 
47 {
48  if(TransNode_!=NULL)
49  {
50  TransNode_->AddTranslation(v);
51  }
52 }
53 
55  double rotationagle)
56 {
57  // BIASASSERT(TransNode_);
58 
59  if(TransNode_!=NULL)
60  {
61  TransNode_->Rotate(axis,rotationagle);
62  }
63 }
64 
65 bool TrackballTransControl::LeftMouseMoved(int x1, int x2, int y1, int y2)
66 {
67 
69  double angleRAD;
70  if(!GetRotationAxisAndAngle(controlledObject_,
71  x1, x2, y1, y2,
72  axis,angleRAD))
73  {
74  return(false);
75  }
76  Rotate(axis, angleRAD);
77  return true;
78 }
79 
80 // rotateaorundpot in trabckballcontrol
82 {
83  Rotate_(axis,angleRAD);
84 }
85 
86 //would be set point of interest... but poi is not needed here...
87 //so use it for scaling...
89 {
90  //TODO scaling...
91  return(false);
92 }
93 
95  LeftAndRightMouseMoved(int x1, int x2, int y1, int y2)
96 {
97  Vector3<double> viewdir;
98  GetViewDirection(controlledObject_,viewdir);
99  double rotationAngleRAD =
100  GetRotationAngle(controlledObject_,x1, x2, y1, y2, viewdir);
101  RotateAroundViewingDirection(rotationAngleRAD);
102  return(false);
103 }
104 
106 {
107  MoveInViewingDirection(stepsize);
108  return (true);
109 }
110 
111 bool TrackballTransControl::MiddleMouseMoved(int x1, int x2, int y1, int y2)
112 {
113  Vector3<double> direction(0,0,0), up(0,1,0), C,viewdir;
114  controlledObject_->GetExtrinsics(C, up);
115  GetViewDirection(controlledObject_,viewdir);
116  GetTranslation(controlledObject_,x1, x2, y1, y2,viewdir,direction);
117  direction *=-1.0;
118  Translate_(direction);
119  return(true);
120 }
121 
123  RotateAroundViewingDirection(double rotationAngleRAD)
124 {
125  Vector3<double> viewdir;
126  GetViewDirection(controlledObject_,viewdir);
127  Rotate(viewdir, rotationAngleRAD);
128 }
129 
130 
131 
132 
133 
134 
void RotateAroundViewingDirection(double rotationAngleRAD)
bool LeftMouseMoved(int x1, int x2, int y1, int y2)
Rotates the tranformed object.
bool RightMouseMoved(int x1, int x2, int y1, int y2)
react to mouse movement while right button held down overwrite in derived class of desired ...
bool LeftMouseDoubleClicked(int x, int y)
should set point of interesr but is not supported by
void MoveInViewingDirection(double stepSize)
bool LeftAndRightMouseMoved(int x1, int x2, int y1, int y2)
rotate around viewing direction
void Rotate_(BIAS::Vector3< double > &axis, double rotationagle)
void Translate_(BIAS::Vector3< double > &v)
bool MouseWheelUsed(double stepsize)
Handles Mouse Wheel events and zooms in or out.
bool MiddleMouseMoved(int x1, int x2, int y1, int y2)
Moves the transform node left/right/up/down.
void Rotate(BIAS::Vector3< double > axis, double angleRAD)