Workspace 6.21.5
Public Slots | Public Member Functions | Properties | List of all members
ConversionSpinBox Class Reference

Spin box designed for easy unit conversions in the GUI. More...

#include <ApplicationSupport/Widgets/conversionspinbox.h>

Inherits QDoubleSpinBox.

Public Slots

void toggleSecondaryMode (bool toggle)
 

Public Member Functions

 ConversionSpinBox (QWidget *parent=nullptr)
 
double getConversionFactor () const
 
double getPrimaryValue () const
 
int getSecondaryDecimals () const
 
double getSecondaryMaximum () const
 
double getSecondaryMinimum () const
 
QString getSecondaryPrefix () const
 
double getSecondarySingleStep () const
 
QString getSecondarySuffix () const
 
void setConversionFactor (double factor)
 
void setSecondaryDecimals (int decimals)
 
void setSecondaryMaximum (double maximum)
 
void setSecondaryMinimum (double minimum)
 
void setSecondaryPrefix (const QString &prefix)
 
void setSecondarySingleStep (double step)
 
void setSecondarySuffix (const QString &suffix)
 
void setValueAsPrimary (double value)
 

Properties

double conversionFactor
 
int secondaryDecimals
 
double secondaryMaximum
 
double secondaryMinimum
 
QString secondaryPrefix
 
double secondarySingleStep
 
QString secondarySuffix
 

Detailed Description

This spin box is intended to allow an easy way to perform unit conversions (or unit scaling) at the GUI layer. The unit conversion does not affect the workflow that interfaces with the spin box. Any workflow attached to this spin box always interfaces by the 'primary' unit type. This functionality is achieved by exposing a secondary set of properties with a conversion factor to perform conversions from/to the primary properties. Slots are exposed to activate the conversion operation.

As an example, a workflow can internally perform calculations based on metric units while a user can blissfully enter/view inputs/outputs in Imperial units.

Constructor & Destructor Documentation

◆ ConversionSpinBox()

ConversionSpinBox ( QWidget *  parent = nullptr)

Member Function Documentation

◆ getConversionFactor()

double getConversionFactor ( ) const

◆ getPrimaryValue()

double getPrimaryValue ( ) const

◆ getSecondaryDecimals()

int getSecondaryDecimals ( ) const

◆ getSecondaryMaximum()

double getSecondaryMaximum ( ) const

◆ getSecondaryMinimum()

double getSecondaryMinimum ( ) const

◆ getSecondaryPrefix()

QString getSecondaryPrefix ( ) const

◆ getSecondarySingleStep()

double getSecondarySingleStep ( ) const

◆ getSecondarySuffix()

QString getSecondarySuffix ( ) const

◆ setConversionFactor()

void setConversionFactor ( double  factor)

◆ setSecondaryDecimals()

void setSecondaryDecimals ( int  decimals)

◆ setSecondaryMaximum()

void setSecondaryMaximum ( double  maximum)

◆ setSecondaryMinimum()

void setSecondaryMinimum ( double  minimum)

◆ setSecondaryPrefix()

void setSecondaryPrefix ( const QString &  prefix)

◆ setSecondarySingleStep()

void setSecondarySingleStep ( double  step)

◆ setSecondarySuffix()

void setSecondarySuffix ( const QString &  suffix)

◆ setValueAsPrimary()

void setValueAsPrimary ( double  value)
Parameters
valueInput value is expected to be in primary units.

◆ toggleSecondaryMode

void toggleSecondaryMode ( bool  toggle)
slot

Slot to toggle between the widget's primary and secondary properties. The current value is converted as part of the transition.

Property Documentation

◆ conversionFactor

double conversionFactor
readwrite

◆ secondaryDecimals

int secondaryDecimals
readwrite

◆ secondaryMaximum

double secondaryMaximum
readwrite

◆ secondaryMinimum

double secondaryMinimum
readwrite

◆ secondaryPrefix

QString secondaryPrefix
readwrite

◆ secondarySingleStep

double secondarySingleStep
readwrite

◆ secondarySuffix

QString secondarySuffix
readwrite