Skip to content

Commit d8d671e

Browse files
committed
renamed enum classes
1 parent 44ab6e0 commit d8d671e

22 files changed

+211
-209
lines changed

NodeGraphQt/base/commands.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
22
from Qt import QtWidgets
33

4-
from NodeGraphQt.constants import PORT_TYPE
4+
from NodeGraphQt.constants import PortTypeEnum
55

66

77
class PropertyChangedCmd(QtWidgets.QUndoCommand):
@@ -158,7 +158,7 @@ class NodeInputConnectedCmd(QtWidgets.QUndoCommand):
158158

159159
def __init__(self, src_port, trg_port):
160160
QtWidgets.QUndoCommand.__init__(self)
161-
if src_port.type_() == PORT_TYPE.IN.value:
161+
if src_port.type_() == PortTypeEnum.IN.value:
162162
self.source = src_port
163163
self.target = trg_port
164164
else:
@@ -185,7 +185,7 @@ class NodeInputDisconnectedCmd(QtWidgets.QUndoCommand):
185185

186186
def __init__(self, src_port, trg_port):
187187
QtWidgets.QUndoCommand.__init__(self)
188-
if src_port.type_() == PORT_TYPE.IN.value:
188+
if src_port.type_() == PortTypeEnum.IN.value:
189189
self.source = src_port
190190
self.target = trg_port
191191
else:
@@ -355,9 +355,9 @@ def set_visible(self, visible):
355355
self.port.view.setVisible(visible)
356356
node_view = self.port.node().view
357357
text_item = None
358-
if self.port.type_() == PORT_TYPE.IN.value:
358+
if self.port.type_() == PortTypeEnum.IN.value:
359359
text_item = node_view.get_input_text_item(self.port.view)
360-
elif self.port.type_() == PORT_TYPE.OUT.value:
360+
elif self.port.type_() == PortTypeEnum.OUT.value:
361361
text_item = node_view.get_output_text_item(self.port.view)
362362
if text_item:
363363
text_item.setVisible(visible)

NodeGraphQt/base/graph.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from NodeGraphQt.base.port import Port
1919
from NodeGraphQt.constants import (
2020
NODE_LAYOUT_DIRECTION, NODE_LAYOUT_HORIZONTAL, NODE_LAYOUT_VERTICAL,
21-
PIPE_LAYOUT,
21+
PipeLayoutEnum,
2222
URI_SCHEME, URN_SCHEME,
23-
PORT_TYPE,
24-
VIEWER_STYLING
23+
PortTypeEnum,
24+
ViewerEnum
2525
)
2626
from NodeGraphQt.nodes.backdrop_node import BackdropNode
2727
from NodeGraphQt.nodes.base_node import BaseNode
@@ -369,7 +369,8 @@ def _on_connection_changed(self, disconnected, connected):
369369
return
370370

371371
label = 'connect node(s)' if connected else 'disconnect node(s)'
372-
ptypes = {PORT_TYPE.IN.value: 'inputs', PORT_TYPE.OUT.value: 'outputs'}
372+
ptypes = {PortTypeEnum.IN.value: 'inputs',
373+
PortTypeEnum.OUT.value: 'outputs'}
373374

374375
self._undo_stack.beginMacro(label)
375376
for p1_view, p2_view in disconnected:
@@ -396,7 +397,8 @@ def _on_connection_sliced(self, ports):
396397
"""
397398
if not ports:
398399
return
399-
ptypes = {PORT_TYPE.IN.value: 'inputs', PORT_TYPE.OUT.value: 'outputs'}
400+
ptypes = {PortTypeEnum.IN.value: 'inputs',
401+
PortTypeEnum.OUT.value: 'outputs'}
400402
self._undo_stack.beginMacro('slice connections')
401403
for p1_view, p2_view in ports:
402404
node1 = self._model.nodes[p1_view.node.id]
@@ -562,20 +564,20 @@ def set_grid_mode(self, mode=None):
562564
563565
Node graph background types:
564566
565-
* :attr:`NodeGraphQt.constants.VIEWER_STYLING.GRID_DISPLAY_NONE.value`
566-
* :attr:`NodeGraphQt.constants.VIEWER_STYLING.GRID_DISPLAY_DOTS.value`
567-
* :attr:`NodeGraphQt.constants.VIEWER_STYLING.GRID_DISPLAY_LINES.value`
567+
* :attr:`NodeGraphQt.constants.ViewerEnum.GRID_DISPLAY_NONE.value`
568+
* :attr:`NodeGraphQt.constants.ViewerEnum.GRID_DISPLAY_DOTS.value`
569+
* :attr:`NodeGraphQt.constants.ViewerEnum.GRID_DISPLAY_LINES.value`
568570
569571
Args:
570572
mode (int): background style.
571573
"""
572574
display_types = [
573-
VIEWER_STYLING.GRID_DISPLAY_NONE.value,
574-
VIEWER_STYLING.GRID_DISPLAY_DOTS.value,
575-
VIEWER_STYLING.GRID_DISPLAY_LINES.value
575+
ViewerEnum.GRID_DISPLAY_NONE.value,
576+
ViewerEnum.GRID_DISPLAY_DOTS.value,
577+
ViewerEnum.GRID_DISPLAY_LINES.value
576578
]
577579
if mode not in display_types:
578-
mode = VIEWER_STYLING.GRID_DISPLAY_LINES.value
580+
mode = ViewerEnum.GRID_DISPLAY_LINES.value
579581
self.scene().grid_mode = mode
580582
self._viewer.force_update()
581583

