3Depict
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Typedefs | Enumerations | Functions
basics.h File Reference
#include "mathfuncs.h"
#include "common/assertion.h"
#include <vector>
#include <sstream>
#include <list>
#include <fstream>
#include <algorithm>
Include dependency graph for basics.h:
This graph shows which files directly or indirectly include this file:

Classes

class  UniqueIDHandler
 A class to manage "tear-off" ID values, to allow for indexing without knowing position. More...
 
class  ComparePairFirst
 
class  ComparePairSecond
 
class  ComparePairFirstReverse
 
class  BoundCube
 A helper class to define a bounding cube. More...
 
struct  RGBf
 Data holder for colour as float. More...
 
class  ColourRGBA
 
class  ColourRGBAf
 

Macros

#define THREEDEP_ARRAYSIZE(f)   (sizeof (f) / sizeof(*f))
 Basic objects header file. More...
 
#define ATOMIC_BOOL   bool
 

Typedefs

typedef struct RGBf RGBf
 Data holder for colour as float. More...
 

Enumerations

enum  { ERR_FILE_OPEN =1, ERR_FILE_FORMAT, ERR_FILE_NUM_FIELDS, ERR_FILE_ENUM_END }
 Text file loader errors. More...
 

Functions

void pushLocale (const char *newLocale, int type)
 
void popLocale ()
 
int fpeek (FILE *stream)
 
template<class T >
bool rangesOverlap (const T &minA, const T &maxA, const T &minB, const T &maxB)
 
template<class T >
bool xorFunc (const T a, const T b)
 
template<class T >
void rotate3 (T &a, T &b, T &c)
 
template<class T >
maxValue (const T *t, size_t n)
 
template<class T >
minValue (const T *t, size_t n)
 
template<class T1 , class T2 >
bool hasFirstInPairVec (const std::vector< std::pair< T1, T2 > > &v, const std::pair< T1, T2 > &r)
 
void tickSpacingsFromInterspace (float start, float end, float interSpacing, std::vector< float > &spacings)
 Convert a normal string to a latex one, using character replacement. More...
 
void tickSpacingsFromFixedNum (float start, float end, unsigned int nTicks, std::vector< float > &spacings)
 
std::string veryFuzzyTimeSince (time_t origTime, time_t newTime)
 Get a "human-like" version of the time elapsed between new and original time period. More...
 
unsigned int loadTextData (const char *cpFilename, std::vector< std::vector< float > > &dataVec, std::vector< std::string > &header, const char *delim)
 A routine for loading numeric data from a text file. Returns 0 on success. More...
 
unsigned int loadTextStringData (const char *cpFilename, std::vector< std::vector< std::string > > &dataVec, const char *delim)
 Load non-numeric data from a text file into ragged array, using specified delimiters. More...
 
template<class T >
bool writeTextFile (const char *cpFilename, const std::vector< std::pair< T, T > > &dataVec, const char delim='\t')
 
void setDefaultFontFile (const std::string &font)
 Return the default font file to use. Must precede (first) call to getDefaultFontFile. More...
 
std::string getDefaultFontFile ()
 Return the default font file to use. More...
 
template<class T1 , class T2 >
bool stream_cast (T1 &result, const T2 &obj)
 Template function to cast and object to another by the stringstream. More...
 
void nullifyMarker (char *buffer, char marker)
 Replace first instance of marker with null terminator. More...
 
unsigned int getBitNum (unsigned int u)
 
bool getFilesize (const char *fname, size_t &size)
 Get total filesize in bytes. More...
 
int getTotalRAM ()
 get total ram in MB More...
 
size_t getAvailRAM ()
 Get available ram in MB. More...
 
bool isNotDirectory (const char *filename)
 Determine if a given path is a not a directory,. More...
 
bool rmFile (const std::string &filename)
 
template<class T >
size_t randomSelect (std::vector< T > &result, const std::vector< T > &source, RandNumGen &rng, size_t num, unsigned int &progress, ATOMIC_BOOL &wantAbort, bool strongRandom=false)
 
template<class T >
size_t randomDigitSelection (std::vector< T > &result, const size_t max, RandNumGen &rng, size_t num, unsigned int &progress, bool strongRandom=false)
 
template<class T >
void vectorMultiErase (std::vector< T > &vec, const std::vector< bool > &wantKill)
 

