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

Cleaning up lose ends on Stretch Refactor #3970

Merged
merged 24 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cd722a0
Stretch refactor inital move of Blob out of Stretch and creation of S…
krlberry Jul 30, 2020
c68530f
Cleanup and move setting of name into CubeStretch class
krlberry Jul 30, 2020
3d3448e
Add band numbers initial work
krlberry Jul 31, 2020
e492211
Added the ability to save the band number to the stretch blob and als…
krlberry Aug 3, 2020
3e1a4ea
Merge
krlberry Aug 3, 2020
9f93c4f
Moves primary save/load/delete to StretchTool from AdvancedStretchToo…
krlberry Aug 4, 2020
f7bac57
Get RGB stretches working, first draft
krlberry Aug 6, 2020
5750155
Add CubeStretch and StretchBlob
krlberry Aug 6, 2020
7224a96
Merge
krlberry Aug 6, 2020
98928e6
Update Blob.cpp
scsides Aug 6, 2020
d654177
Update saved stretches for RGB from the advanced stretch tool
krlberry Aug 7, 2020
228f6bf
Merge
krlberry Aug 7, 2020
fe8edbd
Merge
krlberry Aug 7, 2020
e2a9e30
Remove couts and cleanup merge
krlberry Aug 7, 2020
a94df04
Re-remove save/load/restore buttons from RGB StretchType panels
krlberry Aug 7, 2020
f9ede33
Update button name from Load to Restore
krlberry Aug 7, 2020
bb82d62
Remove unused color/grayscale type from StretchBlob output, clean up …
krlberry Aug 7, 2020
928c588
Update button location for AdvancedStretchTool
krlberry Aug 10, 2020
ba738bd
Switch Blob and Cube Reader filter list from QList<QPair> to QMap
krlberry Aug 10, 2020
4e855b8
Add documentation to new classes, update to not allow you to select o…
krlberry Aug 11, 2020
59ff232
Merge
krlberry Aug 11, 2020
00b9b34
Add gtests and delete old-style tests
krlberry Aug 11, 2020
6afe278
Add missing StretchBlob test
krlberry Aug 11, 2020
c3045fd
Update Blob.cpp
scsides Aug 11, 2020
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
15 changes: 9 additions & 6 deletions isis/src/base/objs/Blob/Blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace Isis {
* when there are multiple blobs with the same name, but different keywords that
* define the exact blob (see Stretch with a band number)
*/
void Blob::Find(const Pvl &pvl, const QList<QPair<QString,QString>> keywords) {
void Blob::Find(const Pvl &pvl, const QMap<QString, QString> keywords) {
bool found = false;
try {
// Search for the blob name
Expand All @@ -191,12 +191,15 @@ namespace Isis {
QString curName = obj["Name"];
curName = curName.toUpper();
if (blobName == curName) {

if (keywords.size() >= 1) {
found = true;
for (int i=0; i < keywords.size(); i++) {
if(obj.hasKeyword(keywords[i].first) && (keywords[i].second != obj[keywords[i].first])) {
QMap<QString, QString>::const_iterator i = keywords.constBegin();
while (i != keywords.constEnd()) {
if (obj.hasKeyword(i.key()) && (i.value() != obj[i.key()])) {
found = false;
}
++i;
}
if (found) {
p_blobPvl = obj;
Expand Down Expand Up @@ -259,7 +262,7 @@ namespace Isis {
* @throws iException::Io - Unable to open file
* @throws iException::Pvl - Invalid label format
*/
void Blob::Read(const QString &file, const QList<QPair<QString,QString>> keywords) {
void Blob::Read(const QString &file, const QMap<QString,QString> keywords) {
// Expand the filename
QString temp(FileName(file).expanded());

Expand All @@ -283,7 +286,7 @@ namespace Isis {
*
* @throws iException::Io - Unable to open file
*/
void Blob::Read(const QString &file, const Pvl &pvlLabels, const QList<QPair<QString,QString>> keywords) {
void Blob::Read(const QString &file, const Pvl &pvlLabels, const QMap<QString,QString> keywords) {
// Expand the filename
QString temp(FileName(file).expanded());

Expand Down Expand Up @@ -317,7 +320,7 @@ namespace Isis {
*
* @throws iException::Io - Unable to open file
*/
void Blob::Read(const Pvl &pvl, std::istream &istm, const QList<QPair<QString,QString>> keywords){
void Blob::Read(const Pvl &pvl, std::istream &istm, const QMap<QString,QString> keywords){
try {
Find(pvl, keywords);
ReadInit();
Expand Down
10 changes: 5 additions & 5 deletions isis/src/base/objs/Blob/Blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ namespace Isis {
int Size() const;
PvlObject &Label();

void Read(const QString &file, const QList<QPair<QString,QString>>
keywords=QList<QPair<QString,QString>>());
void Read(const QString &file, const QMap<QString,QString>
keywords=QMap<QString,QString>());
void Read(const QString &file, const Pvl &pvlLabels,
const QList<QPair<QString,QString>> keywords = QList<QPair<QString,QString>>());
const QMap<QString,QString> keywords = QMap<QString,QString>());
virtual void Read(const Pvl &pvl, std::istream &is,
const QList<QPair<QString,QString>> keywords = QList<QPair<QString,QString>>());
const QMap<QString,QString> keywords = QMap<QString,QString>());

void Write(const QString &file);
void Write(Pvl &pvl, std::fstream &stm,
const QString &detachedFileName = "", bool overwrite=true);

protected:
void Find(const Pvl &pvl, const QList<QPair<QString,QString>> keywords = QList<QPair<QString,QString>>());
void Find(const Pvl &pvl, const QMap<QString,QString> keywords = QMap<QString,QString>());
virtual void ReadInit();
virtual void ReadData(std::istream &is);
virtual void WriteInit();
Expand Down
4 changes: 1 addition & 3 deletions isis/src/base/objs/Cube/Cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ namespace Isis {
*
* @return (type)return description
*/
void Cube::read(Blob &blob, const QList<QPair<QString,QString>> keywords) const {
void Cube::read(Blob &blob, const QMap<QString,QString> keywords) const {
if (!isOpen()) {
string msg = "The cube is not opened so you can't read a blob from it";
throw IException(IException::Programmer, msg, _FILEINFO_);
Expand All @@ -805,8 +805,6 @@ namespace Isis {
QMutexLocker locker2(m_ioHandler->dataFileMutex());
blob.Read(cubeFile.toString(), *label(), keywords);
}
// add optional argument QList<QPair<QString, QString>>, default to empty
// or add new function with this signature.


/**
Expand Down
4 changes: 2 additions & 2 deletions isis/src/base/objs/Cube/Cube.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// This is needed for the QVariant macro
#include <QMetaType>
#include <QList>
#include <QPair>
#include <QMap>

#include <nlohmann/json.hpp>

Expand Down Expand Up @@ -260,7 +260,7 @@ namespace Isis {
void reopen(QString access = "r");

void read(Blob &blob,
const QList<QPair<QString,QString>> keywords = QList<QPair<QString,QString>>()) const;
const QMap<QString,QString> keywords = QMap<QString,QString>()) const;
void read(Buffer &rbuf) const;
void write(Blob &blob, bool overwrite=true);
void write(Buffer &wbuf);
Expand Down
96 changes: 82 additions & 14 deletions isis/src/base/objs/CubeStretch/CubeStretch.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
/**
* Do we still need this??
* @file
* $Revision: 1.19 $
* $Date: 2010/03/22 19:44:53 $
*
* Unless noted otherwise, the portions of Isis written by the USGS are
* public domain. See individual third-party library and package descriptions
* for intellectual property information, user agreements, and related
* information.
*
* Although Isis has been used by the USGS, no warranty, expressed or
* implied, is made by the USGS as to the accuracy and functioning of such
* software and related material nor shall the fact of distribution
* constitute any such warranty, and no responsibility is assumed by the
* USGS in connection therewith.
*
* For additional information, launch
* $ISISROOT/doc//documents/Disclaimers/Disclaimers.html
* in a browser or see the Privacy &amp; Disclaimers page on the Isis website,
* http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
* http://www.usgs.gov/privacy.html.
*/

#include "CubeStretch.h"

namespace Isis {
Expand All @@ -11,7 +29,7 @@ namespace Isis {
*/
CubeStretch::CubeStretch() {
m_name = "DefaultStretch";
m_type = "DefaultLinear";
m_type = "Default";
m_bandNumber = 1;
}

Expand All @@ -20,23 +38,23 @@ namespace Isis {
* Constructs a Stretch object with default mapping of special pixel values to
* themselves and a provided name.
*
* @param name Name to use for Stretch
* @param name Name to use for CubeStretch
*/
CubeStretch::CubeStretch(QString name) : m_name(name) {
m_type = "DefaultLinear";
m_type = "Default";
m_bandNumber = 1;
}


/**
* Constructs a Stretch object with default mapping of special pixel values to
* Constructs a CubeStretch object with default mapping of special pixel values to
* themselves and a provided name, and a provided stretch type
*
* @param name Name to use for Stretch
* @param type Type of stretch
*/
CubeStretch::CubeStretch(QString name, QString stretchType, int bandNumber) : m_name(name), m_type(stretchType) {
m_bandNumber = bandNumber;
CubeStretch::CubeStretch(QString name, QString stretchType, int bandNumber) : m_name(name),
m_type(stretchType), m_bandNumber(bandNumber) {
}


Expand All @@ -45,23 +63,44 @@ namespace Isis {
}


// semi-copy constructor
/**
* Constructs a CubeStretch object from a normal Stretch.
*
* @param Stretch Stretch to construct the CubeStretch from.
*/
CubeStretch::CubeStretch(Stretch const& stretch): Stretch(stretch) {
m_name = "Unknown";
m_name = "DefaultStretch";
m_bandNumber = 1;
m_type = "Default";
}



// semi-copy constructor
/**
* Constructs a CubeStretch object from a normal Stretch.
*
* @param Stretch Stretch to construct the CubeStretch from.
*/
CubeStretch::CubeStretch(Stretch const& stretch, QString stretchType): Stretch(stretch), m_type(stretchType) {
m_name = "Unknown";
m_name = "DefaultName";
m_bandNumber = 1;
}


/**
* Check if the CubeStretches are equal
*
* @param stretch2 The stretch to compare with
*
* @return bool True if stretches are equal. Else, false.
*/
bool CubeStretch::operator==(CubeStretch& stretch2) {
return (getBandNumber() == stretch2.getBandNumber()) &&
(getName() == stretch2.getName()) &&
(Text() == stretch2.Text());
}

/**
* Get the Type of Stretch. This is only used by the AdvancedStretchTool.
* Get the Type of Stretch.
*
* @return QString Type of Stretch.
*/
Expand All @@ -70,22 +109,51 @@ namespace Isis {
}


/**
* Set the type of Stretch.
*
* @param QString Type of Stretch.
*/
void CubeStretch::setType(QString stretchType){
m_type = stretchType;
}


/**
* Set the Stretch name.
*
* @param QString name for stretch
*/
void CubeStretch::setName(QString name){
m_name = name;
}


/**
* Get the Stretch name.
*
* @return QString name of stretch
*/
QString CubeStretch::getName(){
return m_name;
}


/**
* Get the band number for the stretch.
*
* @return int band number
*/
int CubeStretch::getBandNumber() {
return m_bandNumber;
}


/**
* Set the band number for the stretch.
*
* @param int band number
*/
void CubeStretch::setBandNumber(int bandNumber) {
m_bandNumber = bandNumber;
}
Expand Down
30 changes: 26 additions & 4 deletions isis/src/base/objs/CubeStretch/CubeStretch.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
#ifndef CubeStretch_h
#define CubeStretch_h

/**
* Do we still need the big block of info up here?
*/
* @file
* $Revision: 1.17 $
* $Date: 2010/03/22 19:44:53 $
*
* Unless noted otherwise, the portions of Isis written by the USGS are
* public domain. See individual third-party library and package descriptions
* for intellectual property information, user agreements, and related
* information.
*
* Although Isis has been used by the USGS, no warranty, expressed or
* implied, is made by the USGS as to the accuracy and functioning of such
* software and related material nor shall the fact of distribution
* constitute any such warranty, and no responsibility is assumed by the
* USGS in connection therewith.
*
* For additional information, launch
* $ISISROOT/doc//documents/Disclaimers/Disclaimers.html
* in a browser or see the Privacy &amp; Disclaimers page on the Isis website,
* http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
* http://www.usgs.gov/privacy.html.
*/

#include "Stretch.h"
#include "StretchBlob.h"

namespace Isis {
/**
* @brief Stores stretch information for a cube.
* @brief Stores stretch information for a cube. Stores stretch pairs,
* band number associated with the stretch, and the stretch type from
* the Advanced Stretch Tool (or 'Default' if not specified)
*
* @ingroup Utility
*
Expand All @@ -30,6 +50,8 @@ namespace Isis {
CubeStretch(Stretch const& stretch, QString type);
CubeStretch(Stretch const& stretch, QString type, QString name, int bandNumber=1);

bool operator==(CubeStretch& stretch2);

QString getType();
void setType(QString stretchType);

Expand Down
64 changes: 0 additions & 64 deletions isis/src/base/objs/CubeStretch/CubeStretch.truth

This file was deleted.

Loading