Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/gui/inc/TCanvasImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ friend class TCanvas;
virtual void Unlock() {}
virtual Bool_t IsLocked() { return kFALSE; }

virtual Bool_t IsUseVirtualX() const;
virtual Bool_t IsWeb() const { return kFALSE; }
virtual Bool_t PerformUpdate(Bool_t /* async */) { return kFALSE; }
virtual TVirtualPadPainter *CreatePadPainter() { return nullptr; }
Expand Down
11 changes: 11 additions & 0 deletions core/gui/src/TCanvasImp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ and a drawing area).
#include "TSystem.h"


////////////////////////////////////////////////////////////////////////////////
/// Returns true if gVirtualX instance used by the canvas implementation
/// In the ROOT6 it is be default on - means all necessary libraries will be loaded and initialized
/// In the ROOT7 it will be switched to off by default and probably completely removed
/// from the API

Bool_t TCanvasImp::IsUseVirtualX() const
{
return kTRUE;
}

////////////////////////////////////////////////////////////////////////////////
/// Change mouse pointer, redirect to gVirtualX

Expand Down
4 changes: 2 additions & 2 deletions graf2d/gpad/inc/TCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ friend class TInterpreter;
protected:
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
//-- used by friend TThread class
void Init();
void Init(Bool_t init_virtualx_graphics = kTRUE);

