X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fmanipulator.cpp;h=dfcdd2cccbdc859a08c4cf6326aba090bf2e1696;hb=d27edb207810f0b4e44be8c3632d421faa5fed80;hp=09d32fd8bfdeb782aff9d514c449528a234b012d;hpb=e179208d1c8370f87ce6ec87f649e5e99eb5724f;p=r2c2.git diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 09d32fd..dfcdd2c 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -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() @@ -76,15 +67,14 @@ void Manipulator::duplicate() list new_tracks; for(vector::iterator i=tracks.begin(); i!=tracks.end(); ++i) { - Track *track = i->track->copy(); - designer.get_layout()->add_track(*track); + Track *track = new Track(*designer.get_layout(), i->track->get_type()); 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); @@ -364,19 +354,14 @@ void Manipulator::render() glPopMatrix(); } -/*** private ***/ - void Manipulator::selection_changed() { if(mode) 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();