Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPolyLine.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Rene Brun 12/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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 <iostream>
13#include <vector>
14#include "TROOT.h"
15#include "TBuffer.h"
16#include "TMath.h"
17#include "TVirtualPad.h"
18#include "TPolyLine.h"
19
20
21/** \class TPolyLine
22\ingroup BasicGraphics
23
24Defined by an array on N points in a 2-D space.
25
26One can draw the contour of the polyline or/and its fill area.
27Example:
28Begin_Macro(source)
29{
30 Double_t x[5] = {.2,.7,.6,.25,.2};
31 Double_t y[5] = {.5,.1,.9,.7,.5};
32 TPolyLine *pline = new TPolyLine(5,x,y);
33 pline->SetFillColor(38);
34 pline->SetLineColor(2);
35 pline->SetLineWidth(4);
36 pline->Draw("f");
37 pline->Draw();
38}
39End_Macro
40*/
41
42////////////////////////////////////////////////////////////////////////////////
43/// PolyLine default constructor.
44
48
49////////////////////////////////////////////////////////////////////////////////
50/// PolyLine normal constructor without initialisation.
51/// Allocates n points.
52
55{
57 if (n <= 0)
58 return;
59
60 fN = n;
61 fX = new Double_t[fN];
62 fY = new Double_t[fN];
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// PolyLine normal constructor (single precision).
67/// Makes n points with (x, y) coordinates from x and y.
68
71{
73 if (n <= 0)
74 return;
75
76 fN = n;
77 fX = new Double_t[fN];
78 fY = new Double_t[fN];
79 if (!x || !y) return;
80 for (Int_t i = 0; i < fN; i++) {
81 fX[i] = x[i];
82 fY[i] = y[i];
83 }
84 fLastPoint = fN-1;
85}
86
87////////////////////////////////////////////////////////////////////////////////
88/// PolyLine normal constructor (double precision).
89/// Makes n points with (x, y) coordinates from x and y.
90
93{
95 if (n <= 0)
96 return;
97 fN = n;
98 fX = new Double_t[fN];
99 fY = new Double_t[fN];
100 if (!x || !y) return;
101 for (Int_t i=0; i<fN;i++) {
102 fX[i] = x[i];
103 fY[i] = y[i];
104 }
105 fLastPoint = fN-1;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109///assignment operator
110
112{
113 if(this != &pl)
114 pl.TPolyLine::Copy(*this);
115 return *this;
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// PolyLine default destructor.
120
122{
123 if (fX) delete [] fX;
124 if (fY) delete [] fY;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// PolyLine copy constructor.
129
130TPolyLine::TPolyLine(const TPolyLine &polyline) : TObject(polyline), TAttLine(polyline), TAttFill(polyline)
131{
132 polyline.TPolyLine::Copy(*this);
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Copy this polyline to polyline.
137
138void TPolyLine::Copy(TObject &obj) const
139{
140 TObject::Copy(obj);
141 TAttLine::Copy(((TPolyLine&)obj));
142 TAttFill::Copy(((TPolyLine&)obj));
143 ((TPolyLine&)obj).fN = fN;
144 delete [] ((TPolyLine&)obj).fX;
145 delete [] ((TPolyLine&)obj).fY;
146 if (fN > 0) {
147 ((TPolyLine&)obj).fX = new Double_t[fN];
148 ((TPolyLine&)obj).fY = new Double_t[fN];
149 for (Int_t i = 0; i < fN; i++) {
150 ((TPolyLine &)obj).fX[i] = fX[i];
151 ((TPolyLine &)obj).fY[i] = fY[i];
152 }
153 } else {
154 ((TPolyLine&)obj).fX = nullptr;
155 ((TPolyLine&)obj).fY = nullptr;
156 }
157 ((TPolyLine&)obj).fOption = fOption;
158 ((TPolyLine&)obj).fLastPoint = fLastPoint;
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Returns closest distance in pixels from point (px, py) to a polyline.
163///
164/// First looks for distances to the points of the polyline. Stops search
165/// and returns if a vertex of the polyline is found to be closer than 10
166/// pixels. Thus the return value may depend on the ordering of points
167/// in the polyline.
168///
169/// Then looks for distances to the lines of the polyline. There is no
170/// arbitrary cutoff; any distance may be found.
171///
172/// Finally checks whether (px, py) is inside a closed and filled polyline.
173/// (Must be EXACTLY closed. "Filled" means fill color and fill style are
174/// both non-zero.) If so, returns zero.
175///
176/// Returns 9999 if the polyline has no points.
177
179{
180 const Int_t big = 9999;
181 if (!gPad) return big;
182 const Int_t kMaxDiff = 10;
183
184 // check if point is near one of the points
185 Int_t i, pxp, pyp, d;
186 Int_t distance = big;
187 if (Size() <= 0) return distance;
188
189 for (i=0;i<Size();i++) {
190 pxp = gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
191 pyp = gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
192 d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py);
193 if (d < distance) distance = d;
194 }
195 if (distance < kMaxDiff) return distance;
196
197 // check if point is near one of the connecting lines
198 for (i=0;i<Size()-1;i++) {
199 d = DistancetoLine(px, py, gPad->XtoPad(fX[i]), gPad->YtoPad(fY[i]), gPad->XtoPad(fX[i+1]), gPad->YtoPad(fY[i+1]));
200 if (d < distance) distance = d;
201 }
202
203 // in case of a closed and filled polyline, check if we are inside
204 if (fFillColor && fFillStyle && fX[0] == fX[fLastPoint] && fY[0] == fY[fLastPoint]) {
205 if (TMath::IsInside(gPad->AbsPixeltoX(px),gPad->AbsPixeltoY(py),fLastPoint+1,fX,fY)) distance = 0;
206 }
207 return distance;
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Draw this polyline with its current attributes.
212
217
218////////////////////////////////////////////////////////////////////////////////
219/// Draw this polyline with new coordinates.
220
222{
223 TPolyLine *newpolyline = new TPolyLine(n,x,y);
224 TAttLine::Copy(*newpolyline);
225 TAttFill::Copy(*newpolyline);
226 newpolyline->fOption = fOption;
227 newpolyline->SetBit(kCanDelete);
228 newpolyline->AppendPad(option);
229 return newpolyline;
230}
231
233 public:
234 Int_t sdx = 0, sdy = 0, ipoint = 0;
235};
236
237
238////////////////////////////////////////////////////////////////////////////////
239/// Execute action corresponding to one event.
240///
241/// This member function is called when a polyline is clicked with the locator
242///
243/// If Left button clicked on one of the line end points, this point
244/// follows the cursor until button is released.
245///
246/// if Middle button clicked, the line is moved parallel to itself
247/// until the button is released.
248
250{
251 if (!gPad || !gPad->IsEditable()) return;
252
253 auto &parent = *gPad;
254
255 constexpr Int_t kMaxDiff = 10;
256 Bool_t opaque = parent.OpaqueMoving();
257
258 Int_t np = Size();
259 Bool_t is_last_same = (np > 1) && (fX[0] == fX[np-1]) && (fY[0] == fY[np-1]);
260 if (is_last_same)
261 np--;
262
263 auto paint_hollow = [this, &parent] () {
264 TAttLine::ModifyOn(parent);
265 if (TestBit(kPolyLineNDC)) {
266 parent.PaintPolyLineNDC(Size(), fX, fY, "ipolyline");
267 } else {
268 Double_t *x = fX, *y = fY;
269 std::vector<Double_t> xx, yy;
270 if (parent.GetLogx()) {
271 xx.resize(Size());
272 for (Int_t ix = 0; ix < Size(); ix++)
273 xx[ix] = parent.XtoPad(x[ix]);
274 x = xx.data();
275 }
276 if (parent.GetLogy()) {
277 yy.resize(Size());
278 for (Int_t iy = 0; iy < Size(); iy++)
279 yy[iy] = parent.YtoPad(y[iy]);
280 y = yy.data();
281 }
282 parent.PaintPolyLine(Size(), x, y, "ipolyline");
283 }
284 };
285
286 auto get_point = [this, &parent](Int_t i, Int_t &pntx, Int_t &pnty) {
287 if (TestBit(kPolyLineNDC)) {
288 pntx = parent.UtoAbsPixel(fX[i]);
289 pnty = parent.VtoAbsPixel(fY[i]);
290 } else {
291 pntx = parent.XtoAbsPixel(parent.XtoPad(fX[i]));
292 pnty = parent.YtoAbsPixel(parent.YtoPad(fY[i]));
293 }
294 };
295
296 auto set_point = [this, &parent](Int_t i, Int_t pntx, Int_t pnty) {
297 if (TestBit(kPolyLineNDC)) {
298 Double_t ww = parent.GetWw();
299 Double_t wndc = parent.GetAbsWNDC();
300 Double_t wh = parent.GetWh();
301 Double_t hndc = parent.GetAbsHNDC();
302 fX[i] = ww > 0 && wndc > 0 ? (pntx / ww - parent.GetAbsXlowNDC()) / wndc : 0.;
303 fY[i] = wh > 0 && hndc > 0 ? ((1. - pnty / wh) - parent.GetAbsYlowNDC()) / hndc : 0.;
304 } else {
305 fX[i] = parent.PadtoX(parent.AbsPixeltoX(pntx));
306 fY[i] = parent.PadtoY(parent.AbsPixeltoY(pnty));
307 }
308 };
309
310 auto inter = parent.GetInteractive<TPolyLineInteractive>(this);
311
312 switch (event) {
313
314 case kArrowKeyPress:
315 case kButton1Down:
316 inter = parent.MakeInteractive<TPolyLineInteractive>(this);
317 // No break !!!
318 case kMouseMotion: {
319 Int_t minDiff = kMaxDiff, ipoint = -1;
320 for (Int_t i = 0; i < np; i++) {
321 Int_t pxp, pyp;
322 get_point(i, pxp, pyp);
323 if ((i == 0) && inter) {
324 inter->sdx = pxp - px;
325 inter->sdy = pyp - py;
326 }
327 Int_t d = TMath::Abs(pxp - px) + TMath::Abs(pyp - py);
328 if (d < minDiff) {
329 ipoint = i;
330 minDiff = d;
331 if (inter) {
332 inter->sdx = pxp - px;
333 inter->sdy = pyp - py;
334 }
335 }
336 }
337 if (ipoint < 0)
338 parent.SetCursor(kMove);
339 else
340 parent.SetCursor(kHand);
341 if (inter)
342 inter->ipoint = ipoint;
343 break;
344 }
345
346 case kButton1Motion:
347 if (!inter)
348 break;
349
350 if (inter->ipoint < 0) {
351 Int_t pxp0 = 0, pyp0 = 0, pxp = 0, pyp = 0;
352 // move all points
353 for (Int_t i = 0; i < np; i++) {
354 get_point(i, pxp, pyp);
355 if (i == 0) {
356 pxp0 = pxp;
357 pyp0 = pyp;
358 }
359 set_point(i, px + inter->sdx + pxp - pxp0, py + inter->sdy + pyp - pyp0);
360 }
361 } else {
362 // move only selected point
363 set_point(inter->ipoint, px + inter->sdx, py + inter->sdy);
364 }
365 if (is_last_same) {
366 fX[np] = fX[0];
367 fY[np] = fY[0];
368 }
369
370 if (!opaque)
371 paint_hollow();
372 else
373 parent.Modified();
374 parent.UpdateAsync();
375 break;
376
377 case kButton1Up:
378 if (!opaque) {
379 parent.Modified();
380 parent.UpdateAsync();
381 }
382 parent.FreeInteractive(this);
383 break;
384 }
385}
386
387////////////////////////////////////////////////////////////////////////////////
388/// List this polyline with its attributes.
389/// The option string is ignored.
390
392{
394 printf("TPolyLine N=%d\n",fN);
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Merge polylines in the collection in this polyline
399
401{
402 if (!li) return 0;
403 TIter next(li);
404
405 //first loop to count the number of entries
406 TPolyLine *pl;
407 Int_t npoints = 0;
408 while ((pl = (TPolyLine*)next())) {
409 if (!pl->InheritsFrom(TPolyLine::Class())) {
410 Error("Add","Attempt to add object of class: %s to a %s",pl->ClassName(),this->ClassName());
411 return -1;
412 }
413 npoints += pl->Size();
414 }
415
416 //extend this polyline to hold npoints
417 if (npoints > 1) SetPoint(npoints-1,0,0);
418
419 //merge all polylines
420 next.Reset();
421 while ((pl = (TPolyLine*)next())) {
422 Int_t np = pl->Size();
423 Double_t *x = pl->GetX();
424 Double_t *y = pl->GetY();
425 for (Int_t i=0;i<np;i++) {
426 SetPoint(i,x[i],y[i]);
427 }
428 }
429
430 return npoints;
431}
432
433////////////////////////////////////////////////////////////////////////////////
434/// Paint this polyline with its current attributes.
435
443
444////////////////////////////////////////////////////////////////////////////////
445/// Draw this polyline with new coordinates.
446///
447/// If option = 'f' or 'F' the fill area is drawn.
448/// The default is to draw the lines only.
449
451{
452 if (!gPad || n <= 0) return;
453 TAttLine::Modify(); //Change line attributes only if necessary
454 TAttFill::Modify(); //Change fill area attributes only if necessary
455 std::vector<Double_t> xx, yy;
456 if (gPad->GetLogx()) {
457 xx.resize(n);
458 for (Int_t ix = 0; ix < n; ix++)
459 xx[ix] = gPad->XtoPad(x[ix]);
460 x = xx.data();
461 }
462 if (gPad->GetLogy()) {
463 yy.resize(n);
464 for (Int_t iy = 0; iy < n; iy++)
465 yy[iy] = gPad->YtoPad(y[iy]);
466 y = yy.data();
467 }
468 if (option && (*option == 'f' || *option == 'F'))
469 gPad->PaintFillArea(n, x, y, option);
470 else
471 gPad->PaintPolyLine(n, x, y, option);
472}
473
474////////////////////////////////////////////////////////////////////////////////
475/// Draw this polyline with new coordinates in NDC.
476
478{
479 TAttLine::Modify(); // Change line attributes only if necessary
480 TAttFill::Modify(); // Change fill area attributes only if necessary
481 if (option && (*option == 'f' || *option == 'F'))
482 gPad->PaintFillAreaNDC(n, x, y, option);
483 else
484 gPad->PaintPolyLineNDC(n, x, y, option);
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Dump this polyline with its attributes.
489/// The option string is ignored.
490
492{
493 printf("PolyLine N=%d\n",fN);
494}
495
496////////////////////////////////////////////////////////////////////////////////
497/// Save primitive as a C++ statement(s) on output stream out
498
499void TPolyLine::SavePrimitive(std::ostream &out, Option_t *option)
500{
501 TString args;
502 if (Size() > 0) {
503 TString arrx = SavePrimitiveVector(out, "polyline", Size(), fX, kTRUE);
504 TString arry = SavePrimitiveVector(out, "polyline", Size(), fY);
505 args.Form("%d, %s.data(), %s.data(), ", Size(), arrx.Data(), arry.Data());
506 } else {
507 args.Form("%d, ", fN);
508 }
509 args.Append(TString::Format("\"%s\"", TString(fOption).ReplaceSpecialCppChars().Data()));
510
511 SavePrimitiveConstructor(out, Class(), "polyline", args, Size() == 0);
512 SaveFillAttributes(out, "polyline", -1, -1);
513 SaveLineAttributes(out, "polyline", 1, 1, 1);
514
515 if (!option || !strstr(option, "nodraw"))
516 out << " polyline->Draw(\"" << TString(option).ReplaceSpecialCppChars() << "\");\n";
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Set NDC mode on if isNDC = kTRUE, off otherwise
521
523{
525 if (isNDC) SetBit(kPolyLineNDC);
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Set point following LastPoint to x, y.
530/// Returns index of the point (new last point).
531
538
539////////////////////////////////////////////////////////////////////////////////
540/// Set point number n to (x, y)
541/// If n is greater than the current size, the arrays are automatically
542/// extended.
543
545{
546 if (n < 0) return;
547 if (!fX || !fY || n >= fN) {
548 // re-allocate the object
549 Int_t newN = TMath::Max(2*fN,n+1);
550 Double_t *savex = new Double_t [newN];
551 Double_t *savey = new Double_t [newN];
552 if (fX && fN){
553 memcpy(savex,fX,fN*sizeof(Double_t));
554 memset(&savex[fN],0,(newN-fN)*sizeof(Double_t));
555 delete [] fX;
556 }
557 if (fY && fN){
558 memcpy(savey,fY,fN*sizeof(Double_t));
559 memset(&savey[fN],0,(newN-fN)*sizeof(Double_t));
560 delete [] fY;
561 }
562 fX = savex;
563 fY = savey;
564 fN = newN;
565 }
566 fX[n] = x;
567 fY[n] = y;
569}
570
571////////////////////////////////////////////////////////////////////////////////
572/// Resize this polyline to size n.
573/// If n <= 0 the current arrays of points are deleted.
574/// If n is greater than the current size, the new points are set to (0, 0)
575
577{
578 if (n <= 0) {
579 fN = 0;
580 fLastPoint = -1;
581 delete [] fX;
582 delete [] fY;
583 fX = fY = nullptr;
584 return;
585 }
586 if (n < fN) {
587 fN = n;
588 fLastPoint = n - 1;
589 } else {
590 SetPoint(n-1,0,0);
591 }
592}
593
594////////////////////////////////////////////////////////////////////////////////
595/// Set new values for this polyline (single precision).
596///
597/// If n <= 0 the current arrays of points are deleted.
598
600{
601 if (n <= 0) {
602 fN = 0;
603 fLastPoint = -1;
604 delete [] fX;
605 delete [] fY;
606 fX = fY = nullptr;
607 return;
608 }
609 fN =n;
610 if (fX) delete [] fX;
611 if (fY) delete [] fY;
612 fX = new Double_t[fN];
613 fY = new Double_t[fN];
614 for (Int_t i=0; i<fN;i++) {
615 if (x) fX[i] = (Double_t)x[i];
616 if (y) fY[i] = (Double_t)y[i];
617 }
618 fOption = option;
619 fLastPoint = fN-1;
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// Set new values for this polyline (double precision).
624///
625/// If n <= 0 the current arrays of points are deleted.
626
628{
629 if (n <= 0) {
630 fN = 0;
631 fLastPoint = -1;
632 delete [] fX;
633 delete [] fY;
634 fX = fY = nullptr;
635 return;
636 }
637 fN =n;
638 if (fX) delete [] fX;
639 if (fY) delete [] fY;
640 fX = new Double_t[fN];
641 fY = new Double_t[fN];
642 for (Int_t i=0; i<fN;i++) {
643 if (x) fX[i] = x[i];
644 if (y) fY[i] = y[i];
645 }
646 fOption = option;
647 fLastPoint = fN-1;
648}
649
650////////////////////////////////////////////////////////////////////////////////
651/// Stream a class object.
652
654{
655 if (b.IsReading()) {
656 UInt_t R__s, R__c;
657 Version_t R__v = b.ReadVersion(&R__s, &R__c);
658 if (R__v > 1) {
659 b.ReadClassBuffer(TPolyLine::Class(), this, R__v, R__s, R__c);
660 return;
661 }
662 //====process old versions before automatic schema evolution
666 b >> fN;
667 fX = new Double_t[fN];
668 fY = new Double_t[fN];
669 Float_t *x = new Float_t[fN];
670 Float_t *y = new Float_t[fN];
671 b.ReadFastArray(x,fN);
672 b.ReadFastArray(y,fN);
673 for (Int_t i=0;i<fN;i++) {
674 fX[i] = x[i];
675 fY[i] = y[i];
676 }
678 b.CheckByteCount(R__s, R__c, TPolyLine::IsA());
679 //====end of old versions
680
681 delete [] x;
682 delete [] y;
683 } else {
684 b.WriteClassBuffer(TPolyLine::Class(),this);
685 }
686}
@ kMouseMotion
Definition Buttons.h:23
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kArrowKeyPress
Definition Buttons.h:21
@ kButton1Down
Definition Buttons.h:17
@ kMove
Definition GuiTypes.h:375
@ kHand
Definition GuiTypes.h:375
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
cudaEvent_t event
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
Option_t Option_t option
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 np
#define gPad
Fill Area Attributes class.
Definition TAttFill.h:21
virtual void Streamer(TBuffer &)
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition TAttFill.cxx:203
virtual void Modify()
Change current fill area attributes if necessary.
Definition TAttFill.cxx:212
Style_t fFillStyle
Fill area style.
Definition TAttFill.h:25
Color_t fFillColor
Fill area color.
Definition TAttFill.h:24
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition TAttFill.cxx:240
Line Attributes class.
Definition TAttLine.h:21
virtual void Streamer(TBuffer &)
virtual void ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
Definition TAttLine.cxx:255
virtual void Modify()
Change current line attributes if necessary.
Definition TAttLine.cxx:246
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:176
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
Definition TAttLine.cxx:210
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition TAttLine.cxx:289
Buffer base class used for serializing objects.
Definition TBuffer.h:43
Collection abstract base class.
Definition TCollection.h:65
void Reset()
Mother of all ROOT objects.
Definition TObject.h:42
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:995
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:158
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:776
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
Definition TObject.cxx:795
void ResetBit(UInt_t f)
Definition TObject.h:203
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
Defined by an array on N points in a 2-D space.
Definition TPolyLine.h:23
TString fOption
options
Definition TPolyLine.h:30
virtual Int_t Size() const
Definition TPolyLine.h:71
Int_t fLastPoint
The index of the last filled point.
Definition TPolyLine.h:27
virtual Int_t Merge(TCollection *list)
Merge polylines in the collection in this polyline.
virtual void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates in NDC.
void Copy(TObject &polyline) const override
Copy this polyline to polyline.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Returns closest distance in pixels from point (px, py) to a polyline.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Double_t * GetX() const
Definition TPolyLine.h:54
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
virtual void SetPoint(Int_t point, Double_t x, Double_t y)
Set point number n to (x, y) If n is greater than the current size, the arrays are automatically exte...
TPolyLine()
PolyLine default constructor.
Definition TPolyLine.cxx:45
TClass * IsA() const override
Definition TPolyLine.h:73
~TPolyLine() override
PolyLine default destructor.
Double_t * GetY() const
Definition TPolyLine.h:55
virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
void Draw(Option_t *option="") override
Draw this polyline with its current attributes.
Double_t * fX
[fN] Array of X coordinates
Definition TPolyLine.h:28
static TClass * Class()
void Paint(Option_t *option="") override
Paint this polyline with its current attributes.
void ls(Option_t *option="") const override
List this polyline with its attributes.
TPolyLine & operator=(const TPolyLine &)
assignment operator
void Streamer(TBuffer &) override
Stream a class object.
virtual TPolyLine * DrawPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
Int_t fN
Number of points.
Definition TPolyLine.h:26
Double_t * fY
[fN] Array of Y coordinates
Definition TPolyLine.h:29
virtual void SetPolyLine(Int_t n)
Resize this polyline to size n.
@ kPolyLineNDC
Polyline coordinates are in NDC space.
Definition TPolyLine.h:37
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual Int_t SetNextPoint(Double_t x, Double_t y)
Set point following LastPoint to x, y.
void Print(Option_t *option="") const override
Dump this polyline with its attributes.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3067
Basic string class.
Definition TString.h:137
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
const char * Data() const
Definition TString.h:385
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1493
TString & Append(const char *cs)
Definition TString.h:582
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2438
Helper class to store interactive parameters for individual objects Should be used via MakeInteractiv...
Definition TVirtualPad.h:72
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Definition TMath.h:1326
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122