| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2024 Kacper Donat <[email protected]> * |
| 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 |
#ifndef GUI_SO3DANNOTATION_H |
| 23 |
#define GUI_SO3DANNOTATION_H |
| 24 |
|
| 25 |
#include <Inventor/actions/SoGLRenderAction.h> |
| 26 |
#include <Inventor/nodes/SoSeparator.h> |
| 27 |
#include <Inventor/elements/SoElement.h> |
| 28 |
#include <Inventor/elements/SoSubElement.h> |
| 29 |
#include <FCGlobal.h> |
| 30 |
#include <vector> |
| 31 |
|
| 32 |
namespace Gui |
| 33 |
{ |
| 34 |
|
| 35 |
class GuiExport SoDelayedAnnotationsElement: public SoElement |
| 36 |
{ |
| 37 |
using inherited = SoElement; |
| 38 |
|
| 39 |
SO_ELEMENT_HEADER(SoDelayedAnnotationsElement); |
| 40 |
|
| 41 |
protected: |
| 42 |
~SoDelayedAnnotationsElement() override = default; |
| 43 |
|
| 44 |
SoDelayedAnnotationsElement& operator=(const SoDelayedAnnotationsElement& other) = default; |
| 45 |
SoDelayedAnnotationsElement& operator=(SoDelayedAnnotationsElement&& other) noexcept = default; |
| 46 |
|
| 47 |
// internal structure to hold path with it's rendering |
| 48 |
// priority (lower renders first) |
| 49 |
struct PriorityPath |
| 50 |
{ |
| 51 |
SoPath* path; |
| 52 |
int priority; |
| 53 |
|
| 54 |
PriorityPath(SoPath* p, int pr = 0) |
| 55 |
: path(p) |
| 56 |
, priority(pr) |
| 57 |
{} |
| 58 |
}; |
| 59 |
|
| 60 |
public: |
| 61 |
SoDelayedAnnotationsElement(const SoDelayedAnnotationsElement& other) = delete; |
| 62 |
SoDelayedAnnotationsElement(SoDelayedAnnotationsElement&& other) noexcept = delete; |
| 63 |
|
| 64 |
void init(SoState* state) override; |
| 65 |
|
| 66 |
static void initClass(); |
| 67 |
|
| 68 |
static void addDelayedPath(SoState* state, SoPath* path, int priority = 0); |
| 69 |
|
| 70 |
static SoPathList getDelayedPaths(SoState* state); |
| 71 |
|
| 72 |
static void processDelayedPathsWithPriority(SoState* state, SoGLRenderAction* action); |
| 73 |
|
| 74 |
static bool isProcessingDelayedPaths; |
| 75 |
|
| 76 |
SbBool matches([[maybe_unused]] const SoElement* element) const override |
| 77 |
{ |
| 78 |
return FALSE; |
| 79 |
} |
| 80 |
|
| 81 |
SoElement* copyMatchInfo() const override |
| 82 |
{ |
| 83 |
return nullptr; |
| 84 |
} |
| 85 |
|
| 86 |
private: |
| 87 |
std::vector<PriorityPath> paths; |
| 88 |
}; |
| 89 |
|
| 90 |
/*! @brief 3D Annotation Node - Annotation with depth buffer |
| 91 |
* |
| 92 |
* This class is just like SoAnnotation with the difference that it does not disable |
| 93 |
* the depth buffer instead it clears it and renders on top of everything with proper |
| 94 |
* depth control. |
| 95 |
* |
| 96 |
* It should be used with caution as it does clear the depth buffer for each annotation! |
| 97 |
*/ |
| 98 |
class GuiExport So3DAnnotation: public SoSeparator |
| 99 |
{ |
| 100 |
using inherited = SoSeparator; |
| 101 |
|
| 102 |
SO_NODE_HEADER(So3DAnnotation); |
| 103 |
|
| 104 |
public: |
| 105 |
static bool render; |
| 106 |
|
| 107 |
So3DAnnotation(); |
| 108 |
|
| 109 |
So3DAnnotation(const So3DAnnotation& other) = delete; |
| 110 |
So3DAnnotation(So3DAnnotation&& other) noexcept = delete; |
| 111 |
So3DAnnotation& operator=(const So3DAnnotation& other) = delete; |
| 112 |
So3DAnnotation& operator=(So3DAnnotation&& other) noexcept = delete; |
| 113 |
|
| 114 |
static void initClass(); |
| 115 |
|
| 116 |
void GLRender(SoGLRenderAction* action) override; |
| 117 |
void GLRenderBelowPath(SoGLRenderAction* action) override; |
| 118 |
void GLRenderInPath(SoGLRenderAction* action) override; |
| 119 |
void GLRenderOffPath(SoGLRenderAction* action) override; |
| 120 |
|
| 121 |
protected: |
| 122 |
~So3DAnnotation() override = default; |
| 123 |
}; |
| 124 |
|
| 125 |
} // namespace Gui |
| 126 |
|
| 127 |
#endif // GUI_SO3DANNOTATION_H |