3Depict
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | List of all members
RangeFile Class Reference

Data storage and retrieval class for various range files. More...

#include <APTRanges.h>

Public Member Functions

 RangeFile ()
 
const RangeFileoperator= (const RangeFile &other)
 
unsigned int open (const char *rangeFile, unsigned int format=RANGE_FORMAT_ORNL)
 Open a specified range file, returns zero on success, nonzero on failure. More...
 
bool openGuessFormat (const char *rangeFile)
 Open a specified range file - returns true on success. More...
 
void setEnforceConsistent (bool shouldEnforce=true)
 
bool isSelfConsistent () const
 Performs checks for self consistency. More...
 
void printErr (std::ostream &strm) const
 Print the translated error associated with the current range file state. More...
 
std::string getErrString () const
 Retrieve the translated error associated with the current range file state. More...
 
unsigned int getNumRanges () const
 Get the number of unique ranges. More...
 
unsigned int getNumRanges (unsigned int ionID) const
 Get the number of ranges for a given ion ID. More...
 
unsigned int getNumIons () const
 Get the number of unique ions. More...
 
std::pair< float, float > getRange (unsigned int) const
 Retrieve the start and end of a given range as a pair(start,end) More...
 
std::pair< float, float > & getRangeByRef (unsigned int)
 Retrieve the start and end of a given range as a pair(start,end) More...
 
RGBf getColour (unsigned int) const
 Retrieve a given colour from the ion ID. More...
 
void setColour (unsigned int, const RGBf &r)
 Set the colour using the ion ID. More...
 
unsigned int getIonID (float mass) const
 Retrieve the colour from a given ion ID. More...
 
unsigned int getIonID (unsigned int range) const
 Get the ion ID from a given range ID. More...
 
unsigned int getIonID (const char *name, bool useShortName=true) const
 Get the ion ID from its short or long name, returns -1 if name does not exist. Case must match. More...
 
unsigned int getIonID (const std::string &name) const
 
void setIonID (unsigned int range, unsigned int newIonId)
 Set the ion ID for a given range. More...
 
bool isRanged (float mass) const
 returns true if a specified mass is ranged More...
 
bool isRanged (const IonHit &) const
 Returns true if an ion is ranged. More...
 
void range (std::vector< IonHit > &ionHits) const
 Clips out ions that are not inside any range. More...
 
void range (const std::vector< IonHit > &ionsIn, std::vector< IonHit > &ionHits) const
 Clips out ions that are not inside any range, keeping. More...
 
bool range (std::vector< IonHit > &ionHits, std::string shortIonName)
 Clips out ions that dont match the specified ion name. More...
 
void rangeByIon (const std::vector< IonHit > &ions, const std::vector< bool > &selectedIons, std::vector< IonHit > &output) const
 Clip out only a specific subset of ions. More...
 
bool rangeByID (std::vector< IonHit > &ionHits, unsigned int range)
 Clips out ions that dont lie in the specified range number. More...
 
void rangeByRangeID (std::vector< IonHit > &ionHits, unsigned int rangeID)
 
std::string getName (unsigned int ionID, bool shortName=true) const
 Get the short name or long name of a specified ionID. More...
 
std::string getName (const IonHit &ion, bool shortName) const
 
void setIonShortName (unsigned int ionID, const std::string &newName)
 set the short name for a given ion More...
 
void setIonLongName (unsigned int ionID, const std::string &newName)
 Set the long name for a given ion. More...
 
bool isRanged (std::string shortName, bool caseSensitive=true)
 Check to see if an atom is ranged. More...
 
unsigned int write (std::ostream &o, size_t format=RANGE_FORMAT_ORNL) const
 Write the rangefile to the specified output stream (default ORNL format) More...
 
unsigned int write (const char *datafile, size_t format=RANGE_FORMAT_ORNL) const
 WRite the rangefile to a file (ORNL format) More...
 
unsigned int atomicNumberFromRange (unsigned int range) const
 Return the atomic number of the element from either the long or short version of the atomic name. More...
 
unsigned int atomicNumberFromIonID (unsigned int ionID) const
 Get atomic number from ion ID. More...
 
unsigned int getRangeID (float mass) const
 Get a range ID from mass to charge. More...
 
void swap (RangeFile &rng)
 Swap a range file with this one. More...
 
bool moveRange (unsigned int range, bool limit, float newMass)
 Move a range's mass to a new location. More...
 
bool moveBothRanges (unsigned int range, float newLow, float newHigh)
 Move both of a range's masses to a new location. More...
 
unsigned int addRange (float start, float end, unsigned int ionID)
 Add a range to the rangefile. Returns ID number of added range. More...
 
unsigned int addIon (const std::string &shortName, const std::string &longName, const RGBf &ionCol)
 
