Open Inventor Reference
SoDragger.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 base class for draggers that
48 | use a click-drag-release paradigm.
49 |
50 | NOTE TO DEVELOPERS:
51 | For info about the structure of SoDragger:
52 | [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure
53 | [2] type: ivNodeKitStructure SoDragger.
54 | [3] The program prints a diagram of the scene graph and a table with
55 | information about each part.
56 |
57 | Author(s): Paul Isaacs, David Mott, Howard Look
58 |
59 ______________ S I L I C O N G R A P H I C S I N C . ____________
60 _______________________________________________________________________
61 */
62
63#ifndef _SO_DRAGGER_
64#define _SO_DRAGGER_
65
66#include <Inventor/SbBox.h>
68#include <Inventor/SbLinear.h>
74
75
76class SoPickedPoint;
77class SoAction;
80class SoEvent;
81class SoPath;
82class SoTempPath;
83class SbPList;
84
85class SoDragger;
86
88typedef void INVENTOR_API SoDraggerCB(void *userData, SoDragger *dragger );
89
90
93
224
226
228
229 SO_KIT_CATALOG_ENTRY_HEADER(motionMatrix);
230
231 public:
232
235
239
243 void addStartCallback(SoDraggerCB *f, void *userData = NULL);
245 void removeStartCallback(SoDraggerCB *f, void *userData = NULL);
246
249 void addMotionCallback(SoDraggerCB *f, void *userData = NULL);
252 void removeMotionCallback(SoDraggerCB *f, void *userData = NULL);
253
256 void addFinishCallback(SoDraggerCB *f, void *userData = NULL);
259 void removeFinishCallback(SoDraggerCB *f, void *userData = NULL);
260
264 void addValueChangedCallback(SoDraggerCB *f, void *userData = NULL);
266 void removeValueChangedCallback(SoDraggerCB *f, void *userData = NULL);
267
270 void setMinGesture(int pixels) { minGesture = pixels; }
273 int getMinGesture() const { return minGesture; }
274
278 static void setMinScale( float newMinScale ) { minScale = newMinScale; }
280 static float getMinScale() { return minScale; }
281
291 bool enableValueChangedCallbacks( bool newVal );
292
293 SoEXTENDER public:
294
301
305
310 void addOtherEventCallback(SoDraggerCB *f, void *userData = NULL);
311 void removeOtherEventCallback(SoDraggerCB *f, void *userData = NULL);
312
327
331
336
346 void getPartToLocalMatrix( const SbName &partName,
347 SbMatrix &partToLocalMatrix,
348 SbMatrix &localToPartMatrix);
349
351 void transformMatrixLocalToWorld( const SbMatrix &fromMatrix,
352 SbMatrix &toMatrix);
353 void transformMatrixWorldToLocal( const SbMatrix &fromMatrix,
354 SbMatrix &toMatrix);
355 void transformMatrixToLocalSpace( const SbMatrix &fromMatrix,
356 SbMatrix &toMatrix, const SbName &fromSpacePartName);
357
360 void setMotionMatrix( const SbMatrix &newMatrix );
361
369
372 const SbMatrix &getStartMotionMatrix() { return startMotionMatrix; }
377 virtual void saveStartParameters();
378
380 const SoPath *getPickPath() const;
381 const SoEvent *getEvent() const;
387
395 { return pathToSurrogatePickOwner;}
399 { return surrogateNameInPickOwner; }
405 { return surrogatePathInPickOwner;}
406
409 void setStartingPoint( const SoPickedPoint *newPoint );
413 void setStartingPoint( const SbVec3f &newPoint );
414
421 const SbViewVolume &getViewVolume() { return viewVolume; }
422 void setViewVolume(const SbViewVolume &vol) { viewVolume = vol; }
423
424 const SbViewportRegion &getViewportRegion() { return vpRegion; }
425 void setViewportRegion(const SbViewportRegion &reg) { vpRegion = reg; }
426
429 { return handleEventAction; }
431
435 void setTempPathToThis(const SoPath *somethingClose);
436
438 virtual void grabEventsSetup();
439 virtual void grabEventsCleanup();
440
458 const SbVec3f *translationPtr,
459 const SbRotation *rotationPtr,
460 const SbVec3f *scaleFactorPtr,
461 const SbRotation *scaleOrientationPtr,
462 const SbVec3f *centerPtr);
463
469 static void getTransformFast( SbMatrix &mtx, SbVec3f &translation,
470 SbRotation &rotation, SbVec3f &scaleFactor,
471 SbRotation &scaleOrientation,
472 const SbVec3f &center);
473 static void getTransformFast( SbMatrix &mtx, SbVec3f &translation,
474 SbRotation &rotation, SbVec3f &scaleFactor,
475 SbRotation &scaleOrientation);
476
481 const SbVec3f &translation,
482 const SbMatrix *conversion = NULL );
483 static SbMatrix appendScale( const SbMatrix &mtx,
484 const SbVec3f &scale, const SbVec3f &scaleCenter,
485 const SbMatrix *conversion = NULL );
486 static SbMatrix appendRotation( const SbMatrix &mtx,
487 const SbRotation &rot, const SbVec3f &rotCenter,
488 const SbMatrix *conversion = NULL );
489
490 SoINTERNAL public:
491 static void initClass();
492
494 static void initClasses();
495
502 FRONT, BACK, USE_PICK
503 };
505 { projectorFrontSetting = newVal; }
507 { return projectorFrontSetting;}
508
509 protected:
510
513
521
523 SbVec2s getStartLocaterPosition() const { return startLocater; }
524
528 void setStartLocaterPosition(SbVec2s p) { startLocater = p; }
529
533
542 virtual bool shouldGrabBasedOnSurrogate( const SoPath *pickPath,
543 const SoPath *surrogatePath );
544
548 void setCameraInfo( SoAction *action );
549
553
556 // Added by cschumann 2015.08.24 to allow to overwrite button masks
557 virtual bool mouseButtonPressed(const SoEvent *ev);
558
561 // Added by cschumann 2015.08.24 to allow to overwrite button masks
562 virtual bool mouseButtonReleased(const SoEvent *ev);
563
572
575 void setIgnoreInBbox( bool newVal ) { ignoreInBbox = newVal; }
576 bool isIgnoreInBbox() { return ignoreInBbox; }
577
582
586 static void childValueChangedCB(void *, SoDragger *);
587 static void childStartCB(void *, SoDragger *);
588 static void childMotionCB(void *, SoDragger *);
589 static void childFinishCB(void *, SoDragger *);
590 static void childOtherEventCB(void *, SoDragger *);
591
595 void setActiveChildDragger( SoDragger *newChildDragger );
596 SoDragger *getActiveChildDragger() const { return activeChildDragger; }
597
617
618 virtual ~SoDragger();
619
620 private:
621
623 SoCallbackList *startCallbacks;
624 SoCallbackList *motionCallbacks;
625 SoCallbackList *finishCallbacks;
626 SoCallbackList *valueChangedCallbacks;
627
628 SoCallbackList *otherEventCallbacks;
629
630 bool valueChangedCallbacksEnabled;
631 SoDragger *activeChildDragger;
632
633 SoHandleEventAction *handleEventAction;
634
640 SbVec3f startingWorldPoint;
641
643 SbMatrix startMotionMatrix;
644
646 SbVec2s startLocater;
647
648
650 void setPickPath(SoPath *newPickPath);
651 SoPath *pickPath;
652
654 void setNoPickedSurrogate();
655 void setPickedSurrogate( SoPath *pathToOwner, SbName &nameUsedByOwner,
656 SoPath *pathUsedByOwner );
657
658 SbName surrogateNameInPickOwner;
659 SoPath *pathToSurrogatePickOwner;
660 SoPath *surrogatePathInPickOwner;
661
670 SoTempPath *tempPathToThis;
671 SbPList *tempPathNumKidsHack;
675 bool isTempPathToThisOk();
677 SoTempPath *createTempPathFromFullPath( const SoFullPath *fp ) const;
678
681 int minGesture;
682
686 static float minScale;
687
688 SbViewVolume viewVolume;
689 SbViewportRegion vpRegion;
690
695
697 void validateMatrices();
698
705 bool cachedPathToThisValid;
706 bool cachedMotionMatrixValid;
707 SbMatrix cachedMotionMatrix;
709 SbMatrix postMotionToWorldMatrix;
710 SbMatrix worldToPostMotionMatrix;
712 SbMatrix preMotionToWorldMatrix;
713 SbMatrix worldToPreMotionMatrix;
714
717 bool ignoreInBbox;
718
721 bool mouseMovedYet;
722
723 ProjectorFrontSetting projectorFrontSetting;
724};
725
726#endif /* _SO_DRAGGER_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition SbBasic.h:154
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
void INVENTOR_API SoDraggerCB(void *userData, SoDragger *dragger)
forward reference
Definition SoDragger.h:88
#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
4x4 matrix class.
Definition SbLinear.h:823
Character string stored in a hash table.
Definition SbString.h:264
List of generic (void *) pointers.
Definition SbPList.h:78
Class for representing a rotation.
Definition SbLinear.h:678
2D vector class.
Definition SbLinear.h:246
2D vector class.
Definition SbLinear.h:354
3D vector class.
Definition SbLinear.h:120
3D viewing volume class.
Definition SbLinear.h:1058
Class for representing a viewport.
Abstract base class for all actions.
Definition SoAction.h:179
Manages a list of callback functions and associated data.
Base class for nodekits that move in response to click-drag-release mouse events.
Definition SoDragger.h:225
const SoEvent * getEvent() const
const SbViewVolume & getViewVolume()
Information about the window an event occurred in.
Definition SoDragger.h:421
void setMinGesture(int pixels)
Set and get the number of pixels of movement required to initiate a constraint gesture.
Definition SoDragger.h:270
static void childMotionCB(void *, SoDragger *)
bool isIgnoreInBbox()
Definition SoDragger.h:576
void registerChildDragger(SoDragger *child)
Compound draggers should call this for each child dragger so that user callbacks (valueChanged,...
void getPartToLocalMatrix(const SbName &partName, SbMatrix &partToLocalMatrix, SbMatrix &localToPartMatrix)
Get the matrix which converts from the space of one part into local space.
virtual void saveStartParameters()
By default, saves the motionMatrix as the startMotionMatrix.
void removeMotionCallback(SoDraggerCB *f, void *userData=NULL)
Motion callbacks are called after each movement of the mouse during dragging.
void removeFinishCallback(SoDraggerCB *f, void *userData=NULL)
Finish callbacks are made after dragging ends and the dragger has stopped grabbing events.
virtual ~SoDragger()
static void childValueChangedCB(void *, SoDragger *)
static SbMatrix appendRotation(const SbMatrix &mtx, const SbRotation &rot, const SbVec3f &rotCenter, const SbMatrix *conversion=NULL)
void unregisterChildDraggerMovingIndependently(SoDragger *child)
void registerChildDraggerMovingIndependently(SoDragger *child)
These two routines tie the child to the parent, but WITHOUT the transferMotion callback.
virtual bool mouseButtonPressed(const SoEvent *ev)
This is called during handleEvent.
SoSFBool isActive
This field is a boolean that is TRUE when the mouse is down and we are dragging, FALSE otherwise.
Definition SoDragger.h:238
virtual bool shouldGrabBasedOnSurrogate(const SoPath *pickPath, const SoPath *surrogatePath)
Given a pickPath and a surrogatePath, decides whether it should grab based on the surrogate.
void addOtherEventCallback(SoDraggerCB *f, void *userData=NULL)
In addition to the public callback functions, these callback functions can also be used by subclasses...
void setTempPathToThis(const SoPath *somethingClose)
A path leading to 'this.
void setHandleEventAction(SoHandleEventAction *newAction)
static void workValuesIntoTransform(SbMatrix &mtx, const SbVec3f *translationPtr, const SbRotation *rotationPtr, const SbVec3f *scaleFactorPtr, const SbRotation *scaleOrientationPtr, const SbVec3f *centerPtr)
Same as above, but values are given explicitly as pointers.
virtual void grabEventsCleanup()
SoSFBool enable
This field is a boolean that enables / disables interaction.
Definition SoDragger.h:234
void setStartingPoint(const SoPickedPoint *newPoint)
Set the point where the drag begins.
SbVec3f getLocalStartingPoint()
Returns the starting point in local coordinates.
virtual void handleEvent(SoHandleEventAction *ha)
This is called during traversal by a HandleEventAction.
SbMatrix getLocalToWorldMatrix()
Get the matrix which converts from one dragger space to another.
bool isAdequateConstraintMotion()
Has the locater moved far enough from where it started to choose a constraint gesture.
bool enableValueChangedCallbacks(bool newVal)
You can temporarily disable a dragger's valueChangedCallbacks.
SoDragger * getActiveChildDragger() const
Definition SoDragger.h:596
void setIgnoreInBbox(bool newVal)
Set/get whether the dragger should be ignored during bounding box calculations.
Definition SoDragger.h:575
static void initClasses()
Initialize ALL Inventor detail classes.
const SbViewportRegion & getViewportRegion()
Definition SoDragger.h:424
static void getTransformFast(SbMatrix &mtx, SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation, const SbVec3f &center)
Faster versions of getTransform() and factor() that take advantage of the case where there is no scal...
void addFinishCallback(SoDraggerCB *f, void *userData=NULL)
Finish callbacks are made after dragging ends and the dragger has stopped grabbing events.
ProjectorFrontSetting getFrontOnProjector() const
Definition SoDragger.h:506
const SoPath * getSurrogatePartPickedOwner() const
Surrogate Pick Information.
Definition SoDragger.h:394
void setActiveChildDragger(SoDragger *newChildDragger)
Called by the above child callbacks.
virtual void setDefaultOnNonWritingFields()
Called by the SoBaseKit::write() method.
SbVec2f getNormalizedLocaterPosition()
Get the last known position of the locator (mouse).
static void getTransformFast(SbMatrix &mtx, SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation)
virtual bool mouseButtonReleased(const SoEvent *ev)
This is called during handleEvent.
void transformMatrixLocalToWorld(const SbMatrix &fromMatrix, SbMatrix &toMatrix)
Transforms a given matrix from one space into another space.
const SbMatrix & getStartMotionMatrix()
Used to calculate motion relative to the dragger's position at the beginning of the dragging.
Definition SoDragger.h:372
void transferMotion(SoDragger *child)
This should be called by every child dragger of a compound dragger as a result of compoundDragger->re...
void addStartCallback(SoDraggerCB *f, void *userData=NULL)
Start callbacks are made after the mouse button 1 goes down and the dragger determines that it has be...
void workFieldsIntoTransform(SbMatrix &mtx)
Changes only that part of the matrix for which this dragger has fields.
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Implements getBoundingBox action.
void setStartLocaterPosition(SbVec2s p)
The start locater position is automatically set when button 1 goes down over the dragger.
Definition SoDragger.h:528
static SbMatrix appendScale(const SbMatrix &mtx, const SbVec3f &scale, const SbVec3f &scaleCenter, const SbMatrix *conversion=NULL)
SbVec2s getStartLocaterPosition() const
Get the position of the locater when dragging started.
Definition SoDragger.h:523
void setViewportRegion(const SbViewportRegion &reg)
Definition SoDragger.h:425
void transformMatrixWorldToLocal(const SbMatrix &fromMatrix, SbMatrix &toMatrix)
void removeStartCallback(SoDraggerCB *f, void *userData=NULL)
SbVec2s getLocaterPosition()
void setStartingPoint(const SbVec3f &newPoint)
The SbVec3f version would usually be a point saved from the end of another gesture.
static SbMatrix appendTranslation(const SbMatrix &mtx, const SbVec3f &translation, const SbMatrix *conversion=NULL)
Appends the given motion to the end of 'mtx'.
void unregisterChildDragger(SoDragger *child)
void removeValueChangedCallback(SoDraggerCB *f, void *userData=NULL)
static void setMinScale(float newMinScale)
The smallest scale that any dragger will write.
Definition SoDragger.h:278
const SoPath * getPickPath() const
Information that's good to have during a valueChanged callback.
SbMatrix getWorldToLocalMatrix()
void valueChanged()
Invokes the valueChangedCallbacks.
const SbName & getSurrogatePartPickedName() const
Name: Name of the surrogate part within the owners list.
Definition SoDragger.h:398
void setMotionMatrix(const SbMatrix &newMatrix)
Set the motion matrix.
static void initClass()
SoDragger()
Constructor.
int getMinGesture() const
Set and get the number of pixels of movement required to initiate a constraint gesture.
Definition SoDragger.h:273
const SoPath * getSurrogatePartPickedPath() const
SurrogatePath: The owner's surrogate path for this name.
Definition SoDragger.h:404
void addMotionCallback(SoDraggerCB *f, void *userData=NULL)
Motion callbacks are called after each movement of the mouse during dragging.
void setViewVolume(const SbViewVolume &vol)
Definition SoDragger.h:422
SoPath * createPathToThis()
Creates a new path leading to this dragger, if the last path given by setTempPathToThis() is still va...
SbVec3f getWorldStartingPoint()
Returns the starting point in world coordinates.
void addValueChangedCallback(SoDraggerCB *f, void *userData=NULL)
Value-changed callbacks are made after a dragger changes any of its fields.
static void childOtherEventCB(void *, SoDragger *)
static float getMinScale()
Get min scale.
Definition SoDragger.h:280
void setFrontOnProjector(ProjectorFrontSetting newVal)
Definition SoDragger.h:504
SoHandleEventAction * getHandleEventAction() const
Get the most recent handleEventAction.
Definition SoDragger.h:428
static void childTransferMotionAndValueChangedCB(void *, SoDragger *)
Stubs used by compound draggers to get user callbacks from the child dragger.
void setCameraInfo(SoAction *action)
The dragger looks in this action to get information about the camera and the viewport.
static void childFinishCB(void *, SoDragger *)
static void childStartCB(void *, SoDragger *)
void transformMatrixToLocalSpace(const SbMatrix &fromMatrix, SbMatrix &toMatrix, const SbName &fromSpacePartName)
void removeOtherEventCallback(SoDraggerCB *f, void *userData=NULL)
const SbMatrix & getMotionMatrix()
Get the motion matrix.
virtual void grabEventsSetup()
Called when the dragger gains or loses status as "grabber" of events.
ProjectorFrontSetting
These control behavior of the rotational parts.
Definition SoDragger.h:501
Base class for all events.
Definition SoEvent.h:84
This SoEXTENDER class allows expert users to examine "hidden" children in paths.
Definition SoPath.h:299
Computes bounding box of a scene.
Allows nodes in a graph to receive input events.
Base class for all interaction nodekit classes.
Path that points to a list of hierarchical nodes.
Definition SoPath.h:109
Represents point on surface of picked object.
Field containing a single boolean value.
Definition SoSFBool.h:78
This class is internal to Inventor.
Definition SoTempPath.h:74