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#include "TVirtualX.h"
19
20
21/** \class TVirtualPadPainter
22\ingroup Base
23
24To make it possible to use GL for 2D graphic in a TPad/TCanvas.
25TVirtualPadPainter interface must be used instead of TVirtualX.
26Internally, non-GL implementation _should_ delegate all calls
27to gVirtualX, GL implementation will delegate part of calls
28to gVirtualX, and has to implement some of the calls from the scratch.
29*/
30
31////////////////////////////////////////////////////////////////////////////////
32///Virtual dtor.
33
37
38////////////////////////////////////////////////////////////////////////////////
39///Empty definition.
40
44
45////////////////////////////////////////////////////////////////////////////////
46///Empty definition.
47
51
52////////////////////////////////////////////////////////////////////////////////
53///Empty definition.
54
58
59////////////////////////////////////////////////////////////////////////////////
60/// Create a pad painter of specified type.
61
63{
64 TVirtualPadPainter *painter = nullptr;
65 TPluginHandler *h = gPluginMgr->FindHandler("TVirtualPadPainter", type);
66
67 if (h && h->LoadPlugin() != -1)
68 painter = (TVirtualPadPainter *) h->ExecPlugin(0);
69
70 return painter;
71}
72
73
74////////////////////////////////////////////////////////////////////////////////
75/// Draw N segments on the pad
76/// Exclude segments where both points match
77
79{
80 for(Int_t i = 0; i < 2*n; i += 2)
81 if ((x[i] != x[i+1]) || (y[i] != y[i + 1]))
82 DrawLine(x[i], y[i], x[i+1], y[i+1]);
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Draw N segments in NDC coordinates on the pad
87/// Exclude segments where both points match
88
90{
91 for(Int_t i = 0; i < 2*n; i += 2)
92 if ((u[i] != u[i+1]) || (v[i] != v[i + 1]))
93 DrawLineNDC(u[i], v[i], u[i+1], v[i+1]);
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Draw text with url link
98/// By default only text is drawn
99
100void TVirtualPadPainter::DrawTextUrl(Double_t x, Double_t y, const char *text, const char * /* url */)
101{
102 DrawText(x, y, text, kClear);
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Set fill attributes
107
109{
110 SetFillColor(att.GetFillColor());
111 SetFillStyle(att.GetFillStyle());
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Set line attributes
116
118{
119 SetLineColor(att.GetLineColor());
120 SetLineStyle(att.GetLineStyle());
121 SetLineWidth(att.GetLineWidth());
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Set marker attributes
126
128{
129 SetMarkerColor(att.GetMarkerColor());
130 SetMarkerSize(att.GetMarkerSize());
131 SetMarkerStyle(att.GetMarkerStyle());
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Set text attributes
136
138{
139 SetTextAlign(att.GetTextAlign());
140 SetTextAngle(att.GetTextAngle());
141 SetTextColor(att.GetTextColor());
142 SetTextSize(att.GetTextSize());
143 SetTextFont(att.GetTextFont());
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Set double buffer mode for specified device, redirect to gVirtualX
148
150{
151 // TODO: move to actual painter classes, call only for selected device
152 if (gVirtualX)
153 gVirtualX->SetDoubleBuffer(device, mode);
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Set cursor for specified device, redirect to gVirtualX
158
160{
161 // TODO: move to actual painter classes, call only for selected device
162 if (gVirtualX)
163 gVirtualX->SetCursor(device, cursor);
164}
ECursor
Definition GuiTypes.h:373
#define h(i)
Definition RSha256.hxx:106
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
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 TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t SetFillStyle
Option_t Option_t SetTextSize
Option_t Option_t SetLineColor
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint const char mode
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
#define gVirtualX
Definition TVirtualX.h:365
Fill Area Attributes class.
Definition TAttFill.h:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:21
Text Attributes class.
Definition TAttText.h:21
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 void SetTextAngle(Float_t tangle=0)=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 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 void LockPainter()
Empty definition.
virtual void SetCursor(Int_t win, ECursor cursor)
Set cursor for specified device, redirect to gVirtualX.
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 void InitPainter()
Empty definition.
virtual void SetTextAlign(Short_t align=11)=0
virtual void SetMarkerSize(Size_t=1)
virtual void SetDoubleBuffer(Int_t device, Int_t mode)
Set double buffer mode for specified device, redirect to gVirtualX.
virtual void SetMarkerColor(Color_t=1)
virtual void SetTextColor(Color_t tcolor=1)=0
virtual void InvalidateCS()
Empty definition.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16