24#include <nlohmann/json.hpp>
41 fVisibleEdgeColor (col_visible),
42 fHiddenEdgeColor (col_hidden),
107 Set_t &imp_set = entry->second.f_implied;
109 entry->first->FillImpliedSelectedSet(imp_set, entry->second.f_sec_idcs);
111 auto i = imp_set.begin();
112 while (i != imp_set.end())
114 if ((*i)->GetElementId() == 0)
118 Info(
"REveSelection::DoElementSelect",
119 "Element '%s' [%s] with 0 id detected and removed.",
120 (*i)->GetCName(), (*i)->IsA()->GetName());
127 (*i)->IncImpliedSelected();
139 Set_t &imp_set = entry->second.f_implied;
141 for (
auto &imp_el: imp_set) imp_el->DecImpliedSelected();
159 return !
fMap.empty();
168 return el !=
this &&
fMap.find(el) ==
fMap.end() &&
186 auto i =
fMap.find(el);
187 i->second.f_is_sec = secondary;
188 i->second.f_sec_idcs = sec_idcs;
202 auto i =
fMap.find(el);
216 Warning(
"REveSelection::RemoveNieceLocal",
"element not found in map.");
228 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i)
230 i->first->RemoveAunt(
this);
247 bool changed =
false;
251 auto j = i.second.f_implied.find(el);
252 if (j != i.second.f_implied.end())
254 i.second.f_implied.erase(j);
269 bool changed =
false;
271 smi->first->FillImpliedSelectedSet(set, smi->second.f_sec_idcs);
274 if (smi->second.f_implied.find(i) == smi->second.f_implied.end())
276 smi->second.f_implied.insert(i);
277 i->IncImpliedSelected();
293 auto i =
fMap.find(el);
302 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i)
304 if (i->second.f_implied.find(el) != i->second.f_implied.end())
354 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i) {
367 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i) {
386 switch (pick_to_select)
496 static const REveException eh(
"REveSelection::NewElementPicked ");
504 throw eh +
"picked element id=" +
id +
" not found.";
509 if (
fDeviator &&
fDeviator->DeviateSelection(
this, el, multi, secondary, secondary_idcs))
527 std::string debug_secondary;
529 debug_secondary =
" {";
530 for (
auto si : secondary_idcs) {
531 debug_secondary.append(
" ");
532 debug_secondary.append(std::to_string(si));
534 debug_secondary.append(
" }");
536 ::Info(
"REveSelection::NewElementPickedInternal",
" %p, multi: %d, secondary: %d %s", el, multi, secondary, debug_secondary.c_str());
553 for (
auto &
ns : secondary_idcs)
562 for (
auto &dit : dup)
568 if (!newSet.empty()) {
596 bool modified = (rec->
f_sec_idcs != secondary_idcs);
633 static const REveException eh(
"REveSelection::NewElementPickedStr ");
635 if (secondary_idcs == 0 || secondary_idcs[0] == 0)
641 static const std::regex comma_re(
"\\s*,\\s*", std::regex::optimize);
642 std::string str(secondary_idcs);
644 std::sregex_token_iterator itr(str.begin(), str.end(), comma_re, -1);
645 std::sregex_token_iterator end;
648 while (itr != end) sis.insert(std::stoi(*itr++));
650 catch (
const std::invalid_argument&) {
651 throw eh +
"invalid secondary index argument '" + *itr +
"' - must be int.";
680 auto j = i.second.f_implied.find(el);
682 if (j != i.second.f_implied.end())
684 i.second.f_implied.erase(j);
707 nlohmann::json rec = {}, imp = nlohmann::json::array(), sec = nlohmann::json::array();
709 rec[
"primary"] = i.first->GetElementId();
712 for (
auto &sec_id : i.second.f_sec_idcs)
713 sec.push_back(sec_id);
716 for (
auto &imp_el : i.second.f_implied) {
717 imp.push_back(imp_el->GetElementId());
718 imp_el->FillExtraSelectionData(rec[
"extra"], sec);
721 rec[
"implied"] = imp;
724 if (i.first->RequiresExtraSelectionData()) {
725 i.first->FillExtraSelectionData(rec[
"extra"], sec);
728 rec[
"sec_idcs"] = sec;
732 rec[
"tooltip"] = i.first->GetHighlightTooltip(i.second.f_sec_idcs);
734 sel_list.push_back(rec);
737 j[
"sel_list"] = sel_list;
739 j[
"UT_PostStream"] =
"UT_Selection_Refresh_State";
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
R__EXTERN TEveManager * gEve
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
virtual void AddNiece(REveElement *el)
virtual void RemoveNiece(REveElement *el)
TClass * IsA() const
Return class for this element.
REveCompound * GetCompound()
virtual REveElement * GetSelectionMaster()
Returns the master element - that is:
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
void StampObjPropsPreChk()
void DecImpliedSelected()
std::set< REveElement * > Set_t
REveException Exception-type thrown by Eve classes.
REveProjectable * GetProjectable() const
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
!
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.
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.
Color_t fHiddenEdgeColor
!
std::vector< int > fPickToSelect
!
virtual void ActivateSelection()
Activate this selection.
bool HasNieces() const override
Check if any elements are selected.
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.
SelMap_t::iterator SelMap_i
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 AddPickToSelect(int ps)
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.
Color_t fVisibleEdgeColor
!
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.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
static constexpr double ns
basic_json< std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, adl_serializer, std::vector< std::uint8_t > > json
bool is_secondary() const
std::set< int > f_sec_idcs