00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __MANIPULATOR_EVENTS_DOT_H
00020 #define __MANIPULATOR_EVENTS_DOT_H
00021
00022 #include "ManipEventBase.h"
00023 #include "Manip.h"
00024
00025 namespace gutz {
00026
00027 typedef ManipEventBase<Manip> ManipEvent;
00028 typedef gutz::SmartPtr< ManipEvent > ManipEventSP;
00029
00030
00031
00032
00033
00034 class RotateManipEvent : public ManipEventBase<Manip> {
00035 public:
00036 RotateManipEvent(float speed = 1.0f)
00037 : ManipEventBase<Manip>(speed), _tumbquat(quatf_id) {}
00038 RotateManipEvent(const RotateManipEvent &mre)
00039 : ManipEventBase<Manip>(mre), _tumbquat(mre._tumbquat)
00040 {}
00041 virtual ~RotateManipEvent() {}
00042
00043 RotateManipEvent &operator=(const RotateManipEvent &mre)
00044 { ManipEventBase<Manip>::operator =(mre); return *this;
00045 _tumbquat = mre._tumbquat;
00046 }
00047
00048 virtual ManipEventBase<Manip> *clone() const { return new RotateManipEvent(*this); }
00049
00050
00051
00052
00053
00054 bool startEvent(Manip *m, const MouseEvent &me);
00055
00056 bool handleEvent(Manip *m, const MouseMoveEvent &mme);
00057
00058 void endEvent(Manip *m, const MouseEvent &me);
00059
00060 bool tumble(Manip *m);
00061
00062
00063 protected:
00064 float _rad;
00065 quatf _tumbquat;
00066 };
00067
00068
00069
00070
00071
00072
00073
00074 class TransXYManipEvent : public ManipEventBase<Manip> {
00075 public:
00076 TransXYManipEvent(float speed = 1.0f)
00077 : ManipEventBase<Manip>(speed), _lastTrans(vec3f_zero)
00078 {}
00079 TransXYManipEvent(const TransXYManipEvent &tme)
00080 : ManipEventBase<Manip>(tme), _lastTrans(vec3f_zero)
00081 {}
00082 virtual ~TransXYManipEvent() {}
00083
00084 TransXYManipEvent &operator=(const TransXYManipEvent &tme)
00085 { ManipEventBase<Manip>::operator =(tme);
00086 _lastTrans = vec3f_zero;
00087 return *this;
00088 }
00089
00090
00091 virtual ManipEventBase<Manip> *clone() const { return new TransXYManipEvent(*this); }
00092
00093
00094
00095
00096
00097 bool startEvent(Manip *m, const MouseEvent &me);
00098
00099 bool handleEvent(Manip *m, const MouseMoveEvent &mme);
00100
00101 void endEvent(Manip *m, const MouseEvent &me);
00102
00103 bool tumble(Manip *m);
00104
00105
00106 protected:
00107
00108 vec3f getDelta(Manip *m, const MouseMoveEvent &mme) const;
00109
00110 vec3f _lastTrans;
00111 };
00112
00113
00114
00115
00116
00117
00118 class TransZManipEvent : public TransXYManipEvent {
00119 public:
00120 TransZManipEvent(float speed = 1.0f)
00121 : TransXYManipEvent(speed)
00122 {}
00123 TransZManipEvent(const TransZManipEvent &tme)
00124 : TransXYManipEvent(tme)
00125 {}
00126 virtual ~TransZManipEvent() {}
00127
00128 TransZManipEvent &operator=(const TransZManipEvent &tme)
00129 { TransXYManipEvent::operator =(tme);
00130 return *this;
00131 }
00132
00133 virtual ManipEventBase<Manip> *clone() const { return new TransZManipEvent(*this); }
00134
00135
00136
00137
00138 bool handleEvent(Manip *m, const MouseMoveEvent &mme);
00139
00140
00141 protected:
00142 };
00143
00144
00145
00146
00147
00148
00149
00150
00151 class TransPlaneManipEvent : public TransXYManipEvent {
00152 public:
00153 HAS_SLOTS;
00154
00155 TransPlaneManipEvent(gutz::vec3f ppos = vec3f_zero,
00156 gutz::vec3f pnorm = vec3f_z,
00157 float speed = 1.0f)
00158 : TransXYManipEvent(speed), _ppos(ppos), _pnorm(pnorm)
00159 {}
00160 TransPlaneManipEvent(const TransPlaneManipEvent &tpme)
00161 : TransXYManipEvent(tpme), _ppos(tpme._ppos), _pnorm(tpme._pnorm)
00162 {}
00163 virtual ~TransPlaneManipEvent() {}
00164
00165 TransPlaneManipEvent &operator=(const TransPlaneManipEvent &tpme)
00166 {
00167 TransXYManipEvent::operator =(tpme);
00168 _ppos = tpme._ppos;
00169 _pnorm = tpme._pnorm;
00170 }
00171
00172 virtual ManipEventBase<Manip> *clone() const { return new TransPlaneManipEvent(*this); }
00173
00174
00175
00176
00177
00178 void setPlane(const gutz::planef &pln)
00179 { _ppos = pln.p; _pnorm = pln.n; }
00180 void setPlanePos( const gutz::vec3f &ppos) { _ppos = ppos; }
00181 gutz::vec3f getPlanePos() const { return _ppos; }
00182 void setPlaneNorm( const gutz::vec3f &pnorm) { _pnorm = pnorm; }
00183 gutz::vec3f getPlaneNorm()const { return _pnorm; }
00184
00185
00186
00187
00188
00189 bool startEvent(Manip *m, const MouseEvent &me);
00190
00191 bool handleEvent(Manip *m, const MouseMoveEvent &mme);
00192
00193
00194 protected:
00195 gutz::vec3f _start;
00196 gutz::vec3f _ppos;
00197 gutz::vec3f _pnorm;
00198
00199 };
00200
00201
00202 }
00203
00204
00205 #endif
00206
00207