partial implementation of sequence track copy
[mussa.git] / alg / glseqbrowser.hpp
index 5a6638d5049fb2552961b892ec5a9db796d00668..109bc5055b0d1d5ed46f3c810de5ddf41cebadaa 100644 (file)
@@ -51,11 +51,12 @@ public:
   //! zoom in to a reasonable sequence view
   double zoomToSequence();
   //! set the current zoom level in (base pairs / pix )
-  /*! its a double as zoom levels of [0.01, 1.0] make nice sequence views
-   */
+  //! its a double as zoom levels of [0.01, 1.0] make nice sequence views
   void setZoom(double zoom_level);
   //! returns the current zoom level as basepairs per pixel
   double zoom() const;
+  //! center the provided path in the current viewport
+  void centerOnPath(const std::vector<int>&);
 
   void setColorMapper(AnnotationColors& cm);
   AnnotationColors& colorMapper();
@@ -76,9 +77,16 @@ public:
   void link(const std::vector<int>& path, const std::vector<bool>& isRC, int length);
   //! returns the index of pathids based on order added by link
   const std::set<int>& selectedPaths() const;
-  //! center the provided path in the current viewport
-  void centerOnPath(const std::vector<int>&);
-
+  //! define our function for formating sequence copy
+  typedef std::string format_track(const Sequence& s, int left, int right);
+  //! copy sequence from selected track using formating function
+  void copySelectedTracks(std::string& copy_buffer, format_track func);
+  //! copy sequence from selected tracks as plain sequences
+  void copySelectedTracksAsString(std::string& copy_buffer);
+  //! copy sequence from selected tracks as FASTA sequences
+  void copySelectedTracksAsFasta(std::string& copy_buffer);
+  
+  
   //! Provide a logical name for a type discriminator for our glName stack
   enum FeatureType { MussaTrack, MussaSegment };
 
@@ -124,6 +132,21 @@ public:
   typedef std::map<segment_key, Segment> pair_segment_map;
   typedef std::vector<pair_segment_map> path_segment_map_vector;
   path_segment_map_vector path_segments;
+
+  struct TrackRegion
+  {
+    GLuint track_id;
+    int left;
+    int right;
+
+    TrackRegion():track_id(0), left(0), right(0) {};
+    TrackRegion(const TrackRegion& o)
+      : track_id(o.track_id), left(o.left), right(o.right) {}
+    TrackRegion(GLuint id, int l, int r)
+      : track_id(id), left(l), right(r) {}
+    void set(GLuint id, int l, int r) { track_id = id; left=l; right=r; };
+  };
+
 private:
   //! recalculate the viewable world
   /*! depending on the size of our canvas, our zoom level and
@@ -135,7 +158,10 @@ private:
   void update_layout();
 
   //! convert opengl selections into the list of paths we should highlight
-  void processSelection(GLuint hits, GLuint buffer[], GLuint bufsize);
+  void processSelection(GLuint hits, 
+                        GLuint buffer[], 
+                        GLuint bufsize, 
+                        const rect<float>& r);
 
   //! master scene drawing function
   /*! draw is broken out for the opengl selection code
@@ -164,14 +190,14 @@ private:
   int pathid;
 
 protected:
-  //! where to draw our box 
+  //! where to draw our box (world coordinates)
   rect<float> selectedRegion;
   //! true if we have a selection
   bool selectedMode;
   //! indicate which paths are selected
   std::set<int> selected_paths;
   //! which track is selected (it only makes sense to have one track selected).
-  std::set<int> selected_tracks;
-
+  std::list<TrackRegion> selected_tracks;
+  typedef std::list<TrackRegion>::iterator selected_track_iterator;
 };
 #endif