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-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_SURROUND_SCALE_ 00051 #define _SO_SURROUND_SCALE_ 00052 00053 #include <Inventor/fields/SoFieldData.h> 00054 #include <Inventor/nodes/SoNode.h> 00055 #include <Inventor/nodes/SoTransformation.h> 00056 #include <Inventor/fields/SoSFInt32.h> 00057 00058 class SoFullPath; 00059 class SoGetBoundingBoxAction; 00060 class SbThreadMutex; 00061 00063 // 00064 // Class: SoSurroundScale 00065 // 00066 // Appends a transform to the localMatrix so that a default size cube will 00067 // surround the objects specified by its fields. 00068 // 00069 // To determine what to surround, the node looks at the current path in 00070 // the action. An SoGetBoundingBoxAction is applied to the node that is 00071 // 'numNodesUpToContainer' nodes above this node in the path. 00072 // The action will be told to reset the bounding box upon traversal of the 00073 // node that is 'numNodesUpToReset' nodes above this node in the path. 00074 // 00075 // For example, when a trackballManip wants to surround the objects it 00076 // is going to move, the scene graph will look something like this: 00077 // Separator 00078 // | 00079 // ------------------------- 00080 // | | 00081 // trackballManip subGraphOfObjectsThatWilMove 00082 // | 00083 // trackballDragger 00084 // | 00085 // topSeparator(top part within of the dragger) 00086 // | 00087 // ----------------------------------- 00088 // | | | 00089 // motionMatrix surroundScale parts of the dragger. 00090 // The manip will set the fields on the surround scale node to be: 00091 // numNodesUpToContainer = 4; 00092 // numNodesUpToReset = 3; 00093 // 00094 // The action will therefore be applied to the Separator, and will be 00095 // reset after traversing the trackballManip. 00096 // So the surroundScale will surround the objects below 'separator' and 00097 // not including 'trackballManip,' producing the desired effect. 00098 // 00099 // Note that, therefore, designers of draggers and manipulators which use 00100 // this node should base their models on default size cubes (2 by 2 by 2). 00101 // 00103 00193 class SoSurroundScale : public SoTransformation { 00194 00195 SO_NODE_HEADER(SoSurroundScale); 00196 00197 public: 00198 00202 SoSurroundScale(); 00203 00204 // Fields 00212 SoSFInt32 numNodesUpToContainer; 00220 SoSFInt32 numNodesUpToReset; 00221 00226 void invalidate(); 00227 00228 private: 00229 // Called by actions that need to change the state with a new matrix. 00230 void doAction(SoAction *action); 00231 00232 void setDoingTranslations( SbBool doEm ) { doTranslations = doEm; } 00233 SbBool isDoingTranslations() { return doTranslations; } 00234 00235 virtual void callback(SoCallbackAction *action); 00236 virtual void GLRender(SoGLRenderAction *action); 00237 virtual void getBoundingBox(SoGetBoundingBoxAction *action); 00238 virtual void getMatrix(SoGetMatrixAction *action); 00239 virtual void pick(SoPickAction *action); 00240 00241 private: 00242 static void initClass(); 00243 static void exitClass(); 00244 00245 SB_THREAD_TLS_HEADER(); 00246 00247 const SbVec3f& getScale() { return cachedScale; } 00248 const SbVec3f& getTranslation() { return cachedTranslation; } 00249 00250 private: 00251 00252 void updateMySurroundParams( SoAction *action, const SbMatrix &inv); 00253 00254 void setIgnoreInBbox( SbBool newVal ) { ignoreInBbox = newVal; } 00255 SbBool isIgnoreInBbox() { return ignoreInBbox; } 00256 00257 SbVec3f cachedScale; 00258 SbVec3f cachedInvScale; 00259 SbVec3f cachedTranslation; 00260 SbBool cacheOK; 00261 00262 SbBool doTranslations; 00263 00264 virtual ~SoSurroundScale(); 00265 00266 // Class static thread local storage 00267 struct MTstruct { 00268 SoGetBoundingBoxAction *bboxAction; 00269 }; 00270 00271 // Mutex to protect during updateMySurroundParams 00272 SbThreadMutex *m_mutex; 00273 00274 private: 00275 SbBool ignoreInBbox; 00276 }; 00277 00278 #endif /* _SO_SURROUND_SCALE_ */ 00279 00280