|
FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
|
Manages the blocks in the GUI, both their rendering and interaction. More...
#include <BlocksManager.h>
Inheritance diagram for business_logic::BlocksManager:
Collaboration diagram for business_logic::BlocksManager:Additional Inherited Members | |
Protected Member Functions inherited from business_logic::calculations::BlocksCalculator | |
| void | calculateBlockValues (business_logic::elements::blocks::BaseBlock *block) |
| Calculates the values of the dependencies of a block and then the block itself. | |
| std::optional< std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > > | hasCycle (elements::structures::BlocksConnectionSide side) |
| Checks if there is a cycle in the graph. | |
Manages the blocks in the GUI, both their rendering and interaction.
Definition at line 34 of file BlocksManager.h.
|
explicit |
Definition at line 5 of file BlocksManager.cpp.
|
overridedefaultnoexcept |
|
delete |
|
delete |
| void business_logic::BlocksManager::clearActiveChoicesInput | ( | ) |
Clears the active input choices and the corresponding generated UI texts rows.
Definition at line 261 of file BlocksManager.cpp.
References inputChoiceInteraction, inputChoicesUiTextsRows, and business_logic::Loggable< BlocksManager >::logger.
Referenced by handleEscapeKeyPress(), and handleNumericKeyPress().
Here is the caller graph for this function:| std::optional< std::shared_ptr< business_logic::elements::blocks::BaseBlock > > business_logic::BlocksManager::getBlockAt | ( | int | x, |
| int | y | ||
| ) |
Gets the block at the given coordinates.
| x | X coordinate of the mouse |
| y | Y coordinate of the mouse |
std::nullopt if no block is at the given coordinates Definition at line 143 of file BlocksManager.cpp.
References blocks.
Referenced by getBlockAtMousePos().
Here is the caller graph for this function:| std::optional< std::shared_ptr< business_logic::elements::blocks::BaseBlock > > business_logic::BlocksManager::getBlockAtMousePos | ( | ) |
Gets the block at the mouse position.
std::nullopt if no block is at the mouse position Definition at line 138 of file BlocksManager.cpp.
References getBlockAt(), mouseX, and mouseY.
Referenced by handleMouseDown(), and gui::elements::SkiaBlocksManagerRenderer::render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Gets the blocks.
Implements business_logic::calculations::delegate::IBlocksRegistryDelegate.
Definition at line 372 of file BlocksManager.cpp.
References blocks.
|
overridevirtual |
Gets the connections registry.
Implements business_logic::calculations::delegate::IBlocksRegistryDelegate.
Definition at line 378 of file BlocksManager.cpp.
References connectionsRegistry.
| void business_logic::BlocksManager::handleEscapeKeyPress | ( | ) |
Handles the ESC key press event.
Definition at line 95 of file BlocksManager.cpp.
References clearActiveChoicesInput(), connectPortsInteraction, hasActiveChoicesInput(), business_logic::input::ConnectPortsInteraction::isStarted(), business_logic::Loggable< BlocksManager >::logger, and business_logic::input::ConnectPortsInteraction::resetInteraction().
Here is the call graph for this function:| void business_logic::BlocksManager::handleMouseDown | ( | ) |
Handles the mouse down event.
Definition at line 13 of file BlocksManager.cpp.
References connectPortsInteraction, business_logic::constants::DOUBLE_CLICK_TIME_THRESHOLD_MS(), doubleClickCtLastMouseClickTime, draggedBlock, dragOffset, getBlockAtMousePos(), business_logic::input::ConnectPortsInteraction::handleUserInteractedWith(), hasActiveChoicesInput(), business_logic::Loggable< BlocksManager >::logger, mouseX, mouseY, business_logic::elements::interactions::IDoubleClickable::onDoubleClick(), business_logic::elements::blocks::BaseBlock::onDragStart(), business_logic::geometry::Size2D::width, and windowDelegate.
Here is the call graph for this function:| void business_logic::BlocksManager::handleMouseMove | ( | int | x, |
| int | y | ||
| ) |
Handles the mouse move event.
| x | X coordinate of the mouse |
| y | Y coordinate of the mouse |
Definition at line 128 of file BlocksManager.cpp.
References draggedBlock, dragOffset, business_logic::geometry::Size2D::height, mouseX, mouseY, business_logic::elements::blocks::BaseBlock::onDragProgress(), and business_logic::geometry::Size2D::width.
Here is the call graph for this function:| void business_logic::BlocksManager::handleMouseUp | ( | ) |
Handles the mouse up event.
Definition at line 87 of file BlocksManager.cpp.
References draggedBlock, business_logic::elements::blocks::BaseBlock::getSelfId(), business_logic::Loggable< BlocksManager >::logger, and business_logic::elements::blocks::BaseBlock::onDragEnd().
Here is the call graph for this function:| void business_logic::BlocksManager::handleNumericKeyPress | ( | int | number | ) |
Handles the numeric key press event.
| number | The number that was pressed |
Definition at line 107 of file BlocksManager.cpp.
References clearActiveChoicesInput(), inputChoiceInteraction, business_logic::Loggable< BlocksManager >::logger, onNewBlockChoice(), business_logic::delegate::IWindowDelegate::showWarning(), and windowDelegate.
Here is the call graph for this function:| void business_logic::BlocksManager::handleRightClickOnBlock | ( | const std::shared_ptr< business_logic::elements::blocks::BaseBlock > & | block | ) |
Handles right click event on a block.
| block | The block that was right-clicked |
Definition at line 322 of file BlocksManager.cpp.
References business_logic::elements::structures::BlocksConnectionSide::block, blocks, connectionsRegistry, connectPortsInteraction, business_logic::elements::blocks::BaseBlock::getPortAtCoordinates(), business_logic::input::ConnectPortsInteraction::isStarted(), business_logic::Loggable< BlocksManager >::logger, mouseX, mouseY, business_logic::delegate::IWindowDelegate::promptConfirmation(), business_logic::input::ConnectPortsInteraction::resetInteraction(), and windowDelegate.
Here is the call graph for this function:| bool business_logic::BlocksManager::hasActiveChoicesInput | ( | ) | const |
Checks if the input callback is active.
Definition at line 259 of file BlocksManager.cpp.
References inputChoiceInteraction.
Referenced by handleEscapeKeyPress(), and handleMouseDown().
Here is the caller graph for this function:
|
overridevirtual |
Checks if there is a connection between two entities.
| source | The source side of the connection |
| dest | The destination side of the connection |
Implements business_logic::delegate::IBlockLifecycleManagerDelegate.
Definition at line 270 of file BlocksManager.cpp.
References business_logic::elements::structures::BlocksConnectionSide::block, connectionsRegistry, and business_logic::elements::structures::BlocksConnectionSide::port.
|
overridevirtual |
Checks if the input port is connected to anything.
| side | The side to check |
Implements business_logic::delegate::IBlockLifecycleManagerDelegate.
Definition at line 286 of file BlocksManager.cpp.
References connectionsRegistry.
|
overridevirtual |
Called when a block is deleted.
| block | The block that was deleted |
Implements business_logic::delegate::IBlockLifecycleManagerDelegate.
Definition at line 299 of file BlocksManager.cpp.
References connectionsRegistry, and draggedBlock.
|
overridevirtual |
Called when a new block is chosen to be added to the canvas.
| blockType | The type of the block that was chosen |
Implements business_logic::delegate::INewBlockChoiceDelegate.
Definition at line 161 of file BlocksManager.cpp.
References business_logic::elements::blocks::Add, blocks, business_logic::elements::blocks::Constant, business_logic::elements::blocks::Divide, business_logic::elements::blocks::Invert, business_logic::Loggable< BlocksManager >::logger, business_logic::elements::blocks::Monitor, mouseX, mouseY, business_logic::elements::blocks::Multiply, business_logic::elements::blocks::Power, business_logic::delegate::IWindowDelegate::showWarning(), business_logic::elements::blocks::Subtract, and windowDelegate.
Referenced by handleNumericKeyPress().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Invoked when a connection is made between two ports + blocks (sides)
| source | The source side of the connection |
| dest | The destination side of the connection |
Implements business_logic::delegate::IBlockLifecycleManagerDelegate.
Definition at line 294 of file BlocksManager.cpp.
References connectionsRegistry.
|
delete |
|
delete |
| void business_logic::BlocksManager::setActiveChoicesInput | ( | business_logic::input::InputChoiceInteraction< business_logic::elements::blocks::BlockType > && | inputChoiceInteraction | ) |
Sets the input callback; this will override rendering other entities.
| inputChoiceInteraction | The input choice interaction |
Definition at line 216 of file BlocksManager.cpp.
References business_logic::components::UIText::Choice, inputChoiceInteraction, inputChoicesUiTextsRows, business_logic::Loggable< BlocksManager >::logger, and business_logic::constants::MAX_INPUT_CHOICES_PER_ROW.
|
protected |
The blocks in the manager
Definition at line 180 of file BlocksManager.h.
Referenced by getBlockAt(), getBlocks(), handleRightClickOnBlock(), onNewBlockChoice(), and gui::elements::SkiaBlocksManagerRenderer::render().
|
protected |
The blocks registry
Definition at line 236 of file BlocksManager.h.
Referenced by getConnectionsRegistry(), handleRightClickOnBlock(), hasConnectionBetween(), isInputConnected(), onBlockDeleted(), onPortsConnected(), and gui::elements::SkiaBlocksManagerRenderer::render().
|
protected |
The connect ports interaction singleton
Definition at line 222 of file BlocksManager.h.
Referenced by handleEscapeKeyPress(), handleMouseDown(), handleRightClickOnBlock(), and gui::elements::SkiaBlocksManagerRenderer::maybeRenderDraggedLine().
|
protected |
The time of the last mouse click, used for tracking double-clicks
Definition at line 205 of file BlocksManager.h.
Referenced by handleMouseDown().
|
protected |
The block that is currently being dragged
Definition at line 185 of file BlocksManager.h.
Referenced by handleMouseDown(), handleMouseMove(), handleMouseUp(), and onBlockDeleted().
|
protected |
The offset from the block's center when dragging started
Definition at line 200 of file BlocksManager.h.
Referenced by handleMouseDown(), and handleMouseMove().
|
protected |
The input choice interaction
Definition at line 217 of file BlocksManager.h.
Referenced by clearActiveChoicesInput(), handleNumericKeyPress(), hasActiveChoicesInput(), gui::elements::SkiaBlocksManagerRenderer::render(), and setActiveChoicesInput().
|
protected |
The UI texts for the choices; prepared inside setActiveChoicesInput(...) and used in render(...)
Definition at line 228 of file BlocksManager.h.
Referenced by clearActiveChoicesInput(), gui::elements::SkiaBlocksManagerRenderer::render(), and setActiveChoicesInput().
|
protected |
Stores the cycle path (if present)
Definition at line 243 of file BlocksManager.h.
Referenced by gui::elements::SkiaBlocksManagerRenderer::render().
|
protected |
The mouse X coordinate
Definition at line 190 of file BlocksManager.h.
Referenced by getBlockAtMousePos(), handleMouseDown(), handleMouseMove(), handleRightClickOnBlock(), gui::elements::SkiaBlocksManagerRenderer::maybeRenderDraggedLine(), onNewBlockChoice(), and gui::elements::SkiaBlocksManagerRenderer::render().
|
protected |
The mouse Y coordinate
Definition at line 195 of file BlocksManager.h.
Referenced by getBlockAtMousePos(), handleMouseDown(), handleMouseMove(), handleRightClickOnBlock(), gui::elements::SkiaBlocksManagerRenderer::maybeRenderDraggedLine(), onNewBlockChoice(), and gui::elements::SkiaBlocksManagerRenderer::render().
|
protected |
The window delegate
Definition at line 210 of file BlocksManager.h.
Referenced by handleMouseDown(), handleNumericKeyPress(), handleRightClickOnBlock(), and onNewBlockChoice().