author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年01月24日 19:11:33 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年01月30日 21:26:02 +0100 |
commit | 349fb72c939405efb9a25aea3fbd90da2f10a8f8 (patch) | |
tree | 1baf8ee0fb4de3c4ea697d1bc81f73ddfbf8dfb1 | |
parent | cba327706ed34d8c3166a748a3114d5a9ddc10b0 (diff) | |
download | gsl-shell-349fb72c939405efb9a25aea3fbd90da2f10a8f8.tar.gz |
-rw-r--r-- | agg-plot/lua-plot.cpp | 2 | ||||
-rw-r--r-- | agg-plot/plot.h | 14 | ||||
-rw-r--r-- | agg-plot/text.cpp | 19 | ||||
-rw-r--r-- | agg-plot/trans.h | 2 |
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 1bf9e8ec..5c3d481d 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -549,7 +549,7 @@ plot_save_svg (lua_State *L) return luaL_error(L, "cannot open filename: %s", filename); canvas_svg canvas(f, h); - agg::trans_affine m(w, 0.0, 0.0, -h, 0.0, h); + agg::trans_affine_scaling m(w, h); canvas.write_header(w, h); p->draw(canvas, m); canvas.write_end(); diff --git a/agg-plot/plot.h b/agg-plot/plot.h index d90b06e0..00cd749f 100644 --- a/agg-plot/plot.h +++ b/agg-plot/plot.h @@ -525,8 +525,7 @@ void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx) dy_label = xbr.y2 - xbr.y1; } - const double sx = fabs(canvas_mtx.sx), sy = fabs(canvas_mtx.sy); - const int ysign = (canvas_mtx.sy < 0.0 ? -1 : 1); + const double sx = canvas_mtx.sx, sy = canvas_mtx.sy; const double lsx = (dx_label + 4 * ppad * sx + 2 * fpad) / (1 + 4 * ppad); const double lsy = (dy_label + 4 * ppad * sy + 2 * fpad) / (1 + 4 * ppad); @@ -595,7 +594,7 @@ void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx) canvas_mtx.transform(&_labx, &laby); draw::text xlabel(m_xlabel.cstr(), label_text_size, line_width, 0.5, 0.0); - xlabel.set_point(labx, laby + ysign * (syr*ppad + fpad)); + xlabel.set_point(labx, laby + syr*ppad + fpad); xlabel.apply_transform(identity_matrix, 1.0); canvas.draw(xlabel, colors::black); @@ -620,7 +619,7 @@ void plot<VS,RM>::draw_axis(canvas_type& canvas, agg::trans_affine& canvas_mtx) m.transform(&labx, &laby); draw::text title(m_title.cstr(), title_text_size, line_width, 0.5, 0.0); - title.set_point(labx, laby + ysign * (2*syr*ppad)); + title.set_point(labx, laby + 2*syr*ppad); title.apply_transform(identity_matrix, 1.0); canvas.draw(title, colors::black); @@ -633,13 +632,12 @@ template<class VS, class RM> agg::trans_affine plot<VS,RM>::viewport_scale(agg::trans_affine& canvas_mtx) { agg::trans_affine m; - int ysign = (canvas_mtx.sy < 0.0 ? -1 : 1); m.sx = canvas_mtx.sx - (m_left_margin + m_right_margin); - m.sy = canvas_mtx.sy - ysign * (m_top_margin + m_bottom_margin); + m.sy = canvas_mtx.sy - (m_top_margin + m_bottom_margin); m.shx = 0.0; m.shy = 0.0; - m.tx = m_left_margin + canvas_mtx.tx; - m.ty = ysign * m_bottom_margin + canvas_mtx.ty; + m.tx = canvas_mtx.tx + m_left_margin; + m.ty = canvas_mtx.ty + m_bottom_margin; return m; } diff --git a/agg-plot/text.cpp b/agg-plot/text.cpp index b23d2218..ad6bd021 100644 --- a/agg-plot/text.cpp +++ b/agg-plot/text.cpp @@ -28,11 +28,6 @@ namespace draw { m_matrix = m_user_matrix; - if (m.sy < 0.0) { - m_matrix.shy *= -1.0; - m_matrix.sy *= -1.0; - } - m_trans.transformer(m_matrix); m_stroke.approximation_scale(as); } @@ -72,25 +67,25 @@ namespace draw { int txt_size = (int)(m_text_height * 1.5); - double x = 0.0, y = m_vjustif * m_text_height * 1.2; + double x = 0.0, y = - m_vjustif * m_text_height * 1.2; + if (!need_rotate) { - x += m.tx; - y += m.ty; + x = x + m.tx; + y = svg_y_coord(y + m.ty, h); } - double x_svg = x, y_svg = svg_y_coord(y, h); - const char* cont = m_text_buf.cstr(); str txt = str::print("<text x=\"%g\" y=\"%g\" id=\"text%i\"" \ " style=\"font-size:%i%s\">" \ " <tspan id=\"tspan%i\">%s</tspan>" \ "</text>", - x_svg, y_svg, id, txt_size, style.cstr(), + x, y, id, txt_size, style.cstr(), id, cont); if (need_rotate) { s = str::print("<g transform=\"matrix(%g,%g,%g,%g,%g,%g)\">%s</g>", - m.sx, m.shx, m.shy, m.sy, m.tx, m.ty, txt.cstr()); + m.sx, m.shx, m.shy, m.sy, m.tx, svg_y_coord(m.ty, h), + txt.cstr()); } else { s = txt; } diff --git a/agg-plot/trans.h b/agg-plot/trans.h index 99498738..c3aa60c2 100644 --- a/agg-plot/trans.h +++ b/agg-plot/trans.h @@ -188,8 +188,6 @@ struct trans { virtual void apply_transform(const agg::trans_affine& m, double as) { - m_scale.sy = (m.sy > 0.0 ? m_size : -m_size); - m_symbol->apply_transform(m_scale, as); m_source->apply_transform(m, as); } |