Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoInteractionKit.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul Isaacs (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2022 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_INTERACTION_KIT_
51#define _SO_INTERACTION_KIT_
52
58
59class SoPath;
60class SoPathList;
61
63//
64// Class: SoInteractionKit
65//
66// NOTE TO DEVELOPERS:
67// For info about the structure of SoInteractionKit:
68// [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure
69// [2] type: ivNodeKitStructure SoInteractionKit.
70// [3] The program prints a diagram of the scene graph and a table with
71// information about each part.
72//
73// Base class for all draggers.
74//
76
150
152
153 SO_KIT_CATALOG_ENTRY_HEADER(topSeparator);
154 SO_KIT_CATALOG_ENTRY_HEADER(geomSeparator);
155
156 public:
157
185 virtual SbBool setPartAsPath( const SbName &partName,
186 SoPath *surrogatePath );
187
188 // Override the default behavior of SoNode
189 virtual SbBool affectsState() const;
190
206
207 // Fields
208#if 1 SoDEPRECATED
215#endif
234
235 private:
236
237 // Sets the part, then sets the field for that part to default.
238 // using partField.setDefault(TRUE).
239 // Hence 'newNode' becomes the new default value, and the part
240 // only writes if [a] the part is set to a different node.
241 // [b] values are changes in the fields of newNode.
242 // [c] any child below newNode changes.
243 //
244 // If the flag 'onlyIfAlready' is TRUE, then this will only change values
245 // of parts that are already in a default state.
246 //
247 // Returns FALSE on failure, TRUE otherwise.
248 // First version sets the part to the given node.
249 // Second version looks up resourceName in the global dictionary and sets
250 // the part with the node found.
251 virtual SbBool setPartAsDefault(const SbName &partName,
252 SoNode *newNode, SbBool onlyIfAlready = TRUE );
253 virtual SbBool setPartAsDefault(const SbName &partName,
254 const SbName &newNodeName, SbBool onlyIfAlready = TRUE);
255
256 // Is the 'inPath' valid as a surrogate path anywhere in this node's
257 // subgraph?
258 // Examines the surrogate paths of all InteractionKits from this node down.
259 // The first time a surrogate path is found that is contained within
260 // 'inPath', then TRUE is returned.
261 // The second version also returns information about the surrogate,
262 // only if (fillArgs == TRUE).
263 SbBool isPathSurrogateInMySubgraph(const SoPath *pathToCheck);
264 SbBool isPathSurrogateInMySubgraph(const SoPath *pathToCheck,
265 SoPath *&pathToOwner,
266 SbName &surrogateNameInOwner,
267 SoPath *&surrogatePathInOwner,
268 SbBool fillArgs = TRUE );
269
270 static void setSwitchValue( SoNode *n, int newVal );
271
272 private:
273 static void initClass(); // initialize the class
274 static void exitClass();
275
276 private:
279
280 // Copies the contents of the given instance into this instance
281 // This copies the surrogatePartPathList and the surrogatePartNameList
282 virtual void copyContents(const SoFieldContainer *fromFC,
283 SbBool copyConnections);
284
285 // These are overloaded to set the surrogate path to NULL after completing
286 // their work.
287 virtual SoNode *getAnyPart( const SbName &partName, SbBool makeIfNeeded,
288 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
289 virtual SoNodeKitPath *createPathToAnyPart(const SbName &partName,
290 SbBool makeIfNeeded,
291 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE,
292 const SoPath *pathToExtend = NULL );
293 virtual SbBool setAnyPart( const SbName &partName, SoNode *from,
294 SbBool anyPart = TRUE );
295
296 // This allows you to set any part in the nodekit as a surrogate path.
297 // Note: The node corresponding to 'partName' will become empty.
298 // If 'partName' is not a leaf, the subgraph below it will disappear.
299 virtual SbBool setAnyPartAsPath( const SbName &partName,
300 SoPath *surrogatePath,
301 SbBool leafCheck = FALSE,
302 SbBool publicCheck = FALSE );
303
304 // Reads in from file. Takes care of checking values in
305 // the topSeparator fields and the field of this node.
306 virtual SbBool readInstance(SoInput *in, unsigned short flags);
307
308 static void readDefaultParts(const SbString& fileName, // file to read
309 const char defaultBuffer[], // if no file,
310 int defBufSize); // read from buffer
311
312 // Protected versions of these methods that allow you to set non-leaf
313 // and/or private parts.
314 virtual SbBool setAnyPartAsDefault(const SbName &partName,
315 SoNode *newNode, SbBool anyPart = TRUE,
316 SbBool onlyIfAlready = TRUE );
317 virtual SbBool setAnyPartAsDefault(const SbName &partName,
318 const SbName &newNodeName, SbBool anyPart = TRUE,
319 SbBool onlyIfAlready = TRUE );
320
321 SbBool setAnySurrogatePath( const SbName &inName, SoPath *inPath,
322 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
323
324 // detach/attach any sensors, callbacks, and/or field connections.
325 // Called by: start/end of SoBaseKit::readInstance
326 // and on new copy by: start/end of SoBaseKit::copy.
327 // Classes that redefine must call setUpConnections(TRUE,TRUE)
328 // at end of constructor.
329 // Returns the state of the node when this was called.
330 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
331
332 // Called by the SoBaseKit::write() method.
333 //
334 // InteractionKits don't want to write fields if they have default vals.
335 //
336 // Calls setDefault(TRUE) on caching fields if default and not
337 // connected.
338 //
339 // Calls setDefault(TRUE) on the topSeparator.
340 // Calls setDefault(TRUE) on the geomSeparator.
341 //
342 // Calls setDefault(TRUE) on any non-leaf part of type exactly == SoSwitch.
343 // Subclasses can override this if they like, since the function is virtual.
344 // But interactionKits use non-leaf switches to turn parts on and off, and
345 // this does not need to be written to file.
346 //
347 // Lastly, calls same method on SoBaseKit.
348 //
349 // NOTE: Parts which are set to default may still wind up writing to file
350 // if, for example, they lie on a path.
351 virtual void setDefaultOnNonWritingFields();
352
353 // This sensor will watch the topSeparator part. If the part changes to a
354 // new node, then the fields of the old part will be disconnected and
355 // the fields of the new part will be connected.
356 // Connections are made from/to the boundingBoxCaching,
357 // renderCulling and pickCulling fields. This way, the SoInteractionKit
358 // can be treated from the outside just like a regular SoSeparator node.
359 // Setting the fields will affect caching and culling, even though the
360 // topSeparator takes care of it.
361 // oldTopSep keeps track of the part for comparison.
362 SoFieldSensor *fieldSensor;
363 static void fieldSensorCB( void *, SoSensor *);
364 SoSeparator *oldTopSep;
365
366 void connectSeparatorFields( SoSeparator *dest, SbBool onOff );
367
368 private:
369
370 // This list stores all paths that represent surrogate parts.
371 // These special parts do not have geometry in the dragger subgraph.
372 // Rather, picking one of these paths is regarded as tantamount to
373 // picking a particular part.
374 SoPathList *surrogatePartPathList;
375 SbPList *surrogatePartNameList;
376
377 void setMySurrogatePath( const SbName &name, SoPath *newPath );
378 int indexOfSurrogateInMyList(const SoPath *pathToCheck);
379
380 // used to read information by 'readDefaultParts'
381 static SoGroup *readFromFile(const SbString& fileName);
382 static SoGroup *readFromBuffer(const char defaultBuffer[], int defBufSize);
383
384 static SbPList* m_buffStuffList;
385 static SbPList* m_fileStuffList;
386};
387
388#endif /* _SO_INTERACTION_KIT_ */
389
390
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
#define SO_KIT_CATALOG_ENTRY_HEADER(partName)
Definition SoSubKit.h:107
#define SO_KIT_HEADER(className)
Definition SoSubKit.h:91
Character string stored in a hash table.
Definition SbName.h:162
List of generic (void *) pointers.
Definition SbPList.h:77
Class for smart character strings.
Definition SbString.h:202
Base class for all node kits.
Definition SoBaseKit.h:302
Abstract base class for objects that contain fields.
Sensor class that can be attached to Open Inventor fields.
Base class for all group nodes.
Definition SoGroup.h:122
Used to read Open Inventor data files.
Definition SoInput.h:363
Base class for all interaction nodekit classes.
virtual SbBool affectsState() const
Returns TRUE if a node has an effect on the state during traversal.
SoDEPRECATED SoSFEnum renderCaching
Set render caching mode.
CacheEnabled
Possible values for caching.
@ AUTO
Automatic caching.
@ OFF
Never build or use a cache.
@ ON
Always try to build a cache.
virtual SbBool setPartAsPath(const SbName &partName, SoPath *surrogatePath)
Sets any public part in the interaction kit as a "surrogate" path instead.
SoSFEnum boundingBoxCaching
Set bounding box caching mode.
SoSFEnum renderCulling
Set render culling mode.
SoSFEnum pickCulling
Set pick caching mode.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodekits.
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
Field containing an enumerated value.
Definition SoSFEnum.h:89
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:97
Group node that saves and restores traversal state.
int SbBool
Boolean type.
Definition SbBase.h:87