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);
86 m_chip->SetCubePosition(samp, line);
87 x = ((int)
m_chip->ChipSample()) - 1;
88 y = ((int)
m_chip->ChipLine()) - 1;
90 return m_chip->IsInsideChip(samp, line);
110 if (
chip == NULL || chipCube == NULL) {
112 "Can not view NULL chip pointer",
123 m_image =
new QImage(
chip->Samples(),
chip->Lines(), QImage::Format_RGB32);
165 m_gray.stretch = *newStretch;
199 for (
int line = 1; line <
m_chip->Lines(); line++) {
200 for (
int samp = 1; samp <
m_chip->Samples(); samp++) {
201 double value =
m_chip->GetValue(samp, line);
207 for (
int line = 1; line <=
m_chip->Lines(); line++) {
208 for (
int samp = 1; samp <=
m_chip->Samples(); samp++) {
209 double value =
m_chip->GetValue(samp, line);
220 stretch.
AddPair(-DBL_MAX, 0.0);
221 stretch.
AddPair(DBL_MAX, 255.0);
235 for (
int y = 0; y <
m_chip->Lines(); y++) {
236 QRgb *rgb = (QRgb *)
m_image->scanLine(y);
238 for (
int x = 0; x <
m_chip->Samples(); x++) {
239 r = g = b = (int)
m_gray.stretch.Map(
m_chip->GetValue(x + 1, y + 1));
240 rgb[x] = qRgb(r, g, b);
262 QPainter painter(
this);
265 painter.drawImage(0, 0, *(
m_tempView->m_image));
268 painter.drawImage(0, 0, *
m_image);
272 painter.setPen(Qt::red);
278 painter.setPen(Qt::red);
285 if (m_controlNet && !serialNumber.isEmpty()
286 && m_controlNet->GetCubeSerials().contains(serialNumber)) {
292 m_controlNet->GetNumPoints() != 0) {
294 m_controlNet->GetMeasuresInCube(serialNumber);
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);
351 return m_chip->CubeSample();
362 return m_chip->CubeLine();
372 y =
m_chip->TackLine() - 1;
374 m_chip->SetChipPosition((
double)x, (
double)y);
385 y =
m_chip->TackLine() + 1;
387 m_chip->SetChipPosition((
double)x, (
double)y);
397 x =
m_chip->TackSample() - 1;
400 m_chip->SetChipPosition((
double)x, (
double)y);
410 x =
m_chip->TackSample() + 1;
413 m_chip->SetChipPosition((
double)x, (
double)y);
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);
515 m_chip->SetChipPosition((
double)x, (
double)y);
517 emit userMovedTackPoint();
532 QPoint p =
event->pos();
533 if (event->button() == Qt::LeftButton) {
535 m_chip->SetChipPosition((
double)p.x(), (
double)p.y());
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.
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.
PointType GetType() const
@ 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.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
virtual void AddData(const double *data, const unsigned int count)
Add an array of doubles to the histogram counters.
@ 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.
QString toString() const
Returns a string representation of this exception.
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
This class is used to accumulate statistics on double arrays.
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
void ClearPairs()
Clears the stretch pairs.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.