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-2014 BY FEI S.A.S, *** 00042 *** MERIGNAC, 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 00240 class SoSearchAction : public SoAction { 00241 00242 SO_ACTION_HEADER(SoSearchAction); 00243 00244 public: 00245 00247 enum LookFor { 00251 NODE = 0x01, 00255 TYPE = 0x02, 00259 NAME = 0x04 00260 }; 00261 00263 enum Interest { 00267 FIRST, 00271 LAST, 00275 ALL 00276 }; 00277 00281 SoSearchAction(); 00282 00283 // Destructor 00284 #ifndef HIDDEN_FROM_DOC 00285 virtual ~SoSearchAction(); 00286 #endif // HIDDEN_FROM_DOC 00287 00293 virtual void reset(); 00294 00299 virtual void clearApplyResult(); 00300 00307 void setFind(int what) { lookingFor = what; } 00308 00312 int getFind() { return lookingFor; } 00313 00317 SoNode *getNode() const { return node; } 00318 00322 void setNode(SoNode *n); 00323 00330 SoType getType(SbBool &derivedIsOk) const 00331 { derivedIsOk = derivedOk; return type; } 00332 00338 void setType(SoType t, SbBool derivedIsOk = TRUE); 00339 00343 const SbName &getName() const { return name; } 00344 00348 void setName(const SbName &n); 00349 00353 Interest getInterest() const { return interest; } 00354 00358 void setInterest(Interest i) { interest = i; } 00359 00364 SbBool isSearchingAll() const { return searchingAll; } 00365 00373 void setSearchingAll(SbBool flag) { searchingAll = flag; } 00374 00379 SoPath *getPath() const { return retPath; } 00380 00384 SoPathList &getPaths() { return retPaths; } 00385 00386 private: 00387 00388 // Sets/returns whether action has found all desired nodes 00389 // (implementation moved into source file for v2.6) 00390 virtual void setFound(); 00391 SbBool isFound() const { return hasTerminated(); } 00392 00393 // Sets found path or adds to list of found paths (depending on interest) 00394 void addPath(SoPath *path); 00395 00396 private: 00397 00398 static void initClass(); 00399 static void exitClass(); 00400 00401 // This flag is used by the SoSwitch node, which must return a 00402 // different result from its 'affectsState' method when called 00403 // during a SearchAction that is searching all children. 00404 static SbBool duringSearchAll; 00405 00406 private: 00407 00408 // Initiates action on graph 00409 virtual void beginTraversal(SoNode *node); 00410 00411 private: 00412 00413 // Node type id to search for 00414 SoType type; 00415 00416 // Exact match or derived ok 00417 SbBool derivedOk; 00418 00419 // Node to search for 00420 SoNode *node; 00421 00422 // Name of node to search for 00423 SbName name; 00424 00425 // What to search for 00426 int lookingFor; 00427 00428 // Which paths to return 00429 Interest interest; 00430 00431 // Search all children or follow normal traversal rules. 00432 SbBool searchingAll; 00433 00434 // Found node (if interest != ALL) 00435 SoPath *retPath; 00436 00437 // Found nodes (if interest == ALL) 00438 SoPathList retPaths; 00439 }; 00440 00441 #endif /* _SO_SEARCH_ACTION_ */ 00442 00443