@@ -759,7 +761,7 @@ def set_pipe_collision(self, mode=True):
759761
self._model.pipe_collision = mode
760762
self._viewer.pipe_collision = mode
761763

762-
def set_pipe_style(self, style=PIPE_LAYOUT.CURVED.value):
764+
def set_pipe_style(self, style=PipeLayoutEnum.CURVED.value):
763765
"""
764766
Set node graph pipes to be drawn as straight, curved or angled.
765767
@@ -771,17 +773,17 @@ def set_pipe_style(self, style=PIPE_LAYOUT.CURVED.value):
771773
772774
Pipe Layout Styles:
773775
774-
* :attr:`NodeGraphQt.constants.PIPE_LAYOUT.CURVED.value`
775-
* :attr:`NodeGraphQt.constants.PIPE_LAYOUT.STRAIGHT.value`
776-
* :attr:`NodeGraphQt.constants.PIPE_LAYOUT.ANGLE.value`
776+
* :attr:`NodeGraphQt.constants.PipeLayoutEnum.CURVED.value`
777+
* :attr:`NodeGraphQt.constants.PipeLayoutEnum.STRAIGHT.value`
778+
* :attr:`NodeGraphQt.constants.PipeLayoutEnum.ANGLE.value`
777779
778780
Args:
779781
style (int): pipe layout style.
780782
"""
781-
pipe_max = max([PIPE_LAYOUT.CURVED.value,
782-
PIPE_LAYOUT.STRAIGHT.value,
783-
PIPE_LAYOUT.ANGLE.value])
784-
style = style if 0 <= style <= pipe_max else PIPE_LAYOUT.CURVED.value
783+
pipe_max = max([PipeLayoutEnum.CURVED.value,
784+
PipeLayoutEnum.STRAIGHT.value,
785+
PipeLayoutEnum.ANGLE.value])
786+
style = style if 0 <= style <= pipe_max else PipeLayoutEnum.CURVED.value
785787
self._viewer.set_pipe_layout(style)
786788

