load and display a motif list
[mussa.git] / qui / PathScene.hpp
1 #ifndef _PATHSCENE_H_
2 #define _PATHSCENE_H_
3
4 #include <QGLWidget>
5 #include <QRectF>
6 #include <QPoint>
7 #include <vector>
8 #include <GL/gl.h>
9
10 #include "alg/mussa.hpp"
11 #include "alg/glsequence.hpp"
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 motifs
43   void loadMotifList();
44   //! load a mussa parameter file (which specifies an analysis to run)
45   void loadMupa();
46   //! load a previously run analysis
47   void loadSavedAnalysis();
48   //! set the soft threshold used by the Nway_Path algorithm
49   void setSoftThreshold(int thres);
50   //! indicate that we should update our scene
51   void updateScene();
52
53 signals:
54   //! emitted when our analysis has changed
55   void analysisUpdated();
56   void viewportChanged();
57
58 protected:
59   int viewport_height;
60   int viewport_width;
61   double clipZ;
62   int zoom;
63   QRectF maxOrtho2d;
64   QRectF curOrtho2d;
65   //! where the "center" of the viewport is
66   float viewport_center;
67   //! true if we have a selection
68   bool selectedMode;
69   //! indicate which paths are selected
70   std::vector<bool> selectedPaths;
71   //! which track is selected (it only makes sense to have one track selected).
72   unsigned int selectedTrack;
73
74   void initializeGL();
75   void resizeGL(int width, int height);
76   void paintGL();
77   // recompute our current viewport dimensions, used by setViewportX & setZoom
78   void updateViewport(float left, int new_zoom);
79
80   void mussaesque();
81   //! draw all of our sequence tracks
82   void draw_tracks() const;
83   void draw_lines() const;
84   GLuint make_line_list();
85   //! convert opengl selections into the list of paths we should highlight
86   void processSelection(GLuint hits, GLuint buffer[], GLuint bufsize);
87   //! Provide a logical name for a type discriminator for our glName stack
88   enum FeatureType { MussaTracks, MussaPaths };
89
90   //! \defgroup Selection
91   QRubberBand *rubberBand;
92   QPoint bandOrigin;
93   QRectF previousBand;
94   bool drawingBand;
95   void mousePressEvent(QMouseEvent *);
96   void mouseMoveEvent(QMouseEvent *);
97   void mouseReleaseEvent(QMouseEvent *);
98
99 };
100 #endif