1 /**************************************************************************\
2 * Copyright (c) Kongsberg Oil & Gas Technologies AS
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32
33 #ifdef HAVE_CONFIG_H
34 #include "config.h"
35 #endif // HAVE_CONFIG_H
36
37 #ifdef HAVE_NODEKITS
38
39 /*!
40 \class SoNodeKitDetail SoNodeKitDetail.h Inventor/details/SoNodeKitDetail.h
41 \brief The SoNodeKitDetail class is yet to be documented.
42
43 \ingroup details
44
45 When a pick action is executed and geometry within a nodekit is hit,
46 the nodekit generates an SoNodeKitDetail object which contains
47 information about the specific part inside the nodekit hit by the pick
48 ray.
49
50 \sa SoRayPickAction
51 */
52
53 #include <Inventor/details/SoNodeKitDetail.h>
54 #include <Inventor/nodekits/SoBaseKit.h>
55
56 /*!
57 \var SoBaseKit * SoNodeKitDetail::myNodeKit
58 The nodekit generating this details object.
59 */
60 /*!
61 \var SoNode * SoNodeKitDetail::myPart
62 Node inside nodekit which was hit.
63 */
64 /*!
65 \var SbName SoNodeKitDetail::myPartName
66 Catalog name of nodekit part which was hit.
67 */
68
69
70 SO_DETAIL_SOURCE(SoNodeKitDetail);
71
72 /*!
73 Constructor.
74 */
SoNodeKitDetail(void)75 SoNodeKitDetail::SoNodeKitDetail(void)
76 : myNodeKit(NULL), myPart(NULL), myPartName("")
77 {
78 }
79
80 /*!
81 Destructor.
82 */
~SoNodeKitDetail()83 SoNodeKitDetail::~SoNodeKitDetail()
84 {
85 if (this->myNodeKit) myNodeKit->unref();
86 if (this->myPart) myPart->unref();
87 }
88
89 // Doc in superclass.
90 void
initClass(void)91 SoNodeKitDetail::initClass(void)
92 {
93 SoNodeKitDetail::classTypeId =
94 SoType::createType(inherited::getClassTypeId(),
95 SbName("SoNodeKitDetail"));
96 }
97
98 // Doc in superclass.
99 SoDetail *
copy(void) const100 SoNodeKitDetail::copy(void) const
101 {
102 SoNodeKitDetail * copy = new SoNodeKitDetail();
103 copy->myNodeKit = this->myNodeKit;
104 copy->myPart = this->myPart;
105 copy->myPartName = this->myPartName;
106
107 // got to ref once more if set
108 if (this->myNodeKit) this->myNodeKit->ref();
109 if (this->myPart) this->myPart->ref();
110
111 return copy;
112 }
113
114 /*!
115 Set the pointer indicating which nodekit generated this detail object.
116 */
117 void
setNodeKit(SoBaseKit * kit)118 SoNodeKitDetail::setNodeKit(SoBaseKit * kit)
119 {
120 if (this->myNodeKit) this->myNodeKit->unref();
121 this->myNodeKit = kit;
122 if (kit) kit->ref();
123 }
124
125 /*!
126 Returns a pointer to the nodekit generating this details object.
127 */
128 SoBaseKit *
getNodeKit(void) const129 SoNodeKitDetail::getNodeKit(void) const
130 {
131 return this->myNodeKit;
132 }
133
134 /*!
135 Set the pointer indicating which node inside the nodekit was hit
136 by a pick.
137 */
138 void
setPart(SoNode * part)139 SoNodeKitDetail::setPart(SoNode * part)
140 {
141 if (this->myPart) this->myPart->unref();
142 this->myPart = part;
143 if (part) part->ref();
144 }
145
146 /*!
147 Return node inside nodekit which was hit.
148 */
149 SoNode *
getPart(void) const150 SoNodeKitDetail::getPart(void) const
151 {
152 return this->myPart;
153 }
154
155 /*!
156 Set catalog name of node part which was hit.
157 */
158 void
setPartName(const SbName & name)159 SoNodeKitDetail::setPartName(const SbName & name)
160 {
161 this->myPartName = name;
162 }
163
164 /*!
165 Return catalog name of nodekit part which was hit.
166 */
167 const SbName &
getPartName(void) const168 SoNodeKitDetail::getPartName(void) const
169 {
170 return this->myPartName;
171 }
172
173 #endif // HAVE_NODEKITS
174