File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis Developer Reference
Cube.h
Go to the documentation of this file.
1#ifndef Cube_h
2#define Cube_h
7
8/* SPDX-License-Identifier: CC0-1.0 */
9
10#include <vector>
11
12// This is needed for the QVariant macro
13#include <QMetaType>
14#include <QList>
15#include <QMap>
16
17#include <nlohmann/json.hpp>
18
19#include "Endian.h"
20#include "PixelType.h"
21#include "PvlKeyword.h"
22
23class QFile;
24class QMutex;
25class QString;
26
27namespace Isis {
28 class Blob;
29 class Buffer;
30 class Camera;
33 class CubeIoHandler;
34 class CubeStretch;
35 class FileName;
36 class Projection;
37 class Pvl;
38 class PvlGroup;
39 class Statistics;
40 class Table;
41 class Histogram;
42 class History;
43 class OriginalLabel;
44 class OriginalXmlLabel;
45 class ImagePolygon;
46
47
168 class Cube {
169 public:
170 Cube();
171 Cube(const FileName &fileName, QString access = "r");
172
173 virtual ~Cube();
174
179 enum Format {
234 };
235
236 void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access);
237 void fromIsd(const FileName &fileName, FileName &labelFile, FileName &isdFile, QString access);
238
239 void fromLabel(const FileName &fileName, Pvl &label, QString access);
240
241 bool isOpen() const;
242 bool isProjected() const;
243 bool isReadOnly() const;
244 bool isReadWrite() const;
245 bool labelsAttached() const;
246
247 void attachSpiceFromIsd(nlohmann::json Isd);
248 void attachLineScanTableFromIsd(nlohmann::json isd);
249
250 void close(bool remove = false);
251 Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
252 void create(const QString &cfile);
253 void create(const QString &cfile, const CubeAttributeOutput &att);
254 void open(const QString &cfile, QString access = "r");
255 void reopen(QString access = "r");
256
257 void read(Blob &blob,
258 const std::vector<PvlKeyword> keywords = std::vector<PvlKeyword>()) const;
259 void read(Buffer &rbuf) const;
260 OriginalLabel readOriginalLabel(const QString &name="IsisCube") const;
261 CubeStretch readCubeStretch(QString name="CubeStretch",
262 const std::vector<PvlKeyword> keywords = std::vector<PvlKeyword>()) const;
264 History readHistory(const QString &name = "IsisCube") const;
266 Table readTable(const QString &name);
267 void write(Blob &blob, bool overwrite=true);
268 void write(const Table &table);
269 void write(const CubeStretch &cubeStretch);
270 void write(OriginalLabel &lab);
271 void write(const OriginalXmlLabel &lab);
272 void write(History &history, const QString &name = "IsisCube");
273 void write(const ImagePolygon &polygon);
274 void write(Buffer &wbuf);
275
276 void setBaseMultiplier(double base, double mult);
277 void setMinMax(double min, double max);
279 void setDimensions(int ns, int nl, int nb);
280 void setExternalDnData(FileName cubeFileWithDnData);
281 void setFormat(Format format);
282 void setLabelsAttached(bool attached);
283 void setLabelSize(int labelBytes);
285 void setVirtualBands(const QList<QString> &vbands);
286 void setVirtualBands(const std::vector<QString> &vbands);
287
288 void relocateDnData(FileName dnDataFile);
289// static void relocateDnData(FileName externalLabelFile, FileName dnDataFile);
290
291 virtual int bandCount() const;
292 double base() const;
293 ByteOrder byteOrder() const;
294 Camera *camera();
296 virtual QString fileName() const;
297 Format format() const;
298 virtual Histogram *histogram(const int &band = 1,
299 QString msg = "Gathering histogram");
300 virtual Histogram *histogram(const int &band, const double &validMin,
301 const double &validMax,
302 QString msg = "Gathering histogram");
303 Pvl *label() const;
304 int labelSize(bool actual = false) const;
305 int lineCount() const;
306 double multiplier() const;
307 PixelType pixelType() const;
308 virtual int physicalBand(const int &virtualBand) const;
310 int sampleCount() const;
311 Statistics *statistics(const int &band = 1,
312 QString msg = "Gathering statistics");
313 Statistics *statistics(const int &band, const double &validMin,
314 const double &validMax,
315 QString msg = "Gathering statistics");
316 bool storesDnData() const;
317
319 void clearIoCache();
320 bool deleteBlob(QString BlobName, QString BlobType);
321 void deleteGroup(const QString &group);
322 PvlGroup &group(const QString &group) const;
323 bool hasGroup(const QString &group) const;
324 bool hasTable(const QString &name);
325 bool hasBlob(const QString &name, const QString &type);
326 void putGroup(const PvlGroup &group);
327 void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude,
328 double &maxLongitude);
329
330
331 private:
332 void applyVirtualBandsToLabel();
333 void cleanUp(bool remove);
334
335 void construct();
336 QFile *dataFile() const;
337 FileName realDataFileName() const;
338
339 void initialize();
340 void initCoreFromLabel(const Pvl &label);
341 void initLabelFromFile(FileName labelFileName, bool readWrite);
342 void openCheck();
343 Pvl realDataFileLabel() const;
344 void reformatOldIsisLabel(const QString &oldCube);
345 void writeLabels();
346
347 private:
356 QFile *m_labelFile;
362 QFile *m_dataFile;
363
368 CubeIoHandler *m_ioHandler;
369
375 ByteOrder m_byteOrder;
376
382 Format m_format;
383
389 PixelType m_pixelType;
390
392 QMutex *m_mutex;
393
395 Camera *m_camera;
396
398 Projection *m_projection;
399
401 FileName *m_labelFileName;
402
404 FileName *m_dataFileName;
405
411 FileName *m_tempCube;
412
414 FileName *m_formatTemplateFile;
415
417 bool m_attached;
418
424 bool m_storesDnData;
425
427 Pvl *m_label;
428
430 int m_labelBytes;
431
433 int m_samples;
434
436 int m_lines;
437
439 int m_bands;
440
445 double m_base;
446
451 double m_multiplier;
452
454 QList<int> *m_virtualBandList;
455 };
456}
457
460
461#endif
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *'s to be stored in a QVariant.
Definition Blob.h:51
Buffer for reading and writing cube data.
Definition Buffer.h:53
Definition Camera.h:236
Manipulate and parse attributes of output cube filenames.
Definition CubeAttribute.h:473
This is the parent of the caching algorithms.
Definition CubeCachingAlgorithm.h:31
IO Handler for Isis Cubes.
Definition Cube.h:168
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
Definition Cube.cpp:1955
void clearIoCache()
This will clear excess RAM used for quicker IO in the cube.
Definition Cube.cpp:1971
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
Definition Cube.cpp:2076
ImagePolygon readFootprint() const
Read the footprint polygon for the Cube.
Definition Cube.cpp:879
Cube()
Constructs a Cube object.
Definition Cube.cpp:50
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Definition Cube.cpp:1317
void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude, double &maxLongitude)
Returns the latitude and longitude range for the Cube.
Definition Cube.cpp:2543
void deleteGroup(const QString &group)
Deletes a group from the cube labels.
Definition Cube.cpp:2010
void attachLineScanTableFromIsd(nlohmann::json isd)
Definition Cube.cpp:1541
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band,...
Definition Cube.cpp:1279
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.
Definition Cube.cpp:1988
Format format() const
Definition Cube.cpp:1608
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
Definition Cube.cpp:1379
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...
Definition Cube.cpp:1632
int lineCount() const
Definition Cube.cpp:1767
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
Definition Cube.cpp:1781
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files.
Definition Cube.cpp:1291
CubeStretch readCubeStretch(QString name="CubeStretch", const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
Read a Stretch from a cube.
Definition Cube.cpp:925
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...
Definition Cube.cpp:1863
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Definition Cube.cpp:1230
Camera * camera()
Return a camera associated with the cube.
Definition Cube.cpp:1464
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
Definition Cube.cpp:1568
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
Definition Cube.cpp:2024
int sampleCount() const
Definition Cube.cpp:1840
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
Definition Cube.cpp:2089
bool isOpen() const
Test if a cube file has been opened/created.
Definition Cube.cpp:189
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...
Definition Cube.cpp:1164
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true.
Definition Cube.cpp:215
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
Definition Cube.cpp:1440
void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access)
Initialize Cube data from a PVL label and JSON ISD.
Definition Cube.cpp:99
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
Definition Cube.cpp:1181
void attachSpiceFromIsd(nlohmann::json Isd)
Definition Cube.cpp:1472
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
Definition Cube.cpp:278
void create(const QString &cfile)
This method will create an isis cube for writing.
Definition Cube.cpp:416
bool hasBlob(const QString &name, const QString &type)
Check to see if the cube contains a BLOB.
Definition Cube.cpp:2052
ByteOrder byteOrder() const
Returns the byte order/endian-ness of the cube file.
Definition Cube.cpp:1452
bool labelsAttached() const
Test if labels are attached.
Definition Cube.cpp:250
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
Definition Cube.cpp:629
PixelType pixelType() const
Definition Cube.cpp:1791
bool storesDnData() const
This method returns a boolean value.
Definition Cube.cpp:1937
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
Definition Cube.cpp:1334
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Definition Cube.cpp:820
bool isProjected() const
Returns true if the labels of the cube appear to have a valid mapping group.
Definition Cube.cpp:204
OriginalLabel readOriginalLabel(const QString &name="IsisCube") const
Read the original PDS3 label from a cube.
Definition Cube.cpp:902
Format
These are the possible storage formats of ISIS cubes.
Definition Cube.h:179
@ Tile
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
Definition Cube.h:233
@ Bsq
Cubes are stored in band-sequential format, that is the order of the pixels in the file (on disk) is:
Definition Cube.h:200
virtual int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Definition Cube.cpp:1806
Table readTable(const QString &name)
Read a Table from the cube.
Definition Cube.cpp:965
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
Definition Cube.cpp:2037
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
Definition Cube.cpp:1304
OriginalXmlLabel readOriginalXmlLabel() const
Read the original PDS4 label from a cube.
Definition Cube.cpp:944
virtual QString fileName() const
Returns the opened cube's filename.
Definition Cube.cpp:1596
void fromLabel(const FileName &fileName, Pvl &label, QString access)
Initialize Cube data from a PVL label.
Definition Cube.cpp:76
virtual ~Cube()
Destroys the Cube object.
Definition Cube.cpp:166
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
Definition Cube.cpp:984
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
Definition Cube.cpp:237
void setExternalDnData(FileName cubeFileWithDnData)
Used to set external dn data to cube.
Definition Cube.cpp:1247
void close(bool remove=false)
Closes the cube and updates the labels.
Definition Cube.cpp:262
History readHistory(const QString &name="IsisCube") const
Read the History from the Cube.
Definition Cube.cpp:860
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
Definition Cube.cpp:1746
Projection * projection()
Definition Cube.cpp:1827
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Definition Cube.cpp:1423
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1734
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
Definition Cube.cpp:787
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
Definition Cube.cpp:1215
Handles converting buffers to and from disk.
Definition CubeIoHandler.h:109
Stores stretch information for a cube.
Definition CubeStretch.h:27
File name manipulation and expansion.
Definition FileName.h:100
Container of a cube histogram.
Definition Histogram.h:74
Definition History.h:38
Create cube polygons, read/write polygons to blobs.
Definition ImagePolygon.h:153
Read and store original labels.
Definition OriginalLabel.h:35
Read and store original Xml labels.
Definition OriginalXmlLabel.h:32
Base class for Map Projections.
Definition Projection.h:155
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:93
Class for storing Table blobs information.
Definition Table.h:61
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
ByteOrder
Tests the current architecture for byte order.
Definition Endian.h:42
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
PixelType
Enumerations for Isis Pixel Types.
Definition PixelType.h:27