Loading isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.cpp +32 −16 Original line number Diff line number Diff line Loading @@ -420,21 +420,21 @@ namespace Isis { /* * We have a rotated rectangle: * * --across--> * -------------- * --acrossLength--> * -------------------- * |A B| * | | | * | | | * | | | * | | | * | | | length * | | | rectangleLength * | | | * | | | * | | | * | | | * | | V * |D C| * -------------- * ------------------- * * A is the point where the user initially clicked to start drawing the * rectangle. A is clickSample, clickLine. Loading Loading @@ -463,16 +463,30 @@ namespace Isis { double acrossVectorX = acrossSample - clickSample; double acrossVectorY = acrossLine - clickLine; // Get length of "green" line on the screen int acrossLength = qRound(sqrt(acrossVectorX * acrossVectorX + acrossVectorY * acrossVectorY)); // Prevent length of zero for later calculations if (acrossLength == 0) { acrossLength = 1; } double sampleStepAcross = (1.0 / (double)acrossLength) * acrossVectorX; double lineStepAcross = (1.0 / (double)acrossLength) * acrossVectorY; double lengthVectorSample = endSample - clickSample; double lengthVectorLine = endLine - clickLine; // Get length of "red" line on the screen int rectangleLength = qRound(sqrt(lengthVectorSample * lengthVectorSample + lengthVectorLine * lengthVectorLine)); // Prevent length of zero for later calculations if (rectangleLength == 0) { rectangleLength = 1; } SurfacePoint startPoint; UniversalGroundMap *groundMap = cvp->universalGroundMap(); if (targetUnits != PlotCurve::PixelNumber) { Loading @@ -491,7 +505,7 @@ namespace Isis { } } // walk the "green" line on the screen // walk the "red" line on the screen for(int index = 0; index <= rectangleLength; index++) { Statistics acrossStats; Loading @@ -508,6 +522,8 @@ namespace Isis { double sampleMid = sample + (acrossLength / 2.0) * sampleStepAcross; double lineMid = line + (acrossLength / 2.0) * lineStepAcross; // For each pixel length in the red line direction, we are now recursing through each // pixel length in the green line's direction and adding the pixel values for(int acrossPixel = 0; acrossPixel <= acrossLength; acrossPixel++) { Loading isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.h +7 −5 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ namespace Isis { * and #1950. * @history 2014-07-31 Ian Humphrey - Added What's This help for SpatialPlotTool. * References #2089. * @history 2018-01-12 Summer Stapleton - Prevented lengths of zero for the rotated rectangle * selection to address segfault. Fixes #4953. */ class SpatialPlotTool : public AbstractPlotTool { Q_OBJECT Loading Loading
isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.cpp +32 −16 Original line number Diff line number Diff line Loading @@ -420,21 +420,21 @@ namespace Isis { /* * We have a rotated rectangle: * * --across--> * -------------- * --acrossLength--> * -------------------- * |A B| * | | | * | | | * | | | * | | | * | | | length * | | | rectangleLength * | | | * | | | * | | | * | | | * | | V * |D C| * -------------- * ------------------- * * A is the point where the user initially clicked to start drawing the * rectangle. A is clickSample, clickLine. Loading Loading @@ -463,16 +463,30 @@ namespace Isis { double acrossVectorX = acrossSample - clickSample; double acrossVectorY = acrossLine - clickLine; // Get length of "green" line on the screen int acrossLength = qRound(sqrt(acrossVectorX * acrossVectorX + acrossVectorY * acrossVectorY)); // Prevent length of zero for later calculations if (acrossLength == 0) { acrossLength = 1; } double sampleStepAcross = (1.0 / (double)acrossLength) * acrossVectorX; double lineStepAcross = (1.0 / (double)acrossLength) * acrossVectorY; double lengthVectorSample = endSample - clickSample; double lengthVectorLine = endLine - clickLine; // Get length of "red" line on the screen int rectangleLength = qRound(sqrt(lengthVectorSample * lengthVectorSample + lengthVectorLine * lengthVectorLine)); // Prevent length of zero for later calculations if (rectangleLength == 0) { rectangleLength = 1; } SurfacePoint startPoint; UniversalGroundMap *groundMap = cvp->universalGroundMap(); if (targetUnits != PlotCurve::PixelNumber) { Loading @@ -491,7 +505,7 @@ namespace Isis { } } // walk the "green" line on the screen // walk the "red" line on the screen for(int index = 0; index <= rectangleLength; index++) { Statistics acrossStats; Loading @@ -508,6 +522,8 @@ namespace Isis { double sampleMid = sample + (acrossLength / 2.0) * sampleStepAcross; double lineMid = line + (acrossLength / 2.0) * lineStepAcross; // For each pixel length in the red line direction, we are now recursing through each // pixel length in the green line's direction and adding the pixel values for(int acrossPixel = 0; acrossPixel <= acrossLength; acrossPixel++) { Loading
isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.h +7 −5 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ namespace Isis { * and #1950. * @history 2014-07-31 Ian Humphrey - Added What's This help for SpatialPlotTool. * References #2089. * @history 2018-01-12 Summer Stapleton - Prevented lengths of zero for the rotated rectangle * selection to address segfault. Fixes #4953. */ class SpatialPlotTool : public AbstractPlotTool { Q_OBJECT Loading