Math edit window consolidated with trace edit window

This commit is contained in:
Jan Käberich 2021-02-22 21:50:28 +01:00
parent f6cc46781e
commit 23ab9383ee
11 changed files with 588 additions and 604 deletions

View File

@ -78,7 +78,6 @@ HEADERS += \
Traces/Math/parser/utGeneric.h \
Traces/Math/tdr.h \
Traces/Math/tracemath.h \
Traces/Math/tracematheditdialog.h \
Traces/Math/windowfunction.h \
Traces/fftcomplex.h \
Traces/markerwidget.h \
@ -184,7 +183,6 @@ SOURCES += \
Traces/Math/parser/mpVariable.cpp \
Traces/Math/tdr.cpp \
Traces/Math/tracemath.cpp \
Traces/Math/tracematheditdialog.cpp \
Traces/Math/windowfunction.cpp \
Traces/fftcomplex.cpp \
Traces/markerwidget.cpp \
@ -246,7 +244,6 @@ FORMS += \
Traces/Math/newtracemathdialog.ui \
Traces/Math/tdrdialog.ui \
Traces/Math/tdrexplanationwidget.ui \
Traces/Math/tracematheditdialog.ui \
Traces/markerwidget.ui \
Traces/smithchartdialog.ui \
Traces/tracecsvexport.ui \

View File

