From b3a73308d67de22a2d65cc56b14edeab25537eba Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 29 Oct 2010 10:30:49 +0000 Subject: [PATCH] Make Designer::get_layout and get_layout_3d return references --- source/designer/designer.h | 4 ++-- source/designer/manipulator.cpp | 8 ++++---- source/designer/measure.cpp | 2 +- source/designer/toolbar.cpp | 14 +++++++------- source/designer/trackwrap.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/designer/designer.h b/source/designer/designer.h index d0f8e81..63d2591 100644 --- a/source/designer/designer.h +++ b/source/designer/designer.h @@ -86,8 +86,8 @@ public: void quit(); const Marklin::Catalogue &get_catalogue() const { return catalogue; } - Marklin::Layout *get_layout() { return layout; } - Marklin::Layout3D *get_layout_3d() { return layout_3d; } + Marklin::Layout &get_layout() { return *layout; } + Marklin::Layout3D &get_layout_3d() { return *layout_3d; } const Msp::GL::Camera &get_camera() const { return camera; } const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; } Msp::GLtk::Root &get_root() const { return *root; } diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 7abe3d7..9af1e60 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -64,7 +64,7 @@ void Manipulator::duplicate() list new_tracks; for(vector::iterator i=tracks.begin(); i!=tracks.end(); ++i) { - Track *track = new Track(*designer.get_layout(), i->track->get_type()); + Track *track = new Track(designer.get_layout(), i->track->get_type()); track->set_position(i->track->get_position()); track->set_rotation(i->track->get_rotation()); new_tracks.push_back(track); @@ -348,7 +348,7 @@ void Manipulator::connect() if(j==types_by_length.end()) throw LogicError("Internal error"); - Track *track = new Track(*designer.get_layout(), *j->second); + Track *track = new Track(designer.get_layout(), *j->second); track->set_position(pos1); track->set_rotation(dir1); @@ -375,7 +375,7 @@ void Manipulator::button_press(int, int, float, float, unsigned btn) for(vector::iterator j=tracks.begin(); j!=tracks.end(); ++j) j->track->break_link(**i); - const set <racks = designer.get_layout()->get_tracks(); + const set <racks = designer.get_layout().get_tracks(); for(set::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) { bool ok = true; @@ -409,7 +409,7 @@ void Manipulator::pointer_motion(int, int y, float gx, float gy) i->track->set_rotation(i->rot); } - const set <racks = designer.get_layout()->get_tracks(); + const set <racks = designer.get_layout().get_tracks(); MTrack *snapped = 0; for(set::const_iterator i=ltracks.begin(); (i!=ltracks.end() && !snapped); ++i) { diff --git a/source/designer/measure.cpp b/source/designer/measure.cpp index cbe1793..201674c 100644 --- a/source/designer/measure.cpp +++ b/source/designer/measure.cpp @@ -27,7 +27,7 @@ void Measure::start() void Measure::snap_to_tracks(Point &pt, float &dir) { - const set <racks = designer.get_layout()->get_tracks(); + const set <racks = designer.get_layout().get_tracks(); for(set::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) if((*i)->snap(pt, dir)) return; diff --git a/source/designer/toolbar.cpp b/source/designer/toolbar.cpp index ec18adb..629205c 100644 --- a/source/designer/toolbar.cpp +++ b/source/designer/toolbar.cpp @@ -79,10 +79,10 @@ Toolbar::Toolbar(Designer &d): btn->set_tooltip("Add selected tracks to current route"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::add_selection_to_route)); - designer.get_layout()->signal_route_added.connect(sigc::mem_fun(this, &Toolbar::route_added)); - designer.get_layout()->signal_route_removed.connect(sigc::hide(sigc::mem_fun(this, &Toolbar::update_routes))); + designer.get_layout().signal_route_added.connect(sigc::mem_fun(this, &Toolbar::route_added)); + designer.get_layout().signal_route_removed.connect(sigc::hide(sigc::mem_fun(this, &Toolbar::update_routes))); - const set &routes = designer.get_layout()->get_routes(); + const set &routes = designer.get_layout().get_routes(); for(set::const_iterator i=routes.begin(); i!=routes.end(); ++i) (*i)->signal_name_changed.connect(sigc::hide(sigc::mem_fun(this, &Toolbar::update_routes))); @@ -93,8 +93,8 @@ void Toolbar::route_selected(unsigned index, const string &) { if(index==drp_routes->get_n_items()-1) { - Layout &layout = *designer.get_layout(); - const set &routes = designer.get_layout()->get_routes(); + Layout &layout = designer.get_layout(); + const set &routes = layout.get_routes(); Route *route = new Route(layout); route->set_name(format("Route %d", routes.size())); designer.edit_route(route); @@ -108,7 +108,7 @@ void Toolbar::route_selected(unsigned index, const string &) } else { - const set &routes = designer.get_layout()->get_routes(); + const set &routes = designer.get_layout().get_routes(); set::const_iterator i = routes.begin(); advance(i, index); designer.edit_route(*i); @@ -131,7 +131,7 @@ void Toolbar::route_added(Route &r) void Toolbar::update_routes() { drp_routes->clear(); - const set &routes = designer.get_layout()->get_routes(); + const set &routes = designer.get_layout().get_routes(); int selected = -1; unsigned n = 0; for(set::const_iterator i=routes.begin(); i!=routes.end(); ++i, ++n) diff --git a/source/designer/trackwrap.cpp b/source/designer/trackwrap.cpp index febeade..3c5a834 100644 --- a/source/designer/trackwrap.cpp +++ b/source/designer/trackwrap.cpp @@ -54,7 +54,7 @@ GL::Mesh &TrackWrap::get_mesh(const TrackType &type) if(j!=meshes.end()) return *j->second; - const TrackType3D &type3d = designer.get_layout_3d()->get_catalogue().get_track(type); + const TrackType3D &type3d = designer.get_layout_3d().get_catalogue().get_track(type); float min_area = -1; float angle; -- 2.45.2