From 95153f03dc48b8d5d3150b272d563af5dd939512 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 13 Feb 2006 13:15:52 +0000 Subject: [PATCH] Added Scale and Translate methods. Added many drawing hints and raised the default num. of steps when drawing circles. Added MouseDown without coords (for remembering changes of keys modifiers) Added ZMode to the default modes under Alt+left Added DrawPostApply (to be completed) --- wrap/gui/trackball.cpp | 60 +++++++++++++++++++++++++++++++++++++----- wrap/gui/trackball.h | 30 ++++++++++++++++++--- 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/wrap/gui/trackball.cpp b/wrap/gui/trackball.cpp index 372fa2f4..5aac85da 100644 --- a/wrap/gui/trackball.cpp +++ b/wrap/gui/trackball.cpp @@ -24,6 +24,10 @@ History $Log: not supported by cvs2svn $ +Revision 1.14 2005/10/17 01:29:46 cignoni +Main restructuring. Removed the Draw function and slightly changed the meaning of the trackball itself. +See the notes at the beginning of trackball.h + Revision 1.13 2005/04/17 17:48:24 ganovelli modes deallocation commented (quick and dirty solution..to debug) @@ -87,6 +91,7 @@ Trackball::Trackball(): current_button(0), current_mode(NULL), modes[BUTTON_LEFT] = new SphereMode(); modes[BUTTON_LEFT | KEY_CTRL] = new PlaneMode(Plane3f(0, Point3f(1, 0, 0))); modes[BUTTON_LEFT | KEY_SHIFT] = new ScaleMode(); + modes[BUTTON_LEFT | KEY_ALT ] = new ZMode(); modes[WHEEL] = new ScaleMode(); SetCurrentAction(); } @@ -109,10 +114,30 @@ void Trackball::GetView() { camera.GetView(); } +void Trackball::DrawPostApply() { + glPushMatrix(); + + glTranslate(center); + glMultMatrix(track.InverseMatrix()); + Matrix44f r; + track.rot.ToMatrix(r); + glMultMatrix(r); + DrawIcon(); + + glTranslate(-center); +glMultMatrix(track.Matrix()); +} + void Trackball::Apply(bool ToDraw) { glTranslate(center); if(ToDraw) { + if(DH.DrawTrack) { + glBegin(GL_LINE_STRIP); + for(vector::iterator vi=Hits.begin();vi!=Hits.end();++vi) + glVertex(*vi); + glEnd(); + } glPushMatrix(); Matrix44f r; track.rot.ToMatrix(r); @@ -130,13 +155,25 @@ void Trackball::ApplyInverse() { glTranslate(-center); } +void Trackball::Scale(const float s) +{ + track.sca*=s; +} + +void Trackball::Translate(Point3f tr) +{ + Matrix44f m; + track.rot.ToMatrix(m); + track.tra = last_track.tra + Inverse(m)*tr/track.sca;; +} + /***************************************************************/ void Trackball::DrawCircle() { int nside=DH.CircleStep; const double pi2=3.14159265*2.0; - glBegin(GL_LINE_STRIP); - for(double i=0;i<=nside;i++){ + glBegin(GL_LINE_LOOP); + for(double i=0;i +#include #include #include #include @@ -126,9 +134,20 @@ namespace vcg { class DrawingHint { public: - DrawingHint() { CircleStep=32; } + DrawingHint() { + CircleStep=64; + HideStill=false; + DrawTrack=false; + LineWidthStill=0.5f; + LineWidthMoving=1.5f; + color=Color4b::LightBlue; + } int CircleStep; + bool HideStill,DrawTrack; + Color4b color; + float LineWidthStill; + float LineWidthMoving; }; @@ -151,20 +170,25 @@ namespace vcg { void SetPosition(const Point3f &c, int millisec = 0); void SetScale(const float s) {radius=s;}; void SetTransform(const Transform &transform, int miilisec = 0); + void Translate(Point3f tr); + void Scale(const float f); + //operating void GetView();\ void Apply(bool Draw=true); + void DrawPostApply(); void ApplyInverse(); void DrawIcon(); void Reset(); - + // Internal Drawing stuff void DrawCircle (); void DrawPlane(); void DrawPlaneHandle(); //interface + void MouseDown(/*Button*/ int button); void MouseDown(int x, int y, /*Button*/ int button); void MouseMove(int x, int y); void MouseUp(int x, int y, /*Button */ int button);