Logo ROOT   6.19/01
Reference Guide
REveSelection.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT7_REveSelection
13 #define ROOT7_REveSelection
14 
15 #include <ROOT/REveElement.hxx>
16 
17 #include <map>
18 
19 namespace ROOT {
20 namespace Experimental {
21 
22 ////////////////////////////////////////////////////////////////////////////////
23 /// REveSelection
24 /// Container for selected and highlighted elements.
25 ////////////////////////////////////////////////////////////////////////////////
26 
27 class REveSelection : public REveElement,
28  public REveAunt
29 {
30 public:
31  enum EPickToSelect // How to convert picking events to top selected element:
32  { kPS_Ignore, // ignore picking
33  kPS_Element, // select element (default for selection)
34  kPS_Projectable, // select projectable
35  kPS_Compound, // select compound
36  kPS_PableCompound, // select projectable and compound
37  kPS_Master // select master element (top-level compound)
38  };
39 
40  struct Record
41  {
42  REveElement *f_primary{nullptr}; ///<! it's also implied through the map -- XXXX do i need it ????
44  std::set<int> f_sec_idcs;
45  bool f_is_sec{false}; ///<! is secondary-selected -- XXXX do i need it ????
46 
48  f_primary (el),
49  f_is_sec (false)
50  {
51  // Apparently done in DoElementSelect
52  // el->FillImpliedSelectedSet(f_implied);
53  }
54 
55  Record(REveElement *el, const std::set<int>& secondary_idcs) :
56  f_primary (el),
57  f_sec_idcs (secondary_idcs),
58  f_is_sec (true)
59  {
60  // Apparently done in DoElementSelect
61  // el->FillImpliedSelectedSet(f_implied);
62  }
63 
64  bool is_secondary() const { return f_is_sec; }
65  };
66 
67  typedef std::map<REveElement*, Record> SelMap_t;
68  typedef SelMap_t::iterator SelMap_i;
69 
70 private:
71  REveSelection(const REveSelection &); // Not implemented
72  REveSelection &operator=(const REveSelection &); // Not implemented
73 
74 protected:
77 
78  std::vector<int> fPickToSelect; ///<!
81 
82  SelMap_t fMap; ///<!
83 
85  {
86  auto i = fMap.find(el);
87  return i != fMap.end() ? & i->second : nullptr;
88  }
89 
90  void DoElementSelect (SelMap_i &entry);
91  void DoElementUnselect(SelMap_i &entry);
92 
93  void RecheckImpliedSet(SelMap_i &entry);
94 
95 public:
96  REveSelection(const std::string &n = "REveSelection", const std::string &t = "",
97  Color_t col_visible = kViolet, Color_t col_hidden = kPink);
98  virtual ~REveSelection();
99 
102 
103  void SetHighlightMode();
104 
105  const std::vector<int>& RefPickToSelect() const { return fPickToSelect; }
106  void ClearPickToSelect() { fPickToSelect.clear(); }
107  void AddPickToSelect(int ps) { fPickToSelect.push_back(ps); }
108 
109  Bool_t GetIsMaster() const { return fIsMaster; }
111 
112  bool IsEmpty() const { return fMap.empty(); }
113  bool NotEmpty() const { return ! fMap.empty(); }
114 
115  // Abstract methods of REveAunt
116  bool HasNiece(REveElement *el) const override;
117  bool HasNieces() const override;
118  bool AcceptNiece(REveElement *el) override;
119  void AddNieceInternal(REveElement *el) override;
120  void RemoveNieceInternal(REveElement *el) override;
121  void RemoveNieces() override;
122 
124 
126 
127  void SelectionAdded(REveElement *el); // *SIGNAL*
128  void SelectionRemoved(REveElement *el); // *SIGNAL*
129  void SelectionCleared(); // *SIGNAL*
130  void SelectionRepeated(REveElement *el); // *SIGNAL*
131 
132  // ----------------------------------------------------------------
133  // Interface to make selection active/non-active.
134 
135  virtual void ActivateSelection();
136  virtual void DeactivateSelection();
137 
138  // ----------------------------------------------------------------
139  // User input processing.
140 
142 
143  virtual void UserPickedElement(REveElement *el, Bool_t multi = kFALSE);
144  virtual void UserRePickedElement(REveElement *el);
145  virtual void UserUnPickedElement(REveElement *el);
146 
147  void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set<int>& secondary_idcs={});
148  void ClearSelection();
149 
151 
152  // ----------------------------------------------------------------
153 
154  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
155 
156 };
157 
158 } // namespace Experimental
159 } // namespace ROOT
160 
161 #endif
bool f_is_sec
! is secondary-selected – XXXX do i need it ????
virtual void UserUnPickedElement(REveElement *el)
Called when an element is unselected.
virtual void DeactivateSelection()
Deactivate this selection.
REveSelection(const REveSelection &)
void SelectionCleared()
Emit SelectionCleared signal.
auto * m
Definition: textangle.C:8
virtual ~REveSelection()
Destructor.
VSD Structures.
Definition: StringConv.hxx:21
void SetHighlightMode()
Set to &#39;highlight&#39; mode.
std::map< REveElement *, Record > SelMap_t
#define g(i)
Definition: RSha256.hxx:105
REveSelection & operator=(const REveSelection &)
virtual void ActivateSelection()
Activate this selection.
static constexpr double ps
void RemoveImpliedSelected(REveElement *el)
Remove element from all implied-selected sets.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void DoElementUnselect(SelMap_i &entry)
Deselect element indicated by the entry and clear its implied-selected set.
virtual void UserPickedElement(REveElement *el, Bool_t multi=kFALSE)
Called when user picks/clicks on an element.
void ClearSelection()
Clear selection if not empty.
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json. If rnr_offset negative, render data will not be written.
bool HasNieces() const override
Check if any elements are selected.
Definition: Rtypes.h:65
short Color_t
Definition: RtypesCore.h:79
virtual void UserRePickedElement(REveElement *el)
Called when element selection is repeated.
REveElement * MapPickedToSelected(REveElement *el)
Given element el that was picked or clicked by the user, find the parent/ancestor element that should...
int RemoveImpliedSelectedReferencesTo(REveElement *el)
Remove pointers to el from implied selected sets.
bool AcceptNiece(REveElement *el) override
Pre-addition check.
void SelectionRemoved(REveElement *el)
Emit SelectionRemoved signal.
void AddNieceInternal(REveElement *el) override
Add an element into selection, virtual from REveAunt.
const std::vector< int > & RefPickToSelect() const
ROOT::R::TRInterface & r
Definition: Object.C:4
void RecheckImpliedSet(SelMap_i &entry)
Recalculate implied-selected state for given selection entry.
void SelectionRepeated(REveElement *el)
Emit SelectionRepeated signal.
REveElement(const std::string &name="", const std::string &title="")
Default constructor.
Definition: REveElement.cxx:51
void SelectionAdded(REveElement *el)
Emit SelectionAdded signal.
unsigned int ElementId_t
Definition: REveTypes.hxx:25
const Bool_t kFALSE
Definition: RtypesCore.h:88
std::vector< int > fPickToSelect
!
void RemoveNieceInternal(REveElement *el) override
Virtual from REveAunt.
std::set< REveElement * > Set_t
Definition: REveElement.hxx:79
void SetVisibleEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set visible highlight color.
void RemoveNieces() override
Add an element into selection, virtual from REveAunt.
REveElement * f_primary
! it&#39;s also implied through the map – XXXX do i need it ????
Record(REveElement *el, const std::set< int > &secondary_idcs)
Record * find_record(REveElement *el)
void RecheckImpliedSetForElement(REveElement *el)
If given element is selected or implied-selected within this selection then recheck implied-set for g...
Definition: Rtypes.h:65
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
unsigned char UChar_t
Definition: RtypesCore.h:34
REveSelection Container for selected and highlighted elements.
bool HasNiece(REveElement *el) const override
Check if elemenet el is selected (not implied selected).
const Int_t n
Definition: legend1.C:16
void SetHiddenEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set hidden highlight color.
void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set< int > &secondary_idcs={})
void DoElementSelect(SelMap_i &entry)
Select element indicated by the entry and fill its implied-selected set.