24#include <nlohmann/json.hpp>
38REveSelection::REveSelection(
const std::string&
n,
const std::string& t,
100 if ((*i)->GetElementId() == 0)
104 Info(
"REveSelection::DoElementSelect",
105 "Element '%s' [%s] with 0 id detected and removed.",
106 (*i)->GetCName(), (*i)->IsA()->GetName());
113 (*i)->IncImpliedSelected();
145 return !
fMap.empty();
155 el->IsA()->InheritsFrom(TClass::GetClass<REveSelection>()) ==
kFALSE;
202 Warning(
"REveSelection::RemoveNieceLocal",
"element not found in map.");
214 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i)
216 i->first->RemoveAunt(
this);
237 auto j = i.second.f_implied.find(
el);
238 if (
j != i.second.f_implied.
end())
240 i.second.f_implied.erase(
j);
257 smi->first->FillImpliedSelectedSet(set,
smi->second.f_sec_idcs);
260 if (
smi->second.f_implied.find(i) ==
smi->second.f_implied.
end())
262 smi->second.f_implied.insert(i);
263 i->IncImpliedSelected();
286 if (
el->GetImpliedSelected() > 0)
288 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i)
290 if (i->second.f_implied.find(
el) != i->second.f_implied.end())
340 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i) {
353 for (
auto i =
fMap.begin(); i !=
fMap.end(); ++i) {
490 throw eh +
"picked element id=" +
id +
" not found.";
542 auto ir = rec->f_sec_idcs.insert(
nsi);
549 rec->f_sec_idcs.erase(
dit);
552 std::set<int>
newSet = rec->f_sec_idcs;
627 static const std::regex
comma_re(
"\\s*,\\s*", std::regex::optimize);
630 std::sregex_token_iterator
itr(str.begin(), str.end(),
comma_re, -1);
631 std::sregex_token_iterator end;
634 while (
itr != end)
sis.insert(std::stoi(*
itr++));
636 catch (
const std::invalid_argument&) {
637 throw eh +
"invalid secondary index argument '" + *
itr +
"' - must be int.";
666 auto j = i.second.f_implied.find(
el);
668 if (
j != i.second.f_implied.
end())
670 i.second.f_implied.erase(
j);
671 el->DecImpliedSelected();
691 nlohmann::json
sel_list = nlohmann::json::array();
695 nlohmann::json rec = {},
imp = nlohmann::json::array(),
sec = nlohmann::json::array();
697 rec[
"primary"] = i.first->GetElementId();
700 for (
auto &
sec_id : i.second.f_sec_idcs)
704 for (
auto &
imp_el : i.second.f_implied) {
706 if (
imp_el->RequiresExtraSelectionData())
707 imp_el->FillExtraSelectionData(rec[
"extra"],
sec);
710 rec[
"implied"] =
imp;
713 if (i.first->RequiresExtraSelectionData()) {
714 i.first->FillExtraSelectionData(rec[
"extra"],
sec);
717 rec[
"sec_idcs"] =
sec;
721 rec[
"tooltip"] = i.first->GetHighlightTooltip(i.second.f_sec_idcs);
728 j[
"UT_PostStream"] =
"UT_Selection_Refresh_State";
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
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
virtual void AddNiece(REveElement *el)
virtual void RemoveNiece(REveElement *el)
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
void StampObjPropsPreChk()
std::set< REveElement * > Set_t
REveException Exception-type thrown by Eve classes.
REveElement * FindElementById(ElementId_t id) const
Lookup ElementId in element map and return corresponding REveElement*.
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.
~REveSelection() override
Destructor.
void SelectionRemoved(REveElement *el)
Emit SelectionRemoved signal.
void SetHiddenEdgeColorRGB(UChar_t r, UChar_t g, UChar_t b)
Set hidden highlight color.
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 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.
const_iterator begin() const
const_iterator end() const
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
R__EXTERN REveManager * gEve