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 ** Modified by : Howard Look (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2022 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_DRAGPOINT_DRAGGER_ 00052 #define _SO_DRAGPOINT_DRAGGER_ 00053 00054 #include <Inventor/SbLinear.h> 00055 #include <Inventor/SbBox.h> 00056 #include <Inventor/draggers/SoDragger.h> 00057 #include <Inventor/fields/SoSFVec3f.h> 00058 #include <Inventor/sensors/SoSensor.h> 00059 00060 00061 class SoFieldSensor; 00062 00064 // 00065 // Class: SoDragPointDragger 00066 // 00067 // DragPoint dragger - allows user to move a single coordinate in 00068 // three dimensions. 00069 // 00071 00325 class SoDragPointDragger : public SoDragger 00326 { 00327 SO_KIT_HEADER(SoDragPointDragger); 00328 00329 SO_KIT_CATALOG_ENTRY_HEADER(noRotSep); 00330 SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorSwitch); 00331 SO_KIT_CATALOG_ENTRY_HEADER(xTranslator); 00332 SO_KIT_CATALOG_ENTRY_HEADER(xyTranslatorSwitch); 00333 SO_KIT_CATALOG_ENTRY_HEADER(xyTranslator); 00334 00335 SO_KIT_CATALOG_ENTRY_HEADER(rotXSep); 00336 SO_KIT_CATALOG_ENTRY_HEADER(rotX); 00337 SO_KIT_CATALOG_ENTRY_HEADER(xzTranslatorSwitch); 00338 SO_KIT_CATALOG_ENTRY_HEADER(xzTranslator); 00339 00340 SO_KIT_CATALOG_ENTRY_HEADER(rotYSep); 00341 SO_KIT_CATALOG_ENTRY_HEADER(rotY); 00342 SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorSwitch); 00343 SO_KIT_CATALOG_ENTRY_HEADER(zTranslator); 00344 SO_KIT_CATALOG_ENTRY_HEADER(yzTranslatorSwitch); 00345 SO_KIT_CATALOG_ENTRY_HEADER(yzTranslator); 00346 00347 SO_KIT_CATALOG_ENTRY_HEADER(rotZSep); 00348 SO_KIT_CATALOG_ENTRY_HEADER(rotZ); 00349 SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorSwitch); 00350 SO_KIT_CATALOG_ENTRY_HEADER(yTranslator); 00351 00352 SO_KIT_CATALOG_ENTRY_HEADER(xFeedbackSwitch); 00353 SO_KIT_CATALOG_ENTRY_HEADER(xFeedbackSep); 00354 SO_KIT_CATALOG_ENTRY_HEADER(xFeedbackTranslation); 00355 SO_KIT_CATALOG_ENTRY_HEADER(xFeedback); 00356 00357 SO_KIT_CATALOG_ENTRY_HEADER(yFeedbackSwitch); 00358 SO_KIT_CATALOG_ENTRY_HEADER(yFeedbackSep); 00359 SO_KIT_CATALOG_ENTRY_HEADER(yFeedbackTranslation); 00360 SO_KIT_CATALOG_ENTRY_HEADER(yFeedback); 00361 00362 SO_KIT_CATALOG_ENTRY_HEADER(zFeedbackSwitch); 00363 SO_KIT_CATALOG_ENTRY_HEADER(zFeedbackSep); 00364 SO_KIT_CATALOG_ENTRY_HEADER(zFeedbackTranslation); 00365 SO_KIT_CATALOG_ENTRY_HEADER(zFeedback); 00366 00367 SO_KIT_CATALOG_ENTRY_HEADER(planeFeedbackSep); 00368 SO_KIT_CATALOG_ENTRY_HEADER(planeFeedbackTranslation); 00369 SO_KIT_CATALOG_ENTRY_HEADER(planeFeedbackSwitch); 00370 SO_KIT_CATALOG_ENTRY_HEADER(yzFeedback); 00371 SO_KIT_CATALOG_ENTRY_HEADER(xzFeedback); 00372 SO_KIT_CATALOG_ENTRY_HEADER(xyFeedback); 00373 00374 public: 00378 SoDragPointDragger(); 00379 00384 SoSFVec3f translation; 00385 00386 public: 00392 void setJumpLimit(float limit) { jumpLimit = limit; } 00396 float getJumpLimit() const { return jumpLimit; } 00397 00404 void showNextDraggerSet(); 00405 00407 enum DraggerSet { 00408 /* 00409 * X axis dragger set (x-line/yz-plane) 00410 */ 00411 X_AXIS, 00412 /* 00413 * Y axis dragger set (y-line/xz-plane) 00414 */ 00415 Y_AXIS, 00416 /* 00417 * Z axis dragger set (z-line/xy-plane) 00418 */ 00419 Z_AXIS 00420 }; 00421 00427 void showDraggerSet( DraggerSet set ); 00428 00429 private: 00430 static void initClass(); // initialize the class 00431 static void exitClass(); 00432 00433 private: 00434 00435 static void startCB( void *, SoDragger * ); 00436 static void motionCB( void *, SoDragger * ); 00437 static void finishCB( void *, SoDragger * ); 00438 00439 SoFieldSensor *fieldSensor; 00440 static void fieldSensorCB( void *, SoSensor * ); 00441 static void valueChangedCB( void *, SoDragger * ); 00442 00443 static void metaKeyChangeCB( void *, SoDragger *); 00444 00445 void dragStart(); 00446 void drag(); 00447 void dragFinish(); 00448 00449 // detach/attach any sensors, callbacks, and/or field connections. 00450 // Also set geometry of childDraggers to be our default instead of their 00451 // regular default, using our resources. 00452 // Called by: start/end of SoBaseKit::readInstance 00453 // and on new copy by: start/end of SoBaseKit::copy. 00454 // Classes that redefine must call setUpConnections(TRUE,TRUE) 00455 // at end of constructor. 00456 // Returns the state of the node when this was called. 00457 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00458 00459 virtual void setDefaultOnNonWritingFields(); 00460 00461 virtual ~SoDragPointDragger(); 00462 00463 private: 00464 00465 SoDragger *currentDragger; 00466 SbVec3f startLocalHitPt; 00467 00468 SbBool shftDown; // used to keep track of if meta key is down. 00469 00470 // The box defining the area where the feedback appears. 00471 // This box stays still in world space whil the dragger is moved. 00472 // But when the dragger gets too close to the edge, it jumps over 00473 // to define a new box. 00474 // Limit box in local space preserves size of box even when world 00475 // space coordinates are very large (small box dimensions could be 00476 // lost because of limited floating point precision). 00477 SbBox3f limitBox; 00478 SbBox3f localLimitBox; 00479 00480 // when to jump 00481 float jumpLimit; 00482 00483 // sets the feedback geometry based on the level of 00484 // constraints 00485 void setFeedbackGeometry(); 00486 00487 // checks the limit box and extends it if necessary 00488 void checkBoxLimits(); 00489 00490 // Sets the offsetWorkLimit box and updates the feedback geometry 00491 void updateLimitBoxAndFeedback(); 00492 00493 static const char geomBuffer[]; 00494 00495 SoGetBoundingBoxAction* bba; 00496 00497 // Cached values to make updating feedback more efficient 00498 SoNode *oldXAxisNode; 00499 SoNode *oldYAxisNode; 00500 SoNode *oldZAxisNode; 00501 00502 }; 00503 00504 #endif /* _SO_DRAGPOINT_DRAGGER_ */ 00505 00506