1
/***************************************************************************
2
* Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
26
# include <Inventor/elements/SoOverrideElement.h>
29
#include "SoFCInteractiveElement.h"
33
SO_ELEMENT_SOURCE(SoFCInteractiveElement)
35
void SoFCInteractiveElement::initClass()
37
SO_ELEMENT_INIT_CLASS(SoFCInteractiveElement, inherited);
38
SO_ENABLE(SoGLRenderAction, SoFCInteractiveElement);
41
void SoFCInteractiveElement::init(SoState * /*state*/)
43
this->interactiveMode = false;
46
SoFCInteractiveElement::~SoFCInteractiveElement() = default;
48
void SoFCInteractiveElement::set(SoState * const state, SoNode * const node, SbBool mode)
50
auto elem = (SoFCInteractiveElement *)
51
SoReplacedElement::getElement(state, classStackIndex, node);
55
SbBool SoFCInteractiveElement::get(SoState * const state)
57
return SoFCInteractiveElement::getInstance(state)->interactiveMode;
60
void SoFCInteractiveElement::setElt(SbBool mode)
62
this->interactiveMode = mode;
65
const SoFCInteractiveElement * SoFCInteractiveElement::getInstance(SoState * state)
67
return (const SoFCInteractiveElement *) SoElement::getConstElement(state, classStackIndex);
70
// ---------------------------------
72
SO_ELEMENT_SOURCE(SoGLWidgetElement)
74
void SoGLWidgetElement::initClass()
76
SO_ELEMENT_INIT_CLASS(SoGLWidgetElement, inherited);
77
SO_ENABLE(SoGLRenderAction, SoGLWidgetElement);
78
SO_ENABLE(SoHandleEventAction, SoGLWidgetElement);
81
void SoGLWidgetElement::init(SoState * state)
83
inherited::init(state);
84
this->window = nullptr;
87
SoGLWidgetElement::~SoGLWidgetElement() = default;
89
void SoGLWidgetElement::set(SoState * state, QtGLWidget * window)
91
auto elem = static_cast<SoGLWidgetElement *>
92
(SoElement::getElement(state, classStackIndex));
93
elem->window = window;
96
void SoGLWidgetElement::get(SoState * state, QtGLWidget *& window)
98
const auto that = static_cast<const SoGLWidgetElement *>
99
(SoElement::getConstElement(state, classStackIndex));
100
window = that->window;
103
void SoGLWidgetElement::push(SoState * state)
105
inherited::push(state);
108
void SoGLWidgetElement::pop(SoState * state, const SoElement * prevTopElement)
110
inherited::pop(state, prevTopElement);
113
SbBool SoGLWidgetElement::matches(const SoElement * /*element*/) const
118
SoElement * SoGLWidgetElement::copyMatchInfo() const
123
// ---------------------------------
125
SO_ELEMENT_SOURCE(SoGLRenderActionElement)
127
void SoGLRenderActionElement::initClass()
129
SO_ELEMENT_INIT_CLASS(SoGLRenderActionElement, inherited);
130
SO_ENABLE(SoGLRenderAction, SoGLRenderActionElement);
131
SO_ENABLE(SoHandleEventAction, SoGLRenderActionElement);
134
void SoGLRenderActionElement::init(SoState * state)
136
inherited::init(state);
137
this->glRenderAction = nullptr;
140
SoGLRenderActionElement::~SoGLRenderActionElement() = default;
142
void SoGLRenderActionElement::set(SoState * state, SoGLRenderAction * action)
144
auto elem = static_cast<SoGLRenderActionElement *>
145
(SoElement::getElement(state, classStackIndex));
146
elem->glRenderAction = action;
149
void SoGLRenderActionElement::get(SoState * state, SoGLRenderAction * & action)
151
const auto that = static_cast<const SoGLRenderActionElement *>
152
(SoElement::getConstElement(state, classStackIndex));
153
action = that->glRenderAction;
156
void SoGLRenderActionElement::push(SoState * state)
158
inherited::push(state);
161
void SoGLRenderActionElement::pop(SoState * state, const SoElement * prevTopElement)
163
inherited::pop(state, prevTopElement);
166
SbBool SoGLRenderActionElement::matches(const SoElement * /*element*/) const
171
SoElement * SoGLRenderActionElement::copyMatchInfo() const
176
// ---------------------------------
178
SO_NODE_SOURCE(SoGLWidgetNode)
183
SoGLWidgetNode::SoGLWidgetNode()
185
SO_NODE_CONSTRUCTOR(SoGLWidgetNode);
191
SoGLWidgetNode::~SoGLWidgetNode() = default;
193
// Doc from superclass.
194
void SoGLWidgetNode::initClass()
196
SO_NODE_INIT_CLASS(SoGLWidgetNode, SoNode, "Node");
198
SO_ENABLE(SoGLRenderAction, SoGLWidgetElement);
201
// Doc from superclass.
202
void SoGLWidgetNode::doAction(SoAction * action)
204
SoGLWidgetElement::set(action->getState(), this->window);
207
// Doc from superclass.
208
void SoGLWidgetNode::GLRender(SoGLRenderAction * action)
210
SoGLWidgetNode::doAction(action);
213
// ---------------------------------
215
SO_ELEMENT_SOURCE(SoGLVBOActivatedElement)
217
void SoGLVBOActivatedElement::initClass()
219
SO_ELEMENT_INIT_CLASS(SoGLVBOActivatedElement, inherited);
220
SO_ENABLE(SoGLRenderAction, SoGLVBOActivatedElement);
221
SO_ENABLE(SoHandleEventAction, SoGLVBOActivatedElement);
224
void SoGLVBOActivatedElement::init(SoState * state)
226
inherited::init(state);
227
this->active = false;
230
SoGLVBOActivatedElement::~SoGLVBOActivatedElement() = default;
232
void SoGLVBOActivatedElement::set(SoState * state, SbBool active)
234
auto elem = static_cast<SoGLVBOActivatedElement *>
235
(SoElement::getElement(state, classStackIndex));
236
elem->active = active;
239
void SoGLVBOActivatedElement::get(SoState * state, SbBool& active)
241
const auto self = static_cast<const SoGLVBOActivatedElement *>
242
(SoElement::getConstElement(state, classStackIndex));
243
active = self->active;
245
uint32_t flags = SoOverrideElement::getFlags(state);
246
if(flags & (SoOverrideElement::COLOR_INDEX|
247
SoOverrideElement::DIFFUSE_COLOR|
248
SoOverrideElement::MATERIAL_BINDING|
249
SoOverrideElement::TRANSPARENCY|
250
SoOverrideElement::NORMAL_VECTOR|
251
SoOverrideElement::NORMAL_BINDING))
256
void SoGLVBOActivatedElement::push(SoState * state)
258
inherited::push(state);
261
void SoGLVBOActivatedElement::pop(SoState * state, const SoElement * prevTopElement)
263
inherited::pop(state, prevTopElement);
266
SbBool SoGLVBOActivatedElement::matches(const SoElement * /*element*/) const
271
SoElement * SoGLVBOActivatedElement::copyMatchInfo() const