Commit 42d9a74e authored by Don Gagne's avatar Don Gagne

Added min/max invalid display

parent 1898be3f
...@@ -37,6 +37,8 @@ RCChannelWidget::RCChannelWidget(QWidget *parent) : ...@@ -37,6 +37,8 @@ RCChannelWidget::RCChannelWidget(QWidget *parent) :
_min(_centerValue), _min(_centerValue),
_max(_centerValue), _max(_centerValue),
_trim(_centerValue), _trim(_centerValue),
_minValid(false),
_maxValid(false),
_showMinMax(false), _showMinMax(false),
_showTrim(false) _showTrim(false)
{ {
...@@ -90,20 +92,37 @@ void RCChannelWidget::paintEvent(QPaintEvent *event) ...@@ -90,20 +92,37 @@ void RCChannelWidget::paintEvent(QPaintEvent *event)
painter.setBrush(hGradientBrush); painter.setBrush(hGradientBrush);
if (_showMinMax) { if (_showMinMax) {
QString text;
// Draw the Min numeric value display to the left // Draw the Min numeric value display to the left
painter.drawText(0, rowHeigth, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, "Min"); painter.drawText(0, rowHeigth, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, "Min");
painter.drawText(0, rowHeigth * 2, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, QString::number(_min)); if (_minValid) {
text = QString::number(_min);
} else {
text = "----";
}
painter.drawText(0, rowHeigth * 2, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, text);
// Draw the Max numeric value display to the right // Draw the Max numeric value display to the right
painter.drawText(width() - minMaxDisplayWidth, rowHeigth, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, "Max"); painter.drawText(width() - minMaxDisplayWidth, rowHeigth, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, "Max");
painter.drawText(width() - minMaxDisplayWidth, rowHeigth * 2, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, QString::number(_max)); if (_maxValid) {
text = QString::number(_max);
} else {
text = QString::number(_max);
}
painter.drawText(width() - minMaxDisplayWidth, rowHeigth * 2, minMaxDisplayWidth, fontHeight, Qt::AlignHCenter | Qt::AlignBottom, text);
// Draw the Min/Max tick marks on the axis // Draw the Min/Max tick marks on the axis
int xTick;
if (_minValid) {
int xTick = rcValueAxis.left() + (rcValueAxis.width() * ((float)(_min-_minRange) / (_maxRange-_minRange))); int xTick = rcValueAxis.left() + (rcValueAxis.width() * ((float)(_min-_minRange) / (_maxRange-_minRange)));
painter.drawLine(xTick, rcValueAxis.top(), xTick, rcValueAxis.bottom()); painter.drawLine(xTick, rcValueAxis.top(), xTick, rcValueAxis.bottom());
}
if (_maxValid) {
xTick = rcValueAxis.left() + (rcValueAxis.width() * ((float)(_max-_minRange) / (_maxRange-_minRange))); xTick = rcValueAxis.left() + (rcValueAxis.width() * ((float)(_max-_minRange) / (_maxRange-_minRange)));
painter.drawLine(xTick, rcValueAxis.top(), xTick, rcValueAxis.bottom()); painter.drawLine(xTick, rcValueAxis.top(), xTick, rcValueAxis.bottom());
} }
}
if (_showTrim) { if (_showTrim) {
// Draw the Trim value pointer // Draw the Trim value pointer
...@@ -221,3 +240,17 @@ void RCChannelWidget::_drawValuePointer(QPainter* painter, int xTip, int yTip, i ...@@ -221,3 +240,17 @@ void RCChannelWidget::_drawValuePointer(QPainter* painter, int xTip, int yTip, i
painter->drawPolygon (trianglePoints, 3); painter->drawPolygon (trianglePoints, 3);
} }
/// @brief Set whether the Min range value is valid or not.
void RCChannelWidget::setMinValid(bool valid)
{
_minValid = valid;
update();
}
/// @brief Set whether the Max range value is valid or not.
void RCChannelWidget::setMaxValid(bool valid)
{
_maxValid = valid;
update();
}
...@@ -46,6 +46,12 @@ public: ...@@ -46,6 +46,12 @@ public:
void setMinMax(int min, int max); void setMinMax(int min, int max);
/// @brief Set whether the Min range value is valid or not.
void setMinValid(bool valid);
/// @brief Set whether the Max range value is valid or not.
void setMaxValid(bool valid);
/// @brief Sets the Trim value for the channel /// @brief Sets the Trim value for the channel
void setTrim(int value); void setTrim(int value);
...@@ -56,6 +62,8 @@ public: ...@@ -56,6 +62,8 @@ public:
void showMinMax(bool show); void showMinMax(bool show);
bool isMinMaxShown() { return _showMinMax; } bool isMinMaxShown() { return _showMinMax; }
bool isMinValid(void) { return _minValid; }
bool isMaxValid(void) { return _maxValid; }
void showTrim(bool show); void showTrim(bool show);
bool isTrimShown() { return _showTrim; } bool isTrimShown() { return _showTrim; }
...@@ -71,6 +79,9 @@ private: ...@@ -71,6 +79,9 @@ private:
int _max; ///< Max RC value int _max; ///< Max RC value
int _trim; ///< RC Value for Trim position int _trim; ///< RC Value for Trim position
bool _minValid; ///< true: minimum value is valid
bool _maxValid; ///< true: maximum value is valid
bool _showMinMax; ///< true: show min max values on display bool _showMinMax; ///< true: show min max values on display
bool _showTrim; ///< true: show trim value on display bool _showTrim; ///< true: show trim value on display
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment