Skip to content
Merged
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
5 changes: 5 additions & 0 deletions core/base/inc/TVirtualPadPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class TVirtualPadPainter {
virtual void SetAttMarker(const TAttMarker &att);
virtual void SetAttText(const TAttText &att);

virtual const TAttFill &GetAttFill() const;
virtual const TAttLine &GetAttLine() const;
virtual const TAttMarker &GetAttMarker() const;
virtual const TAttText &GetAttText() const;

//This part is an interface to X11 pixmap management and to save sub-pads off-screens for OpenGL.
//Currently, must be implemented only for X11/GDI
virtual Int_t CreateDrawable(UInt_t w, UInt_t h) = 0;//gVirtualX->OpenPixmap
Expand Down
49 changes: 49 additions & 0 deletions core/base/src/TVirtualPadPainter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,55 @@ void TVirtualPadPainter::SetAttText(const TAttText &att)
SetTextFont(att.GetTextFont());
}

////////////////////////////////////////////////////////////////////////////////
/// Get fill attributes

const TAttFill &TVirtualPadPainter::GetAttFill() const
{
static TAttFill att;
att.SetFillColor(GetFillColor());
att.SetFillStyle(GetFillStyle());
return att;
}

////////////////////////////////////////////////////////////////////////////////
/// Get line attributes

const TAttLine &TVirtualPadPainter::GetAttLine() const
{
static TAttLine att;
att.SetLineColor(GetLineColor());
att.SetLineStyle(GetLineStyle());
att.SetLineWidth(GetLineWidth());
return att;
}

////////////////////////////////////////////////////////////////////////////////
/// Get marker attributes

const TAttMarker &TVirtualPadPainter::GetAttMarker() const
{
static TAttMarker att;
att.SetMarkerColor(GetMarkerColor());
att.SetMarkerSize(GetMarkerSize());
att.SetMarkerStyle(GetMarkerStyle());
return att;
}

////////////////////////////////////////////////////////////////////////////////
/// Get text attributes

const TAttText &TVirtualPadPainter::GetAttText() const
{
static TAttText att;
att.SetTextAlign(GetTextAlign());
att.SetTextAngle(GetTextAngle());
att.SetTextColor(GetTextColor());
att.SetTextSize(GetTextSize());
att.SetTextFont(GetTextFont());
return att;
}

////////////////////////////////////////////////////////////////////////////////
/// Set double buffer mode for specified device, redirect to gVirtualX

Expand Down
1 change: 1 addition & 0 deletions graf2d/gpad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Gpad
TGroupButton.h
TInspectCanvas.h
TPad.h
TPadPainterBase.h
TPadPainter.h
TPadPainterPS.h
TPaveClass.h
Expand Down
1 change: 1 addition & 0 deletions graf2d/gpad/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#pragma link C++ class TSliderBox+;
#pragma link C++ class TView+;
#pragma link C++ class TViewer3DPad;
#pragma link C++ class TPadPainterBase;
#pragma link C++ class TPadPainter;
#pragma link C++ class TPadPainterPS;
#pragma link C++ class TRatioPlot+;
Expand Down
53 changes: 4 additions & 49 deletions graf2d/gpad/inc/TPadPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,25 @@
#ifndef ROOT_TPadPainter
#define ROOT_TPadPainter

#include "TVirtualPadPainter.h"
#include "GuiTypes.h"
#include "TPadPainterBase.h"

/*
TVirtualPadPainter is an attempt to abstract
painting operation furthermore. gVirtualX can
be X11 or GDI, but pad painter can be gVirtualX (X11 or GDI),
TPadPainter is implementation of TVirtualPadPainter interface for TVirtualX.
gVirtualX can be X11 or GDI, but pad painter can be gVirtualX (X11 or GDI),
or gl pad painter.
*/

class TVirtualPad;

