27using namespace std::string_literals;
36 if (!
gROOT->IsWebDisplayBatch()) {
38 fWebWindow->SetDefaultPage(
"file:rootui5sys/geom/index.html");
107 std::string user_args =
"";
114 if ((
fWebWindow->NumConnections(
true) == 0) || always_start_new_browser)
142 std::vector<int> *stack{
nullptr}, res;
207 if (
json.find(
"GDRAW:") != 0) {
208 printf(
"GDRAW missing!!!!\n");
222 if (arg ==
"GETDRAW") {
226 }
else if (arg ==
"QUIT_ROOT") {
230 }
else if (arg.compare(0, 7,
"SEARCH:") == 0) {
232 std::string query = arg.substr(7);
234 std::string hjson,
json;
244 }
else if (arg.compare(0,4,
"GET:") == 0) {
251 std::string
json{
"SHAPE:"};
257 }
else if (arg.compare(0, 6,
"GVREQ:") == 0) {
259 auto req = TBufferJSON::FromJSON<RGeomRequest>(arg.substr(6));
261 if (req && (req->oper ==
"HOVER")) {
262 if ((req->path.size() > 0 ) && (req->path[0] !=
"OFF"))
265 }
else if (req && (req->oper ==
"HIGHL")) {
266 if (req->stack.size() > 0)
269 }
else if (req && (req->oper ==
"INFO")) {
285 }
else if ((arg.compare(0, 7,
"SETVI0:") == 0) || (arg.compare(0, 7,
"SETVI1:") == 0)) {
288 auto nodeid = std::stoi(arg.substr(7));
290 bool selected = (arg[5] ==
'1');
304 std::string
json{
"APPND:"};
308 }
else if (selected) {
320 }
else if (arg.compare(0,6,
"BRREQ:") == 0) {
328 }
else if (arg.compare(0,6,
"IMAGE:") == 0) {
329 auto separ = arg.find(
"::",6);
330 if (separ == std::string::npos)
return;
332 std::string fname = arg.substr(6, separ-6);
337 if (cnt++>0) fname += std::to_string(cnt);
344 std::ofstream ofs(fname);
348 printf(
"Image file %s size %d has been created\n", fname.c_str(), (
int) binary.
Length());
350 }
else if (arg.compare(0,4,
"CFG:") == 0) {
355 }
else if (arg ==
"RELOAD") {
#define R__LOG_ERROR(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
R__EXTERN TSystem * gSystem
std::string ProcessBrowserRequest(const std::string &req="")
Find description object for requested shape If not exists - will be created.
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...
int GetJsonComp() const
Returns JSON compression level for data transfer.
bool IsPrincipalEndNode(int nodeid)
return true when node used in main geometry drawing and does not have childs for such nodes one could...
std::vector< int > MakeStackByIds(const std::vector< int > &ids)
Creates stack for given array of ids, first element always should be 0.
const std::string & GetDrawJson() const
std::unique_ptr< RGeomNodeInfo > MakeNodeInfo(const std::vector< std::string > &path)
Change visibility for specified element Returns true if changes was performed.
void ProduceDrawData()
Collect all information required to draw geometry on the client This includes list of each visible no...
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< std::string > MakePathByStack(const std::vector< int > &stack)
Returns path string for provided stack.
bool ChangeConfiguration(const std::string &json)
Change configuration by client Returns true if any parameter was really changed.
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 SetBuildShapes(int lvl=1)
Instruct to build binary 3D model already on the server (true) or send TGeoShape as is to client,...
void SetPreferredOffline(bool on)
Set preference of offline operations.
int FindNodeId(const std::vector< int > &stack)
Returns nodeid for given stack array, returns -1 in case of failure.
bool ChangeNodeVisibility(int nodeid, bool selected)
Change visibility for specified element Returns true if changes was performed.
std::string ProduceModifyReply(int nodeid)
Return string with only part of nodes description which were modified Checks also volume.
void SetDrawOptions(const std::string &opt="")
Set draw options as string for JSROOT TGeoPainter.
void SetJsonComp(int comp=0)
Set JSON compression level for data transfer.
void Build(TGeoManager *mgr, const std::string &volname="")
Collect information about geometry hierarchy into flat list like it done in JSROOT ClonedNodes....
RGeomViewer(TGeoManager *mgr=nullptr, const std::string &volname="")
constructor
void Show(const RWebDisplayArgs &args="", bool always_start_new_browser=false)
Show or update geometry in web window If web browser already started - just refresh drawing like "rel...
void SetGeometry(TGeoManager *mgr, const std::string &volname="")
assign new geometry to the viewer
std::vector< int > GetStackFromJson(const std::string &json, bool node_ids=false)
convert JSON into stack array
virtual ~RGeomViewer()
destructor
std::shared_ptr< RWebWindow > fWebWindow
! web window to show geometry
std::string GetWindowAddr() const
Return URL address of web window used for geometry viewer.
std::string fSelectedVolume
! name of selected volume
void Update()
Update geometry drawings in all web displays.
bool GetShowHierarchy() const
Returns default hierarchy browser visibility.
void SetDrawOptions(const std::string &opt)
Configures draw option for geometry Normally has effect before first drawing of the geometry When geo...
TGeoManager * fGeoManager
! geometry to show
RGeomDescription fDesc
! geometry description, send to the client as first message
void SendGeometry(unsigned connid)
Send data for principal geometry draw.
void WebWindowCallback(unsigned connid, const std::string &arg)
receive data from client
void SetOnlyVolume(TGeoVolume *vol)
Draw only specified volume, special case when volume stored without valid geomanager.
void SelectVolume(const std::string &volname)
Select visible top volume, all other volumes will be disabled.
void SaveImage(const std::string &fname="geometry.png", int width=0, int height=0)
Produce PNG image of the geometry If web-browser is shown and drawing completed, image is requested f...
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
const std::string & GetWidgetKind() const
returns widget kind
static bool ProduceImage(const std::string &fname, const std::string &json, int width=800, int height=600, const char *batch_file=nullptr)
Produce image file using JSON data as source Invokes JSROOT drawing functionality in headless browser...
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
static TString Decode(const char *data)
Decode a base64 string date into a generic TString.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
@ kSkipTypeInfo
do not store typenames in JSON
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
@ kSameSuppression
zero suppression plus compress many similar values together
static Bool_t FromJSON(T *&obj, const char *json)
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
The manager class for any TGeo geometry.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
const char * Data() const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
RLogChannel & RGeomLog()
Log channel for Eve diagnostics.