13 .type = ElementType::DLatch,
14 .group = ElementGroup::Memory,
19 .canChangeAppearance =
true,
21 static_assert(
validate(constraints));
27 meta.titleText = QT_TRANSLATE_NOOP(
"DLatch",
"D-LATCH");
28 meta.translatedName = QT_TRANSLATE_NOOP(
"DLatch",
"D-Latch");
29 meta.trContext =
"DLatch";
79 if (enable == Status::Active) {
81 q1 = (D == Status::Active) ? Status::Inactive : Status::Active;
Graphic element for the D latch.
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.
constexpr bool validate(const ElementConstraints &c)
Validates element constraints at compile time.
Enums::ElementType ElementType
Port classes: Port (base), InputPort, and OutputPort.
Graphical representation of a level-sensitive D latch.
void updateLogic() override
Updates Q based on D and enable level.
DLatch(QGraphicsItem *parent=nullptr)
Constructs the element with optional parent.
void updatePortsProperties() override
Updates port names for this latch.
void updateTheme() override
Refreshes the pixmap when the application theme changes.
static QString pixmapPath()
static void registerCreator(ElementType type, std::function< GraphicElement *()> creator)
Registers a creator lambda for type, used by buildElement().
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
const QVector< Status > & simInputs() const
Read-only view of the cached simulation input values.
virtual void updateTheme()
Updates the element's visual theme according to the current dark/light palette.
void setOutputValue(const int index, const Status value)
Sets simulation output port index to value.
InputPort * inputPort(const int index=0) const
Returns the input port at index (default 0).
OutputPort * outputPort(const int index=0) const
Returns the output port at index (default 0).
bool simUpdateInputs()
Snapshots each predecessor's output into the simulation input cache.
const QVector< Status > & simOutputs() const
Read-only view of the current simulation output values.
void setPixmap(const QString &pixmapPath)
Loads and applies the pixmap located at pixmapPath.
void setDefaultStatus(const Status defaultStatus)
Sets the status applied when the port has no connection.
void setName(const QString &name)
Sets the label text shown next to the port.
Compile-time-validatable subset of ElementMetadata.
static const bool registered
static ElementMetadata metadata()
static constexpr ElementConstraints constraints
Self-registering element information trait.