gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/plot.h
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年02月03日 23:31:10 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年02月03日 23:31:10 +0100
commit86a26bb75cbd79a327ee96e4e8e7faf24e9a5f24 (patch)
tree8510a83c00bbc2dd16b80d5828f66ea315675394 /agg-plot/plot.h
parent23cb4843b180005e213a320c1dccd8d79a3330c6 (diff)
downloadgsl-shell-86a26bb75cbd79a327ee96e4e8e7faf24e9a5f24.tar.gz
Change plot title drawing to be always centered in the canvas
Diffstat (limited to 'agg-plot/plot.h')
-rw-r--r--agg-plot/plot.h 53
1 files changed, 27 insertions, 26 deletions
diff --git a/agg-plot/plot.h b/agg-plot/plot.h
index f3814250..bd2dc600 100644
--- a/agg-plot/plot.h
+++ b/agg-plot/plot.h
@@ -566,6 +566,11 @@ double plot<VS,RM>::draw_axis_m(axis_e dir, units& u,
return label_size;
}
+static inline double approx_text_height(double text_size)
+{
+ return text_size * 1.5;
+}
+
template <class VS, class RM>
agg::trans_affine plot<VS,RM>::draw_mini_plots(canvas_type& canvas,
agg::trans_affine& canvas_mtx)
@@ -576,8 +581,28 @@ agg::trans_affine plot<VS,RM>::draw_mini_plots(canvas_type& canvas,
double dxl, dxr, dyb, dyt;
- dxl = dxr = fpad+ppad*sx;
- dyb = dyt = fpad+ppad*sy;
+ dxl = dxr = fpad + ppad * sx;
+ dyb = dyt = fpad + ppad * sy;
+
+ if (!str_is_null(&m_title))
+ {
+ const double scale = compute_scale(canvas_mtx);
+ const double line_width = std_line_width(scale);
+ const double ptpad = double(axis_title_prop_space) / 1000.0;
+ const double title_text_size = 12.0 * scale;
+ const double th = approx_text_height(title_text_size);
+
+ double labx = canvas_mtx.tx + canvas_mtx.sx * 0.5;
+ double laby = canvas_mtx.sy - (ptpad + dyt + title_text_size);
+
+ draw::text title(m_title.cstr(), title_text_size, line_width, 0.5, 0.0);
+ title.set_point(labx, laby);
+ title.apply_transform(identity_matrix, 1.0);
+
+ canvas.draw(title, colors::black);
+
+ dyt += 2 * ptpad + th;
+ }
for (int k = 0; k < 4; k++)
{
@@ -631,11 +656,6 @@ agg::trans_affine plot<VS,RM>::draw_mini_plots(canvas_type& canvas,
return agg::trans_affine(ssx, 0.0, 0.0, ssy, cpx + dxl, cpy + dyb);
}
-static inline double approx_text_height(double text_size)
-{
- return text_size * 1.5;
-}
-
template <class VS, class RM>
void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx,
agg::rect_base<int>* clip)
@@ -674,7 +694,6 @@ void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx,
const double line_width = std_line_width(scale);
const double label_text_size = 11.0 * scale;
- const double title_text_size = 12.0 * scale;
const double plpad = double(axis_label_prop_space) / 1000.0;
const double ptpad = double(axis_title_prop_space) / 1000.0;
@@ -700,12 +719,6 @@ void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx,
ppad_bottom += ptpad;
}
- if (!str_is_null(&m_title))
- {
- dy_top += approx_text_height(title_text_size);
- ppad_top += ptpad;
- }
-
const double sx = canvas_mtx.sx, sy = canvas_mtx.sy;
const double xppad = (ppad_left + ppad_right);
@@ -767,18 +780,6 @@ void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx,
canvas.draw(ylabel, colors::black);
}
- if (!str_is_null(&m_title))
- {
- double labx = canvas_mtx.tx + canvas_mtx.sx * 0.5;
- double laby = m.ty + m.sy + 2 * ptpad * syr;
-
- draw::text title(m_title.cstr(), title_text_size, line_width, 0.5, 0.0);
- title.set_point(labx, laby);
- title.apply_transform(identity_matrix, 1.0);
-
- canvas.draw(title, colors::black);
- }
-
if (clip)
canvas.reset_clipping();
}
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月14日 10:55:07 +0000

AltStyle によって変換されたページ (->オリジナル) /