13 const auto* startSideBlockPtr = startSide.block;
14 const auto* startSidePortPtr = startSide.port;
16 if ((startSideBlockPtr !=
nullptr) && (startSidePortPtr !=
nullptr)) {
17 auto portCoords = startSideBlockPtr->getPortCoordinates(startSidePortPtr);
29 paint.setStrokeWidth(4);
30 paint.setAntiAlias(
true);
39 paint.setStrokeWidth(4);
40 paint.setAntiAlias(
true);
52 std::vector<components::UITextsRow> rows = {
54 components::UIText::Variant::Headline)}),
57 "Press a number to choose a block type. Press ESC to cancel.",
58 components::UIText::Variant::MenuCaption),
67 std::back_inserter(rows));
76 for (
auto& block :
blocks) {
77 for (
const auto& port : block->getInputPorts()) {
78 block->setPortValue(&port, std::numeric_limits<FloatingPoint>::quiet_NaN());
89 logger->error(
"Graph cycle detected: {}", e.what());
98 for (
const auto& block :
blocks) {
99 auto isFocused = maybeHoveredBlock.has_value() && (maybeHoveredBlock == block);
106 const auto& sourceBlock = source.block;
107 const auto& sourcePort = source.port;
108 const auto& sourcePortCoords = sourceBlock->getPortCoordinates(sourcePort);
110 for (
const auto& dest : destinations) {
111 const auto& destBlock = dest.block;
112 const auto& destPort = dest.port;
118 const auto& destPortCoords = destBlock->getPortCoordinates(destPort);
120 canvas->drawLine(sourcePortCoords.x,
std::unordered_map< business_logic::elements::structures::BlocksConnectionSide, std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > > connectionsRegistry
std::optional< std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > > maybeGraphCycle
std::optional< std::shared_ptr< business_logic::elements::blocks::BaseBlock > > getBlockAtMousePos()
Gets the block at the mouse position.
business_logic::input::ConnectPortsInteraction connectPortsInteraction
std::optional< business_logic::input::InputChoiceInteraction< business_logic::elements::blocks::BlockType > > inputChoiceInteraction
std::vector< components::UITextsRow > inputChoicesUiTextsRows
std::vector< std::shared_ptr< business_logic::elements::blocks::BaseBlock > > blocks
std::shared_ptr< spdlog::logger > logger
void calculateValuesFlow()
Calculates the values flowing through the graph.
The UI renderable text primitive.
The UI renderable row of UITexts primitive.
Exception thrown when a graph cycle is detected.
const std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > & getCyclePath() const
Gets the cycle path.
static void render(business_logic::elements::blocks::BaseBlock *block, SkCanvas *canvas, int mouseX, int mouseY, bool isHovered)
Renders a block on an SkCanvas.
void maybeRenderDraggedLine(SkCanvas *canvas)
Renders the dragged line on the canvas.
static SkPaint connectorPaint
void render(SkCanvas *canvas, const business_logic::geometry::Size2D &size, gui::renderer::delegate::UIRendererDelegate< SkCanvas > *&uiRendererDelegate)
Renders the blocks on the canvas.
static SkPaint cycleConnectorPaint
The delegate for the UI renderer.
virtual void renderCenteredTextsRows(Canvas *canvas, const business_logic::geometry::Size2D &size, const std::vector< components::UITextsRow > &rows)=0
Renders the texts on the canvas around the center horizontally, centered vertically.
The GUI counterpart carrying implementations integrating with business_logic::elements.
const SkColor PURPLE_BLUE
A basic struct representing a 2D size.