SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
ogdfCircuit.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <span>
21
#include <unordered_map>
22
23
#include <QPointF>
24
25
#include <
ui/circuit/diagram/scene/diagramScene.hpp
>
26
27
namespace
SILICON::core
{
28
class
Circuit
;
29
}
30
31
namespace
SILICON::ui
{
32
class
GraphicalLogicComponent
;
33
34
enum class
GraphLayoutAlgorithm
{
35
Layered
,
36
ForceDirected
,
37
};
38
40
enum class
GraphLayoutDirection
{
41
TopToBottom
,
42
LeftToRight
,
43
};
44
51
struct
GraphLayoutOptions
{
53
GraphLayoutAlgorithm
algorithm
=
GraphLayoutAlgorithm::Layered
;
55
GraphLayoutDirection
direction
=
GraphLayoutDirection::TopToBottom
;
57
int
randomSeed
= 0;
59
int
nodeDistance
= 6 *
DiagramScene::GRID_SIZE
;
61
int
layerDistance
= 10 *
DiagramScene::GRID_SIZE
;
63
int
connectedComponentDistance
= 12 *
DiagramScene::GRID_SIZE
;
65
int
fallbackNodeWidth
= 8 *
DiagramScene::GRID_SIZE
;
67
int
fallbackNodeHeight
= 5 *
DiagramScene::GRID_SIZE
;
69
QPointF
origin
= QPointF(0.0, 0.0);
71
bool
deterministic
=
true
;
72
};
73
82
class
GraphLayout
{
83
public
:
87
using
PlacementMap
= std::unordered_map<GraphicalLogicComponent*, QPointF>;
88
101
[[nodiscard]]
static
PlacementMap
102
compute
(
const
core::Circuit
& circuit,
103
std::span<GraphicalLogicComponent* const> components,
104
const
GraphLayoutOptions
& options = {});
105
};
106
107
}
// namespace SILICON::ui
SILICON::core::Circuit
Represents a digital circuit as a directed graph of components.
Definition
circuit.hpp:125
SILICON::ui::DiagramScene::GRID_SIZE
static constexpr int GRID_SIZE
Grid cell size in scene units.
Definition
diagramScene.hpp:251
SILICON::ui::GraphLayout
Pure OGDF adapter for calculating circuit component positions.
Definition
ogdfCircuit.hpp:82
SILICON::ui::GraphLayout::compute
static PlacementMap compute(const core::Circuit &circuit, std::span< GraphicalLogicComponent *const > components, const GraphLayoutOptions &options={})
Computes component placements for the subset represented by components.
Definition
ogdfCircuit.cpp:61
SILICON::ui::GraphLayout::PlacementMap
std::unordered_map< GraphicalLogicComponent *, QPointF > PlacementMap
Map from graphical component to the computed scene position for that item.
Definition
ogdfCircuit.hpp:87
SILICON::ui::GraphicalLogicComponent
Base class for logic-gate graphical components.
Definition
graphicalLogicComponent.hpp:55
diagramScene.hpp
SILICON::core
Definition
activeKeyGuard.hpp:28
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::GraphLayoutDirection
GraphLayoutDirection
Signal-flow direction used for a layered layout.
Definition
ogdfCircuit.hpp:40
SILICON::ui::GraphLayoutDirection::LeftToRight
@ LeftToRight
Definition
ogdfCircuit.hpp:42
SILICON::ui::GraphLayoutDirection::TopToBottom
@ TopToBottom
Definition
ogdfCircuit.hpp:41
SILICON::ui::GraphLayoutAlgorithm
GraphLayoutAlgorithm
Definition
ogdfCircuit.hpp:34
SILICON::ui::GraphLayoutAlgorithm::ForceDirected
@ ForceDirected
Definition
ogdfCircuit.hpp:36
SILICON::ui::GraphLayoutAlgorithm::Layered
@ Layered
Definition
ogdfCircuit.hpp:35
SILICON::ui::GraphLayoutOptions
Configuration for OGDF-based component placement.
Definition
ogdfCircuit.hpp:51
SILICON::ui::GraphLayoutOptions::deterministic
bool deterministic
True to use a single deterministic Sugiyama crossing-minimization run.
Definition
ogdfCircuit.hpp:71
SILICON::ui::GraphLayoutOptions::nodeDistance
int nodeDistance
Minimum horizontal scene distance between nodes on the same OGDF layer.
Definition
ogdfCircuit.hpp:59
SILICON::ui::GraphLayoutOptions::fallbackNodeHeight
int fallbackNodeHeight
Height used when a graphical item has no valid scene bounds.
Definition
ogdfCircuit.hpp:67
SILICON::ui::GraphLayoutOptions::randomSeed
int randomSeed
Deterministic seed used by force-directed candidates.
Definition
ogdfCircuit.hpp:57
SILICON::ui::GraphLayoutOptions::layerDistance
int layerDistance
Minimum vertical scene distance between neighboring OGDF layers.
Definition
ogdfCircuit.hpp:61
SILICON::ui::GraphLayoutOptions::connectedComponentDistance
int connectedComponentDistance
Minimum distance between disconnected graph components.
Definition
ogdfCircuit.hpp:63
SILICON::ui::GraphLayoutOptions::algorithm
GraphLayoutAlgorithm algorithm
Placement family used to generate the candidate.
Definition
ogdfCircuit.hpp:53
SILICON::ui::GraphLayoutOptions::direction
GraphLayoutDirection direction
Scene direction assigned to source-to-target ranks.
Definition
ogdfCircuit.hpp:55
SILICON::ui::GraphLayoutOptions::origin
QPointF origin
Top-left scene position of the normalized arranged layout.
Definition
ogdfCircuit.hpp:69
SILICON::ui::GraphLayoutOptions::fallbackNodeWidth
int fallbackNodeWidth
Width used when a graphical item has no valid scene bounds.
Definition
ogdfCircuit.hpp:65
src
ui
circuit
diagram
ogdfCircuit.hpp
Generated by
1.17.0