class TPadPainter : public TVirtualPadPainter {
class TPadPainter : public TPadPainterBase {
WinContext_t fWinContext;
Int_t fSetLineWidth = 0; ///< remember set width to optimize some painting
Style_t fSetFillStyle = 0; ///< remember set fill style to optimize painting

public:
TPadPainter();
//Final overriders for TVirtualPadPainter pure virtual functions.
//1. Part, which simply delegates to TVirtualX.

//Line attributes.
Color_t GetLineColor() const override;
Style_t GetLineStyle() const override;
Width_t GetLineWidth() const override;

void SetLineColor(Color_t lcolor) override;
void SetLineStyle(Style_t lstyle) override;
void SetLineWidth(Width_t lwidth) override;

//Fill attributes.
Color_t GetFillColor() const override;
Style_t GetFillStyle() const override;
Bool_t IsTransparent() const override;

void SetFillColor(Color_t fcolor) override;
void SetFillStyle(Style_t fstyle) override;
void SetOpacity(Int_t percent) override;

//Text attributes.
Short_t GetTextAlign() const override;
Float_t GetTextAngle() const override;
Color_t GetTextColor() const override;
Font_t GetTextFont() const override;
Float_t GetTextSize() const override;
Float_t GetTextMagnitude() const override;

void SetTextAlign(Short_t align) override;
void SetTextAngle(Float_t tangle) override;
void SetTextColor(Color_t tcolor) override;
void SetTextFont(Font_t tfont) override;
void SetTextSize(Float_t tsize) override;
void SetTextSizePixels(Int_t npixels) override;

//Marker attributes
Color_t GetMarkerColor() const override;
Style_t GetMarkerStyle() const override;
Size_t GetMarkerSize() const override;

void SetMarkerColor(Color_t mcolor) override;
void SetMarkerStyle(Style_t mstyle) override;
void SetMarkerSize(Size_t msize) override;

//Overall attributes
void SetAttFill(const TAttFill &att) override;
void SetAttLine(const TAttLine &att) override;
Expand Down
108 changes: 108 additions & 0 deletions graf2d/gpad/inc/TPadPainterBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// @(#)root/gpad:$Id$
// Author: Sergey Linev 1/04/2026

/*************************************************************************
* Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

#ifndef ROOT_TPadPainterBase
#define ROOT_TPadPainterBase

#include "TVirtualPadPainter.h"
#include "TAttFill.h"
#include "TAttLine.h"
#include "TAttMarker.h"
#include "TAttText.h"

class TPadPainterBase : public TVirtualPadPainter {
protected:
TAttFill fAttFill; ///< current fill attributes
TAttLine fAttLine; ///< current line attributes
TAttMarker fAttMarker; ///< current marker attributes
TAttText fAttText; ///< current text attributes

public:

/// _____________________________________________________________________
/// old methods only for backward compatibility

//Line attributes to be set up in TPad.
Color_t GetLineColor() const override { return fAttLine.GetLineColor(); }
Style_t GetLineStyle() const override { return fAttLine.GetLineStyle(); }
Width_t GetLineWidth() const override { return fAttLine.GetLineWidth(); }

void SetLineColor(Color_t lcolor) override { fAttLine.SetLineColor(lcolor); SetAttLine(fAttLine); }
void SetLineStyle(Style_t lstyle) override { fAttLine.SetLineStyle(lstyle); SetAttLine(fAttLine); }
void SetLineWidth(Width_t lwidth) override { fAttLine.SetLineWidth(lwidth); SetAttLine(fAttLine); }

//Fill attributes to be set up in TPad.
Color_t GetFillColor() const override { return fAttFill.GetFillColor(); }
Style_t GetFillStyle() const override { return fAttFill.GetFillStyle(); }
Bool_t IsTransparent() const override { return fAttFill.IsTransparent(); }

void SetFillColor(Color_t fcolor) override { fAttFill.SetFillColor(fcolor); SetAttFill(fAttFill); }
void SetFillStyle(Style_t fstyle) override { fAttFill.SetFillStyle(fstyle); SetAttFill(fAttFill); }

//Text attributes.
Short_t GetTextAlign() const override { return fAttText.GetTextAlign(); }
Float_t GetTextAngle() const override { return fAttText.GetTextAngle(); }
Color_t GetTextColor() const override { return fAttText.GetTextColor(); }
Font_t GetTextFont() const override { return fAttText.GetTextFont(); }
Float_t GetTextSize() const override { return fAttText.GetTextSize(); }
Float_t GetTextMagnitude() const override { return 1.; }

void SetTextAlign(Short_t align) override { fAttText.SetTextAlign(align); SetAttText(fAttText); }
void SetTextAngle(Float_t tangle) override { fAttText.SetTextAngle(tangle); SetAttText(fAttText); }
void SetTextColor(Color_t tcolor) override { fAttText.SetTextColor(tcolor); SetAttText(fAttText); }
void SetTextFont(Font_t tfont) override { fAttText.SetTextFont(tfont); SetAttText(fAttText); }
void SetTextSize(Float_t tsize) override { fAttText.SetTextSize(tsize); SetAttText(fAttText); }
void SetTextSizePixels(Int_t npixels) override { fAttText.SetTextSizePixels(npixels); SetAttText(fAttText); }

//Marker attributes
Color_t GetMarkerColor() const override { return fAttMarker.GetMarkerColor(); }
Style_t GetMarkerStyle() const override { return fAttMarker.GetMarkerStyle(); }
Size_t GetMarkerSize() const override { return fAttMarker.GetMarkerSize(); }

void SetMarkerColor(Color_t mcolor) override { fAttMarker.SetMarkerColor(mcolor); SetAttMarker(fAttMarker); }
void SetMarkerStyle(Style_t mstyle) override { fAttMarker.SetMarkerStyle(mstyle); SetAttMarker(fAttMarker); }
void SetMarkerSize(Size_t msize) override { fAttMarker.SetMarkerSize(msize); SetAttMarker(fAttMarker); }

/// _____________________________________________________________________

const TAttFill &GetAttFill() const override { return fAttFill; }
const TAttLine &GetAttLine() const override { return fAttLine; }
const TAttMarker &GetAttMarker()const override { return fAttMarker; }
const TAttText &GetAttText() const override { return fAttText; }

void SetAttFill(const TAttFill &att) override
{
if (&att != &fAttFill)
att.Copy(fAttFill);
}

void SetAttLine(const TAttLine &att) override
{
if (&att != &fAttLine)
att.Copy(fAttLine);
}

void SetAttMarker(const TAttMarker &att) override
{
if (&att != &fAttMarker)
att.Copy(fAttMarker);
}

void SetAttText(const TAttText &att) override
{
if (&att != &fAttText)
att.Copy(fAttText);
}

ClassDefOverride(TPadPainterBase, 0)//Pad painter with attributes handling
};

#endif
54 changes: 10 additions & 44 deletions graf2d/gpad/inc/TPadPainterPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef ROOT_TPadPainterPS
#define ROOT_TPadPainterPS

#include "TVirtualPadPainter.h"
#include "TPadPainterBase.h"

/*
TPadPainterPS is an attempt to abstract
Expand All @@ -23,57 +23,23 @@ one also will be able to produce vector-based and binary images */
class TVirtualPad;
class TVirtualPS;

class TPadPainterPS : public TVirtualPadPainter {
class TPadPainterPS : public TPadPainterBase {
private:
TVirtualPS *fPS = nullptr;
TVirtualPad *fPad = nullptr;
public:
TPadPainterPS(TVirtualPS *ps);

//Final overriders for TVirtualPadPainter pure virtual functions.
//1. Part, which simply delegates to TVirtualX.

//Line attributes.
Color_t GetLineColor() const override;
Style_t GetLineStyle() const override;
Width_t GetLineWidth() const override;

void SetLineColor(Color_t lcolor) override;
void SetLineStyle(Style_t lstyle) override;
void SetLineWidth(Width_t lwidth) override;

//Fill attributes.
Color_t GetFillColor() const override;
Style_t GetFillStyle() const override;
Bool_t IsTransparent() const override;

void SetFillColor(Color_t fcolor) override;
void SetFillStyle(Style_t fstyle) override;
void SetOpacity(Int_t percent) override;

//Text attributes.
Short_t GetTextAlign() const override;
Float_t GetTextAngle() const override;
Color_t GetTextColor() const override;
Font_t GetTextFont() const override;
Float_t GetTextSize() const override;
Float_t GetTextMagnitude() const override;

void SetTextAlign(Short_t align) override;
void SetTextAngle(Float_t tangle) override;
void SetTextColor(Color_t tcolor) override;
void SetTextFont(Font_t tfont) override;
void SetTextSize(Float_t tsize) override;
void SetTextSizePixels(Int_t npixels) override;

//Marker attributes
Color_t GetMarkerColor() const override;
Style_t GetMarkerStyle() const override;
Size_t GetMarkerSize() const override;

void SetMarkerColor(Color_t mcolor) override;
void SetMarkerStyle(Style_t mstyle) override;
void SetMarkerSize(Size_t msize) override;
//Overall attributes
void SetAttFill(const TAttFill &att) override;
void SetAttLine(const TAttLine &att) override;
void SetAttMarker(const TAttMarker &att) override;
void SetAttText(const TAttText &att) override;

//Final overriders for TVirtualPadPainter pure virtual functions.
//1. Part, which simply delegates to TVirtualX.

//2. "Off-screen management" part.
Int_t CreateDrawable(UInt_t w, UInt_t h) override;
Expand Down
Loading
Loading