FreeCAD

Форк
0
/
SoFCInteractiveElement.cpp 
274 строки · 7.9 Кб
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
#include "PreCompiled.h"
24

25
#ifndef _PreComp_
26
# include <Inventor/elements/SoOverrideElement.h>
27
#endif
28

29
#include "SoFCInteractiveElement.h"
30

31
using namespace Gui;
32

33
SO_ELEMENT_SOURCE(SoFCInteractiveElement)
34

35
void SoFCInteractiveElement::initClass()
36
{
37
  SO_ELEMENT_INIT_CLASS(SoFCInteractiveElement, inherited);
38
  SO_ENABLE(SoGLRenderAction, SoFCInteractiveElement);
39
}
40

41
void SoFCInteractiveElement::init(SoState * /*state*/)
42
{
43
  this->interactiveMode = false;
44
}
45

46
SoFCInteractiveElement::~SoFCInteractiveElement() = default;
47

48
void SoFCInteractiveElement::set(SoState * const state, SoNode * const node, SbBool mode)
49
{
50
    auto elem = (SoFCInteractiveElement *)
51
    SoReplacedElement::getElement(state, classStackIndex, node);
52
  elem->setElt(mode);
53
}
54

55
SbBool SoFCInteractiveElement::get(SoState * const state)
56
{
57
  return SoFCInteractiveElement::getInstance(state)->interactiveMode;
58
}
59

60
void SoFCInteractiveElement::setElt(SbBool mode)
61
{
62
  this->interactiveMode = mode;
63
}
64

65
const SoFCInteractiveElement * SoFCInteractiveElement::getInstance(SoState * state)
66
{
67
  return (const SoFCInteractiveElement *) SoElement::getConstElement(state, classStackIndex);
68
}
69

70
// ---------------------------------
71

72
SO_ELEMENT_SOURCE(SoGLWidgetElement)
73

74
void SoGLWidgetElement::initClass()
75
{
76
  SO_ELEMENT_INIT_CLASS(SoGLWidgetElement, inherited);
77
  SO_ENABLE(SoGLRenderAction, SoGLWidgetElement);
78
  SO_ENABLE(SoHandleEventAction, SoGLWidgetElement);
79
}
80

81
void SoGLWidgetElement::init(SoState * state)
82
{
83
  inherited::init(state);
84
  this->window = nullptr;
85
}
86

87
SoGLWidgetElement::~SoGLWidgetElement() = default;
88

89
void SoGLWidgetElement::set(SoState * state, QtGLWidget * window)
90
{
91
    auto elem = static_cast<SoGLWidgetElement *>
92
        (SoElement::getElement(state, classStackIndex));
93
  elem->window = window;
94
}
95

96
void SoGLWidgetElement::get(SoState * state, QtGLWidget *& window)
97
{
98
    const auto that =  static_cast<const SoGLWidgetElement *>
99
        (SoElement::getConstElement(state, classStackIndex));
100
    window = that->window;
101
}
102

103
void SoGLWidgetElement::push(SoState * state)
104
{
105
    inherited::push(state);
106
}
107

108
void SoGLWidgetElement::pop(SoState * state, const SoElement * prevTopElement)
109
{
110
    inherited::pop(state, prevTopElement);
111
}
112

113
SbBool SoGLWidgetElement::matches(const SoElement * /*element*/) const
114
{
115
    return true;
116
}
117

118
SoElement * SoGLWidgetElement::copyMatchInfo() const
119
{
120
    return nullptr;
121
}
122

123
// ---------------------------------
124

125
SO_ELEMENT_SOURCE(SoGLRenderActionElement)
126

127
void SoGLRenderActionElement::initClass()
128
{
129
  SO_ELEMENT_INIT_CLASS(SoGLRenderActionElement, inherited);
130
  SO_ENABLE(SoGLRenderAction, SoGLRenderActionElement);
131
  SO_ENABLE(SoHandleEventAction, SoGLRenderActionElement);
132
}
133

134
void SoGLRenderActionElement::init(SoState * state)
135
{
136
  inherited::init(state);
137
  this->glRenderAction = nullptr;
138
}
139

140
SoGLRenderActionElement::~SoGLRenderActionElement() = default;
141

