Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves save/restore/delete of Stretch from AdvancedStretchTool to StretchTool. #3965

Merged
merged 6 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions isis/src/qisis/objs/CubeViewport/CubeViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "PvlKeyword.h"
#include "PvlObject.h"
#include "Stretch.h"
#include "CubeStretch.h"
#include "StretchTool.h"
#include "Tool.h"
#include "UniversalGroundMap.h"
Expand Down Expand Up @@ -1669,7 +1670,7 @@ namespace Isis {


//! Return the gray band stretch
Stretch CubeViewport::grayStretch() const {
CubeStretch CubeViewport::grayStretch() const {
return p_gray.getStretch();
}

Expand Down Expand Up @@ -2405,7 +2406,7 @@ namespace Isis {


CubeViewport::BandInfo::BandInfo() : band(1), stretch(NULL) {
stretch = new Stretch;
stretch = new CubeStretch;
stretch->SetNull(0.0);
stretch->SetLis(0.0);
stretch->SetLrs(0.0);
Expand All @@ -2419,7 +2420,7 @@ namespace Isis {
CubeViewport::BandInfo::BandInfo(const CubeViewport::BandInfo &other) :
band(other.band) {
stretch = NULL;
stretch = new Stretch(*other.stretch);
stretch = new CubeStretch(*other.stretch);
}


Expand All @@ -2431,7 +2432,7 @@ namespace Isis {
}


Stretch CubeViewport::BandInfo::getStretch() const {
CubeStretch CubeViewport::BandInfo::getStretch() const {
ASSERT_PTR(stretch);

return *stretch;
Expand All @@ -2448,7 +2449,7 @@ namespace Isis {
ASSERT_PTR(other.stretch);

stretch = NULL;
stretch = new Stretch;
stretch = new CubeStretch;
*stretch = *other.stretch;
band = other.band;

Expand Down
7 changes: 4 additions & 3 deletions isis/src/qisis/objs/CubeViewport/CubeViewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Isis {
class Projection;
class Pvl;
class PvlKeyword;
class CubeStretch;
class Stretch;
class Tool;
class UniversalGroundMap;
Expand Down Expand Up @@ -174,14 +175,14 @@ namespace Isis {
const BandInfo &operator=(BandInfo other);

//! @return The Stretch
Stretch getStretch() const;
CubeStretch getStretch() const;
//! @param newStretch The new Stretch value
void setStretch(const Stretch &newStretch);
//! The band
int band;
private:
//! The Stretch
Stretch *stretch;
CubeStretch *stretch;
};

//! @param cube The cube to set the CubeViewport window to
Expand Down Expand Up @@ -339,7 +340,7 @@ namespace Isis {
*/
double grayPixel(int sample, int line);
//! @return The gray Stretch
Stretch grayStretch() const;
CubeStretch grayStretch() const;
//! @return The red Stretch
Stretch redStretch() const;
//! @return The green Stretch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Projection.h"
#include "RingPlaneProjection.h"
#include "TProjection.h"
#include "CubeStretch.h"
#include "Stretch.h"
#include "StretchTool.h"
#include "ViewportBuffer.h"
Expand Down Expand Up @@ -162,7 +163,7 @@ namespace Isis

void IndependentCubeViewport::restretch(ViewportBuffer * buffer)
{
Stretch globalStretch = grayStretch();
CubeStretch globalStretch = grayStretch();
globalStretch.CopyPairs(StretchTool::stretchBand(this, StretchTool::Gray));
stretchGray(globalStretch);
}
Expand Down Expand Up @@ -234,7 +235,7 @@ namespace Isis
newGlobal.AddPair(DBL_MAX, 255.0);
}

globalStretch = new Stretch(newGlobal);
globalStretch = new CubeStretch(newGlobal);

if (isVisible())
stretchGray(newGlobal);
Expand Down
6 changes: 2 additions & 4 deletions isis/src/qisis/objs/StretchTool/AdvancedStretch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ namespace Isis {
else if (stretchTypeName.compare("Manual") == 0) {
index = 3;
}
// Fail by defaulting to Linear

// Fail by defaulting to Linear. This is correct for non-Advanced Stretch

p_stretchTypeSelection->setCurrentIndex(index);
StretchType *stretchType = (StretchType *)
p_stretchTypeStack->currentWidget();
stretchType->setStretch(newStretch);
}


Expand Down
49 changes: 42 additions & 7 deletions isis/src/qisis/objs/StretchTool/StretchTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ namespace Isis {
connect(m_flashButton, SIGNAL(pressed()), this, SLOT(stretchChanged()));
connect(m_flashButton, SIGNAL(released()), this, SLOT(stretchChanged()));

// Buttons migrated out of Advanced Stretch Tool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not make sense to a programmer in a few days

QPushButton *saveToCubeButton = new QPushButton("Save");
connect(saveToCubeButton, SIGNAL(clicked(bool)), this, SLOT(saveStretchToCube()));

QPushButton *deleteFromCubeButton = new QPushButton("Delete");
connect(deleteFromCubeButton, SIGNAL(clicked(bool)), this, SLOT(deleteFromCube()));

QPushButton *loadStretchButton = new QPushButton("Load");
connect(loadStretchButton, SIGNAL(clicked(bool)), this, SLOT(loadStretchFromCube()));

QHBoxLayout *layout = new QHBoxLayout(hbox);
layout->setMargin(0);
layout->addWidget(m_copyButton);
Expand All @@ -301,6 +311,13 @@ namespace Isis {
layout->addWidget(m_stretchMaxEdit);
layout->addWidget(advancedButton);
layout->addWidget(m_flashButton);

// should only display if gray stretch
// Save/Restore strech only supported for Grayscale images. Hide buttons if in RGB.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm omitting the change suggested in this comment, because I'm working on adding RGB now.

layout->addWidget(saveToCubeButton);
layout->addWidget(deleteFromCubeButton);
layout->addWidget(loadStretchButton);

layout->addStretch(); // Pushes everything else left in the menu bar
hbox->setLayout(layout);

Expand Down Expand Up @@ -353,6 +370,7 @@ namespace Isis {
}
}


/**
* Update the streches and corresponding histograms for all the
* colors Red, Green and Blue for Stretch All Mode.
Expand Down Expand Up @@ -398,8 +416,11 @@ namespace Isis {
for (objIter=lab->beginObject(); objIter<lab->endObject(); objIter++) {
if (objIter->name() == "Stretch") {
PvlKeyword tempKeyword = objIter->findKeyword("Name");
QString tempName = tempKeyword[0];
namelist.append(tempName);
int bandNumber = int(objIter->findKeyword("BandNumber"));
if (cvp->grayBand() == bandNumber) {
QString tempName = tempKeyword[0];
namelist.append(tempName);
}
}
}

Expand All @@ -412,7 +433,11 @@ namespace Isis {
StretchBlob stretchBlob(stretchName);
icube->read(stretchBlob);
CubeStretch cubeStretch = stretchBlob.getStretch();
m_advancedStretch->restoreSavedStretch(cubeStretch);
if (m_advancedStretch->isVisible()) {
m_advancedStretch->restoreSavedStretch(cubeStretch);
}
cvp->stretchGray(cubeStretch);
emit stretchChanged();
}
}

Expand All @@ -431,8 +456,11 @@ namespace Isis {
for (objIter=lab->beginObject(); objIter<lab->endObject(); objIter++) {
if (objIter->name() == "Stretch") {
PvlKeyword tempKeyword = objIter->findKeyword("Name");
QString tempName = tempKeyword[0];
namelist.append(tempName);
int bandNumber = int(objIter->findKeyword("BandNumber"));
if (cvp->grayBand() == bandNumber) {
QString tempName = tempKeyword[0];
namelist.append(tempName);
}
}
}

Expand Down Expand Up @@ -538,8 +566,16 @@ namespace Isis {
}
}

CubeStretch stretch = m_advancedStretch->getGrayCubeStretch();
CubeStretch stretch;
if (m_advancedStretch->isVisible()) {
stretch = m_advancedStretch->getGrayCubeStretch();
}
else {
stretch = cvp->grayStretch();
}

stretch.setName(text);
stretch.setBandNumber(cvp->grayBand());
StretchBlob stretchBlob(stretch);
icube->write(stretchBlob);

Expand Down Expand Up @@ -908,7 +944,6 @@ namespace Isis {
m_advancedStretch->updateStretch(cubeViewport());
m_advancedStretch->show();
}

updateTool();
}

Expand Down