From b29d7193d03833109cfdda3ab576fe183efd8acf Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 18 Sep 2016 00:58:40 +0300 Subject: [PATCH] move gears along their axis with the mousewheel --- src/gear.cc | 5 +++++ src/gear.h | 1 + src/main.cc | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/src/gear.cc b/src/gear.cc index f6872cf..c916e76 100644 --- a/src/gear.cc +++ b/src/gear.cc @@ -48,6 +48,11 @@ void Gear::set_axis(const Vec3 &axis) xform_valid = false; } +const Vec3 &Gear::get_axis() const +{ + return axis; +} + void Gear::set_position(const Vec3 &pos) { this->pos = pos; diff --git a/src/gear.h b/src/gear.h index e8796e9..7f230e4 100644 --- a/src/gear.h +++ b/src/gear.h @@ -78,6 +78,7 @@ public: // of the gear, to achieve the required tooth pitch void set_teeth(int nt, float tooth_pitch); void set_axis(const Vec3 &axis); + const Vec3 &get_axis() const; void set_position(const Vec3 &pos); const Vec3 &get_position() const; Vec3 get_global_position() const; // taking parent gear into account diff --git a/src/main.cc b/src/main.cc index f98f190..ce8466e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -215,6 +215,14 @@ static void mouse(int bn, int st, int x, int y) sel_gear = 0; } } + + if(bidx == 3 || bidx == 4) { /* wheel */ + if(hover_gear) { + float dz = bidx == 4 ? 1 : -1; + hover_gear->set_position(hover_gear->get_position() + hover_gear->get_axis() * dz); + machine->invalidate_meshing(); + } + } } static void motion(int x, int y) -- 1.7.10.4