6#include <QCoreApplication>
20 const int value = QMetaEnum::fromType<ElementType>().keyToValue(text.toLatin1());
21 return (value == -1) ? ElementType::Unknown :
static_cast<ElementType>(value);
28 if (type == ElementType::Unknown) {
33 return QVariant::fromValue(type).toString();
40 if (type == ElementType::Unknown) {
41 return tr(
"MULTIPLE TYPES");
45 return QCoreApplication::translate(meta.trContext, meta.titleText);
50 if (type == ElementType::Unknown) {
55 return QCoreApplication::translate(meta.trContext, meta.translatedName);
61 case ElementType::InputVcc:
return tr(
"Constant logic HIGH (1) source.");
62 case ElementType::InputGnd:
return tr(
"Constant logic LOW (0) source.");
63 case ElementType::InputButton:
return tr(
"Push button: outputs HIGH only while pressed.");
64 case ElementType::InputSwitch:
return tr(
"Toggle switch: click to flip between 0 and 1.");
65 case ElementType::InputRotary:
return tr(
"Rotary switch with several selectable positions.");
66 case ElementType::Clock:
return tr(
"Clock: a square wave at a configurable frequency.");
67 case ElementType::Led:
return tr(
"LED: lights up while its input is HIGH.");
68 case ElementType::Display7:
return tr(
"7-segment display for a single digit.");
69 case ElementType::Display14:
return tr(
"14-segment alphanumeric display.");
70 case ElementType::Display16:
return tr(
"16-segment alphanumeric display.");
71 case ElementType::Buzzer:
return tr(
"Buzzer: plays a tone while its input is HIGH.");
72 case ElementType::AudioBox:
return tr(
"Audio box: plays an audio file while its input is HIGH.");
73 case ElementType::And:
return tr(
"AND gate: output is HIGH only when every input is HIGH.");
74 case ElementType::Or:
return tr(
"OR gate: output is HIGH when any input is HIGH.");
75 case ElementType::Not:
return tr(
"NOT gate: inverts its input.");
76 case ElementType::Nand:
return tr(
"NAND gate: LOW only when every input is HIGH.");
77 case ElementType::Nor:
return tr(
"NOR gate: HIGH only when every input is LOW.");
78 case ElementType::Xor:
return tr(
"XOR gate: HIGH when an odd number of inputs are HIGH.");
79 case ElementType::Xnor:
return tr(
"XNOR gate: HIGH when the inputs match.");
80 case ElementType::Node:
return tr(
"Node: a wire junction / branch point.");
81 case ElementType::TruthTable:
return tr(
"Truth table: custom logic you define, output by output.");
82 case ElementType::Mux:
return tr(
"Multiplexer: routes the selected input to the output.");
83 case ElementType::Demux:
return tr(
"Demultiplexer: routes the input to the selected output.");
84 case ElementType::DLatch:
return tr(
"D latch: stores the D input while Enable is HIGH.");
85 case ElementType::SRLatch:
return tr(
"SR latch: a Set/Reset storage element.");
86 case ElementType::DFlipFlop:
return tr(
"D flip-flop: stores D on the active clock edge.");
87 case ElementType::JKFlipFlop:
return tr(
"JK flip-flop: set, reset or toggle on the active clock edge.");
88 case ElementType::TFlipFlop:
return tr(
"T flip-flop: toggles on the active clock edge when T is HIGH.");
89 case ElementType::Text:
return tr(
"Text: a free-text annotation on the canvas.");
90 case ElementType::Line:
return tr(
"Line: a decorative annotation on the canvas.");
97 if (type == ElementType::Unknown) {
108 if (type == ElementType::Unknown) {
112 const auto it =
instance().m_creatorMap.constFind(type);
114 if (it ==
instance().m_creatorMap.constEnd()) {
123 instance().m_creatorMap[type] = std::move(creator);
128 return instance().m_creatorMap.contains(type);
Common logging utilities, the Pandaception error type, and helper macros.
#define PANDACEPTION(msg,...)
#define qCDebug(category)
Singleton factory for all circuit element types.
Enums::ElementType ElementType
Abstract base class for all graphical circuit elements.
static QString translatedName(const ElementType type)
Returns the translated human-readable name for type.
static bool hasCreator(ElementType type)
Returns true if a creator function is registered for type.
static QPixmap pixmap(const ElementType type)
Returns the pixmap icon for the given element type.
static void registerCreator(ElementType type, std::function< GraphicElement *()> creator)
Registers a creator lambda for type, used by buildElement().
static QString typeToText(const ElementType type)
Converts type to its internal name string.
static QString description(const ElementType type)
static QString typeToTitleText(const ElementType type)
Returns the display title string for type.
static ElementFactory & instance()
Returns the singleton ElementFactory instance.
static ElementType textToType(const QString &text)
Converts an element type name string to its ElementType enum value.
static GraphicElement * buildElement(const ElementType type)
Constructs and returns a new graphic element of the given type.
Abstract base class for all graphical circuit elements in wiRedPanda.