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
00051 #ifndef _SO_SELECTION_
00052 #define _SO_SELECTION_
00053
00054 #include <Inventor/SoLists.h>
00055 #include <Inventor/SbColor.h>
00056 #include <Inventor/misc/SoCallbackList.h>
00057 #include <Inventor/nodes/SoSeparator.h>
00058
00059 #include <Inventor/STL/list>
00060
00061 class SoCallbackList;
00062 class SoEvent;
00063 class SoHandleEventAction;
00064 class SoSearchAction;
00065 class SoPickedPoint;
00066 class SoPickedPointList;
00067 class SoTypeList;
00068 class SoSelection;
00069 class SoPath;
00070
00071
00072
00076 typedef void SoSelectionPathCB(void *userData, SoPath *path);
00080 typedef void SoSelectionClassCB(void *userData, SoSelection *sel);
00084 typedef SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick);
00085
00087
00088
00089
00090
00091
00093
00094
00293 class SoSelection : public SoSeparator {
00294
00295 SO_NODE_HEADER(SoSelection);
00296
00297 public:
00301 SoSelection();
00305 SoSelection(int nChildren);
00306
00307
00308
00309
00310
00311
00312 enum Policy {
00318 SINGLE,
00319
00324 TOGGLE,
00325
00330 SHIFT,
00331
00335 DISABLE
00336 };
00337
00338
00344 SoSFEnum policy;
00345
00346
00347
00348
00349
00357 void select(const SoPath *path);
00364 void select(SoNode *node);
00365
00369 void deselect(const SoPath *path);
00374 void deselect(int which);
00381 void deselect(SoNode *node);
00382
00387 void toggle(const SoPath *path);
00393 void toggle(SoNode *node);
00394
00399 SbBool isSelected(const SoPath *path) const;
00406 SbBool isSelected(SoNode *node) const;
00412 SbBool isSelected(const SoNode *node) const;
00413
00417 void deselectAll();
00418
00422 int getNumSelected() const { return selectionList.getLength(); }
00426 const SoPathList *getList() const { return &selectionList; }
00430 SoPath *getPath(int index) const;
00431
00435 SoPath * operator [](int i) const
00436 { return getPath(i); }
00437
00444 void setPickRadius(float radiusInPixels)
00445 { m_pickRadius = radiusInPixels; }
00446
00451 float getPickRadius() const
00452 { return m_pickRadius; }
00453
00454
00455
00456
00457
00458
00459
00467 void addSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00475 void removeSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00476
00484 void addDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00492 void removeDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00493
00504 void addStartCallback(SoSelectionClassCB *f, void *userData = NULL);
00515 void removeStartCallback(SoSelectionClassCB *f, void *userData = NULL);
00516
00526 void addFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
00536 void removeFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
00537
00576 void setPickFilterCallback(
00577 SoSelectionPickCB *f,
00578 void *userData = NULL,
00579 SbBool callOnlyIfSelectable = TRUE);
00580
00589 void setPickMatching(SbBool pickTwice) { pickMatching = pickTwice; }
00593 SbBool isPickMatching() const { return pickMatching; }
00594
00595 private:
00596
00597
00598 virtual void handleEvent(SoHandleEventAction *action);
00599
00600 private:
00601
00602 virtual void notify(SoNotList *list);
00603
00604
00605
00606 void addChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
00607 void removeChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
00608
00609 SbBool getPickMatching() const { return pickMatching; }
00610
00611
00612 static void initClass();
00613 static void exitClass();
00614
00615
00616 void addPaths( const SoPathList &in );
00617
00618 private:
00619
00620
00621 void addPathCore( const SoPath *path );
00622
00623 void removePathCore( SoPath *p );
00624
00625
00626 SoPathList selectionList;
00627
00628
00629 SoCallbackList *selCBList;
00630 SoCallbackList *deselCBList;
00631 SoCallbackList *startCBList;
00632 SoCallbackList *finishCBList;
00633
00634
00635 SoSelectionPickCB *pickCBFunc;
00636 void *pickCBData;
00637 SbBool callPickCBOnlyIfSelectable;
00638
00639
00640 SoCallbackList *changeCBList;
00641
00642
00643 SoPath *mouseDownPickPath;
00644 SbBool pickMatching;
00645 SbBool m_mouse_button_down;
00646
00647
00648
00649
00650
00651 void invokeSelectionPolicy(SoPath *path, SbBool shiftDown);
00652 void performSingleSelection(SoPath *path);
00653 void performToggleSelection(SoPath *path);
00654
00655
00656
00657 SoPath *copyFromThis(const SoPath *path) const;
00658
00659
00660
00661 SoPath *copyFromThis_( const SoPath *path, bool tempPath = false) const;
00662
00663
00664 void addPath(SoPath *path);
00665 void removePath(int which);
00666 void removePaths( const std::list<int> &which );
00667 void truncatePaths( int fromWhich );
00668
00669
00670
00671 int findPath(const SoPath *path) const;
00672
00673
00674 ~SoSelection();
00675
00676
00677 float m_pickRadius;
00678
00679 private:
00680
00681 static SoSearchAction *searchAction;
00682
00683
00684 void constructorCommon();
00685
00686
00687 };
00688
00689
00690
00691 #endif
00692
00693