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.
This commit is contained in:
Laurent Trinques
2026-10-10 10:01:12 +02:00
parent 8d8a998f75
commit fb226d435e
10 changed files with 51 additions and 1 deletions
@@ -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;
}
};
@@ -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;
}
@@ -122,6 +122,11 @@
<string>Ground</string>
</property>
</item>
<item>
<property name="text">
<string>Anti-parallel diodes</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2" colspan="2">
@@ -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;
}
@@ -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;
}
@@ -127,6 +127,11 @@
<string>Ground</string>
</property>
</item>
<item>
<property name="text">
<string>Anti-parallel diodes</string>
</property>
</item>
</widget>
</item>
<item row="8" column="0">
@@ -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;
}
@@ -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);
+6
View File
@@ -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");
}
+2 -1
View File
@@ -175,7 +175,8 @@ class ElementData : public PropertiesInterface
TTFuse,
TTSectional,
TTDiode,
TTGround
TTGround,
TTAntiParallelDiodes
};
Q_ENUM(TerminalType)