|
wiRedPanda
Logic Circuit Simulator
|
Owns the visual appearance of a GraphicElement: the displayed pixmap, its SVG renderer, the default/alternative appearance lists, and the selection-highlight colors. More...
#include <ElementAppearance.h>
Public Member Functions | |
| const QStringList & | alternativeAppearances () const |
| Returns the active (possibly user-customised) appearance paths. | |
| void | applyOrientation () |
| Re-derives the displayed pixmap (and SVG renderer) from the owner's current orientation. | |
| void | applyTheme (const ThemeAttributes &theme) |
| Applies the selection-highlight colors from theme. | |
| const QStringList & | defaultAppearances () const |
| Returns the built-in default appearance paths. | |
| ElementAppearance (GraphicElement *owner) | |
| Constructs the appearance bound to its owning owner element. | |
| QStringList | externalFiles () const |
| Returns the external (non-resource) appearance file paths the element depends on. | |
| bool | hasDefaultAppearances () const |
| Returns true if at least one default appearance is available. | |
| QPixmap | pixmap () const |
| Returns the pixmap currently displayed. | |
| QPointF | pixmapCenter () const |
| Returns the centre point of the displayed pixmap in local coordinates. | |
| QPixmap | previewPixmapAt (const int index, const QSize &size) const |
| void | recomputeUsingDefault () |
| Recomputes the using-default flag by comparing the alternative and default lists. | |
| void | render (QPainter *painter, const QRectF &boundingRect, const bool selected) const |
| Draws the selection highlight (when selected) and the SVG/pixmap body onto painter. | |
| void | resetAlternativeToDefault () |
| Copies the default appearances over the alternative list (restore-to-default). | |
| void | seedFromMetadata (const QStringList &defaultAppearances, const QStringList &alternativeAppearances, const QString &pixmapPath) |
| QColor | selectionBrush () const |
| Fill color of the selection highlight rectangle. | |
| QColor | selectionPen () const |
| Border color of the selection highlight rectangle. | |
| void | setAlternativeAppearanceAt (const int index, const QString &path) |
| Sets one alternative-appearance slot without reloading the pixmap (serializer / subclass use). | |
| void | setAppearance (const bool defaultAppearance, const QString &fileName) |
| Switches the appearance: restores defaults or applies fileName at slot 0. | |
| void | setAppearanceAt (const int index, const QString &fileName) |
| Sets a custom appearance at index (empty fileName restores that slot's default). | |
| void | setPixmap (const int index) |
| Loads and applies the appearance at position index in the active list. | |
| void | setPixmap (const QString &pixmapPath) |
| Loads and applies the pixmap located at pixmapPath. | |
| void | setRenderPixmap (const QPixmap &pixmap) |
| void | setUsingDefaultAppearance (const bool value) |
| Sets the "using built-in default appearance" flag. | |
| bool | usingDefaultAppearance () const |
| Returns true when the active appearance still matches the built-in default. | |
| ~ElementAppearance () | |
| Out-of-line so the unique_ptr to the forward-declared QSvgRenderer can be destroyed. | |
Owns the visual appearance of a GraphicElement: the displayed pixmap, its SVG renderer, the default/alternative appearance lists, and the selection-highlight colors.
Extracted from GraphicElement so the rendering bulk (pixmap loading, SVG text counter-orientation, the per-appearance caches, and the paint body) lives in one cohesive unit. Orientation state (rotation/flip) stays on the owning element; this type reads it back through a narrow owner reference, which it also uses to trigger repaints and resolve the element's context directory.
Definition at line 34 of file ElementAppearance.h.
|
explicit |
Constructs the appearance bound to its owning owner element.
Definition at line 212 of file ElementAppearance.cpp.
|
default |
Out-of-line so the unique_ptr to the forward-declared QSvgRenderer can be destroyed.
References alternativeAppearances(), and defaultAppearances().
|
inline |
Returns the active (possibly user-customised) appearance paths.
Definition at line 92 of file ElementAppearance.h.
Referenced by GraphicElementSerializer::save(), seedFromMetadata(), and ~ElementAppearance().
| void ElementAppearance::applyOrientation | ( | ) |
Re-derives the displayed pixmap (and SVG renderer) from the owner's current orientation.
Definition at line 354 of file ElementAppearance.cpp.
Referenced by setPixmap().
| void ElementAppearance::applyTheme | ( | const ThemeAttributes & | theme | ) |
Applies the selection-highlight colors from theme.
Definition at line 492 of file ElementAppearance.cpp.
References ThemeAttributes::m_selectionBrush, and ThemeAttributes::m_selectionPen.
|
inline |
Returns the built-in default appearance paths.
Definition at line 89 of file ElementAppearance.h.
Referenced by seedFromMetadata(), and ~ElementAppearance().
| QStringList ElementAppearance::externalFiles | ( | ) | const |
Returns the external (non-resource) appearance file paths the element depends on.
Definition at line 451 of file ElementAppearance.cpp.
|
inline |
Returns true if at least one default appearance is available.
Definition at line 60 of file ElementAppearance.h.
|
inline |
Returns the pixmap currently displayed.
Definition at line 54 of file ElementAppearance.h.
Referenced by previewPixmapAt(), and setRenderPixmap().
| QPointF ElementAppearance::pixmapCenter | ( | ) | const |
Returns the centre point of the displayed pixmap in local coordinates.
Definition at line 237 of file ElementAppearance.cpp.
Referenced by setPixmap(), and setRenderPixmap().
| QPixmap ElementAppearance::previewPixmapAt | ( | const int | index, |
| const QSize & | size ) const |
Returns a scaled-down preview of the appearance at index, without mutating the element's live displayed pixmap. Returns a null pixmap for an out-of-range index.
Definition at line 322 of file ElementAppearance.cpp.
References pixmap().
| void ElementAppearance::recomputeUsingDefault | ( | ) |
Recomputes the using-default flag by comparing the alternative and default lists.
Definition at line 443 of file ElementAppearance.cpp.
| void ElementAppearance::render | ( | QPainter * | painter, |
| const QRectF & | boundingRect, | ||
| const bool | selected ) const |
Draws the selection highlight (when selected) and the SVG/pixmap body onto painter.
Definition at line 463 of file ElementAppearance.cpp.
|
inline |
Copies the default appearances over the alternative list (restore-to-default).
Definition at line 95 of file ElementAppearance.h.
| void ElementAppearance::seedFromMetadata | ( | const QStringList & | defaultAppearances, |
| const QStringList & | alternativeAppearances, | ||
| const QString & | pixmapPath ) |
Seeds the appearance lists from element metadata (lazily deriving defaults from pixmapPath when defaultAppearances is empty; alternatives default to the defaults).
Definition at line 219 of file ElementAppearance.cpp.
References alternativeAppearances(), and defaultAppearances().
|
inline |
Fill color of the selection highlight rectangle.
Definition at line 121 of file ElementAppearance.h.
|
inline |
Border color of the selection highlight rectangle.
Definition at line 124 of file ElementAppearance.h.
| void ElementAppearance::setAlternativeAppearanceAt | ( | const int | index, |
| const QString & | path ) |
Sets one alternative-appearance slot without reloading the pixmap (serializer / subclass use).
Definition at line 435 of file ElementAppearance.cpp.
| void ElementAppearance::setAppearance | ( | const bool | defaultAppearance, |
| const QString & | fileName ) |
Switches the appearance: restores defaults or applies fileName at slot 0.
Definition at line 407 of file ElementAppearance.cpp.
References setPixmap().
| void ElementAppearance::setAppearanceAt | ( | const int | index, |
| const QString & | fileName ) |
Sets a custom appearance at index (empty fileName restores that slot's default).
Definition at line 419 of file ElementAppearance.cpp.
References setPixmap().
| void ElementAppearance::setPixmap | ( | const int | index | ) |
Loads and applies the appearance at position index in the active list.
Definition at line 248 of file ElementAppearance.cpp.
References setPixmap().
Referenced by setAppearance(), setAppearanceAt(), and setPixmap().
| void ElementAppearance::setPixmap | ( | const QString & | pixmapPath | ) |
Loads and applies the pixmap located at pixmapPath.
Definition at line 253 of file ElementAppearance.cpp.
References applyOrientation(), PANDACEPTION, pixmapCenter(), and qCDebug.
| void ElementAppearance::setRenderPixmap | ( | const QPixmap & | pixmap | ) |
Replaces the displayed pixmap with a procedurally-built one (Mux/Demux/TruthTable/IC). From then on the owner draws its own body from this pixmap's footprint: orientation changes leave it untouched, and the owner's transform origin is kept at its centre.
Definition at line 337 of file ElementAppearance.cpp.
References pixmap(), and pixmapCenter().
Referenced by ICRenderer::generatePixmap().
|
inline |
Sets the "using built-in default appearance" flag.
Definition at line 101 of file ElementAppearance.h.
|
inline |
Returns true when the active appearance still matches the built-in default.
Definition at line 104 of file ElementAppearance.h.