forked from gpospelov/qt-mvvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|