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());
32 void PathScene::setViewportCenter(float x)
34 const float epsilon = 1e-10;
35 float center = GlTracks::viewportCenter();
36 float difference = fabsf(x - center);
37 float abs_x = fabsf(x);
38 center = fabsf(center);
40 // the difference < epsilon * val is one of the recommended tests
41 // for float equality.
42 // of course since we're looking for not equals, we need to toss a
43 // not at the beginning
44 if (not (difference < epsilon * abs_x or difference < epsilon * center))
46 GlTracks::setViewportCenter(x);
47 emit viewportChanged();
52 void PathScene::setZoom(int new_zoom)
54 if (new_zoom != GlTracks::zoom()) {
55 GlTracks::setZoom(new_zoom);
56 emit viewportChanged();
61 void PathScene::setClipPlane(int )
64 if (clipZ != (double) newZ){
65 clipZ = (double) newZ;
73 void PathScene::initializeGL()
75 GlTracks::initializeGL();
78 void PathScene::resizeGL(int width, int height)
80 GlTracks::resizeGL(width, height);
83 void PathScene::paintGL()
88 void PathScene::mousePressEvent( QMouseEvent *e)
93 bandOrigin = e->pos();
95 rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
97 rubberBand->setGeometry(QRect(bandOrigin, QSize()));
101 void PathScene::mouseMoveEvent( QMouseEvent *e)
104 rubberBand->setGeometry(QRect(bandOrigin, e->pos()).normalized());
107 void PathScene::mouseReleaseEvent( QMouseEvent *e)
111 QRect r = QRect(bandOrigin, e->pos()).normalized();
112 bandOrigin = r.topLeft();
114 selectRegion(r.top(), r.left(), r.bottom(), r.right());