|
FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
|
A monitor block that displays the value of its input port. More...
#include <MonitorBlock.h>
Inheritance diagram for business_logic::elements::blocks::MonitorBlock:
Collaboration diagram for business_logic::elements::blocks::MonitorBlock:Public Member Functions | |
| MonitorBlock (int cx, int cy, business_logic::delegate::INewBlockChoiceDelegate *newBlockChoiceDelegate, business_logic::delegate::IBlockLifecycleManagerDelegate *blockLifecycleManagerDelegate, business_logic::delegate::IWindowDelegate *windowDelegate) | |
| Constructor. | |
| std::optional< std::string > | getValueToRenderAboveBlock (bool isHovered) override |
| Wrapper that gets the value of the output port above the block; if the input port is not connected, it will not be rendered. | |
| std::string | getSelfId () const override |
| void | calculateOutputValues () override |
| Calculates the output port values based on input port values. | |
Public Member Functions inherited from business_logic::Loggable< MonitorBlock > | |
| Loggable () | |
Public Member Functions inherited from business_logic::elements::blocks::BaseBlock | |
| BaseBlock (int cx, int cy, int blockWidth, int blockHeight, business_logic::delegate::INewBlockChoiceDelegate *newBlockChoiceDelegate, business_logic::delegate::IBlockLifecycleManagerDelegate *blockLifecycleManagerDelegate, business_logic::delegate::IWindowDelegate *windowDelegate, std::shared_ptr< spdlog::logger > logger) | |
| Constructor. | |
| void | updateWidthHeight (int newWidth, int newHeight) |
| Updates the width and height of the block. | |
| ~BaseBlock () noexcept override | |
| BaseBlock (const BaseBlock &)=delete | |
| BaseBlock & | operator= (const BaseBlock &)=delete |
| BaseBlock (BaseBlock &&)=delete | |
| BaseBlock & | operator= (BaseBlock &&)=delete |
| virtual bool | isHovered (int x, int y) const |
| Checks if the block is hovered over by the mouse. | |
| void | onDragStart () override |
| Called when dragging starts. | |
| void | onDragProgress (int x, int y) override |
| Called during dragging. | |
| void | onDragEnd () override |
| Called when dragging ends. | |
| const business_logic::geometry::Point2D & | getPortCoordinates (const structures::Port *port) const |
| Gets the coordinates of a port. | |
| std::optional< const structures::Port * > | getPortAtCoordinates (const geometry::Point2D &point) const |
| Gets the port at given coordinates. | |
| const FloatingPoint & | getPortValue (const structures::Port *port) const |
| Gets the value of the port. | |
| void | setPortValue (const business_logic::elements::structures::Port *port, const FloatingPoint &value) |
| Sets the value of the port. | |
| int | getCx () const |
| Gets the center y coordinate of the block. | |
| int | getCy () const |
| Gets the center y coordinate of the block. | |
| int | getLeftX () const |
| Gets the left x coordinate of the block. | |
| int | getRightX () const |
| Gets the right x coordinate of the block. | |
| int | getTopY () const |
| Gets the top y coordinate of the block. | |
| int | getBottomY () const |
| Gets the bottom y coordinate of the block. | |
| int | getWidth () const |
| Gets the width of the block. | |
| int | getHeight () const |
| Gets the height of the block. | |
| std::unordered_map< const structures::Port *, geometry::Point2D > & | getPortCoordinates () |
| Gets the cache of (center) coordinates of the ports of the block; updated after rendering. | |
Public Member Functions inherited from business_logic::elements::interactions::IDraggable | |
| virtual | ~IDraggable ()=default |
Protected Member Functions | |
| const std::vector< business_logic::elements::structures::Port > & | getInputPorts () const override |
| Gets the input ports of the block. | |
| const std::vector< business_logic::elements::structures::Port > & | getOutputPorts () const override |
| Gets the output ports of the block. | |
| business_logic::elements::blocks::BlockType | getBlockType () const override |
| Gets the type of the block. | |
Protected Member Functions inherited from business_logic::elements::blocks::BaseBlock | |
| void | cacheCornerCoordinates () |
Caches the bottom right corner of the block, so that it is not recalculated every time isHovered() is called. | |
| std::optional< const structures::Port * > | checkPort (const structures::Port *port, const geometry::Point2D &point) const |
| Checks if a point is inside the hitbox of a port. | |
Protected Attributes | |
| std::string | selfId |
Protected Attributes inherited from business_logic::Loggable< MonitorBlock > | |
| std::shared_ptr< spdlog::logger > | logger |
Protected Attributes inherited from business_logic::elements::blocks::BaseBlock | |
| int | cx |
| int | cy |
| int | width |
| int | height |
| int | leftX |
| int | rightX |
| int | topY |
| int | bottomY |
| float | centerY |
| std::shared_ptr< spdlog::logger > | logger |
| std::unordered_map< const structures::Port *, FloatingPoint > | portValues |
| The registry of port values. | |
| business_logic::delegate::INewBlockChoiceDelegate * | newBlockChoiceDelegate |
| business_logic::delegate::IBlockLifecycleManagerDelegate * | blockLifecycleManagerDelegate |
| business_logic::delegate::IWindowDelegate * | windowDelegate |
| std::unordered_map< const structures::Port *, geometry::Point2D > | portCoordinates |
| Caches the (center) coordinates of the ports of the block; must be updated after rendering. | |
Static Protected Attributes | |
| static constexpr int | MONITOR_BLOCK_WIDTH = 120 |
| static constexpr int | MONITOR_BLOCK_HEIGHT = 120 |
| static const std::vector< business_logic::elements::structures::Port > | inputPorts |
| static const std::vector< business_logic::elements::structures::Port > | outputPorts = {} |
Static Protected Attributes inherited from business_logic::elements::blocks::BaseBlock | |
| static const FloatingPoint | NaN = std::numeric_limits<FloatingPoint>::quiet_NaN() |
A monitor block that displays the value of its input port.
When hovered, the displayed value will present all stored fraction digits of the input port.
Definition at line 19 of file MonitorBlock.h.
| business_logic::elements::blocks::MonitorBlock::MonitorBlock | ( | int | cx, |
| int | cy, | ||
| business_logic::delegate::INewBlockChoiceDelegate * | newBlockChoiceDelegate, | ||
| business_logic::delegate::IBlockLifecycleManagerDelegate * | blockLifecycleManagerDelegate, | ||
| business_logic::delegate::IWindowDelegate * | windowDelegate | ||
| ) |
Constructor.
| cx | The center x coordinate where to place the center of the block |
| cy | The center y coordinate where to place the center of the block |
| newBlockChoiceDelegate | The delegate that is notified when a new block is chosen to be added to the canvas |
| blockLifecycleManagerDelegate | The delegate that manages the lifecycles of blocks |
| windowDelegate | The delegate of the window |
Definition at line 5 of file MonitorBlock.cpp.
|
inlineoverridevirtual |
Calculates the output port values based on input port values.
| std::runtime_error | if input values are missing |
Implements business_logic::elements::blocks::BaseBlock.
Definition at line 50 of file MonitorBlock.h.
|
inlineoverrideprotectedvirtual |
Gets the type of the block.
Implements business_logic::elements::blocks::BaseBlock.
Definition at line 94 of file MonitorBlock.h.
References business_logic::elements::blocks::Monitor.
|
inlineoverrideprotectedvirtual |
Gets the input ports of the block.
Implements business_logic::elements::blocks::BaseBlock.
Definition at line 78 of file MonitorBlock.h.
References inputPorts.
|
inlineoverrideprotectedvirtual |
Gets the output ports of the block.
Implements business_logic::elements::blocks::BaseBlock.
Definition at line 86 of file MonitorBlock.h.
References outputPorts.
|
inlineoverridevirtual |
The unique identifier of the block (its address in memory), used for logging purposes; should return the same value as business_logic::stringifyAddressOf(this)
Implements business_logic::elements::blocks::BaseBlock.
Definition at line 48 of file MonitorBlock.h.
References selfId.
|
overridevirtual |
Wrapper that gets the value of the output port above the block; if the input port is not connected, it will not be rendered.
| isHovered | True if the block is hovered over, false otherwise |
std::nullopt if the value should not be rendered Reimplemented from business_logic::elements::blocks::BaseBlock.
Definition at line 21 of file MonitorBlock.cpp.
References business_logic::elements::structures::BlocksConnectionSide::block, business_logic::elements::blocks::BaseBlock::blockLifecycleManagerDelegate, business_logic::constants::DEFAULT_VALUE_DISPLAY_PRECISION, business_logic::elements::blocks::BaseBlock::getPortValue(), inputPorts, business_logic::elements::blocks::BaseBlock::isHovered(), and business_logic::delegate::IBlockLifecycleManagerDelegate::isInputConnected().
Here is the call graph for this function:
|
staticprotected |
The input ports of the block
Definition at line 101 of file MonitorBlock.h.
Referenced by getInputPorts(), and getValueToRenderAboveBlock().
|
staticconstexprprotected |
The height of the block
Definition at line 73 of file MonitorBlock.h.
|
staticconstexprprotected |
The width of the block
Definition at line 68 of file MonitorBlock.h.
|
staticprotected |
The output ports of the block
Definition at line 106 of file MonitorBlock.h.
Referenced by getOutputPorts().
|
protected |
The address of the block in memory, used for logging purposes
Definition at line 63 of file MonitorBlock.h.
Referenced by getSelfId().