Open Inventor Reference
SoBaseKit.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | Defines the SoBaseKit class. A base class for all
48  | of the SoNodeKit classes
49  |
50  | Author(s) : Paul Isaacs, Thad Beier
51  |
52  ______________ S I L I C O N G R A P H I C S I N C . ____________
53  _______________________________________________________________________
54 */
55 
56 #ifndef _SO_BASE_KIT_
57 #define _SO_BASE_KIT_
58 
63 #include <Inventor/nodes/SoNode.h>
66 #include <Inventor/SoNodeKitPath.h>
67 
68 class SoSeparator;
69 class SbBox3f;
70 class SbDict;
71 class SoGroup;
72 
73 
76 
261 
262 class INVENTOR_API SoBaseKit : public SoNode {
263 
270 
271  private:
272  static SoNodekitCatalog *nodekitCatalog; /* design of this class */
273  static const SoNodekitCatalog **parentNodekitCatalogPtr; /* parent design */
274  public:
277  { return nodekitCatalog; }
278 
279  /* Returns an SoNodekitCatalog for the node */
285  virtual const SoNodekitCatalog *getNodekitCatalog() const;
287 
288  protected:
290  { return (const SoNodekitCatalog **)&nodekitCatalog; }
291 
294 
295  public:
296 
299 
351  virtual SoNode *getPart( const SbName &partName, bool makeIfNeeded );
352 
357  SbString getPartString( const SoBase *part );
358 
371  virtual SoNodeKitPath *createPathToPart( const SbName &partName,
372  bool makeIfNeeded, const SoPath *pathToExtend = NULL );
373 
397  virtual bool setPart( const SbName &partName, SoNode *from );
398 
403  bool set(char *nameValuePairListString);
404  bool set(char *partNameString, char *parameterString);
405 
408  static bool isSearchingChildren() { return searchingChildren; }
411  static void setSearchingChildren( bool newVal );
412 
413  SoEXTENDER public:
414  virtual void doAction( SoAction *action );
416  virtual void callback( SoCallbackAction *action );
417  virtual void GLRender( SoGLRenderAction *action );
418  virtual void getBoundingBox( SoGetBoundingBoxAction *action );
419  virtual void getMatrix(SoGetMatrixAction *action );
420  virtual void handleEvent( SoHandleEventAction *action );
421  virtual void rayPick( SoRayPickAction *action );
422  virtual void search( SoSearchAction *action );
423  virtual void write( SoWriteAction *action );
424 
425  SoINTERNAL public:
426  static void initClass();
427 
429  virtual SoChildList *getChildren() const;
430 
431  static SoNode *typeCheck( const SbName &partName, const SoType &partType,
432  SoNode *node );
433 
434  void printDiagram();
435  void printSubDiagram( const SbName &rootName, int level );
436  void printTable();
437 
440  virtual void addWriteReference(SoOutput *out,
441  bool isFromField = FALSE);
442 
443  friend class SoNodekitCatalogEntry;
444  friend class SoNodekitParts;
445  friend class SoV1BaseKit;
446 
457 
458  protected:
459 
461 
463  virtual SoNode * addToCopyDict() const;
464 
466  virtual void copyContents(const SoFieldContainer *fromFC,
467  bool copyConnections);
468 
471  SoGroup *getContainerNode( const SbName &listName,
472  bool makeIfNeeded = TRUE );
473 
478  virtual SoNode *getAnyPart( const SbName &partName, bool makeIfNeeded,
479  bool leafCheck = FALSE, bool publicCheck = FALSE );
480  virtual SoNodeKitPath *createPathToAnyPart(const SbName &partName,
481  bool makeIfNeeded,
482  bool leafCheck = FALSE, bool publicCheck = FALSE,
483  const SoPath *pathToExtend = NULL );
484  virtual bool setAnyPart( const SbName &partName, SoNode *from,
485  bool anyPart = TRUE );
486 
489 
494  virtual void createDefaultParts();
495 
498  { return nodekitPartsList; };
499 
501  void catalogError();
502 
513  virtual bool setUpConnections( bool onOff, bool doItAlways = FALSE );
515 
517  virtual bool readInstance(SoInput *in, unsigned short flags);
518 
530 
551 
552  virtual ~SoBaseKit();
553 
554  private:
555  void skipWhiteSpace(char *&string);
556 
559  bool isNodeFieldValuesImportant( SoNode *n );
560 
563  void createFieldDataForWriting();
566  SoFieldData *fieldDataForWriting;
567 
569  bool readMyFields(SoInput *in, SoFieldData *&unknownFieldData );
570 
579  void undoSetDefaultOnFieldsThatMustWrite();
580 
582  int getNumChildren() const { return (children->getLength()); }
583  void removeChild( int index );
584  void removeChild( SoNode *child ) { removeChild(findChild(child)); }
585  void addChild( SoNode *child );
586  int findChild( const SoNode *child ) const;
587  void insertChild( SoNode *child, int newChildIndex );
588  SoNode *getChild( int index) const { return (*children)[index]; }
589  void replaceChild( int index, SoNode *newChild);
590  void replaceChild( SoNode *oldChild, SoNode *newChild)
591  { replaceChild(findChild(oldChild),newChild); }
592 
593  static bool searchingChildren;
594 };
595 
608 
609 
610 #ifdef DEBUG
611 #define SO_GET_PART( kitContainingPart, partName, partClassName ) \
612  ((partClassName *) SoBaseKit::typeCheck( partName, \
613  partClassName::getClassTypeId(), \
614  kitContainingPart->getPart( partName, TRUE )))
615 
616 #define SO_CHECK_PART( kitContainingPart, partName, partClassName ) \
617  ((partClassName *) SoBaseKit::typeCheck( partName, \
618  partClassName::getClassTypeId(), \
619  kitContainingPart->getPart( partName, FALSE )))
620 
621 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName ) \
622  ((partClassName *) SoBaseKit::typeCheck( partName, \
623  partClassName::getClassTypeId(), \
624  kitContainingPart->getAnyPart( partName, TRUE, FALSE, FALSE )))
625 
626 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName ) \
627  ((partClassName *) SoBaseKit::typeCheck( partName, \
628  partClassName::getClassTypeId(), \
629  kitContainingPart->getAnyPart( partName, FALSE, FALSE, FALSE )))
630 #else
631 
632 #define SO_GET_PART( kitContainingPart, partName, partClassName ) \
633  ((partClassName *) kitContainingPart->getPart( partName, TRUE ))
634 #define SO_CHECK_PART( kitContainingPart, partName, partClassName ) \
635  ((partClassName *) kitContainingPart->getPart( partName, FALSE ))
636 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName ) \
637  ((partClassName *) kitContainingPart->getAnyPart( partName, TRUE, \
638  FALSE, FALSE ))
639 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName ) \
640  ((partClassName *) kitContainingPart->getAnyPart( partName, FALSE, \
641  FALSE, FALSE ))
642 #endif
643 
644 #endif /* _SO_BASE_KIT_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define TRUE
Definition: SbBasic.h:76
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
#define SO_NODE_HEADER(className)
Non-abstract classes have everything abstract classes have, plus a way to create an instance.
Definition: SoSubNode.h:170
3D box class.
Definition: SbBox.h:81
This is a dictionary mapping (size_t) integer keys to (void *) data pointers.
Definition: SbDict.h:101
Character string stored in a hash table.
Definition: SbString.h:264
int getLength() const
Returns number of pointers in list.
Definition: SbPList.h:110
Class for smart character strings.
Definition: SbString.h:85
Abstract base class for all actions.
Definition: SoAction.h:179
Base class for all node kits.
Definition: SoBaseKit.h:262
virtual SoChildList * getChildren() const
Returns pointer to children.
virtual void handleEvent(SoHandleEventAction *action)
virtual void search(SoSearchAction *action)
void createNodekitPartsList()
called during construction to create parts list
void printSubDiagram(const SbName &rootName, int level)
virtual SoNodeKitPath * createPathToAnyPart(const SbName &partName, bool makeIfNeeded, bool leafCheck=FALSE, bool publicCheck=FALSE, const SoPath *pathToExtend=NULL)
virtual bool setUpConnections(bool onOff, bool doItAlways=FALSE)
detach/attach any sensors, callbacks, and/or field connections.
static bool isSearchingChildren()
Sets and queries if nodekit children are searched during SoSearchAction traversal.
Definition: SoBaseKit.h:408
virtual void rayPick(SoRayPickAction *action)
virtual void GLRender(SoGLRenderAction *action)
These virtual functions implement all of the actions for nodes, Most of the default implementations d...
virtual void copyContents(const SoFieldContainer *fromFC, bool copyConnections)
Copies the contents of the given nodekit into this instance.
bool set(char *partNameString, char *parameterString)
void printTable()
static void initClass()
virtual const SoNodekitCatalog * getNodekitCatalog() const
Returns the SoNodekitCatalog for this instance of SoBaseKit.
virtual void createDefaultParts()
called during construction to create any parts that are created by default (such as the cube in the S...
SoBaseKit()
Constructor.
virtual ~SoBaseKit()
SO_KIT_CATALOG_ENTRY_HEADER(callbackList)
Define fields for the new parts of the kit...
static const SoNodekitCatalog ** getClassNodekitCatalogPtr()
...end of contents of SO_KIT_HEADER
Definition: SoBaseKit.h:289
virtual SoNodeKitPath * createPathToPart(const SbName &partName, bool makeIfNeeded, const SoPath *pathToExtend=NULL)
Returns a path that begins at this nodekit and ends at partName.
virtual SoNode * addToCopyDict() const
Redefines this to add this node and all part nodes to the dictionary.
virtual bool readInstance(SoInput *in, unsigned short flags)
Reads in from file. Takes care of setting parts and stuff.
virtual SoNode * getPart(const SbName &partName, bool makeIfNeeded)
Searches the nodekit catalog (and those of all nested nodekits) for the part named partName.
static void setSearchingChildren(bool newVal)
Sets and queries if nodekit children are searched during SoSearchAction traversal.
bool forceChildDrivenWriteRefs(SoOutput *out)
This returns TRUE if the nodekit intends to write out.
virtual void addWriteReference(SoOutput *out, bool isFromField=FALSE)
Overrides the default method to use countMyFields() instead of the regular SoFieldData writing mechan...
virtual SoNode * getAnyPart(const SbName &partName, bool makeIfNeeded, bool leafCheck=FALSE, bool publicCheck=FALSE)
like their public versions, but are allowed access to non-leaf and private parts.
static SoNode * typeCheck(const SbName &partName, const SoType &partType, SoNode *node)
virtual bool setPart(const SbName &partName, SoNode *from)
Inserts the given node (not a copy) as the new part specified by partName.
SoNodekitParts * nodekitPartsList
parts list.
Definition: SoBaseKit.h:488
virtual void getMatrix(SoGetMatrixAction *action)
void printDiagram()
virtual void doAction(SoAction *action)
This method performs the "typical" operation of a node for any action.
virtual void callback(SoCallbackAction *action)
These functions implement all actions for nodekits.
virtual void setDefaultOnNonWritingFields()
This is called during countMyFields() method.
virtual void write(SoWriteAction *action)
SoGroup * getContainerNode(const SbName &listName, bool makeIfNeeded=TRUE)
Returns the containerNode within the SoNodeKitListPart given by listName.
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
void countMyFields(SoOutput *out)
This is called during addWriteReference() to write the fields.
void catalogError()
Prints an Error when there's trouble building a catalog.
virtual bool setAnyPart(const SbName &partName, SoNode *from, bool anyPart=TRUE)
const SoNodekitParts * getNodekitPartsList() const
Return the node's partsList.
Definition: SoBaseKit.h:497
bool set(char *nameValuePairListString)
SETTING FIELDS OF PARTS.
SbString getPartString(const SoBase *part)
Given a node or a path to a node, checks if the part exists in the nodekit, in a nested nodekit,...
SoChildList * children
Definition: SoBaseKit.h:460
bool connectionsSetUp
Definition: SoBaseKit.h:514
static const SoNodekitCatalog * getClassNodekitCatalog()
Returns the SoNodekitCatalog for the class SoBaseKit.
Definition: SoBaseKit.h:276
Base class for all nodes, paths, and engines.
Definition: SoBase.h:90
Performs a generic traversal of the scene graph.
This class maintains a list of child nodes for any node.
Definition: SoChildList.h:83
Abstract base class for objects that contain fields.
The SoFieldData class holds data about fields of an object: the number of fields the object has,...
Definition: SoFieldData.h:88
Renders a scene graph using OpenGL.
Computes bounding box of a scene.
Computes transformation matrix for subgraph.
Base class for all group nodes.
Definition: SoGroup.h:104
Allows nodes in a graph to receive input events.
Used to read Inventor data files.
Definition: SoInput.h:128
Path that points to a list of hierarchical nodekits.
Abstract base class for all database nodes.
Definition: SoNode.h:103
an internal class that should be accessed only by an SoNodekitCatalog
Nodekit catalog class.
Used to write Inventor data files.
Definition: SoOutput.h:90
Path that points to a list of hierarchical nodes.
Definition: SoPath.h:109
Intersects objects with a ray cast into scene.
Searches for nodes in a scene graph.
Group node that saves and restores traversal state.
Definition: SoSeparator.h:118
SoType has no virtual functions to keep it small...
Definition: SoType.h:103
Writes a scene graph to a file.
Definition: SoWriteAction.h:80