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 "TVirtualPadPainter.h"
19#include "TAttMarker.h"
20#include "TPolyLine.h"
21
22
23/** \class TPolyLine
24\ingroup BasicGraphics
25
26Defined by an array on N points in a 2-D space.
27
28One can draw the contour of the polyline or/and its fill area.
29Example:
30Begin_Macro(source)
31{
32 Double_t x[5] = {.2,.7,.6,.25,.2};
33 Double_t y[5] = {.5,.1,.9,.7,.5};
34 TPolyLine *pline = new TPolyLine(5,x,y);
35 pline->SetFillColor(38);
36 pline->SetLineColor(2);
37 pline->SetLineWidth(4);
38 pline->Draw("f");
39 pline->Draw();
40}
41End_Macro
42*/
43
44////////////////////////////////////////////////////////////////////////////////
45/// PolyLine default constructor.
46
50
51////////////////////////////////////////////////////////////////////////////////
52/// PolyLine normal constructor without initialisation.
53/// Allocates n points.
54
57{
59 if (n <= 0)
60 return;
61
62 fN = n;
63 fX = new Double_t[fN];
64 fY = new Double_t[fN];
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// PolyLine normal constructor (single precision).
69/// Makes n points with (x, y) coordinates from x and y.
70
73{
75 if (n <= 0)
76 return;
77
78 fN = n;
79 fX = new Double_t[fN];
80 fY = new Double_t[fN];
81 if (!x || !y) return;
82 for (Int_t i = 0; i < fN; i++) {
83 fX[i] = x[i];
84 fY[i] = y[i];
85 }
86 fLastPoint = fN-1;
87}
88
89////////////////////////////////////////////////////////////////////////////////
90/// PolyLine normal constructor (double precision).
91/// Makes n points with (x, y) coordinates from x and y.
92
95{
97 if (n <= 0)
98 return;
99 fN = n;
100 fX = new Double_t[fN];
101 fY = new Double_t[fN];
102 if (!x || !y) return;
103 for (Int_t i=0; i<fN;i++) {
104 fX[i] = x[i];
105 fY[i] = y[i];
106 }
107 fLastPoint = fN-1;
108}
109
110////////////////////////////////////////////////////////////////////////////////
111///assignment operator
112
114{
115 if(this != &pl)
116 pl.TPolyLine::Copy(*this);
117 return *this;
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// PolyLine default destructor.
122
124{
125 if (fX) delete [] fX;
126 if (fY) delete [] fY;
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// PolyLine copy constructor.
131
136
137////////////////////////////////////////////////////////////////////////////////
138/// Copy this polyline to polyline.
139
140void TPolyLine::Copy(TObject &obj) const
141{
142 TObject::Copy(obj);
143 TAttLine::Copy(((TPolyLine&)obj));
144 TAttFill::Copy(((TPolyLine&)obj));
145 ((TPolyLine&)obj).fN = fN;
146 delete [] ((TPolyLine&)obj).fX;
147 delete [] ((TPolyLine&)obj).fY;
148 if (fN > 0) {
149 ((TPolyLine&)obj).fX = new Double_t[fN];
150 ((TPolyLine&)obj).fY = new Double_t[fN];
151 for (Int_t i = 0; i < fN; i++) {
152 ((TPolyLine &)obj).fX[i] = fX[i];
153 ((TPolyLine &)obj).fY[i] = fY[i];
154 }
155 } else {
156 ((TPolyLine&)obj).fX = nullptr;
157 ((TPolyLine&)obj).fY = nullptr;
158 }
159 ((TPolyLine&)obj).fOption = fOption;
160 ((TPolyLine&)obj).fLastPoint = fLastPoint;
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Returns closest distance in pixels from point (px, py) to a polyline.
165///
166/// First looks for distances to the points of the polyline. Stops search
167/// and returns if a vertex of the polyline is found to be closer than 10
168/// pixels. Thus the return value may depend on the ordering of points
169/// in the polyline.
170///
171/// Then looks for distances to the lines of the polyline. There is no
172/// arbitrary cutoff; any distance may be found.
173///
174/// Finally checks whether (px, py) is inside a closed and filled polyline.
175/// (Must be EXACTLY closed. "Filled" means fill color and fill style are
176/// both non-zero.) If so, returns zero.
177///
178/// Returns 9999 if the polyline has no points.
179
181{
182 const Int_t big = 9999;
183 if (!gPad) return big;
184 const Int_t kMaxDiff = 10;
185
186 // check if point is near one of the points
187 Int_t i, pxp, pyp, d;
189 if (Size() <= 0) return distance;
190
191 for (i=0;i<Size();i++) {
192 pxp = gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
193 pyp = gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
194 d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py);
195 if (d < distance) distance = d;
196 }
197 if (distance < kMaxDiff) return distance;
198
199 // check if point is near one of the connecting lines
200 for (i=0;i<Size()-1;i++) {
201 d = DistancetoLine(px, py, gPad->XtoPad(fX[i]), gPad->YtoPad(fY[i]), gPad->XtoPad(fX[i+1]), gPad->YtoPad(fY[i+1]));
202 if (d < distance) distance = d;
203 }
204
205 // in case of a closed and filled polyline, check if we are inside
206 if (fFillColor && fFillStyle && fX[0] == fX[fLastPoint] && fY[0] == fY[fLastPoint]) {
207 if (TMath::IsInside(gPad->AbsPixeltoX(px),gPad->AbsPixeltoY(py),fLastPoint+1,fX,fY)) distance = 0;
208 }
209 return distance;
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Draw this polyline with its current attributes.
214
219
220////////////////////////////////////////////////////////////////////////////////
221/// Draw this polyline with new coordinates.
222
233
234////////////////////////////////////////////////////////////////////////////////
235/// Execute action corresponding to one event.
236///
237/// This member function is called when a polyline is clicked with the locator
238///
239/// If Left button clicked on one of the line end points, this point
240/// follows the cursor until button is released.
241///
242/// if Middle button clicked, the line is moved parallel to itself
243/// until the button is released.
244
246{
247 if (!gPad || !gPad->IsEditable()) return;
248
249 auto &parent = *gPad;
250
251 constexpr Int_t kMaxDiff = 10;
252 Bool_t opaque = parent.OpaqueMoving();
253 static Int_t sdx, sdy, ipoint;
254 static Bool_t first_move;
255
256 Int_t np = Size();
257 Bool_t is_last_same = (np > 1) && (fX[0] == fX[np-1]) && (fY[0] == fY[np-1]);
258 if (is_last_same)
259 np--;
260
261 auto paint_hollow = [this,&parent,is_last_same] () {
262 auto pp = parent.GetPainter();
263 pp->SetAttLine({1,1,GetLineWidth()});
264 Double_t *x = fX, *y = fY;
265 if (TestBit(kPolyLineNDC)) {
266 pp->DrawPolyLineNDC(Size(), x, y);
267 } else {
268 std::vector<Double_t> xx, yy;
269 if (parent.GetLogx()) {
270 xx.resize(Size());
271 for (Int_t ix = 0; ix < Size(); ix++)
272 xx[ix] = parent.XtoPad(x[ix]);
273 x = xx.data();
274 }
275 if (parent.GetLogy()) {
276 yy.resize(Size());
277 for (Int_t iy = 0; iy < Size(); iy++)
278 yy[iy] = parent.YtoPad(y[iy]);
279 y = yy.data();
280 }
281 pp->DrawPolyLine(Size(), x, y);
282
283 pp->SetAttMarker({1,25,1});
284 pp->DrawPolyMarker(is_last_same ? Size()-1 : Size(), x, y);
285 }
286 };
287
288 auto get_point = [this, &parent](Int_t i, Int_t &pntx, Int_t &pnty) {
289 if (TestBit(kPolyLineNDC)) {
290 pntx = parent.UtoAbsPixel(fX[i]);
291 pnty = parent.VtoAbsPixel(fY[i]);
292 } else {
293 pntx = parent.XtoAbsPixel(parent.XtoPad(fX[i]));
294 pnty = parent.YtoAbsPixel(parent.YtoPad(fY[i]));
295 }
296 };
297
298 auto set_point = [this, &parent](Int_t i, Int_t pntx, Int_t pnty) {
299 if (TestBit(kPolyLineNDC)) {
300 Double_t ww = parent.GetWw();
301 Double_t wndc = parent.GetAbsWNDC();
302 Double_t wh = parent.GetWh();
303 Double_t hndc = parent.GetAbsHNDC();
304 fX[i] = ww > 0 && wndc > 0 ? (pntx / ww - parent.GetAbsXlowNDC()) / wndc : 0.;
305 fY[i] = wh > 0 && hndc > 0 ? ((1. - pnty / wh) - parent.GetAbsYlowNDC()) / hndc : 0.;
306 } else {
307 fX[i] = parent.PadtoX(parent.AbsPixeltoX(pntx));
308 fY[i] = parent.PadtoY(parent.AbsPixeltoY(pnty));
309 }
310 };
311
312 switch (event) {
313
314 case kArrowKeyPress:
315 case kButton1Down:
316 // No break !!!
317 case kMouseMotion: {
318
320 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) {
325 sdx = pxp - px;
326 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 sdx = pxp - px;
333 sdy = pyp - py;
334 }
335 }
337 if (ipoint < 0)
338 parent.SetCursor(kMove);
339 else
340 parent.SetCursor(kHand);
341 break;
342 }
343
344 case kButton1Motion:
345 if (!opaque && !first_move)
346 paint_hollow();
347
348 if (ipoint < 0) {
349 Int_t pxp0, pyp0, pxp, pyp;
350 // move all points
351 for (Int_t i = 0; i < np; i++) {
352 get_point(i, pxp, pyp);
353 if (i == 0) {
354 pxp0 = pxp;
355 pyp0 = pyp;
356 }
357 set_point(i, px + sdx + pxp - pxp0, py + sdy + pyp - pyp0);
358 }
359 } else {
360 // move only selected point
361 set_point(ipoint, px + sdx, py + sdy);
362 }
363 if (is_last_same) {
364 fX[np] = fX[0];
365 fY[np] = fY[0];
366 }
367
369 if (!opaque)
370 paint_hollow();
371 else
372 parent.ModifiedUpdate();
373 break;
374
375 case kButton1Up:
376 if (!opaque)
377 parent.ModifiedUpdate();
378 break;
379 }
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// List this polyline with its attributes.
384/// The option string is ignored.
385
387{
389 printf("TPolyLine N=%d\n",fN);
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// Merge polylines in the collection in this polyline
394
396{
397 if (!li) return 0;
398 TIter next(li);
399
400 //first loop to count the number of entries
401 TPolyLine *pl;
402 Int_t npoints = 0;
403 while ((pl = (TPolyLine*)next())) {
404 if (!pl->InheritsFrom(TPolyLine::Class())) {
405 Error("Add","Attempt to add object of class: %s to a %s",pl->ClassName(),this->ClassName());
406 return -1;
407 }
408 npoints += pl->Size();
409 }
410
411 //extend this polyline to hold npoints
412 if (npoints > 1) SetPoint(npoints-1,0,0);
413
414 //merge all polylines
415 next.Reset();
416 while ((pl = (TPolyLine*)next())) {
417 Int_t np = pl->Size();
418 Double_t *x = pl->GetX();
419 Double_t *y = pl->GetY();
420 for (Int_t i=0;i<np;i++) {
421 SetPoint(i,x[i],y[i]);
422 }
423 }
424
425 return npoints;
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Paint this polyline with its current attributes.
430
438
439////////////////////////////////////////////////////////////////////////////////
440/// Draw this polyline with new coordinates.
441///
442/// If option = 'f' or 'F' the fill area is drawn.
443/// The default is to draw the lines only.
444
446{
447 if (!gPad || n <= 0) return;
448 TAttLine::Modify(); //Change line attributes only if necessary
449 TAttFill::Modify(); //Change fill area attributes only if necessary
450 std::vector<Double_t> xx, yy;
451 if (gPad->GetLogx()) {
452 xx.resize(n);
453 for (Int_t ix = 0; ix < n; ix++)
454 xx[ix] = gPad->XtoPad(x[ix]);
455 x = xx.data();
456 }
457 if (gPad->GetLogy()) {
458 yy.resize(n);
459 for (Int_t iy = 0; iy < n; iy++)
460 yy[iy] = gPad->YtoPad(y[iy]);
461 y = yy.data();
462 }
463 if (option && (*option == 'f' || *option == 'F'))
464 gPad->PaintFillArea(n, x, y, option);
465 else
466 gPad->PaintPolyLine(n, x, y, option);
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Draw this polyline with new coordinates in NDC.
471
473{
474 TAttLine::Modify(); // Change line attributes only if necessary
475 TAttFill::Modify(); // Change fill area attributes only if necessary
476 if (option && (*option == 'f' || *option == 'F'))
477 gPad->PaintFillAreaNDC(n, x, y, option);
478 else
479 gPad->PaintPolyLineNDC(n, x, y, option);
480}
481
482////////////////////////////////////////////////////////////////////////////////
483/// Dump this polyline with its attributes.
484/// The option string is ignored.
485
487{
488 printf("PolyLine N=%d\n",fN);
489}
490
491////////////////////////////////////////////////////////////////////////////////
492/// Save primitive as a C++ statement(s) on output stream out
493
494void TPolyLine::SavePrimitive(std::ostream &out, Option_t *option)
495{
496 TString args;
497 if (Size() > 0) {
498 TString arrx = SavePrimitiveVector(out, "polyline", Size(), fX, kTRUE);
499 TString arry = SavePrimitiveVector(out, "polyline", Size(), fY);
500 args.Form("%d, %s.data(), %s.data(), ", Size(), arrx.Data(), arry.Data());
501 } else {
502 args.Form("%d, ", fN);
503 }
504 args.Append(TString::Format("\"%s\"", TString(fOption).ReplaceSpecialCppChars().Data()));
505
506 SavePrimitiveConstructor(out, Class(), "polyline", args, Size() == 0);
507 SaveFillAttributes(out, "polyline", -1, -1);
508 SaveLineAttributes(out, "polyline", 1, 1, 1);
509
510 if (!option || !strstr(option, "nodraw"))
511 out << " polyline->Draw(\"" << TString(option).ReplaceSpecialCppChars() << "\");\n";
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Set NDC mode on if isNDC = kTRUE, off otherwise
516
522
523////////////////////////////////////////////////////////////////////////////////
524/// Set point following LastPoint to x, y.
525/// Returns index of the point (new last point).
526
533
534////////////////////////////////////////////////////////////////////////////////
535/// Set point number n to (x, y)
536/// If n is greater than the current size, the arrays are automatically
537/// extended.
538
540{
541 if (n < 0) return;
542 if (!fX || !fY || n >= fN) {
543 // re-allocate the object
544 Int_t newN = TMath::Max(2*fN,n+1);
545 Double_t *savex = new Double_t [newN];
546 Double_t *savey = new Double_t [newN];
547 if (fX && fN){
548 memcpy(savex,fX,fN*sizeof(Double_t));
549 memset(&savex[fN],0,(newN-fN)*sizeof(Double_t));
550 delete [] fX;
551 }
552 if (fY && fN){
553 memcpy(savey,fY,fN*sizeof(Double_t));
554 memset(&savey[fN],0,(newN-fN)*sizeof(Double_t));
555 delete [] fY;
556 }
557 fX = savex;
558 fY = savey;
559 fN = newN;
560 }
561 fX[n] = x;
562 fY[n] = y;
564}
565
566////////////////////////////////////////////////////////////////////////////////
567/// Resize this polyline to size n.
568/// If n <= 0 the current arrays of points are deleted.
569/// If n is greater than the current size, the new points are set to (0, 0)
570
572{
573 if (n <= 0) {
574 fN = 0;
575 fLastPoint = -1;
576 delete [] fX;
577 delete [] fY;
578 fX = fY = nullptr;
579 return;
580 }
581 if (n < fN) {
582 fN = n;
583 fLastPoint = n - 1;
584 } else {
585 SetPoint(n-1,0,0);
586 }
587}
588
589////////////////////////////////////////////////////////////////////////////////
590/// Set new values for this polyline (single precision).
591///
592/// If n <= 0 the current arrays of points are deleted.
593
595{
596 if (n <= 0) {
597 fN = 0;
598 fLastPoint = -1;
599 delete [] fX;
600 delete [] fY;
601 fX = fY = nullptr;
602 return;
603 }
604 fN =n;
605 if (fX) delete [] fX;
606 if (fY) delete [] fY;
607 fX = new Double_t[fN];
608 fY = new Double_t[fN];
609 for (Int_t i=0; i<fN;i++) {
610 if (x) fX[i] = (Double_t)x[i];
611 if (y) fY[i] = (Double_t)y[i];
612 }
613 fOption = option;
614 fLastPoint = fN-1;
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Set new values for this polyline (double precision).
619///
620/// If n <= 0 the current arrays of points are deleted.
621
623{
624 if (n <= 0) {
625 fN = 0;
626 fLastPoint = -1;
627 delete [] fX;
628 delete [] fY;
629 fX = fY = nullptr;
630 return;
631 }
632 fN =n;
633 if (fX) delete [] fX;
634 if (fY) delete [] fY;
635 fX = new Double_t[fN];
636 fY = new Double_t[fN];
637 for (Int_t i=0; i<fN;i++) {
638 if (x) fX[i] = x[i];
639 if (y) fY[i] = y[i];
640 }
641 fOption = option;
642 fLastPoint = fN-1;
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Stream a class object.
647
649{
650 if (b.IsReading()) {
652 Version_t R__v = b.ReadVersion(&R__s, &R__c);
653 if (R__v > 1) {
654 b.ReadClassBuffer(TPolyLine::Class(), this, R__v, R__s, R__c);
655 return;
656 }
657 //====process old versions before automatic schema evolution
661 b >> fN;
662 fX = new Double_t[fN];
663 fY = new Double_t[fN];
664 Float_t *x = new Float_t[fN];
665 Float_t *y = new Float_t[fN];
666 b.ReadFastArray(x,fN);
667 b.ReadFastArray(y,fN);
668 for (Int_t i=0;i<fN;i++) {
669 fX[i] = x[i];
670 fY[i] = y[i];
671 }
673 b.CheckByteCount(R__s, R__c, TPolyLine::IsA());
674 //====end of old versions
675
676 delete [] x;
677 delete [] y;
678 } else {
679 b.WriteClassBuffer(TPolyLine::Class(),this);
680 }
681}
@ 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
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
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 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 Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
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:997
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:204
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:159
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
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:777
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:796
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:47
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.
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.
@ kPolyLineNDC
Polyline coordinates are in NDC space.
Definition TPolyLine.h:37
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3052
Basic string class.
Definition TString.h:138
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
const char * Data() const
Definition TString.h:384
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1418
TString & Append(const char *cs)
Definition TString.h:581
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:2385
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2363
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:1320
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122