Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPolyLine.h
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#ifndef ROOT_TPolyLine
13#define ROOT_TPolyLine
14
15
16#include "TString.h"
17#include "TObject.h"
18#include "TAttLine.h"
19#include "TAttFill.h"
20
21class TCollection;
22
23class TPolyLine : public TObject, public TAttLine, public TAttFill {
24
25protected:
26 Int_t fN{0}; ///<Number of points
27 Int_t fLastPoint{-1}; ///<The index of the last filled point
28 Double_t *fX{nullptr}; ///<[fN] Array of X coordinates
29 Double_t *fY{nullptr}; ///<[fN] Array of Y coordinates
30 TString fOption; ///<options
31
33
34public:
35 // TPolyLine status bits
36 enum {
37 kPolyLineNDC = BIT(14) ///< Polyline coordinates are in NDC space.
38 };
39
40 TPolyLine();
44 TPolyLine(const TPolyLine &polyline);
45 ~TPolyLine() override;
46
47 void Copy(TObject &polyline) const override;
48 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
49 void Draw(Option_t *option="") override;
51 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
52 virtual Int_t GetLastPoint() const { return fLastPoint;}
53 Int_t GetN() const {return fN;}
54 Double_t *GetX() const {return fX;}
55 Double_t *GetY() const {return fY;}
56 Option_t *GetOption() const override { return fOption.Data(); }
57 void ls(Option_t *option="") const override;
58 virtual Int_t Merge(TCollection *list);
59 void Paint(Option_t *option="") override;
60 virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="");
61 virtual void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="");
62 void Print(Option_t *option="") const override;
63 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
64 virtual void SetNDC(Bool_t isNDC=kTRUE);
65 virtual Int_t SetNextPoint(Double_t x, Double_t y); // *MENU*
66 virtual void SetOption(Option_t *option="") {fOption = option;}
67 virtual void SetPoint(Int_t point, Double_t x, Double_t y); // *MENU*
68 virtual void SetPolyLine(Int_t n);
69 virtual void SetPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *option="");
70 virtual void SetPolyLine(Int_t n, Double_t *x, Double_t *y3, Option_t *option="");
71 virtual Int_t Size() const {return fLastPoint+1;}
72
74};
75
76#endif
77
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Fill Area Attributes class.
Definition TAttFill.h:19
Line Attributes class.
Definition TAttLine.h:18
Collection abstract base class.
Definition TCollection.h:65
Mother of all ROOT objects.
Definition TObject.h:41
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.
virtual Int_t GetLastPoint() const
Definition TPolyLine.h:52
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:47
Int_t GetN() const
Definition TPolyLine.h:53
~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.
Double_t * fX
[fN] Array of X coordinates
Definition TPolyLine.h:28
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
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
Option_t * GetOption() const override
Definition TPolyLine.h:56
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
virtual void SetOption(Option_t *option="")
Definition TPolyLine.h:66
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
th1 Draw()