bool setRangeStart (unsigned int rangeID, float v)
 
bool setRangeEnd (unsigned int rangeID, float v)
 
void eraseRange (size_t rangeId)
 
void eraseIon (size_t ionId)
 
bool isSelfDecomposable () const
 
bool decompose (RangeFile &rng) const
 
bool getDecomposition (std::map< unsigned int, std::vector< std::pair< unsigned int, unsigned int > > > &decomposition) const
 

Static Public Member Functions

static bool extensionIsRange (const char *ext)
 is the extension string the same as that for a range file? I don't advocate this method, but it is convenient in a pinch. More...
 
static void getAllExts (std::vector< std::string > &exts)
 Grab a vector that contains all the extensions that are valid for range files. More...
 
static unsigned int detectFileType (const char *file)
 
static bool decomposeIonNames (const std::string &name, std::vector< std::pair< std::string, size_t > > &fragments)
 

Detailed Description

Data storage and retrieval class for various range files.

Constructor & Destructor Documentation

◆ RangeFile()

RangeFile::RangeFile ( )

Member Function Documentation

◆ addIon()

unsigned int RangeFile::addIon ( const std::string &  shortName,
const std::string &  longName,
const RGBf ionCol 
)

◆ addRange()

unsigned int RangeFile::addRange ( float  start,
float  end,
unsigned int  ionID 
)

Add a range to the rangefile. Returns ID number of added range.

If enforceConsistency is true, this will disallow addition of ranges that

References ASSERT, and isSelfConsistent().

Referenced by PendingRange::commit(), computeMatrixEntries(), getIonID(), VoxeliseFilter::getRefreshUseMask(), setGridABCoords(), ProfileFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), and RangeFileFilter::writePackageState().

Here is the caller graph for this function:

◆ atomicNumberFromIonID()

unsigned int RangeFile::atomicNumberFromIonID ( unsigned int  ionID) const

Get atomic number from ion ID.

Referenced by getIonID().

Here is the caller graph for this function:

◆ atomicNumberFromRange()

unsigned int RangeFile::atomicNumberFromRange ( unsigned int  range) const

Return the atomic number of the element from either the long or short version of the atomic name.

Referenced by getIonID().

Here is the caller graph for this function:

◆ decompose()

bool RangeFile::decompose ( RangeFile rng) const

References addIon(), ASSERT, RGBf::blue, decomposeIonNames(), getIonID(), RGBf::green, isSelfDecomposable(), and RGBf::red.

Referenced by getIonID().

Here is the caller graph for this function:

◆ decomposeIonNames()

bool RangeFile::decomposeIonNames ( const std::string &  name,
std::vector< std::pair< std::string, size_t > > &  fragments 
)
static

◆ detectFileType()

unsigned int RangeFile::detectFileType ( const char *  file)
static

◆ eraseIon()

void RangeFile::eraseIon ( size_t  ionId)

References ASSERT, and vectorMultiErase().

Referenced by getIonID(), and RangeEditorDialog::OnBtnRangeIonRemove().

Here is the caller graph for this function:

◆ eraseRange()

void RangeFile::eraseRange ( size_t  rangeId)

References ASSERT.

Referenced by getIonID(), and RangeEditorDialog::OnBtnRangeIonRemove().

Here is the caller graph for this function:

◆ extensionIsRange()

bool RangeFile::extensionIsRange ( const char *  ext)
static

is the extension string the same as that for a range file? I don't advocate this method, but it is convenient in a pinch.

References RANGE_EXTS.

Referenced by MainWindowFrame::OnDropFiles().

Here is the caller graph for this function:

◆ getAllExts()

void RangeFile::getAllExts ( std::vector< std::string > &  exts)
static

Grab a vector that contains all the extensions that are valid for range files.

References ASSERT, RANGE_EXTS, and THREEDEP_ARRAYSIZE.

◆ getColour()

RGBf RangeFile::getColour ( unsigned int  ui) const

◆ getDecomposition()

bool RangeFile::getDecomposition ( std::map< unsigned int, std::vector< std::pair< unsigned int, unsigned int > > > &  decomposition) const

References decomposeIonNames(), and getIonID().

Referenced by getIonID().

Here is the caller graph for this function:

◆ getErrString()

std::string RangeFile::getErrString ( ) const

Retrieve the translated error associated with the current range file state.

References ASSERT, COMPILE_ASSERT, RANGE_ERR_ENUM_END, rangeErrStrings, THREEDEP_ARRAYSIZE, and TRANS.

Referenced by setEnforceConsistent().

Here is the caller graph for this function:

◆ getIonID() [1/4]

unsigned int RangeFile::getIonID ( float  mass) const

◆ getIonID() [2/4]

unsigned int RangeFile::getIonID ( unsigned int  range) const

