14 #include "qui/PathScene.hpp"
15 #include "alg/glsequence.hpp"
16 #include "mussa_exceptions.hpp"
20 PathScene::PathScene(QWidget *parent)
27 QSize PathScene::sizeHint() const
29 //return QSize((int)GlTracks::viewportHeight(), (int)GlTracks::viewportWidth());
30 return QSize(600, 400);
33 void PathScene::setViewportCenter(float x)
35 const float epsilon = 1e-10;
36 float center = GlTracks::viewportCenter();
37 float difference = fabsf(x - center);
38 float abs_x = fabsf(x);
39 center = fabsf(center);
41 // the difference < epsilon * val is one of the recommended tests
42 // for float equality.
43 // of course since we're looking for not equals, we need to toss a
44 // not at the beginning
45 if (not (difference < epsilon * abs_x or difference < epsilon * center))
47 GlTracks::setViewportCenter(x);
48 emit viewportChanged();
53 void PathScene::setZoom(int new_zoom)
55 if (new_zoom != GlTracks::zoom()) {
56 GlTracks::setZoom(new_zoom);
57 emit viewportChanged();
62 void PathScene::setClipPlane(int )
65 if (clipZ != (double) newZ){
66 clipZ = (double) newZ;
72 void PathScene::clear()
78 void PathScene::push_sequence(const Sequence &s)
80 GlTracks::push_sequence(s);
84 void PathScene::push_sequence(GlSequence &gs)
86 GlTracks::push_sequence(gs);
92 void PathScene::initializeGL()
94 GlTracks::initializeGL();
97 void PathScene::resizeGL(int width, int height)
99 GlTracks::resizeGL(width, height);
102 void PathScene::paintGL()
107 void PathScene::mousePressEvent( QMouseEvent *e)
111 selectedMode = false;
112 bandOrigin = e->pos();
114 rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
116 rubberBand->setGeometry(QRect(bandOrigin, QSize()));
120 void PathScene::mouseMoveEvent( QMouseEvent *e)
123 rubberBand->setGeometry(QRect(bandOrigin, e->pos()).normalized());
126 void PathScene::mouseReleaseEvent( QMouseEvent *e)
130 QRect r = QRect(bandOrigin, e->pos()).normalized();
131 bandOrigin = r.topLeft();
133 selectRegion(r.top(), r.left(), r.bottom(), r.right());