Isis Developer Reference
ChipViewport.h
Go to the documentation of this file.
1 #ifndef ChipViewport_h
2 #define ChipViewport_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <QPaintEvent>
13 #include <QResizeEvent>
14 #include <QWidget>
15 
16 #include "Chip.h"
17 #include "Histogram.h"
18 #include "Stretch.h"
19 
20 class QImage;
21 
22 namespace Isis {
23  class ControlNet;
24  class CubeViewport;
25 
71  class ChipViewport : public QWidget {
72  Q_OBJECT
73 
74 
75  public:
76  ChipViewport(int width, int height, QWidget *parent = 0);
77  virtual ~ChipViewport();
78 
79  bool cubeToViewport(double samp, double line, int &x, int &y);
80 
82  void setChip(Chip *chip, Cube *chipCube);
83 
85  void loadView(ChipViewport &newView);
86 
88  Chip *chip() const {
89  return m_chip;
90  };
91 
92  Cube *chipCube() const {
93  return m_chipCube;
94  };
95 
97  int chipSamples() const {
98  return m_chip->Samples();
99  };
100 
102  int chipLines() const {
103  return m_chip->Lines();
104  };
105 
107  int grayBand() const {
108  return m_gray.band;
109  };
110 
112  double tackSample();
113  double tackLine();
114 
116  double zoomFactor();
117 
119  //void markPoint (double sample, double line);
120 
123  return m_gray.stretch;
124  };
125 
126 
127  signals:
129  void tackPointChanged(double);
130 
131  // TODO: This needs better name, tackPointChanged signal is emitted
132  // even if user does not initiate, maybe change tackPointChanged signal
133  // to only emit if user moves the tack point???
135 
136 
137  public slots:
138  void autoStretch();
140  void changeStretchLock(int);
141  void setPoints(bool checked);
142  void setCross(bool checked);
143  void rotateChip(int rotation);
144  void setCircle(bool checked);
145  void setCircleSize(int size);
146 
147  void geomChip(Chip *matchChip, Cube *matchChipCube);
148  void nogeomChip();
149 
150  void panUp();
151  void panDown();
152  void panLeft();
153  void panRight();
154 
155  void zoomIn();
156  void zoomOut();
157  void zoom1();
158  void zoom(double zoomFactor);
159 
160  void refreshView(double tackSample, double tackLine);
161 
167  void setControlNet(ControlNet *newControlNet) {
168  m_controlNet = newControlNet;
169  }
170 
171 
172  protected:
173  void paintEvent(QPaintEvent *e);
174  void enterEvent(QEvent *e);
175  void keyPressEvent(QKeyEvent *e);
176  void mousePressEvent(QMouseEvent *event);
177 
178 
179  private:
180  void reloadChip(double tackSample = 0., double tackLine = 0.);
181 
182  void computeStretch(Stretch &stretch, bool force = false);
183  void paintImage();
184 
192  class BandInfo {
193  public:
194  int band;
195  Stretch stretch;
196  BandInfo() {
198  band = 1;
199  stretch.SetNull(0.0);
200  stretch.SetLis(0.0);
201  stretch.SetLrs(0.0);
202  stretch.SetHis(255.0);
203  stretch.SetHrs(255.0);
204  };
205  };
206 
207  BandInfo m_gray;
208  Chip *m_chip;
209  Cube *m_chipCube;
210 
211  int m_width;
212  int m_height;
213 
214  bool m_geomIt;
215  Chip *m_matchChip;
216  Cube *m_matchChipCube;
217 
218  double m_zoomFactor;
219  int m_rotation;
220 
221  QImage *m_image;
222  bool m_paintImage;
223  bool m_showPoints;
224  bool m_cross;
225  bool m_circle;
226  int m_circleSize;
227 
228  ChipViewport *m_tempView;
229 
230  // The ControlNet pointed to by this pointer is not owned by this class!
231  // It is ok for m_controlNet to be NULL any time. If it is not NULL then
232  // it is used to paint measures in the viewport.
233  //
234  // After construction, it is the responsibility of the user of this class
235  // to maintain this pointer with the setControlNet method (to make sure
236  // that either NULL or a valid ControlNet is being pointed to).
237  ControlNet *m_controlNet;
238 
239  bool m_stretchLocked;
240  Stretch *m_stretch;
241  };
242 };
243 
244 #endif
Isis::Chip::IsInsideChip
bool IsInsideChip(double sample, double line)
Definition: Chip.cpp:162
Isis::ChipViewport::chipLines
int chipLines() const
Return the number of lines in the chip.
Definition: ChipViewport.h:102
Stretch.h
Isis::ControlMeasure::Parent
ControlPoint * Parent()
Definition: ControlMeasure.h:260
QWidget
Isis::Cube::fileName
virtual QString fileName() const
Returns the opened cube's filename.
Definition: Cube.cpp:1563
Cube.h
Isis::ChipViewport::zoom
void zoom(double zoomFactor)
Zoom by a specified factor.
Definition: ChipViewport.cpp:454
Isis::ChipViewport::enterEvent
void enterEvent(QEvent *e)
If mouse enters, make sure key events are processed w/o clicking.
Definition: ChipViewport.cpp:486
Isis::ChipViewport::setCircleSize
void setCircleSize(int size)
Set the size of the circle.
Definition: ChipViewport.cpp:603
Isis::ChipViewport::grayStretch
Stretch grayStretch() const
Draw X on point.
Definition: ChipViewport.h:122
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::ChipViewport::grayBand
int grayBand() const
Return the gray band currently viewed.
Definition: ChipViewport.h:107
Isis::ChipViewport::zoomOut
void zoomOut()
Zoom out.
Definition: ChipViewport.cpp:434
Histogram.h
Isis::Stretch::SetLis
void SetLis(const double value)
Sets the mapping for LIS pixels.
Definition: Stretch.h:105
Isis::Chip::TackCube
void TackCube(const double cubeSample, const double cubeLine)
This sets which cube position will be located at the chip tack position.
Definition: Chip.cpp:182
Isis::Stretch
Pixel value mapper.
Definition: Stretch.h:58
Isis::SerialNumber::Compose
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
Definition: SerialNumber.cpp:38
Isis::Chip::GetValue
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition: Chip.h:145
Isis::Chip::ChipSample
double ChipSample() const
Definition: Chip.h:219
Isis::Chip::SetCubePosition
void SetCubePosition(const double sample, const double line)
Compute the position of the chip given a cube coordinate.
Definition: Chip.cpp:660
Isis::Stretch::SetHrs
void SetHrs(const double value)
Sets the mapping for HRS pixels.
Definition: Stretch.h:138
Isis::ChipViewport::setCross
void setCross(bool checked)
Slot to change state of crosshair.
Definition: ChipViewport.cpp:572
Isis::ControlNet::GetMeasuresInCube
QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber)
Get all the measures pertaining to a given cube serial number.
Definition: ControlNet.cpp:1065
Isis::ChipViewport::tackSample
double tackSample()
Return the position of cube under cross hair.
Definition: ChipViewport.cpp:353
Isis::Chip::CubeSample
double CubeSample() const
Definition: Chip.h:203
Isis::ChipViewport::chipCube
Cube * chipCube() const
Definition: ChipViewport.h:92
Isis::Stretch::SetLrs
void SetLrs(const double value)
Sets the mapping for LRS pixels.
Definition: Stretch.h:116
Isis::ChipViewport::tackLine
double tackLine()
Returns tack line.
Definition: ChipViewport.cpp:364
Isis::ControlNet::GetCubeSerials
QList< QString > GetCubeSerials() const
Use this method to get a complete list of all the cube serial numbers in the network.
Definition: ControlNet.cpp:1016
Isis::Stretch::SetHis
void SetHis(const double value)
Sets the mapping for HIS pixels.
Definition: Stretch.h:127
Isis::ControlMeasure::IsIgnored
bool IsIgnored() const
Definition: ControlMeasure.cpp:630
Isis::Chip::Load
void Load(Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
Load cube data into the Chip.
Definition: Chip.cpp:203
CubeViewport.h
Isis::ChipViewport::setControlNet
void setControlNet(ControlNet *newControlNet)
sets the ControlNet to be used for drawing measure locations
Definition: ChipViewport.h:167
Isis::Chip::TackSample
int TackSample() const
This method returns a chip's fixed tack sample; the middle of the chip.
Definition: Chip.h:176
Isis::Chip::CubeLine
double CubeLine() const
Definition: Chip.h:210
Isis::ChipViewport::rotateChip
void rotateChip(int rotation)
Slot to rotate chip.
Definition: ChipViewport.cpp:677
Isis::ControlPoint::Fixed
@ Fixed
A Fixed point is a Control Point whose lat/lon is well established and should not be changed.
Definition: ControlPoint.h:371
Isis::Chip::Lines
int Lines() const
Definition: Chip.h:106
ControlNet.h
Isis::ChipViewport::keyPressEvent
void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
Definition: ChipViewport.cpp:496
Isis::ControlNet::GetNumPoints
int GetNumPoints() const
Return the number of control points in the network.
Definition: ControlNet.cpp:1465
Isis::ChipViewport::refreshView
void refreshView(double tackSample, double tackLine)
Slot to refresh viewport when the tack point has changed.
Definition: ChipViewport.cpp:476
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::ChipViewport::~ChipViewport
virtual ~ChipViewport()
Destructor.
Definition: ChipViewport.cpp:67
Isis::Chip::TackLine
int TackLine() const
This method returns a chip's fixed tack line; the middle of the chip.
Definition: Chip.h:187
Isis::IException::toString
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:537
Isis::Chip::ChipLine
double ChipLine() const
Definition: Chip.h:226
Isis::ChipViewport::geomChip
void geomChip(Chip *matchChip, Cube *matchChipCube)
Slot to geom chip (apply geometry transformation)
Definition: ChipViewport.cpp:621
Isis::ChipViewport::paintEvent
void paintEvent(QPaintEvent *e)
Repaint the viewport.
Definition: ChipViewport.cpp:264
Isis::ChipViewport::zoomFactor
double zoomFactor()
Return the zoom factor.
Definition: ChipViewport.cpp:465
Isis::Stretch::AddPair
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
Definition: Stretch.cpp:48
Isis::Stretch::ClearPairs
void ClearPairs()
Clears the stretch pairs.
Definition: Stretch.h:170
Isis::ChipViewport::zoom1
void zoom1()
Zoom by a factor of one.
Definition: ChipViewport.cpp:443
Isis::ControlMeasure::GetSample
double GetSample() const
Definition: ControlMeasure.cpp:723
ControlPoint.h
Isis::ControlNet
a control network
Definition: ControlNet.h:257
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::CubeViewport
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:122
ASSERT
#define ASSERT(x)
Definition: IsisDebug.h:134
Isis::ChipViewport::ChipViewport
ChipViewport(int width, int height, QWidget *parent=0)
Construct an empty viewport.
Definition: ChipViewport.cpp:35
Isis::ChipViewport::panLeft
void panLeft()
Pan left.
Definition: ChipViewport.cpp:399
Isis::ChipViewport
Viewport for Isis Chips.
Definition: ChipViewport.h:71
Isis::ChipViewport::autoStretch
void autoStretch()
Apply automatic stretch using data from entire chip.
Definition: ChipViewport.cpp:135
Isis::ChipViewport::panRight
void panRight()
Pan right.
Definition: ChipViewport.cpp:412
Isis::ChipViewport::setChip
void setChip(Chip *chip, Cube *chipCube)
Set chip.
Definition: ChipViewport.cpp:110
Isis::ChipViewport::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Process mouse events.
Definition: ChipViewport.cpp:534
Isis::ChipViewport::tackPointChanged
void tackPointChanged(double)
< Signal sent when tack point changes
Isis::Stretch::SetNull
void SetNull(const double value)
Sets the mapping for NULL pixels.
Definition: Stretch.h:94
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::ChipViewport::changeStretchLock
void changeStretchLock(int)
Locks or unlocks the stretch on the chip viewport during transformations (zoom, pan,...
Definition: ChipViewport.cpp:182
Isis::Chip
A small chip of data used for pattern matching.
Definition: Chip.h:86
Isis::ControlMeasure::GetLine
double GetLine() const
Definition: ControlMeasure.cpp:690
Isis::Chip::Samples
int Samples() const
Definition: Chip.h:99
Isis::ChipViewport::chipSamples
int chipSamples() const
Return the number of samples in the chip.
Definition: ChipViewport.h:97
Isis::ChipViewport::setPoints
void setPoints(bool checked)
Slot to set whether control points are drawn.
Definition: ChipViewport.cpp:556
Isis::ControlPoint::IsIgnored
bool IsIgnored() const
Definition: ControlPoint.cpp:1311
Isis::ChipViewport::setCircle
void setCircle(bool checked)
Slot to change state of circle.
Definition: ChipViewport.cpp:588
Isis::ControlPoint::GetType
PointType GetType() const
Definition: ControlPoint.cpp:1401
Isis::ChipViewport::chip
Chip * chip() const
Return chip.
Definition: ChipViewport.h:88
Isis::ChipViewport::loadView
void loadView(ChipViewport &newView)
Load with another ChipViewport, used for blinking.
Definition: ChipViewport.cpp:342
Isis::Chip::SetChipPosition
void SetChipPosition(const double sample, const double line)
Compute the position of the cube given a chip coordinate.
Definition: Chip.cpp:643
ChipViewport.h
Isis::ChipViewport::zoomIn
void zoomIn()
Zoom in.
Definition: ChipViewport.cpp:425
Isis::ChipViewport::userMovedTackPoint
void userMovedTackPoint()
Isis::ChipViewport::nogeomChip
void nogeomChip()
Slot to un-geom chip (revert geometry transformation)
Definition: ChipViewport.cpp:649
Isis::ChipViewport::stretchFromCubeViewport
void stretchFromCubeViewport(Stretch *, CubeViewport *)
Applies a new stretch to the specified cube viewport.
Definition: ChipViewport.cpp:148
IsisDebug.h
Isis::ChipViewport::cubeToViewport
bool cubeToViewport(double samp, double line, int &x, int &y)
Get viewport x and y from cube sample and line.
Definition: ChipViewport.cpp:85
SerialNumber.h
Isis::CubeViewport::cube
Cube * cube() const
Definition: CubeViewport.h:338
Isis::ChipViewport::panDown
void panDown()
Pan down.
Definition: ChipViewport.cpp:386
ControlMeasure.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Chip.h
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126
Isis::ChipViewport::panUp
void panUp()
Pan up.
Definition: ChipViewport.cpp:373
Isis::ControlMeasure
a control measurement
Definition: ControlMeasure.h:175