mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-09 08:23:41 +00:00
smithchart data next to cursor
This commit is contained in:
parent
93bf7255c3
commit
4093578b62
4 changed files with 63 additions and 1 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <QDebug>
|
||||
#include "preferences.h"
|
||||
#include "ui_smithchartdialog.h"
|
||||
#include "unit.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -46,6 +47,12 @@ QPoint TraceSmithChart::dataToPixel(Trace::Data d)
|
|||
return transform.map(QPoint(d.S.real() * smithCoordMax, -d.S.imag() * smithCoordMax));
|
||||
}
|
||||
|
||||
std::complex<double> TraceSmithChart::pixelToData(QPoint p)
|
||||
{
|
||||
auto data = transform.inverted().map(QPointF(p));
|
||||
return complex<double>(data.x() / smithCoordMax, -data.y() / smithCoordMax);
|
||||
}
|
||||
|
||||
QPoint TraceSmithChart::markerToPixel(TraceMarker *m)
|
||||
{
|
||||
QPoint ret = QPoint();
|
||||
|
|
@ -194,6 +201,22 @@ void TraceSmithChart::traceDropped(Trace *t, QPoint position)
|
|||
}
|
||||
}
|
||||
|
||||
QString TraceSmithChart::mouseText(QPoint pos)
|
||||
{
|
||||
auto data = pixelToData(pos);
|
||||
if(abs(data) <= 1.0) {
|
||||
data = 50.0 * (1-.0 + data) / (1.0 - data);
|
||||
auto ret = Unit::ToString(data.real(), "", " ", 3);
|
||||
if(data.imag() >= 0) {
|
||||
ret += "+";
|
||||
}
|
||||
ret += Unit::ToString(data.imag(), "j", " ", 3);
|
||||
return ret;
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
//void TraceSmithChart::paintEvent(QPaintEvent * /* the event */)
|
||||
//{
|
||||
// auto pref = Preferences::getInstance();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue