/
GraphTreeModelPopulator.h
53 lines (43 loc) · 1.14 KB
/
GraphTreeModelPopulator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include "iscenegraph.h"
#include "ientity.h"
#include "GraphTreeModel.h"
namespace ui {
/**
* greebo: The purpose of this class is to traverse the entire scenegraph and
* push all the found nodes into the given GraphTreeModel.
*
* This is used by the GraphTreeModel itself to update its status on show.
*/
class GraphTreeModelPopulator :
public scene::NodeVisitor
{
private:
// The model to be populated
GraphTreeModel& _model;
bool _visibleNodesOnly;
public:
GraphTreeModelPopulator(GraphTreeModel& model, bool visibleNodesOnly) :
_model(model),
_visibleNodesOnly(visibleNodesOnly)
{
// Clear out the model before traversal
_model.clear();
}
// NodeVisitor implementation
bool pre(const scene::INodePtr& node)
{
if ((!_visibleNodesOnly || node->visible()) && node->getNodeType() != scene::INode::Type::EntityConnection)
{
// Insert this node into the GraphTreeModel
_model.insert(node);
}
Entity* ent = Node_getEntity(node);
if (ent != NULL && ent->isWorldspawn()) {
// Don't accumulate the worldspawn brushes
return false;
}
return true; // traverse children
}
};
} // namespace ui