add prototype wrapping of the qt sequence browser
[mussa.git] / qui / seqbrowser / SequenceBrowserWidget.hpp
1 #ifndef _PATH_WIDGET_H_
2 #define _PATH_WIDGET_H_
3 #include <vector>
4
5 #include <boost/shared_ptr.hpp>
6
7 #include <QDir>
8 #include <QScrollArea>
9 #include <QSize>
10 #include <QWidget>
11
12 #include "alg/sequence.hpp"
13 #include "alg/glsequence.hpp"
14 #include "qui/seqbrowser/ScrollableSequenceBrowser.hpp"
15 #include "qui/seqbrowser/SequenceBrowserSidebar.hpp"
16
17 //! the master widget that makes a useful Sequence Browser
18 class SequenceBrowserWidget : public QScrollArea 
19 {
20   Q_OBJECT 
21
22 public:
23   SequenceBrowserWidget(QWidget *parent=0);
24   SequenceBrowserWidget(const SequenceBrowserWidget &);
25   SequenceBrowserWidget(boost::shared_ptr<QDir>, QWidget *parent=0);
26
27   //! return our wrapped browser, so we can test it.
28   SequenceBrowser& browser() { return scrollable_browser->browser(); }
29   
30   //! return the popup menu for the glcanvas (reference stored internally)
31   QMenu *getPopupMenu();
32   //! return our fasta copy action (reference stored internally)
33   QAction *getCopySelectedSequenceAsFastaAction();
34   //! return our string copy action (reference stored internally)
35   QAction *getCopySelectedSequenceAsStringAction();
36   //! return sequence properties edit action
37   QAction *getEditSequencePropertiesAction();
38
39   QSize sizeHint() const;
40     
41   //! copy selected track regions into a list of SequenceLocations
42   void copySelectedTracksAsSeqLocation(std::list<SequenceLocation>& );
43
44   //! return current zoom size
45   double zoom();
46
47   //! reset all of our stored data back to the empty state
48   void clear();
49
50   /* Attach sequences to our browser, its best to attach them all
51    * at once, as otherwise the Sidebar has some rendering trouble
52    * as it draw and redraws the SequenceDescriptions in the various
53    * positions.
54    */
55   void setSequences(
56       const std::vector< boost::shared_ptr<Sequence> >& sequences, 
57       boost::shared_ptr<AnnotationColors> cm);
58   void setSequences(std::vector<boost::shared_ptr<GlSequence> >& sequences);
59   const std::vector<boost::shared_ptr<GlSequence> >& sequences() const;
60
61   //! reset just the links we're displaying
62   void clear_links();
63   //! set per species links
64   void link(const std::vector<int> &path, const std::vector<bool>& isRC, int length);
65   // return set of pathids defined by order of link calls
66   const std::set<int> selectedPaths() const;
67   void centerOnPath(const std::vector<int>& paths);
68  
69 public slots:
70   //! copy selected sequence
71   void copySelectedSequenceAsFasta();
72
73   //! set the zoom level of our browser
74   void setZoom(double);
75   //! zoom to fit the whole scene on the screen
76   double zoomOut();
77   //! zoom to sequence
78   double zoomToSequence();
79
80   void updatePosition();
81   //! ask the user where to save an image of the current browser view
82   void promptSaveBrowserPixmap();
83
84   void update();
85   
86 signals:
87   //! emit when someone copies basepairs
88   void basepairsCopied(size_t);
89   //! emit when sequence browser alerts this widget of mouse wheel zoom event
90   void mouseWheelZoom(double);
91   
92 private:
93   boost::shared_ptr<QDir> default_dir;
94   ScrollableSequenceBrowser *scrollable_browser;
95   SequenceBrowserSidebar *left_sidebar;
96   SequenceBrowserSidebar *right_sidebar;
97   QHBoxLayout *layout;
98   QWidget *layout_container;
99
100   //! sequences created by a setSequences(vector<Sequences>) call
101   /*! I need to save them so i can free them to avoid a memory leak 
102    */
103   std::vector<GlSequenceRef > converted_sequences;
104
105   //! shared code for constructors
106   void init();
107 };
108 #endif