Skip to content

Commit

Permalink
Merge pull request #2963 from PeterBowman/yarpmotorgui_cpu
Browse files Browse the repository at this point in the history
Merge `setAlignment` commands in yarpmotorgui
  • Loading branch information
randaz81 authored May 30, 2023
2 parents ee5f948 + ff06ecb commit 1d54322
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
8 changes: 8 additions & 0 deletions doc/release/yarp_3_8/yarpmotorgui_cpu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
yarpmotorgui_cpu {#yarp_3_8}
-----------

### tools

#### `yarpmotorgui`

* Fixed an issue regarding high CPU usage (#2955).
22 changes: 8 additions & 14 deletions src/yarpmotorgui/sliderWithTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,25 @@ void SliderWithTarget::paintEvent(QPaintEvent *e)
double value = this->value();
double newX = ((double)w / (double)totValues) * ((double)value + abs(this->minimum()));
QString label_text = QString("%L1").arg((double)value / sliderStep, 0, 'f', number_of_decimals);
int label_text_siz = label_text.size();
sliderCurrentLabel->setText(label_text);
sliderCurrentLabel->setAlignment(Qt::AlignLeft);
sliderCurrentLabel->setAlignment(Qt::AlignVCenter);
sliderCurrentLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
//these adjustment are required to have the label properly aligned and
//to avoid overflow
double newX2 = newX;
if (newX2<0) newX2 = 0;
if (newX2>w-30) newX2 = w-30;
sliderCurrentLabel->setGeometry(newX2, -10, 60, 20);
if (newX<0) newX = 0;
if (newX>w-30) newX = w-30;
sliderCurrentLabel->setGeometry(newX, -10, 60, 20);
}
if (enableViewTargetValue)
{
double newX = ((double)w / (double)totValues) * ((double)target + abs(this->minimum()));
QString label_text = QString("Ref:%L1").arg((double)target, 0, 'f', number_of_decimals);
int label_text_siz = label_text.size();
sliderTargetLabel->setText(label_text);
sliderCurrentLabel->setAlignment(Qt::AlignLeft);
sliderCurrentLabel->setAlignment(Qt::AlignVCenter);
sliderTargetLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
//these adjustment are required to have the label properly aligned and
//to avoid overflow
double newX2 = newX;
if (newX2 < 0) newX2 = 0;
if (newX2 > w - 30) newX2 = w - 30;
sliderTargetLabel->setGeometry(newX2, +10, 60, 20);
if (newX < 0) newX = 0;
if (newX > w - 30) newX = w - 30;
sliderTargetLabel->setGeometry(newX, +10, 60, 20);
}
else
{
Expand Down

0 comments on commit 1d54322

Please sign in to comment.