--- /dev/null
+#include "libr2c2/blockiter.h"
+#include "libr2c2/trackiter.h"
+#include "layout.h"
+#include "path.h"
+#include "track.h"
+#include "trackcircuit.h"
+
+using namespace std;
+using namespace Msp;
+
+namespace R2C2 {
+
+TrackCircuit3D::TrackCircuit3D(Layout3D &l, TrackCircuit &tc):
+ Utility3D(l),
+ track_circuit(tc)
+{
+ Block *block = track_circuit.get_block();
+ TrackIter iter = BlockIter(block, 0).track_iter();
+ for(; (iter && &iter->get_block()==block); iter=iter.next())
+ {
+ Path3D *path = new Path3D(layout.get<Track3D>(*iter));
+ paths.push_back(path);
+ path->set_side(iter.entry()*2-1);
+ }
+
+ track_circuit.signal_state_changed.connect(sigc::mem_fun(this, &TrackCircuit3D::state_changed));
+ state_changed(track_circuit.get_state());
+}
+
+void TrackCircuit3D::state_changed(Sensor::State state)
+{
+ GL::Color color;
+ if(state>=Sensor::ACTIVE)
+ color = GL::Color(0.3f, 0.8f, 0.0f);
+ else if(state>Sensor::INACTIVE)
+ color = GL::Color(0.6f, 0.5f, 0.0f);
+ else
+ color = GL::Color(0.0f, 0.3f, 0.6f);
+
+ for(list<Path3D *>::const_iterator i=paths.begin(); i!=paths.end(); ++i)
+ (*i)->set_color(color);
+}
+
+} // namespace R2C2