00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _SO_HANDLEBOX_DRAGGER_
00052 #define _SO_HANDLEBOX_DRAGGER_
00053
00054 #include <Inventor/draggers/SoDragger.h>
00055 #include <Inventor/fields/SoSFVec3f.h>
00056 #include <Inventor/sensors/SoSensor.h>
00057
00058 class SbDict;
00059 class SoDrawStyle;
00060 class SbPlaneProjector;
00061 class SbLineProjector;
00062 class SoFieldSensor;
00063
00065
00066
00067
00068
00069
00071
00523 class SoHandleBoxDragger : public SoDragger {
00524
00525 SO_KIT_HEADER(SoHandleBoxDragger);
00526
00527 SO_KIT_CATALOG_ENTRY_HEADER(drawStyle);
00528
00529
00530 SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
00531
00532 SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
00533 SO_KIT_CATALOG_ENTRY_HEADER(translator1);
00534 SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
00535 SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
00536 SO_KIT_CATALOG_ENTRY_HEADER(translator2);
00537 SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
00538 SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
00539 SO_KIT_CATALOG_ENTRY_HEADER(translator3);
00540 SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
00541 SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
00542 SO_KIT_CATALOG_ENTRY_HEADER(translator4);
00543 SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
00544 SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
00545 SO_KIT_CATALOG_ENTRY_HEADER(translator5);
00546 SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
00547 SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
00548 SO_KIT_CATALOG_ENTRY_HEADER(translator6);
00549 SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
00550
00551
00552 SO_KIT_CATALOG_ENTRY_HEADER(extruder1Switch);
00553 SO_KIT_CATALOG_ENTRY_HEADER(extruder1);
00554 SO_KIT_CATALOG_ENTRY_HEADER(extruder1Active);
00555 SO_KIT_CATALOG_ENTRY_HEADER(extruder2Switch);
00556 SO_KIT_CATALOG_ENTRY_HEADER(extruder2);
00557 SO_KIT_CATALOG_ENTRY_HEADER(extruder2Active);
00558 SO_KIT_CATALOG_ENTRY_HEADER(extruder3Switch);
00559 SO_KIT_CATALOG_ENTRY_HEADER(extruder3);
00560 SO_KIT_CATALOG_ENTRY_HEADER(extruder3Active);
00561 SO_KIT_CATALOG_ENTRY_HEADER(extruder4Switch);
00562 SO_KIT_CATALOG_ENTRY_HEADER(extruder4);
00563 SO_KIT_CATALOG_ENTRY_HEADER(extruder4Active);
00564 SO_KIT_CATALOG_ENTRY_HEADER(extruder5Switch);
00565 SO_KIT_CATALOG_ENTRY_HEADER(extruder5);
00566 SO_KIT_CATALOG_ENTRY_HEADER(extruder5Active);
00567 SO_KIT_CATALOG_ENTRY_HEADER(extruder6Switch);
00568 SO_KIT_CATALOG_ENTRY_HEADER(extruder6);
00569 SO_KIT_CATALOG_ENTRY_HEADER(extruder6Active);
00570
00571 SO_KIT_CATALOG_ENTRY_HEADER(uniform1Switch);
00572 SO_KIT_CATALOG_ENTRY_HEADER(uniform1);
00573 SO_KIT_CATALOG_ENTRY_HEADER(uniform1Active);
00574 SO_KIT_CATALOG_ENTRY_HEADER(uniform2Switch);
00575 SO_KIT_CATALOG_ENTRY_HEADER(uniform2);
00576 SO_KIT_CATALOG_ENTRY_HEADER(uniform2Active);
00577 SO_KIT_CATALOG_ENTRY_HEADER(uniform3Switch);
00578 SO_KIT_CATALOG_ENTRY_HEADER(uniform3);
00579 SO_KIT_CATALOG_ENTRY_HEADER(uniform3Active);
00580 SO_KIT_CATALOG_ENTRY_HEADER(uniform4Switch);
00581 SO_KIT_CATALOG_ENTRY_HEADER(uniform4);
00582 SO_KIT_CATALOG_ENTRY_HEADER(uniform4Active);
00583 SO_KIT_CATALOG_ENTRY_HEADER(uniform5Switch);
00584 SO_KIT_CATALOG_ENTRY_HEADER(uniform5);
00585 SO_KIT_CATALOG_ENTRY_HEADER(uniform5Active);
00586 SO_KIT_CATALOG_ENTRY_HEADER(uniform6Switch);
00587 SO_KIT_CATALOG_ENTRY_HEADER(uniform6);
00588 SO_KIT_CATALOG_ENTRY_HEADER(uniform6Active);
00589 SO_KIT_CATALOG_ENTRY_HEADER(uniform7Switch);
00590 SO_KIT_CATALOG_ENTRY_HEADER(uniform7);
00591 SO_KIT_CATALOG_ENTRY_HEADER(uniform7Active);
00592 SO_KIT_CATALOG_ENTRY_HEADER(uniform8Switch);
00593 SO_KIT_CATALOG_ENTRY_HEADER(uniform8);
00594 SO_KIT_CATALOG_ENTRY_HEADER(uniform8Active);
00595
00596 SO_KIT_CATALOG_ENTRY_HEADER(arrowTranslation);
00597
00598 SO_KIT_CATALOG_ENTRY_HEADER(arrow1Switch);
00599 SO_KIT_CATALOG_ENTRY_HEADER(arrow1);
00600 SO_KIT_CATALOG_ENTRY_HEADER(arrow2Switch);
00601 SO_KIT_CATALOG_ENTRY_HEADER(arrow2);
00602 SO_KIT_CATALOG_ENTRY_HEADER(arrow3Switch);
00603 SO_KIT_CATALOG_ENTRY_HEADER(arrow3);
00604 SO_KIT_CATALOG_ENTRY_HEADER(arrow4Switch);
00605 SO_KIT_CATALOG_ENTRY_HEADER(arrow4);
00606 SO_KIT_CATALOG_ENTRY_HEADER(arrow5Switch);
00607 SO_KIT_CATALOG_ENTRY_HEADER(arrow5);
00608 SO_KIT_CATALOG_ENTRY_HEADER(arrow6Switch);
00609 SO_KIT_CATALOG_ENTRY_HEADER(arrow6);
00610
00611 public:
00615 SoHandleBoxDragger();
00616
00621 SoSFVec3f translation;
00626 SoSFVec3f scaleFactor;
00627
00628 private:
00629 static void initClass();
00630 static void exitClass();
00631
00632 private:
00633
00634
00635 static void startCB( void *, SoDragger * );
00636 static void motionCB( void *, SoDragger * );
00637 static void finishCB( void *, SoDragger * );
00638
00639 SoFieldSensor *translFieldSensor;
00640 SoFieldSensor *scaleFieldSensor;
00641 static void fieldSensorCB( void *, SoSensor * );
00642 static void valueChangedCB( void *, SoDragger * );
00643
00644
00645 static void metaKeyChangeCB( void *, SoDragger *);
00646
00647
00648 void dragStart();
00649 void drag();
00650 void dragFinish();
00651
00652 void setAllPartsActive( SbBool onOrOff );
00653
00654
00655
00656
00657
00658
00659
00660 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00661
00662 virtual void setDefaultOnNonWritingFields();
00663
00664 virtual ~SoHandleBoxDragger();
00665
00666 private:
00667
00668 enum WhichAxis
00669 { POSX, POSY, POSZ, NEGX, NEGY, NEGZ };
00670 void highlightAxisForScale( WhichAxis axis );
00671
00672 enum State
00673 { INACTIVE,
00674 SCALE_GEOM_ONLY,
00675 RIT_X_SCALE, TOP_Y_SCALE, FNT_Z_SCALE,
00676 LFT_X_SCALE, BOT_Y_SCALE, BAK_Z_SCALE,
00677
00678 PX_PY_PZ_3D_SCALE, PX_PY_NZ_3D_SCALE, PX_NY_PZ_3D_SCALE,
00679 PX_NY_NZ_3D_SCALE, NX_PY_PZ_3D_SCALE, NX_PY_NZ_3D_SCALE,
00680 NX_NY_PZ_3D_SCALE, NX_NY_NZ_3D_SCALE,
00681
00682 RIT_TRANSLATE, TOP_TRANSLATE, FNT_TRANSLATE,
00683 LFT_TRANSLATE, BOT_TRANSLATE, BAK_TRANSLATE };
00684
00685 State currentState;
00686 int translateDir;
00687
00688
00689
00690 SbPlaneProjector *motionPlaneProj;
00691 SbLineProjector *motionLineProj;
00692
00693 State restartState;
00694 SbVec3f worldRestartPt;
00695
00696 SbBool altDown, ctlDown, shftDown;
00697
00698
00699
00700 void setHighlights();
00701 void setFeedbackArrows();
00702
00703 SbBool translateInit();
00704 SbBool faceScaleInit();
00705 SbBool uniformScaleInit();
00706 SbBool scaleGeomSizeOnlyInit();
00707
00708 SbBool translateDrag();
00709 SbBool scaleDrag();
00710 SbBool scaleGeomSizeOnlyDrag();
00711
00712
00713 static const char geomBuffer[];
00714 };
00715
00716 #endif
00717
00718