| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* Further, this software is distributed without any warranty that it is |
| 16 |
* free of the rightful claim of any third person regarding infringement |
| 17 |
* or the like. Any license provided herein, whether implied or |
| 18 |
* otherwise, applies only to this software file. Patent licenses, if |
| 19 |
* any, provided herein do not apply to combinations of this program with |
| 20 |
* other software, or any other product whatsoever. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU Lesser General Public |
| 23 |
* License along with this library; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 |
* Mountain View, CA 94043, or: |
| 28 |
* |
| 29 |
* http://www.sgi.com |
| 30 |
* |
| 31 |
* For further information regarding this notice, see: |
| 32 |
* |
| 33 |
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 |
* |
| 35 |
*/ |
| 36 |
|
| 37 |
/* |
| 38 |
* Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 |
* |
| 40 |
_______________________________________________________________________ |
| 41 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 |
| |
| 43 |
| $Revision: 1.1.1.1 $ |
| 44 |
| |
| 45 |
| Classes: |
| 46 |
| SoDrawStyle |
| 47 |
| |
| 48 |
| Author(s) : Paul S. Strauss |
| 49 |
| |
| 50 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 |
_______________________________________________________________________ |
| 52 |
*/ |
| 53 |
|
| 54 |
#include <Inventor/actions/SoCallbackAction.h> |
| 55 |
#include <Inventor/actions/SoGLRenderAction.h> |
| 56 |
#include <Inventor/elements/SoDrawStyleElement.h> |
| 57 |
#include <Inventor/elements/SoLinePatternElement.h> |
| 58 |
#include <Inventor/elements/SoLineWidthElement.h> |
| 59 |
#include <Inventor/elements/SoPointSizeElement.h> |
| 60 |
#include <Inventor/elements/SoOverrideElement.h> |
| 61 |
#include <Inventor/nodes/SoDrawStyle.h> |
| 62 |
|
| 63 |
SO_NODE_SOURCE(SoDrawStyle); |
| 64 |
|
| 65 |
//////////////////////////////////////////////////////////////////////// |
| 66 |
// |
| 67 |
// Description: |
| 68 |
// Constructor |
| 69 |
// |
| 70 |
// Use: public |
| 71 |
|
| 72 |
SoDrawStyle::SoDrawStyle() |
| 73 |
// |
| 74 |
//////////////////////////////////////////////////////////////////////// |
| 75 |
{ |
| 76 |
SO_NODE_CONSTRUCTOR(SoDrawStyle); |
| 77 |
|
| 78 |
SO_NODE_ADD_FIELD(style, (SoDrawStyleElement::getDefault())); |
| 79 |
SO_NODE_ADD_FIELD(pointSize, (SoPointSizeElement::getDefault())); |
| 80 |
SO_NODE_ADD_FIELD(lineWidth, (SoLineWidthElement::getDefault())); |
| 81 |
SO_NODE_ADD_FIELD(linePattern, (SoLinePatternElement::getDefault())); |
| 82 |
|
| 83 |
// Set up static info for enumerated type field |
| 84 |
SO_NODE_DEFINE_ENUM_VALUE(Style, FILLED); |
| 85 |
SO_NODE_DEFINE_ENUM_VALUE(Style, LINES); |
| 86 |
SO_NODE_DEFINE_ENUM_VALUE(Style, POINTS); |
| 87 |
SO_NODE_DEFINE_ENUM_VALUE(Style, INVISIBLE); |
| 88 |
|
| 89 |
// Set up info in enumerated type field |
| 90 |
SO_NODE_SET_SF_ENUM_TYPE(style, Style); |
| 91 |
|
| 92 |
isBuiltIn = TRUE; |
| 93 |
} |
| 94 |
|
| 95 |
//////////////////////////////////////////////////////////////////////// |
| 96 |
// |
| 97 |
// Description: |
| 98 |
// Destructor |
| 99 |
// |
| 100 |
// Use: private |
| 101 |
|
| 102 |
SoDrawStyle::~SoDrawStyle() |
| 103 |
// |
| 104 |
//////////////////////////////////////////////////////////////////////// |
| 105 |
{ |
| 106 |
} |
| 107 |
|
| 108 |
//////////////////////////////////////////////////////////////////////// |
| 109 |
// |
| 110 |
// Description: |
| 111 |
// Handles actions. |
| 112 |
// |
| 113 |
// Use: extender |
| 114 |
|
| 115 |
void |
| 116 |
SoDrawStyle::doAction(SoAction *action) |
| 117 |
// |
| 118 |
//////////////////////////////////////////////////////////////////////// |
| 119 |
{ |
| 120 |
SoState *state = action->getState(); |
| 121 |
SbBool isFilled; |
| 122 |
|
| 123 |
if (! style.isIgnored() |
| 124 |
&& ! SoOverrideElement::getDrawStyleOverride(state)) { |
| 125 |
if (isOverride()) { |
| 126 |
SoOverrideElement::setDrawStyleOverride(state, this, TRUE); |
| 127 |
} |
| 128 |
SoDrawStyleElement::set(state, |
| 129 |
(SoDrawStyleElement::Style) style.getValue()); |
| 130 |
isFilled = style.getValue() == FILLED; |
| 131 |
} |
| 132 |
else |
| 133 |
isFilled = TRUE; |
| 134 |
|
| 135 |
if (! pointSize.isIgnored() |
| 136 |
&& ! SoOverrideElement::getPointSizeOverride(state)) { |
| 137 |
if (isOverride()) { |
| 138 |
SoOverrideElement::setPointSizeOverride(state, this, TRUE); |
| 139 |
} |
| 140 |
SoPointSizeElement::set(state, pointSize.getValue()); |
| 141 |
} |
| 142 |
|
| 143 |
if (! lineWidth.isIgnored() |
| 144 |
&& ! SoOverrideElement::getLineWidthOverride(state)) { |
| 145 |
if (isOverride()) { |
| 146 |
SoOverrideElement::setLineWidthOverride(state, this, TRUE); |
| 147 |
} |
| 148 |
SoLineWidthElement::set(state, lineWidth.getValue()); |
| 149 |
} |
| 150 |
|
| 151 |
if (! linePattern.isIgnored() |
| 152 |
&& ! SoOverrideElement::getLinePatternOverride(state)) { |
| 153 |
if (isOverride()) { |
| 154 |
SoOverrideElement::setLinePatternOverride(state, this, TRUE); |
| 155 |
} |
| 156 |
SoLinePatternElement::set(state, linePattern.getValue()); |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
//////////////////////////////////////////////////////////////////////// |
| 161 |
// |
| 162 |
// Description: |
| 163 |
// Does callback action thing. |
| 164 |
// |
| 165 |
// Use: extender |
| 166 |
|
| 167 |
void |
| 168 |
SoDrawStyle::callback(SoCallbackAction *action) |
| 169 |
// |
| 170 |
//////////////////////////////////////////////////////////////////////// |
| 171 |
{ |
| 172 |
SoDrawStyle::doAction(action); |
| 173 |
} |
| 174 |
|
| 175 |
//////////////////////////////////////////////////////////////////////// |
| 176 |
// |
| 177 |
// Description: |
| 178 |
// Does GL render action. |
| 179 |
// |
| 180 |
// Use: extender |
| 181 |
|
| 182 |
void |
| 183 |
SoDrawStyle::GLRender(SoGLRenderAction *action) |
| 184 |
// |
| 185 |
//////////////////////////////////////////////////////////////////////// |
| 186 |
{ |
| 187 |
SoDrawStyle::doAction(action); |
| 188 |
} |