X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fmanipulator.cpp;h=b41b29eeac9ac6e6562df825824f316a817fa3f7;hb=cb222b6df855da4196a331c5b9859750c4321fa0;hp=300802110e295ae0ba090d3ea722c5294546d908;hpb=d6ad508feda1aaa9b2ac2ca2d303c8d28d3094b9;p=r2c2.git diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 3008021..b41b29e 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -1,6 +1,6 @@ /* $Id$ -This file is part of the MSP Märklin suite +This file is part of R²C² Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -8,13 +8,13 @@ Distributed under the GPL #include #include #include -#include "libmarklin/tracktype.h" +#include "libr2c2/tracktype.h" #include "designer.h" #include "manipulator.h" #include "selection.h" using namespace std; -using namespace Marklin; +using namespace R2C2; using namespace Msp; Manipulator::Manipulator(Designer &d, Graphics::EventSource &es, Selection &s): @@ -59,12 +59,26 @@ void Manipulator::start_elevate() mode = ELEVATE; } -void Manipulator::start_extend() +bool Manipulator::start_extend() { if(mode) cancel(); - mode = EXTEND; + bool ok = false; + const set &stracks = selection.get_tracks(); + for(set::const_iterator i=stracks.begin(); (!ok && i!=stracks.end()); ++i) + { + const vector &links = (*i)->get_links(); + for(vector::const_iterator j=links.begin(); (!ok && j!=links.end()); ++j) + ok = !*j; + } + + if(ok) + mode = EXTEND; + else + signal_status.emit("No free endpoints"); + + return ok; } void Manipulator::duplicate() @@ -358,8 +372,8 @@ void Manipulator::button_press(int, int, unsigned btn, unsigned) void Manipulator::pointer_motion(int x, int y) { - pointer_y = y; - gpointer = designer.map_pointer_to_ground(x, event_source.get_height()-1-y); + pointer_y = event_source.get_height()-1-y; + gpointer = designer.map_pointer_to_ground(x, pointer_y); if(mode==MOVE) { @@ -420,7 +434,7 @@ void Manipulator::pointer_motion(int x, int y) } else if(mode==ELEVATE) { - float dz = (y-elev_origin)/1000.; + float dz = (pointer_y-elev_origin)/1000.; signal_status.emit(format("Elevation: %+.0fmm (%.0fmm)", dz*1000, (center.z+dz)*1000)); @@ -562,7 +576,7 @@ void Manipulator::set_slope(TrackOrder &track, float z, float dz) } } -vector Manipulator::create_straight(const Marklin::Point &start, float dir, float length, float limit) +vector Manipulator::create_straight(const R2C2::Point &start, float dir, float length, float limit) { const Catalogue::TrackMap &track_types = designer.get_catalogue().get_tracks(); std::map types_by_length;