Isis 3 Programmer Reference
CubeStretch.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "CubeStretch.h"
9 
10 namespace Isis {
11 
19  CubeStretch::CubeStretch(QString name, QString stretchType, int bandNumber) : m_name(name),
20  m_type(stretchType), m_bandNumber(bandNumber) {
21  }
22 
23 
27  CubeStretch::CubeStretch(CubeStretch const& stretch): Stretch(stretch) {
28  m_name = stretch.getName();
29  m_type = stretch.getType();
30  m_bandNumber = stretch.getBandNumber();
31  }
32 
33 
39  CubeStretch::CubeStretch(Stretch const& stretch): Stretch(stretch) {
40  m_name = "DefaultStretch";
41  m_bandNumber = 1;
42  m_type = "Default";
43  }
44 
45 
51  CubeStretch::CubeStretch(Stretch const& stretch, QString stretchType): Stretch(stretch), m_type(stretchType) {
52  m_name = "DefaultName";
53  m_bandNumber = 1;
54  }
55 
56 
63  char *buff = blob.getBuffer();
64  std::string stringFromBuffer(buff, blob.Size());
65  setName(blob.Label()["Name"][0]);
66  setType(blob.Label()["StretchType"][0]);
67  Parse(QString::fromStdString(stringFromBuffer));
68  setBandNumber(blob.Label()["BandNumber"][0].toInt());
69  }
70 
71 
72  // CubeStretch destructor
73  CubeStretch::~CubeStretch() {
74  }
75 
76 
85  Isis::Blob blob("CubeStretch", "Stretch");
86 
87  blob.Label()["Name"] = getName();
88  blob.Label() += PvlKeyword("StretchType", getType());
89  blob.Label() += PvlKeyword("BandNumber", QString::number(getBandNumber()));
90  std::string blobString = Text().toStdString();
91  blob.setData(blobString.c_str(), blobString.size());
92  return blob;
93  }
94 
95 
104  return (getBandNumber() == stretch2.getBandNumber()) &&
105  (getName() == stretch2.getName()) &&
106  (Text() == stretch2.Text());
107  }
108 
109 
115  QString CubeStretch::getType() const{
116  return m_type;
117  }
118 
119 
125  void CubeStretch::setType(QString stretchType){
126  m_type = stretchType;
127  }
128 
129 
135  void CubeStretch::setName(QString name){
136  m_name = name;
137  }
138 
139 
145  QString CubeStretch::getName() const{
146  return m_name;
147  }
148 
149 
156  return m_bandNumber;
157  }
158 
159 
165  void CubeStretch::setBandNumber(int bandNumber) {
166  m_bandNumber = bandNumber;
167  }
168 } // end namespace isis
Isis::CubeStretch::m_type
QString m_type
The name of the stretch.
Definition: CubeStretch.h:52
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::Blob::setData
void setData(const char *buffer, int nbytes)
Set the data stored in the BLOB.
Definition: Blob.cpp:382
Isis::Stretch
Pixel value mapper.
Definition: Stretch.h:58
Isis::CubeStretch::operator==
bool operator==(CubeStretch &stretch2)
Check if the CubeStretches are equal.
Definition: CubeStretch.cpp:103
Isis::CubeStretch::setName
void setName(QString name)
Set the Stretch name.
Definition: CubeStretch.cpp:135
Isis::CubeStretch
Stores stretch information for a cube.
Definition: CubeStretch.h:27
Isis::CubeStretch::getBandNumber
int getBandNumber() const
Get the band number for the stretch.
Definition: CubeStretch.cpp:155
Isis::Blob::getBuffer
char * getBuffer()
Get the internal data buff of the Blob.
Definition: Blob.cpp:546
Isis::Blob::Label
PvlObject & Label()
Accessor method that returns a PvlObject containing the Blob label.
Definition: Blob.cpp:151
Isis::Stretch::Parse
void Parse(const QString &pairs)
Parses a string of the form "i1:o1 i2:o2...iN:oN" where each i:o represents an input:output pair.
Definition: Stretch.cpp:181
Isis::CubeStretch::m_bandNumber
int m_bandNumber
Type of stretch. This is only currently used in the AdvancedStretchTool.
Definition: CubeStretch.h:53
Isis::Stretch::Text
QString Text() const
Converts stretch pair to a string.
Definition: Stretch.cpp:268
Isis::Blob::Size
int Size() const
Accessor method that returns the number of bytes in the blob data.
Definition: Blob.cpp:142
Isis::CubeStretch::toBlob
Isis::Blob toBlob() const
Serialize the CubeStretch to a Blob.
Definition: CubeStretch.cpp:84
Isis::CubeStretch::setBandNumber
void setBandNumber(int bandNumber)
Set the band number for the stretch.
Definition: CubeStretch.cpp:165
Isis::CubeStretch::getType
QString getType() const
Get the Type of Stretch.
Definition: CubeStretch.cpp:115
Isis::CubeStretch::setType
void setType(QString stretchType)
Set the type of Stretch.
Definition: CubeStretch.cpp:125
Isis::CubeStretch::CubeStretch
CubeStretch(QString name="DefaultStretch", QString stretchType="Default", int bandNumber=1)
Constructs a CubeStretch object with default mapping of special pixel values to themselves and a prov...
Definition: CubeStretch.cpp:19
Isis::Blob
Definition: Blob.h:51
Isis::CubeStretch::getName
QString getName() const
Get the Stretch name.
Definition: CubeStretch.cpp:145
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16