factor out viewport to display scaling functions
[mussa.git] / alg / glseqbrowser.hpp
index 38ede4bc05476ffa32458850db76aafe9ae1e368..f88caf5e7e5bb57e4dea0b1ff56f20d4f8c21408 100644 (file)
@@ -28,6 +28,8 @@ public:
 
   //! select a region (using canvas coordinates)
   void selectRegion(int top, int left, int bottom, int right);
+  //! turn off selection
+  void clearSelection();
 
   //! border size
   float border() const;
@@ -55,6 +57,11 @@ public:
   int viewportPixelHeight() const;
   //! return viewport width in pixels
   int viewportPixelWidth() const;
+  
+  //! convert x axis from display to world coordinates
+  float viewportXtoWorldX(int x);
+  //! convert y axis from display to world coordinates
+  float viewportYtoWorldY(int y);
 
   //! zoom out far enough to show the full size of the sequence
   double zoomOut();
@@ -69,7 +76,7 @@ public:
   void centerOnPath(const std::vector<int>&);
 
   void setColorMapper(boost::shared_ptr<AnnotationColors> cm);
-  const AnnotationColors& colorMapper();
+  const AnnotationColorsRef colorMapper();
 
   //! clear our tracks and connections
   void clear();
@@ -208,13 +215,13 @@ private:
   //! the center of our current viewport (world coord) (used for scrollbar)
   float viewport_center;
   double zoom_level;
-  boost::shared_ptr<AnnotationColors> color_mapper;
+  AnnotationColorsRef color_mapper;
   //! counter for each path added to us via connect
   int pathid;
 
 protected:
   //! container of all the GlSequences loaded into our scene
-  std::vector<boost::shared_ptr<GlSequence> > track_container;
+  std::vector<GlSequenceRef > track_container;
   //! where to draw our box (world coordinates)
   rect<float> selectedRegion;
   //! true if we have a selection
@@ -225,4 +232,15 @@ protected:
   std::list<TrackRegion> selected_tracks;
   typedef std::list<TrackRegion>::iterator selected_track_iterator;
 };
+
+inline float GlSeqBrowser::viewportXtoWorldX(int x) {
+  GLfloat x_scale = cur_ortho.width()/((float)viewport_size.x);
+  return (cur_ortho.left + (x * x_scale));
+}
+
+inline float GlSeqBrowser::viewportYtoWorldY(int y) {
+  GLfloat y_scale = cur_ortho.height()/((float)viewport_size.y);
+  return cur_ortho.top-(y * y_scale);
+}
+
 #endif