Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TVirtualPadPainter.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Timur Pocheptsov 6/5/2009
3
4/*************************************************************************
5 * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TVirtualPadPainter.h"
13#include "TPluginManager.h"
14#include "TAttFill.h"
15#include "TAttLine.h"
16#include "TAttMarker.h"
17#include "TAttText.h"
18
19
20/** \class TVirtualPadPainter
21\ingroup Base
22
23To make it possible to use GL for 2D graphic in a TPad/TCanvas.
24TVirtualPadPainter interface must be used instead of TVirtualX.
25Internally, non-GL implementation _should_ delegate all calls
26to gVirtualX, GL implementation will delegate part of calls
27to gVirtualX, and has to implement some of the calls from the scratch.
28*/
29
30////////////////////////////////////////////////////////////////////////////////
31///Virtual dtor.
32
36
37////////////////////////////////////////////////////////////////////////////////
38///Empty definition.
39
43
44////////////////////////////////////////////////////////////////////////////////
45///Empty definition.
46
50
51////////////////////////////////////////////////////////////////////////////////
52///Empty definition.
53
57
58////////////////////////////////////////////////////////////////////////////////
59/// Create a pad painter of specified type.
60
62{
63 TVirtualPadPainter *painter = nullptr;
64 TPluginHandler *h = gPluginMgr->FindHandler("TVirtualPadPainter", type);
65
66 if (h && h->LoadPlugin() != -1)
67 painter = (TVirtualPadPainter *) h->ExecPlugin(0);
68
69 return painter;
70}
71
72
73////////////////////////////////////////////////////////////////////////////////
74/// Draw N segments on the pad
75/// Exclude segments where both points match
76
78{
79 for(Int_t i = 0; i < 2*n; i += 2)
80 if ((x[i] != x[i+1]) || (y[i] != y[i + 1]))
81 DrawLine(x[i], y[i], x[i+1], y[i+1]);
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Draw N segments in NDC coordinates on the pad
86/// Exclude segments where both points match
87
89{
90 for(Int_t i = 0; i < 2*n; i += 2)
91 if ((u[i] != u[i+1]) || (v[i] != v[i + 1]))
92 DrawLineNDC(u[i], v[i], u[i+1], v[i+1]);
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Draw text with url link
97/// By default only text is drawn
98
99void TVirtualPadPainter::DrawTextUrl(Double_t x, Double_t y, const char *text, const char * /* url */)
100{
101 DrawText(x, y, text, kClear);
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Set fill attributes
106
108{
109 SetFillColor(att.GetFillColor());
110 SetFillStyle(att.GetFillStyle());
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Set line attributes
115
117{
118 SetLineColor(att.GetLineColor());
119 SetLineStyle(att.GetLineStyle());
120 SetLineWidth(att.GetLineWidth());
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Set marker attributes
125
127{
128 SetMarkerColor(att.GetMarkerColor());
129 SetMarkerSize(att.GetMarkerSize());
130 SetMarkerStyle(att.GetMarkerStyle());
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Set text attributes
135
137{
138 SetTextAlign(att.GetTextAlign());
139 SetTextAngle(att.GetTextAngle());
140 SetTextColor(att.GetTextColor());
141 SetTextSize(att.GetTextSize());
142 SetTextFont(att.GetTextFont());
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Get fill attributes
147
149{
150 static TAttFill att;
151 att.SetFillColor(GetFillColor());
152 att.SetFillStyle(GetFillStyle());
153 return att;
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Get line attributes
158
160{
161 static TAttLine att;
162 att.SetLineColor(GetLineColor());
163 att.SetLineStyle(GetLineStyle());
164 att.SetLineWidth(GetLineWidth());
165 return att;
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// Get marker attributes
170
172{
173 static TAttMarker att;
174 att.SetMarkerColor(GetMarkerColor());
175 att.SetMarkerSize(GetMarkerSize());
176 att.SetMarkerStyle(GetMarkerStyle());
177 return att;
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Get text attributes
182
184{
185 static TAttText att;
186 att.SetTextAlign(GetTextAlign());
187 att.SetTextAngle(GetTextAngle());
188 att.SetTextColor(GetTextColor());
189 att.SetTextSize(GetTextSize());
190 att.SetTextFont(GetTextFont());
191 return att;
192}
193
194////////////////////////////////////////////////////////////////////////////////
195/// Draw image, need to be implemented in correspondent
196
#define h(i)
Definition RSha256.hxx:106
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetLineWidth
Option_t Option_t SetFillStyle
Option_t Option_t SetTextSize
Option_t Option_t SetLineColor
Option_t Option_t SetTextFont
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char DrawLine
Option_t Option_t SetMarkerStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint DrawText
Option_t Option_t TPoint TPoint const char text
R__EXTERN TPluginManager * gPluginMgr
Fill Area Attributes class.
Definition TAttFill.h:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:22
Text Attributes class.
Definition TAttText.h:21
An abstract interface to image processing library.
Definition TImage.h:29
TPluginHandler * FindHandler(const char *base, const char *uri=nullptr)
Returns the handler if there exists a handler for the specified URI.
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
virtual ~TVirtualPadPainter()
Virtual dtor.
virtual void SetAttFill(const TAttFill &att)
Set fill attributes.
virtual Float_t GetTextAngle() const =0
virtual Size_t GetMarkerSize() const
virtual Short_t GetTextAlign() const =0
virtual Font_t GetTextFont() const =0
virtual const TAttText & GetAttText() const
Get text attributes.
virtual void DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags=0)
Draw image, need to be implemented in correspondent.
virtual void SetTextAngle(Float_t tangle=0)=0
virtual Color_t GetLineColor() const =0
virtual void DrawTextUrl(Double_t x, Double_t y, const char *text, const char *url)
Draw text with url link By default only text is drawn.
virtual void SetAttMarker(const TAttMarker &att)
Set marker attributes.
virtual Float_t GetTextSize() const =0
virtual Color_t GetFillColor() const =0
virtual void DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v)
Draw N segments in NDC coordinates on the pad Exclude segments where both points match.
virtual void SetLineStyle(Style_t lstyle)=0
virtual Color_t GetMarkerColor() const
virtual void LockPainter()
Empty definition.
virtual Color_t GetTextColor() const =0
virtual Style_t GetMarkerStyle() const
virtual Style_t GetLineStyle() const =0
virtual void SetAttLine(const TAttLine &att)
Set line attributes.
virtual void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)=0
virtual void DrawSegments(Int_t n, Double_t *x, Double_t *y)
Draw N segments on the pad Exclude segments where both points match.
static TVirtualPadPainter * PadPainter(Option_t *opt="")
Create a pad painter of specified type.
virtual void SetAttText(const TAttText &att)
Set text attributes.
virtual Width_t GetLineWidth() const =0
virtual const TAttFill & GetAttFill() const
Get fill attributes.
virtual void InitPainter()
Empty definition.
virtual void SetTextAlign(Short_t align=11)=0
virtual void SetMarkerSize(Size_t=1)
virtual void SetMarkerColor(Color_t=1)
virtual Style_t GetFillStyle() const =0
virtual const TAttMarker & GetAttMarker() const
Get marker attributes.
virtual void SetTextColor(Color_t tcolor=1)=0
virtual void InvalidateCS()
Empty definition.
virtual const TAttLine & GetAttLine() const
Get line attributes.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16