Coin Logo http://www.sim.no
http://www.coin3d.org

SoBaseKit.h
1 #ifndef COIN_SOBASEKIT_H
2 #define COIN_SOBASEKIT_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/nodekits/SoSubKit.h>
28 #include <Inventor/nodes/SoNode.h>
29 #ifdef COIN_INTERNAL
30 class SoNodeKitPath;
31 #else // !COIN_INTERNAL
32 // Include these header files for better Open Inventor compatibility.
33 #include <Inventor/SoNodeKitPath.h>
34 #include <Inventor/misc/SoChildList.h>
35 #endif // !COIN_INTERNAL
36 
37 class SoGroup;
38 class SoNodekitParts;
39 class SoNodekitCatalog;
40 class SoPath;
41 
42 // Convenience macros. FIXME: document. 20000113 mortene.
43 
44 #define SO_GET_PART(_kit_, _name_, _classname_) \
45  ((_classname_ *)_kit_->getPart(_name_, TRUE))
46 
47 #define SO_CHECK_PART(_kit_, _name_, _classname_) \
48  ((_classname_ *)_kit_->getPart(_name_, FALSE))
49 
50 #define SO_GET_ANY_PART(_kit_, _name_, _classname_) \
51  ((_classname_ *)_kit_->getAnyPart(_name_, TRUE, FALSE, FALSE))
52 
53 #define SO_CHECK_ANY_PART(_kit_, _name_, _classname_) \
54  ((_classname_ *)_kit_->getAnyPart(_name_, FALSE, FALSE, FALSE))
55 
56 
57 class COIN_DLL_API SoBaseKit : public SoNode {
58  typedef SoNode inherited;
59 
60  SO_NODE_HEADER(SoBaseKit);
61 
62  SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
63 
64 public:
65  static void initClass(void);
66  SoBaseKit(void);
67 
68  static const SoNodekitCatalog * getClassNodekitCatalog(void);
69  virtual const SoNodekitCatalog * getNodekitCatalog(void) const;
70 
71  virtual SoNode * getPart(const SbName & partname, SbBool makeifneeded);
72  SbString getPartString(const SoBase * part);
73  virtual SoNodeKitPath * createPathToPart(const SbName & partname,
74  SbBool makeifneeded,
75  const SoPath * pathtoextend = NULL);
76  virtual SbBool setPart(const SbName & partname, SoNode * from);
77  SbBool set(const char * namevaluepairliststring);
78  SbBool set(const char * partnamestring, const char * parameterstring);
79 
80  virtual void doAction(SoAction * action);
81  virtual void callback(SoCallbackAction * action);
82  virtual void GLRender(SoGLRenderAction * action);
83  virtual void getBoundingBox(SoGetBoundingBoxAction * action);
84  virtual void getMatrix(SoGetMatrixAction * action);
85  virtual void handleEvent(SoHandleEventAction * action);
86  virtual void rayPick(SoRayPickAction * action);
87  virtual void search(SoSearchAction * action);
88  virtual void write(SoWriteAction * action);
89  virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
90 
91  virtual SoChildList * getChildren(void) const;
92 
93  void printDiagram(void);
94  void printSubDiagram(const SbName & rootname, int level);
95  void printTable(void);
96 
97  virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
98  SbBool forceChildDrivenWriteRefs(SoOutput * out);
99 
100  static SbBool isSearchingChildren(void);
101  static void setSearchingChildren(const SbBool newval);
102  static SoNode * typeCheck(const SbName & partname, const SoType & parttype,
103  SoNode * node);
104 
105 
106 protected:
107  virtual ~SoBaseKit();
108 
109  static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void);
110 
111  virtual SoNode * addToCopyDict(void) const;
112  virtual void copyContents(const SoFieldContainer * fromfc,
113  SbBool copyconnections);
114 
115  SoGroup * getContainerNode(const SbName & listname,
116  SbBool makeifneeded = TRUE);
117  virtual SoNode * getAnyPart(const SbName & partname, SbBool makeifneeded,
118  SbBool leafcheck = FALSE,
119  SbBool publiccheck = FALSE);
120  virtual SoNodeKitPath * createPathToAnyPart(const SbName & partname,
121  SbBool makeifneeded,
122  SbBool leafcheck = FALSE,
123  SbBool publiccheck = FALSE,
124  const SoPath * pathtoextend = NULL);
125  virtual SbBool setAnyPart(const SbName & partname, SoNode * from,
126  SbBool anypart = TRUE);
127  void createNodekitPartsList(void); // not part of Coin
128  void createFieldList(void); // replaces above method
129  virtual void createDefaultParts(void);
130  const SoNodekitParts * getNodekitPartsList(void) const; // not part of Coin
131  const SbList<SoSFNode*> & getCatalogInstances(void) const; // replaces above method
132 
133  void catalogError(void);
134  virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
135  virtual SbBool readInstance(SoInput * in, unsigned short flags);
136  virtual void setDefaultOnNonWritingFields(void);
137  void countMyFields(SoOutput * out);
138 
139  virtual SbBool setPart(const int partNum, SoNode * node);
140 
143 
144 private:
145  friend class SoInteractionKit;
146  static SbBool findPart(const SbString & partname, SoBaseKit *& kit,
147  int & partnum, SbBool & islist, int & listidx,
148  const SbBool makeifneeded, SoPath * path = NULL,
149  const SbBool recsearch = FALSE);
150  static void atexit_cleanupkit(void);
151 
152  SbBool makePart(const int partnum);
153  int getRightSiblingIndex(const int partnum);
154  int findNodeInThisKit(SoNode *node, const int parentnum = -1) const;
155 
156  static SoNodekitCatalog * classcatalog;
157  static const SoNodekitCatalog ** parentcatalogptr;
158  static SbBool searchchildren;
159 
160  class SoBaseKitP * pimpl;
161  friend class SoBaseKitP;
162 };
163 
164 #endif // !COIN_SOBASEKIT_H
The SbName class stores strings by reference.
Definition: SbName.h:31
The SbString class is a string class with convenience functions for string operations.
Definition: SbString.h:42
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:67
The SoBaseKit class is the toplevel superclass for nodekits.
Definition: SoBaseKit.h:57
SbBool connectionsSetUp
Definition: SoBaseKit.h:142
SoChildList * children
Definition: SoBaseKit.h:141
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:41
The SoCallbackAction class invokes callbacks at specific nodes.
Definition: SoCallbackAction.h:70
The SoChildList class is a container for node children.
Definition: SoChildList.h:33
The SoFieldContainer class is a base class for all classes that contain fields.
Definition: SoFieldContainer.h:35
SbBool set(const char *const fielddata)
Definition: SoFieldContainer.cpp:291
virtual void addWriteReference(SoOutput *out, SbBool isfromfield=0)
Definition: SoFieldContainer.cpp:605
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition: SoGLRenderAction.h:39
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.
Definition: SoGetBoundingBoxAction.h:34
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph.
Definition: SoGetMatrixAction.h:35
The SoGetPrimitiveCountAction class counts the primitives in a scene.
Definition: SoGetPrimitiveCountAction.h:32
The SoGroup class is a node which managed other node instances.
Definition: SoGroup.h:31
The SoHandleEventAction class distributes user events to the scene.
Definition: SoHandleEventAction.h:36
The SoInput class is an abstraction of file import functionality.
Definition: SoInput.h:55
The SoInteractionKit class is a base class for draggers.
Definition: SoInteractionKit.h:41
The SoNodeKitPath class is a path that contains only nodekit nodes.
Definition: SoNodeKitPath.h:33
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:47
virtual SoChildList * getChildren(void) const
Definition: SoNode.cpp:1265
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
Definition: SoNode.cpp:846
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoNode.cpp:1031
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Definition: SoNode.cpp:817
virtual void doAction(SoAction *action)
Definition: SoNode.cpp:761
virtual void callback(SoCallbackAction *action)
Definition: SoNode.cpp:974
virtual void getMatrix(SoGetMatrixAction *action)
Definition: SoNode.cpp:1001
virtual SbBool readInstance(SoInput *in, unsigned short flags)
Definition: SoNode.cpp:1438
virtual SoNode * addToCopyDict(void) const
Definition: SoNode.cpp:1334
virtual void rayPick(SoRayPickAction *action)
Definition: SoNode.cpp:1087
virtual void copyContents(const SoFieldContainer *from, SbBool copyconnections)
Definition: SoNode.cpp:1382
virtual void search(SoSearchAction *action)
Definition: SoNode.cpp:1120
virtual void write(SoWriteAction *action)
Definition: SoNode.cpp:1189
virtual void GLRender(SoGLRenderAction *action)
Definition: SoNode.cpp:904
The SoNodekitCatalog class is a container for nodekit layouts.
Definition: SoNodekitCatalog.h:36
The SoOutput class is an abstraction of an output stream.
Definition: SoOutput.h:42
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:43
The SoRayPickAction class does ray intersection with scene graphs.
Definition: SoRayPickAction.h:40
The SoSearchAction class provides methods for searching through scene graphs.
Definition: SoSearchAction.h:32
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:50
The SoWriteAction class writes a scene graph to file.
Definition: SoWriteAction.h:31

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 21 2021 for Coin by Doxygen. 1.9.1