  | 
  
    Isis 3 Programmer Reference
    
   | 
 
 
 
 
    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> 
   20 #include "CubePlotCurve.h" 
   22 #include "InterestOperator.h" 
   24 #include "Longitude.h" 
   25 #include "MdiCubeViewport.h" 
   27 #include "PolygonTools.h" 
   28 #include "Projection.h" 
   29 #include "RingPlaneProjection.h" 
   30 #include "TProjection.h" 
   32 #include "RubberBandComboBox.h" 
   33 #include "RubberBandTool.h" 
   34 #include "Statistics.h" 
   35 #include "SurfacePoint.h" 
   37 #include "UniversalGroundMap.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);
 
  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;
 
  527             double pixelValue = interp.
Interpolate(sample + 0.5, line + 0.5,
 
  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()));
 
  
 
double kilometers() const
Get the distance in kilometers.
 
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
 
Cube display widget for certain Isis MDI applications.
 
This class is used to accumulate statistics on double arrays.
 
@ CubeDN
The data is a Cube DN value.
 
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
 
Combo box for choosing a rubber band type.
 
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
 
Buffer for containing a two dimensional section of an image.
 
This class is designed to encapsulate the concept of a Latitude.
 
This is a plot curve with information relating it to a particular cube or region of a cube.
 
@ PixelNumber
The data is a pixel #.
 
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
 
double * DoubleBuffer() const
Returns the value of the shape buffer.
 
Distance GetDistanceToPoint(const SurfacePoint &other) const
Computes and returns the distance between two surface points.
 
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 ...
 
Isis::Camera * Camera() const
Return the camera associated with the ground map (NULL implies none)
 
@ Meters
The data is in meters.
 
Units
These are all the possible units for the x or y data in a plot curve.
 
virtual void add(CubePlotCurve *pc)
This method adds the curves to the plot.
 
bool IsSpecial(const double d)
Returns if the input pixel is special.
 
UniversalGroundMap * universalGroundMap() const
 
@ Kilometers
The data is in kilometers.
 
Distance measurement, usually in meters.
 
This class is designed to encapsulate the concept of a Longitude.
 
PlotCurve::Units xAxisUnits() const
This is the data-type of the curves' x data in this plot window.
 
@ Meters
The distance is being specified in meters.
 
interpType
The interpolator type, including: None, Nearest Neighbor, BiLinear or Cubic Convultion.
 
int toInt(const QString &string)
Global function to convert from a string to an integer.
 
const double Null
Value for an Isis Null pixel.
 
Isis::Projection * Projection() const
Return the projection associated with the ground map (NULL implies none)
 
double Average() const
Computes and returns the average.
 
PixelType pixelType() const
 
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.
 
void SetType(const interpType &type)
Sets the type of interpolation.
 
double meters() const
Get the distance in meters.
 
This is free and unencumbered software released into the public domain.
 
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection.
 
@ RotatedRectangle
RotatedRectangle.
 
int Samples()
Returns the number of samples needed by the interpolator.
 
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
 
This is free and unencumbered software released into the public domain.
 
void replot()
Reset the scale of the plot, replot it and emit plot changed.
 
void SetPosition(const double sample, const double line, const int band)
Sets the line and sample position of the buffer.
 
This class defines a body-fixed surface point.
 
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
 
This is free and unencumbered software released into the public domain.
 
Distance LocalRadius() const
Returns the local radius at the intersection point.