Realistic terminal strip: draw the clamp of the terminal chosen in the catalog

The realistic styles drew every terminal of a strip with the clamp of the
layout (RealisticScrew or RealisticPushIn), whatever terminal was chosen:
a Phoenix Contact ST (spring) was drawn with screws in a screw layout.

Each entry of the terminal catalog now has its clamp: screw (Phoenix
Contact UT, Weidmüller WDU, ABB Entrelec M, Legrand Viking 3), spring
(Phoenix Contact ST) or push-in (WAGO TOPJOB S). A terminal chosen in the
catalog is drawn with its own clamp, the spring-cage ones like the push-in
ones; the clamp of the layout is kept for the other terminals, so a strip
mixing screw and spring terminals is drawn as it is.
This commit is contained in:
Laurent Trinques
2026-10-18 15:39:05 +02:00
parent f7196c48e1
commit ea2acfcaeb
5 changed files with 58 additions and 30 deletions
@@ -17,6 +17,7 @@
*/
#include "realisticterminalstripdrawer.h"
#include "terminalstripdrawerhelpers.h"
#include "../terminalcatalog.h"
#include <QFontMetricsF>
#include <QHash>
@@ -545,7 +546,8 @@ void paint(QPainter *painter,
const QPointF &hover_pos,
QVector<XrefRect> *xref_rects)
{
const bool screw_{style == TerminalStripLayoutPattern::DrawStyle::RealisticScrew};
//Clamp of the layout, used for the terminals not chosen in the catalog
const bool layout_screw_{style == TerminalStripLayoutPattern::DrawStyle::RealisticScrew};
const qreal s_{pattern.m_realistic_px_per_mm};
const qreal length_{pattern.m_realistic_length_mm * s_};
if (s_ <= 0 || length_ <= 0) {
@@ -601,6 +603,13 @@ void paint(QPainter *painter,
const auto first_{g_.reals.first()};
const int levels_{static_cast<int>(g_.reals.size())};
//A terminal chosen in the catalog is drawn with its own clamp, so that a strip
//mixing screw and spring terminals is drawn as it is. The spring-cage clamps
//(opened with a screwdriver) are drawn like the push-in ones.
const auto *catalog_entry_{TerminalCatalog::entryByLabel(first_->catalogEntry())};
const bool screw_{catalog_entry_ ? catalog_entry_->clamp == TerminalCatalog::Clamp::Screw
: layout_screw_};
QColor fill_, stripe_;
Helpers::terminalColors(first_, fill_, stripe_);
if (!fill_.isValid()) {
@@ -85,6 +85,9 @@ namespace TerminalStripDrawer
//Second color of a two-tone color (like green/yellow), drawn as stripes over color()
virtual QColor stripeColor() const { return QColor(); }
virtual qreal widthMm() const { return 0; }
//Label of the terminal chosen in the catalog (TerminalCatalog), empty if unknown.
//The realistic styles draw its clamp (screw or push-in) instead of the one of the layout.
virtual QString catalogEntry() const { return QString(); }
//A separator plate is mounted after the terminal (drawn by the realistic styles)
virtual bool hasSeparatorAfter() const { return false; }
};
@@ -168,6 +168,11 @@ namespace TerminalStripDrawer
return m_real ? m_real->widthMm() : 0;
}
QString TrueRealTerminal::catalogEntry() const
{
return m_real ? m_real->catalogEntry() : QString();
}
bool TrueRealTerminal::hasSeparatorAfter() const
{
return m_real ? m_real->hasSeparatorAfter() : false;
@@ -67,6 +67,7 @@ namespace TerminalStripDrawer
QColor color() const override;
QColor stripeColor() const override;
qreal widthMm() const override;
QString catalogEntry() const override;
bool hasSeparatorAfter() const override;
private:
+39 -29
View File
@@ -33,11 +33,21 @@
*/
namespace TerminalCatalog
{
/**
* How the wire is clamped in the terminal.
* Used by the realistic drawing of the terminal strip.
*/
enum class Clamp {
Screw, ///< Screw clamp (Phoenix Contact UT, Weidmüller WDU...)
Spring, ///< Spring-cage clamp, opened with a screwdriver (Phoenix Contact ST)
PushIn ///< Push-in clamp (WAGO TOPJOB S)
};
/**
* Width (mm) of a terminal sold by a manufacturer.
* For ABB Entrelec the value is the spacing (pitch) given by the catalog.
*/
struct WidthEntry { double mm; const char *label; double section; const char *manufacturer; };
struct WidthEntry { double mm; const char *label; double section; const char *manufacturer; Clamp clamp; };
inline const QVector<double> &sections()
{
@@ -93,34 +103,34 @@ namespace TerminalCatalog
inline const QVector<WidthEntry> &widthEntries()
{
static const QVector<WidthEntry> entries_ {
{4.2, "Phoenix Contact ST 1,5", 1.5, "Phoenix Contact"},
{5.0, "ABB Entrelec MA 2.5/5", 2.5, "ABB Entrelec"},
{5.1, "Weidmüller WDU 2.5", 2.5, "Weidmüller"},
{5.2, "WAGO 2002 (TOPJOB S)", 2.5, "WAGO"},
{5.2, "Phoenix Contact ST 2,5 / ST 2,5-QUATTRO", 2.5, "Phoenix Contact"},
{6.0, "ABB Entrelec M 4/6", 4.0, "ABB Entrelec"},
{6.0, "Legrand Viking 3 (4 mm²)", 4.0, "Legrand"},
{6.1, "Weidmüller WDU 4", 4.0, "Weidmüller"},
{6.2, "Phoenix Contact UT 4", 4.0, "Phoenix Contact"},
{6.2, "Phoenix Contact ST 4", 4.0, "Phoenix Contact"},
{7.5, "WAGO 2006 (TOPJOB S)", 6.0, "WAGO"},
{7.9, "Weidmüller WDU 6", 6.0, "Weidmüller"},
{8.0, "ABB Entrelec M 6/8", 6.0, "ABB Entrelec"},
{8.0, "ABB Entrelec M 4/8", 4.0, "ABB Entrelec"},
{8.2, "Phoenix Contact UT 6", 6.0, "Phoenix Contact"},
{10.0, "ABB Entrelec M 10/10", 10.0, "ABB Entrelec"},
{10.2, "Phoenix Contact UT 10", 10.0, "Phoenix Contact"},
{11.9, "Weidmüller WDU 16/ZA", 16.0, "Weidmüller"},
{12.0, "ABB Entrelec M 16/12", 16.0, "ABB Entrelec"},
{12.0, "Legrand Viking 3 (16 mm²)", 16.0, "Legrand"},
{12.2, "Phoenix Contact UT 16", 16.0, "Phoenix Contact"},
{16.0, "ABB Entrelec M 35/16", 35.0, "ABB Entrelec"},
{16.0, "Phoenix Contact UT 35", 35.0, "Phoenix Contact"},
{16.0, "Weidmüller WDU 35N", 35.0, "Weidmüller"},
{26.0, "ABB Entrelec M 35/26.FF", 35.0, "ABB Entrelec"},
{31.0, "ABB Entrelec M 70/31.AF", 70.0, "ABB Entrelec"},
{35.0, "ABB Entrelec M 120/35.F", 120.0, "ABB Entrelec"},
{42.0, "ABB Entrelec M 300/42.FF", 300.0, "ABB Entrelec"}
{4.2, "Phoenix Contact ST 1,5", 1.5, "Phoenix Contact", Clamp::Spring},
{5.0, "ABB Entrelec MA 2.5/5", 2.5, "ABB Entrelec", Clamp::Screw},
{5.1, "Weidmüller WDU 2.5", 2.5, "Weidmüller", Clamp::Screw},
{5.2, "WAGO 2002 (TOPJOB S)", 2.5, "WAGO", Clamp::PushIn},
{5.2, "Phoenix Contact ST 2,5 / ST 2,5-QUATTRO", 2.5, "Phoenix Contact", Clamp::Spring},
{6.0, "ABB Entrelec M 4/6", 4.0, "ABB Entrelec", Clamp::Screw},
{6.0, "Legrand Viking 3 (4 mm²)", 4.0, "Legrand", Clamp::Screw},
{6.1, "Weidmüller WDU 4", 4.0, "Weidmüller", Clamp::Screw},
{6.2, "Phoenix Contact UT 4", 4.0, "Phoenix Contact", Clamp::Screw},
{6.2, "Phoenix Contact ST 4", 4.0, "Phoenix Contact", Clamp::Spring},
{7.5, "WAGO 2006 (TOPJOB S)", 6.0, "WAGO", Clamp::PushIn},
{7.9, "Weidmüller WDU 6", 6.0, "Weidmüller", Clamp::Screw},
{8.0, "ABB Entrelec M 6/8", 6.0, "ABB Entrelec", Clamp::Screw},
{8.0, "ABB Entrelec M 4/8", 4.0, "ABB Entrelec", Clamp::Screw},
{8.2, "Phoenix Contact UT 6", 6.0, "Phoenix Contact", Clamp::Screw},
{10.0, "ABB Entrelec M 10/10", 10.0, "ABB Entrelec", Clamp::Screw},
{10.2, "Phoenix Contact UT 10", 10.0, "Phoenix Contact", Clamp::Screw},
{11.9, "Weidmüller WDU 16/ZA", 16.0, "Weidmüller", Clamp::Screw},
{12.0, "ABB Entrelec M 16/12", 16.0, "ABB Entrelec", Clamp::Screw},
{12.0, "Legrand Viking 3 (16 mm²)", 16.0, "Legrand", Clamp::Screw},
{12.2, "Phoenix Contact UT 16", 16.0, "Phoenix Contact", Clamp::Screw},
{16.0, "ABB Entrelec M 35/16", 35.0, "ABB Entrelec", Clamp::Screw},
{16.0, "Phoenix Contact UT 35", 35.0, "Phoenix Contact", Clamp::Screw},
{16.0, "Weidmüller WDU 35N", 35.0, "Weidmüller", Clamp::Screw},
{26.0, "ABB Entrelec M 35/26.FF", 35.0, "ABB Entrelec", Clamp::Screw},
{31.0, "ABB Entrelec M 70/31.AF", 70.0, "ABB Entrelec", Clamp::Screw},
{35.0, "ABB Entrelec M 120/35.F", 120.0, "ABB Entrelec", Clamp::Screw},
{42.0, "ABB Entrelec M 300/42.FF", 300.0, "ABB Entrelec", Clamp::Screw}
};
return entries_;
}