FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add comments · BehaviorTree/nodeeditor@fddd431 · GitHub

Commit fddd431

Browse files
committed
Add comments
1 parent e207d16 commit fddd431

7 files changed

Lines changed: 100 additions & 50 deletions

File tree

‎examples/main.cpp‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,28 @@ registerDataModels()
1818
{
1919
DataModelRegistry::registerModel<NaiveDataModel>("NaiveDataModel");
2020

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+
2130
return true;
2231
}
2332

24-
2533
static bool registerOK = registerDataModels();
2634

35+
36+
//------------------------------------------------------------------------------
37+
2738
int
2839
main(int argc, char* argv[])
2940
{
3041
QApplication app(argc, argv);
3142

32-
//FlowScene::instance();
33-
34-
3543
FlowGraphicsView view(&FlowScene::instance());
3644

3745
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView,

‎examples/models.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#include "models.hpp"
22

3+
// For some reason CMake could not generate moc-files correctly
4+
// without having a cpp for an QObject from hpp.

‎examples/models.hpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#include <nodes/NodeData>
66
#include <nodes/NodeDataModel>
77

8+
9+
/// The class can potentially incapsulate any user data which
10+
/// need to be transferred within the Node Editor graph
811
class MyNodeData : public NodeData
912
{
1013
public:
@@ -20,7 +23,8 @@ class MyNodeData : public NodeData
2023

2124
//------------------------------------------------------------------------------
2225

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.
2428
class NaiveDataModel : public NodeDataModel
2529
{
2630
Q_OBJECT

‎src/Node.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Node::NodeImpl
3030
_nodeGeometry.recalculateSize();
3131
}
3232

33+
/// Destructor
3334
~NodeImpl()
3435
{
3536
std::cout << "About to delete graphics object" << std::endl;

‎src/NodeGraphicsObject.hpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef NODE_GRAPHICS_OBJECT_HPP
2-
#define NODE_GRAPHICS_OBJECT_HPP
1+
#pragma once
32

43
#include <QtCore/QUuid>
54
#include <QtWidgets/QGraphicsObject>
@@ -11,6 +10,8 @@
1110

1211
class FlowItemEntry;
1312

13+
/// Class reacts on GUI events, mouse clicks and
14+
/// forwards painting operation.
1415
class NodeGraphicsObject : public QGraphicsObject
1516
{
1617
Q_OBJECT
@@ -54,5 +55,3 @@ class NodeGraphicsObject : public QGraphicsObject
5455

5556
NodeGeometry& _nodeGeometry;
5657
};
57-
58-
#endif // NODE_GRAPHICS_OBJECT_HPP

‎src/NodeState.cpp‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff 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; }

‎src/NodeState.hpp‎

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#ifndef NODE_STATE_HPP
2-
#define NODE_STATE_HPP
1+
#pragma once
32

43
#include <vector>
54

65
#include <QtCore/QUuid>
76

87
#include "EndType.hpp"
98

9+
/// Contains vectors of connected input and output connections.
10+
/// Stores bool for reacting on hovering connections
1011
class NodeState
1112
{
1213
public:
@@ -18,57 +19,30 @@ class NodeState
1819

1920
public:
2021
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);
2623

2724
public:
2825

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;
4329

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;
4633

47-
return entries[nEntry];
48-
}
34+
/// Assign connection id to the given entry
35+
void setConnectionId(EndType endType, size_t nEntry, QUuid id);
4936

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;
5738

58-
ReactToConnectionState reaction() const
59-
{ return _reaction; }
39+
void setReaction(ReactToConnectionState reaction);
6040

61-
void setReaction(ReactToConnectionState reaction)
62-
{ _reaction = reaction; }
63-
64-
bool isReacting() const
65-
{ return _reaction == REACTING; }
41+
bool isReacting() const;
6642

6743
private:
6844
std::vector<QUuid> _sources;
6945
std::vector<QUuid> _sinks;
7046

7147
ReactToConnectionState _reaction;
7248
};
73-
74-
#endif // NODE_STATE_HPP

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL