]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/overlay.h
Add an overlay to display aspects of tracks
[r2c2.git] / source / 3d / overlay.h
diff --git a/source/3d/overlay.h b/source/3d/overlay.h
new file mode 100644 (file)
index 0000000..0a9a022
--- /dev/null
@@ -0,0 +1,60 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2010 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#ifndef MARKLIN3D_OVERLAY_H_
+#define MARKLIN3D_OVERLAY_H_
+
+#include <msp/gbase/window.h>
+#include <msp/gl/camera.h>
+#include <msp/gl/font.h>
+#include <msp/gl/mesh.h>
+#include <msp/gl/renderable.h>
+
+namespace Marklin {
+
+class Track3D;
+
+class Overlay3D: public Msp::GL::Renderable
+{
+private:       
+       struct Icon
+       {
+               std::vector<const Msp::GL::Mesh *> graphics;
+               std::string label;
+               float width;
+               Msp::GL::Mesh background;
+
+               Icon();
+       };
+
+       const Msp::Graphics::Window &window;
+       const Msp::GL::Camera &camera;
+       const Msp::GL::Font &font;
+       std::map<std::string, Msp::GL::Mesh *> graphics;
+       std::map<const Track3D *, Icon *> icons;
+
+public:
+       Overlay3D(const Msp::Graphics::Window &, const Msp::GL::Camera &, const Msp::GL::Font &);
+       ~Overlay3D();
+
+       void set_label(const Track3D &, const std::string &);
+       void add_graphic(const Track3D &, const std::string &);
+       void remove_graphic(const Track3D &, const std::string &);
+       void clear_graphics(const Track3D &);
+       void clear(const Track3D &);
+
+       virtual void render(const Msp::GL::Tag &) const;
+
+private:
+       Icon &get_icon(const Track3D &);
+       const Msp::GL::Mesh *get_graphic(const std::string &);
+       void update_icon(Icon &);
+};
+
+} // namespace Marklin
+
+#endif