Hi, first of all, thanks for making all of this open source, this is much appreciated !
The goal of this PR is to add a text zone on the bottom of the oscilloscope screen to indicate actual mouse cursor's voltage. I needed it to follow some curves with mouse pointer and having precise voltage measurements.
This branch consists of two distinct commits. I tried to minimize changes made to code, not to alter the "spirit" of the code and keep it "consistent". Typically, I resisted to the temptation of making it more close to the MVC paradigm.
First commit
goal: access to oscilloscope gain without having to parse gainText[ui->ch1GainSlider->value()] at each mouse movement
method: I replaced the string array gains definition by an array of structs:
struct Gain {
float value;
QString unit;
QString display; // human readable version; ex "80mV"
}
advantages:
efficiency: direct access to gain value, unit and human readable display without need to add CPU load
clarity: more readable / maintainable code: unit = gains[ui->ch2GainSlider->value()].unit is easy to write and read
before:
for(int i = 0; i < unit.length(); i++) {
if(unit[i] == 'm' || unit[i] == 'V') {
value = unit.left(i).toDouble();
unit = unit.remove(unit.left(i));
break;
}
after:
gain = gains[ui->ch1GainSlider->value()].value;
Second commit
goal: add the text zone to display volts value. Conversion from pixels position to volts is done.
changes in XprotolabInterface::moveCursor may looks big, but I only:
put existing code without any modification in this if instruction:
if(event->buttons() & Qt::LeftButton & (currentSelected != isNone))
added } else if(!event->buttons()) { block to handle mouse move without pressed button
More to-do ?
In the same spirit, we could also indicate cursor's current "time", but I didn't needed it, as I can place vertical markers.
this looks good to me, any one against merging this ?
without negative feedback i can merge this change in a couple of weeks
remind me to merge and update debian package
regards
Hi, first of all, thanks for making all of this open source, this is much appreciated !
The goal of this PR is to add a text zone on the bottom of the oscilloscope screen to indicate actual mouse cursor's voltage. I needed it to follow some curves with mouse pointer and having precise voltage measurements.
This branch consists of two distinct commits. I tried to minimize changes made to code, not to alter the "spirit" of the code and keep it "consistent". Typically, I resisted to the temptation of making it more close to the MVC paradigm.
First commit
gainText[ui->ch1GainSlider->value()]
at each mouse movementunit = gains[ui->ch2GainSlider->value()].unit
is easy to write and readSecond commit
XprotolabInterface::moveCursor
may looks big, but I only:if(event->buttons() & Qt::LeftButton & (currentSelected != isNone))
} else if(!event->buttons()) {
block to handle mouse move without pressed buttonMore to-do ?
In the same spirit, we could also indicate cursor's current "time", but I didn't needed it, as I can place vertical markers.