chartflow 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chartflow/__init__.py +28 -0
- chartflow/_verify_importexport.py +169 -0
- chartflow/edit/__init__.py +119 -0
- chartflow/edit/code_editor.py +1007 -0
- chartflow/edit/code_folder.py +523 -0
- chartflow/edit/completer.py +2652 -0
- chartflow/edit/context_analyzer.py +521 -0
- chartflow/edit/demo.py +469 -0
- chartflow/edit/line_number_area.py +548 -0
- chartflow/edit/minimap.py +581 -0
- chartflow/edit/python_editor.py +509 -0
- chartflow/edit/syntax_highlighter.py +291 -0
- chartflow/edit/test_editor.py +190 -0
- chartflow/flow/__init__.py +31 -0
- chartflow/flow/_demo.py +98 -0
- chartflow/flow/chart.py +1101 -0
- chartflow/flow/editor.py +375 -0
- chartflow/flow/flow.py +6 -0
- chartflow/flow/qchart.py +1250 -0
- chartflow/flow/test/__init__.py +0 -0
- chartflow/flow/test/test_chart.py +537 -0
- chartflow/flow/test_decorator_sync.py +102 -0
- chartflow/fsm/__init__.py +84 -0
- chartflow/fsm/decorators.py +395 -0
- chartflow/fsm/demo.py +381 -0
- chartflow/fsm/demo_pyqt6.py +881 -0
- chartflow/fsm/demo_tree.py +46 -0
- chartflow/fsm/logic.py +447 -0
- chartflow/fsm/meta.py +569 -0
- chartflow/fsm/scheduler.py +427 -0
- chartflow/fsm/stage.py +2079 -0
- chartflow/fsm/stdio.py +66 -0
- chartflow/fsm/test/__init__.py +7 -0
- chartflow/fsm/test/test_decorators.py +210 -0
- chartflow/fsm/test/test_events.py +202 -0
- chartflow/fsm/test/test_integration.py +596 -0
- chartflow/fsm/test/test_logic.py +371 -0
- chartflow/fsm/test/test_meta.py +192 -0
- chartflow/fsm/test/test_runtime_param.py +336 -0
- chartflow/fsm/test/test_scheduler.py +280 -0
- chartflow/fsm/test/test_stage.py +314 -0
- chartflow/fsm/test_behavior_events.py +263 -0
- chartflow/fsm/test_nested_parallel.py +80 -0
- chartflow/fsm/test_stage_spec.py +448 -0
- chartflow/fsm/utils.py +34 -0
- chartflow/node/__init__.py +66 -0
- chartflow/node/_node_base.py +727 -0
- chartflow/node/_node_interaction.py +488 -0
- chartflow/node/_node_interface.py +426 -0
- chartflow/node/_node_markers.py +648 -0
- chartflow/node/_node_ports.py +536 -0
- chartflow/node/_port_interface.py +111 -0
- chartflow/node/arrow_item.py +287 -0
- chartflow/node/color_utils.py +113 -0
- chartflow/node/connection_item.py +939 -0
- chartflow/node/demo.py +258 -0
- chartflow/node/demo_arrow_drag.py +46 -0
- chartflow/node/demo_decorator.py +63 -0
- chartflow/node/demo_ports.py +69 -0
- chartflow/node/enums.py +35 -0
- chartflow/node/example.py +84 -0
- chartflow/node/layout_utils.py +307 -0
- chartflow/node/main_window.py +196 -0
- chartflow/node/menu_bar.py +240 -0
- chartflow/node/node_canvas.py +1730 -0
- chartflow/node/node_item.py +754 -0
- chartflow/node/popmenu.py +472 -0
- chartflow/node/port_item.py +591 -0
- chartflow/node/qnode_editor.py +73 -0
- chartflow/node/selection_rect.py +53 -0
- chartflow/node/style_panel.py +615 -0
- chartflow/node/styles.py +63 -0
- chartflow/node/test_qnode.py +2336 -0
- chartflow/showcase.py +528 -0
- chartflow/theme.py +508 -0
- chartflow-0.1.dist-info/METADATA +23 -0
- chartflow-0.1.dist-info/RECORD +79 -0
- chartflow-0.1.dist-info/WHEEL +5 -0
- chartflow-0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
"""
|
|
2
|
+
节点项接口契约模块
|
|
3
|
+
|
|
4
|
+
定义 INodeItem(Protocol) —— 节点项的对外类型契约。
|
|
5
|
+
Protocol 仅用于静态类型检查与文档, 不参与运行时继承(不进入 MRO),
|
|
6
|
+
因此可安全地与 QGraphicsEllipseItem 继承体系并存。
|
|
7
|
+
|
|
8
|
+
INodeItem 声明了 NodeItem 对外暴露的全部公开属性与方法签名,
|
|
9
|
+
是 _NodeCore 及其子类的"契约说明"。最终具体类 NodeItem 在运行时
|
|
10
|
+
通过多层继承组合 _NodeCore/_NodePortMixin/_NodeInteractionMixin 实现
|
|
11
|
+
该契约, 但并不显式继承 Protocol。
|
|
12
|
+
|
|
13
|
+
约定: 本模块只含类型声明, 不得有运行时依赖, 以避免循环导入。
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from typing import Any, Dict, Optional, Protocol, runtime_checkable, TYPE_CHECKING
|
|
17
|
+
|
|
18
|
+
from PyQt6.QtCore import QPointF, pyqtSignal
|
|
19
|
+
from PyQt6.QtGui import QColor, QFont
|
|
20
|
+
|
|
21
|
+
from chartflow.node.enums import NodeShape, NodeState
|
|
22
|
+
from chartflow.node.styles import NodeStyle
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from chartflow.node.port_item import QNodePortSpec
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@runtime_checkable
|
|
29
|
+
class INodeItem(Protocol):
|
|
30
|
+
"""节点项接口契约
|
|
31
|
+
|
|
32
|
+
声明一个节点项应具备的对外属性与方法。具体实现由 _NodeCore 及其
|
|
33
|
+
Mixin 子类逐层填充, 最终由 NodeItem 组合完成。
|
|
34
|
+
|
|
35
|
+
注: Protocol 不参与运行时继承, 实现类无需显式声明 ``class X(INodeItem)``;
|
|
36
|
+
只要结构(属性/方法签名)匹配即视为满足契约(结构子类型, duck typing)。
|
|
37
|
+
|
|
38
|
+
契约按职责分为若干组:
|
|
39
|
+
|
|
40
|
+
- **身份与状态**: ``name`` / ``nodeShape`` / ``state`` / ``radius`` / ``center``
|
|
41
|
+
- **数据与编辑器**: ``data`` / ``editorClass``
|
|
42
|
+
- **装饰器**: ``decorator``
|
|
43
|
+
- **端口**: ``ports`` / :meth:`setPorts`
|
|
44
|
+
- **字体与样式**: ``font`` / ``fontFamily`` / ``fontSize`` / ``strokeWidth`` /
|
|
45
|
+
``fillColor`` / ``strokeColor`` / ``isEditingName`` / :meth:`setColor` /
|
|
46
|
+
:meth:`setBorder` / :meth:`setFont` / :meth:`setRadius` /
|
|
47
|
+
:meth:`setEdgeIndicatorVisible` / :meth:`isEdgeIndicatorVisible` /
|
|
48
|
+
:meth:`setConnectable` / :meth:`isConnectable`
|
|
49
|
+
- **标记与编辑窗口**: :meth:`setStartMarkerVisible` / :meth:`setSingleMarkerVisible` /
|
|
50
|
+
:meth:`setCustomMarkerVisible` / :meth:`setCustomMarkerStyle` /
|
|
51
|
+
:meth:`getCustomMarkerStyle` / :meth:`setEditWindowOpen`
|
|
52
|
+
- **信号**: ``editRequested`` / ``nameChanged``
|
|
53
|
+
- **几何与序列化**: :meth:`getEdgePoint` / :meth:`toDict` / :meth:`fromDict`
|
|
54
|
+
|
|
55
|
+
除 ``center`` / ``data`` / ``font`` 等显式标注只读的属性外, 凡带 setter 的
|
|
56
|
+
属性均可读可写; 写入即触发对应的重算/重绘(详见各成员文档)。
|
|
57
|
+
|
|
58
|
+
所有坐标默认为 **场景坐标(scene coordinate)**, 几何单位为像素。
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
# ---- 身份与状态 ----
|
|
62
|
+
@property
|
|
63
|
+
def name(self) -> str:
|
|
64
|
+
"""节点显示名称(可读写)。
|
|
65
|
+
|
|
66
|
+
读取返回当前名称; 赋值会更新文本、重新居中并发出
|
|
67
|
+
:attr:`nameChanged` 信号。空串或纯空白会被忽略。
|
|
68
|
+
"""
|
|
69
|
+
...
|
|
70
|
+
|
|
71
|
+
@name.setter
|
|
72
|
+
def name(self, value: str) -> None: ...
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def nodeShape(self) -> NodeShape:
|
|
76
|
+
"""节点形状(可读写), 取值见 :class:`~chartflow.node.enums.NodeShape`:
|
|
77
|
+
|
|
78
|
+
- ``ELLIPSE`` 椭圆/圆形(强制为宽高相等的标准圆)
|
|
79
|
+
- ``RECTANGLE`` 圆角矩形
|
|
80
|
+
- ``DIAMOND`` 菱形
|
|
81
|
+
|
|
82
|
+
赋值后若未设置自定义半径, 会按新形状重算尺寸; 切换到圆形时
|
|
83
|
+
端口会从轴向排布切换为沿侧弧径向排布。
|
|
84
|
+
"""
|
|
85
|
+
...
|
|
86
|
+
|
|
87
|
+
@nodeShape.setter
|
|
88
|
+
def nodeShape(self, value: NodeShape) -> None: ...
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def state(self) -> NodeState:
|
|
92
|
+
"""节点交互状态(可读写), 取值见
|
|
93
|
+
:class:`~chartflow.node.enums.NodeState`: ``IDLE`` / ``HOVER`` /
|
|
94
|
+
``SELECTED``。状态变化会驱动填充色与描边色的样式切换。
|
|
95
|
+
"""
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
@state.setter
|
|
99
|
+
def state(self, value: NodeState) -> None: ...
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def radius(self) -> float:
|
|
103
|
+
"""节点半宽(半边长, 可读写)。
|
|
104
|
+
|
|
105
|
+
赋值等价于调用 :meth:`setRadius`: 以方形覆盖原尺寸, 小于
|
|
106
|
+
``MIN_RADIUS`` 的值会被钳制为 ``MIN_RADIUS``。赋值会重排端口。
|
|
107
|
+
"""
|
|
108
|
+
...
|
|
109
|
+
|
|
110
|
+
@radius.setter
|
|
111
|
+
def radius(self, value: float) -> None: ...
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def center(self) -> QPointF:
|
|
115
|
+
"""节点中心点的 **场景坐标**(只读), 取自 ``sceneBoundingRect().center()``。"""
|
|
116
|
+
...
|
|
117
|
+
|
|
118
|
+
# ---- 数据与编辑器 ----
|
|
119
|
+
@property
|
|
120
|
+
def data(self) -> Dict[str, Any]:
|
|
121
|
+
"""节点自定义数据字典(只读引用, 内容可改)。
|
|
122
|
+
|
|
123
|
+
返回内部 ``_data`` 字典本身而非副本, 调用方可直接增删键值。
|
|
124
|
+
会被 :meth:`toDict` / :meth:`fromDict` 序列化。
|
|
125
|
+
"""
|
|
126
|
+
...
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def editorClass(self) -> Optional[type]:
|
|
130
|
+
"""节点编辑器类(可读写)。
|
|
131
|
+
|
|
132
|
+
设为某个 ``QWidget`` 子类 ``type`` 时, 双击节点或点击悬浮按钮会
|
|
133
|
+
通过 :attr:`editRequested` 信号请求由该类创建编辑面板;
|
|
134
|
+
``None`` 表示该节点不绑定编辑器。
|
|
135
|
+
"""
|
|
136
|
+
...
|
|
137
|
+
|
|
138
|
+
@editorClass.setter
|
|
139
|
+
def editorClass(self, value: Optional[type]) -> None: ...
|
|
140
|
+
|
|
141
|
+
# ---- 装饰器 ----
|
|
142
|
+
@property
|
|
143
|
+
def decorator(self) -> Optional[str]:
|
|
144
|
+
"""装饰器类型(可读写), 用于以特殊描边色标记节点语义。
|
|
145
|
+
|
|
146
|
+
支持 ``'recursive'`` / ``'behavior'`` / ``'sequence'`` /
|
|
147
|
+
``'selector'`` / ``'parallel'``; ``None`` 表示无装饰器。
|
|
148
|
+
赋值后立即重绘以应用对应的边框颜色。
|
|
149
|
+
"""
|
|
150
|
+
...
|
|
151
|
+
|
|
152
|
+
@decorator.setter
|
|
153
|
+
def decorator(self, value: Optional[str]) -> None: ...
|
|
154
|
+
|
|
155
|
+
# ---- 端口 ----
|
|
156
|
+
@property
|
|
157
|
+
def ports(self) -> Dict[str, list]:
|
|
158
|
+
"""端口配置(可读写), 形如 ``{"left": [...], "right": [...]}``。
|
|
159
|
+
|
|
160
|
+
仅识别 ``'left'`` 与 ``'right'`` 两个键; 列表元素可为
|
|
161
|
+
:class:`~chartflow.node.port_item.QNodePortSpec` 或 ``dict``(自动转换)。
|
|
162
|
+
赋值会重新规范化、重建端口渲染项并重排布局; 赋 ``None`` 清空端口。
|
|
163
|
+
"""
|
|
164
|
+
...
|
|
165
|
+
|
|
166
|
+
@ports.setter
|
|
167
|
+
def ports(self, value: Optional[Dict[str, list]]) -> None: ...
|
|
168
|
+
|
|
169
|
+
def setPorts(self, value: Optional[Dict[str, list]]) -> None:
|
|
170
|
+
"""设置端口, 等价于直接赋值 ``self.ports = value``。
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
value: 端口配置字典, 见 :attr:`ports`; ``None`` 表示清空。
|
|
174
|
+
"""
|
|
175
|
+
...
|
|
176
|
+
|
|
177
|
+
# ---- 字体与样式 ----
|
|
178
|
+
@property
|
|
179
|
+
def font(self) -> QFont:
|
|
180
|
+
"""节点名称文本所用的 :class:`~PyQt6.QtGui.QFont`(只读)。
|
|
181
|
+
|
|
182
|
+
如需修改字体请用 :meth:`setFont` —— 它会同步刷新端口文本字号
|
|
183
|
+
并在未设置自定义半径时按新字号重算节点尺寸。
|
|
184
|
+
"""
|
|
185
|
+
...
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def fontFamily(self) -> str:
|
|
189
|
+
"""当前字体家族名(只读)。"""
|
|
190
|
+
...
|
|
191
|
+
|
|
192
|
+
@property
|
|
193
|
+
def fontSize(self) -> int:
|
|
194
|
+
"""当前字体点距大小 pointSize(只读)。"""
|
|
195
|
+
...
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
def strokeWidth(self) -> float:
|
|
199
|
+
"""当前描边宽度(只读)。"""
|
|
200
|
+
...
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def fillColor(self) -> QColor:
|
|
204
|
+
"""当前 IDLE 填充色(只读)。通过 :meth:`setColor` 修改。"""
|
|
205
|
+
...
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def strokeColor(self) -> QColor:
|
|
209
|
+
"""当前 IDLE 描边色(只读)。通过 :meth:`setBorder` 修改。"""
|
|
210
|
+
...
|
|
211
|
+
|
|
212
|
+
@property
|
|
213
|
+
def isEditingName(self) -> bool:
|
|
214
|
+
"""是否正处于名称原位编辑状态(只读)。"""
|
|
215
|
+
...
|
|
216
|
+
|
|
217
|
+
def setColor(self, color: QColor) -> None:
|
|
218
|
+
"""设置节点填充色。
|
|
219
|
+
|
|
220
|
+
会写入自定义填充色并立即重绘; 该颜色会被 :meth:`toDict` 序列化、
|
|
221
|
+
由 :meth:`fromDict` 还原。
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
color: 新的填充色。
|
|
225
|
+
"""
|
|
226
|
+
...
|
|
227
|
+
|
|
228
|
+
def setBorder(self, width: int = 1, color: QColor = None) -> None:
|
|
229
|
+
"""设置描边宽度与颜色。
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
width: 描边宽度, ``<= 0`` 表示移除描边(NoPen)。
|
|
233
|
+
color: 描边颜色, ``None`` 表示沿用默认/已有颜色。设为非 ``None``
|
|
234
|
+
时会同时作为选中态描边色。
|
|
235
|
+
"""
|
|
236
|
+
...
|
|
237
|
+
|
|
238
|
+
def setFont(self, family: str = None, size: int = None) -> None:
|
|
239
|
+
"""设置节点文本字体家族与字号。
|
|
240
|
+
|
|
241
|
+
两个参数均可单独提供(只改其一); 字体变化后会重新居中文字、
|
|
242
|
+
刷新端口文本字号, 并在未设置自定义半径时重算节点尺寸。
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
family: 字体家族名, ``None`` 表示不改变。
|
|
246
|
+
size: 字体 pointSize, ``None`` 或 ``<= 0`` 表示不改变。
|
|
247
|
+
"""
|
|
248
|
+
...
|
|
249
|
+
|
|
250
|
+
def setRadius(self, radius: float) -> None:
|
|
251
|
+
"""设置节点半径(以方形覆盖原尺寸)并重排端口。
|
|
252
|
+
|
|
253
|
+
Args:
|
|
254
|
+
radius: 新的半径值(半边长); 小于 ``MIN_RADIUS`` 时钳制为 ``MIN_RADIUS``。
|
|
255
|
+
"""
|
|
256
|
+
...
|
|
257
|
+
|
|
258
|
+
def setEdgeIndicatorVisible(self, visible: bool) -> None:
|
|
259
|
+
"""设置节点外环(可连线边缘指示器)是否显示。
|
|
260
|
+
|
|
261
|
+
外环是绘制在节点边缘、提示可从此处拖拽创建连线的浅灰色环。
|
|
262
|
+
关闭后仅停止绘制, 边缘的连线命中判定(``node_canvas._is_on_node_edge``)
|
|
263
|
+
不受影响。该状态会被 :meth:`toDict` / :meth:`fromDict` 序列化。
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
visible: ``True`` 显示外环, ``False`` 隐藏。
|
|
267
|
+
"""
|
|
268
|
+
...
|
|
269
|
+
|
|
270
|
+
def isEdgeIndicatorVisible(self) -> bool:
|
|
271
|
+
"""查询节点外环(可连线边缘指示器)当前是否显示。
|
|
272
|
+
|
|
273
|
+
Returns:
|
|
274
|
+
``True`` 表示显示中, ``False`` 表示已隐藏。
|
|
275
|
+
"""
|
|
276
|
+
...
|
|
277
|
+
|
|
278
|
+
def setConnectable(self, connectable: bool) -> None:
|
|
279
|
+
"""设置节点是否可参与连线。
|
|
280
|
+
|
|
281
|
+
设为 ``False`` 时:
|
|
282
|
+
- 清除该节点已有的全部连线(两端任一为本节点即删除);
|
|
283
|
+
- 软联动隐藏外环(此后用户仍可单独调用
|
|
284
|
+
:meth:`setEdgeIndicatorVisible` 重新开启, 不会被强制覆盖);
|
|
285
|
+
- 后续任何新建连线(边缘拖拽 / 箭头重连 / 导入)只要涉及本节点,
|
|
286
|
+
都会被 ``NodeCanvas.addConnection`` 拒绝。
|
|
287
|
+
|
|
288
|
+
设为 ``True`` 时仅恢复连线能力, 不重建已删连线, 也不自动恢复外环。
|
|
289
|
+
该状态会被 :meth:`toDict` / :meth:`fromDict` 以及
|
|
290
|
+
``NodeCanvas.importData`` 序列化。
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
connectable: ``True`` 允许参与连线, ``False`` 禁止并清除已有连线。
|
|
294
|
+
"""
|
|
295
|
+
...
|
|
296
|
+
|
|
297
|
+
def isConnectable(self) -> bool:
|
|
298
|
+
"""查询节点当前是否可参与连线。
|
|
299
|
+
|
|
300
|
+
Returns:
|
|
301
|
+
``True`` 可参与连线(默认), ``False`` 已被禁止。
|
|
302
|
+
"""
|
|
303
|
+
...
|
|
304
|
+
|
|
305
|
+
# ---- 标记与编辑窗口 ----
|
|
306
|
+
def setStartMarkerVisible(self, visible: bool) -> None:
|
|
307
|
+
"""显示或隐藏「起点(Start)」标记, 带淡入/淡出动画。
|
|
308
|
+
|
|
309
|
+
Args:
|
|
310
|
+
visible: ``True`` 显示, ``False`` 隐藏。
|
|
311
|
+
"""
|
|
312
|
+
...
|
|
313
|
+
|
|
314
|
+
def setSingleMarkerVisible(self, visible: bool) -> None:
|
|
315
|
+
"""显示或隐藏「Single」标记, 带淡入/淡出动画。
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
visible: ``True`` 显示, ``False`` 隐藏。
|
|
319
|
+
"""
|
|
320
|
+
...
|
|
321
|
+
|
|
322
|
+
def setCustomMarkerVisible(self, visible: bool) -> None:
|
|
323
|
+
"""显示或隐藏「Custom」自定义标记, 带淡入/淡出动画。
|
|
324
|
+
|
|
325
|
+
若标记尚未创建, 显示时会自动创建一个默认样式的 CustomMarker。
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
visible: ``True`` 显示, ``False`` 隐藏。
|
|
329
|
+
"""
|
|
330
|
+
...
|
|
331
|
+
|
|
332
|
+
def setCustomMarkerStyle(
|
|
333
|
+
self,
|
|
334
|
+
text: str = None,
|
|
335
|
+
bg_color: QColor = None,
|
|
336
|
+
fg_color: QColor = None,
|
|
337
|
+
border_color: QColor = None,
|
|
338
|
+
border_width: float = None,
|
|
339
|
+
radius: float = None,
|
|
340
|
+
) -> None:
|
|
341
|
+
"""配置「Custom」自定义标记的样式。
|
|
342
|
+
|
|
343
|
+
仅传入非 ``None`` 的参数会覆盖对应字段, 其余保持不变;
|
|
344
|
+
若标记尚未创建, 会先按这些参数创建一个 CustomMarker。
|
|
345
|
+
|
|
346
|
+
Args:
|
|
347
|
+
text: 显示的文本字符。
|
|
348
|
+
bg_color: 背景色。
|
|
349
|
+
fg_color: 前景(文本)色。
|
|
350
|
+
border_color: 边框色。
|
|
351
|
+
border_width: 边框厚度。
|
|
352
|
+
radius: 标记外接半径。
|
|
353
|
+
"""
|
|
354
|
+
...
|
|
355
|
+
|
|
356
|
+
def getCustomMarkerStyle(self) -> dict:
|
|
357
|
+
"""获取「Custom」标记的当前样式配置。
|
|
358
|
+
|
|
359
|
+
Returns:
|
|
360
|
+
样式字典(text/bg_color/fg_color/border_color/border_width/radius);
|
|
361
|
+
若标记尚未创建则返回空字典 ``{}``。
|
|
362
|
+
"""
|
|
363
|
+
...
|
|
364
|
+
|
|
365
|
+
def setEditWindowOpen(self, open: bool) -> None:
|
|
366
|
+
"""切换编辑窗口打开状态, 进而控制悬浮编辑按钮的显示。
|
|
367
|
+
|
|
368
|
+
设为打开时立即显示悬浮按钮(带淡入); 关闭时淡出隐藏。
|
|
369
|
+
|
|
370
|
+
Args:
|
|
371
|
+
open: ``True`` 表示编辑窗口已打开(显示按钮), ``False`` 关闭。
|
|
372
|
+
"""
|
|
373
|
+
...
|
|
374
|
+
|
|
375
|
+
# ---- 信号(只读属性, 返回 pyqtSignal) ----
|
|
376
|
+
@property
|
|
377
|
+
def editRequested(self) -> pyqtSignal:
|
|
378
|
+
"""编辑请求信号(只读)。
|
|
379
|
+
|
|
380
|
+
双击节点或点击悬浮按钮时发射, 载荷为本节点实例本身; 供宿主
|
|
381
|
+
(如画布/窗口)据此弹出 ``editorClass`` 对应的编辑面板。
|
|
382
|
+
"""
|
|
383
|
+
...
|
|
384
|
+
|
|
385
|
+
@property
|
|
386
|
+
def nameChanged(self) -> pyqtSignal:
|
|
387
|
+
"""名称变更信号(只读)。名称被修改时发射。"""
|
|
388
|
+
...
|
|
389
|
+
|
|
390
|
+
# ---- 几何与序列化 ----
|
|
391
|
+
def getEdgePoint(self, target_pos: QPointF) -> QPointF:
|
|
392
|
+
"""计算从节点中心指向 ``target_pos`` 方向、落在节点外轮廓上的交点。
|
|
393
|
+
|
|
394
|
+
依据当前 :attr:`nodeShape` 采用不同算法: 圆形用三角函数、
|
|
395
|
+
圆角矩形先求外接矩形交点再修正圆角、菱形用 L1 范数缩放。
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
target_pos: 目标位置(场景坐标)。
|
|
399
|
+
|
|
400
|
+
Returns:
|
|
401
|
+
边缘交点(场景坐标)。退化为重合时返回节点中心。
|
|
402
|
+
"""
|
|
403
|
+
...
|
|
404
|
+
|
|
405
|
+
def toDict(self) -> dict:
|
|
406
|
+
"""将节点序列化为可持久化的字典。
|
|
407
|
+
|
|
408
|
+
包含字段: ``id`` / ``name`` / ``shape`` / ``position`` / ``data``;
|
|
409
|
+
若存在自定义样式、custom 标记配置或端口配置, 会分别追加
|
|
410
|
+
``style`` / ``custom`` / ``ports`` 键。
|
|
411
|
+
|
|
412
|
+
Returns:
|
|
413
|
+
节点数据字典(深拷贝, 修改返回值不影响节点)。
|
|
414
|
+
"""
|
|
415
|
+
...
|
|
416
|
+
|
|
417
|
+
def fromDict(self, data: dict) -> None:
|
|
418
|
+
"""从字典恢复/更新节点状态(增量合并, 忽略未知键)。
|
|
419
|
+
|
|
420
|
+
可识别的键与 :meth:`toDict` 一致; 样式应用完成后会重新排布端口。
|
|
421
|
+
传入的 ``data`` 缺失的键不会被清空。
|
|
422
|
+
|
|
423
|
+
Args:
|
|
424
|
+
data: 由 :meth:`toDict` 产生(或同构)的字典。
|
|
425
|
+
"""
|
|
426
|
+
...
|