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
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;
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
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 = dynamic_cast<TPolyLineInteractive *>(parent.Interactive(this));
311
312 switch (event) {
313
314 case kArrowKeyPress:
315 case kButton1Down:
317 parent.Interactive(this, inter);
318 // No break !!!
319 case kMouseMotion: {
320 Int_t minDiff = kMaxDiff, ipoint = -1;
321 for (Int_t i = 0; i < np; i++) {
322 Int_t pxp, pyp;
323 get_point(i, pxp, pyp);
324 if ((i == 0) && inter) {
325 inter->sdx = pxp - px;
326 inter->sdy = pyp - py;
327 }
328 Int_t d = TMath::Abs(pxp - px) + TMath::Abs(pyp - py);
329 if (d < minDiff) {
330 ipoint = i;
331 minDiff = d;
332 if (inter) {
333 inter->sdx = pxp - px;
334 inter->sdy = pyp - py;
335 }
336 }
337 }
338 if (ipoint < 0)
339 parent.SetCursor(kMove);
340 else
341 parent.SetCursor(kHand);
342 if (inter)
343 inter->ipoint = ipoint;
344 break;
345 }
346
347 case kButton1Motion:
348 if (!inter)
349 break;
350
351 if (inter->ipoint < 0) {
352 Int_t pxp0 = 0, pyp0 = 0, pxp = 0, pyp = 0;
353 // move all points
354 for (Int_t i = 0; i < np; i++) {
355 get_point(i, pxp, pyp);
356 if (i == 0) {
357 pxp0 = pxp;
358 pyp0 = pyp;
359 }
360 set_point(i, px + inter->sdx + pxp - pxp0, py + inter->sdy + pyp - pyp0);
361 }
362 } else {
363 // move only selected point
364 set_point(inter->ipoint, px + inter->sdx, py + inter->sdy);
365 }
366 if (is_last_same) {
367 fX[np] = fX[0];
368 fY[np] = fY[0];
369 }
370
371 if (!opaque)
372 paint_hollow();
373 else
374 parent.Modified();
375 parent.UpdateAsync();
376 break;
377
378 case kButton1Up:
379 if (!opaque) {
380 parent.Modified();
381 parent.UpdateAsync();
382 }
383 parent.Interactive(); // delete interactive object
384 break;
385 }
386}
387
388////////////////////////////////////////////////////////////////////////////////
389/// List this polyline with its attributes.
390/// The option string is ignored.
391
393{
395 printf("TPolyLine N=%d\n",fN);
396}
397
398////////////////////////////////////////////////////////////////////////////////
399/// Merge polylines in the collection in this polyline
400
402{
403 if (!li) return 0;
404 TIter next(li);
405
406 //first loop to count the number of entries
407 TPolyLine *pl;
408 Int_t npoints = 0;
409 while ((pl = (TPolyLine*)next())) {
410 if (!pl->InheritsFrom(TPolyLine::Class())) {
411 Error("Add","Attempt to add object of class: %s to a %s",pl->ClassName(),this->ClassName());
412 return -1;
413 }
414 npoints += pl->Size();
415 }
416
417 //extend this polyline to hold npoints
418 if (npoints > 1) SetPoint(npoints-1,0,0);
419
420 //merge all polylines
421 next.Reset();
422 while ((pl = (TPolyLine*)next())) {
423 Int_t np = pl->Size();
424 Double_t *x = pl->GetX();
425 Double_t *y = pl->GetY();
426 for (Int_t i=0;i<np;i++) {
427 SetPoint(i,x[i],y[i]);
428 }
429 }
430
431 return npoints;
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Paint this polyline with its current attributes.
436
444
445////////////////////////////////////////////////////////////////////////////////
446/// Draw this polyline with new coordinates.
447///
448/// If option = 'f' or 'F' the fill area is drawn.
449/// The default is to draw the lines only.
450
452{
453 if (!gPad || n <= 0) return;
454 TAttLine::Modify(); //Change line attributes only if necessary
455 TAttFill::Modify(); //Change fill area attributes only if necessary
456 std::vector<Double_t> xx, yy;
457 if (gPad->GetLogx()) {
458 xx.resize(n);
459 for (Int_t ix = 0; ix < n; ix++)
460 xx[ix] = gPad->XtoPad(x[ix]);
461 x = xx.data();
462 }
463 if (gPad->GetLogy()) {
464 yy.resize(n);
465 for (Int_t iy = 0; iy < n; iy++)
466 yy[iy] = gPad->YtoPad(y[iy]);
467 y = yy.data();
468 }
469 if (option && (*option == 'f' || *option == 'F'))
470 gPad->PaintFillArea(n, x, y, option);
471 else
472 gPad->PaintPolyLine(n, x, y, option);
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Draw this polyline with new coordinates in NDC.
477
479{
480 TAttLine::Modify(); // Change line attributes only if necessary
481 TAttFill::Modify(); // Change fill area attributes only if necessary
482 if (option && (*option == 'f' || *option == 'F'))
483 gPad->PaintFillAreaNDC(n, x, y, option);
484 else
485 gPad->PaintPolyLineNDC(n, x, y, option);
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Dump this polyline with its attributes.
490/// The option string is ignored.
491
493{
494 printf("PolyLine N=%d\n",fN);
495}
496
497////////////////////////////////////////////////////////////////////////////////
498/// Save primitive as a C++ statement(s) on output stream out
499
500void TPolyLine::SavePrimitive(std::ostream &out, Option_t *option)
501{
502 TString args;
503 if (Size() > 0) {
504 TString arrx = SavePrimitiveVector(out, "polyline", Size(), fX, kTRUE);
505 TString arry = SavePrimitiveVector(out, "polyline", Size(), fY);
506 args.Form("%d, %s.data(), %s.data(), ", Size(), arrx.Data(), arry.Data());
507 } else {
508 args.Form("%d, ", fN);
509 }
510 args.Append(TString::Format("\"%s\"", TString(fOption).ReplaceSpecialCppChars().Data()));
511
512 SavePrimitiveConstructor(out, Class(), "polyline", args, Size() == 0);
513 SaveFillAttributes(out, "polyline", -1, -1);
514 SaveLineAttributes(out, "polyline", 1, 1, 1);
515
516 if (!option || !strstr(option, "nodraw"))
517 out << " polyline->Draw(\"" << TString(option).ReplaceSpecialCppChars() << "\");\n";
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Set NDC mode on if isNDC = kTRUE, off otherwise
522
524{
526 if (isNDC) SetBit(kPolyLineNDC);
527}
528
529////////////////////////////////////////////////////////////////////////////////
530/// Set point following LastPoint to x, y.
531/// Returns index of the point (new last point).
532
539
540////////////////////////////////////////////////////////////////////////////////
541/// Set point number n to (x, y)
542/// If n is greater than the current size, the arrays are automatically
543/// extended.
544
546{
547 if (n < 0) return;
548 if (!fX || !fY || n >= fN) {
549 // re-allocate the object
550 Int_t newN = TMath::Max(2*fN,n+1);
551 Double_t *savex = new Double_t [newN];
552 Double_t *savey = new Double_t [newN];
553 if (fX && fN){
554 memcpy(savex,fX,fN*sizeof(Double_t));
555 memset(&savex[fN],0,(newN-fN)*sizeof(Double_t));
556 delete [] fX;
557 }
558 if (fY && fN){
559 memcpy(savey,fY,fN*sizeof(Double_t));
560 memset(&savey[fN],0,(newN-fN)*sizeof(Double_t));
561 delete [] fY;
562 }
563 fX = savex;
564 fY = savey;
565 fN = newN;
566 }
567 fX[n] = x;
568 fY[n] = y;
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Resize this polyline to size n.
574/// If n <= 0 the current arrays of points are deleted.
575/// If n is greater than the current size, the new points are set to (0, 0)
576
578{
579 if (n <= 0) {
580 fN = 0;
581 fLastPoint = -1;
582 delete [] fX;
583 delete [] fY;
584 fX = fY = nullptr;
585 return;
586 }
587 if (n < fN) {
588 fN = n;
589 fLastPoint = n - 1;
590 } else {
591 SetPoint(n-1,0,0);
592 }
593}
594
595////////////////////////////////////////////////////////////////////////////////
596/// Set new values for this polyline (single precision).
597///
598/// If n <= 0 the current arrays of points are deleted.
599
601{
602 if (n <= 0) {
603 fN = 0;
604 fLastPoint = -1;
605 delete [] fX;
606 delete [] fY;
607 fX = fY = nullptr;
608 return;
609 }
610 fN =n;
611 if (fX) delete [] fX;
612 if (fY) delete [] fY;
613 fX = new Double_t[fN];
614 fY = new Double_t[fN];
615 for (Int_t i=0; i<fN;i++) {
616 if (x) fX[i] = (Double_t)x[i];
617 if (y) fY[i] = (Double_t)y[i];
618 }
619 fOption = option;
620 fLastPoint = fN-1;
621}
622
623////////////////////////////////////////////////////////////////////////////////
624/// Set new values for this polyline (double precision).
625///
626/// If n <= 0 the current arrays of points are deleted.
627
629{
630 if (n <= 0) {
631 fN = 0;
632 fLastPoint = -1;
633 delete [] fX;
634 delete [] fY;
635 fX = fY = nullptr;
636 return;
637 }
638 fN =n;
639 if (fX) delete [] fX;
640 if (fY) delete [] fY;
641 fX = new Double_t[fN];
642 fY = new Double_t[fN];
643 for (Int_t i=0; i<fN;i++) {
644 if (x) fX[i] = x[i];
645 if (y) fY[i] = y[i];
646 }
647 fOption = option;
648 fLastPoint = fN-1;
649}
650
651////////////////////////////////////////////////////////////////////////////////
652/// Stream a class object.
653
655{
656 if (b.IsReading()) {
658 Version_t R__v = b.ReadVersion(&R__s, &R__c);
659 if (R__v > 1) {
660 b.ReadClassBuffer(TPolyLine::Class(), this, R__v, R__s, R__c);
661 return;
662 }
663 //====process old versions before automatic schema evolution
667 b >> fN;
668 fX = new Double_t[fN];
669 fY = new Double_t[fN];
670 Float_t *x = new Float_t[fN];
671 Float_t *y = new Float_t[fN];
672 b.ReadFastArray(x,fN);
673 b.ReadFastArray(y,fN);
674 for (Int_t i=0;i<fN;i++) {
675 fX[i] = x[i];
676 fY[i] = y[i];
677 }
679 b.CheckByteCount(R__s, R__c, TPolyLine::IsA());
680 //====end of old versions
681
682 delete [] x;
683 delete [] y;
684 } else {
685 b.WriteClassBuffer(TPolyLine::Class(),this);
686 }
687}
@ 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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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 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.
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.
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 gPad->Interact...
Definition TVirtualPad.h:75
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