Debian Codegraph @

src/Gui/SoFCInteractiveElement.cpp

raw
1 /***************************************************************************
2 * Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #include <Inventor/elements/SoOverrideElement.h>
25
26
27 #include "SoFCInteractiveElement.h"
28
29 using namespace Gui;
30
31 SO_ELEMENT_SOURCE(SoFCInteractiveElement)
32
33 void SoFCInteractiveElement::initClass()
34 {
35 SO_ELEMENT_INIT_CLASS(SoFCInteractiveElement, inherited);
36 SO_ENABLE(SoGLRenderAction, SoFCInteractiveElement);
37 }
38
39 void SoFCInteractiveElement::init(SoState* /*state*/)
40 {
41 this->interactiveMode = false;
42 }
43
44 SoFCInteractiveElement::~SoFCInteractiveElement() = default;
45
46 void SoFCInteractiveElement::set(SoState* const state, SoNode* const node, SbBool mode)
47 {
48 auto elem = (SoFCInteractiveElement*)SoReplacedElement::getElement(state, classStackIndex, node);
49 elem->setElt(mode);
50 }
51
52 SbBool SoFCInteractiveElement::get(SoState* const state)
53 {
54 return SoFCInteractiveElement::getInstance(state)->interactiveMode;
55 }
56
57 void SoFCInteractiveElement::setElt(SbBool mode)
58 {
59 this->interactiveMode = mode;
60 }
61
62 const SoFCInteractiveElement* SoFCInteractiveElement::getInstance(SoState* state)
63 {
64 return (const SoFCInteractiveElement*)SoElement::getConstElement(state, classStackIndex);
65 }
66
67 // ---------------------------------
68
69 SO_ELEMENT_SOURCE(SoGLWidgetElement)
70
71 void SoGLWidgetElement::initClass()
72 {
73 SO_ELEMENT_INIT_CLASS(SoGLWidgetElement, inherited);
74 SO_ENABLE(SoGLRenderAction, SoGLWidgetElement);
75 SO_ENABLE(SoHandleEventAction, SoGLWidgetElement);
76 }
77
78 void SoGLWidgetElement::init(SoState* state)
79 {
80 inherited::init(state);
81 this->window = nullptr;
82 }
83
84 SoGLWidgetElement::~SoGLWidgetElement() = default;
85
86 void SoGLWidgetElement::set(SoState* state, QOpenGLWidget* window)
87 {
88 auto elem = static_cast<SoGLWidgetElement*>(SoElement::getElement(state, classStackIndex));
89 elem->window = window;
90 }
91
92 void SoGLWidgetElement::get(SoState* state, QOpenGLWidget*& window)
93 {
94 const auto that = static_cast<const SoGLWidgetElement*>(
95 SoElement::getConstElement(state, classStackIndex)
96 );
97 window = that->window;
98 }
99
100 void SoGLWidgetElement::push(SoState* state)
101 {
102 inherited::push(state);
103 }
104
105 void SoGLWidgetElement::pop(SoState* state, const SoElement* prevTopElement)
106 {
107 inherited::pop(state, prevTopElement);
108 }
109
110 SbBool SoGLWidgetElement::matches(const SoElement* /*element*/) const
111 {
112 return true;
113 }
114
115 SoElement* SoGLWidgetElement::copyMatchInfo() const
116 {
117 return nullptr;
118 }
119
120 // ---------------------------------
121
122 SO_ELEMENT_SOURCE(SoGLRenderActionElement)
123
124 void SoGLRenderActionElement::initClass()
125 {
126 SO_ELEMENT_INIT_CLASS(SoGLRenderActionElement, inherited);
127 SO_ENABLE(SoGLRenderAction, SoGLRenderActionElement);
128 SO_ENABLE(SoHandleEventAction, SoGLRenderActionElement);
129 }
130
131 void SoGLRenderActionElement::init(SoState* state)
132 {
133 inherited::init(state);
134 this->glRenderAction = nullptr;
135 }
136
137 SoGLRenderActionElement::~SoGLRenderActionElement() = default;
138
139 void SoGLRenderActionElement::set(SoState* state, SoGLRenderAction* action)
140 {
141 auto elem = static_cast<SoGLRenderActionElement*>(SoElement::getElement(state, classStackIndex));
142 elem->glRenderAction = action;
143 }
144
145 void SoGLRenderActionElement::get(SoState* state, SoGLRenderAction*& action)
146 {
147 const auto that = static_cast<const SoGLRenderActionElement*>(
148 SoElement::getConstElement(state, classStackIndex)
149 );
150 action = that->glRenderAction;
151 }
152
153 void SoGLRenderActionElement::push(SoState* state)
154 {
155 inherited::push(state);
156 }
157
158 void SoGLRenderActionElement::pop(SoState* state, const SoElement* prevTopElement)
159 {
160 inherited::pop(state, prevTopElement);
161 }
162
163 SbBool SoGLRenderActionElement::matches(const SoElement* /*element*/) const
164 {
165 return true;
166 }
167
168 SoElement* SoGLRenderActionElement::copyMatchInfo() const
169 {
170 return nullptr;
171 }
172
173 // ---------------------------------
174
175 SO_NODE_SOURCE(SoGLWidgetNode)
176
177 /*!
178 Constructor.
179 */
180 SoGLWidgetNode::SoGLWidgetNode()
181 {
182 SO_NODE_CONSTRUCTOR(SoGLWidgetNode);
183 }
184
185 /*!
186 Destructor.
187 */
188 SoGLWidgetNode::~SoGLWidgetNode() = default;
189
190 // Doc from superclass.
191 void SoGLWidgetNode::initClass()
192 {
193 SO_NODE_INIT_CLASS(SoGLWidgetNode, SoNode, "Node");
194
195 SO_ENABLE(SoGLRenderAction, SoGLWidgetElement);
196 }
197
198 // Doc from superclass.
199 void SoGLWidgetNode::doAction(SoAction* action)
200 {
201 SoGLWidgetElement::set(action->getState(), this->window);
202 }
203
204 // Doc from superclass.
205 void SoGLWidgetNode::GLRender(SoGLRenderAction* action)
206 {
207 SoGLWidgetNode::doAction(action);
208 }
209
210 // ---------------------------------
211
212 SO_ELEMENT_SOURCE(SoGLVBOActivatedElement)
213
214 void SoGLVBOActivatedElement::initClass()
215 {
216 SO_ELEMENT_INIT_CLASS(SoGLVBOActivatedElement, inherited);
217 SO_ENABLE(SoGLRenderAction, SoGLVBOActivatedElement);
218 SO_ENABLE(SoHandleEventAction, SoGLVBOActivatedElement);
219 }
220
221 void SoGLVBOActivatedElement::init(SoState* state)
222 {
223 inherited::init(state);
224 this->active = false;
225 }
226
227 SoGLVBOActivatedElement::~SoGLVBOActivatedElement() = default;
228
229 void SoGLVBOActivatedElement::set(SoState* state, SbBool active)
230 {
231 auto elem = static_cast<SoGLVBOActivatedElement*>(SoElement::getElement(state, classStackIndex));
232 elem->active = active;
233 }
234
235 void SoGLVBOActivatedElement::get(SoState* state, SbBool& active)
236 {
237 const auto self = static_cast<const SoGLVBOActivatedElement*>(
238 SoElement::getConstElement(state, classStackIndex)
239 );
240 active = self->active;
241 if (active) {
242 uint32_t flags = SoOverrideElement::getFlags(state);
243 if (flags
244 & (SoOverrideElement::COLOR_INDEX | SoOverrideElement::DIFFUSE_COLOR
245 | SoOverrideElement::MATERIAL_BINDING | SoOverrideElement::TRANSPARENCY
246 | SoOverrideElement::NORMAL_VECTOR | SoOverrideElement::NORMAL_BINDING)) {
247 active = false;
248 }
249 }
250 }
251
252 void SoGLVBOActivatedElement::push(SoState* state)
253 {
254 inherited::push(state);
255 }
256
257 void SoGLVBOActivatedElement::pop(SoState* state, const SoElement* prevTopElement)
258 {
259 inherited::pop(state, prevTopElement);
260 }
261
262 SbBool SoGLVBOActivatedElement::matches(const SoElement* /*element*/) const
263 {
264 return true;
265 }
266
267 SoElement* SoGLVBOActivatedElement::copyMatchInfo() const
268 {
269 return nullptr;
270 }