X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fmanipulator.cpp;h=e690c1d43aa34bf242361a0e485d49117a4b4574;hb=02c9a9779954d993cb73fe5f7a72b0847e87f633;hp=f4e75e7f40d2a512c24549af65b65f085e9f7a59;hpb=f42183985c65e1e12f19e9246dee90b8e7e44a34;p=r2c2.git diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index f4e75e7..e690c1d 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -19,23 +19,14 @@ using namespace std; using namespace Marklin; using namespace Msp; -Manipulator::Manipulator(Designer &d): +Manipulator::Manipulator(Designer &d, Selection &s): designer(d), - selection(0), + selection(s), wrap_rot(0), mode(NONE), angle(0) -{ } - -void Manipulator::set_selection(Selection *s) { - selection_changed_conn.disconnect(); - - selection = s; - if(selection) - selection_changed_conn = selection->signal_changed.connect(sigc::mem_fun(this, &Manipulator::selection_changed)); - - selection_changed(); + selection.signal_changed.connect(sigc::mem_fun(this, &Manipulator::selection_changed)); } void Manipulator::start_move() @@ -81,10 +72,10 @@ void Manipulator::duplicate() new_tracks.push_back(track); } - selection->clear(); + selection.clear(); for(list::iterator i=new_tracks.begin(); i!=new_tracks.end(); ++i) { - selection->add_track(*i); + selection.add_track(*i); for(list::iterator j=i; j!=new_tracks.end(); ++j) if(j!=i) (*i)->snap_to(**j, true); @@ -372,11 +363,8 @@ void Manipulator::selection_changed() cancel(); tracks.clear(); - if(selection) - { - const set &stracks = selection->get_tracks(); - tracks.insert(tracks.end(), stracks.begin(), stracks.end()); - } + const set &stracks = selection.get_tracks(); + tracks.insert(tracks.end(), stracks.begin(), stracks.end()); update_neighbors(); update_wrap(); @@ -387,6 +375,7 @@ void Manipulator::update_wrap() wrap.clear(); float min_x = 0, max_x = 0; float min_y = 0, max_y = 0; + float min_z = 0; for(vector::iterator i=tracks.begin(); i!=tracks.end(); ++i) { Track3D &t3d = designer.get_layout_3d()->get_track(*i->track); @@ -404,7 +393,7 @@ void Manipulator::update_wrap() float s = sin(a); float x = (minp.x+maxp.x)/2; float y = (minp.y+maxp.y)/2; - tw.pos = Point(c*x-s*y, s*x+c*y, (minp.z+maxp.z)/2); + tw.pos = Point(c*x-s*y, s*x+c*y, minp.z); tw.rot = a; tw.width = maxp.x-minp.x+0.01; tw.height = maxp.y-minp.y+0.01; @@ -417,6 +406,7 @@ void Manipulator::update_wrap() { min_x = max_x = tw.pos.x; min_y = max_y = tw.pos.y; + min_z = tw.pos.z; } else { @@ -424,22 +414,24 @@ void Manipulator::update_wrap() max_x = max(max_x, tw.pos.x); min_y = min(min_y, tw.pos.y); max_y = max(max_y, tw.pos.y); + min_z = min(min_z, tw.pos.z); } wrap.push_back(tw); } - center = Point((min_x+max_x)/2, (min_y+max_y)/2, 0); + center = Point((min_x+max_x)/2, (min_y+max_y)/2, min_z); wrap_pos = center; wrap_rot = 0; for(vector::iterator i=tracks.begin(); i!=tracks.end(); ++i) { const Point &tp = i->track->get_position(); - i->pos = Point(tp.x-center.x, tp.y-center.y, tp.z); + i->pos = Point(tp.x-center.x, tp.y-center.y, tp.z-center.z); } for(list::iterator i=wrap.begin(); i!=wrap.end(); ++i) { i->pos.x -= center.x; i->pos.y -= center.y; + i->pos.z -= center.z; } }