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
2 changes: 2 additions & 0 deletions core/base/inc/TAttFill.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Rtypes.h"

class TColorNumber;
class TVirtualPad;

class TAttFill {

Expand All @@ -31,6 +32,7 @@ class TAttFill {
virtual Color_t GetFillColor() const { return fFillColor; } ///< Return the fill area color
virtual Style_t GetFillStyle() const { return fFillStyle; } ///< Return the fill area style
virtual Bool_t IsTransparent() const;
virtual void ModifyOn(TVirtualPad *pad);
virtual void Modify();
virtual void ResetAttFill(Option_t *option="");
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001);
Expand Down
2 changes: 2 additions & 0 deletions core/base/inc/TAttLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Rtypes.h"

class TColorNumber;
class TVirtualPad;

class TAttLine {

Expand All @@ -36,6 +37,7 @@ class TAttLine {
virtual Style_t GetLineStyle() const {return fLineStyle;} ///< Return the line style
virtual Width_t GetLineWidth() const {return fLineWidth;} ///< Return the line width
virtual void Modify();
virtual void ModifyOn(TVirtualPad *pad);
virtual void ResetAttLine(Option_t *option="");
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1);
virtual void SetLineAttributes(); // *MENU*
Expand Down
2 changes: 2 additions & 0 deletions core/base/inc/TAttMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Rtypes.h"

class TColorNumber;
class TVirtualPad;

class TAttMarker {

Expand All @@ -33,6 +34,7 @@ class TAttMarker {
virtual Style_t GetMarkerStyle() const {return fMarkerStyle;} ///< Return the marker style
virtual Size_t GetMarkerSize() const {return fMarkerSize;} ///< Return the marker size
virtual void Modify();
virtual void ModifyOn(TVirtualPad *pad);
virtual void ResetAttMarker(Option_t *toption="");
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1);
virtual void SetMarkerAttributes(); // *MENU*
Expand Down
2 changes: 2 additions & 0 deletions core/base/inc/TAttText.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Rtypes.h"

class TColorNumber;
class TVirtualPad;

class TAttText {

Expand All @@ -38,6 +39,7 @@ class TAttText {
virtual Float_t GetTextSize() const {return fTextSize;} ///< Return the text size
virtual Float_t GetTextSizePercent(Float_t size); ///< Return the text in percent of the pad size
virtual void Modify();
virtual void ModifyOn(TVirtualPad *pad);
virtual void ResetAttText(Option_t *toption="");
virtual void SaveTextAttributes(std::ostream &out, const char *name, Int_t alidef=12, Float_t angdef=0, Int_t coldef=1, Int_t fondef=61, Float_t sizdef=1);
virtual void SetTextAttributes(); // *MENU*
Expand Down
21 changes: 19 additions & 2 deletions core/base/inc/TVirtualPadPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,20 @@ class TVirtualPadPainter {
virtual void SetTextSize(Float_t tsize=1) = 0;
virtual void SetTextSizePixels(Int_t npixels) = 0;

//Marker attributes
virtual Color_t GetMarkerColor() const { return 0; }
virtual Style_t GetMarkerStyle() const { return 0; }
virtual Size_t GetMarkerSize() const { return 0; }

virtual void SetMarkerColor(Color_t /* mcolor */ = 1) {}
virtual void SetMarkerStyle(Style_t /* mstyle */ = 1) {}
virtual void SetMarkerSize(Size_t /* msize */ = 1) {}

//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
virtual void ClearDrawable() = 0;//gVirtualX->Clear()
virtual Int_t ResizeDrawable(Int_t /* device */, UInt_t /* w */, UInt_t /* h */) { return 0; } //gVirtualX->ResizePixmap
virtual void CopyDrawable(Int_t device, Int_t px, Int_t py) = 0;
virtual void DestroyDrawable(Int_t device) = 0;//gVirtualX->CloseWindow
virtual void SelectDrawable(Int_t device) = 0;//gVirtualX->SelectWindow
Expand All @@ -82,6 +92,7 @@ class TVirtualPadPainter {
virtual void InitPainter();
virtual void InvalidateCS();
virtual void LockPainter();
virtual void NewPage() {}

//Now, drawing primitives.
virtual void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) = 0;
Expand All @@ -96,8 +107,8 @@ class TVirtualPadPainter {
virtual void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) = 0;
virtual void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) = 0;

virtual void DrawSegments(Int_t n, const Double_t *x, const Double_t *y);
virtual void DrawSegmentsNDC(Int_t n, const Double_t *u, const Double_t *v);
virtual void DrawSegments(Int_t n, Double_t *x, Double_t *y);
virtual void DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v);

virtual void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) = 0;
virtual void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) = 0;
Expand All @@ -107,9 +118,15 @@ class TVirtualPadPainter {
virtual void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) = 0;
virtual void DrawTextNDC(Double_t u, Double_t v, const wchar_t *text, ETextMode mode) = 0;

virtual void DrawTextUrl(Double_t x, Double_t y, const char *text, const char *url);

//gif, jpg, png, bmp output.
virtual void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const = 0;

virtual void OnPad(TVirtualPad *) {}

virtual Bool_t IsNative() const { return kFALSE; }
virtual Bool_t IsCocoa() const { return kFALSE; }

static TVirtualPadPainter *PadPainter(Option_t *opt = "");

Expand Down
22 changes: 14 additions & 8 deletions core/base/src/TAttFill.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include <iostream>
#include "TAttFill.h"
#include "TVirtualPad.h"
#include "TStyle.h"
#include "TVirtualX.h"
#include "TVirtualPad.h"
#include "TVirtualPadPainter.h"
#include "TVirtualPadEditor.h"
#include "TColor.h"

Expand Down Expand Up @@ -215,13 +215,19 @@ void TAttFill::Copy(TAttFill &attfill) const

void TAttFill::Modify()
{
if (!gPad) return;
if (!gPad->IsBatch()) {
gVirtualX->SetFillColor(fFillColor);
gVirtualX->SetFillStyle(fFillStyle);
}
ModifyOn(gPad);
}

gPad->SetAttFillPS(fFillColor,fFillStyle);
////////////////////////////////////////////////////////////////////////////////
/// Change current fill area attributes on speicifed pad

void TAttFill::ModifyOn(TVirtualPad *pad)
{
auto pp = pad ? pad->GetPainter() : nullptr;
if (!pp)
return;
pp->SetFillColor(fFillColor);
pp->SetFillStyle(fFillStyle);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
28 changes: 16 additions & 12 deletions core/base/src/TAttLine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "TAttLine.h"
#include "TVirtualPad.h"
#include "TStyle.h"
#include "TVirtualX.h"
#include "TVirtualPadPainter.h"
#include "TVirtualPadEditor.h"
#include "TStyle.h"
#include "TColor.h"
#include <cmath>
#include <iostream>
Expand Down Expand Up @@ -245,19 +245,23 @@ Int_t TAttLine::DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, D

void TAttLine::Modify()
{
if (!gPad) return;
Int_t lineWidth = std::abs(fLineWidth%100);
if (!gPad->IsBatch()) {
gVirtualX->SetLineColor(fLineColor);
if (fLineStyle > 0 && fLineStyle < 30) gVirtualX->SetLineStyle(fLineStyle);
else gVirtualX->SetLineStyle(1);
gVirtualX->SetLineWidth(lineWidth);
}
ModifyOn(gPad);
}

if (fLineStyle > 0 && fLineStyle < 30) gPad->SetAttLinePS(fLineColor,fLineStyle,lineWidth);
else gPad->SetAttLinePS(fLineColor,1,lineWidth);
////////////////////////////////////////////////////////////////////////////////
/// Change current line attributes on specified pad

void TAttLine::ModifyOn(TVirtualPad *pad)
{
auto pp = pad ? pad->GetPainter() : nullptr;
if (!pp)
return;
pp->SetLineColor(fLineColor);
pp->SetLineStyle((fLineStyle > 0 && fLineStyle < 30) ? fLineStyle : 1);
pp->SetLineWidth(std::abs(fLineWidth % 100));
}


////////////////////////////////////////////////////////////////////////////////
/// Reset this line attributes to default values.

Expand Down
26 changes: 17 additions & 9 deletions core/base/src/TAttMarker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "Strlen.h"
#include "TAttMarker.h"
#include "TVirtualPad.h"
#include "TStyle.h"
#include "TVirtualX.h"
#include "TVirtualPadPainter.h"
#include "TVirtualPadEditor.h"
#include "TStyle.h"
#include "TColor.h"


Expand Down Expand Up @@ -321,16 +321,24 @@ Width_t TAttMarker::GetMarkerLineWidth(Style_t style)

void TAttMarker::Modify()
{
if (!gPad) return;
if (!gPad->IsBatch()) {
gVirtualX->SetMarkerColor(fMarkerColor);
gVirtualX->SetMarkerSize (fMarkerSize);
gVirtualX->SetMarkerStyle(fMarkerStyle);
}
ModifyOn(gPad);
}

gPad->SetAttMarkerPS(fMarkerColor,fMarkerStyle,fMarkerSize);
////////////////////////////////////////////////////////////////////////////////
/// Change current marker attributes if necessary on specified pad.

void TAttMarker::ModifyOn(TVirtualPad *pad)
{
auto pp = pad ? pad->GetPainter() : nullptr;
if (!pp)
return;

pp->SetMarkerColor(fMarkerColor);
pp->SetMarkerSize (fMarkerSize);
pp->SetMarkerStyle(fMarkerStyle);
}


////////////////////////////////////////////////////////////////////////////////
/// Reset this marker attributes to the default values.

Expand Down
69 changes: 45 additions & 24 deletions core/base/src/TAttText.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include "TROOT.h"
#include "TAttText.h"
#include "TVirtualPad.h"
#include "TVirtualPadPainter.h"
#include "TVirtualPadEditor.h"
#include "TStyle.h"
#include "TVirtualX.h"
#include "TError.h"
#include "TVirtualPadEditor.h"
#include "TColor.h"


Expand Down Expand Up @@ -326,33 +326,54 @@ Float_t TAttText::GetTextSizePercent(Float_t size)

void TAttText::Modify()
{
if (!gPad) return;

// Do we need to change font?
if (!gPad->IsBatch()) {
gVirtualX->SetTextAngle(fTextAngle);
Float_t tsize;
if (fTextFont%10 > 2) {
tsize = fTextSize;
} else {
Float_t wh = (Float_t)gPad->XtoPixel(gPad->GetX2());
Float_t hh = (Float_t)gPad->YtoPixel(gPad->GetY1());
if (wh < hh) tsize = fTextSize*wh;
else tsize = fTextSize*hh;
}
ModifyOn(gPad);
}

if (gVirtualX->GetTextFont() != fTextFont) {
gVirtualX->SetTextFont(fTextFont);
gVirtualX->SetTextSize(tsize);
} else if (gVirtualX->GetTextSize() != tsize) {
gVirtualX->SetTextSize(tsize);

////////////////////////////////////////////////////////////////////////////////
/// Change current text attributes if necessary on specified pad.

void TAttText::ModifyOn(TVirtualPad *pad)
{
auto pp = pad ? pad->GetPainter() : nullptr;
if (!pp)
return;

Float_t tsize = fTextSize;

// there was difference in text size handling, keep it in one place
if (pp->IsNative()) {
if (fTextFont % 10 <= 2) {
auto wh = pad->XtoPixel(pad->GetX2());
auto hh = pad->YtoPixel(pad->GetY1());
if (wh < hh) tsize *= wh;
else tsize *= hh;
}
gVirtualX->SetTextAlign(fTextAlign);
gVirtualX->SetTextColor(fTextColor);
} else {
if (fTextFont % 10 > 2) {
Float_t wh = pad->XtoPixel(pad->GetX2());
Float_t hh = pad->YtoPixel(pad->GetY1());
if (wh < hh) {
Float_t dy = pad->AbsPixeltoX(Int_t(tsize)) - pad->AbsPixeltoX(0);
tsize = dy/(pad->GetX2() - pad->GetX1());
} else {
Float_t dy = pad->AbsPixeltoY(0) - pad->AbsPixeltoY(Int_t(tsize));
tsize = dy/(pad->GetY2() - pad->GetY1());
}
}
}
pp->SetTextAngle(fTextAngle);
if (pp->GetTextFont() != fTextFont) {
pp->SetTextFont(fTextFont);
pp->SetTextSize(tsize);
} else if (pp->GetTextSize() != tsize) {
pp->SetTextSize(tsize);
}
gPad->SetAttTextPS(fTextAlign,fTextAngle,fTextColor,fTextFont,fTextSize);
pp->SetTextAlign(fTextAlign);
pp->SetTextColor(fTextColor);
}


////////////////////////////////////////////////////////////////////////////////
/// Reset this text attributes to default values.

Expand Down
13 changes: 11 additions & 2 deletions core/base/src/TVirtualPadPainter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TVirtualPadPainter *TVirtualPadPainter::PadPainter(Option_t *type)
/// Draw N segments on the pad
/// Exclude segments where both points match

void TVirtualPadPainter::DrawSegments(Int_t n, const Double_t *x, const Double_t *y)
void TVirtualPadPainter::DrawSegments(Int_t n, Double_t *x, Double_t *y)
{
for(Int_t i = 0; i < 2*n; i += 2)
if ((x[i] != x[i+1]) || (y[i] != y[i + 1]))
Expand All @@ -81,9 +81,18 @@ void TVirtualPadPainter::DrawSegments(Int_t n, const Double_t *x, const Double_t
/// Draw N segments in NDC coordinates on the pad
/// Exclude segments where both points match

void TVirtualPadPainter::DrawSegmentsNDC(Int_t n, const Double_t *u, const Double_t *v)
void TVirtualPadPainter::DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v)
{
for(Int_t i = 0; i < 2*n; i += 2)
if ((u[i] != u[i+1]) || (v[i] != v[i + 1]))
DrawLineNDC(u[i], v[i], u[i+1], v[i+1]);
}

////////////////////////////////////////////////////////////////////////////////
/// Draw text with url link
/// By default only text is drawn

void TVirtualPadPainter::DrawTextUrl(Double_t x, Double_t y, const char *text, const char * /* url */)
{
DrawText(x, y, text, kClear);
}
2 changes: 2 additions & 0 deletions graf2d/gpad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Gpad
TInspectCanvas.h
TPad.h
TPadPainter.h
TPadPainterPS.h
TPaveClass.h
TRatioPlot.h
TSliderBox.h
Expand All @@ -46,6 +47,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Gpad
src/TInspectCanvas.cxx
src/TPad.cxx
src/TPadPainter.cxx
src/TPadPainterPS.cxx
src/TPaveClass.cxx
src/TRatioPlot.cxx
src/TSliderBox.cxx
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 @@ -32,6 +32,7 @@
#pragma link C++ class TView+;
#pragma link C++ class TViewer3DPad;
#pragma link C++ class TPadPainter;
#pragma link C++ class TPadPainterPS;
#pragma link C++ class TRatioPlot+;

#endif
Loading
Loading