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