33#include <nlohmann/json.hpp>
42#define REVEGEO_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
44#define REVEGEO_DEBUG_PRINT(fmt, ...)
69 if (iter->stack == stack) {
85 auto isVisible = [&stack](std::vector<RGeomNodeVisibility> &
visVec) ->
bool {
139 using namespace std::string_literals;
143 if (arg.compare(0, 6,
"CDTOP:") == 0)
145 std::vector<std::string>
ep;
150 else if (arg.compare(0, 5,
"CDUP:") == 0)
158 else if (arg.compare(0, 8,
"SETAPEX:") == 0) {
159 auto path = TBufferJSON::FromJSON<std::vector<std::string>>(arg.substr(8));
164 if (path->size() > 1) {
165 result.insert(
result.end(), path->begin() + 1, path->end());
171 else if ((arg.compare(0, 7,
"SETVI0:") == 0) || (arg.compare(0, 7,
"SETVI1:") == 0)) {
174 bool on = (arg[5] ==
'1');
175 auto path = TBufferJSON::FromJSON<std::vector<std::string>>(arg.substr(7));
177 std::vector<int> base =
eveDesc.GetIndexStack();
179 stack.insert(stack.begin(), base.begin(), base.end());
182 std::cout <<
"Set visibilty rnr CHIDLREN \n";
187 else if ((arg.compare(0, 5,
"SHOW:") == 0) || (arg.compare(0, 5,
"HIDE:") == 0)) {
189 auto path = TBufferJSON::FromJSON<std::vector<std::string>>(arg.substr(5));
190 bool on = (arg.compare(0, 5,
"SHOW:") == 0);
193 std::vector<int> base =
eveDesc.GetIndexStack();
195 stack.insert(stack.begin(), base.begin(), base.end());
198 std::cout <<
"Set visibilty rnr PHY \n";
231 for (
size_t t = 0; t < path.size(); t++) {
232 std::string s = path[t];
233 std::cout << s << std::endl;
236 throw std::runtime_error(
"Apex::LocateNodeWithPath(), can't locate node with path " + s);
247 std::ostringstream
oss;
251 for (
size_t i = 1; i < fPath.size(); ++i)
252 oss <<
"/" << fPath[i];
265 std::vector<std::string>
nameStack = fPath;
269 for (
size_t i = start; i <
nameStack.size(); ++i)
279 for (
int j = 0;
j < nd; ++
j)
293 std::cerr <<
"Node not found: " <<
targetName << std::endl;
308 throw std::runtime_error(
"Critical Error: Failed to import geometry file");
319 fDesc.AddSignalHandler(
this, [
this](
const std::string &kind) { ProcessSignal(kind); });
323 fWebHierarchy = std::make_shared<REveGeomHierarchy>(
fDesc,
true);
324 fWebHierarchy->SetReceiver(
this);
329 std::regex re(R
"([/\\]+)");
330 std::sregex_token_iterator it(path.begin(), path.end(), re, -1);
331 std::sregex_token_iterator end;
332 std::vector<std::string>
result;
334 for (; it != end; ++it) {
335 if (!it->str().empty()) {
342 for (
auto &
el : fNieces) {
351 for (
auto &
el : fNieces) {
368 if ((kind ==
"SelectTop") || (kind ==
"CdTop") || (kind ==
"CdUp"))
370 for (
auto &
el : fNieces) {
375 else if (kind ==
"HighlightItem") {
380 }
else if (kind ==
"ClickItem") {
381 printf(
"REveGeoTopNodeData element CLICKED selected --------------------------------\n");
385 for (
auto &
n : fNieces) {
455 auto it = set.begin();
458 std::cout <<
"highlight node with ID " << pos <<
"\n";
460 std::string res =
"GeoNode name";
467 while ((node =
git.Next()))
490 std::set<TGeoShape *> shapes;
494 std::cout <<
"Shape size " << shapes.size() <<
"\n";
504 std::cout <<
"Node size " <<
fNodes.size() <<
"\n";
508 printf(
"NODES Real time: %.3f s\n",
timer.RealTime());
509 printf(
"NODES CPU time: %.3f s\n",
timer.CpuTime());
516 printf(
"collect nodes \n");
533 while ((node = it.
Next()))
547 if (
mat->IsScale()) {
594 for (
int i = 0; i < 16; ++i)
600 for (
size_t i = 0; i <
browsables.size(); i++) {
611 for (
int i = 1; i <= it.
GetLevel(); ++i)
620 if (nodeId > 300000) {
622 printf(
"num nodes locked !!! \n");
630 printf(
"collect shapes \n");
633 while ((node =
geoit.Next()))
642 auto it = shapes.find(shape);
643 if (it == shapes.end()) {
644 shapes.insert(shape);
664 for (
size_t i = 0; i <
polyShape.GetVertices().size(); i++)
668 for (
size_t i = 0; i <
polyShape.GetPolyDesc().size(); i += 4) {
682 fRenderData = std::make_unique<REveRenderData>(
"makeGeoTopNode");
683 for (
size_t i = 0; i <
fNodes.size(); ++i) {
688 uint32_t
v = (
c[0] << 16) + (
c[1] << 8) +
c[2];
690 std::memcpy(&pc, &
v,
sizeof(pc));
734 for (
size_t i = 0; i <
fShapes.size(); ++i) {
742 for (
size_t p = 0;
p <
fShapes[i].indices.size(); ++
p)
760 for (
size_t i = 0; i <
fNodes.size(); ++i) {
763 for (
int t = 0; t < 16; t++)
797 auto jbb = json::array();
826 while ((node = it.
Next())) {
842 printf(
"GetIndicesFromBrowserStack stack size %zu res size %zu\n", stack.size(), res.size());
858 while ((node = it.
Next())) {
thread_local ElementId_t gSelId
#define R__LOG_ERROR(...)
char Text_t
General string (char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
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 Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char mode
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
std::unique_ptr< REveRenderData > fRenderData
! Vertex / normal / triangle index information for rendering.
ElementId_t GetElementId() const
REveRenderData * GetRenderData() const
REveGeoManagerHolder Exception-safe global variable holders.
void SetChannel(unsigned connid, int chid)
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void InitPath(const std::string &path)
void VisibilityChanged(bool on, REveGeomDescription::ERnrFlags flag, const std::vector< int > &path)
REveGeomDescription fDesc
REveGeomDescription & RefDescription()
REveGeoTopNodeData(const REveGeoTopNodeData &)=delete
void ProcessSignal(const std::string &)
void GetIndicesFromBrowserStack(const std::vector< int > &stack, std::set< int > &outStack)
std::string GetHighlightTooltip(const std::set< int > &secondary_idcs) const override
REveGeoTopNodeViz(const REveGeoTopNodeViz &)=delete
void CollectNodes(TGeoVolume *volume, std::vector< BNode > &bnl, std::vector< BShape > &browsables)
void BuildRenderData() override
Write transformation Matrix to render data.
REveGeoTopNodeData * fGeoData
void VisibilityChanged(bool on, REveGeomDescription::ERnrFlags flag, const std::vector< int > &path)
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Write core json.
void SetGeoData(REveGeoTopNodeData *d, bool rebuild=true)
std::vector< BNode > fNodes
void SetVizMode(EMode mode)
bool AcceptNode(TGeoIterator &it, bool skip=true) const
void CollectShapes(TGeoNode *node, std::set< TGeoShape * > &shapes, std::vector< BShape > &browsables)
std::vector< BShape > fShapes
std::vector< int > GetIndexStack() const
std::string GetFlatPath() const
void SetFromPath(std::vector< std::string > absPath)
TGeoNode * LocateNodeWithPath(const std::vector< std::string > &path) const
std::vector< std::string > fPath
void InitPath(const std::vector< std::string > &path)
bool ChangeEveVisibility(const std::vector< int > &stack, ERnrFlags rnrFlag, bool on)
std::vector< int > GetIndexStack()
std::vector< RGeomNodeVisibility > fVisibilitySelf
virtual void RefineGeoItem(ROOT::RGeoItem &item, const std::vector< int > &stack) override
Method which allows to add/modify information in RGeoItem which will be provided to client - like tit...
bool GetVisiblityForStack(const std::vector< int > &stack)
void ImportFile(const char *filePath)
const std::vector< std::string > & GetApexPath() const
static TGeoManager * s_geoManager
static TGeoManager * GetGeoManager()
std::vector< RGeomNodeVisibility > fVisibilityRec
REveGeoTopNodeData * fReceiver
virtual void WebWindowCallback(unsigned connid, const std::string &kind) override
Table signal handling.
REveSelection * GetSelection() const
std::shared_ptr< ROOT::RWebWindow > GetWebWindow() const
void SetAlwaysSecSelect(Bool_t f)
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.
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE)
Fill col with RGBA values corresponding to index ci.
Representation of single item in the geometry browser.
std::vector< RGeomNode > fDesc
! converted description, send to client
void SetVisLevel(int lvl=3)
Set maximal visible level.
void IssueSignal(const void *handler, const std::string &kind)
Issue signal, which distributed on all handlers - excluding source handler.
int GetVisLevel() const
Returns maximal visible level.
std::vector< int > MakeStackByPath(const std::vector< std::string > &path)
Produce stack based on string path Used to highlight geo volumes by browser hover event.
void Build(TGeoManager *mgr, const std::string &volname="")
Collect information about geometry hierarchy into flat list like it done in JSROOT ClonedNodes....
std::shared_ptr< RWebWindow > fWebWindow
! web window to show geometry
virtual void WebWindowCallback(unsigned connid, const std::string &arg)
Process data from client.
RGeomDescription & fDesc
! geometry description, shared with external
const_iterator begin() const
const_iterator end() const
virtual Color_t GetLineColor() const
Return the line color.
Composite shapes are Boolean combinations of two or more shape components.
Matrix class used for computing global transformations Should NOT be used for node definition.
const TGeoMatrix * GetCurrentMatrix() const
Returns global matrix for current node.
TGeoNode * GetNode(Int_t level) const
Returns current node at a given level.
Int_t GetIndex(Int_t i) const
TGeoNode * Next()
Returns next node.
void Skip()
Stop iterating the current branch.
The manager class for any TGeo geometry.
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
Geometrical transformation package.
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
TGeoVolume * GetVolume() const
Int_t GetNdaughters() const
Base abstract class for all shapes.
virtual void ComputeBBox()=0
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Int_t GetNdaughters() const
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
TGeoShape * GetShape() const
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
const char * GetName() const override
Returns name of object.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Namespace for ROOT features in testing.
ROOT::RLogChannel & REveLog()
Log channel for Eve diagnostics.
R__EXTERN REveManager * gEve