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-2020 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 00327 class SoDragPointDragger : public SoDragger 00328 { 00329 SO_KIT_HEADER(SoDragPointDragger); 00330 00331 SO_KIT_CATALOG_ENTRY_HEADER(noRotSep); 00332 SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorSwitch); 00333 SO_KIT_CATALOG_ENTRY_HEADER(xTranslator); 00334 SO_KIT_CATALOG_ENTRY_HEADER(xyTranslatorSwitch); 00335 SO_KIT_CATALOG_ENTRY_HEADER(xyTranslator); 00336 00337 SO_KIT_CATALOG_ENTRY_HEADER(rotXSep); 00338 SO_KIT_CATALOG_ENTRY_HEADER(rotX); 00339 SO_KIT_CATALOG_ENTRY_HEADER(xzTranslatorSwitch); 00340 SO_KIT_CATALOG_ENTRY_HEADER(xzTranslator); 00341 00342 SO_KIT_CATALOG_ENTRY_HEADER(rotYSep); 00343 SO_KIT_CATALOG_ENTRY_HEADER(rotY); 00344 SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorSwitch); 00345 SO_KIT_CATALOG_ENTRY_HEADER(zTranslator); 00346 SO_KIT_CATALOG_ENTRY_HEADER(yzTranslatorSwitch); 00347 SO_KIT_CATALOG_ENTRY_HEADER(yzTranslator); 00348 00349 SO_KIT_CATALOG_ENTRY_HEADER(rotZSep); 00350 SO_KIT_CATALOG_ENTRY_HEADER(rotZ); 00351 SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorSwitch); 00352 SO_KIT_CATALOG_ENTRY_HEADER(yTranslator); 00353 00354 SO_KIT_CATALOG_ENTRY_HEADER(xFeedbackSwitch); 00355 SO_KIT_CATALOG_ENTRY_HEADER(xFeedbackSep); 00356 SO_KIT_CATALOG_ENTRY_HEADER(xFeedbackTranslation); 00357 SO_KIT_CATALOG_ENTRY_HEADER(xFeedback); 00358 00359 SO_KIT_CATALOG_ENTRY_HEADER(yFeedbackSwitch); 00360 SO_KIT_CATALOG_ENTRY_HEADER(yFeedbackSep); 00361 SO_KIT_CATALOG_ENTRY_HEADER(yFeedbackTranslation); 00362 SO_KIT_CATALOG_ENTRY_HEADER(yFeedback); 00363 00364 SO_KIT_CATALOG_ENTRY_HEADER(zFeedbackSwitch); 00365 SO_KIT_CATALOG_ENTRY_HEADER(zFeedbackSep); 00366 SO_KIT_CATALOG_ENTRY_HEADER(zFeedbackTranslation); 00367 SO_KIT_CATALOG_ENTRY_HEADER(zFeedback); 00368 00369 SO_KIT_CATALOG_ENTRY_HEADER(planeFeedbackSep); 00370 SO_KIT_CATALOG_ENTRY_HEADER(planeFeedbackTranslation); 00371 SO_KIT_CATALOG_ENTRY_HEADER(planeFeedbackSwitch); 00372 SO_KIT_CATALOG_ENTRY_HEADER(yzFeedback); 00373 SO_KIT_CATALOG_ENTRY_HEADER(xzFeedback); 00374 SO_KIT_CATALOG_ENTRY_HEADER(xyFeedback); 00375 00376 public: 00380 SoDragPointDragger(); 00381 00386 SoSFVec3f translation; 00387 00388 public: 00394 void setJumpLimit(float limit) { jumpLimit = limit; } 00398 float getJumpLimit() const { return jumpLimit; } 00399 00406 void showNextDraggerSet(); 00407 00409 enum DraggerSet { 00410 /* 00411 * X axis dragger set (x-line/yz-plane) 00412 */ 00413 X_AXIS, 00414 /* 00415 * Y axis dragger set (y-line/xz-plane) 00416 */ 00417 Y_AXIS, 00418 /* 00419 * Z axis dragger set (z-line/xy-plane) 00420 */ 00421 Z_AXIS 00422 }; 00423 00429 void showDraggerSet( DraggerSet set ); 00430 00431 private: 00432 static void initClass(); // initialize the class 00433 static void exitClass(); 00434 00435 private: 00436 00437 static void startCB( void *, SoDragger * ); 00438 static void motionCB( void *, SoDragger * ); 00439 static void finishCB( void *, SoDragger * ); 00440 00441 SoFieldSensor *fieldSensor; 00442 static void fieldSensorCB( void *, SoSensor * ); 00443 static void valueChangedCB( void *, SoDragger * ); 00444 00445 static void metaKeyChangeCB( void *, SoDragger *); 00446 00447 void dragStart(); 00448 void drag(); 00449 void dragFinish(); 00450 00451 // detach/attach any sensors, callbacks, and/or field connections. 00452 // Also set geometry of childDraggers to be our default instead of their 00453 // regular default, using our resources. 00454 // Called by: start/end of SoBaseKit::readInstance 00455 // and on new copy by: start/end of SoBaseKit::copy. 00456 // Classes that redefine must call setUpConnections(TRUE,TRUE) 00457 // at end of constructor. 00458 // Returns the state of the node when this was called. 00459 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00460 00461 virtual void setDefaultOnNonWritingFields(); 00462 00463 virtual ~SoDragPointDragger(); 00464 00465 private: 00466 00467 SoDragger *currentDragger; 00468 SbVec3f startLocalHitPt; 00469 00470 SbBool shftDown; // used to keep track of if meta key is down. 00471 00472 // The box defining the area where the feedback appears. 00473 // This box stays still in world space whil the dragger is moved. 00474 // But when the dragger gets too close to the edge, it jumps over 00475 // to define a new box. 00476 // Limit box in local space preserves size of box even when world 00477 // space coordinates are very large (small box dimensions could be 00478 // lost because of limited floating point precision). 00479 SbBox3f limitBox; 00480 SbBox3f localLimitBox; 00481 00482 // when to jump 00483 float jumpLimit; 00484 00485 // sets the feedback geometry based on the level of 00486 // constraints 00487 void setFeedbackGeometry(); 00488 00489 // checks the limit box and extends it if necessary 00490 void checkBoxLimits(); 00491 00492 // Sets the offsetWorkLimit box and updates the feedback geometry 00493 void updateLimitBoxAndFeedback(); 00494 00495 static const char geomBuffer[]; 00496 00497 SoGetBoundingBoxAction* bba; 00498 00499 // Cached values to make updating feedback more efficient 00500 SoNode *oldXAxisNode; 00501 SoNode *oldYAxisNode; 00502 SoNode *oldZAxisNode; 00503 00504 }; 00505 00506 #endif /* _SO_DRAGPOINT_DRAGGER_ */ 00507 00508