]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/trackwrap.cpp
Rename Point to Vector
[r2c2.git] / source / designer / trackwrap.cpp
index 3c5a834badbf2d24a0c581be63009c50189ceea8..45ec19c85a8c1a33ac4b0bdfb1dbaac9c8c1ffe3 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 © 2010  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
@@ -14,7 +14,7 @@ Distributed under the GPL
 
 using namespace std;
 using namespace Msp;
-using namespace Marklin;
+using namespace R2C2;
 
 TrackWrap::TrackWrap(Designer &d, Selection &s):
        designer(d),
@@ -23,12 +23,18 @@ TrackWrap::TrackWrap(Designer &d, Selection &s):
        selection.signal_changed.connect(sigc::mem_fun(this, &TrackWrap::selection_changed));
 }
 
+TrackWrap::~TrackWrap()
+{
+       for(map<const TrackType *, GL::Mesh *>::iterator i=meshes.begin(); i!=meshes.end(); ++i)
+               delete i->second;
+}
+
 void TrackWrap::render(const GL::Tag &) const
 {
        for(list<Wrap>::const_iterator i=wraps.begin(); i!=wraps.end(); ++i)
        {
                GL::PushMatrix _pushm;
-               const Point &pos = i->track->get_position();
+               const Vector &pos = i->track->get_position();
                GL::translate(pos.x, pos.y, pos.z);
                GL::rotate(i->track->get_rotation()*180/M_PI, 0, 0, 1);
                i->mesh->draw();
@@ -57,13 +63,13 @@ GL::Mesh &TrackWrap::get_mesh(const TrackType &type)
        const TrackType3D &type3d = designer.get_layout_3d().get_catalogue().get_track(type);
 
        float min_area = -1;
-       float angle;
-       Point center;
-       float width;
-       float height;
+       float angle = 0;
+       Vector center;
+       float width = 0;
+       float height = 0;
        for(float a=0; a<M_PI; a+=0.01)
        {
-               Point minp, maxp;
+               Vector minp, maxp;
                type3d.get_bounds(a, minp, maxp);
                float area = (maxp.x-minp.x)*(maxp.y-minp.y);
                if(area<min_area || min_area<0)
@@ -72,7 +78,7 @@ GL::Mesh &TrackWrap::get_mesh(const TrackType &type)
                        float s = sin(a);
                        float x = (minp.x+maxp.x)/2;
                        float y = (minp.y+maxp.y)/2;
-                       center = Point(c*x-s*y, s*x+c*y, minp.z);
+                       center = Vector(c*x-s*y, s*x+c*y, minp.z);
                        angle = a;
                        width = maxp.x-minp.x+0.01;
                        height = maxp.y-minp.y+0.01;