Macro Definition Documentation

◆ ATOMIC_BOOL

#define ATOMIC_BOOL   bool

◆ THREEDEP_ARRAYSIZE

#define THREEDEP_ARRAYSIZE (   f)    (sizeof (f) / sizeof(*f))

Typedef Documentation

◆ RGBf

typedef struct RGBf RGBf

Data holder for colour as float.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Text file loader errors.

Enumerator
ERR_FILE_OPEN 
ERR_FILE_FORMAT 
ERR_FILE_NUM_FIELDS 
ERR_FILE_ENUM_END 

Function Documentation

◆ fpeek()

int fpeek ( FILE *  stream)
inline

Referenced by RangeFile::detectFileType().

Here is the caller graph for this function:

◆ getAvailRAM()

size_t getAvailRAM ( )

Get available ram in MB.

Referenced by FilterTree::refreshFilterTree(), and UniqueIDHandler::size().

Here is the caller graph for this function:

◆ getBitNum()

unsigned int getBitNum ( unsigned int  u)

References ASSERT.

Referenced by FilterTree::contains(), stream_cast(), and Filter::updateOutputInfo().

Here is the caller graph for this function:

◆ getDefaultFontFile()

std::string getDefaultFontFile ( )

Return the default font file to use.

References defaultFontFile.

Referenced by DrawColourBarOverlay::DrawColourBarOverlay(), DrawPointLegendOverlay::DrawPointLegendOverlay(), BoundingBoxFilter::numBytesForCache(), AnnotateFilter::refresh(), and writeTextFile().

Here is the caller graph for this function:

◆ getFilesize()

bool getFilesize ( const char *  fname,
size_t &  size 
)

◆ getTotalRAM()

int getTotalRAM ( )

get total ram in MB

Referenced by UniqueIDHandler::size().

Here is the caller graph for this function:

◆ hasFirstInPairVec()

template<class T1 , class T2 >
bool hasFirstInPairVec ( const std::vector< std::pair< T1, T2 > > &  v,
const std::pair< T1, T2 > &  r 
)

◆ isNotDirectory()

bool isNotDirectory ( const char *  filename)

Determine if a given path is a not a directory,.

Referenced by RangeFile::detectFileType(), loadTextData(), loadTextStringData(), DataLoadFilter::setProperty(), and UniqueIDHandler::size().

Here is the caller graph for this function:

◆ loadTextData()

unsigned int loadTextData ( const char *  cpFilename,
std::vector< std::vector< float > > &  dataVec,
std::vector< std::string > &  header,
const char *  delim 
)

A routine for loading numeric data from a text file. Returns 0 on success.

References ERR_FILE_FORMAT, ERR_FILE_NUM_FIELDS, ERR_FILE_OPEN, isNotDirectory(), splitStrsRef(), stream_cast(), strhas(), and stripZeroEntries().

Referenced by hasFirstInPairVec(), limitLoadTextFile(), ExternalProgramFilter::refresh(), and DataLoadFilter::refresh().

Here is the caller graph for this function:

◆ loadTextStringData()

unsigned int loadTextStringData ( const char *  cpFilename,
std::vector< std::vector< std::string > > &  dataVec,
const char *  delim 
)

Load non-numeric data from a text file into ragged array, using specified delimiters.

References ERR_FILE_FORMAT, ERR_FILE_OPEN, isNotDirectory(), splitStrsRef(), and stripZeroEntries().

Referenced by StringKeyFrameDialog::getStrings(), and hasFirstInPairVec().

Here is the caller graph for this function:

◆ maxValue()

template<class T >
T maxValue ( const T *  t,
size_t  n 
)

References ASSERT.

Referenced by VoxeliseFilter::getRefreshUseMask().

Here is the caller graph for this function:

◆ minValue()

template<class T >
T minValue ( const T *  t,
size_t  n 
)

References ASSERT.

Referenced by VoxeliseFilter::getRefreshUseMask().

Here is the caller graph for this function:

◆ nullifyMarker()

void nullifyMarker ( char *  buffer,
char  marker 
)

Replace first instance of marker with null terminator.

Referenced by RangeFile::detectFileType(), and stream_cast().

Here is the caller graph for this function:

◆ popLocale()

void popLocale ( )

