Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/interaction/include/Inventor/draggers/SoTabPlaneDragger.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,92   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 tab plane dragger class.
00048  |      This dragger allows you to perform scales
00049  |      and translations, all in one tidy plane.
00050  |
00051  | NOTE TO DEVELOPERS:
00052  |     For info about the structure of SoTabPlaneDragger:
00053  |     [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure
00054  |     [2] type:    ivNodeKitStructure SoTabPlaneDragger.
00055  |     [3] The program prints a diagram of the scene graph and a table with 
00056  |         information about each part.
00057  |
00058  |  The following parts in this dragger are created at construction time.
00059  |  'ResourceName' corresponds to the name of the default geometry for the
00060  |  part. The dragger's constructor gets the scene graph for 'ResourceName'
00061  |  by querying the global dictionary ( SoDB::getByName("ResourceName"); ).  
00062  |
00063  |  Resource Name:                           Part Name:
00064  |
00065  |  tabPlaneTranslator                     - translator
00066  |  tabPlaneScaleTabMaterial               - scaleTabMaterial
00067  |  tabPlaneScaleTabHints                  - scaleTabHints
00068  |
00069  |
00070  |   Author(s): Paul Isaacs
00071  |
00072  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00073  _______________________________________________________________________
00074  */
00075 
00076 #ifndef  _SO_TAB_PLANE_DRAGGER_
00077 #define  _SO_TAB_PLANE_DRAGGER_
00078 
00079 #include <Inventor/SbLinear.h>
00080 #include <Inventor/sensors/SoSensor.h>
00081 #include <Inventor/projectors/SbLineProjector.h>
00082 #include <Inventor/projectors/SbPlaneProjector.h>
00083 #include <Inventor/actions/SoCallbackAction.h>
00084 #include <Inventor/draggers/SoDragger.h>
00085 
00086 class SoNode;
00087 class SoCoordinate3;
00088 class SoGLRenderAction;
00089 class SoRayPickAction;
00090 class SoFieldSensor;
00091 
00094 
00170 
00171 
00172 class INVENTOR_API SoTabPlaneDragger : public SoDragger
00173 {
00175     SO_KIT_HEADER(SoTabPlaneDragger);
00176 
00177     SO_KIT_CATALOG_ENTRY_HEADER(planeSwitch);
00178     SO_KIT_CATALOG_ENTRY_HEADER(translator);
00179     SO_KIT_CATALOG_ENTRY_HEADER(scaleTabs);
00180     SO_KIT_CATALOG_ENTRY_HEADER(scaleTabMaterial);
00181     SO_KIT_CATALOG_ENTRY_HEADER(scaleTabHints);
00182     SO_KIT_CATALOG_ENTRY_HEADER(scaleTabMaterialBinding);
00183     SO_KIT_CATALOG_ENTRY_HEADER(scaleTabNormalBinding);
00184     SO_KIT_CATALOG_ENTRY_HEADER(scaleTabNormal);
00185     SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleCoords);
00186     SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab0);
00187     SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab1);
00188     SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab2);
00189     SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab3);
00190     SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleCoords);
00191     SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab0);
00192     SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab1);
00193     SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab2);
00194     SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab3);
00195 
00196   public:
00197 
00199     SoTabPlaneDragger();
00200 
00201     SoSFVec3f    translation;
00202     SoSFVec3f    scaleFactor;
00203 
00209     void    adjustScaleTabSize();
00210 
00211   SoINTERNAL public:
00212     static void initClass();  
00213 
00214   protected:
00215 
00216     static void startCB( void *, SoDragger *);
00217     static void motionCB( void *, SoDragger *);
00218     static void finishCB( void *, SoDragger *);
00219     static void metaKeyChangeCB( void *, SoDragger *);
00220 
00221     SbLineProjector     *lineProj;
00222     SbPlaneProjector    *planeProj;
00223 
00224     SoFieldSensor *translFieldSensor;
00225     SoFieldSensor *scaleFieldSensor;
00226     static void   fieldSensorCB( void *, SoSensor * );
00227     static void valueChangedCB( void *, SoDragger * );
00228 
00229     virtual void    GLRender( SoGLRenderAction *action );
00230 
00231     void        dragStart();
00232     void        drag();
00233     void        dragFinish();
00234 
00235     void        translateStart();
00236     void        translateDrag();
00237     
00238     void        edgeScaleStart();
00239     void        edgeScaleDrag();
00240     
00241     void        cornerScaleStart();
00242     void        cornerScaleDrag();
00243     
00244     void        scaleUniformStart();
00245     void        scaleUniformDrag();
00246 
00247     SbVec3f           worldRestartPt;
00248     int               currentScalePatch;
00249 
00250     enum State {
00251             INACTIVE, TRANSLATING, EDGE_SCALING, CORNER_SCALING, UNIFORM_SCALING
00252     };
00253     SbBool              shftDown;
00254 
00255     State               currentState;
00256     State               restartState;
00257     int                 translateDir;
00258 
00259     SbVec3f             scaleCenter;
00260 
00261     SbBool              needScaleTabAdjustment;
00262     void                reallyAdjustScaleTabSize(SoGLRenderAction *action);
00263 
00264     void getXYScreenLengths( SbVec2f &lengths, const SbMatrix &localToScreen, 
00265                                 const SbVec2s &winSize);
00266 
00273     virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00274 
00275     virtual void setDefaultOnNonWritingFields();
00276 
00277     virtual ~SoTabPlaneDragger();
00278 
00279   private:
00280     static const char geomBuffer[];
00281 };    
00282 
00283 #endif  /* _SO_TAB_PLANE_DRAGGER_ */