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 class SoShaderProgram;
00067
00219 class SoTabPlaneDragger : public SoDragger
00220 {
00221
00222 SO_KIT_HEADER(SoTabPlaneDragger);
00223
00224 SO_KIT_CATALOG_ENTRY_HEADER(planeSwitch);
00225 SO_KIT_CATALOG_ENTRY_HEADER(translator);
00226 SO_KIT_CATALOG_ENTRY_HEADER(scaleTabs);
00227 SO_KIT_CATALOG_ENTRY_HEADER(tabsShader);
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(scaleTabPixelSize);
00234 SO_KIT_CATALOG_ENTRY_HEADER(edgeType0);
00235 SO_KIT_CATALOG_ENTRY_HEADER(edgeType1);
00236 SO_KIT_CATALOG_ENTRY_HEADER(edgeType2);
00237 SO_KIT_CATALOG_ENTRY_HEADER(edgeType3);
00238 SO_KIT_CATALOG_ENTRY_HEADER(showEdges);
00239 SO_KIT_CATALOG_ENTRY_HEADER(edgeTypeCorner0);
00240 SO_KIT_CATALOG_ENTRY_HEADER(edgeTypeCorner1);
00241 SO_KIT_CATALOG_ENTRY_HEADER(edgeTypeCorner2);
00242 SO_KIT_CATALOG_ENTRY_HEADER(edgeTypeCorner3);
00243 SO_KIT_CATALOG_ENTRY_HEADER(scaleCoords);
00244 SO_KIT_CATALOG_ENTRY_HEADER(edgeScale0);
00245 SO_KIT_CATALOG_ENTRY_HEADER(edgeScale1);
00246 SO_KIT_CATALOG_ENTRY_HEADER(edgeScale2);
00247 SO_KIT_CATALOG_ENTRY_HEADER(edgeScale3);
00248 SO_KIT_CATALOG_ENTRY_HEADER(edgeSeparator0);
00249 SO_KIT_CATALOG_ENTRY_HEADER(edgeSeparator1);
00250 SO_KIT_CATALOG_ENTRY_HEADER(edgeSeparator2);
00251 SO_KIT_CATALOG_ENTRY_HEADER(edgeSeparator3);
00252 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTranslation0);
00253 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTranslation1);
00254 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTranslation2);
00255 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTranslation3);
00256 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab0);
00257 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab1);
00258 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab2);
00259 SO_KIT_CATALOG_ENTRY_HEADER(edgeScaleTab3);
00260 SO_KIT_CATALOG_ENTRY_HEADER(cornerScale0);
00261 SO_KIT_CATALOG_ENTRY_HEADER(cornerScale1);
00262 SO_KIT_CATALOG_ENTRY_HEADER(cornerScale2);
00263 SO_KIT_CATALOG_ENTRY_HEADER(cornerScale3);
00264 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch0);
00265 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch1);
00266 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch2);
00267 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch3);
00268 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch4);
00269 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch5);
00270 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch6);
00271 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightSwitch7);
00272 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightMaterial0);
00273 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightMaterial1);
00274 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightMaterial2);
00275 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightMaterial3);
00276 SO_KIT_CATALOG_ENTRY_HEADER(tabHighLightMaterial4);
00277 SO_KIT_CATALOG_ENTRY_HEADER(tabHighLightMaterial5);
00278 SO_KIT_CATALOG_ENTRY_HEADER(tabHighLightMaterial6);
00279 SO_KIT_CATALOG_ENTRY_HEADER(tabHighLightMaterial7);
00280 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale0);
00281 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale1);
00282 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale2);
00283 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale3);
00284 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale4);
00285 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale5);
00286 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale6);
00287 SO_KIT_CATALOG_ENTRY_HEADER(tabHighlightScale7);
00288 SO_KIT_CATALOG_ENTRY_HEADER(cornerSeparator0);
00289 SO_KIT_CATALOG_ENTRY_HEADER(cornerSeparator1);
00290 SO_KIT_CATALOG_ENTRY_HEADER(cornerSeparator2);
00291 SO_KIT_CATALOG_ENTRY_HEADER(cornerSeparator3);
00292 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTranslation0);
00293 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTranslation1);
00294 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTranslation2);
00295 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTranslation3);
00296 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab0);
00297 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab1);
00298 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab2);
00299 SO_KIT_CATALOG_ENTRY_HEADER(cornerScaleTab3);
00300 SO_KIT_CATALOG_ENTRY_HEADER(translatorMaterial);
00301 SO_KIT_CATALOG_ENTRY_HEADER(translatorDrawStyle);
00302 SO_KIT_CATALOG_ENTRY_HEADER(translatorCoordinates);
00303
00304 public:
00308 SoTabPlaneDragger();
00309
00313 SoSFVec3f translation;
00314
00318 SoSFVec3f scaleFactor;
00319
00326 SoSFBool resizeHandles;
00327
00333 SoSFBool scaleUniform;
00334
00340 SoSFBool twoSidedLighting;
00341
00347 SoSFFloat lineWidth;
00348
00354 SoSFInt32 tabPixelSize;
00355
00364 void adjustScaleTabSize();
00365
00367 void showEdgeScales( const SbBool show );
00368
00370 void showCornerScales( const SbBool show );
00371
00372 private:
00374 static void initClass();
00376 static void exitClass();
00377
00378 int getCurrentState();
00379
00380 void notify( SoNotList* list );
00381
00382 private:
00383
00385 SoSwitch* m_edgeSwitch;
00386
00388 SoSwitch* m_cornerSwitch;
00389
00390
00391 SoFieldSensor *lightingSensor;
00392
00393
00394 SoFieldSensor *lineWidthSensor;
00395
00396 static void lightingSensorCB( void *, SoSensor * );
00397 static void lineWidthSensorCB( void *, SoSensor * );
00398
00399 static void startCB( void *, SoDragger *);
00400 static void motionCB( void *, SoDragger *);
00401 static void finishCB( void *, SoDragger *);
00402 static void metaKeyChangeCB( void *, SoDragger *);
00403
00404 SbLineProjector *lineProj;
00405 SbPlaneProjector *planeProj;
00406
00407 SoFieldSensor *translFieldSensor;
00408 SoFieldSensor *scaleFieldSensor;
00409 static void fieldSensorCB( void *, SoSensor * );
00410 static void valueChangedCB( void *, SoDragger * );
00411
00412 virtual void GLRender( SoGLRenderAction *action );
00413 virtual void rayPick(SoRayPickAction *action);
00414
00415 void dragStart();
00416 void drag();
00417 void dragFinish();
00418
00419 void translateStart();
00420 void translateDrag();
00421
00422 void edgeScaleStart();
00423 void edgeScaleDrag();
00424
00425 void cornerScaleStart();
00426 void cornerScaleDrag();
00427
00428 void scaleUniformStart();
00429 void scaleUniformDrag();
00430
00431 SbVec3f worldRestartPt;
00432 int currentScalePatch;
00433
00434 enum State {
00435 INACTIVE, TRANSLATING, EDGE_SCALING, CORNER_SCALING, UNIFORM_SCALING
00436 };
00437 SbBool shftDown;
00438
00439 State currentState;
00440 State restartState;
00441 int translateDir;
00442
00443 SbVec3f scaleCenter;
00444
00445
00446
00447
00448
00449
00450
00451 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00452
00453 virtual void setDefaultOnNonWritingFields();
00454
00455 virtual ~SoTabPlaneDragger();
00456
00457 private:
00458 static const char geomBuffer[];
00459 static bool s_resizeOnInactiveOnly;
00460 static SoShaderProgram* s_tabsShader;
00461 static const float s_tabHighlightScaleCoef;
00462 };
00463
00464 #endif
00465
00466