Referenced by RangeFile::open(), and MathGLPane::saveSVG().

Here is the caller graph for this function:

◆ pushLocale()

void pushLocale ( const char *  newLocale,
int  type 
)

References ASSERT.

Referenced by RangeFile::open(), and MathGLPane::saveSVG().

Here is the caller graph for this function:

◆ randomDigitSelection()

template<class T >
size_t randomDigitSelection ( std::vector< T > &  result,
const size_t  max,
RandNumGen rng,
size_t  num,
unsigned int &  progress,
bool  strongRandom = false 
)

◆ randomSelect()

template<class T >
size_t randomSelect ( std::vector< T > &  result,
const std::vector< T > &  source,
RandNumGen rng,
size_t  num,
unsigned int &  progress,
ATOMIC_BOOL wantAbort,
bool  strongRandom = false 
)

◆ rangesOverlap()

template<class T >
bool rangesOverlap ( const T &  minA,
const T &  maxA,
const T &  minB,
const T &  maxB 
)

References ASSERT.

Referenced by PropertyAnimator::checkSelfConsistent(), and RegionGroup::getOverlaps().

Here is the caller graph for this function:

◆ rmFile()

bool rmFile ( const std::string &  filename)

◆ rotate3()

template<class T >
void rotate3 ( T &  a,
T &  b,
T &  c 
)

Referenced by VoxeliseFilter::getRefreshUseMask().

Here is the caller graph for this function:

◆ setDefaultFontFile()

void setDefaultFontFile ( const std::string &  font)

Return the default font file to use. Must precede (first) call to getDefaultFontFile.

References defaultFontFile.

Referenced by threeDepictApp::OnInit(), and writeTextFile().

Here is the caller graph for this function:

◆ stream_cast()

template<class T1 , class T2 >
bool stream_cast ( T1 &  result,
const T2 &  obj 
)

Template function to cast and object to another by the stringstream.

References getBitNum(), and nullifyMarker().

