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 S. Strauss (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-2020 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_SEARCH_ACTION_ 00051 #define _SO_SEARCH_ACTION_ 00052 00053 #include <Inventor/actions/SoSubAction.h> 00054 00056 // 00057 // Class: SoSearchAction 00058 // 00059 // For searching for specific nodes in scene graphs. Nodes can be 00060 // searched for by pointer, by type (exact or derived), by name, or 00061 // by a combination of these. You can also specify whether you are 00062 // interested in only the first match, only the last match, or all 00063 // matches. You can also control whether normal traversal rules are 00064 // followed (switching, separators, etc.) or whether every single 00065 // node is to be searched. 00066 // 00068 00241 class SoSearchAction : public SoAction { 00242 00243 SO_ACTION_HEADER(SoSearchAction); 00244 00245 public: 00246 00248 enum LookFor { 00252 NODE = 0x01, 00256 TYPE = 0x02, 00260 NAME = 0x04 00261 }; 00262 00264 enum Interest { 00268 FIRST, 00272 LAST, 00276 ALL 00277 }; 00278 00282 SoSearchAction(); 00283 00284 // Destructor 00285 #ifndef HIDDEN_FROM_DOC 00286 virtual ~SoSearchAction(); 00287 #endif // HIDDEN_FROM_DOC 00288 00294 virtual void reset(); 00295 00300 virtual void clearApplyResult(); 00301 00308 void setFind(int what) { lookingFor = what; } 00309 00313 int getFind() { return lookingFor; } 00314 00318 SoNode *getNode() const { return node; } 00319 00323 void setNode(SoNode *n); 00324 00331 SoType getType(SbBool &derivedIsOk) const 00332 { derivedIsOk = derivedOk; return type; } 00333 00339 void setType(SoType t, SbBool derivedIsOk = TRUE); 00340 00344 const SbName &getName() const { return name; } 00345 00349 void setName(const SbName &n); 00350 00354 Interest getInterest() const { return interest; } 00355 00359 void setInterest(Interest i) { interest = i; } 00360 00365 SbBool isSearchingAll() const { return searchingAll; } 00366 00374 void setSearchingAll(SbBool flag) { searchingAll = flag; } 00375 00380 SoPath *getPath() const { return retPath; } 00381 00385 SoPathList &getPaths() { return retPaths; } 00386 00387 private: 00388 00389 // Sets/returns whether action has found all desired nodes 00390 // (implementation moved into source file for v2.6) 00391 virtual void setFound(); 00392 SbBool isFound() const { return hasTerminated(); } 00393 00394 // Sets found path or adds to list of found paths (depending on interest) 00395 void addPath(SoPath *path); 00396 00397 private: 00398 00399 static void initClass(); 00400 static void exitClass(); 00401 00402 // This flag is used by the SoSwitch node, which must return a 00403 // different result from its 'affectsState' method when called 00404 // during a SearchAction that is searching all children. 00405 static SbBool duringSearchAll; 00406 00407 private: 00408 00409 // Initiates action on graph 00410 virtual void beginTraversal(SoNode *node); 00411 00412 private: 00413 00414 // Node type id to search for 00415 SoType type; 00416 00417 // Exact match or derived ok 00418 SbBool derivedOk; 00419 00420 // Node to search for 00421 SoNode *node; 00422 00423 // Name of node to search for 00424 SbName name; 00425 00426 // What to search for 00427 int lookingFor; 00428 00429 // Which paths to return 00430 Interest interest; 00431 00432 // Search all children or follow normal traversal rules. 00433 SbBool searchingAll; 00434 00435 // Found node (if interest != ALL) 00436 SoPath *retPath; 00437 00438 // Found nodes (if interest == ALL) 00439 SoPathList retPaths; 00440 }; 00441 00442 #endif /* _SO_SEARCH_ACTION_ */ 00443 00444