]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/layout.cpp
Add an internal layout to Catalogue for selecting tracks
[r2c2.git] / source / 3d / layout.cpp
index 1b54e4be7509dd487d519d31a14d827557bfb801..b95d4e59c835798d2df81530d060e6e7303bff7d 100644 (file)
@@ -7,6 +7,8 @@ Distributed under the GPL
 
 #include <algorithm>
 #include <limits>
+#include <msp/gl/clip.h>
+#include <msp/gl/matrix.h>
 #include <msp/gl/rendermode.h>
 #include <msp/gl/select.h>
 #include <msp/gl/texture.h>
@@ -25,6 +27,10 @@ Layout3D::Layout3D(Layout &l):
 {
        layout.signal_track_added.connect(sigc::mem_fun(this, &Layout3D::track_added));
        layout.signal_track_removed.connect(sigc::mem_fun(this, &Layout3D::track_removed));
+
+       const set<Track *> &ltracks = layout.get_tracks();
+       for(set<Track *>::iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
+               track_added(**i);
 }
 
 Layout3D::~Layout3D()
@@ -65,41 +71,22 @@ Track3D *Layout3D::pick_track(float x, float y, float size) const
        GL::select_buffer(select_buf);
        GL::render_mode(GL::SELECT);
 
-       glPushMatrix();
-       glLoadIdentity();
-
-       double clip[4];
-       clip[0] = 1;
-       clip[1] = 0;
-       clip[2] = x-size;
-       clip[3] = 0;
-       glClipPlane(GL_CLIP_PLANE0, clip);
-       glEnable(GL_CLIP_PLANE0);
-
-       clip[0] = -1;
-       clip[2] = -(x+size);
-       glClipPlane(GL_CLIP_PLANE1, clip);
-       glEnable(GL_CLIP_PLANE1);
-
-       clip[0] = 0;
-       clip[1] = 1;
-       clip[2] = y-size;
-       glClipPlane(GL_CLIP_PLANE2, clip);
-       glEnable(GL_CLIP_PLANE2);
-
-       clip[1] = -1;
-       clip[2] = -(y+size);
-       glClipPlane(GL_CLIP_PLANE3, clip);
-       glEnable(GL_CLIP_PLANE3);
+       {
+               GL::PushMatrix push_mat;
+               GL::load_identity();
 
-       glPopMatrix();
+               GL::ClipPlane(1, 0, x-size, 0).apply_to(0);
+               GL::ClipPlane(-1, 0, -x-size, 0).apply_to(1);
+               GL::ClipPlane(0, 1, y-size, 0).apply_to(2);
+               GL::ClipPlane(0, -1, -y-size, 0).apply_to(3);
+       }
 
        scene.render(0);
 
-       glDisable(GL_CLIP_PLANE0);
-       glDisable(GL_CLIP_PLANE1);
-       glDisable(GL_CLIP_PLANE2);
-       glDisable(GL_CLIP_PLANE3);
+       GL::ClipPlane::disable(0);
+       GL::ClipPlane::disable(1);
+       GL::ClipPlane::disable(2);
+       GL::ClipPlane::disable(3);
 
        GL::render_mode(GL::RENDER);
        Track3D *track = 0;