Logo ROOT   6.16/01
Reference Guide
TAxis3D.cxx
Go to the documentation of this file.
1// @(#)root/g3d:$Id$
2// Author: Valery Fine(fine@mail.cern.ch) 07/01/2000
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 <ctype.h>
13#include <assert.h>
14
15#include "Riostream.h"
16#include "TMath.h"
17#include "TList.h"
18#include "TClass.h"
19#include "TAxis3D.h"
20#include "TCanvas.h"
21#include "TPad.h"
22#include "TGaxis.h"
23#include "TView.h"
24#include "TVirtualPad.h"
25#include "TVirtualX.h"
26#include "TBrowser.h"
27#include "TStyle.h"
28
29/** \class TAxis3D
30\ingroup g3d
31
32The 3D axis painter class
33
34This class provide up to 3 axes to any 3D ROOT plot and "ZOOM" service.
35ExecuteEvent() method does provide zooming and moving a projection
363D object within TPad client area. With Zoom mode on the user can access
37TAxis3D context menu and set /change the attributes of axes all together
38or separately.
39
40To add the 3D rulers to any 3D view one has to create
41an instance of this class and Draw it.
42
43~~~ {.cpp}
44 TAxis3D rulers;
45 rulers.Draw();
46~~~
47
48One can use a static method to create ruler and attach it to the current gPad
49
50~~~ {.cpp}
51 TAxis3D::ToggleRulers(); // Brings the 3D axes up
52 TAxis3D::ToggleRulers(); // next calls remove the rulers from the TPad etc
53~~~
54
55To activate Zoomer one may call
56
57~~~ {.cpp}
58 TAxis3D::ToggleZoom();
59~~~
60
61each time one needs move or zoom the image. Then the user can:
62
63 - move:
64\image html g3d_axis3d_01.png
65 - zoom:
66\image html g3d_axis3d_02.png
67
68its 3D view with <left-mouse button> press / move.
69The "Zoom" deactivates itself just the user release the <left-mouse button>
70
71To change attributes of the rulers attached to the current Pad, one may
72query its pointer first:
73
74~~~ {.cpp}
75TAxis3D *axis = TAxis3D::GetPadAxis(); // Ask axis pointer
76if (axis) {
77 TAxis3D::ToggleRulers() // To pop axes down
78 axis->SetLabelColor(kBlue); // Paint the axes labels with blue color
79 axis->SetAxisColor(kRed); // Paint the axes itself with blue color
80 TAxis3D::ToggleRulers() // To pop axes up
81}
82~~~
83
84The attributes of the created axes are affected by the current style
85(see TStyle class ) and Set... methods of this class
86
87For example:
88~~~ {.cpp}
89 gStyle->SetAxisColor(kYellow,"X");
90 gStyle->SetAxisColor(kYellow,"Y");
91 gStyle->SetAxisColor(kYellow,"Z");
92
93 gStyle->SetLabelColor(kYellow,"X");
94 gStyle->SetLabelColor(kYellow,"Y");
95 gStyle->SetLabelColor(kYellow,"Z");
96
97 TAxis3D::ToggleRulers();
98 TAxis3D::ToggleRulers();
99~~~
100
101will draw all axes and labels with yellow color.
102*/
103
104const Char_t *TAxis3D::fgRulerName = "axis3druler";
106
107////////////////////////////////////////////////////////////////////////////////
108/// Normal constructor.
109
110TAxis3D::TAxis3D() : TNamed(TAxis3D::fgRulerName,"ruler")
111{
112 fSelected = 0;
115 InitSet();
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Normal constructor.
120
121TAxis3D::TAxis3D(Option_t *) : TNamed(TAxis3D::fgRulerName,"ruler")
122{
123 fSelected = 0;
124 InitSet();
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Copy constructor.
131
132TAxis3D::TAxis3D(const TAxis3D &axis) : TNamed(axis)
133{
134 ((TAxis3D&)axis).Copy(*this);
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Copy axis3d
139
140void TAxis3D::Copy(TObject &obj) const
141{
142 TNamed::Copy(obj);
143 for (Int_t i=0;i<2;i++) fAxis[i].Copy(((TAxis3D&)obj).fAxis[i]);
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Initialization.
148
150{
151 fAxis[0].SetName("xaxis");
152 fAxis[1].SetName("yaxis");
153 fAxis[2].SetName("zaxis");
154
155 fAxis[0].Set(1,0.,1.);
156 fAxis[1].Set(1,0.,1.);
157 fAxis[2].Set(1,0.,1.);
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Add all 3 axes to the TBrowser
163
165{
166 for (Int_t i=0;i<3;i++) b->Add(&fAxis[i],fAxis[i].GetTitle());
167}
168
169////////////////////////////////////////////////////////////////////////////////
170/// Compute distance from point px,py to a line.
171
173{
174 Int_t dist = 9;
175 for (int i=0;i<3;i++) {
176 Int_t axDist = fAxis[i].DistancetoPrimitive(px,py);
177 if (dist > axDist) { dist = axDist; fSelected = &fAxis[i]; }
178 }
179 if (fZoomMode)
180 return 0;
181 else
182 return dist;
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Execute action corresponding to one event.
187///
188/// This member function is called when an axis is clicked with the locator
189
191{
192 if (!gPad) return;
193
194 if (fSelected) fSelected->ExecuteEvent(event,px,py);
195
196 // Execute action corresponding to the mouse event
197
198 static Double_t x0, y0, x1, y1;
199
200 static Int_t pxold, pyold;
201 static Int_t px0, py0;
202 static Int_t linedrawn;
203
204 if (!fZoomMode) return;
205
206 // something to zoom ?
207
208 gPad->SetCursor(kCross);
209
210 switch (event) {
211
212 case kButton1Down:
213 gVirtualX->SetLineColor(-1);
214 gPad->TAttLine::Modify(); //Change line attributes only if necessary
215 ((TPad *)gPad)->AbsPixeltoXY(px,py,x0,y0);
216 px0 = px; py0 = py;
217 pxold = px; pyold = py;
218 linedrawn = 0;
219 break;
220
221 case kButton1Motion:
222 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
223 pxold = px;
224 pyold = py;
225 linedrawn = 1;
226 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
227 break;
228
229 case kButton1Up: {
230 Int_t i;
231 gPad->SetDoubleBuffer(1);
232 gVirtualX->SetDrawMode(TVirtualX::kCopy); // set drawing mode back to normal (copy) mode
233 TView *view = gPad->GetView();
234 if (!view) break; // no 3D view yet
235
236 Double_t min[3],max[3],viewCenter[3],viewCenterNDC[3];
237
238 view->GetRange(min,max);
239 for (i =0; i<3;i++) viewCenter[i] = (max[i]+min[i])/2;
240 view->WCtoNDC(viewCenter,viewCenterNDC);
241 // Define the center
242 Double_t center[3],pointNDC[3],size[3],oldSize[3];
243 ((TPad *)gPad)->AbsPixeltoXY(px,py,x1,y1);
244 pointNDC[0] = (x0+x1)/2; pointNDC[1] = (y0+y1)/2;
245 pointNDC[2] = viewCenterNDC[2];
246 view->NDCtoWC(pointNDC, center);
247
248 for (i =0; i<3;i++) oldSize[i] = size[i]= (max[i]-min[i])/2;
249
250 // If there was a small motion, move the center only, do not change a scale
251 if (TMath::Abs(px-px0)+TMath::Abs(py - py0) > 4 ) {
252 Double_t newEdge[3];
253 for (i =0; i<3;i++) size[i] = -1;
254
255 pointNDC[0] = x0; pointNDC[1] = y0;
256
257 view->NDCtoWC(pointNDC, newEdge);
258 for (i =0; i<3;i++) {
259 Double_t newSize = TMath::Abs(newEdge[i]-center[i]);
260 if ( newSize/oldSize[i] > 0.002)
261 size[i] = TMath::Max(size[i], newSize);
262 else
263 size[i] = oldSize[i];
264 }
265
266 pointNDC[0] = x1; pointNDC[1] = y1;
267
268 view->NDCtoWC(pointNDC, newEdge);
269 for (i =0; i<3;i++) {
270 Double_t newSize = TMath::Abs(newEdge[i]-center[i]);
271 if ( newSize/oldSize[i] > 0.002)
272 size[i] = TMath::Max(size[i], newSize);
273 else
274 size[i] = oldSize[i];
275 }
276#if 0
277 if (fZooms == kMAXZOOMS) fZoom = 0;
278 fZooms++;
279 memcpy(fZoomMin[fZooms],min,3*sizeof(Float_t));
280 memcpy(fZoomMax[fZooms],max,3*sizeof(Float_t));
281#endif
282 }
283 for (i =0; i<3;i++) {
284 max[i] = center[i] + size[i];
285 min[i] = center[i] - size[i];
286 }
287 view->SetRange(min,max);
288
290 gPad->Modified(kTRUE);
291 gPad->Update();
292 break;
293 }
294 default: break;
295 }
296}
297
298////////////////////////////////////////////////////////////////////////////////
299/// Dummy method
300/// returns the const char * to "axis3d"
301
303{
304 return (char*)"axis3d";
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Paint axis over 3D view on the TPad
309
311{
312 TGaxis axis;
313 PaintAxis(&axis, 90);
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Draw the axis for TView object.
318///
319/// The original idea belongs:
320///
321/// void THistPainter::PaintLegoAxis(TGaxis *axis, Double_t ang)
322
324{
325 static Double_t epsil = 0.001;
326
327 Double_t cosa, sina;
328 Double_t bmin, bmax;
329 Double_t r[24] /* was [3][8] */;
330 Int_t ndiv, i;
331 Double_t x1[3], x2[3], y1[3], y2[3], z1[3], z2[3], av[24] /* was [3][8] */;
332 char chopax[10];
333 Int_t ix1, ix2, iy1, iy2, iz1, iz2;
335
336 TView *view = gPad->GetView();
337 if (!view) {
338 Error("PaintAxis", "no TView in current pad");
339 return;
340 }
341
342 rad = TMath::ATan(1.) * 4. / 180.;
343 cosa = TMath::Cos(ang*rad);
344 sina = TMath::Sin(ang*rad);
345
346 view->AxisVertex(ang, av, ix1, ix2, iy1, iy2, iz1, iz2);
347 for (i = 1; i <= 8; ++i) {
348 r[i*3 - 3] = av[i*3 - 3] + av[i*3 - 2]*cosa;
349 r[i*3 - 2] = av[i*3 - 2]*sina;
350 r[i*3 - 1] = av[i*3 - 1];
351 }
352
353 view->WCtoNDC(&r[ix1*3 - 3], x1);
354 view->WCtoNDC(&r[ix2*3 - 3], x2);
355 view->WCtoNDC(&r[iy1*3 - 3], y1);
356 view->WCtoNDC(&r[iy2*3 - 3], y2);
357 view->WCtoNDC(&r[iz1*3 - 3], z1);
358 view->WCtoNDC(&r[iz2*3 - 3], z2);
359
360 view->SetAxisNDC(x1, x2, y1, y2, z1, z2);
361
362 Double_t *rmin = view->GetRmin();
363 Double_t *rmax = view->GetRmax();
364
365 axis->SetLineWidth(1);
366
367 for (i=0;i<3;i++) {
368
369 // X axis drawing
370 Double_t ax[2], ay[2];
371 Bool_t logAx = kFALSE;
372 memset(chopax,0,sizeof(chopax));
373 switch (i) {
374 case 0 :
375 ax[0] = x1[0]; ax[1] = x2[0];
376 ay[0] = x1[1]; ay[1] = x2[1];
377 logAx = gPad->GetLogx();
378 break;
379 case 1 :
380 if (TMath::Abs(y1[0] - y2[0]) < epsil) y2[0] = y1[0];
381 ax[0] = y1[0]; ax[1] = y2[0];
382 ay[0] = y1[1]; ay[1] = y2[1];
383 logAx = gPad->GetLogy();
384 break;
385 case 2 :
386 ax[0] = z1[0]; ax[1] = z2[0];
387 ay[0] = z1[1]; ay[1] = z2[1];
388 strlcpy(chopax, "SDH+=",10);
389 logAx = gPad->GetLogz();
390 break;
391 default:
392 assert(0);
393 continue;
394 };
395
396 // If the axis is too short - skip it
397 if ( ( TMath::Abs(ax[0] - ax[1]) + TMath::Abs(ay[0] - ay[1])) < epsil ) continue;
398
399 if (i != 2 ) {
400 if (ax[0] > ax[1]) strlcpy(chopax, "SDHV=+",10);
401 else strlcpy(chopax, "SDHV=-",10);
402 }
403
404 if (i==1 && (TMath::Abs(z1[0] - z2[0]) + TMath::Abs(z1[1] - z2[1])) < epsil)
405 strlcpy(chopax, "SDH+=",10);
406
407 // Initialize the axis options
408 if (logAx) {
409 strlcat(chopax,"G",10);
410 bmin = TMath::Power(10, rmin[i]);
411 bmax = TMath::Power(10, rmax[i]);
412 } else {
413 bmin = rmin[i];
414 bmax = rmax[i];
415 }
416
417 axis->SetLineColor( fAxis[i].GetAxisColor());
418 axis->SetTextFont( fAxis[i].GetTitleFont());
419 axis->SetTextColor( fAxis[i].GetTitleColor());
420 axis->SetTickSize( fAxis[i].GetTickLength());
421 axis->SetLabelColor( fAxis[i].GetLabelColor());
422 axis->SetLabelFont( fAxis[i].GetLabelFont());
424 axis->SetLabelSize( fAxis[i].GetLabelSize());
425 axis->SetTitle( fAxis[i].GetTitle());
427 axis->SetTitleSize( fAxis[i].GetTitleSize());
428 enum { kCenterTitle = BIT(12) }; // to be removed with the last version of ROOT
429 axis->SetBit(kCenterTitle, fAxis[i].TestBit(kCenterTitle));
430
431 //*-*- Initialize the number of divisions. If the
432 //*-*- number of divisions is negative, option 'N' is required.
433 ndiv = fAxis[i].GetNdivisions();
434 if (ndiv < 0) {
435 ndiv = -ndiv;
436 chopax[6] = 'N';
437 }
438
439 // Option time display is required ?
440 if (fAxis[i].GetTimeDisplay()) {
441 strlcat(chopax,"t",10);
442 if (strlen(fAxis[i].GetTimeFormatOnly()) == 0) {
443 axis->SetTimeFormat(fAxis[i].ChooseTimeFormat(bmax-bmin));
444 } else {
445 axis->SetTimeFormat(fAxis[i].GetTimeFormat());
446 }
447 }
448 axis->SetOption(chopax);
449 axis->PaintAxis(ax[0], ay[0], ax[1], ay[1], bmin, bmax, ndiv, chopax);
450 }
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Convert "screen pixel" coordinates to some center of 3D WC coordinate
455/// if view and gPad present
456
458{
459 Double_t *thisPoint = 0;
460 if (!view && gPad) view = gPad->GetView();
461 if (view) {
462 Double_t x[3] = {px,py,0.5}; // ((TPad *)thisPad)->AbsPixeltoXY(px,py,x[0],x[1]);
463 Double_t min[3], max[3];
464 view->GetRange(min,max);
465 Int_t i;
466 for (i =0; i<3;i++) min[i] = (max[i]+min[i])/2;
467 view->WCtoNDC(min,max);
468 min[0] = x[0]; min[1] = x[1];
469 min[2] = max[2];
470 view->NDCtoWC(min, x);
471 for (i=0;i<3;i++) point3D[i] = x[i];
472 thisPoint = point3D;
473 }
474 return thisPoint;
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Save primitive as a C++ statement(s) on output stream out
479
480void TAxis3D::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
481{
482 fAxis[0].SaveAttributes(out,GetName(),"->GetXaxis()");
483 fAxis[1].SaveAttributes(out,GetName(),"->GetYaxis()");
484 fAxis[2].SaveAttributes(out,GetName(),"->GetZaxis()");
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Replace current attributes by current style.
489
491{
492 if (gStyle->IsReading()) {
493 fAxis[0].ResetAttAxis("X");
494 fAxis[1].ResetAttAxis("Y");
495 fAxis[2].ResetAttAxis("Z");
496
497 fAxis[0].SetTitle("x");
501 } else {
510 gStyle->SetTitleSize (fAxis[0].GetTitleSize(), "x");
511 gStyle->SetTitleColor (fAxis[0].GetTitleColor(), "x");
512 gStyle->SetTitleFont (fAxis[0].GetTitleFont(), "x");
513
522 gStyle->SetTitleSize (fAxis[1].GetTitleSize(), "y");
523 gStyle->SetTitleColor (fAxis[1].GetTitleColor(), "y");
524 gStyle->SetTitleFont (fAxis[1].GetTitleFont(), "y");
525
534 gStyle->SetTitleSize (fAxis[2].GetTitleSize(), "z");
535 gStyle->SetTitleColor (fAxis[2].GetTitleColor(), "z");
536 gStyle->SetTitleFont (fAxis[2].GetTitleFont(), "z");
537 }
538}
539
540////////////////////////////////////////////////////////////////////////////////
541/// Return the axis index by its name
542
544{
545 char achoice = toupper(axis[0]);
546 if (achoice == 'X') return 0;
547 if (achoice == 'Y') return 1;
548 if (achoice == 'Z') return 2;
549 return -1;
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Get number of divisions.
554
556{
557 Int_t ax = AxisChoice(axis);
558 if (ax < 0) return 0;
559 return fAxis[ax].GetNdivisions();
560}
561
562////////////////////////////////////////////////////////////////////////////////
563/// Get axis color.
564
566{
567 Int_t ax = AxisChoice(axis);
568 if (ax < 0) return 0;
569 return fAxis[ax].GetAxisColor();
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Get label color.
574
576{
577 Int_t ax = AxisChoice(axis);
578 if (ax < 0) return 0;
579 return fAxis[ax].GetLabelColor();
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Get label font.
584
586{
587 Int_t ax = AxisChoice(axis);
588 if (ax < 0) return 0;
589 return fAxis[ax].GetLabelFont();
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Get label offset.
594
596{
597 Int_t ax = AxisChoice(axis);
598 if (ax < 0) return 0;
599 return fAxis[ax].GetLabelOffset();
600}
601
602////////////////////////////////////////////////////////////////////////////////
603/// Get label size.
604
606{
607 Int_t ax = AxisChoice(axis);
608 if (ax < 0) return 0;
609 return fAxis[ax].GetLabelSize();
610}
611
612////////////////////////////////////////////////////////////////////////////////
613/// Get tick mark length.
614
616{
617 Int_t ax = AxisChoice(axis);
618 if (ax < 0) return 0;
619 return fAxis[ax].GetTickLength();
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// Get title offset.
624
626{
627 Int_t ax = AxisChoice(axis);
628 if (ax < 0) return 0;
629 return fAxis[ax].GetTitleOffset();
630}
631
632////////////////////////////////////////////////////////////////////////////////
633
634#define AXISCHOICE \
635 Int_t i = AxisChoice(axis); \
636 Int_t nax = 1; \
637 if (i == -1) { i = 0; nax = 3;}\
638 for (Int_t ax=i;ax<nax+i;ax++)
639
640////////////////////////////////////////////////////////////////////////////////
641/// Set number of divisions.
642
644{
646}
647
648////////////////////////////////////////////////////////////////////////////////
649/// Set axis color.
650
652{
653 AXISCHOICE {fAxis[ax].SetAxisColor(color);}
654}
655
656////////////////////////////////////////////////////////////////////////////////
657/// Set axis range.
658
660{
661 Int_t ax = AxisChoice(axis);
662 if (ax < 0) return;
663 TAxis *theAxis = &fAxis[ax];
664 Int_t bin1 = theAxis->FindBin(xmin);
665 Int_t bin2 = theAxis->FindBin(xmax);
666 theAxis->SetRange(bin1, bin2);
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Set label color.
671
673{
674 AXISCHOICE { fAxis[ax].SetLabelColor(color); }
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// Set label font.
679
681{
682 AXISCHOICE { fAxis[ax].SetLabelFont(font); }
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// Set label offset.
687
689{
690 AXISCHOICE { fAxis[ax].SetLabelOffset(offset); }
691}
692
693////////////////////////////////////////////////////////////////////////////////
694/// Set label size.
695
697{
698 AXISCHOICE { fAxis[ax].SetLabelSize(size); }
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Set tick mark length.
703
705{
706 AXISCHOICE { fAxis[ax].SetTickLength(length); }
707}
708
709////////////////////////////////////////////////////////////////////////////////
710/// Set title offset.
711
713{
714 AXISCHOICE { fAxis[ax].SetTitleOffset(offset); }
715}
716#undef AXISCHOICE
717
718////////////////////////////////////////////////////////////////////////////////
719/// Returns the "pad" Axis3D object pointer if any.
720
722{
723 TObject *obj = 0;
724 TVirtualPad *thisPad=pad;
725 if (!thisPad) thisPad = gPad;
726 if (thisPad) {
727 // Find axis in the current thisPad
728 obj = thisPad->FindObject(TAxis3D::fgRulerName);
729 if (!(obj && obj->InheritsFrom(Class()->GetName()))) obj = 0;
730 }
731 return (TAxis3D *)obj;
732}
733
734////////////////////////////////////////////////////////////////////////////////
735/// Turn ON / OFF the "Ruler", TAxis3D object attached
736/// to the current pad
737
739{
740 TAxis3D *ax = 0;
741 TVirtualPad *thisPad=pad;
742 if (!thisPad) thisPad = gPad;
743 if (thisPad && thisPad->GetView() ) {
744 TAxis3D *a = GetPadAxis(pad);
745 if (a) delete a;
746 else {
747 ax = new TAxis3D;
748 ax->SetBit(kCanDelete);
749 ax->Draw();
750 }
751 thisPad->Modified();
752 thisPad->Update();
753 }
754 return ax;
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Turn ON / OFF the "Ruler" and "zoom mode" of the TAxis3D object attached
759/// to the current pad (if pad = 0; gPad is used "by default")
760///
761/// User is given a chance to either:
762/// 1. move the center of the 3D scene at the cursor position
763/// 2. zoom view with mouse "drugging" the bounder rectangle with "left" mouse
764/// 3. Change the axis attributes via TContextMenu with "right mouse button click"
765
767{
768 TAxis3D *ax = 0;
769 TVirtualPad *thisPad=pad;
770 if (!thisPad) thisPad = gPad;
771 if (thisPad && thisPad->GetView()) {
772 // Find axis in the current thisPad
773 TList *l = thisPad->GetListOfPrimitives();
774 TObject *o = l->FindObject(TAxis3D::fgRulerName);
775 if (o && o->InheritsFrom(Class()->GetName())) { // Find axis
776 if (o != l->Last()) { // make sure the TAxis3D is the last object of the Pad.
777 l->Remove(o);
778 l->AddLast(o);
779 }
780 ax = (TAxis3D *)o;
781 } else { // There is no
782 ax = new TAxis3D;
783 ax->SetBit(kCanDelete);
784 ax->Draw();
785 }
786 ax->SwitchZoom();
787 }
788 return ax;
789}
@ kButton1Motion
Definition: Buttons.h:20
@ kButton1Up
Definition: Buttons.h:19
@ kButton1Down
Definition: Buttons.h:17
void Class()
Definition: Class.C:29
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
char Char_t
Definition: RtypesCore.h:29
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
short Style_t
Definition: RtypesCore.h:76
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:82
#define ClassImp(name)
Definition: Rtypes.h:363
@ kRed
Definition: Rtypes.h:63
@ kGreen
Definition: Rtypes.h:63
@ kBlue
Definition: Rtypes.h:63
#define AXISCHOICE
Definition: TAxis3D.cxx:634
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
#define gPad
Definition: TVirtualPad.h:286
#define gVirtualX
Definition: TVirtualX.h:345
@ kCross
Definition: TVirtualX.h:46
virtual Color_t GetLabelColor() const
Definition: TAttAxis.h:38
virtual Int_t GetNdivisions() const
Definition: TAttAxis.h:36
virtual Color_t GetAxisColor() const
Definition: TAttAxis.h:37
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
Definition: TAttAxis.cxx:294
virtual Float_t GetLabelOffset() const
Definition: TAttAxis.h:40
virtual void SetAxisColor(Color_t color=1, Float_t alpha=1.)
Set color of the line axis and tick marks.
Definition: TAttAxis.cxx:163
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:204
virtual Style_t GetLabelFont() const
Definition: TAttAxis.h:39
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels The distance is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:193
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
Definition: TAttAxis.cxx:183
virtual Float_t GetLabelSize() const
Definition: TAttAxis.h:41
virtual Float_t GetTickLength() const
Definition: TAttAxis.h:44
virtual void ResetAttAxis(Option_t *option="")
Reset axis attributes.
Definition: TAttAxis.cxx:79
virtual Float_t GetTitleOffset() const
Definition: TAttAxis.h:42
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length The length is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:280
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:229
virtual void SetLabelColor(Color_t color=1, Float_t alpha=1.)
Set color of labels.
Definition: TAttAxis.cxx:173
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
The 3D axis painter class.
Definition: TAxis3D.h:31
virtual Float_t GetLabelSize(Option_t *axis="X") const
Get label size.
Definition: TAxis3D.cxx:605
Bool_t SwitchZoom()
Definition: TAxis3D.h:113
virtual void SetNdivisions(Int_t n=510, Option_t *axis="*")
Set number of divisions.
Definition: TAxis3D.cxx:643
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TAxis3D.cxx:190
virtual void Paint(Option_t *option="")
Paint axis over 3D view on the TPad.
Definition: TAxis3D.cxx:310
static TAxis3D * ToggleZoom(TVirtualPad *pad=0)
Turn ON / OFF the "Ruler" and "zoom mode" of the TAxis3D object attached to the current pad (if pad =...
Definition: TAxis3D.cxx:766
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
Definition: TAxis3D.cxx:172
void PaintAxis(TGaxis *axis, Float_t ang)
Draw the axis for TView object.
Definition: TAxis3D.cxx:323
virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="*")
Set label offset.
Definition: TAxis3D.cxx:688
virtual void SetLabelFont(Style_t font=62, Option_t *axis="*")
Set label font.
Definition: TAxis3D.cxx:680
static Double_t * PixeltoXYZ(Double_t px, Double_t py, Double_t *point3D, TView *view=0)
Convert "screen pixel" coordinates to some center of 3D WC coordinate if view and gPad present.
Definition: TAxis3D.cxx:457
TAxis fAxis[3]
Definition: TAxis3D.h:38
virtual Style_t GetLabelFont(Option_t *axis="X") const
Get label font.
Definition: TAxis3D.cxx:585
static TAxis3D * GetPadAxis(TVirtualPad *pad=0)
Returns the "pad" Axis3D object pointer if any.
Definition: TAxis3D.cxx:721
virtual Float_t GetLabelOffset(Option_t *axis="X") const
Get label offset.
Definition: TAxis3D.cxx:595
virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="*")
Set axis range.
Definition: TAxis3D.cxx:659
virtual Float_t GetTickLength(Option_t *axis="X") const
Get tick mark length.
Definition: TAxis3D.cxx:615
virtual void SetLabelSize(Float_t size=0.02, Option_t *axis="*")
Set label size.
Definition: TAxis3D.cxx:696
Int_t AxisChoice(Option_t *axis) const
Return the axis index by its name.
Definition: TAxis3D.cxx:543
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TAxis3D.cxx:480
virtual Color_t GetAxisColor(Option_t *axis="X") const
Get axis color.
Definition: TAxis3D.cxx:565
virtual void SetAxisColor(Color_t color=1, Option_t *axis="*")
Set axis color.
Definition: TAxis3D.cxx:651
virtual Color_t GetLabelColor(Option_t *axis="X") const
Get label color.
Definition: TAxis3D.cxx:575
virtual void Browse(TBrowser *b)
Add all 3 axes to the TBrowser.
Definition: TAxis3D.cxx:164
Bool_t fZoomMode
The selected axis to play with.
Definition: TAxis3D.h:42
virtual Float_t GetTitleOffset(Option_t *axis="X") const
Get title offset.
Definition: TAxis3D.cxx:625
void InitSet()
Initialization.
Definition: TAxis3D.cxx:149
void UseCurrentStyle()
Replace current attributes by current style.
Definition: TAxis3D.cxx:490
virtual Int_t GetNdivisions(Option_t *axis="X") const
Get number of divisions.
Definition: TAxis3D.cxx:555
static const char * fgRulerName
Definition: TAxis3D.h:40
virtual void SetTickLength(Float_t length=0.02, Option_t *axis="*")
Set tick mark length.
Definition: TAxis3D.cxx:704
static TAxis3D * ToggleRulers(TVirtualPad *pad=0)
Turn ON / OFF the "Ruler", TAxis3D object attached to the current pad.
Definition: TAxis3D.cxx:738
virtual void Copy(TObject &hnew) const
Copy axis3d.
Definition: TAxis3D.cxx:140
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Dummy method returns the const char * to "axis3d".
Definition: TAxis3D.cxx:302
virtual void SetLabelColor(Color_t color=1, Option_t *axis="*")
Set label color.
Definition: TAxis3D.cxx:672
Bool_t fStickyZoom
Definition: TAxis3D.h:43
TAxis3D()
Normal constructor.
Definition: TAxis3D.cxx:110
virtual void SetTitleOffset(Float_t offset=1, Option_t *axis="*")
Set title offset.
Definition: TAxis3D.cxx:712
TAxis * fSelected
Definition: TAxis3D.h:41
Class to manage histogram axis.
Definition: TAxis.h:30
virtual void SaveAttributes(std::ostream &out, const char *name, const char *subname)
Save axis attributes as C++ statement(s) on output stream out.
Definition: TAxis.cxx:647
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TAxis.cxx:267
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:279
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Definition: TAxis.cxx:717
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to an axis.
Definition: TAxis.cxx:251
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
Definition: TAxis.cxx:903
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
The axis painter class.
Definition: TGaxis.h:24
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition: TGaxis.cxx:2718
virtual void PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt="", Double_t gridlength=0, Bool_t drawGridOnly=kFALSE)
Control function to draw an axis.
Definition: TGaxis.cxx:956
void SetTitleOffset(Float_t titleoffset=1)
Definition: TGaxis.h:125
void SetLabelFont(Int_t labelfont)
Definition: TGaxis.h:106
void SetTitleSize(Float_t titlesize)
Definition: TGaxis.h:126
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition: TGaxis.cxx:2691
void SetLabelOffset(Float_t labeloffset)
Definition: TGaxis.h:107
void SetLabelColor(Int_t labelcolor)
Definition: TGaxis.h:105
void SetTickSize(Float_t ticksize)
Definition: TGaxis.h:119
void SetLabelSize(Float_t labelsize)
Definition: TGaxis.h:108
void SetOption(Option_t *option="")
To set axis options.
Definition: TGaxis.cxx:2683
A doubly linked list.
Definition: TList.h:44
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void Copy(TObject &named) const
Copy this to obj.
Definition: TNamed.cxx:94
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:321
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
The most important graphics class in the ROOT system.
Definition: TPad.h:29
void SetAxisColor(Color_t color=1, Option_t *axis="X")
Set color to draw the axis line and tick marks.
Definition: TStyle.cxx:1129
Bool_t IsReading() const
Definition: TStyle.h:277
void SetTitleFont(Style_t font=62, Option_t *axis="X")
Definition: TStyle.cxx:1580
void SetTitleOffset(Float_t offset=1, Option_t *axis="X")
Specify a parameter offset to control the distance between the axis and the axis title.
Definition: TStyle.cxx:1603
void SetTitleColor(Color_t color=1, Option_t *axis="X")
Definition: TStyle.cxx:1559
void SetLabelFont(Style_t font=62, Option_t *axis="X")
Set font number used to draw axis labels.
Definition: TStyle.cxx:1219
void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Set offset between axis and axis labels.
Definition: TStyle.cxx:1235
void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
Definition: TStyle.cxx:1622
void SetTickLength(Float_t length=0.03, Option_t *axis="X")
Set the tick marks length for an axis.
Definition: TStyle.cxx:1540
void SetNdivisions(Int_t n=510, Option_t *axis="X")
Set the number of divisions to draw an axis.
Definition: TStyle.cxx:1115
void SetLabelColor(Color_t color=1, Option_t *axis="X")
Set axis labels color.
Definition: TStyle.cxx:1199
void SetLabelSize(Float_t size=0.04, Option_t *axis="X")
Set size of axis labels.
Definition: TStyle.cxx:1250
See TView3D.
Definition: TView.h:25
virtual Double_t * GetRmax()=0
virtual void SetAxisNDC(const Double_t *x1, const Double_t *x2, const Double_t *y1, const Double_t *y2, const Double_t *z1, const Double_t *z2)=0
virtual Double_t * GetRmin()=0
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)=0
virtual void GetRange(Float_t *min, Float_t *max)=0
virtual void SetRange(const Double_t *min, const Double_t *max)=0
virtual void AxisVertex(Double_t ang, Double_t *av, Int_t &ix1, Int_t &ix2, Int_t &iy1, Int_t &iy2, Int_t &iz1, Int_t &iz2)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
virtual void Modified(Bool_t flag=1)=0
virtual TList * GetListOfPrimitives() const =0
virtual void Update()=0
virtual TView * GetView() const =0
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
static constexpr double rad
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Double_t ATan(Double_t)
Definition: TMath.h:663
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:723
Double_t Cos(Double_t)
Definition: TMath.h:629
Double_t Sin(Double_t)
Definition: TMath.h:625
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
auto * l
Definition: textangle.C:4
auto * a
Definition: textangle.C:12