Get the ion ID from a given range ID.

No validation checks are performed outside debug mode. Ion range must exist

References ASSERT, and range().

◆ getIonID() [3/4]

unsigned int RangeFile::getIonID ( const char *  name,
bool  useShortName = true 
) const

Get the ion ID from its short or long name, returns -1 if name does not exist. Case must match.

◆ getIonID() [4/4]

unsigned int RangeFile::getIonID ( const std::string &  name) const
inline

◆ getName() [1/2]

std::string RangeFile::getName ( unsigned int  ionID,
bool  shortName = true 
) const

◆ getName() [2/2]

std::string RangeFile::getName ( const IonHit ion,
bool  shortName 
) const

◆ getNumIons()

unsigned int RangeFile::getNumIons ( ) const

◆ getNumRanges() [1/2]

unsigned int RangeFile::getNumRanges ( ) const

◆ getNumRanges() [2/2]

unsigned int RangeFile::getNumRanges ( unsigned int  ionID) const

Get the number of ranges for a given ion ID.

References getIonID().

◆ getRange()

pair< float, float > RangeFile::getRange ( unsigned int  ui) const

◆ getRangeByRef()

pair< float, float > & RangeFile::getRangeByRef ( unsigned int  ui)

Retrieve the start and end of a given range as a pair(start,end)

Referenced by setEnforceConsistent(), and PlotRegion::updateParent().

Here is the caller graph for this function:

◆ getRangeID()

unsigned int RangeFile::getRangeID ( float  mass) const

Get a range ID from mass to charge.

Referenced by getIonID(), ProfileFilter::ProfileFilter(), and RangeFileFilter::refresh().

Here is the caller graph for this function:

◆ isRanged() [1/3]

bool RangeFile::isRanged ( float  mass) const

returns true if a specified mass is ranged

Referenced by getIonID(), getName(), isRanged(), range(), and RangeFileFilter::writePackageState().

Here is the caller graph for this function:

◆ isRanged() [2/3]

bool RangeFile::isRanged ( const IonHit ion) const

Returns true if an ion is ranged.

References IonHit::getMassToCharge(), and isRanged().

◆ isRanged() [3/3]

bool RangeFile::isRanged ( std::string  shortName,
bool  caseSensitive = true 
)

Check to see if an atom is ranged.

Returns true if rangefile holds at least one range with shortname corresponding input value. Case sensitivity search is default

◆ isSelfConsistent()

bool RangeFile::isSelfConsistent ( ) const

Performs checks for self consistency.

Referenced by addIon(), addRange(), open(), openGuessFormat(), setEnforceConsistent(), setRangeEnd(), and setRangeStart().

Here is the caller graph for this function:

◆ isSelfDecomposable()

bool RangeFile::isSelfDecomposable ( ) const

References decomposeIonNames(), and getIonID().

Referenced by decompose(), and getIonID().

Here is the caller graph for this function:

◆ moveBothRanges()

bool RangeFile::moveBothRanges ( unsigned int  range,
float  newLow,
float  newHigh 
)

Move both of a range's masses to a new location.

Referenced by getIonID(), and RangeFileFilter::setPropFromRegion().

Here is the caller graph for this function:

◆ moveRange()

bool RangeFile::moveRange ( unsigned int  range,
bool  limit,
float  newMass 
)

Move a range's mass to a new location.

Referenced by getIonID(), RangeFileFilter::setProperty(), and RangeFileFilter::setPropFromRegion().

Here is the caller graph for this function:

◆ open()

unsigned int RangeFile::open ( const char *  rangeFile,
unsigned int  format = RANGE_FORMAT_ORNL 
)

Open a specified range file, returns zero on success, nonzero on failure.

References ASSERT, getFilesize(), isSelfConsistent(), MAX_RANGEFILE_SIZE, popLocale(), pushLocale(), RANGE_ERR_DATA_INCONSISTENT, RANGE_ERR_FILESIZE, RANGE_ERR_FORMAT, RANGE_ERR_OPEN, RANGE_FORMAT_DBL_ORNL, RANGE_FORMAT_ENV, RANGE_FORMAT_ORNL, and RANGE_FORMAT_RRNG.

Referenced by openGuessFormat().

Here is the caller graph for this function:

◆ openGuessFormat()

bool RangeFile::openGuessFormat ( const char *  rangeFile)

◆ operator=()

const RangeFile & RangeFile::operator= ( const RangeFile other)

◆ printErr()

void RangeFile::printErr ( std::ostream &  strm) const

Print the translated error associated with the current range file state.

References ASSERT, RANGE_ERR_ENUM_END, rangeErrStrings, and TRANS.

Referenced by setEnforceConsistent().

Here is the caller graph for this function:

◆ range() [1/3]

