]> git.tdb.fi Git - r2c2.git/commitdiff
Make Designer::get_layout and get_layout_3d return references
authorMikko Rasa <tdb@tdb.fi>
Fri, 29 Oct 2010 10:30:49 +0000 (10:30 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 29 Oct 2010 10:30:49 +0000 (10:30 +0000)
source/designer/designer.h
source/designer/manipulator.cpp
source/designer/measure.cpp
source/designer/toolbar.cpp
source/designer/trackwrap.cpp

index d0f8e81e694cb7402e7d4ccba0e409224a5bbaad..63d2591959ab152aee38b74dd706c1c7b027a1cc 100644 (file)
@@ -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; }
index 7abe3d750650448b31989e09f082d8919888da3c..9af1e60a0aa94f7f506b3fa77357a7a8af6cbb3e 100644 (file)
@@ -64,7 +64,7 @@ void Manipulator::duplicate()
        list<Track *> new_tracks;
        for(vector<MTrack>::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<MTrack>::iterator j=tracks.begin(); j!=tracks.end(); ++j)
                                j->track->break_link(**i);
 
-               const set<Track *> &ltracks = designer.get_layout()->get_tracks();
+               const set<Track *> &ltracks = designer.get_layout().get_tracks();
                for(set<Track *>::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<Track *> &ltracks = designer.get_layout()->get_tracks();
+               const set<Track *> &ltracks = designer.get_layout().get_tracks();
                MTrack *snapped = 0;
                for(set<Track *>::const_iterator i=ltracks.begin(); (i!=ltracks.end() && !snapped); ++i)
                {
index cbe17938dd3debe1fa28f367c86175329b956130..201674c86a206cd025c32da9fa3dd935e84997f2 100644 (file)
@@ -27,7 +27,7 @@ void Measure::start()
 
 void Measure::snap_to_tracks(Point &pt, float &dir)
 {
-       const set<Track *> &ltracks = designer.get_layout()->get_tracks();
+       const set<Track *> &ltracks = designer.get_layout().get_tracks();
        for(set<Track *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
                if((*i)->snap(pt, dir))
                        return;
index ec18adb259980ef19ff17805ac2bcadbf75cacf3..629205c6ce89cba05f2f2b77eaaf1583e6cd99f8 100644 (file)
@@ -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<Route *> &routes = designer.get_layout()->get_routes();
+       const set<Route *> &routes = designer.get_layout().get_routes();
        for(set<Route *>::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<Route *> &routes = designer.get_layout()->get_routes();
+               Layout &layout = designer.get_layout();
+               const set<Route *> &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<Route *> &routes = designer.get_layout()->get_routes();
+               const set<Route *> &routes = designer.get_layout().get_routes();
                set<Route *>::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<Route *> &routes = designer.get_layout()->get_routes();
+       const set<Route *> &routes = designer.get_layout().get_routes();
        int selected = -1;
        unsigned n = 0;
        for(set<Route *>::const_iterator i=routes.begin(); i!=routes.end(); ++i, ++n)
index febeadee4412c0b64db6cdee9078aef4fbe9c9bb..3c5a834badbf2d24a0c581be63009c50189ceea8 100644 (file)
@@ -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;