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-2014 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 00192 class SoSurroundScale : public SoTransformation { 00193 00194 SO_NODE_HEADER(SoSurroundScale); 00195 00196 public: 00197 00201 SoSurroundScale(); 00202 00203 // Fields 00211 SoSFInt32 numNodesUpToContainer; 00219 SoSFInt32 numNodesUpToReset; 00220 00225 void invalidate(); 00226 00227 private: 00228 // Called by actions that need to change the state with a new matrix. 00229 void doAction(SoAction *action); 00230 00231 void setDoingTranslations( SbBool doEm ) { doTranslations = doEm; } 00232 SbBool isDoingTranslations() { return doTranslations; } 00233 00234 virtual void callback(SoCallbackAction *action); 00235 virtual void GLRender(SoGLRenderAction *action); 00236 virtual void getBoundingBox(SoGetBoundingBoxAction *action); 00237 virtual void getMatrix(SoGetMatrixAction *action); 00238 virtual void pick(SoPickAction *action); 00239 00240 private: 00241 static void initClass(); 00242 static void exitClass(); 00243 00244 SB_THREAD_TLS_HEADER(); 00245 00246 const SbVec3f& getScale() { return cachedScale; } 00247 const SbVec3f& getTranslation() { return cachedTranslation; } 00248 00249 private: 00250 00251 void updateMySurroundParams( SoAction *action, const SbMatrix &inv); 00252 00253 void setIgnoreInBbox( SbBool newVal ) { ignoreInBbox = newVal; } 00254 SbBool isIgnoreInBbox() { return ignoreInBbox; } 00255 00256 SbVec3f cachedScale; 00257 SbVec3f cachedInvScale; 00258 SbVec3f cachedTranslation; 00259 SbBool cacheOK; 00260 00261 SbBool doTranslations; 00262 00263 virtual ~SoSurroundScale(); 00264 00265 // Class static thread local storage 00266 struct MTstruct { 00267 SoGetBoundingBoxAction *bboxAction; 00268 }; 00269 00270 // Mutex to protect during updateMySurroundParams 00271 SbThreadMutex *m_mutex; 00272 00273 private: 00274 SbBool ignoreInBbox; 00275 }; 00276 00277 #endif /* _SO_SURROUND_SCALE_ */ 00278 00279