class Layout3D
{
private:
- Layout &layout;
+ Layout &layout;
std::list<Track3D *> tracks;
- unsigned quality;
+ unsigned quality;
public:
Layout3D(Layout &);
void set_quality(unsigned);
const std::list<Track3D *> &get_tracks() const { return tracks; }
- void render(bool =false) const;
+ void render(bool =false) const;
Track3D &get_track(const Track &) const;
Track3D *pick_track(float, float, float) const;
private:
build_object();
}
+void Track3D::set_color(const Msp::GL::Color &c)
+{
+ color=c;
+}
+
void Track3D::set_quality(unsigned q)
{
quality=q;
class Track3D
{
private:
- Track &track;
+ Track &track;
Msp::GL::Color color;
std::vector<Point> border;
Msp::GL::VertexArray varray;
public:
Track3D(Track &, unsigned);
- void set_color(const Msp::GL::Color &c) { color=c; }
+ Track &get_track() const { return track; }
+ void set_color(const Msp::GL::Color &);
void set_quality(unsigned);
void get_bounds(float, Point &, Point &) const;
- Track &get_track() const { return track; }
void render() const;
void render_endpoints() const;
void render_route(int) const;
using namespace Marklin;
using namespace Msp;
+Application::RegApp<Designer> Designer::reg;
+
Designer::Designer(int argc, char **argv):
screen_w(1280),
screen_h(960),
base_mesh(0),
- input(0),
mode(SELECT),
+ input(0),
cam_yaw(M_PI/2),
cam_pitch(-M_PI/4),
cam_pos(0, -0.5, 0.5),
input=0;
mode=SELECT;
}
-
-Application::RegApp<Designer> Designer::reg;
Msp::Graphics::Display *dpy;
Msp::Graphics::Window *wnd;
Msp::Graphics::GLContext *glc;
- unsigned screen_w;
- unsigned screen_h;
- Msp::GL::Font *font;
+ unsigned screen_w;
+ unsigned screen_h;
+ Msp::GL::Font *font;
+
Marklin::Catalogue catalogue;
- Marklin::Layout *layout;
- Marklin::Layout3D *layout_3d;
- Marklin::Layout *cat_layout;
- Marklin::Layout3D *cat_layout_3d;
- Msp::GL::Mesh *base_mesh;
- Selection *selection;
- Manipulator *manipulator;
- Measure *measure;
- Input *input;
- Mode mode;
- float cam_yaw;
- float cam_pitch;
+ Marklin::Layout *layout;
+ Marklin::Layout3D *layout_3d;
+ Marklin::Layout *cat_layout;
+ Marklin::Layout3D *cat_layout_3d;
+ Msp::GL::Mesh *base_mesh;
+
+ Mode mode;
+ Selection *selection;
+ Manipulator *manipulator;
+ Measure *measure;
+ Input *input;
+
+ float cam_yaw;
+ float cam_pitch;
Marklin::Point cam_pos;
- bool shift;
- int move_x;
- int move_y;
- int zoom;
- int rotate;
- int pitch;
- int pointer_x;
- int pointer_y;
- int tooltip_x;
- int tooltip_y;
- std::string tooltip;
+
+ bool shift;
+ int move_x;
+ int move_y;
+ int zoom;
+ int rotate;
+ int pitch;
+ int pointer_x;
+ int pointer_y;
+
+ int tooltip_x;
+ int tooltip_y;
+ std::string tooltip;
Msp::Time::TimeStamp tooltip_timeout;
+
Msp::Time::TimeStamp last_tick;
+ static Msp::Application::RegApp<Designer> reg;
+
public:
Designer(int, char **);
~Designer();
Marklin::Layout *get_layout() { return layout; }
Marklin::Layout3D *get_layout_3d() { return layout_3d; }
- Msp::GL::Font &get_font() { return *font; }
- int main();
- void map_pointer_coords(int, int, float &, float &);
+ Msp::GL::Font &get_font() { return *font; }
+ int main();
+ void map_pointer_coords(int, int, float &, float &);
private:
void tick();
void key_press(unsigned, unsigned, wchar_t);
void turnout_id_accept();
void sensor_id_accept();
void input_dismiss();
-
- static Msp::Application::RegApp<Designer> reg;
};
#endif
sigc::signal<void> signal_accept;
sigc::signal<void> signal_cancel;
- Input(Designer &, const std::string &, const std::string & ="");
- const std::string &get_text() { return text; }
- void key_press(unsigned, unsigned, wchar_t);
- void render();
private:
- Designer &designer;
+ Designer &designer;
std::string title;
std::string text;
- unsigned pos;
+ unsigned pos;
+
+public:
+ Input(Designer &, const std::string &, const std::string & =std::string());
+ const std::string &get_text() { return text; }
+ void key_press(unsigned, unsigned, wchar_t);
+ void render();
};
#endif
float height;
};
- Designer &designer;
- Selection *selection;
+public:
+ sigc::signal<void, const std::string &> signal_status;
+ sigc::signal<void, bool> signal_done;
+
+private:
+ Designer &designer;
+ Selection *selection;
std::vector<MTrack> tracks;
Marklin::Point center;
float wrap_rot;
Marklin::Point gpointer;
- int pointer_y;
- Mode mode;
+ int pointer_y;
+ Mode mode;
Marklin::Point move_origin;
- float angle;
- float rot_origin;
- int elev_origin;
+ float angle;
+ float rot_origin;
+ int elev_origin;
std::set<Marklin::Track *> neighbors;
sigc::connection selection_changed_conn;
public:
- sigc::signal<void, const std::string &> signal_status;
- sigc::signal<void, bool> signal_done;
-
Manipulator(Designer &);
void set_selection(Selection *);
ACTIVE
};
+public:
+ sigc::signal<void> signal_done;
+ sigc::signal<void> signal_changed;
+
+private:
Designer &designer;
Marklin::Point pointer;
Marklin::Point spoint;
State state;
public:
- sigc::signal<void> signal_done;
- sigc::signal<void> signal_changed;
-
Measure(Designer &);
- float get_parallel_distance() const { return par_dist; }
+ float get_parallel_distance() const { return par_dist; }
float get_perpendicular_distance() const { return perp_dist; }
- float get_angle_difference() const { return adiff; }
+ float get_angle_difference() const { return adiff; }
void start();
void button_press(int, int, float, float, unsigned);
void pointer_motion(int, int, float, float);
class Selection
{
+public:
+ sigc::signal<void> signal_changed;
+
private:
std::set<Marklin::Track *> tracks;
public:
- sigc::signal<void> signal_changed;
-
const std::set<Marklin::Track *> &get_tracks() const { return tracks; }
Marklin::Track *get_track() const;
unsigned size() const { return tracks.size(); }
fullscreen(false),
layout(catalogue),
layout_3d(layout),
- no_lighting(false),
+ train_prop(0),
+ train_prop_stale(false),
placing_train(0),
placing_block(0),
placing_entry(0),
- simulate(false),
- train_prop(0),
- train_prop_stale(false)
+ no_lighting(false),
+ simulate(false)
{
string res;
- bool debug=false;
+ bool debug=false;
string device="/dev/ttyS0";
unsigned quality=4;
GL::Immediate imm((GL::COLOR4_UBYTE, GL::VERTEX2));
imm.color(1.0f, 1.0f, 1.0f);
imm.begin(GL::TRIANGLE_FAN);
- imm.vertex(0.08, 0);
- imm.vertex(0.05, 0.03);
- imm.vertex(0.05, 0.01);
- imm.vertex(0, 0.01);
- imm.vertex(0, -0.01);
- imm.vertex(0.05, -0.01);
- imm.vertex(0.05, -0.03);
+ imm.vertex(0.08, 0);
+ imm.vertex(0.05, 0.03);
+ imm.vertex(0.05, 0.01);
+ imm.vertex(0, 0.01);
+ imm.vertex(0, -0.01);
+ imm.vertex(0.05, -0.01);
+ imm.vertex(0.05, -0.03);
imm.end();
GL::pop_matrix();
class Engineer: public Msp::Application
{
private:
- Msp::Graphics::Display *dpy;
- Msp::Graphics::Window *wnd;
+ Msp::Graphics::Display *dpy;
+ Msp::Graphics::Window *wnd;
Msp::Graphics::GLContext *glc;
- Msp::GLtk::Root *root;
- unsigned screen_w;
- unsigned screen_h;
- bool fullscreen;
- Marklin::Catalogue catalogue;
- Marklin::Layout layout;
- Marklin::Layout3D layout_3d;
- Marklin::Control control;
- Marklin::Point cam_pos;
- float cam_rot;
+ unsigned screen_w;
+ unsigned screen_h;
+ bool fullscreen;
Msp::GLtk::Resources ui_res;
- MainPanel *main_panel;
- std::list<TrainPanel *> train_panels;
- bool no_lighting;
+ Msp::GLtk::Root *root;
+
+ Marklin::Catalogue catalogue;
+ Marklin::Layout layout;
+ Marklin::Layout3D layout_3d;
+ Marklin::Control control;
Marklin::TrafficManager *trfc_mgr;
- Marklin::Train *placing_train;
- Marklin::Block *placing_block;
- unsigned placing_entry;
- bool simulate;
- TrainProperties *train_prop;
- bool train_prop_stale;
+
+ Marklin::Point cam_pos;
+ float cam_rot;
+
+ MainPanel *main_panel;
+ std::list<TrainPanel *> train_panels;
+ TrainProperties *train_prop;
+ bool train_prop_stale;
+ Marklin::Train *placing_train;
+ Marklin::Block *placing_block;
+ unsigned placing_entry;
+
+ bool no_lighting;
+ bool simulate;
public:
Engineer(int argc, char **argv);
~Engineer();
const Marklin::Catalogue &get_catalogue() const { return catalogue; }
- Marklin::Control &get_control() { return control; }
- void add_train();
- Marklin::Train *add_train(const Marklin::LocoType &, unsigned);
- void place_train(Marklin::Train &);
- int main();
- void quit() { exit(0); }
+ Marklin::Control &get_control() { return control; }
+ void add_train();
+ Marklin::Train *add_train(const Marklin::LocoType &, unsigned);
+ void place_train(Marklin::Train &);
+ int main();
+ void quit() { exit(0); }
private:
void tick();
void key_press(unsigned, unsigned, wchar_t);
class TrainProperties: public Msp::GLtk::Panel
{
+public:
+ sigc::signal<void> signal_ok;
+
private:
Engineer &engineer;
Marklin::Train *train;
Msp::GLtk::Entry *ent_name;
public:
- sigc::signal<void> signal_ok;
-
TrainProperties(Engineer &, Msp::GLtk::Resources &, Marklin::Train *);
private:
void ok_clicked();
public:
struct Endpoint
{
- Track *track;
+ Track *track;
unsigned track_ep;
- Block *link;
+ Block *link;
unsigned routes;
Endpoint(Track *, unsigned);
private:
TrafficManager &trfc_mgr;
- unsigned id;
- unsigned sensor_id;
- unsigned turnout_id;
- std::set<Track *> tracks;
+ unsigned id;
+ unsigned sensor_id;
+ unsigned turnout_id;
+ std::set<Track *> tracks;
std::vector<Endpoint> endpoints;
- const Train *train;
+ const Train *train;
public:
Block(TrafficManager &, Track &);
/* $Id$
This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
class Command
{
+public:
+ sigc::signal<void, const Reply &> signal_done;
+
private:
Cmd cmd;
unsigned char data[128];
bool sent;
public:
- sigc::signal<void, const Reply &> signal_done;
-
Command(Cmd, const unsigned char *, unsigned);
void send(int);
- bool get_sent() const { return sent; }
+ bool is_sent() const { return sent; }
Cmd get_command() const { return cmd; }
friend std::ostream &operator<<(std::ostream &, const Command &);
/* $Id$
This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
close(serial_fd);
}
-void Control::set_power(bool p)
-{
- power=p;
- if(power)
- command(CMD_POWER_ON);
- else
- command(CMD_POWER_OFF);
-
- signal_power_event.emit(power);
-}
-
-void Control::set_debug(bool d)
-{
- debug=d;
-}
-
void Control::open(const string &dev)
{
serial_fd=::open(dev.c_str(), O_RDWR);
command(CMD_STATUS).signal_done.connect(sigc::mem_fun(this, &Control::status_done));
}
+void Control::set_debug(bool d)
+{
+ debug=d;
+}
+
+void Control::set_power(bool p)
+{
+ power=p;
+ if(power)
+ command(CMD_POWER_ON);
+ else
+ command(CMD_POWER_OFF);
+
+ signal_power_event.emit(power);
+}
+
Command &Control::command(Cmd cmd)
{
queue.push_back(Command(cmd, 0, 0));
poll_sensors=false;
}
- if(!queue.empty() && queue.front().get_sent())
+ if(!queue.empty() && queue.front().is_sent())
{
pollfd pfd={serial_fd, POLLIN, 0};
if(poll(&pfd, 1, 0)>0)
return timer.add(dt);
}
-void Control::read_all(int fd, char *buf, int size)
-{
- int pos=0;
- while(pos<size)
- {
- int len=read(fd, buf+pos, size-pos);
- pos+=len;
- }
-}
-
void Control::status_done(const Reply &reply)
{
power=((reply.get_data()[0]&0x08)!=0);
class Control
{
+public:
+ sigc::signal<void, bool> signal_power_event;
+ sigc::signal<void, unsigned, bool> signal_turnout_event;
+ sigc::signal<void, unsigned, bool> signal_sensor_event;
+
private:
- int serial_fd;
+ int serial_fd;
bool power;
std::list<Command> queue;
std::map<unsigned, Turnout *> turnouts;
Msp::Time::Timer timer;
public:
- sigc::signal<void, bool> signal_power_event;
- sigc::signal<void, unsigned, bool> signal_turnout_event;
- sigc::signal<void, unsigned, bool> signal_sensor_event;
-
Control();
~Control();
- void set_power(bool);
- bool get_power() const { return power; }
- void set_debug(bool);
- const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
- const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
- unsigned get_queue_length() const { return queue.size(); }
- void open(const std::string &);
- Command &command(Cmd);
- Command &command(Cmd, unsigned char);
- Command &command(Cmd, const unsigned char *, unsigned);
+ void open(const std::string &);
+ void set_debug(bool);
+ void set_power(bool);
+ bool get_power() const { return power; }
+ Command &command(Cmd);
+ Command &command(Cmd, unsigned char);
+ Command &command(Cmd, const unsigned char *, unsigned);
+ unsigned get_queue_length() const { return queue.size(); }
- void add_turnout(Turnout &);
- Turnout &get_turnout(unsigned) const;
- void add_locomotive(Locomotive &);
+ void add_turnout(Turnout &);
+ Turnout &get_turnout(unsigned) const;
+ const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
+ void add_locomotive(Locomotive &);
Locomotive &get_locomotive(unsigned) const;
- void add_sensor(Sensor &);
- Sensor &get_sensor(unsigned) const;
+ void add_sensor(Sensor &);
+ Sensor &get_sensor(unsigned) const;
+ const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
- void tick();
+ void tick();
Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
private:
- void read_all(int, char *, int);
- std::string read_reply(Cmd);
void status_done(const Reply &);
void event_query_done(const Reply &);
void turnout_event_done(const Reply &);
(*i)->save(st.sub);
writer.write(st);
}
- /*ofstream out(fn.c_str());
- if(!out) return -1;
-
- filename=fn;
-
- if(!base.empty())
- out<<"base \""<<base<<"\";\n";
- for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
- {
- out<<"track "<<(*i)->get_type().get_article_number()<<"\n{\n";
- const Point &p=(*i)->get_position();
- out<<"\tposition "<<p.x<<' '<<p.y<<' '<<p.z<<";\n";
- out<<"\trotation "<<(*i)->get_rotation()<<";\n";
- out<<"\tslope "<<(*i)->get_slope()<<";\n";
-
- unsigned id=(*i)->get_turnout_id();
- if(id)
- out<<"\tturnout_id "<<id<<";\n";
-
- id=(*i)->get_sensor_id();
- if(id)
- out<<"\tsensor_id "<<id<<";\n";
-
- if((*i)->get_flex())
- out<<"\tflex true;\n";
-
- out<<"};\n";
- }
-
- return 0;*/
}
void track(unsigned);
};
+public:
+ sigc::signal<void, Track &> signal_track_added;
+ sigc::signal<void, Track &> signal_track_removed;
+
private:
const Catalogue &catalogue;
std::string base;
std::set<Track *> tracks;
- //RouteSeq routes;
+ //std::set<Route *> routes;
public:
- sigc::signal<void, Track &> signal_track_added;
- sigc::signal<void, Track &> signal_track_removed;
-
Layout(const Catalogue &);
~Layout();
const Catalogue &get_catalogue() const { return catalogue; }
const std::string &get_base() const { return base; }
const std::set<Track *> &get_tracks() const { return tracks; }
- void add_track(Track &);
- void remove_track(Track &);
- void check_links();
- void save(const std::string &);
+ void add_track(Track &);
+ void remove_track(Track &);
+ void check_links();
+ void save(const std::string &);
};
} // namespace Marklin
class Locomotive
{
+public:
+ sigc::signal<void, unsigned> signal_speed_changing;
+ sigc::signal<void, unsigned> signal_speed_changed;
+ sigc::signal<void, unsigned, bool> signal_function_changed;
+
private:
const LocoType &type;
- Control &control;
+ Control &control;
unsigned addr;
unsigned speed;
- bool reverse;
+ bool reverse;
unsigned funcs;
public:
- sigc::signal<void, unsigned> signal_speed_changing;
- sigc::signal<void, unsigned> signal_speed_changed;
- sigc::signal<void, unsigned, bool> signal_function_changed;
-
Locomotive(const LocoType &, Control &, unsigned);
const LocoType &get_type() const { return type; }
- void set_speed(unsigned);
- void set_reverse(bool);
- void set_function(unsigned, bool);
- unsigned get_address() const { return addr; }
- unsigned get_speed() const { return speed; }
- bool get_reverse() const { return reverse; }
- bool get_function(unsigned f) const { return (funcs>>f)&1; }
- void refresh_status();
+ unsigned get_address() const { return addr; }
+ void set_speed(unsigned);
+ void set_reverse(bool);
+ void set_function(unsigned, bool);
+ unsigned get_speed() const { return speed; }
+ bool get_reverse() const { return reverse; }
+ bool get_function(unsigned f) const { return (funcs>>f)&1; }
+ void refresh_status();
private:
- void send_command(bool);
- void status_reply(const Reply &);
- bool reverse_timeout();
+ void send_command(bool);
+ void status_reply(const Reply &);
+ bool reverse_timeout();
};
} // namespace Marklin
/* $Id$
This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
#ifndef LIBMARKLIN_ROUTE_H_
#define LIBMARKLIN_ROUTE_H_
-#include <list>
#include <map>
#include <set>
#include <string>
class Route
{
-public:
- Route();
- const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
- void add_track(Track *);
- ~Route();
private:
std::string name;
std::set<Track *> tracks;
std::map<unsigned, Turnout *> turnouts;
+
+public:
+ Route();
+ ~Route();
+
+ const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
+ void add_track(Track *);
};
} // namespace Marklin
/* $Id$
This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
class Sensor
{
+public:
+ sigc::signal<void, bool> signal_state_changed;
+
private:
- Control &control;
+ Control &control;
unsigned addr;
- bool state;
+ bool state;
Msp::Time::TimeStamp off_timeout;
public:
- sigc::signal<void, bool> signal_state_changed;
-
Sensor(Control &, unsigned);
unsigned get_address() const { return addr; }
- bool get_state() const { return state; }
- void tick();
+ bool get_state() const { return state; }
+ void tick();
private:
void sensor_event(unsigned, bool);
};
flex=f;
}
+void Track::check_slope()
+{
+ if(links.size()!=2)
+ return;
+
+ if(links[0] && links[1])
+ {
+ Point epp0=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
+ Point epp1=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
+ pos.z=epp0.z;
+ slope=epp1.z-pos.z;
+ }
+ else
+ {
+ slope=0;
+ if(links[0])
+ {
+ Point epp=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
+ pos.z=epp.z;
+ }
+ else if(links[1])
+ {
+ Point epp=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
+ pos.z=epp.z;
+ }
+ }
+}
+
void Track::set_turnout_id(unsigned i)
{
turnout_id=i;
return links[i];
}
-void Track::check_slope()
-{
- if(links.size()!=2)
- return;
-
- if(links[0] && links[1])
- {
- Point epp0=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
- Point epp1=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
- pos.z=epp0.z;
- slope=epp1.z-pos.z;
- }
- else
- {
- slope=0;
- if(links[0])
- {
- Point epp=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
- pos.z=epp.z;
- }
- else if(links[1])
- {
- Point epp=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
- pos.z=epp.z;
- }
- }
-}
-
int Track::traverse(unsigned i, unsigned route) const
{
const vector<Endpoint> &eps=type.get_endpoints();
Track::Loader::Loader(Track &t):
DataFile::BasicLoader<Track>(t)
{
- add("position", &Loader::position);
- add("rotation", &Track::rot);
- add("slope", &Track::slope);
- add("turnout_id", &Track::turnout_id);
- add("sensor_id", &Track::sensor_id);
- add("flex", &Track::flex);
+ add("position", &Loader::position);
+ add("rotation", &Track::rot);
+ add("slope", &Track::slope);
+ add("turnout_id", &Track::turnout_id);
+ add("sensor_id", &Track::sensor_id);
+ add("flex", &Track::flex);
}
void Track::Loader::position(float x, float y, float z)
private:
const TrackType &type;
- Point pos;
- float rot;
- float slope;
- bool flex;
- unsigned turnout_id;
- unsigned sensor_id;
+ Point pos;
+ float rot;
+ float slope;
+ bool flex;
+ unsigned turnout_id;
+ unsigned sensor_id;
std::vector<Track *> links;
+ // Direct copying not allowed due to links. See the copy() function.
+ Track(const Track &);
+ Track &operator=(const Track &);
public:
Track(const TrackType &);
~Track();
const TrackType &get_type() const { return type; }
- void set_position(const Point &);
- const Point &get_position() const { return pos; }
- void set_rotation(float);
- float get_rotation() const { return rot; }
- void set_slope(float);
- float get_slope() const { return slope; }
- void set_flex(bool);
- bool get_flex() const { return flex; }
- void set_turnout_id(unsigned);
- unsigned get_turnout_id() const { return turnout_id; }
- void set_sensor_id(unsigned);
- unsigned get_sensor_id() const { return sensor_id; }
- int get_endpoint_by_link(const Track &) const;
- Point get_endpoint_position(unsigned) const;
- float get_endpoint_direction(unsigned) const;
- bool snap_to(Track &, bool);
- bool snap(Point &, float &) const;
- void break_link(Track &);
- void break_links();
+
+ void set_position(const Point &);
+ void set_rotation(float);
+ void set_slope(float);
+ void set_flex(bool);
+ const Point &get_position() const { return pos; }
+ float get_rotation() const { return rot; }
+ float get_slope() const { return slope; }
+ bool get_flex() const { return flex; }
+ void check_slope();
+
+ void set_turnout_id(unsigned);
+ void set_sensor_id(unsigned);
+ unsigned get_turnout_id() const { return turnout_id; }
+ unsigned get_sensor_id() const { return sensor_id; }
+
+ int get_endpoint_by_link(const Track &) const;
+ Point get_endpoint_position(unsigned) const;
+ float get_endpoint_direction(unsigned) const;
+ bool snap_to(Track &, bool);
+ bool snap(Point &, float &) const;
+ void break_link(Track &);
+ void break_links();
const std::vector<Track *> &get_links() const { return links; }
- Track *get_link(unsigned) const;
- void check_slope();
- int traverse(unsigned, unsigned) const;
- Point get_point(unsigned, unsigned, float) const;
+ Track *get_link(unsigned) const;
+ int traverse(unsigned, unsigned) const;
+ Point get_point(unsigned, unsigned, float) const;
/**
Creates a copy of the track. The new track will be almost identical, but
Track *copy() const;
void save(std::list<Msp::DataFile::Statement> &) const;
-private:
-
- // Direct copying not allowed due to links. See the copy() function.
- Track(const Track &);
- Track &operator=(const Track &);
};
} // namespace Marklin
void start(float, float, float);
};
- Point pos;
- float dir;
- float length;
- float radius;
+ Point pos;
+ float dir;
+ float length;
+ float radius;
unsigned route;
- bool dead_end;
+ bool dead_end;
TrackPart();
};
private:
- unsigned art_nr;
- std::string description;
+ unsigned art_nr;
+ std::string description;
std::vector<TrackPart> parts;
std::vector<Endpoint> endpoints;
float get_route_length(int) const;
unsigned get_n_routes() const;
const std::vector<TrackPart> &get_parts() const { return parts; }
- const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
+ const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
private:
- void collect_endpoints();
+ void collect_endpoints();
};
} // namespace Marklin
void train(unsigned, unsigned);
};
+ sigc::signal<void, const Block &, const Train *> signal_block_reserved;
+
private:
Control &control;
Layout &layout;
Msp::Time::TimeStamp last_tick;
public:
- sigc::signal<void, const Block &, const Train *> signal_block_reserved;
-
TrafficManager(Control &, Layout &);
~TrafficManager();
Loader(Train &);
};
+ sigc::signal<void, const std::string &> signal_name_changed;
+ sigc::signal<void, const std::string &> signal_status_changed;
+
private:
struct BlockRef
{
Point pos;
public:
- sigc::signal<void, const std::string &> signal_name_changed;
- sigc::signal<void, const std::string &> signal_status_changed;
-
Train(TrafficManager &, Locomotive &);
void set_name(const std::string &);
class Turnout
{
+public:
+ sigc::signal<void, unsigned> signal_route_changing;
+ sigc::signal<void, unsigned> signal_route_changed;
+
private:
- Control &control;
+ Control &control;
unsigned addr;
unsigned route;
- bool dual;
+ bool dual;
public:
- sigc::signal<void, unsigned> signal_route_changing;
- sigc::signal<void, unsigned> signal_route_changed;
-
Turnout(Control &, unsigned, bool =false);
- void set_route(unsigned);
+ void set_route(unsigned);
unsigned get_address() const { return addr; }
- unsigned get_route() const { return route; }
+ unsigned get_route() const { return route; }
private:
void command(bool);
void status_reply(const Reply &, bool);