Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TWebPS.cxx
Go to the documentation of this file.
1// Author: Sergey Linev, GSI 23/10/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#include "TWebPS.h"
12
13#include <memory>
14
15/** \class TWebPS
16\ingroup webgui6
17
18*/
19
20
22{
24}
25
27{
28 fPainting = std::make_unique<TWebPainting>();
29}
30
31
32Float_t *TWebPS::StoreOperation(const std::string &oper, unsigned attrkind, int opersize)
33{
34 if (attrkind & attrLine)
35 fPainting->AddLineAttr(*this);
36
37 if (attrkind & attrFill)
38 fPainting->AddFillAttr(*this);
39
40 if (attrkind & attrMarker)
41 fPainting->AddMarkerAttr(*this);
42
43 if (attrkind & attrText)
44 fPainting->AddTextAttr(*this);
45
46 fPainting->AddOper(oper);
47
48 return fPainting->Reserve(opersize);
49}
50
52{
53 Float_t *buf = (GetFillStyle() > 0) ? StoreOperation("b", attrFill, 4) : StoreOperation("r", attrLine, 4);
54
55 buf[0] = x1;
56 buf[1] = y1;
57 buf[2] = x2;
58 buf[3] = y2;
59}
60
62{
63 if (nPoints < 1) return;
64
65 Float_t *buf = StoreOperation(std::string("m") + std::to_string(nPoints), attrLine | attrMarker, nPoints*2);
66
67 for (Int_t n=0;n<nPoints;++n) {
68 buf[n*2] = x[n];
69 buf[n*2+1] = y[n];
70 }
71}
72
74{
75 if (nPoints < 1) return;
76
77 Float_t *buf = StoreOperation(std::string("m") + std::to_string(nPoints), attrLine | attrMarker, nPoints*2);
78
79 for (Int_t n=0;n<nPoints;++n) {
80 buf[n*2] = x[n];
81 buf[n*2+1] = y[n];
82 }
83}
84
85void TWebPS::DrawPS(Int_t nPoints, Float_t *xw, Float_t *yw)
86{
87 Float_t *buf = nullptr;
88 if (nPoints < 0) {
89 nPoints = -nPoints;
90 if ((GetFillStyle() <= 0) || (nPoints < 3)) return;
91 buf = StoreOperation(std::string("f") + std::to_string(nPoints), attrFill, nPoints*2);
92 } else {
93 if ((GetLineWidth() <= 0) || (nPoints < 2)) return;
94 buf = StoreOperation(std::string("l") + std::to_string(nPoints), attrLine, nPoints*2);
95 }
96 for (Int_t n=0;n<nPoints;++n) {
97 buf[n*2] = xw[n];
98 buf[n*2+1] = yw[n];
99 }
100}
101
102void TWebPS::DrawPS(Int_t nPoints, Double_t *xw, Double_t *yw)
103{
104 Float_t *buf = nullptr;
105 if (nPoints < 0) {
106 nPoints = -nPoints;
107 if ((GetFillStyle() <= 0) || (nPoints < 3)) return;
108 buf = StoreOperation(std::string("f") + std::to_string(nPoints), attrFill, nPoints*2);
109 } else {
110 if ((GetLineWidth() <= 0) || (nPoints < 2)) return;
111 buf = StoreOperation(std::string("l") + std::to_string(nPoints), attrLine, nPoints*2);
112 }
113 for (Int_t n=0;n<nPoints;++n) {
114 buf[n*2] = xw[n];
115 buf[n*2+1] = yw[n];
116 }
117}
118
119void TWebPS::Text(Double_t x, Double_t y, const char *str)
120{
122 buf[0] = x;
123 buf[1] = y;
124}
125
126
127void TWebPS::Text(Double_t x, Double_t y, const wchar_t *)
128{
130 buf[0] = x;
131 buf[1] = y;
132}
float Float_t
Definition RtypesCore.h:57
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:31
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:35
void CreatePainting()
Definition TWebPS.cxx:26
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Definition TWebPS.cxx:51
Float_t * StoreOperation(const std::string &oper, unsigned attrkind, int opersize=0)
Definition TWebPS.cxx:32
std::unique_ptr< TWebPainting > fPainting
Definition TWebPS.h:23
@ attrFill
Definition TWebPS.h:25
@ attrMarker
Definition TWebPS.h:25
@ attrLine
Definition TWebPS.h:25
@ attrText
Definition TWebPS.h:25
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Definition TWebPS.cxx:61
TWebPS()
Definition TWebPS.cxx:21
void Text(Double_t x, Double_t y, const char *str) override
Definition TWebPS.cxx:119
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Definition TWebPS.cxx:85
static std::string MakeTextOper(const char *str)
Create text operation If text include special symbols - use simple hex coding.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16