record selected track
[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 "qui/GlSequence.h"
11
12 class QMouseEvent;
13 class QRubberBand;
14
15 /*! \brief Render mussa sequences and paths 
16  */
17 class PathScene: public QGLWidget
18 {
19   Q_OBJECT
20
21 public: 
22   PathScene(Mussa *analysis=0,  QWidget *parent=0);
23
24   QSize sizeHint() const;
25
26   Mussa* mussaAnalysis;
27   std::vector<GlSequence> tracks;
28
29 public slots:
30   void setX(int x);
31   void setClipPlane(int z);
32   void setZoom(int);
33   //! load a mussa parameter file (which specifies an analysis to run)
34   void loadMupa( );
35   //! load a previously run analysis
36   void loadSavedAnalysis();
37   //! set the soft threshold used by the Nway_Path algorithm
38   void setSoftThreshold(int thres);
39   //! indicate that we should update our scene
40   void updateScene();
41
42 signals:
43   //! emitted when our analysis has changed
44   void analysisUpdated();
45
46 protected:
47   int X;
48   double clipZ;
49   int zoom;
50   QRectF maxOrtho2d;
51   QRectF curOrtho2d;
52   // true if we have a selection
53   bool selectedMode;
54   // indicate which paths are selected
55   std::vector<bool> selectedPaths;
56   // which track is selected (it only makes sense to have one track selected).
57   unsigned int selectedTrack;
58
59   void initializeGL();
60   void resizeGL(int width, int height);
61   void paintGL();
62
63   void mussaesque();
64   //! draw all of our sequence tracks
65   void draw_tracks() const;
66   void draw_lines() const;
67   GLuint make_line_list();
68   //! convert opengl selections into the list of paths we should highlight
69   void processSelection(GLuint hits, GLuint buffer[], GLuint bufsize);
70   //! Provide a logical name for a type discriminator for our glName stack
71   enum FeatureType { MussaTracks, MussaPaths };
72
73   //! \defgroup Selection
74   QRubberBand *rubberBand;
75   QPoint bandOrigin;
76   QRectF previousBand;
77   bool drawingBand;
78   void mousePressEvent(QMouseEvent *);
79   void mouseMoveEvent(QMouseEvent *);
80   void mouseReleaseEvent(QMouseEvent *);
81
82 };
83 #endif