3 #include "SpatialPlotTool.h" 7 #include <geos/geom/Polygon.h> 8 #include <geos/geom/CoordinateArraySequence.h> 9 #include <geos/geom/Point.h> 11 #include <QHBoxLayout> 14 #include <QMessageBox> 15 #include <QStackedWidget> 32 #include "RubberBandComboBox.h" 33 #include "RubberBandTool.h" 89 QString text =
"<b>Function:</b> Create a spatial plot of the selected pixels' DN values.";
115 Interpolator::NearestNeighborType);
117 Interpolator::BiLinearType);
119 Interpolator::CubicConvolutionType);
128 QHBoxLayout *layout =
new QHBoxLayout(wrapper);
129 layout->setMargin(0);
131 layout->addWidget(
new QLabel(
"Interpolation:"));
133 layout->addWidget(abstractToolWidgets);
134 layout->addWidget(m_xUnitsCombo);
135 layout->addStretch(1);
136 wrapper->setLayout(layout);
151 m_xUnitsCombo->currentIndex()).
toInt();
153 while (m_xUnitsCombo->count())
154 m_xUnitsCombo->removeItem(0);
158 bool haveGroundMaps =
true;
163 if (haveGroundMaps) {
168 if (m_xUnitsCombo->findData(preferredUnits) != -1) {
169 m_xUnitsCombo->setCurrentIndex(
170 m_xUnitsCombo->findData(preferredUnits));
173 m_xUnitsCombo->setVisible(m_xUnitsCombo->count() > 1);
186 m_xUnitsCombo->currentIndex()).
toInt(),
213 if (rubberBandTool()->isValid()) {
217 QMessageBox::information(NULL,
"Error",
218 "The selected Area contains no valid pixels",
231 if (activeViewport && rubberBandTool()->isValid()) {
237 m_xUnitsCombo->itemData(m_xUnitsCombo->currentIndex()).
toInt()) {
246 if (data.size() > 0) {
252 (*m_spatialCurves)[viewport]->setData(
new QwtPointSeriesData(data));
253 (*m_spatialCurves)[viewport]->setSource(
254 viewport, rubberBandPoints, band);
273 m_xUnitsCombo->currentIndex()).
toInt();
275 QPen spatialPen(Qt::white);
276 spatialPen.setWidth(1);
277 spatialPen.setStyle(Qt::SolidLine);
285 targetWindow->
add(plotCurve);
324 m_xUnitsCombo->currentIndex()).
toInt();
326 if (cvp && vertices.size()) {
337 if (rubberBandTool()->currentMode() == RubberBandTool::LineMode) {
338 double startSample =
Null;
339 double endSample =
Null;
340 double startLine =
Null;
341 double endLine =
Null;
344 startSample, startLine);
349 int lineLength = qRound(sqrt(pow(startSample - endSample, 2) +
350 pow(startLine - endLine, 2)));
355 if (groundMap->
SetImage(startSample, startLine)) {
356 startPoint = resultToSurfacePoint(groundMap);
359 QMessageBox::warning(qobject_cast<QWidget *>(parent()),
360 tr(
"Failed to project points along line"),
361 tr(
"Failed to project (calculate a latitude, longitude, and radius) for the " 362 "starting point of the line (sample [%1], line [%2]).")
363 .arg(startSample).arg(startLine));
368 if (lineLength > 0) {
369 for(
int index = 0; index <= lineLength; index++) {
371 double sample = (index / (double)lineLength) * (endSample - startSample) +
374 sample -= (interp.
Samples() / 2.0 - 0.5);
376 double line = (index / (double)lineLength) * (endLine - startLine) +
378 line -= (interp.
Lines() / 2.0 - 0.5);
380 dataReader.SetPosition(sample, line, band);
383 double result = interp.
Interpolate(sample + 0.5, line + 0.5, dataReader.DoubleBuffer());
386 double plotXValue = index + 1;
391 if (groundMap->
SetImage(sample, line)) {
395 plotXValue = xDistance.
meters();
400 QMessageBox::warning(qobject_cast<QWidget *>(parent()),
401 tr(
"Failed to project points along line"),
402 tr(
"Failed to project (calculate a latitude, longitude, and radius) for a " 403 "point along the line (sample [%1], line [%2]).")
404 .arg(startSample).arg(startLine));
409 data.append(QPointF(plotXValue, result));
414 QMessageBox::information(NULL,
"Error",
415 "The selected Area contains no valid pixels",
419 else if (rubberBandTool()->currentMode() == RubberBandTool::RotatedRectangleMode) {
449 double clickSample =
Null;
450 double clickLine =
Null;
451 double acrossSample =
Null;
452 double acrossLine =
Null;
453 double endSample =
Null;
454 double endLine =
Null;
457 clickSample, clickLine);
459 acrossSample, acrossLine);
463 double acrossVectorX = acrossSample - clickSample;
464 double acrossVectorY = acrossLine - clickLine;
467 int acrossLength = qRound(sqrt(acrossVectorX * acrossVectorX +
468 acrossVectorY * acrossVectorY));
470 double sampleStepAcross = (1.0 / (double)acrossLength) * acrossVectorX;
471 double lineStepAcross = (1.0 / (double)acrossLength) * acrossVectorY;
473 double lengthVectorSample = endSample - clickSample;
474 double lengthVectorLine = endLine - clickLine;
477 int rectangleLength = qRound(sqrt(lengthVectorSample * lengthVectorSample +
478 lengthVectorLine * lengthVectorLine));
481 if (rectangleLength == 0) {
488 double midStartSample = (clickSample + acrossSample) / 2.0;
489 double midStartLine = (clickLine + acrossLine) / 2.0;
490 if (groundMap->
SetImage(midStartSample, midStartLine)) {
491 startPoint = resultToSurfacePoint(groundMap);
494 QMessageBox::warning(qobject_cast<QWidget *>(parent()),
495 tr(
"Failed to project points along line"),
496 tr(
"Failed to project (calculate a latitude, longitude, and radius) for the " 497 "starting point of the line (sample [%1], line [%2]).")
498 .arg(midStartSample).arg(midStartLine));
504 for(
int index = 0; index <= rectangleLength; index++) {
508 double sample = (index / (double)rectangleLength) * lengthVectorSample +
511 sample -= (interp.
Samples() / 2.0 - 0.5);
513 double line = (index / (double)rectangleLength) * lengthVectorLine +
515 line -= (interp.
Lines() / 2.0 - 0.5);
517 double sampleMid = sample + (acrossLength / 2.0) * sampleStepAcross;
518 double lineMid = line + (acrossLength / 2.0) * lineStepAcross;
522 for(
int acrossPixel = 0;
523 acrossPixel <= acrossLength;
525 dataReader.SetPosition(sample, line, band);
527 double pixelValue = interp.
Interpolate(sample + 0.5, line + 0.5,
528 dataReader.DoubleBuffer());
531 acrossStats.
AddData(pixelValue);
534 sample += sampleStepAcross;
535 line += lineStepAcross;
539 double plotXValue = index + 1;
542 if (groundMap->
SetImage(sampleMid, lineMid)) {
546 plotXValue = xDistance.
meters();
551 QMessageBox::warning(qobject_cast<QWidget *>(parent()),
552 tr(
"Failed to project points along line"),
553 tr(
"Failed to project (calculate a latitude, longitude, and radius) for a " 554 "point along the line (sample [%1], line [%2]).")
555 .arg(sampleMid).arg(lineMid));
560 data.append(QPointF(plotXValue, acrossStats.
Average()));
This class defines a body-fixed surface point.
Cube display widget for certain Isis MDI applications.
double meters() const
Get the distance in meters.
const double Null
Value for an Isis Null pixel.
interpType
The interpolator type, including: None, Nearest Neighbor, BiLinear or Cubic Convultion.
double Interpolate(const double isamp, const double iline, const double buf[])
Performs an interpolation on the data according to the parameters set in the constructor.
The data is a Cube DN value.
Distance GetDistanceToPoint(const SurfacePoint &other) const
Computes and returns the distance between two surface points.
Buffer for containing a two dimensional section of an image.
Combo box for choosing a rubber band type.
int toInt(const QString &string)
Global function to convert from a string to an integer.
void SetType(const interpType &type)
Sets the type of interpolation.
This class is designed to encapsulate the concept of a Latitude.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double kilometers() const
Get the distance in kilometers.
Distance measurement, usually in meters.
Distance LocalRadius() const
Returns the local radius at the intersection point.
This class is used to accumulate statistics on double arrays.
This class is designed to encapsulate the concept of a Longitude.
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
int Samples()
Returns the number of samples needed by the interpolator.
UniversalGroundMap * universalGroundMap() const
This is a plot curve with information relating it to a particular cube or region of a cube...
Isis::Projection * Projection() const
Return the projection associated with the ground map (NULL implies none)
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
PlotCurve::Units xAxisUnits() const
This is the data-type of the curves' x data in this plot window.
void read(Blob &blob) const
This method will read data from the specified Blob object.
bool IsSpecial(const double d)
Returns if the input pixel is special.
PixelType pixelType() const
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
int Lines()
Returns the number of lines needed by the interpolator.
static QString defaultWindowTitle()
This is the typical suffix for plot windows, it's here in case we want to update all plot windows to ...
Namespace for ISIS/Bullet specific routines.
Isis::Camera * Camera() const
Return the camera associated with the ground map (NULL implies none)
The distance is being specified in meters.
void replot()
Reset the scale of the plot, replot it and emit plot changed.
The data is in kilometers.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
virtual void add(CubePlotCurve *pc)
This method adds the curves to the plot.
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
double Average() const
Computes and returns the average.
Units
These are all the possible units for the x or y data in a plot curve.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.