Prevent class/instance name clash

This commit is contained in:
Jan Käberich 2022-03-16 15:02:15 +01:00
parent 5897705f32
commit bd69646c32
6 changed files with 162 additions and 162 deletions

View File

@ -19,8 +19,8 @@ TraceWaterfall::TraceWaterfall(TraceModel &model, QWidget *parent)
keepDataBeyondPlotSize(false), keepDataBeyondPlotSize(false),
maxDataSweeps(500) maxDataSweeps(500)
{ {
XAxis.set(XAxis::Type::Frequency, false, true, 0, 6000000000, 500000000); xAxis.set(XAxis::Type::Frequency, false, true, 0, 6000000000, 500000000);
YAxis.set(YAxis::Type::Magnitude, false, true, -1, 1, 1); yAxis.set(YAxis::Type::Magnitude, false, true, -1, 1, 1);
initializeTraceInfo(); initializeTraceInfo();
} }
@ -115,16 +115,16 @@ bool TraceWaterfall::configureForTrace(Trace *t)
{ {
switch(t->outputType()) { switch(t->outputType()) {
case Trace::DataType::Frequency: case Trace::DataType::Frequency:
XAxis.set(XAxis::Type::Frequency, false, true, 0, 1, 0.1); xAxis.set(XAxis::Type::Frequency, false, true, 0, 1, 0.1);
YAxis.set(YAxis::Type::Magnitude, false, true, 0, 1, 1.0); yAxis.set(YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
break; break;
case Trace::DataType::Time: case Trace::DataType::Time:
XAxis.set(XAxis::Type::Time, false, true, 0, 1, 0.1); xAxis.set(XAxis::Type::Time, false, true, 0, 1, 0.1);
YAxis.set(YAxis::Type::ImpulseMag, false, true, 0, 1, 1.0); yAxis.set(YAxis::Type::ImpulseMag, false, true, 0, 1, 1.0);
break; break;
case Trace::DataType::Power: case Trace::DataType::Power:
XAxis.set(XAxis::Type::Power, false, true, 0, 1, 0.1); xAxis.set(XAxis::Type::Power, false, true, 0, 1, 0.1);
YAxis.set(YAxis::Type::Magnitude, false, true, 0, 1, 1.0); yAxis.set(YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
break; break;
case Trace::DataType::Invalid: case Trace::DataType::Invalid:
// unable to add // unable to add
@ -136,7 +136,7 @@ bool TraceWaterfall::configureForTrace(Trace *t)
bool TraceWaterfall::domainMatch(Trace *t) bool TraceWaterfall::domainMatch(Trace *t)
{ {
switch(XAxis.getType()) { switch(xAxis.getType()) {
case XAxis::Type::Frequency: case XAxis::Type::Frequency:
return t->outputType() == Trace::DataType::Frequency; return t->outputType() == Trace::DataType::Frequency;
case XAxis::Type::Distance: case XAxis::Type::Distance:
@ -225,10 +225,10 @@ void TraceWaterfall::draw(QPainter &p)
} }
QString unit = ""; QString unit = "";
if(pref.Graphs.showUnits) { if(pref.Graphs.showUnits) {
unit = YAxis.Unit(); unit = yAxis.Unit();
} }
QString labelMin = Unit::ToString(YAxis.getRangeMin(), unit, YAxis.Prefixes(), 4); QString labelMin = Unit::ToString(yAxis.getRangeMin(), unit, yAxis.Prefixes(), 4);
QString labelMax = Unit::ToString(YAxis.getRangeMax(), unit, YAxis.Prefixes(), 4); QString labelMax = Unit::ToString(yAxis.getRangeMax(), unit, yAxis.Prefixes(), 4);
p.setPen(QPen(pref.Graphs.Color.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
p.save(); p.save();
p.translate(w.width() - yAxisDisabledSpace - yAxisLegendSpace, w.height()); p.translate(w.width() - yAxisDisabledSpace - yAxisLegendSpace, w.height());
@ -248,21 +248,21 @@ void TraceWaterfall::draw(QPainter &p)
auto font = p.font(); auto font = p.font();
font.setPixelSize(AxisLabelSize); font.setPixelSize(AxisLabelSize);
p.setFont(font); p.setFont(font);
p.drawText(QRect(0, w.height()-AxisLabelSize*1.5, w.width(), AxisLabelSize*1.5), Qt::AlignHCenter, XAxis.TypeToName()); p.drawText(QRect(0, w.height()-AxisLabelSize*1.5, w.width(), AxisLabelSize*1.5), Qt::AlignHCenter, xAxis.TypeToName());
if(XAxis.getTicks().size() >= 1) { if(xAxis.getTicks().size() >= 1) {
// draw X ticks // draw X ticks
int significantDigits; int significantDigits;
bool displayFullFreq; bool displayFullFreq;
if(XAxis.getLog()) { if(xAxis.getLog()) {
significantDigits = 5; significantDigits = 5;
displayFullFreq = true; displayFullFreq = true;
} else { } else {
// this only works for evenly distributed ticks: // this only works for evenly distributed ticks:
auto max = qMax(abs(XAxis.getTicks().front()), abs(XAxis.getTicks().back())); auto max = qMax(abs(xAxis.getTicks().front()), abs(xAxis.getTicks().back()));
double step; double step;
if(XAxis.getTicks().size() >= 2) { if(xAxis.getTicks().size() >= 2) {
step = abs(XAxis.getTicks()[0] - XAxis.getTicks()[1]); step = abs(xAxis.getTicks()[0] - xAxis.getTicks()[1]);
} else { } else {
// only one tick, set arbitrary number of digits // only one tick, set arbitrary number of digits
step = max / 1000; step = max / 1000;
@ -274,11 +274,11 @@ void TraceWaterfall::draw(QPainter &p)
QString prefixes = "fpnum kMG"; QString prefixes = "fpnum kMG";
QString unit = ""; QString unit = "";
if(pref.Graphs.showUnits) { if(pref.Graphs.showUnits) {
unit = XAxis.Unit(); unit = xAxis.Unit();
} }
QString commonPrefix = QString(); QString commonPrefix = QString();
if(!displayFullFreq) { if(!displayFullFreq) {
auto fullFreq = Unit::ToString(XAxis.getTicks().front(), unit, prefixes, significantDigits); auto fullFreq = Unit::ToString(xAxis.getTicks().front(), unit, prefixes, significantDigits);
commonPrefix = fullFreq.at(fullFreq.size() - 1); commonPrefix = fullFreq.at(fullFreq.size() - 1);
auto front = fullFreq; auto front = fullFreq;
front.truncate(fullFreq.size() - displayLastDigits - unit.length()); front.truncate(fullFreq.size() - displayLastDigits - unit.length());
@ -293,8 +293,8 @@ void TraceWaterfall::draw(QPainter &p)
} }
int lastTickLabelEnd = 0; int lastTickLabelEnd = 0;
for(auto t : XAxis.getTicks()) { for(auto t : xAxis.getTicks()) {
auto xCoord = XAxis.transform(t, plotAreaLeft, plotAreaLeft + plotAreaWidth); auto xCoord = xAxis.transform(t, plotAreaLeft, plotAreaLeft + plotAreaWidth);
p.setPen(QPen(pref.Graphs.Color.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
p.drawLine(xCoord, plotAreaBottom, xCoord, plotAreaBottom + 2); p.drawLine(xCoord, plotAreaBottom, xCoord, plotAreaBottom + 2);
if(xCoord != plotAreaLeft && xCoord != plotAreaLeft + plotAreaWidth) { if(xCoord != plotAreaLeft && xCoord != plotAreaLeft + plotAreaWidth) {
@ -344,29 +344,29 @@ void TraceWaterfall::draw(QPainter &p)
for(i=data.size() - 1;i>=0;i--) { for(i=data.size() - 1;i>=0;i--) {
auto sweep = data[i]; auto sweep = data[i];
for(unsigned int s=0;s<sweep.size();s++) { for(unsigned int s=0;s<sweep.size();s++) {
auto x = XAxis.sampleToCoordinate(sweep[s], trace); auto x = xAxis.sampleToCoordinate(sweep[s], trace);
double x_start; double x_start;
double x_stop; double x_stop;
if(x < XAxis.getRangeMin() || x > XAxis.getRangeMax()) { if(x < xAxis.getRangeMin() || x > xAxis.getRangeMax()) {
// out of range, skip // out of range, skip
continue; continue;
} }
if(s == 0) { if(s == 0) {
x_start = x; x_start = x;
} else { } else {
auto prev_x = XAxis.sampleToCoordinate(sweep[s-1], trace); auto prev_x = xAxis.sampleToCoordinate(sweep[s-1], trace);
x_start = (prev_x + x) / 2.0; x_start = (prev_x + x) / 2.0;
} }
x_start = XAxis.transform(x_start, plotAreaLeft, plotAreaLeft + plotAreaWidth); x_start = xAxis.transform(x_start, plotAreaLeft, plotAreaLeft + plotAreaWidth);
if(s == sweep.size() - 1) { if(s == sweep.size() - 1) {
x_stop = x; x_stop = x;
} else { } else {
auto next_x = XAxis.sampleToCoordinate(sweep[s+1], trace); auto next_x = xAxis.sampleToCoordinate(sweep[s+1], trace);
x_stop = (next_x + x) / 2.0; x_stop = (next_x + x) / 2.0;
} }
x_stop = XAxis.transform(x_stop, plotAreaLeft, plotAreaLeft + plotAreaWidth); x_stop = xAxis.transform(x_stop, plotAreaLeft, plotAreaLeft + plotAreaWidth);
auto y = YAxis.sampleToCoordinate(sweep[s]); auto y = yAxis.sampleToCoordinate(sweep[s]);
auto color = getColor(YAxis.transform(y, 0.0, 1.0)); auto color = getColor(yAxis.transform(y, 0.0, 1.0));
auto rect = QRect(round(x_start), ytop, round(x_stop - x_start) + 1, ybottom - ytop + 1); auto rect = QRect(round(x_start), ytop, round(x_stop - x_start) + 1, ybottom - ytop + 1);
p.fillRect(rect, QBrush(color)); p.fillRect(rect, QBrush(color));
} }
@ -420,7 +420,7 @@ bool TraceWaterfall::supported(Trace *t)
return false; return false;
} }
switch(YAxis.getType()) { switch(yAxis.getType()) {
case YAxis::Type::Disabled: case YAxis::Type::Disabled:
return false; return false;
case YAxis::Type::VSWR: case YAxis::Type::VSWR:
@ -458,9 +458,9 @@ QString TraceWaterfall::mouseText(QPoint pos)
{ {
QString ret; QString ret;
if(QRect(plotAreaLeft, 0, plotAreaWidth + 1, plotAreaBottom).contains(pos)) { if(QRect(plotAreaLeft, 0, plotAreaWidth + 1, plotAreaBottom).contains(pos)) {
double x = XAxis.inverseTransform(pos.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth); double x = xAxis.inverseTransform(pos.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth);
int significantDigits = floor(log10(abs(XAxis.getRangeMax()))) - floor(log10((abs(XAxis.getRangeMax() - XAxis.getRangeMin())) / 1000.0)) + 1; int significantDigits = floor(log10(abs(xAxis.getRangeMax()))) - floor(log10((abs(xAxis.getRangeMax() - xAxis.getRangeMin())) / 1000.0)) + 1;
ret += Unit::ToString(x, XAxis.Unit(), "fpnum kMG", significantDigits) + "\n"; ret += Unit::ToString(x, xAxis.Unit(), "fpnum kMG", significantDigits) + "\n";
} }
return ret; return ret;
} }
@ -474,13 +474,13 @@ bool TraceWaterfall::markerVisible(double x)
void TraceWaterfall::traceDataChanged(unsigned int begin, unsigned int end) void TraceWaterfall::traceDataChanged(unsigned int begin, unsigned int end)
{ {
if(XAxis.getAutorange()) { if(xAxis.getAutorange()) {
double min_x = trace->sample(0).x; double min_x = trace->sample(0).x;
double max_x = trace->sample(trace->size() - 1).x; double max_x = trace->sample(trace->size() - 1).x;
if(min_x != XAxis.getRangeMin() || max_x != XAxis.getRangeMax()) { if(min_x != xAxis.getRangeMin() || max_x != xAxis.getRangeMax()) {
resetWaterfall(); resetWaterfall();
// adjust axis // adjust axis
XAxis.set(XAxis.getType(), XAxis.getLog(), true, min_x, max_x, 0); xAxis.set(xAxis.getType(), xAxis.getLog(), true, min_x, max_x, 0);
} }
} }
bool YAxisUpdateRequired = false; bool YAxisUpdateRequired = false;
@ -498,12 +498,12 @@ void TraceWaterfall::traceDataChanged(unsigned int begin, unsigned int end)
} }
// grab trace data // grab trace data
data.back().resize(trace->size()); data.back().resize(trace->size());
double min = YAxis.getRangeMin(); double min = yAxis.getRangeMin();
double max = YAxis.getRangeMax(); double max = yAxis.getRangeMax();
for(unsigned int i=begin;i<end;i++) { for(unsigned int i=begin;i<end;i++) {
data.back()[i] = trace->sample(i); data.back()[i] = trace->sample(i);
if(YAxis.getAutorange() && !YAxisUpdateRequired) { if(yAxis.getAutorange() && !YAxisUpdateRequired) {
double val = YAxis.sampleToCoordinate(trace->sample(i)); double val = yAxis.sampleToCoordinate(trace->sample(i));
if(val < min) { if(val < min) {
min = val; min = val;
} }
@ -512,9 +512,9 @@ void TraceWaterfall::traceDataChanged(unsigned int begin, unsigned int end)
} }
} }
} }
if(YAxis.getAutorange() && !YAxisUpdateRequired && (min != YAxis.getRangeMin() || max != YAxis.getRangeMax())) { if(yAxis.getAutorange() && !YAxisUpdateRequired && (min != yAxis.getRangeMin() || max != yAxis.getRangeMax())) {
// axis scaling needs update due to new trace data // axis scaling needs update due to new trace data
YAxis.set(YAxis.getType(), YAxis.getLog(), true, min, max, 0); yAxis.set(yAxis.getType(), yAxis.getLog(), true, min, max, 0);
} else if(YAxisUpdateRequired) { } else if(YAxisUpdateRequired) {
updateYAxis(); updateYAxis();
} }
@ -522,12 +522,12 @@ void TraceWaterfall::traceDataChanged(unsigned int begin, unsigned int end)
void TraceWaterfall::updateYAxis() void TraceWaterfall::updateYAxis()
{ {
if(YAxis.getAutorange()) { if(yAxis.getAutorange()) {
double min = std::numeric_limits<double>::max(); double min = std::numeric_limits<double>::max();
double max = std::numeric_limits<double>::lowest(); double max = std::numeric_limits<double>::lowest();
for(auto sweep : data) { for(auto sweep : data) {
for(unsigned int i=0;i<sweep.size();i++) { for(unsigned int i=0;i<sweep.size();i++) {
double val = YAxis.sampleToCoordinate(sweep[i]); double val = yAxis.sampleToCoordinate(sweep[i]);
if(isnan(val) || isinf(val)) { if(isnan(val) || isinf(val)) {
continue; continue;
} }
@ -540,7 +540,7 @@ void TraceWaterfall::updateYAxis()
} }
} }
if(max > min) { if(max > min) {
YAxis.set(YAxis.getType(), YAxis.getLog(), true, min, max, 0); yAxis.set(yAxis.getType(), yAxis.getLog(), true, min, max, 0);
} }
} }
} }

View File

@ -58,8 +58,8 @@ private:
Trace *trace; Trace *trace;
XAxis XAxis; XAxis xAxis;
YAxis YAxis; YAxis yAxis;
std::deque<std::vector<Trace::Data>> data; std::deque<std::vector<Trace::Data>> data;
unsigned int pixelsPerLine; unsigned int pixelsPerLine;

View File

@ -34,7 +34,7 @@ TraceXYPlot::TraceXYPlot(TraceModel &model, QWidget *parent)
void TraceXYPlot::setYAxis(int axis, YAxis::Type type, bool log, bool autorange, double min, double max, double div) void TraceXYPlot::setYAxis(int axis, YAxis::Type type, bool log, bool autorange, double min, double max, double div)
{ {
if(YAxis[axis].getType() != type) { if(yAxis[axis].getType() != type) {
// remove traces that are active but not supported with the new axis type // remove traces that are active but not supported with the new axis type
bool erased = false; bool erased = false;
do { do {
@ -48,7 +48,7 @@ void TraceXYPlot::setYAxis(int axis, YAxis::Type type, bool log, bool autorange,
} }
} while(erased); } while(erased);
} }
YAxis[axis].set(type, log, autorange, min, max, div); yAxis[axis].set(type, log, autorange, min, max, div);
traceRemovalPending = true; traceRemovalPending = true;
updateContextMenu(); updateContextMenu();
replot(); replot();
@ -60,7 +60,7 @@ void TraceXYPlot::setXAxis(XAxis::Type type, XAxisMode mode, bool log, double mi
if(mode == XAxisMode::FitTraces || mode == XAxisMode::UseSpan) { if(mode == XAxisMode::FitTraces || mode == XAxisMode::UseSpan) {
autorange = true; autorange = true;
} }
XAxis.set(type, log, autorange, min, max, div); xAxis.set(type, log, autorange, min, max, div);
xAxisMode = mode; xAxisMode = mode;
traceRemovalPending = true; traceRemovalPending = true;
updateContextMenu(); updateContextMenu();
@ -70,7 +70,7 @@ void TraceXYPlot::setXAxis(XAxis::Type type, XAxisMode mode, bool log, double mi
void TraceXYPlot::enableTrace(Trace *t, bool enabled) void TraceXYPlot::enableTrace(Trace *t, bool enabled)
{ {
for(int axis = 0;axis < 2;axis++) { for(int axis = 0;axis < 2;axis++) {
enableTraceAxis(t, axis, enabled && supported(t, YAxis[axis].getType())); enableTraceAxis(t, axis, enabled && supported(t, yAxis[axis].getType()));
} }
} }
@ -82,7 +82,7 @@ void TraceXYPlot::updateSpan(double min, double max)
void TraceXYPlot::replot() void TraceXYPlot::replot()
{ {
if(xAxisMode != XAxisMode::Manual || YAxis[0].getAutorange() || YAxis[1].getAutorange()) { if(xAxisMode != XAxisMode::Manual || yAxis[0].getAutorange() || yAxis[1].getAutorange()) {
updateAxisTicks(); updateAxisTicks();
} }
TracePlot::replot(); TracePlot::replot();
@ -92,21 +92,21 @@ nlohmann::json TraceXYPlot::toJSON()
{ {
nlohmann::json j; nlohmann::json j;
nlohmann::json jX; nlohmann::json jX;
jX["type"] = XAxis.TypeToName().toStdString(); jX["type"] = xAxis.TypeToName().toStdString();
jX["mode"] = AxisModeToName(xAxisMode).toStdString(); jX["mode"] = AxisModeToName(xAxisMode).toStdString();
jX["log"] = XAxis.getLog(); jX["log"] = xAxis.getLog();
jX["min"] = XAxis.getRangeMin(); jX["min"] = xAxis.getRangeMin();
jX["max"] = XAxis.getRangeMax(); jX["max"] = xAxis.getRangeMax();
jX["div"] = XAxis.getRangeDiv(); jX["div"] = xAxis.getRangeDiv();
j["XAxis"] = jX; j["XAxis"] = jX;
for(unsigned int i=0;i<2;i++) { for(unsigned int i=0;i<2;i++) {
nlohmann::json jY; nlohmann::json jY;
jY["type"] = YAxis[i].TypeToName().toStdString(); jY["type"] = yAxis[i].TypeToName().toStdString();
jY["log"] = YAxis[i].getLog(); jY["log"] = yAxis[i].getLog();
jY["autorange"] = YAxis[i].getAutorange(); jY["autorange"] = yAxis[i].getAutorange();
jY["min"] = YAxis[i].getRangeMin(); jY["min"] = yAxis[i].getRangeMin();
jY["max"] = YAxis[i].getRangeMax(); jY["max"] = yAxis[i].getRangeMax();
jY["div"] = YAxis[i].getRangeDiv(); jY["div"] = yAxis[i].getRangeDiv();
nlohmann::json jtraces; nlohmann::json jtraces;
for(auto t : tracesAxis[i]) { for(auto t : tracesAxis[i]) {
jtraces.push_back(t->toHash()); jtraces.push_back(t->toHash());
@ -262,7 +262,7 @@ void TraceXYPlot::updateContextMenu()
}); });
for(int axis = 0;axis < 2;axis++) { for(int axis = 0;axis < 2;axis++) {
if(YAxis[axis].getType() == YAxis::Type::Disabled) { if(yAxis[axis].getType() == YAxis::Type::Disabled) {
continue; continue;
} }
if(axis == 0) { if(axis == 0) {
@ -272,7 +272,7 @@ void TraceXYPlot::updateContextMenu()
} }
for(auto t : traces) { for(auto t : traces) {
// Skip traces that are not applicable for the selected axis type // Skip traces that are not applicable for the selected axis type
if(!supported(t.first, YAxis[axis].getType())) { if(!supported(t.first, yAxis[axis].getType())) {
continue; continue;
} }
@ -309,7 +309,7 @@ bool TraceXYPlot::dropSupported(Trace *t)
bool TraceXYPlot::supported(Trace *t) bool TraceXYPlot::supported(Trace *t)
{ {
// potentially possible to add every kind of trace (depends on axis) // potentially possible to add every kind of trace (depends on axis)
if(supported(t, YAxis[0].getType()) || supported(t, YAxis[1].getType())) { if(supported(t, yAxis[0].getType()) || supported(t, yAxis[1].getType())) {
return true; return true;
} else { } else {
// no axis // no axis
@ -328,16 +328,16 @@ void TraceXYPlot::draw(QPainter &p)
auto pen = QPen(pref.Graphs.Color.axis, 0); auto pen = QPen(pref.Graphs.Color.axis, 0);
pen.setCosmetic(true); pen.setCosmetic(true);
p.setPen(pen); p.setPen(pen);
plotAreaLeft = YAxis[0].getType() == YAxis::Type::Disabled ? yAxisDisabledSpace : yAxisSpace; plotAreaLeft = yAxis[0].getType() == YAxis::Type::Disabled ? yAxisDisabledSpace : yAxisSpace;
plotAreaWidth = w.width(); plotAreaWidth = w.width();
plotAreaTop = 10; plotAreaTop = 10;
plotAreaBottom = w.height() - xAxisSpace; plotAreaBottom = w.height() - xAxisSpace;
if(YAxis[0].getType() != YAxis::Type::Disabled) { if(yAxis[0].getType() != YAxis::Type::Disabled) {
plotAreaWidth -= yAxisSpace; plotAreaWidth -= yAxisSpace;
} else { } else {
plotAreaWidth -= yAxisDisabledSpace; plotAreaWidth -= yAxisDisabledSpace;
} }
if(YAxis[1].getType() != YAxis::Type::Disabled) { if(yAxis[1].getType() != YAxis::Type::Disabled) {
plotAreaWidth -= yAxisSpace; plotAreaWidth -= yAxisSpace;
} else { } else {
plotAreaWidth -= yAxisDisabledSpace; plotAreaWidth -= yAxisDisabledSpace;
@ -350,12 +350,12 @@ void TraceXYPlot::draw(QPainter &p)
auto font = p.font(); auto font = p.font();
font.setPixelSize(AxisLabelSize); font.setPixelSize(AxisLabelSize);
p.setFont(font); p.setFont(font);
p.drawText(QRect(0, w.height()-AxisLabelSize*1.5, w.width(), AxisLabelSize*1.5), Qt::AlignHCenter, XAxis.TypeToName()); p.drawText(QRect(0, w.height()-AxisLabelSize*1.5, w.width(), AxisLabelSize*1.5), Qt::AlignHCenter, xAxis.TypeToName());
for(int i=0;i<2;i++) { for(int i=0;i<2;i++) {
if(YAxis[i].getType() == YAxis::Type::Disabled) { if(yAxis[i].getType() == YAxis::Type::Disabled) {
continue; continue;
} }
QString labelY = YAxis[i].TypeToName(); QString labelY = yAxis[i].TypeToName();
p.setPen(QPen(pref.Graphs.Color.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
auto xStart = i == 0 ? 0 : w.width() - AxisLabelSize * 1.5; auto xStart = i == 0 ? 0 : w.width() - AxisLabelSize * 1.5;
p.save(); p.save();
@ -364,20 +364,20 @@ void TraceXYPlot::draw(QPainter &p)
p.drawText(QRect(0, 0, w.height()-xAxisSpace, AxisLabelSize*1.5), Qt::AlignHCenter, labelY); p.drawText(QRect(0, 0, w.height()-xAxisSpace, AxisLabelSize*1.5), Qt::AlignHCenter, labelY);
p.restore(); p.restore();
// draw ticks // draw ticks
if(YAxis[i].getType() != YAxis::Type::Disabled && YAxis[i].getTicks().size() > 0) { if(yAxis[i].getType() != YAxis::Type::Disabled && yAxis[i].getTicks().size() > 0) {
// this only works for evenly distributed ticks: // this only works for evenly distributed ticks:
auto max = qMax(abs(YAxis[i].getTicks().front()), abs(YAxis[i].getTicks().back())); auto max = qMax(abs(yAxis[i].getTicks().front()), abs(yAxis[i].getTicks().back()));
double step; double step;
if(YAxis[i].getTicks().size() >= 2) { if(yAxis[i].getTicks().size() >= 2) {
step = abs(YAxis[i].getTicks()[0] - YAxis[i].getTicks()[1]); step = abs(yAxis[i].getTicks()[0] - yAxis[i].getTicks()[1]);
} else { } else {
// only one tick, set arbitrary number of digits // only one tick, set arbitrary number of digits
step = max / 1000; step = max / 1000;
} }
int significantDigits = floor(log10(max)) - floor(log10(step)) + 1; int significantDigits = floor(log10(max)) - floor(log10(step)) + 1;
for(unsigned int j = 0; j < YAxis[i].getTicks().size(); j++) { for(unsigned int j = 0; j < yAxis[i].getTicks().size(); j++) {
auto yCoord = YAxis[i].transform(YAxis[i].getTicks()[j], w.height() - xAxisSpace, plotAreaTop); auto yCoord = yAxis[i].transform(yAxis[i].getTicks()[j], w.height() - xAxisSpace, plotAreaTop);
p.setPen(QPen(pref.Graphs.Color.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
// draw tickmark on axis // draw tickmark on axis
auto tickStart = i == 0 ? plotAreaLeft : plotAreaLeft + plotAreaWidth; auto tickStart = i == 0 ? plotAreaLeft : plotAreaLeft + plotAreaWidth;
@ -386,10 +386,10 @@ void TraceXYPlot::draw(QPainter &p)
QString unit = ""; QString unit = "";
QString prefix = " "; QString prefix = " ";
if(pref.Graphs.showUnits) { if(pref.Graphs.showUnits) {
unit = YAxis[i].Unit(); unit = yAxis[i].Unit();
prefix = YAxis[i].Prefixes(); prefix = yAxis[i].Prefixes();
} }
auto tickValue = Unit::ToString(YAxis[i].getTicks()[j], unit, prefix, significantDigits); auto tickValue = Unit::ToString(yAxis[i].getTicks()[j], unit, prefix, significantDigits);
if(i == 0) { if(i == 0) {
p.drawText(QRectF(0, yCoord - AxisLabelSize/2 - 2, tickStart + 2 * tickLen, AxisLabelSize), Qt::AlignRight, tickValue); p.drawText(QRectF(0, yCoord - AxisLabelSize/2 - 2, tickStart + 2 * tickLen, AxisLabelSize), Qt::AlignRight, tickValue);
} else { } else {
@ -406,8 +406,8 @@ void TraceXYPlot::draw(QPainter &p)
if (pref.Graphs.Color.Ticks.Background.enabled) { if (pref.Graphs.Color.Ticks.Background.enabled) {
if (j%2) if (j%2)
{ {
int yCoordTop = YAxis[i].transform(YAxis[i].getTicks()[j], plotAreaTop, w.height() - xAxisSpace); int yCoordTop = yAxis[i].transform(yAxis[i].getTicks()[j], plotAreaTop, w.height() - xAxisSpace);
int yCoordBot = YAxis[i].transform(YAxis[i].getTicks()[j-1], plotAreaTop, w.height() - xAxisSpace); int yCoordBot = yAxis[i].transform(yAxis[i].getTicks()[j-1], plotAreaTop, w.height() - xAxisSpace);
if(yCoordTop > yCoordBot) { if(yCoordTop > yCoordBot) {
auto buf = yCoordBot; auto buf = yCoordBot;
yCoordBot = yCoordTop; yCoordBot = yCoordTop;
@ -441,8 +441,8 @@ void TraceXYPlot::draw(QPainter &p)
p.setPen(pen); p.setPen(pen);
auto nPoints = t->size(); auto nPoints = t->size();
for(unsigned int j=1;j<nPoints;j++) { for(unsigned int j=1;j<nPoints;j++) {
auto last = traceToCoordinate(t, j-1, YAxis[i]); auto last = traceToCoordinate(t, j-1, yAxis[i]);
auto now = traceToCoordinate(t, j, YAxis[i]); auto now = traceToCoordinate(t, j, yAxis[i]);
if(isnan(last.y()) || isnan(now.y()) || isinf(last.y()) || isinf(now.y())) { if(isnan(last.y()) || isnan(now.y()) || isinf(last.y()) || isinf(now.y())) {
continue; continue;
@ -463,7 +463,7 @@ void TraceXYPlot::draw(QPainter &p)
auto markers = t->getMarkers(); auto markers = t->getMarkers();
for(auto m : markers) { for(auto m : markers) {
double xPosition = m->getPosition(); double xPosition = m->getPosition();
if (xPosition < XAxis.getRangeMin() || xPosition > XAxis.getRangeMax()) { if (xPosition < xAxis.getRangeMin() || xPosition > xAxis.getRangeMax()) {
// marker not in graph range // marker not in graph range
continue; continue;
} }
@ -476,12 +476,12 @@ void TraceXYPlot::draw(QPainter &p)
QPointF markerPoint; QPointF markerPoint;
if(xPosition < t->sample(index).x && index > 0) { if(xPosition < t->sample(index).x && index > 0) {
// marker is not located exactly at this point, interpolate display location // marker is not located exactly at this point, interpolate display location
QPointF l0 = traceToCoordinate(t, index - 1, YAxis[i]); QPointF l0 = traceToCoordinate(t, index - 1, yAxis[i]);
QPointF l1 = traceToCoordinate(t, index, YAxis[i]); QPointF l1 = traceToCoordinate(t, index, yAxis[i]);
auto t0 = (xPosition - t->sample(index - 1).x) / (t->sample(index).x - t->sample(index - 1).x); auto t0 = (xPosition - t->sample(index - 1).x) / (t->sample(index).x - t->sample(index - 1).x);
markerPoint = l0 + (l1 - l0) * t0; markerPoint = l0 + (l1 - l0) * t0;
} else { } else {
markerPoint = traceToCoordinate(t, t->index(xPosition), YAxis[i]); markerPoint = traceToCoordinate(t, t->index(xPosition), yAxis[i]);
} }
auto point = plotValueToPixel(markerPoint, i); auto point = plotValueToPixel(markerPoint, i);
if(!plotRect.contains(point)) { if(!plotRect.contains(point)) {
@ -497,19 +497,19 @@ void TraceXYPlot::draw(QPainter &p)
p.setClipping(false); p.setClipping(false);
} }
if(XAxis.getTicks().size() >= 1) { if(xAxis.getTicks().size() >= 1) {
// draw X ticks // draw X ticks
int significantDigits; int significantDigits;
bool displayFullFreq; bool displayFullFreq;
if(XAxis.getLog()) { if(xAxis.getLog()) {
significantDigits = 5; significantDigits = 5;
displayFullFreq = true; displayFullFreq = true;
} else { } else {
// this only works for evenly distributed ticks: // this only works for evenly distributed ticks:
auto max = qMax(abs(XAxis.getTicks().front()), abs(XAxis.getTicks().back())); auto max = qMax(abs(xAxis.getTicks().front()), abs(xAxis.getTicks().back()));
double step; double step;
if(XAxis.getTicks().size() >= 2) { if(xAxis.getTicks().size() >= 2) {
step = abs(XAxis.getTicks()[0] - XAxis.getTicks()[1]); step = abs(xAxis.getTicks()[0] - xAxis.getTicks()[1]);
} else { } else {
// only one tick, set arbitrary number of digits // only one tick, set arbitrary number of digits
step = max / 1000; step = max / 1000;
@ -521,11 +521,11 @@ void TraceXYPlot::draw(QPainter &p)
QString prefixes = "fpnum kMG"; QString prefixes = "fpnum kMG";
QString unit = ""; QString unit = "";
if(pref.Graphs.showUnits) { if(pref.Graphs.showUnits) {
unit = XAxis.Unit(); unit = xAxis.Unit();
} }
QString commonPrefix = QString(); QString commonPrefix = QString();
if(!displayFullFreq) { if(!displayFullFreq) {
auto fullFreq = Unit::ToString(XAxis.getTicks().front(), unit, prefixes, significantDigits); auto fullFreq = Unit::ToString(xAxis.getTicks().front(), unit, prefixes, significantDigits);
commonPrefix = fullFreq.at(fullFreq.size() - 1); commonPrefix = fullFreq.at(fullFreq.size() - 1);
auto front = fullFreq; auto front = fullFreq;
front.truncate(fullFreq.size() - displayLastDigits - unit.length()); front.truncate(fullFreq.size() - displayLastDigits - unit.length());
@ -540,8 +540,8 @@ void TraceXYPlot::draw(QPainter &p)
} }
int lastTickLabelEnd = 0; int lastTickLabelEnd = 0;
for(auto t : XAxis.getTicks()) { for(auto t : xAxis.getTicks()) {
auto xCoord = XAxis.transform(t, plotAreaLeft, plotAreaLeft + plotAreaWidth); auto xCoord = xAxis.transform(t, plotAreaLeft, plotAreaLeft + plotAreaWidth);
p.setPen(QPen(pref.Graphs.Color.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
p.drawLine(xCoord, plotAreaBottom, xCoord, plotAreaBottom + 2); p.drawLine(xCoord, plotAreaBottom, xCoord, plotAreaBottom + 2);
if(xCoord != plotAreaLeft && xCoord != plotAreaLeft + plotAreaWidth) { if(xCoord != plotAreaLeft && xCoord != plotAreaLeft + plotAreaWidth) {
@ -579,8 +579,8 @@ void TraceXYPlot::draw(QPainter &p)
p.setOpacity(0.5); p.setOpacity(0.5);
p.setBrush(Qt::white); p.setBrush(Qt::white);
p.setPen(Qt::white); p.setPen(Qt::white);
if((YAxis[0].getType() == YAxis::Type::Disabled || !supported(dropTrace, YAxis[0].getType())) if((yAxis[0].getType() == YAxis::Type::Disabled || !supported(dropTrace, yAxis[0].getType()))
|| (YAxis[1].getType() == YAxis::Type::Disabled || !supported(dropTrace, YAxis[1].getType()))) { || (yAxis[1].getType() == YAxis::Type::Disabled || !supported(dropTrace, yAxis[1].getType()))) {
// only one axis enabled, show drop area over whole plot // only one axis enabled, show drop area over whole plot
p.drawRect(plotRect); p.drawRect(plotRect);
auto font = p.font(); auto font = p.font();
@ -637,7 +637,7 @@ void TraceXYPlot::updateAxisTicks()
// this trace is currently displayed // this trace is currently displayed
double trace_min = trace->minX(); double trace_min = trace->minX();
double trace_max = trace->maxX(); double trace_max = trace->maxX();
if(XAxis.getType() == XAxis::Type::Distance) { if(xAxis.getType() == XAxis::Type::Distance) {
trace_min = trace->timeToDistance(trace_min); trace_min = trace->timeToDistance(trace_min);
trace_max = trace->timeToDistance(trace_max); trace_max = trace->timeToDistance(trace_max);
} }
@ -651,12 +651,12 @@ void TraceXYPlot::updateAxisTicks()
} }
} }
if(min < max) { if(min < max) {
XAxis.set(XAxis.getType(), XAxis.getLog(), true, min, max, 0); xAxis.set(xAxis.getType(), xAxis.getLog(), true, min, max, 0);
} }
} }
for(int i=0;i<2;i++) { for(int i=0;i<2;i++) {
if(YAxis[i].getAutorange()) { if(yAxis[i].getAutorange()) {
// automatic mode, figure out limits // automatic mode, figure out limits
double max = std::numeric_limits<double>::lowest(); double max = std::numeric_limits<double>::lowest();
double min = std::numeric_limits<double>::max(); double min = std::numeric_limits<double>::max();
@ -666,9 +666,9 @@ void TraceXYPlot::updateAxisTicks()
} }
unsigned int samples = t->size(); unsigned int samples = t->size();
for(unsigned int j=0;j<samples;j++) { for(unsigned int j=0;j<samples;j++) {
auto point = traceToCoordinate(t, j, YAxis[i]); auto point = traceToCoordinate(t, j, yAxis[i]);
if(point.x() < XAxis.getRangeMin() || point.x() > XAxis.getRangeMax()) { if(point.x() < xAxis.getRangeMin() || point.x() > xAxis.getRangeMax()) {
// this point is not in the displayed X range, skip for auto Y range calculation // this point is not in the displayed X range, skip for auto Y range calculation
continue; continue;
} }
@ -704,7 +704,7 @@ void TraceXYPlot::updateAxisTicks()
max = 1.0; max = 1.0;
min = -1.0; min = -1.0;
} }
YAxis[i].set(YAxis[i].getType(), YAxis[i].getLog(), true, min, max, 0); yAxis[i].set(yAxis[i].getType(), yAxis[i].getLog(), true, min, max, 0);
} }
} }
} }
@ -732,7 +732,7 @@ QString TraceXYPlot::AxisModeToName(TraceXYPlot::XAxisMode mode)
void TraceXYPlot::enableTraceAxis(Trace *t, int axis, bool enabled) void TraceXYPlot::enableTraceAxis(Trace *t, int axis, bool enabled)
{ {
if(enabled && !supported(t, YAxis[axis].getType())) { if(enabled && !supported(t, yAxis[axis].getType())) {
// unable to add trace to the requested axis // unable to add trace to the requested axis
return; return;
} }
@ -762,7 +762,7 @@ void TraceXYPlot::enableTraceAxis(Trace *t, int axis, bool enabled)
bool TraceXYPlot::domainMatch(Trace *t) bool TraceXYPlot::domainMatch(Trace *t)
{ {
switch(XAxis.getType()) { switch(xAxis.getType()) {
case XAxis::Type::Frequency: case XAxis::Type::Frequency:
return t->outputType() == Trace::DataType::Frequency; return t->outputType() == Trace::DataType::Frequency;
case XAxis::Type::Distance: case XAxis::Type::Distance:
@ -806,10 +806,10 @@ bool TraceXYPlot::supported(Trace *t, YAxis::Type type)
return true; return true;
} }
QPointF TraceXYPlot::traceToCoordinate(Trace *t, unsigned int sample, class YAxis &yaxis) QPointF TraceXYPlot::traceToCoordinate(Trace *t, unsigned int sample, YAxis &yaxis)
{ {
QPointF ret = QPointF(numeric_limits<double>::quiet_NaN(), numeric_limits<double>::quiet_NaN()); QPointF ret = QPointF(numeric_limits<double>::quiet_NaN(), numeric_limits<double>::quiet_NaN());
ret.setX(XAxis.sampleToCoordinate(t->sample(sample), t, sample)); ret.setX(xAxis.sampleToCoordinate(t->sample(sample), t, sample));
ret.setY(yaxis.sampleToCoordinate(t->sample(sample), t, sample)); ret.setY(yaxis.sampleToCoordinate(t->sample(sample), t, sample));
return ret; return ret;
} }
@ -817,23 +817,23 @@ QPointF TraceXYPlot::traceToCoordinate(Trace *t, unsigned int sample, class YAxi
QPoint TraceXYPlot::plotValueToPixel(QPointF plotValue, int Yaxis) QPoint TraceXYPlot::plotValueToPixel(QPointF plotValue, int Yaxis)
{ {
QPoint p; QPoint p;
p.setX(XAxis.transform(plotValue.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth)); p.setX(xAxis.transform(plotValue.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth));
p.setY(YAxis[Yaxis].transform(plotValue.y(), plotAreaBottom, plotAreaTop)); p.setY(yAxis[Yaxis].transform(plotValue.y(), plotAreaBottom, plotAreaTop));
return p; return p;
} }
QPointF TraceXYPlot::pixelToPlotValue(QPoint pixel, int Yaxis) QPointF TraceXYPlot::pixelToPlotValue(QPoint pixel, int Yaxis)
{ {
QPointF p; QPointF p;
p.setX(XAxis.inverseTransform(pixel.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth)); p.setX(xAxis.inverseTransform(pixel.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth));
p.setY(YAxis[Yaxis].inverseTransform(pixel.y(), plotAreaBottom, plotAreaTop)); p.setY(yAxis[Yaxis].inverseTransform(pixel.y(), plotAreaBottom, plotAreaTop));
return p; return p;
} }
QPoint TraceXYPlot::markerToPixel(Marker *m) QPoint TraceXYPlot::markerToPixel(Marker *m)
{ {
auto t = m->getTrace(); auto t = m->getTrace();
QPointF plotPoint = traceToCoordinate(t, t->index(m->getPosition()), YAxis[0]); QPointF plotPoint = traceToCoordinate(t, t->index(m->getPosition()), yAxis[0]);
return plotValueToPixel(plotPoint, 0); return plotValueToPixel(plotPoint, 0);
} }
@ -848,7 +848,7 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance)
unsigned int closestIndex = 0; unsigned int closestIndex = 0;
auto samples = t->size(); auto samples = t->size();
for(unsigned int i=0;i<samples;i++) { for(unsigned int i=0;i<samples;i++) {
auto point = traceToCoordinate(t, i, YAxis[0]); auto point = traceToCoordinate(t, i, yAxis[0]);
if(isnan(point.x()) || isnan(point.y())) { if(isnan(point.x()) || isnan(point.y())) {
continue; continue;
} }
@ -863,8 +863,8 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance)
} }
closestDistance = sqrt(closestDistance); closestDistance = sqrt(closestDistance);
if(closestIndex > 0) { if(closestIndex > 0) {
auto l1 = plotValueToPixel(traceToCoordinate(t, closestIndex - 1, YAxis[0]), 0); auto l1 = plotValueToPixel(traceToCoordinate(t, closestIndex - 1, yAxis[0]), 0);
auto l2 = plotValueToPixel(traceToCoordinate(t, closestIndex, YAxis[0]), 0); auto l2 = plotValueToPixel(traceToCoordinate(t, closestIndex, yAxis[0]), 0);
double ratio; double ratio;
auto distance = Util::distanceToLine(pixel, l1, l2, nullptr, &ratio); auto distance = Util::distanceToLine(pixel, l1, l2, nullptr, &ratio);
if(distance < closestDistance) { if(distance < closestDistance) {
@ -873,8 +873,8 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance)
} }
} }
if(closestIndex < t->size() - 1) { if(closestIndex < t->size() - 1) {
auto l1 = plotValueToPixel(traceToCoordinate(t, closestIndex, YAxis[0]), 0); auto l1 = plotValueToPixel(traceToCoordinate(t, closestIndex, yAxis[0]), 0);
auto l2 = plotValueToPixel(traceToCoordinate(t, closestIndex + 1, YAxis[0]), 0); auto l2 = plotValueToPixel(traceToCoordinate(t, closestIndex + 1, yAxis[0]), 0);
double ratio; double ratio;
auto distance = Util::distanceToLine(pixel, l1, l2, nullptr, &ratio); auto distance = Util::distanceToLine(pixel, l1, l2, nullptr, &ratio);
if(distance < closestDistance) { if(distance < closestDistance) {
@ -882,7 +882,7 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance)
closestXpos = t->sample(closestIndex).x + (t->sample(closestIndex+1).x - t->sample(closestIndex).x) * ratio; closestXpos = t->sample(closestIndex).x + (t->sample(closestIndex+1).x - t->sample(closestIndex).x) * ratio;
} }
} }
if(XAxis.getType() == XAxis::Type::Distance) { if(xAxis.getType() == XAxis::Type::Distance) {
closestXpos = t->distanceToTime(closestXpos); closestXpos = t->distanceToTime(closestXpos);
} }
if(distance) { if(distance) {
@ -893,7 +893,7 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance)
bool TraceXYPlot::markerVisible(double x) bool TraceXYPlot::markerVisible(double x)
{ {
if(x >= min(XAxis.getRangeMin(), XAxis.getRangeMax()) && x <= max(XAxis.getRangeMax(), XAxis.getRangeMin())) { if(x >= min(xAxis.getRangeMin(), xAxis.getRangeMax()) && x <= max(xAxis.getRangeMax(), xAxis.getRangeMin())) {
return true; return true;
} else { } else {
return false; return false;
@ -914,16 +914,16 @@ void TraceXYPlot::traceDropped(Trace *t, QPoint position)
return; return;
} }
} }
if(YAxis[0].getType() == YAxis::Type::Disabled && YAxis[1].getType() == YAxis::Type::Disabled) { if(yAxis[0].getType() == YAxis::Type::Disabled && yAxis[1].getType() == YAxis::Type::Disabled) {
// no Y axis enabled, unable to drop // no Y axis enabled, unable to drop
return; return;
} }
if(YAxis[0].getType() == YAxis::Type::Disabled) { if(yAxis[0].getType() == YAxis::Type::Disabled) {
// only axis 1 enabled // only axis 1 enabled
enableTraceAxis(t, 1, true); enableTraceAxis(t, 1, true);
return; return;
} }
if(YAxis[1].getType() == YAxis::Type::Disabled) { if(yAxis[1].getType() == YAxis::Type::Disabled) {
// only axis 0 enabled // only axis 0 enabled
enableTraceAxis(t, 0, true); enableTraceAxis(t, 0, true);
return; return;
@ -946,14 +946,14 @@ QString TraceXYPlot::mouseText(QPoint pos)
QPointF coords[2]; QPointF coords[2];
coords[0] = pixelToPlotValue(pos, 0); coords[0] = pixelToPlotValue(pos, 0);
coords[1] = pixelToPlotValue(pos, 1); coords[1] = pixelToPlotValue(pos, 1);
int significantDigits = floor(log10(abs(XAxis.getRangeMax()))) - floor(log10((abs(XAxis.getRangeMax() - XAxis.getRangeMin())) / 1000.0)) + 1; int significantDigits = floor(log10(abs(xAxis.getRangeMax()))) - floor(log10((abs(xAxis.getRangeMax() - xAxis.getRangeMin())) / 1000.0)) + 1;
ret += Unit::ToString(coords[0].x(), XAxis.Unit(), "fpnum kMG", significantDigits) + "\n"; ret += Unit::ToString(coords[0].x(), xAxis.Unit(), "fpnum kMG", significantDigits) + "\n";
for(int i=0;i<2;i++) { for(int i=0;i<2;i++) {
if(YAxis[i].getType() != YAxis::Type::Disabled) { if(yAxis[i].getType() != YAxis::Type::Disabled) {
auto max = qMax(abs(YAxis[i].getRangeMax()), abs(YAxis[i].getRangeMin())); auto max = qMax(abs(yAxis[i].getRangeMax()), abs(yAxis[i].getRangeMin()));
auto step = abs(YAxis[i].getRangeMax() - YAxis[i].getRangeMin()) / 1000.0; auto step = abs(yAxis[i].getRangeMax() - yAxis[i].getRangeMin()) / 1000.0;
significantDigits = floor(log10(max)) - floor(log10(step)) + 1; significantDigits = floor(log10(max)) - floor(log10(step)) + 1;
ret += Unit::ToString(coords[i].y(), YAxis[i].Unit(), YAxis[i].Prefixes(), significantDigits) + "\n"; ret += Unit::ToString(coords[i].y(), yAxis[i].Unit(), yAxis[i].Prefixes(), significantDigits) + "\n";
} }
} }
} }

View File

@ -62,8 +62,8 @@ private:
std::set<Trace*> tracesAxis[2]; std::set<Trace*> tracesAxis[2];
YAxis YAxis[2]; YAxis yAxis[2];
XAxis XAxis; XAxis xAxis;
XAxisMode xAxisMode; XAxisMode xAxisMode;
int plotAreaLeft, plotAreaWidth, plotAreaBottom, plotAreaTop; int plotAreaLeft, plotAreaWidth, plotAreaBottom, plotAreaTop;

View File

@ -63,24 +63,24 @@ WaterfallAxisDialog::WaterfallAxisDialog(TraceWaterfall *plot) :
ui->WmaxSweeps->setEnabled(index == 1); ui->WmaxSweeps->setEnabled(index == 1);
}); });
ui->XType->setCurrentIndex((int) plot->XAxis.getType()); ui->XType->setCurrentIndex((int) plot->xAxis.getType());
ui->Wmin->setPrefixes("pnum kMG"); ui->Wmin->setPrefixes("pnum kMG");
ui->Wmax->setPrefixes("pnum kMG"); ui->Wmax->setPrefixes("pnum kMG");
XAxisTypeChanged((int) plot->XAxis.getType()); XAxisTypeChanged((int) plot->xAxis.getType());
connect(ui->XType, qOverload<int>(&QComboBox::currentIndexChanged), this, &WaterfallAxisDialog::XAxisTypeChanged); connect(ui->XType, qOverload<int>(&QComboBox::currentIndexChanged), this, &WaterfallAxisDialog::XAxisTypeChanged);
// Fill initial values // Fill initial values
ui->Wtype->setCurrentIndex((int) plot->YAxis.getType()); ui->Wtype->setCurrentIndex((int) plot->yAxis.getType());
if(plot->YAxis.getLog()) { if(plot->yAxis.getLog()) {
ui->Wlog->setChecked(true); ui->Wlog->setChecked(true);
} else { } else {
ui->Wlinear->setChecked(true); ui->Wlinear->setChecked(true);
} }
ui->Wauto->setChecked(plot->YAxis.getAutorange()); ui->Wauto->setChecked(plot->yAxis.getAutorange());
ui->Wmin->setValueQuiet(plot->YAxis.getRangeMin()); ui->Wmin->setValueQuiet(plot->yAxis.getRangeMin());
ui->Wmax->setValueQuiet(plot->YAxis.getRangeMax()); ui->Wmax->setValueQuiet(plot->yAxis.getRangeMax());
if(plot->dir == TraceWaterfall::Direction::TopToBottom) { if(plot->dir == TraceWaterfall::Direction::TopToBottom) {
ui->Wdir->setCurrentIndex(0); ui->Wdir->setCurrentIndex(0);
} else { } else {
@ -90,7 +90,7 @@ WaterfallAxisDialog::WaterfallAxisDialog(TraceWaterfall *plot) :
ui->Wmode->setCurrentIndex(plot->keepDataBeyondPlotSize ? 1 : 0); ui->Wmode->setCurrentIndex(plot->keepDataBeyondPlotSize ? 1 : 0);
ui->WmaxSweeps->setValue(plot->maxDataSweeps); ui->WmaxSweeps->setValue(plot->maxDataSweeps);
if(plot->XAxis.getLog()) { if(plot->xAxis.getLog()) {
ui->Xlog->setChecked(true); ui->Xlog->setChecked(true);
} else { } else {
ui->Xlinear->setChecked(true); ui->Xlinear->setChecked(true);
@ -105,8 +105,8 @@ WaterfallAxisDialog::~WaterfallAxisDialog()
void WaterfallAxisDialog::on_buttonBox_accepted() void WaterfallAxisDialog::on_buttonBox_accepted()
{ {
// set plot values to the ones selected in the dialog // set plot values to the ones selected in the dialog
plot->XAxis.set(plot->XAxis.getType(), ui->Xlog->isChecked(), true, plot->XAxis.getRangeMin(), plot->XAxis.getRangeMax(), 0); plot->xAxis.set(plot->xAxis.getType(), ui->Xlog->isChecked(), true, plot->xAxis.getRangeMin(), plot->xAxis.getRangeMax(), 0);
plot->YAxis.set((YAxis::Type) ui->Wtype->currentIndex(), ui->Wlog->isChecked(), ui->Wauto->isChecked(), ui->Wmin->value(), ui->Wmax->value(), 2); plot->yAxis.set((YAxis::Type) ui->Wtype->currentIndex(), ui->Wlog->isChecked(), ui->Wauto->isChecked(), ui->Wmin->value(), ui->Wmax->value(), 2);
if(ui->Wdir->currentIndex() == 0) { if(ui->Wdir->currentIndex() == 0) {
plot->dir = TraceWaterfall::Direction::TopToBottom; plot->dir = TraceWaterfall::Direction::TopToBottom;
} else { } else {

View File

@ -99,7 +99,7 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
ui->Xautomode->setEnabled(checked); ui->Xautomode->setEnabled(checked);
}); });
ui->XType->setCurrentIndex((int) plot->XAxis.getType()); ui->XType->setCurrentIndex((int) plot->xAxis.getType());
ui->Xmin->setPrefixes("pnum kMG"); ui->Xmin->setPrefixes("pnum kMG");
ui->Xmax->setPrefixes("pnum kMG"); ui->Xmax->setPrefixes("pnum kMG");
ui->Xdivs->setPrefixes("pnum kMG"); ui->Xdivs->setPrefixes("pnum kMG");
@ -112,36 +112,36 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
ui->Y2max->setPrefixes("pnum kMG"); ui->Y2max->setPrefixes("pnum kMG");
ui->Y2divs->setPrefixes("pnum kMG"); ui->Y2divs->setPrefixes("pnum kMG");
XAxisTypeChanged((int) plot->XAxis.getType()); XAxisTypeChanged((int) plot->xAxis.getType());
connect(ui->XType, qOverload<int>(&QComboBox::currentIndexChanged), this, &XYplotAxisDialog::XAxisTypeChanged); connect(ui->XType, qOverload<int>(&QComboBox::currentIndexChanged), this, &XYplotAxisDialog::XAxisTypeChanged);
connect(ui->Xlog, &QCheckBox::toggled, [=](bool checked){ connect(ui->Xlog, &QCheckBox::toggled, [=](bool checked){
ui->Xdivs->setEnabled(!checked && !ui->Xauto->isChecked()); ui->Xdivs->setEnabled(!checked && !ui->Xauto->isChecked());
}); });
// Fill initial values // Fill initial values
ui->Y1type->setCurrentIndex((int) plot->YAxis[0].getType()); ui->Y1type->setCurrentIndex((int) plot->yAxis[0].getType());
if(plot->YAxis[0].getLog()) { if(plot->yAxis[0].getLog()) {
ui->Y1log->setChecked(true); ui->Y1log->setChecked(true);
} else { } else {
ui->Y1linear->setChecked(true); ui->Y1linear->setChecked(true);
} }
ui->Y1auto->setChecked(plot->YAxis[0].getAutorange()); ui->Y1auto->setChecked(plot->yAxis[0].getAutorange());
ui->Y1min->setValueQuiet(plot->YAxis[0].getRangeMin()); ui->Y1min->setValueQuiet(plot->yAxis[0].getRangeMin());
ui->Y1max->setValueQuiet(plot->YAxis[0].getRangeMax()); ui->Y1max->setValueQuiet(plot->yAxis[0].getRangeMax());
ui->Y1divs->setValueQuiet(plot->YAxis[0].getRangeDiv()); ui->Y1divs->setValueQuiet(plot->yAxis[0].getRangeDiv());
ui->Y2type->setCurrentIndex((int) plot->YAxis[1].getType()); ui->Y2type->setCurrentIndex((int) plot->yAxis[1].getType());
if(plot->YAxis[1].getLog()) { if(plot->yAxis[1].getLog()) {
ui->Y2log->setChecked(true); ui->Y2log->setChecked(true);
} else { } else {
ui->Y2linear->setChecked(true); ui->Y2linear->setChecked(true);
} }
ui->Y2auto->setChecked(plot->YAxis[1].getAutorange()); ui->Y2auto->setChecked(plot->yAxis[1].getAutorange());
ui->Y2min->setValueQuiet(plot->YAxis[1].getRangeMin()); ui->Y2min->setValueQuiet(plot->yAxis[1].getRangeMin());
ui->Y2max->setValueQuiet(plot->YAxis[1].getRangeMax()); ui->Y2max->setValueQuiet(plot->yAxis[1].getRangeMax());
ui->Y2divs->setValueQuiet(plot->YAxis[1].getRangeDiv()); ui->Y2divs->setValueQuiet(plot->yAxis[1].getRangeDiv());
if(plot->XAxis.getLog()) { if(plot->xAxis.getLog()) {
ui->Xlog->setChecked(true); ui->Xlog->setChecked(true);
} else { } else {
ui->Xlinear->setChecked(true); ui->Xlinear->setChecked(true);
@ -152,9 +152,9 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
} else { } else {
ui->Xautomode->setCurrentIndex(1); ui->Xautomode->setCurrentIndex(1);
} }
ui->Xmin->setValueQuiet(plot->XAxis.getRangeMin()); ui->Xmin->setValueQuiet(plot->xAxis.getRangeMin());
ui->Xmax->setValueQuiet(plot->XAxis.getRangeMax()); ui->Xmax->setValueQuiet(plot->xAxis.getRangeMax());
ui->Xdivs->setValueQuiet(plot->XAxis.getRangeDiv()); ui->Xdivs->setValueQuiet(plot->xAxis.getRangeDiv());
} }
XYplotAxisDialog::~XYplotAxisDialog() XYplotAxisDialog::~XYplotAxisDialog()