/* $Id$
This file is part of R²C²
-Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
+Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
#include <cmath>
#include <msp/gl/matrix.h>
#include <msp/gl/misc.h>
+#include <msp/gl/renderer.h>
#include "libr2c2/tracktype.h"
#include "endpoint.h"
#include "layout.h"
layout.get_scene().add(*this);
const vector<TrackType::Endpoint> &type_eps = track.get_type().get_endpoints();
+ const vector<Track *> &links = track.get_links();
for(unsigned i=0; i<type_eps.size(); ++i)
- endpoints.push_back(new Endpoint3D(*this, i));
+ {
+ if(!links[i] || links[i]>&track)
+ endpoints.push_back(new Endpoint3D(*this, i));
+ else
+ endpoints.push_back(0);
+ }
+
+ track.signal_link_changed.connect(sigc::mem_fun(this, &Track3D::link_changed));
}
Track3D::~Track3D()
return matrix;
}
-void Track3D::setup_render(const GL::Tag &) const
+void Track3D::setup_render(Msp::GL::Renderer &renderer, const GL::Tag &) const
{
- GL::MatrixStack::modelview().push();
- GL::MatrixStack::modelview() *= get_matrix();
+ renderer.matrix_stack() *= get_matrix();
glPushName(reinterpret_cast<unsigned>(this));
}
-void Track3D::finish_render(const GL::Tag &) const
+void Track3D::finish_render(Msp::GL::Renderer &, const GL::Tag &) const
{
glPopName();
- GL::MatrixStack::modelview().pop();
+}
+
+void Track3D::link_changed(unsigned i, Track *trk)
+{
+ if(!trk || trk>&track)
+ {
+ if(!endpoints[i])
+ endpoints[i] = new Endpoint3D(*this, i);
+ }
+ else if(endpoints[i])
+ {
+ delete endpoints[i];
+ endpoints[i] = 0;
+ }
}
} // namespace R2C2