SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
graphicalText.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
SPDX-License-Identifier: GPL-3.0-or-later
5
*/
6
7
#pragma once
8
9
#include <
ui/circuit/diagram/graphicalComponent.hpp
>
10
11
namespace
SILICON::ui
{
12
14
class
GraphicalText
:
public
GraphicalComponent
{
15
public
:
16
static
constexpr
std::string_view
COMPONENT_TYPE
=
"Text"
;
17
18
explicit
GraphicalText
(QGraphicsItem* parent =
nullptr
);
19
20
[[nodiscard]]
int
type
()
const override
{
return
TEXT
; }
21
[[nodiscard]] std::string
getTypeName
()
const override
22
{
23
return
std::string(
COMPONENT_TYPE
);
24
}
25
[[nodiscard]]
const
PropertyMap
&
getProperties
()
const override
{
return
properties
; }
26
[[nodiscard]] std::optional<std::reference_wrapper<const StringPropertyOptions>>
27
getStringPropertyOptions
(std::string_view key)
const override
;
28
[[nodiscard]]
bool
isMultilineProperty
(std::string_view key)
const override
29
{
30
return
key ==
"text"
;
31
}
32
[[nodiscard]]
bool
participatesInCollisions
()
const override
{
return
false
; }
33
34
[[nodiscard]] std::span<const ResizeHandle>
resizeHandles
()
const override
35
{
36
return
AllResizeHandles
;
37
}
38
[[nodiscard]]
PropertyMap
resizedProperties
(QSizeF size,
ResizeHandle
handle,
39
const
PropertyMap
& initial)
override
;
40
41
void
applyProperty
(std::string_view key,
const
PropertyValue
& value)
override
;
42
[[nodiscard]] nlohmann::ordered_json
serialize
()
const override
;
43
void
loadSerializedState
(
const
nlohmann::json& json)
override
;
44
45
private
:
46
void
setProperties
(
PropertyMap
next);
47
PropertyMap
properties
{{
"text"
, std::string(
"Text"
)},
48
{
"size"
, 12},
49
{
"font"
, std::string(
"Quicksand"
)},
50
{
"wrapWidth"
, 0}};
51
};
52
53
}
// namespace SILICON::ui
SILICON::ui::GraphicalComponent::GraphicalComponent
GraphicalComponent(ItemCategory category, QGraphicsItem *shape, QGraphicsItem *parent=nullptr, bool scanShape=false)
Definition
graphicalComponent.cpp:209
SILICON::ui::GraphicalText::applyProperty
void applyProperty(std::string_view key, const PropertyValue &value) override
Definition
graphicalText.cpp:383
SILICON::ui::GraphicalText::serialize
nlohmann::ordered_json serialize() const override
Serializes the component to JSON.
Definition
graphicalText.cpp:395
SILICON::ui::GraphicalText::type
int type() const override
Definition
graphicalText.hpp:20
SILICON::ui::GraphicalText::getStringPropertyOptions
std::optional< std::reference_wrapper< const StringPropertyOptions > > getStringPropertyOptions(std::string_view key) const override
Definition
graphicalText.cpp:326
SILICON::ui::GraphicalText::resizedProperties
PropertyMap resizedProperties(QSizeF size, ResizeHandle handle, const PropertyMap &initial) override
Definition
graphicalText.cpp:365
SILICON::ui::GraphicalText::participatesInCollisions
bool participatesInCollisions() const override
Annotations remain selectable but do not obstruct placement or routing.
Definition
graphicalText.hpp:32
SILICON::ui::GraphicalText::setProperties
void setProperties(PropertyMap next)
Definition
graphicalText.cpp:333
SILICON::ui::GraphicalText::properties
PropertyMap properties
Definition
graphicalText.hpp:47
SILICON::ui::GraphicalText::loadSerializedState
void loadSerializedState(const nlohmann::json &json) override
Loads subclass-specific serialized state.
Definition
graphicalText.cpp:405
SILICON::ui::GraphicalText::COMPONENT_TYPE
static constexpr std::string_view COMPONENT_TYPE
Definition
graphicalText.hpp:16
SILICON::ui::GraphicalText::GraphicalText
GraphicalText(QGraphicsItem *parent=nullptr)
Definition
graphicalText.cpp:317
SILICON::ui::GraphicalText::getTypeName
std::string getTypeName() const override
Gets the component type name for serialization.
Definition
graphicalText.hpp:21
SILICON::ui::GraphicalText::resizeHandles
std::span< const ResizeHandle > resizeHandles() const override
Definition
graphicalText.hpp:34
SILICON::ui::GraphicalText::getProperties
const PropertyMap & getProperties() const override
Properties exposed by graphical and simulation components alike.
Definition
graphicalText.hpp:25
SILICON::ui::GraphicalText::isMultilineProperty
bool isMultilineProperty(std::string_view key) const override
Definition
graphicalText.hpp:28
graphicalComponent.hpp
SILICON::core::PropertyValue
std::variant< int, bool, std::string, BusValue > PropertyValue
Variant type for component properties.
Definition
component.hpp:142
SILICON::core::PropertyMap
std::unordered_map< std::string, PropertyValue, TransparentStringHash, TransparentStringEqual > PropertyMap
Map from property names to their values.
Definition
component.hpp:145
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::ResizeHandle
ResizeHandle
Definition
componentResize.hpp:16
SILICON::ui::AllResizeHandles
constexpr std::array AllResizeHandles
Definition
componentResize.hpp:27
SILICON::ui::TEXT
@ TEXT
Definition
enums.hpp:115
src
ui
circuit
components
graphicalText.hpp
Generated by
1.17.0