Logo ROOT  
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 &) = delete;
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
m
auto * m
Definition: textangle.C:8
n
const Int_t n
Definition: legend1.C:16
ROOT::Experimental::REveSelection::Record::f_sec_idcs
std::set< int > f_sec_idcs
Definition: REveSelection.hxx:44
ROOT::Experimental::REveSelection::ClearPickToSelect
void ClearPickToSelect()
Definition: REveSelection.hxx:106
ROOT::Experimental::REveSelection::RemoveImpliedSelected
void RemoveImpliedSelected(REveElement *el)
Remove element from all implied-selected sets.
Definition: REveSelection.cxx:229
ROOT::Experimental::REveSelection::NewElementPicked
void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set< int > &secondary_idcs={})
Definition: REveSelection.cxx:475
ROOT::Experimental::REveSelection::Record::is_secondary
bool is_secondary() const
Definition: REveSelection.hxx:64
ROOT::Experimental::REveSelection::SelectionRemoved
void SelectionRemoved(REveElement *el)
Emit SelectionRemoved signal.
Definition: REveSelection.cxx:306
ROOT::Experimental::REveSelection::SelectionCleared
void SelectionCleared()
Emit SelectionCleared signal.
Definition: REveSelection.cxx:315
nlohmann::json
basic_json<> json
Definition: REveElement.hxx:58
ROOT::Experimental::REveSelection::Record::f_primary
REveElement * f_primary
! it's also implied through the map – XXXX do i need it ????
Definition: REveSelection.hxx:42
ROOT::Experimental::REveSelection::fActive
Bool_t fActive
!
Definition: REveSelection.hxx:79
ROOT::Experimental::REveSelection::IsEmpty
bool IsEmpty() const
Definition: REveSelection.hxx:112
ROOT::Experimental::ElementId_t
unsigned int ElementId_t
Definition: REveTypes.hxx:25
ROOT::Experimental::REveSelection::ClearSelection
void ClearSelection()
Clear selection if not empty.
Definition: REveSelection.cxx:596
ROOT::Experimental::REveSelection::fIsMaster
Bool_t fIsMaster
!
Definition: REveSelection.hxx:80
r
ROOT::R::TRInterface & r
Definition: Object.C:4
kViolet
@ kViolet
Definition: Rtypes.h:67
ROOT::Experimental::REveSelection::UserPickedElement
virtual void UserPickedElement(REveElement *el, Bool_t multi=kFALSE)
Called when user picks/clicks on an element.
Definition: REveSelection.cxx:426
ROOT::Experimental::REveSelection::fVisibleEdgeColor
Color_t fVisibleEdgeColor
!
Definition: REveSelection.hxx:75
ROOT::Experimental::REveSelection::kPS_PableCompound
@ kPS_PableCompound
Definition: REveSelection.hxx:36
ROOT::Experimental::REveSelection::SetVisibleEdgeColorRGB
void SetVisibleEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set visible highlight color.
Definition: REveSelection.cxx:71
kPink
@ kPink
Definition: Rtypes.h:67
ROOT::Experimental::REveSelection::SelectionAdded
void SelectionAdded(REveElement *el)
Emit SelectionAdded signal.
Definition: REveSelection.cxx:297
Int_t
int Int_t
Definition: RtypesCore.h:45
TGeant4Unit::ps
static constexpr double ps
Definition: TGeant4SystemOfUnits.h:165
ROOT::Experimental::REveSelection::kPS_Compound
@ kPS_Compound
Definition: REveSelection.hxx:35
ROOT::Experimental::REveSelection::~REveSelection
virtual ~REveSelection()
Destructor.
Definition: REveSelection.cxx:62
ROOT::Experimental::REveSelection::REveSelection
REveSelection(const REveSelection &)=delete
ROOT::Experimental::REveSelection::SetHiddenEdgeColorRGB
void SetHiddenEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set hidden highlight color.
Definition: REveSelection.cxx:79
ROOT::Experimental::REveSelection::Record::f_is_sec
bool f_is_sec
! is secondary-selected – XXXX do i need it ????
Definition: REveSelection.hxx:45
ROOT::Experimental::REveSelection::Record::Record
Record(REveElement *el, const std::set< int > &secondary_idcs)
Definition: REveSelection.hxx:55
ROOT::Experimental::REveElement
Definition: REveElement.hxx:80
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
Color_t
short Color_t
Definition: RtypesCore.h:83
ROOT::Experimental::REveSelection::kPS_Ignore
@ kPS_Ignore
Definition: REveSelection.hxx:32
ROOT::Experimental::REveSelection::RecheckImpliedSet
void RecheckImpliedSet(SelMap_i &entry)
Recalculate implied-selected state for given selection entry.
Definition: REveSelection.cxx:251
ROOT::Experimental::REveSelection::Record::f_implied
Set_t f_implied
Definition: REveSelection.hxx:43
b
#define b(i)
Definition: RSha256.hxx:100
ROOT::Experimental::REveSelection::WriteCoreJson
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json. If rnr_offset negative, render data will not be written.
Definition: REveSelection.cxx:632
bool
ROOT::Experimental::REveSelection::SetIsMaster
void SetIsMaster(Bool_t m)
Definition: REveSelection.hxx:110
ROOT::Experimental::REveSelection::NotEmpty
bool NotEmpty() const
Definition: REveSelection.hxx:113
ROOT::Experimental::REveSelection::SetHighlightMode
void SetHighlightMode()
Set to 'highlight' mode.
Definition: REveSelection.cxx:88
ROOT::Experimental::REveSelection::ActivateSelection
virtual void ActivateSelection()
Activate this selection.
Definition: REveSelection.cxx:333
ROOT::Experimental::REveSelection::HasNieces
bool HasNieces() const override
Check if any elements are selected.
Definition: REveSelection.cxx:153
ROOT::Experimental::REveSelection::AddNieceInternal
void AddNieceInternal(REveElement *el) override
Add an element into selection, virtual from REveAunt.
Definition: REveSelection.cxx:171
ROOT::Experimental::REveSelection::GetIsMaster
Bool_t GetIsMaster() const
Definition: REveSelection.hxx:109
REveElement.hxx
ROOT::Experimental::REveSelection::RemoveImpliedSelectedReferencesTo
int RemoveImpliedSelectedReferencesTo(REveElement *el)
Remove pointers to el from implied selected sets.
Definition: REveSelection.cxx:610
ROOT::Experimental::REveSelection::kPS_Master
@ kPS_Master
Definition: REveSelection.hxx:37
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
ROOT::Experimental::REveSelection::Record::Record
Record(REveElement *el)
Definition: REveSelection.hxx:47
ROOT::Experimental::REveSelection
REveSelection Container for selected and highlighted elements.
Definition: REveSelection.hxx:29
ROOT::Experimental::REveSelection::fPickToSelect
std::vector< int > fPickToSelect
!
Definition: REveSelection.hxx:78
ROOT::Experimental::REveSelection::UserRePickedElement
virtual void UserRePickedElement(REveElement *el)
Called when element selection is repeated.
Definition: REveSelection.cxx:449
ROOT::Experimental::REveElement::Set_t
std::set< REveElement * > Set_t
Definition: REveElement.hxx:89
ROOT::Experimental::REveSelection::SelMap_t
std::map< REveElement *, Record > SelMap_t
Definition: REveSelection.hxx:67
ROOT::Experimental::REveAunt
Definition: REveElement.hxx:402
ROOT::Experimental::REveSelection::RecheckImpliedSetForElement
void RecheckImpliedSetForElement(REveElement *el)
If given element is selected or implied-selected within this selection then recheck implied-set for g...
Definition: REveSelection.cxx:273
ROOT::Experimental::REveSelection::operator=
REveSelection & operator=(const REveSelection &)=delete
ROOT::Experimental::REveElement::REveElement
REveElement(const std::string &name="", const std::string &title="")
Default constructor.
Definition: REveElement.cxx:51
ROOT::Experimental::REveSelection::MapPickedToSelected
REveElement * MapPickedToSelected(REveElement *el)
Given element el that was picked or clicked by the user, find the parent/ancestor element that should...
Definition: REveSelection.cxx:363
ROOT::Experimental::REveSelection::EPickToSelect
EPickToSelect
Definition: REveSelection.hxx:32
ROOT::Experimental::REveSelection::find_record
Record * find_record(REveElement *el)
Definition: REveSelection.hxx:84
ROOT::Experimental::REveSelection::RemoveNieces
void RemoveNieces() override
Add an element into selection, virtual from REveAunt.
Definition: REveSelection.cxx:208
ROOT::Experimental::REveSelection::DeactivateSelection
virtual void DeactivateSelection()
Deactivate this selection.
Definition: REveSelection.cxx:347
ROOT::Experimental::REveSelection::SelectionRepeated
void SelectionRepeated(REveElement *el)
Emit SelectionRepeated signal.
Definition: REveSelection.cxx:324
ROOT::Experimental::REveSelection::UserUnPickedElement
virtual void UserUnPickedElement(REveElement *el)
Called when an element is unselected.
Definition: REveSelection.cxx:463
ROOT::Experimental::REveSelection::DoElementSelect
void DoElementSelect(SelMap_i &entry)
Select element indicated by the entry and fill its implied-selected set.
Definition: REveSelection.cxx:101
ROOT::Experimental::REveSelection::fHiddenEdgeColor
Color_t fHiddenEdgeColor
!
Definition: REveSelection.hxx:76
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
ROOT::Experimental::REveSelection::AddPickToSelect
void AddPickToSelect(int ps)
Definition: REveSelection.hxx:107
ROOT::Experimental::REveSelection::DoElementUnselect
void DoElementUnselect(SelMap_i &entry)
Deselect element indicated by the entry and clear its implied-selected set.
Definition: REveSelection.cxx:133
ROOT::Experimental::REveSelection::HasNiece
bool HasNiece(REveElement *el) const override
Check if elemenet el is selected (not implied selected).
Definition: REveSelection.cxx:145
ROOT::Experimental::REveSelection::RemoveNieceInternal
void RemoveNieceInternal(REveElement *el) override
Virtual from REveAunt.
Definition: REveSelection.cxx:184
ROOT::Experimental::REveSelection::kPS_Element
@ kPS_Element
Definition: REveSelection.hxx:33
ROOT::Experimental::REveSelection::kPS_Projectable
@ kPS_Projectable
Definition: REveSelection.hxx:34
ROOT::Experimental::REveSelection::AcceptNiece
bool AcceptNiece(REveElement *el) override
Pre-addition check.
Definition: REveSelection.cxx:162
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveSelection::Record
Definition: REveSelection.hxx:41
ROOT::Experimental::REveSelection::SelMap_i
SelMap_t::iterator SelMap_i
Definition: REveSelection.hxx:68
ROOT::Experimental::REveSelection::RefPickToSelect
const std::vector< int > & RefPickToSelect() const
Definition: REveSelection.hxx:105
ROOT::Experimental::REveSelection::fMap
SelMap_t fMap
!
Definition: REveSelection.hxx:82
g
#define g(i)
Definition: RSha256.hxx:105