OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
SceneNodeBase.h
Go to the documentation of this file.
1#pragma once
2
3#include "OTCore/CoreTypes.h"
4#include "Visualiser.h"
5#include <string>
6#include <list>
7#include <cassert>
8
9#include "OldTreeIcon.h"
10
11namespace osg { class Switch; };
12
14{
15public:
16 SceneNodeBase() : shapeNode(nullptr), treeItemID(0), modelEntityID(0), editable(false), visible(true), selected(false), transparent(false),
17 wireframe(false), highlighted(false), offset(1.0), selectChildren(true), manageVisibilityOfParent(true), manageVisibilityOfChildren(true), parent(nullptr) {};
18 virtual ~SceneNodeBase()
19 {
20 for (Visualiser* visualiser : m_visualiser)
21 {
22 delete visualiser;
23 visualiser = nullptr;
24 }
25
26 if (parent != nullptr)
27 {
28 parent->removeChild(this);
29 }
30 std::list<SceneNodeBase*> currentChilds = children;
31 for (auto child : currentChilds)
32 {
33 delete child;
34 }
35 };
36
37 void setName(const std::string &n) { name = n; };
38 const std::string& getName(void) { return name; };
39
40 void setShapeNode(osg::Switch *node) { shapeNode = node; };
41 osg::Switch *getShapeNode(void) { return shapeNode; };
42
43 void setTreeItemID(ot::UID iD) { treeItemID = iD; };
44 ot::UID getTreeItemID(void) { return treeItemID; };
45
46 void setModelEntityID(unsigned long long id) { modelEntityID = id; };
47 unsigned long long getModelEntityID(void) { return modelEntityID; };
48
49 bool isEditable(void) { return editable; };
50 virtual void setEditable(bool v) { editable = v; };
51
52 bool isVisible(void) { return visible; };
53 virtual void setVisible(bool v) { visible = v; };
54
55 bool isSelected(void) { return selected; };
56 virtual void setSelected(bool _selected, bool _selectionFromNavigationTree)
57 {
58 selected = _selected;
59
60 };
61
62
63 bool isTransparent(void) { return transparent; };
64 virtual void setTransparent(bool t) { transparent = t; };
65
66 bool isWireframe(void) { return wireframe; };
67 virtual void setWireframe(bool w) { wireframe = w; };
68
69 bool isHighlighted(void) { return highlighted; };
70 virtual void setHighlighted(bool h) { if (highlighted != h) { highlighted = h; if (selectChildren) { for (auto child : children) child->setHighlighted(h); } } };
71
72 void setErrors(std::string &e) { errors = e; };
73 bool hasErrors(void) { return !errors.empty(); };
74 std::string getErrors(void) { return errors; };
75
76 void setOffset(double value) { offset = value; };
77 double getOffset(void) { return offset; };
78
79 void setSelectChildren(bool flag) { selectChildren = flag; }
80 virtual bool getSelectChildren(void) { return selectChildren; }
81
82 void setManageVisibilityOfParent(bool flag) { manageVisibilityOfParent = flag; }
83 bool getManageVisibilityOfParent(void) { return manageVisibilityOfParent; }
84
85 void setManageVisibilityOfChildren(bool flag) { manageVisibilityOfChildren = flag; }
86 bool getManageVisibilityOfChildren(void) { return manageVisibilityOfChildren; }
87
88 void setParent(SceneNodeBase *item) { parent = item; };
89 SceneNodeBase *getParent(void) { return parent; };
90
91 void addChild(SceneNodeBase *child) { assert(std::find(children.begin(), children.end(), child) == children.end()); children.push_back(child); child->setParent(this); };
92 void removeChild(SceneNodeBase *child) { assert(std::find(children.begin(), children.end(), child) != children.end()); children.remove(child); };
93 const std::list<SceneNodeBase*> &getChildren(void) { return children; };
94
95 void setOldTreeIcons(const OldTreeIcon &icons) { treeIcons = icons; };
96 const OldTreeIcon &getOldTreeIcons(void) { return treeIcons; };
97
98 virtual void getPrefetch(std::string &projectName, std::list<std::pair<unsigned long long, unsigned long long>> &prefetchIDs) {};
99
100 virtual bool isItem1D(void) = 0;
101 virtual bool isItem3D(void) = 0;
102
103 void addVisualiser(Visualiser* _visualiser) { m_visualiser.push_back(_visualiser); }
104 const std::list<Visualiser*>& getVisualiser() { return m_visualiser; }
105
106protected:
107 osg::Switch * shapeNode;
108 const float transparency = 0.15;
109
110private:
111 std::string name;
112 ot::UID treeItemID;
113 unsigned long long modelEntityID;
114 bool editable;
115 bool visible;
116 bool selected;
117 bool m_selectionFromNavigationTree;
118 bool transparent;
119 bool wireframe;
120 bool highlighted;
121 double offset;
122 bool selectChildren;
123 bool manageVisibilityOfParent;
124 bool manageVisibilityOfChildren;
125 std::string errors;
126 SceneNodeBase * parent;
127 std::list<SceneNodeBase*> children;
128 OldTreeIcon treeIcons;
129
130 std::list<Visualiser*> m_visualiser;
131};
132
bsoncxx::types::value value
Definition DocumentManager.h:16
@ e
Definition SourceTarget.h:4
@ h
Definition SourceTarget.h:4
Definition SceneNodeBase.h:14
bool isEditable(void)
Definition SceneNodeBase.h:49
osg::Switch * shapeNode
Definition SceneNodeBase.h:107
virtual void setHighlighted(bool h)
Definition SceneNodeBase.h:70
SceneNodeBase * getParent(void)
Definition SceneNodeBase.h:89
virtual bool isItem1D(void)=0
void setModelEntityID(unsigned long long id)
Definition SceneNodeBase.h:46
double getOffset(void)
Definition SceneNodeBase.h:77
void setSelectChildren(bool flag)
Definition SceneNodeBase.h:79
bool getManageVisibilityOfParent(void)
Definition SceneNodeBase.h:83
std::string getErrors(void)
Definition SceneNodeBase.h:74
virtual bool getSelectChildren(void)
Definition SceneNodeBase.h:80
void setTreeItemID(ot::UID iD)
Definition SceneNodeBase.h:43
virtual ~SceneNodeBase()
Definition SceneNodeBase.h:18
virtual void setSelected(bool _selected, bool _selectionFromNavigationTree)
Definition SceneNodeBase.h:56
void setParent(SceneNodeBase *item)
Definition SceneNodeBase.h:88
virtual void setTransparent(bool t)
Definition SceneNodeBase.h:64
bool getManageVisibilityOfChildren(void)
Definition SceneNodeBase.h:86
void setShapeNode(osg::Switch *node)
Definition SceneNodeBase.h:40
bool hasErrors(void)
Definition SceneNodeBase.h:73
void setName(const std::string &n)
Definition SceneNodeBase.h:37
void addVisualiser(Visualiser *_visualiser)
Definition SceneNodeBase.h:103
void removeChild(SceneNodeBase *child)
Definition SceneNodeBase.h:92
const std::list< Visualiser * > & getVisualiser()
Definition SceneNodeBase.h:104
bool isHighlighted(void)
Definition SceneNodeBase.h:69
void setOldTreeIcons(const OldTreeIcon &icons)
Definition SceneNodeBase.h:95
const std::list< SceneNodeBase * > & getChildren(void)
Definition SceneNodeBase.h:93
bool isWireframe(void)
Definition SceneNodeBase.h:66
virtual void setVisible(bool v)
Definition SceneNodeBase.h:53
const std::string & getName(void)
Definition SceneNodeBase.h:38
void setManageVisibilityOfParent(bool flag)
Definition SceneNodeBase.h:82
unsigned long long getModelEntityID(void)
Definition SceneNodeBase.h:47
void setErrors(std::string &e)
Definition SceneNodeBase.h:72
ot::UID getTreeItemID(void)
Definition SceneNodeBase.h:44
SceneNodeBase()
Definition SceneNodeBase.h:16
void setManageVisibilityOfChildren(bool flag)
Definition SceneNodeBase.h:85
osg::Switch * getShapeNode(void)
Definition SceneNodeBase.h:41
const float transparency
Definition SceneNodeBase.h:108
bool isSelected(void)
Definition SceneNodeBase.h:55
virtual bool isItem3D(void)=0
void addChild(SceneNodeBase *child)
Definition SceneNodeBase.h:91
const OldTreeIcon & getOldTreeIcons(void)
Definition SceneNodeBase.h:96
virtual void setEditable(bool v)
Definition SceneNodeBase.h:50
bool isTransparent(void)
Definition SceneNodeBase.h:63
virtual void setWireframe(bool w)
Definition SceneNodeBase.h:67
virtual void getPrefetch(std::string &projectName, std::list< std::pair< unsigned long long, unsigned long long > > &prefetchIDs)
Definition SceneNodeBase.h:98
bool isVisible(void)
Definition SceneNodeBase.h:52
void setOffset(double value)
Definition SceneNodeBase.h:76
Definition Visualiser.h:8
Definition RubberbandOsgWrapper.h:22
unsigned long UID
Unique identifier (32 bit unsigned integer)
Definition CoreTypes.h:27