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年08月03日 09:32:23 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年08月03日 09:32:23 +0200
commit7980634816359aac92c4338ea7b48ec983bb650c (patch)
treeca67e1af0d72556f4d38af3a0bf8ab9210272f69 /agg-plot/plot.h
parent757911578dd111b05db7686c574d28f7ea63b437 (diff)
parent23e5174f22419bf6c5cf7a52c412c4ec3641a1e8 (diff)
downloadgsl-shell-7980634816359aac92c4338ea7b48ec983bb650c.tar.gz
Merge branch 'master' into fox-gui
Conflicts: agg-plot/Makefile agg-plot/lua-draw.h
Diffstat (limited to 'agg-plot/plot.h')
-rw-r--r--agg-plot/plot.h 37
1 files changed, 34 insertions, 3 deletions
diff --git a/agg-plot/plot.h b/agg-plot/plot.h
index 85c3d247..9cfb159b 100644
--- a/agg-plot/plot.h
+++ b/agg-plot/plot.h
@@ -117,14 +117,29 @@ public:
axis_e dir;
bool use_categories;
category_map categories;
+ units::format_e format_tag;
axis(axis_e _dir, const char* _title = 0):
title(_title ? _title : ""), dir(_dir), use_categories(false),
+ format_tag(units::format_invalid),
m_labels_angle(0.0),
m_labels_hjustif(_dir == x_axis ? 0.5 : 1.0),
m_labels_vjustif(_dir == x_axis ? 1.0 : 0.5)
{ }
+ const char* label_format() const
+ {
+ return (format_tag == units::format_invalid ? 0 : m_label_format);
+ }
+
+ void set_label_format(units::format_e tag, const char* fmt)
+ {
+ format_tag = tag;
+ memcpy(m_label_format, fmt, strlen(fmt) + 1);
+ }
+
+ void clear_label_format() { format_tag = units::format_invalid; }
+
void set_labels_angle(double angle)
{
double a = (dir == x_axis ? -angle + M_PI/2 : -angle);
@@ -141,6 +156,7 @@ public:
private:
double m_labels_angle;
double m_labels_hjustif, m_labels_vjustif;
+ char m_label_format[units::label_format_max_size];
};
plot(bool use_units = true) :
@@ -246,6 +262,21 @@ public:
bool pad_mode() const { return m_pad_units; }
+ bool enable_label_format(axis_e dir, const char* fmt)
+ {
+ if (!fmt)
+ {
+ get_axis(dir).clear_label_format();
+ return true;
+ }
+
+ units::format_e tag = units::parse_label_format(fmt);
+ if (tag == units::format_invalid)
+ return false;
+ get_axis(dir).set_label_format(tag, fmt);
+ return true;
+ }
+
void enable_categories(axis_e dir) { get_axis(dir).use_categories = true; }
void disable_categories(axis_e dir)
@@ -523,7 +554,7 @@ double plot<RM>::draw_axis_m(axis_e dir, units& u,
double langle = ax.labels_angle();
category_map::iterator clabels(ax.categories);
- units_iterator ulabels(u);
+ units_iterator ulabels(u, ax.format_tag, ax.label_format());
label_iterator* ilabels = (ax.use_categories ? (label_iterator*) &clabels : (label_iterator*) &ulabels);
@@ -636,14 +667,14 @@ agg::trans_affine plot<RM>::draw_legends(canvas_type& canvas,
switch (k)
{
case right:
- dx = sx * size_frac_x;
+ dx = max(sx * size_frac_x, bb_dx);
dy = dx * bb_dy / bb_dx;
px = sx - dx - ppad * sx - dxr;
py = (sy - dy) / 2;
dxr += dx + 2 * ppad * sx;
break;
case left:
- dx = sx * size_frac_x;
+ dx = max(sx * size_frac_x, bb_dx);
dy = dx * bb_dy / bb_dx;
px = ppad * sx + dxr;
py = (sy - dy) / 2;
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月13日 14:47:33 +0000

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