787789
def fit_to_selection(self):
@@ -1254,8 +1256,8 @@ def _serialize(self, nodes):
12541256
for conn_id, prt_names in conn_data.items():
12551257
for conn_prt in prt_names:
12561258
pipe = {
1257-
PORT_TYPE.IN.value: [n_id, pname],
1258-
PORT_TYPE.OUT.value: [conn_id, conn_prt]
1259+
PortTypeEnum.IN.value: [n_id, pname],
1260+
PortTypeEnum.OUT.value: [conn_id, conn_prt]
12591261
}
12601262
if pipe not in serial_data['connections']:
12611263
serial_data['connections'].append(pipe)
@@ -1264,8 +1266,8 @@ def _serialize(self, nodes):
12641266
for conn_id, prt_names in conn_data.items():
12651267
for conn_prt in prt_names:
12661268
pipe = {
1267-
PORT_TYPE.OUT.value: [n_id, pname],
1268-
PORT_TYPE.IN.value: [conn_id, conn_prt]
1269+
PortTypeEnum.OUT.value: [n_id, pname],
1270+
PortTypeEnum.IN.value: [conn_id, conn_prt]
12691271
}
12701272
if pipe not in serial_data['connections']:
12711273
serial_data['connections'].append(pipe)
@@ -2374,8 +2376,8 @@ def get_node_by_port(self, port):
23742376
PortInputNode or PortOutputNode: port node object.
23752377
"""
23762378
func_type = {
2377-
PORT_TYPE.IN.value: self.get_input_port_nodes,
2378-
PORT_TYPE.OUT.value: self.get_output_port_nodes
2379+
PortTypeEnum.IN.value: self.get_input_port_nodes,
2380+
PortTypeEnum.OUT.value: self.get_output_port_nodes
23792381
}
23802382
for n in func_type.get(port.type_(), []):
23812383
if port == n.parent_port:

NodeGraphQt/base/graph_actions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,48 +256,48 @@ def _curved_pipe(graph):
256256
"""
257257
Set node graph pipes layout as curved.
258258
"""
259-
from NodeGraphQt.constants import PIPE_LAYOUT
260-
graph.set_pipe_style(PIPE_LAYOUT.CURVED.value)
259+
from NodeGraphQt.constants import PipeLayoutEnum
260+
graph.set_pipe_style(PipeLayoutEnum.CURVED.value)
261261

262262

263263
def _straight_pipe(graph):
264264
"""
265265
Set node graph pipes layout as straight.
266266
"""
267-
from NodeGraphQt.constants import PIPE_LAYOUT
268-
graph.set_pipe_style(PIPE_LAYOUT.STRAIGHT.value)
267+
from NodeGraphQt.constants import PipeLayoutEnum
268+
graph.set_pipe_style(PipeLayoutEnum.STRAIGHT.value)
269269

270270

271271
def _angle_pipe(graph):
272272
"""
273273
Set node graph pipes layout as angled.
274274
"""
275-
from NodeGraphQt.constants import PIPE_LAYOUT
276-
graph.set_pipe_style(PIPE_LAYOUT.ANGLE.value)
275+
from NodeGraphQt.constants import PipeLayoutEnum
276+
graph.set_pipe_style(PipeLayoutEnum.ANGLE.value)
277277

278278

279279
def _bg_grid_none(graph):
280280
"""
281281
Turn off the background patterns.
282282
"""
283-
from NodeGraphQt.constants import VIEWER_STYLING
284-
graph.set_grid_mode(VIEWER_STYLING.GRID_DISPLAY_NONE.value)
283+
from NodeGraphQt.constants import ViewerEnum
284+
graph.set_grid_mode(ViewerEnum.GRID_DISPLAY_NONE.value)
285285

286286

287287
def _bg_grid_dots(graph):
288288
"""
289289
Set background node graph background with grid dots.
290290
"""
291-
from NodeGraphQt.constants import VIEWER_STYLING
292-
graph.set_grid_mode(VIEWER_STYLING.GRID_DISPLAY_DOTS.value)
291+
from NodeGraphQt.constants import ViewerEnum
292+
graph.set_grid_mode(ViewerEnum.GRID_DISPLAY_DOTS.value)
293293

294294

295295
def _bg_grid_lines(graph):
296296
"""
297297
Set background node graph background with grid lines.
298298
"""
299-
from NodeGraphQt.constants import VIEWER_STYLING
300-
graph.set_grid_mode(VIEWER_STYLING.GRID_DISPLAY_LINES.value)
299+
from NodeGraphQt.constants import ViewerEnum
300+
graph.set_grid_mode(ViewerEnum.GRID_DISPLAY_LINES.value)
301301

302302

303303
def _layout_graph_down(graph):

NodeGraphQt/base/port.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
NodeInputDisconnectedCmd
1010
)
1111
from NodeGraphQt.base.model import PortModel
12-
from NodeGraphQt.constants import PORT_TYPE
12+
from NodeGraphQt.constants import PortTypeEnum
1313
from NodeGraphQt.errors import PortError
1414

1515

@@ -196,9 +196,9 @@ def connected_ports(self):
196196
for node_id, port_names in self.model.connected_ports.items():
197197
for port_name in port_names:
198198
node = graph.get_node_by_id(node_id)
199-
if self.type_() == PORT_TYPE.IN.value:
199+
if self.type_() == PortTypeEnum.IN.value:
200200
ports.append(node.outputs()[port_name])
201-
elif self.type_() == PORT_TYPE.OUT.value:
201+
elif self.type_() == PortTypeEnum.OUT.value:
202202
ports.append(node.inputs()[port_name])
203203
return ports
204204

@@ -284,8 +284,8 @@ def connect_to(self, port=None, push_undo=True):
284284

285285
# emit "port_connected" signal from the parent graph.
286286
ports = {p.type_(): p for p in [self, port]}
287-
graph.port_connected.emit(ports[PORT_TYPE.IN.value],
288-
ports[PORT_TYPE.OUT.value])
287+
graph.port_connected.emit(ports[PortTypeEnum.IN.value],
288+
ports[PortTypeEnum.OUT.value])
289289

290290
def disconnect_from(self, port=None, push_undo=True):
291291
"""
@@ -316,8 +316,8 @@ def disconnect_from(self, port=None, push_undo=True):
316316

317317
# emit "port_disconnected" signal from the parent graph.
318318
ports = {p.type_(): p for p in [self, port]}
319-
graph.port_disconnected.emit(ports[PORT_TYPE.IN.value],
320-
ports[PORT_TYPE.OUT.value])
319+
graph.port_disconnected.emit(ports[PortTypeEnum.IN.value],
320+
ports[PortTypeEnum.OUT.value])
321321

