Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TCreatePrimitives.cxx
Go to the documentation of this file.
1// @(#)root/gpad:$Id: TCreatePrimitives.cxx
2
3/*************************************************************************
4 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11/** \class TCreatePrimitives
12\ingroup gpad
13
14Creates new primitives.
15
16The functions in this static class are called by TPad::ExecuteEvent
17to create new primitives from the TCanvas toolbar.
18*/
19
20#include "TCreatePrimitives.h"
21
22#include "TCanvas.h"
23#include "TStyle.h"
24#include "TGraph.h"
25#include "TMarker.h"
26#include "TGroupButton.h"
27#include "TROOT.h"
28#include "TSystem.h"
29#include "TMath.h"
30#include "KeySymbols.h"
31#include "TCutG.h"
32#include "TLatex.h"
33#include "TCurlyArc.h"
34#include "TArrow.h"
35#include "TArc.h"
36#include "TPavesText.h"
37#include "TPaveLabel.h"
38#include "TDiamond.h"
39#include "TGraph.h"
40
41
42////////////////////////////////////////////////////////////////////////////////
43/// @deprecated
44/// Create a new arc/ellipse in this gPad.
45
46void TCreatePrimitives::Ellipse(Int_t event, Int_t px, Int_t py, Int_t mode)
47{
48 if (auto pad = dynamic_cast<TPad *>(gPad))
49 ExecuteTwoPoint(*pad, mode, event, px, py);
50}
51
52/////////////////////////////////////////////
53/// Internal class implementing mouse click/move/relase editing
54/// Used for many classes like line, arrow, arc, pad, paves, ...
56 public:
57
59 {
60 fMode = mode;
61 fX0 = x0;
62 fY0 = y0;
63 fPX0 = px0;
64 fPY0 = py0;
65 }
66
67 template<typename T, typename... Rest>
68 T *Make(TPad &parent, Rest&&... rest)
69 {
70 if (fObject) {
71 // check that object of expected type
72 auto res = dynamic_cast<T *>(fObject);
73 // if not match - just "forget" about it, pad will take care about correct cleanup
74 if (!res)
75 fObject = nullptr; // failure, interactive will be deleted
76 return res;
77 }
78 auto res2 = new T(std::forward<Rest>(rest)...);
79 // add created object to pad list of primitives, delegating ownership to the pad
80 parent.Add(res2);
81 fObject = res2;
82 return res2;
83 }
84
85 template<class T>
86 void SetCoord(T *obj, Double_t x, Double_t y)
87 {
88 obj->SetX1(TMath::Min(x, fX0));
89 obj->SetX2(TMath::Max(x, fX0));
90 obj->SetY1(TMath::Min(y, fY0));
91 obj->SetY2(TMath::Max(y, fY0));
92 }
93
94 Int_t fMode = 0; ///< edit mode when interactive action started
95 Double_t fX0 = 0, fY0 = 0; ///< initial mouse pointer position in user coordiantes
96 Int_t fPX0 = 0, fPY0 = 0; ///< initial mouse pointer position in pixel coordiantes
97 TObject *fObject = nullptr; ///< object created by interactive action, owned by pad
98};
99
100
101/////////////////////////////////////////////
102/// Internal class implementing text editing
104 public:
105
107 {
108 fLatex = ltx;
109 }
110
112 {
113 fLabel = lbl;
114 }
115
117 {
118 fPaveText = txt;
119 }
120
122 {
123 if (fLatex)
124 return fLatex;
125 if (fLabel)
126 return fLabel;
127 if (fPaveText)
128 return fPaveText;
129 return nullptr;
130 }
131
133 {
134 if (fLatex)
135 return fLatex->GetTitle();
136 if (fLabel)
137 return fLabel->GetLabel();
138 if (fPaveText)
139 return fPaveText->GetSize() > 0 ? fPaveText->GetLine(0)->GetTitle() : "";
140 return "";
141 }
142
143 void SetText(const TString &s)
144 {
145 if (fLatex)
146 fLatex->SetTitle(s);
147 else if (fLabel)
148 return fLabel->SetLabel(s);
149 else if (fPaveText && (fPaveText->GetSize() > 0))
150 fPaveText->GetLine(0)->SetTitle(s);
151 }
152
154 {
155 auto s = GetText();
156 Int_t l = s.Length();
157 if (l > 1) {
158 s.Remove(l-1);
159 SetText(s);
160 }
161 }
162
163 bool ProcessKeyPress(TPad &parent, Int_t py)
164 {
165 if ((py == kKey_Return) || (py == kKey_Enter)) {
168 parent.Modified(kTRUE);
169 gROOT->SetEditorMode();
170 parent.Update();
171 parent.GetCanvas()->Selected(&parent, GetObject(), kButton1Down);
172 return true;
173 }
174
175 auto s = GetText();
176 Int_t l = s.Length();
177
178 if (py == kKey_Backspace) {
179 if (l > 1) {
180 s.Replace(l-2, 2, "<");
181 SetText(s);
182 parent.Modified(kTRUE);
183 parent.Update();
184 }
185 } else if (isprint(py)) {
186 s.Insert(l - 1, (char)py);
187 SetText(s);
188 parent.Modified(kTRUE);
189 parent.Update();
190 }
191
192 return false;
193 }
194
195 TLatex *fLatex = nullptr; ///< editing text in TLatex
196 TPaveLabel *fLabel = nullptr; ///< or in TPaveLabel
197 TPaveText *fPaveText = nullptr; ///< or in TPave(s)Text
198};
199
200
201////////////////////////////////////////////////////////////////////////////////
202/// Create a new line/arrow/pave/subpad in the specified pad
203///
204/// - Click left button to indicate object start position.
205/// - Move mouse pointer when left button pressed to specify second position
206/// - Release left button to stop position/size change
207/// - for TPaveText, TPavesText, TPaveLabel text editing started until Enter key is pressed
208
210{
211 if (mode == kPaveLabel)
212 parent.EventPave(); // TODO: check if this is really needed
213
214 // special branch for text editing
215 if ((mode == kPaveLabel) || (mode == kPaveText) || (mode == kPavesText)) {
216 auto inter_edit = parent.GetInteractive<TTextEditInteractive>(&parent);
217 if (inter_edit) {
218 if ((event == kKeyPress) && inter_edit->ProcessKeyPress(parent, py))
219 parent.FreeInteractive(&parent);
220 return;
221 }
222 }
223
224 Double_t x = parent.PadtoX(parent.AbsPixeltoX(px));
225 Double_t y = parent.PadtoY(parent.AbsPixeltoY(py));
226
227 // first mouse click
228 if (event == kButton1Down) {
229 parent.MakeInteractive<TTwoPointInteractive>(&parent, mode, x, y, px, py);
230 return;
231 }
232
233 auto inter = parent.GetInteractive<TTwoPointInteractive>(&parent);
234 if (!inter)
235 return;
236
237 // verify that object is still there or mode is changed
238 if ((inter->fObject && !parent.FindObject(inter->fObject)) || (mode != inter->fMode)) {
239 parent.FreeInteractive(&parent);
240 return;
241 }
242
243 // when mouse released - finish interactive
244 if (event == kButton1Up) {
245 auto obj = inter->fObject;
246 if (mode == kPad) {
247 parent.Remove(obj);
248 Int_t npads = 0;
249 TIter next(parent.GetListOfPrimitives());
250 while (auto pobj = next()) {
251 if (pobj->InheritsFrom(TPad::Class()))
252 npads++;
253 }
254
255 auto box = (TBox *) obj;
256 Double_t xlow = (parent.XtoPad(box->GetX1()) - parent.GetX1())/(parent.GetX2() - parent.GetX1());
257 Double_t ylow = (parent.YtoPad(box->GetY1()) - parent.GetY1())/(parent.GetY2() - parent.GetY1());
258 Double_t xup = (parent.XtoPad(box->GetX2()) - parent.GetX1())/(parent.GetX2() - parent.GetX1());
259 Double_t yup = (parent.YtoPad(box->GetY2()) - parent.GetY1())/(parent.GetY2() - parent.GetY1());
260
261 // TBox object no longer needed
262 delete obj;
263 obj = nullptr;
264
265 // to preserve gPad when new pad is created
266 TVirtualPad::TContext padtxt(true);
267
268 auto newpad = new TPad(TString::Format("%s_%d",parent.GetName(),npads+1).Data(),"newpad", xlow, ylow, xup, yup);
269 if (!newpad->IsZombie()) {
270 newpad->UseCurrentStyle();
271 parent.Add(newpad);
272 obj = newpad;
273 }
274 }
275
276 if (obj)
277 parent.GetCanvas()->Selected(&parent, obj, kButton1Down);
278
279 parent.FreeInteractive(&parent);
280
281 if (((mode == kPaveText) || (mode == kPavesText)) && obj)
282 parent.MakeInteractive<TTextEditInteractive>(&parent, (TPaveText *)obj);
283 else if ((mode == kPaveLabel) && obj)
284 parent.MakeInteractive<TTextEditInteractive>(&parent, (TPaveLabel *)obj);
285 else
286 gROOT->SetEditorMode();
287 return;
288 }
289
290 // ignore all other events
291 if (event != kButton1Motion)
292 return;
293
294 bool had_object = (inter->fObject != nullptr);
295
296 switch (mode) {
297 case kLine:
298 if (auto line = inter->Make<TLine>(parent, inter->fX0, inter->fY0, x, y)) {
299 line->SetX2(x);
300 line->SetY2(y);
301 }
302 break;
303 case kArrow:
304 if (auto arrow = inter->Make<TArrow>(parent, inter->fX0, inter->fY0, x, y, TArrow::GetDefaultArrowSize(),
306 arrow->SetX2(x);
307 arrow->SetY2(y);
308 }
309 break;
310 case kCurlyLine:
311 if (auto cline = inter->Make<TCurlyLine>(parent, inter->fX0, inter->fY0, x, y, TCurlyLine::GetDefaultWaveLength(),
313 cline->SetEndPoint(x, y);
314 break;
315 case kCurlyArc:
316 if (auto carc = inter->Make<TCurlyArc>(parent, inter->fX0, inter->fY0, 1., 0., 360.,
318 auto pradius = TMath::Sqrt((px - inter->fPX0) * (px - inter->fPX0) + (py - inter->fPY0) * (py - inter->fPY0));
319 auto radius = parent.PixeltoX((Int_t)pradius) - parent.PixeltoX(0);
320 carc->SetRadius(radius);
321 }
322 break;
323 case kArc:
324 if (auto arc = inter->Make<TArc>(parent, 1., 1., 1, 45, 315)) {
325 arc->SetR1(0.5 * TMath::Abs(x - inter->fX0));
326 arc->SetR2(0.5 * TMath::Abs(y - inter->fY0));
327 arc->SetX1(0.5*(x + inter->fX0));
328 arc->SetY1(0.5*(y + inter->fY0));
329 }
330 break;
331 case kEllipse:
332 if (auto ellipse = inter->Make<TEllipse>(parent, 1., 1., 1, 1)) {
333 ellipse->SetR1(0.5 * TMath::Abs(x - inter->fX0));
334 ellipse->SetR2(0.5 * TMath::Abs(y - inter->fY0));
335 ellipse->SetX1(0.5*(x + inter->fX0));
336 ellipse->SetY1(0.5*(y + inter->fY0));
337 }
338 break;
339 case kPave:
340 if (auto pave = inter->Make<TPave>(parent, x, y, x, y))
341 inter->SetCoord<TPave>(pave, x, y);
342 break;
343 case kPaveLabel:
344 if (auto pave = inter->Make<TPaveLabel>(parent, x, y, x, y, ">"))
345 inter->SetCoord<TPave>(pave, x, y);
346 break;
347 case kPaveText:
348 if (auto pave = inter->Make<TPaveText>(parent, x, y, x, y)) {
349 if (!had_object)
350 pave->AddText(">");
351 inter->SetCoord<TPave>(pave, x, y);
352 }
353 break;
354 case kPavesText:
355 if (auto pave = inter->Make<TPavesText>(parent, x, y, x, y)) {
356 if (!had_object)
357 pave->AddText(">");
358 inter->SetCoord<TPave>(pave, x, y);
359 }
360 break;
361 case kDiamond:
362 if (auto diamond = inter->Make<TDiamond>(parent, x, y, x, y))
363 inter->SetCoord<TPave>(diamond, x, y);
364 break;
365 case kPad:
366 if (auto box = inter->Make<TBox>(parent, x, y, x, y)) {
367 box->SetFillStyle(1); // to paint only border
368 inter->SetCoord<TBox>(box, x, y);
369 }
370 break;
371
372 default: break;
373 }
374
375 if (inter->fObject) {
376 parent.Modified(kTRUE);
377 parent.Update();
378 } else
379 parent.FreeInteractive(&parent);
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// @deprecated
384/// Create a new line/arrow in this gPad.
385
386void TCreatePrimitives::Line(Int_t event, Int_t px, Int_t py, Int_t mode)
387{
388 if (auto pad = dynamic_cast<TPad *>(gPad))
389 ExecuteTwoPoint(*pad, mode, event, px, py);
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// @deprecated
394/// Create a new pad in gPad.
395
396void TCreatePrimitives::Pad(Int_t event, Int_t px, Int_t py, Int_t)
397{
398 if (auto pad = dynamic_cast<TPad *>(gPad))
399 ExecuteTwoPoint(*pad, kPad, event, px, py);
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// @deprecated
404/// Create a new pave-derived object in gPad.
405
406void TCreatePrimitives::Pave(Int_t event, Int_t px, Int_t py, Int_t mode)
407{
408 if (auto pad = dynamic_cast<TPad *>(gPad))
409 ExecuteTwoPoint(*pad, mode, event, px, py);
410}
411
412////////////////////////////////////////////////////////////////////////////////
413/// Interactive object for TGraph and TCutG editing
415 public:
416
418 {
419 fX0 = x0;
420 fY0 = y0;
421 fPX0 = px0;
422 fPY0 = py0;
423 if (mode == kPolyLine) {
424 fGraph = new TGraph(2);
427 } else {
428 fGraph = new TCutG(name, 2);
429 }
430 fGraph->SetPoint(0, x0, y0);
431 fGraph->SetPoint(1, x0, y0);
432 fNPoints = 1;
433 }
434
435 Double_t fX0 = 0, fY0 = 0;
436 Int_t fPX0 = 0, fPY0 = 0;
437 TGraph *fGraph = nullptr;
439};
440
441
442////////////////////////////////////////////////////////////////////////////////
443/// Create a new TGraph or TCutG in the pad
444///
445/// - Click left button to indicate a new point.
446/// - Click left button at same place or double click to close the polyline.
447
449{
450 Double_t x = parent.PadtoX(parent.AbsPixeltoX(px));
451 Double_t y = parent.PadtoY(parent.AbsPixeltoY(py));
452
453 auto inter = parent.GetInteractive<TPolyLineEditInteractive>(&parent);
454
455 switch (event) {
456
457 case kButton1Down:
458 if (inter) {
459 inter->fGraph->SetPoint(inter->fNPoints, x, y);
460 // if new point close to original point - just stop editing
461 if ((inter->fNPoints > 1) && (TMath::Abs(px - inter->fPX0) + TMath::Abs(py - inter->fPY0) < 7)) {
462 inter->fGraph->SetPoint(inter->fNPoints, inter->fX0, inter->fY0);
463 parent.GetCanvas()->Selected(&parent, inter->fGraph, kButton1Down);
464 parent.FreeInteractive(&parent);
465 parent.Modified();
466 parent.Update();
467 gROOT->SetEditorMode();
468 } else {
469 // add new point
470 inter->fNPoints++;
471 inter->fGraph->Set(inter->fNPoints + 1);
472 inter->fGraph->SetPoint(inter->fNPoints, x, y);
473 }
474 } else {
475 TString name = mode == kPolyLine ? "graph" : "CUTG";
476 Int_t cnt = 0;
477 while (parent.FindObject(name.Data()) && (cnt++ < 1000))
478 name.Form("%s%d", mode == kPolyLine ? "gr_" : "cutg_", cnt);
479
480 inter = parent.MakeInteractive<TPolyLineEditInteractive>(&parent, mode, name.Data(), x, y, px, py);
481 parent.Add(inter->fGraph, "L");
482 }
483 break;
484
485 case kButton1Double:
486 if (inter) {
487 if (inter->fNPoints < (mode == kCutG ? 3 : 2)) {
488 // too few points - primitive is not complete
489 parent.Remove(inter->fGraph);
490 delete inter->fGraph;
491 } else if (mode == kCutG) {
492 // force same first and last point
493 inter->fGraph->SetPoint(inter->fNPoints, inter->fX0, inter->fY0);
494 } else {
495 // just remove last point which only was visisble during painting
496 inter->fGraph->Set(inter->fNPoints);
497 }
498 parent.GetCanvas()->Selected(&parent, inter->fGraph, kButton1Down);
499
500 parent.FreeInteractive(&parent);
501 parent.Modified();
502 parent.Update();
503 gROOT->SetEditorMode();
504 }
505 break;
506
507 case kMouseMotion:
508 if (inter) {
509 inter->fGraph->SetPoint(inter->fNPoints, x, y);
510 parent.Modified();
511 parent.Update();
512 }
513 break;
514 }
515}
516
517////////////////////////////////////////////////////////////////////////////////
518/// @deprecated
519/// Create a new PolyLine in gPad.
520
521void TCreatePrimitives::PolyLine(Int_t event, Int_t px, Int_t py, Int_t mode)
522{
523 if (auto pad = dynamic_cast<TPad *>(gPad))
524 ExecutePolyLine(*pad, mode, event, px, py);
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Create a new TLatex or TMarker at the cursor position in the provided pad
529///
530/// - Click left button to indicate the text position.
531/// - Type text
532/// - Press Enter or click mouse once again to stop editing
533
535{
536 auto inter = (mode == kText) ? parent.GetInteractive<TTextEditInteractive>(&parent) : nullptr;
537 if (inter && !parent.FindObject(inter->GetObject())) {
538 parent.FreeInteractive(&parent);
539 inter = nullptr;
540 }
541
542 switch (event) {
543
544 case kKeyPress:
545 // only modify in editor mode
546 if (inter && inter->ProcessKeyPress(parent, py))
547 parent.FreeInteractive(&parent);
548 break;
549
550 case kButton1Down: {
551 if (inter) {
552 // second click during editing will finalize editor
553 inter->FinishEditing();
555 parent.Modified(kTRUE);
556 gROOT->SetEditorMode();
557 parent.Update();
558 parent.GetCanvas()->Selected(&parent, inter->fLatex, kButton1Down);
559 parent.FreeInteractive(&parent);
560 break;
561 }
562
563 Double_t x = parent.PadtoX(parent.AbsPixeltoX(px));
564 Double_t y = parent.PadtoY(parent.AbsPixeltoY(py));
565
566 if (mode == kMarker) {
567 auto marker = new TMarker(x, y, 28);
568 parent.GetCanvas()->Selected(&parent, marker, kButton1Down);
569 parent.Add(marker);
570 gROOT->SetEditorMode();
571 } else if (mode == kText) {
572 parent.StartEditing();
574 auto ltx = new TLatex(x,y,"<");
575 parent.GetCanvas()->Selected(&parent, ltx, kButton1Down);
576 parent.Add(ltx);
577 parent.Modified(kTRUE);
578 parent.Update();
579 parent.MakeInteractive<TTextEditInteractive>(&parent, ltx);
580 }
581 break;
582 }
583 }
584}
585
586////////////////////////////////////////////////////////////////////////////////
587/// @deprecated
588/// Create a new TLatex or TMarker at the cursor position in gPad.
589
590void TCreatePrimitives::Text(Int_t event, Int_t px, Int_t py, Int_t mode)
591{
592 if (auto pad = dynamic_cast<TPad *>(gPad))
593 ExecuteText(*pad, mode, event, px, py);
594}
595
596////////////////////////////////////////////////////////////////////////////////
597/// Handle edit mode in the TPad
598/// Executed when editmode is not 0
599
601{
602 switch (edit_mode) {
603 case kMarker:
604 case kText: ExecuteText(pad, edit_mode, event, px, py); break;
605 case kLine:
606 case kArrow:
607 case kCurlyLine:
608 case kCurlyArc:
609 case kArc:
610 case kEllipse:
611 case kPave:
612 case kPaveLabel:
613 case kPaveText:
614 case kPavesText:
615 case kDiamond:
616 case kPad: ExecuteTwoPoint(pad, edit_mode, event, px, py); break;
617 case kPolyLine:
618 case kCutG: ExecutePolyLine(pad, edit_mode, event, px, py); break;
619 default: gROOT->SetEditorMode(); break; // any other values dismissed
620 }
621}
@ kMouseMotion
Definition Buttons.h:23
@ kKeyPress
Definition Buttons.h:20
@ kButton1Double
Definition Buttons.h:24
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kButton1Down
Definition Buttons.h:17
@ kMarker
Definition Buttons.h:34
@ kCurlyArc
Definition Buttons.h:38
@ kPad
Definition Buttons.h:30
@ kPolyLine
Definition Buttons.h:28
@ kDiamond
Definition Buttons.h:37
@ kPave
Definition Buttons.h:31
@ kArrow
Definition Buttons.h:33
@ kPaveText
Definition Buttons.h:32
@ kCutG
Definition Buttons.h:38
@ kLine
Definition Buttons.h:33
@ kPavesText
Definition Buttons.h:32
@ kCurlyLine
Definition Buttons.h:38
@ kPaveLabel
Definition Buttons.h:31
@ kEllipse
Definition Buttons.h:32
@ kText
Definition Buttons.h:30
@ kArc
Definition Buttons.h:33
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_Backspace
Definition KeySymbols.h:29
@ kKey_Enter
Definition KeySymbols.h:31
cudaEvent_t event
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:142
#define gROOT
Definition TROOT.h:417
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gPad
Create an Arc.
Definition TArc.h:26
Draw all kinds of Arrows.
Definition TArrow.h:29
static Option_t * GetDefaultOption()
Get default option.
Definition TArrow.cxx:415
static Float_t GetDefaultArrowSize()
Get default arrow size.
Definition TArrow.cxx:406
Create a Box.
Definition TBox.h:22
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition TCanvas.cxx:1659
static void Int_t Int_t py
static void Int_t px
static void ExecutePolyLine(TPad &parent, Int_t mode, Int_t event, Int_t px, Int_t py)
Create a new TGraph or TCutG in the pad.
static void Int_t Int_t Int_t mode
static void ExecuteTwoPoint(TPad &pad, Int_t mode, Int_t event, Int_t px, Int_t py)
Create a new line/arrow/pave/subpad in the specified pad.
static void ExecuteText(TPad &pad, Int_t mode, Int_t event, Int_t px, Int_t py)
Create a new TLatex or TMarker at the cursor position in the provided pad.
static void ExecuteEvent(TPad &pad, Int_t edit_mode, Int_t event, Int_t px, Int_t py)
Handle edit mode in the TPad Executed when editmode is not 0.
Implements curly or wavy arcs used to draw Feynman diagrams.
Definition TCurlyArc.h:16
static Double_t GetDefaultWaveLength()
Get default wave length.
static Double_t GetDefaultAmplitude()
Get default wave amplitude.
Implements curly or wavy polylines used to draw Feynman diagrams.
Definition TCurlyLine.h:19
static Double_t GetDefaultWaveLength()
Get default wave length.
static Double_t GetDefaultAmplitude()
Get default amplitude.
Graphical cut class.
Definition TCutG.h:20
Draw a Diamond.
Definition TDiamond.h:17
Draw Ellipses.
Definition TEllipse.h:25
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition TGraph.cxx:2386
@ kClipFrame
Clip to the frame boundary.
Definition TGraph.h:75
void SetName(const char *name="") override
Set graph name.
Definition TGraph.cxx:2425
To draw Mathematical Formula.
Definition TLatex.h:20
Use the TLine constructor to create a simple line.
Definition TLine.h:22
virtual void SetY2(Double_t y2)
Definition TLine.h:70
virtual void SetX2(Double_t x2)
Definition TLine.h:68
Manages Markers.
Definition TMarker.h:22
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:42
void ResetBit(UInt_t f)
Definition TObject.h:203
The most important graphics class in the ROOT system.
Definition TPad.h:32
static TClass * Class()
virtual void StartEditing()
Definition TPad.h:439
Double_t PadtoY(Double_t y) const override
Convert y from pad to Y.
Definition TPad.cxx:3412
Double_t GetY2() const override
Definition TPad.h:256
TObject * Remove(TObject *obj, Bool_t modified=kTRUE) override
Remove object from list of primitives When.
Definition TPad.cxx:5349
TList * GetListOfPrimitives() const override
Definition TPad.h:258
Double_t AbsPixeltoY(Double_t py) override
Definition TPad.h:177
Double_t PadtoX(Double_t x) const override
Convert x from pad to X.
Definition TPad.cxx:3403
Double_t YtoPad(Double_t y) const override
Convert y from Y to pad.
Definition TPad.cxx:3433
virtual void EventPave()
Definition TPad.h:438
void Update() override
Update pad.
Definition TPad.cxx:2769
Double_t AbsPixeltoX(Double_t px) override
Definition TPad.h:176
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7272
Double_t GetY1() const override
Definition TPad.h:255
TCanvas * GetCanvas() const override
Definition TPad.h:275
void Add(TObject *obj, Option_t *opt="", Bool_t modified=kTRUE) override
Add an object to list of primitives with specified draw option When.
Definition TPad.cxx:485
TObject * FindObject(const char *name) const override
Search if object named name is inside this pad or in pads inside this pad.
Definition TPad.cxx:2469
Double_t PixeltoX(Double_t px) override
Convert pixel to X coordinate.
Definition TPad.cxx:7291
Double_t GetX2() const override
Definition TPad.h:254
Double_t GetX1() const override
Definition TPad.h:253
const char * GetName() const override
Returns name of object.
Definition TPad.h:273
Double_t XtoPad(Double_t x) const override
Convert x from X to pad.
Definition TPad.cxx:3421
A Pave (see TPave) with a text centered in the Pave.
Definition TPaveLabel.h:20
const char * GetLabel() const
Definition TPaveLabel.h:36
virtual void SetLabel(const char *label)
Definition TPaveLabel.h:42
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
virtual Int_t GetSize() const
return number of text lines (ignoring TLine, etc)
virtual TText * GetLine(Int_t number) const
Get Pointer to line number in this pavetext.
A TBox with a bordersize and a shadow option.
Definition TPave.h:19
A PaveText (see TPaveText) with several stacked paves.
Definition TPavesText.h:18
Interactive object for TGraph and TCutG editing.
TPolyLineEditInteractive(Int_t mode, const char *name, Double_t x0, Double_t y0, Int_t px0, Int_t py0)
Basic string class.
Definition TString.h:137
const char * Data() const
Definition TString.h:385
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
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:419
Internal class implementing text editing.
TTextEditInteractive(TPaveLabel *lbl)
TPaveText * fPaveText
or in TPave(s)Text
bool ProcessKeyPress(TPad &parent, Int_t py)
TLatex * fLatex
editing text in TLatex
TObject * GetObject() const
TTextEditInteractive(TPaveText *txt)
TPaveLabel * fLabel
or in TPaveLabel
void SetText(const TString &s)
Internal class implementing mouse click/move/relase editing Used for many classes like line,...
Int_t fMode
edit mode when interactive action started
T * Make(TPad &parent, Rest &&... rest)
TObject * fObject
object created by interactive action, owned by pad
TTwoPointInteractive(Int_t mode, Double_t x0, Double_t y0, Int_t px0, Int_t py0)
Double_t fY0
initial mouse pointer position in user coordiantes
Int_t fPY0
initial mouse pointer position in pixel coordiantes
void SetCoord(T *obj, Double_t x, Double_t y)
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:58
Helper class to store interactive parameters for individual objects Should be used via MakeInteractiv...
Definition TVirtualPad.h:72
T * GetInteractive(TObject *obj)
T * MakeInteractive(TObject *obj, Rest &&... rest)
void FreeInteractive(TObject *obj)
Release interactive instance for specified object.
TLine * line
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
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
TLine l
Definition textangle.C:4