Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TCanvasWidget.cpp
Go to the documentation of this file.
1// Author: Sergey Linev, GSI 13/01/2021
2
3/*************************************************************************
4 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#include "TCanvasWidget.h"
12
13#include "TCanvas.h"
14#include "TROOT.h"
15#include "TClass.h"
16#include "TEnv.h"
17
18#include "TWebCanvas.h"
19
21{
22 setObjectName("TCanvasWidget");
23
24 setSizeIncrement(QSize(100, 100));
25
27 setMouseTracking(true);
28
29 setFocusPolicy(Qt::TabFocus);
30 setCursor(Qt::CrossCursor);
31
32 setAcceptDrops(true);
33
34 static int wincnt = 1;
35
36 auto name = TString::Format("Canvas%d", wincnt++);
37
39
40 auto web = static_cast<TWebCanvas *> (fCanvas->GetCanvasImp());
41
42 web->SetCanCreateObjects(kFALSE); // not yet create objects on server side
43
44 web->SetUpdatedHandler([this]() { emit CanvasUpdated(); });
45
46 web->SetActivePadChangedHandler([this](TPad *pad) { emit SelectedPadChanged(pad); });
47
48 web->SetPadClickedHandler([this](TPad *pad, int x, int y) { emit PadClicked(pad, x, y); });
49
50 web->SetPadDblClickedHandler([this](TPad *pad, int x, int y) { emit PadDblClicked(pad, x, y); });
51
53
54 web->ShowWebWindow(where);
55
56 fView = findChild<QWebEngineView *>("RootWebView");
57 if (!fView) {
58 printf("FAIL TO FIND QWebEngineView - ROOT Qt5Web plugin does not work properly !!!!!\n");
59 exit(11);
60 }
61
62 fView->resize(width(), height());
64}
65
67{
68 if (fCanvas) {
69 gROOT->GetListOfCanvases()->Remove(fCanvas);
70
71 fCanvas->SetCanvasImp(nullptr);
72
73 fCanvas->Close();
74 delete fCanvas;
75 fCanvas = nullptr;
76 }
77}
78
80{
81 fView->resize(width(), height());
83}
84
86{
87 TWebCanvas *cimp = dynamic_cast<TWebCanvas *>(fCanvas->GetCanvasImp());
88 if (cimp) {
89 cimp->ShowEditor(kTRUE);
90 cimp->ActivateInEditor(pad, obj);
91 }
92}
93
95{
97 if (cimp)
98 cimp->ShowEditor(flag);
99}
100
102{
104 if (cimp)
105 cimp->ShowStatusBar(kTRUE);
106}
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:406
static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt="", unsigned qtversion=0x50000)
Returns string which can be used as argument in RWebWindow::Show() method to display web window in pr...
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:30
TCanvas * fCanvas
void SelectedPadChanged(TPad *)
void PadDblClicked(TPad *, int, int)
void resizeEvent(QResizeEvent *event) override
virtual ~TCanvasWidget()
QWebEngineView * fView
qt webwidget to show
TCanvasWidget(QWidget *parent=nullptr)
void activateEditor(TPad *pad=nullptr, TObject *obj=nullptr)
void PadClicked(TPad *, int, int)
void setEditorVisible(bool flag=true)
void activateStatusLine()
void CanvasUpdated()
TCanvasImp * GetCanvasImp() const override
Definition TCanvas.h:158
void Close(Option_t *option="") override
Close canvas.
Definition TCanvas.cxx:788
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2160
void SetCanvasSize(UInt_t ww, UInt_t wh) override
Set Width and Height of canvas to ww and wh respectively.
Definition TCanvas.cxx:1950
Mother of all ROOT objects.
Definition TObject.h:41
The most important graphics class in the ROOT system.
Definition TPad.h:28
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
Basic TCanvasImp ABI implementation for Web-based Graphics Provides painting of main ROOT classes in ...
Definition TWebCanvas.h:35
static TCanvas * CreateWebCanvas(const char *name, const char *title, UInt_t width=1200, UInt_t height=800)
Create TCanvas and assign TWebCanvas implementation to it Canvas is not displayed automatically,...
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17