File indexing completed on 2025-01-18 10:10:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT7_REveSelection
0013 #define ROOT7_REveSelection
0014
0015 #include <ROOT/REveElement.hxx>
0016
0017 #include <map>
0018
0019 namespace ROOT {
0020 namespace Experimental {
0021
0022
0023
0024
0025
0026
0027 class REveSelection : public REveElement,
0028 public REveAunt
0029 {
0030 friend class Deviator;
0031
0032 public:
0033 enum EPickToSelect
0034 { kPS_Ignore,
0035 kPS_Element,
0036 kPS_Projectable,
0037 kPS_Compound,
0038 kPS_PableCompound,
0039 kPS_Master
0040 };
0041
0042 struct Record
0043 {
0044 REveElement *f_primary{nullptr};
0045 Set_t f_implied;
0046 std::set<int> f_sec_idcs;
0047 bool f_is_sec{false};
0048
0049 Record(REveElement *el) :
0050 f_primary (el),
0051 f_is_sec (false)
0052 {
0053
0054
0055 }
0056
0057 Record(REveElement *el, const std::set<int>& secondary_idcs) :
0058 f_primary (el),
0059 f_sec_idcs (secondary_idcs),
0060 f_is_sec (true)
0061 {
0062
0063
0064 }
0065
0066 bool is_secondary() const { return f_is_sec; }
0067 };
0068
0069 class Deviator {
0070 public:
0071 virtual ~Deviator(){};
0072 Deviator() {}
0073 virtual bool DeviateSelection(REveSelection* s, REveElement* el, bool multi, bool secondary, const std::set<int>& secondary_idcs) = 0;
0074 protected:
0075 void ExecuteNewElementPicked(REveSelection* s, REveElement* el, bool multi, bool secondary, const std::set<int>& secondary_idcs)
0076 {
0077 s->NewElementPickedInternal(el, multi, secondary, secondary_idcs);
0078 }
0079 };
0080
0081 typedef std::map<REveElement*, Record> SelMap_t;
0082 typedef SelMap_t::iterator SelMap_i;
0083
0084 private:
0085 REveSelection(const REveSelection &) = delete;
0086 REveSelection &operator=(const REveSelection &) = delete;
0087
0088 protected:
0089 Color_t fVisibleEdgeColor;
0090 Color_t fHiddenEdgeColor;
0091
0092 std::vector<int> fPickToSelect;
0093 bool fActive{true};
0094 bool fIsMaster{false};
0095 bool fIsHighlight{false};
0096
0097 SelMap_t fMap;
0098
0099 std::shared_ptr<Deviator> fDeviator;
0100
0101 Record* find_record(REveElement *el)
0102 {
0103 auto i = fMap.find(el);
0104 return i != fMap.end() ? & i->second : nullptr;
0105 }
0106
0107 void DoElementSelect (SelMap_i &entry);
0108 void DoElementUnselect(SelMap_i &entry);
0109
0110 void RecheckImpliedSet(SelMap_i &entry);
0111
0112 void AddNieceForSelection(REveElement*, bool secondary, const std::set<int>&);
0113
0114 void NewElementPickedInternal(REveElement* el, bool multi, bool secondary, const std::set<int>& secondary_idcs);
0115
0116 public:
0117 REveSelection(const std::string &n = "REveSelection", const std::string &t = "",
0118 Color_t col_visible = kViolet, Color_t col_hidden = kPink);
0119 ~REveSelection() override;
0120
0121 void SetVisibleEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b);
0122 void SetHiddenEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b);
0123
0124 const std::vector<int>& RefPickToSelect() const { return fPickToSelect; }
0125 void ClearPickToSelect() { fPickToSelect.clear(); }
0126 void AddPickToSelect(int ps) { fPickToSelect.push_back(ps); }
0127
0128 bool GetIsMaster() const { return fIsMaster; }
0129 void SetIsMaster(bool m) { fIsMaster = m; }
0130 bool GetIsHighlight() const { return fIsHighlight; }
0131 void SetIsHighlight(bool m) { fIsHighlight = m; }
0132
0133 std::shared_ptr<Deviator> GetDeviator() const { return fDeviator; }
0134 void SetDeviator(std::shared_ptr<Deviator> d) { fDeviator = d; }
0135
0136 bool IsEmpty() const { return fMap.empty(); }
0137 bool NotEmpty() const { return ! fMap.empty(); }
0138
0139
0140 bool HasNiece(REveElement *el) const override;
0141 bool HasNieces() const override;
0142 bool AcceptNiece(REveElement *el) override;
0143 void AddNieceInternal(REveElement *el) override;
0144 void RemoveNieceInternal(REveElement *el) override;
0145 void RemoveNieces() override;
0146
0147 void RemoveImpliedSelected(REveElement *el);
0148
0149 void RecheckImpliedSetForElement(REveElement *el);
0150
0151 void SelectionAdded(REveElement *el);
0152 void SelectionRemoved(REveElement *el);
0153 void SelectionCleared();
0154 void SelectionRepeated(REveElement *el);
0155
0156
0157
0158
0159 virtual void ActivateSelection();
0160 virtual void DeactivateSelection();
0161
0162
0163
0164
0165 REveElement *MapPickedToSelected(REveElement *el);
0166
0167 virtual void UserPickedElement(REveElement *el, Bool_t multi = kFALSE);
0168 virtual void UserRePickedElement(REveElement *el);
0169 virtual void UserUnPickedElement(REveElement *el);
0170
0171 void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set<int>& secondary_idcs={});
0172 void NewElementPickedStr(ElementId_t id, bool multi, bool secondary, const char* secondary_idcs="");
0173 void ClearSelection();
0174
0175 int RemoveImpliedSelectedReferencesTo(REveElement *el);
0176
0177
0178
0179 Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
0180
0181 };
0182
0183 }
0184 }
0185
0186 #endif