| 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 |
| SoV1SceneKit |
| 47 |
| |
| 48 |
| Author(s) : Paul Isaacs |
| 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/SoV1SceneKit.h> |
| 56 |
#include <Inventor/nodekits/SoCameraKit.h> |
| 57 |
#include <Inventor/nodekits/SoLightKit.h> |
| 58 |
#include <Inventor/nodekits/SoSeparatorKit.h> |
| 59 |
#include <Inventor/nodekits/SoInteractionKit.h> |
| 60 |
#include <Inventor/nodes/SoSeparator.h> |
| 61 |
#include <Inventor/nodes/SoSwitch.h> |
| 62 |
#include <Inventor/nodekits/SoSceneKit.h> |
| 63 |
|
| 64 |
// Define the required type id and name inquiry methods |
| 65 |
SO_NODE_SOURCE(SoV1SceneKit); |
| 66 |
|
| 67 |
// Define the required catalog inquiry methods |
| 68 |
SO_V1_SUBKIT_CATALOG_VARS(SoV1SceneKit); |
| 69 |
SO_V1_SUBKIT_CATALOG_METHODS(SoV1SceneKit); |
| 70 |
|
| 71 |
//////////////////////////////////////////////////////////////////////// |
| 72 |
// |
| 73 |
// Description: |
| 74 |
// Constructor |
| 75 |
// |
| 76 |
// Use: public |
| 77 |
|
| 78 |
SoV1SceneKit::SoV1SceneKit() |
| 79 |
// |
| 80 |
//////////////////////////////////////////////////////////////////////// |
| 81 |
{ |
| 82 |
SO_NODE_CONSTRUCTOR(SoV1SceneKit); |
| 83 |
|
| 84 |
if(SO_NODE_IS_FIRST_INSTANCE() ) { |
| 85 |
|
| 86 |
// Initialize children catalog and add entries to it |
| 87 |
// These are the macros you use to make a catalog. |
| 88 |
// Use ...INHERIT_CATALOG once, and put it first. |
| 89 |
// Then, use combinations of ...ADD_CATALOG_ENTRY |
| 90 |
// and ...ADD_CATALOG_LIST_ENTRY. See SoSubKit.h for more info |
| 91 |
// on syntax of these macros. |
| 92 |
SO_V1_SUBKIT_INHERIT_CATALOG(SoV1SceneKit, SoV1BaseKit ); |
| 93 |
|
| 94 |
// this is a switch node, so the user can pick which camera to look |
| 95 |
// through. |
| 96 |
SO_V1_SUBKIT_ADD_CATALOG_ENTRY("topSeparator", SoSeparator, "this", "", FALSE); |
| 97 |
SO_V1_SUBKIT_ADD_CATALOG_LIST_ENTRY("cameraList", SoSwitch, |
| 98 |
"topSeparator", "", SoCameraKit, TRUE ); |
| 99 |
SO_V1_SUBKIT_ADD_CATALOG_LIST_ENTRY("lightList", SoGroup, |
| 100 |
"topSeparator", "", SoLightKit, TRUE ); |
| 101 |
SO_V1_SUBKIT_ADD_CATALOG_LIST_ENTRY("childList", SoGroup, |
| 102 |
"topSeparator", "", SoSeparatorKit, TRUE ); |
| 103 |
SO_V1_SUBKIT_ADD_CATALOG_LIST_ENTRY("manipulatorList", SoSeparator, |
| 104 |
"topSeparator", "", SoInteractionKit, TRUE ); |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
createNodekitPartsList(); |
| 112 |
if ( getNodekitCatalog() != NULL ) { |
| 113 |
setCameraNumber( 0 ); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
//////////////////////////////////////////////////////////////////////// |
| 118 |
// |
| 119 |
// Description: |
| 120 |
// Destructor (necessary since inline destructor is too complex) |
| 121 |
// |
| 122 |
// Use: public |
| 123 |
|
| 124 |
SoV1SceneKit::~SoV1SceneKit() |
| 125 |
// |
| 126 |
//////////////////////////////////////////////////////////////////////// |
| 127 |
{ |
| 128 |
} |
| 129 |
|
| 130 |
//////////////////////////////////////////////////////////////////////// |
| 131 |
// |
| 132 |
// Description: |
| 133 |
// gets the child number of the camera in 'cameraList' that is currently |
| 134 |
// selected by the switch node. |
| 135 |
// |
| 136 |
// Use: public |
| 137 |
|
| 138 |
int |
| 139 |
SoV1SceneKit::getCameraNumber() |
| 140 |
// |
| 141 |
//////////////////////////////////////////////////////////////////////// |
| 142 |
{ |
| 143 |
SoGroup *grp; |
| 144 |
SoSwitch *sw; |
| 145 |
SbPList eltTypes; |
| 146 |
|
| 147 |
grp = (SoGroup *) getAnyPart( "cameraList", SoSwitch::getClassTypeId(), TRUE, FALSE, FALSE ); |
| 148 |
sw = (SoSwitch *) grp; |
| 149 |
int answer = (int) sw->whichChild.getValue(); |
| 150 |
return answer; |
| 151 |
} |
| 152 |
//////////////////////////////////////////////////////////////////////// |
| 153 |
// |
| 154 |
// Description: |
| 155 |
// sets the switch node in 'cameraList' to be the number given |
| 156 |
// |
| 157 |
// Use: public |
| 158 |
|
| 159 |
void |
| 160 |
SoV1SceneKit::setCameraNumber(int camNum ) |
| 161 |
// |
| 162 |
//////////////////////////////////////////////////////////////////////// |
| 163 |
{ |
| 164 |
SoGroup *grp; |
| 165 |
SoSwitch *sw; |
| 166 |
SbPList eltTypes; |
| 167 |
|
| 168 |
grp = (SoGroup *) getAnyPart("cameraList",SoSwitch::getClassTypeId(),TRUE, FALSE, FALSE ); |
| 169 |
int numCams = grp->getNumChildren(); |
| 170 |
if ( camNum == 0 || (camNum >= 0 && camNum < numCams) ) { |
| 171 |
sw = (SoSwitch *) grp; |
| 172 |
|
| 173 |
sw->whichChild.setValue( camNum ); |
| 174 |
} |
| 175 |
} |
| 176 |
SoNode * |
| 177 |
SoV1SceneKit::createNewNode() |
| 178 |
{ |
| 179 |
return new SoSceneKit; |
| 180 |
} |
| 181 |
|
| 182 |
//////////////////////////////////////////////////////////////////////// |
| 183 |
// |
| 184 |
// Description: |
| 185 |
// A virtual function that allows classes to treat parts that fail the |
| 186 |
// tests of 'tryToSetPartInNewNode' |
| 187 |
// |
| 188 |
// If tryToSetPartInNewNode fails, then this routine is called. |
| 189 |
// It will fail for the parts: |
| 190 |
// "manipulatorList" |
| 191 |
// This routine will simply discard those parts with a warning, but |
| 192 |
// no error. |
| 193 |
// |
| 194 |
// Use: public |
| 195 |
// |
| 196 |
SbBool |
| 197 |
SoV1SceneKit::dealWithUpgradedPart( SoBaseKit *newNode, SoNode *newPart, |
| 198 |
const SbName &newPartName ) |
| 199 |
// |
| 200 |
//////////////////////////////////////////////////////////////////////// |
| 201 |
{ |
| 202 |
// First, try to let base class handle it... |
| 203 |
if ( SoV1BaseKit::dealWithUpgradedPart( newNode, newPart, newPartName ) ) |
| 204 |
return TRUE; |
| 205 |
|
| 206 |
// If the part name is "manipulatorList" just print |
| 207 |
// a warning, don't set the part, and return TRUE. |
| 208 |
if ( newPartName == "manpulatorList" ) { |
| 209 |
|
| 210 |
SoDebugError::postWarning("SoV1SceneKit::dealWithUpgradedPart", |
| 211 |
"the input file contained a part named %s. This part no longer exists, so you will unfortunately have to lose it.", newPartName.getString() ); |
| 212 |
return TRUE; |
| 213 |
} |
| 214 |
|
| 215 |
return FALSE; // don't know how to do anything yet... |
| 216 |
} |