--- trunk/src/selection/SelectionManager.hpp 2005/02/01 06:55:00 277 +++ trunk/src/selection/SelectionManager.hpp 2005/12/02 15:38:03 770 @@ -42,15 +42,109 @@ #ifndef SELECTION_SELECTIONMANAGER_HPP #define SELECTION_SELECTIONMANAGER_HPP +#include "utils/OOPSEBitSet.hpp" +#include "primitives/StuntDouble.hpp" namespace oopse { -/** - * @class SelectionManager SelectionManager.hpp "selection/SelectionManager.hpp" - * @brief - */ -class SelectionManager { + class SimInfo; + /** + * @class SelectionManager SelectionManager.hpp "selection/SelectionManager.hpp" + * @brief + */ + class SelectionManager { + public: + SelectionManager(SimInfo* info); -}; + void addSelection(StuntDouble* sd) { + bsSelection_.setBitOn(sd->getGlobalIndex()); + } + + void addSelectionSet(const OOPSEBitSet& bs) { + bsSelection_ |= bs; + } + void setSelection(StuntDouble* sd) { + bsSelection_.clearAll(); + bsSelection_.setBitOn(sd->getGlobalIndex()); + } + + void setSelectionSet(const OOPSEBitSet& bs) { + bsSelection_ = bs; + } + + void toggleSelection(StuntDouble* sd) { + bsSelection_.flip(sd->getGlobalIndex()); + } + + void toggleSelection() { + bsSelection_.flip(); + } + + 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(); + } + + OOPSEBitSet 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_; + OOPSEBitSet bsSelection_; + std::vector stuntdoubles_; + }; + } #endif