Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TQt6Canvas.cxx
Go to the documentation of this file.
1// Author: Sergey Linev, GSI 26/06/2026
2
3/*************************************************************************
4 * Copyright (C) 1995-2026, 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 "TQt6Canvas.h"
12
13#include "TQt6PadPainter.h"
14#include "TQt6Application.h"
15
16#include "TSystem.h"
17#include "TStyle.h"
18#include "TCanvas.h"
19#include "TROOT.h"
20#include "TClass.h"
21
22#include <cstdio>
23#include <cstring>
24#include <iostream>
25#include <memory>
26
27#include "QCanvasWidget.h"
28
29using namespace ROOT::Experimental;
30
31/** \class TQt6Canvas
32 \ingroup qt6canvas
33 \brief Basic TCanvasImp ABI implementation for Qt6
34*/
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor
38
39TQt6Canvas::TQt6Canvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height)
41{
42}
43
44
45////////////////////////////////////////////////////////////////////////////////
46/// Destructor
47
49{
50 // delete fTimer;
51}
52
53
54////////////////////////////////////////////////////////////////////////////////
55/// Initialize window for the qt6 canvas
56
58{
59 return 111222333; // should not be used at all
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Creates pad painter
64
69
70
71//////////////////////////////////////////////////////////////////////////////////////////
72/// Close qt6 canvas - not implemented
73
75{
76}
77
78//////////////////////////////////////////////////////////////////////////////////////////
79/// Show qt6 canvas
80
82{
83}
84
85//////////////////////////////////////////////////////////////////////////////////////////
86/// Returns kTRUE if web canvas has graphical editor
87
92
93//////////////////////////////////////////////////////////////////////////////////////////
94/// Returns kTRUE if web canvas has menu bar
95
97{
98 return (fClientBits & TCanvas::kMenuBar) != 0;
99}
100
101//////////////////////////////////////////////////////////////////////////////////////////
102/// Returns kTRUE if web canvas has status bar
103
108
109//////////////////////////////////////////////////////////////////////////////////////////
110/// Returns kTRUE if tooltips are activated in web canvas
111
116
117//////////////////////////////////////////////////////////////////////////////////////////
118/// Set window position of web canvas
119
125
126//////////////////////////////////////////////////////////////////////////////////////////
127/// Set window size of web canvas
128
130{
131 if (fCanvasWidget)
132 fCanvasWidget->resize(w, h);
133}
134
135//////////////////////////////////////////////////////////////////////////////////////////
136/// Set window title of web canvas
137
139{
140 if (fCanvasWidget)
141 fCanvasWidget->setWindowTitle(QString::fromLatin1(newTitle));
142}
143
144//////////////////////////////////////////////////////////////////////////////////////////
145/// Set canvas size
146
148{
150 if ((cw > 0) && (ch > 0)) {
151 // Canvas()->fCw = cw;
152 // Canvas()->fCh = ch;
153 } else {
154 // temporary value, will be reported back from client
155 // Canvas()->fCw = Canvas()->fWindowWidth;
156 // Canvas()->fCh = Canvas()->fWindowHeight;
157 }
158}
159
160//////////////////////////////////////////////////////////////////////////////////////////
161/// Iconify browser window
162
164{
165 if (fCanvasWidget)
166 fCanvasWidget->showMinimized();
167}
168
169//////////////////////////////////////////////////////////////////////////////////////////
170/// Raise browser window
171
173{
174 if (fCanvasWidget) {
175 fCanvasWidget->showNormal();
176 fCanvasWidget->raise();
177 fCanvasWidget->activateWindow();
178 }
179}
180
181//////////////////////////////////////////////////////////////////////////////////////////
182/// Assign clients bits
183
195
196//////////////////////////////////////////////////////////////////////////////////////////
197/// Returns canvas geometry
198
200{
201 (void) wid;
202 if (fPaintWidget) {
203 w = fPaintWidget->width();
204 h = fPaintWidget->height();
205 } else {
206 w = 780;
207 h = 580;
208 }
209}
210
211
212//////////////////////////////////////////////////////////////////////////////////////////
213/// Returns window geometry including borders and menus
214
216{
217 if (fCanvasWidget) {
218 auto pos = fCanvasWidget->pos();
219 x = pos.x();
220 y = pos.y();
221 w = fCanvasWidget->width();
222 h = fCanvasWidget->height();
223 } else {
224 x = y = 0;
225 w = 800;
226 h = 600;
227 }
228
229 return 0;
230}
231
232//////////////////////////////////////////////////////////////////////////////////////////
233/// if canvas or any subpad was modified,
234/// invoke Qt update() which will redraw area
235
237{
238 if (Canvas()->IsModified() && fPaintWidget)
239 fPaintWidget->update();
240 return kTRUE;
241}
242
243//////////////////////////////////////////////////////////////////////////////////////////
244/// Increment canvas version and force sending data to client - do not wait for reply
245
247{
248}
249
250//////////////////////////////////////////////////////////////////////////////////////////////////
251/// Static method to create TQt6Canvas instance
252/// Used by plugin manager to directly create TQt6Canvas without gui factory
253
255{
256 // ensure QApplication is exists
258
259 auto widget = new QCanvasWidget();
260 widget->setWindowTitle(QString(c->GetTitle()));
261 if ((x < 0) && (y < 0))
262 widget->resize(width, height);
263 else
264 widget->setGeometry(x, y, width, height);
265 widget->show();
266
267 auto imp = new TQt6Canvas(c, name, x, y, width, height);
268
269 imp->fCanvasWidget = widget;
270 imp->fPaintWidget = widget->GetPaintWidget();
271
272 if (imp->fPaintWidget)
273 imp->fPaintWidget->SetCanvas(c);
274
275 // set all internal dimensions
276 c->Resize();
277
278 // TODO: maybe apply same logic to adjust canvas dimension as in TRootCanvas
279 // Keep commented code here intentionally to be able find this place when
280 // search for correspondent class members
281
282 // c->fWindowTopX = x;
283 // c->fWindowTopY = y;
284 // c->fWindowWidth = width;
285 // c->fWindowHeight = height;
286 // if (!gROOT->IsBatch() && (height > 25))
287 // height -= 25;
288 // c->fCw = width;
289 // c->fCh = height;
290
291 return imp;
292}
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
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:142
Qt widget which display canvas and provides menu, toolbar and status bar Actual graphics shown in the...
void ApplyCanvasStatusBits()
Apply canvas status bits like show tooltip or menu bar.
static void CreateQApplication(int argc=0, char **argv=nullptr)
Create QApplication and timer to handle Qt events.
void Close() override
Close qt6 canvas - not implemented.
TQt6Canvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height)
Constructor.
void SetWindowSize(UInt_t w, UInt_t h) override
Set window size of web canvas.
void SetCanvasSize(UInt_t w, UInt_t h) override
Set canvas size.
void ForceUpdate() override
Increment canvas version and force sending data to client - do not wait for reply.
Int_t InitWindow() override
Initialize window for the qt6 canvas.
UInt_t fClientBits
! latest status bits from client like editor visible or not
Definition TQt6Canvas.h:32
void Iconify() override
Iconify browser window.
void Show() override
Show qt6 canvas.
~TQt6Canvas() override
Destructor.
void AssignStatusBits(UInt_t bits)
Assign clients bits.
Bool_t HasMenuBar() const override
Returns kTRUE if web canvas has menu bar.
UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override
Returns window geometry including borders and menus.
static TCanvasImp * NewCanvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height)
Static method to create TQt6Canvas instance Used by plugin manager to directly create TQt6Canvas with...
Bool_t HasEditor() const override
Returns kTRUE if web canvas has graphical editor.
void SetWindowTitle(const char *newTitle) override
Set window title of web canvas.
Bool_t PerformUpdate(Bool_t async) override
if canvas or any subpad was modified, invoke Qt update() which will redraw area
void GetCanvasGeometry(Int_t wid, UInt_t &w, UInt_t &h) override
Returns canvas geometry.
Bool_t HasToolTips() const override
Returns kTRUE if tooltips are activated in web canvas.
Bool_t HasStatusBar() const override
Returns kTRUE if web canvas has status bar.
TVirtualPadPainter * CreatePadPainter() override
Creates pad painter.
void SetWindowPosition(Int_t x, Int_t y) override
Set window position of web canvas.
void RaiseWindow() override
Raise browser window.
QCanvasWidget * fCanvasWidget
Definition TQt6Canvas.h:28
Bool_t fFixedSize
! true when fixed-size canvas is configured
Definition TQt6Canvas.h:31
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:31
TCanvas * Canvas() const
Definition TCanvasImp.h:59
The Canvas class.
Definition TCanvas.h:23
@ kShowToolTips
Definition TCanvas.h:101
@ kShowToolBar
Definition TCanvas.h:96
@ kShowEventStatus
Definition TCanvas.h:93
@ kMenuBar
Definition TCanvas.h:95
@ kShowEditor
Definition TCanvas.h:97
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Namespace for ROOT features in testing.
Definition TROOT.h:100