322322
def clear_connections(self, push_undo=True):
323323
"""

NodeGraphQt/constants.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
# =================================== GLOBAL ===================================
5353

5454

55-
class VERSION(Enum):
55+
class VersionEnum(Enum):
5656
"""
5757
Current framework version.
58-
:py:mod:`NodeGraphQt.constants.VERSION`
58+
:py:mod:`NodeGraphQt.constants.VersionEnum`
5959
"""
6060
#:
6161
VERSION = _v
@@ -69,10 +69,10 @@ class VERSION(Enum):
6969
# =================================== VIEWER ===================================
7070

7171

72-
class VIEWER_STYLING(Enum):
72+
class ViewerEnum(Enum):
7373
"""
7474
Node graph viewer styling layout:
75-
:py:mod:`NodeGraphQt.constants.VIEWER_STYLING`
75+
:py:mod:`NodeGraphQt.constants.ViewerEnum`
7676
"""
7777
#: default background color for the node graph.
7878
BACKGROUND_COLOR = (35, 35, 35)
@@ -88,10 +88,10 @@ class VIEWER_STYLING(Enum):
8888
GRID_COLOR = (45, 45, 45)
8989

9090

91-
class VIEWER_NAV_STYLING(Enum):
91+
class ViewerNavEnum(Enum):
9292
"""
9393
Node graph viewer navigation styling layout:
94-
:py:mod:`NodeGraphQt.constants.VIEWER_NAV_STYLING`
94+
:py:mod:`NodeGraphQt.constants.ViewerNavEnum`
9595
"""
9696
#: default background color.
9797
BACKGROUND_COLOR = (25, 25, 25)
@@ -101,10 +101,10 @@ class VIEWER_NAV_STYLING(Enum):
101101
# ==================================== NODE ====================================
102102

103103

104-
class NODE_STYLING(Enum):
104+
class NodeEnum(Enum):
105105
"""
106106
Node styling layout:
107-
:py:mod:`NodeGraphQt.constants.NODE_STYLING`
107+
:py:mod:`NodeGraphQt.constants.NodeEnum`
108108
"""
109109
#: default node width.
110110
WIDTH = 160
@@ -120,10 +120,10 @@ class NODE_STYLING(Enum):
120120
# ==================================== PORT ====================================
121121

122122

123-
class PORT_STYLING(Enum):
123+
class PortEnum(Enum):
124124
"""
125125
Port styling layout:
126-
:py:mod:`NodeGraphQt.constants.PORT_STYLING`
126+
:py:mod:`NodeGraphQt.constants.PortEnum`
127127
"""
128128
#: default port size.
129129
SIZE = 22.0
@@ -143,10 +143,10 @@ class PORT_STYLING(Enum):
143143
CLICK_FALLOFF = 15.0
144144

145145

146-
class PORT_TYPE(Enum):
146+
class PortTypeEnum(Enum):
147147
"""
148148
Port connection types:
149-
:py:mod:`NodeGraphQt.constants.PORT_TYPE`
149+
:py:mod:`NodeGraphQt.constants.PortTypeEnum`
150150
"""
151151
#: Connection type for input ports.
152152
IN = 'in'
@@ -156,10 +156,10 @@ class PORT_TYPE(Enum):
156156
# ==================================== PIPE ====================================
157157

158158

159-
class PIPE_STYLING(Enum):
159+
class PipeEnum(Enum):
160160
"""
161161
Pipe styling layout:
162-
:py:mod:`NodeGraphQt.constants.PIPE_STYLING`
162+
:py:mod:`NodeGraphQt.constants.PipeEnum`
163163
"""
164164
#: default width.
165165
WIDTH = 1.2
@@ -179,21 +179,21 @@ class PIPE_STYLING(Enum):
179179
DRAW_TYPE_DOTTED = 2
180180

181181

182-
class PIPE_SLICER_STYLING(Enum):
182+
class PipeSlicerEnum(Enum):
183183
"""
184184
Slicer Pipe styling layout:
185-
:py:mod:`NodeGraphQt.constants.PIPE_SLICER_STYLING`
185+
:py:mod:`NodeGraphQt.constants.PipeSlicerEnum`
186186
"""
187187
#: default width.
188188
WIDTH = 1.5
189189
#: default color.
190190
COLOR = (255, 50, 75)
191191

192192

193-
class PIPE_LAYOUT(Enum):
193+
class PipeLayoutEnum(Enum):
194194
"""
195195
Pipe connection drawing layout:
196-
:py:mod:`NodeGraphQt.constants.PIPE_LAYOUT`
196+
:py:mod:`NodeGraphQt.constants.PipeLayoutEnum`
197197
"""
198198
#: draw straight lines for pipe connections.
199199
STRAIGHT = 0

0 commit comments

Comments
 (0)