USGS

Isis 3.0 Object Programmers' Reference

Home

ExportDescription.cpp

00001 #include "ExportDescription.h"
00002 
00003 #include <float.h>
00004 
00005 #include <QList>
00006 
00007 #include "IString.h"
00008 
00009 namespace Isis {
00013   ExportDescription::ExportDescription() {
00014     m_channels = NULL;
00015     m_channels = new QList<ChannelDescription *>;
00016 
00017     m_type = Isis::None;
00018     m_outputMin = 0.0;
00019     m_outputMax = 255.0;
00020     m_outputNull = 0.0;
00021   }
00022 
00023 
00027   ExportDescription::~ExportDescription() {
00028     for (int i = 0; i < m_channels->size(); i++) delete (*m_channels)[i];
00029     delete m_channels;
00030     m_channels = NULL;
00031   }
00032 
00033 
00040   void ExportDescription::setPixelType(PixelType type) {
00041     m_type = type;
00042     switch (type) {
00043       case UnsignedByte:
00044         m_outputMin = 1.0;
00045         m_outputMax = 255.0;
00046         break;
00047       case SignedWord:
00048         m_outputMin = -32752.0;
00049         m_outputMax = 32767.0;
00050         m_outputNull = -32768.0;
00051         break;
00052       case UnsignedWord:
00053         m_outputMin = 3.0;
00054         m_outputMax = 65522.0;
00055         break;
00056       default:
00057         throw IException(IException::Programmer,
00058             "Invalid export pixel type [" + toString(type) + "]",
00059             _FILEINFO_);
00060     }
00061   }
00062 
00063 
00069   PixelType ExportDescription::getPixelType() const {
00070     return m_type;
00071   }
00072 
00073 
00079   double ExportDescription::getOutputMinimum() const {
00080     return m_outputMin;
00081   }
00082 
00083 
00089   double ExportDescription::getOutputMaximum() const {
00090     return m_outputMax;
00091   }
00092 
00093 
00100   double ExportDescription::getOutputNull() const {
00101     return m_outputNull;
00102   }
00103 
00104 
00114   int ExportDescription::addChannel(FileName filename,
00115       CubeAttributeInput &att) {
00116 
00117     m_channels->append(new ChannelDescription(filename, att));
00118     return m_channels->size() - 1;
00119   }
00120 
00121 
00133   int ExportDescription::addChannel(
00134       FileName filename, CubeAttributeInput &att, double min, double max) {
00135 
00136     ChannelDescription *desc = new ChannelDescription(filename, att);
00137     desc->setInputRange(min, max);
00138     m_channels->append(desc);
00139     return m_channels->size() - 1;
00140   }
00141 
00142 
00150   const ExportDescription::ChannelDescription &
00151       ExportDescription::getChannel(int i) const {
00152 
00153     return *(*m_channels)[i];
00154   }
00155 
00156 
00162   int ExportDescription::channelCount() const {
00163     return m_channels->size();
00164   }
00165 
00166 
00173   ExportDescription::ChannelDescription::ChannelDescription(
00174       FileName &filename, CubeAttributeInput &att) {
00175 
00176     m_filename = filename;
00177     m_att = att;
00178 
00179     m_customRange = false;
00180     m_inputMin = DBL_MIN;
00181     m_inputMax = DBL_MAX;
00182   }
00183 
00184 
00190   FileName ExportDescription::ChannelDescription::filename() const {
00191     return m_filename;
00192   }
00193 
00194 
00200   CubeAttributeInput ExportDescription::ChannelDescription::attributes() const {
00201     return m_att;
00202   }
00203 
00204 
00213   void ExportDescription::ChannelDescription::setInputRange(
00214       double min, double max) {
00215 
00216     m_inputMin = min;
00217     m_inputMax = max;
00218     m_customRange = true;
00219   }
00220 
00221 
00228   double ExportDescription::ChannelDescription::getInputMinimum() const {
00229     return m_inputMin;
00230   }
00231 
00232 
00239   double ExportDescription::ChannelDescription::getInputMaximum() const {
00240     return m_inputMax;
00241   }
00242 
00243 
00250   bool ExportDescription::ChannelDescription::hasCustomRange() const {
00251     return m_customRange;
00252   }
00253 };
00254