00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Paul Isaacs (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2022 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_INTERACTION_KIT_ 00051 #define _SO_INTERACTION_KIT_ 00052 00053 #include <Inventor/nodes/SoSeparator.h> 00054 #include <Inventor/nodekits/SoBaseKit.h> 00055 #include <Inventor/fields/SoSFEnum.h> 00056 #include <Inventor/sensors/SoFieldSensor.h> 00057 #include <Inventor/SoNodeKitPath.h> 00058 00059 class SoPath; 00060 class SoPathList; 00061 00063 // 00064 // Class: SoInteractionKit 00065 // 00066 // NOTE TO DEVELOPERS: 00067 // For info about the structure of SoInteractionKit: 00068 // [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure 00069 // [2] type: ivNodeKitStructure SoInteractionKit. 00070 // [3] The program prints a diagram of the scene graph and a table with 00071 // information about each part. 00072 // 00073 // Base class for all draggers. 00074 // 00076 00149 class SoInteractionKit : public SoBaseKit { 00150 00151 SO_KIT_HEADER(SoInteractionKit); 00152 00153 SO_KIT_CATALOG_ENTRY_HEADER(topSeparator); 00154 SO_KIT_CATALOG_ENTRY_HEADER(geomSeparator); 00155 00156 public: 00157 00185 virtual SbBool setPartAsPath( const SbName &partName, 00186 SoPath *surrogatePath ); 00187 00188 // Override the default behavior of SoNode 00189 virtual SbBool affectsState() const; 00190 00192 enum CacheEnabled { 00196 OFF, 00200 ON, 00204 AUTO 00205 }; 00206 00207 // Fields 00208 #if 1 SoDEPRECATED 00214 SoSFEnum renderCaching; 00215 #endif 00222 SoSFEnum boundingBoxCaching; 00223 00228 SoSFEnum renderCulling; 00233 SoSFEnum pickCulling; 00234 00235 private: 00236 00237 // Sets the part, then sets the field for that part to default. 00238 // using partField.setDefault(TRUE). 00239 // Hence 'newNode' becomes the new default value, and the part 00240 // only writes if [a] the part is set to a different node. 00241 // [b] values are changes in the fields of newNode. 00242 // [c] any child below newNode changes. 00243 // 00244 // If the flag 'onlyIfAlready' is TRUE, then this will only change values 00245 // of parts that are already in a default state. 00246 // 00247 // Returns FALSE on failure, TRUE otherwise. 00248 // First version sets the part to the given node. 00249 // Second version looks up resourceName in the global dictionary and sets 00250 // the part with the node found. 00251 virtual SbBool setPartAsDefault(const SbName &partName, 00252 SoNode *newNode, SbBool onlyIfAlready = TRUE ); 00253 virtual SbBool setPartAsDefault(const SbName &partName, 00254 const SbName &newNodeName, SbBool onlyIfAlready = TRUE); 00255 00256 // Is the 'inPath' valid as a surrogate path anywhere in this node's 00257 // subgraph? 00258 // Examines the surrogate paths of all InteractionKits from this node down. 00259 // The first time a surrogate path is found that is contained within 00260 // 'inPath', then TRUE is returned. 00261 // The second version also returns information about the surrogate, 00262 // only if (fillArgs == TRUE). 00263 SbBool isPathSurrogateInMySubgraph(const SoPath *pathToCheck); 00264 SbBool isPathSurrogateInMySubgraph(const SoPath *pathToCheck, 00265 SoPath *&pathToOwner, 00266 SbName &surrogateNameInOwner, 00267 SoPath *&surrogatePathInOwner, 00268 SbBool fillArgs = TRUE ); 00269 00270 static void setSwitchValue( SoNode *n, int newVal ); 00271 00272 private: 00273 static void initClass(); // initialize the class 00274 static void exitClass(); 00275 00276 private: 00277 SoInteractionKit(); 00278 ~SoInteractionKit(); 00279 00280 // Copies the contents of the given instance into this instance 00281 // This copies the surrogatePartPathList and the surrogatePartNameList 00282 virtual void copyContents(const SoFieldContainer *fromFC, 00283 SbBool copyConnections); 00284 00285 // These are overloaded to set the surrogate path to NULL after completing 00286 // their work. 00287 virtual SoNode *getAnyPart( const SbName &partName, SbBool makeIfNeeded, 00288 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE ); 00289 virtual SoNodeKitPath *createPathToAnyPart(const SbName &partName, 00290 SbBool makeIfNeeded, 00291 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE, 00292 const SoPath *pathToExtend = NULL ); 00293 virtual SbBool setAnyPart( const SbName &partName, SoNode *from, 00294 SbBool anyPart = TRUE ); 00295 00296 // This allows you to set any part in the nodekit as a surrogate path. 00297 // Note: The node corresponding to 'partName' will become empty. 00298 // If 'partName' is not a leaf, the subgraph below it will disappear. 00299 virtual SbBool setAnyPartAsPath( const SbName &partName, 00300 SoPath *surrogatePath, 00301 SbBool leafCheck = FALSE, 00302 SbBool publicCheck = FALSE ); 00303 00304 // Reads in from file. Takes care of checking values in 00305 // the topSeparator fields and the field of this node. 00306 virtual SbBool readInstance(SoInput *in, unsigned short flags); 00307 00308 static void readDefaultParts(const SbString& fileName, // file to read 00309 const char defaultBuffer[], // if no file, 00310 int defBufSize); // read from buffer 00311 00312 // Protected versions of these methods that allow you to set non-leaf 00313 // and/or private parts. 00314 virtual SbBool setAnyPartAsDefault(const SbName &partName, 00315 SoNode *newNode, SbBool anyPart = TRUE, 00316 SbBool onlyIfAlready = TRUE ); 00317 virtual SbBool setAnyPartAsDefault(const SbName &partName, 00318 const SbName &newNodeName, SbBool anyPart = TRUE, 00319 SbBool onlyIfAlready = TRUE ); 00320 00321 SbBool setAnySurrogatePath( const SbName &inName, SoPath *inPath, 00322 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE ); 00323 00324 // detach/attach any sensors, callbacks, and/or field connections. 00325 // Called by: start/end of SoBaseKit::readInstance 00326 // and on new copy by: start/end of SoBaseKit::copy. 00327 // Classes that redefine must call setUpConnections(TRUE,TRUE) 00328 // at end of constructor. 00329 // Returns the state of the node when this was called. 00330 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00331 00332 // Called by the SoBaseKit::write() method. 00333 // 00334 // InteractionKits don't want to write fields if they have default vals. 00335 // 00336 // Calls setDefault(TRUE) on caching fields if default and not 00337 // connected. 00338 // 00339 // Calls setDefault(TRUE) on the topSeparator. 00340 // Calls setDefault(TRUE) on the geomSeparator. 00341 // 00342 // Calls setDefault(TRUE) on any non-leaf part of type exactly == SoSwitch. 00343 // Subclasses can override this if they like, since the function is virtual. 00344 // But interactionKits use non-leaf switches to turn parts on and off, and 00345 // this does not need to be written to file. 00346 // 00347 // Lastly, calls same method on SoBaseKit. 00348 // 00349 // NOTE: Parts which are set to default may still wind up writing to file 00350 // if, for example, they lie on a path. 00351 virtual void setDefaultOnNonWritingFields(); 00352 00353 // This sensor will watch the topSeparator part. If the part changes to a 00354 // new node, then the fields of the old part will be disconnected and 00355 // the fields of the new part will be connected. 00356 // Connections are made from/to the boundingBoxCaching, 00357 // renderCulling and pickCulling fields. This way, the SoInteractionKit 00358 // can be treated from the outside just like a regular SoSeparator node. 00359 // Setting the fields will affect caching and culling, even though the 00360 // topSeparator takes care of it. 00361 // oldTopSep keeps track of the part for comparison. 00362 SoFieldSensor *fieldSensor; 00363 static void fieldSensorCB( void *, SoSensor *); 00364 SoSeparator *oldTopSep; 00365 00366 void connectSeparatorFields( SoSeparator *dest, SbBool onOff ); 00367 00368 private: 00369 00370 // This list stores all paths that represent surrogate parts. 00371 // These special parts do not have geometry in the dragger subgraph. 00372 // Rather, picking one of these paths is regarded as tantamount to 00373 // picking a particular part. 00374 SoPathList *surrogatePartPathList; 00375 SbPList *surrogatePartNameList; 00376 00377 void setMySurrogatePath( const SbName &name, SoPath *newPath ); 00378 int indexOfSurrogateInMyList(const SoPath *pathToCheck); 00379 00380 // used to read information by 'readDefaultParts' 00381 static SoGroup *readFromFile(const SbString& fileName); 00382 static SoGroup *readFromBuffer(const char defaultBuffer[], int defBufSize); 00383 00384 static SbPList* m_buffStuffList; 00385 static SbPList* m_fileStuffList; 00386 }; 00387 00388 #endif /* _SO_INTERACTION_KIT_ */ 00389 00390 00391