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 /*!
34   \class SoCacheHint SoCacheHint.h Inventor/nodes/SoCacheHint.h
35   \brief The SoCacheHint class is a node containing hints about how to cache geometry.
36 
37   \ingroup nodes
38 
39   The SoCacheHint node is used to set up clues to the rendering
40   subsystem about how Coin should cache vertex data.
41 
42   Please note that this is an experimental class. The API might change
43   a lot before/if it's included in any official Coin release.
44 
45   <b>FILE FORMAT/DEFAULTS:</b>
46   \code
47     CacheHint {
48         memValue 0.5
49         gfxValue 0.5
50     }
51   \endcode
52 */
53 
54 /*!
55   \var SoSFFloat SoCacheHint::memValue
56 
57   Sets the value for main memory usage. Should be a number between 0
58   and 1. A higher value will use more memory for caching.  Default
59   value is 0.5
60 
61 */
62 
63 /*!
64   \var SoSFFloat SoCacheHint::gfxValue
65 
66   Sets the value for gfx memory usage. Should be a number between 0
67   and 1. A higher value will use more memory for caching.  Default
68   value is 0.5
69 
70 */
71 
72 #include <Inventor/nodes/SoCacheHint.h>
73 
74 #include <Inventor/actions/SoCallbackAction.h>
75 #include <Inventor/actions/SoGLRenderAction.h>
76 #include <Inventor/actions/SoGetBoundingBoxAction.h>
77 #include <Inventor/actions/SoPickAction.h>
78 #include <Inventor/elements/SoCacheHintElement.h>
79 
80 #include "nodes/SoSubNodeP.h"
81 
82 // *************************************************************************
83 
84 SO_NODE_SOURCE(SoCacheHint);
85 
86 /*!
87   Constructor.
88 */
SoCacheHint(void)89 SoCacheHint::SoCacheHint(void)
90 {
91   SO_NODE_INTERNAL_CONSTRUCTOR(SoCacheHint);
92   SO_NODE_ADD_FIELD(memValue, (0.5f));
93   SO_NODE_ADD_FIELD(gfxValue, (0.5f));
94 }
95 
96 /*!
97   Destructor.
98 */
~SoCacheHint()99 SoCacheHint::~SoCacheHint()
100 {
101 }
102 
103 // doc in super
104 void
initClass(void)105 SoCacheHint::initClass(void)
106 {
107   SO_NODE_INTERNAL_INIT_CLASS(SoCacheHint, SO_FROM_COIN_2_4);
108 
109   SO_ENABLE(SoGLRenderAction, SoCacheHintElement);
110 }
111 
112 void
doAction(SoAction * action)113 SoCacheHint::doAction(SoAction * action)
114 {
115   SoState * state = action->getState();
116   SoCacheHintElement::set(state, this,
117                           this->memValue.getValue(),
118                           this->gfxValue.getValue());
119 }
120 
121 void
GLRender(SoGLRenderAction * action)122 SoCacheHint::GLRender(SoGLRenderAction * action)
123 {
124   SoCacheHint::doAction(action);
125 }
126 
127 void
callback(SoCallbackAction * action)128 SoCacheHint::callback(SoCallbackAction * action)
129 {
130   // do nothing
131   SoNode::callback(action);
132 }
133 
134 void
pick(SoPickAction * action)135 SoCacheHint::pick(SoPickAction * action)
136 {
137   // do nothing
138   SoNode::pick(action);
139 }
140 
141 void
getBoundingBox(SoGetBoundingBoxAction * action)142 SoCacheHint::getBoundingBox(SoGetBoundingBoxAction * action)
143 {
144   // do nothing
145   SoNode::getBoundingBox(action);
146 }
147