Isis 3.0
Back | Home
Cube.h
Go to the documentation of this file.
1 #ifndef Cube_h
2 #define Cube_h
3 
26 #include <vector>
27 
28 // This is needed for the QVariant macro
29 #include <QMetaType>
30 
31 #include "Endian.h"
32 #include "PixelType.h"
33 
34 class QFile;
35 class QMutex;
36 class QString;
37 
38 namespace Isis {
39  class Blob;
40  class Buffer;
41  class Camera;
42  class CubeAttributeOutput;
43  class CubeCachingAlgorithm;
44  class CubeIoHandler;
45  class FileName;
46  class Projection;
47  class Pvl;
48  class PvlGroup;
49  class Statistics;
50  class Histogram;
51 
158  class Cube {
159  public:
160  Cube();
161  Cube(const FileName &fileName, QString access = "r");
162  virtual ~Cube();
163 
168  enum Format {
223  };
224 
225  bool isOpen() const;
226  bool isProjected() const;
227  bool isReadOnly() const;
228  bool isReadWrite() const;
229  bool labelsAttached() const;
230 
231  void close(bool remove = false);
232  Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
233  void create(const QString &cfile);
234  void create(const QString &cfile, const CubeAttributeOutput &att);
235  void open(const QString &cfile, QString access = "r");
236  void reopen(QString access = "r");
237 
238  void read(Blob &blob) const;
239  void read(Buffer &rbuf) const;
240  void write(Blob &blob);
241  void write(Buffer &wbuf);
242 
243  void setBaseMultiplier(double base, double mult);
244  void setMinMax(double min, double max);
246  void setDimensions(int ns, int nl, int nb);
247  void setExternalDnData(FileName cubeFileWithDnData);
248  void setFormat(Format format);
249  void setLabelsAttached(bool attached);
250  void setLabelSize(int labelBytes);
252  void setVirtualBands(const QList<QString> &vbands);
253  void setVirtualBands(const std::vector<QString> &vbands);
254 
255  void relocateDnData(FileName dnDataFile);
256 // static void relocateDnData(FileName externalLabelFile, FileName dnDataFile);
257 
258  int bandCount() const;
259  double base() const;
260  ByteOrder byteOrder() const;
261  Camera *camera();
263  QString fileName() const;
264  Format format() const;
265  Histogram *histogram(const int &band = 1,
266  QString msg = "Gathering histogram");
267  Histogram *histogram(const int &band, const double &validMin,
268  const double &validMax,
269  QString msg = "Gathering histogram");
270  Pvl *label() const;
271  int labelSize(bool actual = false) const;
272  int lineCount() const;
273  double multiplier() const;
274  PixelType pixelType() const;
275  int physicalBand(const int &virtualBand) const;
277  int sampleCount() const;
278  Statistics *statistics(const int &band = 1,
279  QString msg = "Gathering statistics");
280  Statistics *statistics(const int &band, const double &validMin,
281  const double &validMax,
282  QString msg = "Gathering statistics");
283  bool storesDnData() const;
284 
286  void clearIoCache();
287  bool deleteBlob(QString BlobType, QString BlobName);
288  void deleteGroup(const QString &group);
289  PvlGroup &group(const QString &group) const;
290  bool hasGroup(const QString &group) const;
291  bool hasTable(const QString &name);
292  void putGroup(const PvlGroup &group);
293 
294  private:
295  void applyVirtualBandsToLabel();
296  void cleanUp(bool remove);
297 
298  void construct();
299  QFile *dataFile() const;
300  FileName realDataFileName() const;
301 
302  void initialize();
303  void initCoreFromLabel(const Pvl &label);
304  void initLabelFromFile(FileName labelFileName, bool readWrite);
305  void openCheck();
306  Pvl realDataFileLabel() const;
307  void reformatOldIsisLabel(const QString &oldCube);
308  void writeLabels();
309 
310  private:
319  QFile *m_labelFile;
325  QFile *m_dataFile;
326 
331  CubeIoHandler *m_ioHandler;
332 
338  ByteOrder m_byteOrder;
339 
345  Format m_format;
346 
352  PixelType m_pixelType;
353 
355  QMutex *m_mutex;
356 
358  Camera *m_camera;
359 
361  Projection *m_projection;
362 
364  FileName *m_labelFileName;
365 
367  FileName *m_dataFileName;
368 
374  FileName *m_tempCube;
375 
377  FileName *m_formatTemplateFile;
378 
380  bool m_attached;
381 
387  bool m_storesDnData;
388 
390  Pvl *m_label;
391 
393  int m_labelBytes;
394 
396  int m_samples;
397 
399  int m_lines;
400 
402  int m_bands;
403 
408  double m_base;
409 
414  double m_multiplier;
415 
417  QList<int> *m_virtualBandList;
418  };
419 }
420 
423 
424 #endif
425 
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:1427
Buffer for reading and writing cube data.
Definition: Buffer.h:68
bool deleteBlob(QString BlobType, QString BlobName)
This method will delete a blob label object from the cube as specified by the Blob type and name...
Definition: Cube.cpp:1547
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:1196
bool labelsAttached() const
Test if labels are attached.
Definition: Cube.cpp:163
PixelType pixelType() const
Definition: Cube.cpp:1355
File name manipulation and expansion.
Definition: FileName.h:111
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:1132
Format format() const
Definition: Cube.cpp:1172
virtual ~Cube()
Destroys the Cube object.
Definition: Cube.cpp:75
Camera * camera()
Return a camera associated with the cube.
Definition: Cube.cpp:1118
bool isOpen() const
Test if a cube file has been opened/created.
Definition: Cube.cpp:98
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
Definition: Cube.cpp:1345
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1298
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band...
Definition: Cube.cpp:938
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:150
ByteOrder
Tests the current architecture for byte order.
Definition: Endian.h:59
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files...
Definition: Cube.cpp:950
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *&#39;s to be stored in a QVariant.
Projection * projection()
Definition: Cube.cpp:1391
void read(Blob &blob) const
This method will read data from the specified Blob object.
Definition: Cube.cpp:686
ByteOrder byteOrder() const
Returns the byte order/endian-ness of the cube file.
Definition: Cube.cpp:1106
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Definition: Cube.cpp:894
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
Handles converting buffers to and from disk.
Definition: CubeIoHandler.h:119
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
Definition: Cube.cpp:653
Definition: Camera.h:240
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:109
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
Definition: Cube.cpp:1583
Base class for Map Projections.
Definition: Projection.h:169
int sampleCount() const
Definition: Cube.cpp:1404
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
Definition: Cube.h:222
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Definition: Cube.cpp:976
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
Definition: Cube.cpp:1610
Container of a cube histogram.
Definition: Histogram.h:78
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
Definition: Cube.cpp:1310
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
Definition: Blob.h:64
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
Definition: Cube.cpp:993
Manipulate and parse attributes of output cube filenames.
Definition: CubeAttribute.h:485
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:828
int bandCount() const
Returns the number of virtual bands for the cube.
Definition: Cube.cpp:1077
void close(bool remove=false)
Closes the cube and updates the labels.
Definition: Cube.cpp:175
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Definition: Cube.cpp:509
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Definition: Cube.cpp:183
Cube()
Constructs a Cube object.
Definition: Cube.cpp:56
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
Definition: Cube.cpp:1514
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
Definition: Cube.cpp:1094
Container for cube-like labels.
Definition: Pvl.h:135
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true...
Definition: Cube.cpp:128
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:879
Cubes are stored in band-sequential format, that is the order of the pixels in the file (on disk) is:...
Definition: Cube.h:189
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:845
bool storesDnData() const
Definition: Cube.cpp:1496
void clearIoCache()
This will clear excess RAM used for quicker IO in the cube.
Definition: Cube.cpp:1530
bool isProjected() const
Returns true if the labels of the cube appear to have a valid mapping group.
Definition: Cube.cpp:117
void write(Blob &blob)
This method will write a blob of data (e.g.
Definition: Cube.cpp:725
void relocateDnData(FileName dnDataFile)
Definition: Cube.cpp:1033
void setExternalDnData(FileName cubeFileWithDnData)
Definition: Cube.cpp:906
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
Definition: Cube.cpp:1635
QString fileName() const
Returns the opened cube&#39;s filename.
Definition: Cube.cpp:1160
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
Definition: Cube.cpp:1596
void deleteGroup(const QString &group)
Deletes a group from the cube labels.
Definition: Cube.cpp:1569
int lineCount() const
Definition: Cube.cpp:1331
void create(const QString &cfile)
This method will create an isis cube for writing.
Definition: Cube.cpp:321
Format
These are the possible storage formats of Isis3 cubes.
Definition: Cube.h:168
This is the parent of the caching algorithms.
Definition: CubeCachingAlgorithm.h:47
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:963
int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Definition: Cube.cpp:1370
IO Handler for Isis Cubes.
Definition: Cube.h:158

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:16:58