PulseView  unreleased development snapshot
A Qt-based sigrok GUI
pv::util Namespace Reference

Typedefs

typedef boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
 Timestamp type providing yoctosecond resolution. More...
 

Enumerations

enum  TimeUnit { TimeUnit::None = 0, TimeUnit::Time = 1, TimeUnit::Samples = 2 }
 
enum  SIPrefix {
  SIPrefix::unspecified = -1, SIPrefix::yocto, SIPrefix::zepto, SIPrefix::atto,
  SIPrefix::femto, SIPrefix::pico, SIPrefix::nano, SIPrefix::micro,
  SIPrefix::milli, SIPrefix::none, SIPrefix::kilo, SIPrefix::mega,
  SIPrefix::giga, SIPrefix::tera, SIPrefix::peta, SIPrefix::exa,
  SIPrefix::zetta, SIPrefix::yotta
}
 

Functions

static QTextStream & operator<< (QTextStream &stream, SIPrefix prefix)
 
int exponent (SIPrefix prefix)
 Returns the exponent that corresponds to a given prefix. More...
 
static SIPrefix successor (SIPrefix prefix)
 
static QTextStream & operator<< (QTextStream &stream, const Timestamp &t)
 
SIPrefix determine_value_prefix (double v)
 
QString format_time_si (const Timestamp &v, SIPrefix prefix, unsigned int precision, QString unit, bool sign)
 
QString format_value_si (double v, SIPrefix prefix, unsigned precision, QString unit, bool sign)
 
QString format_time_si_adjusted (const Timestamp &t, SIPrefix prefix, unsigned precision, QString unit, bool sign)
 
static QString pad_number (unsigned int number, int length)
 
QString format_time_minutes (const Timestamp &t, signed precision, bool sign)
 
vector< string > split_string (string text, string separator)
 
std::streamsize text_width (const QFontMetrics &metric, const QString &string)
 
QString format_time_si (const Timestamp &v, SIPrefix prefix=SIPrefix::unspecified, unsigned precision=0, QString unit="s", bool sign=true)
 

Typedef Documentation

typedef boost::multiprecision::number< boost::multiprecision::cpp_dec_float<24>, boost::multiprecision::et_off> pv::util::Timestamp

Timestamp type providing yoctosecond resolution.

Definition at line 67 of file util.hpp.

Enumeration Type Documentation

enum pv::util::SIPrefix
strong
Enumerator
unspecified 
yocto 
zepto 
atto 
femto 
pico 
nano 
micro 
milli 
none 
kilo 
mega 
giga 
tera 
peta 
exa 
zetta 
yotta 

Definition at line 50 of file util.hpp.

enum pv::util::TimeUnit
strong
Enumerator
None 
Time 
Samples 

Definition at line 44 of file util.hpp.

Function Documentation

SIPrefix pv::util::determine_value_prefix ( double  v)

Chooses a prefix so that the value in front of the decimal point is between 1 and 999.

Definition at line 113 of file util.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int pv::util::exponent ( SIPrefix  prefix)

Returns the exponent that corresponds to a given prefix.

Definition at line 68 of file util.cpp.

Here is the caller graph for this function:

QString pv::util::format_time_minutes ( const Timestamp t,
signed  precision = 0,
bool  sign = true 
)

Formats the given timestamp using "[+-]DD:HH:MM:SS.mmm uuu nnn ppp..." format.

"DD" and "HH" are left out if they would be "00" (but if "DD" is generated, "HH" is also always generated. The "MM:SS" part is always produced, the number of subsecond digits can be influenced using the 'precision' parameter.

Parameters
tThe value to format.
precisionThe number of digits after the decimal separator.
signWhether or not to add a sign also for positive numbers.
Returns
The formatted value.

Definition at line 200 of file util.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString pv::util::format_time_si ( const Timestamp v,
SIPrefix  prefix = SIPrefix::unspecified,
unsigned  precision = 0,
QString  unit = "s",
bool  sign = true 
)

Formats a given timestamp with the specified SI prefix.

If 'prefix' is left 'unspecified', the function chooses a prefix so that the value in front of the decimal point is between 1 and 999.

The default value "s" for the unit argument makes the most sense when formatting time values, but a different value can be given if the function is reused to format a value of another quantity.

Parameters
tThe value to format.
prefixThe SI prefix to use.
precisionThe number of digits after the decimal separator.
unitThe unit of quantity.
signWhether or not to add a sign also for positive numbers.
Returns
The formatted value.
QString pv::util::format_time_si ( const Timestamp v,
SIPrefix  prefix,
unsigned int  precision,
QString  unit,
bool  sign 
)

Definition at line 132 of file util.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString pv::util::format_time_si_adjusted ( const Timestamp t,
SIPrefix  prefix,
unsigned  precision = 0,
QString  unit = "s",
bool  sign = true 
)

Wrapper around 'format_time_si()' that interprets the given 'precision' value as the number of decimal places if the timestamp would be formatted without a SI prefix (using 'SIPrefix::none') and adjusts the precision to match the given 'prefix'

Parameters
tThe value to format.
prefixThe SI prefix to use.
precisionThe number of digits after the decimal separator if the 'prefix' would be 'SIPrefix::none', see above for more information.
unitThe unit of quantity.
signWhether or not to add a sign also for positive numbers.
Returns
The formatted value.

Definition at line 180 of file util.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString pv::util::format_value_si ( double  v,
SIPrefix  prefix = SIPrefix::unspecified,
unsigned  precision = 0,
QString  unit = "",
bool  sign = true 
)

Formats a given value into a representation using SI units.

If 'prefix' is left 'unspecified', the function chooses a prefix so that the value in front of the decimal point is between 1 and 999.

Parameters
valueThe value to format.
prefixThe SI prefix to use.
precisionThe number of digits after the decimal separator.
unitThe unit of quantity.
signWhether or not to add a sign also for positive numbers.
Returns
The formatted value.

Definition at line 153 of file util.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static QTextStream& pv::util::operator<< ( QTextStream &  stream,
SIPrefix  prefix 
)
static

Definition at line 44 of file util.cpp.

static QTextStream& pv::util::operator<< ( QTextStream &  stream,
const Timestamp t 
)
static

Definition at line 81 of file util.cpp.

Here is the call graph for this function:

static QString pv::util::pad_number ( unsigned int  number,
int  length 
)
static

Definition at line 195 of file util.cpp.

Here is the caller graph for this function:

vector< string > pv::util::split_string ( string  text,
string  separator 
)

Split a string into tokens at occurences of the separator.

Parameters
[in]textThe input string to split.
[in]separatorThe delimiter between tokens.
Returns
A vector of broken down tokens.

Definition at line 268 of file util.cpp.

Here is the caller graph for this function:

static SIPrefix pv::util::successor ( SIPrefix  prefix)
static

Definition at line 73 of file util.cpp.

Here is the caller graph for this function:

std::streamsize pv::util::text_width ( const QFontMetrics &  metric,
const QString &  string 
)

Return the width of a string in a given font.

Parameters
[in]metricmetrics of the font
[in]stringthe string whose width should be determined
Returns
width of the string in pixels

Definition at line 290 of file util.cpp.

Here is the caller graph for this function: