ROOT  6.06/09
Reference Guide
TCreatePrimitives.cxx
Go to the documentation of this file.
1 // @(#)root/gpad:$Id: TCreatePrimitives.cxx,v 1.0
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2000, 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 
14 Creates new primitives.
15 
16 The functions in this static class are called by TPad::ExecuteEvent
17 to create new primitives in gPad from the TPad toolbar.
18 */
19 
20 #include "TCanvas.h"
21 #include "TStyle.h"
22 #include "TGraph.h"
23 #include "TMarker.h"
24 #include "TGroupButton.h"
25 #include "TVirtualPad.h"
26 #include "TCreatePrimitives.h"
27 #include "TROOT.h"
28 #include "TSystem.h"
29 #include "TMath.h"
30 #include "KeySymbols.h"
31 #include "TCutG.h"
32 
33 #include <iostream>
34 
35 TLatex *TCreatePrimitives::fgText = 0;
36 TCurlyLine *TCreatePrimitives::fgCLine = 0;
37 TArrow *TCreatePrimitives::fgArrow = 0;
38 TLine *TCreatePrimitives::fgLine = 0;
39 TCurlyArc *TCreatePrimitives::fgCArc = 0;
40 TArc *TCreatePrimitives::fgArc = 0;
41 TEllipse *TCreatePrimitives::fgEllipse = 0;
42 TPave *TCreatePrimitives::fgPave = 0;
43 TPaveText *TCreatePrimitives::fgPaveText = 0;
44 TPavesText *TCreatePrimitives::fgPavesText = 0;
45 TDiamond *TCreatePrimitives::fgDiamond = 0;
46 TPaveLabel *TCreatePrimitives::fgPaveLabel = 0;
47 TGraph *TCreatePrimitives::fgPolyLine = 0;
48 TBox *TCreatePrimitives::fgPadBBox = 0;
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// TCreatePrimitives default constructor.
52 
54 {
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// TCreatePrimitives destructor.
59 
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Create a new arc/ellipse in this gPad.
66 ///
67 /// - Click left button to indicate arrow starting position.
68 /// - Release left button to terminate the arrow.
69 
71 {
72  static Double_t x0, y0, x1, y1;
73  Double_t xc,yc,r1,r2,xold,yold;
74 
75  switch (event) {
76 
77  case kButton1Down:
78  x0 = gPad->AbsPixeltoX(px);
79  y0 = gPad->AbsPixeltoY(py);
80  xold = gPad->AbsPixeltoX(px);
81  yold = gPad->AbsPixeltoY(py);
82  break;
83 
84  case kButton1Motion:
85  xold = gPad->AbsPixeltoX(px);
86  yold = gPad->AbsPixeltoY(py);
87 
88  if (gPad->GetLogx()) xold = TMath::Power(10,xold);
89  if (gPad->GetLogy()) yold = TMath::Power(10,yold);
90 
91  xc = 0.5*(x0+xold);
92  yc = 0.5*(y0+yold);
93  if (mode == kArc) {
94  r1 = 0.5*TMath::Abs(xold-x0);
95  if (fgArc) {
96  fgArc->SetR1(r1);
97  fgArc->SetR2(r1);
98  fgArc->SetX1(xc);
99  fgArc->SetY1(yc);
100  } else {
101  fgArc = new TArc(xc, yc, r1);
102  fgArc->Draw();
103  }
104  gPad->Modified(kTRUE);
105  gPad->Update();
106  }
107  if (mode == kEllipse) {
108  r1 = 0.5*TMath::Abs(xold-x0);
109  r2 = 0.5*TMath::Abs(yold-y0);
110  if (fgEllipse) {
111  fgEllipse->SetR1(r1);
112  fgEllipse->SetR2(r2);
113  fgEllipse->SetX1(xc);
114  fgEllipse->SetY1(yc);
115  } else {
116  fgEllipse = new TEllipse(xc, yc, r1, r2);
117  fgEllipse->Draw();
118  }
119  gPad->Modified(kTRUE);
120  gPad->Update();
121  }
122  break;
123 
124  case kButton1Up:
125  x1 = gPad->AbsPixeltoX(px);
126  y1 = gPad->AbsPixeltoY(py);
127  if (gPad->GetLogx()) {
128  x0 = TMath::Power(10,x0);
129  x1 = TMath::Power(10,x1);
130  }
131  if (gPad->GetLogy()) {
132  y0 = TMath::Power(10,y0);
133  y1 = TMath::Power(10,y1);
134  }
135  xc = 0.5*(x0+x1);
136  yc = 0.5*(y0+y1);
137 
138  if (mode == kArc) {
139  gPad->GetCanvas()->Selected(gPad, fgArc, kButton1Down);
140  fgArc = 0;
141  }
142  if (mode == kEllipse) {
143  gPad->GetCanvas()->Selected(gPad, fgEllipse, kButton1Down);
144  fgEllipse = 0;
145  }
146 
147  gROOT->SetEditorMode();
148  break;
149  }
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////
153 /// Create a new line/arrow in this gPad.
154 ///
155 /// - Click left button to indicate arrow starting position.
156 /// - Release left button to terminate the arrow.
157 
158 void TCreatePrimitives::Line(Int_t event, Int_t px, Int_t py, Int_t mode)
159 {
160  static Double_t x0, y0;
161 
162  static Int_t pxold, pyold;
163  static Int_t px0, py0;
164  Double_t radius, phimin,phimax;
165 
166  switch (event) {
167 
168  case kButton1Down:
169  x0 = gPad->AbsPixeltoX(px);
170  y0 = gPad->AbsPixeltoY(py);
171  px0 = px; py0 = py;
172  pxold = px; pyold = py;
173  if (gPad->GetLogx()) {
174  px0 = TMath::Power(10,px0);
175  pxold = TMath::Power(10,pxold);
176  }
177  if (gPad->GetLogy()) {
178  py0 = TMath::Power(10,py0);
179  pyold = TMath::Power(10,pyold);
180  }
181  break;
182 
183  case kButton1Motion:
184  pxold = px;
185  pyold = py;
186 
187  if (gPad->GetLogx()) pxold = TMath::Power(10,pxold);
188  if (gPad->GetLogy()) pyold = TMath::Power(10,pyold);
189 
190  if (mode == kLine) {
191  if (fgLine){
192  fgLine->SetX2(gPad->AbsPixeltoX(pxold));
193  fgLine->SetY2(gPad->AbsPixeltoY(pyold));
194  } else {
195  fgLine = new TLine(x0,y0,gPad->AbsPixeltoX(pxold),gPad->AbsPixeltoY(pyold));
196  fgLine->Draw();
197  }
198  gPad->Modified(kTRUE);
199  gPad->Update();
200  }
201 
202  if (mode == kArrow) {
203  if (fgArrow){
204  fgArrow->SetX2(gPad->AbsPixeltoX(pxold));
205  fgArrow->SetY2(gPad->AbsPixeltoY(pyold));
206  } else {
207  fgArrow = new TArrow(x0,y0,gPad->AbsPixeltoX(pxold),gPad->AbsPixeltoY(pyold)
210  fgArrow->Draw();
211  }
212  gPad->Modified(kTRUE);
213  gPad->Update();
214  }
215 
216  if (mode == kCurlyLine) {
217  if (fgCLine) fgCLine->SetEndPoint(gPad->AbsPixeltoX(pxold), gPad->AbsPixeltoY(pyold));
218  else {
219  fgCLine = new TCurlyLine(gPad->AbsPixeltoX(px0),gPad->AbsPixeltoY(py0),gPad->AbsPixeltoX(pxold),gPad->AbsPixeltoY(pyold)
222  fgCLine->Draw();
223  }
224  gPad->Modified(kTRUE);
225  gPad->Update();
226  }
227 
228  if (mode == kCurlyArc) {
229  //calculate radius in pixels and convert to users x
230  radius = gPad->PixeltoX((Int_t)(TMath::Sqrt((Double_t)((px-px0)*(px-px0) + (py-py0)*(py-py0)))))
231  - gPad->PixeltoX(0);
232  if (fgCArc) {
233  fgCArc->SetStartPoint(gPad->AbsPixeltoX(pxold), gPad->AbsPixeltoY(pyold));
234  fgCArc->SetRadius(radius);
235  } else {
236  phimin = 0;
237  phimax = 360;
238  fgCArc = new TCurlyArc(x0,y0,radius,phimin,phimax
241  fgCArc->Draw();
242  }
243  gPad->Modified(kTRUE);
244  gPad->Update();
245  }
246  break;
247 
248  case kButton1Up:
249  if (mode == kLine) {
250  gPad->GetCanvas()->Selected(gPad, fgLine, kButton1Down);
251  fgLine = 0;
252  }
253  if (mode == kArrow) {
254  gPad->GetCanvas()->Selected(gPad, fgArrow, kButton1Down);
255  fgArrow = 0;
256  }
257  if (mode == kCurlyLine) {
258  gPad->GetCanvas()->Selected(gPad, fgCLine, kButton1Down);
259  fgCLine = 0;
260  }
261  if (mode == kCurlyArc) {
262  gPad->GetCanvas()->Selected(gPad, fgCArc, kButton1Down);
263  fgCArc = 0;
264  }
265  gROOT->SetEditorMode();
266  break;
267  }
268 }
269 
270 ////////////////////////////////////////////////////////////////////////////////
271 /// Create a new pad in gPad.
272 ///
273 /// - Click left button to indicate one corner of the pad.
274 /// - Click left button to indicate the opposite corner.
275 ///
276 /// The new pad is inserted in the pad where the first point is selected.
277 
279 {
280  static Int_t px1old, py1old, px2old, py2old;
281  static Int_t px1, py1, px2, py2, pxl, pyl, pxt, pyt;
282  static TPad *padsav;
283  Double_t xlow, ylow, xup, yup;
284  TPad * newpad;
285 
286  Int_t n = 0;
287  TObject *obj;
288  TIter next(gPad->GetListOfPrimitives());
289 
290  while ((obj = next())) {
291  if (obj->InheritsFrom(TPad::Class())) {
292  n++;
293  }
294  }
295 
296  switch (event) {
297 
298  case kButton1Down:
299  padsav = (TPad*)gPad;
300  gPad->cd();
301  px1 = gPad->XtoAbsPixel(gPad->GetX1());
302  py1 = gPad->YtoAbsPixel(gPad->GetY1());
303  px2 = gPad->XtoAbsPixel(gPad->GetX2());
304  py2 = gPad->YtoAbsPixel(gPad->GetY2());
305  px1old = px; py1old = py;
306  break;
307 
308  case kButton1Motion:
309  px2old = px;
310  px2old = TMath::Max(px2old, px1);
311  px2old = TMath::Min(px2old, px2);
312  py2old = py;
313  py2old = TMath::Max(py2old, py2);
314  py2old = TMath::Min(py2old, py1);
315  pxl = TMath::Min(px1old, px2old);
316  pxt = TMath::Max(px1old, px2old);
317  pyl = TMath::Max(py1old, py2old);
318  pyt = TMath::Min(py1old, py2old);
319 
320  if (fgPadBBox) {
321  fgPadBBox->SetX1(gPad->AbsPixeltoX(pxl));
322  fgPadBBox->SetY1(gPad->AbsPixeltoY(pyl));
323  fgPadBBox->SetX2(gPad->AbsPixeltoX(pxt));
324  fgPadBBox->SetY2(gPad->AbsPixeltoY(pyt));
325  } else {
326  fgPadBBox = new TBox(pxl, pyl, pxt, pyt);
327  fgPadBBox->Draw("l");
328  }
329  gPad->Modified(kTRUE);
330  gPad->Update();
331  break;
332 
333  case kButton1Up:
334  fgPadBBox->Delete();
335  fgPadBBox = 0;
336  xlow = (Double_t(pxl) - Double_t(px1))/(Double_t(px2) - Double_t(px1));
337  ylow = (Double_t(py1) - Double_t(pyl))/(Double_t(py1) - Double_t(py2));
338  xup = (Double_t(pxt) - Double_t(px1))/(Double_t(px2) - Double_t(px1));
339  yup = (Double_t(py1) - Double_t(pyt))/(Double_t(py1) - Double_t(py2));
340  gROOT->SetEditorMode();
341  if (xup <= xlow || yup <= ylow) return;
342  newpad = new TPad(Form("%s_%d",gPad->GetName(),n+1),"newpad",xlow, ylow, xup, yup);
343  if (newpad->IsZombie()) break;
344  newpad->SetFillColor(gStyle->GetPadColor());
345  newpad->Draw();
346  TCanvas *canvas = gPad->GetCanvas();
347  if (canvas) canvas->Selected((TPad*)gPad, newpad, kButton1Down);
348  padsav->cd();
349  break;
350  }
351 }
352 
353 ////////////////////////////////////////////////////////////////////////////////
354 /// Create a new pavetext in gPad.
355 ///
356 /// - Click left button to indicate one corner of the pavelabel.
357 /// - Release left button at the opposite corner.
358 
359 void TCreatePrimitives::Pave(Int_t event, Int_t px, Int_t py, Int_t mode)
360 {
361  static Double_t x0, y0;
362  Double_t xp0,xp1,yp0,yp1,xold,yold;
363 
364  if (mode == kPaveLabel)
365  ((TPad *)gPad)->EventPave();
366 
367  switch (event) {
368 
369  case kKeyPress:
370  if (mode == kPaveLabel) {
371  if ((py == kKey_Return) || (py == kKey_Enter)) {
373  Int_t l = s.Length();
374  s.Remove(l-1);
375  fgPaveLabel->SetLabel(s.Data());
377  gPad->Modified(kTRUE);
378  gROOT->SetEditorMode();
379  gPad->Update();
380  fgPaveLabel = 0;
381  } else if (py == kKey_Backspace) {
383  Int_t l = s.Length();
384  if (l>1) {
385  s.Replace(l-2, 2, "<");
386  fgPaveLabel->SetLabel(s.Data());
387  gPad->Modified(kTRUE);
388  gPad->Update();
389  }
390  } else if (isprint(py)) {
392  Int_t l = s.Length();
393  s.Insert(l-1,(char)py);
394  fgPaveLabel->SetLabel(s.Data());
395  gPad->Modified(kTRUE);
396  gPad->Update();
397  }
398  }
399  break;
400 
401  case kButton1Down:
402  x0 = gPad->AbsPixeltoX(px);
403  y0 = gPad->AbsPixeltoY(py);
404  break;
405 
406  case kButton1Motion:
407  xold = gPad->AbsPixeltoX(px);
408  yold = gPad->AbsPixeltoY(py);
409 
410  xp0 = gPad->PadtoX(x0);
411  xp1 = gPad->PadtoX(xold);
412  yp0 = gPad->PadtoY(y0);
413  yp1 = gPad->PadtoY(yold);
414 
415  if (mode == kPave) {
416  if (fgPave) {
417  if (xold < x0) {
418  fgPave->SetX1(xold);
419  fgPave->SetX2(x0);
420  } else {
421  fgPave->SetX1(x0);
422  fgPave->SetX2(xold);
423  }
424  if (yold < y0) {
425  fgPave->SetY1(yold);
426  fgPave->SetY2(y0);
427  } else {
428  fgPave->SetY1(y0);
429  fgPave->SetY2(yold);
430  }
431  } else {
432  fgPave = new TPave(xp0,yp0,xp1,yp1);
433  fgPave->Draw();
434  }
435  gPad->Modified(kTRUE);
436  gPad->Update();
437  }
438 
439  if (mode == kPaveText ) {
440  if (fgPaveText){
441  if (xold < x0) {
442  fgPaveText->SetX1(xold);
443  fgPaveText->SetX2(x0);
444  } else {
445  fgPaveText->SetX1(x0);
446  fgPaveText->SetX2(xold);
447  }
448  if (yold < y0) {
449  fgPaveText->SetY1(yold);
450  fgPaveText->SetY2(y0);
451  } else {
452  fgPaveText->SetY1(y0);
453  fgPaveText->SetY2(yold);
454  }
455  } else {
456  fgPaveText = new TPaveText(xp0,yp0,xp1,yp1);
457  fgPaveText->Draw();
458  }
459  gPad->Modified(kTRUE);
460  gPad->Update();
461  }
462 
463  if (mode == kPavesText) {
464  if (fgPavesText){
465  if (xold < x0) {
466  fgPavesText->SetX1(xold);
467  fgPavesText->SetX2(x0);
468  } else {
469  fgPavesText->SetX1(x0);
470  fgPavesText->SetX2(xold);
471  }
472  if (yold < y0) {
473  fgPavesText->SetY1(yold);
474  fgPavesText->SetY2(y0);
475  } else {
476  fgPavesText->SetY1(y0);
477  fgPavesText->SetY2(yold);
478  }
479  } else {
480  fgPavesText = new TPavesText(xp0,yp0,xp1,yp1);
481  fgPavesText->Draw();
482  }
483  gPad->Modified(kTRUE);
484  gPad->Update();
485  }
486 
487  if (mode == kPaveLabel) {
488  if (fgPaveLabel){
489  if (xold < x0) {
490  fgPaveLabel->SetX1(xold);
491  fgPaveLabel->SetX2(x0);
492  } else {
493  fgPaveLabel->SetX1(x0);
494  fgPaveLabel->SetX2(xold);
495  }
496  if (yold < y0) {
497  fgPaveLabel->SetY1(yold);
498  fgPaveLabel->SetY2(y0);
499  } else {
500  fgPaveLabel->SetY1(y0);
501  fgPaveLabel->SetY2(yold);
502  }
503  } else {
504  fgPaveLabel = new TPaveLabel(xp0,yp0,xp1,yp1,">");
505  fgPaveLabel->Draw();
506  }
507  gPad->Modified(kTRUE);
508  gPad->Update();
509  }
510 
511  if (mode == kDiamond) {
512  if (fgDiamond){
513  if (xold < x0) {
514  fgDiamond->SetX1(xold);
515  fgDiamond->SetX2(x0);
516  } else {
517  fgDiamond->SetX1(x0);
518  fgDiamond->SetX2(xold);
519  }
520  if (yold < y0) {
521  fgDiamond->SetY1(yold);
522  fgDiamond->SetY2(y0);
523  } else {
524  fgDiamond->SetY1(y0);
525  fgDiamond->SetY2(yold);
526  }
527  } else {
528  fgDiamond = new TDiamond(x0,y0,xold,yold);
529  fgDiamond->Draw();
530  }
531  gPad->Modified(kTRUE);
532  gPad->Update();
533  }
534  break;
535 
536  case kButton1Up:
537  gPad->GetCanvas()->Selected(gPad, fgPave, kButton1Down);
538  if (mode == kPave) {
539  gPad->GetCanvas()->Selected(gPad, fgPave, kButton1Down);
540  fgPave = 0;
541  }
542  if (mode == kPaveText ) {
543  gPad->GetCanvas()->Selected(gPad, fgPaveText, kButton1Down);
544  fgPaveText = 0;
545  }
546  if (mode == kPavesText) {
547  gPad->GetCanvas()->Selected(gPad, fgPavesText, kButton1Down);
548  fgPavesText = 0;
549  }
550  if (mode == kDiamond) {
551  gPad->GetCanvas()->Selected(gPad, fgDiamond, kButton1Down);
552  fgDiamond = 0;
553  }
554  if (mode == kPaveLabel) {
555  gPad->GetCanvas()->Selected(gPad, fgPaveLabel, kButton1Down);
556  ((TPad *)gPad)->StartEditing();
558  if (mode == kPaveLabel) {
559  gPad->Modified(kTRUE);
560  gPad->Update();
561  break;
562  }
563  }
564  gROOT->SetEditorMode();
565  break;
566  }
567 }
568 
569 ////////////////////////////////////////////////////////////////////////////////
570 /// Create a new PolyLine in gPad.
571 ///
572 /// - Click left button to indicate a new point.
573 /// - Click left button at same place or double click to close the polyline.
574 
576 {
577  static Int_t pxnew, pynew, pxold, pyold, dp;
578  Double_t xnew, ynew, xold, yold;
579  static Int_t npoints = 0;
580 
581  switch (event) {
582 
583  case kButton1Down:
584  pxnew = px;
585  pynew = py;
586  npoints++;
587  if (fgPolyLine) {
588  fgPolyLine->Set(fgPolyLine->GetN() +1);
589  fgPolyLine->SetPoint(npoints, gPad->PadtoX(gPad->AbsPixeltoX(pxnew)),
590  gPad->PadtoY(gPad->AbsPixeltoY(pynew)));
591  // stop collecting new points if new point is close to previous point
592  if (npoints > 1) {
593  xnew = gPad->PadtoX(gPad->AbsPixeltoX(pxnew));
594  ynew = gPad->PadtoY(gPad->AbsPixeltoY(pynew));
595  fgPolyLine->GetPoint(fgPolyLine->GetN()-3, xold, yold);
596  pxold = gPad->XtoAbsPixel(xold);
597  pyold = gPad->YtoAbsPixel(yold);
598  dp = TMath::Abs(pxnew-pxold) +TMath::Abs(pynew-pyold);
599  if (dp < 7) {
600  if (mode == kPolyLine) {
601  fgPolyLine->Set(npoints-1);
602  } else {
603  fgPolyLine->GetPoint(0, xnew, ynew);
604  fgPolyLine->SetPoint(npoints, xnew, ynew);
605  }
606  gPad->GetCanvas()->Selected(gPad, fgPolyLine, kButton1Down);
607  fgPolyLine = 0;
608  npoints = 0;
609  gPad->Modified();
610  gPad->Update();
611  gROOT->SetEditorMode();
612  }
613  }
614  }
615  break;
616 
617  case kButton1Double:
618  if (fgPolyLine) {
619  if (mode == kPolyLine) {
620  fgPolyLine->Set(npoints);
621  } else {
622  fgPolyLine->GetPoint(0, xnew, ynew);
623  fgPolyLine->SetPoint(npoints, xnew, ynew);
624  }
625  gPad->GetCanvas()->Selected(gPad, fgPolyLine, kButton1Down);
626  fgPolyLine = 0;
627  npoints = 0;
628  gPad->Modified();
629  gPad->Update();
630  gROOT->SetEditorMode();
631  }
632  break;
633 
634  case kMouseMotion:
635  pxnew = px;
636  pynew = py;
637  if (fgPolyLine) {
638  fgPolyLine->SetPoint(npoints, gPad->PadtoX(gPad->AbsPixeltoX(pxnew)),
639  gPad->PadtoY(gPad->AbsPixeltoY(pynew)));
640  gPad->Modified();
641  gPad->Update();
642  } else {
643  if (mode == kPolyLine) {
644  fgPolyLine = new TGraph(1);
646  } else { // TCutG case
647  fgPolyLine = (TGraph*) new TCutG("CUTG",1);
648  }
649  fgPolyLine->SetPoint(0, gPad->PadtoX(gPad->AbsPixeltoX(pxnew)),
650  gPad->PadtoY(gPad->AbsPixeltoY(pynew)));
651  fgPolyLine->Draw("L");
652  }
653  break;
654  }
655 }
656 
657 ////////////////////////////////////////////////////////////////////////////////
658 /// Create a new TLatex at the cursor position in gPad.
659 ///
660 /// - Click left button to indicate the text position.
661 
662 void TCreatePrimitives::Text(Int_t event, Int_t px, Int_t py, Int_t mode)
663 {
664  static Double_t x, y;
665 
666  switch (event) {
667 
668  case kKeyPress:
669  if ((py == kKey_Return) || (py == kKey_Enter)) {
670  TString s(fgText->GetTitle());
671  Int_t l = s.Length();
672  s.Remove(l-1);
673  fgText->SetText(x,y,s.Data());
675  gPad->Modified(kTRUE);
676  gROOT->SetEditorMode();
677  gPad->Update();
678  gPad->GetCanvas()->Selected(gPad, fgText, kButton1Down);
679  fgText = 0;
680  } else if (py == kKey_Backspace) {
681  TString s(fgText->GetTitle());
682  Int_t l = s.Length();
683  if (l>1) {
684  s.Replace(l-2, 2, "<");
685  fgText->SetText(x,y,s.Data());
686  gPad->Modified(kTRUE);
687  gPad->Update();
688  }
689  } else if (isprint(py)) {
690  TString s(fgText->GetTitle());
691  Int_t l = s.Length();
692  s.Insert(l-1,(char)py);
693  fgText->SetText(x,y,s.Data());
694  gPad->Modified(kTRUE);
695  gPad->Update();
696  }
697  break;
698 
699  case kButton1Down:
700  if (fgText) {
701  TString s(fgText->GetTitle());
702  Int_t l = s.Length();
703  s.Remove(l-1);
704  fgText->SetText(x,y,s.Data());
705  }
706 
707  x = gPad->AbsPixeltoX(px);
708  y = gPad->AbsPixeltoY(py);
709  if (gPad->GetLogx()) x = TMath::Power(10,x);
710  if (gPad->GetLogy()) y = TMath::Power(10,y);
711 
712  if (mode == kMarker) {
713  TMarker *marker;
714  marker = new TMarker(x,y,gStyle->GetMarkerStyle());
715  gPad->GetCanvas()->Selected(gPad, marker, kButton1Down);
716  marker->Draw();
717  gROOT->SetEditorMode();
718  break;
719  }
720 
721  ((TPad *)gPad)->StartEditing();
723 
724  fgText = new TLatex(x,y,"<");
725  fgText->Draw();
726  gPad->Modified(kTRUE);
727  gPad->Update();
728  break;
729  }
730 }
virtual void SetY2(Double_t y2)
Definition: TLine.h:85
virtual void Draw(Option_t *option="")
Draw this diamond with its current attributes.
Definition: TDiamond.cxx:94
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
static TPave * fgPave
static Double_t GetDefaultWaveLength()
Get default wave length.
Definition: TCurlyLine.cxx:441
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition: TCanvas.cxx:1503
static TGraph * fgPolyLine
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:420
static void PolyLine(Int_t event, Int_t px, Int_t py, Int_t mode)
Create a new PolyLine in gPad.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
static Double_t GetDefaultAmplitude()
Get default wave amplitude.
Definition: TCurlyArc.cxx:502
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Create a Box.
Definition: TBox.h:44
Definition: Buttons.h:33
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
virtual void Draw(Option_t *option="")
Draw this marker with its current attributes.
Definition: TMarker.cxx:139
virtual ~TCreatePrimitives()
TCreatePrimitives destructor.
#define gROOT
Definition: TROOT.h:340
static Double_t GetDefaultWaveLength()
Get default wave length.
Definition: TCurlyArc.cxx:494
Bool_t IsZombie() const
Definition: TObject.h:141
Basic string class.
Definition: TString.h:137
Manages Markers.
Definition: TMarker.h:40
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
int Int_t
Definition: RtypesCore.h:41
static TLatex * fgText
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
virtual void SetX1(Double_t x1)
Definition: TBox.h:83
virtual void SetX2(Double_t x2)
Definition: TBox.h:84
Int_t GetN() const
Definition: TGraph.h:132
virtual void SetR1(Double_t r1)
Definition: TEllipse.h:85
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:740
virtual void Draw(Option_t *option="")
Draw this pavestext with its current attributes.
Definition: TPavesText.cxx:79
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:501
static void Text(Int_t event, Int_t px, Int_t py, Int_t mode)
Create a new TLatex at the cursor position in gPad.
A TBox with a bordersize and a shadow option.
Definition: TPave.h:31
static TDiamond * fgDiamond
static TArc * fgArc
virtual void SetY2(Double_t y2)
Set the Y2 value.
Definition: TPave.cxx:669
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
Graphical cut class.
Definition: TCutG.h:29
Double_t x[n]
Definition: legend1.C:17
virtual void SetText(Double_t x, Double_t y, const char *text)
Definition: TText.h:89
static Float_t GetDefaultArrowSize()
Get default arrow size.
Definition: TArrow.cxx:418
void Class()
Definition: Class.C:29
virtual void SetStartPoint(Double_t x1, Double_t y1)
Set start point.
Definition: TCurlyLine.cxx:397
virtual void Draw(Option_t *option="")
Draw this arrow with its current attributes.
Definition: TArrow.cxx:121
static TBox * fgPadBBox
Implements curly or wavy polylines used to draw Feynman diagrams.
Definition: TCurlyLine.h:32
To draw Mathematical Formula.
Definition: TLatex.h:33
static TCurlyLine * fgCLine
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1196
virtual void SetRadius(Double_t radius)
Set Curly Arc radius.
Definition: TCurlyArc.cxx:443
virtual void Draw(Option_t *option="")
Draw this ellipse with its current attributes.
Definition: TEllipse.cxx:167
static TEllipse * fgEllipse
virtual void SetLabel(const char *label)
Definition: TPaveLabel.h:53
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:32
static Double_t GetDefaultAmplitude()
Get default amplitude.
Definition: TCurlyLine.cxx:449
Create an Arc.
Definition: TArc.h:29
virtual void SetX2(Double_t x2)
Definition: TLine.h:83
virtual void SetEndPoint(Double_t x2, Double_t y2)
Set end point.
Definition: TCurlyLine.cxx:407
virtual void Delete(Option_t *option="")
Delete this object.
Definition: TObject.cxx:228
virtual void SetY1(Double_t y1)
Definition: TEllipse.h:89
static TPaveText * fgPaveText
virtual void Draw(Option_t *option="")
Draw this polyline with its current attributes.
Definition: TPolyLine.cxx:232
Definition: Buttons.h:33
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
Definition: Buttons.h:33
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
Draw a Diamond.
Definition: TDiamond.h:35
virtual void SetX1(Double_t x1)
Definition: TEllipse.h:88
const char * GetTitle() const
Returns title of object.
Definition: TPaveLabel.h:48
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
virtual void SetX1(Double_t x1)
Set the X1 value.
Definition: TPave.cxx:630
The most important graphics class in the ROOT system.
Definition: TPad.h:46
static TArrow * fgArrow
char * Form(const char *fmt,...)
virtual void SetR2(Double_t r2)
Definition: TEllipse.h:86
A simple line.
Definition: TLine.h:41
static TPavesText * fgPavesText
TLine * l
Definition: textangle.C:4
virtual void SetY2(Double_t y2)
Definition: TBox.h:86
virtual void Draw(Option_t *option="")
Draw this pave with its current attributes.
Definition: TPave.cxx:209
The Canvas class.
Definition: TCanvas.h:48
virtual void SetY1(Double_t y1)
Set the Y1 value.
Definition: TPave.cxx:656
static const double x1[5]
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:35
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Definition: TPaveLabel.cxx:77
double Double_t
Definition: RtypesCore.h:55
Color_t GetPadColor() const
Definition: TStyle.h:217
Definition: Buttons.h:31
static void Pad(Int_t event, Int_t px, Int_t py, Int_t)
Create a new pad in gPad.
Double_t y[n]
Definition: legend1.C:17
static TPaveLabel * fgPaveLabel
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
Definition: TGraph.cxx:1551
Draw Ellipses.
Definition: TEllipse.h:44
virtual void SetX2(Double_t x2)
Set the X2 value.
Definition: TPave.cxx:643
virtual void Draw(Option_t *option="")
Draw this box with its current attributes.
Definition: TBox.cxx:180
Mother of all ROOT objects.
Definition: TObject.h:58
static Option_t * GetDefaultOption()
Get default option.
Definition: TArrow.cxx:428
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2127
static TCurlyArc * fgCArc
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
#define gPad
Definition: TVirtualPad.h:288
void ResetBit(UInt_t f)
Definition: TObject.h:172
static void Line(Int_t event, Int_t px, Int_t py, Int_t mode)
Create a new line/arrow in this gPad.
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
Draw all kinds of Arrows.
Definition: TArrow.h:35
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
Definition: TGraph.cxx:2076
static TLine * fgLine
A PaveText (see TPaveText) with several stacked paves.
Definition: TPavesText.h:28
virtual Style_t GetMarkerStyle() const
Definition: TAttMarker.h:45
const Bool_t kTRUE
Definition: Rtypes.h:91
static void Pave(Int_t event, Int_t px, Int_t py, Int_t mode)
Create a new pavetext in gPad.
TObject * obj
virtual void SetY1(Double_t y1)
Definition: TBox.h:85
Implements curly or wavy arcs used to draw Feynman diagrams.
Definition: TCurlyArc.h:25
TCreatePrimitives()
TCreatePrimitives default constructor.
const Int_t n
Definition: legend1.C:16
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322
static void Ellipse(Int_t event, Int_t px, Int_t py, Int_t mode)
Create a new arc/ellipse in this gPad.