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