Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoSurroundScale.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 Isaacs (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-2014 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_SURROUND_SCALE_
51#define _SO_SURROUND_SCALE_
52
53#include <Inventor/fields/SoFieldData.h>
54#include <Inventor/nodes/SoNode.h>
55#include <Inventor/nodes/SoTransformation.h>
56#include <Inventor/fields/SoSFInt32.h>
57
58class SoFullPath;
60class SbThreadMutex;
61
63//
64// Class: SoSurroundScale
65//
66// Appends a transform to the localMatrix so that a default size cube will
67// surround the objects specified by its fields.
68//
69// To determine what to surround, the node looks at the current path in
70// the action. An SoGetBoundingBoxAction is applied to the node that is
71// 'numNodesUpToContainer' nodes above this node in the path.
72// The action will be told to reset the bounding box upon traversal of the
73// node that is 'numNodesUpToReset' nodes above this node in the path.
74//
75// For example, when a trackballManip wants to surround the objects it
76// is going to move, the scene graph will look something like this:
77// Separator
78// |
79// -------------------------
80// | |
81// trackballManip subGraphOfObjectsThatWilMove
82// |
83// trackballDragger
84// |
85// topSeparator(top part within of the dragger)
86// |
87// -----------------------------------
88// | | |
89// motionMatrix surroundScale parts of the dragger.
90// The manip will set the fields on the surround scale node to be:
91// numNodesUpToContainer = 4;
92// numNodesUpToReset = 3;
93//
94// The action will therefore be applied to the Separator, and will be
95// reset after traversing the trackballManip.
96// So the surroundScale will surround the objects below 'separator' and
97// not including 'trackballManip,' producing the desired effect.
98//
99// Note that, therefore, designers of draggers and manipulators which use
100// this node should base their models on default size cubes (2 by 2 by 2).
101//
103
193
194 SO_NODE_HEADER(SoSurroundScale);
195
196 public:
197
202
203 // Fields
220
226
227 private:
228 // Called by actions that need to change the state with a new matrix.
229 void doAction(SoAction *action);
230
231 void setDoingTranslations( SbBool doEm ) { doTranslations = doEm; }
232 SbBool isDoingTranslations() { return doTranslations; }
233
234 virtual void callback(SoCallbackAction *action);
235 virtual void GLRender(SoGLRenderAction *action);
236 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
237 virtual void getMatrix(SoGetMatrixAction *action);
238 virtual void pick(SoPickAction *action);
239
240 private:
241 static void initClass();
242 static void exitClass();
243
244 SB_THREAD_TLS_HEADER();
245
246 const SbVec3f& getScale() { return cachedScale; }
247 const SbVec3f& getTranslation() { return cachedTranslation; }
248
249 private:
250
251 void updateMySurroundParams( SoAction *action, const SbMatrix &inv);
252
253 void setIgnoreInBbox( SbBool newVal ) { ignoreInBbox = newVal; }
254 SbBool isIgnoreInBbox() { return ignoreInBbox; }
255
256 SbVec3f cachedScale;
257 SbVec3f cachedInvScale;
258 SbVec3f cachedTranslation;
259 SbBool cacheOK;
260
261 SbBool doTranslations;
262
263 virtual ~SoSurroundScale();
264
265 // Class static thread local storage
266 struct MTstruct {
267 SoGetBoundingBoxAction *bboxAction;
268 };
269
270 // Mutex to protect during updateMySurroundParams
271 SbThreadMutex *m_mutex;
272
273 private:
274 SbBool ignoreInBbox;
275};
276
277#endif /* _SO_SURROUND_SCALE_ */
278
4x4 matrix class.
Definition SbMatrix.h:309
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
3D vector class.
Definition SbVec.h:932
Abstract base class for all actions.
Definition SoAction.h:132
Performs a generic traversal of a scene graph or path.
Path that allows access to hidden children.
Definition SoPath.h:612
Renders a scene graph using Open Inventor's Render Engine.
Computes bounding box of a scene.
Computes transformation matrix for a subgraph.
Abstract base class for picking objects in a scene.
Field containing a int32_t integer.
Definition SoSFInt32.h:80
Transformation node that adjusts the current matrix so a default cube will surround other objects.
void invalidate()
If you call this, then next time an action is applied the node will re-calculate its cached translati...
SoSFInt32 numNodesUpToContainer
When traversed by an action, if surroundScale needs to calculate a new box, surroundScale looks at th...
SoSurroundScale()
Creates a surround scale node with default settings.
SoSFInt32 numNodesUpToReset
Before applying the SoGetBoundingBoxAction (see the numNodesUpToContainer field above) the surroundSc...
Abstract base class for all geometric transformation nodes.
int SbBool
Boolean type.
Definition SbBase.h:87