KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
graphvizlayerlayouter.cpp
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2014 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: Kevin Funk <kevin.funk@kdab.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8
9 Licensees holding valid commercial KDAB State Machine Editor Library
10 licenses may use this file in accordance with the KDAB State Machine Editor
11 Library License Agreement provided with the Software.
12
13 Contact info@kdab.com if any conditions of this licensing are not clear to you.
14*/
15
17
19#include "element.h"
20#include "state.h"
21#include "transition.h"
22
23#include "debug.h"
24
25#include <QRectF>
26
27using namespace KDSME;
28
35
37{
38 delete m_backend;
39}
40
41QRectF GraphvizLayerLayouter::layout(State *state, const LayoutProperties *properties)
42{
43 m_backend->openLayout(state, properties);
44
45 const QList<State *> childStates = state->childStates();
46
47 // Step 1: Create Graphviz structures out of the State/Transition tree
48 // Step 1.1: build nodes
49 for (State *childState : childStates) {
50 m_backend->buildState(childState);
51 }
52 // Step 1.2: build edges
53 for (const State *childState : childStates) {
54 const auto stateTransitions = childState->transitions();
55 for (Transition *transition : stateTransitions) {
56 // TODO: What to do with transitions crossing hierarchies?
57 if (!childStates.contains(transition->targetState())) {
58 continue; // ignore for now
59 }
60 m_backend->buildTransition(transition);
61 }
62 }
63
64 m_backend->layout();
65
66 // Step 2: Import the information from the Graphviz structures to the State/Transition tree
67 m_backend->import();
68
69 const QRectF boundingRect = m_backend->boundingRect();
70 m_backend->closeLayout();
71 return boundingRect;
72}
void openLayout(KDSME::State *state, const KDSME::LayoutProperties *properties)
void buildState(KDSME::State *state)
void setLayoutMode(LayoutMode mode)
void buildTransition(KDSME::Transition *transition)
@ NonRecursiveMode
Only a direct import of state machine elements.
QRectF layout(State *state, const LayoutProperties *properties) override
GraphvizLayerLayouter(QObject *parent=nullptr)
QList< State * > childStates() const
Definition state.cpp:93

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8