From fb226d435e55d1e96f50c27f25d05c81913583c7 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Sat, 10 Oct 2026 10:01:12 +0200 Subject: [PATCH] Terminal strip: add an anti-parallel diodes terminal type Add ElementData::TTAntiParallelDiodes (xml value "antiparallel_diodes"), selectable in the element editor, the terminal strip editor and the free terminal editor, and drawn in the terminal strip plan as two diodes wired in opposite directions between the top and the bottom of the terminal. --- .../GraphicsItem/terminalstripdrawer.cpp | 26 +++++++++++++++++++ .../TerminalStrip/ui/freeterminaleditor.cpp | 2 ++ .../TerminalStrip/ui/freeterminaleditor.ui | 5 ++++ .../TerminalStrip/ui/freeterminalmodel.cpp | 1 + .../TerminalStrip/ui/terminalstripeditor.cpp | 2 ++ .../TerminalStrip/ui/terminalstripeditor.ui | 5 ++++ .../TerminalStrip/ui/terminalstripmodel.cpp | 1 + .../ui/elementpropertieseditorwidget.cpp | 1 + sources/properties/elementdata.cpp | 6 +++++ sources/properties/elementdata.h | 3 ++- 10 files changed, 51 insertions(+), 1 deletion(-) diff --git a/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp b/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp index be933ab63..8eccb75df 100644 --- a/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp +++ b/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp @@ -90,6 +90,31 @@ void drawGroundSymbol(QPainter *painter) painter->drawLine(QPointF{-1, 4}, QPointF{1, 4}); } + //Two diodes side by side, wired in anti-parallel between the top and + //the bottom of the terminal (current flows through the left one from + //the top to the bottom and through the right one the other way) +void drawAntiParallelDiodesSymbol(QPainter *painter) +{ + painter->drawLine(QPointF{0, -7}, QPointF{0, -5}); + painter->drawLine(QPointF{-5, -5}, QPointF{5, -5}); + painter->drawLine(QPointF{0, 5}, QPointF{0, 7}); + painter->drawLine(QPointF{-5, 5}, QPointF{5, 5}); + + //Left diode, anode on top + const QPointF left_diode[3] { {-8, -3}, {-2, -3}, {-5, 2} }; + painter->drawLine(QPointF{-5, -5}, QPointF{-5, -3}); + painter->drawPolygon(left_diode, 3); + painter->drawLine(QPointF{-8, 2}, QPointF{-2, 2}); + painter->drawLine(QPointF{-5, 2}, QPointF{-5, 5}); + + //Right diode, anode at the bottom + const QPointF right_diode[3] { {2, 2}, {8, 2}, {5, -3} }; + painter->drawLine(QPointF{5, -5}, QPointF{5, -3}); + painter->drawPolygon(right_diode, 3); + painter->drawLine(QPointF{2, -3}, QPointF{8, -3}); + painter->drawLine(QPointF{5, 2}, QPointF{5, 5}); +} + /** * @brief drawScaled * Call @a draw with the painter moved by @a dx and scaled by @a factor. @@ -147,6 +172,7 @@ void drawTypeSymbol(QPainter *painter, const QRectF &box, ElementData::TerminalT case ElementData::TTSectional : drawSectionalSymbol(p); break; case ElementData::TTDiode : drawDiodeSymbol(p); break; case ElementData::TTGround : drawGroundSymbol(p); break; + case ElementData::TTAntiParallelDiodes : drawAntiParallelDiodesSymbol(p); break; default: break; } }; diff --git a/sources/TerminalStrip/ui/freeterminaleditor.cpp b/sources/TerminalStrip/ui/freeterminaleditor.cpp index 50e006d7b..3f08e39d6 100644 --- a/sources/TerminalStrip/ui/freeterminaleditor.cpp +++ b/sources/TerminalStrip/ui/freeterminaleditor.cpp @@ -191,6 +191,8 @@ void FreeTerminalEditor::on_m_type_cb_activated(int index) override_type = ElementData::TTDiode; break; case 4: override_type = ElementData::TTGround; break; + case 5: + override_type = ElementData::TTAntiParallelDiodes; break; default: override_type = ElementData::TTGeneric; break; } diff --git a/sources/TerminalStrip/ui/freeterminaleditor.ui b/sources/TerminalStrip/ui/freeterminaleditor.ui index 56f6c4c2a..736c2b12d 100644 --- a/sources/TerminalStrip/ui/freeterminaleditor.ui +++ b/sources/TerminalStrip/ui/freeterminaleditor.ui @@ -122,6 +122,11 @@ Ground + + + Anti-parallel diodes + + diff --git a/sources/TerminalStrip/ui/freeterminalmodel.cpp b/sources/TerminalStrip/ui/freeterminalmodel.cpp index 27183100e..7eb2eb1f6 100644 --- a/sources/TerminalStrip/ui/freeterminalmodel.cpp +++ b/sources/TerminalStrip/ui/freeterminalmodel.cpp @@ -429,6 +429,7 @@ QWidget *FreeTerminalModelDelegate::createEditor(QWidget *parent, const QStyleOp qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTDiode), ElementData::TTDiode); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGround), ElementData::TTGround); + qcb->addItem(ElementData::translatedTerminalType(ElementData::TTAntiParallelDiodes), ElementData::TTAntiParallelDiodes); return qcb; } diff --git a/sources/TerminalStrip/ui/terminalstripeditor.cpp b/sources/TerminalStrip/ui/terminalstripeditor.cpp index 9a56339b0..ba3964f1e 100644 --- a/sources/TerminalStrip/ui/terminalstripeditor.cpp +++ b/sources/TerminalStrip/ui/terminalstripeditor.cpp @@ -569,6 +569,8 @@ void TerminalStripEditor::on_m_type_cb_activated(int index) override_type = ElementData::TTDiode; break; case 4: override_type = ElementData::TTGround; break; + case 5: + override_type = ElementData::TTAntiParallelDiodes; break; default: override_type = ElementData::TTGeneric; break; } diff --git a/sources/TerminalStrip/ui/terminalstripeditor.ui b/sources/TerminalStrip/ui/terminalstripeditor.ui index 35fbb9f5d..46998a04e 100644 --- a/sources/TerminalStrip/ui/terminalstripeditor.ui +++ b/sources/TerminalStrip/ui/terminalstripeditor.ui @@ -127,6 +127,11 @@ Ground + + + Anti-parallel diodes + + diff --git a/sources/TerminalStrip/ui/terminalstripmodel.cpp b/sources/TerminalStrip/ui/terminalstripmodel.cpp index c6e3fac46..2f363ba1c 100644 --- a/sources/TerminalStrip/ui/terminalstripmodel.cpp +++ b/sources/TerminalStrip/ui/terminalstripmodel.cpp @@ -833,6 +833,7 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTDiode), ElementData::TTDiode); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGround), ElementData::TTGround); + qcb->addItem(ElementData::translatedTerminalType(ElementData::TTAntiParallelDiodes), ElementData::TTAntiParallelDiodes); return qcb; } diff --git a/sources/editor/ui/elementpropertieseditorwidget.cpp b/sources/editor/ui/elementpropertieseditorwidget.cpp index 178d08a21..d45477483 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.cpp +++ b/sources/editor/ui/elementpropertieseditorwidget.cpp @@ -225,6 +225,7 @@ void ElementPropertiesEditorWidget::setUpInterface() ui->m_terminal_type_cb->addItem(tr("Sectionable"), ElementData::TTSectional); ui->m_terminal_type_cb->addItem(tr("Diode"), ElementData::TTDiode); ui->m_terminal_type_cb->addItem(tr("Ground"), ElementData::TTGround); + ui->m_terminal_type_cb->addItem(tr("Anti-parallel diodes"), ElementData::TTAntiParallelDiodes); ui->m_terminal_func_cb->addItem(tr("Generic"), ElementData::TFGeneric); ui->m_terminal_func_cb->addItem(tr("Phase"), ElementData::TFPhase); diff --git a/sources/properties/elementdata.cpp b/sources/properties/elementdata.cpp index 8586c243e..2804295ed 100644 --- a/sources/properties/elementdata.cpp +++ b/sources/properties/elementdata.cpp @@ -840,6 +840,8 @@ QString ElementData::terminalTypeToString(ElementData::TerminalType type) return QStringLiteral("diode"); case ElementData::TTGround: return QStringLiteral("ground"); + case ElementData::TTAntiParallelDiodes: + return QStringLiteral("antiparallel_diodes"); } return QStringLiteral("generic"); } @@ -856,6 +858,8 @@ ElementData::TerminalType ElementData::terminalTypeFromString(const QString &str return ElementData::TTDiode; } else if (string == QLatin1String("ground")) { return ElementData::TTGround; + } else if (string == QLatin1String("antiparallel_diodes")) { + return ElementData::TTAntiParallelDiodes; } qDebug() << "ElementData::terminalTypeFromString : string : " @@ -877,6 +881,8 @@ QString ElementData::translatedTerminalType(ElementData::TerminalType type) return QObject::tr("Diode", "diode terminal element type"); case ElementData::TTGround: return QObject::tr("Ground", "ground terminal element type"); + case ElementData::TTAntiParallelDiodes: + return QObject::tr("Anti-parallel diodes", "anti-parallel diodes terminal element type"); } return QObject::tr("Generic", "generic terminal element type"); } diff --git a/sources/properties/elementdata.h b/sources/properties/elementdata.h index 51b9c9678..97a834840 100644 --- a/sources/properties/elementdata.h +++ b/sources/properties/elementdata.h @@ -175,7 +175,8 @@ class ElementData : public PropertiesInterface TTFuse, TTSectional, TTDiode, - TTGround + TTGround, + TTAntiParallelDiodes }; Q_ENUM(TerminalType)