Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
server.cxx File Reference

Detailed Description

This tutorial demonstrates how three.js model for geometry can be created.

In server.cxx one uses RGeomDescription class from geometry viewer, which produces JSON data with all necessary information. Then RWebWindow is started and this information provided. In client.html one uses build function to create Object3D with geometry Then such object placed in three.js scene and rendered. Also simple animation is implemented

std::shared_ptr<ROOT::RWebWindow> window;
int counter{0};
void ProcessData(unsigned connid, const std::string &arg)
{
printf("Get msg %s \n", arg.c_str());
counter++;
if (arg == "get_text") {
// send arbitrary text message
window->Send(connid, TString::Format("Message%d", counter).Data());
} else if (arg == "get_binary") {
// send float array as binary
float arr[10];
for (int n = 0; n < 10; ++n)
arr[n] = counter;
window->SendBinary(connid, arr, sizeof(arr));
} else if (arg == "halt") {
// terminate ROOT
window->TerminateROOT();
}
}
void server()
{
// create window
// Detect macro file location to specify full path to the HTML file
std::string fname = __FILE__;
auto pos = fname.find("server.cxx");
if (pos > 0)
fname.resize(pos);
else
fname.clear();
fname.append("client.html");
// configure default html page
// either HTML code can be specified or just name of file after 'file:' prefix
window->SetDefaultPage("file:" + fname);
// this is call-back, invoked when message received from client
window->SetDataCallBack(ProcessData);
window->SetGeometry(300, 500); // configure predefined geometry
window->Show();
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
const Int_t n
Definition legend1.C:16
Author
Sergey Linev

Definition in file server.cxx.