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

SoPath.h
1 #ifndef COIN_SOPATH_H
2 #define COIN_SOPATH_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/misc/SoBase.h>
28 #include <Inventor/lists/SbList.h>
29 #include <Inventor/lists/SoNodeList.h>
30 
31 #ifndef COIN_INTERNAL
32 // For SGI / TGS Open Inventor compile-time compatibility.
33 #include <Inventor/SoLists.h>
34 #endif // !COIN_INTERNAL
35 
36 
37 class SoWriteAction;
38 class SoNotList;
39 class SoInput;
40 class SoPathList;
41 
42 
43 class COIN_DLL_API SoPath : public SoBase {
44  typedef SoBase inherited;
45 
46 public:
47  static void initClass(void);
48 
49  SoPath(const int approxlength = 4);
50  SoPath(SoNode * const head);
51  SoPath(const SoPath & rhs);
52 
53  SoPath & operator=(const SoPath & rhs);
54 
55  static SoType getClassTypeId(void);
56  virtual SoType getTypeId(void) const;
57 
58  void setHead(SoNode * const head);
59  SoNode * getHead(void) const;
60  void append(const int childindex);
61  void append(SoNode * const node);
62  void append(const SoPath * const frompath);
63  void push(const int childindex);
64  void pop(void);
65  SoNode * getTail(void) const;
66  SoNode * getNode(const int index) const;
67  SoNode * getNodeFromTail(const int index) const;
68  int getIndex(const int index) const;
69  int getIndexFromTail(const int index) const;
70  int getLength(void) const;
71  void truncate(const int length);
72 
73  int findFork(const SoPath * const path) const;
74  int findNode(const SoNode * const node) const;
75 
76  SbBool containsNode(const SoNode * const node) const;
77  SbBool containsPath(const SoPath * const path) const;
78  SoPath * copy(const int startfromnodeindex = 0, int numnodes = 0) const;
79  friend COIN_DLL_API SbBool operator==(const SoPath & lhs, const SoPath & rhs);
80  friend COIN_DLL_API SbBool operator!=(const SoPath & lhs, const SoPath & rhs);
81 
82  static SoPath * getByName(const SbName name);
83  static int getByName(const SbName name, SoPathList & l);
84 
85  void insertIndex(SoNode * const parent, const int newindex);
86  void removeIndex(SoNode * const parent, const int oldindex);
87  void replaceIndex(SoNode * const parent, const int index,
88  SoNode * const newchild);
89  SbBool isRelevantNotification(SoNotList * const l) const;
90 
91  virtual void write(SoWriteAction * action);
92 
93 protected:
94  virtual ~SoPath();
95  void auditPath(const SbBool flag);
96 
97 private:
98  static void * createInstance(void);
99  void append(SoNode * const node, const int index);
100  int getFullLength(void) const;
101  void truncate(const int length, const SbBool donotify);
102  virtual SbBool readInstance(SoInput * in, unsigned short flags);
103  void setFirstHidden(void);
104 
105  SoNodeList nodes;
106  SbList<int> indices;
107  SbBool isauditing;
108  int firsthidden;
109  SbBool firsthiddendirty;
110  static SoType classTypeId;
111 
112  friend class SoFullPath;
113  friend class SoNodeKitPath;
114  friend class SoAction;
115  friend class SoTempPath;
116 };
117 
119 
120 inline int
121 SoPath::getFullLength(void) const
122 {
123  return this->nodes.getLength();
124 }
125 
126 inline void
127 SoPath::push(const int childindex)
128 {
129  this->append(childindex);
130 }
131 
132 inline void
134 {
135  this->truncate(this->getFullLength() - 1);
136 }
137 
139 
140 
141 #ifndef COIN_INTERNAL
142 // For SGI / TGS Open Inventor compile-time compatibility.
143 #include <Inventor/SoFullPath.h>
144 #include <Inventor/misc/SoLightPath.h>
145 #endif // COIN_INTERNAL
146 
147 #endif // !COIN_SOPATH_H
SoPath::getIndexFromTail
int getIndexFromTail(const int index) const
Definition: SoPath.cpp:455
SbPList::getLength
int getLength(void) const
Definition: SbPList.h:94
SoPath::isRelevantNotification
SbBool isRelevantNotification(SoNotList *const l) const
Definition: SoPath.cpp:976
SoType::badType
static SoType badType(void)
Definition: SoType.cpp:664
SoBase::getNamedBase
static SoBase * getNamedBase(const SbName &name, SoType type)
Definition: SoBase.cpp:1072
SoReadError::post
static void post(const SoInput *const in, const char *const format,...)
Definition: SoReadError.cpp:110
SoPath::auditPath
void auditPath(const SbBool flag)
Definition: SoPath.cpp:1026
SbList::getArrayPtr
const Type * getArrayPtr(const int start=0) const
Definition: SbList.h:168
SbName
The SbName class stores strings by reference.
Definition: SbName.h:31
SoPath::~SoPath
virtual ~SoPath()
Definition: SoPath.cpp:155
SoPath::getTypeId
virtual SoType getTypeId(void) const
Definition: SoPath.cpp:1043
SoPath::getTail
SoNode * getTail(void) const
Definition: SoPath.cpp:373
SoPath::push
void push(const int childindex)
Definition: SoPath.h:127
SoNodeList::append
void append(SoNode *const ptr)
Definition: SoNodeList.cpp:80
SoChildList
The SoChildList class is a container for node children.
Definition: SoChildList.h:33
SoDebugError::post
static void post(const char *const source, const char *const format,...)
Definition: SoDebugError.cpp:314
SoWriteAction
The SoWriteAction class writes a scene graph to file.
Definition: SoWriteAction.h:31
SoNotList::getLastRec
SoNotRec * getLastRec(void) const
Definition: SoNotification.cpp:149
SoBaseList
The SoBaseList class is a container for pointers to SoBase derived objects.
Definition: SoBaseList.h:32
SoOutput::write
virtual void write(const char c)
Definition: SoOutput.cpp:757
SoPath::operator=
SoPath & operator=(const SoPath &rhs)
Definition: SoPath.cpp:128
SoOutput::indent
virtual void indent(void)
Definition: SoOutput.cpp:1074
SoOutput
The SoOutput class is an abstraction of an output stream.
Definition: SoOutput.h:42
SoNodeKitPath
The SoNodeKitPath class is a path that contains only nodekit nodes.
Definition: SoNodeKitPath.h:33
SoBaseList::truncate
void truncate(const int length)
Definition: SoBaseList.cpp:156
SoPath::getByName
static SoPath * getByName(const SbName name)
Definition: SoPath.cpp:718
SbList::truncate
void truncate(const int length, const int dofit=0)
Definition: SbList.h:149
SoNotRec::getBase
SoBase * getBase(void) const
Definition: SoNotRec.cpp:71
SoBase::getClassTypeId
static SoType getClassTypeId(void)
Definition: SoBase.cpp:720
SoDebugError::postWarning
static void postWarning(const char *const source, const char *const format,...)
Definition: SoDebugError.cpp:324
SoAction
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:67
SoFullPath
The SoFullPath class allows examination of hidden children in paths.
Definition: SoFullPath.h:29
SoBase::readInstance
virtual SbBool readInstance(SoInput *in, unsigned short flags)=0
SoNotRec
The SoNotRec class specifies records for notification lists.
Definition: SoNotRec.h:33
SoPathList
The SoPathList class is a container for pointers to SoPath objects.
Definition: SoPathList.h:31
SbList::append
void append(const Type item)
Definition: SbList.h:98
SoPath::containsPath
SbBool containsPath(const SoPath *const path) const
Definition: SoPath.cpp:611
SoBase::writeHeader
SbBool writeHeader(SoOutput *out, SbBool isgroup, SbBool isengine) const
Definition: SoBase.cpp:1315
SoPathList::append
void append(SoPath *const path)
Definition: SoPathList.cpp:88
SoPath::findNode
int findNode(const SoNode *const node) const
Definition: SoPath.cpp:587
SoPath
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:43
SoBase::getNamedBases
static int getNamedBases(const SbName &name, SoBaseList &baselist, SoType type)
Definition: SoBase.cpp:1096
SoPath::pop
void pop(void)
Definition: SoPath.h:133
SoType
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:50
SoOutput::isBinary
virtual SbBool isBinary(void) const
Definition: SoOutput.cpp:650
SoPath::getLength
int getLength(void) const
Definition: SoPath.cpp:473
SbList< int >
SbName::getString
const char * getString(void) const
Definition: SbName.cpp:278
SoDebugError::postInfo
static void postInfo(const char *const source, const char *const format,...)
Definition: SoDebugError.cpp:334
SoChildList::removePathAuditor
void removePathAuditor(SoPath *const path)
Definition: SoChildList.cpp:451
SoBase::read
static SbBool read(SoInput *in, SoBase *&base, SoType expectedtype)
Definition: SoBase.cpp:1146
SoPath::write
virtual void write(SoWriteAction *action)
Definition: SoPath.cpp:933
SbList::getLength
int getLength(void) const
Definition: SbList.h:145
SoWriteAction::continueToApply
void continueToApply(SoNode *node)
Definition: SoWriteAction.cpp:173
SoBase::addWriteReference
virtual void addWriteReference(SoOutput *out, SbBool isfromfield=0)
Definition: SoBase.cpp:1002
SoWriteAction::getOutput
SoOutput * getOutput(void) const
Definition: SoWriteAction.cpp:160
SoChildList::addPathAuditor
void addPathAuditor(SoPath *const path)
Definition: SoChildList.cpp:437
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:41
SoPath::getNodeFromTail
SoNode * getNodeFromTail(const int index) const
Definition: SoPath.cpp:419
SbBox2i32::operator!=
int operator!=(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:91
SoPath::append
void append(const int childindex)
Definition: SoPath.cpp:191
SoPath::replaceIndex
void replaceIndex(SoNode *const parent, const int index, SoNode *const newchild)
Definition: SoPath.cpp:817
SoPath::setHead
void setHead(SoNode *const head)
Definition: SoPath.cpp:167
SoNode::getChildren
virtual SoChildList * getChildren(void) const
Definition: SoNode.cpp:1265
SoBase::startNotify
virtual void startNotify(void)
Definition: SoBase.cpp:857
SoPath::copy
SoPath * copy(const int startfromnodeindex=0, int numnodes=0) const
Definition: SoPath.cpp:673
SoFullPath::getNodeFromTail
SoNode * getNodeFromTail(const int index) const
Definition: SoFullPath.cpp:85
SoBase::getTypeId
virtual SoType getTypeId(void) const =0
SoOutput::getStage
Stage getStage(void) const
Definition: SoOutput.cpp:744
SoPath::insertIndex
void insertIndex(SoNode *const parent, const int newindex)
Definition: SoPath.cpp:750
SoType::createType
static const SoType createType(const SoType parent, const SbName name, const instantiationMethod method=(instantiationMethod) NULL, const uint16_t data=0)
Definition: SoType.cpp:256
SoPath::findFork
int findFork(const SoPath *const path) const
Definition: SoPath.cpp:565
SoPath::truncate
void truncate(const int length)
Definition: SoPath.cpp:493
SoInput::read
virtual SbBool read(char &c)
Definition: SoInput.cpp:1180
SoPath::getIndex
int getIndex(const int index) const
Definition: SoPath.cpp:436
SoBase::writeFooter
void writeFooter(SoOutput *out) const
Definition: SoBase.cpp:1428
SoNodeList
The SoNodeList class is a container for pointers to SoNode objects.
Definition: SoNodeList.h:31
SoBase::assertAlive
void assertAlive(void) const
Definition: SoBase.cpp:546
SoPath::getNode
SoNode * getNode(const int index) const
Definition: SoPath.cpp:402
SbPList::find
int find(void *item) const
Definition: SbPList.cpp:212
SoInput
The SoInput class is an abstraction of file import functionality.
Definition: SoInput.h:55
SoBase::isOfType
SbBool isOfType(SoType type) const
Definition: SoBase.cpp:710
SoNode
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:47
SoPath::removeIndex
void removeIndex(SoNode *const parent, const int oldindex)
Definition: SoPath.cpp:779
SoType::getName
SbName getName(void) const
Definition: SoType.cpp:628
SoFullPath::getLength
int getLength(void) const
Definition: SoFullPath.cpp:106
SoBase::initClass
static void initClass(void)
Definition: SoBase.cpp:455
SoPath::SoPath
SoPath(const int approxlength=4)
Definition: SoPath.cpp:98
SoBaseList::isReferencing
SbBool isReferencing(void) const
Definition: SoBaseList.cpp:260
SbBox2i32::operator==
int operator==(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:87
SoPath::containsNode
SbBool containsNode(const SoNode *const node) const
Definition: SoPath.cpp:601
SoNotList
The SoNotList class is a list of SoNotRec notification records.
Definition: SoNotification.h:34
SoBase::hasMultipleWriteRefs
SbBool hasMultipleWriteRefs(void) const
Definition: SoBase.cpp:1286
SoNotRec::getPrevious
const SoNotRec * getPrevious(void) const
Definition: SoNotRec.cpp:90
SoPath::getHead
SoNode * getHead(void) const
Definition: SoPath.cpp:180
SbPList::getArrayPtr
void ** getArrayPtr(const int start=0) const
Definition: SbPList.h:110
SoNotRec::getType
SoNotRec::Type getType(void) const
Definition: SoNotRec.cpp:80

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

Generated on Wed Jul 24 2019 for Coin by Doxygen. 1.8.17