Referenced by ExportRngDialog::addRangeData(), Filter::applyPropertyNow(), MainWindowFrame::checkReloadAutosave(), choiceString(), choiceStringToVector(), RangeFile::decomposeIonNames(), RangeFile::detectFileType(), digitString(), DrawColourBarOverlay::draw(), filterIsSampling(), filterTreeTests(), getActiveChoice(), Filter::getBaseErrString(), MathGLPane::getErrString(), ExportAnimationDialog::getFilename(), InterpData::getInterpolatedData(), IonClipFilter::getProperties(), IonColourFilter::getProperties(), TransformFilter::getProperties(), BoundingBoxFilter::getProperties(), SpectrumPlotFilter::getProperties(), IonDownsampleFilter::getProperties(), AnnotateFilter::getProperties(), IonInfoFilter::getProperties(), RangeFileFilter::getProperties(), ProfileFilter::getProperties(), VoxeliseFilter::getProperties(), DataLoadFilter::getProperties(), ClusterAnalysisFilter::getProperties(), SpatialAnalysisFilter::getProperties(), CameraLookAt::getProperties(), getPropValueFromEvent(), getRealKeyFrame(), IonDownsampleFilter::getRefreshUseMask(), VoxeliseFilter::getRefreshUseMask(), StringKeyFrameDialog::getStartFrame(), limitLoadTextFile(), loadTapsimBinFile(), loadTextData(), MainWindowFrame::MainWindowFrame(), IonInfoFilter::needsUnrangedData(), MainWindowFrame::OnAutosaveTimer(), ExportPosDialog::OnBtnAddData(), ExportAnimationDialog::OnBtnResolution(), MainWindowFrame::OnClose(), MainWindowFrame::OnFileExportFilterVideo(), MainWindowFrame::OnFileExportVideo(), PrefDialog::OnFilterCellChange(), ExportAnimationDialog::OnFilterGridCellSelected(), ExportAnimationDialog::OnFrameViewSlider(), MainWindowFrame::OnGridCameraPropertyChange(), MainWindowFrame::OnGridFilterPropertyChange(), RangeEditorDialog::OnGridRangesCellChange(), ExportRngDialog::OnListRangeItemActivate(), ResolutionDialog::OnMouseWheelHeight(), ResolutionDialog::OnMouseWheelWidth(), MainWindowFrame::OnStatusBarTimer(), ExportAnimationDialog::OnTextFrame(), ResolutionDialog::OnTextHeight(), ResolutionDialog::OnTextWidth(), ExportPosDialog::OnTreeFiltersSelChanged(), StashDialog::OnTreeSelChange(), MainWindowFrame::OnUpdateTimer(), RangeFile::openGuessFormat(), Point3D::parse(), parseVersion(), parseXMLColour(), ExportAnimationDialog::prepare(), ConfigFile::read(), readOps(), readScalarsXML(), IonColourFilter::readState(), BoundingBoxFilter::readState(), SpectrumPlotFilter::readState(), RangeFileFilter::readState(), ProfileFilter::readState(), VoxeliseFilter::readState(), DataLoadFilter::readState(), CameraLookAt::readState(), readVectorsXML(), AnnotateFilter::refresh(), IonInfoFilter::refresh(), VoxeliseFilter::refresh(), DataLoadFilter::refresh(), ClusterAnalysisFilter::refresh(), MainWindowFrame::restoreConfigDefaults(), AnalysisState::save(), BasicGLPane::saveImageSequence(), FilterTree::saveXML(), FilterTree::serialiseToStringPaths(), ExportAnimationDialog::setDefImSize(), RangeEditorDialog::setPlotWrapper(), IonColourFilter::setProperty(), TransformFilter::setProperty(), SpectrumPlotFilter::setProperty(), BoundingBoxFilter::setProperty(), IonDownsampleFilter::setProperty(), AnnotateFilter::setProperty(), IonInfoFilter::setProperty(), RangeFileFilter::setProperty(), ProfileFilter::setProperty(), VoxeliseFilter::setProperty(), DataLoadFilter::setProperty(), ClusterAnalysisFilter::setProperty(), SpatialAnalysisFilter::setProperty(), CameraLookAt::setProperty(), IonClipFilter::setPropFromBinding(), TransformFilter::setPropFromBinding(), AnnotateFilter::setPropFromBinding(), ProfileFilter::setPropFromBinding(), SpatialAnalysisFilter::setPropFromBinding(), ResolutionDialog::setRes(), StringKeyFrameDialog::StringKeyFrameDialog(), updateCameraPropertyGrid(), updateFilterPropertyGrid(), VisController::updateRawGrid(), validateTextAsStream(), wxErrMsg(), XMLGetAttrib(), XMLGetNextElemAttrib(), XMLHelpGetProp(), and Scene::~Scene().

◆ tickSpacingsFromFixedNum()

void tickSpacingsFromFixedNum ( float  start,
float  end,
unsigned int  nTicks,
std::vector< float > &  spacings 
)

References ASSERT.

Referenced by hasFirstInPairVec(), and AnnotateFilter::refresh().

Here is the caller graph for this function:

◆ tickSpacingsFromInterspace()

void tickSpacingsFromInterspace ( float  start,
float  end,
float  interSpacing,
std::vector< float > &  spacings 
)

Convert a normal string to a latex one, using character replacement.

References ASSERT.

Referenced by hasFirstInPairVec(), and AnnotateFilter::refresh().

Here is the caller graph for this function:

◆ vectorMultiErase()

template<class T >
void vectorMultiErase ( std::vector< T > &  vec,
const std::vector< bool > &  wantKill 
)

◆ veryFuzzyTimeSince()

std::string veryFuzzyTimeSince ( time_t  origTime,
time_t  newTime 
)

Get a "human-like" version of the time elapsed between new and original time period.

References ASSERT, COMPILE_ASSERT, NTRANS, THREEDEP_ARRAYSIZE, and TRANS.

Referenced by MainWindowFrame::checkReloadAutosave(), and hasFirstInPairVec().

Here is the caller graph for this function:

◆ writeTextFile()

template<class T >
bool writeTextFile ( const char *  cpFilename,
const std::vector< std::pair< T, T > > &  dataVec,
const char  delim = '\t' 
)

References getDefaultFontFile(), and setDefaultFontFile().

Referenced by ExternalProgramFilter::refresh().

Here is the caller graph for this function:

◆ xorFunc()

template<class T >
bool xorFunc ( const T  a,
const T  b 
)

Referenced by Plot2DStreamData::getNumBasicObjects(), and SpatialAnalysisFilter::setPropFromBinding().

Here is the caller graph for this function: