diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 59dea2dc9..4b1240148 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -64,7 +64,6 @@ jobs: sudo apt-get update sudo apt-get install -y libglx-dev libgl1-mesa-dev flex bison gperf dos2unix flex bison gperf dos2unix sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 - sudo apt install libqt5charts5-dev - name: 'Install Qt6' uses: jurplel/install-qt-action@v4 @@ -212,7 +211,7 @@ jobs: build-mac-universal: - runs-on: macos-latest + runs-on: macos-15 needs: setup strategy: fail-fast: false diff --git a/README.md b/README.md index 2ab9e9aa7..88783457b 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,13 @@ Use CMake to build Qucs-S. Install all necessary dependencies: GCC, Qt, Flex, Bi #### Ubuntu ~~~ -sudo apt-get install ngspice build-essential git cmake qtbase5-dev qttools5-dev libqt5svg5-dev flex bison gperf dos2unix +sudo apt-get install ngspice build-essential git cmake qtbase5-dev qttools5-dev libqt5svg5-dev libqt5charts5-dev flex bison gperf dos2unix ~~~ #### OpenSUSE Tumbleweed ~~~ -sudo zypper install ngspice git cmake libqt5-qtbase-devel libqt5-qttools-devel libqt5-qtsvg-devel flex bison gperf dos2unix +sudo zypper install ngspice git cmake libqt5-qtbase-devel libqt5-qttools-devel libqt5-qtsvg-devel libqt5-qtcharts-devel flex bison gperf dos2unix ~~~ ### Compiling diff --git a/qucs-powercombining/qucspowercombiningtool.cpp b/qucs-powercombining/qucspowercombiningtool.cpp index 67c1d8f5e..fba602ea5 100644 --- a/qucs-powercombining/qucspowercombiningtool.cpp +++ b/qucs-powercombining/qucspowercombiningtool.cpp @@ -787,7 +787,7 @@ QString QucsPowerCombiningTool::calcChebyLines(double RL, double Z0, double gamm { QMessageBox::warning(0, QObject::tr("Error"), QObject::tr("Chebyshev weighting for N>7 is not available")); - return QString(""); + return QString(); } QString s; double sec_theta_m;// = cosh((1/(1.*N))*acosh((1/gamma)*fabs((RL-Z0)/(Z0+RL))) ); @@ -2065,7 +2065,7 @@ QString QucsPowerCombiningTool::ConvertLengthFromM(double len) return QString("%1 mm").arg(RoundVariablePrecision(conv)); } }while(true); - return QString(""); + return QString(); } // Copied from Qucs misc class diff --git a/qucs-s-spar-viewer/main.cpp b/qucs-s-spar-viewer/main.cpp index 52badc64f..0d17f59a3 100644 --- a/qucs-s-spar-viewer/main.cpp +++ b/qucs-s-spar-viewer/main.cpp @@ -108,7 +108,7 @@ int main( int argc, char ** argv ) qucs->move(QucsSettings.x, QucsSettings.y); // position before "show" !!! qucs->show(); - QScreen* primaryScreen = QGuiApplication::screens().first(); + QScreen* primaryScreen = QGuiApplication::screens().constFirst(); qucs->resize(primaryScreen->availableGeometry().size() * 0.9); qucs->setGeometry( diff --git a/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp b/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp index f6befd11c..bd1bd2654 100644 --- a/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp +++ b/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp @@ -1,14 +1,25 @@ -/**************************************************************************** -** Qucs Attenuator Synthesis -** qucsattenuator.cpp -** -** -** -** -** -** -** -*****************************************************************************/ +/* + * qucs-s-spar-viewer.cpp - S-parameter viewer for Qucs-S + * + * copyright (C) 2024 Andres Martinez-Mera + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this package; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * + */ #ifdef HAVE_CONFIG_H #include @@ -35,10 +46,8 @@ #include - Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() { - QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); @@ -51,6 +60,21 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() fileQuit->setShortcut(QKeySequence::Quit); connect(fileQuit, SIGNAL(triggered(bool)), SLOT(slotQuit())); + QAction *fileOpenSession = new QAction(tr("&Open session file"), this); + fileOpenSession->setShortcut(QKeySequence::Open); + connect(fileOpenSession, SIGNAL(triggered(bool)), SLOT(slotLoadSession())); + + QAction *fileSaveAsSession = new QAction(tr("&Save session as ..."), this); + fileSaveAsSession->setShortcut(QKeySequence::SaveAs); + connect(fileSaveAsSession, SIGNAL(triggered(bool)), SLOT(slotSaveAs())); + + QAction *fileSaveSession = new QAction(tr("&Save session"), this); + fileSaveSession->setShortcut(QKeySequence::Save); + connect(fileSaveSession, SIGNAL(triggered(bool)), SLOT(slotSave())); + + fileMenu->addAction(fileOpenSession); + fileMenu->addAction(fileSaveSession); + fileMenu->addAction(fileSaveAsSession); fileMenu->addAction(fileQuit); QMenu *helpMenu = new QMenu(tr("&Help")); @@ -64,7 +88,6 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() helpMenu->addAction(helpAbout); connect(helpAbout, SIGNAL(triggered(bool)), SLOT(slotHelpAbout())); - helpMenu->addSeparator(); QAction * helpAboutQt = new QAction(tr("About Qt..."), this); @@ -75,6 +98,9 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() menuBar()->addSeparator(); menuBar()->addMenu(helpMenu); + // Set frequency units + frequency_units << "Hz" << "kHz" << "MHz" << "GHz"; + // Left panel QScrollArea *scrollArea_Files = new QScrollArea(); FileList_Widget = new QWidget(); @@ -113,7 +139,6 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() }"); connect(Delete_All_Files, SIGNAL(clicked()), SLOT(removeAllFiles())); - hLayout_Files_Buttons->addWidget(Button_Add_File); hLayout_Files_Buttons->addWidget(Delete_All_Files); @@ -136,7 +161,6 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() addDockWidget(Qt::LeftDockWidgetArea, dockChart); - // These are two maximum markers to find the lowest and the highest frequency in the data samples. // They are used to prevent the user from zooming out too much f_min = 1e20; @@ -192,18 +216,15 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() available_x_axis_div.clear(); available_x_axis_div << 2000 << 1000 << 500 << 400 << 200 << 100 << 50 << 25 << 20 << 10 << 5 << 1 << 0.5 << 0.2 << 0.1; - for (const double &value : available_x_axis_div) { - QComboBox_x_axis_div->addItem(QString::number(value)); + for (const double &value : qAsConst(available_x_axis_div)) { + QComboBox_x_axis_div->addItem(QString::number(value)); } connect(QComboBox_x_axis_div, SIGNAL(currentIndexChanged(int)), SLOT(updatePlot())); SettingsGrid->addWidget(QComboBox_x_axis_div, 1, 3); QCombobox_x_axis_units = new QComboBox(); - QCombobox_x_axis_units->addItem("Hz"); - QCombobox_x_axis_units->addItem("kHz"); - QCombobox_x_axis_units->addItem("MHz"); - QCombobox_x_axis_units->addItem("GHz"); + QCombobox_x_axis_units->addItems(frequency_units); QCombobox_x_axis_units->setCurrentIndex(2); connect(QCombobox_x_axis_units, SIGNAL(currentIndexChanged(int)), SLOT(changeFreqUnits())); SettingsGrid->addWidget(QCombobox_x_axis_units, 1, 4); @@ -230,7 +251,7 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() QComboBox_y_axis_div = new QComboBox(); available_y_axis_div.clear(); available_y_axis_div << 50 << 25 << 20 << 10 << 5 << 2 << 1 << 0.5 << 0.2 << 0.1; - for (const double &value : available_y_axis_div) { + for (const double &value : qAsConst(available_y_axis_div)) { QComboBox_y_axis_div->addItem(QString::number(value)); } connect(QComboBox_y_axis_div, SIGNAL(currentIndexChanged(int)), SLOT(updatePlot())); @@ -266,6 +287,13 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() QSpinBox_y2_axis_div->hide(); // QCombobox_y2_axis_units->hide(); + // Lock axis settings button + Lock_axis_settings_Button = new QPushButton("Lock Axes"); + connect(Lock_axis_settings_Button, SIGNAL(clicked(bool)), SLOT(lock_unlock_axis_settings())); + lock_axis = false; + + SettingsGrid->addWidget(Lock_axis_settings_Button, 0, 4); + QWidget * TracesGroup = new QWidget(); QVBoxLayout *Traces_VBox = new QVBoxLayout(TracesGroup); @@ -330,12 +358,12 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() Traces_VBox->addWidget(TraceSelection_Widget); Traces_VBox->addWidget(scrollArea_Traces); - // Markers dock + // Markers dock QWidget * MarkersGroup = new QWidget(); QVBoxLayout *Markers_VBox = new QVBoxLayout(MarkersGroup); // Trace addition box - QWidget * MarkerSelection_Widget = new QWidget(); // Add trace + QWidget * MarkerSelection_Widget = new QWidget(); MarkersGrid = new QGridLayout(MarkerSelection_Widget); QLabel *Frequency_Marker_Label = new QLabel("Frequency"); @@ -353,7 +381,7 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() min-width: 10em;\ padding: 6px;\ }"); - connect(Button_add_marker, SIGNAL(clicked()), SLOT(addMarker())); // Connect button with the handler + connect(Button_add_marker, SIGNAL(clicked()), SLOT(addMarker())); // Connect button with the handler MarkersGrid->addWidget(Button_add_marker, 0, 0); Button_Remove_All_Markers = new QPushButton("Remove all"); @@ -395,10 +423,85 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() Markers_VBox->addWidget(scrollArea_Marker); Markers_VBox->addWidget(tableMarkers); + // Limits dock + QWidget * LimitsGroup = new QWidget(); + QVBoxLayout *Limits_VBox = new QVBoxLayout(LimitsGroup); + + // Limit addition box + QWidget * AddLimit_Widget = new QWidget(); // Add trace + + LimitsGrid = new QGridLayout(AddLimit_Widget); + + Button_add_Limit = new QPushButton("Add Limit"); + Button_add_Limit->setStyleSheet("QPushButton {background-color: green;\ + border-style: outset;\ + border-width: 2px;\ + border-radius: 10px;\ + border-color: beige;\ + font: bold 14px;\ + color: white;\ + min-width: 10em;\ + padding: 6px;\ + }"); + connect(Button_add_Limit, SIGNAL(clicked()), SLOT(addLimit())); // Connect button with the handler + LimitsGrid->addWidget(Button_add_Limit, 0, 0); + + + Button_Remove_All_Limits = new QPushButton("Remove all"); + Button_Remove_All_Limits->setStyleSheet("QPushButton {background-color: red;\ + border-style: outset;\ + border-width: 2px;\ + border-radius: 10px;\ + border-color: beige;\ + font: bold 14px;\ + color: white;\ + min-width: 10em;\ + padding: 6px;\ + }"); + connect(Button_Remove_All_Limits, SIGNAL(clicked()), SLOT(removeAllLimits())); // Connect button with the handler + LimitsGrid->addWidget(Button_Remove_All_Limits, 0, 1); + + QGroupBox * LimitSettings = new QGroupBox("Settings"); + QGridLayout * LimitsSettingLayout = new QGridLayout(LimitSettings); + QLabel * LimitsOffsetLabel = new QLabel("Limits Offset"); + Limits_Offset = new QDoubleSpinBox(); + Limits_Offset->setValue(0); + Limits_Offset->setSingleStep(0.1); + Limits_Offset->setMaximum(1e4); + Limits_Offset->setMinimum(-1e4); + connect(Limits_Offset, SIGNAL(valueChanged(double)), SLOT(updateTraces())); + LimitsSettingLayout->addWidget(LimitsOffsetLabel, 0, 0); + LimitsSettingLayout->addWidget(Limits_Offset, 0, 1); + + // Limit management + QWidget * LimitList_Widget = new QWidget(); // Panel with the trace settings + + QLabel * Label_Limit = new QLabel("Limit"); + QLabel * Label_Limit_Start = new QLabel("Start"); + QLabel * Label_Limit_Stop = new QLabel("Stop"); + QLabel * Label_Remove_Limit = new QLabel("Remove"); + + LimitsGrid = new QGridLayout(LimitList_Widget); + LimitsGrid->addWidget(Label_Limit, 0, 0, Qt::AlignCenter); + LimitsGrid->addWidget(Label_Limit_Start, 0, 1, 1, 2, Qt::AlignCenter); + LimitsGrid->addWidget(Label_Limit_Stop, 0, 3, 1, 2, Qt::AlignCenter); + LimitsGrid->addWidget(Label_Remove_Limit, 0, 5, Qt::AlignCenter); + + QScrollArea *scrollArea_Limits = new QScrollArea(); + scrollArea_Limits->setWidget(LimitList_Widget); + scrollArea_Limits->setWidgetResizable(true); + + Limits_VBox->addWidget(AddLimit_Widget); + Limits_VBox->addWidget(LimitSettings); + Limits_VBox->addWidget(scrollArea_Limits); + + + dockFiles = new QDockWidget("S-parameter files", this); dockAxisSettings = new QDockWidget("Axis Settings", this); dockTracesList = new QDockWidget("Traces List", this); dockMarkers = new QDockWidget("Markers", this); + dockLimits = new QDockWidget("Limits", this); // Disable dock closing dockChart->setFeatures(dockChart->features() & ~QDockWidget::DockWidgetClosable); @@ -406,20 +509,24 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() dockAxisSettings->setFeatures(dockAxisSettings->features() & ~QDockWidget::DockWidgetClosable); dockTracesList->setFeatures(dockTracesList->features() & ~QDockWidget::DockWidgetClosable); dockMarkers->setFeatures(dockMarkers->features() & ~QDockWidget::DockWidgetClosable); + dockLimits->setFeatures(dockLimits->features() & ~QDockWidget::DockWidgetClosable); dockAxisSettings->setWidget(SettingsGroup); dockTracesList->setWidget(TracesGroup); dockFiles->setWidget(FilesGroup); dockMarkers->setWidget(MarkersGroup); + dockLimits->setWidget(LimitsGroup); addDockWidget(Qt::RightDockWidgetArea, dockAxisSettings); addDockWidget(Qt::RightDockWidgetArea, dockTracesList); addDockWidget(Qt::RightDockWidgetArea, dockFiles); addDockWidget(Qt::RightDockWidgetArea, dockMarkers); + addDockWidget(Qt::RightDockWidgetArea, dockLimits); splitDockWidget(dockTracesList, dockAxisSettings, Qt::Vertical); tabifyDockWidget(dockFiles, dockTracesList); tabifyDockWidget(dockTracesList, dockMarkers); + tabifyDockWidget(dockMarkers, dockLimits); dockFiles->raise(); setDockNestingEnabled(true); @@ -462,13 +569,6 @@ void Qucs_S_SPAR_Viewer::slotHelpAbout() void Qucs_S_SPAR_Viewer::slotQuit() { - int tmp; - tmp = x(); - tmp = y(); - tmp = width(); - tmp = height(); - Q_UNUSED(tmp); - qApp->quit(); } @@ -491,7 +591,6 @@ void Qucs_S_SPAR_Viewer::addFiles(QStringList fileNames) int existing_files = this->datasets.size(); // Get the number of entries in the map // Variables for reading the Touchstone data - QString line; QStringList values; QString filename; @@ -510,7 +609,7 @@ void Qucs_S_SPAR_Viewer::addFiles(QStringList fileNames) for (int i = 0; i < fileNames.length(); i++){ filename = QFileInfo(fileNames.at(i)).fileName(); // Check if this file already exists - QString new_filename = filename.left(filename.indexOf('.')); + QString new_filename = filename.left(filename.lastIndexOf('.')); if (files_dataset.contains(new_filename)){ // Remove it from the list of new files to load fileNames.removeAt(i); @@ -530,7 +629,7 @@ void Qucs_S_SPAR_Viewer::addFiles(QStringList fileNames) // Create the file name label filename = QFileInfo(fileNames.at(i-existing_files)).fileName(); - QLabel * Filename_Label = new QLabel(filename.left(filename.indexOf('.'))); + QLabel * Filename_Label = new QLabel(filename.left(filename.lastIndexOf('.'))); Filename_Label->setObjectName(QString("File_") + QString::number(i)); List_FileNames.append(Filename_Label); this->FilesGrid->addWidget(List_FileNames.last(), i,0,1,1); @@ -546,6 +645,7 @@ void Qucs_S_SPAR_Viewer::addFiles(QStringList fileNames) border-radius: 10px;\ border-color: beige;\ font: bold 14px;\ + margin: auto;\ }"); List_RemoveButton.append(RemoveButton); @@ -737,13 +837,12 @@ void Qucs_S_SPAR_Viewer::addFiles(QStringList fileNames) } } // 3) Add data to the dataset - filename = filename.left(filename.indexOf('.')); // Remove file extension + filename = filename.left(filename.lastIndexOf('.')); // Remove file extension datasets[filename] = file_data; file.close(); // 4) Add new dataset to the trace selection combobox QCombobox_datasets->addItem(filename); - QString current_dataset = QCombobox_datasets->currentText(); // Update traces updateTracesCombo(); } @@ -780,7 +879,7 @@ void Qucs_S_SPAR_Viewer::addFiles(QStringList fileNames) QString filename; for (int i = 0; i < fileNames.length(); i++){ filename = QFileInfo(fileNames.at(i)).fileName(); - filename = filename.left(filename.indexOf('.')); + filename = filename.left(filename.lastIndexOf('.')); // Pick a random color QColor trace_color = QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)); this->addTrace(filename, QString("S21"), trace_color); @@ -836,7 +935,10 @@ void Qucs_S_SPAR_Viewer::removeFile(int index_to_delete) QList indices_to_remove; for (int i = 0; i < List_TraceNames.size(); i++){ QString trace_name = List_TraceNames.at(i)->text(); - QStringList parts = trace_name.split(".");//Trace name = dataset + trace + QStringList parts = { + trace_name.section('.', 0, -2), + trace_name.section('.', -1) + }; QString dataset_trace = parts[0]; if (dataset_trace == dataset_to_remove ){ QString Label_Object_Name = List_TraceNames.at(i)->objectName(); @@ -885,10 +987,11 @@ void Qucs_S_SPAR_Viewer::removeFile(int index_to_delete) } } - // Check if there are more files. If not, remove markers - if (datasets.keys().size() == 0) + // Check if there are more files. If not, remove markers and limits + if (datasets.size() == 0) { removeAllMarkers(); + removeAllLimits(); } } @@ -975,6 +1078,8 @@ void Qucs_S_SPAR_Viewer::removeTrace(int index_to_delete) for (int i = 0; i < files.size(); i++){ adjust_x_axis_to_file(files[i]); } + + updateGridLayout(TracesGrid); } @@ -1082,7 +1187,7 @@ void Qucs_S_SPAR_Viewer::addTrace() // Read the dataset and trace Comboboxes and add a trace to the display list -void Qucs_S_SPAR_Viewer::addTrace(QString selected_dataset, QString selected_trace, QColor trace_color) +void Qucs_S_SPAR_Viewer::addTrace(QString selected_dataset, QString selected_trace, QColor trace_color, int trace_width, QString trace_style) { int n_trace = this->trace_list.size()+1; // Number of displayed traces; // Get the name of the selected dataset @@ -1105,13 +1210,13 @@ void Qucs_S_SPAR_Viewer::addTrace(QString selected_dataset, QString selected_tra // Label QLabel * new_trace_label = new QLabel(trace_name); - new_trace_label->setObjectName(QString("Trace_Name_") + QString::number(n_trace)); + new_trace_label->setObjectName(QString("Trace_Name_") + trace_name); List_TraceNames.append(new_trace_label); this->TracesGrid->addWidget(new_trace_label, n_trace, 0); // Color picker QPushButton * new_trace_color = new QPushButton(); - new_trace_color->setObjectName(QString("Trace_Color_") + QString::number(n_trace)); + new_trace_color->setObjectName(QString("Trace_Color_") + trace_name); connect(new_trace_color, SIGNAL(clicked()), SLOT(changeTraceColor())); QString styleSheet = QString("QPushButton { background-color: %1; }").arg(trace_color.name()); new_trace_color->setStyleSheet(styleSheet); @@ -1121,20 +1226,22 @@ void Qucs_S_SPAR_Viewer::addTrace(QString selected_dataset, QString selected_tra // Line Style QComboBox * new_trace_linestyle = new QComboBox(); - new_trace_linestyle->setObjectName(QString("Trace_LineStyle_") + QString::number(n_trace)); + new_trace_linestyle->setObjectName(QString("Trace_LineStyle_") + trace_name); new_trace_linestyle->addItem("Solid"); new_trace_linestyle->addItem("- - - -"); new_trace_linestyle->addItem("·······"); new_trace_linestyle->addItem("-·-·-·-"); new_trace_linestyle->addItem("-··-··-"); + int index = new_trace_linestyle->findText(trace_style); + new_trace_linestyle->setCurrentIndex(index); connect(new_trace_linestyle, SIGNAL(currentIndexChanged(int)), SLOT(changeTraceLineStyle())); List_Trace_LineStyle.append(new_trace_linestyle); this->TracesGrid->addWidget(new_trace_linestyle, n_trace, 2); // Line width QSpinBox * new_trace_width = new QSpinBox(); - new_trace_width->setObjectName(QString("Trace_Width_") + QString::number(n_trace)); - new_trace_width->setValue(1); + new_trace_width->setObjectName(QString("Trace_Width_") + trace_name); + new_trace_width->setValue(trace_width); connect(new_trace_width, SIGNAL(valueChanged(int)), SLOT(changeTraceWidth())); List_TraceWidth.append(new_trace_width); this->TracesGrid->addWidget(new_trace_width, n_trace, 3); @@ -1142,7 +1249,7 @@ void Qucs_S_SPAR_Viewer::addTrace(QString selected_dataset, QString selected_tra // Remove button QToolButton * new_trace_removebutton = new QToolButton(); - new_trace_removebutton->setObjectName(QString("Trace_RemoveButton_") + QString::number(n_trace)); + new_trace_removebutton->setObjectName(QString("Trace_RemoveButton_") + trace_name); QIcon icon(":/bitmaps/trash.png"); // Use a resource path or a relative path new_trace_removebutton->setIcon(icon); new_trace_removebutton->setStyleSheet(R"( @@ -1150,14 +1257,12 @@ void Qucs_S_SPAR_Viewer::addTrace(QString selected_dataset, QString selected_tra background-color: #FF0000; color: white; border-radius: 20px; + margin: auto; } )"); connect(new_trace_removebutton, SIGNAL(clicked()), SLOT(removeTrace())); List_Button_DeleteTrace.append(new_trace_removebutton); - this->TracesGrid->addWidget(new_trace_removebutton, n_trace, 4, Qt::AlignCenter); - - adjust_x_axis_to_file(selected_dataset); - adjust_y_axis_to_trace(selected_dataset, selected_trace); + this->TracesGrid->addWidget(new_trace_removebutton, n_trace, 4); QLineSeries* series = new QLineSeries(); series->setName(trace_name); @@ -1331,9 +1436,11 @@ void Qucs_S_SPAR_Viewer::changeTraceWidth() void Qucs_S_SPAR_Viewer::updatePlot() { + if (lock_axis == false){ // Update axes update_X_axis(); update_Y_axis(); + } // Trim the traces according to the new settings updateTraces(); @@ -1368,7 +1475,7 @@ void Qucs_S_SPAR_Viewer::update_X_axis() xAxis->setRange(x_min, x_max); // Set the range of the axis xAxis->setTickInterval(x_div); // Set the interval between ticks xAxis->setTickCount(floor((x_max-x_min)/x_div)+1); - xAxis->setTitleText("frequency " + QCombobox_x_axis_units->currentText()); + xAxis->setTitleText("frequency (" + QCombobox_x_axis_units->currentText() + ")"); // Add the axis to the chart chart->addAxis(xAxis, Qt::AlignBottom); @@ -1415,9 +1522,17 @@ void Qucs_S_SPAR_Viewer::updateTraces() QList seriesList = chart->series(); // Remove series from the chart - for (QAbstractSeries *series : seriesList) { - chart->removeSeries(series); - } + for (QAbstractSeries *series : qAsConst(seriesList)) { + chart->removeSeries(series); + } + + + // Remove all custom labels + for (QGraphicsItem* label : textLabels) { + chart->scene()->removeItem(label); + delete label; + } + textLabels.clear(); double freq_scale = getFreqScale(); @@ -1428,16 +1543,19 @@ void Qucs_S_SPAR_Viewer::updateTraces() double y_axis_min = QSpinBox_y_axis_min->value(); double y_axis_max = QSpinBox_y_axis_max->value(); - // Remove marker traces + // Remove marker and limit traces // Iterate through the series list QList seriesToRemove; - for (QAbstractSeries *series : seriesList) { + for (QAbstractSeries *series : qAsConst(seriesList)) { //qDebug() << series->name(); if (series->name().startsWith("Mkr", Qt::CaseInsensitive)) { seriesToRemove.append(series); } + if (series->name().startsWith("Limit", Qt::CaseInsensitive)) { + seriesToRemove.append(series); + } } - for (QAbstractSeries *series : seriesToRemove) { + for (QAbstractSeries *series : qAsConst(seriesToRemove)) { seriesList.removeOne(series); // If the series is added to a chart, remove it from the chart as well @@ -1454,11 +1572,14 @@ void Qucs_S_SPAR_Viewer::updateTraces() // 2) If so, trim the trace according to the new limits // 3) If not, add extra padding - for (QAbstractSeries *series : seriesList) { + for (QAbstractSeries *series : qAsConst(seriesList)) { QString trace_name = series->name(); qreal minX_trace, maxX_trace, minY_trace, maxY_trace; - QStringList trace_name_parts = trace_name.split('.'); + QStringList trace_name_parts = { + trace_name.section('.', 0, -2), + trace_name.section('.', -1) + }; QString data_file = trace_name_parts[0]; QString trace_file = trace_name_parts[1]; @@ -1557,11 +1678,68 @@ void Qucs_S_SPAR_Viewer::updateTraces() verticalLine->setName(verticalLine_name); seriesList.append(verticalLine); + + QGraphicsTextItem *textItem = new QGraphicsTextItem(chart); + QString freq_marker = tableMarkers->item(r,0)->text(); + textItem->setPlainText(QString("%1").arg(freq_marker)); + textItem->setFont(QFont("Arial", 8)); + + // Get the axes + auto axes = chart->axes(Qt::Horizontal); + QValueAxis *xAxis = qobject_cast(axes.first()); + qreal xRatio = (x - xAxis->min()) / (xAxis->max() - xAxis->min()); + + // Calculate the position + QRectF plotArea = chart->plotArea(); + qreal xPixel = plotArea.left() + xRatio * plotArea.width(); + + // Center the text horizontally + QFontMetrics fm(textItem->font()); + int textWidth = fm.horizontalAdvance(textItem->toPlainText()); + qreal textX = xPixel - textWidth / 2; + + // Position above the chart area + qreal textY = plotArea.top() - fm.height() - 5; // 5 pixels above the plot area + + textItem->setPos(textX, textY); + textLabels.append(textItem); } } + // Add limits + double limits_offset = Limits_Offset->value(); + for (int i = 0; i < List_LimitNames.size(); i++){ + // Start frequency + double fstart = List_Limit_Start_Freq[i]->value(); + double fstart_scale = getFreqScale(List_Limit_Start_Freq_Scale[i]->currentText()); + fstart = fstart / fstart_scale;// Hz + fstart *= getFreqScale();// Normalize x with respect to the axis scale + + // Stop frequency + double fstop = List_Limit_Stop_Freq[i]->value(); + double fstop_scale = getFreqScale(List_Limit_Stop_Freq_Scale[i]->currentText()); + fstop = fstop / fstop_scale;// Hz + fstop *= getFreqScale();// Normalize x with respect to the axis scale + + // Start value + double val_start = List_Limit_Start_Value[i]->value()+limits_offset; + + // Stop value + double val_stop = List_Limit_Stop_Value[i]->value()+limits_offset; + + QLineSeries *limitLine = new QLineSeries(); + limitLine->append(fstart, val_start); + limitLine->append(fstop, val_stop); + limitLine->setPen(QPen(Qt::black, 2)); + + QString limitLine_name = QString("Limit_%1").arg(i); + limitLine->setName(limitLine_name); + + seriesList.append(limitLine); + } + // Add series again to the chart. Each series must be linked to an axis - for (QAbstractSeries *series : seriesList) { + for (QAbstractSeries *series : qAsConst(seriesList)) { chart->addSeries(series); series->attachAxis(xAxis); series->attachAxis(yAxis); @@ -1788,11 +1966,27 @@ void Qucs_S_SPAR_Viewer::adjust_x_axis_to_file(QString filename){ } -void Qucs_S_SPAR_Viewer::addMarker(){ - double f1 = QSpinBox_x_axis_min->value(); - double f2 = QSpinBox_x_axis_max->value(); - double f_marker = f1 + 0.5*(f2-f1); +void Qucs_S_SPAR_Viewer::addMarker(double freq){ + + // If there are no traces in the display, show a message and exit + if (trace_list.size() == 0){ + QMessageBox::information( + this, + tr("Warning"), + tr("The display contains no traces.") ); + return; + } + double f_marker; + if (freq == -1) { + // There's no specific frequency argument, then pick the middle point + double f1 = QSpinBox_x_axis_min->value(); + double f2 = QSpinBox_x_axis_max->value(); + f_marker = f1 + 0.5*(f2-f1); + } else { + f_marker= freq; + f_marker *= getFreqScale();// Scale according to the x-axis units + } QString Freq_Marker_Scale = QCombobox_x_axis_units->currentText(); int n_markers = List_MarkerNames.size(); @@ -1817,10 +2011,7 @@ void Qucs_S_SPAR_Viewer::addMarker(){ QString Combobox_name = QString("Mkr_ComboBox%1").arg(n_markers); QComboBox * new_marker_Combo = new QComboBox(); new_marker_Combo->setObjectName(Combobox_name); - new_marker_Combo->addItem("Hz"); - new_marker_Combo->addItem("kHz"); - new_marker_Combo->addItem("MHz"); - new_marker_Combo->addItem("GHz"); + new_marker_Combo->addItems(frequency_units); new_marker_Combo->setCurrentIndex(QCombobox_x_axis_units->currentIndex()); connect(new_marker_Combo, SIGNAL(currentIndexChanged(int)), SLOT(changeMarkerLimits())); List_MarkerScale.append(new_marker_Combo); @@ -1873,10 +2064,10 @@ void Qucs_S_SPAR_Viewer::updateMarkerTable(){ QStringList headers; headers.clear(); headers.append("freq"); - for (QAbstractSeries *series : seriesList) { + for (QAbstractSeries *series : qAsConst(seriesList)) { QString series_name = series->name(); - if (series_name.startsWith("Mkr", Qt::CaseSensitive)){ - //Markers are traces in the QChart, but they cannot be added as markers again! + if (series_name.startsWith("Mkr", Qt::CaseSensitive) || series_name.startsWith("Limit", Qt::CaseSensitive)){ + //Markers and limits are traces in the QChart, but they cannot be added as markers again! continue; } headers.append(series_name); @@ -1903,9 +2094,19 @@ void Qucs_S_SPAR_Viewer::updateMarkerTable(){ continue; } targetX = getFreqFromText(freq_marker); - //Normalize with respect to the scale of the x-axis - targetX = targetX*getFreqScale(); - P = findClosestPoint(seriesList[c-1], targetX); + // Look into dataset, traces may be clipped. + // It is important to grab the data from the dataset, not from the displayed trace. + QString trace_name = seriesList[c-1]->name(); + QStringList parts = { + trace_name.section('.', 0, -2), + trace_name.section('.', -1) + }; + QString file = parts[0]; + QString trace = parts[1]; + if (trace.at(0) == 'S'){ + trace.append("_dB"); + } + P = findClosestPoint(datasets[file]["frequency"], datasets[file][trace], targetX); new_val = QString("%1").arg(QString::number(P.y(), 'f', 2)); QTableWidgetItem *new_item = new QTableWidgetItem(new_val); tableMarkers->setItem(r, c, new_item); @@ -1916,33 +2117,26 @@ void Qucs_S_SPAR_Viewer::updateMarkerTable(){ } // Find the closest x-axis value in a series given a x value (not necesarily in the grid) -QPointF Qucs_S_SPAR_Viewer::findClosestPoint(QAbstractSeries* series, qreal targetX) +QPointF Qucs_S_SPAR_Viewer::findClosestPoint(const QList& xValues, const QList& yValues, double targetX) { - // Cast to QXYSeries since we need access to points - QXYSeries* xySeries = qobject_cast(series); - if (!xySeries) { - return QPointF(); // Return invalid point if cast fails - } - - QVector points = xySeries->points().toVector(); - if (points.isEmpty()) { - return QPointF(); // Return invalid point if series is empty - } + if (xValues.isEmpty() || yValues.isEmpty() || xValues.size() != yValues.size()) { + return QPointF(); // Return invalid point if lists are empty or have different sizes + } - // Initialize with the first point - QPointF closestPoint = points.first(); - qreal minDistance = qAbs(targetX - closestPoint.x()); + // Initialize with the first point + QPointF closestPoint(xValues.first(), yValues.first()); + double minDistance = qAbs(targetX - closestPoint.x()); - // Iterate through all points to find the closest one - for (const QPointF& point : points) { - qreal distance = qAbs(targetX - point.x()); - if (distance < minDistance) { - minDistance = distance; - closestPoint = point; - } + // Iterate through all points to find the closest one + for (int i = 0; i < xValues.size(); ++i) { + double distance = qAbs(targetX - xValues[i]); + if (distance < minDistance) { + minDistance = distance; + closestPoint = QPointF(xValues[i], yValues[i]); } + } - return closestPoint; + return closestPoint; } @@ -1978,7 +2172,7 @@ double Qucs_S_SPAR_Viewer::getFreqFromText(QString freq) } -// This function is called when the user wants to remove a trace from the plot +// This function is called when the user wants to remove a marker from the plot void Qucs_S_SPAR_Viewer::removeMarker() { QString ID = qobject_cast(sender())->objectName(); @@ -2023,6 +2217,8 @@ void Qucs_S_SPAR_Viewer::removeMarker(int index_to_delete) delete ButtonToRemove; updateMarkerTable(); + updateMarkerNames(); + updateGridLayout(MarkersGrid); } void Qucs_S_SPAR_Viewer::removeAllMarkers() @@ -2031,8 +2227,119 @@ void Qucs_S_SPAR_Viewer::removeAllMarkers() for (int i = 0; i < n_markers; i++) { removeMarker(n_markers-i-1); } +} + +// After removing a marker, the names of the other markers must be updated +void Qucs_S_SPAR_Viewer::updateMarkerNames() +{ + int n_markers = List_MarkerNames.size(); + for (int i = 0; i < n_markers; i++) { + QLabel * MarkerLabel = List_MarkerNames[i]; + MarkerLabel->setText(QString("Mkr%1").arg(i+1)); + } +} + +// After removing a marker, the names of the other markers must be updated +void Qucs_S_SPAR_Viewer::updateLimitNames() +{ + int n_limits = List_LimitNames.size(); + for (int i = 0; i < n_limits; i++) { + QLabel * LimitLabel = List_LimitNames[i]; + LimitLabel->setText(QString("Limit %1").arg(i+1)); + } +} + +// This function is called when the user wants to remove a limit from the plot +void Qucs_S_SPAR_Viewer::removeLimit() +{ + QString ID = qobject_cast(sender())->objectName(); + //qDebug() << "Clicked button:" << ID; + + //Find the index of the button to remove + int index_to_delete = -1; + for (int i = 0; i < List_Button_Delete_Limit.size(); i++) { + if (List_Button_Delete_Limit.at(i)->objectName() == ID) { + index_to_delete = i; + break; + } + } + removeLimit(index_to_delete); +} + +void Qucs_S_SPAR_Viewer::removeLimit(int index_to_delete) +{ + // Delete the label + QLabel* labelToRemove = List_LimitNames.at(index_to_delete); + LimitsGrid->removeWidget(labelToRemove); + List_LimitNames.removeAt(index_to_delete); + delete labelToRemove; + + // Delete the fstart SpinBox + QDoubleSpinBox * SpinBox_fstart_ToRemove = List_Limit_Start_Freq.at(index_to_delete); + LimitsGrid->removeWidget(SpinBox_fstart_ToRemove); + List_Limit_Start_Freq.removeAt(index_to_delete); + delete SpinBox_fstart_ToRemove; + + // Delete the fstop SpinBox + QDoubleSpinBox * SpinBox_fstop_ToRemove = List_Limit_Stop_Freq.at(index_to_delete); + LimitsGrid->removeWidget(SpinBox_fstop_ToRemove); + List_Limit_Stop_Freq.removeAt(index_to_delete); + delete SpinBox_fstop_ToRemove; + + // Delete the start value SpinBox + QDoubleSpinBox * SpinBox_val_start_ToRemove = List_Limit_Start_Value.at(index_to_delete); + LimitsGrid->removeWidget(SpinBox_val_start_ToRemove); + List_Limit_Start_Value.removeAt(index_to_delete); + delete SpinBox_val_start_ToRemove; + + // Delete the stop value SpinBox + QDoubleSpinBox * SpinBox_val_stop_ToRemove = List_Limit_Stop_Value.at(index_to_delete); + LimitsGrid->removeWidget(SpinBox_val_stop_ToRemove); + List_Limit_Stop_Value.removeAt(index_to_delete); + delete SpinBox_val_stop_ToRemove; + + //Delete frequency scale combo. fstart + QComboBox* Combo_fstart_ToRemove = List_Limit_Start_Freq_Scale.at(index_to_delete); + LimitsGrid->removeWidget(Combo_fstart_ToRemove); + List_Limit_Start_Freq_Scale.removeAt(index_to_delete); + delete Combo_fstart_ToRemove; + + //Delete frequency scale combo. fstop + QComboBox* Combo_fstop_ToRemove = List_Limit_Stop_Freq_Scale.at(index_to_delete); + LimitsGrid->removeWidget(Combo_fstop_ToRemove); + List_Limit_Stop_Freq_Scale.removeAt(index_to_delete); + delete Combo_fstop_ToRemove; + + // Delete the "delete" button + QToolButton* ButtonToRemove = List_Button_Delete_Limit.at(index_to_delete); + LimitsGrid->removeWidget(ButtonToRemove); + List_Button_Delete_Limit.removeAt(index_to_delete); + delete ButtonToRemove; + + // Delete the "coupled" button + QPushButton* ButtonCoupledToRemove = List_Couple_Value.at(index_to_delete); + LimitsGrid->removeWidget(ButtonCoupledToRemove); + List_Couple_Value.removeAt(index_to_delete); + delete ButtonCoupledToRemove; + + // Delete the separator + QFrame* SeparatorToRemove = List_Separators.at(index_to_delete); + LimitsGrid->removeWidget(SeparatorToRemove); + List_Separators.removeAt(index_to_delete); + delete SeparatorToRemove; + + updateTraces(); + + updateGridLayout(LimitsGrid); + updateLimitNames(); +} - // Remove marker traces +void Qucs_S_SPAR_Viewer::removeAllLimits() +{ + int n_limits = List_LimitNames.size(); + for (int i = 0; i < n_limits; i++) { + removeLimit(n_limits-i-1); + } } void Qucs_S_SPAR_Viewer::changeFreqUnits() @@ -2093,6 +2400,11 @@ void Qucs_S_SPAR_Viewer::adjust_x_axis_div() disconnect(QComboBox_x_axis_div, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePlot())); QComboBox_x_axis_div->setCurrentIndex(new_index); connect(QComboBox_x_axis_div, SIGNAL(currentIndexChanged(int)), SLOT(updatePlot())); + + //Update the step of the spinboxes + double step = QComboBox_x_axis_div->currentText().toDouble()/10; + QSpinBox_x_axis_min->setSingleStep(step); + QSpinBox_x_axis_max->setSingleStep(step); } } @@ -2168,13 +2480,756 @@ void Qucs_S_SPAR_Viewer::dropEvent(QDropEvent *event) QList urls = event->mimeData()->urls(); QStringList fileList; - for (const QUrl &url : urls) { + for (const QUrl &url : qAsConst(urls)) { if (url.isLocalFile()) { fileList << url.toLocalFile(); } } if (!fileList.isEmpty()) { - addFiles(fileList); + // Check if this is a session file + if (fileList.size() == 1){ + if (fileList.first().endsWith(".spar", Qt::CaseInsensitive)) {// Then open it as a session settings file. + // Remove traces and the dataset from the current session before loading the session file + removeAllFiles(); + loadSession(fileList.first()); + this->activateWindow(); + return; + } + } + + addFiles(fileList); + this->activateWindow(); + } +} + + +void Qucs_S_SPAR_Viewer::lock_unlock_axis_settings(bool toogle) +{ + if (toogle == true) { + lock_axis = !lock_axis; + } + + if (lock_axis == false){ + Lock_axis_settings_Button->setText("Lock Axes"); + //Frozen axes inputs + QSpinBox_x_axis_min->setEnabled(true); + QSpinBox_x_axis_max->setEnabled(true); + QComboBox_x_axis_div->setEnabled(true); + QCombobox_x_axis_units->setEnabled(true); + QSpinBox_y_axis_min->setEnabled(true); + QSpinBox_y_axis_max->setEnabled(true); + QComboBox_y_axis_div->setEnabled(true); + } + else{ + Lock_axis_settings_Button->setText("Unlock Axes"); + //Unfrozen axes inputs + QSpinBox_x_axis_min->setDisabled(true); + QSpinBox_x_axis_max->setDisabled(true); + QComboBox_x_axis_div->setDisabled(true); + QCombobox_x_axis_units->setDisabled(true); + QSpinBox_y_axis_min->setDisabled(true); + QSpinBox_y_axis_max->setDisabled(true); + QComboBox_y_axis_div->setDisabled(true); + } +} + + +void Qucs_S_SPAR_Viewer::addLimit(double f_limit1, QString f_limit1_unit, double f_limit2, QString f_limit2_unit, double y_limit1, double y_limit2, bool coupled) +{ + // If there are no traces in the display, show a message and exit + if (trace_list.size() == 0){ + QMessageBox::information( + this, + tr("Warning"), + tr("The display contains no traces.") ); + return; + } + + if (f_limit1 == -1) { + // There's no specific data passed. Then get it from the widgets + double f1 = QSpinBox_x_axis_min->value(); + double f2 = QSpinBox_x_axis_max->value(); + f_limit1 = f1 + 0.25*(f2-f1); + f_limit2 = f1 + 0.75*(f2-f1); + + double y1 = QSpinBox_y_axis_min->value(); + double y2 = QSpinBox_y_axis_max->value(); + + y_limit1 = y1 + (y2-y1)/2; + y_limit2 = y_limit1; + + } + + int n_limits = List_LimitNames.size(); + n_limits++; + int limit_index = 3*n_limits-2; + + QString tooltip_message; + + QString new_limit_name = QString("Limit %1").arg(n_limits); + QLabel * new_limit_label = new QLabel(new_limit_name); + new_limit_label->setObjectName(new_limit_name); + List_LimitNames.append(new_limit_label); + this->LimitsGrid->addWidget(new_limit_label, limit_index, 0); + + QString SpinBox_fstart_name = QString("Lmt_Freq_Start_SpinBox_%1").arg(new_limit_name); + QDoubleSpinBox * new_limit_fstart_Spinbox = new QDoubleSpinBox(); + new_limit_fstart_Spinbox->setObjectName(SpinBox_fstart_name); + new_limit_fstart_Spinbox->setMaximum(QSpinBox_x_axis_max->minimum()); + new_limit_fstart_Spinbox->setMaximum(QSpinBox_x_axis_max->maximum()); + new_limit_fstart_Spinbox->setSingleStep(QComboBox_x_axis_div->currentText().toDouble()/5); + new_limit_fstart_Spinbox->setValue(f_limit1); + connect(new_limit_fstart_Spinbox, SIGNAL(valueChanged(double)), SLOT(updateTraces())); + List_Limit_Start_Freq.append(new_limit_fstart_Spinbox); + this->LimitsGrid->addWidget(new_limit_fstart_Spinbox, limit_index, 1); + + QString Combobox_start_name = QString("Lmt_Start_ComboBox_%1").arg(new_limit_name); + QComboBox * new_start_limit_Combo = new QComboBox(); + new_start_limit_Combo->setObjectName(Combobox_start_name); + new_start_limit_Combo->addItems(frequency_units); + if (f_limit1_unit.isEmpty()){ + new_start_limit_Combo->setCurrentIndex(QCombobox_x_axis_units->currentIndex()); + } else { + int index = new_start_limit_Combo->findText(f_limit1_unit); + new_start_limit_Combo->setCurrentIndex(index); + } + connect(new_start_limit_Combo, SIGNAL(currentIndexChanged(int)), SLOT(updateTraces())); + List_Limit_Start_Freq_Scale.append(new_start_limit_Combo); + this->LimitsGrid->addWidget(new_start_limit_Combo, limit_index, 2); + + QString SpinBox_fstop_name = QString("Lmt_Freq_Stop_SpinBox_%1").arg(new_limit_name); + QDoubleSpinBox * new_limit_fstop_Spinbox = new QDoubleSpinBox(); + new_limit_fstop_Spinbox->setObjectName(SpinBox_fstop_name); + new_limit_fstop_Spinbox->setMaximum(QSpinBox_x_axis_max->minimum()); + new_limit_fstop_Spinbox->setMaximum(QSpinBox_x_axis_max->maximum()); + new_limit_fstop_Spinbox->setSingleStep(QComboBox_x_axis_div->currentText().toDouble()/5); + new_limit_fstop_Spinbox->setValue(f_limit2); + connect(new_limit_fstop_Spinbox, SIGNAL(valueChanged(double)), SLOT(updateTraces())); + List_Limit_Stop_Freq.append(new_limit_fstop_Spinbox); + this->LimitsGrid->addWidget(new_limit_fstop_Spinbox, limit_index, 3); + + QString Combobox_stop_name = QString("Lmt_Stop_ComboBox_%1").arg(new_limit_name); + QComboBox * new_stop_limit_Combo = new QComboBox(); + new_stop_limit_Combo->setObjectName(Combobox_stop_name); + new_stop_limit_Combo->addItems(frequency_units); + if (f_limit2_unit.isEmpty()){ + new_stop_limit_Combo->setCurrentIndex(QCombobox_x_axis_units->currentIndex()); + } else { + int index = new_stop_limit_Combo->findText(f_limit2_unit); + new_stop_limit_Combo->setCurrentIndex(index); + } + + connect(new_stop_limit_Combo, SIGNAL(currentIndexChanged(int)), SLOT(updateTraces())); + List_Limit_Stop_Freq_Scale.append(new_stop_limit_Combo); + this->LimitsGrid->addWidget(new_stop_limit_Combo, limit_index, 4); + + // Remove button + QString DeleteButton_name = QString("Lmt_Delete_Btn_%1").arg(new_limit_name); + QToolButton * new_limit_removebutton = new QToolButton(); + new_limit_removebutton->setObjectName(DeleteButton_name); + tooltip_message = QString("Remove this limit"); + new_limit_removebutton->setToolTip(tooltip_message); + QIcon icon(":/bitmaps/trash.png"); + new_limit_removebutton->setIcon(icon); + new_limit_removebutton->setStyleSheet(R"( + QToolButton { + background-color: #FF0000; + color: white; + border-radius: 20px; + } + )"); + connect(new_limit_removebutton, SIGNAL(clicked()), SLOT(removeLimit())); + List_Button_Delete_Limit.append(new_limit_removebutton); + this->LimitsGrid->addWidget(new_limit_removebutton, limit_index, 5, Qt::AlignCenter); + + QString SpinBox_val_start_name = QString("Lmt_Val_Start_SpinBox_%1").arg(new_limit_name); + QDoubleSpinBox * new_limit_val_start_Spinbox = new QDoubleSpinBox(); + new_limit_val_start_Spinbox->setObjectName(SpinBox_val_start_name); + new_limit_val_start_Spinbox->setMaximum(QSpinBox_y_axis_max->minimum()); + new_limit_val_start_Spinbox->setMaximum(QSpinBox_y_axis_max->maximum()); + new_limit_val_start_Spinbox->setValue(y_limit1); + new_limit_val_start_Spinbox->setSingleStep(QComboBox_y_axis_div->currentText().toDouble()/5); + connect(new_limit_val_start_Spinbox, SIGNAL(valueChanged(double)), SLOT(updateLimits())); + List_Limit_Start_Value.append(new_limit_val_start_Spinbox); + this->LimitsGrid->addWidget(new_limit_val_start_Spinbox, limit_index+1, 1); + + // Coupled spinbox value + QString CoupleButton_name = QString("Lmt_Couple_Btn_%1").arg(new_limit_name); + QPushButton * new_limit_CoupleButton = new QPushButton("<--->"); + new_limit_CoupleButton->setObjectName(CoupleButton_name); + new_limit_CoupleButton->setChecked(coupled); + tooltip_message = QString("Couple start and stop values"); + new_limit_CoupleButton->setToolTip(tooltip_message); + connect(new_limit_CoupleButton, SIGNAL(clicked(bool)), SLOT(coupleSpinBoxes())); + List_Couple_Value.append(new_limit_CoupleButton); + this->LimitsGrid->addWidget(new_limit_CoupleButton, limit_index+1, 2); + + QString SpinBox_val_stop_name = QString("Lmt_Val_Stop_SpinBox_%1").arg(new_limit_name); + QDoubleSpinBox * new_limit_val_stop_Spinbox = new QDoubleSpinBox(); + new_limit_val_stop_Spinbox->setObjectName(SpinBox_val_stop_name); + new_limit_val_stop_Spinbox->setMaximum(QSpinBox_y_axis_max->minimum()); + new_limit_val_stop_Spinbox->setMaximum(QSpinBox_y_axis_max->maximum()); + new_limit_val_stop_Spinbox->setValue(y_limit2); + new_limit_val_stop_Spinbox->setSingleStep(QComboBox_y_axis_div->currentText().toDouble()/5); + connect(new_limit_val_stop_Spinbox, SIGNAL(valueChanged(double)), SLOT(updateLimits())); + List_Limit_Stop_Value.append(new_limit_val_stop_Spinbox); + this->LimitsGrid->addWidget(new_limit_val_stop_Spinbox, limit_index+1, 3); + + if (coupled){ + new_limit_CoupleButton->setText("<--->"); + } else { + new_limit_CoupleButton->setText("<-X->"); + } + new_limit_CoupleButton->click(); + + QString Separator_name = QString("Lmt_Separator_%1").arg(new_limit_name); + QFrame * new_Separator = new QFrame(); + new_Separator->setObjectName(Separator_name); + new_Separator->setFrameShape(QFrame::HLine); + new_Separator->setFrameShadow(QFrame::Sunken); + List_Separators.append(new_Separator); + this->LimitsGrid->addWidget(new_Separator, limit_index+2, 0, 1, 6); + + updateTraces(); + +} + +void Qucs_S_SPAR_Viewer::coupleSpinBoxes(){ + + QPushButton* button = qobject_cast(sender()); + // Get the button ID, from it we can get the index and then lock the upper limit spinbox + QString name_button = button->objectName(); + // Get the limit name + int lastUnderscoreIndex = name_button.lastIndexOf('_'); + QString limit_name = name_button.mid(lastUnderscoreIndex + 1); + + // Get a list with the limit names + QList labelNames; + for (const QLabel *label : qAsConst(List_LimitNames)) { + labelNames.append(label->text()); + } + + int index = labelNames.indexOf(limit_name); + + QDoubleSpinBox * upper_limit_spinbox = List_Limit_Stop_Value.at(index); + + if (button->text() == "<--->"){ + button->setText("<-X->"); + QString tooltip_message = QString("Uncouple start and stop values"); + button->setToolTip(tooltip_message); + QDoubleSpinBox * lower_limit_spinbox = List_Limit_Start_Value.at(index); + upper_limit_spinbox->setValue(lower_limit_spinbox->value()); + upper_limit_spinbox->setDisabled(true); + }else{ + button->setText("<--->"); + upper_limit_spinbox->setEnabled(true); + } +} + +// This function is called when a limit widget is changed. It is needed in case some value-coupling +// button is activated +void Qucs_S_SPAR_Viewer::updateLimits() +{ + // First check if some value-coupling button is activated. If not, simply call updateTraces() + int n_limits = List_Couple_Value.size(); + for (int i = 0; i < n_limits; i++) { + QPushButton* button = List_Couple_Value.at(i); + if (button->text() == "<-X->"){ + // The control is locked. Set the stop value equal to the start value + QDoubleSpinBox* start = List_Limit_Start_Value.at(i); + QDoubleSpinBox* stop = List_Limit_Stop_Value.at(i); + double val_start = start->value(); + stop->setValue(val_start); + } + } + updateTraces(); +} + + +void Qucs_S_SPAR_Viewer::slotSave() +{ + if (savepath.isEmpty()){ + slotSaveAs(); + return; + } + save(); +} + +void Qucs_S_SPAR_Viewer::slotSaveAs() +{ + if (datasets.isEmpty()){ + // Nothing to save + QMessageBox::information( + this, + tr("Error"), + tr("Nothing to save: No data was loaded.") ); + return; + } + + // Get the path to save + savepath = QFileDialog::getSaveFileName(this, + tr("Save session"), + QDir::homePath() + "/ViewerSession.spar", + tr("Qucs-S snp viewer session (*.spar);")); + + // If the user decides not to enter a path, then return. + if (savepath.isEmpty()){ + return; + } + save(); +} + +bool Qucs_S_SPAR_Viewer::save() +{ + if (datasets.isEmpty()){ + // Nothing to save + QMessageBox::information( + this, + tr("Error"), + tr("Nothing to save: No data was loaded.") ); + return false; + } + QFile file(savepath); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + return false; + } + + QXmlStreamWriter xmlWriter(&file); + xmlWriter.setAutoFormatting(true); + xmlWriter.writeStartDocument(); + xmlWriter.writeStartElement("DATA");//Top level + + // ---------------------------------------------------------------- + // Save the markers + if (List_MarkerFreq.size() != 0){ + xmlWriter.writeStartElement("MARKERS"); + double freq; + for (int i = 0; i < List_MarkerFreq.size(); i++) + { + freq = List_MarkerFreq[i]->value(); + QString scale = List_MarkerScale[i]->currentText(); + freq /= getFreqScale(scale); + xmlWriter.writeTextElement("Mkr", QString::number(freq)); + } + xmlWriter.writeEndElement(); // Markers + } + // ---------------------------------------------------------------- + // Save the limits + if (List_Limit_Start_Freq.size() != 0){ + double freq, value; + bool Coupled_Limits; + xmlWriter.writeStartElement("LIMITS"); + + // Offset + value = Limits_Offset->value(); + xmlWriter.writeTextElement("offset", QString::number(value)); + + for (int i = 0; i < List_Limit_Start_Freq.size(); i++) + { + xmlWriter.writeStartElement("Limit"); + + // fstart + freq = List_Limit_Start_Freq[i]->value(); + xmlWriter.writeTextElement("fstart", QString::number(freq)); + + // fstart unit + QString fstart_unit = List_Limit_Start_Freq_Scale[i]->currentText(); + xmlWriter.writeTextElement("fstart_unit", fstart_unit); + + // Start value + value = List_Limit_Start_Value[i]->value(); + xmlWriter.writeTextElement("val_start", QString::number(value)); + + // fstop + freq = List_Limit_Stop_Freq[i]->value(); + xmlWriter.writeTextElement("fstop", QString::number(freq)); + + // fstop unit + QString fstop_unit = List_Limit_Stop_Freq_Scale[i]->currentText(); + xmlWriter.writeTextElement("fstop_unit", fstop_unit); + + // Stop value + value = List_Limit_Stop_Value[i]->value(); + xmlWriter.writeTextElement("val_stop", QString::number(value)); + + // Couple values + Coupled_Limits = (List_Couple_Value[i]->text() == "<-X->"); + xmlWriter.writeTextElement("couple_values", QString::number(Coupled_Limits)); + + xmlWriter.writeEndElement(); // Limit + } + xmlWriter.writeEndElement(); // Limits + } + // ---------------------------------------------------------------- + // Save the traces displayed and their properties + if (List_TraceNames.size() != 0){ + xmlWriter.writeStartElement("DISPLAYED_TRACES"); + QString trace_name, color, style; + int width; + for (int i = 0; i < List_TraceNames.size(); i++){ + xmlWriter.writeStartElement("trace"); + // Trace name + trace_name = List_TraceNames[i]->text(); + xmlWriter.writeTextElement("trace_name", trace_name); + + // Trace width + width = List_TraceWidth[i]->value(); + xmlWriter.writeTextElement("trace_width", QString::number(width)); + + // Trace color + color = List_Trace_Color[i]->palette().color(QPalette::Button).name(); + xmlWriter.writeTextElement("trace_color", color); + + // Trace style + style = List_Trace_LineStyle[i]->currentText(); + xmlWriter.writeTextElement("trace_style", style); + xmlWriter.writeEndElement(); // Trace + + } + xmlWriter.writeEndElement(); // Displayed traces + } + // ---------------------------------------------------------------- + // Save the axes settings + xmlWriter.writeStartElement("AXES"); + xmlWriter.writeTextElement("x-axis-min", QString::number(QSpinBox_x_axis_min->value())); + xmlWriter.writeTextElement("x-axis-max", QString::number(QSpinBox_x_axis_max->value())); + xmlWriter.writeTextElement("x-axis-div", QComboBox_x_axis_div->currentText()); + xmlWriter.writeTextElement("x-axis-scale", QCombobox_x_axis_units->currentText()); + xmlWriter.writeTextElement("y-axis-min", QString::number(QSpinBox_y_axis_min->value())); + xmlWriter.writeTextElement("y-axis-max", QString::number(QSpinBox_y_axis_max->value())); + xmlWriter.writeTextElement("y-axis-div", QComboBox_y_axis_div->currentText()); + xmlWriter.writeTextElement("lock_status", QString::number(lock_axis)); + + xmlWriter.writeEndElement(); // Axes + // ---------------------------------------------------------------- + // Save the datasets + xmlWriter.writeStartElement("DATASETS"); + for (auto outerIt = datasets.constBegin(); outerIt != datasets.constEnd(); ++outerIt) + { + xmlWriter.writeStartElement("file"); + xmlWriter.writeAttribute("file_name", outerIt.key()); + + const QMap>& innerMap = outerIt.value(); + for (auto innerIt = innerMap.constBegin(); innerIt != innerMap.constEnd(); ++innerIt) + { + xmlWriter.writeStartElement("trace"); + xmlWriter.writeAttribute("trace_name", innerIt.key()); + + const QList& values = innerIt.value(); + for (const double& value : values) + { + xmlWriter.writeTextElement("value", QString::number(value)); + } + + xmlWriter.writeEndElement(); // inner-item + } + + xmlWriter.writeEndElement(); // outer-item + } + + xmlWriter.writeEndElement(); // Datasets + // ---------------------------------------------------------------- + + + xmlWriter.writeEndElement(); // Top level + xmlWriter.writeEndDocument(); + + file.close(); + return true; +} + + +void Qucs_S_SPAR_Viewer::slotLoadSession() +{ + QString fileName = QFileDialog::getOpenFileName(this, + tr("Open S-parameter Viewer Session"), + QDir::homePath(), + tr("Qucs-S snp viewer session (*.spar);")); + + loadSession(fileName); +} + + +void Qucs_S_SPAR_Viewer::loadSession(QString session_file) +{ + QFile file(session_file); + + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Error opening file:" << file.errorString(); + return; + } + + savepath = session_file; + + QXmlStreamReader xml(&file); + + // Trace properties + QList trace_width; + QList trace_name, trace_color, trace_style; + + // Limit data + QList Limit_Start_Freq, Limit_Start_Val, Limit_Stop_Freq, Limit_Stop_Val; + QList Limit_Couple_Values; + QList Limit_Start_Freq_Unit, Limit_Stop_Freq_Unit; + double x_axis_min, x_axis_max, y_axis_min, y_axis_max; + int index_x_axis_units, index_x_axis_div, index_y_axis_div; + bool lock_axis_setting; + // Markers + QList Markers; + + // Clear current dataset + datasets.clear(); + + // Ensure that the axes settings are unlocked + lock_axis = true; + lock_unlock_axis_settings(); + + while (!xml.atEnd() && !xml.hasError()) { + // Read next element + QXmlStreamReader::TokenType token = xml.readNext(); + + // If token is StartElement, check element name + if (token == QXmlStreamReader::StartElement) { + if (xml.name() == QStringLiteral("trace")) { + while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == QStringLiteral("trace"))) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == QStringLiteral("trace_name")) { + trace_name.append(xml.readElementText()); + } else if (xml.name() == QStringLiteral("trace_width")) { + trace_width.append(xml.readElementText().toInt()); + } else if (xml.name() == QStringLiteral("trace_color")) { + trace_color.append(xml.readElementText()); + } else if (xml.name() == QStringLiteral("trace_style")) { + trace_style.append(xml.readElementText()); + } + } + } + } else if (xml.name().toString().contains("x-axis-min")) { + x_axis_min = xml.readElementText().toDouble(); + } else if (xml.name().toString().contains("x-axis-max")) { + x_axis_max = xml.readElementText().toDouble(); + } else if (xml.name().toString().contains("x-axis-div")) { + int x_axis_div = xml.readElementText().toInt(); + index_x_axis_div = available_x_axis_div.indexOf(x_axis_div); + } else if (xml.name().toString().contains("x-axis-scale")) { + QString x_axis_scale = xml.readElementText(); + index_x_axis_units = frequency_units.indexOf(x_axis_scale); + } else if (xml.name().toString().contains("y-axis-min")) { + y_axis_min = xml.readElementText().toDouble(); + } else if (xml.name().toString().contains("y-axis-max")) { + y_axis_max = xml.readElementText().toDouble(); + } else if (xml.name().toString().contains("y-axis-div")) { + int y_axis_div = xml.readElementText().toInt(); + index_y_axis_div = available_y_axis_div.indexOf(y_axis_div); + } else if (xml.name().toString().contains("lock_status")) { + lock_axis_setting = xml.readElementText().toInt(); + } else if (xml.name() == QStringLiteral("Limit")) { + while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == QStringLiteral("Limit"))) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == QStringLiteral("fstart")) { + Limit_Start_Freq.append(xml.readElementText().toDouble()); + } else if (xml.name() == QStringLiteral("val_start")) { + Limit_Start_Val.append(xml.readElementText().toDouble()); + } else if (xml.name() == QStringLiteral("fstop")) { + Limit_Stop_Freq.append(xml.readElementText().toDouble()); + } else if (xml.name() == QStringLiteral("val_stop")) { + Limit_Stop_Val.append(xml.readElementText().toDouble()); + } else if (xml.name() == QStringLiteral("fstart_unit")) { + Limit_Start_Freq_Unit.append(xml.readElementText()); + } else if (xml.name() == QStringLiteral("fstop_unit")) { + Limit_Stop_Freq_Unit.append(xml.readElementText()); + } else if (xml.name() == QStringLiteral("couple_values")) { + Limit_Couple_Values.append(xml.readElementText().toInt()); + }else if (xml.name() == QStringLiteral("offset")) { + Limits_Offset->setValue(xml.readElementText().toDouble()); + } + } + } + } else if (xml.name() == QStringLiteral("MARKERS")){ + while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == QStringLiteral("MARKERS"))) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + double value = xml.readElementText().toDouble(); + Markers.append(value); + } + } + } else if (xml.name() == QStringLiteral("file")) { + // Load datasets + QString fileName, traceName; + while (!xml.atEnd() && !xml.hasError()) + { + if (xml.tokenType() == QXmlStreamReader::StartElement) + { + if (xml.name() == QStringLiteral("file")) + { + fileName = xml.attributes().value("file_name").toString(); + //qDebug() << "File name:" << fileName; + } + else if (xml.name() == QStringLiteral("trace")) + { + traceName = xml.attributes().value("trace_name").toString(); + //qDebug() << "Trace name:" << traceName; + } + else if (xml.name() == QStringLiteral("value")) + { + QString value = xml.readElementText(); + //qDebug() << "Value:" << value; + datasets[fileName][traceName].append(value.toDouble()); + } + } + xml.readNext(); + } + } } + } + + + if (xml.hasError()) { + qDebug() << "Error parsing XML: " << xml.errorString(); + } + + // Close the file + file.close(); + + + // Update dataset and trace selection comboboxes + QStringList files = datasets.keys(); + for (int i = 0; i < files.size(); i++){ + QString file = files.at(i); + QCombobox_datasets->addItem(file); + + // Add file management widgets + // Label + QLabel * Filename_Label = new QLabel(file); + Filename_Label->setObjectName(QString("File_") + QString::number(i)); + List_FileNames.append(Filename_Label); + this->FilesGrid->addWidget(List_FileNames.last(), i, 0, 1, 1); + + // Create the "Remove" button + QToolButton * RemoveButton = new QToolButton(); + RemoveButton->setObjectName(QString("Remove_") + QString::number(i)); + QIcon icon(":/bitmaps/trash.png"); // Use a resource path or a relative path + RemoveButton->setIcon(icon); + + RemoveButton->setStyleSheet("QToolButton {background-color: red;\ + border-width: 2px;\ + border-radius: 10px;\ + border-color: beige;\ + font: bold 14px;\ + }"); + List_RemoveButton.append(RemoveButton); + this->FilesGrid->addWidget(List_RemoveButton.last(), i, 1, 1, 1); + connect(RemoveButton, SIGNAL(clicked()), SLOT(removeFile())); // Connect button with the handler to remove the entry. + + } + updateTracesCombo();// Update traces + + // Add traces to the display + for (int i = 0; i < trace_name.size(); i++){ + QStringList parts = { + trace_name[i].section('.', 0, -2), + trace_name[i].section('.', -1) + }; + addTrace(parts[0], parts[1], trace_color.at(i), trace_width.at(i), trace_style.at(i)); + } + + // Apply axis settings + // It's needed to disconnect the signals first in order to avoid unneeded calls to the slots + disconnect(QSpinBox_x_axis_min, SIGNAL(valueChanged(double)), this, SLOT(updatePlot())); + disconnect(QSpinBox_x_axis_max, SIGNAL(valueChanged(double)), this, SLOT(updatePlot())); + disconnect(QComboBox_x_axis_div, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePlot())); + disconnect(QCombobox_x_axis_units, SIGNAL(currentIndexChanged(int)), this, SLOT(changeFreqUnits())); + disconnect(QSpinBox_y_axis_min, SIGNAL(valueChanged(double)), this, SLOT(updatePlot())); + disconnect(QSpinBox_y_axis_max, SIGNAL(valueChanged(double)), this, SLOT(updatePlot())); + + QSpinBox_x_axis_min->setValue(x_axis_min); + QSpinBox_x_axis_max->setValue(x_axis_max); + QComboBox_x_axis_div->setCurrentIndex(index_x_axis_div); + QCombobox_x_axis_units->setCurrentIndex(index_x_axis_units); + QSpinBox_y_axis_min->setValue(y_axis_min); + QSpinBox_y_axis_max->setValue(y_axis_max); + QComboBox_y_axis_div->setCurrentIndex(index_y_axis_div); + + connect(QSpinBox_x_axis_min, SIGNAL(valueChanged(double)), SLOT(updatePlot())); + connect(QSpinBox_x_axis_max, SIGNAL(valueChanged(double)), SLOT(updatePlot())); + connect(QComboBox_x_axis_div, SIGNAL(currentIndexChanged(int)), SLOT(updatePlot())); + connect(QCombobox_x_axis_units, SIGNAL(currentIndexChanged(int)), SLOT(changeFreqUnits())); + connect(QSpinBox_y_axis_min, SIGNAL(valueChanged(double)), SLOT(updatePlot())); + connect(QSpinBox_y_axis_max, SIGNAL(valueChanged(double)), SLOT(updatePlot())); + + // Apply lock axes status + lock_axis = lock_axis_setting; + lock_unlock_axis_settings(false);//false means "don't change the state" inside the function + + // Update chart frequency limits + this->f_min = x_axis_min*getFreqScale(QCombobox_x_axis_units->currentText()); + this->f_max = x_axis_max*getFreqScale(QCombobox_x_axis_units->currentText()); + + // Add markers + for (int i = 0; i < Markers.size(); i++){ + addMarker(Markers.at(i)); + } + + // Add limits + for (int i = 0; i < Limit_Start_Freq.size(); i++){ + addLimit(Limit_Start_Freq.at(i), Limit_Start_Freq_Unit.at(i), Limit_Stop_Freq.at(i), Limit_Stop_Freq_Unit.at(i), Limit_Start_Val.at(i), Limit_Stop_Val.at(i), Limit_Couple_Values.at(i)); + } + + // Show the trace settings widget + dockTracesList->raise(); + + return; +} + +void Qucs_S_SPAR_Viewer::updateGridLayout(QGridLayout* layout) +{ + // Store widget information + struct WidgetInfo { + QWidget* widget; + int row, column, rowSpan, columnSpan; + Qt::Alignment alignment; + }; + QVector widgetInfos; + + // Collect information about remaining widgets + for (int i = 0; i < layout->count(); ++i) { + QLayoutItem* item = layout->itemAt(i); + QWidget* widget = item->widget(); + if (widget) { + int row, column, rowSpan, columnSpan; + layout->getItemPosition(i, &row, &column, &rowSpan, &columnSpan); + widgetInfos.push_back({widget, row, column, rowSpan, columnSpan, item->alignment()}); + } + } + + // Clear the layout + while (layout->count() > 0) { + QLayoutItem* item = layout->takeAt(0); + delete item; + } + + // Re-add widgets with updated positions + int row = 0; + for (const auto& info : widgetInfos) { + int newColumn = info.column; + + if (info.columnSpan == layout->columnCount()){// Separator widget + row++; + } + + layout->addWidget(info.widget, row, newColumn, info.rowSpan, info.columnSpan, info.alignment); + + if (info.columnSpan == layout->columnCount()){ + row++; + } + + if (newColumn == layout->columnCount()-1) { + row++; + } + } + } diff --git a/qucs-s-spar-viewer/qucs-s-spar-viewer.h b/qucs-s-spar-viewer/qucs-s-spar-viewer.h index 9694a83b6..6ccccc746 100644 --- a/qucs-s-spar-viewer/qucs-s-spar-viewer.h +++ b/qucs-s-spar-viewer/qucs-s-spar-viewer.h @@ -43,11 +43,20 @@ class Qucs_S_SPAR_Viewer : public QMainWindow Qucs_S_SPAR_Viewer(); ~Qucs_S_SPAR_Viewer(); +protected: + void resizeEvent(QResizeEvent *event) override { + QMainWindow::resizeEvent(event); + updateTraces(); + } + private slots: void slotHelpIntro(); void slotHelpAbout(); void slotHelpAboutQt(); void slotQuit(); + void slotSave(); + void slotSaveAs(); + void slotLoadSession(); void addFile(); void addFiles(QStringList); @@ -56,12 +65,13 @@ class Qucs_S_SPAR_Viewer : public QMainWindow void removeAllFiles(); void addTrace(); - void addTrace(QString, QString, QColor); + void addTrace(QString, QString, QColor, int trace_width = 1, QString trace_style = "Solid"); void removeTrace(); void removeTrace(int); void removeTrace(QList); void updatePlot(); + void updateTraces(); void updateTracesCombo(); void changeTraceColor(); @@ -73,12 +83,25 @@ class Qucs_S_SPAR_Viewer : public QMainWindow void update_X_axis(); void update_Y_axis(); + void lock_unlock_axis_settings(bool toogle = true); - void addMarker(); + void addMarker(double freq = -1); void removeMarker(); void removeMarker(int); void removeAllMarkers(); void updateMarkerTable(); + void updateMarkerNames(); + + void addLimit(double f_limit1=-1, QString f_limit1_unit = "", double f_limit2=-1, QString f_limit2_unit = "", double y_limit1=-1, double y_limit2=-1, bool coupled=false); + void removeLimit(); + void removeLimit(int); + void removeAllLimits(); + void updateLimits(); + void updateLimitNames(); + + void coupleSpinBoxes(); + + void updateGridLayout(QGridLayout*); protected: void dragEnterEvent(QDragEnterEvent *event) override; @@ -120,6 +143,9 @@ class Qucs_S_SPAR_Viewer : public QMainWindow QList available_y_axis_div; QComboBox *QComboBox_y_axis_div; QDoubleSpinBox *QSpinBox_y2_axis_min, *QSpinBox_y2_axis_max, *QSpinBox_y2_axis_div; + QPushButton *Lock_axis_settings_Button; + bool lock_axis; + QStringList frequency_units; // Trace management widgets QComboBox *QCombobox_datasets, *QCombobox_traces; @@ -146,8 +172,8 @@ class Qucs_S_SPAR_Viewer : public QMainWindow QValueAxis *xAxis, *yAxis; double f_min, f_max, y_min, y_max; // Minimum (maximum) values of the display QList default_colors; + QList textLabels; bool removeSeriesByName(QChart*, const QString&); - void updateTraces(); // Markers QDockWidget *dockMarkers; @@ -161,6 +187,24 @@ class Qucs_S_SPAR_Viewer : public QMainWindow QList List_MarkerScale; QList List_Button_DeleteMarker; + // Limits + QDockWidget *dockLimits; + QWidget *Limits_Widget; + QGridLayout * LimitsGrid; + QPushButton *Button_add_Limit, *Button_Remove_All_Limits; + QList List_LimitNames; + QList List_Limit_Start_Freq, List_Limit_Stop_Freq; + QList List_Limit_Start_Value, List_Limit_Stop_Value; + QList List_Limit_Start_Freq_Scale, List_Limit_Stop_Freq_Scale; + QList List_Button_Delete_Limit; + QList List_Separators; + QList List_Couple_Value; + QDoubleSpinBox * Limits_Offset; + + // Save + QString savepath; + bool save(); + void loadSession(QString); // Utilities void convert_MA_RI_to_dB(double *, double *, double *, double *, QString); @@ -172,7 +216,7 @@ class Qucs_S_SPAR_Viewer : public QMainWindow void adjust_x_axis_to_file(QString); void adjust_y_axis_to_trace(QString, QString); void adjust_x_axis_div(); - QPointF findClosestPoint(QAbstractSeries*, qreal); + QPointF findClosestPoint(const QList&, const QList&, qreal); double getFreqFromText(QString); }; diff --git a/qucs/components/bjtsub.cpp b/qucs/components/bjtsub.cpp index cdc517452..e6ab22ead 100644 --- a/qucs/components/bjtsub.cpp +++ b/qucs/components/bjtsub.cpp @@ -128,7 +128,7 @@ Basic_BJT::Basic_BJT() BJTsub::BJTsub() { Description = QObject::tr("bipolar junction transistor with substrate"); - Simulator = spicecompat::simQucsator; + Simulator = spicecompat::simAll; createSymbol(); tx = x2+4; ty = y1+4; diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index c9256b2fb..c05f2d4e8 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -252,7 +252,7 @@ void Component::paint(QPainter *p) { QRect text_br{tx, ty, 0, 0}; if (showName) { - p->drawText(tx, ty, 0, 0, Qt::TextDontClip, Name, &text_br); + p->drawText(tx, ty, 1, 1, Qt::TextDontClip, Name, &text_br); } for (auto *prop : Props) { @@ -763,7 +763,7 @@ QString Component::spice_netlist(bool) { } QString Component::va_code() { - return QString(""); // ignore if not implemented + return QString(); // ignore if not implemented } // ------------------------------------------------------- @@ -772,7 +772,7 @@ QString Component::getNetlist() { case COMP_IS_ACTIVE: return netlist(); case COMP_IS_OPEN: - return QString(""); + return QString(); } // Component is shortened. @@ -795,7 +795,7 @@ QString Component::getSpiceNetlist(bool isXyce) { s.replace(" gnd ", " 0 "); return s; case COMP_IS_OPEN: - return QString(""); + return QString(); } // Component is shortened. @@ -820,16 +820,16 @@ QString Component::getVerilogACode() { return s; case COMP_IS_OPEN: default: - return QString(""); + return QString(); } } QString Component::getExpression(bool) { - return QString(""); + return QString(); } QString Component::getEquations(QString, QStringList &) { - return QString(""); + return QString(); } QStringList Component::getExtraVariables() { @@ -837,35 +837,35 @@ QStringList Component::getExtraVariables() { } QString Component::getProbeVariable(bool) { - return QString(""); + return QString(); } QString Component::getSpiceModel() { - return QString(""); + return QString(); } QString Component::getNgspiceBeforeSim(QString sim, int lvl) { Q_UNUSED(sim) // To suppress warning Q_UNUSED(lvl) - return QString(""); + return QString(); } QString Component::getNgspiceAfterSim(QString sim, int lvl) { Q_UNUSED(sim) // To suppress warning Q_UNUSED(lvl) - return QString(""); + return QString(); } // ------------------------------------------------------- QString Component::verilogCode(int) { - return QString(""); // no digital model + return QString(); // no digital model } // ------------------------------------------------------- QString Component::get_Verilog_Code(int NumPorts) { switch (isActive) { case COMP_IS_OPEN: - return QString(""); + return QString(); case COMP_IS_ACTIVE: return verilogCode(NumPorts); } @@ -882,14 +882,14 @@ QString Component::get_Verilog_Code(int NumPorts) { // ------------------------------------------------------- QString Component::vhdlCode(int) { - return QString(""); // no digital model + return QString(); // no digital model } // ------------------------------------------------------- QString Component::get_VHDL_Code(int NumPorts) { switch (isActive) { case COMP_IS_OPEN: - return QString(""); + return QString(); case COMP_IS_ACTIVE: return vhdlCode(NumPorts); } @@ -1787,7 +1787,7 @@ Component *getComponentFromName(QString &Line, Schematic *p) { if (!c) { /// \todo enable user to load partial schematic, skip unknown components - if (QucsMain != 0) { + if (QucsMain != nullptr) { QMessageBox *msg = new QMessageBox(QMessageBox::Warning, QObject::tr("Warning"), QObject::tr("Format Error:\nUnknown component!\n" "%1\n\n" diff --git a/qucs/components/component.h b/qucs/components/component.h index cc98bd096..64966355e 100644 --- a/qucs/components/component.h +++ b/qucs/components/component.h @@ -49,11 +49,11 @@ class Component : public Element { virtual QStringList getExtraVariables(); virtual QString getProbeVariable(bool isXyce = false); virtual QString getSpiceModel(); - virtual QString getSpiceLibrary() { return QString(""); } + virtual QString getSpiceLibrary() { return QString(); } virtual QString getNgspiceBeforeSim(QString sim, int lvl=0); virtual QString getNgspiceAfterSim(QString sim, int lvl=0); - virtual QString getVAvariables() {return QString("");}; - virtual QString getVAExpressions() {return QString("");}; + virtual QString getVAvariables() {return QString();}; + virtual QString getVAExpressions() {return QString();}; virtual void getExtraVANodes(QStringList& ) {}; QString get_VHDL_Code(int); QString get_Verilog_Code(int); diff --git a/qucs/components/componentdialog.cpp b/qucs/components/componentdialog.cpp index 68b9069e1..8e585db05 100644 --- a/qucs/components/componentdialog.cpp +++ b/qucs/components/componentdialog.cpp @@ -422,7 +422,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) connect(ButtDown, SIGNAL(clicked()), SLOT(slotButtDown())); QStringList allowedFillFromSPICE; - allowedFillFromSPICE<<"_BJT"<<"JFET"<<"MOSFET"<<"_MOSFET"<<"Diode"; + allowedFillFromSPICE<<"_BJT"<<"JFET"<<"MOSFET"<<"_MOSFET"<<"Diode"<<"BJT"; ButtFillFromSpice = new QPushButton(tr("Fill from SPICE .MODEL")); if (!allowedFillFromSPICE.contains(Comp->Model)) { ButtFillFromSpice->setEnabled(false); diff --git a/qucs/components/d_flipflop.cpp b/qucs/components/d_flipflop.cpp index e1d59d548..40076cec3 100644 --- a/qucs/components/d_flipflop.cpp +++ b/qucs/components/d_flipflop.cpp @@ -122,7 +122,7 @@ Element* D_FlipFlop::info(QString& Name, char* &BitmapFile, bool getNewOne) QString D_FlipFlop::spice_netlist(bool isXyce) { - if (isXyce) return QString(""); + if (isXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/dff_SR.cpp b/qucs/components/dff_SR.cpp index 2f1463d77..d93427fbb 100644 --- a/qucs/components/dff_SR.cpp +++ b/qucs/components/dff_SR.cpp @@ -177,7 +177,7 @@ QString dff_SR::verilogCode( int ) QString dff_SR::spice_netlist(bool isXyce) { - if (isXyce) return QString(""); + if (isXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/diode.cpp b/qucs/components/diode.cpp index 5dda286a0..4a581e888 100644 --- a/qucs/components/diode.cpp +++ b/qucs/components/diode.cpp @@ -119,7 +119,7 @@ QString Diode::spice_netlist(bool isXyce) <<"Nr"<<"Ffe"<<"Temp"<<"Area"<<"Symbol"<<"UseGlobTemp"; // spice-incompatible parameters } else { spice_tr<<"Tbv"<<"Tcv"; - spice_incompat<<"Cp"<<"Isr"<<"Nr"<<"Ffe"<<"Temp"<<"Area"<<"Symbol"<<"UseGLobTemp"; + spice_incompat<<"Cp"<<"Isr"<<"Nr"<<"Ffe"<<"Temp"<<"Area"<<"Symbol"<<"UseGlobTemp"; } QString par_str; @@ -174,12 +174,14 @@ Element* Diode::info(QString& Name, char* &BitmapFile, bool getNewOne) // ------------------------------------------------------- void Diode::createSymbol() { - if(Props.back()->Value.at(0) == 'V') { + auto pp = getProperty("Symbol"); + if (pp == nullptr) return; + if(pp->Value.at(0) == 'V') { Lines.append(new qucs::Line(-30, 0, -9, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -6, 0, 30, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -9, -9, -9, 9,QPen(Qt::darkBlue,2))); } - else if(Props.back()->Value.at(0) == 'U') { + else if(pp->Value.at(0) == 'U') { Lines.append(new qucs::Line(-30, 0, -6, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 6, 0, 30, 0,QPen(Qt::darkBlue,2))); } @@ -191,11 +193,11 @@ void Diode::createSymbol() Lines.append(new qucs::Line( -6, 0, 6, -9,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -6, 0, 6, 9,QPen(Qt::darkBlue,2))); - if(Props.back()->Value.at(0) == 'S') { + if(pp->Value.at(0) == 'S') { Lines.append(new qucs::Line( -6, -9,-12,-12,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -6, 9, 0, 12,QPen(Qt::darkBlue,2))); } - else if(Props.back()->Value.at(0) == 'Z') { + else if(pp->Value.at(0) == 'Z') { Lines.append(new qucs::Line( -6, 9, -1, 9,QPen(Qt::darkBlue,2))); } diff --git a/qucs/components/equation.cpp b/qucs/components/equation.cpp index 6bbfd508f..b45432f8a 100644 --- a/qucs/components/equation.cpp +++ b/qucs/components/equation.cpp @@ -124,7 +124,7 @@ QString Equation::getVAExpressions() */ QString Equation::getExpression(bool isXyce) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QStringList ng_vars,ngsims; getNgnutmegVars(ng_vars,ngsims); @@ -172,7 +172,7 @@ QString Equation::getExpression(bool isXyce) */ QString Equation::getEquations(QString sim, QStringList &dep_vars) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QStringList ng_vars,ngsims; getNgnutmegVars(ng_vars,ngsims); @@ -214,7 +214,7 @@ QString Equation::getNgspiceScript() QString s; s.clear(); - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); for (int i=0;iValue.split( this->param_split_str ); @@ -166,7 +166,7 @@ QString Param_Sweep::getNgspiceBeforeSim(QString sim, int lvl) QString Param_Sweep::getNgspiceAfterSim(QString sim, int lvl) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; QStringList parameter_list = getProperty("Param")->Value.split( this->param_split_str ); diff --git a/qucs/components/potentiometer.cpp b/qucs/components/potentiometer.cpp index 60f7aa4cd..c8ff23857 100644 --- a/qucs/components/potentiometer.cpp +++ b/qucs/components/potentiometer.cpp @@ -115,9 +115,9 @@ QString potentiometer::spice_netlist(bool isXyce) { Q_UNUSED(isXyce); QString s; - QString R = getProperty("R_pot")->Value; - QString rot = getProperty("Rotation")->Value; - QString max_rot = getProperty("Max_Rotation")->Value; + QString R = spicecompat::normalize_value(getProperty("R_pot")->Value); + QString rot = spicecompat::normalize_value(getProperty("Rotation")->Value); + QString max_rot = spicecompat::normalize_value(getProperty("Max_Rotation")->Value); QString pin1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); QString pin2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); QString pin3 = spicecompat::normalize_node_name(Ports.at(2)->Connection->Name); diff --git a/qucs/components/simulation.cpp b/qucs/components/simulation.cpp index 616ab5714..163654eb7 100644 --- a/qucs/components/simulation.cpp +++ b/qucs/components/simulation.cpp @@ -119,7 +119,7 @@ void SimulationComponent::drawSymbol(QPainter *p) p->setPen(pen()); p->setFont(label_font); QRect label_bounds; - p->drawText(0, 0, 0, 0, Qt::TextDontClip, label_text, &label_bounds); + p->drawText(0, 0, 1, 1, Qt::TextDontClip, label_text, &label_bounds); // Simulation component look like an isometric box // or a brick, with a label on its top side, being @@ -160,4 +160,4 @@ void SimulationComponent::drawSymbol(QPainter *p) updateComponentBounds(ABCD); } -} // namespace qucs::component \ No newline at end of file +} // namespace qucs::component diff --git a/qucs/components/spicefile.cpp b/qucs/components/spicefile.cpp index 6a163b06c..3fbd7edef 100644 --- a/qucs/components/spicefile.cpp +++ b/qucs/components/spicefile.cpp @@ -154,7 +154,7 @@ void SpiceFile::createSymbol() QString SpiceFile::netlist() { if(Props.at(1)->Value.isEmpty()) - return QString(""); // no ports, no subcircuit instance + return QString(); // no ports, no subcircuit instance QString s = "Sub:"+Name; // SPICE netlist is subcircuit for (Port *pp : Ports) @@ -388,7 +388,7 @@ bool SpiceFile::recreateSubNetlist(QString *SpiceFile, QString *FileName) (*filstream) << NetText; // only interact with the GUI if it was launched - if (QucsMain) { + if (QucsMain != nullptr) { QucsMain->statusBar()->showMessage(tr("Converting SPICE file \"%1\".").arg(*SpiceFile), 2000); } else diff --git a/qucs/components/subcirport.cpp b/qucs/components/subcirport.cpp index 4dd6e34f2..4ce4455ce 100644 --- a/qucs/components/subcirport.cpp +++ b/qucs/components/subcirport.cpp @@ -104,20 +104,20 @@ Element* SubCirPort::info(QString& Name, char* &BitmapFile, bool getNewOne) // ------------------------------------------------------- QString SubCirPort::netlist() { - return QString(""); + return QString(); } // ------------------------------------------------------- QString SubCirPort::spice_netlist(bool) { - return QString(""); + return QString(); } // ------------------------------------------------------- QString SubCirPort::vhdlCode(int) { if(Props.at(1)->Value != "out") - return QString(""); + return QString(); // Insert dummy buffer to avoid reading from an output port. QString s = " net_out"; @@ -130,5 +130,5 @@ QString SubCirPort::vhdlCode(int) // ------------------------------------------------------- QString SubCirPort::verilogCode(int) { - return QString(""); + return QString(); } diff --git a/qucs/components/tff_SR.cpp b/qucs/components/tff_SR.cpp index 00d604f99..c89eac4a5 100644 --- a/qucs/components/tff_SR.cpp +++ b/qucs/components/tff_SR.cpp @@ -177,7 +177,7 @@ QString tff_SR::verilogCode( int ) QString tff_SR::spice_netlist(bool isXyce) { - if (isXyce) return QString(""); + if (isXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/vacomponent.cpp b/qucs/components/vacomponent.cpp index 83d853065..5f9213d45 100644 --- a/qucs/components/vacomponent.cpp +++ b/qucs/components/vacomponent.cpp @@ -298,7 +298,7 @@ void vacomponent::createSymbol(QJsonObject json) QString vacomponent::spice_netlist(bool isXyce) { - if (isXyce) return QString(""); + if (isXyce) return QString(); QString s = SpiceModel + Name + " "; for(const auto pp: Ports) { diff --git a/qucs/components/vcresistor.cpp b/qucs/components/vcresistor.cpp index e6358ac57..ab7e5217f 100644 --- a/qucs/components/vcresistor.cpp +++ b/qucs/components/vcresistor.cpp @@ -16,13 +16,14 @@ ***************************************************************************/ #include "vcresistor.h" +#include "node.h" #include "extsimkernels/spicecompat.h" vcresistor::vcresistor() { Description = QObject::tr("voltage controlled resistor"); - Simulator = spicecompat::simQucsator; + Simulator = spicecompat::simAll; // The resistor shape Lines.append(new qucs::Line(5, 18, 5, -18, QPen(Qt::darkBlue,2))); @@ -67,6 +68,7 @@ vcresistor::vcresistor() ty = y2+4; Model = "vcresistor"; Name = "VCR"; + SpiceModel = "R"; Props.append(new Property("gain", "1", true, QObject::tr("resistance gain"))); @@ -90,3 +92,33 @@ Element* vcresistor::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } +QString vcresistor::netlist() +{ + QString s; + QString EDD_Name = "EDD" + Name; + QString in1 = Ports.at(0)->Connection->Name; + QString in2 = Ports.at(1)->Connection->Name; + QString out1 = Ports.at(2)->Connection->Name; + QString out2 = Ports.at(3)->Connection->Name; + QString gain = getProperty("gain")->Value; + s = QString("EDD:%1 %2 %3 %4 %5 I1=\"%1.I1\" Q1=\"%1.Q1\" I2=\"%1.I2\" Q2=\"%1.Q2\"\n").arg(EDD_Name,in1,in2,out1,out2); + s += QString("Eqn:Eqn%1I1 %1.I1=\"0\" Export=\"no\"\n").arg(EDD_Name); + s += QString("Eqn:Eqn%1Q1 %1.Q1=\"0\" Export=\"no\"\n").arg(EDD_Name); + s += QString("Eqn:Eqn%1I2 %1.I2=\"V2/(1e-20+abs(V1*(%2)))\" Export=\"no\"\n").arg(EDD_Name,gain); + s += QString("Eqn:Eqn%1Q2 %1.Q2=\"0\" Export=\"no\"\n").arg(EDD_Name); + return s; +} + +QString vcresistor::spice_netlist(bool isXyce) +{ + Q_UNUSED(isXyce); + QString s; + QString gain = spicecompat::normalize_value(getProperty("gain")->Value); + QString in1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); + QString in2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); + QString out1 = spicecompat::normalize_node_name(Ports.at(2)->Connection->Name); + QString out2 = spicecompat::normalize_node_name(Ports.at(3)->Connection->Name); + s = QString("R%1 %2 %3 R='1e-15+abs(V(%4,%5)*(%6))'\n").arg(Name, out1, out2, in1, in2, gain); + return s; +} + diff --git a/qucs/components/vcresistor.h b/qucs/components/vcresistor.h index 1d1a305e5..33c813c8c 100644 --- a/qucs/components/vcresistor.h +++ b/qucs/components/vcresistor.h @@ -27,6 +27,9 @@ class vcresistor : public Component { ~vcresistor(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); +protected: + QString netlist(); + QString spice_netlist(bool isXyce); }; #endif diff --git a/qucs/components/verilogfile.cpp b/qucs/components/verilogfile.cpp index 00c6bd7ec..8d682ce80 100644 --- a/qucs/components/verilogfile.cpp +++ b/qucs/components/verilogfile.cpp @@ -97,7 +97,7 @@ QString Verilog_File::loadFile() QFile f(File); if(!f.open(QIODevice::ReadOnly)) - return QString(""); + return QString(); QTextStream stream(&f); File = stream.readAll(); // QString is better for "find" function diff --git a/qucs/components/vhdlfile.cpp b/qucs/components/vhdlfile.cpp index 07ce89f38..e303b01a5 100644 --- a/qucs/components/vhdlfile.cpp +++ b/qucs/components/vhdlfile.cpp @@ -104,7 +104,7 @@ QString VHDL_File::loadFile() QFile f(File); if(!f.open(QIODevice::ReadOnly)) - return QString(""); + return QString(); QTextStream stream(&f); File = stream.readAll(); // QString is better for "find" function @@ -332,11 +332,11 @@ QString VHDL_File_Info::parsePorts(QString s, int j) Expr.setPattern("\\bport\\b"); // start of interface definition i = s.indexOf(Expr, j+1); if(i < 0) - return QString(""); + return QString(); // find opening ( i = s.indexOf('(', i+4) + 1; if(i <= 0) - return QString(""); + return QString(); // find closing ( p = i; @@ -344,7 +344,7 @@ QString VHDL_File_Info::parsePorts(QString s, int j) do { j = s.indexOf(')', j+1); if(j < 0) - return QString(""); + return QString(); p = s.indexOf('(', p+1); if(p >= 0 && p > j) p = -1; } while (p >= 0); @@ -395,11 +395,11 @@ QString VHDL_File_Info::parseGenerics(QString s, int j) Expr.setPattern("\\bgeneric\\b"); i = s.indexOf(Expr, j+1); if(i < 0) - return QString(""); + return QString(); // find opening ( i = s.indexOf('(', i+4) + 1; if(i <= 0) - return QString(""); + return QString(); // find closing ( p = i; @@ -407,7 +407,7 @@ QString VHDL_File_Info::parseGenerics(QString s, int j) do { j = s.indexOf(')', j+1); if(j < 0) - return QString(""); + return QString(); p = s.indexOf('(', p+1); if(p >= 0 && p > j) p = -1; } while (p >= 0); diff --git a/qucs/diagrams/diagram.cpp b/qucs/diagrams/diagram.cpp index d30899a28..739b31793 100644 --- a/qucs/diagrams/diagram.cpp +++ b/qucs/diagrams/diagram.cpp @@ -1902,8 +1902,8 @@ bool Diagram::calcYAxis(Axis *Axis, int x0) { bool back = false; if (Axis->log) { if (Axis->autoScale) { - if (Axis->max * Axis->min <= 0.0) return false; // invalid - } else if (Axis->limit_min * Axis->limit_max <= 0.0) return false; // invalid + if (Axis->max <= 0.0 or Axis->min <= 0.0) return false; // invalid + } else if (Axis->limit_min <= 0.0 or Axis->limit_max <= 0.0) return false; // invalid back = calcAxisLogScale(Axis, z, zD, zDstep, corr, y2); diff --git a/qucs/diagrams/marker.cpp b/qucs/diagrams/marker.cpp index ca6aefe27..8bd8a853d 100644 --- a/qucs/diagrams/marker.cpp +++ b/qucs/diagrams/marker.cpp @@ -425,7 +425,7 @@ void Marker::paint(QPainter* painter) { } painter->setPen(QPen(Qt::black, 1)); - painter->drawText(x1, y1, 0, 0, Qt::TextDontClip, Text); + painter->drawText(x1, y1, 1, 1, Qt::TextDontClip, Text); painter->setPen(QPen(Qt::darkMagenta, 0)); painter->drawRect(text_box); diff --git a/qucs/diagrams/tabdiagram.cpp b/qucs/diagrams/tabdiagram.cpp index 333149bf8..a5074a904 100644 --- a/qucs/diagrams/tabdiagram.cpp +++ b/qucs/diagrams/tabdiagram.cpp @@ -110,13 +110,13 @@ void TabDiagram::paintDiagram(QPainter *painter) { painter->setPen(Qt::black); for (Text *pt : Texts) { - painter->drawText(pt->x, -pt->y, 0, 0, Qt::TextDontClip, pt->s); + painter->drawText(pt->x, -pt->y, 1, 1, Qt::TextDontClip, pt->s); } if (isSelected) { painter->setPen(QPen(Qt::darkGray,3)); painter->drawRect(-5, -y2-5, x2+10, y2+10); - painter->setPen(QPen(Qt::darkRed,2)); + misc::draw_resize_handle(painter, QPoint{0, -y2}); misc::draw_resize_handle(painter, QPoint{0, 0}); misc::draw_resize_handle(painter, QPoint{x2, -y2}); diff --git a/qucs/diagrams/timingdiagram.cpp b/qucs/diagrams/timingdiagram.cpp index 93ef4d30c..e8fa86193 100644 --- a/qucs/diagrams/timingdiagram.cpp +++ b/qucs/diagrams/timingdiagram.cpp @@ -62,7 +62,7 @@ void TimingDiagram::paintDiagram(QPainter *painter) { painter->setPen(Qt::black); for (Text *pt : Texts) { - painter->drawText(pt->x, -pt->y, 0, 0, Qt::TextDontClip, pt->s); + painter->drawText(pt->x, -pt->y, 1, 1, Qt::TextDontClip, pt->s); } if (y1 > 0) { // paint scroll bar ? diff --git a/qucs/dialogs/matchdialog.cpp b/qucs/dialogs/matchdialog.cpp index 2b3f324ef..7caa09815 100644 --- a/qucs/dialogs/matchdialog.cpp +++ b/qucs/dialogs/matchdialog.cpp @@ -817,7 +817,7 @@ QString MatchDialog::calcMatchingLC(double r_real, double r_imag, double Z0, 0, tr("Error"), tr("Real part of impedance must be greater zero,\nbut is %1 !") .arg(Zreal)); - return QString(""); // matching not possible + return QString(); // matching not possible } // In high-Q circuits, Zreal often becomes somewhat about -1e-16 @@ -1303,7 +1303,7 @@ QString MatchDialog::calcDoubleStub(double r_real, double r_imag, double Z0, { QMessageBox::warning(0, tr("Error"), tr("It is not possible to match this load using the double stub method")); - return QString(""); + return QString(); } // Stubs susceptance @@ -1432,7 +1432,7 @@ QString MatchDialog::calcChebyLines(double r_real, double r_imag, double Z0, QMessageBox::warning( 0, QObject::tr("Error"), QObject::tr("Chebyshev weighting for N>7 is not available")); - return QString(""); + return QString(); } QString laddercode; diff --git a/qucs/element.cpp b/qucs/element.cpp index f421f14a9..182b66c90 100644 --- a/qucs/element.cpp +++ b/qucs/element.cpp @@ -100,7 +100,7 @@ double Text::angle() const { // x and y are relative to component's x and y void Property::paint(int x, int y, QPainter* p) { - p->drawText(x, y, 0, 0, Qt::TextDontClip, Name + "=" + Value, &br); + p->drawText(x, y, 1, 1, Qt::TextDontClip, Name + "=" + Value, &br); } Element::Element() diff --git a/qucs/extsimkernels/ngspice.cpp b/qucs/extsimkernels/ngspice.cpp index 2170ac2ac..cc20a9ec0 100644 --- a/qucs/extsimkernels/ngspice.cpp +++ b/qucs/extsimkernels/ngspice.cpp @@ -400,7 +400,7 @@ QString Ngspice::getParentSWPscript(Component *pc_swp, QString sim, bool before, } } } - return QString(""); + return QString(); } /*! @@ -486,7 +486,7 @@ void Ngspice::slotSimulate() QString ngsp_cmd = cmd_args.at(0); cmd_args.removeAt(0); SimProcess->start(ngsp_cmd,cmd_args); - if (QucsMain) + if (QucsMain != nullptr) emit started(); } diff --git a/qucs/extsimkernels/spicecompat.cpp b/qucs/extsimkernels/spicecompat.cpp index 8c14cf344..dfd5de75a 100644 --- a/qucs/extsimkernels/spicecompat.cpp +++ b/qucs/extsimkernels/spicecompat.cpp @@ -344,7 +344,7 @@ QString spicecompat::convert_sweep_type(const QString& sweep) { if (sweep=="lin") return QString("lin"); if (sweep=="log") return QString("dec"); - return QString(""); + return QString(); } /*! diff --git a/qucs/main.cpp b/qucs/main.cpp index cbaca9553..c788dec8d 100644 --- a/qucs/main.cpp +++ b/qucs/main.cpp @@ -63,7 +63,7 @@ tQucsSettings QucsSettings; -QucsApp *QucsMain = 0; // the Qucs application itself +QucsApp *QucsMain = nullptr; // the Qucs application itself QString lastDir; // to remember last directory for several dialogs QStringList qucsPathList; VersionTriplet QucsVersion; // Qucs version string @@ -179,7 +179,9 @@ bool saveApplSettings() qs.setItem("font", QucsSettings.font.toString()); qs.setItem("appFont", QucsSettings.appFont.toString()); qs.setItem("textFont", QucsSettings.textFont.toString()); - qs.setItem("MainWindowGeometry", QucsMain->saveGeometry()); + if (QucsMain != nullptr) { + qs.setItem("MainWindowGeometry", QucsMain->saveGeometry()); + } // store LargeFontSize as a string, so it will be also human-readable in the settings file (will be a @Variant() otherwise) qs.setItem("LargeFontSize", QString::number(QucsSettings.largeFontSize)); diff --git a/qucs/misc.cpp b/qucs/misc.cpp index be9f2278a..d48efe73f 100644 --- a/qucs/misc.cpp +++ b/qucs/misc.cpp @@ -791,7 +791,7 @@ void misc::draw_richtext(QPainter* painter, int x, int y, const QString &text, Q QRect fragment_br; painter->drawText( current_text_x, current_text_y + (is_sub ? subscript_offset : superscript_offset), - 0, 0, + 1, 1, Qt::TextDontClip, text.mid(i, len ? len : 1), &fragment_br); @@ -811,7 +811,7 @@ void misc::draw_richtext(QPainter* painter, int x, int y, const QString &text, Q QRect fragment_br; painter->drawText( - current_text_x, current_text_y, 0, 0, + current_text_x, current_text_y, 1, 1, Qt::TextDontClip, text.mid(i, len), &fragment_br); @@ -846,11 +846,12 @@ void misc::draw_resize_handle(QPainter* painter, const QPointF& center) { // 1. Find out where on canvas lies the central point and remember these // coordinates // 2. Remove all transformations and draw the handle in its natural size - QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size + static QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size resize_handle.moveCenter(painter->transform().map(center)); + static QTransform transform{}; // reset transformation painter->save(); - painter->setTransform(QTransform{}); + painter->setTransform(transform); painter->setPen(QPen{Qt::darkRed, 2}); painter->drawRect(resize_handle); painter->restore(); diff --git a/qucs/module.cpp b/qucs/module.cpp index 42a008c8c..9375bcdc6 100644 --- a/qucs/module.cpp +++ b/qucs/module.cpp @@ -422,6 +422,7 @@ void Module::registerModules (void) { REGISTER_NONLINEAR_1 (OpAmp); REGISTER_NONLINEAR_1 (EqnDefined); + REGISTER_NONLINEAR_1 (vcresistor); //if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) { REGISTER_NONLINEAR_1 (Diac); @@ -455,7 +456,6 @@ void Module::registerModules (void) { REGISTER_VERILOGA_1 (photodiode); REGISTER_VERILOGA_1 (phototransistor); REGISTER_VERILOGA_1 (nigbt); - REGISTER_VERILOGA_1 (vcresistor); //} // digital components diff --git a/qucs/paintings/ellipse.cpp b/qucs/paintings/ellipse.cpp index 9a883aad3..b6f0a743f 100644 --- a/qucs/paintings/ellipse.cpp +++ b/qucs/paintings/ellipse.cpp @@ -57,8 +57,6 @@ void qucs::Ellipse::paint(QPainter *painter) { painter->setPen(QPen(Qt::white, Pen.width(), Pen.style())); painter->drawEllipse(cx, cy, x2, y2); - painter->setPen(QPen(Qt::darkRed,2)); - misc::draw_resize_handle(painter, QPoint{cx, cy}); misc::draw_resize_handle(painter, QPoint{cx, cy + y2}); misc::draw_resize_handle(painter, QPoint{cx + x2, cy}); diff --git a/qucs/paintings/ellipsearc.cpp b/qucs/paintings/ellipsearc.cpp index ea31fd976..a9a2a3130 100644 --- a/qucs/paintings/ellipsearc.cpp +++ b/qucs/paintings/ellipsearc.cpp @@ -53,9 +53,9 @@ void EllipseArc::paint(QPainter *painter) { painter->drawArc(cx, cy, x2, y2, Angle, ArcLen); misc::draw_resize_handle(painter, QPoint{cx, cy}); - misc::draw_resize_handle(painter, QPoint{cx, y2}); - misc::draw_resize_handle(painter, QPoint{x2, cy}); - misc::draw_resize_handle(painter, QPoint{x2, y2}); + misc::draw_resize_handle(painter, QPoint{cx, cy + y2}); + misc::draw_resize_handle(painter, QPoint{cx + x2, cy}); + misc::draw_resize_handle(painter, QPoint{cx + x2, cy + y2}); } painter->restore(); } diff --git a/qucs/paintings/id_text.cpp b/qucs/paintings/id_text.cpp index 1809435c7..99c66e6c4 100644 --- a/qucs/paintings/id_text.cpp +++ b/qucs/paintings/id_text.cpp @@ -42,18 +42,18 @@ void ID_Text::paint(QPainter* painter) { painter->setPen(QPen(Qt::black,1)); QRect r; - painter->drawText(QRect(0, 0, 0, 0), Qt::TextDontClip, Prefix, &r); + painter->drawText(QRect(0, 0, 1, 1), Qt::TextDontClip, Prefix, &r); x2 = r.width(); y2 = r.height(); - painter->drawText(QRect(0, y2, 0, 0), Qt::TextDontClip, "File=name", &r); + painter->drawText(QRect(0, y2, 1, 1), Qt::TextDontClip, "File=name", &r); x2 = std::max(x2, r.width()); y2 += r.height(); QList::const_iterator it; for(it = Parameter.constBegin(); it != Parameter.constEnd(); it++) { if((*it)->display) { - painter->drawText(QRect(0, y2, 0, 0), Qt::TextDontClip, (*it)->Name, &r); + painter->drawText(QRect(0, y2, 1, 1), Qt::TextDontClip, (*it)->Name, &r); x2 = std::max(x2, r.width()); y2 += r.height(); } diff --git a/qucs/paintings/portsymbol.cpp b/qucs/paintings/portsymbol.cpp index a57607588..86a32c4de 100644 --- a/qucs/paintings/portsymbol.cpp +++ b/qucs/paintings/portsymbol.cpp @@ -88,7 +88,7 @@ void PortSymbol::paint(QPainter *painter) { } painter->setPen(Qt::black); - painter->drawText(0, 0, 0, 0, Qt::TextDontClip, nameStr.isEmpty() ? numberStr : nameStr); + painter->drawText(0, 0, 1, 1, Qt::TextDontClip, nameStr.isEmpty() ? numberStr : nameStr); } painter->restore(); diff --git a/qucs/qucs_actions.cpp b/qucs/qucs_actions.cpp index b6f0e03a7..a4123f5e6 100644 --- a/qucs/qucs_actions.cpp +++ b/qucs/qucs_actions.cpp @@ -821,7 +821,7 @@ void QucsApp::slotShowLastNetlist() // Is called to start the text editor. void QucsApp::slotCallEditor() { - editFile(QString("")); + editFile(QString()); } // ------------------------------------------------------------------------ diff --git a/qucs/schematic.cpp b/qucs/schematic.cpp index 51ea30459..ad8b2fab5 100644 --- a/qucs/schematic.cpp +++ b/qucs/schematic.cpp @@ -386,8 +386,8 @@ void Schematic::paintFrame(QPainter* painter) { auto cn = QString::number(column_number); auto tx = x - h_step / 2 + 5; - painter->drawText(tx, 3, 0, 0, Qt::TextDontClip, cn); - painter->drawText(tx, frame_height - frame_margin + 3, 0, 0, Qt::TextDontClip, cn); + painter->drawText(tx, 3, 1, 1, Qt::TextDontClip, cn); + painter->drawText(tx, frame_height - frame_margin + 3, 1, 1, Qt::TextDontClip, cn); column_number++; } @@ -421,15 +421,15 @@ void Schematic::paintFrame(QPainter* painter) { const double z = 200.0; y1_ -= painter->fontMetrics().lineSpacing() + d; painter->drawLine(x1_, y1_, x2_, y1_); - painter->drawText(x1_ + d, y1_ + (d >> 1), 0, 0, Qt::TextDontClip, Frame_Text2); + painter->drawText(x1_ + d, y1_ + (d >> 1), 1, 1, Qt::TextDontClip, Frame_Text2); painter->drawLine(x1_ + z, y1_, x1_ + z, y1_ + painter->fontMetrics().lineSpacing() + d); - painter->drawText(x1_ + d + z, y1_ + (d >> 1), 0, 0, Qt::TextDontClip, Frame_Text3); + painter->drawText(x1_ + d + z, y1_ + (d >> 1), 1, 1, Qt::TextDontClip, Frame_Text3); y1_ -= painter->fontMetrics().lineSpacing() + d; painter->drawLine(x1_, y1_, x2_, y1_); - painter->drawText(x1_ + d, y1_ + (d >> 1), 0, 0, Qt::TextDontClip, Frame_Text1); + painter->drawText(x1_ + d, y1_ + (d >> 1), 1, 1, Qt::TextDontClip, Frame_Text1); y1_ -= (Frame_Text0.count('\n') + 1) * painter->fontMetrics().lineSpacing() + d; painter->drawRect(x2_, y2_, x1_ - x2_ - 1, y1_ - y2_ - 1); - painter->drawText(x1_ + d, y1_ + (d >> 1), 0, 0, Qt::TextDontClip, Frame_Text0); + painter->drawText(x1_ + d, y1_ + (d >> 1), 1, 1, Qt::TextDontClip, Frame_Text0); painter->restore(); } diff --git a/qucs/schematic_file.cpp b/qucs/schematic_file.cpp index e6061fee1..34a0330c2 100644 --- a/qucs/schematic_file.cpp +++ b/qucs/schematic_file.cpp @@ -1070,7 +1070,7 @@ bool Schematic::loadDocument() QFile file(DocName); if(!file.open(QIODevice::ReadOnly)) { /// \todo implement unified error/warning handling GUI and CLI - if (QucsMain) + if (QucsMain != nullptr) QMessageBox::critical(0, QObject::tr("Error"), QObject::tr("Cannot load document: ")+DocName); else @@ -1509,7 +1509,7 @@ bool Schematic::throughAllComps(QTextStream *stream, int& countInit, delete d; /// \todo implement error/warning message dispatcher for GUI and CLI modes. QString message = QObject::tr("ERROR: Cannot load subcircuit \"%1\".").arg(s); - if (QucsMain) // GUI is running + if (QucsMain != nullptr) // GUI is running ErrText->appendPlainText(message); else // command line qCritical() << "Schematic::throughAllComps" << message; diff --git a/qucs/spicecomponents/BJT_SPICE.cpp b/qucs/spicecomponents/BJT_SPICE.cpp index 6439b6e06..1ed509e6d 100644 --- a/qucs/spicecomponents/BJT_SPICE.cpp +++ b/qucs/spicecomponents/BJT_SPICE.cpp @@ -183,7 +183,7 @@ Element* BJT_SPICE::infoPNP5(QString& Name, char* &BitmapFile, bool getNewOne) QString BJT_SPICE::netlist() { - return QString(""); + return QString(); } QString BJT_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/C_SPICE.cpp b/qucs/spicecomponents/C_SPICE.cpp index 8097d3c8a..f530fcceb 100644 --- a/qucs/spicecomponents/C_SPICE.cpp +++ b/qucs/spicecomponents/C_SPICE.cpp @@ -106,7 +106,7 @@ Element* C_SPICE::info_C3(QString& Name, char* &BitmapFile, bool getNewOne) QString C_SPICE::netlist() { - return QString(""); + return QString(); } QString C_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/DIODE_SPICE.cpp b/qucs/spicecomponents/DIODE_SPICE.cpp index c42f832cf..e56f750c7 100644 --- a/qucs/spicecomponents/DIODE_SPICE.cpp +++ b/qucs/spicecomponents/DIODE_SPICE.cpp @@ -111,7 +111,7 @@ Element* DIODE_SPICE::info_DIODE3(QString& Name, char* &BitmapFile, bool getNewO QString DIODE_SPICE::netlist() { - return QString(""); + return QString(); } QString DIODE_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/Icouple.cpp b/qucs/spicecomponents/Icouple.cpp index 9ed3a4205..7d7e76543 100644 --- a/qucs/spicecomponents/Icouple.cpp +++ b/qucs/spicecomponents/Icouple.cpp @@ -97,7 +97,7 @@ Element* Icouple::info(QString& Name, char* &BitmapFile, bool getNewOne) QString Icouple::netlist() { - return QString(""); + return QString(); } QString Icouple::spice_netlist(bool) diff --git a/qucs/spicecomponents/K_SPICE.cpp b/qucs/spicecomponents/K_SPICE.cpp index 131a412fe..c68a21013 100644 --- a/qucs/spicecomponents/K_SPICE.cpp +++ b/qucs/spicecomponents/K_SPICE.cpp @@ -72,7 +72,7 @@ Element* K_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString K_SPICE::netlist() { - return QString(""); + return QString(); } QString K_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/LTL_SPICE.cpp b/qucs/spicecomponents/LTL_SPICE.cpp index f355dd8a6..65e3863ef 100644 --- a/qucs/spicecomponents/LTL_SPICE.cpp +++ b/qucs/spicecomponents/LTL_SPICE.cpp @@ -85,7 +85,7 @@ Element* LTL_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString LTL_SPICE::netlist() { - return QString(""); + return QString(); } QString LTL_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/LTRA_SPICE.cpp b/qucs/spicecomponents/LTRA_SPICE.cpp index 3cfdd26d4..7e0651ba9 100644 --- a/qucs/spicecomponents/LTRA_SPICE.cpp +++ b/qucs/spicecomponents/LTRA_SPICE.cpp @@ -91,7 +91,7 @@ Element* LTRA_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString LTRA_SPICE::netlist() { - return QString(""); + return QString(); } QString LTRA_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/L_SPICE.cpp b/qucs/spicecomponents/L_SPICE.cpp index fa7f71608..1fb50b1da 100644 --- a/qucs/spicecomponents/L_SPICE.cpp +++ b/qucs/spicecomponents/L_SPICE.cpp @@ -80,7 +80,7 @@ Element* L_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString L_SPICE::netlist() { - return QString(""); + return QString(); } QString L_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/MESFET_SPICE.cpp b/qucs/spicecomponents/MESFET_SPICE.cpp index acf80ca41..539c234f2 100644 --- a/qucs/spicecomponents/MESFET_SPICE.cpp +++ b/qucs/spicecomponents/MESFET_SPICE.cpp @@ -83,7 +83,7 @@ Element* MESFET_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString MESFET_SPICE::netlist() { - return QString(""); + return QString(); } QString MESFET_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/MOS_SPICE.cpp b/qucs/spicecomponents/MOS_SPICE.cpp index 5af21e2a0..7c33b985e 100644 --- a/qucs/spicecomponents/MOS_SPICE.cpp +++ b/qucs/spicecomponents/MOS_SPICE.cpp @@ -176,7 +176,7 @@ Element* MOS_SPICE::info_PX4pin(QString& Name, char* &BitmapFile, bool getNewOne QString MOS_SPICE::netlist() { - return QString(""); + return QString(); } void MOS_SPICE::createSymbol() diff --git a/qucs/spicecomponents/NJF_SPICE.cpp b/qucs/spicecomponents/NJF_SPICE.cpp index 716ba9457..f11150b5b 100644 --- a/qucs/spicecomponents/NJF_SPICE.cpp +++ b/qucs/spicecomponents/NJF_SPICE.cpp @@ -90,7 +90,7 @@ Element* NJF_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString NJF_SPICE::netlist() { - return QString(""); + return QString(); } QString NJF_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/NMOS_SPICE.cpp b/qucs/spicecomponents/NMOS_SPICE.cpp index c559936b9..3e483754e 100644 --- a/qucs/spicecomponents/NMOS_SPICE.cpp +++ b/qucs/spicecomponents/NMOS_SPICE.cpp @@ -99,7 +99,7 @@ Element* NMOS_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString NMOS_SPICE::netlist() { - return QString(""); + return QString(); } QString NMOS_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/NPN_SPICE.cpp b/qucs/spicecomponents/NPN_SPICE.cpp index 800d0fcf4..3844a98cd 100644 --- a/qucs/spicecomponents/NPN_SPICE.cpp +++ b/qucs/spicecomponents/NPN_SPICE.cpp @@ -91,7 +91,7 @@ Element* NPN_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString NPN_SPICE::netlist() { - return QString(""); + return QString(); } QString NPN_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/PJF_SPICE.cpp b/qucs/spicecomponents/PJF_SPICE.cpp index 302b6e945..bd9fd03a0 100644 --- a/qucs/spicecomponents/PJF_SPICE.cpp +++ b/qucs/spicecomponents/PJF_SPICE.cpp @@ -90,7 +90,7 @@ Element* PJF_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString PJF_SPICE::netlist() { - return QString(""); + return QString(); } QString PJF_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/PMF_MESFET_SPICE.cpp b/qucs/spicecomponents/PMF_MESFET_SPICE.cpp index 29d56ab9f..5339a4bb5 100644 --- a/qucs/spicecomponents/PMF_MESFET_SPICE.cpp +++ b/qucs/spicecomponents/PMF_MESFET_SPICE.cpp @@ -83,7 +83,7 @@ Element* PMF_MESFET_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne QString PMF_MESFET_SPICE::netlist() { - return QString(""); + return QString(); } QString PMF_MESFET_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/PMOS_SPICE.cpp b/qucs/spicecomponents/PMOS_SPICE.cpp index c9c352e2a..bebc6896d 100644 --- a/qucs/spicecomponents/PMOS_SPICE.cpp +++ b/qucs/spicecomponents/PMOS_SPICE.cpp @@ -99,7 +99,7 @@ Element* PMOS_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString PMOS_SPICE::netlist() { - return QString(""); + return QString(); } QString PMOS_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/PNP_SPICE.cpp b/qucs/spicecomponents/PNP_SPICE.cpp index 66b67e2e3..1d3f0f226 100644 --- a/qucs/spicecomponents/PNP_SPICE.cpp +++ b/qucs/spicecomponents/PNP_SPICE.cpp @@ -92,7 +92,7 @@ Element* PNP_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString PNP_SPICE::netlist() { - return QString(""); + return QString(); } QString PNP_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/R_SPICE.cpp b/qucs/spicecomponents/R_SPICE.cpp index bc030024a..974b7e4fa 100644 --- a/qucs/spicecomponents/R_SPICE.cpp +++ b/qucs/spicecomponents/R_SPICE.cpp @@ -110,7 +110,7 @@ Element* R_SPICE::info_R3(QString& Name, char* &BitmapFile, bool getNewOne) QString R_SPICE::netlist() { - return QString(""); + return QString(); } QString R_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/S4Q_Ieqndef.cpp b/qucs/spicecomponents/S4Q_Ieqndef.cpp index 09235513a..368014814 100644 --- a/qucs/spicecomponents/S4Q_Ieqndef.cpp +++ b/qucs/spicecomponents/S4Q_Ieqndef.cpp @@ -83,7 +83,7 @@ Element* S4Q_Ieqndef::info(QString& Name, char* &BitmapFile, bool getNewOne) QString S4Q_Ieqndef::netlist() { - return QString(""); + return QString(); } QString S4Q_Ieqndef::spice_netlist(bool) diff --git a/qucs/spicecomponents/S4Q_S.cpp b/qucs/spicecomponents/S4Q_S.cpp index 0373bfc99..181a00e0a 100644 --- a/qucs/spicecomponents/S4Q_S.cpp +++ b/qucs/spicecomponents/S4Q_S.cpp @@ -90,7 +90,7 @@ Element* S4Q_S::info(QString& Name, char* &BitmapFile, bool getNewOne) //QString S4Q_S::netlist() //{ - // return QString(""); + // return QString(); //} QString S4Q_S::spice_netlist(bool) diff --git a/qucs/spicecomponents/SDTF.cpp b/qucs/spicecomponents/SDTF.cpp index c0fc3688e..62b6cb609 100644 --- a/qucs/spicecomponents/SDTF.cpp +++ b/qucs/spicecomponents/SDTF.cpp @@ -80,7 +80,7 @@ Element* SDTF::info(QString& Name, char* &BitmapFile, bool getNewOne) QString SDTF::netlist() { - return QString(""); + return QString(); } QString SDTF::spice_netlist(bool) diff --git a/qucs/spicecomponents/UDRCTL_SPICE.cpp b/qucs/spicecomponents/UDRCTL_SPICE.cpp index 3c46c938f..38bf675d9 100644 --- a/qucs/spicecomponents/UDRCTL_SPICE.cpp +++ b/qucs/spicecomponents/UDRCTL_SPICE.cpp @@ -89,7 +89,7 @@ Element* UDRCTL_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString UDRCTL_SPICE::netlist() { - return QString(""); + return QString(); } QString UDRCTL_SPICE::spice_netlist(bool) diff --git a/qucs/spicecomponents/XAPWL.cpp b/qucs/spicecomponents/XAPWL.cpp index ca46ded6d..888fe8273 100644 --- a/qucs/spicecomponents/XAPWL.cpp +++ b/qucs/spicecomponents/XAPWL.cpp @@ -80,7 +80,7 @@ Element* XAPWL::info(QString& Name, char* &BitmapFile, bool getNewOne) QString XAPWL::netlist() { - return QString(""); + return QString(); } QString XAPWL::spice_netlist(bool) diff --git a/qucs/spicecomponents/core.cpp b/qucs/spicecomponents/core.cpp index a5d456ea7..7b163ac82 100644 --- a/qucs/spicecomponents/core.cpp +++ b/qucs/spicecomponents/core.cpp @@ -87,7 +87,7 @@ Element* core::info(QString& Name, char* &BitmapFile, bool getNewOne) QString core::netlist() { - return QString(""); + return QString(); } QString core::spice_netlist(bool) diff --git a/qucs/spicecomponents/eNL.cpp b/qucs/spicecomponents/eNL.cpp index da9f44b74..39a3271b6 100644 --- a/qucs/spicecomponents/eNL.cpp +++ b/qucs/spicecomponents/eNL.cpp @@ -79,7 +79,7 @@ Element* eNL::info(QString& Name, char* &BitmapFile, bool getNewOne) QString eNL::netlist() { - return QString(""); + return QString(); } QString eNL::spice_netlist(bool) diff --git a/qucs/spicecomponents/gNL.cpp b/qucs/spicecomponents/gNL.cpp index 1ea4007a9..f218c0e1f 100644 --- a/qucs/spicecomponents/gNL.cpp +++ b/qucs/spicecomponents/gNL.cpp @@ -78,7 +78,7 @@ Element* gNL::info(QString& Name, char* &BitmapFile, bool getNewOne) QString gNL::netlist() { - return QString(""); + return QString(); } QString gNL::spice_netlist(bool) diff --git a/qucs/spicecomponents/iAmpMod.cpp b/qucs/spicecomponents/iAmpMod.cpp index 161672a5e..9eaacd590 100644 --- a/qucs/spicecomponents/iAmpMod.cpp +++ b/qucs/spicecomponents/iAmpMod.cpp @@ -86,7 +86,7 @@ Element* iAmpMod::info(QString& Name, char* &BitmapFile, bool getNewOne) QString iAmpMod::netlist() { - return QString(""); + return QString(); } QString iAmpMod::spice_netlist(bool) diff --git a/qucs/spicecomponents/iPWL.cpp b/qucs/spicecomponents/iPWL.cpp index ce534f137..966c2a365 100644 --- a/qucs/spicecomponents/iPWL.cpp +++ b/qucs/spicecomponents/iPWL.cpp @@ -87,7 +87,7 @@ Element* iPWL::info(QString& Name, char* &BitmapFile, bool getNewOne) QString iPWL::netlist() { - return QString(""); + return QString(); } QString iPWL::spice_netlist(bool) @@ -111,7 +111,7 @@ QString Line_8= Props.at(7)->Value; QString Line_9= Props.at(8)->Value; QString Line_10= Props.at(9)->Value; - s += QString(""); + s += QString(); if( PWL.length() > 0) s += QString("%1").arg(PWL); if( Line_2.length() > 0 ) s += QString("\n%1").arg(Line_2); diff --git a/qucs/spicecomponents/iTRNOISE.cpp b/qucs/spicecomponents/iTRNOISE.cpp index e382dffed..db3bbf302 100644 --- a/qucs/spicecomponents/iTRNOISE.cpp +++ b/qucs/spicecomponents/iTRNOISE.cpp @@ -95,7 +95,7 @@ Element* iTRNOISE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString iTRNOISE::netlist() { - return QString(""); + return QString(); } QString iTRNOISE::spice_netlist(bool) diff --git a/qucs/spicecomponents/incl_script.cpp b/qucs/spicecomponents/incl_script.cpp index 8074fc88a..cc589deb3 100644 --- a/qucs/spicecomponents/incl_script.cpp +++ b/qucs/spicecomponents/incl_script.cpp @@ -80,6 +80,6 @@ Element* InclScript::info(QString& Name, char* &BitmapFile, bool getNewOne) QString InclScript::getExpression(bool) { if (isActive != COMP_IS_ACTIVE) - return QString(""); + return QString(); return Props.at(0)->Value+"\n"; } diff --git a/qucs/spicecomponents/incl_script.h b/qucs/spicecomponents/incl_script.h index 4871a437c..41748c07c 100644 --- a/qucs/spicecomponents/incl_script.h +++ b/qucs/spicecomponents/incl_script.h @@ -30,9 +30,9 @@ class InclScript : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/isffm.cpp b/qucs/spicecomponents/isffm.cpp index 01fb3304d..7325ffe0d 100644 --- a/qucs/spicecomponents/isffm.cpp +++ b/qucs/spicecomponents/isffm.cpp @@ -86,7 +86,7 @@ Element* iSffm::info(QString& Name, char* &BitmapFile, bool getNewOne) QString iSffm::netlist() { - return QString(""); + return QString(); } QString iSffm::spice_netlist(bool) diff --git a/qucs/spicecomponents/sp_func.cpp b/qucs/spicecomponents/sp_func.cpp index 451886bd6..e8869a1d6 100644 --- a/qucs/spicecomponents/sp_func.cpp +++ b/qucs/spicecomponents/sp_func.cpp @@ -72,7 +72,7 @@ Element* SpiceFunc::info(QString& Name, char* &BitmapFile, bool getNewOne) QString SpiceFunc::getExpression(bool) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_func.h b/qucs/spicecomponents/sp_func.h index af6778f4c..f942921e9 100644 --- a/qucs/spicecomponents/sp_func.h +++ b/qucs/spicecomponents/sp_func.h @@ -31,9 +31,9 @@ class SpiceFunc : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_globalpar.cpp b/qucs/spicecomponents/sp_globalpar.cpp index 608e80154..4cb3d4d52 100644 --- a/qucs/spicecomponents/sp_globalpar.cpp +++ b/qucs/spicecomponents/sp_globalpar.cpp @@ -72,7 +72,7 @@ Element* SpiceGlobalParam::info(QString& Name, char* &BitmapFile, bool getNewOne QString SpiceGlobalParam::getExpression(bool) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_globalpar.h b/qucs/spicecomponents/sp_globalpar.h index 710170c96..aee5cbb11 100644 --- a/qucs/spicecomponents/sp_globalpar.h +++ b/qucs/spicecomponents/sp_globalpar.h @@ -32,9 +32,9 @@ class SpiceGlobalParam : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_ic.cpp b/qucs/spicecomponents/sp_ic.cpp index 7e5ef9d81..c9f535fd6 100644 --- a/qucs/spicecomponents/sp_ic.cpp +++ b/qucs/spicecomponents/sp_ic.cpp @@ -71,7 +71,7 @@ Element* SpiceIC::info(QString& Name, char* &BitmapFile, bool getNewOne) QString SpiceIC::getExpression(bool) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_ic.h b/qucs/spicecomponents/sp_ic.h index 722a361dd..a6b4b6439 100644 --- a/qucs/spicecomponents/sp_ic.h +++ b/qucs/spicecomponents/sp_ic.h @@ -31,9 +31,9 @@ class SpiceIC : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_include.cpp b/qucs/spicecomponents/sp_include.cpp index 2f23b689b..a8c6d6b62 100644 --- a/qucs/spicecomponents/sp_include.cpp +++ b/qucs/spicecomponents/sp_include.cpp @@ -77,7 +77,7 @@ Element* S4Q_Include::info(QString& Name, char* &BitmapFile, bool getNewOne) QString S4Q_Include::getSpiceLibrary() { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_include.h b/qucs/spicecomponents/sp_include.h index 2126b2dcb..e457cfda4 100644 --- a/qucs/spicecomponents/sp_include.h +++ b/qucs/spicecomponents/sp_include.h @@ -31,9 +31,9 @@ class S4Q_Include : public Component { QString getSpiceLibrary(); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_lib.cpp b/qucs/spicecomponents/sp_lib.cpp index 82074e31e..b50c2fc7f 100644 --- a/qucs/spicecomponents/sp_lib.cpp +++ b/qucs/spicecomponents/sp_lib.cpp @@ -73,7 +73,7 @@ Element* S4Q_Lib::info(QString& Name, char* &BitmapFile, bool getNewOne) QString S4Q_Lib::getSpiceLibrary() { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_lib.h b/qucs/spicecomponents/sp_lib.h index df40fc685..4104548d5 100644 --- a/qucs/spicecomponents/sp_lib.h +++ b/qucs/spicecomponents/sp_lib.h @@ -31,9 +31,9 @@ class S4Q_Lib : public Component { QString getSpiceLibrary(); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_model.cpp b/qucs/spicecomponents/sp_model.cpp index 23349d819..5f64e7ed4 100644 --- a/qucs/spicecomponents/sp_model.cpp +++ b/qucs/spicecomponents/sp_model.cpp @@ -78,7 +78,7 @@ Element* S4Q_Model::info(QString& Name, char* &BitmapFile, bool getNewOne) QString S4Q_Model::getSpiceModel() { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_model.h b/qucs/spicecomponents/sp_model.h index 3b3cc433d..f9932b69f 100644 --- a/qucs/spicecomponents/sp_model.h +++ b/qucs/spicecomponents/sp_model.h @@ -31,9 +31,9 @@ class S4Q_Model : public Component { QString getSpiceModel(); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_nodeset.cpp b/qucs/spicecomponents/sp_nodeset.cpp index ef18e27c7..5762cc965 100644 --- a/qucs/spicecomponents/sp_nodeset.cpp +++ b/qucs/spicecomponents/sp_nodeset.cpp @@ -71,7 +71,7 @@ Element* SpiceNodeset::info(QString& Name, char* &BitmapFile, bool getNewOne) QString SpiceNodeset::getExpression(bool) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_nodeset.h b/qucs/spicecomponents/sp_nodeset.h index 3ef76130c..cadf0f454 100644 --- a/qucs/spicecomponents/sp_nodeset.h +++ b/qucs/spicecomponents/sp_nodeset.h @@ -31,9 +31,9 @@ class SpiceNodeset : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_nutmeg.cpp b/qucs/spicecomponents/sp_nutmeg.cpp index 3d2f92b05..2179bf926 100644 --- a/qucs/spicecomponents/sp_nutmeg.cpp +++ b/qucs/spicecomponents/sp_nutmeg.cpp @@ -74,7 +74,7 @@ Element* NutmegEquation::info(QString& Name, char* &BitmapFile, bool getNewOne) QString NutmegEquation::getEquations(QString sim, QStringList &dep_vars) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; QRegularExpression sim_rx("^\\w+\\d+"); diff --git a/qucs/spicecomponents/sp_nutmeg.h b/qucs/spicecomponents/sp_nutmeg.h index 8457202e7..e07e5df8f 100644 --- a/qucs/spicecomponents/sp_nutmeg.h +++ b/qucs/spicecomponents/sp_nutmeg.h @@ -31,9 +31,9 @@ class NutmegEquation : public Component { QString getEquations(QString sim, QStringList &dep_vars); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_options.cpp b/qucs/spicecomponents/sp_options.cpp index 15e881222..a423e2df7 100644 --- a/qucs/spicecomponents/sp_options.cpp +++ b/qucs/spicecomponents/sp_options.cpp @@ -73,7 +73,7 @@ Element* SpiceOptions::info(QString& Name, char* &BitmapFile, bool getNewOne) QString SpiceOptions::getExpression(bool isXyce) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_options.h b/qucs/spicecomponents/sp_options.h index 97dfdfe24..05100a5fa 100644 --- a/qucs/spicecomponents/sp_options.h +++ b/qucs/spicecomponents/sp_options.h @@ -32,9 +32,9 @@ class SpiceOptions : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/sp_parameter.cpp b/qucs/spicecomponents/sp_parameter.cpp index 7c6906878..bbe819ff8 100644 --- a/qucs/spicecomponents/sp_parameter.cpp +++ b/qucs/spicecomponents/sp_parameter.cpp @@ -71,7 +71,7 @@ Element* SpiceParam::info(QString& Name, char* &BitmapFile, bool getNewOne) QString SpiceParam::getExpression(bool) { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_parameter.h b/qucs/spicecomponents/sp_parameter.h index c29c079f6..571614732 100644 --- a/qucs/spicecomponents/sp_parameter.h +++ b/qucs/spicecomponents/sp_parameter.h @@ -32,9 +32,9 @@ class SpiceParam : public Component { QString getExpression(bool isXyce); protected: - QString vhdlCode(int) { return QString(""); } - QString verilogCode(int) { return QString(""); } - QString netlist() { return QString(""); } + QString vhdlCode(int) { return QString(); } + QString verilogCode(int) { return QString(); } + QString netlist() { return QString(); } }; #endif diff --git a/qucs/spicecomponents/spicegeneric.cpp b/qucs/spicecomponents/spicegeneric.cpp index d88d38aef..7de862615 100644 --- a/qucs/spicecomponents/spicegeneric.cpp +++ b/qucs/spicecomponents/spicegeneric.cpp @@ -131,7 +131,7 @@ void SpiceGeneric::createSymbol() // --------------------------------------------------- QString SpiceGeneric::netlist() { - return QString(""); + return QString(); } QString SpiceGeneric::spice_netlist(bool) diff --git a/qucs/spicecomponents/spicelibcomp.cpp b/qucs/spicecomponents/spicelibcomp.cpp index c0acf0eef..e89845403 100644 --- a/qucs/spicecomponents/spicelibcomp.cpp +++ b/qucs/spicecomponents/spicelibcomp.cpp @@ -241,7 +241,7 @@ QString SpiceLibComp::spice_netlist(bool) QString SpiceLibComp::getSpiceLibrary() { - if (isActive != COMP_IS_ACTIVE) return QString(""); + if (isActive != COMP_IS_ACTIVE) return QString(); QString f = misc::properAbsFileName(Props.at(0)->Value, containingSchematic); QString s = QString(".INCLUDE \"%1\"\n").arg(f); return s; diff --git a/qucs/spicecomponents/src_eqndef.cpp b/qucs/spicecomponents/src_eqndef.cpp index 666745d7c..eaf0ec426 100644 --- a/qucs/spicecomponents/src_eqndef.cpp +++ b/qucs/spicecomponents/src_eqndef.cpp @@ -64,7 +64,7 @@ Element* Src_eqndef::info(QString& Name, char* &BitmapFile, bool getNewOne) QString Src_eqndef::netlist() { - return QString(""); + return QString(); } QString Src_eqndef::spice_netlist(bool) diff --git a/qucs/spicecomponents/vAmpMod.cpp b/qucs/spicecomponents/vAmpMod.cpp index bcd47fada..ac0b35927 100644 --- a/qucs/spicecomponents/vAmpMod.cpp +++ b/qucs/spicecomponents/vAmpMod.cpp @@ -88,7 +88,7 @@ Element* vAmpMod::info(QString& Name, char* &BitmapFile, bool getNewOne) QString vAmpMod::netlist() { - return QString(""); + return QString(); } QString vAmpMod::spice_netlist(bool) diff --git a/qucs/spicecomponents/vPWL.cpp b/qucs/spicecomponents/vPWL.cpp index 45c25ac58..f42946ad9 100644 --- a/qucs/spicecomponents/vPWL.cpp +++ b/qucs/spicecomponents/vPWL.cpp @@ -86,7 +86,7 @@ Element* vPWL::info(QString& Name, char* &BitmapFile, bool getNewOne) QString vPWL::netlist() { - return QString(""); + return QString(); } QString vPWL::spice_netlist(bool) @@ -110,7 +110,7 @@ QString Line_8= Props.at(7)->Value; QString Line_9= Props.at(8)->Value; QString Line_10= Props.at(9)->Value; - s += QString(""); + s += QString(); if( PWL.length() > 0) s += QString("%1").arg(PWL); if( Line_2.length() > 0 ) s += QString("\n%1").arg(Line_2); diff --git a/qucs/spicecomponents/vTRNOISE.cpp b/qucs/spicecomponents/vTRNOISE.cpp index 910a7ed48..8de541635 100644 --- a/qucs/spicecomponents/vTRNOISE.cpp +++ b/qucs/spicecomponents/vTRNOISE.cpp @@ -91,7 +91,7 @@ Element* vTRNOISE::info(QString& Name, char* &BitmapFile, bool getNewOne) QString vTRNOISE::netlist() { - return QString(""); + return QString(); } QString vTRNOISE::spice_netlist(bool) diff --git a/qucs/spicecomponents/vTRRANDOM.cpp b/qucs/spicecomponents/vTRRANDOM.cpp index 9628924a2..a511937c3 100644 --- a/qucs/spicecomponents/vTRRANDOM.cpp +++ b/qucs/spicecomponents/vTRRANDOM.cpp @@ -93,7 +93,7 @@ Element* vTRRANDOM::info(QString& Name, char* &BitmapFile, bool getNewOne) QString vTRRANDOM::netlist() { - return QString(""); + return QString(); } QString vTRRANDOM::spice_netlist(bool) diff --git a/qucs/spicecomponents/vsffm.cpp b/qucs/spicecomponents/vsffm.cpp index de576768c..2468a1b66 100644 --- a/qucs/spicecomponents/vsffm.cpp +++ b/qucs/spicecomponents/vsffm.cpp @@ -86,7 +86,7 @@ Element* vSffm::info(QString& Name, char* &BitmapFile, bool getNewOne) QString vSffm::netlist() { - return QString(""); + return QString(); } QString vSffm::spice_netlist(bool) diff --git a/qucs/spicecomponents/xsp_cmlib.cpp b/qucs/spicecomponents/xsp_cmlib.cpp index d265ec623..cbef493e4 100644 --- a/qucs/spicecomponents/xsp_cmlib.cpp +++ b/qucs/spicecomponents/xsp_cmlib.cpp @@ -88,7 +88,7 @@ QString XSP_CMlib::getSpiceInit() QString XSP_CMlib::spice_netlist() { - return QString(""); + return QString(); } diff --git a/qucs/spicecomponents/xsp_codemodel.cpp b/qucs/spicecomponents/xsp_codemodel.cpp index 7bc21093d..c47dd34be 100644 --- a/qucs/spicecomponents/xsp_codemodel.cpp +++ b/qucs/spicecomponents/xsp_codemodel.cpp @@ -71,7 +71,7 @@ Element* XSP_CodeModel::info(QString& Name, char* &BitmapFile, bool getNewOne) QString XSP_CodeModel::spice_netlist() { - return QString(""); + return QString(); } diff --git a/qucs/spicecomponents/xspicegeneric.cpp b/qucs/spicecomponents/xspicegeneric.cpp index 10b855408..5ff748eae 100644 --- a/qucs/spicecomponents/xspicegeneric.cpp +++ b/qucs/spicecomponents/xspicegeneric.cpp @@ -142,7 +142,7 @@ void XspiceGeneric::createSymbol() // --------------------------------------------------- QString XspiceGeneric::netlist() { - return QString(""); + return QString(); } QString XspiceGeneric::spice_netlist(bool) diff --git a/qucs/symbolwidget.cpp b/qucs/symbolwidget.cpp index 49d9b1613..c77de3864 100644 --- a/qucs/symbolwidget.cpp +++ b/qucs/symbolwidget.cpp @@ -123,14 +123,14 @@ void SymbolWidget::mouseMoveEvent(QMouseEvent* event) void SymbolWidget::paintEvent(QPaintEvent*) { QPainter Painter(this); - Painter.drawText(2, 2, 0, 0, Qt::AlignLeft | Qt::TextDontClip, PaintText); + Painter.drawText(2, 2, 1, 1, Qt::AlignLeft | Qt::TextDontClip, PaintText); QFontMetrics metrics(QucsSettings.font, 0); - Painter.drawText(2, metrics.height(), 0, 0, Qt::AlignLeft | Qt::TextDontClip, Warning); + Painter.drawText(2, metrics.height(), 1, 1, Qt::AlignLeft | Qt::TextDontClip, Warning); int dx = (x2-x1)/2 + TextWidth - DragNDropWidth/2; if(dx < 2) dx = 2; - Painter.drawText(dx, y2-y1+2, 0, 0, Qt::AlignLeft | Qt::TextDontClip, DragNDropText); + Painter.drawText(dx, y2-y1+2, 1, 1, Qt::AlignLeft | Qt::TextDontClip, DragNDropText); // paint all lines for(int i=0; iSize); Painter.setFont(Font); Painter.setPen(pt->Color); - Painter.drawText(cx+pt->x, cy+pt->y, 0, 0, Qt::TextDontClip, pt->s); + Painter.drawText(cx+pt->x, cy+pt->y, 1, 1, Qt::TextDontClip, pt->s); } } diff --git a/qucs/wirelabel.cpp b/qucs/wirelabel.cpp index 243b5a249..ee2d86d1f 100644 --- a/qucs/wirelabel.cpp +++ b/qucs/wirelabel.cpp @@ -116,7 +116,7 @@ void WireLabel::paint(QPainter *p) const { }); QRect text_br; - p->drawText(x1, y1, 0, 0, Qt::TextDontClip, Name, &text_br); + p->drawText(x1, y1, 1, 1, Qt::TextDontClip, Name, &text_br); bool right = text_br.right() < cx; bool bottom = text_br.bottom() < cy;