OpenStructure
Loading...
Searching...
No Matches
gfx_node.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_GFX_NODE_HH
20#define OST_GFX_NODE_HH
21
22/*
23 Author: Ansgar Philippsen
24*/
25
26#include <vector>
27
28#include <boost/enable_shared_from_this.hpp>
29
31
32#include "render_pass.hh"
33#include "gfx_node_fw.hh"
34#include "gfx_object_fw.hh"
35#include "gfx_node_visitor.hh"
36#include "povray_fw.hh"
37#include "exporter_fw.hh"
38
39namespace ost { namespace gfx {
40
41typedef std::vector<GfxNodeP> GfxNodeVector;
42
43class DLLEXPORT_OST_GFX GfxNode: public boost::enable_shared_from_this<GfxNode>
44{
45 public:
46
47 // initialize with a name
48 GfxNode(const String& name);
49
50 virtual ~GfxNode();
51
52 // deep copy interface
53 virtual GfxNodeP Copy() const;
54
55 virtual void DeepSwap(GfxNode& n);
56
57 // render all child leaves and nodes
58 virtual void RenderGL(RenderPass pass);
59
60 // render all child leaves and nodes into POVray state
61 virtual void RenderPov(PovState& pov);
62
63 virtual void Export(Exporter* ex);
64
65 // visitor interface
67
68 virtual int GetType() const;
69
70 // return name
71 String GetName() const;
72
73 // remove all child nodes
74 void RemoveAll();
75 // change name
76 void Rename(const String& name);
77
78 // add a graphical object - leaf
79 void Add(GfxObjP obj);
80
81
84 bool IsNameAvailable(const String& name) const;
85
86
87 // remove given graphical object
88 void Remove(GfxObjP obj);
89
90 // add another node - branch
91 void Add(GfxNodeP node);
92
93 // remove given node
94 void Remove(GfxNodeP node);
95
96 // remove obj or node of given name (or several if multiple matches)
97 void Remove(const String& name);
98
99 size_t GetChildCount() const;
100
101 // hide all child leafs and nodes
102 void Hide();
103 // display all child leafs and nodes
104 void Show();
105 // return visibility state
106 bool IsVisible() const;
107
108 virtual void ContextSwitch();
109
112 bool IsAttachedToScene() const;
113
114
116
117 const GfxNodeVector& GetChildren() const { return node_vector_; }
118 GfxNodeVector& GetChildren() { return node_vector_; }
119 private:
120 GfxNode(const GfxNode& o);
121 GfxNode& operator=(const GfxNode&);
122
123
124 String name_;
125 bool show_;
126 GfxNodeVector node_vector_;
127 boost::weak_ptr<GfxNode> parent_;
128};
129
130}}
131
132#endif
GfxNodeVector & GetChildren()
Definition gfx_node.hh:118
virtual void ContextSwitch()
String GetName() const
virtual int GetType() const
void Rename(const String &name)
void Add(GfxNodeP node)
GfxNode(const String &name)
void Remove(GfxNodeP node)
bool IsVisible() const
void Remove(const String &name)
void Remove(GfxObjP obj)
bool IsAttachedToScene() const
whether the node (or one of it's parents) has been added to the scene
void Add(GfxObjP obj)
bool IsNameAvailable(const String &name) const
returns true if no scene node of the given name is a child of this node.
virtual ~GfxNode()
virtual void RenderGL(RenderPass pass)
size_t GetChildCount() const
virtual void DeepSwap(GfxNode &n)
gfx::GfxNodeP GetParent() const
virtual void RenderPov(PovState &pov)
const GfxNodeVector & GetChildren() const
Definition gfx_node.hh:117
virtual void Export(Exporter *ex)
virtual void Apply(GfxNodeVisitor &v, GfxNodeVisitor::Stack st)
virtual GfxNodeP Copy() const
std::stack< GfxNode * > Stack
#define DLLEXPORT_OST_GFX
std::string String
Definition base.hh:54
boost::shared_ptr< GfxNode > GfxNodeP
std::vector< GfxNodeP > GfxNodeVector
Definition gfx_node.hh:41
boost::shared_ptr< GfxObj > GfxObjP
Definition base.dox:1