4819c6715bbd8eee7bdbc901dfef12a7c591b3ee
[mussa.git] / qui / PathScene.h
1 #ifndef _PATHSCENE_H_
2 #define _PATHSCENE_H_
3
4 #include <QGLWidget>
5 #include <QRectF>
6 #include <QPoint>
7 #include <vector>
8
9 #include "alg/mussa_class.hh"
10 #include "alg/glsequence.h"
11 #include "GL/gl.h"
12
13 class QMouseEvent;
14 class QRubberBand;
15
16 /*! \brief Render mussa sequences and paths 
17  */
18 class PathScene: public QGLWidget
19 {
20   Q_OBJECT
21
22 public: 
23   PathScene(Mussa *analysis=0,  QWidget *parent=0);
24
25   QSize sizeHint() const;
26
27   Mussa* mussaAnalysis;
28   std::vector<GlSequence> tracks;
29
30   float left();
31   float right();
32   float viewportLeft();
33   float viewportRight();
34   float viewportCenter();
35     
36 public slots:
37   void setClipPlane(int z);
38   //! set the center of the current viewport
39   void setViewportX(float x);
40   //! set our magnification level
41   void setZoom(int);
42   //! load a mussa parameter file (which specifies an analysis to run)
43   void loadMupa( );
44   //! load a previously run analysis
45   void loadSavedAnalysis();
46   //! set the soft threshold used by the Nway_Path algorithm
47   void setSoftThreshold(int thres);
48   //! indicate that we should update our scene
49   void updateScene();
50
51 signals:
52   //! emitted when our analysis has changed
53   void analysisUpdated();
54   void viewportChanged();
55
56 protected:
57   int viewport_height;
58   int viewport_width;
59   double clipZ;
60   int zoom;
61   QRectF maxOrtho2d;
62   QRectF curOrtho2d;
63   //! where the "center" of the viewport is
64   float viewport_center;
65   //! true if we have a selection
66   bool selectedMode;
67   //! indicate which paths are selected
68   std::vector<bool> selectedPaths;
69   //! which track is selected (it only makes sense to have one track selected).
70   unsigned int selectedTrack;
71
72   void initializeGL();
73   void resizeGL(int width, int height);
74   void paintGL();
75   // recompute our current viewport dimensions, used by setViewportX & setZoom
76   void updateViewport(float left, int new_zoom);
77
78   void mussaesque();
79   //! draw all of our sequence tracks
80   void draw_tracks() const;
81   void draw_lines() const;
82   GLuint make_line_list();
83   //! convert opengl selections into the list of paths we should highlight
84   void processSelection(GLuint hits, GLuint buffer[], GLuint bufsize);
85   //! Provide a logical name for a type discriminator for our glName stack
86   enum FeatureType { MussaTracks, MussaPaths };
87
88   //! \defgroup Selection
89   QRubberBand *rubberBand;
90   QPoint bandOrigin;
91   QRectF previousBand;
92   bool drawingBand;
93   void mousePressEvent(QMouseEvent *);
94   void mouseMoveEvent(QMouseEvent *);
95   void mouseReleaseEvent(QMouseEvent *);
96
97 };
98 #endif