Skip to content

Commit

Permalink
Node editor README
Browse files Browse the repository at this point in the history
  • Loading branch information
gpospelov committed Jan 18, 2021
1 parent b34bdff commit a5737a1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
Binary file added doc/assets/nodeeditor.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/assets/nodeeditor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@

<hr>

### [Nodeeditor: how to implement the node editor.](nodeeditor/README.md)

![saveloadproject](../doc/assets/nodeeditor.png)

<hr>

### Under development

+ modelinqml
+ nodeeditor

56 changes: 53 additions & 3 deletions examples/nodeeditor/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,59 @@
# Example "nodeeditor".

The example shows a node editor (similar to the one we can find in LabView, Blender,
and others).
The example shows a node editor similar to those we can find in LabView,
Blender, Maya, and other applications. It allows organizing complex settings in
the form of a dependency graph, displaying nodes and the connections between
their attributes.

> Node editor: original code is taken from
> http://algoholic.eu/qnodeseditor-qt-nodesports-based-data-processing-flow-editor/
> Copyright (c) 2012, STANISLAW ADASZEWSKI
> Copyright (c) 2012, STANISLAW ADASZEWSKI.
The example from the link was adapted for `qt-mvvm` library. The resulting
application provides a data model, various view models (e.g. node editor,
property editor, hierarchy view), serialization, and undo/redo.

![plotgraphs](../../doc/assets/nodeeditor.png)

## The context.

In this particular example, the node editor is used to set up `ParticleLayout`
for further simulation of neutron scattering from some nano-particle arrangement.
The layout carries information about particles populating a crystal lattice.
The `ParticleLayout` can have an arbitrary amount of particles attached, but
only one single lattice. Particles can be rotated with the help of the
`Transformation` object. There can be many layouts on the scene.

## Widgets.

- The list view on the left. Items from the list can be drag-and-dropped on the scene.
- Node editor. Ports of the same color can be connected together.
- Tree view present same data model as node editor in the form of object hierarchy.
- Property editor shows all properties of currently selected node.

## Details.

### `ConnectableItem, ConnectableView and ConnectableItemController`

The `ConnectableItem` is a base class for all items representing nodes. Doesn't
have own visual representation. Serves as a building block for `SampleModel`. The
`ConnectableView` is a counterpart of `ConnectableItem` on the graphics scene.
The `ConnectableItemController` provides updates of view's position/appearance on
graphics scene, when underlying item changes. Similarly, it provides update of
item's properties while view is moved on the scene by the user.

### `NodePort, NodeConnection and NodeController`

This is the part which came originally from [Node Editor by STANISLAW ADASZEWSKI](http://algoholic.eu/qnodeseditor-qt-nodesports-based-data-processing-flow-editor).
Contains machinery to establish elastic connections between ports.

### `GraphicsScene and GraphicsSceneController`

The `GraphicsSceneController` listens to the original `SampleModel`
and updates scene on model change. When item is removed from the model, the corresponding view will be removed too. When item is added to the model,
new view will be added to the scene.
When elastic connection is established between two nodes, this triggers parent change request to the `SampleModel`. This in turn, leads to the
connections in the node editor created as necessary to represent new parent/child relationships in the underlying model.

![plotgraphs](../../doc/assets/nodeeditor.gif)

0 comments on commit a5737a1

Please sign in to comment.