Directory: | ./ |
---|---|
File: | include/gepetto/viewer/config-osg.h |
Date: | 2025-01-14 11:10:37 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 8 | 9 | 88.9% |
Branches: | 7 | 20 | 35.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // config-osg.h | ||
3 | // gepetto-viewer | ||
4 | // | ||
5 | // Created by Justin Carpentier on 06/02/2014. | ||
6 | // Modified by Mathieu Geisert in November 2014. | ||
7 | // Copyright (c) 2014 LAAS-CNRS. All rights reserved. | ||
8 | // | ||
9 | |||
10 | #ifndef DynAndGraph_config_h | ||
11 | #define DynAndGraph_config_h | ||
12 | |||
13 | #include <gepetto/viewer/fwd.h> | ||
14 | #include <gepetto/viewer/macros.h> | ||
15 | |||
16 | #include <QMetaType> | ||
17 | #include <osg/AlphaFunc> | ||
18 | #include <osg/AutoTransform> | ||
19 | #include <osg/BlendFunc> | ||
20 | #include <osg/Camera> | ||
21 | #include <osg/ClearNode> | ||
22 | #include <osg/Depth> | ||
23 | #include <osg/Geode> | ||
24 | #include <osg/Geometry> | ||
25 | #include <osg/GraphicsContext> | ||
26 | #include <osg/Group> | ||
27 | #include <osg/Light> | ||
28 | #include <osg/LightSource> | ||
29 | #include <osg/LineWidth> | ||
30 | #include <osg/Material> | ||
31 | #include <osg/MatrixTransform> | ||
32 | #include <osg/Node> | ||
33 | #include <osg/PolygonMode> | ||
34 | #include <osg/PositionAttitudeTransform> | ||
35 | #include <osg/Shape> | ||
36 | #include <osg/ShapeDrawable> | ||
37 | #include <osg/State> | ||
38 | #include <osg/StateSet> | ||
39 | #include <osg/Switch> | ||
40 | #include <osg/Viewport> | ||
41 | #include <osgViewer/Viewer> | ||
42 | #include <osgViewer/ViewerBase> | ||
43 | |||
44 | namespace osg { | ||
45 | |||
46 | DEF_CLASS_SMART_PTR(Geode) | ||
47 | |||
48 | DEF_OSG_CLASS_REF_PTR(Sphere) | ||
49 | DEF_OSG_CLASS_REF_PTR(Box) | ||
50 | DEF_OSG_CLASS_REF_PTR(Cone) | ||
51 | DEF_OSG_CLASS_REF_PTR(Cylinder) | ||
52 | DEF_OSG_CLASS_REF_PTR(Capsule) | ||
53 | DEF_OSG_CLASS_REF_PTR(ShapeDrawable) | ||
54 | DEF_OSG_CLASS_REF_PTR(Geometry) | ||
55 | DEF_OSG_CLASS_REF_PTR(LineWidth) | ||
56 | |||
57 | DEF_OSG_CLASS_REF_PTR(Geode) | ||
58 | DEF_OSG_CLASS_REF_PTR(PositionAttitudeTransform) | ||
59 | DEF_OSG_CLASS_REF_PTR(AutoTransform) | ||
60 | DEF_OSG_CLASS_REF_PTR(MatrixTransform) | ||
61 | DEF_OSG_CLASS_REF_PTR(Light) | ||
62 | DEF_OSG_CLASS_REF_PTR(LightSource) | ||
63 | |||
64 | DEF_OSG_CLASS_REF_PTR(Node) | ||
65 | DEF_OSG_CLASS_REF_PTR(Group) | ||
66 | DEF_OSG_CLASS_REF_PTR(Switch) | ||
67 | DEF_OSG_CLASS_REF_PTR(ClearNode) | ||
68 | |||
69 | DEF_OSG_CLASS_REF_PTR(Depth) | ||
70 | |||
71 | DEF_OSG_CLASS_REF_PTR(AlphaFunc) | ||
72 | DEF_OSG_CLASS_REF_PTR(BlendFunc) | ||
73 | DEF_OSG_CLASS_REF_PTR(StateSet) | ||
74 | |||
75 | DEF_OSG_CLASS_REF_PTR(State) | ||
76 | DEF_OSG_CLASS_REF_PTR(StateSet) | ||
77 | |||
78 | DEF_OSG_CLASS_REF_PTR(Material) | ||
79 | |||
80 | DEF_OSG_CLASS_REF_PTR(Camera) | ||
81 | DEF_OSG_CLASS_REF_PTR(Viewport) | ||
82 | DEF_OSG_CLASS_REF_PTR(GraphicsContext) | ||
83 | |||
84 | DEF_OSG_CLASS_REF_PTR(Vec3Array) | ||
85 | DEF_OSG_CLASS_REF_PTR(Vec4Array) | ||
86 | |||
87 | DEF_OSG_CLASS_REF_PTR(PolygonMode) | ||
88 | |||
89 | typedef ::osg::ref_ptr<GraphicsContext::Traits> TraitsRefPtr; | ||
90 | |||
91 | } /* namespace osg */ | ||
92 | |||
93 | namespace osgViewer { | ||
94 | DEF_OSG_CLASS_REF_PTR(Viewer) | ||
95 | |||
96 | } /* namespace osgViewer */ | ||
97 | |||
98 | typedef ::osg::Vec2f osgVector2; | ||
99 | typedef ::osg::Vec3f osgVector3; | ||
100 | typedef ::osg::Vec4f osgVector4; | ||
101 | |||
102 | typedef ::osg::Quat osgQuat; | ||
103 | |||
104 | namespace gepetto { | ||
105 | namespace viewer { | ||
106 | |||
107 | enum VisibilityMode { VISIBILITY_OFF = 0, VISIBILITY_ON = 1, ALWAYS_ON_TOP }; | ||
108 | |||
109 | enum LightingMode { LIGHT_INFLUENCE_OFF = 0, LIGHT_INFLUENCE_ON = 1 }; | ||
110 | |||
111 | enum WireFrameMode { FILL = 0, WIREFRAME, FILL_AND_WIREFRAME }; | ||
112 | |||
113 | enum FaceMode { FACE = 0, EDGE, FACE_AND_EDGE }; | ||
114 | |||
115 | struct Configuration { | ||
116 | osgVector3 position; | ||
117 | osgQuat quat; | ||
118 | 5 | Configuration() {} | |
119 | /// \param XYZW when false, the 4 last parameters are a quaternion (w,x,y,z) | ||
120 | /// otherwise, a quaternion (x,y,z,w) | ||
121 | explicit Configuration(const float* a, bool XYZW) | ||
122 | : position(a[0], a[1], a[2]), | ||
123 | quat(a[(XYZW ? 3 : 4)], a[(XYZW ? 4 : 5)], a[(XYZW ? 5 : 6)], | ||
124 | a[(XYZW ? 6 : 3)]) {} | ||
125 | 4 | Configuration(const osgVector3& p, const osgQuat& q) : position(p), quat(q) {} | |
126 | |||
127 | bool operator==(const Configuration& other) const { | ||
128 | return position == other.position && quat == other.quat; | ||
129 | } | ||
130 | |||
131 | 7 | bool operator!=(const Configuration& other) const { | |
132 |
3/4✓ Branch 1 taken 1 times.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
7 | return position != other.position || quat != other.quat; |
133 | } | ||
134 | |||
135 | ✗ | bool valid() const { return position.valid() && quat.asVec4().valid(); } | |
136 | }; | ||
137 | |||
138 | } /* namespace viewer */ | ||
139 | } /* namespace gepetto */ | ||
140 | |||
141 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | Q_DECLARE_METATYPE(osgVector2) |
142 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | Q_DECLARE_METATYPE(osgVector3) |
143 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | Q_DECLARE_METATYPE(osgVector4) |
144 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | Q_DECLARE_METATYPE(gepetto::viewer::Configuration) |
145 | |||
146 | #endif | ||
147 |