--- trunk/src/selection/SelectionManager.hpp 2005/02/01 22:49:23 278 +++ trunk/src/selection/SelectionManager.hpp 2005/02/16 19:36:30 353 @@ -43,24 +43,107 @@ #define SELECTION_SELECTIONMANAGER_HPP #include "utils/BitSet.hpp" - +#include "primitives/StuntDouble.hpp" namespace oopse { +class SimInfo; /** * @class SelectionManager SelectionManager.hpp "selection/SelectionManager.hpp" * @brief */ class SelectionManager { public: - SelectionManager(); + SelectionManager(SimInfo* info); + void addSelection(StuntDouble* sd) { + bsSelection_.setBitOn(sd->getGlobalIndex()); + } + + void addSelectionSet(const BitSet& bs) { + bsSelection_ |= bs; + } - bool isSelected(StuntDouble* sd); + void setSelection(StuntDouble* sd) { + bsSelection_.clearAll(); + bsSelection_.setBitOn(sd->getGlobalIndex()); + } - private: + void setSelectionSet(const BitSet& bs) { + bsSelection_ = bs; + } + + void toggleSelection(StuntDouble* sd) { + bsSelection_.flip(sd->getGlobalIndex()); + } + + void toggleSelection() { + bsSelection_.flip(); + } - BitSet bsSelection; - BitSet bsNull; + void selectAll() { + bsSelection_.setAll(); + } + + void clearSelection() { + bsSelection_.clearAll(); + } + + void clearSelection(StuntDouble* sd) { + bsSelection_.setBitOff(sd->getGlobalIndex()); + } + + bool isSelected(StuntDouble* sd) { + return bsSelection_[sd->getGlobalIndex()]; + } + + bool isEmpty() { + return bsSelection_.none(); + } + + int getSelectionCount() { + return bsSelection_.countBits(); + } + + BitSet getSelectionSet() { + return bsSelection_; + } + + + StuntDouble* beginSelected(int& i); + StuntDouble* nextSelected(int& i); + + StuntDouble* beginUnselected(int& i); + StuntDouble* nextUnSelected(int& i); + + SelectionManager& operator&= (const SelectionManager &sman) { + bsSelection_ &= sman.bsSelection_; + return *this; + } + + SelectionManager& operator|= (const SelectionManager &sman) { + bsSelection_ |= sman.bsSelection_; + return *this; + } + + SelectionManager& operator^= (const SelectionManager &sman) { + bsSelection_ ^= sman.bsSelection_; + return *this; + } + + SelectionManager& operator-= (const SelectionManager &sman) { + bsSelection_ -= sman.bsSelection_; + return *this; + } + + friend SelectionManager operator| (const SelectionManager& sman1, const SelectionManager& sman2); + friend SelectionManager operator& (const SelectionManager& sman1, const SelectionManager& sman2); + friend SelectionManager operator^ (const SelectionManager& sman1, const SelectionManager& sman2); + friend SelectionManager operator-(const SelectionManager& sman1, const SelectionManager& sman2); + + private: + SimInfo* info_; + BitSet bsSelection_; + std::vector stuntdoubles_; }; }