DART 6.12.2
Loading...
Searching...
No Matches
GridVisual.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_GUI_OSG_GRIDVISUAL_HPP_
34#define DART_GUI_OSG_GRIDVISUAL_HPP_
35
36#include <osg/Geode>
37#include <osg/LineWidth>
38
42
43namespace dart {
44namespace gui {
45namespace osg {
46
49{
50public:
51 enum class PlaneType : unsigned char
52 {
53 XY = 0u,
54 YZ = 1u,
55 ZX = 2u,
56 };
57
59 GridVisual();
60
62 void setNumCells(std::size_t cells);
63
65 std::size_t getNumCells() const;
66
68 void setMinorLineStepSize(double size);
69
71 double getMinorLineStepSize() const;
72
74 void setNumMinorLinesPerMajorLine(std::size_t size);
75
77 std::size_t getNumMinorLinesPerMajorLine() const;
78
81
83 PlaneType getPlaneType() const;
84
86 void setOffset(const Eigen::Vector3d& offset);
87
89 const Eigen::Vector3d& getOffset() const;
90
92 void display(bool display);
93
95 bool isDisplayed() const;
96
98 void setMajorLineColor(const Eigen::Vector4d& color);
99
101 Eigen::Vector4d getMajorLineColor() const;
102
104 void setMinorLineColor(const Eigen::Vector4d& color);
105
107 Eigen::Vector4d getMinorLineColor() const;
108
110 void setAxisLineWidth(float width);
111
113 float getAxisLineWidth() const;
114
116 void setMajorLineWidth(float width);
117
119 float getMajorLineWidth() const;
120
122 void setMinorLineWidth(float width);
123
125 float getMinorLineWidth() const;
126
128 void refresh() override final;
129
130protected:
132 void initialize();
133
136
138 std::size_t mNumCells;
139
142
145
147 Eigen::Vector3d mOffset;
148
151
153 ::osg::ref_ptr<::osg::Vec4Array> mAxisLineColor;
154
156 ::osg::ref_ptr<::osg::Vec4Array> mMajorLineColor;
157
159 ::osg::ref_ptr<::osg::Vec4Array> mMinorLineColor;
160
162 ::osg::ref_ptr<::osg::Geode> mGeode;
163
165 ::osg::ref_ptr<::osg::Geometry> mAxisLineGeom;
166
168 ::osg::ref_ptr<::osg::Geometry> mMajorLineGeom;
169
171 ::osg::ref_ptr<::osg::Geometry> mMinorLineGeom;
172
174 ::osg::ref_ptr<::osg::Vec3Array> mMinorLineVertices;
175
177 ::osg::ref_ptr<::osg::Vec3Array> mMajorLineVertices;
178
180 ::osg::ref_ptr<::osg::Vec3Array> mAxisLineVertices;
181
183 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis1PositiveFaces;
184
186 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis1NegativeFaces;
187
189 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis2PositiveFaces;
190
192 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis2NegativeFaces;
193
195 ::osg::ref_ptr<::osg::DrawElementsUInt> mMajorLineFaces;
196
198 ::osg::ref_ptr<::osg::DrawElementsUInt> mMinorLineFaces;
199
201 ::osg::ref_ptr<::osg::LineWidth> mAxisLineWidth;
202
204 ::osg::ref_ptr<::osg::LineWidth> mMajorLineWidth;
205
207 ::osg::ref_ptr<::osg::LineWidth> mMinorLineWidth;
208
211};
212
213} // namespace osg
214} // namespace gui
215} // namespace dart
216
217#endif // DART_GUI_OSG_GRIDVISUAL_HPP_
std::string type
Definition SdfParser.cpp:82
Attach this to a Viewer in order to visualize grid.
Definition GridVisual.hpp:49
::osg::ref_ptr<::osg::Vec3Array > mMajorLineVertices
Vertices of major lines.
Definition GridVisual.hpp:177
PlaneType getPlaneType() const
Returns the plane type among XY, YZ, ZX planes.
Definition GridVisual.cpp:113
const Eigen::Vector3d & getOffset() const
Returns the elevation of display for the support polygon.
Definition GridVisual.cpp:129
::osg::ref_ptr<::osg::LineWidth > mMinorLineWidth
Line width for minor line.
Definition GridVisual.hpp:207
void setAxisLineWidth(float width)
Sets line width for axis lines.
Definition GridVisual.cpp:193
void setNumMinorLinesPerMajorLine(std::size_t size)
Sets the number of minor lines per major line.
Definition GridVisual.cpp:87
float getMajorLineWidth() const
Returns line width for major lines.
Definition GridVisual.cpp:219
void display(bool display)
Displays the support polygon.
Definition GridVisual.cpp:135
::osg::ref_ptr<::osg::DrawElementsUInt > mMajorLineFaces
Faces of major lines.
Definition GridVisual.hpp:195
float getMinorLineWidth() const
Returns line width for minor lines.
Definition GridVisual.cpp:235
void setPlaneType(PlaneType type)
Set the plane type among XY, YZ, ZX planes.
Definition GridVisual.cpp:103
::osg::ref_ptr<::osg::Geometry > mMajorLineGeom
Geometry to describe minor lines.
Definition GridVisual.hpp:168
void setMajorLineWidth(float width)
Sets line width for major lines.
Definition GridVisual.cpp:209
bool mNeedUpdate
Dirty flag to notify this grid needs to be updated.
Definition GridVisual.hpp:210
::osg::ref_ptr<::osg::Vec3Array > mMinorLineVertices
Vertices of axis lines.
Definition GridVisual.hpp:174
::osg::ref_ptr<::osg::Geometry > mAxisLineGeom
Geometry to describe axis lines.
Definition GridVisual.hpp:165
::osg::ref_ptr<::osg::Geode > mGeode
Geode to hold the grid.
Definition GridVisual.hpp:162
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis1NegativeFaces
Faces of the first axis negative line.
Definition GridVisual.hpp:186
::osg::ref_ptr<::osg::Vec3Array > mAxisLineVertices
Vertices of minor lines.
Definition GridVisual.hpp:180
std::size_t getNumMinorLinesPerMajorLine() const
Returns the number of minor lines per major line.
Definition GridVisual.cpp:97
double getMinorLineStepSize() const
Returns the step size of minor lines in meters.
Definition GridVisual.cpp:81
::osg::ref_ptr<::osg::Vec4Array > mMinorLineColor
Color for minor lines.
Definition GridVisual.hpp:159
void setNumCells(std::size_t cells)
Sets the number of cells along each axis.
Definition GridVisual.cpp:52
GridVisual()
Default constructor.
Definition GridVisual.cpp:46
void setMinorLineStepSize(double size)
Sets the step size of minor lines in meters.
Definition GridVisual.cpp:68
PlaneType
Definition GridVisual.hpp:52
bool isDisplayed() const
Returns true if the support polygon is being displayed.
Definition GridVisual.cpp:149
bool mDisplayGrid
Whether to display the grid.
Definition GridVisual.hpp:150
std::size_t mNumMinorLinesPerMajorLine
Number of minor lines per major line.
Definition GridVisual.hpp:144
void setOffset(const Eigen::Vector3d &offset)
Changes the offset at which the grid is displayed.
Definition GridVisual.cpp:119
Eigen::Vector4d getMinorLineColor() const
Returns the color of minor lines.
Definition GridVisual.cpp:186
::osg::ref_ptr<::osg::Vec4Array > mMajorLineColor
Color for major lines.
Definition GridVisual.hpp:156
::osg::ref_ptr<::osg::LineWidth > mAxisLineWidth
Line width for axis line.
Definition GridVisual.hpp:201
float getAxisLineWidth() const
Returns line width for axis lines.
Definition GridVisual.cpp:203
void setMajorLineColor(const Eigen::Vector4d &color)
Sets the color of major lines.
Definition GridVisual.cpp:155
Eigen::Vector4d getMajorLineColor() const
Returns the color of major lines.
Definition GridVisual.cpp:167
::osg::ref_ptr<::osg::DrawElementsUInt > mMinorLineFaces
Faces of minor lines.
Definition GridVisual.hpp:198
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis1PositiveFaces
Faces of the first axis positive line.
Definition GridVisual.hpp:183
void refresh() override final
Updates the support polygon visual.
Definition GridVisual.cpp:415
double mMinorLineStepSize
Step size of minor lines in meters.
Definition GridVisual.hpp:141
::osg::ref_ptr<::osg::Geometry > mMinorLineGeom
Geometry to describe major lines.
Definition GridVisual.hpp:171
void setMinorLineColor(const Eigen::Vector4d &color)
Sets the color of minor lines.
Definition GridVisual.cpp:174
void initialize()
Initializes the memory used by this visual.
Definition GridVisual.cpp:482
::osg::ref_ptr<::osg::LineWidth > mMajorLineWidth
Line width for major line.
Definition GridVisual.hpp:204
std::size_t getNumCells() const
Returns the number of cells along each axis.
Definition GridVisual.cpp:62
PlaneType mPlaneType
Plane type among XY, YZ, ZX planes.
Definition GridVisual.hpp:135
Eigen::Vector3d mOffset
Elevation that this visual should use.
Definition GridVisual.hpp:147
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis2PositiveFaces
Faces of the second axis positive line.
Definition GridVisual.hpp:189
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis2NegativeFaces
Faces of the second axis negative line.
Definition GridVisual.hpp:192
::osg::ref_ptr<::osg::Vec4Array > mAxisLineColor
Color for axis lines.
Definition GridVisual.hpp:153
void setMinorLineWidth(float width)
Sets line width for minor lines.
Definition GridVisual.cpp:225
std::size_t mNumCells
Number of cells along each axis.
Definition GridVisual.hpp:138
Definition Viewer.hpp:76
Definition Random-impl.hpp:92
Definition BulletCollisionDetector.cpp:60
Definition SharedLibraryManager.hpp:46