public:
// TCanvas status bits
Expand Down Expand Up @@ -209,7 +209,7 @@ friend class TInterpreter;
void SetGrayscale(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsGrayscale
void SetWindowPosition(Int_t x, Int_t y);
void SetWindowSize(UInt_t ww, UInt_t wh);
void SetCanvasImp(TCanvasImp *i);
void SetCanvasImp(TCanvasImp *imp);
void SetCanvasSize(UInt_t ww, UInt_t wh) override; // *MENU*
void SetHighLightColor(Color_t col) { fHighLightColor = col; }
void SetSelected(TObject *obj) override;
Expand Down
69 changes: 46 additions & 23 deletions graf2d/gpad/src/TCanvas.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,24 @@ void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
////////////////////////////////////////////////////////////////////////////////
/// Initialize the TCanvas members. Called by all constructors.

void TCanvas::Init()
void TCanvas::Init(Bool_t init_virtualx_graphics)
{
// Make sure the application environment exists. It is need for graphics
// (colors are initialized in the TApplication ctor).
if (!gApplication)
TApplication::CreateApplication();

// Load and initialize graphics libraries if
// TApplication::NeedGraphicsLibs() has been called by a
// library static initializer.
if (gApplication)
gApplication->InitializeGraphics(gROOT->IsWebDisplay());
if (init_virtualx_graphics) {
if (!gApplication)
TApplication::CreateApplication();

// Load and initialize graphics libraries if
// TApplication::NeedGraphicsLibs() has been called by a
// library static initializer.
if (gApplication)
gApplication->InitializeGraphics(gROOT->IsWebDisplay());
} else {
// ensure that all colors are created
TColor::InitializeColors();
}

// Get some default from .rootrc. Used in fCanvasImp->InitWindow().
fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
Expand Down Expand Up @@ -602,7 +608,8 @@ void TCanvas::Build()
// Get window identifier
if (fCanvasID == -1 && fCanvasImp)
fCanvasID = fCanvasImp->InitWindow();
if (fCanvasID == -1) return;
if (fCanvasID == -1)
return;

if (fCw !=0 && fCh !=0) {
if (fCw < fCh) fXsizeReal = fYsizeReal*Float_t(fCw)/Float_t(fCh);
Expand All @@ -624,14 +631,16 @@ void TCanvas::Build()
} else {
//normal mode with a screen window
if (auto pp = GetCanvasPainter()) {
// only with virtualx one allowed to paint outside of Update() method
// Set default physical canvas attributes
pp->SelectDrawable(fCanvasID);
pp->SetAttFill({1, 1001}); //Set color index for fill area
pp->SetAttLine({1, 1, 1}); //Set color index for lines
pp->SetAttMarker({1, 1, 1}); //Set color index for markers
// pp->SetAttText({22, 0., 1, 42, 12}); //Set color index for text
// Clear workstation
pp->ClearWindow(fCanvasID);
if (fCanvasImp->IsUseVirtualX())
pp->ClearWindow(fCanvasID);
}

// Set Double Buffer on by default
Expand Down Expand Up @@ -664,13 +673,16 @@ void TCanvas::Build()
SetRightMargin(gStyle->GetPadRightMargin());
SetBorderSize(gStyle->GetCanvasBorderSize());
SetBorderMode(gStyle->GetCanvasBorderMode());
fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
fBorderMode = gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
SetPad(0, 0, 1, 1);
Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y

if (auto pp = GetCanvasPainter())
pp->SelectDrawable(fPixmapID); //pixmap must be selected
PaintBorder(GetFillColor(), kTRUE); //paint background
if (fCanvasImp->IsUseVirtualX()) {
// only with virtualx one allowed to paint outside of Update() method
if (auto pp = GetCanvasPainter())
pp->SelectDrawable(fPixmapID); //pixmap must be selected
PaintBorder(GetFillColor(), kTRUE); //paint background
}
}

// transient canvases have typically no menubar and should not get
Expand Down Expand Up @@ -1997,7 +2009,7 @@ void TCanvas::SetCursor(ECursor cursor)

void TCanvas::SetDoubleBuffer(Int_t mode)
{
if (IsBatch() || IsWeb())
if (IsBatch() || IsWeb() || !fPainter)
return;
fDoubleBuffer = mode;
if (fCanvasID != -1)
Expand Down Expand Up @@ -2181,21 +2193,32 @@ void TCanvas::SetWindowSize(UInt_t ww, UInt_t wh)

////////////////////////////////////////////////////////////////////////////////
/// Set canvas implementation
/// If web-based implementation provided, some internal fields also initialized
/// Should be used with care!
/// Normally invoked for not-initialized canvas created with `new TCanvas(kFALSE)` constructor.
/// After implementation assigned canvas will be initialized
/// @note For web-based implementation there is special handling, which will be removed in ROOT7

void TCanvas::SetCanvasImp(TCanvasImp *imp)
{
Bool_t was_web = IsWeb();
Bool_t was_nox = fCanvasImp && !fCanvasImp->IsUseVirtualX();

fCanvasImp = imp;

if (!was_web && IsWeb()) {
fCanvasID = fCanvasImp->InitWindow();
fPixmapID = 0;
fMother = this;
if (!fCw) fCw = 800;
if (!fCh) fCh = 600;
} else if (was_web && !imp) {
if (fCanvasImp) {
if (fCanvasImp->IsWeb()) {
// special handling for web canvas, need to be sync with possible apps
fCanvasID = fCanvasImp->InitWindow();
fPixmapID = 0;
fMother = this;
if (!fCw) fCw = 800;
if (!fCh) fCh = 600;
} else {
Init(fCanvasImp->IsUseVirtualX());
Build();
ResizePad();
}
} else if (!imp && (was_web || was_nox)) {
fCanvasID = -1;
fPixmapID = -1;
fMother = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions gui/gtk4canvas/inc/TGtk4Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class TGtk4Canvas : public TCanvasImp {
Bool_t PerformUpdate(Bool_t async) override;
TVirtualPadPainter *CreatePadPainter() override;

Bool_t IsUseVirtualX() const override { return kFALSE; }

void AssignStatusBits(UInt_t bits);


Expand Down
2 changes: 2 additions & 0 deletions gui/gui/inc/TRootCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ friend class TRootContainer;
Atom_t HandleDNDEnter(Atom_t * typelist) override;
Bool_t HandleDNDLeave() override;

Bool_t IsUseVirtualX() const override { return kTRUE; }

TVirtualPadPainter *CreatePadPainter() override;

public:
Expand Down
23 changes: 12 additions & 11 deletions gui/qt6canvas/inc/TQt6Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ class TQt6Canvas : public TCanvasImp {
QPaintWidget *fPaintWidget = nullptr;

Bool_t fFixedSize = kFALSE; ///<! true when fixed-size canvas is configured
UInt_t fClientBits = 0; ///<! latest status bits from client like editor visible or not

Bool_t PerformUpdate(Bool_t async) override;
TVirtualPadPainter *CreatePadPainter() override;

void AssignStatusBits(UInt_t bits);
Bool_t IsUseVirtualX() const override { return kFALSE; }


public:
Expand All @@ -53,11 +52,11 @@ class TQt6Canvas : public TCanvasImp {
void ResizeCanvasWindow(Int_t) override {}
void UpdateDisplay(Int_t = 0, Bool_t = kFALSE) override {}

void ShowMenuBar(Bool_t = kTRUE) override { }
void ShowStatusBar(Bool_t = kTRUE) override { }
void ShowMenuBar(Bool_t = kTRUE) override;
void ShowStatusBar(Bool_t = kTRUE) override;
void ShowEditor(Bool_t = kTRUE) override { }
void ShowToolBar(Bool_t = kTRUE) override { }
void ShowToolTips(Bool_t = kTRUE) override { }
void ShowToolBar(Bool_t = kTRUE) override;
void ShowToolTips(Bool_t = kTRUE) override;

void ForceUpdate() override;

Expand All @@ -69,14 +68,16 @@ class TQt6Canvas : public TCanvasImp {
void Iconify() override;
void RaiseWindow() override;

Bool_t HasEditor() const override;
Bool_t HasMenuBar() const override;
Bool_t HasStatusBar() const override;
Bool_t HasToolBar() const override { return kFALSE; }
Bool_t HasToolTips() const override;
Bool_t HasEditor() const override { return kFALSE; }
Bool_t HasMenuBar() const override { return kTRUE; }
Bool_t HasStatusBar() const override { return kTRUE; }
Bool_t HasToolBar() const override { return kTRUE; }
Bool_t HasToolTips() const override { return kTRUE; }

static TCanvasImp *NewCanvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height);

static TCanvas *EmbedQt6Canvas(class QWidget *parent, const char *name);

ClassDefOverride(TQt6Canvas, 0) // Qt6 implementation for TCanvasImp
};

Expand Down
15 changes: 11 additions & 4 deletions gui/qt6canvas/src/QCanvasWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ QCanvasWidget::~QCanvasWidget()
{
}


////////////////////////////////////////////////////////////////////////////////
/// Create new canvas.

Expand Down Expand Up @@ -455,6 +456,14 @@ void QCanvasWidget::QuitRoot()
TTimer::SingleShot(100, "TApplication", gApplication, "Terminate()");
}

////////////////////////////////////////////////////////////////////////////////
/// Set visibility of menu

void QCanvasWidget::SetViewMenubar(bool on)
{
fMenuBar->setVisible(on);
}

////////////////////////////////////////////////////////////////////////////////
/// Set visibility of tool bar

Expand Down Expand Up @@ -533,15 +542,13 @@ void QCanvasWidget::ApplyCanvasStatusBits()
if (!canv)
return;

SetViewMenubar(canv->TestBit(TCanvas::kMenuBar));

SetViewEventStatus(canv->TestBit(TCanvas::kShowEventStatus));

// canv->TestBit(TCanvas::kShowEditor);

SetViewToolbar(canv->TestBit(TCanvas::kShowToolBar));

SetViewToolTip(canv->TestBit(TCanvas::kShowToolTips));

fMenuBar->setVisible(canv->TestBit(TCanvas::kMenuBar));


}
4 changes: 2 additions & 2 deletions gui/qt6canvas/src/QCanvasWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#include <string>
#include <vector>

class TH1F;
class TH2I;
class TCanvas;

class QCanvasWidget : public QWidget, public Ui::QCanvasWidget {
Q_OBJECT
Expand Down Expand Up @@ -61,6 +60,7 @@ public slots:
void ShowMarkers();
void IconifyCanvas();

void SetViewMenubar(bool);
void SetViewToolbar(bool);
void SetViewEventStatus(bool);
void SetViewToolTip(bool);
Expand Down
Loading
Loading