Isis 3 Developer Reference
ChipViewport.h
Go to the documentation of this file.
1 #ifndef ChipViewport_h
2 #define ChipViewport_h
3 
26 #include <QPaintEvent>
27 #include <QResizeEvent>
28 #include <QWidget>
29 
30 #include "Chip.h"
31 #include "Histogram.h"
32 #include "Stretch.h"
33 
34 class QImage;
35 
36 namespace Isis {
37  class ControlNet;
38  class CubeViewport;
39 
85  class ChipViewport : public QWidget {
86  Q_OBJECT
87 
88 
89  public:
90  ChipViewport(int width, int height, QWidget *parent = 0);
91  virtual ~ChipViewport();
92 
93  bool cubeToViewport(double samp, double line, int &x, int &y);
94 
96  void setChip(Chip *chip, Cube *chipCube);
97 
99  void loadView(ChipViewport &newView);
100 
102  Chip *chip() const {
103  return m_chip;
104  };
105 
106  Cube *chipCube() const {
107  return m_chipCube;
108  };
109 
111  int chipSamples() const {
112  return m_chip->Samples();
113  };
114 
116  int chipLines() const {
117  return m_chip->Lines();
118  };
119 
121  int grayBand() const {
122  return m_gray.band;
123  };
124 
126  double tackSample();
127  double tackLine();
128 
130  double zoomFactor();
131 
133  //void markPoint (double sample, double line);
134 
137  return m_gray.stretch;
138  };
139 
140 
141  signals:
143  void tackPointChanged(double);
144 
145  // TODO: This needs better name, tackPointChanged signal is emitted
146  // even if user does not initiate, maybe change tackPointChanged signal
147  // to only emit if user moves the tack point???
148  void userMovedTackPoint();
149 
150 
151  public slots:
152  void autoStretch();
154  void changeStretchLock(int);
155  void setPoints(bool checked);
156  void setCross(bool checked);
157  void rotateChip(int rotation);
158  void setCircle(bool checked);
159  void setCircleSize(int size);
160 
161  void geomChip(Chip *matchChip, Cube *matchChipCube);
162  void nogeomChip();
163 
164  void panUp();
165  void panDown();
166  void panLeft();
167  void panRight();
168 
169  void zoomIn();
170  void zoomOut();
171  void zoom1();
172  void zoom(double zoomFactor);
173 
174  void refreshView(double tackSample, double tackLine);
175 
181  void setControlNet(ControlNet *newControlNet) {
182  m_controlNet = newControlNet;
183  }
184 
185 
186  protected:
187  void paintEvent(QPaintEvent *e);
188  void enterEvent(QEvent *e);
189  void keyPressEvent(QKeyEvent *e);
190  void mousePressEvent(QMouseEvent *event);
191 
192 
193  private:
194  void reloadChip(double tackSample = 0., double tackLine = 0.);
195 
196  void computeStretch(Stretch &stretch, bool force = false);
197  void paintImage();
198 
206  class BandInfo {
207  public:
208  int band;
209  Stretch stretch;
210  BandInfo() {
212  band = 1;
213  stretch.SetNull(0.0);
214  stretch.SetLis(0.0);
215  stretch.SetLrs(0.0);
216  stretch.SetHis(255.0);
217  stretch.SetHrs(255.0);
218  };
219  };
220 
221  BandInfo m_gray;
222  Chip *m_chip;
223  Cube *m_chipCube;
224 
225  int m_width;
226  int m_height;
227 
228  bool m_geomIt;
229  Chip *m_matchChip;
230  Cube *m_matchChipCube;
231 
232  double m_zoomFactor;
233  int m_rotation;
234 
235  QImage *m_image;
236  bool m_paintImage;
237  bool m_showPoints;
238  bool m_cross;
239  bool m_circle;
240  int m_circleSize;
241 
242  ChipViewport *m_tempView;
243 
244  // The ControlNet pointed to by this pointer is not owned by this class!
245  // It is ok for m_controlNet to be NULL any time. If it is not NULL then
246  // it is used to paint measures in the viewport.
247  //
248  // After construction, it is the responsibility of the user of this class
249  // to maintain this pointer with the setControlNet method (to make sure
250  // that either NULL or a valid ControlNet is being pointed to).
251  ControlNet *m_controlNet;
252 
253  bool m_stretchLocked;
254  Stretch *m_stretch;
255  };
256 };
257 
258 #endif
void zoom(double zoomFactor)
Zoom by a specified factor.
Definition: ChipViewport.cpp:446
void enterEvent(QEvent *e)
If mouse enters, make sure key events are processed w/o clicking.
Definition: ChipViewport.cpp:478
void panUp()
Pan up.
Definition: ChipViewport.cpp:365
int chipLines() const
Return the number of lines in the chip.
Definition: ChipViewport.h:116
void setCircleSize(int size)
Set the size of the circle.
Definition: ChipViewport.cpp:595
Stretch grayStretch() const
Draw X on point.
Definition: ChipViewport.h:136
A small chip of data used for pattern matching.
Definition: Chip.h:102
int grayBand() const
Return the gray band currently viewed.
Definition: ChipViewport.h:121
void zoomOut()
Zoom out.
Definition: ChipViewport.cpp:426
void SetLis(const double value)
Sets the mapping for LIS pixels.
Definition: Stretch.h:119
void setCross(bool checked)
Slot to change state of crosshair.
Definition: ChipViewport.cpp:564
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:132
double tackLine()
Returns tack line.
Definition: ChipViewport.cpp:356
double tackSample()
Return the position of cube under cross hair.
Definition: ChipViewport.cpp:345
void setControlNet(ControlNet *newControlNet)
sets the ControlNet to be used for drawing measure locations
Definition: ChipViewport.h:181
void rotateChip(int rotation)
Slot to rotate chip.
Definition: ChipViewport.cpp:669
Cube * chipCube() const
Definition: ChipViewport.h:106
void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
Definition: ChipViewport.cpp:488
void SetHrs(const double value)
Sets the mapping for HRS pixels.
Definition: Stretch.h:152
int Lines() const
Definition: Chip.h:122
virtual ~ChipViewport()
Destructor.
Definition: ChipViewport.cpp:59
a control network
Definition: ControlNet.h:271
Pixel value mapper.
Definition: Stretch.h:72
void SetLrs(const double value)
Sets the mapping for LRS pixels.
Definition: Stretch.h:130
void SetHis(const double value)
Sets the mapping for HIS pixels.
Definition: Stretch.h:141
void refreshView(double tackSample, double tackLine)
Slot to refresh viewport when the tack point has changed.
Definition: ChipViewport.cpp:468
void geomChip(Chip *matchChip, Cube *matchChipCube)
Slot to geom chip (apply geometry transformation)
Definition: ChipViewport.cpp:613
ChipViewport(int width, int height, QWidget *parent=0)
Construct an empty viewport.
Definition: ChipViewport.cpp:27
void paintEvent(QPaintEvent *e)
Repaint the viewport.
Definition: ChipViewport.cpp:256
double zoomFactor()
Return the zoom factor.
Definition: ChipViewport.cpp:457
void autoStretch()
Apply automatic stretch using data from entire chip.
Definition: ChipViewport.cpp:127
void zoom1()
Zoom by a factor of one.
Definition: ChipViewport.cpp:435
void mousePressEvent(QMouseEvent *event)
Process mouse events.
Definition: ChipViewport.cpp:526
void changeStretchLock(int)
Locks or unlocks the stretch on the chip viewport during transformations (zoom, pan, etc.)
Definition: ChipViewport.cpp:174
void panLeft()
Pan left.
Definition: ChipViewport.cpp:391
Viewport for Isis Chips.
Definition: ChipViewport.h:85
int Samples() const
Definition: Chip.h:115
void setChip(Chip *chip, Cube *chipCube)
Set chip.
Definition: ChipViewport.cpp:102
void tackPointChanged(double)
< Signal sent when tack point changes
void panRight()
Pan right.
Definition: ChipViewport.cpp:404
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void zoomIn()
Zoom in.
Definition: ChipViewport.cpp:417
void panDown()
Pan down.
Definition: ChipViewport.cpp:378
void setPoints(bool checked)
Slot to set whether control points are drawn.
Definition: ChipViewport.cpp:548
int chipSamples() const
Return the number of samples in the chip.
Definition: ChipViewport.h:111
void setCircle(bool checked)
Slot to change state of circle.
Definition: ChipViewport.cpp:580
Chip * chip() const
Return chip.
Definition: ChipViewport.h:102
void SetNull(const double value)
Sets the mapping for NULL pixels.
Definition: Stretch.h:108
void loadView(ChipViewport &newView)
Load with another ChipViewport, used for blinking.
Definition: ChipViewport.cpp:334
void stretchFromCubeViewport(Stretch *, CubeViewport *)
Applies a new stretch to the specified cube viewport.
Definition: ChipViewport.cpp:140
void nogeomChip()
Slot to un-geom chip (revert geometry transformation)
Definition: ChipViewport.cpp:641
bool cubeToViewport(double samp, double line, int &x, int &y)
Get viewport x and y from cube sample and line.
Definition: ChipViewport.cpp:77
IO Handler for Isis Cubes.
Definition: Cube.h:170