Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/interaction/include/Inventor/draggers/SoHandleBoxDragger.h
Go to the documentation of this file.
00001 /*
00002  *
00003  *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  * 
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027  *  Mountain View, CA  94043, or:
00028  * 
00029  *  http://www.sgi.com 
00030  * 
00031  *  For further information regarding this notice, see: 
00032  * 
00033  *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034  *
00035  */
00036 
00037 
00038 /*
00039  * Copyright (C) 1990,91   Silicon Graphics, Inc.
00040  *
00041  _______________________________________________________________________
00042  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00043  |
00044  |   $Revision: 1.1.1.1 $
00045  |
00046  |   Description:
00047  |      This file defines the handle box dragger class.
00048  |
00049  | NOTE TO DEVELOPERS:
00050  |     For info about the structure of SoHandleBoxDragger:
00051  |     [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure
00052  |     [2] type:    ivNodeKitStructure SoHandleBoxDragger.
00053  |     [3] The program prints a diagram of the scene graph and a table with 
00054  |         information about each part.
00055  |
00056  |  The following parts in this dragger are created at construction time.
00057  |  'ResourceName' corresponds to the name of the default geometry for the
00058  |  part. The dragger's constructor gets the scene graph for 'ResourceName'
00059  |  by querying the global dictionary ( SoDB::getByName("ResourceName"); ).  
00060  |
00061  |  Resource Name:                           Part Name:
00062  |
00063  |  NOTE: for the translators and extruders, 
00064  |        numbering refers to a cube-face:
00065  |        1=top,2=bot,3=lft,4=rit,5=fnt,6=bak
00066  |
00067  |      handleBoxTranslator1               - translator1
00068  |      handleBoxTranslator1Active         - translator1Active
00069  |      (ditto for translator2-translator6)
00070  |
00071  |      handleBoxExtruder1                 - extruder1
00072  |      handleBoxExtruder1Active           - extruder1Active
00073  |      (ditto for extruder2-extruder6)
00074  |
00075  |  
00076  |  NOTE: for the uniform scalers, 
00077  |        numbers refer to a corner: 
00078  |        1=+x+y+z,  2=+x+y-z, 3=+x-y+z, 
00079  |        4=+x-y-z,  5=-x+y+z,  6=-x+y-z, 
00080  |        7=-x-y+z, 8=-x-y-z
00081  |      handleBoxUniform1                  - uniform1
00082  |      handleBoxUniform1Active            - uniform1Active
00083  |      (ditto for uniform2-uniform8)
00084  |
00085  |  NOTE: for the arrows, numbering refers
00086  |        to cube-face they point out from:
00087  |        1=top,2=bot,3=lft,4=rit,5=fnt,6=bak
00088  |  
00089  |      handleBoxArrow1                    - arrow1
00090  |      (ditto for arrow2-arrow6)
00091  |
00092  |   Author(s): Paul Isaacs, David Mott
00093  |
00094  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00095  _______________________________________________________________________
00096  */
00097 
00098 #ifndef  _SO_HANDLEBOX_DRAGGER_
00099 #define  _SO_HANDLEBOX_DRAGGER_
00100 
00101 #include <Inventor/draggers/SoDragger.h>
00102 #include <Inventor/fields/SoSFVec3f.h>
00103 #include <Inventor/sensors/SoSensor.h>
00104 
00105 class SbDict;
00106 class SoDrawStyle;
00107 class SbPlaneProjector;
00108 class SbLineProjector;
00109 class SoFieldSensor;
00110 
00111 
00114 
00202 
00203 
00204 class INVENTOR_API SoHandleBoxDragger : public SoDragger {
00205 
00206     SO_KIT_HEADER(SoHandleBoxDragger);
00207 
00208     SO_KIT_CATALOG_ENTRY_HEADER(drawStyle);
00209 
00211     SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
00212 
00213     SO_KIT_CATALOG_ENTRY_HEADER(translator1Switch);
00214     SO_KIT_CATALOG_ENTRY_HEADER(translator1);
00215     SO_KIT_CATALOG_ENTRY_HEADER(translator1Active);
00216     SO_KIT_CATALOG_ENTRY_HEADER(translator2Switch);
00217     SO_KIT_CATALOG_ENTRY_HEADER(translator2);
00218     SO_KIT_CATALOG_ENTRY_HEADER(translator2Active);
00219     SO_KIT_CATALOG_ENTRY_HEADER(translator3Switch);
00220     SO_KIT_CATALOG_ENTRY_HEADER(translator3);
00221     SO_KIT_CATALOG_ENTRY_HEADER(translator3Active);
00222     SO_KIT_CATALOG_ENTRY_HEADER(translator4Switch);
00223     SO_KIT_CATALOG_ENTRY_HEADER(translator4);
00224     SO_KIT_CATALOG_ENTRY_HEADER(translator4Active);
00225     SO_KIT_CATALOG_ENTRY_HEADER(translator5Switch);
00226     SO_KIT_CATALOG_ENTRY_HEADER(translator5);
00227     SO_KIT_CATALOG_ENTRY_HEADER(translator5Active);
00228     SO_KIT_CATALOG_ENTRY_HEADER(translator6Switch);
00229     SO_KIT_CATALOG_ENTRY_HEADER(translator6);
00230     SO_KIT_CATALOG_ENTRY_HEADER(translator6Active);
00231 
00232 
00233     SO_KIT_CATALOG_ENTRY_HEADER(extruder1Switch);
00234     SO_KIT_CATALOG_ENTRY_HEADER(extruder1);
00235     SO_KIT_CATALOG_ENTRY_HEADER(extruder1Active);
00236     SO_KIT_CATALOG_ENTRY_HEADER(extruder2Switch);
00237     SO_KIT_CATALOG_ENTRY_HEADER(extruder2);
00238     SO_KIT_CATALOG_ENTRY_HEADER(extruder2Active);
00239     SO_KIT_CATALOG_ENTRY_HEADER(extruder3Switch);
00240     SO_KIT_CATALOG_ENTRY_HEADER(extruder3);
00241     SO_KIT_CATALOG_ENTRY_HEADER(extruder3Active);
00242     SO_KIT_CATALOG_ENTRY_HEADER(extruder4Switch);
00243     SO_KIT_CATALOG_ENTRY_HEADER(extruder4);
00244     SO_KIT_CATALOG_ENTRY_HEADER(extruder4Active);
00245     SO_KIT_CATALOG_ENTRY_HEADER(extruder5Switch);
00246     SO_KIT_CATALOG_ENTRY_HEADER(extruder5);
00247     SO_KIT_CATALOG_ENTRY_HEADER(extruder5Active);
00248     SO_KIT_CATALOG_ENTRY_HEADER(extruder6Switch);
00249     SO_KIT_CATALOG_ENTRY_HEADER(extruder6);
00250     SO_KIT_CATALOG_ENTRY_HEADER(extruder6Active);
00251 
00252     SO_KIT_CATALOG_ENTRY_HEADER(uniform1Switch);
00253     SO_KIT_CATALOG_ENTRY_HEADER(uniform1);
00254     SO_KIT_CATALOG_ENTRY_HEADER(uniform1Active);
00255     SO_KIT_CATALOG_ENTRY_HEADER(uniform2Switch);
00256     SO_KIT_CATALOG_ENTRY_HEADER(uniform2);
00257     SO_KIT_CATALOG_ENTRY_HEADER(uniform2Active);
00258     SO_KIT_CATALOG_ENTRY_HEADER(uniform3Switch);
00259     SO_KIT_CATALOG_ENTRY_HEADER(uniform3);
00260     SO_KIT_CATALOG_ENTRY_HEADER(uniform3Active);
00261     SO_KIT_CATALOG_ENTRY_HEADER(uniform4Switch);
00262     SO_KIT_CATALOG_ENTRY_HEADER(uniform4);
00263     SO_KIT_CATALOG_ENTRY_HEADER(uniform4Active);
00264     SO_KIT_CATALOG_ENTRY_HEADER(uniform5Switch);
00265     SO_KIT_CATALOG_ENTRY_HEADER(uniform5);
00266     SO_KIT_CATALOG_ENTRY_HEADER(uniform5Active);
00267     SO_KIT_CATALOG_ENTRY_HEADER(uniform6Switch);
00268     SO_KIT_CATALOG_ENTRY_HEADER(uniform6);
00269     SO_KIT_CATALOG_ENTRY_HEADER(uniform6Active);
00270     SO_KIT_CATALOG_ENTRY_HEADER(uniform7Switch);
00271     SO_KIT_CATALOG_ENTRY_HEADER(uniform7);
00272     SO_KIT_CATALOG_ENTRY_HEADER(uniform7Active);
00273     SO_KIT_CATALOG_ENTRY_HEADER(uniform8Switch);
00274     SO_KIT_CATALOG_ENTRY_HEADER(uniform8);
00275     SO_KIT_CATALOG_ENTRY_HEADER(uniform8Active);
00276 
00277     SO_KIT_CATALOG_ENTRY_HEADER(arrowTranslation);
00278 
00279     SO_KIT_CATALOG_ENTRY_HEADER(arrow1Switch);
00280     SO_KIT_CATALOG_ENTRY_HEADER(arrow1);
00281     SO_KIT_CATALOG_ENTRY_HEADER(arrow2Switch);
00282     SO_KIT_CATALOG_ENTRY_HEADER(arrow2);
00283     SO_KIT_CATALOG_ENTRY_HEADER(arrow3Switch);
00284     SO_KIT_CATALOG_ENTRY_HEADER(arrow3);
00285     SO_KIT_CATALOG_ENTRY_HEADER(arrow4Switch);
00286     SO_KIT_CATALOG_ENTRY_HEADER(arrow4);
00287     SO_KIT_CATALOG_ENTRY_HEADER(arrow5Switch);
00288     SO_KIT_CATALOG_ENTRY_HEADER(arrow5);
00289     SO_KIT_CATALOG_ENTRY_HEADER(arrow6Switch);
00290     SO_KIT_CATALOG_ENTRY_HEADER(arrow6);
00291 
00292   public:
00293 
00295     SoHandleBoxDragger();
00296     
00297     SoSFVec3f    translation;
00298     SoSFVec3f    scaleFactor;
00299 
00300   SoINTERNAL public:
00301     static void         initClass();    
00302 
00303   protected:
00304 
00306     static void startCB( void *, SoDragger * );
00307     static void motionCB( void *, SoDragger * );
00308     static void finishCB( void *, SoDragger * );
00309     
00310     SoFieldSensor *translFieldSensor;
00311     SoFieldSensor *scaleFieldSensor;
00312     static void   fieldSensorCB( void *, SoSensor * );
00313     static void valueChangedCB( void *, SoDragger * );
00314 
00316     static void metaKeyChangeCB( void *, SoDragger *);
00317 
00319     void        dragStart();
00320     void        drag();
00321     void        dragFinish();
00322 
00323     void setAllPartsActive( SbBool onOrOff );
00324 
00331     virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00332 
00333     virtual void setDefaultOnNonWritingFields();
00334 
00335     virtual ~SoHandleBoxDragger();
00336 
00337   private:
00338 
00339     enum WhichAxis 
00340         { POSX, POSY, POSZ, NEGX, NEGY, NEGZ };
00341     void   highlightAxisForScale( WhichAxis axis );
00342 
00343     enum State
00344         { INACTIVE, 
00345           SCALE_GEOM_ONLY,
00346            RIT_X_SCALE,  TOP_Y_SCALE,  FNT_Z_SCALE, 
00347            LFT_X_SCALE,  BOT_Y_SCALE,  BAK_Z_SCALE, 
00348 
00349           PX_PY_PZ_3D_SCALE, PX_PY_NZ_3D_SCALE, PX_NY_PZ_3D_SCALE, 
00350           PX_NY_NZ_3D_SCALE, NX_PY_PZ_3D_SCALE, NX_PY_NZ_3D_SCALE, 
00351           NX_NY_PZ_3D_SCALE, NX_NY_NZ_3D_SCALE, 
00352 
00353           RIT_TRANSLATE,  TOP_TRANSLATE,  FNT_TRANSLATE,
00354           LFT_TRANSLATE,  BOT_TRANSLATE,  BAK_TRANSLATE };
00355 
00356     State               currentState;     
00357     int                 translateDir;   
00358 
00359 
00360 
00361     SbPlaneProjector    *motionPlaneProj;
00362     SbLineProjector     *motionLineProj;
00363 
00364     State           restartState;     
00365     SbVec3f         worldRestartPt; 
00366 
00367     SbBool          altDown, ctlDown, shftDown;  
00368 
00369 
00371     void        setHighlights();
00372     void        setFeedbackArrows();
00373 
00374     SbBool              translateInit();
00375     SbBool              faceScaleInit();
00376     SbBool              uniformScaleInit();
00377     SbBool              scaleGeomSizeOnlyInit();
00378 
00379     SbBool              translateDrag();
00380     SbBool              scaleDrag();
00381     SbBool              scaleGeomSizeOnlyDrag();
00382 
00384     static const char geomBuffer[];             
00385 };
00386 
00387 #endif /* _SO_HANDLEBOX_DRAGGER_ */