|
15 | 15 | from NodeGraphQt.base.node import NodeObject |
16 | 16 | from NodeGraphQt.base.port import Port |
17 | 17 | from NodeGraphQt.constants import DRAG_DROP_ID |
18 | | -from NodeGraphQt.widgets.node_tree import NodeTreeWidget |
19 | 18 | from NodeGraphQt.widgets.viewer import NodeViewer |
20 | 19 |
|
21 | 20 |
|
@@ -45,8 +44,6 @@ def __init__(self, parent=None): |
45 | 44 | self._node_factory = NodeFactory() |
46 | 45 | self._undo_stack = QtWidgets.QUndoStack(self) |
47 | 46 |
|
48 | | - self._nodes_tree = None |
49 | | - |
50 | 47 | tab = QtWidgets.QAction('Search Nodes', self) |
51 | 48 | tab.setShortcut('tab') |
52 | 49 | tab.triggered.connect(self._toggle_tab_search) |
@@ -231,26 +228,63 @@ def scene(self): |
231 | 228 | """ |
232 | 229 | return self._viewer.scene() |
233 | 230 |
|
234 | | - def add_properties_bin(self, prop_bin): |
| 231 | + def background_color(self): |
235 | 232 | """ |
236 | | - Wire up a properties bin widget to the node graph. |
| 233 | + Return the node graph background color. |
| 234 | +
|
| 235 | + Returns: |
| 236 | + tuple: r, g ,b |
| 237 | + """ |
| 238 | + return self.scene().background_color |
| 239 | + |
| 240 | + def set_background_color(self, r, g, b): |
| 241 | + """ |
| 242 | + Set node graph background color. |
237 | 243 |
|
238 | 244 | Args: |
239 | | - prop_bin (NodeGraphQt.PropertiesBinWidget): properties widget. |
| 245 | + r (int): red value. |
| 246 | + g (int): green value. |
| 247 | + b (int): blue value. |
240 | 248 | """ |
241 | | - prop_bin.property_changed.connect(self._on_property_bin_changed) |
| 249 | + self.scene().background_color = (r, g, b) |
242 | 250 |
|
243 | | - def nodes_tree(self): |
| 251 | + def grid_color(self): |
244 | 252 | """ |
245 | | - Initializes the nodes list widget when first called. |
| 253 | + Return the node graph grid color. |
246 | 254 |
|
247 | 255 | Returns: |
248 | | - NodeTreeWidget: the initialized widget. |
| 256 | + tuple: r, g ,b |
| 257 | + """ |
| 258 | + return self.scene().grid_color |
| 259 | + |
| 260 | + def set_grid_color(self, r, g, b): |
| 261 | + """ |
| 262 | + Set node graph grid color. |
| 263 | +
|
| 264 | + Args: |
| 265 | + r (int): red value. |
| 266 | + g (int): green value. |
| 267 | + b (int): blue value. |
249 | 268 | """ |
250 | | - if self._nodes_tree is None: |
251 | | - self._nodes_tree = NodeTreeWidget() |
252 | | - self._nodes_tree.set_node_factory(self._node_factory) |
253 | | - return self._nodes_tree |
| 269 | + self.scene().grid_color = (r, g, b) |
| 270 | + |
| 271 | + def display_grid(self, display=True): |
| 272 | + """ |
| 273 | + Display node graph background grid. |
| 274 | +
|
| 275 | + Args: |
| 276 | + display: False to not draw the background grid. |
| 277 | + """ |
| 278 | + self.scene().grid = display |
| 279 | + |
| 280 | + def add_properties_bin(self, prop_bin): |
| 281 | + """ |
| 282 | + Wire up a properties bin widget to the node graph. |
| 283 | +
|
| 284 | + Args: |
| 285 | + prop_bin (NodeGraphQt.PropertiesBinWidget): properties widget. |
| 286 | + """ |
| 287 | + prop_bin.property_changed.connect(self._on_property_bin_changed) |
254 | 288 |
|
255 | 289 | def undo_stack(self): |
256 | 290 | """ |
@@ -303,12 +337,12 @@ def acyclic(self): |
303 | 337 | """ |
304 | 338 | return self._model.acyclic |
305 | 339 |
|
306 | | - def set_acyclic(self, mode=True): |
| 340 | + def set_acyclic(self, mode=False): |
307 | 341 | """ |
308 | | - Set the node graph to be acyclic or not. (default=True) |
| 342 | + Enable the node graph to be a acyclic graph. (default=False) |
309 | 343 |
|
310 | 344 | Args: |
311 | | - mode (bool): false to disable acyclic. |
| 345 | + mode (bool): true to enable acyclic. |
312 | 346 | """ |
313 | 347 | self._model.acyclic = mode |
314 | 348 | self._viewer.acyclic = mode |
|
0 commit comments