Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RGeomData.hxx
Go to the documentation of this file.
1// Author: Sergey Linev, 14.12.2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT7_RGeomData
12#define ROOT7_RGeomData
13
14#include <vector>
15#include <string>
16#include <functional>
17#include <memory>
18
20
21#include "TVirtualMutex.h"
22
23class TGeoNode;
24class TGeoManager;
25class TGeoShape;
26class TGeoMatrix;
27class TGeoVolume;
28
29// do not use namespace to avoid too long JSON
30
31namespace ROOT {
32
33class RGeomBrowserIter;
34class RLogChannel;
35
36/// Log channel for Geomviewer diagnostics.
37RLogChannel &RGeomLog();
38
39/** Base description of geometry node, required only to build hierarchy */
40
42public:
43 int id{0}; ///< node id, index in array
44 std::string name; ///< node name
45 std::vector<int> chlds; ///< list of childs id
46 int vis{0}; ///< visibility flag, 0 - off, 1 - only when level==0, 99 - always
47 bool nochlds{false}; ///< how far in hierarchy depth should be scanned
48
49 std::string color; ///< rgb code in hex format
50 std::string material; ///< name of the material
51 int sortid{0}; ///<! place in sorted array, to check cuts, or id of original node when used search structures
52
53 RGeomNodeBase(int _id = 0) : id(_id) {}
54
55 bool IsVisible() const { return vis > 0; }
56
57 /** Returns argument for regexp */
58 const char *GetArg(int kind)
59 {
60 if (kind == 1) return color.c_str();
61 if (kind == 2) return material.c_str();
62 return name.c_str();
63 }
64};
65
66/** Full node description including matrices and other attributes */
67
68class RGeomNode : public RGeomNodeBase {
69public:
70 std::vector<float> matr; ///< matrix for the node, can have reduced number of elements
71 double vol{0}; ///<! volume estimation
72 int nfaces{0}; ///<! number of shape faces
73 int idshift{-1}; ///<! used to jump over then scan all geom hierarchy
74 bool useflag{false}; ///<! extra flag, used for selection
75 float opacity{1.}; ///<! opacity of the color
76
78
79 /** True when there is shape and it can be displayed */
80 bool CanDisplay() const { return (vol > 0.) && (nfaces > 0); }
81};
82
83/** \class RGeoItem
84\ingroup rbrowser
85\brief Representation of single item in the geometry browser
86*/
87
88class RGeoItem : public Browsable::RItem {
89
90protected:
91 // this is part for browser, visible for I/O
92 int id{0}; ///< node id
93 std::string color; ///< color
94 std::string material; ///< material
95 int vis{0}; ///< visibility of logical node
96 int pvis{0}; ///< visibility of physical node
97 bool top{false}; ///< indicates if node selected as top
98
99public:
100
101 /** Default constructor */
102 RGeoItem() = default;
103
104 RGeoItem(const std::string &_name, int _nchilds, int _nodeid, const std::string &_color,
105 const std::string &_material = "", int _vis = 0, int _pvis = 0) :
106 Browsable::RItem(_name, _nchilds), id(_nodeid), color(_color), material(_material), vis(_vis), pvis(_pvis) {
107 }
108
109 // should be here, one needs virtual table for correct streaming of RRootBrowserReply
110 ~RGeoItem() override = default;
111
114 void SetTop(bool on = true) { top = on; }
115};
116
117
118/** Base class for render info block */
120public:
121 /// virtual destructor required for the I/O
122 virtual ~RGeomRenderInfo() = default;
123};
124
125/** Render info with raw data */
127public:
128 std::vector<unsigned char> raw; ///< float vertices as raw data, JSON_base64
129 std::vector<int> idx; ///< vertex indexes, always triangles
130 ~RGeomRawRenderInfo() override = default;
131};
132
133/** Render info with shape itself - client can produce shape better */
135public:
136 TGeoShape *shape{nullptr}; ///< original shape - can be much less than binary data
137 ~RGeomShapeRenderInfo() override = default;
138};
139
140
141/** RGeomVisible contains description of visible node
142 * It is path to the node plus reference to shape rendering data */
143
145public:
146 int nodeid{0}; ///< selected node id,
147 int seqid{0}; ///< sequence id, used for merging later
148 std::vector<int> stack; ///< path to the node, index in list of childs
149 std::string color; ///< color in rgb format
150 double opacity{1}; ///< opacity
151 RGeomRenderInfo *ri{nullptr}; ///< render information for the shape, can be same for different nodes
152
153 RGeomVisible() = default;
154 RGeomVisible(int _nodeid, int _seqid, const std::vector<int> &_stack) : nodeid(_nodeid), seqid(_seqid), stack(_stack) {}
155};
156
157
158/** Configuration parameters which can be configured on the client
159 * Send as is to-from client */
160
162public:
163 int vislevel{0}; ///< visible level
164 int maxnumnodes{0}; ///< maximal number of nodes
165 int maxnumfaces{0}; ///< maximal number of faces
166 bool showtop{false}; ///< show geometry top volume, off by default
167 int build_shapes{1}; ///< when shapes build on server 0 - never, 1 - TGeoComposite, 2 - plus non-cylindrical, 3 - all
168 int nsegm{0}; ///< number of segments for cylindrical shapes
169 std::string drawopt; ///< draw options for TGeoPainter
170};
171
172
173/** Object with full description for drawing geometry
174 * It includes list of visible items and list of nodes required to build them */
175
177public:
178 RGeomConfig *cfg{nullptr}; ///< current configurations
179 int numnodes{0}; ///< total number of nodes in description
180 std::vector<RGeomNode*> nodes; ///< all used nodes to display visible items and not known for client
181 std::vector<RGeomVisible> visibles; ///< all visible items
182};
183
184
185/** Node information including rendering data */
187public:
188 std::vector<std::string> path; ///< full path to node
189 std::string node_type; ///< node class name
190 std::string node_name; ///< node name
191 std::string shape_type; ///< shape type (if any)
192 std::string shape_name; ///< shape class name (if any)
193
194 RGeomRenderInfo *ri{nullptr}; ///< rendering information (if applicable)
195};
196
197/** Custom settings for physical Node visibility */
199public:
200 std::vector<int> stack; ///< path to the node
201 bool visible{false}; ///< visible flag
202 RGeomNodeVisibility(const std::vector<int> &_stack, bool _visible) : stack(_stack), visible(_visible) {}
203};
204
205using RGeomScanFunc_t = std::function<bool(RGeomNode &, std::vector<int> &, bool, int)>;
206
207using RGeomSignalFunc_t = std::function<void(const std::string &)>;
208
210
211 friend class RGeomBrowserIter;
212
214 public:
215 int id{0}; ///<! sequential id
216 TGeoShape *fShape{nullptr}; ///<! original shape
217 int nfaces{0}; ///<! number of faces in render data
218 RGeomRawRenderInfo fRawInfo; ///<! raw render info
219 RGeomShapeRenderInfo fShapeInfo; ///<! shape itself as info
221
222 bool has_shape() const { return nfaces == 1; }
223 bool has_raw() const { return nfaces > 1; }
224
225 /// Provide render info for visible item
227 {
228 if (has_shape()) return &fShapeInfo;
229 if (has_raw()) return &fRawInfo;
230 return nullptr;
231 }
232
233 void reset()
234 {
235 nfaces = 0;
236 fShapeInfo.shape = nullptr;
237 fRawInfo.raw.clear();
238 }
239 };
240
241 std::vector<TGeoNode *> fNodes; ///<! flat list of all nodes
242 std::vector<RGeomNode> fDesc; ///<! converted description, send to client
243 std::vector<RGeomNodeVisibility> fVisibility; ///<! custom visibility flags for physical nodes
244
245 TGeoVolume *fDrawVolume{nullptr};///<! select volume independent from TGeoManager
246 std::vector<int> fSelectedStack; ///<! selected branch of geometry by stack
247
248 std::vector<int> fHighlightedStack; ///<! highlighted element by stack
249 std::vector<int> fClickedStack; ///<! clicked element by stack
250
251 std::vector<int> fSortMap; ///<! nodes in order large -> smaller volume
252 std::vector<ShapeDescr> fShapes; ///<! shapes with created descriptions
253
254 std::string fSearch; ///<! search string in hierarchy
255 std::string fSearchJson; ///<! drawing json for search
256 std::string fDrawJson; ///<! JSON with main nodes drawn by client
257 int fDrawIdCut{0}; ///<! sortid used for selection of most-significant nodes
258 int fActualLevel{0}; ///<! level can be reduced when selecting nodes
259 bool fPreferredOffline{false}; ///<! indicates that full description should be provided to client
260 int fJsonComp{0}; ///<! default JSON compression
261 std::string fActiveItemName; ///<! name of item which should be activated in hierarchy
262
263 RGeomConfig fCfg; ///<! configuration parameter editable from GUI
264
265 TVirtualMutex *fMutex{nullptr}; ///<! external mutex used to protect all data
266
267 std::vector<std::pair<const void *, RGeomSignalFunc_t>> fSignals; ///<! registered signals
268
269 void PackMatrix(std::vector<float> &arr, TGeoMatrix *matr);
270
271 int MarkVisible(bool on_screen = false);
272
273 void ProduceIdShifts();
274
275 int ScanNodes(bool only_visible, int maxlvl, RGeomScanFunc_t func);
276
277 void ResetRndrInfos();
278
280
282
283 int GetUsedNSegments(int min = 20);
284
285 int CountShapeFaces(TGeoShape *shape);
286
288
289 void CollectNodes(RGeomDrawing &drawing, bool all_nodes = false);
290
291 std::string MakeDrawingJson(RGeomDrawing &drawing, bool has_shapes = false);
292
293 void ClearDescription();
294
296
297 TGeoVolume *GetVolume(int nodeid);
298
299 int IsPhysNodeVisible(const std::vector<int> &stack);
300
301 virtual bool IsFullModelStreamedAtOnce() const;
302
303 virtual void RefineGeoItem(RGeoItem &item, const std::vector<int> &stack);
304
305 /** clear drawing data without locking mutex */
307 {
308 fDrawJson.clear();
309 fSearchJson.clear();
310 }
311
312public:
313 RGeomDescription() = default;
314 virtual ~RGeomDescription() = default;
315
316 void AddSignalHandler(const void *handler, RGeomSignalFunc_t func);
317
318 void RemoveSignalHandler(const void *handler);
319
320 void IssueSignal(const void *handler, const std::string &kind);
321
322 /** Set mutex, it must be recursive one */
323 void SetMutex(TVirtualMutex *mutex) { fMutex = mutex; }
324 /** Return currently used mutex */
325 TVirtualMutex *GetMutex() const { return fMutex; }
326
327 /** Set maximal number of nodes which should be selected for drawing */
328 void SetMaxVisNodes(int cnt)
329 {
330 TLockGuard lock(fMutex);
331 fCfg.maxnumnodes = cnt;
333 }
334 /** Returns maximal visible number of nodes, ignored when non-positive */
335 int GetMaxVisNodes() const
336 {
337 TLockGuard lock(fMutex);
338 return fCfg.maxnumnodes;
339 }
340
341 /** Set maximal number of faces which should be selected for drawing */
342 void SetMaxVisFaces(int cnt)
343 {
344 TLockGuard lock(fMutex);
345 fCfg.maxnumfaces = cnt;
347 }
348 /** Returns maximal visible number of faces, ignored when non-positive */
349 int GetMaxVisFaces() const
350 {
351 TLockGuard lock(fMutex);
352 return fCfg.maxnumfaces;
353 }
354
355 /** Set maximal visible level */
356 void SetVisLevel(int lvl = 3)
357 {
358 TLockGuard lock(fMutex);
359 fCfg.vislevel = lvl;
361 }
362 /** Returns maximal visible level */
363 int GetVisLevel() const
364 {
365 TLockGuard lock(fMutex);
366 return fCfg.vislevel;
367 }
368
369 /** Set draw options as string for JSROOT TGeoPainter */
370 void SetTopVisible(bool on = true)
371 {
372 TLockGuard lock(fMutex);
373 fCfg.showtop = on;
375 }
376 /** Returns draw options, used for JSROOT TGeoPainter */
377 bool GetTopVisible() const
378 {
379 TLockGuard lock(fMutex);
380 return fCfg.showtop;
381 }
382
383 /** Instruct to build binary 3D model already on the server (true) or send TGeoShape as is to client, which can build model itself */
384 void SetBuildShapes(int lvl = 1)
385 {
386 TLockGuard lock(fMutex);
389 }
390 /** Returns true if binary 3D model build already by C++ server (default) */
391 int IsBuildShapes() const
392 {
393 TLockGuard lock(fMutex);
394 return fCfg.build_shapes;
395 }
396
397 /** Set number of segments for cylindrical shapes, if 0 - default value will be used */
398 void SetNSegments(int n = 0)
399 {
400 TLockGuard lock(fMutex);
401 fCfg.nsegm = n;
403 }
404 /** Return of segments for cylindrical shapes, if 0 - default value will be used */
405 int GetNSegments() const
406 {
407 TLockGuard lock(fMutex);
408 return fCfg.nsegm;
409 }
410
411 /** Set draw options as string for JSROOT TGeoPainter */
412 void SetDrawOptions(const std::string &opt = "")
413 {
414 TLockGuard lock(fMutex);
415 fCfg.drawopt = opt;
417 }
418 /** Returns draw options, used for JSROOT TGeoPainter */
419 std::string GetDrawOptions() const
420 {
421 TLockGuard lock(fMutex);
422 return fCfg.drawopt;
423 }
424
425 /** Set JSON compression level for data transfer */
426 void SetJsonComp(int comp = 0)
427 {
428 TLockGuard lock(fMutex);
429 fJsonComp = comp;
431 }
432 /** Returns JSON compression level for data transfer */
433 int GetJsonComp() const
434 {
435 TLockGuard lock(fMutex);
436 return fJsonComp;
437 }
438
439 /** Set preference of offline operations.
440 * Server provides more info to client from the begin on to avoid communication */
442 {
443 TLockGuard lock(fMutex);
445 }
446 /** Is offline operations preferred.
447 * After get full description, client can do most operations without extra requests */
449 {
450 TLockGuard lock(fMutex);
451 return fPreferredOffline;
452 }
453
454 /** Get top node path */
455 const std::vector<int>& GetSelectedStack() const { return fSelectedStack; }
456
457 void Build(TGeoManager *mgr, const std::string &volname = "");
458
459 void Build(TGeoVolume *vol);
460
461 /** Number of unique nodes in the geometry */
462 int GetNumNodes() const { TLockGuard lock(fMutex); return fDesc.size(); }
463
464 bool IsBuild() const { return GetNumNodes() > 0; }
465
466 std::string ProduceJson(bool all_nodes = false);
467
468 bool IsPrincipalEndNode(int nodeid);
469
470 std::string ProcessBrowserRequest(const std::string &req = "");
471
472 bool HasDrawData() const;
473 void ProduceDrawData();
474 void ProduceSearchData();
475 std::string GetDrawJson() const { TLockGuard lock(fMutex); return fDrawJson; }
476 std::string GetSearch() const { TLockGuard lock(fMutex); return fSearch; }
477 std::string GetSearchJson() const { TLockGuard lock(fMutex); return fSearchJson; }
478 void ClearDrawData();
479
480 void ClearCache();
481
482 int SearchVisibles(const std::string &find, std::string &hjson, std::string &json);
483
484 int FindNodeId(const std::vector<int> &stack);
485
486 std::string ProduceModifyReply(int nodeid);
487
488 std::vector<int> MakeStackByIds(const std::vector<int> &ids);
489
490 std::vector<int> MakeIdsByStack(const std::vector<int> &stack);
491
492 std::vector<int> MakeStackByPath(const std::vector<std::string> &path);
493
494 std::vector<std::string> MakePathByStack(const std::vector<int> &stack);
495
496 bool ProduceDrawingFor(int nodeid, std::string &json, bool check_volume = false);
497
498 bool SetHighlightedItem(const std::vector<int> &stack)
499 {
500 TLockGuard lock(fMutex);
501 bool changed = fHighlightedStack != stack;
502 fHighlightedStack = stack;
503 return changed;
504 }
505
506 std::vector<int> GetHighlightedItem() const
507 {
508 TLockGuard lock(fMutex);
509 return fHighlightedStack;
510 }
511
512 bool SetClickedItem(const std::vector<int> &stack)
513 {
514 TLockGuard lock(fMutex);
515 bool changed = fClickedStack != stack;
516 fClickedStack = stack;
517 return changed;
518 }
519
520 std::vector<int> GetClickedItem() const
521 {
522 TLockGuard lock(fMutex);
523 return fClickedStack;
524 }
525
526 bool SetActiveItem(const std::string &itemname)
527 {
528 TLockGuard lock(fMutex);
529 bool changed = (fActiveItemName != itemname);
531 return changed;
532 }
533
534 std::string GetActiveItem() const
535 {
536 TLockGuard lock(fMutex);
537 return fActiveItemName;
538 }
539
540 bool ChangeConfiguration(const std::string &json);
541
542 std::unique_ptr<RGeomNodeInfo> MakeNodeInfo(const std::vector<int> &stack);
543
544 bool ChangeNodeVisibility(const std::vector<std::string> &path, bool on);
545
546 bool SelectTop(const std::vector<std::string> &path);
547
548 bool SetPhysNodeVisibility(const std::vector<std::string> &path, bool on = true);
549
550 bool SetPhysNodeVisibility(const std::string &path, bool on = true);
551
552 bool ClearPhysNodeVisibility(const std::vector<std::string> &path);
553
555
556 bool SetSearch(const std::string &query, const std::string &json);
557
558 void SavePrimitive(std::ostream &fs, const std::string &name);
559};
560
561} // namespace ROOT
562
563#endif
nlohmann::json json
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
char name[80]
Definition TGX11.cxx:148
Representation of single item in the browser.
Definition RItem.hxx:23
Representation of single item in the geometry browser.
Definition RGeomData.hxx:88
RGeoItem(const std::string &_name, int _nchilds, int _nodeid, const std::string &_color, const std::string &_material="", int _vis=0, int _pvis=0)
void SetPhysicalVisibility(int physicalVis)
std::string color
color
Definition RGeomData.hxx:93
bool top
indicates if node selected as top
Definition RGeomData.hxx:97
void SetTop(bool on=true)
std::string material
material
Definition RGeomData.hxx:94
~RGeoItem() override=default
void SetLogicalVisibility(int logicalVis)
int pvis
visibility of physical node
Definition RGeomData.hxx:96
int vis
visibility of logical node
Definition RGeomData.hxx:95
RGeoItem()=default
Default constructor.
Iterator of hierarchical geometry structures.
Definition RGeomData.cxx:60
Configuration parameters which can be configured on the client Send as is to-from client.
bool showtop
show geometry top volume, off by default
int maxnumfaces
maximal number of faces
int vislevel
visible level
int maxnumnodes
maximal number of nodes
std::string drawopt
draw options for TGeoPainter
int build_shapes
when shapes build on server 0 - never, 1 - TGeoComposite, 2 - plus non-cylindrical,...
int nsegm
number of segments for cylindrical shapes
int nfaces
! number of faces in render data
RGeomShapeRenderInfo fShapeInfo
! shape itself as info
TGeoShape * fShape
! original shape
RGeomRenderInfo * rndr_info()
Provide render info for visible item.
RGeomRawRenderInfo fRawInfo
! raw render info
RGeomConfig fCfg
! configuration parameter editable from GUI
std::vector< std::pair< const void *, RGeomSignalFunc_t > > fSignals
! registered signals
int IsPhysNodeVisible(const std::vector< int > &stack)
Check if there special settings for specified physical node returns -1 if nothing is found.
std::vector< int > fSelectedStack
! selected branch of geometry by stack
void SetMaxVisNodes(int cnt)
Set maximal number of nodes which should be selected for drawing.
std::string ProcessBrowserRequest(const std::string &req="")
Find description object for requested shape If not exists - will be created.
std::vector< RGeomNode > fDesc
! converted description, send to client
void PackMatrix(std::vector< float > &arr, TGeoMatrix *matr)
Pack matrix into vector, which can be send to client Following sizes can be used for vector: 0 - Iden...
bool ProduceDrawingFor(int nodeid, std::string &json, bool check_volume=false)
Produce shape rendering data for given stack All nodes, which are referencing same shape will be tran...
std::unique_ptr< RGeomNodeInfo > MakeNodeInfo(const std::vector< int > &stack)
Change visibility for specified element Returns true if changes was performed.
bool HasDrawData() const
Check if there is draw data available.
std::vector< int > MakeIdsByStack(const std::vector< int > &stack)
Produce list of node ids for given stack If found nodes preselected - use their ids.
int MarkVisible(bool on_screen=false)
Set visibility flag for each nodes.
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 GetUsedNSegments(int min=20)
Returns really used number of cylindrical segments.
bool IsPrincipalEndNode(int nodeid)
return true when node used in main geometry drawing and does not have childs for such nodes one could...
const std::vector< int > & GetSelectedStack() const
Get top node path.
bool SetSearch(const std::string &query, const std::string &json)
Change search query and belongs to it json string Returns true if any parameter was really changed.
std::vector< RGeomNodeVisibility > fVisibility
! custom visibility flags for physical nodes
bool SetHighlightedItem(const std::vector< int > &stack)
void SetPreferredOffline(bool on)
Set preference of offline operations.
bool SelectTop(const std::vector< std::string > &path)
Select top node by path Used by the client to change active node Returns true if selected node was ch...
int GetMaxVisNodes() const
Returns maximal visible number of nodes, ignored when non-positive.
int GetVisLevel() const
Returns maximal visible level.
int GetMaxVisFaces() const
Returns maximal visible number of faces, ignored when non-positive.
void ClearCache()
Clear cached data, need to be clear when connection broken.
std::string GetDrawJson() const
virtual void RefineGeoItem(RGeoItem &item, const std::vector< int > &stack)
Method which allows to add/modify information in RGeoItem which will be provided to client - like tit...
void ClearDescription()
Clear geometry description.
std::vector< int > MakeStackByIds(const std::vector< int > &ids)
Creates stack for given array of ids, first element always should be 0.
void SetMaxVisFaces(int cnt)
Set maximal number of faces which should be selected for drawing.
bool IsPreferredOffline() const
Is offline operations preferred.
std::vector< ShapeDescr > fShapes
! shapes with created descriptions
std::string GetSearch() const
int fJsonComp
! default JSON compression
bool ChangeNodeVisibility(const std::vector< std::string > &path, bool on)
Change visibility for specified element Returns true if changes was performed.
void SetMutex(TVirtualMutex *mutex)
Set mutex, it must be recursive one.
std::string fSearch
! search string in hierarchy
std::string fSearchJson
! drawing json for search
void SavePrimitive(std::ostream &fs, const std::string &name)
Save geometry configuration as C++ macro.
std::vector< int > fHighlightedStack
! highlighted element by stack
bool ClearAllPhysVisibility()
Reset all custom visibility settings.
std::string MakeDrawingJson(RGeomDrawing &drawing, bool has_shapes=false)
Produce JSON for the drawing If TGeoShape appears in the drawing, one has to keep typeinfo But in thi...
int fActualLevel
! level can be reduced when selecting nodes
TGeoVolume * GetVolume(int nodeid)
Get volume for specified nodeid If specific volume was configured, it will be returned for nodeid==0.
bool SetActiveItem(const std::string &itemname)
int GetNumNodes() const
Number of unique nodes in the geometry.
void SetTopVisible(bool on=true)
Set draw options as string for JSROOT TGeoPainter.
void ProduceDrawData()
Collect all information required to draw geometry on the client This includes list of each visible no...
void SetNSegments(int n=0)
Set number of segments for cylindrical shapes, if 0 - default value will be used.
bool GetTopVisible() const
Returns draw options, used for JSROOT TGeoPainter.
bool SetPhysNodeVisibility(const std::vector< std::string > &path, bool on=true)
Set visibility of physical node by path It overrules TGeo visibility flags - but only for specific ph...
bool ClearPhysNodeVisibility(const std::vector< std::string > &path)
Reset custom visibility of physical node by path.
void BuildDescription(TGeoNode *topnode, TGeoVolume *topvolume)
Build geometry description.
int SearchVisibles(const std::string &find, std::string &hjson, std::string &json)
Search visible nodes for provided name If number of found elements less than 100, create description ...
std::vector< int > fSortMap
! nodes in order large -> smaller volume
std::string ProduceJson(bool all_nodes=false)
Produce JSON string which can be directly used with build function from JSROOT to create three....
void ClearDrawData()
Clear drawing data.
std::vector< std::string > MakePathByStack(const std::vector< int > &stack)
Returns path string for provided stack.
TVirtualMutex * fMutex
! external mutex used to protect all data
void AddSignalHandler(const void *handler, RGeomSignalFunc_t func)
Add signal handler.
bool ChangeConfiguration(const std::string &json)
Change configuration by client Returns true if any parameter was really changed.
void CopyMaterialProperties(TGeoVolume *vol, RGeomNode &node)
Copy material properties.
std::vector< int > GetClickedItem() const
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.
int ScanNodes(bool only_visible, int maxlvl, RGeomScanFunc_t func)
Iterate over all nodes and call function for visible.
int IsBuildShapes() const
Returns true if binary 3D model build already by C++ server (default)
void ProduceSearchData()
Produces search data if necessary.
TVirtualMutex * GetMutex() const
Return currently used mutex.
void SetJsonComp(int comp=0)
Set JSON compression level for data transfer.
void SetBuildShapes(int lvl=1)
Instruct to build binary 3D model already on the server (true) or send TGeoShape as is to client,...
void CollectNodes(RGeomDrawing &drawing, bool all_nodes=false)
Collect nodes which are used in visibles.
int fDrawIdCut
! sortid used for selection of most-significant nodes
TGeoVolume * fDrawVolume
! select volume independent from TGeoManager
int CountShapeFaces(TGeoShape *shape)
Count number of faces for the shape.
ShapeDescr & MakeShapeDescr(TGeoShape *shape)
Find description object and create render information.
bool fPreferredOffline
! indicates that full description should be provided to client
void _ClearDrawData()
clear drawing data without locking mutex
virtual ~RGeomDescription()=default
void SetDrawOptions(const std::string &opt="")
Set draw options as string for JSROOT TGeoPainter.
ShapeDescr & FindShapeDescr(TGeoShape *shape)
Find description object for requested shape If not exists - will be created.
std::vector< int > GetHighlightedItem() const
std::string fDrawJson
! JSON with main nodes drawn by client
void RemoveSignalHandler(const void *handler)
Remove signal handler.
int FindNodeId(const std::vector< int > &stack)
Returns nodeid for given stack array, returns -1 in case of failure.
void ProduceIdShifts()
Count total number of visible childs under each node.
std::string ProduceModifyReply(int nodeid)
Return string with only part of nodes description which were modified Checks also volume.
std::string fActiveItemName
! name of item which should be activated in hierarchy
std::string GetActiveItem() const
void ResetRndrInfos()
Reset shape info, which used to pack binary data.
std::string GetSearchJson() const
int GetNSegments() const
Return of segments for cylindrical shapes, if 0 - default value will be used.
std::string GetDrawOptions() const
Returns draw options, used for JSROOT TGeoPainter.
std::vector< TGeoNode * > fNodes
! flat list of all nodes
int GetJsonComp() const
Returns JSON compression level for data transfer.
virtual bool IsFullModelStreamedAtOnce() const
Decide if the whole model is streamed at once Function is called from ProcessBrowserRequest.
void Build(TGeoManager *mgr, const std::string &volname="")
Collect information about geometry hierarchy into flat list like it done in JSROOT ClonedNodes....
std::vector< int > fClickedStack
! clicked element by stack
bool SetClickedItem(const std::vector< int > &stack)
Object with full description for drawing geometry It includes list of visible items and list of nodes...
int numnodes
total number of nodes in description
std::vector< RGeomVisible > visibles
all visible items
RGeomConfig * cfg
current configurations
std::vector< RGeomNode * > nodes
all used nodes to display visible items and not known for client
Base description of geometry node, required only to build hierarchy.
Definition RGeomData.hxx:41
bool IsVisible() const
Definition RGeomData.hxx:55
int vis
visibility flag, 0 - off, 1 - only when level==0, 99 - always
Definition RGeomData.hxx:46
std::string material
name of the material
Definition RGeomData.hxx:50
RGeomNodeBase(int _id=0)
Definition RGeomData.hxx:53
int sortid
! place in sorted array, to check cuts, or id of original node when used search structures
Definition RGeomData.hxx:51
bool nochlds
how far in hierarchy depth should be scanned
Definition RGeomData.hxx:47
std::string color
rgb code in hex format
Definition RGeomData.hxx:49
std::vector< int > chlds
list of childs id
Definition RGeomData.hxx:45
std::string name
node name
Definition RGeomData.hxx:44
const char * GetArg(int kind)
Returns argument for regexp.
Definition RGeomData.hxx:58
Node information including rendering data.
std::string shape_name
shape class name (if any)
std::string node_type
node class name
std::string node_name
node name
RGeomRenderInfo * ri
rendering information (if applicable)
std::string shape_type
shape type (if any)
std::vector< std::string > path
full path to node
Custom settings for physical Node visibility.
RGeomNodeVisibility(const std::vector< int > &_stack, bool _visible)
bool visible
visible flag
std::vector< int > stack
path to the node
Full node description including matrices and other attributes.
Definition RGeomData.hxx:68
float opacity
! opacity of the color
Definition RGeomData.hxx:75
int idshift
! used to jump over then scan all geom hierarchy
Definition RGeomData.hxx:73
double vol
! volume estimation
Definition RGeomData.hxx:71
bool useflag
! extra flag, used for selection
Definition RGeomData.hxx:74
std::vector< float > matr
matrix for the node, can have reduced number of elements
Definition RGeomData.hxx:70
RGeomNode(int _id=0)
Definition RGeomData.hxx:77
int nfaces
! number of shape faces
Definition RGeomData.hxx:72
bool CanDisplay() const
True when there is shape and it can be displayed.
Definition RGeomData.hxx:80
Render info with raw data.
std::vector< int > idx
vertex indexes, always triangles
std::vector< unsigned char > raw
float vertices as raw data, JSON_base64
~RGeomRawRenderInfo() override=default
Base class for render info block.
virtual ~RGeomRenderInfo()=default
virtual destructor required for the I/O
Render info with shape itself - client can produce shape better.
TGeoShape * shape
original shape - can be much less than binary data
~RGeomShapeRenderInfo() override=default
RGeomVisible contains description of visible node It is path to the node plus reference to shape rend...
int seqid
sequence id, used for merging later
std::string color
color in rgb format
RGeomVisible(int _nodeid, int _seqid, const std::vector< int > &_stack)
RGeomRenderInfo * ri
render information for the shape, can be same for different nodes
double opacity
opacity
int nodeid
selected node id,
RGeomVisible()=default
std::vector< int > stack
path to the node, index in list of childs
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
Geometrical transformation package.
Definition TGeoMatrix.h:39
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
Base abstract class for all shapes.
Definition TGeoShape.h:25
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
This class implements a mutex interface.
const Int_t n
Definition legend1.C:16
RLogChannel & RGeomLog()
Log channel for Geomviewer diagnostics.
Definition RGeomData.cxx:49
std::function< bool(RGeomNode &, std::vector< int > &, bool, int)> RGeomScanFunc_t
std::function< void(const std::string &)> RGeomSignalFunc_t