Open Inventor Reference
SoTranslate2Dragger.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,92 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 two dimensional translate dragger class.
48  | This is a simple dragger that allows an object to
49  | be translated within a plane. (defined by the plane normal (default
50  | normal is (0,0,1) and by the point initially hit by the user).
51  |
52  | If the user presses the SHIFT key while dragging, the motion will
53  | constrain to linear motion along one of the two main axes of motion.
54  | The axis selected will be the primary axis followed by the user's
55  | dragging gesture.
56  |
57  | The amount moved in the plane determines the translation.
58  |
59  | NOTE TO DEVELOPERS:
60  | For info about the structure of SoTranslate2Dragger:
61  | [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure
62  | [2] type: ivNodeKitStructure SoTranslate2Dragger.
63  | [3] The program prints a diagram of the scene graph and a table with
64  | information about each part.
65  |
66  | The following parts in this dragger are created at construction time.
67  | 'ResourceName' corresponds to the name of the default geometry for the
68  | part. The dragger's constructor gets the scene graph for 'ResourceName'
69  | by querying the global dictionary ( SoDB::getByName("ResourceName"); ).
70  |
71  | Resource Name: Part Name:
72  |
73  | translate2Translator - translator
74  | translate2TranslatorActive - translatorActive
75  | translate2Feedback - feedback
76  | translate2FeedbackActive - feedbackActive
77  |
78  | NOTE: These are only shown if dragger
79  | is moving and the axis is a
80  | permissable direction of motion.
81  | When pressing <shift>, motion is
82  | constrained, and only 1 is displayed.
83  | translate2XAxisFeedback - xAxisFeedback
84  | translate2YAxisFeedback - yAxisFeedback
85  |
86  | Author(s): Paul Isaacs, Howard Look
87  |
88  ______________ S I L I C O N G R A P H I C S I N C . ____________
89  _______________________________________________________________________
90  */
91 
92 #ifndef _SO_TRANSLATE_2_DRAGGER_
93 #define _SO_TRANSLATE_2_DRAGGER_
94 
95 #include <Inventor/SbLinear.h>
99 
100 class SbDict;
101 class SbPlaneProjector;
102 class SoFieldSensor;
103 
106 
170 
172 {
174 
175  SO_KIT_CATALOG_ENTRY_HEADER(translatorSwitch);
176  SO_KIT_CATALOG_ENTRY_HEADER(translator);
177  SO_KIT_CATALOG_ENTRY_HEADER(translatorActive);
178  SO_KIT_CATALOG_ENTRY_HEADER(feedbackSwitch);
179  SO_KIT_CATALOG_ENTRY_HEADER(feedback);
180  SO_KIT_CATALOG_ENTRY_HEADER(feedbackActive);
181  SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackSwitch);
182  SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedback);
183  SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedback);
184 
185  public:
186 
189 
191 
192  SoINTERNAL public:
193  static void initClass();
194 
195  protected:
196 
200 
201  static void startCB( void *, SoDragger * );
202  static void motionCB( void *, SoDragger * );
203  static void finishCB( void *, SoDragger * );
204 
206  static void fieldSensorCB( void *, SoSensor * );
207  static void valueChangedCB( void *, SoDragger * );
208 
209  void dragStart();
210  void drag();
211  void dragFinish();
212 
215  virtual void initPlaneProjector();
216 
218  static void metaKeyChangeCB( void *, SoDragger *);
219 
226  virtual bool setUpConnections( bool onOff, bool doItAlways = FALSE );
227 
229 
230  private:
231  int translateDir;
232  bool shftDown;
233 
234  static const unsigned char geomBuffer[];
235 };
236 
237 #endif /* _SO_TRANSLATE_2_DRAGGER_ */
238 
239 
240 
#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
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
Sensor class that can be attached to Inventor fields.
Definition: SoFieldSensor.h:80
Field containing a three-dimensional vector.
Definition: SoSFVec3f.h:79
Abstract base class for Inventor sensors.
Definition: SoSensor.h:108
Object you can translate within a plane by dragging with the mouse.
static void finishCB(void *, SoDragger *)
virtual void initPlaneProjector()
Setup the projector at start of the translation.
SbPlaneProjector * planeProj
projector for planar translation
static void motionCB(void *, SoDragger *)
static void initClass()
initialize the class
virtual bool setUpConnections(bool onOff, bool doItAlways=FALSE)
detach/attach any sensors, callbacks, and/or field connections.
SoTranslate2Dragger()
Constructor.
virtual ~SoTranslate2Dragger()
static void fieldSensorCB(void *, SoSensor *)
static void metaKeyChangeCB(void *, SoDragger *)
Callback for pressing and releasing the meta keys.
static void startCB(void *, SoDragger *)
SoFieldSensor * fieldSensor
SbVec3f worldRestartPt
used if SHIFT key goes down to initiate a new gesture.
static void valueChangedCB(void *, SoDragger *)