KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
semanticzoommanager.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
16#include "semanticzoommanager.h"
17
18#include "runtimecontroller.h"
19#include "state.h"
20#include "transition.h"
21#include "elementwalker.h"
22#include "statemachinescene.h"
23
24using namespace KDSME;
25
27 : QObject(parent)
28 , m_scene(nullptr)
29 , m_runtimeController(nullptr)
30 , m_enabled(false)
31{
32}
33
35{
36 return m_scene;
37}
38
40{
41 if (m_scene == scene)
42 return;
43
44 if (m_scene) {
45 disconnect(m_scene, &StateMachineScene::rootStateChanged,
46 this, &SemanticZoomManager::updateRuntimeController);
47 }
48 m_scene = scene;
49 if (m_scene) {
51 this, &SemanticZoomManager::updateRuntimeController);
52 }
53 updateRuntimeController();
54 Q_EMIT sceneChanged(m_scene);
55}
56
58{
59 return m_runtimeController;
60}
61
63{
64 if (m_runtimeController == controller)
65 return;
66
67 if (m_runtimeController) {
68 disconnect(m_runtimeController, &RuntimeController::activeConfigurationChanged,
69 this, &SemanticZoomManager::handleActiveConfigurationChanged);
70 }
71 m_runtimeController = controller;
72 if (m_runtimeController) {
73 connect(m_runtimeController, &RuntimeController::activeConfigurationChanged,
74 this, &SemanticZoomManager::handleActiveConfigurationChanged);
75 }
76}
77
79{
80 return m_enabled;
81}
82
84{
85 if (m_enabled == enabled)
86 return;
87
88 m_enabled = enabled;
89 Q_EMIT enabledChanged(m_enabled);
90}
91
92void SemanticZoomManager::handleActiveConfigurationChanged(const QSet<State *> &configuration)
93{
94 if (!m_enabled)
95 return;
96
97 auto root = m_scene->rootState();
99 walker.walkChildren(root, [&](Element *i) -> ElementWalker::VisitResult {
100 auto state = qobject_cast<State *>(i);
101 if (!state) {
103 }
104
105 const bool expand = configuration.contains(state);
106 state->setExpanded(expand);
108 });
109
110 m_scene->layout();
111}
112
113void SemanticZoomManager::updateRuntimeController()
114{
115 if (m_scene) {
116 const auto machine = m_scene->rootState() ? m_scene->rootState()->machine() : nullptr;
117 setRuntimeController(machine ? machine->runtimeController() : nullptr);
118 }
119}
void activeConfigurationChanged(const QSet< KDSME::State * > &configuration)
KDSME::StateMachineScene * scene
void setScene(StateMachineScene *scene)
void enabledChanged(bool enabled)
void sceneChanged(KDSME::StateMachineScene *controller)
void setRuntimeController(RuntimeController *controller)
RuntimeController * runtimeController() const
SemanticZoomManager(QObject *parent=nullptr)
void rootStateChanged(KDSME::State *state)
Q_INVOKABLE KDSME::StateMachine * machine() const
Definition state.cpp:195
@ RecursiveWalk
Traverse the children of this item.
Definition treewalker.h:49

© 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