Shortcuts for adding/removing plots
This commit is contained in:
parent
59f3057dd9
commit
ccb71f9650
@ -214,6 +214,14 @@ void TileWidget::setPlot(TracePlot *plot)
|
||||
}
|
||||
}
|
||||
|
||||
void TileWidget::removePlot()
|
||||
{
|
||||
if(hasContent) {
|
||||
content->setParentTile(nullptr);
|
||||
removeContent();
|
||||
}
|
||||
}
|
||||
|
||||
TileWidget::TileWidget(TraceModel &model, TileWidget &parent)
|
||||
: TileWidget(model)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ public slots:
|
||||
void splitHorizontally(bool moveContentToSecondChild = false);
|
||||
void closeTile();
|
||||
void setPlot(TracePlot *plot);
|
||||
void removePlot();
|
||||
|
||||
private slots:
|
||||
void on_bSmithchart_clicked();
|
||||
|
@ -659,19 +659,19 @@ void EyeDiagramPlot::draw(QPainter &p)
|
||||
} else {
|
||||
qDebug() << "Empty eye data, displaydata:" << displayData;
|
||||
}
|
||||
if(dropPending) {
|
||||
p.setOpacity(0.5);
|
||||
p.setBrush(Qt::white);
|
||||
p.setPen(Qt::white);
|
||||
if(dropPending && supported(dropTrace)) {
|
||||
p.setOpacity(dropOpacity);
|
||||
p.setBrush(dropBackgroundColor);
|
||||
p.setPen(dropForegroundColor);
|
||||
// show drop area over whole plot
|
||||
p.drawRect(plotRect);
|
||||
p.drawRect(getDropRect());
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
p.setOpacity(1.0);
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor);
|
||||
auto text = "Drop here to add\n" + dropTrace->name() + "\nto eye diagram";
|
||||
p.drawText(plotRect, Qt::AlignCenter, text);
|
||||
p.drawText(getDropRect(), Qt::AlignCenter, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include "preferences.h"
|
||||
#include "Util/util.h"
|
||||
#include "CustomWidgets/tilewidget.h"
|
||||
#include "tracexyplot.h"
|
||||
#include "tracesmithchart.h"
|
||||
#include "eyediagramplot.h"
|
||||
#include "tracewaterfall.h"
|
||||
#include "tracepolarchart.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
@ -101,6 +106,41 @@ void TracePlot::updateSpan(double min, double max)
|
||||
triggerReplot();
|
||||
}
|
||||
|
||||
QString TracePlot::TypeToString(Type t)
|
||||
{
|
||||
switch(t) {
|
||||
case Type::EyeDiagram: return "Eye Diagram";
|
||||
case Type::PolarChart: return "Polar Chart";
|
||||
case Type::SmithChart: return "Smith Chart";
|
||||
case Type::Waterfall: return "Waterfall";
|
||||
case Type::XYPlot: return "XY Plot";
|
||||
}
|
||||
}
|
||||
|
||||
TracePlot::Type TracePlot::TypeFromString(QString s)
|
||||
{
|
||||
for(unsigned int i=0;i<=(int) Type::EyeDiagram;i++) {
|
||||
if(TypeToString((Type) i) == s) {
|
||||
return (Type) i;
|
||||
}
|
||||
}
|
||||
// use default
|
||||
return Type::XYPlot;
|
||||
}
|
||||
|
||||
TracePlot *TracePlot::createFromType(TraceModel &model, Type t)
|
||||
{
|
||||
switch(t) {
|
||||
case Type::EyeDiagram: return new EyeDiagramPlot(model);
|
||||
case Type::PolarChart: return new TracePolarChart(model);
|
||||
case Type::SmithChart: return new TraceSmithChart(model);
|
||||
case Type::Waterfall: return new TraceWaterfall(model);
|
||||
case Type::XYPlot: return new TraceXYPlot(model);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TracePlot::initializeTraceInfo()
|
||||
{
|
||||
// Populate already present traces
|
||||
@ -295,6 +335,46 @@ void TracePlot::paintEvent(QPaintEvent *event)
|
||||
p.setWindow(0, 0, w, h);
|
||||
|
||||
draw(p);
|
||||
|
||||
if(dropPending) {
|
||||
p.setOpacity(dropOpacity);
|
||||
p.setBrush(dropBackgroundColor);
|
||||
p.setPen(dropForegroundColor);
|
||||
|
||||
auto dropRect = getDropRect();
|
||||
|
||||
p.fillRect(0, 0, dropRect.left(), h-1, p.brush());
|
||||
p.fillRect(dropRect.left(), 0, dropRect.width()-1, dropRect.top(), p.brush());
|
||||
p.fillRect(dropRect.left(), dropRect.bottom(), dropRect.width()-1, h-1, p.brush());
|
||||
p.fillRect(dropRect.right(), 0, w-1, h-1, p.brush());
|
||||
|
||||
p.setOpacity(1.0);
|
||||
p.drawLine(QPoint(0, 0), dropRect.topLeft());
|
||||
p.drawLine(QPoint(0, h-1), dropRect.bottomLeft());
|
||||
p.drawLine(QPoint(w-1, 0), dropRect.topRight());
|
||||
p.drawLine(QPoint(w-1, h-1), dropRect.bottomRight());
|
||||
p.drawLine(QPoint(0, 0), QPoint(0, h-1));
|
||||
p.drawLine(QPoint(0, h-1), QPoint(w-1, h-1));
|
||||
p.drawLine(QPoint(w-1, h-1), QPoint(w-1, 0));
|
||||
p.drawLine(QPoint(w-1, 0), QPoint(0, 0));
|
||||
p.drawLine(dropRect.topLeft(), dropRect.topRight());
|
||||
p.drawLine(dropRect.topRight(), dropRect.bottomRight());
|
||||
p.drawLine(dropRect.bottomRight(), dropRect.bottomLeft());
|
||||
p.drawLine(dropRect.bottomLeft(), dropRect.topLeft());
|
||||
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
p.setPen(dropSection == DropSection::Above ? dropHighlightColor : dropForegroundColor);
|
||||
p.drawText(QRect(0, 0, w, dropRect.top()), Qt::AlignCenter, "Insert above");
|
||||
p.setPen(dropSection == DropSection::Below ? dropHighlightColor : dropForegroundColor);
|
||||
p.drawText(QRect(0, dropRect.bottom(), w, dropRect.top()), Qt::AlignCenter, "Insert below");
|
||||
p.setPen(dropSection == DropSection::ToTheLeft ? dropHighlightColor : dropForegroundColor);
|
||||
p.drawText(QRect(0, 0, dropRect.left(), h), Qt::AlignCenter, "Insert to\nthe left");
|
||||
p.setPen(dropSection == DropSection::ToTheRight ? dropHighlightColor : dropForegroundColor);
|
||||
p.drawText(QRect(dropRect.right(), 0, dropRect.left(), h), Qt::AlignCenter, "Insert to\nthe right");
|
||||
}
|
||||
|
||||
replotTimer.start(MaxUpdateInterval);
|
||||
}
|
||||
|
||||
@ -330,6 +410,15 @@ void TracePlot::finishContextMenu()
|
||||
contextmenu->addMenu(add);
|
||||
}
|
||||
|
||||
auto removeTile = new QAction("Remove Tile", contextmenu);
|
||||
contextmenu->addAction(removeTile);
|
||||
connect(removeTile, &QAction::triggered, [=]() {
|
||||
markedForDeletion = true;
|
||||
QTimer::singleShot(0, [=](){
|
||||
parentTile->closeTile();
|
||||
});
|
||||
});
|
||||
|
||||
auto close = new QAction("Close", contextmenu);
|
||||
contextmenu->addAction(close);
|
||||
connect(close, &QAction::triggered, [=]() {
|
||||
@ -511,19 +600,91 @@ void TracePlot::dragEnterEvent(QDragEnterEvent *event)
|
||||
quintptr dropPtr;
|
||||
stream >> dropPtr;
|
||||
auto trace = (Trace*) dropPtr;
|
||||
if(dropSupported(trace)) {
|
||||
// if(dropSupported(trace)) {
|
||||
event->acceptProposedAction();
|
||||
dropPending = true;
|
||||
dropTrace = trace;
|
||||
}
|
||||
// }
|
||||
}
|
||||
triggerReplot();
|
||||
}
|
||||
|
||||
void TracePlot::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
if(!dropPending) {
|
||||
return;
|
||||
}
|
||||
auto dropRect = getDropRect();
|
||||
auto pos = event->position().toPoint() - QPoint(marginLeft, marginTop);
|
||||
if(dropRect.contains(pos)) {
|
||||
dropSection = DropSection::OnPlot;
|
||||
} else {
|
||||
// transform to relative coordinates from 0 to 1
|
||||
auto x = (double) pos.x() / (width() - marginLeft - marginRight);
|
||||
auto y = (double) pos.y() / (height() - marginTop - marginBottom);
|
||||
qDebug() << "x:" << x << "y:" << y;
|
||||
if(y < 0.5) {
|
||||
if(x < y) {
|
||||
dropSection = DropSection::ToTheLeft;
|
||||
} else if(x > (1.0 - y)) {
|
||||
dropSection = DropSection::ToTheRight;
|
||||
} else {
|
||||
dropSection = DropSection::Above;
|
||||
}
|
||||
} else {
|
||||
if(x < (1.0 - y)) {
|
||||
dropSection = DropSection::ToTheLeft;
|
||||
} else if(x > y) {
|
||||
dropSection = DropSection::ToTheRight;
|
||||
} else {
|
||||
dropSection = DropSection::Below;
|
||||
}
|
||||
}
|
||||
}
|
||||
dropPosition = pos;
|
||||
replot();
|
||||
}
|
||||
|
||||
void TracePlot::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if(dropTrace) {
|
||||
traceDropped(dropTrace, event->position().toPoint() - - QPoint(marginLeft, marginTop));
|
||||
if(dropSection == DropSection::OnPlot) {
|
||||
traceDropped(dropTrace, event->position().toPoint() - - QPoint(marginLeft, marginTop));
|
||||
} else {
|
||||
TileWidget *newTile = nullptr;
|
||||
// parentTile will be modified by the split, save here
|
||||
TileWidget *oldParent = parentTile;
|
||||
switch(dropSection) {
|
||||
case DropSection::Above:
|
||||
parentTile->splitVertically(true);
|
||||
newTile = oldParent->Child1();
|
||||
break;
|
||||
case DropSection::Below:
|
||||
parentTile->splitVertically(false);
|
||||
newTile = oldParent->Child2();
|
||||
break;
|
||||
case DropSection::ToTheLeft:
|
||||
parentTile->splitHorizontally(true);
|
||||
newTile = oldParent->Child1();
|
||||
break;
|
||||
case DropSection::ToTheRight:
|
||||
parentTile->splitHorizontally(false);
|
||||
newTile = oldParent->Child2();
|
||||
break;
|
||||
case DropSection::OnPlot:
|
||||
// already handled above
|
||||
break;
|
||||
}
|
||||
TracePlot *graph = createDefaultPlotForTrace(model, dropTrace);
|
||||
if(!graph->configureForTrace(dropTrace)) {
|
||||
// can't be used for the configuration the trace is in, fall back to XY-Plot
|
||||
delete graph;
|
||||
graph = new TraceXYPlot(model);
|
||||
graph->configureForTrace(dropTrace);
|
||||
}
|
||||
newTile->setPlot(graph);
|
||||
graph->enableTrace(dropTrace, true);
|
||||
}
|
||||
}
|
||||
dropPending = false;
|
||||
dropTrace = nullptr;
|
||||
@ -547,11 +708,32 @@ void TracePlot::traceDropped(Trace *t, QPoint position)
|
||||
}
|
||||
}
|
||||
|
||||
QRect TracePlot::getDropRect()
|
||||
{
|
||||
constexpr double dropBorders = 0.2;
|
||||
auto w = width() - marginLeft - marginRight;
|
||||
auto h = height() - marginTop - marginBottom;
|
||||
return QRect(QPoint(w*dropBorders, h*dropBorders), QSize(w*(1.0-2*dropBorders), h*(1.0-2*dropBorders)));
|
||||
}
|
||||
|
||||
std::set<TracePlot *> TracePlot::getPlots()
|
||||
{
|
||||
return plots;
|
||||
}
|
||||
|
||||
TracePlot *TracePlot::createDefaultPlotForTrace(TraceModel &model, Trace *t)
|
||||
{
|
||||
auto &p = Preferences::getInstance();
|
||||
|
||||
TracePlot *ret = nullptr;
|
||||
if(t->isReflection()) {
|
||||
ret = createFromType(model, TypeFromString(p.Graphs.defaultGraphs.reflection));
|
||||
} else {
|
||||
ret = createFromType(model, TypeFromString(p.Graphs.defaultGraphs.transmission));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TracePlot::newTraceAvailable(Trace *t)
|
||||
{
|
||||
traces[t] = false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef TRACEPLOT_H
|
||||
#ifndef TRACEPLOT_H
|
||||
#define TRACEPLOT_H
|
||||
|
||||
#include "tracemodel.h"
|
||||
@ -33,6 +33,10 @@ public:
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
virtual void updateSpan(double min, double max);
|
||||
virtual Type getType() = 0;
|
||||
static QString TypeToString(Type t);
|
||||
static Type TypeFromString(QString s);
|
||||
static TracePlot* createFromType(TraceModel &model, Type t);
|
||||
static TracePlot *createDefaultPlotForTrace(TraceModel &model, Trace *t);
|
||||
|
||||
static std::set<TracePlot *> getPlots();
|
||||
|
||||
@ -92,10 +96,12 @@ protected:
|
||||
// handle trace drops
|
||||
virtual bool dropSupported(Trace *t);
|
||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||
virtual void traceDropped(Trace *t, QPoint position);
|
||||
virtual QString mouseText(QPoint pos) {Q_UNUSED(pos) return QString();}
|
||||
QRect getDropRect();
|
||||
|
||||
protected slots:
|
||||
void newTraceAvailable(Trace *t);
|
||||
@ -110,6 +116,11 @@ protected:
|
||||
static constexpr unsigned int marginLeft = 0;
|
||||
static constexpr unsigned int marginRight = 0;
|
||||
|
||||
static constexpr double dropOpacity = 0.9;
|
||||
static constexpr auto dropBackgroundColor = Qt::darkGray;
|
||||
static constexpr auto dropForegroundColor = Qt::white;
|
||||
static constexpr auto dropHighlightColor = Qt::red;
|
||||
|
||||
double sweep_fmin, sweep_fmax;
|
||||
double xSweep; // current position in the sweep (NaN if no live traces are active on the plot)
|
||||
TraceModel &model;
|
||||
@ -123,6 +134,15 @@ protected:
|
||||
|
||||
bool dropPending;
|
||||
QPoint dropPosition;
|
||||
enum class DropSection {
|
||||
Above,
|
||||
Below,
|
||||
ToTheLeft,
|
||||
ToTheRight,
|
||||
OnPlot,
|
||||
};
|
||||
DropSection dropSection;
|
||||
|
||||
Trace *dropTrace;
|
||||
|
||||
QLabel *cursorLabel;
|
||||
|
@ -207,22 +207,20 @@ void TracePolarChart::draw(QPainter &p) {
|
||||
}
|
||||
}
|
||||
|
||||
if(dropPending) {
|
||||
if(dropPending && supported(dropTrace)) {
|
||||
// adjust coords due to shifted restore
|
||||
p.setOpacity(0.5);
|
||||
p.setBrush(Qt::white);
|
||||
p.setPen(Qt::white);
|
||||
p.drawEllipse(-polarCoordMax, -polarCoordMax, 2*polarCoordMax, 2*polarCoordMax);
|
||||
p.setOpacity(dropOpacity);
|
||||
p.setBrush(dropBackgroundColor);
|
||||
p.setPen(dropForegroundColor);
|
||||
p.drawRect(getDropRect());
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
p.setOpacity(1.0);
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor);
|
||||
auto text = "Drop here to add\n" + dropTrace->name() + "\nto polar chart";
|
||||
p.drawText(p.window(), Qt::AlignCenter, text);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool TracePolarChart::dropSupported(Trace *t)
|
||||
|
@ -380,20 +380,19 @@ void TraceSmithChart::draw(QPainter &p) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dropPending) {
|
||||
if(dropPending && supported(dropTrace)) {
|
||||
// adjust coords due to shifted restore
|
||||
p.setOpacity(0.5);
|
||||
p.setBrush(Qt::white);
|
||||
p.setPen(Qt::white);
|
||||
p.drawEllipse(-polarCoordMax, -polarCoordMax, 2*polarCoordMax, 2*polarCoordMax);
|
||||
p.setOpacity(dropOpacity);
|
||||
p.setBrush(dropBackgroundColor);
|
||||
p.setPen(dropForegroundColor);
|
||||
p.drawRect(getDropRect());
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
p.setOpacity(1.0);
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor);
|
||||
auto text = "Drop here to add\n" + dropTrace->name() + "\nto Smith chart";
|
||||
p.drawText(p.window(), Qt::AlignCenter, text);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,18 +470,18 @@ void TraceWaterfall::draw(QPainter &p)
|
||||
}
|
||||
|
||||
if(dropPending) {
|
||||
p.setOpacity(0.5);
|
||||
p.setBrush(Qt::white);
|
||||
p.setPen(Qt::white);
|
||||
p.setOpacity(dropOpacity);
|
||||
p.setBrush(dropBackgroundColor);
|
||||
p.setPen(dropForegroundColor);
|
||||
// show drop area over whole plot
|
||||
p.drawRect(plotRect);
|
||||
p.drawRect(getDropRect());
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
p.setOpacity(1.0);
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor);
|
||||
auto text = "Drop here to add\n" + dropTrace->name() + "\nto waterfall plot";
|
||||
p.drawText(plotRect, Qt::AlignCenter, text);
|
||||
p.drawText(getDropRect(), Qt::AlignCenter, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QTableView>
|
||||
|
||||
|
||||
TraceWidget::TraceWidget(TraceModel &model, QWidget *parent) :
|
||||
@ -30,6 +31,11 @@ TraceWidget::TraceWidget(TraceModel &model, QWidget *parent) :
|
||||
ui->view->viewport()->installEventFilter(this);
|
||||
connect(ui->bImport, &QPushButton::clicked, this, &TraceWidget::importDialog);
|
||||
connect(ui->bExport, &QPushButton::clicked, this, &TraceWidget::exportDialog);
|
||||
connect(ui->view->selectionModel(), &QItemSelectionModel::currentRowChanged, this, [=](const QModelIndex ¤t, const QModelIndex &previous){
|
||||
Q_UNUSED(previous)
|
||||
ui->edit->setEnabled(current.isValid());
|
||||
ui->remove->setEnabled(current.isValid());
|
||||
});
|
||||
installEventFilter(this);
|
||||
createCount = 0;
|
||||
SetupSCPI();
|
||||
@ -65,6 +71,8 @@ bool TraceWidget::eventFilter(QObject *, QEvent *event)
|
||||
int key = static_cast<QKeyEvent *>(event)->key();
|
||||
if(key == Qt::Key_Escape) {
|
||||
ui->view->clearSelection();
|
||||
ui->edit->setEnabled(false);
|
||||
ui->remove->setEnabled(false);
|
||||
return true;
|
||||
} else if(key == Qt::Key_Delete) {
|
||||
model.removeTrace(ui->view->currentIndex().row());
|
||||
|
@ -123,6 +123,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -183,6 +186,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="edit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -32,7 +32,6 @@ TraceXYPlot::TraceXYPlot(TraceModel &model, QWidget *parent)
|
||||
setXAxis(XAxis::Type::Frequency, XAxisMode::UseSpan, false, 0, 6000000000, 600000000);
|
||||
initializeTraceInfo();
|
||||
}
|
||||
|
||||
TraceXYPlot::~TraceXYPlot()
|
||||
{
|
||||
for(auto l : constantLines) {
|
||||
@ -782,40 +781,66 @@ void TraceXYPlot::draw(QPainter &p)
|
||||
}
|
||||
|
||||
if(dropPending) {
|
||||
p.setOpacity(0.5);
|
||||
p.setBrush(Qt::white);
|
||||
p.setPen(Qt::white);
|
||||
p.setOpacity(dropOpacity);
|
||||
p.setBrush(dropBackgroundColor);
|
||||
p.setPen(dropForegroundColor);
|
||||
|
||||
auto dropRect = getDropRect();
|
||||
|
||||
if((yAxis[0].getType() == YAxis::Type::Disabled || !supported(dropTrace, yAxis[0].getType()))
|
||||
|| (yAxis[1].getType() == YAxis::Type::Disabled || !supported(dropTrace, yAxis[1].getType()))) {
|
||||
// only one axis enabled, show drop area over whole plot
|
||||
p.drawRect(plotRect);
|
||||
p.drawRect(dropRect);
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
p.setOpacity(1.0);
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor);
|
||||
auto text = "Drop here to add\n" + dropTrace->name() + "\nto XY-plot";
|
||||
p.drawText(plotRect, Qt::AlignCenter, text);
|
||||
p.drawText(dropRect, Qt::AlignCenter, text);
|
||||
dropOnLeftAxis = true;
|
||||
dropOnRightAxis = true;
|
||||
} else {
|
||||
// both axis enabled, show regions
|
||||
auto leftRect = plotRect;
|
||||
leftRect.setWidth(plotRect.width() * 0.3);
|
||||
auto centerRect = plotRect;
|
||||
centerRect.setX(centerRect.x() + plotRect.width() * 0.35);
|
||||
centerRect.setWidth(plotRect.width() * 0.3);
|
||||
auto rightRect = plotRect;
|
||||
rightRect.setX(rightRect.x() + plotRect.width() * 0.7);
|
||||
rightRect.setWidth(plotRect.width() * 0.3);
|
||||
auto leftRect = dropRect;
|
||||
leftRect.setWidth(dropRect.width() * 0.333);
|
||||
auto centerRect = dropRect;
|
||||
centerRect.setX(centerRect.x() + dropRect.width() * 0.333);
|
||||
centerRect.setWidth(dropRect.width() * 0.333);
|
||||
auto rightRect = dropRect;
|
||||
rightRect.setX(rightRect.x() + dropRect.width() * 0.666);
|
||||
rightRect.setWidth(dropRect.width() * 0.333);
|
||||
p.drawRect(leftRect);
|
||||
p.drawRect(centerRect);
|
||||
p.drawRect(rightRect);
|
||||
p.setOpacity(1.0);
|
||||
p.setPen(Qt::white);
|
||||
p.setPen(dropForegroundColor);
|
||||
auto font = p.font();
|
||||
font.setPixelSize(20);
|
||||
p.setFont(font);
|
||||
if(dropSection == DropSection::OnPlot && leftRect.contains(dropPosition)) {
|
||||
p.setPen(dropHighlightColor);
|
||||
dropOnLeftAxis = true;
|
||||
dropOnRightAxis = false;
|
||||
} else {
|
||||
p.setPen(dropForegroundColor);
|
||||
}
|
||||
p.drawText(leftRect, Qt::AlignCenter, "Drop here to add\nto primary axis");
|
||||
if(dropSection == DropSection::OnPlot && centerRect.contains(dropPosition)) {
|
||||
p.setPen(dropHighlightColor);
|
||||
dropOnLeftAxis = true;
|
||||
dropOnRightAxis = true;
|
||||
} else {
|
||||
p.setPen(dropForegroundColor);
|
||||
}
|
||||
p.drawText(centerRect, Qt::AlignCenter, "Drop here to add\nto boths axes");
|
||||
if(dropSection == DropSection::OnPlot && rightRect.contains(dropPosition)) {
|
||||
p.setPen(dropHighlightColor);
|
||||
dropOnLeftAxis = false;
|
||||
dropOnRightAxis = true;
|
||||
} else {
|
||||
p.setPen(dropForegroundColor);
|
||||
}
|
||||
p.drawText(rightRect, Qt::AlignCenter, "Drop here to add\nto secondary axis");
|
||||
}
|
||||
}
|
||||
@ -1162,12 +1187,11 @@ void TraceXYPlot::traceDropped(Trace *t, QPoint position)
|
||||
enableTraceAxis(t, 0, true);
|
||||
return;
|
||||
}
|
||||
// both axis enabled, check drop position
|
||||
auto drop = Util::Scale<double>(position.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth, 0.0, 1.0);
|
||||
if(drop < 0.66) {
|
||||
// both axis enabled
|
||||
if(dropOnLeftAxis) {
|
||||
enableTraceAxis(t, 0, true);
|
||||
}
|
||||
if(drop > 0.33) {
|
||||
if(dropOnRightAxis) {
|
||||
enableTraceAxis(t, 1, true);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ private:
|
||||
void traceDropped(Trace *t, QPoint position) override;
|
||||
QString mouseText(QPoint pos) override;
|
||||
|
||||
bool dropOnLeftAxis;
|
||||
bool dropOnRightAxis;
|
||||
|
||||
std::set<Trace*> tracesAxis[2];
|
||||
|
||||
YAxis yAxis[2];
|
||||
|
@ -1570,12 +1570,7 @@ void VNA::createDefaultTracesAndGraphs(int ports)
|
||||
QString param = "S"+QString::number(i+1)+QString::number(j+1);
|
||||
auto trace = new Trace(param, getDefaultColor(ports, i, j), param);
|
||||
traceModel.addTrace(trace);
|
||||
TracePlot *plot;
|
||||
if(i == j) {
|
||||
plot = new TraceSmithChart(traceModel);
|
||||
} else {
|
||||
plot = new TraceXYPlot(traceModel);
|
||||
}
|
||||
TracePlot *plot = TracePlot::createDefaultPlotForTrace(traceModel, trace);
|
||||
plot->updateSpan(settings.Freq.start, settings.Freq.stop);
|
||||
plot->enableTrace(trace, true);
|
||||
plots[i].push_back(plot);
|
||||
|
@ -258,6 +258,8 @@ void PreferencesDialog::setInitialGUIState()
|
||||
ui->AcquisitionFullSpanStop->setValue(p->Acquisition.fullSpanStop);
|
||||
ui->AcquisitionFullSpanCalibrated->setChecked(p->Acquisition.fullSpanCalibratedRange);
|
||||
|
||||
ui->GraphsDefaultTransmission->setCurrentText(p->Graphs.defaultGraphs.transmission);
|
||||
ui->GraphsDefaultReflection->setCurrentText(p->Graphs.defaultGraphs.reflection);
|
||||
ui->GraphsShowUnit->setChecked(p->Graphs.showUnits);
|
||||
ui->GraphsColorBackground->setColor(p->Graphs.Color.background);
|
||||
ui->GraphsColorAxis->setColor(p->Graphs.Color.axis);
|
||||
@ -353,6 +355,8 @@ void PreferencesDialog::updateFromGUI()
|
||||
p->Acquisition.fullSpanStop = ui->AcquisitionFullSpanStop->value();
|
||||
p->Acquisition.fullSpanCalibratedRange = ui->AcquisitionFullSpanCalibrated->isChecked();
|
||||
|
||||
p->Graphs.defaultGraphs.transmission = ui->GraphsDefaultTransmission->currentText();
|
||||
p->Graphs.defaultGraphs.reflection = ui->GraphsDefaultReflection->currentText();
|
||||
p->Graphs.showUnits = ui->GraphsShowUnit->isChecked();
|
||||
p->Graphs.Color.background = ui->GraphsColorBackground->getColor();
|
||||
p->Graphs.Color.axis = ui->GraphsColorAxis->getColor();
|
||||
|
@ -137,6 +137,11 @@ public:
|
||||
bool hide;
|
||||
double hidePercent;
|
||||
} SweepIndicator;
|
||||
|
||||
struct {
|
||||
QString transmission;
|
||||
QString reflection;
|
||||
} defaultGraphs;
|
||||
} Graphs;
|
||||
struct {
|
||||
struct {
|
||||
@ -223,6 +228,8 @@ private:
|
||||
{&Graphs.SweepIndicator.line, "Graphs.SweepIndicator.line", false},
|
||||
{&Graphs.SweepIndicator.hide, "Graphs.SweepIndicator.hide", false},
|
||||
{&Graphs.SweepIndicator.hidePercent, "Graphs.SweepIndicator.hidePercent", 3.0},
|
||||
{&Graphs.defaultGraphs.transmission, "Graphs.defaultGraphs.transmission", "XY Plot"},
|
||||
{&Graphs.defaultGraphs.reflection, "Graphs.defaultGraphs.reflection", "Smith Chart"},
|
||||
{&Marker.defaultBehavior.showDataOnGraphs, "Marker.defaultBehavior.ShowDataOnGraphs", true},
|
||||
{&Marker.defaultBehavior.showdB, "Marker.defaultBehavior.showdB", true},
|
||||
{&Marker.defaultBehavior.showdBm, "Marker.defaultBehavior.showdBm", true},
|
||||
|
@ -93,7 +93,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Startup">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
@ -107,8 +107,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>679</width>
|
||||
<height>836</height>
|
||||
<width>683</width>
|
||||
<height>897</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
@ -698,8 +698,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>320</height>
|
||||
<width>697</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
@ -855,13 +855,84 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>437</width>
|
||||
<height>862</height>
|
||||
<width>683</width>
|
||||
<height>1058</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_22">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>Default Graphs</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>For transmission measurements:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="text">
|
||||
<string>For reflection measurements:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="GraphsDefaultTransmission">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>XY Plot</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Polar Chart</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Waterfall</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Eye Diagram</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="GraphsDefaultReflection">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>XY-Plot</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Smith Chart</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Polar Chart</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Waterfall</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="GraphsShowUnit">
|
||||
<property name="text">
|
||||
@ -1278,8 +1349,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>402</width>
|
||||
<height>540</height>
|
||||
<width>683</width>
|
||||
<height>605</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@ -1617,8 +1688,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>138</width>
|
||||
<height>112</height>
|
||||
<width>168</width>
|
||||
<height>127</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
@ -1707,8 +1778,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>194</width>
|
||||
<height>146</height>
|
||||
<width>215</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_19">
|
||||
|
Loading…
Reference in New Issue
Block a user