Loading...
Searching...
No Matches
pappso::PrecisionWidget Class Reference

`#include <precisionwidget.h>`

Inheritance diagram for pappso::PrecisionWidget:

## Signals

void | precisionChanged (pappso::PrecisionPtr precision) const

## Public Member Functions

| PrecisionWidget (QWidget *parent=0)
| ~PrecisionWidget ()
void | setPrecision (PrecisionPtr precision)
const PrecisionPtr & | getPrecision () const

## Private Member Functions

Q_SLOT void | setCurrentIndex (int)
Q_SLOT void | setPpmValueChanged (double)
Q_SLOT void | setResValueChanged (double)
Q_SLOT void | setDaltonValueChanged (double)

## Private Attributes

QComboBox * | mp_unitComboBox
QDoubleSpinBox * | mp_ppmValueSpinBox
QDoubleSpinBox * | mp_resValueSpinBox
QDoubleSpinBox * | mp_daltonValueSpinBox
PrecisionPtr | mp_precisionDalton
PrecisionPtr | mp_precisionPpm
PrecisionPtr | mp_precisionRes
int | m_oldIndex

## Detailed Description

Definition at line 45 of file precisionwidget.h.

## Constructor & Destructor Documentation

## PrecisionWidget()

pappso::PrecisionWidget::PrecisionWidget | ( | QWidget * | parent = 0 | ) |

Definition at line 41 of file precisionwidget.cpp.

: QWidget(parent)
{
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__
//<< "PrecisionWidget::PrecisionWidget begin";
setLayout(new QHBoxLayout(this));
this->layout()->setContentsMargins(0, 0, 0, 0);
// Each precision type has its own double spin box.
mp_daltonValueSpinBox = new QDoubleSpinBox();
this->layout()->addWidget(mp_daltonValueSpinBox);
mp_ppmValueSpinBox = new QDoubleSpinBox();
this->layout()->addWidget(mp_ppmValueSpinBox);
mp_resValueSpinBox = new QDoubleSpinBox();
this->layout()->addWidget(mp_resValueSpinBox);
mp_unitComboBox = new QComboBox();
this->layout()->addWidget(mp_unitComboBox);
mp_unitComboBox->addItem("dalton", QString("dalton"));
mp_unitComboBox->addItem("ppm", QString("ppm"));
mp_unitComboBox->addItem("res", QString("res"));
mp_precisionDalton = PrecisionFactory::getDaltonInstance(0.02);
mp_precisionPpm = PrecisionFactory::getPpmInstance(10);
mp_precisionRes = PrecisionFactory::getResInstance(20000);
mp_daltonValueSpinBox->setDecimals(6);
mp_daltonValueSpinBox->setSingleStep(0.01);
mp_daltonValueSpinBox->setRange(0, 30);
mp_ppmValueSpinBox->setDecimals(4);
mp_ppmValueSpinBox->setSingleStep(10);
mp_ppmValueSpinBox->setRange(0.0001, 300);
mp_resValueSpinBox->setDecimals(0);
mp_resValueSpinBox->setSingleStep(1000);
mp_resValueSpinBox->setRange(1, 2000000);
// By default set precision to be of the Dalton type.
setPrecision(mp_precisionDalton);
connect(mp_unitComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentIndex(int)));
connect(
mp_daltonValueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setDaltonValueChanged(double)));
connect(mp_ppmValueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPpmValueChanged(double)));
connect(mp_resValueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setResValueChanged(double)));
m_oldIndex = -1;
// qDebug() << "PrecisionWidget::PrecisionWidget end";
}
pappso::PrecisionFactory::getResInstance
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
Definition precision.cpp:181
pappso::PrecisionFactory::getPpmInstance
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
Definition precision.cpp:155
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition precision.cpp:136
pappso::PrecisionWidget::mp_daltonValueSpinBox
QDoubleSpinBox * mp_daltonValueSpinBox
Definition precisionwidget.h:54
pappso::PrecisionWidget::setDaltonValueChanged
Q_SLOT void setDaltonValueChanged(double)
Definition precisionwidget.cpp:152
pappso::PrecisionWidget::mp_unitComboBox
QComboBox * mp_unitComboBox
Definition precisionwidget.h:50
pappso::PrecisionWidget::mp_ppmValueSpinBox
QDoubleSpinBox * mp_ppmValueSpinBox
Definition precisionwidget.h:52
pappso::PrecisionWidget::setResValueChanged
Q_SLOT void setResValueChanged(double)
Definition precisionwidget.cpp:180
pappso::PrecisionWidget::setCurrentIndex
Q_SLOT void setCurrentIndex(int)
Definition precisionwidget.cpp:103
pappso::PrecisionWidget::mp_precisionRes
PrecisionPtr mp_precisionRes
Definition precisionwidget.h:58
pappso::PrecisionWidget::setPpmValueChanged
Q_SLOT void setPpmValueChanged(double)
Definition precisionwidget.cpp:166
pappso::PrecisionWidget::setPrecision
void setPrecision(PrecisionPtr precision)
Definition precisionwidget.cpp:216
pappso::PrecisionWidget::mp_resValueSpinBox
QDoubleSpinBox * mp_resValueSpinBox
Definition precisionwidget.h:53
pappso::PrecisionWidget::mp_precisionDalton
PrecisionPtr mp_precisionDalton
Definition precisionwidget.h:56
pappso::PrecisionWidget::m_oldIndex
int m_oldIndex
Definition precisionwidget.h:60
pappso::PrecisionWidget::mp_precisionPpm
PrecisionPtr mp_precisionPpm
Definition precisionwidget.h:57

