20 #include "THttpServer.h"
24 #include <QGridLayout>
25 #include <QApplication>
32 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,23,0)
34 #include "TWebCanvas.h"
45 #if QT_VERSION > QT_VERSION_CHECK(5,6,0)
47 fQtScalingfactor = (double) metric(QPaintDevice::PdmDevicePixelRatioScaled)/65536.;
50 setObjectName(
"QWebCanvas");
52 setSizeIncrement( QSize( 100, 100 ) );
54 setUpdatesEnabled(
true );
55 setMouseTracking(
true);
57 setFocusPolicy( Qt::TabFocus );
58 setCursor( Qt::CrossCursor );
72 QGridLayout *gridLayout =
new QGridLayout(
this);
73 gridLayout->setSpacing(10);
74 gridLayout->setContentsMargins(1,1,1,1);
87 static int wincnt = 1;
90 fCanvas->SetName(Form(
"Canvas%d", wincnt++));
92 fCanvas->ResetBit(TCanvas::kShowEditor);
98 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,23,0)
99 TWebCanvas *web =
new TWebCanvas(
fCanvas,
"title", 0, 0, 800, 600, kFALSE);
105 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,19,0)
108 static std::string go4script;
110 if (go4script.empty()) {
112 go4script = THttpServer::ReadFileContent(fname.Data());
115 web->SetCustomScripts(go4script);
116 web->AddCustomClass(
"TGo4Marker");
117 web->AddCustomClass(
"TGo4Condition",
true);
118 web->AddCustomClass(
"TGo4CondArray");
123 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,26,0)
124 web->SetAsyncMode(kTRUE);
141 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
142 ROOT::Experimental::RWebDisplayArgs args(
"qt6");
144 ROOT::Experimental::RWebDisplayArgs args(
"qt5");
146 args.SetDriverData(
this);
147 args.SetUrlOpt(
"noopenui");
149 web->ShowWebWindow(args);
151 fView = findChild<QWebEngineView*>(
"RootWebView");
153 printf(
"FAIL TO FIND QWebEngineView - ROOT Qt5Web plugin does not work properly !!!!!\n");
157 gridLayout->addWidget(
fView);
159 QObject::connect(
fView, SIGNAL(drop(QDropEvent*)),
this, SLOT(
dropView(QDropEvent*)));
169 gROOT->GetListOfCanvases()->Remove(
fCanvas);
179 Long_t offset = TCanvas::Class()->GetDataMemberOffset(
"fCanvasID");
181 Int_t *
id = (Int_t *)((
char*)
fCanvas + offset);
182 if (*
id ==
fCanvas->GetCanvasID()) *
id = on_init ? 111222333 : -1;
184 printf(
"ERROR: Cannot modify TCanvas::fCanvasID data member\n");
187 offset = TCanvas::Class()->GetDataMemberOffset(
"fPixmapID");
189 Int_t *
id = (Int_t *)((
char*)
fCanvas + offset);
190 if (*
id ==
fCanvas->GetPixmapID()) *
id = on_init ? 332211 : -1;
192 printf(
"ERROR: Cannot modify TCanvas::fPixmapID data member\n");
195 offset = TCanvas::Class()->GetDataMemberOffset(
"fMother");
197 TPad **moth = (TPad **)((
char*)
fCanvas + offset);
198 if (*moth ==
fCanvas->GetMother()) *moth = on_init ?
fCanvas :
nullptr;
200 printf(
"ERROR: Cannot set TCanvas::fMother data member\n");
218 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
219 QPoint pos =
event->pos();
221 QPoint pos =
event->position().toPoint();
225 printf(
"Drop on pad %s\n", pad ? pad->GetName() :
"---");
233 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
234 QPoint pos =
event->pos();
236 QPoint pos =
event->position().toPoint();
240 printf(
"Drop on view %s\n", pad ? pad->GetName() :
"---");
247 TWebCanvas *cimp =
dynamic_cast<TWebCanvas*
> (
fCanvas->GetCanvasImp());
249 cimp->ShowEditor(kTRUE);
250 cimp->ActivateInEditor(pad, obj);
256 return fCanvas->GetShowEventStatus();
261 return fCanvas->GetShowEditor();
266 if (
fCanvas->GetShowEventStatus() != flag)
272 TCanvasImp *cimp =
fCanvas->GetCanvasImp();
273 if (cimp) cimp->ShowEditor(flag);
278 TCanvasImp *cimp =
fCanvas->GetCanvasImp();
279 if (cimp) cimp->ShowStatusBar(kTRUE);
void SetPadDblClickedHandler(PadClickedSignal_t func)
void SetActivePadChangedHandler(PadSignal_t func)
void activateStatusLine()
bool isStatusBarVisible()
void ProcessPadDblClicked(TPad *pad, int x, int y)
virtual void dropEvent(QDropEvent *event)
QWebEngineView * fView
qt webwidget to show
void activateEditor(TPad *pad=0, TObject *obj=0)
QWebCanvas(QWidget *parent=0)
void ProcessCanvasUpdated()
void ProcessActivePadChanged(TPad *pad)
void dropView(QDropEvent *event)
void setEditorVisible(bool flag=true)
virtual void resizeEvent(QResizeEvent *event)
static TString subGO4SYS(const char *subdir)
void SetCanCreateObjects(Bool_t on=kTRUE)
void SetPadClickedHandler(PadClickedSignal_t func)
void CanvasDropEvent(QDropEvent *, TPad *)
double scaledPosition(int p)
void processRepaintTimer()
void setStatusBarVisible(bool flag=true)
void SetPrivateCanvasFields(bool on_init)
void ProcessPadClicked(TPad *pad, int x, int y)