28using namespace std::string_literals;
36 fWebWindow->SetDefaultPage(
"file:rootui5sys/eve7/geom.html");
65 fSelectedVolume = volname;
67 fDesc.Build(mgr, volname);
78 if (volname != fSelectedVolume)
79 SetGeometry(fGeoManager, volname);
89 std::string user_args =
"";
90 if (!GetShowHierarchy()) user_args =
"{ nobrowser: true }";
91 fWebWindow->SetUserArgs(user_args);
96 if ((fWebWindow->NumConnections(
true) == 0) || always_start_new_browser)
97 fWebWindow->Show(args);
107 if (!fWebWindow)
return "";
108 return fWebWindow->GetAddr();
116 fWebWindow->Send(0,
"RELOAD");
124 std::vector<int> *stack{
nullptr}, res;
127 if (node_ids) res = fDesc.MakeStackByIds(*stack);
142 if (!fDesc.HasDrawData())
143 fDesc.CollectVisibles();
145 auto &json = fDesc.GetDrawJson();
149 fWebWindow->Send(connid, json);
159 fDesc.SetDrawOptions(opt);
160 unsigned connid = fWebWindow->GetConnectionId();
162 fWebWindow->Send(connid,
"DROPT:"s + opt);
172 unsigned connid = fWebWindow->GetConnectionId();
174 fWebWindow->Send(connid,
"IMAGE:"s + fname);
182 printf(
"Recv %s\n", arg.substr(0,100).c_str());
184 if (arg ==
"GETDRAW") {
186 SendGeometry(connid);
188 }
else if (arg ==
"QUIT_ROOT") {
190 fWebWindow->TerminateROOT();
192 }
else if (arg.compare(0, 7,
"SEARCH:") == 0) {
194 std::string query = arg.substr(7);
196 std::string hjson, json;
198 auto nmatches = fDesc.SearchVisibles(query, hjson, json);
200 printf(
"Searches %s found %d hjson %d json %d\n", query.c_str(), nmatches, (
int) hjson.length(), (
int) json.length());
203 fWebWindow->Send(connid, hjson);
206 fWebWindow->Send(connid, json);
208 }
else if (arg.compare(0,4,
"GET:") == 0) {
211 auto stack = GetStackFromJson(arg.substr(4));
213 auto nodeid = fDesc.FindNodeId(stack);
215 std::string json{
"SHAPE:"};
217 fDesc.ProduceDrawingFor(nodeid, json);
219 printf(
"Produce shape for stack json %d\n", (
int) json.length());
221 fWebWindow->Send(connid, json);
223 }
else if (arg.compare(0, 6,
"GVREQ:") == 0) {
225 auto req = TBufferJSON::FromJSON<REveGeomRequest>(arg.substr(6));
227 if (req && (req->oper ==
"HOVER")) {
228 if ((req->path.size() > 0 ) && (req->path[0] !=
"OFF"))
229 req->stack = fDesc.MakeStackByPath(req->path);
231 }
else if (req && (req->oper ==
"HIGHL")) {
232 if (req->stack.size() > 0)
233 req->path = fDesc.MakePathByStack(req->stack);
235 }
else if (req && (req->oper ==
"INFO")) {
237 auto info = fDesc.MakeNodeInfo(req->path);
251 }
else if ((arg.compare(0, 7,
"SETVI0:") == 0) || (arg.compare(0, 7,
"SETVI1:") == 0)) {
254 auto nodeid = std::stoi(arg.substr(7));
256 bool selected = (arg[5] ==
'1');
258 if (fDesc.ChangeNodeVisibility(nodeid, selected)) {
261 std::string json0 = fDesc.ProduceModifyReply(nodeid);
264 fWebWindow->Send(connid, json0);
266 if (selected && fDesc.IsPrincipalEndNode(nodeid)) {
270 std::string json{
"APPND:"};
272 if (fDesc.ProduceDrawingFor(nodeid, json,
true)) {
274 printf(
"Send appending JSON %d\n", (
int) json.length());
276 fWebWindow->Send(connid, json);
278 }
else if (selected) {
284 auto json = fDesc.ProcessBrowserRequest();
285 if (json.length() > 0) fWebWindow->Send(connid, json);
287 SendGeometry(connid);
290 }
else if (arg.compare(0,6,
"BRREQ:") == 0) {
294 if (!fDesc.IsBuild()) fDesc.Build(fGeoManager);
296 auto json = fDesc.ProcessBrowserRequest(arg.substr(6));
297 if (json.length() > 0) fWebWindow->Send(connid, json);
298 }
else if (arg.compare(0,6,
"IMAGE:") == 0) {
299 auto separ = arg.find(
"::",6);
300 if (separ == std::string::npos)
return;
302 std::string fname = arg.substr(6, separ-6);
307 if (cnt++>0) fname += std::to_string(cnt);
314 std::ofstream ofs(fname);
318 printf(
"Image file %s size %d has been created\n", fname.c_str(), (
int) binary.
Length());
320 }
else if (arg.compare(0,4,
"CFG:") == 0) {
322 if (fDesc.ChangeConfiguration(arg.substr(4)))
323 SendGeometry(connid);
325 }
else if (arg ==
"RELOAD") {
327 SendGeometry(connid);
#define R__LOG_ERROR(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
R__EXTERN TSystem * gSystem
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 SetPreferredOffline(bool on)
Set preference of offline operations.
void SaveImage(const std::string &fname="geometry.png")
Produce PNG image of drawn geometry Drawing should be completed at the moment Executed asynchronous -...
void SelectVolume(const std::string &volname)
Select visible top volume, all other volumes will be disabled.
void Update()
Update geometry drawings in all web displays.
void SendGeometry(unsigned connid)
Send data for principal geometry draw.
std::string GetWindowAddr() const
Return URL address of web window used for geometry viewer.
std::shared_ptr< RWebWindow > fWebWindow
! web window to show geometry
REveGeomDescription fDesc
! geometry description, send to the client as first message
REveGeomViewer(TGeoManager *mgr=nullptr, const std::string &volname="")
constructor
void WebWindowCallback(unsigned connid, const std::string &arg)
receive data from client
std::vector< int > GetStackFromJson(const std::string &json, bool node_ids=false)
convert JSON into stack array
virtual ~REveGeomViewer()
destructor
void SetDrawOptions(const std::string &opt)
Configures draw option for geometry Normally has effect before first drawing of the geometry When geo...
void SetGeometry(TGeoManager *mgr, const std::string &volname="")
assign new geometry to the viewer
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...
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
const std::string & GetWidgetKind() const
returns widget kind
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.
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 & REveLog()
Log channel for Eve diagnostics.