References pappso::PrecisionFactory::getDaltonInstance(), pappso::PrecisionFactory::getPpmInstance(), pappso::PrecisionFactory::getResInstance(), m_oldIndex, mp_daltonValueSpinBox, mp_ppmValueSpinBox, mp_precisionDalton, mp_precisionPpm, mp_precisionRes, mp_resValueSpinBox, mp_unitComboBox, setCurrentIndex(), setDaltonValueChanged(), setPpmValueChanged(), setPrecision(), and setResValueChanged().

## ~PrecisionWidget()

pappso::PrecisionWidget::~PrecisionWidget | ( |  | ) |

Definition at line 98 of file precisionwidget.cpp.

{
}

## Member Function Documentation

## getPrecision()

const PrecisionPtr & pappso::PrecisionWidget::getPrecision | ( |  | ) | const

Definition at line 194 of file precisionwidget.cpp.

{
if(mp_unitComboBox->itemData(mp_unitComboBox->currentIndex()) == "dalton")
{
return mp_precisionDalton;
}
else if(mp_unitComboBox->itemData(mp_unitComboBox->currentIndex()) == "ppm")
{
return mp_precisionPpm;
}
else if(mp_unitComboBox->itemData(mp_unitComboBox->currentIndex()) == "res")
{
return mp_precisionRes;
}
else
{
throw ExceptionNotPossible("precisionwidget.cpp @ getPrecision()-- ERROR programming error.");
}
}

References mp_precisionDalton, mp_precisionPpm, mp_precisionRes, and mp_unitComboBox.

## precisionChanged

void pappso::PrecisionWidget::precisionChanged | ( | pappso::PrecisionPtr | precision | ) | const

signal

Referenced by setCurrentIndex(), setDaltonValueChanged(), setPpmValueChanged(), and setResValueChanged().

## setCurrentIndex()

void pappso::PrecisionWidget::setCurrentIndex | ( | int | index | ) |

private

Definition at line 103 of file precisionwidget.cpp.

