gepetto-viewer 6.0.0
An user-friendly Graphical Interface
Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1//
2// node.h
3// gepetto-viewer
4//
5// Created by Justin Carpentier, Mathieu Geisert in November 2014.
6// Copyright (c) 2014 LAAS-CNRS. All rights reserved.
7//
8
9#ifndef GEPETTO_VIEWER_NODE_HH
10#define GEPETTO_VIEWER_NODE_HH
11
13#include <gepetto/viewer/fwd.h>
16
17#include <iostream>
18
19namespace gepetto {
20namespace viewer {
21
22enum { VisibilityBit = 1 << 0, IntersectionBit = 1 << 1, NodeBit = 1 << 2 };
23
25class Node : public Properties {
26 private:
27 friend struct NodeTest;
28
29 std::string id_name_; // automoatic id generated by the program
30 bool dirty_;
31
33 osg::MatrixTransformRefPtr transform_ptr_;
35 osg::Matrixf Ms_;
37
40 osg::GroupRefPtr switch_node_ptr_;
41 WireFrameMode selected_wireframe_;
42 std::vector< ::osg::GroupRefPtr> wireframe_modes_;
43
44 osg::GroupRefPtr hl_switch_node_ptr_;
45 std::size_t selected_highlight_;
46 bool highlight_enabled_;
47 std::vector< ::osg::GroupRefPtr> highlight_nodes_;
48
49 VisibilityMode visibilityMode_;
50 LightingMode lightingMode_;
51
53 void init();
54
55 void updateTransform();
56
57 ::osg::Group* setupHighlightState(unsigned int state);
58
59 protected:
61 ::osg::GeodeRefPtr landmark_geode_ptr_;
62
64 ::osg::GeodeRefPtr geode_ptr_;
66 float alpha_;
67
71 Node(const std::string& name);
72
74 Node(const Node& other);
75
79 ::osg::GroupRefPtr asQueue() const { return transform_ptr_; }
80
81 void setID(const std::string& id_name) {
82 id_name_ = id_name;
83 switch_node_ptr_->setName(id_name_);
84 }
85
86 void setTransparentRenderingBin(bool transparent = true,
87 osg::StateSet* ss = NULL);
88
89 public:
91
97
101 std::string getID() const { return id_name_; }
102
103 bool isDirty() const { return dirty_; }
104
105 void setDirty(bool dirty = true) { dirty_ = dirty; }
106
109 bool isSelectable() const {
110 return transform_ptr_->getNodeMask() & IntersectionBit;
111 }
112
115 void setSelectable(bool selectable = true);
116
119 inline void applyConfiguration(const osgVector3& position,
120 const osgQuat& quat) {
121 applyConfiguration(Configuration(position, quat));
122 }
123
126 void applyConfiguration(const Configuration& cfg) { M_.set(cfg); }
127
130 void setStaticTransform(const osgVector3& position, const osgQuat& quat);
131
135
139
144 virtual void setVisibilityMode(const VisibilityMode& visibility_state);
145
146 virtual const VisibilityMode& getVisibilityMode() const {
147 return visibilityMode_;
148 }
149
154 virtual void setLightingMode(const LightingMode& lighting_state);
155
157
162 virtual void setWireFrameMode(const WireFrameMode& wireframe_state);
163
164 virtual const WireFrameMode& getWireFrameMode() const {
165 return selected_wireframe_;
166 }
167
169 void setScale(float scale) { setScale(osgVector3(scale, scale, scale)); }
170
172 void setScale(const osgVector3& scale) { scale_.set(scale); }
173
176 osgVector3 getScale() const { return scale_.value; }
177
179 virtual void setColor(const osgVector4& color) = 0;
180
181 virtual osg::ref_ptr<osg::Node> getOsgNode() const;
182
186 virtual ::osg::GroupRefPtr asGroup() const { return switch_node_ptr_; }
187
188 virtual void addLandmark(const float& size);
189
190 bool hasLandmark() const;
191
192 ::osg::StateSetRefPtr getOrCreateRootStateSet() {
193 return switch_node_ptr_->getOrCreateStateSet();
194 }
195
197
198 bool getHighlightEnabled() const { return highlight_enabled_; }
199
200 void setHighlightEnabled(bool enabled) {
202 highlight_enabled_ = enabled;
203 }
204
205 void setHighlightState(unsigned int state);
206
207 const std::size_t& getHighlightState() const { return selected_highlight_; }
208
209 /*Tools::ConfigurationPtr_t getConfiguration () const
210 {
211 Tools::ConfigurationPtr_t configuration =
212 Tools::Configuration::create(toDefVector3(auto_transform_ptr_->getPosition()),toEigenQuat(auto_transform_ptr_->getRotation()));
213 return configuration;
214 }*/
215
216 virtual void setAlpha(const float& alpha);
217 virtual float getAlpha() const;
218
219 void setTransparency(const float& transparency);
220 float getTransparency() const;
221
223 virtual void traverse(NodeVisitor& visitor);
224
225 /* Destructor */
226 virtual ~Node();
227
228}; /* class Node */
229
230} /* namespace viewer */
231} /* namespace gepetto */
232
233#endif /* dGEPETTO_VIEWER_NODE_HH */
Definition node-visitor.h:35
Abstract base class of 3D objects in a scene.
Definition node.h:25
bool hasLandmark() const
virtual ::osg::GroupRefPtr asGroup() const
Return the root node to include it in the scene.
Definition node.h:186
void setDirty(bool dirty=true)
Called when a property is modified.
Definition node.h:105
bool isSelectable() const
Definition node.h:109
void setSelectable(bool selectable=true)
void setScale(float scale)
Definition node.h:169
virtual void traverse(NodeVisitor &visitor)
virtual void setColor(const osgVector4 &color)=0
virtual const WireFrameMode & getWireFrameMode() const
Definition node.h:164
virtual const VisibilityMode & getVisibilityMode() const
Definition node.h:146
static const float TransparencyRenderingBinThreshold
Definition node.h:90
void applyConfiguration(const osgVector3 &position, const osgQuat &quat)
Definition node.h:119
friend struct NodeTest
Definition node.h:27
Node(const Node &other)
virtual osg::ref_ptr< osg::Node > getOsgNode() const
virtual float getAlpha() const
Node(const std::string &name)
Default constructor.
virtual void setWireFrameMode(const WireFrameMode &wireframe_state)
Virtual method for setting the wireframe mode of the object : visible or not.
osgVector3 getStaticPosition() const
virtual LightingMode getLightingMode() const
osgQuat getStaticRotation() const
void setID(const std::string &id_name)
Definition node.h:81
virtual void setAlpha(const float &alpha)
float alpha_
Definition node.h:66
osgVector3 getScale() const
Definition node.h:176
float getTransparency() const
std::string getID() const
getID is a public method for getting the id_name of the Object
Definition node.h:101
::osg::GeodeRefPtr landmark_geode_ptr_
Definition node.h:61
void setTransparentRenderingBin(bool transparent=true, osg::StateSet *ss=NULL)
virtual void addLandmark(const float &size)
void setTransparency(const float &transparency)
::osg::StateSetRefPtr getOrCreateRootStateSet()
Definition node.h:192
void setHighlightState(unsigned int state)
void applyConfiguration(const Configuration &cfg)
Definition node.h:126
::osg::GroupRefPtr asQueue() const
Return the root node to include it in the scene.
Definition node.h:79
const std::size_t & getHighlightState() const
Definition node.h:207
void setScale(const osgVector3 &scale)
Definition node.h:172
void setStaticTransform(const osgVector3 &position, const osgQuat &quat)
virtual void setVisibilityMode(const VisibilityMode &visibility_state)
Virtual method for setting the visibility mode of the object : visible or not visible.
void setHighlightEnabled(bool enabled)
Definition node.h:200
SCENE_VIEWER_ACCEPT_VISITOR
Definition node.h:222
::osg::GeodeRefPtr geode_ptr_
Definition node.h:64
bool isDirty() const
Definition node.h:103
virtual void setLightingMode(const LightingMode &lighting_state)
Virtual method for setting the lighting mode of the object : influence by light or not.
bool getHighlightEnabled() const
Definition node.h:198
const Configuration & getGlobalTransform() const
returns rotation and position of the node in word frame
Definition node-property.h:605
Definition node-property.h:522
Definition node-property.h:480
T value
Definition node-property.h:503
::osg::Vec3f osgVector3
Definition config-osg.h:99
::osg::Quat osgQuat
Definition config-osg.h:102
::osg::Vec4f osgVector4
Definition config-osg.h:100
LightingMode
Definition config-osg.h:109
@ NodeBit
Definition node.h:22
@ IntersectionBit
Definition node.h:22
@ VisibilityBit
Definition node.h:22
WireFrameMode
Definition config-osg.h:111
VisibilityMode
Definition config-osg.h:107
Definition action-search-bar.hh:27
Definition config-osg.h:115