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 #ifndef _SO_TAB_PLANE_DRAGGER_
00051 #define _SO_TAB_PLANE_DRAGGER_
00052
00053 #include <Inventor/SbLinear.h>
00054 #include <Inventor/sensors/SoSensor.h>
00055 #include <Inventor/projectors/SbLineProjector.h>
00056 #include <Inventor/projectors/SbPlaneProjector.h>
00057 #include <Inventor/actions/SoCallbackAction.h>
00058 #include <Inventor/draggers/SoDragger.h>
00059
00060 class SoNode;
00061 class SoCoordinate3;
00062 class SoGLRenderAction;
00063 class SoRayPickAction;
00064 class SoFieldSensor;
00065 class SoSwitch;
00066
00220 class SoTabPlaneDragger : public SoDragger
00221 {
00222
00223 SO_KIT_HEADER(SoTabPlaneDragger);
00224
00225 SO_KIT_CATALOG_ENTRY_HEADER(planeSwitch);
00226 SO_KIT_CATALOG_ENTRY_HEADER(translator);
00227 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabs);
00228 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabMaterial);
00229 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabHints);
00230 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabMaterialBinding);
00231 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabNormalBinding);
00232 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabNormal);
00233 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleCoords);
00234 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab0);
00235 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab1);
00236 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab2);
00237 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab3);
00238 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleCoords);
00239 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab0);
00240 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab1);
00241 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab2);
00242 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab3);
00243 SO_KIT_CATALOG_ENTRY_HEADER(translatorMaterial);
00244 SO_KIT_CATALOG_ENTRY_HEADER(translatorDrawStyle);
00245 SO_KIT_CATALOG_ENTRY_HEADER(translatorCoordinates);
00246
00247 public:
00251 SoTabPlaneDragger();
00252
00256 SoSFVec3f translation;
00257
00261 SoSFVec3f scaleFactor;
00262
00269 SoSFBool resizeHandles;
00270
00276 SoSFBool scaleUniform;
00277
00283 SoSFBool twoSidedLighting;
00284
00290 SoSFFloat lineWidth;
00291
00297 SoSFInt32 tabPixelSize;
00298
00307 void adjustScaleTabSize();
00308
00310 void showEdgeScales( const SbBool show );
00311
00313 void showCornerScales( const SbBool show );
00314
00315 private:
00317 static void initClass();
00319 static void exitClass();
00320
00321 int getCurrentState();
00322
00323 private:
00324
00326 SoSwitch* m_edgeSwitch;
00327
00329 SoSwitch* m_cornerSwitch;
00330
00331
00332 SoFieldSensor *lightingSensor;
00333
00334
00335 SoFieldSensor *lineWidthSensor;
00336
00337 static void lightingSensorCB( void *, SoSensor * );
00338 static void lineWidthSensorCB( void *, SoSensor * );
00339
00340 static void startCB( void *, SoDragger *);
00341 static void motionCB( void *, SoDragger *);
00342 static void finishCB( void *, SoDragger *);
00343 static void metaKeyChangeCB( void *, SoDragger *);
00344
00345 SbLineProjector *lineProj;
00346 SbPlaneProjector *planeProj;
00347
00348 SoFieldSensor *translFieldSensor;
00349 SoFieldSensor *scaleFieldSensor;
00350 static void fieldSensorCB( void *, SoSensor * );
00351 static void valueChangedCB( void *, SoDragger * );
00352
00353 virtual void GLRender( SoGLRenderAction *action );
00354 virtual void rayPick(SoRayPickAction *action);
00355
00356 void dragStart();
00357 void drag();
00358 void dragFinish();
00359
00360 void translateStart();
00361 void translateDrag();
00362
00363 void edgeScaleStart();
00364 void edgeScaleDrag();
00365
00366 void cornerScaleStart();
00367 void cornerScaleDrag();
00368
00369 void scaleUniformStart();
00370 void scaleUniformDrag();
00371
00372 SbVec3f worldRestartPt;
00373 int currentScalePatch;
00374
00375 enum State {
00376 INACTIVE, TRANSLATING, EDGE_SCALING, CORNER_SCALING, UNIFORM_SCALING
00377 };
00378 SbBool shftDown;
00379
00380 State currentState;
00381 State restartState;
00382 int translateDir;
00383
00384 SbVec3f scaleCenter;
00385
00386 SbBool needScaleTabAdjustment;
00387 void reallyAdjustScaleTabSize(SoAction *action);
00388
00389 void getXYScreenLengths( SbVec2f &lengths, const SbMatrix &localToScreen,
00390 const SbVec2s &winSize);
00391
00392
00393
00394
00395
00396
00397
00398 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00399
00400 virtual void setDefaultOnNonWritingFields();
00401
00402 virtual ~SoTabPlaneDragger();
00403
00404 private:
00405 static const char geomBuffer[];
00406 static bool s_resizeOnInactiveOnly;
00407
00408 };
00409
00410 #endif
00411
00412