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
138void TQt6Canvas::SetWindowTitle(const char *newTitle)
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/// Set cursor
162
164{
165 if (!fPaintWidget)
166 return;
167
168 switch(cursor) {
169 case kBottomLeft: fPaintWidget->setCursor(Qt::SizeBDiagCursor); break;
170 case kBottomRight: fPaintWidget->setCursor(Qt::SizeFDiagCursor); break;
171 case kTopLeft: fPaintWidget->setCursor(Qt::SizeFDiagCursor); break;
172 case kTopRight: fPaintWidget->setCursor(Qt::SizeBDiagCursor); break;
173 case kBottomSide: fPaintWidget->setCursor(Qt::SizeVerCursor); break;
174 case kLeftSide: fPaintWidget->setCursor(Qt::SizeHorCursor); break;
175 case kTopSide: fPaintWidget->setCursor(Qt::SizeVerCursor); break;
176 case kRightSide: fPaintWidget->setCursor(Qt::SizeHorCursor); break;
177 case kMove: fPaintWidget->setCursor(Qt::DragMoveCursor); break;
178 case kCross: fPaintWidget->setCursor(Qt::CrossCursor); break;
179 case kArrowHor: fPaintWidget->setCursor(Qt::SizeHorCursor); break;
180 case kArrowVer: fPaintWidget->setCursor(Qt::UpArrowCursor); break;
181 case kHand: fPaintWidget->setCursor(Qt::OpenHandCursor); break;
182 case kRotate: fPaintWidget->setCursor(Qt::ClosedHandCursor); break;
183 case kPointer: fPaintWidget->setCursor(Qt::ArrowCursor); break;
184 case kArrowRight: fPaintWidget->setCursor(Qt::SizeHorCursor); break;
185 case kCaret: fPaintWidget->setCursor(Qt::WaitCursor); break;
186 case kWatch: fPaintWidget->setCursor(Qt::WaitCursor); break;
187 case kNoDrop: fPaintWidget->setCursor(Qt::ForbiddenCursor); break;
188 default:
189 fPaintWidget->unsetCursor();
190 }
191}
192
193
194//////////////////////////////////////////////////////////////////////////////////////////
195/// Iconify browser window
196
198{
199 if (fCanvasWidget)
200 fCanvasWidget->showMinimized();
201}
202
203//////////////////////////////////////////////////////////////////////////////////////////
204/// Raise browser window
205
207{
208 if (fCanvasWidget) {
209 fCanvasWidget->showNormal();
210 fCanvasWidget->raise();
211 fCanvasWidget->activateWindow();
212 }
213}
214
215//////////////////////////////////////////////////////////////////////////////////////////
216/// Assign clients bits
217
229
230//////////////////////////////////////////////////////////////////////////////////////////
231/// Returns canvas geometry
232
234{
235 (void) wid;
236 if (fPaintWidget) {
237 w = fPaintWidget->width();
238 h = fPaintWidget->height();
239 } else {
240 w = 780;
241 h = 580;
242 }
243}
244
245
246//////////////////////////////////////////////////////////////////////////////////////////
247/// Returns window geometry including borders and menus
248
250{
251 if (fCanvasWidget) {
252 auto pos = fCanvasWidget->pos();
253 x = pos.x();
254 y = pos.y();
255 w = fCanvasWidget->width();
256 h = fCanvasWidget->height();
257 } else {
258 x = y = 0;
259 w = 800;
260 h = 600;
261 }
262
263 return 0;
264}
265
266//////////////////////////////////////////////////////////////////////////////////////////
267/// if canvas or any subpad was modified,
268/// invoke Qt update() which will redraw area
269
271{
272 if (Canvas()->IsAnyNeedRepaint() && fPaintWidget)
273 fPaintWidget->update();
274 return kTRUE;
275}
276
277//////////////////////////////////////////////////////////////////////////////////////////
278/// Increment canvas version and force sending data to client - do not wait for reply
279
281{
282}
283
284//////////////////////////////////////////////////////////////////////////////////////////////////
285/// Static method to create TQt6Canvas instance
286/// Used by plugin manager to directly create TQt6Canvas without gui factory
287
289{
290 // ensure QApplication is exists
292
293 auto widget = new QCanvasWidget();
294 widget->setWindowTitle(QString(c->GetTitle()));
295 if ((x < 0) && (y < 0))
296 widget->resize(width, height);
297 else
298 widget->setGeometry(x, y, width, height);
299 widget->show();
300
301 auto imp = new TQt6Canvas(c, name, x, y, width, height);
302
303 imp->fCanvasWidget = widget;
304 imp->fPaintWidget = widget->GetPaintWidget();
305
306 if (imp->fPaintWidget)
307 imp->fPaintWidget->SetCanvas(c);
308
309 // set all internal dimensions
310 c->Resize();
311
312 // TODO: maybe apply same logic to adjust canvas dimension as in TRootCanvas
313 // Keep commented code here intentionally to be able find this place when
314 // search for correspondent class members
315
316 // c->fWindowTopX = x;
317 // c->fWindowTopY = y;
318 // c->fWindowWidth = width;
319 // c->fWindowHeight = height;
320 // if (!gROOT->IsBatch() && (height > 25))
321 // height -= 25;
322 // c->fCw = width;
323 // c->fCh = height;
324
325 return imp;
326}
ECursor
Definition GuiTypes.h:373
@ kRightSide
Definition GuiTypes.h:374
@ kBottomSide
Definition GuiTypes.h:374
@ kArrowRight
Definition GuiTypes.h:376
@ kTopLeft
Definition GuiTypes.h:373
@ kBottomRight
Definition GuiTypes.h:373
@ kArrowVer
Definition GuiTypes.h:375
@ kCaret
Definition GuiTypes.h:376
@ kTopSide
Definition GuiTypes.h:374
@ kLeftSide
Definition GuiTypes.h:374
@ kWatch
Definition GuiTypes.h:376
@ kMove
Definition GuiTypes.h:375
@ kTopRight
Definition GuiTypes.h:373
@ kBottomLeft
Definition GuiTypes.h:373
@ kHand
Definition GuiTypes.h:375
@ kCross
Definition GuiTypes.h:375
@ kRotate
Definition GuiTypes.h:375
@ kNoDrop
Definition GuiTypes.h:376
@ kArrowHor
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:376
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
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.
void SetCursor(ECursor cursor) override
Set cursor.
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:102
@ kShowToolBar
Definition TCanvas.h:97
@ kShowEventStatus
Definition TCanvas.h:94
@ kMenuBar
Definition TCanvas.h:96
@ kShowEditor
Definition TCanvas.h:98
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