X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fdesigner.cpp;h=23185cf3252e6d15418a563395795b2de3caf41d;hb=975ea87cc7be179618b06291cb2506a2523cad1f;hp=c071b5b4612d46d47d331d6545fd07da008e7483;hpb=cd6686b4821de95505ac94115e0966e4ff7cdc57;p=r2c2.git diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index c071b5b..23185cf 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -8,7 +8,7 @@ Distributed under the GPL #include #include #include -#include +#include #include #include #include @@ -34,6 +34,7 @@ Distributed under the GPL #include "manipulator.h" #include "measure.h" #include "selection.h" +#include "svgexporter.h" #include "toolbar.h" using namespace std; @@ -49,7 +50,7 @@ Designer::Designer(int argc, char **argv): base_object(0), cur_route(0), mode(SELECT), - manipulator(*this, selection), + manipulator(*this, root, selection), measure(*this), camera_ctl(*this, root, camera), track_wrap(*this, selection) @@ -128,12 +129,12 @@ Designer::Designer(int argc, char **argv): toolbar->set_position(0, window.get_height()-toolbar->get_geometry().h); toolbar->set_focusable(false); - GLtk::Panel *statusbar = new GLtk::Panel(ui_res); + GLtk::Panel *statusbar = new GLtk::Panel; root.add(*statusbar); statusbar->set_size(window.get_width(), 20); statusbar->set_focusable(false); - lbl_status = new GLtk::Label(ui_res); + lbl_status = new GLtk::Label; statusbar->add(*lbl_status); lbl_status->set_geometry(GLtk::Geometry(20, 2, 300, 16)); @@ -225,6 +226,12 @@ void Designer::rename_route() input->signal_accept.connect(sigc::mem_fun(this, &Designer::route_name_accept)); } +void Designer::svg_export() +{ + InputDialog *input = new InputDialog(*this, "SVG export", FS::basepart(filename)+".svg"); + input->signal_accept.connect(sigc::mem_fun(this, &Designer::svg_export_accept)); +} + void Designer::edit_route(Route *r) { cur_route = r; @@ -248,7 +255,7 @@ void Designer::add_selection_to_route() show_route(cur_route); } -Point Designer::map_pointer_coords(int x, int y) +Point Designer::map_pointer_to_ground(int x, int y) { float xf = x*2.0/window.get_width()-1.0; float yf = y*2.0/window.get_height()-1.0; @@ -264,6 +271,9 @@ void Designer::tick() float dt = (t-last_tick)/Msp::Time::sec; last_tick = t; + if(mode==MANIPULATE_DONE) + mode = SELECT; + window.tick(); root.tick(); camera_ctl.tick(dt); @@ -372,6 +382,8 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t) add_selection_to_route(); else if(key==Msp::Input::KEY_C) manipulator.connect(); + else if(key==Msp::Input::KEY_V) + svg_export(); } void Designer::button_press(int x, int y, unsigned btn, unsigned mod) @@ -379,7 +391,7 @@ void Designer::button_press(int x, int y, unsigned btn, unsigned mod) y = window.get_height()-y-1; mod = Input::mod_from_sys(mod); - Point ground = map_pointer_coords(x, y); + Point ground = map_pointer_to_ground(x, y); if(mode==CATALOGUE) { @@ -413,8 +425,6 @@ void Designer::button_press(int x, int y, unsigned btn, unsigned mod) } } } - else if(mode==MANIPULATE) - manipulator.button_press(x, y, ground.x, ground.y, btn); else if(mode==MEASURE) measure.button_press(x, y, ground.x, ground.y, btn); } @@ -425,8 +435,7 @@ void Designer::pointer_motion(int x, int y) if(!root.get_child_at(x, y)) { - Point ground = map_pointer_coords(x, y); - manipulator.pointer_motion(x, y, ground.x, ground.y); + Point ground = map_pointer_to_ground(x, y); measure.pointer_motion(x, y, ground.x, ground.y); } } @@ -552,7 +561,7 @@ void Designer::manipulation_status(const string &status) void Designer::manipulation_done(bool) { - mode = SELECT; + mode = MANIPULATE_DONE; selection_changed(); } @@ -599,6 +608,12 @@ void Designer::route_name_accept(const string &text) cur_route->set_name(text); } +void Designer::svg_export_accept(const string &text) +{ + SvgExporter svg_exp(*layout); + svg_exp.save(text); +} + string Designer::tooltip(int x, int y) { if(Track3D *t3d = pick_track(x, y))