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 #ifndef _SO_EXTENDED_SELECTION_H_
00027 #define _SO_EXTENDED_SELECTION_H_
00028
00029
00030
00031
00032 #include <Inventor/actions/SoCallbackAction.h>
00033 #include <Inventor/nodes/SoSubNode.h>
00034 #include <Inventor/nodes/SoSelection.h>
00035 #include <Inventor/nodes/SoColorIndex.h>
00036 #include <Inventor/nodes/SoDrawStyle.h>
00037 #include <Inventor/nodes/SoMatrixTransform.h>
00038 #include <Inventor/SbViewportRegion.h>
00039 #include <Inventor/STL/vector>
00040 #include <Inventor/misc/SoRef.h>
00041 #include <Inventor/fields/SoSFNode.h>
00042 #include <Inventor/SbEventArg.h>
00043 #include <Inventor/SbEventHandler.h>
00044
00045
00046
00047 class SoCamera;
00048 class SoSeparator;
00049 class SoCoordinate3;
00050 class SbViewportRegion;
00051 class SoMaterial;
00052 class SoPath;
00053 class LassoRenderer;
00054 class SoOrthographicCamera;
00055 class LassoPointsWrapper;
00056 class MatricesEvaluator;
00057 class SbPlanarConvexPolygon;
00058 class SoExtSelection;
00059
00060 SO_PIMPL_PUBLIC_DECLARATION( SoExtSelection )
00061
00062
00181 class SoExtSelection : public SoSelection {
00182
00183 SO_NODE_HEADER(SoExtSelection);
00184 SO_PIMPL_PUBLIC_HEADER( SoExtSelection );
00185
00186
00187 public:
00188
00190 enum LassoType {
00192 NOLASSO,
00194 LASSO,
00196 RECTANGLE,
00198 ELLIPSE
00199 };
00200
00202 enum LassoPolicy {
00204 FULL_BBOX,
00206 PART_BBOX,
00208 FULL,
00210 PART
00211 };
00212
00214 enum LassoMode {
00220 VISIBLE_SHAPES,
00221
00223 ALL_SHAPES
00224 };
00225
00230 SoSFEnum lassoType;
00231
00236 SoSFEnum lassoPolicy;
00237
00262 SoSFEnum lassoMode;
00263
00268 SoSFBool animateLasso;
00269
00274 SoSFColor lassoColor;
00275
00287 SoSFFloat lassoWidth;
00288
00302 SoSFUShort lassoPattern;
00303
00310 SoSFInt32 lassoPatternScaleFactor;
00311
00313 enum ReturnType {
00318 NOSELECT_CONTINUE,
00323 SELECT_RETURN,
00327 SELECT_CONTINUE,
00331 NOSELECT_RETURN
00332 };
00333
00337 SoExtSelection();
00338
00346 void useFastEditing(SbBool flg = TRUE);
00347
00351 SbBool isUsingFastEditing();
00352
00358 SoSeparator *getOverlaySceneGraph();
00359
00360 #if 1 SoDEPRECATED
00366 void setOverlayLassoColorIndex(int index);
00367 SoDEPRECATED
00373 int getOverlayLassoColorIndex();
00374 SoDEPRECATED
00381 void setLassoColor(SbColor c);
00382 SoDEPRECATED
00388 SbColor getLassoColor();
00389 SoDEPRECATED
00395 void setLassoWidth(float width);
00396 SoDEPRECATED
00401 float getLassoWidth();
00402 SoDEPRECATED
00410 void setOverlayLassoPattern(unsigned short pattern);
00411 SoDEPRECATED
00417 unsigned short getOverlayLassoPattern();
00418 SoDEPRECATED
00424 void animateOverlayLasso(SbBool flg = TRUE);
00425 SoDEPRECATED
00430 SbBool isOverlayLassoAnimated();
00431
00432 #endif
00455 void select(SoNode *root, int numCoord, SbVec2f *lassoCoord,
00456 const SbViewportRegion &viewport, SbBool shiftPressed);
00457
00462 typedef SbBool SoExtSelectionTriangleCB(void *userData,
00463 SoCallbackAction *action,
00464 const SoPrimitiveVertex *v1,
00465 const SoPrimitiveVertex *v2,
00466 const SoPrimitiveVertex *v3);
00471 typedef SbBool SoExtSelectionLineSegmentCB(void *userData,
00472 SoCallbackAction *action,
00473 const SoPrimitiveVertex *v1,
00474 const SoPrimitiveVertex *v2);
00479 typedef SbBool SoExtSelectionPointCB(void *userData,
00480 SoCallbackAction *action,
00481 const SoPrimitiveVertex *v1);
00482
00499 typedef SbBool SelectionEventCallback( const SbVec2s& position, const SbVec3f& scenePosition,
00500 SoExtSelection* selection, void* userData );
00501
00508 virtual void addChild( SoNode *child );
00509
00515 struct PreFilterEventArg : public SbEventArg {
00516 public:
00517
00519 PreFilterEventArg(SoPath* path, SoExtSelection* source)
00520 :m_path(path), m_source(source), m_isSkipped(false)
00521 {}
00522
00524 ~PreFilterEventArg() { }
00525
00527 SoExtSelection* getSource() const { return m_source; }
00528
00531 const SoNode* getNode() const { return m_path->getTail(); }
00532
00534 const SoPath* getPath() const { return m_path; }
00535
00537 void skipNode() { m_isSkipped = true; }
00538
00540 SbBool isNodeSkipped() const { return m_isSkipped; }
00541
00542 private:
00543
00544 SoPath* m_path;
00545 SoExtSelection* m_source;
00546 SbBool m_isSkipped;
00547 };
00548
00556 SbEventHandler<PreFilterEventArg&> onPreFilter;
00557
00575 virtual void setSelectionSceneGraph( SoNode* sceneGraph );
00576
00582 virtual SoNode* getSelectionSceneGraph() const;
00583
00589 virtual void setStartSelectionCallback( SelectionEventCallback* callback, void* userData = NULL );
00590
00596 virtual void setEndSelectionCallback( SelectionEventCallback* callback, void* userData = NULL );
00597
00604 virtual void setMovingSelectionCallback( SelectionEventCallback* callback, void* userData = NULL );
00605
00631 void setTriangleFilterCallback(SoExtSelectionTriangleCB *cb,
00632 void *userData = NULL);
00633
00638 void setLineSegmentFilterCallback(SoExtSelectionLineSegmentCB *cb,
00639 void *userData = NULL);
00644 void setPointFilterCallback(SoExtSelectionPointCB *cb,
00645 void *userData = NULL);
00646
00652 const SbVec2s *getLassoCoordsDC(int &numCoords);
00653
00659 const SbVec3f *getLassoCoordsWC(int &numCoords);
00660
00664 const SoPathList &getSelectionPathList() const;
00665
00666
00667
00668
00669 private:
00670
00671
00672 virtual void handleEvent(SoHandleEventAction *action);
00673 virtual void search(SoSearchAction *action);
00674 virtual void GLRender(SoGLRenderAction *action);
00675 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00676
00677 private:
00678 static void initClass();
00679 static void exitClass();
00680
00681 virtual void notify( SoNotList* list );
00682
00683 void setSelection( SbBool on );
00684 SbBool getSelection() const;
00685
00686
00687 private:
00688
00689
00690
00691
00692 virtual ~SoExtSelection();
00693
00694 private:
00695 void commonConstructor();
00696 };
00697
00698 #endif // _SO_EXTENDED_SELECTION_H_
00699
00700