User class with custom JavaScript painter in the web canvas.
#include <iostream>
double fX[3] = {0, 0, 0};
double fY[3] = {0, 0, 0};
public:
TTriangle() {}
TTriangle(
const char *
name,
const char *title =
"") :
TNamed(
name, title) {}
void SetPoints(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
{
fX[2] = x3;
fY[2] = y3;
}
{
return;
if (*opt == 'f')
gPad->PaintFillAreaNDC(3, fX, fY, opt);
else
gPad->PaintPolyLineNDC(3, fX, fY, opt);
}
};
void triangle(bool ignore_jsmodule = false)
{
if (ignore_jsmodule) {
printf("Custom JS module will NOT be provided for TTriangle class\n");
printf("No interactive features will be available\n");
printf("TTriangle::Paint() method will be used for object painting - also in web case\n");
} else {
#ifdef __CLING__
printf("Please run this script in compiled mode by running \".x triangle.cxx+\"\n");
printf("Requires to properly generate dictionary for TTriangle class\n");
return;
#endif
std::string fdir = __FILE__;
auto pos = fdir.find("triangle.cxx");
if (pos != std::string::npos)
fdir.resize(pos);
else
fdir =
gROOT->GetTutorialsDir() + std::string(
"/webcanv/");
}
auto tr1 = new TTriangle("tr1", "first triangle");
tr1->SetPoints(0.4, 0.5, 0.8, 0.3, 0.8, 0.7);
tr1->SetLineWidth(3);
tr1->SetFillColor(
kBlue);
auto tr2 = new TTriangle("tr2", "second triangle");
tr2->SetPoints(0.2, 0.2, 0.2, 0.6, 0.5, 0.4);
auto tr3 = new TTriangle("tr3", "third triangle");
tr3->SetPoints(0.4, 0.8, 0.6, 0.8, 0.5, 0.2);
tr3->SetLineColor(
kCyan);
}
#define ClassDefOverride(name, id)
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
static void AddServerLocation(const std::string &server_prefix, const std::string &files_path)
Configure server location which can be used for loading of custom scripts or files When THttpServer i...
Fill Area Attributes class.
virtual void Modify()
Change current fill area attributes if necessary.
virtual void Modify()
Change current line attributes if necessary.
The TNamed class is the base class for all named ROOT classes.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
static void AddCustomClass(const std::string &clname, bool with_derived=false)
Assign custom class.
static void SetCustomScripts(const std::string &src)
Configures custom script for canvas.