Developer Documentation
FloatingSubtreeNode.cc
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2016, 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  * This class is available on C++11 compilers only.
44  */
45 #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
46 
47 #include "../../ACG/Scenegraph/FloatingSubtreeNode.hh"
48 
49 #include <ACG/GL/IRenderer.hh>
50 
51 namespace ACG {
52 namespace SceneGraph {
53 
54 FloatingSubtreeNode::FloatingSubtreeNode(
55  GLMatrixd modelview_override,
56  BaseNode *_parent, const std::string &_name)
57 
58  : BaseNode(_parent, _name),
59  modelview_override_(std::move(modelview_override)),
60  enable_modelview_override_(true),
61  enable_overlay_(true) {
62 
63  modelview_override_inv_ = modelview_override_;
64  modelview_override_inv_.invert();
65 }
66 
67 FloatingSubtreeNode::~FloatingSubtreeNode() {
68 
69 }
70 
71 void FloatingSubtreeNode::enter(GLState &_state,
72  const DrawModes::DrawMode &_drawMode) {
73  if (enable_modelview_override_) {
74  _state.push_modelview_matrix();
75  _state.set_modelview(modelview_override_, modelview_override_inv_);
76  }
77 }
78 
79 void FloatingSubtreeNode::enter(IRenderer* _renderer, GLState& _state,
80  const DrawModes::DrawMode& _drawMode) {
81  FloatingSubtreeNode::enter(_state, _drawMode);
82 }
83 
84 void FloatingSubtreeNode::leave(GLState &_state,
85  const DrawModes::DrawMode &_drawMode) {
86  if (enable_modelview_override_) {
87  _state.pop_modelview_matrix();
88  }
89 }
90 
91 void FloatingSubtreeNode::leave(IRenderer* _renderer, GLState& _state,
92  const DrawModes::DrawMode& _drawMode) {
93  FloatingSubtreeNode::leave(_state, _drawMode);
94  if (enable_overlay_) {
95  for (auto &obj_it : _renderer->getCollectedSubtreeObjects()) {
96  obj_it.overlay = true;
97  }
98  }
99 }
100 
101 
102 void FloatingSubtreeNode::enterPick(GLState &_state, PickTarget _target,
103  const DrawModes::DrawMode &_drawMode) {
104  FloatingSubtreeNode::enter(_state, _drawMode);
105 }
106 
107 void FloatingSubtreeNode::leavePick(GLState &_state, PickTarget _target,
108  const DrawModes::DrawMode &_drawMode) {
109  FloatingSubtreeNode::leave(_state, _drawMode);
110 }
111 
112 void FloatingSubtreeNode::setModelViewOverride(GLMatrixd modelview_override) {
113  modelview_override_ = std::move(modelview_override);
114  modelview_override_inv_ = modelview_override_;
115  modelview_override_inv_.invert();
116 }
117 
118 } /* namespace Scenegraph */
119 } /* namespace ACG */
120 
121 #endif /* C++11 */
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
GLMatrixT< double > GLMatrixd
typedef
Definition: GLMatrixT.hh:332
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
STL namespace.