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