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 SoLightModelElement Inventor/elements/SoLightModelElement.h
35   \brief The SoLightModelElement class is yet to be documented.
36 
37   \ingroup elements
38 
39   FIXME: write doc.
40 */
41 
42 #include "coindefs.h"
43 #include "SbBasicP.h"
44 
45 #include <Inventor/elements/SoLightModelElement.h>
46 #include <Inventor/elements/SoLazyElement.h>
47 #include <cassert>
48 
49 /*!
50   \fn SoLightModelElement::Model
51 
52   FIXME: write doc.
53 */
54 
55 SO_ELEMENT_SOURCE(SoLightModelElement);
56 
57 /*!
58   This static method initializes static data for the
59   SoLightModelElement class.
60 */
61 
62 void
initClass()63 SoLightModelElement::initClass()
64 {
65   SO_ELEMENT_INIT_CLASS(SoLightModelElement, inherited);
66 }
67 
68 /*!
69   The destructor.
70 */
71 
~SoLightModelElement()72 SoLightModelElement::~SoLightModelElement()
73 {
74 }
75 
76 //! FIXME: write doc.
77 
78 void
init(SoState *)79 SoLightModelElement::init(SoState * /* state */)
80 {
81 }
82 
83 //! FIXME: write doc.
84 
85 void
set(SoState * const state,const Model model)86 SoLightModelElement::set(SoState * const state, const Model model)
87 {
88   SoLazyElement::setLightModel(state, static_cast<int32_t>(model));
89 }
90 
91 //! FIXME: write doc.
92 
93 void
set(SoState * const state,SoNode * const COIN_UNUSED_ARG (node),const Model model)94 SoLightModelElement::set(SoState * const state, SoNode * const COIN_UNUSED_ARG(node),
95                          const Model model)
96 {
97   SoLazyElement::setLightModel(state, static_cast<int32_t>(model));
98 }
99 
100 //! FIXME: write doc.
101 
102 SoLightModelElement::Model
get(SoState * const state)103 SoLightModelElement::get(SoState * const state)
104 {
105   return static_cast<SoLightModelElement::Model>(SoLazyElement::getLightModel(state));
106 }
107 
108 //! FIXME: write doc.
109 
110 SoLightModelElement::Model
getDefault()111 SoLightModelElement::getDefault()
112 {
113   return static_cast<SoLightModelElement::Model>(SoLazyElement::getDefaultLightModel());
114 }
115 
116 //! FIXME: write doc
117 
118 const SoLightModelElement *
getInstance(SoState * state)119 SoLightModelElement::getInstance(SoState *state)
120 {
121   //FIXME: Can this function or any of the similar functions ever
122   //return NULL? BFG 20080916
123   return coin_assert_cast<const SoLightModelElement *>
124     (
125      state->getElementNoPush(classStackIndex)
126      );
127 }
128