My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
ImagePlotter.h
Go to the documentation of this file.
1 // $Id: ImagePlotter.h,v 1.1.1.1 2009/07/06 23:57:23 eml Exp $
2 
3 #ifndef GCP_GRABBER_IMAGEPLOTTER_H
4 #define GCP_GRABBER_IMAGEPLOTTER_H
5 
16 #include <iostream>
17 
18 #include "gcp/util/common/ImageHandler.h"
19 
20 #include "gcp/util/common/Angle.h"
21 
22 #include "gcp/control/code/unix/viewer_src/color_tab.h"
23 
24 namespace gcp {
25  namespace grabber {
26 
28  public:
29 
33  ImagePlotter();
34 
38  friend std::ostream& operator<<(std::ostream& os, ImagePlotter& obj);
39 
43  virtual ~ImagePlotter();
44 
45  // Open a new pgplot device
46 
47  void open(char* device);
48 
49  void draw(bool cmapUpdate=false);
50  void drawDouble();
51 
52  void setGridInterval(gcp::util::Angle& interval);
53 
54  // Install a new image in the image buffer
55 
56  void installNewImage(unsigned short* image);
57 
58  void testDraw();
59 
60  // Given a pixel, in grabber pixel orientation, return the world
61  // coordinate
62 
63  void pixelToWorld(unsigned ix, unsigned iy, double& x, double& y);
64 
65  // Convert from world to pixel coordinate. If truncate = true,
66  // and the world coordinate lies outside the image boundary, the
67  // returned pixel values will be truncated to the nearest valid
68  // pixel. If truncate = false, this function will throw an
69  // error if the world coordinate lies outside the image
70 
71  void worldToPixel(double x, double y, unsigned& ix, unsigned& iy,
72  bool truncate=false);
73 
74  void worldToSkyOffset(double x, double y,
75  gcp::util::Angle& xsky, gcp::util::Angle& ysky);
76 
77  // Reset plot limits
78 
79  void setPlotBoundaries();
80 
81  // Calculate plot limits
82 
83  void calculatePlotLimits();
84 
85  // Set a peak location (in pixel units)
86 
87  void setPeak(unsigned ix, unsigned iy);
88 
89  bool& doGrid() {
90  return doGrid_;
91  }
92 
93  bool& doCompass() {
94  return doCompass_;
95  }
96 
97  bool& doBullseye() {
98  return doBullseye_;
99  }
100 
101  bool& doCrosshair() {
102  return doCrosshair_;
103  }
104 
105  bool& doBoxes() {
106  return doBoxes_;
107  }
108 
109  void setContrast(double contrast = defaultContrast_);
110  void setBrightness(double brightness = defaultBrightness_);
111 
112  void installColormap(std::string cmap);
113  std::string colormapName();
114 
115  // Fiddle the contrast and brightness of a frame grabber image
116 
117  void fiddleContrast(double xa, double ya);
118 
119  void setDisplayedRange(double xa, double xb, double ya, double yb);
120  void setDisplayedRange();
121 
122  void setPgplotId(int pgplotId);
123  int pgplotId();
124 
125  void initialize();
126  void getGreyscale();
127  void drawImage(bool cmapUpdate=false);
128  void drawGrid();
129  void drawBullseye();
130  void drawCompass();
131  void drawCrosshair();
132  void drawBoxes();
133 
134  static const double defaultContrast_;
135  static const double defaultBrightness_;
136 
137  private:
138 
139  bool first_;
140  int pgplotId_;
141  double wxa_, wxb_;
142  double wya_, wyb_;
143  double dwx_, dwy_;
144 
145  double wxaDisp_, wxbDisp_;
146  double wyaDisp_, wybDisp_;
147 
148  // Greyscale limits
149 
150  double wza_, wzb_;
151 
152  gcp::util::Angle gridInterval_;
153 
154  bool isZoomed_;
155  bool imageReceived_;
156  bool doGrid_;
157  bool doBullseye_;
158  bool doCompass_;
159  bool doCrosshair_;
160  bool doBoxes_;
161  bool havePeak_;
162 
163  unsigned ixpeak_, iypeak_;
164 
165  double contrast_;
166  double brightness_;
167  double backoff_;
168 
169  Cmap* cmap_; // The color map for image display
170 
171  float imageToPlot_[GRABBER_IM_SIZE];
172 
173  }; // End class ImagePlotter
174 
175  } // End namespace grabber
176 } // End namespace gcp
177 
178 #endif // End #ifndef GCP_GRABBER_IMAGEPLOTTER_H
void drawGrid()
Definition: ImagePlotter.cc:378
friend std::ostream & operator<<(std::ostream &os, ImagePlotter &obj)
virtual ~ImagePlotter()
Definition: ImagePlotter.cc:41
void drawBoxes()
Definition: ImagePlotter.cc:556
void installNewImage(unsigned short *image)
Definition: ImagePlotter.cc:590
void fiddleContrast(double xa, double ya)
Definition: ImagePlotter.cc:774
void pixelToWorld(unsigned ix, unsigned iy, double &x, double &y)
Definition: ImagePlotter.cc:671
void drawCompass()
Definition: ImagePlotter.cc:431
Definition: ImageHandler.h:30
void draw(bool cmapUpdate=false)
Definition: ImagePlotter.cc:103
ImagePlotter()
Definition: ImagePlotter.cc:24
void calculatePlotLimits()
Definition: ImagePlotter.cc:291
void drawBullseye()
Definition: ImagePlotter.cc:411
void drawDouble()
Definition: ImagePlotter.cc:146
void drawCrosshair()
Definition: ImagePlotter.cc:523
void getGreyscale()
Definition: ImagePlotter.cc:324
void setPlotBoundaries()
Definition: ImagePlotter.cc:279
Definition: Angle.h:20
void worldToPixel(double x, double y, unsigned &ix, unsigned &iy, bool truncate=false)
Definition: ImagePlotter.cc:693
Definition: ImagePlotter.h:27
void initialize()
Definition: ImagePlotter.cc:52
Definition: color_tab.h:50
void drawImage(bool cmapUpdate=false)
Definition: ImagePlotter.cc:206