Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoSearchAction.h
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 S. Strauss (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-2023 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_SEARCH_ACTION_
51#define _SO_SEARCH_ACTION_
52
53#include <Inventor/actions/SoSubAction.h>
54
56//
57// Class: SoSearchAction
58//
59// For searching for specific nodes in scene graphs. Nodes can be
60// searched for by pointer, by type (exact or derived), by name, or
61// by a combination of these. You can also specify whether you are
62// interested in only the first match, only the last match, or all
63// matches. You can also control whether normal traversal rules are
64// followed (switching, separators, etc.) or whether every single
65// node is to be searched.
66//
68
241class SoSearchAction : public SoAction {
242
243 SO_ACTION_HEADER(SoSearchAction);
244
245 public:
246
248 enum LookFor {
252 NODE = 0x01,
256 TYPE = 0x02,
260 NAME = 0x04
261 };
262
278
283
284 // Destructor
285#ifndef HIDDEN_FROM_DOC
286 virtual ~SoSearchAction();
287#endif // HIDDEN_FROM_DOC
288
294 virtual void reset();
295
300 virtual void clearApplyResult();
301
308 void setFind(int what) { lookingFor = what; }
309
313 int getFind() { return lookingFor; }
314
318 SoNode *getNode() const { return node; }
319
323 void setNode(SoNode *n);
324
331 SoType getType(SbBool &derivedIsOk) const
332 { derivedIsOk = derivedOk; return type; }
333
339 void setType(SoType t, SbBool derivedIsOk = TRUE);
340
344 const SbName &getName() const { return name; }
345
349 void setName(const SbName &n);
350
354 Interest getInterest() const { return interest; }
355
359 void setInterest(Interest i) { interest = i; }
360
365 SbBool isSearchingAll() const { return searchingAll; }
366
374 void setSearchingAll(SbBool flag) { searchingAll = flag; }
375
380 SoPath *getPath() const { return retPath; }
381
385 SoPathList &getPaths() { return retPaths; }
386
387 private:
388
389 // Sets/returns whether action has found all desired nodes
390 // (implementation moved into source file for v2.6)
391 virtual void setFound();
392 SbBool isFound() const { return hasTerminated(); }
393
394 // Sets found path or adds to list of found paths (depending on interest)
395 void addPath(SoPath *path);
396
397 private:
398
399 static void initClass();
400 static void exitClass();
401
402 // This flag is used by the SoSwitch node, which must return a
403 // different result from its 'affectsState' method when called
404 // during a SearchAction that is searching all children.
405 static SbBool duringSearchAll;
406
407 private:
408
409 // Initiates action on graph
410 virtual void beginTraversal(SoNode *node);
411
412 private:
413
414 // Node type id to search for
415 SoType type;
416
417 // Exact match or derived ok
418 SbBool derivedOk;
419
420 // Node to search for
421 SoNode *node;
422
423 // Name of node to search for
424 SbName name;
425
426 // What to search for
427 int lookingFor;
428
429 // Which paths to return
430 Interest interest;
431
432 // Search all children or follow normal traversal rules.
433 SbBool searchingAll;
434
435 // Found node (if interest != ALL)
436 SoPath *retPath;
437
438 // Found nodes (if interest == ALL)
439 SoPathList retPaths;
440};
441
442#endif /* _SO_SEARCH_ACTION_ */
443
Character string stored in a hash table.
Definition SbName.h:162
Abstract base class for all actions.
Definition SoAction.h:132
SbBool hasTerminated() const
Returns TRUE if the traversal has reached a termination condition.
Definition SoAction.h:430
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
Searches for nodes in a scene graph.
void setFind(int what)
Sets what to look for; what is a bitmask of LookFor enum values.
void setType(SoType t, SbBool derivedIsOk=TRUE)
Sets the node type to search for.
SbBool isSearchingAll() const
Returns FALSE if searching uses regular traversal, TRUE if it traverses every single node.
int getFind()
Returns what to look for.
virtual void reset()
Resets options back to default values; clears list of returned paths.
SoSearchAction()
Constructor.
Interest
Enum that defines which paths to return.
@ FIRST
Return only the first path found (default)
@ ALL
Return all paths found.
@ LAST
Return only the last path found.
LookFor
Enum that defines the search criterion.
@ NODE
Search for a particular node instance.
@ TYPE
Search for a particular type of node.
@ NAME
Search for a node with a particular name.
SoPathList & getPaths()
Returns resulting path list.
virtual void clearApplyResult()
When applied, an action may reference nodes or create objects (e.g.
SoPath * getPath() const
Returns resulting path, or NULL if no path was found.
const SbName & getName() const
Returns the name of the node to search for.
void setInterest(Interest i)
Sets which paths to return.
SoType getType(SbBool &derivedIsOk) const
Returns the node type to search for.
void setName(const SbName &n)
Sets the name of the node to search for.
void setSearchingAll(SbBool flag)
Sets whether searching uses regular traversal or whether it traverses every single node.
void setNode(SoNode *n)
Sets the node to search for.
SoNode * getNode() const
Returns the node to search for.
Interest getInterest() const
Returns which paths to return.
Stores runtime type information.
Definition SoType.h:98
int SbBool
Boolean type.
Definition SbBase.h:87