]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/designer.cpp
Rename the project to R²C²
[r2c2.git] / source / designer / designer.cpp
index 51dad8f1a6ee4d42b3bcab4bbae1667952e5953e..8ab0465c2347a89d3bf21352001199f2939084ba 100644 (file)
@@ -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,7 +8,7 @@ Distributed under the GPL
 #include <signal.h>
 #include <algorithm>
 #include <cmath>
-#include <GL/gl.h>
+#include <msp/fs/utils.h>
 #include <msp/gl/blend.h>
 #include <msp/gl/framebuffer.h>
 #include <msp/gl/matrix.h>
@@ -26,25 +26,26 @@ Distributed under the GPL
 #include <msp/strings/utils.h>
 #include <msp/time/units.h>
 #include <msp/time/utils.h>
-#include "libmarklin/route.h"
-#include "libmarklin/tracktype.h"
+#include "libr2c2/route.h"
+#include "libr2c2/tracktype.h"
 #include "3d/path.h"
 #include "designer.h"
 #include "input.h"
 #include "manipulator.h"
 #include "measure.h"
 #include "selection.h"
+#include "svgexporter.h"
 #include "toolbar.h"
 
 using namespace std;
-using namespace Marklin;
+using namespace R2C2;
 using namespace Msp;
 
 Application::RegApp<Designer> Designer::reg;
 
 Designer::Designer(int argc, char **argv):
        window(1280, 960),
-       ui_res("marklin.res"),
+       ui_res("r2c2.res"),
        root(ui_res, window),
        base_object(0),
        cur_route(0),
@@ -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;
@@ -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)
@@ -549,7 +561,7 @@ void Designer::manipulation_status(const string &status)
 
 void Designer::manipulation_done(bool)
 {
-       mode = SELECT;
+       mode = MANIPULATE_DONE;
        selection_changed();
 }
 
@@ -596,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))