| 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 |
| SoV1GroupKit |
| 47 |
| |
| 48 |
| Author(s) : Paul Isaacs and Thad Beier |
| 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/SoDB.h> |
| 55 |
#include <Inventor/misc/upgraders/SoV1GroupKit.h> |
| 56 |
#include <Inventor/misc/upgraders/SoV1AppearanceKit.h> |
| 57 |
#include <Inventor/nodes/SoSeparator.h> |
| 58 |
#include <Inventor/nodekits/SoAppearanceKit.h> |
| 59 |
#include <Inventor/nodes/SoCallback.h> |
| 60 |
#include <Inventor/nodes/SoEventCallback.h> |
| 61 |
#include <Inventor/nodes/SoPickStyle.h> |
| 62 |
#include <Inventor/nodes/SoTransform.h> |
| 63 |
#include <Inventor/nodes/SoTexture2Transform.h> |
| 64 |
#include <Inventor/nodekits/SoSeparatorKit.h> |
| 65 |
|
| 66 |
// Define the required type id and name inquiry methods |
| 67 |
SO_NODE_SOURCE(SoV1GroupKit); |
| 68 |
|
| 69 |
// Define the required catalog inquiry methods |
| 70 |
SO_V1_SUBKIT_CATALOG_VARS(SoV1GroupKit); |
| 71 |
SO_V1_SUBKIT_CATALOG_METHODS(SoV1GroupKit); |
| 72 |
|
| 73 |
//////////////////////////////////////////////////////////////////////// |
| 74 |
// |
| 75 |
// Description: |
| 76 |
// Constructor |
| 77 |
// |
| 78 |
// Use: public |
| 79 |
|
| 80 |
SoV1GroupKit::SoV1GroupKit() |
| 81 |
// |
| 82 |
//////////////////////////////////////////////////////////////////////// |
| 83 |
{ |
| 84 |
SO_NODE_CONSTRUCTOR(SoV1GroupKit); |
| 85 |
|
| 86 |
if(SO_NODE_IS_FIRST_INSTANCE() ) { |
| 87 |
|
| 88 |
// Initialize children catalog and add entries to it |
| 89 |
// These are the macros you use to make a catalog. |
| 90 |
// Use ...INHERIT_CATALOG once, and put it first. |
| 91 |
// Then, use combinations of ...ADD_CATALOG_ENTRY |
| 92 |
// and ...ADD_CATALOG_LIST_ENTRY. See SoSubKit.h for more info |
| 93 |
// on syntax of these macros. |
| 94 |
SO_V1_SUBKIT_INHERIT_CATALOG(SoV1GroupKit, SoV1BaseKit ); |
| 95 |
|
| 96 |
SO_V1_SUBKIT_ADD_CATALOG_LIST_ENTRY("callbackList", SoSeparator, |
| 97 |
"this", "", SoCallback, TRUE ); |
| 98 |
SO_V1_SUBKIT_ADD_LIST_ITEM_TYPE("callbackList", SoEventCallback ); |
| 99 |
|
| 100 |
SO_V1_SUBKIT_ADD_CATALOG_ENTRY("topSeparator", SoSeparator, |
| 101 |
"this", "", FALSE ); |
| 102 |
|
| 103 |
SO_V1_SUBKIT_ADD_CATALOG_ENTRY("pickStyle", SoPickStyle, |
| 104 |
"topSeparator", "", TRUE ); |
| 105 |
|
| 106 |
SO_V1_SUBKIT_ADD_CATALOG_ENTRY("appearance", SoAppearanceKit, |
| 107 |
"topSeparator", "", TRUE ); |
| 108 |
|
| 109 |
SO_V1_SUBKIT_ADD_CATALOG_ENTRY("transform", SoTransform, |
| 110 |
"topSeparator", "", TRUE ); |
| 111 |
|
| 112 |
SO_V1_SUBKIT_ADD_CATALOG_ENTRY("texture2Transform", SoTexture2Transform, |
| 113 |
"topSeparator", "", TRUE ); |
| 114 |
|
| 115 |
SO_V1_SUBKIT_ADD_CATALOG_LIST_ENTRY("childList", SoSeparator, |
| 116 |
"topSeparator", "", SoSeparatorKit, TRUE ); |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
createNodekitPartsList(); |
| 124 |
} |
| 125 |
|
| 126 |
//////////////////////////////////////////////////////////////////////// |
| 127 |
// |
| 128 |
// Description: |
| 129 |
// Destructor (necessary since inline destructor is too complex) |
| 130 |
// |
| 131 |
// Use: public |
| 132 |
|
| 133 |
SoV1GroupKit::~SoV1GroupKit() |
| 134 |
// |
| 135 |
//////////////////////////////////////////////////////////////////////// |
| 136 |
{ |
| 137 |
} |
| 138 |
SoNode * |
| 139 |
SoV1GroupKit::createNewNode() |
| 140 |
{ |
| 141 |
return new SoSeparatorKit; |
| 142 |
} |
| 143 |
|
| 144 |
//////////////////////////////////////////////////////////////////////// |
| 145 |
// |
| 146 |
// Description: |
| 147 |
// Virtual method to setUp the new node. |
| 148 |
// |
| 149 |
// Overload this function. After SoV1BaseKit is done, see if there |
| 150 |
// is information in the nodelist |
| 151 |
// SoV1AppearanceKit::unusedTextureXfs. |
| 152 |
// If so, move this into our "texture2Transform" part. |
| 153 |
// Need to do this because Inventor 1.0 texture had fields for |
| 154 |
// texture transforms, but new one does not. So SoV1AppearanceKit just |
| 155 |
// stores this info. We retrieve it and make use of it. |
| 156 |
// |
| 157 |
// Use: public |
| 158 |
|
| 159 |
void |
| 160 |
SoV1GroupKit::setUpNewNode(SoNode *newNode) |
| 161 |
// |
| 162 |
{ |
| 163 |
SoV1BaseKit::setUpNewNode(newNode); |
| 164 |
|
| 165 |
SoSeparatorKit *newKit = (SoSeparatorKit *) newNode; |
| 166 |
|
| 167 |
// Return if newNode doesn't have an "appearance": |
| 168 |
SoNode *appKit = newKit->getPart("appearance", FALSE ); |
| 169 |
if ( appKit == NULL) |
| 170 |
return; |
| 171 |
|
| 172 |
// Return if the appKit didn't have unused texture2Transform fields: |
| 173 |
SoNodeList *kitList = SoV1AppearanceKit::getKitsWithUnusedTextureXfs(); |
| 174 |
int listInd = kitList->find(appKit); |
| 175 |
if (listInd < 0) |
| 176 |
return; |
| 177 |
|
| 178 |
// Get the SoTexture2Transform containing the info unused by our appearance |
| 179 |
SoNodeList *texXfList = SoV1AppearanceKit::getUnusedTextureXfs(); |
| 180 |
SoTexture2Transform *appKitXf |
| 181 |
= (SoTexture2Transform *) (*texXfList)[listInd]; |
| 182 |
|
| 183 |
if (appKitXf == NULL) |
| 184 |
return; |
| 185 |
|
| 186 |
// Okay, there's a texture2Transform that got made when the appearanceKit |
| 187 |
// was read. Let's install it as the texture2Transform part of newKit: |
| 188 |
|
| 189 |
// First, get the "texture2Transform" from newKit: |
| 190 |
SoTexture2Transform *newKitXf |
| 191 |
= SO_GET_PART(newKit,"texture2Transform", SoTexture2Transform ); |
| 192 |
|
| 193 |
// Determine if we're gonna stomp over an already set value in newKitXf: |
| 194 |
SbBool stompTranslate = FALSE; |
| 195 |
SbBool stompRotation = FALSE; |
| 196 |
SbBool stompScale = FALSE; |
| 197 |
SbBool stompCenter = FALSE; |
| 198 |
if ( appKitXf->translation.isDefault() == FALSE |
| 199 |
&& newKitXf->translation.isDefault() == FALSE ) |
| 200 |
stompTranslate = TRUE; |
| 201 |
if ( appKitXf->rotation.isDefault() == FALSE |
| 202 |
&& newKitXf->rotation.isDefault() == FALSE ) |
| 203 |
stompRotation = TRUE; |
| 204 |
if ( appKitXf->scaleFactor.isDefault() == FALSE |
| 205 |
&& newKitXf->scaleFactor.isDefault() == FALSE ) |
| 206 |
stompScale = TRUE; |
| 207 |
if ( appKitXf->center.isDefault() == FALSE |
| 208 |
&& newKitXf->center.isDefault() == FALSE ) |
| 209 |
stompCenter = TRUE; |
| 210 |
|
| 211 |
// Print a warning if we need to: |
| 212 |
if ( stompTranslate || stompRotation || stompScale || stompCenter ) { |
| 213 |
SoDebugError::postWarning("SoV1GroupKit::interpretCustomData", |
| 214 |
"texture2 contains texture transform fields. This kit also has a texture2Transform. The following fields in texture2Transform will be overwritten:"); |
| 215 |
if (stompTranslate) |
| 216 |
SoDebugError::postWarning("SoV1GroupKit::interpretCustomData", "translation"); |
| 217 |
|
| 218 |
if (stompRotation) |
| 219 |
SoDebugError::postWarning("SoV1GroupKit::interpretCustomData", "rotation"); |
| 220 |
|
| 221 |
if (stompScale) |
| 222 |
SoDebugError::postWarning("SoV1GroupKit::interpretCustomData", "scaleFactor"); |
| 223 |
if (stompCenter) |
| 224 |
SoDebugError::postWarning("SoV1GroupKit::interpretCustomData", "center"); |
| 225 |
} |
| 226 |
|
| 227 |
// Set the values in newKitXf |
| 228 |
if ( appKitXf->translation.isDefault() == FALSE ) |
| 229 |
newKitXf->translation = appKitXf->translation; |
| 230 |
if ( appKitXf->rotation.isDefault() == FALSE ) |
| 231 |
newKitXf->rotation = appKitXf->rotation; |
| 232 |
if ( appKitXf->scaleFactor.isDefault() == FALSE ) |
| 233 |
newKitXf->scaleFactor = appKitXf->scaleFactor; |
| 234 |
if ( appKitXf->center.isDefault() == FALSE ) |
| 235 |
newKitXf->center = appKitXf->center; |
| 236 |
} |