| 42 | 
  | 
#ifndef SELECTION_SELECTIONMANAGER_HPP | 
| 43 | 
  | 
#define SELECTION_SELECTIONMANAGER_HPP | 
| 44 | 
  | 
 | 
| 45 | 
+ | 
#include "utils/BitSet.hpp" | 
| 46 | 
+ | 
#include "primitives/StuntDouble.hpp" | 
| 47 | 
  | 
namespace oopse { | 
| 48 | 
  | 
 | 
| 49 | 
  | 
/** | 
| 51 | 
  | 
 * @brief | 
| 52 | 
  | 
 */ | 
| 53 | 
  | 
class SelectionManager { | 
| 54 | 
+ | 
    public: | 
| 55 | 
+ | 
        SelectionManager(int size) {bsSelection_.resize(size);} | 
| 56 | 
  | 
 | 
| 57 | 
+ | 
        void addSelection(StuntDouble* sd) { | 
| 58 | 
+ | 
            bsSelection_.setBitOn(sd->getGlobalIndex()); | 
| 59 | 
+ | 
        } | 
| 60 | 
+ | 
         | 
| 61 | 
+ | 
        void addSelectionSet(const BitSet& bs) { | 
| 62 | 
+ | 
            bsSelection_ |= bs; | 
| 63 | 
+ | 
        } | 
| 64 | 
+ | 
 | 
| 65 | 
+ | 
        void setSelection(StuntDouble* sd) { | 
| 66 | 
+ | 
            bsSelection_.clearAll(); | 
| 67 | 
+ | 
            bsSelection_.setBitOn(sd->getGlobalIndex()); | 
| 68 | 
+ | 
        } | 
| 69 | 
+ | 
         | 
| 70 | 
+ | 
        void setSelectionSet(const BitSet& bs) { | 
| 71 | 
+ | 
            bsSelection_ = bs;            | 
| 72 | 
+ | 
        } | 
| 73 | 
+ | 
 | 
| 74 | 
+ | 
        void toggleSelection(StuntDouble* sd) { | 
| 75 | 
+ | 
            bsSelection_.flip(sd->getGlobalIndex()); | 
| 76 | 
+ | 
        } | 
| 77 | 
+ | 
 | 
| 78 | 
+ | 
        void toggleSelection() { | 
| 79 | 
+ | 
            bsSelection_.flip(); | 
| 80 | 
+ | 
        } | 
| 81 | 
+ | 
         | 
| 82 | 
+ | 
        void selectAll() { | 
| 83 | 
+ | 
            bsSelection_.setAll();                 | 
| 84 | 
+ | 
        } | 
| 85 | 
+ | 
 | 
| 86 | 
+ | 
        void clearSelection() { | 
| 87 | 
+ | 
           bsSelection_.clearAll(); | 
| 88 | 
+ | 
        } | 
| 89 | 
+ | 
 | 
| 90 | 
+ | 
        void clearSelection(StuntDouble* sd) { | 
| 91 | 
+ | 
            bsSelection_.setBitOff(sd->getGlobalIndex()); | 
| 92 | 
+ | 
        } | 
| 93 | 
+ | 
 | 
| 94 | 
+ | 
        bool isSelected(StuntDouble* sd) { | 
| 95 | 
+ | 
            return bsSelection_[sd->getGlobalIndex()]; | 
| 96 | 
+ | 
        } | 
| 97 | 
+ | 
 | 
| 98 | 
+ | 
        bool isEmpty() { | 
| 99 | 
+ | 
            return bsSelection_.none(); | 
| 100 | 
+ | 
        } | 
| 101 | 
+ | 
 | 
| 102 | 
+ | 
        int getSelectionCount() { | 
| 103 | 
+ | 
            return bsSelection_.countBits(); | 
| 104 | 
+ | 
        } | 
| 105 | 
+ | 
 | 
| 106 | 
+ | 
        BitSet getSelectionSet() { | 
| 107 | 
+ | 
            return bsSelection_; | 
| 108 | 
+ | 
        } | 
| 109 | 
+ | 
         | 
| 110 | 
+ | 
    private: | 
| 111 | 
+ | 
         | 
| 112 | 
+ | 
        BitSet bsSelection_; | 
| 113 | 
  | 
}; | 
| 114 | 
  | 
 | 
| 115 | 
  | 
} |