wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
Line.cpp
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
5
8
9template<>
12 .type = ElementType::Line,
13 .group = ElementGroup::Other,
14 .canChangeAppearance = true,
15 // Label is enabled so users can attach a description string directly to the line.
16 .hasLabel = true,
17 };
18 static_assert(validate(constraints));
19
21 {
23 meta.pixmapPath = []{ return QStringLiteral(":/Components/Misc/line.svg"); };
24 meta.titleText = QT_TRANSLATE_NOOP("Line", "LINE");
25 meta.translatedName = QT_TRANSLATE_NOOP("Line", "Line");
26 meta.trContext = "Line";
27 // Seed appearance lists from the constructor-supplied pixmap path (see And.cpp for details).
28 meta.defaultAppearances = QStringList({":/Components/Misc/line.svg"});
29 // Line is decorative and excluded from simulation.
30 return meta;
31 }
32
33 static inline const bool registered = []() {
35 ElementFactory::registerCreator(constraints.type, [] { return new Line(); });
36 return true;
37 }();
38};
39
40// Line is a purely decorative element: 0 inputs and 0 outputs mean it has no
41// simulation role. It exists so users can draw visual separators and annotation
42// lines on the canvas.
43Line::Line(QGraphicsItem *parent)
45{
46}
Singleton factory for all circuit element types.
Self-registering element trait template and compile-time constraint validation.
ElementMetadata metadataFromConstraints(const ElementConstraints &c)
Converts ElementConstraints to an ElementMetadata with all constraint-derived fields set.
Definition ElementInfo.h:80
constexpr bool validate(const ElementConstraints &c)
Validates element constraints at compile time.
Definition ElementInfo.h:48
Enums::ElementType ElementType
Definition Enums.h:107
Graphic element for a decorative line shape (no simulation).
static void registerCreator(ElementType type, std::function< GraphicElement *()> creator)
Registers a creator lambda for type, used by buildElement().
static void registerMetadata(const ElementMetadata &meta)
Registers meta in the global map (called once per element type at startup).
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
Decorative line element used for annotating circuit diagrams.
Definition Line.h:19
Line(QGraphicsItem *parent=nullptr)
Constructs a Line element.
Definition Line.cpp:43
Compile-time-validatable subset of ElementMetadata.
Definition ElementInfo.h:21
static const bool registered
Definition Line.cpp:33
static constexpr ElementConstraints constraints
Definition Line.cpp:11
static ElementMetadata metadata()
Definition Line.cpp:20
Self-registering element information trait.
Compile-time-registered properties for one element type.