--- /dev/null
+#include "layout.h"
+#include "path.h"
+#include "trackchain.h"
+#include "track.h"
+
+using namespace Msp;
+
+namespace R2C2 {
+
+TrackChain3D::TrackChain3D(Layout3D &l, TrackChain &r):
+ layout(l),
+ chain(r),
+ layer(0)
+{
+ chain.signal_track_added.connect(sigc::mem_fun(this, &TrackChain3D::track_added));
+ chain.signal_track_removed.connect(sigc::mem_fun(this, &TrackChain3D::track_removed));
+
+ const TrackChain::TrackSet &tracks = chain.get_tracks();
+ for(TrackChain::TrackSet::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
+ track_added(**i);
+}
+
+TrackChain3D::~TrackChain3D()
+{
+ for(PathMap::iterator i=paths.begin(); i!=paths.end(); ++i)
+ delete i->second;
+}
+
+void TrackChain3D::set_color(const GL::Color &c)
+{
+ color = c;
+ for(PathMap::iterator i=paths.begin(); i!=paths.end(); ++i)
+ i->second->set_color(color);
+}
+
+void TrackChain3D::set_layer(float l)
+{
+ layer = l;
+ for(PathMap::iterator i=paths.begin(); i!=paths.end(); ++i)
+ i->second->set_layer(layer);
+}
+
+void TrackChain3D::track_added(Track &track)
+{
+ Track3D &track_3d = layout.get<Track3D>(track);
+ Path3D *path = new Path3D(track_3d);
+ paths.insert(PathMap::value_type(&track, path));
+ path->set_color(color);
+ path->set_layer(layer);
+}
+
+void TrackChain3D::track_removed(Track &track)
+{
+ PathMap::iterator i = paths.find(&track);
+ if(i!=paths.end())
+ {
+ delete i->second;
+ paths.erase(i);
+ }
+}
+
+} // namespace R2C2
--- /dev/null
+#ifndef R2C2_3D_TRACKCHAIN_H_
+#define R2C2_3D_TRACKCHAIN_H_
+
+#include <msp/gl/color.h>
+#include "libr2c2/trackchain.h"
+
+namespace R2C2 {
+
+class Layout3D;
+class Path3D;
+
+class TrackChain3D: public sigc::trackable
+{
+protected:
+ typedef std::map<Track *, Path3D *> PathMap;
+
+ Layout3D &layout;
+ TrackChain &chain;
+ PathMap paths;
+ Msp::GL::Color color;
+ float layer;
+
+public:
+ TrackChain3D(Layout3D &, TrackChain &);
+ ~TrackChain3D();
+
+ void set_color(const Msp::GL::Color &);
+ void set_layer(float);
+
+protected:
+ void track_added(Track &);
+ void track_removed(Track &);
+};
+
+} // namespace R2C2
+
+#endif