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