Skip to content

Commit 74521dc

Browse files
committed
Update and fix documentation.
1 parent 536b52c commit 74521dc

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed
10.9 KB
Loading

graf2d/gpad/src/TPad.cxx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,13 +1225,12 @@ Int_t TPad::DistancetoPrimitive(Int_t px, Int_t py)
12251225
/// Automatic pad generation by division.
12261226
///
12271227
/// - The current canvas is divided in nx by ny equal divisions (pads).
1228-
/// - xmargin defines the horizontal spacing around each pad as a percentage of the canvas
1229-
/// width. Therefore, the distance between two adjacent pads along the x-axis is equal
1230-
/// to twice the xmargin value.
1231-
/// - ymargin defines the vertical spacing around each pad as a percentage of the canvas
1232-
/// height. Therefore, the distance between two adjacent pads along the y-axis is equal
1233-
/// to twice the ymargin value.
1228+
/// - xmargin defines the horizontal spacing between each pad as a percentage of the canvas
1229+
/// width.
1230+
/// - ymargin defines the vertical spacing between each pad as a percentage of the canvas
1231+
/// height.
12341232
/// - color is the color of the new pads. If 0, color is the canvas color.
1233+
/// - All pads are contained within the inner area defined by the canvas margins.
12351234
///
12361235
/// Pads are automatically named `canvasname_n` where `n` is the division number
12371236
/// starting from top left pad.
@@ -1240,6 +1239,18 @@ Int_t TPad::DistancetoPrimitive(Int_t px, Int_t py)
12401239
///
12411240
/// \image html gpad_pad3.png
12421241
///
1242+
/// Example if:
1243+
/// /// ~~~ {.cpp}
1244+
/// c->SetLeftMargin(0.30);
1245+
/// c->SetBottomMargin(0.10);
1246+
/// c->SetRightMargin(0.05);
1247+
/// c->SetTopMargin(0.10);
1248+
/// c->Divide(nx, ny, 0.03, 0.05, 46);
1249+
/// ~~~
1250+
/// \image html canvas_divide.png
1251+
///
1252+
/// More examples are in `tutorials/visualisation/graphics/canvas_divide_example.C`
1253+
///
12431254
/// Once a pad is divided into sub-pads, one can set the current pad
12441255
/// to a subpad with a given division number as illustrated above
12451256
/// with TPad::cd(subpad_number).

tutorials/visualisation/graphics/canvas_divide_example.C

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,12 @@ void canvas_divide_example(int use_variant = 0)
1818
c->SetFillColor(19);
1919

2020
if (use_variant == 0) {
21-
c->SetLeftMargin(ml);
22-
c->SetBottomMargin(mb);
23-
c->SetRightMargin(mr);
24-
c->SetTopMargin(mt);
25-
21+
c->SetMargin(ml, mr, mb, mt);
2622
c->Divide(nx, ny, 0.03, 0.05, 46);
2723
} else if (use_variant == 1) {
2824
c->Divide(nx, ny, 0.01, 0.01, 46);
2925
} else {
30-
c->SetLeftMargin(0.01);
31-
c->SetBottomMargin(0.01);
32-
c->SetRightMargin(0.01);
33-
c->SetTopMargin(0.01);
34-
26+
c->SetMargin(0.01, 0.01, 0.01, 0.01);
3527
c->Divide(nx, ny, 0.02, 0.02, 46);
3628
}
3729

@@ -121,11 +113,6 @@ void canvas_divide_example(int use_variant = 0)
121113
text.SetTextFont(102);
122114
text.SetNDC(1);
123115

124-
if (use_variant == 0) {
125-
text.DrawText(0.01, 0.90, "c->SetLeftMargin(ml);");
126-
text.DrawText(0.01, 0.85, "c->SetBottomMargin(mb);");
127-
text.DrawText(0.01, 0.80, "c->SetRightMargin(mr);");
128-
text.DrawText(0.01, 0.75, "c->SetTopMargin(mt);");
129-
text.DrawText(0.01, 0.70, "c->Divide(nx, ny, xm, ym);");
130-
}
116+
text.DrawText(0.01, 0.97, "c->SetMargin(ml, mr, mb, mt);");
117+
text.DrawText(0.01, 0.94, "c->Divide(nx, ny, xm, ym);");
131118
}

0 commit comments

Comments
 (0)