| 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 |
#ifndef GUI_SOFCINTERACTIVEELEMENT_H |
| 24 |
#define GUI_SOFCINTERACTIVEELEMENT_H |
| 25 |
|
| 26 |
#include <Inventor/actions/SoGLRenderAction.h> |
| 27 |
#include <Inventor/actions/SoHandleEventAction.h> |
| 28 |
#include <Inventor/elements/SoReplacedElement.h> |
| 29 |
#include <Inventor/nodes/SoNode.h> |
| 30 |
#include <Inventor/nodes/SoSubNode.h> |
| 31 |
|
| 32 |
#include <FCGlobal.h> |
| 33 |
|
| 34 |
class QOpenGLWidget; |
| 35 |
|
| 36 |
namespace Gui |
| 37 |
{ |
| 38 |
/** |
| 39 |
* @author Werner Mayer |
| 40 |
*/ |
| 41 |
class GuiExport SoFCInteractiveElement: public SoReplacedElement |
| 42 |
{ |
| 43 |
using inherited = SoReplacedElement; |
| 44 |
|
| 45 |
SO_ELEMENT_HEADER(SoFCInteractiveElement); |
| 46 |
|
| 47 |
public: |
| 48 |
static void initClass(); |
| 49 |
|
| 50 |
void init(SoState* state) override; |
| 51 |
static void set(SoState* const state, SoNode* const node, SbBool mode); |
| 52 |
static SbBool get(SoState* const state); |
| 53 |
static const SoFCInteractiveElement* getInstance(SoState* state); |
| 54 |
|
| 55 |
protected: |
| 56 |
~SoFCInteractiveElement() override; |
| 57 |
virtual void setElt(SbBool mode); |
| 58 |
|
| 59 |
private: |
| 60 |
SbBool interactiveMode; |
| 61 |
}; |
| 62 |
|
| 63 |
class GuiExport SoGLWidgetElement: public SoElement |
| 64 |
{ |
| 65 |
using inherited = SoElement; |
| 66 |
|
| 67 |
SO_ELEMENT_HEADER(SoGLWidgetElement); |
| 68 |
|
| 69 |
public: |
| 70 |
static void initClass(); |
| 71 |
|
| 72 |
void init(SoState* state) override; |
| 73 |
void push(SoState* state) override; |
| 74 |
void pop(SoState* state, const SoElement* prevTopElement) override; |
| 75 |
|
| 76 |
SbBool matches(const SoElement* element) const override; |
| 77 |
SoElement* copyMatchInfo() const override; |
| 78 |
|
| 79 |
static void set(SoState* state, QOpenGLWidget* window); |
| 80 |
static void get(SoState* state, QOpenGLWidget*& window); |
| 81 |
|
| 82 |
protected: |
| 83 |
~SoGLWidgetElement() override; |
| 84 |
|
| 85 |
protected: |
| 86 |
QOpenGLWidget* window; |
| 87 |
}; |
| 88 |
|
| 89 |
class GuiExport SoGLRenderActionElement: public SoElement |
| 90 |
{ |
| 91 |
using inherited = SoElement; |
| 92 |
|
| 93 |
SO_ELEMENT_HEADER(SoGLRenderActionElement); |
| 94 |
|
| 95 |
public: |
| 96 |
static void initClass(); |
| 97 |
|
| 98 |
void init(SoState* state) override; |
| 99 |
void push(SoState* state) override; |
| 100 |
void pop(SoState* state, const SoElement* prevTopElement) override; |
| 101 |
|
| 102 |
SbBool matches(const SoElement* element) const override; |
| 103 |
SoElement* copyMatchInfo() const override; |
| 104 |
|
| 105 |
static void set(SoState* state, SoGLRenderAction* action); |
| 106 |
static void get(SoState* state, SoGLRenderAction*& action); |
| 107 |
|
| 108 |
protected: |
| 109 |
~SoGLRenderActionElement() override; |
| 110 |
|
| 111 |
protected: |
| 112 |
SoGLRenderAction* glRenderAction; |
| 113 |
}; |
| 114 |
|
| 115 |
class GuiExport SoGLWidgetNode: public SoNode |
| 116 |
{ |
| 117 |
using inherited = SoNode; |
| 118 |
|
| 119 |
SO_NODE_HEADER(SoGLWidgetNode); |
| 120 |
|
| 121 |
public: |
| 122 |
static void initClass(); |
| 123 |
SoGLWidgetNode(); |
| 124 |
|
| 125 |
QOpenGLWidget* window {nullptr}; |
| 126 |
|
| 127 |
void doAction(SoAction* action) override; |
| 128 |
void GLRender(SoGLRenderAction* action) override; |
| 129 |
|
| 130 |
protected: |
| 131 |
~SoGLWidgetNode() override; |
| 132 |
}; |
| 133 |
|
| 134 |
class GuiExport SoGLVBOActivatedElement: public SoElement |
| 135 |
{ |
| 136 |
using inherited = SoElement; |
| 137 |
|
| 138 |
SO_ELEMENT_HEADER(SoGLVBOActivatedElement); |
| 139 |
|
| 140 |
public: |
| 141 |
static void initClass(); |
| 142 |
|
| 143 |
void init(SoState* state) override; |
| 144 |
void push(SoState* state) override; |
| 145 |
void pop(SoState* state, const SoElement* prevTopElement) override; |
| 146 |
|
| 147 |
SbBool matches(const SoElement* element) const override; |
| 148 |
SoElement* copyMatchInfo() const override; |
| 149 |
|
| 150 |
static void set(SoState* state, SbBool); |
| 151 |
static void get(SoState* state, SbBool& active); |
| 152 |
|
| 153 |
protected: |
| 154 |
~SoGLVBOActivatedElement() override; |
| 155 |
|
| 156 |
protected: |
| 157 |
SbBool active; |
| 158 |
}; |
| 159 |
|
| 160 |
} // namespace Gui |
| 161 |
|
| 162 |
#endif // GUI_SOFCINTERACTIVEELEMENT_H |