142
void SoGLRenderActionElement::set(SoState * state, SoGLRenderAction * action)
143
{
144
    auto elem = static_cast<SoGLRenderActionElement *>
145
        (SoElement::getElement(state, classStackIndex));
146
  elem->glRenderAction = action;
147
}
148

149
void SoGLRenderActionElement::get(SoState * state, SoGLRenderAction * & action)
150
{
151
    const auto that =  static_cast<const SoGLRenderActionElement *>
152
        (SoElement::getConstElement(state, classStackIndex));
153
    action = that->glRenderAction;
154
}
155

156
void SoGLRenderActionElement::push(SoState * state)
157
{
158
    inherited::push(state);
159
}
160

161
void SoGLRenderActionElement::pop(SoState * state, const SoElement * prevTopElement)
162
{
163
    inherited::pop(state, prevTopElement);
164
}
165

166
SbBool SoGLRenderActionElement::matches(const SoElement * /*element*/) const
167
{
168
    return true;
169
}
170

171
SoElement * SoGLRenderActionElement::copyMatchInfo() const
172
{
173
    return nullptr;
174
}
175

176
// ---------------------------------
177

178
SO_NODE_SOURCE(SoGLWidgetNode)
179

180
/*!
181
  Constructor.
182
*/
183
SoGLWidgetNode::SoGLWidgetNode()
184
{
185
    SO_NODE_CONSTRUCTOR(SoGLWidgetNode);
186
}
187

188
/*!
189
  Destructor.
190
*/
191
SoGLWidgetNode::~SoGLWidgetNode() = default;
192

193
// Doc from superclass.
194
void SoGLWidgetNode::initClass()
195
{
196
    SO_NODE_INIT_CLASS(SoGLWidgetNode, SoNode, "Node");
197

198
    SO_ENABLE(SoGLRenderAction, SoGLWidgetElement);
199
}
200

201
// Doc from superclass.
202
void SoGLWidgetNode::doAction(SoAction * action)
203
{
204
    SoGLWidgetElement::set(action->getState(), this->window);
205
}
206

207
// Doc from superclass.
208
void SoGLWidgetNode::GLRender(SoGLRenderAction * action)
209
{
210
    SoGLWidgetNode::doAction(action);
211
}
212

213
// ---------------------------------
214

215
SO_ELEMENT_SOURCE(SoGLVBOActivatedElement)
216

217
void SoGLVBOActivatedElement::initClass()
218
{
219
  SO_ELEMENT_INIT_CLASS(SoGLVBOActivatedElement, inherited);
220
  SO_ENABLE(SoGLRenderAction, SoGLVBOActivatedElement);
221
  SO_ENABLE(SoHandleEventAction, SoGLVBOActivatedElement);
222
}
223

224
void SoGLVBOActivatedElement::init(SoState * state)
225
{
226
  inherited::init(state);
227
  this->active = false;
228
}
229

230
SoGLVBOActivatedElement::~SoGLVBOActivatedElement() = default;
231

232
void SoGLVBOActivatedElement::set(SoState * state, SbBool active)
233
{
234
    auto elem = static_cast<SoGLVBOActivatedElement *>
235
        (SoElement::getElement(state, classStackIndex));
236
  elem->active = active;
237
}
238

239
void SoGLVBOActivatedElement::get(SoState * state, SbBool& active)
240
{
241
    const auto self =  static_cast<const SoGLVBOActivatedElement *>
242
        (SoElement::getConstElement(state, classStackIndex));
243
    active = self->active;
244
    if(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))
252
            active = false;
253
    }
254
}
255

256
void SoGLVBOActivatedElement::push(SoState * state)
257
{
258
    inherited::push(state);
259
}
260

261
void SoGLVBOActivatedElement::pop(SoState * state, const SoElement * prevTopElement)
262
{
263
    inherited::pop(state, prevTopElement);
264
}
265

266
SbBool SoGLVBOActivatedElement::matches(const SoElement * /*element*/) const
267
{
268
    return true;
269
}
270

271
SoElement * SoGLVBOActivatedElement::copyMatchInfo() const
272
{
273
    return nullptr;
274
}
275

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.