Display marker data on graphs if enabled
This commit is contained in:
parent
ee82237993
commit
93f5eba6a8
@ -204,7 +204,7 @@ QString TraceMarker::readableData(Format f)
|
|||||||
if(type != Type::Delta) {
|
if(type != Type::Delta) {
|
||||||
switch(f) {
|
switch(f) {
|
||||||
case Format::dB:
|
case Format::dB:
|
||||||
return Unit::ToString(Unit::dB(data), "dB", " ", 3);
|
return Unit::ToString(Unit::dB(data), "dB", " ", 4);
|
||||||
case Format::RealImag:
|
case Format::RealImag:
|
||||||
return Unit::ToString(data.real(), "", " ", 5) + "+"+Unit::ToString(data.imag(), "", " ", 5)+"j";
|
return Unit::ToString(data.real(), "", " ", 5) + "+"+Unit::ToString(data.imag(), "", " ", 5)+"j";
|
||||||
case Format::Impedance: {
|
case Format::Impedance: {
|
||||||
@ -222,7 +222,7 @@ QString TraceMarker::readableData(Format f)
|
|||||||
}
|
}
|
||||||
switch(f) {
|
switch(f) {
|
||||||
case Format::dB:
|
case Format::dB:
|
||||||
return "Δ:"+Unit::ToString(Unit::dB(data) - Unit::dB(delta->data), "dB", " ", 3);
|
return "Δ:"+Unit::ToString(Unit::dB(data) - Unit::dB(delta->data), "dB", " ", 4);
|
||||||
case Format::RealImag:
|
case Format::RealImag:
|
||||||
return "Δ:"+Unit::ToString(data.real() - delta->data.real(), "", " ", 5) + "+"+Unit::ToString(data.imag() - delta->data.real(), "", " ", 5)+"j";
|
return "Δ:"+Unit::ToString(data.real() - delta->data.real(), "", " ", 5) + "+"+Unit::ToString(data.imag() - delta->data.real(), "", " ", 5)+"j";
|
||||||
case Format::Impedance: {
|
case Format::Impedance: {
|
||||||
@ -246,8 +246,8 @@ QString TraceMarker::readableData(Format f)
|
|||||||
return "TODO";
|
return "TODO";
|
||||||
default:
|
default:
|
||||||
switch(f) {
|
switch(f) {
|
||||||
case Format::dB: return Unit::ToString(Unit::dB(data), "dB", " ", 3);
|
case Format::dB: return Unit::ToString(Unit::dB(data), "dB", " ", 4);
|
||||||
case Format::dBAngle: return Unit::ToString(Unit::dB(data), "dB", " ", 3) + "/"+Unit::ToString(arg(data)*180/M_PI, "°", " ", 3);
|
case Format::dBAngle: return Unit::ToString(Unit::dB(data), "dB", " ", 4) + "/"+Unit::ToString(arg(data)*180/M_PI, "°", " ", 3);
|
||||||
case Format::RealImag: return Unit::ToString(data.real(), "", " ", 5) + "+"+Unit::ToString(data.imag(), "", " ", 5)+"j";
|
case Format::RealImag: return Unit::ToString(data.real(), "", " ", 5) + "+"+Unit::ToString(data.imag(), "", " ", 5)+"j";
|
||||||
case Format::Noise: return Unit::ToString(parentTrace->getNoise(position), "dbm/Hz", " ", 3);
|
case Format::Noise: return Unit::ToString(parentTrace->getNoise(position), "dbm/Hz", " ", 3);
|
||||||
case Format::TOI: {
|
case Format::TOI: {
|
||||||
@ -751,6 +751,11 @@ void TraceMarker::setTableFormat(TraceMarker::Format f)
|
|||||||
emit dataChanged(this);
|
emit dataChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<TraceMarker::Format> TraceMarker::getGraphDisplayFormats() const
|
||||||
|
{
|
||||||
|
return formatGraph;
|
||||||
|
}
|
||||||
|
|
||||||
TraceMarker::Type TraceMarker::getType() const
|
TraceMarker::Type TraceMarker::getType() const
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
|
@ -103,6 +103,8 @@ public:
|
|||||||
unsigned int toHash();
|
unsigned int toHash();
|
||||||
|
|
||||||
|
|
||||||
|
std::set<Format> getGraphDisplayFormats() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPosition(double freq);
|
void setPosition(double freq);
|
||||||
signals:
|
signals:
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include "unit.h"
|
||||||
|
|
||||||
std::set<TracePlot*> TracePlot::plots;
|
std::set<TracePlot*> TracePlot::plots;
|
||||||
|
|
||||||
@ -118,28 +119,63 @@ void TracePlot::paintEvent(QPaintEvent *event)
|
|||||||
p.setBackground(QBrush(pref.General.graphColors.background));
|
p.setBackground(QBrush(pref.General.graphColors.background));
|
||||||
p.fillRect(0, 0, width(), height(), QBrush(pref.General.graphColors.background));
|
p.fillRect(0, 0, width(), height(), QBrush(pref.General.graphColors.background));
|
||||||
|
|
||||||
// show names of active traces
|
// show names of active traces and marker data (if enabled)
|
||||||
QFont font = p.font();
|
bool hasMarkerData = false;
|
||||||
font.setPixelSize(12);
|
int x = 1; // xcoordinate for the next trace name
|
||||||
p.setFont(font);
|
int y = marginTop; // ycoordinate for the next marker data
|
||||||
int x = 1;
|
|
||||||
for(auto t : traces) {
|
for(auto t : traces) {
|
||||||
if(!t.second || !t.first->isVisible()) {
|
if(!t.second || !t.first->isVisible()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto textArea = QRect(x, 0, width() - x, marginTop);
|
auto textArea = QRect(x, 0, width() - x, marginTop);
|
||||||
QRect usedArea;
|
QRect usedArea;
|
||||||
|
QFont font = p.font();
|
||||||
|
font.setPixelSize(12);
|
||||||
|
p.setFont(font);
|
||||||
p.setPen(t.first->color());
|
p.setPen(t.first->color());
|
||||||
p.drawText(textArea, 0, t.first->name() + " ", &usedArea);
|
p.drawText(textArea, 0, t.first->name() + " ", &usedArea);
|
||||||
x += usedArea.width();
|
x += usedArea.width();
|
||||||
if(x >= width()) {
|
|
||||||
// used up all available space
|
auto tmarkers = t.first->getMarkers();
|
||||||
break;
|
|
||||||
|
font.setPixelSize(12);
|
||||||
|
p.setFont(font);
|
||||||
|
for(auto m : tmarkers) {
|
||||||
|
if(!xCoordinateVisible(m->getPosition())) {
|
||||||
|
// marker not visible with current plot settings
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(m->getGraphDisplayFormats().size() == 0) {
|
||||||
|
// this marker has nothing to display
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
hasMarkerData = true;
|
||||||
|
|
||||||
|
auto textArea = QRect(width() - marginRight - marginMarkerData, y, width() - marginRight, y + 100);
|
||||||
|
p.drawText(textArea, 0, "Marker "+QString::number(m->getNumber())+m->getSuffix()+": "+Unit::ToString(m->getPosition(), "", "pnum kMG", 6), &usedArea);
|
||||||
|
y += usedArea.height();
|
||||||
|
|
||||||
|
for(auto f : m->getGraphDisplayFormats()) {
|
||||||
|
auto textArea = QRect(width() - marginRight - marginMarkerData, y, width() - marginRight, y + 100);
|
||||||
|
p.drawText(textArea, 0, m->readableData(f), &usedArea);
|
||||||
|
y += usedArea.height();
|
||||||
|
}
|
||||||
|
// leave one row empty between markers
|
||||||
|
y += usedArea.height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setViewport(marginLeft, marginTop, width() - marginLeft - marginRight, height() - marginTop - marginBottom);
|
unsigned int l = marginLeft;
|
||||||
p.setWindow(0, 0, width() - marginLeft - marginRight, height() - marginTop - marginBottom);
|
unsigned int t = marginTop;
|
||||||
|
unsigned int w = width() - marginLeft - marginRight;
|
||||||
|
unsigned int h = height() - marginTop - marginBottom;
|
||||||
|
|
||||||
|
if(hasMarkerData) {
|
||||||
|
w -= marginMarkerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.setViewport(l, t, w, h);
|
||||||
|
p.setWindow(0, 0, w, h);
|
||||||
|
|
||||||
draw(p);
|
draw(p);
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,15 @@ protected slots:
|
|||||||
void checkIfStillSupported(Trace *t);
|
void checkIfStillSupported(Trace *t);
|
||||||
virtual void markerAdded(TraceMarker *m);
|
virtual void markerAdded(TraceMarker *m);
|
||||||
virtual void markerRemoved(TraceMarker *m);
|
virtual void markerRemoved(TraceMarker *m);
|
||||||
|
virtual bool xCoordinateVisible(double x) = 0;
|
||||||
protected:
|
protected:
|
||||||
static constexpr unsigned int marginTop = 20;
|
static constexpr unsigned int marginTop = 20;
|
||||||
static constexpr unsigned int marginBottom = 0;
|
static constexpr unsigned int marginBottom = 0;
|
||||||
static constexpr unsigned int marginLeft = 0;
|
static constexpr unsigned int marginLeft = 0;
|
||||||
static constexpr unsigned int marginRight = 0;
|
static constexpr unsigned int marginRight = 0;
|
||||||
|
|
||||||
|
static constexpr unsigned int marginMarkerData = 150;
|
||||||
|
|
||||||
double sweep_fmin, sweep_fmax;
|
double sweep_fmin, sweep_fmax;
|
||||||
TraceModel &model;
|
TraceModel &model;
|
||||||
TraceMarker *selectedMarker;
|
TraceMarker *selectedMarker;
|
||||||
|
@ -115,6 +115,20 @@ double TraceSmithChart::nearestTracePoint(Trace *t, QPoint pixel)
|
|||||||
return t->sample(closestIndex).x;
|
return t->sample(closestIndex).x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TraceSmithChart::xCoordinateVisible(double x)
|
||||||
|
{
|
||||||
|
if(limitToSpan) {
|
||||||
|
if(x >= sweep_fmin && x <= sweep_fmax) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// complete traces visible
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TraceSmithChart::draw(QPainter &p) {
|
void TraceSmithChart::draw(QPainter &p) {
|
||||||
auto pref = Preferences::getInstance();
|
auto pref = Preferences::getInstance();
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ protected:
|
|||||||
std::complex<double> pixelToData(QPoint p);
|
std::complex<double> pixelToData(QPoint p);
|
||||||
QPoint markerToPixel(TraceMarker *m) override;
|
QPoint markerToPixel(TraceMarker *m) override;
|
||||||
double nearestTracePoint(Trace *t, QPoint pixel) override;
|
double nearestTracePoint(Trace *t, QPoint pixel) override;
|
||||||
|
virtual bool xCoordinateVisible(double x);
|
||||||
|
|
||||||
//void paintEvent(QPaintEvent *event) override;
|
//void paintEvent(QPaintEvent *event) override;
|
||||||
virtual void updateContextMenu() override;
|
virtual void updateContextMenu() override;
|
||||||
|
@ -930,6 +930,15 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel)
|
|||||||
return closestXpos;
|
return closestXpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TraceXYPlot::xCoordinateVisible(double x)
|
||||||
|
{
|
||||||
|
if(x >= min(XAxis.rangeMin, XAxis.rangeMax) && x <= max(XAxis.rangeMax, XAxis.rangeMin)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TraceXYPlot::traceDropped(Trace *t, QPoint position)
|
void TraceXYPlot::traceDropped(Trace *t, QPoint position)
|
||||||
{
|
{
|
||||||
if(t->outputType() == Trace::DataType::Frequency && XAxis.type != XAxisType::Frequency) {
|
if(t->outputType() == Trace::DataType::Frequency && XAxis.type != XAxisType::Frequency) {
|
||||||
|
@ -77,6 +77,7 @@ private:
|
|||||||
QPointF pixelToPlotValue(QPoint pixel, int YAxis);
|
QPointF pixelToPlotValue(QPoint pixel, int YAxis);
|
||||||
QPoint markerToPixel(TraceMarker *m) override;
|
QPoint markerToPixel(TraceMarker *m) override;
|
||||||
double nearestTracePoint(Trace *t, QPoint pixel) override;
|
double nearestTracePoint(Trace *t, QPoint pixel) override;
|
||||||
|
virtual bool xCoordinateVisible(double x);
|
||||||
void traceDropped(Trace *t, QPoint position) override;
|
void traceDropped(Trace *t, QPoint position) override;
|
||||||
QString mouseText(QPoint pos) override;
|
QString mouseText(QPoint pos) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user