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
00187 class SoExtSelection : public SoSelection {
00188
00189 SO_NODE_HEADER(SoExtSelection);
00190 SO_PIMPL_PUBLIC_HEADER( SoExtSelection );
00191
00192
00193 public:
00194
00196 enum LassoType {
00198 NOLASSO,
00200 LASSO,
00202 RECTANGLE,
00204 ELLIPSE
00205 };
00206
00208 enum LassoPolicy {
00210 FULL_BBOX,
00212 PART_BBOX,
00214 FULL,
00216 PART
00217 };
00218
00220 enum LassoMode {
00226 VISIBLE_SHAPES,
00227
00229 ALL_SHAPES
00230 };
00231
00236 SoSFEnum lassoType;
00237
00242 SoSFEnum lassoPolicy;
00243
00268 SoSFEnum lassoMode;
00269
00274 SoSFBool animateLasso;
00275
00280 SoSFColor lassoColor;
00281
00293 SoSFFloat lassoWidth;
00294
00308 SoSFUShort lassoPattern;
00309
00316 SoSFInt32 lassoPatternScaleFactor;
00317
00319 enum ReturnType {
00324 NOSELECT_CONTINUE,
00329 SELECT_RETURN,
00333 SELECT_CONTINUE,
00337 NOSELECT_RETURN
00338 };
00339
00343 SoExtSelection();
00344
00352 void useFastEditing(SbBool flg = TRUE);
00353
00357 SbBool isUsingFastEditing();
00358
00364 SoSeparator *getOverlaySceneGraph();
00365
00366 #if 1 SoDEPRECATED
00372 void setOverlayLassoColorIndex(int index);
00373 SoDEPRECATED
00379 int getOverlayLassoColorIndex();
00380 SoDEPRECATED
00387 void setLassoColor(SbColor c);
00388 SoDEPRECATED
00394 SbColor getLassoColor();
00395 SoDEPRECATED
00401 void setLassoWidth(float width);
00402 SoDEPRECATED
00407 float getLassoWidth();
00408 SoDEPRECATED
00416 void setOverlayLassoPattern(unsigned short pattern);
00417 SoDEPRECATED
00423 unsigned short getOverlayLassoPattern();
00424 SoDEPRECATED
00430 void animateOverlayLasso(SbBool flg = TRUE);
00431 SoDEPRECATED
00436 SbBool isOverlayLassoAnimated();
00437
00438 #endif
00461 void select(SoNode *root, int numCoord, SbVec2f *lassoCoord,
00462 const SbViewportRegion &viewport, SbBool shiftPressed);
00463
00468 typedef SbBool SoExtSelectionTriangleCB(void *userData,
00469 SoCallbackAction *action,
00470 const SoPrimitiveVertex *v1,
00471 const SoPrimitiveVertex *v2,
00472 const SoPrimitiveVertex *v3);
00477 typedef SbBool SoExtSelectionLineSegmentCB(void *userData,
00478 SoCallbackAction *action,
00479 const SoPrimitiveVertex *v1,
00480 const SoPrimitiveVertex *v2);
00485 typedef SbBool SoExtSelectionPointCB(void *userData,
00486 SoCallbackAction *action,
00487 const SoPrimitiveVertex *v1);
00488
00505 typedef SbBool SelectionEventCallback( const SbVec2s& position, const SbVec3f& scenePosition,
00506 SoExtSelection* selection, void* userData );
00507
00514 virtual void addChild( SoNode *child );
00515
00521 struct PreFilterEventArg : public SbEventArg {
00522 public:
00523
00525 PreFilterEventArg(SoPath* path, SoExtSelection* source)
00526 :m_path(path), m_source(source), m_isSkipped(false)
00527 {}
00528
00530 ~PreFilterEventArg() { }
00531
00533 SoExtSelection* getSource() const { return m_source; }
00534
00537 const SoNode* getNode() const { return m_path->getTail(); }
00538
00540 const SoPath* getPath() const { return m_path; }
00541
00543 void skipNode() { m_isSkipped = true; }
00544
00546 SbBool isNodeSkipped() const { return m_isSkipped; }
00547
00548 private:
00549
00550 SoPath* m_path;
00551 SoExtSelection* m_source;
00552 SbBool m_isSkipped;
00553 };
00554
00562 SbEventHandler<PreFilterEventArg&> onPreFilter;
00563
00581 virtual void setSelectionSceneGraph( SoNode* sceneGraph );
00582
00588 virtual SoNode* getSelectionSceneGraph() const;
00589
00595 virtual void setStartSelectionCallback( SelectionEventCallback* callback, void* userData = NULL );
00596
00602 virtual void setEndSelectionCallback( SelectionEventCallback* callback, void* userData = NULL );
00603
00610 virtual void setMovingSelectionCallback( SelectionEventCallback* callback, void* userData = NULL );
00611
00637 void setTriangleFilterCallback(SoExtSelectionTriangleCB *cb,
00638 void *userData = NULL);
00639
00644 void setLineSegmentFilterCallback(SoExtSelectionLineSegmentCB *cb,
00645 void *userData = NULL);
00650 void setPointFilterCallback(SoExtSelectionPointCB *cb,
00651 void *userData = NULL);
00652
00658 const SbVec2s *getLassoCoordsDC(int &numCoords);
00659
00665 const SbVec3f *getLassoCoordsWC(int &numCoords);
00666
00670 const SoPathList &getSelectionPathList() const;
00671
00672
00673
00674
00675 private:
00676
00677
00678 virtual void handleEvent(SoHandleEventAction *action);
00679 virtual void search(SoSearchAction *action);
00680 virtual void GLRender(SoGLRenderAction *action);
00681 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00682
00683 private:
00684 static void initClass();
00685 static void exitClass();
00686
00687 virtual void notify( SoNotList* list );
00688
00689 void setSelection( SbBool on );
00690 SbBool getSelection() const;
00691
00692
00693 private:
00694
00695
00696
00697
00698 virtual ~SoExtSelection();
00699
00700 private:
00701 void commonConstructor();
00702 };
00703
00704 #endif // _SO_EXTENDED_SELECTION_H_
00705
00706