void RangeFile::range ( std::vector< IonHit > &  ionHits) const

Clips out ions that are not inside any range.

References isRanged().

Referenced by countBinnedIons(), getIonID(), rangeByID(), setEnforceConsistent(), and setIonID().

Here is the caller graph for this function:

◆ range() [2/3]

void RangeFile::range ( const std::vector< IonHit > &  ionsIn,
std::vector< IonHit > &  ionHits 
) const

Clips out ions that are not inside any range, keeping.

References isRanged().

◆ range() [3/3]

bool RangeFile::range ( std::vector< IonHit > &  ionHits,
std::string  shortIonName 
)

Clips out ions that dont match the specified ion name.

Returns false if the ion name given doesn't match any in the rangefile (case sensitive)

References IonHit::getMassToCharge().

◆ rangeByID()

bool RangeFile::rangeByID ( std::vector< IonHit > &  ionHits,
unsigned int  range 
)

Clips out ions that dont lie in the specified range number.

Returns false if the range does not exist any in the rangefile (case sensitive)

References range().

Referenced by getIonID().

Here is the caller graph for this function:

◆ rangeByIon()

void RangeFile::rangeByIon ( const std::vector< IonHit > &  ions,
const std::vector< bool > &  selectedIons,
std::vector< IonHit > &  output 
) const

Clip out only a specific subset of ions.

References getIonID(), and IonHit::getMassToCharge().

Referenced by getIonID(), and SpatialAnalysisFilter::setPropFromBinding().

Here is the caller graph for this function:

◆ rangeByRangeID()

void RangeFile::rangeByRangeID ( std::vector< IonHit > &  ionHits,
unsigned int  rangeID 
)

References IonHit::getMassToCharge().

Referenced by getIonID().

Here is the caller graph for this function:

◆ setColour()

void RangeFile::setColour ( unsigned int  id,
const RGBf r 
)

Set the colour using the ion ID.

References ASSERT.

Referenced by RangeEditorDialog::OnGridIonsEditorShown(), RangeFileFilter::readState(), setEnforceConsistent(), and RangeFileFilter::setProperty().

Here is the caller graph for this function:

◆ setEnforceConsistent()

void RangeFile::setEnforceConsistent ( bool  shouldEnforce = true)
inline

◆ setIonID()

void RangeFile::setIonID ( unsigned int  range,
unsigned int  newIonId 
)

Set the ion ID for a given range.

References ASSERT, and range().

Referenced by getIonID(), RangeEditorDialog::OnGridRangesCellChange(), and RangeFileFilter::setProperty().

Here is the caller graph for this function:

◆ setIonLongName()

void RangeFile::setIonLongName ( unsigned int  ionID,
const std::string &  newName 
)

Set the long name for a given ion.

Referenced by getIonID(), RangeEditorDialog::OnGridIonsCellChange(), and RangeFileFilter::setProperty().

Here is the caller graph for this function:

◆ setIonShortName()

void RangeFile::setIonShortName ( unsigned int  ionID,
const std::string &  newName 
)

set the short name for a given ion

Referenced by getIonID(), RangeEditorDialog::OnGridIonsCellChange(), and RangeFileFilter::setProperty().

Here is the caller graph for this function:

◆ setRangeEnd()

bool RangeFile::setRangeEnd ( unsigned int  rangeID,
float  v 
)

References ASSERT, and isSelfConsistent().

Referenced by getIonID(), and RangeEditorDialog::OnGridRangesCellChange().

Here is the caller graph for this function:

◆ setRangeStart()

bool RangeFile::setRangeStart ( unsigned int  rangeID,
float  v 
)

References ASSERT, and isSelfConsistent().

Referenced by getIonID(), and RangeEditorDialog::OnGridRangesCellChange().

Here is the caller graph for this function:

◆ swap()

void RangeFile::swap ( RangeFile rng)

Swap a range file with this one.

Referenced by getIonID().

Here is the caller graph for this function:

◆ write() [1/2]

unsigned int RangeFile::write ( std::ostream &  o,
size_t  format = RANGE_FORMAT_ORNL 
) const

Write the rangefile to the specified output stream (default ORNL format)

References ASSERT, elementList, ColourRGBA::fromRGBf(), PROGRAM_NAME, PROGRAM_VERSION, RANGE_FORMAT_ENV, RANGE_FORMAT_ORNL, RANGE_FORMAT_RRNG, and ColourRGBA::rgbString().

Referenced by getIonID(), RangeStreamData::save(), and write().

Here is the caller graph for this function:

◆ write() [2/2]

unsigned int RangeFile::write ( const char *  datafile,
size_t  format = RANGE_FORMAT_ORNL 
) const

WRite the rangefile to a file (ORNL format)

References write().


The documentation for this class was generated from the following files: