wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementFactory Class Reference

Factory for circuit elements. More...

#include <ElementFactory.h>

Inheritance diagram for ElementFactory:
[legend]

Static Public Member Functions

static GraphicElementbuildElement (const ElementType type)
 Constructs and returns a new graphic element of the given type.
static QString description (const ElementType type)
static bool hasCreator (ElementType type)
 Returns true if a creator function is registered for type.
static ElementFactoryinstance ()
 Returns the singleton ElementFactory instance.
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 ElementType textToType (const QString &text)
 Converts an element type name string to its ElementType enum value.
static QString translatedName (const ElementType type)
 Returns the translated human-readable name for type.
static QString typeToText (const ElementType type)
 Converts type to its internal name string.
static QString typeToTitleText (const ElementType type)
 Returns the display title string for type.

Detailed Description

Factory for circuit elements.

The ElementFactory class is a singleton that handles the creation of circuit elements and provides access to element type properties. ID management is handled by Scene, not by this class.

Definition at line 26 of file ElementFactory.h.

Member Function Documentation

◆ buildElement()

GraphicElement * ElementFactory::buildElement ( const ElementType type)
static

◆ description()

QString ElementFactory::description ( const ElementType type)
static

Returns a short, translated functional description of type for palette tooltips (empty for types without one, e.g. IC).

Definition at line 58 of file ElementFactory.cpp.

Referenced by ElementLabel::ElementLabel().

◆ hasCreator()

bool ElementFactory::hasCreator ( ElementType type)
static

Returns true if a creator function is registered for type.

Definition at line 126 of file ElementFactory.cpp.

References instance().

◆ instance()

ElementFactory & ElementFactory::instance ( )
inlinestatic

Returns the singleton ElementFactory instance.

Definition at line 32 of file ElementFactory.h.

References instance().

Referenced by buildElement(), hasCreator(), instance(), and registerCreator().

◆ pixmap()

QPixmap ElementFactory::pixmap ( const ElementType type)
static

Returns the pixmap icon for the given element type.

Definition at line 95 of file ElementFactory.cpp.

References ElementMetadataRegistry::metadata(), and ElementMetadata::pixmapPath.

Referenced by addElementAction(), ElementContextMenu::exec(), MainWindow::populateMenu(), and ElementLabel::updateTheme().

◆ registerCreator()

void ElementFactory::registerCreator ( ElementType type,
std::function< GraphicElement *()> creator )
static

Registers a creator lambda for type, used by buildElement().

Definition at line 121 of file ElementFactory.cpp.

References instance().

◆ textToType()

ElementType ElementFactory::textToType ( const QString & text)
static

Converts an element type name string to its ElementType enum value.

Definition at line 13 of file ElementFactory.cpp.

References qCDebug.

Referenced by MainWindow::populateMenu().

◆ translatedName()

QString ElementFactory::translatedName ( const ElementType type)
static

Returns the translated human-readable name for type.

Definition at line 48 of file ElementFactory.cpp.

References ElementMetadataRegistry::metadata().

Referenced by addElementAction(), ElementLabel::ElementLabel(), GraphicElement::retranslate(), and ElementLabel::updateName().

◆ typeToText()

QString ElementFactory::typeToText ( const ElementType type)
static

Converts type to its internal name string.

Definition at line 24 of file ElementFactory.cpp.

References qCDebug.

Referenced by buildElement().

◆ typeToTitleText()

QString ElementFactory::typeToTitleText ( const ElementType type)
static

Returns the display title string for type.

Definition at line 36 of file ElementFactory.cpp.

References ElementMetadataRegistry::metadata(), and qCDebug.


The documentation for this class was generated from the following files: