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"
80 for (
auto grpIt = cubeLabel.beginGroup(); grpIt!= cubeLabel.endGroup(); grpIt++) {
100 attachSpiceFromIsd(isd);
117 std::ifstream isdStream(isdFile.expanded().toStdString());
118 std::ifstream labelStream(labelFile.expanded().toStdString());
120 if (isdStream.fail()) {
121 QString msg = QString(
"failed to open isd stream: %1").arg(isdFile.expanded());
123 isdFile.baseName().toStdString().c_str(), 153);
126 if (labelStream.fail()) {
127 QString msg =
"failed to open file stream";
129 fileName.baseName().toStdString().c_str(), 153);
136 labelStream >>
label;
138 catch (std::exception &ex) {
139 QString msg = QString(
"Failed to open label file, %1, %2").arg(labelFile.expanded()).arg(ex.what());
141 fileName.baseName().toStdString().c_str(), 153);
148 catch (std::exception &ex) {
149 QString msg = QString(
"Failed to open ISD file, %1, %2").arg(isdFile.expanded()).arg(ex.what());
151 fileName.baseName().toStdString().c_str(), 145);
209 bool readOnly =
false;
212 QString msg =
"No cube opened";
216 if ((
m_labelFile->openMode() & QIODevice::ReadWrite) != QIODevice::ReadWrite)
274 QObject::tr(
"Cube::copy requires the originating cube to be open"),
284 result->
setFormat(newFileAttributes.fileFormat());
290 if (newFileAttributes.propagatePixelType()) {
297 if (newFileAttributes.propagateMinimumMaximum()) {
306 QObject::tr(
"Cannot reduce the output PixelType for [%1] from [%2] without output "
307 "pixel range").arg(newFile.original()).arg(
fileName());
313 result->
setMinMax(newFileAttributes.minimum(), newFileAttributes.maximum());
328 result->
create(newFile.expanded());
332 for(
int i = 0; i < isisCube.groups(); i++) {
333 outIsisCube.addGroup(isisCube.group(i));
336 if (
label()->hasObject(
"NaifKeywords")) {
338 label()->findObject(
"NaifKeywords"));
343 if (obj.isNamed(
"Table") || obj.isNamed(
"Polygon") || obj.isNamed(
"OriginalLabel") ||
344 obj.isNamed(
"History")) {
345 Isis::Blob t((QString)obj[
"Name"], obj.name());
362 while (!input.end()) {
364 output.Copy(input,
false);
366 result->
write(output);
412 string msg =
"You already have a cube opened";
419 "] cannot be less than 1";
425 QString(
"Cannot create the cube [%1] with a pixel type set to None")
439 int maxSizePreference = 0;
442 Preference::Preferences().findGroup(
"CubeCustomization")[
"MaximumSize"];
444 if (size > maxSizePreference) {
446 msg +=
"The cube you are attempting to create [" + cubeFileName +
"] is ["
447 +
toString(size) +
"GB]. This is larger than the current allowed "
448 "size of [" +
toString(maxSizePreference) +
"GB]. The cube "
452 "wish to create this cube, the maximum value can be changed in your personal "
453 "preference file located in [~/.Isis/IsisPreferences] within the group "
454 "CubeCustomization, keyword MaximumSize. If you do not have an ISISPreference file, "
455 "please refer to the documentation 'Environment and Preference Setup'. Error ";
466 cubFile = cubFile.addExtension(
"cub");
483 labelFileName = labelFileName.setExtension(
"lbl");
503 core.addGroup(ptype);
506 cubFile = cubFile.addExtension(
"ecub");
516 isiscube.addObject(core);
527 Preference::Preferences().findGroup(
"CubeCustomization");
528 bool overwrite = pref[
"Overwrite"][0].toUpper() ==
"ALLOW";
531 "user preference does not allow overwrite";
535 if (!
m_labelFile->open(QIODevice::Truncate | QIODevice::ReadWrite)) {
536 QString msg =
"Failed to create [" +
m_labelFile->fileName() +
"]. ";
537 msg +=
"Verify the output path exists and you have permission to write to the path.";
544 QString msg =
"Failed to create [" +
m_dataFile->fileName() +
"]. ";
545 msg +=
"Verify the output path exists and you have permission to write to the path.";
550 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] for reading. ";
551 msg +=
"Verify the output path exists and you have permission to read from the path.";
603 if (!att.propagatePixelType())
622 void Cube::open(
const QString &cubeFileName, QString access) {
626 string msg =
"You already have a cube opened";
634 if(att.bands().size() != 0) {
635 vector<QString> bands = att.bands();
647 if (core.hasKeyword(
"^Core")) {
650 if (!temp.originalPath().startsWith(
"/")) {
663 else if (core.hasKeyword(
"^DnFile")) {
664 FileName dataFileName(core[
"^DnFile"][0]);
666 if (dataFileName.originalPath() ==
".") {
692 QString msg =
"Failed to open [" +
m_labelFile->fileName() +
"] with "
700 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
708 else if (access ==
"rw") {
710 QString msg =
"Failed to open [" +
m_labelFile->fileName() +
"] with "
718 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
724 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
732 QString msg =
"Unknown value for access [" + access +
"]. Expected 'r' "
748 QPair<bool, Pvl *> dataLabel = qMakePair(
false,
m_label);
763 if (dataLabel.first) {
764 delete dataLabel.second;
765 dataLabel.second = NULL;
782 QString msg =
"Cube has not been opened yet. The filename to re-open is "
789 QList<int> virtualBandList;
797 if (virtualBandList.size()) {
815 string msg =
"The cube is not opened so you can't read a blob from it";
825 blob.Read(cubeFile.toString(), *
label(), keywords);
837 string msg =
"Try opening a file before you read it";
854 Blob historyBlob(name,
"History");
873 Blob footprintBlob(
"Footprint",
"Polygon");
879 QString msg =
"Footprintinit must be run prior to reading the footprint";
880 msg +=
" with POLYGON=TRUE for cube [" +
fileName() +
"]";
896 Blob origLabelBlob(name,
"OriginalLabel");
901 QString msg =
"Unable to locate OriginalLabel in " +
fileName();
919 Blob stretchBlob(name,
"Stretch");
921 read(stretchBlob, keywords);
924 QString msg =
"Unable to locate Stretch information in " +
fileName();
938 Blob origXmlLabelBlob(
"IsisCube",
"OriginalXmlLabel");
940 read(origXmlLabelBlob);
943 QString msg =
"Unable to locate OriginalXmlLabel in " +
fileName();
959 Blob tableBlob(name,
"Table");
964 QString msg =
"Failed to read table [" + name +
"] from cube [" +
fileName() +
"].";
967 return Table(tableBlob);
979 string msg =
"The cube is not opened so you can't write a blob to it";
984 string msg =
"The cube must be opened in read/write mode, not readOnly";
996 ios::in | ios::out | ios::binary);
997 stream.seekp(0, ios::end);
1000 streampos endByte = stream.tellp();
1009 if (endByte < maxbyte) {
1010 stream.seekp(maxbyte, ios::beg);
1014 blob.Write(*
m_label, stream,
"", overwrite);
1020 blobFileName = blobFileName.removeExtension();
1021 blobFileName = blobFileName.addExtension(blob.Type());
1022 blobFileName = blobFileName.addExtension(blob.Name());
1023 QString blobFile(blobFileName.expanded());
1024 ios::openmode flags = ios::in | ios::binary | ios::out | ios::trunc;
1025 fstream detachedStream;
1026 detachedStream.open(blobFile.toLatin1().data(), flags);
1027 if (!detachedStream) {
1028 QString message =
"Unable to open data file [" +
1029 blobFileName.expanded() +
"]";
1033 blob.Write(*
m_label, detachedStream, blobFileName.
name());
1045 Blob labelBlob = lab.toBlob();
1057 Blob labelBlob = lab.toBlob();
1085 Blob cubeStretchBlob = cubeStretch.toBlob();
1086 write(cubeStretchBlob);
1113 Blob polyBlob = polygon.toBlob();
1126 string msg =
"Tried to write to a cube before opening/creating it";
1131 QString msg =
"Cannot write to the cube [" + (QString)QFileInfo(
fileName()).
fileName() +
1132 "] because it is opened read-only";
1137 QString msg =
"The cube [" + QFileInfo(
fileName()).fileName() +
1138 "] does not support storing DN data because it is using an external file for DNs";
1225 if ((ns < 1) || (nl < 1) || (nb < 1)) {
1226 string msg =
"SetDimensions: Invalid number of sample, lines or bands";
1334 if (vbands.size() > 0) {
1335 QListIterator<QString> it(vbands);
1336 while (it.hasNext()) {
1358 QList<QString> realVBands;
1360 for(
unsigned int i = 0; i < vbands.size(); i++)
1361 realVBands << vbands[i];
1375 QString(
"Cannot relocate the DN data to [%1] for an external cube label "
1376 "file which is not open.")
1377 .arg(dnDataFile.original()),
1384 QString(
"The cube [%1] stores DN data. It cannot be relocated to [%2] - "
1385 "this is only supported for external cube label files.")
1391 dnDataFile.original();
1465 void Cube::attachSpiceFromIsd(nlohmann::json isd) {
1467 PvlKeyword pckKeyword(
"TargetAttitudeShape");
1468 PvlKeyword targetSpkKeyword(
"TargetPosition");
1478 Table ckTable = spice.instrumentRotation()->Cache(
"InstrumentPointing");
1481 for (
int i = 0; i < ckKeyword.size(); i++)
1482 ckTable.Label()[
"Kernels"].addValue(ckKeyword[i]);
1484 this->
write(ckTable);
1486 Table spkTable = spice.instrumentPosition()->Cache(
"InstrumentPosition");
1488 for (
int i = 0; i < spkKeyword.size(); i++)
1489 spkTable.Label()[
"Kernels"].addValue(spkKeyword[i]);
1491 this->
write(spkTable);
1493 Table bodyTable = spice.bodyRotation()->Cache(
"BodyRotation");
1495 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1496 bodyTable.Label()[
"Kernels"].addValue(targetSpkKeyword[i]);
1498 for (
int i = 0; i < pckKeyword.size(); i++)
1499 bodyTable.Label()[
"Kernels"].addValue(pckKeyword[i]);
1501 bodyTable.Label() +=
PvlKeyword(
"SolarLongitude",
1502 toString(spice.solarLongitude().degrees()));
1503 this->
write(bodyTable);
1505 Table sunTable = spice.sunPosition()->Cache(
"SunPosition");
1507 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1508 sunTable.Label()[
"Kernels"].addValue(targetSpkKeyword[i]);
1510 this->
write(sunTable);
1516 while (i < label->objects()) {
1518 if (currObj.isNamed(
"NaifKeywords")) {
1526 *(this->
label()) += spice.getStoredNaifKeywords();
1544 "An external cube label file must be opened in order to use "
1545 "Cube::getExternalCubeFileName",
1551 "Cube::getExternalCubeFileName can only be called on an external cube label "
1559 return core[
"^DnFile"][0];
1636 const double &validMax, QString msg) {
1639 QString msg =
"Cannot create histogram object for an unopened cube";
1644 if ((band < 0) || (band >
bandCount())) {
1645 QString msg =
"Invalid band in [CubeInfo::Histogram]";
1649 int bandStart = band;
1650 int bandStop = band;
1667 double binMin = validMin;
1668 double binMax = validMax;
1670 binMin = hist->BinRangeStart();
1674 binMax = hist->BinRangeEnd();
1678 hist->SetValidRange(binMin,binMax);
1685 for(
int useBand = bandStart ; useBand <= bandStop ; useBand++) {
1783 if ((virtualBand < 1) ||
1785 QString msg =
"Out of array bounds [" +
toString(virtualBand) +
"]";
1858 const double &validMax, QString msg) {
1861 QString msg =
"Cannot create statistics object for an unopened cube";
1866 if ((band < 0) || (band >
bandCount())) {
1867 string msg =
"Invalid band in [CubeInfo::Statistics]";
1875 stats->SetValidRange(validMin, validMax);
1877 int bandStart = band;
1878 int bandStop = band;
1892 for(
int useBand = bandStart ; useBand <= bandStop ; useBand++) {
1934 QString msg =
"Cannot add a caching algorithm until the cube is open";
1964 if (obj.name().compare(BlobType) == 0) {
1965 if (obj.findKeyword(
"Name")[0] == BlobName) {
1985 if (!isiscube.hasGroup(
group))
return;
1986 isiscube.deleteGroup(
group);
1999 return isiscube.findGroup(
group);
2012 if (isiscube.hasGroup(
group))
return true;
2028 if (obj.isNamed(type)) {
2029 if (obj.hasKeyword(
"Name")) {
2030 QString temp = (QString) obj[
"Name"];
2031 temp = temp.toUpper();
2032 QString temp2 = name;
2033 temp2 = temp2.toUpper();
2034 if (temp == temp2)
return true;
2050 return hasBlob(name,
"Table");
2064 QString msg =
"Cannot add a group to the label of cube [" + (QString)QFileInfo(
fileName()).
fileName() +
2065 "] because it is opened read-only";
2075 isiscube.addGroup(
group);
2090 for (
int k = 0;k < bandBin.keywords();k++) {
2179 new FileName(
"$ISISROOT/appdata/templates/labels/CubeFormatTemplate.pft");
2227 dir2.cd(guess.
path());
2228 guess = dir2.absolutePath() +
"/" + guess.
name();
2235 if (core.hasKeyword(
"^DnFile")) {
2237 guess = core[
"^DnFile"][0];
2239 if (!guess.
path().startsWith(
"/")) {
2243 else if (core.hasKeyword(
"^Core")) {
2244 result = core[
"^Core"][0];
2250 while (result.
name() ==
"");
2296 if (!core.hasKeyword(
"^DnFile")) {
2298 const PvlGroup &dims = core.findGroup(
"Dimensions");
2304 const PvlGroup &pixelsGroup = core.findGroup(
"Pixels");
2305 m_byteOrder = ByteOrderEnumeration(pixelsGroup[
"ByteOrder"]);
2306 m_base = pixelsGroup[
"Base"];
2311 if ((QString) core[
"Format"] ==
"BandSequential") {
2320 if (!temp.expanded().startsWith(
"/")) {
2340 if (labelFileName.fileExists()) {
2357 tmp = tmp.addExtension(
"cub");
2358 if (tmp.fileExists()) {
2363 labelFileName = tmp;
2377 tmp = tmp.setExtension(
"lbl");
2378 if (tmp.fileExists()) {
2383 labelFileName = tmp;
2397 tmp = tmp.addExtension(
"ecub");
2398 if (tmp.fileExists()) {
2403 labelFileName = tmp;
2429 " because it is an ISIS2 cube.";
2445 string msg =
"Sorry you can't do a SetMethod after the cube is opened";
2463 if (core->hasKeyword(
"^DnFile")) {
2465 FileName temp((*core)[
"^DnFile"][0]);
2466 if (!temp.expanded().startsWith(
"/")) {
2487 QString parameters =
"from=" + oldCube;
2490 parameters +=
" to=" + tempCube.expanded();
2493 QString command =
"$ISISROOT/bin/pds2isis " + parameters;
2497 QString prog =
"pds2isis";
2521 bool isGood =
false;
2522 bool useProj =
true;
2534 QString msg =
"Cannot calculate lat/lon range without a camera or projection";
2543 QString msg =
"Unable to create camera when calculating a lat/lon range.";
2549 minLatitude = 99999;
2550 minLongitude = 99999;
2551 maxLatitude = -99999;
2552 maxLongitude = -99999;
2554 for (
double sample = 0.5; sample <
sampleCount() + 0.5; sample++) {
2556 for (
double line = 0.5; line <
lineCount() + 0.5; line++) {
2558 isGood = proj->SetWorld(sample, line);
2561 isGood = cam->SetImage(sample, line);
2567 lat = proj->UniversalLatitude();
2568 lon = proj->UniversalLongitude();
2571 lat = cam->UniversalLatitude();
2572 lon = cam->UniversalLongitude();
2576 if (lat < minLatitude) {
2579 else if (lat > maxLatitude) {
2583 if (lon < minLongitude) {
2586 else if (lon > maxLongitude) {
2592 if ( (minLatitude == 99999) || (minLongitude == 99999) || (maxLatitude == -99999) ||
2593 (maxLongitude == -99999) ) {
2594 QString msg =
"Unable to calculate a minimum or maximum latitutde or longitude.";
2605 string msg =
"Cube must be opened first before writing labels";
2619 string tempstr = temp.str();
2622 QByteArray labelUnpaddedContents(tempstr.c_str(), tempstr.length());
2623 labelArea.replace(0, labelUnpaddedContents.size(), labelUnpaddedContents);
2630 QString msg =
"Label space is full in [" +
2632 "] 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.