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_VRML97
38 
39 /*!
40   \class SoVRMLVertexLine SoVRMLVertexLine.h Inventor/VRMLnodes/SovRMLVertexLine.h
41   \brief The SoVRMLVertexLine class is a superclass for line based VRML geometry.
42 */
43 
44 /*!
45   \var SoSFNode SoVRMLVertexLine::coord
46   Should contain an SoVRMLCoordinate node.
47 */
48 
49 /*!
50   \var SoSFNode SoVRMLVertexLine::color
51   Can contain an SoVRMLColor node if multiple colors are wanted.
52 */
53 
54 /*!
55   \var SoSFBool SoVRMLVertexLine::colorPerVertex
56 
57   When TRUE, colors will be bound per vertex, otherwise per
58   line. Default value is TRUE.
59 
60 */
61 
62 #include <Inventor/VRMLnodes/SoVRMLVertexLine.h>
63 
64 #include <cstddef>
65 
66 #include <Inventor/VRMLnodes/SoVRMLMacros.h>
67 #include <Inventor/actions/SoGLRenderAction.h>
68 
69 #include "nodes/SoSubNodeP.h"
70 
71 SO_NODE_ABSTRACT_SOURCE(SoVRMLVertexLine);
72 
73 // Doc in parent
74 void
initClass(void)75 SoVRMLVertexLine::initClass(void)
76 {
77   SO_NODE_INTERNAL_INIT_ABSTRACT_CLASS(SoVRMLVertexLine, SO_VRML97_NODE_TYPE);
78 }
79 
80 /*!
81   Constructor.
82 */
SoVRMLVertexLine(void)83 SoVRMLVertexLine::SoVRMLVertexLine(void)
84 {
85   SO_VRMLNODE_INTERNAL_CONSTRUCTOR(SoVRMLVertexLine);
86 
87   SO_VRMLNODE_ADD_EXPOSED_FIELD(coord, (NULL));
88   SO_VRMLNODE_ADD_EXPOSED_FIELD(color, (NULL));
89   SO_VRMLNODE_ADD_FIELD(colorPerVertex, (TRUE));
90 }
91 
92 /*!
93   Destructor.
94 */
~SoVRMLVertexLine()95 SoVRMLVertexLine::~SoVRMLVertexLine()
96 {
97 }
98 
99 // Doc in parent
100 void
doAction(SoAction * action)101 SoVRMLVertexLine::doAction(SoAction * action)
102 {
103   SoNode * node;
104 
105   node = this->coord.getValue();
106   if (node) node->doAction(action);
107 
108   node = this->color.getValue();
109   if (node) node->doAction(action);
110 }
111 
112 // Doc in parent
113 void
GLRender(SoGLRenderAction * action)114 SoVRMLVertexLine::GLRender(SoGLRenderAction * action)
115 {
116   SoNode * node;
117 
118   node = this->coord.getValue();
119   if (node) node->GLRender(action);
120 
121   node = this->color.getValue();
122   if (node) node->GLRender(action);
123 }
124 
125 // Doc in parent
126 void
getBoundingBox(SoGetBoundingBoxAction * action)127 SoVRMLVertexLine::getBoundingBox(SoGetBoundingBoxAction * action)
128 {
129   inherited::getBoundingBox(action);
130 }
131 
132 // Doc in parent
133 void
callback(SoCallbackAction * action)134 SoVRMLVertexLine::callback(SoCallbackAction * action)
135 {
136   inherited::callback(action);
137 }
138 
139 // Doc in parent
140 void
pick(SoPickAction * action)141 SoVRMLVertexLine::pick(SoPickAction * action)
142 {
143   inherited::pick(action);
144 }
145 
146 // Doc in parent
147 void
notify(SoNotList * list)148 SoVRMLVertexLine::notify(SoNotList * list)
149 {
150   inherited::notify(list);
151 }
152 
153 // Doc in parent
154 SbBool
shouldGLRender(SoGLRenderAction * action)155 SoVRMLVertexLine::shouldGLRender(SoGLRenderAction * action)
156 {
157   if (this->coord.getValue() == NULL) return FALSE;
158   return inherited::shouldGLRender(action);
159 }
160 
161 #endif // HAVE_VRML97
162