@ -1,200 +0,0 @@
#include "tracematheditdialog.h"
#include "ui_tracematheditdialog.h"
#include <QHeaderView>
#include "ui_newtracemathdialog.h"
namespace Ui {
class NewTraceMathDialog;
}
#include "medianfilter.h"
TraceMathEditDialog::TraceMathEditDialog(Trace &t, QWidget *parent) :
QDialog(parent),
ui(new Ui::TraceMathEditDialog)
{
auto model = new MathModel(t);
ui->setupUi(this);
ui->view->setModel(model);
QHeaderView *headerView = ui->view->horizontalHeader();
headerView->setSectionResizeMode(MathModel::ColIndexDescription, QHeaderView::Stretch);
headerView->setSectionResizeMode(MathModel::ColIndexStatus, QHeaderView::ResizeToContents);
headerView->setSectionResizeMode(MathModel::ColIndexDomain, QHeaderView::ResizeToContents);
connect(ui->view->selectionModel(), &QItemSelectionModel::currentRowChanged, [=](const QModelIndex &current, const QModelIndex &previous){
Q_UNUSED(previous)
if(!current.isValid()) {
ui->bDelete->setEnabled(false);
ui->bMoveUp->setEnabled(false);
ui->bMoveDown->setEnabled(false);
} else {
ui->bDelete->setEnabled(true);
ui->bMoveUp->setEnabled(current.row() > 1);
ui->bMoveDown->setEnabled(current.row() + 1 < model->rowCount());
}
});
connect(ui->view, &QTableView::doubleClicked, [&](const QModelIndex &index) {
if(index.isValid()) {
auto math = t.getMathOperations().at(index.row()).math;
math->edit();
}
});
connect(ui->bAdd, &QPushButton::clicked, [=](){
auto d = new QDialog();
auto ui = new Ui::NewTraceMathDialog();
ui->setupUi(d);
for(int i = 0; i < (int) TraceMath::Type::Last;i++) {
auto info = TraceMath::getInfo(static_cast<TraceMath::Type>(i));
ui->list->addItem(info.name);
if(!info.explanationWidget) {
info.explanationWidget = new QWidget();
}
ui->stack->addWidget(info.explanationWidget);
}
// always show the widget for the selected function
connect(ui->list, &QListWidget::currentRowChanged, ui->stack, &QStackedWidget::setCurrentIndex);
connect(ui->list, &QListWidget::doubleClicked, ui->buttonBox, &QDialogButtonBox::accepted);
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){
auto newMath = TraceMath::createMath(static_cast<TraceMath::Type>(ui->list->currentRow()));
if(newMath) {
model->addOperation(newMath);
}
});
ui->list->setCurrentRow(0);
ui->stack->setCurrentIndex(0);
d->show();
});
connect(ui->bDelete, &QPushButton::clicked, [=](){
model->deleteRow(ui->view->currentIndex().row());
});
connect(ui->bMoveUp, &QPushButton::clicked, [&](){
auto index = ui->view->currentIndex();
t.swapMathOrder(index.row() - 1);
ui->view->setCurrentIndex(index.sibling(index.row() - 1, 0));
});
connect(ui->bMoveDown, &QPushButton::clicked, [&](){
auto index = ui->view->currentIndex();
t.swapMathOrder(index.row());
ui->view->setCurrentIndex(index.sibling(index.row() + 1, 0));
});
}
TraceMathEditDialog::~TraceMathEditDialog()
{
delete ui;
}
MathModel::MathModel(Trace &t, QObject *parent)
: QAbstractTableModel(parent),
t(t)
{
}
int MathModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return t.getMathOperations().size();
}
int MathModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return ColIndexLast;
}
QVariant MathModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid()) {
return QVariant();
}
auto math = t.getMathOperations().at(index.row());
switch(index.column()) {
case ColIndexStatus:
if(role == Qt::DecorationRole) {
switch(math.math->getStatus()) {
case TraceMath::Status::Ok:
return QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton);
case TraceMath::Status::Warning:
return QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
case TraceMath::Status::Error:
return QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
}
} else if(role == Qt::ToolTipRole) {
if(math.math->getStatus() != TraceMath::Status::Ok) {
return math.math->getStatusDescription();
}
}
break;
case ColIndexDescription:
if(role == Qt::DisplayRole) {
return math.math->description();
}
// else if(role == Qt::CheckStateRole){
// return math.enabled ? Qt::Checked : Qt::Unchecked;
// }
break;
case ColIndexDomain:
if(role == Qt::DisplayRole) {
switch(math.math->getDataType()) {
case TraceMath::DataType::Time:
return "Time";
case TraceMath::DataType::Frequency:
return "Frequency";
case TraceMath::DataType::Invalid:
return "Invalid";
}
}
}
return QVariant();
}
QVariant MathModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch(section) {
case ColIndexStatus: return "Status"; break;
case ColIndexDescription: return "Description"; break;
case ColIndexDomain: return "Output domain"; break;
default: break;
}
}
return QVariant();
}
Qt::ItemFlags MathModel::flags(const QModelIndex &index) const
{
int flags = Qt::NoItemFlags;
if(index.row() >= 1) {
// the first entry is always the trace itself and not enabled
flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
// switch(index.column()) {
// case ColIndexDescription: flags |= Qt::ItemIsUserCheckable; break;
// default:
// break;
// }
return (Qt::ItemFlags) flags;
}
void MathModel::addOperation(TraceMath *math)
{
beginInsertRows(QModelIndex(), t.getMathOperations().size(), t.getMathOperations().size());
t.addMathOperation(math);
endInsertRows();
// open the editor for the newly added operation
math->edit();
}
void MathModel::deleteRow(unsigned int row)
{
beginRemoveRows(QModelIndex(), row, row);
t.removeMathOperation(row);
endRemoveRows();
}

View File

@ -1,50 +0,0 @@
#ifndef TRACEMATHEDITDIALOG_H
#define TRACEMATHEDITDIALOG_H
#include <QDialog>
#include <QAbstractTableModel>
#include "Traces/trace.h"
namespace Ui {
class TraceMathEditDialog;
}
class MathModel : public QAbstractTableModel
{
Q_OBJECT
public:
MathModel(Trace &t, QObject *parent = 0);
enum {
ColIndexStatus = 0,
ColIndexDescription = 1,
ColIndexDomain = 2,
ColIndexLast,
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
void addOperation(TraceMath *math);
void deleteRow(unsigned int row);
private:
Trace &t;
};
class TraceMathEditDialog : public QDialog
{
Q_OBJECT
public:
explicit TraceMathEditDialog(Trace &t, QWidget *parent = nullptr);
~TraceMathEditDialog();
private:
Ui::TraceMathEditDialog *ui;
};
#endif // TRACEMATHEDITDIALOG_H

View File

@ -1,185 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TraceMathEditDialog</class>
<widget class="QDialog" name="TraceMathEditDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>903</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>Math functions</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableView" name="view">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>20</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="bAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Add</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="list-add" resource="../../icons.qrc">
<normaloff>:/icons/add.png</normaloff>:/icons/add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bDelete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="list-remove" resource="../../icons.qrc">
<normaloff>:/icons/remove.png</normaloff>:/icons/remove.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bMoveUp">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move up</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="go-up" resource="../../icons.qrc">
<normaloff>:/icons/up.png</normaloff>:/icons/up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bMoveDown">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="go-down" resource="../../icons.qrc">
<normaloff>:/icons/down.png</normaloff>:/icons/down.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>186</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../icons.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>TraceMathEditDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>216</x>
<y>280</y>
</hint>
<hint type="destinationlabel">
<x>216</x>
<y>150</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -2,7 +2,10 @@
#include "ui_traceeditdialog.h"
#include <QColorDialog>
#include <QFileDialog>
#include "Math/tracematheditdialog.h"
#include "ui_newtracemathdialog.h"
namespace Ui {
class NewTraceMathDialog;
}
TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
QDialog(parent),
@ -95,12 +98,78 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
connect(ui->GSource, qOverload<int>(&QButtonGroup::buttonClicked), updateFileStatus);
connect(ui->touchstoneImport, &TouchstoneImport::statusChanged, updateFileStatus);
connect(ui->touchstoneImport, &TouchstoneImport::filenameChanged, updateFileStatus);
connect(ui->mathSetup, &QPushButton::clicked, [&](){
auto dialog = new TraceMathEditDialog(t);
dialog->show();
});
updateFileStatus();
// setup math part of the GUI
auto model = new MathModel(t);
ui->view->setModel(model);
QHeaderView *headerView = ui->view->horizontalHeader();
headerView->setSectionResizeMode(MathModel::ColIndexDescription, QHeaderView::Stretch);
headerView->setSectionResizeMode(MathModel::ColIndexStatus, QHeaderView::ResizeToContents);
headerView->setSectionResizeMode(MathModel::ColIndexDomain, QHeaderView::ResizeToContents);
connect(ui->view->selectionModel(), &QItemSelectionModel::currentRowChanged, [=](const QModelIndex &current, const QModelIndex &previous){
Q_UNUSED(previous)
if(!current.isValid()) {
ui->bDelete->setEnabled(false);
ui->bMoveUp->setEnabled(false);
ui->bMoveDown->setEnabled(false);
} else {
ui->bDelete->setEnabled(true);
ui->bMoveUp->setEnabled(current.row() > 1);
ui->bMoveDown->setEnabled(current.row() + 1 < model->rowCount());
}
});
connect(ui->view, &QTableView::doubleClicked, [&](const QModelIndex &index) {
if(index.isValid()) {
auto math = t.getMathOperations().at(index.row()).math;
math->edit();
}
});
connect(ui->bAdd, &QPushButton::clicked, [=](){
auto d = new QDialog();
auto ui = new Ui::NewTraceMathDialog();
ui->setupUi(d);
for(int i = 0; i < (int) TraceMath::Type::Last;i++) {
auto info = TraceMath::getInfo(static_cast<TraceMath::Type>(i));
ui->list->addItem(info.name);
if(!info.explanationWidget) {
info.explanationWidget = new QWidget();
}
ui->stack->addWidget(info.explanationWidget);
}
// always show the widget for the selected function
connect(ui->list, &QListWidget::currentRowChanged, ui->stack, &QStackedWidget::setCurrentIndex);
connect(ui->list, &QListWidget::doubleClicked, ui->buttonBox, &QDialogButtonBox::accepted);
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){
auto newMath = TraceMath::createMath(static_cast<TraceMath::Type>(ui->list->currentRow()));
if(newMath) {
model->addOperation(newMath);
}
});
ui->list->setCurrentRow(0);
ui->stack->setCurrentIndex(0);
d->show();
});
connect(ui->bDelete, &QPushButton::clicked, [=](){
model->deleteRow(ui->view->currentIndex().row());
});
connect(ui->bMoveUp, &QPushButton::clicked, [&](){
auto index = ui->view->currentIndex();
t.swapMathOrder(index.row() - 1);
ui->view->setCurrentIndex(index.sibling(index.row() - 1, 0));
});
connect(ui->bMoveDown, &QPushButton::clicked, [&](){
auto index = ui->view->currentIndex();
t.swapMathOrder(index.row());
ui->view->setCurrentIndex(index.sibling(index.row() + 1, 0));
});
}
TraceEditDialog::~TraceEditDialog()
@ -143,3 +212,113 @@ void TraceEditDialog::on_buttonBox_accepted()
}
delete this;
}
MathModel::MathModel(Trace &t, QObject *parent)
: QAbstractTableModel(parent),
t(t)
{
}
int MathModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return t.getMathOperations().size();
}
int MathModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return ColIndexLast;
}
QVariant MathModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid()) {
return QVariant();
}
auto math = t.getMathOperations().at(index.row());
switch(index.column()) {
case ColIndexStatus:
if(role == Qt::DecorationRole) {
switch(math.math->getStatus()) {
case TraceMath::Status::Ok:
return QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton);
case TraceMath::Status::Warning:
return QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
case TraceMath::Status::Error:
return QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
}
} else if(role == Qt::ToolTipRole) {
if(math.math->getStatus() != TraceMath::Status::Ok) {
return math.math->getStatusDescription();
}
}
break;
case ColIndexDescription:
if(role == Qt::DisplayRole) {
return math.math->description();
}
// else if(role == Qt::CheckStateRole){
// return math.enabled ? Qt::Checked : Qt::Unchecked;
// }
break;
case ColIndexDomain:
if(role == Qt::DisplayRole) {
switch(math.math->getDataType()) {
case TraceMath::DataType::Time:
return "Time";
case TraceMath::DataType::Frequency:
return "Frequency";
case TraceMath::DataType::Invalid:
return "Invalid";
}
}
}
return QVariant();
}
QVariant MathModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch(section) {
case ColIndexStatus: return "Status"; break;
case ColIndexDescription: return "Description"; break;
case ColIndexDomain: return "Output domain"; break;
default: break;
}
}
return QVariant();
}
Qt::ItemFlags MathModel::flags(const QModelIndex &index) const
{
int flags = Qt::NoItemFlags;
if(index.row() >= 1) {
// the first entry is always the trace itself and not enabled
flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
// switch(index.column()) {
// case ColIndexDescription: flags |= Qt::ItemIsUserCheckable; break;
// default:
// break;
// }
return (Qt::ItemFlags) flags;
}
void MathModel::addOperation(TraceMath *math)
{
beginInsertRows(QModelIndex(), t.getMathOperations().size(), t.getMathOperations().size());
t.addMathOperation(math);
endInsertRows();
// open the editor for the newly added operation
math->edit();
}
void MathModel::deleteRow(unsigned int row)
{
beginRemoveRows(QModelIndex(), row, row);
t.removeMathOperation(row);
endRemoveRows();
}

View File

@ -3,11 +3,38 @@
#include <QDialog>
#include "trace.h"
#include <QAbstractTableModel>
namespace Ui {
class TraceEditDialog;
}
class MathModel : public QAbstractTableModel
{
Q_OBJECT
public:
MathModel(Trace &t, QObject *parent = 0);
enum {
ColIndexStatus = 0,
ColIndexDescription = 1,
ColIndexDomain = 2,
ColIndexLast,
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
void addOperation(TraceMath *math);
void deleteRow(unsigned int row);
private:
Trace &t;
};
class TraceEditDialog : public QDialog
{
Q_OBJECT

View File

@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<width>1038</width>
<height>365</height>
</rect>
</property>
@ -19,156 +19,311 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="ColorPickerButton" name="color">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mathSetup">
<property name="text">
<string>Math</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Velocity Factor:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SIUnitEdit" name="vFactor"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,1">
<item>
<widget class="QRadioButton" name="bLive">
<property name="text">
<string>Live Capture</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">GSource</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bFile">
<property name="text">
<string>From File</string>
</property>
<attribute name="buttonGroup">
<string notr="true">GSource</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stack">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="CLiveType">
<item>
<property name="text">
<string>Overwrite</string>
</property>
</item>
<item>
<property name="text">
<string>Max hold</string>
</property>
</item>
<item>
<property name="text">
<string>Min hold</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Parameter:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="CLiveParam"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="TouchstoneImport" name="touchstoneImport" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Parameter:</string>
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="CParameter"/>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="ColorPickerButton" name="color">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Velocity Factor:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SIUnitEdit" name="vFactor"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="bLive">
<property name="text">
<string>Live Capture</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">GSource</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bFile">
<property name="text">
<string>From File</string>
</property>
<attribute name="buttonGroup">
<string notr="true">GSource</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stack">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="CLiveType">
<item>
<property name="text">
<string>Overwrite</string>
</property>
</item>
<item>
<property name="text">
<string>Max hold</string>
</property>
</item>
<item>
<property name="text">
<string>Min hold</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Parameter:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="CLiveParam"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="TouchstoneImport" name="touchstoneImport" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Parameter:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="CParameter"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Math operations</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QTableView" name="view">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>20</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="bAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Add</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="list-add" resource="../icons.qrc">
<normaloff>:/icons/add.png</normaloff>:/icons/add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bDelete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="list-remove" resource="../icons.qrc">
<normaloff>:/icons/remove.png</normaloff>:/icons/remove.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bMoveUp">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move up</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="go-up" resource="../icons.qrc">
<normaloff>:/icons/up.png</normaloff>:/icons/up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bMoveDown">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="go-down" resource="../icons.qrc">
<normaloff>:/icons/down.png</normaloff>:/icons/down.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>186</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
@ -197,7 +352,9 @@
<header>CustomWidgets/siunitedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections>
<connection>
<sender>GSource</sender>

View File

@ -9,6 +9,7 @@ TraceTouchstoneExport::TraceTouchstoneExport(TraceModel &model, QWidget *parent)
QDialog(parent),
ui(new Ui::TraceTouchstoneExport),
model(model),
ports(0),
freqsSet(false)
{
ui->setupUi(this);
@ -24,6 +25,10 @@ TraceTouchstoneExport::~TraceTouchstoneExport()
bool TraceTouchstoneExport::setTrace(int portFrom, int portTo, Trace *t)
{
if(t->getDataType() != Trace::DataType::Frequency) {
// can only add frequency traces
return false;
}
if(portFrom < 0 || portFrom >= ui->sbPorts->value() || portTo < 0 || portTo >= ui->sbPorts->value()) {
// invalid port selection
return false;
@ -101,20 +106,36 @@ void TraceTouchstoneExport::on_buttonBox_accepted()
void TraceTouchstoneExport::on_sbPorts_valueChanged(int ports)
{
// remove the previous widgets
QGridLayout *layout = static_cast<QGridLayout*>(ui->gbTraces->layout());
QLayoutItem *child;
while ((child = layout->takeAt(0)) != 0) {
delete child->widget();
delete child;
if((unsigned) ports != this->ports) {
this->ports = ports;
// remove the previous widgets
QLayoutItem *child;
while ((child = layout->takeAt(0)) != 0) {
delete child->widget();
delete child;
}
cTraces.clear();
for(int i=0;i<ports;i++) {
cTraces.push_back(std::vector<QComboBox*>());
for(int j=0;j<ports;j++) {
auto l = new QLabel("S"+QString::number(i+1)+QString::number(j+1)+":");
auto c = new QComboBox();
cTraces[i].push_back(c);
connect(c, qOverload<int>(&QComboBox::currentIndexChanged), [=](int) {
selectionChanged(c);
});
layout->addWidget(l, i, j*2);
layout->addWidget(c, i, j*2 + 1);
}
}
}
cTraces.clear();
auto availableTraces = model.getTraces();
for(int i=0;i<ports;i++) {
cTraces.push_back(std::vector<QComboBox*>());
for(int j=0;j<ports;j++) {
auto l = new QLabel("S"+QString::number(i+1)+QString::number(j+1)+":");
auto c = new QComboBox();
auto c = cTraces[i][j];
c->blockSignals(true);
c->clear();
// create possible trace selections
c->addItem("None");
for(auto t : availableTraces) {
@ -131,12 +152,7 @@ void TraceTouchstoneExport::on_sbPorts_valueChanged(int ports)
}
c->addItem(t->name(), QVariant::fromValue<Trace*>(t));
}
connect(c, qOverload<int>(&QComboBox::currentIndexChanged), [=](int) {
selectionChanged(c);
});
cTraces[i].push_back(c);
layout->addWidget(l, i, j*2);
layout->addWidget(c, i, j*2 + 1);
c->blockSignals(false);
}
}
}
@ -186,5 +202,6 @@ void TraceTouchstoneExport::selectionChanged(QComboBox *w)
ui->lowerFreq->clear();
ui->upperFreq->clear();
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
on_sbPorts_valueChanged(ui->sbPorts->value());
}
}

View File

@ -30,6 +30,7 @@ private:
TraceModel &model;
std::vector<std::vector<QComboBox*>> cTraces;
unsigned int ports;
unsigned int points;
double lowerFreq, upperFreq;
bool freqsSet;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>386</width>
<height>324</height>
<width>519</width>
<height>380</height>
</rect>
</property>
<property name="windowTitle">
@ -17,6 +17,16 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Add/configure de-embedding options in this list. Although not required in most scenarios, multiple options can be active at once; de-embedding will be performed top-to-bottom. Therefore, the bottommost entry is the de-embedding that is closest to the DUT, whereas the topmost option is closest to the physical VNA ports.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>742</width>
<height>198</height>
<width>701</width>
<height>465</height>
</rect>
</property>
<property name="windowTitle">
@ -19,7 +19,38 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>What is this?</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;ul&gt;
&lt;li&gt;2xthru de-embedding attempts to remove the effect of the fixtures contacting the DUT.&lt;/li&gt;
&lt;li&gt;Although not as accurate as a SOLT calibration, it can help in situations where SOLT standards are not usable with the fixtures.&lt;/li&gt;
&lt;li&gt;To create the de-embedding parameters, a 2xThru measurement is required: Connect the fixtures of both ports directly to each other and measure their S parameters.&lt;/li&gt;
&lt;li&gt;If other impedances than 50 Ohm are used, a Fixture-DUT-Fixture measurement is also necessary, attempting to compensate the impedance. Connect the DUT between the fixtures and measure the S parameters.&lt;/li&gt;
&lt;li&gt;For more details of the 2xthru de-embedding see e.g.
&lt;a href=&quot;https://www.signalintegrityjournal.com/articles/463-test-fixture-de-embedding-101&quot;&gt;this&lt;/a&gt; article.
&lt;/li&gt;
&lt;li&gt;For more details and examples on how to use 2xthru de-embedding in this application, see the user manual. &lt;/li&gt;
&lt;/ul&gt; </string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">