18#include "Application.h"
21#include "CameraFactory.h"
22#include "CubeAttribute.h"
23#include "CubeBsqHandler.h"
24#include "CubeTileHandler.h"
25#include "CubeStretch.h"
29#include "ImageHistogram.h"
30#include "ImagePolygon.h"
31#include "IException.h"
32#include "LineManager.h"
34#include "OriginalLabel.h"
35#include "OriginalXmlLabel.h"
36#include "Preference.h"
37#include "ProgramLauncher.h"
38#include "Projection.h"
39#include "SpecialPixel.h"
40#include "Statistics.h"
42#include "TProjection.h"
81 for (
auto grpIt = cubeLabel.beginGroup(); grpIt!= cubeLabel.endGroup(); grpIt++) {
101 attachSpiceFromIsd(isd);
118 std::ifstream isdStream(isdFile.expanded().toStdString());
119 std::ifstream labelStream(labelFile.expanded().toStdString());
121 if (isdStream.fail()) {
122 QString msg = QString(
"failed to open isd stream: %1").arg(isdFile.expanded());
124 isdFile.baseName().toStdString().c_str(), 153);
127 if (labelStream.fail()) {
128 QString msg =
"failed to open file stream";
130 fileName.baseName().toStdString().c_str(), 153);
137 labelStream >>
label;
139 catch (std::exception &ex) {
140 QString msg = QString(
"Failed to open label file, %1, %2").arg(labelFile.expanded()).arg(ex.what());
142 fileName.baseName().toStdString().c_str(), 153);
149 catch (std::exception &ex) {
150 QString msg = QString(
"Failed to open ISD file, %1, %2").arg(isdFile.expanded()).arg(ex.what());
152 fileName.baseName().toStdString().c_str(), 145);
210 bool readOnly =
false;
213 QString msg =
"No cube opened";
217 if ((
m_labelFile->openMode() & QIODevice::ReadWrite) != QIODevice::ReadWrite)
275 QObject::tr(
"Cube::copy requires the originating cube to be open"),
285 result->
setFormat(newFileAttributes.fileFormat());
291 if (newFileAttributes.propagatePixelType()) {
298 if (newFileAttributes.propagateMinimumMaximum()) {
307 QObject::tr(
"Cannot reduce the output PixelType for [%1] from [%2] without output "
308 "pixel range").arg(newFile.original()).arg(
fileName());
314 result->
setMinMax(newFileAttributes.minimum(), newFileAttributes.maximum());
329 result->
create(newFile.expanded());
333 for(
int i = 0; i < isisCube.groups(); i++) {
334 outIsisCube.addGroup(isisCube.group(i));
337 if (
label()->hasObject(
"NaifKeywords")) {
339 label()->findObject(
"NaifKeywords"));
344 if (obj.isNamed(
"Table") || obj.isNamed(
"Polygon") || obj.isNamed(
"OriginalLabel") ||
345 obj.isNamed(
"History")) {
346 Isis::Blob t((QString)obj[
"Name"], obj.name());
363 while (!input.end()) {
365 output.Copy(input,
false);
367 result->
write(output);
413 string msg =
"You already have a cube opened";
420 "] cannot be less than 1";
426 QString(
"Cannot create the cube [%1] with a pixel type set to None")
440 int maxSizePreference = 0;
443 Preference::Preferences().findGroup(
"CubeCustomization")[
"MaximumSize"];
445 if (size > maxSizePreference) {
447 msg +=
"The cube you are attempting to create [" + cubeFileName +
"] is ["
448 +
toString(size) +
"GB]. This is larger than the current allowed "
449 "size of [" +
toString(maxSizePreference) +
"GB]. The cube "
453 "wish to create this cube, the maximum value can be changed in your personal "
454 "preference file located in [~/.Isis/IsisPreferences] within the group "
455 "CubeCustomization, keyword MaximumSize. If you do not have an ISISPreference file, "
456 "please refer to the documentation 'Environment and Preference Setup'. Error ";
467 cubFile = cubFile.addExtension(
"cub");
484 labelFileName = labelFileName.setExtension(
"lbl");
504 core.addGroup(ptype);
507 cubFile = cubFile.addExtension(
"ecub");
517 isiscube.addObject(core);
528 Preference::Preferences().findGroup(
"CubeCustomization");
529 bool overwrite = pref[
"Overwrite"][0].toUpper() ==
"ALLOW";
532 "user preference does not allow overwrite";
536 if (!
m_labelFile->open(QIODevice::Truncate | QIODevice::ReadWrite)) {
537 QString msg =
"Failed to create [" +
m_labelFile->fileName() +
"]. ";
538 msg +=
"Verify the output path exists and you have permission to write to the path.";
545 QString msg =
"Failed to create [" +
m_dataFile->fileName() +
"]. ";
546 msg +=
"Verify the output path exists and you have permission to write to the path.";
551 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] for reading. ";
552 msg +=
"Verify the output path exists and you have permission to read from the path.";
604 if (!att.propagatePixelType())
623 void Cube::open(
const QString &cubeFileName, QString access) {
627 string msg =
"You already have a cube opened";
635 if(att.bands().size() != 0) {
636 vector<QString> bands = att.bands();
648 if (core.hasKeyword(
"^Core")) {
651 if (!temp.originalPath().startsWith(
"/")) {
664 else if (core.hasKeyword(
"^DnFile")) {
665 FileName dataFileName(core[
"^DnFile"][0]);
667 if (dataFileName.originalPath() ==
".") {
693 QString msg =
"Failed to open [" +
m_labelFile->fileName() +
"] with "
701 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
709 else if (access ==
"rw") {
711 QString msg =
"Failed to open [" +
m_labelFile->fileName() +
"] with "
719 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
725 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
733 QString msg =
"Unknown value for access [" + access +
"]. Expected 'r' "
749 QPair<bool, Pvl *> dataLabel = qMakePair(
false,
m_label);
764 if (dataLabel.first) {
765 delete dataLabel.second;
766 dataLabel.second = NULL;
783 QString msg =
"Cube has not been opened yet. The filename to re-open is "
790 QList<int> virtualBandList;
798 if (virtualBandList.size()) {
816 string msg =
"The cube is not opened so you can't read a blob from it";
826 blob.Read(cubeFile.toString(), *
label(), keywords);
838 string msg =
"Try opening a file before you read it";
855 Blob historyBlob(name,
"History");
874 Blob footprintBlob(
"Footprint",
"Polygon");
880 QString msg =
"Footprintinit must be run prior to reading the footprint";
881 msg +=
" with POLYGON=TRUE for cube [" +
fileName() +
"]";
897 Blob origLabelBlob(name,
"OriginalLabel");
902 QString msg =
"Unable to locate OriginalLabel in " +
fileName();
920 Blob stretchBlob(name,
"Stretch");
922 read(stretchBlob, keywords);
925 QString msg =
"Unable to locate Stretch information in " +
fileName();
939 Blob origXmlLabelBlob(
"IsisCube",
"OriginalXmlLabel");
941 read(origXmlLabelBlob);
944 QString msg =
"Unable to locate OriginalXmlLabel in " +
fileName();
960 Blob tableBlob(name,
"Table");
965 QString msg =
"Failed to read table [" + name +
"] from cube [" +
fileName() +
"].";
968 return Table(tableBlob);
980 string msg =
"The cube is not opened so you can't write a blob to it";
985 string msg =
"The cube must be opened in read/write mode, not readOnly";
997 ios::in | ios::out | ios::binary);
998 stream.seekp(0, ios::end);
1001 streampos endByte = stream.tellp();
1010 if (endByte < maxbyte) {
1011 stream.seekp(maxbyte, ios::beg);
1015 blob.Write(*
m_label, stream,
"", overwrite);
1021 blobFileName = blobFileName.removeExtension();
1022 blobFileName = blobFileName.addExtension(blob.Type());
1023 blobFileName = blobFileName.addExtension(blob.Name());
1024 QString blobFile(blobFileName.expanded());
1025 ios::openmode flags = ios::in | ios::binary | ios::out | ios::trunc;
1026 fstream detachedStream;
1027 detachedStream.open(blobFile.toLatin1().data(), flags);
1028 if (!detachedStream) {
1029 QString message =
"Unable to open data file [" +
1030 blobFileName.expanded() +
"]";
1034 blob.Write(*
m_label, detachedStream, blobFileName.
name());
1046 Blob labelBlob = lab.toBlob();
1058 Blob labelBlob = lab.toBlob();
1086 Blob cubeStretchBlob = cubeStretch.toBlob();
1087 write(cubeStretchBlob);
1114 Blob polyBlob = polygon.toBlob();
1127 string msg =
"Tried to write to a cube before opening/creating it";
1132 QString msg =
"Cannot write to the cube [" + (QString)QFileInfo(
fileName()).
fileName() +
1133 "] because it is opened read-only";
1138 QString msg =
"The cube [" + QFileInfo(
fileName()).fileName() +
1139 "] does not support storing DN data because it is using an external file for DNs";
1226 if ((ns < 1) || (nl < 1) || (nb < 1)) {
1227 string msg =
"SetDimensions: Invalid number of sample, lines or bands";
1335 if (vbands.size() > 0) {
1336 QListIterator<QString> it(vbands);
1337 while (it.hasNext()) {
1359 QList<QString> realVBands;
1361 for(
unsigned int i = 0; i < vbands.size(); i++)
1362 realVBands << vbands[i];
1376 QString(
"Cannot relocate the DN data to [%1] for an external cube label "
1377 "file which is not open.")
1378 .arg(dnDataFile.original()),
1385 QString(
"The cube [%1] stores DN data. It cannot be relocated to [%2] - "
1386 "this is only supported for external cube label files.")
1392 dnDataFile.original();
1466 void Cube::attachSpiceFromIsd(nlohmann::json isd) {
1468 PvlKeyword pckKeyword(
"TargetAttitudeShape");
1469 PvlKeyword targetSpkKeyword(
"TargetPosition");
1479 Table ckTable = spice.instrumentRotation()->Cache(
"InstrumentPointing");
1482 for (
int i = 0; i < ckKeyword.size(); i++)
1483 ckTable.Label()[
"Kernels"].addValue(ckKeyword[i]);
1485 this->
write(ckTable);
1487 Table spkTable = spice.instrumentPosition()->Cache(
"InstrumentPosition");
1489 for (
int i = 0; i < spkKeyword.size(); i++)
1490 spkTable.Label()[
"Kernels"].addValue(spkKeyword[i]);
1492 this->
write(spkTable);
1494 Table bodyTable = spice.bodyRotation()->Cache(
"BodyRotation");
1496 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1497 bodyTable.Label()[
"Kernels"].addValue(targetSpkKeyword[i]);
1499 for (
int i = 0; i < pckKeyword.size(); i++)
1500 bodyTable.Label()[
"Kernels"].addValue(pckKeyword[i]);
1502 bodyTable.Label() +=
PvlKeyword(
"SolarLongitude",
1503 toString(spice.solarLongitude().degrees()));
1504 this->
write(bodyTable);
1506 Table sunTable = spice.sunPosition()->Cache(
"SunPosition");
1508 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1509 sunTable.Label()[
"Kernels"].addValue(targetSpkKeyword[i]);
1511 this->
write(sunTable);
1517 while (i < label->objects()) {
1519 if (currObj.isNamed(
"NaifKeywords")) {
1527 *(this->
label()) += spice.getStoredNaifKeywords();
1545 "An external cube label file must be opened in order to use "
1546 "Cube::getExternalCubeFileName",
1552 "Cube::getExternalCubeFileName can only be called on an external cube label "
1560 return core[
"^DnFile"][0];
1637 const double &validMax, QString msg) {
1640 QString msg =
"Cannot create histogram object for an unopened cube";
1645 if ((band < 0) || (band >
bandCount())) {
1646 QString msg =
"Invalid band in [CubeInfo::Histogram]";
1650 int bandStart = band;
1651 int bandStop = band;
1668 double binMin = validMin;
1669 double binMax = validMax;
1671 binMin = hist->BinRangeStart();
1675 binMax = hist->BinRangeEnd();
1679 hist->SetValidRange(binMin,binMax);
1686 for(
int useBand = bandStart ; useBand <= bandStop ; useBand++) {
1784 if ((virtualBand < 1) ||
1786 QString msg =
"Out of array bounds [" +
toString(virtualBand) +
"]";
1859 const double &validMax, QString msg) {
1862 QString msg =
"Cannot create statistics object for an unopened cube";
1867 if ((band < 0) || (band >
bandCount())) {
1868 string msg =
"Invalid band in [CubeInfo::Statistics]";
1876 stats->SetValidRange(validMin, validMax);
1878 int bandStart = band;
1879 int bandStop = band;
1893 for(
int useBand = bandStart ; useBand <= bandStop ; useBand++) {
1935 QString msg =
"Cannot add a caching algorithm until the cube is open";
1965 if (obj.name().compare(BlobType) == 0) {
1966 if (obj.findKeyword(
"Name")[0] == BlobName) {
1986 if (!isiscube.hasGroup(
group))
return;
1987 isiscube.deleteGroup(
group);
2000 return isiscube.findGroup(
group);
2013 if (isiscube.hasGroup(
group))
return true;
2029 if (obj.isNamed(type)) {
2030 if (obj.hasKeyword(
"Name")) {
2031 QString temp = (QString) obj[
"Name"];
2032 temp = temp.toUpper();
2033 QString temp2 = name;
2034 temp2 = temp2.toUpper();
2035 if (temp == temp2)
return true;
2051 return hasBlob(name,
"Table");
2065 QString msg =
"Cannot add a group to the label of cube [" + (QString)QFileInfo(
fileName()).
fileName() +
2066 "] because it is opened read-only";
2076 isiscube.addGroup(
group);
2091 for (
int k = 0;k < bandBin.keywords();k++) {
2180 new FileName(
"$ISISROOT/appdata/templates/labels/CubeFormatTemplate.pft");
2228 dir2.cd(guess.
path());
2229 guess = dir2.absolutePath() +
"/" + guess.
name();
2236 if (core.hasKeyword(
"^DnFile")) {
2238 guess = core[
"^DnFile"][0];
2240 if (!guess.
path().startsWith(
"/")) {
2244 else if (core.hasKeyword(
"^Core")) {
2245 result = core[
"^Core"][0];
2251 while (result.
name() ==
"");
2297 if (!core.hasKeyword(
"^DnFile")) {
2299 const PvlGroup &dims = core.findGroup(
"Dimensions");
2305 const PvlGroup &pixelsGroup = core.findGroup(
"Pixels");
2306 m_byteOrder = ByteOrderEnumeration(pixelsGroup[
"ByteOrder"]);
2307 m_base = pixelsGroup[
"Base"];
2312 if ((QString) core[
"Format"] ==
"BandSequential") {
2321 if (!temp.expanded().startsWith(
"/")) {
2341 if (labelFileName.fileExists()) {
2358 tmp = tmp.addExtension(
"cub");
2359 if (tmp.fileExists()) {
2364 labelFileName = tmp;
2378 tmp = tmp.setExtension(
"lbl");
2379 if (tmp.fileExists()) {
2384 labelFileName = tmp;
2398 tmp = tmp.addExtension(
"ecub");
2399 if (tmp.fileExists()) {
2404 labelFileName = tmp;
2430 " because it is an ISIS2 cube.";
2446 string msg =
"Sorry you can't do a SetMethod after the cube is opened";
2464 if (core->hasKeyword(
"^DnFile")) {
2466 FileName temp((*core)[
"^DnFile"][0]);
2467 if (!temp.expanded().startsWith(
"/")) {
2488 QString parameters =
"from=" + oldCube;
2491 parameters +=
" to=" + tempCube.expanded();
2494 QString command =
"$ISISROOT/bin/pds2isis " + parameters;
2498 QString prog =
"pds2isis";
2522 bool isGood =
false;
2523 bool useProj =
true;
2535 QString msg =
"Cannot calculate lat/lon range without a camera or projection";
2544 QString msg =
"Unable to create camera when calculating a lat/lon range.";
2550 minLatitude = 99999;
2551 minLongitude = 99999;
2552 maxLatitude = -99999;
2553 maxLongitude = -99999;
2555 for (
double sample = 0.5; sample <
sampleCount() + 0.5; sample++) {
2557 for (
double line = 0.5; line <
lineCount() + 0.5; line++) {
2559 isGood = proj->SetWorld(sample, line);
2562 isGood = cam->SetImage(sample, line);
2568 lat = proj->UniversalLatitude();
2569 lon = proj->UniversalLongitude();
2572 lat = cam->UniversalLatitude();
2573 lon = cam->UniversalLongitude();
2577 if (lat < minLatitude) {
2580 else if (lat > maxLatitude) {
2584 if (lon < minLongitude) {
2587 else if (lon > maxLongitude) {
2593 if ( (minLatitude == 99999) || (minLongitude == 99999) || (maxLatitude == -99999) ||
2594 (maxLongitude == -99999) ) {
2595 QString msg =
"Unable to calculate a minimum or maximum latitutde or longitude.";
2606 string msg =
"Cube must be opened first before writing labels";
2620 string tempstr = temp.str();
2623 QByteArray labelUnpaddedContents(tempstr.c_str(), tempstr.length());
2624 labelArea.replace(0, labelUnpaddedContents.size(), labelUnpaddedContents);
2631 QString msg =
"Label space is full in [" +
2633 "] unable to write labels";
Buffer for reading and writing cube data.
int size() const
Returns the total number of pixels in the shape buffer.
double * DoubleBuffer() const
Returns the value of the shape buffer.
Manages a Buffer over a cube.
static Camera * Create(Cube &cube)
Creates a Camera object using Pvl Specifications.
Manipulate and parse attributes of output cube filenames.
IO Handler for Isis Cubes using the BSQ format.
This is the parent of the caching algorithms.
IO Handler for Isis Cubes.
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
void clearIoCache()
This will clear excess RAM used for quicker IO in the cube.
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
QFile * m_dataFile
This is only sometimes allocated.
Pvl realDataFileLabel() const
Function to read data from a cube label and return it as a PVL object.
ImagePolygon readFootprint() const
Read the footprint polygon for the Cube.
Cube()
Constructs a Cube object.
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude, double &maxLongitude)
Returns the latitude and longitude range for the Cube.
void deleteGroup(const QString &group)
Deletes a group from the cube labels.
void reformatOldIsisLabel(const QString &oldCube)
This is a helper, used by open(...), that handles opening Isis 2 cubes as if they were Isis cubes.
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band,...
bool deleteBlob(QString BlobName, QString BlobType)
This method will delete a blob label object from the cube as specified by the Blob type and name.
int m_bands
The band count of the open cube or the cube that will be created.
void initialize()
This sets Cube to its default state: Native byte order Format = Tile PixelType = Real (4 bytes per pi...
PixelType m_pixelType
This is the pixel type on disk.
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
void construct()
Initialize members from their initial undefined states.
int m_labelBytes
The maximum allowed size of the label; the allocated space.
virtual Histogram * histogram(const int &band=1, QString msg="Gathering histogram")
This method returns a pointer to a Histogram object which allows the program to obtain and use variou...
void initLabelFromFile(FileName labelFileName, bool readWrite)
This function initializes the Cube label from a file passed as a parameter.
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
CubeIoHandler * m_ioHandler
This does the heavy lifting for cube DN IO and is always allocated when isOpen() is true.
FileName realDataFileName() const
This gets the file name of the file which actually contains the DN data.
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files.
CubeStretch readCubeStretch(QString name="CubeStretch", const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
Read a Stretch from a cube.
Statistics * statistics(const int &band=1, QString msg="Gathering statistics")
This method returns a pointer to a Statistics object which allows the program to obtain and use vario...
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Camera * camera()
Return a camera associated with the cube.
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
double m_base
The base of the open cube or the cube that will be created; does not apply if m_pixelType is Real.
bool m_attached
True if labels are attached.
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
bool m_storesDnData
True (most common case) when the cube DN data is inside the file we're writing to.
bool isOpen() const
Test if a cube file has been opened/created.
void setBaseMultiplier(double base, double mult)
Used prior to the Create method, this will specify the base and multiplier for converting 8-bit/16-bi...
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true.
int m_lines
The line count of the open cube or the cube that will be created.
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access)
Initialize Cube data from a PVL label and JSON ISD.
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
QFile * dataFile() const
This returns the QFile with cube DN data in it.
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
void create(const QString &cfile)
This method will create an isis cube for writing.
FileName * m_tempCube
If open was called with an Isis 2 cube, then this will be the name of the imported ISIS cube.
bool hasBlob(const QString &name, const QString &type)
Check to see if the cube contains a BLOB.
void cleanUp(bool remove)
This clears all of the allocated memory associated with an open cube.
ByteOrder byteOrder() const
Returns the byte order/endian-ness of the cube file.
ByteOrder m_byteOrder
The byte order of the opened cube; if there is no open cube then this is the byte order that will be ...
QFile * m_labelFile
This is the file that contains the labels always; if labels are attached then this contains the file ...
bool labelsAttached() const
Test if labels are attached.
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
PixelType pixelType() const
bool storesDnData() const
This method returns a boolean value.
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
FileName * m_formatTemplateFile
Label pvl format template file (describes how to format labels)
Pvl * m_label
The label if IsOpen(), otherwise NULL.
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
bool isProjected() const
Returns true if the labels of the cube appear to have a valid mapping group.
OriginalLabel readOriginalLabel(const QString &name="IsisCube") const
Read the original PDS3 label from a cube.
Format
These are the possible storage formats of ISIS cubes.
@ Tile
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
@ Bsq
Cubes are stored in band-sequential format, that is the order of the pixels in the file (on disk) is:
virtual int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Table readTable(const QString &name)
Read a Table from the cube.
Camera * m_camera
Camera allocated from the camera() method.
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
OriginalXmlLabel readOriginalXmlLabel() const
Read the original PDS4 label from a cube.
virtual QString fileName() const
Returns the opened cube's filename.
void fromLabel(const FileName &fileName, Pvl &label, QString access)
Initialize Cube data from a PVL label.
virtual ~Cube()
Destroys the Cube object.
QList< int > * m_virtualBandList
If allocated, converts from physical on-disk band # to virtual band #.
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
FileName * m_labelFileName
The full filename of the label file (.lbl or .cub)
void setExternalDnData(FileName cubeFileWithDnData)
Used to set external dn data to cube.
void close(bool remove=false)
Closes the cube and updates the labels.
History readHistory(const QString &name="IsisCube") const
Read the History from the Cube.
void writeLabels()
Write the Pvl labels to the cube's label file.
QMutex * m_mutex
Basic thread-safety mutex; this class is not optimized for threads.
void initCoreFromLabel(const Pvl &label)
This function initializes the Cube core from a Pvl Label passed as a parameter.
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
int m_samples
The sample count of the open cube or the cube that will be created.
void openCheck()
Throw an exception if the cube is not open.
Projection * projection()
double m_multiplier
The multiplier of the open cube or the cube that will be created; does not apply if m_pixelType is Re...
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
Projection * m_projection
Projection allocated from the projection() method.
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
FileName * m_dataFileName
The full filename of the data file (.cub)
void applyVirtualBandsToLabel()
Applies virtual bands to label.
Format m_format
If isOpen() then this is the IO format that the cube uses.
void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
void addCachingAlgorithm(CubeCachingAlgorithm *algorithm)
This will add the given caching algorithm to the list of attempted caching algorithms.
QMutex * dataFileMutex()
Get the mutex that this IO handler is using around I/Os on the given data file.
void read(Buffer &bufferToFill) const
Read cube data from disk into the buffer.
void write(const Buffer &bufferToWrite)
Write buffer data into the cube data on disk.
void setVirtualBands(const QList< int > *virtualBandList)
This changes the virtual band list.
virtual void updateLabels(Pvl &labels)=0
Function to update the labels with a Pvl object.
BigInt getDataSize() const
Stores stretch information for a cube.
IO Handler for Isis Cubes using the tile format.
File name manipulation and expansion.
QString path() const
Returns the path of the file name.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
static FileName createTempFile(FileName templateFileName="$TEMPORARY/temp")
Creates a temporary file and returns a FileName object created using the temporary file.
QString original() const
Returns the full file name including the file path.
QString originalPath() const
Returns the path of the original file name.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
Container of a cube histogram.
Blob toBlob(const QString &name="IsisCube")
Converts a history object into a new blob object.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
@ Io
A type of error that occurred when performing an actual I/O operation.
Container of a cube histogram.
Create cube polygons, read/write polygons to blobs.
Buffer manager, for moving through a cube in lines.
bool SetLine(const int line, const int band=1)
Positions the buffer at the requested line and returns a status indicator if the set was succesful or...
Read and store original labels.
Read and store original Xml labels.
static void RunIsisProgram(QString isisProgramName, QString arguments)
Executes the Isis program with the given arguments.
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
Program progress reporter.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
void CheckStatus()
Checks and updates the status.
static Isis::Projection * CreateFromCube(Isis::Cube &cube)
This method is a helper method.
Base class for Map Projections.
QString name() const
Returns the container name.
Contains multiple PvlContainers.
Container for cube-like labels.
void write(const QString &file)
Opens and writes PVL information to a file and handles the end of line sequence.
A single keyword-value pair.
void clear()
Clears all values and units for this PvlKeyword object.
Contains Pvl Groups and Pvl Objects.
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
void deleteObject(const QString &name)
Remove an object from the current PvlObject.
int objects() const
Returns the number of objects.
PvlObject & object(const int index)
Return the object at the specified index.
void addObject(const PvlObject &object)
Add a PvlObject.
Obtain SPICE information for a spacecraft.
This class is used to accumulate statistics on double arrays.
Base class for Map TProjections.
Class for storing Table blobs information.
PvlObject & Label()
The Table's label.
Blob toBlob() const
Serialze the Table to a Blob that can be written to a file.
ByteOrder
Tests the current architecture for byte order.
QString FileOpen(const QString &filename)
This error should be used when a file could not be opened.
This is free and unencumbered software released into the public domain.
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
int toInt(const QString &string)
Global function to convert from a string to an integer.
const double ValidMaximum
The maximum valid double value for Isis pixels.
Isis::PixelType PixelTypeEnumeration(const QString &type)
Returns PixelType enumeration given a string.
@ ExternalLabel
The label is pointing to an external DN file - the label is also external to the data.
@ AttachedLabel
The input label is embedded in the image file.
@ DetachedLabel
The input label is in a separate data file from the image.
long long int BigInt
Big int.
const double ValidMinimum
The minimum valid double value for Isis pixels.
QString PixelTypeName(Isis::PixelType pixelType)
Returns string name of PixelType enumeration entered as input parameter.
PixelType
Enumerations for Isis Pixel Types.
Namespace for the standard library.