3Depict
|
Data storage and retrieval class for various range files. More...
#include <APTRanges.h>
Public Member Functions | |
RangeFile () | |
const RangeFile & | operator= (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) |
Data storage and retrieval class for various range files.
RangeFile::RangeFile | ( | ) |
References COMPILE_ASSERT, RANGE_EXTS, RANGE_FORMAT_END_OF_ENUM, and THREEDEP_ARRAYSIZE.
unsigned int RangeFile::addIon | ( | const std::string & | shortName, |
const std::string & | longName, | ||
const RGBf & | ionCol | ||
) |
References ASSERT, and isSelfConsistent().
Referenced by PendingIon::commit(), computeMatrixEntries(), decompose(), getIonID(), VoxeliseFilter::getRefreshUseMask(), setGridABCoords(), ProfileFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), and RangeFileFilter::writePackageState().
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().
unsigned int RangeFile::atomicNumberFromIonID | ( | unsigned int | ionID | ) | const |
Get atomic number from ion ID.
Referenced by getIonID().
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().
bool RangeFile::decompose | ( | RangeFile & | rng | ) | const |
References addIon(), ASSERT, RGBf::blue, decomposeIonNames(), getIonID(), RGBf::green, isSelfDecomposable(), and RGBf::red.
Referenced by getIonID().
|
static |
References stream_cast(), and vectorMultiErase().
Referenced by decompose(), getDecomposition(), getIonID(), isSelfDecomposable(), matchComposedName(), RangeEditorDialog::OnTextOverlay(), and RangeEditorDialog::OnTextOverlayEnter().
|
static |
References ASSERT, ColourRGBA::b(), RGBf::blue, fpeek(), ColourRGBA::g(), RGBf::green, isNotDirectory(), lowercase(), MAX_LINE_SIZE, nullifyMarker(), ColourRGBA::parse(), ColourRGBA::r(), RANGE_ERR_DATA_FLIPPED, RANGE_ERR_DATA_TOO_MANY_USELESS_RANGES, RANGE_ERR_EMPTY, RANGE_ERR_FORMAT, RANGE_ERR_FORMAT_COLOUR, RANGE_ERR_FORMAT_HEADER, RANGE_ERR_FORMAT_LONGNAME, RANGE_ERR_FORMAT_MASS_PAIR, RANGE_ERR_FORMAT_RANGETABLE, RANGE_ERR_FORMAT_SHORTNAME, RANGE_ERR_FORMAT_TABLE_ENTRY, RANGE_ERR_FORMAT_TABLEHEADER_NUMIONS, RANGE_ERR_FORMAT_TABLESEPARATOR, RANGE_FORMAT_DBL_ORNL, RANGE_FORMAT_END_OF_ENUM, RANGE_FORMAT_ENV, RANGE_FORMAT_ORNL, RANGE_FORMAT_RRNG, RGBf::red, splitStrsRef(), stream_cast(), stripChars(), stripWhite(), stripZeroEntries(), and TRANS.
Referenced by openGuessFormat().
void RangeFile::eraseIon | ( | size_t | ionId | ) |
References ASSERT, and vectorMultiErase().
Referenced by getIonID(), and RangeEditorDialog::OnBtnRangeIonRemove().
void RangeFile::eraseRange | ( | size_t | rangeId | ) |
References ASSERT.
Referenced by getIonID(), and RangeEditorDialog::OnBtnRangeIonRemove().
|
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().
|
static |
Grab a vector that contains all the extensions that are valid for range files.
References ASSERT, RANGE_EXTS, and THREEDEP_ARRAYSIZE.
RGBf RangeFile::getColour | ( | unsigned int | ui | ) | const |
Retrieve a given colour from the ion ID.
References ASSERT.
Referenced by RangeFileFilter::getProperties(), RangeEditorDialog::OnGridIonsEditorShown(), SpectrumPlotFilter::refresh(), RangeFileFilter::refresh(), ProfileFilter::refresh(), setEnforceConsistent(), RangeEditorDialog::setPlotWrapper(), ClusterAnalysisFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), RangeFileFilter::writePackageState(), and RangeFileFilter::writeState().
bool RangeFile::getDecomposition | ( | std::map< unsigned int, std::vector< std::pair< unsigned int, unsigned int > > > & | decomposition | ) | const |
References decomposeIonNames(), and getIonID().
Referenced by getIonID().
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().
unsigned int RangeFile::getIonID | ( | float | mass | ) | const |
Retrieve the colour from a given ion ID.
Get the ion's ID from a specified mass
Returns the ions ID if there exists a range that contains this mass. Otherwise (unsigned int)-1 is returned
Referenced by Filter::buildSplitPoints(), computeMatrixEntries(), countBinnedIons(), decompose(), getDecomposition(), Filter::getIonstreamIonID(), getName(), getNumRanges(), RangeFileFilter::getProperties(), PendingIon::isFinished(), isSelfDecomposable(), makeFrequencyTable(), RangeEditorDialog::OnGridIonsCellChange(), RangeEditorDialog::OnGridRangesCellChange(), ExportRngDialog::OnListRangeItemActivate(), openGuessFormat(), ProfileFilter::ProfileFilter(), rangeByIon(), SpectrumPlotFilter::refresh(), IonDownsampleFilter::refresh(), RangeFileFilter::refresh(), IonInfoFilter::refresh(), VoxeliseFilter::refresh(), setEnforceConsistent(), setGridABCoords(), PendingIon::setLongName(), RangeEditorDialog::setPlotWrapper(), RangeFileFilter::setProperty(), ClusterAnalysisFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), and PendingIon::setShortName().
unsigned int RangeFile::getIonID | ( | unsigned int | range | ) | const |
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.
|
inline |
References addIon(), addRange(), atomicNumberFromIonID(), atomicNumberFromRange(), decompose(), decomposeIonNames(), eraseIon(), eraseRange(), getDecomposition(), getIonID(), getName(), getRangeID(), isRanged(), isSelfDecomposable(), moveBothRanges(), moveRange(), range(), RANGE_FORMAT_ORNL, rangeByID(), rangeByIon(), rangeByRangeID(), setIonID(), setIonLongName(), setIonShortName(), setRangeEnd(), setRangeStart(), swap(), and write().
Referenced by getIonID().
std::string RangeFile::getName | ( | unsigned int | ionID, |
bool | shortName = true |
||
) | const |
Get the short name or long name of a specified ionID.
Pass shortname=false to retireve the long name ionID passed in must exist. No checking outside debug mode
References ASSERT.
Referenced by getIonID(), PendingRange::getIonName(), IonDownsampleFilter::getProperties(), RangeFileFilter::getProperties(), VoxeliseFilter::getProperties(), ClusterAnalysisFilter::initFilter(), SpatialAnalysisFilter::initFilter(), makeFrequencyTable(), ExportRngDialog::OnListRangeItemActivate(), SpectrumPlotFilter::refresh(), IonInfoFilter::refresh(), ProfileFilter::refresh(), RangeEditorDialog::setPlotWrapper(), ClusterAnalysisFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), and RangeFileFilter::writePackageState().
std::string RangeFile::getName | ( | const IonHit & | ion, |
bool | shortName | ||
) | const |
References ASSERT, getIonID(), IonHit::getMassToCharge(), and isRanged().
unsigned int RangeFile::getNumIons | ( | ) | const |
Get the number of unique ions.
Referenced by ExportRngDialog::addRangeData(), Filter::buildSplitPoints(), computeEigenValues(), computeMatrixEntries(), countBinnedIons(), RangeFileFilter::getProperties(), VoxeliseFilter::getRefreshUseMask(), IonDownsampleFilter::initFilter(), RangeFileFilter::initFilter(), VoxeliseFilter::initFilter(), ClusterAnalysisFilter::initFilter(), SpatialAnalysisFilter::initFilter(), makeFrequencyTable(), ExportRngDialog::OnListRangeItemActivate(), RangeFileFilter::readState(), IonDownsampleFilter::refresh(), RangeFileFilter::refresh(), IonInfoFilter::refresh(), ProfileFilter::refresh(), setEnforceConsistent(), RangeEditorDialog::setPlotWrapper(), RangeFileFilter::setProperty(), ClusterAnalysisFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), RangeFileFilter::setRangeData(), and RangeFileFilter::updateRng().
unsigned int RangeFile::getNumRanges | ( | ) | const |
Get the number of unique ranges.
Referenced by ExportRngDialog::addRangeData(), computeMatrixEntries(), RangeFileFilter::getProperties(), VoxeliseFilter::getRefreshUseMask(), RangeFileFilter::initFilter(), ClusterAnalysisFilter::initFilter(), SpatialAnalysisFilter::initFilter(), ExportRngDialog::OnListRangeItemActivate(), openGuessFormat(), RangeFileFilter::readState(), SpectrumPlotFilter::refresh(), RangeFileFilter::refresh(), IonInfoFilter::refresh(), setEnforceConsistent(), RangeEditorDialog::setPlotWrapper(), RangeFileFilter::setProperty(), RangeFileFilter::setPropFromRegion(), RangeFileFilter::setRangeData(), and RangeFileFilter::updateRng().
unsigned int RangeFile::getNumRanges | ( | unsigned int | ionID | ) | const |
Get the number of ranges for a given ion ID.
References getIonID().
pair< float, float > RangeFile::getRange | ( | unsigned int | ui | ) | const |
Retrieve the start and end of a given range as a pair(start,end)
Referenced by RangeFileFilter::getProperties(), RangeEditorDialog::OnGridRangesCellChange(), ExportRngDialog::OnListRangeItemActivate(), openGuessFormat(), SpectrumPlotFilter::refresh(), IonInfoFilter::refresh(), setEnforceConsistent(), RangeEditorDialog::setPlotWrapper(), RangeFileFilter::setProperty(), and RangeFileFilter::setPropFromRegion().
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().
unsigned int RangeFile::getRangeID | ( | float | mass | ) | const |
Get a range ID from mass to charge.
Referenced by getIonID(), ProfileFilter::ProfileFilter(), and RangeFileFilter::refresh().
bool RangeFile::isRanged | ( | float | mass | ) | const |
returns true if a specified mass is ranged
Referenced by getIonID(), getName(), isRanged(), range(), and RangeFileFilter::writePackageState().
bool RangeFile::isRanged | ( | const IonHit & | ion | ) | const |
Returns true if an ion is ranged.
References IonHit::getMassToCharge(), and isRanged().
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
bool RangeFile::isSelfConsistent | ( | ) | const |
Performs checks for self consistency.
Referenced by addIon(), addRange(), open(), openGuessFormat(), setEnforceConsistent(), setRangeEnd(), and setRangeStart().
bool RangeFile::isSelfDecomposable | ( | ) | const |
References decomposeIonNames(), and getIonID().
Referenced by decompose(), and getIonID().
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().
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().
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().
bool RangeFile::openGuessFormat | ( | const char * | rangeFile | ) |
Open a specified range file - returns true on success.
References ASSERT, RGBf::blue, detectFileType(), getFilesize(), getIonID(), getNumRanges(), getRange(), RGBf::green, isSelfConsistent(), matchComposedName(), MAX_LINE_SIZE, MAX_RANGEFILE_SIZE, open(), RANGE_ERR_DATA_NOMAPPED_IONNAME, RANGE_ERR_FILESIZE, RANGE_ERR_FORMAT, RANGE_ERR_FORMAT_TABLESEPARATOR, RANGE_ERR_NONUNIQUE_POLYATOMIC, RANGE_FORMAT_END_OF_ENUM, RGBf::red, and stream_cast().
Referenced by MainWindowFrame::OnDropFiles(), RangeFileFilter::readState(), and RangeFileFilter::updateRng().
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().
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().
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().
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().
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().
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().
void RangeFile::rangeByRangeID | ( | std::vector< IonHit > & | ionHits, |
unsigned int | rangeID | ||
) |
References IonHit::getMassToCharge().
Referenced by getIonID().
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().
|
inline |
References getColour(), getErrString(), getIonID(), getNumIons(), getNumRanges(), getRange(), getRangeByRef(), isSelfConsistent(), printErr(), range(), and setColour().
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().
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().
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().
bool RangeFile::setRangeEnd | ( | unsigned int | rangeID, |
float | v | ||
) |
References ASSERT, and isSelfConsistent().
Referenced by getIonID(), and RangeEditorDialog::OnGridRangesCellChange().
bool RangeFile::setRangeStart | ( | unsigned int | rangeID, |
float | v | ||
) |
References ASSERT, and isSelfConsistent().
Referenced by getIonID(), and RangeEditorDialog::OnGridRangesCellChange().
void RangeFile::swap | ( | RangeFile & | rng | ) |
Swap a range file with this one.
Referenced by getIonID().
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().
unsigned int RangeFile::write | ( | const char * | datafile, |
size_t | format = RANGE_FORMAT_ORNL |
||
) | const |
WRite the rangefile to a file (ORNL format)
References write().