DART 6.10.1
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
40
43
44namespace dart {
45namespace gui {
46namespace osg {
47
50{
51public:
52 enum class PlaneType : unsigned char
53 {
54 XY = 0u,
55 YZ = 1u,
56 ZX = 2u,
57 };
58
60 GridVisual();
61
63 void setNumCells(std::size_t cells);
64
66 std::size_t getNumCells() const;
67
69 void setMinorLineStepSize(double size);
70
72 double getMinorLineStepSize() const;
73
75 void setNumMinorLinesPerMajorLine(std::size_t size);
76
78 std::size_t getNumMinorLinesPerMajorLine() const;
79
82
84 PlaneType getPlaneType() const;
85
87 void setOffset(const Eigen::Vector3d& offset);
88
90 const Eigen::Vector3d& getOffset() const;
91
93 void display(bool display);
94
96 bool isDisplayed() const;
97
99 void setMajorLineColor(const Eigen::Vector4d& color);
100
102 Eigen::Vector4d getMajorLineColor() const;
103
105 void setMinorLineColor(const Eigen::Vector4d& color);
106
108 Eigen::Vector4d getMinorLineColor() const;
109
111 void setAxisLineWidth(float width);
112
114 float getAxisLineWidth() const;
115
117 void setMajorLineWidth(float width);
118
120 float getMajorLineWidth() const;
121
123 void setMinorLineWidth(float width);
124
126 float getMinorLineWidth() const;
127
129 void refresh() override final;
130
131protected:
133 void initialize();
134
137
139 std::size_t mNumCells;
140
143
146
148 Eigen::Vector3d mOffset;
149
152
154 ::osg::ref_ptr<::osg::Vec4Array> mAxisLineColor;
155
157 ::osg::ref_ptr<::osg::Vec4Array> mMajorLineColor;
158
160 ::osg::ref_ptr<::osg::Vec4Array> mMinorLineColor;
161
163 ::osg::ref_ptr<::osg::Geode> mGeode;
164
166 ::osg::ref_ptr<::osg::Geometry> mAxisLineGeom;
167
169 ::osg::ref_ptr<::osg::Geometry> mMajorLineGeom;
170
172 ::osg::ref_ptr<::osg::Geometry> mMinorLineGeom;
173
175 ::osg::ref_ptr<::osg::Vec3Array> mMinorLineVertices;
176
178 ::osg::ref_ptr<::osg::Vec3Array> mMajorLineVertices;
179
181 ::osg::ref_ptr<::osg::Vec3Array> mAxisLineVertices;
182
184 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis1PositiveFaces;
185
187 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis1NegativeFaces;
188
190 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis2PositiveFaces;
191
193 ::osg::ref_ptr<::osg::DrawElementsUInt> mAxis2NegativeFaces;
194
196 ::osg::ref_ptr<::osg::DrawElementsUInt> mMajorLineFaces;
197
199 ::osg::ref_ptr<::osg::DrawElementsUInt> mMinorLineFaces;
200
202 ::osg::ref_ptr<::osg::LineWidth> mAxisLineWidth;
203
205 ::osg::ref_ptr<::osg::LineWidth> mMajorLineWidth;
206
208 ::osg::ref_ptr<::osg::LineWidth> mMinorLineWidth;
209
212};
213
214} // namespace osg
215} // namespace gui
216} // namespace dart
217
218#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:50
::osg::ref_ptr<::osg::Vec3Array > mMajorLineVertices
Vertices of major lines.
Definition GridVisual.hpp:178
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:208
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:196
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:169
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:211
::osg::ref_ptr<::osg::Vec3Array > mMinorLineVertices
Vertices of axis lines.
Definition GridVisual.hpp:175
::osg::ref_ptr<::osg::Geometry > mAxisLineGeom
Geometry to describe axis lines.
Definition GridVisual.hpp:166
::osg::ref_ptr<::osg::Geode > mGeode
Geode to hold the grid.
Definition GridVisual.hpp:163
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis1NegativeFaces
Faces of the first axis negative line.
Definition GridVisual.hpp:187
::osg::ref_ptr<::osg::Vec3Array > mAxisLineVertices
Vertices of minor lines.
Definition GridVisual.hpp:181
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:160
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:53
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:151
std::size_t mNumMinorLinesPerMajorLine
Number of minor lines per major line.
Definition GridVisual.hpp:145
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:157
::osg::ref_ptr<::osg::LineWidth > mAxisLineWidth
Line width for axis line.
Definition GridVisual.hpp:202
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:199
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis1PositiveFaces
Faces of the first axis positive line.
Definition GridVisual.hpp:184
void refresh() override final
Updates the support polygon visual.
Definition GridVisual.cpp:418
double mMinorLineStepSize
Step size of minor lines in meters.
Definition GridVisual.hpp:142
::osg::ref_ptr<::osg::Geometry > mMinorLineGeom
Geometry to describe major lines.
Definition GridVisual.hpp:172
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:488
::osg::ref_ptr<::osg::LineWidth > mMajorLineWidth
Line width for major line.
Definition GridVisual.hpp:205
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:136
Eigen::Vector3d mOffset
Elevation that this visual should use.
Definition GridVisual.hpp:148
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis2PositiveFaces
Faces of the second axis positive line.
Definition GridVisual.hpp:190
::osg::ref_ptr<::osg::DrawElementsUInt > mAxis2NegativeFaces
Faces of the second axis negative line.
Definition GridVisual.hpp:193
::osg::ref_ptr<::osg::Vec4Array > mAxisLineColor
Color for axis lines.
Definition GridVisual.hpp:154
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:139
Definition Viewer.hpp:77
Definition Random-impl.hpp:92
Definition BulletCollisionDetector.cpp:65
Definition SharedLibraryManager.hpp:46