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
19namespace ROOT {
20namespace Experimental {
21
22////////////////////////////////////////////////////////////////////////////////
23/// REveSelection
24/// Container for selected and highlighted elements.
25////////////////////////////////////////////////////////////////////////////////
26
28 public REveAunt
29{
30 friend class Deviator;
31
32public:
33 enum EPickToSelect // How to convert picking events to top selected element:
34 { kPS_Ignore, // ignore picking
35 kPS_Element, // select element (default for selection)
36 kPS_Projectable, // select projectable
37 kPS_Compound, // select compound
38 kPS_PableCompound, // select projectable and compound
39 kPS_Master // select master element (top-level compound)
40 };
41
42 struct Record
43 {
44 REveElement *f_primary{nullptr}; ///<! it's also implied through the map -- XXXX do i need it ????
46 std::set<int> f_sec_idcs;
47 bool f_is_sec{false}; ///<! is secondary-selected -- XXXX do i need it ????
48
50 f_primary (el),
51 f_is_sec (false)
52 {
53 // Apparently done in DoElementSelect
54 // el->FillImpliedSelectedSet(f_implied);
55 }
56
57 Record(REveElement *el, const std::set<int>& secondary_idcs) :
58 f_primary (el),
59 f_sec_idcs (secondary_idcs),
60 f_is_sec (true)
61 {
62 // Apparently done in DoElementSelect
63 // el->FillImpliedSelectedSet(f_implied);
64 }
65
66 bool is_secondary() const { return f_is_sec; }
67 };
68
69 class Deviator {
70 public:
71 virtual ~Deviator(){};
73 virtual bool DeviateSelection(REveSelection* s, REveElement* el, bool multi, bool secondary, const std::set<int>& secondary_idcs) = 0;
74 protected:
75 void ExecuteNewElementPicked(REveSelection* s, REveElement* el, bool multi, bool secondary, const std::set<int>& secondary_idcs)
76 {
77 s->NewElementPickedInternal(el, multi, secondary, secondary_idcs);
78 }
79 };
80
81 typedef std::map<REveElement*, Record> SelMap_t;
82 typedef SelMap_t::iterator SelMap_i;
83
84private:
85 REveSelection(const REveSelection &) = delete;
87
88protected:
91
92 std::vector<int> fPickToSelect; ///<!
95
97
98 std::shared_ptr<Deviator> fDeviator;///<!
99
101 {
102 auto i = fMap.find(el);
103 return i != fMap.end() ? & i->second : nullptr;
104 }
105
106 void DoElementSelect (SelMap_i &entry);
107 void DoElementUnselect(SelMap_i &entry);
108
109 void RecheckImpliedSet(SelMap_i &entry);
110
111 void AddNieceForSelection(REveElement*, bool secondary, const std::set<int>&);
112
113 void NewElementPickedInternal(REveElement* el, bool multi, bool secondary, const std::set<int>& secondary_idcs);
114
115public:
116 REveSelection(const std::string &n = "REveSelection", const std::string &t = "",
117 Color_t col_visible = kViolet, Color_t col_hidden = kPink);
118 virtual ~REveSelection();
119
122
123 void SetHighlightMode();
124
125 const std::vector<int>& RefPickToSelect() const { return fPickToSelect; }
127 void AddPickToSelect(int ps) { fPickToSelect.push_back(ps); }
128
129 Bool_t GetIsMaster() const { return fIsMaster; }
131
132 std::shared_ptr<Deviator> GetDeviator() const { return fDeviator; }
133 void SetDeviator(std::shared_ptr<Deviator> d) { fDeviator = d; }
134
135 bool IsEmpty() const { return fMap.empty(); }
136 bool NotEmpty() const { return ! fMap.empty(); }
137
138 // Abstract methods of REveAunt
139 bool HasNiece(REveElement *el) const override;
140 bool HasNieces() const override;
141 bool AcceptNiece(REveElement *el) override;
142 void AddNieceInternal(REveElement *el) override;
143 void RemoveNieceInternal(REveElement *el) override;
144 void RemoveNieces() override;
145
147
149
150 void SelectionAdded(REveElement *el); // *SIGNAL*
151 void SelectionRemoved(REveElement *el); // *SIGNAL*
152 void SelectionCleared(); // *SIGNAL*
153 void SelectionRepeated(REveElement *el); // *SIGNAL*
154
155 // ----------------------------------------------------------------
156 // Interface to make selection active/non-active.
157
158 virtual void ActivateSelection();
159 virtual void DeactivateSelection();
160
161 // ----------------------------------------------------------------
162 // User input processing.
163
165
166 virtual void UserPickedElement(REveElement *el, Bool_t multi = kFALSE);
167 virtual void UserRePickedElement(REveElement *el);
168 virtual void UserUnPickedElement(REveElement *el);
169
170 void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set<int>& secondary_idcs={});
171 void NewElementPickedStr(ElementId_t id, bool multi, bool secondary, const char* secondary_idcs="");
172 void ClearSelection();
173
175
176 // ----------------------------------------------------------------
177
178 Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
179
180};
181
182} // namespace Experimental
183} // namespace ROOT
184
185#endif
#define d(i)
Definition: RSha256.hxx:102
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
short Color_t
Definition: RtypesCore.h:92
unsigned char UChar_t
Definition: RtypesCore.h:38
const Bool_t kFALSE
Definition: RtypesCore.h:101
@ kPink
Definition: Rtypes.h:67
@ kViolet
Definition: Rtypes.h:67
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
Base class for REveUtil visualization elements, providing hierarchy management, rendering control and...
std::set< REveElement * > Set_t
void ExecuteNewElementPicked(REveSelection *s, REveElement *el, bool multi, bool secondary, const std::set< int > &secondary_idcs)
virtual bool DeviateSelection(REveSelection *s, REveElement *el, bool multi, bool secondary, const std::set< int > &secondary_idcs)=0
REveSelection Container for selected and highlighted elements.
void RemoveNieceInternal(REveElement *el) override
Virtual from REveAunt.
void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set< int > &secondary_idcs={})
Called from GUI when user picks or un-picks an element.
bool HasNiece(REveElement *el) const override
Check if elemenet el is selected (not implied selected).
bool AcceptNiece(REveElement *el) override
Pre-addition check.
std::shared_ptr< Deviator > fDeviator
!
std::shared_ptr< Deviator > GetDeviator() const
REveSelection & operator=(const REveSelection &)=delete
void AddNieceForSelection(REveElement *, bool secondary, const std::set< int > &)
void AddNieceInternal(REveElement *el) override
Add an element into selection, virtual from REveAunt.
REveElement * MapPickedToSelected(REveElement *el)
Given element el that was picked or clicked by the user, find the parent/ancestor element that should...
void RemoveImpliedSelected(REveElement *el)
Remove element from all implied-selected sets.
int RemoveImpliedSelectedReferencesTo(REveElement *el)
Remove pointers to el from implied selected sets.
const std::vector< int > & RefPickToSelect() const
void SelectionRemoved(REveElement *el)
Emit SelectionRemoved signal.
void SetHiddenEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set hidden highlight color.
virtual ~REveSelection()
Destructor.
REveSelection(const REveSelection &)=delete
void SetVisibleEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set visible highlight color.
virtual void ActivateSelection()
Activate this selection.
bool HasNieces() const override
Check if any elements are selected.
std::map< REveElement *, Record > SelMap_t
void SetHighlightMode()
Set to 'highlight' mode.
void SelectionCleared()
Emit SelectionCleared signal.
virtual void DeactivateSelection()
Deactivate this selection.
void DoElementSelect(SelMap_i &entry)
Select element indicated by the entry and fill its implied-selected set.
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json. If rnr_offset negative, render data will not be written.
Record * find_record(REveElement *el)
void NewElementPickedInternal(REveElement *el, bool multi, bool secondary, const std::set< int > &secondary_idcs)
Called from NewElementPicked or Deviator::DeviateSelection.
virtual void UserRePickedElement(REveElement *el)
Called when element selection is repeated.
virtual void UserPickedElement(REveElement *el, Bool_t multi=kFALSE)
Called when user picks/clicks on an element.
void SetDeviator(std::shared_ptr< Deviator > d)
void RecheckImpliedSetForElement(REveElement *el)
If given element is selected or implied-selected within this selection then recheck implied-set for g...
void SelectionRepeated(REveElement *el)
Emit SelectionRepeated signal.
void RecheckImpliedSet(SelMap_i &entry)
Recalculate implied-selected state for given selection entry.
void SelectionAdded(REveElement *el)
Emit SelectionAdded signal.
void NewElementPickedStr(ElementId_t id, bool multi, bool secondary, const char *secondary_idcs="")
Wrapper for NewElementPickedStr that takes secondary indices as C-style string.
void RemoveNieces() override
Add an element into selection, virtual from REveAunt.
void DoElementUnselect(SelMap_i &entry)
Deselect element indicated by the entry and clear its implied-selected set.
void ClearSelection()
Clear selection if not empty.
virtual void UserUnPickedElement(REveElement *el)
Called when an element is unselected.
const Int_t n
Definition: legend1.C:16
unsigned int ElementId_t
Definition: REveTypes.hxx:25
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
static constexpr double s
static constexpr double ps
basic_json<> json
Definition: REveElement.hxx:62
REveElement * f_primary
! it's also implied through the map – XXXX do i need it ????
Record(REveElement *el, const std::set< int > &secondary_idcs)
bool f_is_sec
! is secondary-selected – XXXX do i need it ????
TMarker m
Definition: textangle.C:8