Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StatusViewNodeT.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision: 18128 $ *
45 * $LastChangedBy: moebius $ *
46 * $Date: 2014-02-05 10:20:28 +0100 (Wed, 05 Feb 2014) $ *
47 * *
48 \*===========================================================================*/
49
50
51 //=============================================================================
52 //
53 // StatusViewNode: Combined rendering of multiple Status Nodes
54 //
55 //=============================================================================
56
57 #ifndef STATUSVIEWNODE_C
58 #define STATUSVIEWNODE_C
59
60 //== INCLUDES =================================================================
61
62 #include "StatusViewNodeT.hh"
63 #include <ACG/Scenegraph/DrawModes.hh>
64
65 namespace ACG
66 {
67 namespace SceneGraph
68 {
69
70
71 //== IMPLEMENTATION ==========================================================
72
73 template<class MeshT>
74 StatusViewNodeT<MeshT>::StatusViewNodeT(
75 BaseNode* _parent,
76 const std::string& _name,
77 ACG::SceneGraph::SelectionNodeT<MeshT>* _statusNode,
78 ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> >* _areaNode,
79 ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> >* _handleNode,
80 ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> >* _featureNode)
81 : BaseNode(_parent, _name),
82 statusNode_(_statusNode),
83 areaNode_(_areaNode),
84 handleNode_(_handleNode),
85 featureNode_(_featureNode),
86 statusNodeVis_(false),
87 areaNodeVis_(false),
88 handleNodeVis_(false),
89 featureNodeVis_(false)
90 {
91 }
92
93 //----------------------------------------------------------------------------
94
95 template <class MeshT>
96 void StatusViewNodeT<MeshT>::draw( GLState& _state, const DrawModes::DrawMode& _drawMode )
97 {
98 // extract all layers from drawmode
99
100 DrawModes::DrawMode singleLayers[4]; // polygon, edge, halfedge, point
101
102 // remove default property layer
103 for (int i = 0; i < 4; ++i)
104 singleLayers[i].removeLayer(0u);
105
106 for (unsigned int i = 0; i < _drawMode.getNumLayers(); ++i)
107 {
108 const DrawModes::DrawModeProperties* props = _drawMode.getLayer(i);
109
110 switch (props->primitive())
111 {
112 case DrawModes::PRIMITIVE_POLYGON: singleLayers[0].setDrawModeProperties(props); break;
113 case DrawModes::PRIMITIVE_EDGE: singleLayers[1].setDrawModeProperties(props); break;
114 case DrawModes::PRIMITIVE_HALFEDGE: singleLayers[2].setDrawModeProperties(props); break;
115 case DrawModes::PRIMITIVE_POINT: singleLayers[3].setDrawModeProperties(props); break;
116 default: break;
117 }
118 }
119
120 // rendering order: faces -> edges -> halfedges -> points
121 // area -> handle -> feature -> selections
122 for (int i = 0; i < 4; ++i)
123 {
124
125 if (singleLayers[i].getNumLayers() == 0)
126 {
127 DrawModes::DrawModeProperties defaultProps;
128
129 switch (i)
130 {
131 case 0: defaultProps.primitive(DrawModes::PRIMITIVE_POLYGON); break;
132 case 1: defaultProps.primitive(DrawModes::PRIMITIVE_EDGE); break;
133 case 2: defaultProps.primitive(DrawModes::PRIMITIVE_HALFEDGE); break;
134 case 3: defaultProps.primitive(DrawModes::PRIMITIVE_POINT); break;
135 default: break;
136 }
137
138 singleLayers[i].addLayer(&defaultProps);
139 }
140
141 // call enter() and leave() to setup the correct material
142
143 if (areaNodeVis_)
144 {
145 areaNode_->enter(_state, singleLayers[i]);
146 areaNode_->draw(_state, singleLayers[i]);
147 areaNode_->leave(_state, singleLayers[i]);
148 }
149
150 if (handleNodeVis_)
151 {
152 handleNode_->enter(_state, singleLayers[i]);
153 handleNode_->draw(_state, singleLayers[i]);
154 handleNode_->leave(_state, singleLayers[i]);
155 }
156
157 if (featureNodeVis_)
158 {
159 featureNode_->enter(_state, singleLayers[i]);
160 featureNode_->draw(_state, singleLayers[i]);
161 featureNode_->leave(_state, singleLayers[i]);
162 }
163
164 if (statusNodeVis_)
165 {
166 statusNode_->enter(_state, singleLayers[i]);
167 statusNode_->draw(_state, singleLayers[i]);
168 statusNode_->leave(_state, singleLayers[i]);
169 }
170 }
171
172 }
173
174 //----------------------------------------------------------------------------
175
176 template <class MeshT>
177 void StatusViewNodeT<MeshT>::getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat)
178 {
179
180
181
182 // extract all layers from drawmode
183
184 DrawModes::DrawMode singleLayers[4]; // polygon, edge, halfedge, point
185
186 // remove default property layer
187 for (int i = 0; i < 4; ++i)
188 singleLayers[i].removeLayer(0u);
189
190 for (unsigned int i = 0; i < _drawMode.getNumLayers(); ++i)
191 {
192 const DrawModes::DrawModeProperties* props = _drawMode.getLayer(i);
193
194 switch (props->primitive())
195 {
196 case DrawModes::PRIMITIVE_POLYGON: singleLayers[0].setDrawModeProperties(props); break;
197 case DrawModes::PRIMITIVE_EDGE: singleLayers[1].setDrawModeProperties(props); break;
198 case DrawModes::PRIMITIVE_HALFEDGE: singleLayers[2].setDrawModeProperties(props); break;
199 case DrawModes::PRIMITIVE_POINT: singleLayers[3].setDrawModeProperties(props); break;
200 default: break;
201 }
202 }
203
204 // rendering order: faces -> edges -> halfedges -> points
205 // area -> handle -> feature -> selections
206 // rendering order only depends on priority in render objects
207 for (int i = 0; i < 4; ++i)
208 {
209
210 if (singleLayers[i].getNumLayers() == 0)
211 {
212 DrawModes::DrawModeProperties defaultProps;
213
214 switch (i)
215 {
216 case 0: defaultProps.primitive(DrawModes::PRIMITIVE_POLYGON); break;
217 case 1: defaultProps.primitive(DrawModes::PRIMITIVE_EDGE); break;
218 case 2: defaultProps.primitive(DrawModes::PRIMITIVE_HALFEDGE); break;
219 case 3: defaultProps.primitive(DrawModes::PRIMITIVE_POINT); break;
220 default: break;
221 }
222
223 singleLayers[i].addLayer(&defaultProps);
224 }
225
226 if (statusNodeVis_)
227 statusNode_->getRenderObjects(_renderer, _state, singleLayers[i], _mat);
228
229 if (areaNodeVis_)
230 areaNode_->getRenderObjects(_renderer, _state, singleLayers[i], _mat);
231
232 if (handleNodeVis_)
233 handleNode_->getRenderObjects(_renderer, _state, singleLayers[i], _mat);
234
235 if (featureNodeVis_)
236 featureNode_->getRenderObjects(_renderer, _state, singleLayers[i], _mat);
237 }
238 }
239
240
241 //----------------------------------------------------------------------------
242
243 template <class MeshT>
244 void StatusViewNodeT<MeshT>::enter( GLState& _state, const DrawModes::DrawMode& _drawmode )
245 {
246 statusNodeVis_ = statusNode_ && statusNode_->visible();
247 areaNodeVis_ = areaNode_ && areaNode_->visible();
248 handleNodeVis_ = handleNode_ && handleNode_->visible();
249 featureNodeVis_ = featureNode_ && featureNode_->visible();
250
251 // these nodes are manually rendered in this StatusViewNode
252 // hide nodes to prevent drawing them again in the same draw traversal
253
254 if (statusNodeVis_)
255 statusNode_->hide();
256 if (areaNodeVis_)
257 areaNode_->hide();
258 if (handleNodeVis_)
259 handleNode_->hide();
260 if (featureNodeVis_)
261 featureNode_->hide();
262 }
263
264 //----------------------------------------------------------------------------
265
266 template <class MeshT>
267 void StatusViewNodeT<MeshT>::leave( GLState& _state, const DrawModes::DrawMode& _drawmode )
268 {
269 if (statusNodeVis_)
270 statusNode_->show();
271 if (areaNodeVis_)
272 areaNode_->show();
273 if (handleNodeVis_)
274 handleNode_->show();
275 if (featureNodeVis_)
276 featureNode_->show();
277 }
278
279
280 }
281 }
282
283 #endif // STATUSVIEWNODE_C
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
FeatureNodeMod
Definition: StatusNodeMods.hh:203
ACG::SceneGraph::BaseNode::enter
virtual void enter(GLState &, const DrawModes::DrawMode &)
Definition: BaseNode.hh:182
ACG::SceneGraph::SelectionNodeT< MeshT >
HandleNodeMod
Definition: StatusNodeMods.hh:130
AreaNodeMod
Definition: StatusNodeMods.hh:81
ACG::SceneGraph::StatusNodeT
Definition: StatusNodesT.hh:183