{
// qDebug() << "PrecisionWidget::setCurrentIndex index=" << index;
if(m_oldIndex != index)
{
m_oldIndex = index;
if(mp_unitComboBox->itemData(index) == "dalton")
{
mp_daltonValueSpinBox->setValue(mp_precisionDalton->getNominal());
mp_daltonValueSpinBox->setVisible(true);
mp_ppmValueSpinBox->setVisible(false);
mp_resValueSpinBox->setVisible(false);
emit precisionChanged(mp_precisionDalton);
}
else if(mp_unitComboBox->itemData(index) == "ppm")
{
mp_ppmValueSpinBox->setValue(mp_precisionPpm->getNominal());
mp_ppmValueSpinBox->setVisible(true);
mp_daltonValueSpinBox->setVisible(false);
mp_resValueSpinBox->setVisible(false);
emit precisionChanged(mp_precisionPpm);
}
else if(mp_unitComboBox->itemData(index) == "res")
{
mp_resValueSpinBox->setValue(mp_precisionRes->getNominal());
mp_resValueSpinBox->setVisible(true);
mp_daltonValueSpinBox->setVisible(false);
mp_ppmValueSpinBox->setVisible(false);
emit precisionChanged(mp_precisionRes);
}
else
{
throw ExceptionNotPossible(
"precisionwidget.cpp @ setCurrentIndex(int index) -- ERROR "
"programming error.");
}
}
}
pappso::PrecisionWidget::precisionChanged
void precisionChanged(pappso::PrecisionPtr precision) const

References m_oldIndex, mp_daltonValueSpinBox, mp_ppmValueSpinBox, mp_precisionDalton, mp_precisionPpm, mp_precisionRes, mp_resValueSpinBox, mp_unitComboBox, and precisionChanged().

Referenced by PrecisionWidget().

## setDaltonValueChanged()

void pappso::PrecisionWidget::setDaltonValueChanged | ( | double | value | ) |

private

Definition at line 152 of file precisionwidget.cpp.

{
// qDebug() << "dalton PrecisionWidget::setValueChanged value=" << value;
PrecisionPtr precision = PrecisionFactory::getDaltonInstance(value);
if(mp_precisionDalton != precision)
{
mp_precisionDalton = precision;
emit precisionChanged(mp_precisionDalton);
}
}
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122

References pappso::PrecisionFactory::getDaltonInstance(), mp_precisionDalton, and precisionChanged().

Referenced by PrecisionWidget().

## setPpmValueChanged()

void pappso::PrecisionWidget::setPpmValueChanged | ( | double | value | ) |

private

Definition at line 166 of file precisionwidget.cpp.

{
// qDebug() << "ppm PrecisionWidget::setValueChanged value=" << value;
PrecisionPtr precision = PrecisionFactory::getPpmInstance(value);
if(mp_precisionPpm != precision)
{
mp_precisionPpm = precision;
emit precisionChanged(mp_precisionPpm);
}
}

References pappso::PrecisionFactory::getPpmInstance(), mp_precisionPpm, and precisionChanged().

Referenced by PrecisionWidget().

## setPrecision()

void pappso::PrecisionWidget::setPrecision | ( | PrecisionPtr | precision | ) |

Definition at line 216 of file precisionwidget.cpp.

{
if(precision->unit() == Enums::PrecisionUnit::dalton)
{
mp_precisionDalton = precision;
mp_unitComboBox->setCurrentIndex(mp_unitComboBox->findData(QString("dalton")));
mp_daltonValueSpinBox->setValue(precision->getNominal());
mp_daltonValueSpinBox->setVisible(true);
mp_ppmValueSpinBox->setVisible(false);
mp_resValueSpinBox->setVisible(false);
}
else if(precision->unit() == Enums::PrecisionUnit::ppm)
{
mp_precisionPpm = precision;
mp_unitComboBox->setCurrentIndex(mp_unitComboBox->findData(QString("ppm")));
mp_ppmValueSpinBox->setValue(precision->getNominal());
mp_ppmValueSpinBox->setVisible(true);
mp_daltonValueSpinBox->setVisible(false);
mp_resValueSpinBox->setVisible(false);
}
else if(precision->unit() == Enums::PrecisionUnit::res)
{
mp_precisionRes = precision;
mp_unitComboBox->setCurrentIndex(mp_unitComboBox->findData(QString("res")));
mp_resValueSpinBox->setValue(precision->getNominal());
mp_resValueSpinBox->setVisible(true);
mp_daltonValueSpinBox->setVisible(false);
mp_ppmValueSpinBox->setVisible(false);
}
else
{
throw ExceptionNotPossible(
"precisionwidget.cpp @ setPrecision(PrecisionPtr precision)-- ERROR "
"programming error.");
}
}
pappso::Enums::PrecisionUnit::res
@ res
Definition types.h:100
pappso::Enums::PrecisionUnit::ppm
@ ppm
Definition types.h:99
pappso::Enums::PrecisionUnit::dalton
@ dalton
Definition types.h:98

