Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoBaseKit.h
1#ifndef COIN_SOBASEKIT_H
2#define COIN_SOBASEKIT_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/nodekits/SoSubKit.h>
37#include <Inventor/nodes/SoNode.h>
38#ifdef COIN_INTERNAL
39class SoNodeKitPath;
40#else // !COIN_INTERNAL
41// Include these header files for better Open Inventor compatibility.
42#include <Inventor/SoNodeKitPath.h>
43#include <Inventor/misc/SoChildList.h>
44#endif // !COIN_INTERNAL
45
46class SoGroup;
47class SoNodekitParts;
49class SoPath;
50
51// Convenience macros. FIXME: document. 20000113 mortene.
52
53#define SO_GET_PART(_kit_, _name_, _classname_) \
54 ((_classname_ *)_kit_->getPart(_name_, TRUE))
55
56#define SO_CHECK_PART(_kit_, _name_, _classname_) \
57 (static_cast<_classname_ *>(_kit_->getPart(_name_, FALSE)))
58
59#define SO_GET_ANY_PART(_kit_, _name_, _classname_) \
60 (static_cast<_classname_ *>(_kit_->getAnyPart(_name_, TRUE, FALSE, FALSE)))
61
62#define SO_CHECK_ANY_PART(_kit_, _name_, _classname_) \
63 (static_cast<_classname_ *>(_kit_->getAnyPart(_name_, FALSE, FALSE, FALSE)))
64
65
66class COIN_DLL_API SoBaseKit : public SoNode {
67 typedef SoNode inherited;
68
70
71 SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
72
73public:
74 static void initClass(void);
75 SoBaseKit(void);
76
77 static const SoNodekitCatalog * getClassNodekitCatalog(void);
78 virtual const SoNodekitCatalog * getNodekitCatalog(void) const;
79
80 virtual SoNode * getPart(const SbName & partname, SbBool makeifneeded);
81 SbString getPartString(const SoBase * part);
82 virtual SoNodeKitPath * createPathToPart(const SbName & partname,
83 SbBool makeifneeded,
84 const SoPath * pathtoextend = NULL);
85 virtual SbBool setPart(const SbName & partname, SoNode * from);
86 SbBool set(const char * namevaluepairliststring);
87 SbBool set(const char * partnamestring, const char * parameterstring);
88
89 virtual void doAction(SoAction * action);
90 virtual void callback(SoCallbackAction * action);
91 virtual void GLRender(SoGLRenderAction * action);
92 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
93 virtual void getMatrix(SoGetMatrixAction * action);
94 virtual void handleEvent(SoHandleEventAction * action);
95 virtual void rayPick(SoRayPickAction * action);
96 virtual void search(SoSearchAction * action);
97 virtual void write(SoWriteAction * action);
98 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
99
100 virtual SoChildList * getChildren(void) const;
101
102 void printDiagram(void);
103 void printSubDiagram(const SbName & rootname, int level);
104 void printTable(void);
105
106 virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
108
109 static SbBool isSearchingChildren(void);
110 static void setSearchingChildren(const SbBool newval);
111
112protected:
113 virtual ~SoBaseKit();
114
115 static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void);
116
117 virtual SoNode * addToCopyDict(void) const;
118 virtual void copyContents(const SoFieldContainer * fromfc,
119 SbBool copyconnections);
120
121 SoGroup * getContainerNode(const SbName & listname,
122 SbBool makeifneeded = TRUE);
123 virtual SoNode * getAnyPart(const SbName & partname, SbBool makeifneeded,
124 SbBool leafcheck = FALSE,
125 SbBool publiccheck = FALSE);
126 virtual SoNodeKitPath * createPathToAnyPart(const SbName & partname,
127 SbBool makeifneeded,
128 SbBool leafcheck = FALSE,
129 SbBool publiccheck = FALSE,
130 const SoPath * pathtoextend = NULL);
131 virtual SbBool setAnyPart(const SbName & partname, SoNode * from,
132 SbBool anypart = TRUE);
133 void createNodekitPartsList(void); // not part of Coin
134 void createFieldList(void); // replaces above method
135 virtual void createDefaultParts(void);
136 const SoNodekitParts * getNodekitPartsList(void) const; // not part of Coin
137 const SbList<SoSFNode*> & getCatalogInstances(void) const; // replaces above method
138
139 void catalogError(void);
140 virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
141 virtual SbBool readInstance(SoInput * in, unsigned short flags);
142 virtual void setDefaultOnNonWritingFields(void);
143 void countMyFields(SoOutput * out);
144
145 virtual SbBool setPart(const int partNum, SoNode * node);
146
149
150private:
151 friend class SoInteractionKit;
152 static SbBool findPart(const SbString & partname, SoBaseKit *& kit,
153 int & partnum, SbBool & islist, int & listidx,
154 const SbBool makeifneeded, SoPath * path = NULL,
155 const SbBool recsearch = FALSE);
156 static void atexit_cleanupkit(void);
157
158 SbBool makePart(const int partnum);
159 int getRightSiblingIndex(const int partnum);
160 int findNodeInThisKit(SoNode *node, const int parentnum = -1) const;
161
162 static SoNodekitCatalog * classcatalog;
163 static const SoNodekitCatalog ** parentcatalogptr;
164 static SbBool searchchildren;
165
166 class SoBaseKitP * pimpl;
167 friend class SoBaseKitP;
168};
169
170#endif // !COIN_SOBASEKIT_H
The SbList class is a template container class for lists.
Definition SbList.h:70
The SbName class stores strings by reference.
Definition SbName.h:40
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:52
The SoAction class is the base class for all traversal actions.
Definition SoAction.h:77
static const SoNodekitCatalog * getClassNodekitCatalog(void)
Definition SoBaseKit.cpp:589
void printTable(void)
Definition SoBaseKit.cpp:1489
virtual const SoNodekitCatalog * getNodekitCatalog(void) const
Definition SoBaseKit.cpp:589
SbBool connectionsSetUp
Definition SoBaseKit.h:148
virtual void createDefaultParts(void)
Definition SoBaseKit.cpp:1985
void createNodekitPartsList(void)
Definition SoBaseKit.cpp:1950
void printDiagram(void)
Definition SoBaseKit.cpp:1417
SoBaseKit(void)
Definition SoBaseKit.cpp:630
virtual SoNodeKitPath * createPathToPart(const SbName &partname, SbBool makeifneeded, const SoPath *pathtoextend=NULL)
Definition SoBaseKit.cpp:785
virtual SoNode * getAnyPart(const SbName &partname, SbBool makeifneeded, SbBool leafcheck=FALSE, SbBool publiccheck=FALSE)
Definition SoBaseKit.cpp:1696
void catalogError(void)
Definition SoBaseKit.cpp:2034
SoGroup * getContainerNode(const SbName &listname, SbBool makeifneeded=TRUE)
Definition SoBaseKit.cpp:1641
void createFieldList(void)
Definition SoBaseKit.cpp:1963
virtual void setDefaultOnNonWritingFields(void)
Definition SoBaseKit.cpp:1278
static SbBool isSearchingChildren(void)
Definition SoBaseKit.cpp:1528
static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void)
Definition SoBaseKit.cpp:589
const SbList< SoSFNode * > & getCatalogInstances(void) const
Definition SoBaseKit.cpp:2024
virtual SbBool setPart(const SbName &partname, SoNode *from)
Definition SoBaseKit.cpp:794
void countMyFields(SoOutput *out)
Definition SoBaseKit.cpp:1181
const SoNodekitParts * getNodekitPartsList(void) const
Definition SoBaseKit.cpp:2013
static void setSearchingChildren(const SbBool newval)
Definition SoBaseKit.cpp:1538
virtual SoNodeKitPath * createPathToAnyPart(const SbName &partname, SbBool makeifneeded, SbBool leafcheck=FALSE, SbBool publiccheck=FALSE, const SoPath *pathtoextend=NULL)
Definition SoBaseKit.cpp:1788
virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways=FALSE)
Definition SoBaseKit.cpp:2050
SbString getPartString(const SoBase *part)
Definition SoBaseKit.cpp:710
void printSubDiagram(const SbName &rootname, int level)
Definition SoBaseKit.cpp:1431
virtual SoNode * getPart(const SbName &partname, SbBool makeifneeded)
Definition SoBaseKit.cpp:700
SoChildList * children
Definition SoBaseKit.h:147
SbBool forceChildDrivenWriteRefs(SoOutput *out)
Definition SoBaseKit.cpp:1330
virtual SbBool setAnyPart(const SbName &partname, SoNode *from, SbBool anypart=TRUE)
Definition SoBaseKit.cpp:1877
SoBase(void)
Definition SoBase.cpp:190
The SoCallbackAction class invokes callbacks at specific nodes.
Definition SoCallbackAction.h:80
The SoChildList class is a container for node children.
Definition SoChildList.h:42
SoFieldContainer(void)
Definition SoFieldContainer.cpp:133
SbBool set(const char *const fielddata)
Definition SoFieldContainer.cpp:383
virtual void addWriteReference(SoOutput *out, SbBool isfromfield=FALSE)
Definition SoFieldContainer.cpp:698
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition SoGLRenderAction.h:50
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.
Definition SoGetBoundingBoxAction.h:45
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph.
Definition SoGetMatrixAction.h:46
The SoGetPrimitiveCountAction class counts the primitives in a scene.
Definition SoGetPrimitiveCountAction.h:44
The SoGroup class is a node which managed other node instances.
Definition SoGroup.h:40
The SoHandleEventAction class distributes user events to the scene.
Definition SoHandleEventAction.h:46
The SoInput class is an abstraction of file import functionality.
Definition SoInput.h:61
The SoNodeKitPath class is a path that contains only nodekit nodes.
Definition SoNodeKitPath.h:42
virtual SoChildList * getChildren(void) const
Definition SoNode.cpp:1366
SoNode(void)
Definition SoNode.cpp:417
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
Definition SoNode.cpp:943
virtual void handleEvent(SoHandleEventAction *action)
Definition SoNode.cpp:1132
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Definition SoNode.cpp:914
virtual void doAction(SoAction *action)
Definition SoNode.cpp:858
virtual void callback(SoCallbackAction *action)
Definition SoNode.cpp:1075
virtual void getMatrix(SoGetMatrixAction *action)
Definition SoNode.cpp:1102
virtual SbBool readInstance(SoInput *in, unsigned short flags)
Definition SoNode.cpp:1542
virtual SoNode * addToCopyDict(void) const
Definition SoNode.cpp:1435
virtual void rayPick(SoRayPickAction *action)
Definition SoNode.cpp:1188
virtual void copyContents(const SoFieldContainer *from, SbBool copyconnections)
Definition SoNode.cpp:1483
virtual void search(SoSearchAction *action)
Definition SoNode.cpp:1221
virtual void write(SoWriteAction *action)
Definition SoNode.cpp:1290
static void initClass(void)
Sets up initialization for data common to all instances of this class, like submitting necessary info...
Definition SoNode.cpp:573
virtual void GLRender(SoGLRenderAction *action)
Definition SoNode.cpp:1003
The SoNodekitCatalog class is a container for nodekit layouts.
Definition SoNodekitCatalog.h:45
The SoOutput class is an abstraction of an output stream.
Definition SoOutput.h:51
The SoPath class is a container class for traversal path descriptions.
Definition SoPath.h:52
The SoRayPickAction class does ray intersection with scene graphs.
Definition SoRayPickAction.h:50
The SoSearchAction class provides methods for searching through scene graphs.
Definition SoSearchAction.h:44
The SoWriteAction class writes a scene graph to file.
Definition SoWriteAction.h:42
#define SO_NODE_HEADER(classname)
Definition Coin_macros.dox:50