| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e207d16 commit fddd431
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,20 +18,28 @@ registerDataModels() | |||
| 18 | 18 | { | |
| 19 | 19 | DataModelRegistry::registerModel<NaiveDataModel>("NaiveDataModel"); | |
| 20 | 20 | ||
| 21 | + /* | ||
| 22 | + We could have more models registered. | ||
| 23 | + All of them become items in the context meny of the scene. | ||
| 24 | + | ||
| 25 | + DataModelRegistry::registerModel<AnotherDataModel>("AnotherDataModel"); | ||
| 26 | + DataModelRegistry::registerModel<OneMoreDataModel>("OneMoreDataModel"); | ||
| 27 | + | ||
| 28 | + */ | ||
| 29 | + | ||
| 21 | 30 | return true; | |
| 22 | 31 | } | |
| 23 | 32 | ||
| 24 | - | ||
| 25 | 33 | static bool registerOK = registerDataModels(); | |
| 26 | 34 | ||
| 35 | + | ||
| 36 | + //------------------------------------------------------------------------------ | ||
| 37 | + | ||
| 27 | 38 | int | |
| 28 | 39 | main(int argc, char* argv[]) | |
| 29 | 40 | { | |
| 30 | 41 | QApplication app(argc, argv); | |
| 31 | 42 | ||
| 32 | - //FlowScene::instance(); | ||
| 33 | - | ||
| 34 | - | ||
| 35 | 43 | FlowGraphicsView view(&FlowScene::instance()); | |
| 36 | 44 | ||
| 37 | 45 | view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,2 +1,4 @@ | |||
| 1 | 1 | #include "models.hpp" | |
| 2 | 2 | ||
| 3 | + // For some reason CMake could not generate moc-files correctly | ||
| 4 | + // without having a cpp for an QObject from hpp. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,9 @@ | |||
| 5 | 5 | #include <nodes/NodeData> | |
| 6 | 6 | #include <nodes/NodeDataModel> | |
| 7 | 7 | ||
| 8 | + | ||
| 9 | + /// The class can potentially incapsulate any user data which | ||
| 10 | + /// need to be transferred within the Node Editor graph | ||
| 8 | 11 | class MyNodeData : public NodeData | |
| 9 | 12 | { | |
| 10 | 13 | public: | |
@@ -20,7 +23,8 @@ class MyNodeData : public NodeData | |||
| 20 | 23 | ||
| 21 | 24 | //------------------------------------------------------------------------------ | |
| 22 | 25 | ||
| 23 | - // simplest stupid model | ||
| 26 | + /// The model dictates the number of inputs and outputs for the Node. | ||
| 27 | + /// In this example it has no logic. | ||
| 24 | 28 | class NaiveDataModel : public NodeDataModel | |
| 25 | 29 | { | |
| 26 | 30 | Q_OBJECT | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ class Node::NodeImpl | |||
| 30 | 30 | _nodeGeometry.recalculateSize(); | |
| 31 | 31 | } | |
| 32 | 32 | ||
| 33 | + /// Destructor | ||
| 33 | 34 | ~NodeImpl() | |
| 34 | 35 | { | |
| 35 | 36 | std::cout << "About to delete graphics object" << std::endl; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,4 @@ | |||
| 1 | - #ifndef NODE_GRAPHICS_OBJECT_HPP | ||
| 2 | - #define NODE_GRAPHICS_OBJECT_HPP | ||
| 1 | + #pragma once | ||
| 3 | 2 | ||
| 4 | 3 | #include <QtCore/QUuid> | |
| 5 | 4 | #include <QtWidgets/QGraphicsObject> | |
@@ -11,6 +10,8 @@ | |||
| 11 | 10 | ||
| 12 | 11 | class FlowItemEntry; | |
| 13 | 12 | ||
| 13 | + /// Class reacts on GUI events, mouse clicks and | ||
| 14 | + /// forwards painting operation. | ||
| 14 | 15 | class NodeGraphicsObject : public QGraphicsObject | |
| 15 | 16 | { | |
| 16 | 17 | Q_OBJECT | |
@@ -54,5 +55,3 @@ class NodeGraphicsObject : public QGraphicsObject | |||
| 54 | 55 | ||
| 55 | 56 | NodeGeometry& _nodeGeometry; | |
| 56 | 57 | }; | |
| 57 | - | ||
| 58 | - #endif // NODE_GRAPHICS_OBJECT_HPP | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,62 @@ | |||
| 1 | + #include "NodeState.hpp" | ||
| 2 | + | ||
| 3 | + NodeState:: | ||
| 4 | + NodeState(unsigned int nSources, | ||
| 5 | + unsigned int nSinks) | ||
| 6 | + : _sources(nSources, QUuid()) | ||
| 7 | + , _sinks(nSinks, QUuid()) | ||
| 8 | + , _reaction(NOT_REACTING) | ||
| 9 | + {} | ||
| 10 | + | ||
| 11 | + std::vector<QUuid> const& | ||
| 12 | + NodeState:: | ||
| 13 | + getEntries(EndType endType) const | ||
| 14 | + { | ||
| 15 | + Q_ASSERT(endType != EndType::NONE); | ||
| 16 | + | ||
| 17 | + if (endType == EndType::SOURCE) | ||
| 18 | + return _sources; | ||
| 19 | + else | ||
| 20 | + return _sinks; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + QUuid const | ||
| 25 | + NodeState:: | ||
| 26 | + connectionID(EndType endType, size_t nEntry) const | ||
| 27 | + { | ||
| 28 | + std::vector<QUuid> const& entries = | ||
| 29 | + getEntries(endType); | ||
| 30 | + | ||
| 31 | + if (nEntry >= entries.size()) | ||
| 32 | + return QUuid(); | ||
| 33 | + | ||
| 34 | + return entries[nEntry]; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + void | ||
| 39 | + NodeState:: | ||
| 40 | + setConnectionId(EndType endType, size_t nEntry, QUuid id) | ||
| 41 | + { | ||
| 42 | + std::vector<QUuid> const& entries = | ||
| 43 | + const_cast<NodeState const&>(*this).getEntries(endType); | ||
| 44 | + | ||
| 45 | + const_cast<std::vector<QUuid>&>(entries)[nEntry] = id; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + NodeState::ReactToConnectionState | ||
| 50 | + NodeState:: | ||
| 51 | + reaction() const | ||
| 52 | + { return _reaction; } | ||
| 53 | + | ||
| 54 | + void | ||
| 55 | + NodeState:: | ||
| 56 | + setReaction(ReactToConnectionState reaction) | ||
| 57 | + { _reaction = reaction; } | ||
| 58 | + | ||
| 59 | + bool | ||
| 60 | + NodeState:: | ||
| 61 | + isReacting() const | ||
| 62 | + { return _reaction == REACTING; } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,13 @@ | |||
| 1 | - #ifndef NODE_STATE_HPP | ||
| 2 | - #define NODE_STATE_HPP | ||
| 1 | + #pragma once | ||
| 3 | 2 | ||
| 4 | 3 | #include <vector> | |
| 5 | 4 | ||
| 6 | 5 | #include <QtCore/QUuid> | |
| 7 | 6 | ||
| 8 | 7 | #include "EndType.hpp" | |
| 9 | 8 | ||
| 9 | + /// Contains vectors of connected input and output connections. | ||
| 10 | + /// Stores bool for reacting on hovering connections | ||
| 10 | 11 | class NodeState | |
| 11 | 12 | { | |
| 12 | 13 | public: | |
@@ -18,57 +19,30 @@ class NodeState | |||
| 18 | 19 | ||
| 19 | 20 | public: | |
| 20 | 21 | NodeState(unsigned int nSources, | |
| 21 | - unsigned int nSinks) | ||
| 22 | - : _sources(nSources, QUuid()) | ||
| 23 | - , _sinks(nSinks, QUuid()) | ||
| 24 | - , _reaction(NOT_REACTING) | ||
| 25 | - {} | ||
| 22 | + unsigned int nSinks); | ||
| 26 | 23 | ||
| 27 | 24 | public: | |
| 28 | 25 | ||
| 29 | - std::vector<QUuid> const& getEntries(EndType endType) const | ||
| 30 | - { | ||
| 31 | - Q_ASSERT(endType != EndType::NONE); | ||
| 32 | - | ||
| 33 | - if (endType == EndType::SOURCE) | ||
| 34 | - return _sources; | ||
| 35 | - else | ||
| 36 | - return _sinks; | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - QUuid const connectionID(EndType endType, size_t nEntry) const | ||
| 40 | - { | ||
| 41 | - std::vector<QUuid> const& entries = | ||
| 42 | - getEntries(endType); | ||
| 26 | + /// Returns vector of connections ID. | ||
| 27 | + /// Some of them can be empty (null) | ||
| 28 | + std::vector<QUuid> const& getEntries(EndType endType) const; | ||
| 43 | 29 | ||
| 44 | - if (nEntry >= entries.size()) | ||
| 45 | - return QUuid(); | ||
| 30 | + /// Returns connection id for given endtype and | ||
| 31 | + /// given connection number | ||
| 32 | + QUuid const connectionID(EndType endType, size_t nEntry) const; | ||
| 46 | 33 | ||
| 47 | - return entries[nEntry]; | ||
| 48 | - } | ||
| 34 | + /// Assign connection id to the given entry | ||
| 35 | + void setConnectionId(EndType endType, size_t nEntry, QUuid id); | ||
| 49 | 36 | ||
| 50 | - void setConnectionId(EndType endType, size_t nEntry, QUuid id) | ||
| 51 | - { | ||
| 52 | - std::vector<QUuid> const& entries = | ||
| 53 | - const_cast<NodeState const&>(*this).getEntries(endType); | ||
| 54 | - | ||
| 55 | - const_cast<std::vector<QUuid>&>(entries)[nEntry] = id; | ||
| 56 | - } | ||
| 37 | + ReactToConnectionState reaction() const; | ||
| 57 | 38 | ||
| 58 | - ReactToConnectionState reaction() const | ||
| 59 | - { return _reaction; } | ||
| 39 | + void setReaction(ReactToConnectionState reaction); | ||
| 60 | 40 | ||
| 61 | - void setReaction(ReactToConnectionState reaction) | ||
| 62 | - { _reaction = reaction; } | ||
| 63 | - | ||
| 64 | - bool isReacting() const | ||
| 65 | - { return _reaction == REACTING; } | ||
| 41 | + bool isReacting() const; | ||
| 66 | 42 | ||
| 67 | 43 | private: | |
| 68 | 44 | std::vector<QUuid> _sources; | |
| 69 | 45 | std::vector<QUuid> _sinks; | |
| 70 | 46 | ||
| 71 | 47 | ReactToConnectionState _reaction; | |
| 72 | 48 | }; | |
| 73 | - | ||
| 74 | - #endif // NODE_STATE_HPP | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments