9#include "ChipViewport.h"
16#include "ControlMeasure.h"
17#include "ControlNet.h"
18#include "ControlPoint.h"
20#include "CubeViewport.h"
21#include "SerialNumber.h"
35 setFixedSize(width, height);
36 setBackgroundRole(QPalette::Dark);
52 m_image =
new QImage(512, 512, QImage::Format_RGB32);
110 if (
chip == NULL || chipCube == NULL) {
112 "Can not view NULL chip pointer",
199 for (
int line = 1; line <
m_chip->
Lines(); line++) {
202 stats.AddData(&value, 1);
206 Histogram hist(stats.BestMinimum(), stats.BestMaximum());
207 for (
int line = 1; line <=
m_chip->
Lines(); line++) {
210 hist.AddData(&value, 1);
215 if (hist.Percent(0.5) != hist.Percent(99.5)) {
216 stretch.
AddPair(hist.Percent(0.5), 0.0);
217 stretch.
AddPair(hist.Percent(99.5), 255.0);
220 stretch.
AddPair(-DBL_MAX, 0.0);
221 stretch.
AddPair(DBL_MAX, 255.0);
236 QRgb *rgb = (QRgb *)
m_image->scanLine(y);
240 rgb[x] = qRgb(r, g, b);
262 QPainter painter(
this);
268 painter.drawImage(0, 0, *
m_image);
272 painter.setPen(Qt::red);
278 painter.setPen(Qt::red);
285 if (m_controlNet && !serialNumber.isEmpty()
293 QList<ControlMeasure *> measures =
296 for (
int i = 0; i < measures.count(); i++) {
299 double samp = m->GetSample();
300 double line = m->GetLine();
306 if (m->Parent()->IsIgnored() ||
307 (!m->Parent()->IsIgnored() && m->IsIgnored())) {
308 painter.setPen(QColor(255, 255, 0));
312 painter.setPen(Qt::magenta);
315 painter.setPen(Qt::green);
320 painter.drawLine(x - 5, y, x + 5, y);
321 painter.drawLine(x, y - 5, x, y + 5);
497 if (e->key() == Qt::Key_Up) {
500 else if (e->key() == Qt::Key_Down) {
503 else if (e->key() == Qt::Key_Left) {
506 else if (e->key() == Qt::Key_Right) {
510 QWidget::keyPressEvent(e);
517 emit userMovedTackPoint();
532 QPoint p =
event->pos();
533 if (event->button() == Qt::LeftButton) {
537 emit userMovedTackPoint();
627 QString msg =
"Cannot geom chip.\n";
629 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
652 QString msg =
"Cannot load no geom chip.\n";
654 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
680 QString msg =
"Cannot load rotated chip.\n";
682 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
708 "Can not view NULL chip pointer",
722 QString msg =
"Cannot reload chip.\n";
724 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
734 QString msg =
"Cannot reload chip.\n";
736 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
A small chip of data used for pattern matching.
double GetValue(int sample, int line)
Loads a Chip with a value.
int TackSample() const
This method returns a chip's fixed tack sample; the middle of the chip.
bool IsInsideChip(double sample, double line)
void SetChipPosition(const double sample, const double line)
Compute the position of the cube given a chip coordinate.
double ChipSample() const
void TackCube(const double cubeSample, const double cubeLine)
This sets which cube position will be located at the chip tack position.
double CubeSample() const
void Load(Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
Load cube data into the Chip.
int TackLine() const
This method returns a chip's fixed tack line; the middle of the chip.
void SetCubePosition(const double sample, const double line)
Compute the position of the chip given a cube coordinate.
Stretch stretch
Stretch for the band BandInfo constructor.
bool m_stretchLocked
Whether or not to lock the stretch when transforming.
Cube * m_chipCube
The chip's cube.
void loadView(ChipViewport &newView)
Load with another ChipViewport, used for blinking.
ChipViewport * m_tempView
Temporary viewport.
void setPoints(bool checked)
Slot to set whether control points are drawn.
Stretch * m_stretch
Current stretch on the chip viewport.
void setCircle(bool checked)
Slot to change state of circle.
virtual ~ChipViewport()
Destructor.
void enterEvent(QEvent *e)
If mouse enters, make sure key events are processed w/o clicking.
void paintImage()
Paints the chip viewport after the chip has been updated.
Chip * chip() const
Return chip.
Chip * m_matchChip
The matching chip.
double m_zoomFactor
Zoom Factor.
ChipViewport(int width, int height, QWidget *parent=0)
Construct an empty viewport.
double tackSample()
Return the position of cube under cross hair.
double tackLine()
Returns tack line.
void zoom(double zoomFactor)
Zoom by a specified factor.
void nogeomChip()
Slot to un-geom chip (revert geometry transformation)
void rotateChip(int rotation)
Slot to rotate chip.
double zoomFactor()
Return the zoom factor.
void paintEvent(QPaintEvent *e)
Repaint the viewport.
bool m_cross
Draw crosshair.
void computeStretch(Stretch &stretch, bool force=false)
Compute automatic stretch for a portion of the cube.
void panRight()
Pan right.
Cube * m_matchChipCube
The matching chip's cube.
int m_circleSize
Circle size.
void reloadChip(double tackSample=0., double tackLine=0.)
Reloads the chip at the given tack point on the cube.
bool cubeToViewport(double samp, double line, int &x, int &y)
Get viewport x and y from cube sample and line.
void autoStretch()
Apply automatic stretch using data from entire chip.
void geomChip(Chip *matchChip, Cube *matchChipCube)
Slot to geom chip (apply geometry transformation)
bool m_circle
Draw circle.
void changeStretchLock(int)
Locks or unlocks the stretch on the chip viewport during transformations (zoom, pan,...
void setCircleSize(int size)
Set the size of the circle.
void stretchFromCubeViewport(Stretch *, CubeViewport *)
Applies a new stretch to the specified cube viewport.
void tackPointChanged(double)
< Signal sent when tack point changes
void mousePressEvent(QMouseEvent *event)
Process mouse events.
void setCross(bool checked)
Slot to change state of crosshair.
bool m_showPoints
Draw control points.
void zoom1()
Zoom by a factor of one.
BandInfo m_gray
Info for the gray bands.
QImage * m_image
The image.
void refreshView(double tackSample, double tackLine)
Slot to refresh viewport when the tack point has changed.
void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
void setChip(Chip *chip, Cube *chipCube)
Set chip.
int GetNumPoints() const
Return the number of control points in the network.
QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber)
Get all the measures pertaining to a given cube serial number.
QList< QString > GetCubeSerials() const
Use this method to get a complete list of all the cube serial numbers in the network.
@ Fixed
A Fixed point is a Control Point whose lat/lon is well established and should not be changed.
IO Handler for Isis Cubes.
virtual QString fileName() const
Returns the opened cube's filename.
Widget to display Isis cubes for qt apps.
Container of a cube histogram.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
This class is used to accumulate statistics on double arrays.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
void ClearPairs()
Clears the stretch pairs.
double Map(const double value) const
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.
This is free and unencumbered software released into the public domain.