Open Inventor Reference
SoHandleBoxDragger.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | This file defines the handle box dragger class.
48  |
49  | NOTE TO DEVELOPERS:
50  | For info about the structure of SoHandleBoxDragger:
51  | [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure
52  | [2] type: ivNodeKitStructure SoHandleBoxDragger.
53  | [3] The program prints a diagram of the scene graph and a table with
54  | information about each part.
55  |
56  | The following parts in this dragger are created at construction time.
57  | 'ResourceName' corresponds to the name of the default geometry for the
58  | part. The dragger's constructor gets the scene graph for 'ResourceName'
59  | by querying the global dictionary ( SoDB::getByName("ResourceName"); ).
60  |
61  | Resource Name: Part Name:
62  |
63  | NOTE: for the translators and extruders,
64  | numbering refers to a cube-face:
65  | 1=top,2=bot,3=lft,4=rit,5=fnt,6=bak
66  |
67  | handleBoxTranslator1 - translator1
68  | handleBoxTranslator1Active - translator1Active
69  | (ditto for translator2-translator6)
70  |
71  | handleBoxExtruder1 - extruder1
72  | handleBoxExtruder1Active - extruder1Active
73  | (ditto for extruder2-extruder6)
74  |
75  |
76  | NOTE: for the uniform scalers,
77  | numbers refer to a corner:
78  | 1=+x+y+z, 2=+x+y-z, 3=+x-y+z,
79  | 4=+x-y-z, 5=-x+y+z, 6=-x+y-z,
80  | 7=-x-y+z, 8=-x-y-z
81  | handleBoxUniform1 - uniform1
82  | handleBoxUniform1Active - uniform1Active
83  | (ditto for uniform2-uniform8)
84  |
85  | NOTE: for the arrows, numbering refers
86  | to cube-face they point out from:
87  | 1=top,2=bot,3=lft,4=rit,5=fnt,6=bak
88  |
89  | handleBoxArrow1 - arrow1
90  | (ditto for arrow2-arrow6)
91  |
92  | Author(s): Paul Isaacs, David Mott
93  |
94  ______________ S I L I C O N G R A P H I C S I N C . ____________
95  _______________________________________________________________________
96  */
97 
98 #ifndef _SO_HANDLEBOX_DRAGGER_
99 #define _SO_HANDLEBOX_DRAGGER_
100 
104 
105 class SbDict;
106 class SoDrawStyle;
107 class SbPlaneProjector;
108 class SbLineProjector;
109 class SoFieldSensor;
110 
111 
114 
203 
205 
207 
208  SO_KIT_CATALOG_ENTRY_HEADER(drawStyle);
209 
211  SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
212 
213  SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
214  SO_KIT_CATALOG_ENTRY_HEADER(translator1);
215  SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
216  SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
217  SO_KIT_CATALOG_ENTRY_HEADER(translator2);
218  SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
219  SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
220  SO_KIT_CATALOG_ENTRY_HEADER(translator3);
221  SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
222  SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
223  SO_KIT_CATALOG_ENTRY_HEADER(translator4);
224  SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
225  SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
226  SO_KIT_CATALOG_ENTRY_HEADER(translator5);
227  SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
228  SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
229  SO_KIT_CATALOG_ENTRY_HEADER(translator6);
230  SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
231 
232 
233  SO_KIT_CATALOG_ENTRY_HEADER(extruder1Switch);
234  SO_KIT_CATALOG_ENTRY_HEADER(extruder1);
235  SO_KIT_CATALOG_ENTRY_HEADER(extruder1Active);
236  SO_KIT_CATALOG_ENTRY_HEADER(extruder2Switch);
237  SO_KIT_CATALOG_ENTRY_HEADER(extruder2);
238  SO_KIT_CATALOG_ENTRY_HEADER(extruder2Active);
239  SO_KIT_CATALOG_ENTRY_HEADER(extruder3Switch);
240  SO_KIT_CATALOG_ENTRY_HEADER(extruder3);
241  SO_KIT_CATALOG_ENTRY_HEADER(extruder3Active);
242  SO_KIT_CATALOG_ENTRY_HEADER(extruder4Switch);
243  SO_KIT_CATALOG_ENTRY_HEADER(extruder4);
244  SO_KIT_CATALOG_ENTRY_HEADER(extruder4Active);
245  SO_KIT_CATALOG_ENTRY_HEADER(extruder5Switch);
246  SO_KIT_CATALOG_ENTRY_HEADER(extruder5);
247  SO_KIT_CATALOG_ENTRY_HEADER(extruder5Active);
248  SO_KIT_CATALOG_ENTRY_HEADER(extruder6Switch);
249  SO_KIT_CATALOG_ENTRY_HEADER(extruder6);
250  SO_KIT_CATALOG_ENTRY_HEADER(extruder6Active);
251 
252  SO_KIT_CATALOG_ENTRY_HEADER(uniform1Switch);
253  SO_KIT_CATALOG_ENTRY_HEADER(uniform1);
254  SO_KIT_CATALOG_ENTRY_HEADER(uniform1Active);
255  SO_KIT_CATALOG_ENTRY_HEADER(uniform2Switch);
256  SO_KIT_CATALOG_ENTRY_HEADER(uniform2);
257  SO_KIT_CATALOG_ENTRY_HEADER(uniform2Active);
258  SO_KIT_CATALOG_ENTRY_HEADER(uniform3Switch);
259  SO_KIT_CATALOG_ENTRY_HEADER(uniform3);
260  SO_KIT_CATALOG_ENTRY_HEADER(uniform3Active);
261  SO_KIT_CATALOG_ENTRY_HEADER(uniform4Switch);
262  SO_KIT_CATALOG_ENTRY_HEADER(uniform4);
263  SO_KIT_CATALOG_ENTRY_HEADER(uniform4Active);
264  SO_KIT_CATALOG_ENTRY_HEADER(uniform5Switch);
265  SO_KIT_CATALOG_ENTRY_HEADER(uniform5);
266  SO_KIT_CATALOG_ENTRY_HEADER(uniform5Active);
267  SO_KIT_CATALOG_ENTRY_HEADER(uniform6Switch);
268  SO_KIT_CATALOG_ENTRY_HEADER(uniform6);
269  SO_KIT_CATALOG_ENTRY_HEADER(uniform6Active);
270  SO_KIT_CATALOG_ENTRY_HEADER(uniform7Switch);
271  SO_KIT_CATALOG_ENTRY_HEADER(uniform7);
272  SO_KIT_CATALOG_ENTRY_HEADER(uniform7Active);
273  SO_KIT_CATALOG_ENTRY_HEADER(uniform8Switch);
274  SO_KIT_CATALOG_ENTRY_HEADER(uniform8);
275  SO_KIT_CATALOG_ENTRY_HEADER(uniform8Active);
276 
277  SO_KIT_CATALOG_ENTRY_HEADER(arrowTranslation);
278 
279  SO_KIT_CATALOG_ENTRY_HEADER(arrow1Switch);
281  SO_KIT_CATALOG_ENTRY_HEADER(arrow2Switch);
283  SO_KIT_CATALOG_ENTRY_HEADER(arrow3Switch);
285  SO_KIT_CATALOG_ENTRY_HEADER(arrow4Switch);
287  SO_KIT_CATALOG_ENTRY_HEADER(arrow5Switch);
289  SO_KIT_CATALOG_ENTRY_HEADER(arrow6Switch);
291 
292  public:
293 
296 
299 
300  SoINTERNAL public:
301  static void initClass();
302 
303  protected:
304 
306  static void startCB( void *, SoDragger * );
307  static void motionCB( void *, SoDragger * );
308  static void finishCB( void *, SoDragger * );
309 
312  static void fieldSensorCB( void *, SoSensor * );
313  static void valueChangedCB( void *, SoDragger * );
314 
316  static void metaKeyChangeCB( void *, SoDragger *);
317 
319  void dragStart();
320  void drag();
321  void dragFinish();
322 
323  void setAllPartsActive( bool onOrOff );
324 
331  virtual bool setUpConnections( bool onOff, bool doItAlways = FALSE );
332 
334 
336 
337  private:
338 
339  enum WhichAxis
340  { POSX, POSY, POSZ, NEGX, NEGY, NEGZ };
341  void highlightAxisForScale( WhichAxis axis );
342 
343  enum State
344  { INACTIVE,
345  SCALE_GEOM_ONLY,
346  RIT_X_SCALE, TOP_Y_SCALE, FNT_Z_SCALE,
347  LFT_X_SCALE, BOT_Y_SCALE, BAK_Z_SCALE,
348 
349  PX_PY_PZ_3D_SCALE, PX_PY_NZ_3D_SCALE, PX_NY_PZ_3D_SCALE,
350  PX_NY_NZ_3D_SCALE, NX_PY_PZ_3D_SCALE, NX_PY_NZ_3D_SCALE,
351  NX_NY_PZ_3D_SCALE, NX_NY_NZ_3D_SCALE,
352 
353  RIT_TRANSLATE, TOP_TRANSLATE, FNT_TRANSLATE,
354  LFT_TRANSLATE, BOT_TRANSLATE, BAK_TRANSLATE };
355 
356  State currentState;
357  int translateDir;
360 
361  SbPlaneProjector *motionPlaneProj;
362  SbLineProjector *motionLineProj;
363 
364  State restartState;
365  SbVec3f worldRestartPt;
366 
367  bool altDown, ctlDown, shftDown;
369 
371  void setHighlights();
372  void setFeedbackArrows();
373 
374  bool translateInit();
375  bool faceScaleInit();
376  bool uniformScaleInit();
377  bool scaleGeomSizeOnlyInit();
378 
379  bool translateDrag();
380  bool scaleDrag();
381  bool scaleGeomSizeOnlyDrag();
382 
384  static const unsigned char geomBuffer[];
385 };
386 
387 #endif /* _SO_HANDLEBOX_DRAGGER_ */
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
#define SO_KIT_CATALOG_ENTRY_HEADER(partName)
This defines an SoSFNode field for the catalog part given.
Definition: SoSubKit.h:155
#define SO_KIT_HEADER(className)
Definition: SoSubKit.h:143
This is a dictionary mapping (size_t) integer keys to (void *) data pointers.
Definition: SbDict.h:101
Line projector.
Plane projector.
3D vector class.
Definition: SbLinear.h:120
Base class for nodekits that move in response to click-drag-release mouse events.
Definition: SoDragger.h:225
Node that defines the style to use when rendering.
Definition: SoDrawStyle.h:101
Sensor class that can be attached to Inventor fields.
Definition: SoFieldSensor.h:80
Box you can scale, stretch and translate by dragging with the mouse.
virtual bool setUpConnections(bool onOff, bool doItAlways=FALSE)
detach/attach any sensors, callbacks, and/or field connections.
SoFieldSensor * translFieldSensor
static void initClass()
initialize the class
SoHandleBoxDragger()
Constructor.
static void valueChangedCB(void *, SoDragger *)
static void startCB(void *, SoDragger *)
Callbacks for drag start, motion, and finish.
SoFieldSensor * scaleFieldSensor
static void fieldSensorCB(void *, SoSensor *)
virtual ~SoHandleBoxDragger()
static void motionCB(void *, SoDragger *)
static void finishCB(void *, SoDragger *)
void dragStart()
These really do the work during startCB, motionCB, and finishCB.
static void metaKeyChangeCB(void *, SoDragger *)
Callbacks for pressing and releasing the meta keys.
virtual void setDefaultOnNonWritingFields()
Called by the SoBaseKit::write() method.
void setAllPartsActive(bool onOrOff)
Field containing a three-dimensional vector.
Definition: SoSFVec3f.h:79
Abstract base class for Inventor sensors.
Definition: SoSensor.h:108