Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TAttBBox2D.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Anna-Pia Lohfink 27.3.2014
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 "TAttBBox2D.h"
13
14#include "TPoint.h"
15#include "TVirtualPad.h"
16
17
18/** \class TAttBBox2D
19\ingroup Base
20\ingroup GraphicsAtt
21
22Abstract base class for elements drawn in the editor.
23Classes inheriting from TAttBBox2D implementing the TAttBBox2D
24virtual methods, and using TPad::ShowGuideLines in ExecuteEvent
25will automatically get the guide lines drawn when moved in the pad.
26All methods work with pixel coordinates.
27*/
28
29////////////////////////////////////////////////////////////////////////////////
30// TAttBBox2D destructor.
31
35
36////////////////////////////////////////////////////////////////////////////////
37// Returns BBox center
38// By default returns center of rectangle returned by GetBBox() method
39
41{
42 auto box = GetBBox();
43 return { (Short_t) (box.fX + box.fWidth/2), (Short_t) (box.fY + box.fHeight/2)};
44}
45
46////////////////////////////////////////////////////////////////////////////////
47// Set BBox center
48// By default calls SetBBoxCenterX and SetBBoxCenterY
49
51{
52 SetBBoxCenterX(p.GetX());
53 SetBBoxCenterY(p.GetY());
54}
55
56////////////////////////////////////////////////////////////////////////////////
57// Return user X coordinate for pixel X value
58// Used in derived classes to implement SetBBox... methods
59
61{
62 if (!gPad)
63 return 0.;
64
65 if (!is_ndc)
66 return gPad->PadtoX(gPad->PixeltoX(x));
67
68 Int_t pw = gPad->GetPadWidth();
69 return pw > 0 ? 1. * x / pw : 0.;
70}
71
72////////////////////////////////////////////////////////////////////////////////
73// Return user Y coordinate for pixel Y value
74// Used in derived classes to implement SetBBox... methods
75
77{
78 if (!gPad)
79 return 0.;
80
81 if (!is_ndc)
82 return gPad->PadtoY(gPad->PixeltoY(y - gPad->VtoPixel(0)));
83
84 Int_t ph = gPad->GetPadHeight();
85
86 return ph > 0 ? 1. - 1. * y / ph : 0.;
87}
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
#define gPad
Double_t GetYCoord(const Int_t y, Bool_t is_ndc=kFALSE)
virtual void SetBBoxCenterY(const Int_t y)=0
virtual void SetBBoxCenterX(const Int_t x)=0
virtual void SetBBoxCenter(const TPoint &p)
virtual ~TAttBBox2D()
virtual Rectangle_t GetBBox()=0
virtual TPoint GetBBoxCenter()
Double_t GetXCoord(const Int_t x, Bool_t is_ndc=kFALSE)
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17