References pappso::Enums::dalton, pappso::PrecisionBase::getNominal(), mp_daltonValueSpinBox, mp_ppmValueSpinBox, mp_precisionDalton, mp_precisionPpm, mp_precisionRes, mp_resValueSpinBox, mp_unitComboBox, pappso::Enums::ppm, pappso::Enums::res, and pappso::PrecisionBase::unit().

Referenced by PrecisionWidget().

## setResValueChanged()

void pappso::PrecisionWidget::setResValueChanged | ( | double | value | ) |

private

Definition at line 180 of file precisionwidget.cpp.

{
// qDebug() << "res PrecisionWidget::setValueChanged value=" << value;
PrecisionPtr precision = PrecisionFactory::getResInstance(value);
if(mp_precisionRes != precision)
{
mp_precisionRes = precision;
emit precisionChanged(mp_precisionRes);
}
}

References pappso::PrecisionFactory::getResInstance(), mp_precisionRes, and precisionChanged().

Referenced by PrecisionWidget().

## Member Data Documentation

## m_oldIndex

int pappso::PrecisionWidget::m_oldIndex

private

Definition at line 60 of file precisionwidget.h.

Referenced by PrecisionWidget(), and setCurrentIndex().

## mp_daltonValueSpinBox

QDoubleSpinBox* pappso::PrecisionWidget::mp_daltonValueSpinBox

private

Definition at line 54 of file precisionwidget.h.

Referenced by PrecisionWidget(), setCurrentIndex(), and setPrecision().

## mp_ppmValueSpinBox

QDoubleSpinBox* pappso::PrecisionWidget::mp_ppmValueSpinBox

private

Definition at line 52 of file precisionwidget.h.

Referenced by PrecisionWidget(), setCurrentIndex(), and setPrecision().

## mp_precisionDalton

PrecisionPtr pappso::PrecisionWidget::mp_precisionDalton

private

Definition at line 56 of file precisionwidget.h.

Referenced by PrecisionWidget(), getPrecision(), setCurrentIndex(), setDaltonValueChanged(), and setPrecision().

## mp_precisionPpm

PrecisionPtr pappso::PrecisionWidget::mp_precisionPpm

private

Definition at line 57 of file precisionwidget.h.

Referenced by PrecisionWidget(), getPrecision(), setCurrentIndex(), setPpmValueChanged(), and setPrecision().

## mp_precisionRes

PrecisionPtr pappso::PrecisionWidget::mp_precisionRes

private

Definition at line 58 of file precisionwidget.h.

Referenced by PrecisionWidget(), getPrecision(), setCurrentIndex(), setPrecision(), and setResValueChanged().

## mp_resValueSpinBox

QDoubleSpinBox* pappso::PrecisionWidget::mp_resValueSpinBox

private

Definition at line 53 of file precisionwidget.h.

Referenced by PrecisionWidget(), setCurrentIndex(), and setPrecision().

## mp_unitComboBox

QComboBox* pappso::PrecisionWidget::mp_unitComboBox

private

Definition at line 50 of file precisionwidget.h.

Referenced by PrecisionWidget(), getPrecision(), setCurrentIndex(), and setPrecision().

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

- pappsomspp/gui/precisionwidget/precisionwidget.h
- pappsomspp/gui/precisionwidget/precisionwidget.cpp