diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-07-12 14:10:16 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-07-12 14:10:16 +0000 |
commit | f4ce2b5c214cce406dbd7a73dc7f35ae409546ad (patch) | |
tree | 533cc821ffc9c5664c075930be6a40fde9593aba /plugins/Clist_ng/AGG/src | |
parent | 71a88c6d8c4578ca24e02a5c6f4860c206e7c6da (diff) |
Clist NG:
Commit of CList NG by silvercircle from https://github.com/silvercircle/miranda-ng
This is based on clist_nicer and Anti-Grain Geometry: http://www.antigrain.com/
This is the first version that actually compiles.
Do NOT use it in production environment!
git-svn-id: http://svn.miranda-ng.org/main/trunk@14543 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_ng/AGG/src')
51 files changed, 11959 insertions, 0 deletions
diff --git a/plugins/Clist_ng/AGG/src/ChangeLog b/plugins/Clist_ng/AGG/src/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ChangeLog diff --git a/plugins/Clist_ng/AGG/src/Makefile b/plugins/Clist_ng/AGG/src/Makefile new file mode 100644 index 0000000000..429f66ab8e --- /dev/null +++ b/plugins/Clist_ng/AGG/src/Makefile @@ -0,0 +1,59 @@ +include ../Makefile.in.$(shell uname)
+
+CXXFLAGS= $(AGGCXXFLAGS) -I../include -L./
+
+SRC_CXX=\
+agg_arc.cpp \
+agg_arrowhead.cpp \
+agg_bezier_arc.cpp \
+agg_bspline.cpp \
+agg_curves.cpp \
+agg_vcgen_contour.cpp \
+agg_vcgen_dash.cpp \
+agg_vcgen_markers_term.cpp \
+agg_vcgen_smooth_poly1.cpp \
+agg_vcgen_stroke.cpp \
+agg_vcgen_bspline.cpp \
+agg_gsv_text.cpp \
+agg_image_filters.cpp \
+agg_line_aa_basics.cpp \
+agg_line_profile_aa.cpp \
+agg_rounded_rect.cpp \
+agg_sqrt_tables.cpp \
+agg_embedded_raster_fonts.cpp \
+agg_trans_affine.cpp \
+agg_trans_warp_magnifier.cpp \
+agg_trans_single_path.cpp \
+agg_trans_double_path.cpp \
+agg_vpgen_clip_polygon.cpp \
+agg_vpgen_clip_polyline.cpp \
+agg_vpgen_segmentator.cpp \
+ctrl/agg_cbox_ctrl.cpp \
+ctrl/agg_gamma_ctrl.cpp \
+ctrl/agg_gamma_spline.cpp \
+ctrl/agg_rbox_ctrl.cpp \
+ctrl/agg_slider_ctrl.cpp \
+ctrl/agg_spline_ctrl.cpp \
+ctrl/agg_scale_ctrl.cpp \
+ctrl/agg_polygon_ctrl.cpp \
+ctrl/agg_bezier_ctrl.cpp
+
+SRC_C=\
+../gpc/gpc.c
+
+
+OBJ=$(SRC_CXX:.cpp=.o) $(SRC_C:.c=.o)
+
+all: $(OBJ)
+ $(LIB) libagg.a $(OBJ)
+
+clean:
+ rm -f *.o *.a ctrl/*.o ../gpc/*.o
+ rm -rf SunWS_cache
+ rm -rf ctrl/SunWS_cache
+
+%.o: %.cpp
+ $(CXX) -c $(CXXFLAGS) $*.cpp -o $@
+
+%.o: %.c
+ $(C) -c $(CXXFLAGS) $*.c -o $@
diff --git a/plugins/Clist_ng/AGG/src/Makefile.am b/plugins/Clist_ng/AGG/src/Makefile.am new file mode 100644 index 0000000000..f9a35fb27b --- /dev/null +++ b/plugins/Clist_ng/AGG/src/Makefile.am @@ -0,0 +1,47 @@ +SUBDIRS = ctrl . platform
+
+INCLUDES = -I$(top_srcdir)/include
+
+lib_LTLIBRARIES = libagg.la
+
+libagg_la_LDFLAGS = -no-undefined -version-info @AGG_LIB_VERSION@
+libagg_la_SOURCES = agg_arc.cpp \
+ agg_arrowhead.cpp \
+ agg_bezier_arc.cpp \
+ agg_bspline.cpp \
+ agg_curves.cpp \
+ agg_embedded_raster_fonts.cpp \
+ agg_gsv_text.cpp \
+ agg_image_filters.cpp \
+ agg_line_aa_basics.cpp \
+ agg_line_profile_aa.cpp \
+ agg_rounded_rect.cpp \
+ agg_sqrt_tables.cpp \
+ agg_trans_affine.cpp \
+ agg_trans_double_path.cpp \
+ agg_trans_single_path.cpp \
+ agg_trans_warp_magnifier.cpp \
+ agg_vcgen_bspline.cpp \
+ agg_vcgen_contour.cpp \
+ agg_vcgen_dash.cpp \
+ agg_vcgen_markers_term.cpp \
+ agg_vcgen_smooth_poly1.cpp \
+ agg_vcgen_stroke.cpp \
+ agg_vpgen_clip_polygon.cpp \
+ agg_vpgen_clip_polyline.cpp \
+ agg_vpgen_segmentator.cpp
+
+if ENABLE_GPC
+GPCLD=$(top_builddir)/gpc/libagggpc.la
+else
+GPCLD=
+endif
+
+if ENABLE_CTRL
+CTRLLD=$(top_builddir)/src/ctrl/libaggctrl.la
+else
+CTRLLD=
+endif
+
+libagg_la_LIBADD = $(GPCLD) $(CTRLLD)
+
diff --git a/plugins/Clist_ng/AGG/src/agg_arc.cpp b/plugins/Clist_ng/AGG/src/agg_arc.cpp new file mode 100644 index 0000000000..f97717f584 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_arc.cpp @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_arc.h"
+
+
+namespace agg
+{
+ //------------------------------------------------------------------------
+ arc::arc(double x, double y,
+ double rx, double ry,
+ double a1, double a2,
+ bool ccw) :
+ m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0)
+ {
+ normalize(a1, a2, ccw);
+ }
+
+ //------------------------------------------------------------------------
+ void arc::init(double x, double y,
+ double rx, double ry,
+ double a1, double a2,
+ bool ccw)
+ {
+ m_x = x; m_y = y;
+ m_rx = rx; m_ry = ry;
+ normalize(a1, a2, ccw);
+ }
+
+ //------------------------------------------------------------------------
+ void arc::approximation_scale(double s)
+ {
+ m_scale = s;
+ if(m_initialized)
+ {
+ normalize(m_start, m_end, m_ccw);
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void arc::rewind(unsigned)
+ {
+ m_path_cmd = path_cmd_move_to;
+ m_angle = m_start;
+ }
+
+ //------------------------------------------------------------------------
+ unsigned arc::vertex(double* x, double* y)
+ {
+ if(is_stop(m_path_cmd)) return path_cmd_stop;
+ if((m_angle < m_end - m_da/4) != m_ccw)
+ {
+ *x = m_x + cos(m_end) * m_rx;
+ *y = m_y + sin(m_end) * m_ry;
+ m_path_cmd = path_cmd_stop;
+ return path_cmd_line_to;
+ }
+
+ *x = m_x + cos(m_angle) * m_rx;
+ *y = m_y + sin(m_angle) * m_ry;
+
+ m_angle += m_da;
+
+ unsigned pf = m_path_cmd;
+ m_path_cmd = path_cmd_line_to;
+ return pf;
+ }
+
+ //------------------------------------------------------------------------
+ void arc::normalize(double a1, double a2, bool ccw)
+ {
+ double ra = (fabs(m_rx) + fabs(m_ry)) / 2;
+ m_da = acos(ra / (ra + 0.125 / m_scale)) * 2;
+ if(ccw)
+ {
+ while(a2 < a1) a2 += pi * 2.0;
+ }
+ else
+ {
+ while(a1 < a2) a1 += pi * 2.0;
+ m_da = -m_da;
+ }
+ m_ccw = ccw;
+ m_start = a1;
+ m_end = a2;
+ m_initialized = true;
+ }
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_arrowhead.cpp b/plugins/Clist_ng/AGG/src/agg_arrowhead.cpp new file mode 100644 index 0000000000..47a6572a8d --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_arrowhead.cpp @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_arrowhead.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ arrowhead::arrowhead() :
+ m_head_d1(1.0),
+ m_head_d2(1.0),
+ m_head_d3(1.0),
+ m_head_d4(0.0),
+ m_tail_d1(1.0),
+ m_tail_d2(1.0),
+ m_tail_d3(1.0),
+ m_tail_d4(0.0),
+ m_head_flag(false),
+ m_tail_flag(false),
+ m_curr_id(0),
+ m_curr_coord(0)
+ {
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void arrowhead::rewind(unsigned path_id)
+ {
+ m_curr_id = path_id;
+ m_curr_coord = 0;
+ if(path_id == 0)
+ {
+ if(!m_tail_flag)
+ {
+ m_cmd[0] = path_cmd_stop;
+ return;
+ }
+ m_coord[0] = m_tail_d1; m_coord[1] = 0.0;
+ m_coord[2] = m_tail_d1 - m_tail_d4; m_coord[3] = m_tail_d3;
+ m_coord[4] = -m_tail_d2 - m_tail_d4; m_coord[5] = m_tail_d3;
+ m_coord[6] = -m_tail_d2; m_coord[7] = 0.0;
+ m_coord[8] = -m_tail_d2 - m_tail_d4; m_coord[9] = -m_tail_d3;
+ m_coord[10] = m_tail_d1 - m_tail_d4; m_coord[11] = -m_tail_d3;
+
+ m_cmd[0] = path_cmd_move_to;
+ m_cmd[1] = path_cmd_line_to;
+ m_cmd[2] = path_cmd_line_to;
+ m_cmd[3] = path_cmd_line_to;
+ m_cmd[4] = path_cmd_line_to;
+ m_cmd[5] = path_cmd_line_to;
+ m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
+ m_cmd[6] = path_cmd_stop;
+ return;
+ }
+
+ if(path_id == 1)
+ {
+ if(!m_head_flag)
+ {
+ m_cmd[0] = path_cmd_stop;
+ return;
+ }
+ m_coord[0] = -m_head_d1; m_coord[1] = 0.0;
+ m_coord[2] = m_head_d2 + m_head_d4; m_coord[3] = -m_head_d3;
+ m_coord[4] = m_head_d2; m_coord[5] = 0.0;
+ m_coord[6] = m_head_d2 + m_head_d4; m_coord[7] = m_head_d3;
+
+ m_cmd[0] = path_cmd_move_to;
+ m_cmd[1] = path_cmd_line_to;
+ m_cmd[2] = path_cmd_line_to;
+ m_cmd[3] = path_cmd_line_to;
+ m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
+ m_cmd[5] = path_cmd_stop;
+ return;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned arrowhead::vertex(double* x, double* y)
+ {
+ if(m_curr_id < 2)
+ {
+ unsigned curr_idx = m_curr_coord * 2;
+ *x = m_coord[curr_idx];
+ *y = m_coord[curr_idx + 1];
+ return m_cmd[m_curr_coord++];
+ }
+ return path_cmd_stop;
+ }
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_bezier_arc.cpp b/plugins/Clist_ng/AGG/src/agg_bezier_arc.cpp new file mode 100644 index 0000000000..2140783ac6 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_bezier_arc.cpp @@ -0,0 +1,261 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_bezier_arc.h"
+
+
+namespace agg
+{
+
+ // This epsilon is used to prevent us from adding degenerate curves
+ // (converging to a single point).
+ // The value isn't very critical. Function arc_to_bezier() has a limit
+ // of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve
+ // becomes inaccurate. But slight exceeding is quite appropriate.
+ //-------------------------------------------------bezier_arc_angle_epsilon
+ const double bezier_arc_angle_epsilon = 0.01;
+
+ //------------------------------------------------------------arc_to_bezier
+ void arc_to_bezier(double cx, double cy, double rx, double ry,
+ double start_angle, double sweep_angle,
+ double* curve)
+ {
+ double x0 = cos(sweep_angle / 2.0);
+ double y0 = sin(sweep_angle / 2.0);
+ double tx = (1.0 - x0) * 4.0 / 3.0;
+ double ty = y0 - tx * x0 / y0;
+ double px[4];
+ double py[4];
+ px[0] = x0;
+ py[0] = -y0;
+ px[1] = x0 + tx;
+ py[1] = -ty;
+ px[2] = x0 + tx;
+ py[2] = ty;
+ px[3] = x0;
+ py[3] = y0;
+
+ double sn = sin(start_angle + sweep_angle / 2.0);
+ double cs = cos(start_angle + sweep_angle / 2.0);
+
+ unsigned i;
+ for(i = 0; i < 4; i++)
+ {
+ curve[i * 2] = cx + rx * (px[i] * cs - py[i] * sn);
+ curve[i * 2 + 1] = cy + ry * (px[i] * sn + py[i] * cs);
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void bezier_arc::init(double x, double y,
+ double rx, double ry,
+ double start_angle,
+ double sweep_angle)
+ {
+ start_angle = fmod(start_angle, 2.0 * pi);
+ if(sweep_angle >= 2.0 * pi) sweep_angle = 2.0 * pi;
+ if(sweep_angle <= -2.0 * pi) sweep_angle = -2.0 * pi;
+
+ if(fabs(sweep_angle) < 1e-10)
+ {
+ m_num_vertices = 4;
+ m_cmd = path_cmd_line_to;
+ m_vertices[0] = x + rx * cos(start_angle);
+ m_vertices[1] = y + ry * sin(start_angle);
+ m_vertices[2] = x + rx * cos(start_angle + sweep_angle);
+ m_vertices[3] = y + ry * sin(start_angle + sweep_angle);
+ return;
+ }
+
+ double total_sweep = 0.0;
+ double local_sweep = 0.0;
+ double prev_sweep;
+ m_num_vertices = 2;
+ m_cmd = path_cmd_curve4;
+ bool done = false;
+ do
+ {
+ if(sweep_angle < 0.0)
+ {
+ prev_sweep = total_sweep;
+ local_sweep = -pi * 0.5;
+ total_sweep -= pi * 0.5;
+ if(total_sweep <= sweep_angle + bezier_arc_angle_epsilon)
+ {
+ local_sweep = sweep_angle - prev_sweep;
+ done = true;
+ }
+ }
+ else
+ {
+ prev_sweep = total_sweep;
+ local_sweep = pi * 0.5;
+ total_sweep += pi * 0.5;
+ if(total_sweep >= sweep_angle - bezier_arc_angle_epsilon)
+ {
+ local_sweep = sweep_angle - prev_sweep;
+ done = true;
+ }
+ }
+
+ arc_to_bezier(x, y, rx, ry,
+ start_angle,
+ local_sweep,
+ m_vertices + m_num_vertices - 2);
+
+ m_num_vertices += 6;
+ start_angle += local_sweep;
+ }
+ while(!done && m_num_vertices < 26);
+ }
+
+
+
+
+ //--------------------------------------------------------------------
+ void bezier_arc_svg::init(double x0, double y0,
+ double rx, double ry,
+ double angle,
+ bool large_arc_flag,
+ bool sweep_flag,
+ double x2, double y2)
+ {
+ m_radii_ok = true;
+
+ if(rx < 0.0) rx = -rx;
+ if(ry < 0.0) ry = -rx;
+
+ // Calculate the middle point between
+ // the current and the final points
+ //------------------------
+ double dx2 = (x0 - x2) / 2.0;
+ double dy2 = (y0 - y2) / 2.0;
+
+ double cos_a = cos(angle);
+ double sin_a = sin(angle);
+
+ // Calculate (x1, y1)
+ //------------------------
+ double x1 = cos_a * dx2 + sin_a * dy2;
+ double y1 = -sin_a * dx2 + cos_a * dy2;
+
+ // Ensure radii are large enough
+ //------------------------
+ double prx = rx * rx;
+ double pry = ry * ry;
+ double px1 = x1 * x1;
+ double py1 = y1 * y1;
+
+ // Check that radii are large enough
+ //------------------------
+ double radii_check = px1/prx + py1/pry;
+ if(radii_check > 1.0)
+ {
+ rx = sqrt(radii_check) * rx;
+ ry = sqrt(radii_check) * ry;
+ prx = rx * rx;
+ pry = ry * ry;
+ if(radii_check > 10.0) m_radii_ok = false;
+ }
+
+ // Calculate (cx1, cy1)
+ //------------------------
+ double sign = (large_arc_flag == sweep_flag) ? -1.0 : 1.0;
+ double sq = (prx*pry - prx*py1 - pry*px1) / (prx*py1 + pry*px1);
+ double coef = sign * sqrt((sq < 0) ? 0 : sq);
+ double cx1 = coef * ((rx * y1) / ry);
+ double cy1 = coef * -((ry * x1) / rx);
+
+ //
+ // Calculate (cx, cy) from (cx1, cy1)
+ //------------------------
+ double sx2 = (x0 + x2) / 2.0;
+ double sy2 = (y0 + y2) / 2.0;
+ double cx = sx2 + (cos_a * cx1 - sin_a * cy1);
+ double cy = sy2 + (sin_a * cx1 + cos_a * cy1);
+
+ // Calculate the start_angle (angle1) and the sweep_angle (dangle)
+ //------------------------
+ double ux = (x1 - cx1) / rx;
+ double uy = (y1 - cy1) / ry;
+ double vx = (-x1 - cx1) / rx;
+ double vy = (-y1 - cy1) / ry;
+ double p, n;
+
+ // Calculate the angle start
+ //------------------------
+ n = sqrt(ux*ux + uy*uy);
+ p = ux; // (1 * ux) + (0 * uy)
+ sign = (uy < 0) ? -1.0 : 1.0;
+ double v = p / n;
+ if(v < -1.0) v = -1.0;
+ if(v > 1.0) v = 1.0;
+ double start_angle = sign * acos(v);
+
+ // Calculate the sweep angle
+ //------------------------
+ n = sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy));
+ p = ux * vx + uy * vy;
+ sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
+ v = p / n;
+ if(v < -1.0) v = -1.0;
+ if(v > 1.0) v = 1.0;
+ double sweep_angle = sign * acos(v);
+ if(!sweep_flag && sweep_angle > 0)
+ {
+ sweep_angle -= pi * 2.0;
+ }
+ else
+ if (sweep_flag && sweep_angle < 0)
+ {
+ sweep_angle += pi * 2.0;
+ }
+
+ // We can now build and transform the resulting arc
+ //------------------------
+ m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle);
+ trans_affine mtx = trans_affine_rotation(angle);
+ mtx *= trans_affine_translation(cx, cy);
+
+ for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2)
+ {
+ mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1);
+ }
+
+ // We must make sure that the starting and ending points
+ // exactly coincide with the initial (x0,y0) and (x2,y2)
+ m_arc.vertices()[0] = x0;
+ m_arc.vertices()[1] = y0;
+ if(m_arc.num_vertices() > 2)
+ {
+ m_arc.vertices()[m_arc.num_vertices() - 2] = x2;
+ m_arc.vertices()[m_arc.num_vertices() - 1] = y2;
+ }
+ }
+
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_bspline.cpp b/plugins/Clist_ng/AGG/src/agg_bspline.cpp new file mode 100644 index 0000000000..85bdfa969e --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_bspline.cpp @@ -0,0 +1,289 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_bspline.h"
+
+namespace agg
+{
+ //------------------------------------------------------------------------
+ bspline::bspline() :
+ m_max(0),
+ m_num(0),
+ m_x(0),
+ m_y(0),
+ m_last_idx(-1)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ bspline::bspline(int num) :
+ m_max(0),
+ m_num(0),
+ m_x(0),
+ m_y(0),
+ m_last_idx(-1)
+ {
+ init(num);
+ }
+
+ //------------------------------------------------------------------------
+ bspline::bspline(int num, const double* x, const double* y) :
+ m_max(0),
+ m_num(0),
+ m_x(0),
+ m_y(0),
+ m_last_idx(-1)
+ {
+ init(num, x, y);
+ }
+
+
+ //------------------------------------------------------------------------
+ void bspline::init(int max)
+ {
+ if(max > 2 && max > m_max)
+ {
+ m_am.resize(max * 3);
+ m_max = max;
+ m_x = &m_am[m_max];
+ m_y = &m_am[m_max * 2];
+ }
+ m_num = 0;
+ m_last_idx = -1;
+ }
+
+
+ //------------------------------------------------------------------------
+ void bspline::add_point(double x, double y)
+ {
+ if(m_num < m_max)
+ {
+ m_x[m_num] = x;
+ m_y[m_num] = y;
+ ++m_num;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void bspline::prepare()
+ {
+ if(m_num > 2)
+ {
+ int i, k, n1;
+ double* temp;
+ double* r;
+ double* s;
+ double h, p, d, f, e;
+
+ for(k = 0; k < m_num; k++)
+ {
+ m_am[k] = 0.0;
+ }
+
+ n1 = 3 * m_num;
+
+ pod_array<double> al(n1);
+ temp = &al[0];
+
+ for(k = 0; k < n1; k++)
+ {
+ temp[k] = 0.0;
+ }
+
+ r = temp + m_num;
+ s = temp + m_num * 2;
+
+ n1 = m_num - 1;
+ d = m_x[1] - m_x[0];
+ e = (m_y[1] - m_y[0]) / d;
+
+ for(k = 1; k < n1; k++)
+ {
+ h = d;
+ d = m_x[k + 1] - m_x[k];
+ f = e;
+ e = (m_y[k + 1] - m_y[k]) / d;
+ al[k] = d / (d + h);
+ r[k] = 1.0 - al[k];
+ s[k] = 6.0 * (e - f) / (h + d);
+ }
+
+ for(k = 1; k < n1; k++)
+ {
+ p = 1.0 / (r[k] * al[k - 1] + 2.0);
+ al[k] *= -p;
+ s[k] = (s[k] - r[k] * s[k - 1]) * p;
+ }
+
+ m_am[n1] = 0.0;
+ al[n1 - 1] = s[n1 - 1];
+ m_am[n1 - 1] = al[n1 - 1];
+
+ for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
+ {
+ al[k] = al[k] * al[k + 1] + s[k];
+ m_am[k] = al[k];
+ }
+ }
+ m_last_idx = -1;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void bspline::init(int num, const double* x, const double* y)
+ {
+ if(num > 2)
+ {
+ init(num);
+ int i;
+ for(i = 0; i < num; i++)
+ {
+ add_point(*x++, *y++);
+ }
+ prepare();
+ }
+ m_last_idx = -1;
+ }
+
+
+ //------------------------------------------------------------------------
+ void bspline::bsearch(int n, const double *x, double x0, int *i)
+ {
+ int j = n - 1;
+ int k;
+
+ for(*i = 0; (j - *i) > 1; )
+ {
+ if(x0 < x[k = (*i + j) >> 1]) j = k;
+ else *i = k;
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ double bspline::interpolation(double x, int i) const
+ {
+ int j = i + 1;
+ double d = m_x[i] - m_x[j];
+ double h = x - m_x[j];
+ double r = m_x[i] - x;
+ double p = d * d / 6.0;
+ return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
+ ((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
+ }
+
+
+ //------------------------------------------------------------------------
+ double bspline::extrapolation_left(double x) const
+ {
+ double d = m_x[1] - m_x[0];
+ return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
+ (x - m_x[0]) +
+ m_y[0];
+ }
+
+ //------------------------------------------------------------------------
+ double bspline::extrapolation_right(double x) const
+ {
+ double d = m_x[m_num - 1] - m_x[m_num - 2];
+ return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
+ (x - m_x[m_num - 1]) +
+ m_y[m_num - 1];
+ }
+
+ //------------------------------------------------------------------------
+ double bspline::get(double x) const
+ {
+ if(m_num > 2)
+ {
+ int i;
+
+ // Extrapolation on the left
+ if(x < m_x[0]) return extrapolation_left(x);
+
+ // Extrapolation on the right
+ if(x >= m_x[m_num - 1]) return extrapolation_right(x);
+
+ // Interpolation
+ bsearch(m_num, m_x, x, &i);
+ return interpolation(x, i);
+ }
+ return 0.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ double bspline::get_stateful(double x) const
+ {
+ if(m_num > 2)
+ {
+ // Extrapolation on the left
+ if(x < m_x[0]) return extrapolation_left(x);
+
+ // Extrapolation on the right
+ if(x >= m_x[m_num - 1]) return extrapolation_right(x);
+
+ if(m_last_idx >= 0)
+ {
+ // Check if x is not in current range
+ if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
+ {
+ // Check if x between next points (most probably)
+ if(m_last_idx < m_num - 2 &&
+ x >= m_x[m_last_idx + 1] &&
+ x <= m_x[m_last_idx + 2])
+ {
+ ++m_last_idx;
+ }
+ else
+ if(m_last_idx > 0 &&
+ x >= m_x[m_last_idx - 1] &&
+ x <= m_x[m_last_idx])
+ {
+ // x is between pevious points
+ --m_last_idx;
+ }
+ else
+ {
+ // Else perform full search
+ bsearch(m_num, m_x, x, &m_last_idx);
+ }
+ }
+ return interpolation(x, m_last_idx);
+ }
+ else
+ {
+ // Interpolation
+ bsearch(m_num, m_x, x, &m_last_idx);
+ return interpolation(x, m_last_idx);
+ }
+ }
+ return 0.0;
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_curves.cpp b/plugins/Clist_ng/AGG/src/agg_curves.cpp new file mode 100644 index 0000000000..eec67d21f3 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_curves.cpp @@ -0,0 +1,620 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_curves.h"
+#include "agg_math.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ const double curve_distance_epsilon = 1e-30;
+ const double curve_collinearity_epsilon = 1e-30;
+ const double curve_angle_tolerance_epsilon = 0.01;
+ enum curve_recursion_limit_e { curve_recursion_limit = 32 };
+
+
+
+ //------------------------------------------------------------------------
+ void curve3_inc::approximation_scale(double s)
+ {
+ m_scale = s;
+ }
+
+ //------------------------------------------------------------------------
+ double curve3_inc::approximation_scale() const
+ {
+ return m_scale;
+ }
+
+ //------------------------------------------------------------------------
+ void curve3_inc::init(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3)
+ {
+ m_start_x = x1;
+ m_start_y = y1;
+ m_end_x = x3;
+ m_end_y = y3;
+
+ double dx1 = x2 - x1;
+ double dy1 = y2 - y1;
+ double dx2 = x3 - x2;
+ double dy2 = y3 - y2;
+
+ double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2);
+
+ m_num_steps = uround(len * 0.25 * m_scale);
+
+ if(m_num_steps < 4)
+ {
+ m_num_steps = 4;
+ }
+
+ double subdivide_step = 1.0 / m_num_steps;
+ double subdivide_step2 = subdivide_step * subdivide_step;
+
+ double tmpx = (x1 - x2 * 2.0 + x3) * subdivide_step2;
+ double tmpy = (y1 - y2 * 2.0 + y3) * subdivide_step2;
+
+ m_saved_fx = m_fx = x1;
+ m_saved_fy = m_fy = y1;
+
+ m_saved_dfx = m_dfx = tmpx + (x2 - x1) * (2.0 * subdivide_step);
+ m_saved_dfy = m_dfy = tmpy + (y2 - y1) * (2.0 * subdivide_step);
+
+ m_ddfx = tmpx * 2.0;
+ m_ddfy = tmpy * 2.0;
+
+ m_step = m_num_steps;
+ }
+
+ //------------------------------------------------------------------------
+ void curve3_inc::rewind(unsigned)
+ {
+ if(m_num_steps == 0)
+ {
+ m_step = -1;
+ return;
+ }
+ m_step = m_num_steps;
+ m_fx = m_saved_fx;
+ m_fy = m_saved_fy;
+ m_dfx = m_saved_dfx;
+ m_dfy = m_saved_dfy;
+ }
+
+ //------------------------------------------------------------------------
+ unsigned curve3_inc::vertex(double* x, double* y)
+ {
+ if(m_step < 0) return path_cmd_stop;
+ if(m_step == m_num_steps)
+ {
+ *x = m_start_x;
+ *y = m_start_y;
+ --m_step;
+ return path_cmd_move_to;
+ }
+ if(m_step == 0)
+ {
+ *x = m_end_x;
+ *y = m_end_y;
+ --m_step;
+ return path_cmd_line_to;
+ }
+ m_fx += m_dfx;
+ m_fy += m_dfy;
+ m_dfx += m_ddfx;
+ m_dfy += m_ddfy;
+ *x = m_fx;
+ *y = m_fy;
+ --m_step;
+ return path_cmd_line_to;
+ }
+
+ //------------------------------------------------------------------------
+ void curve3_div::init(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3)
+ {
+ m_points.remove_all();
+ m_distance_tolerance_square = 0.5 / m_approximation_scale;
+ m_distance_tolerance_square *= m_distance_tolerance_square;
+ bezier(x1, y1, x2, y2, x3, y3);
+ m_count = 0;
+ }
+
+ //------------------------------------------------------------------------
+ void curve3_div::recursive_bezier(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ unsigned level)
+ {
+ if(level > curve_recursion_limit)
+ {
+ return;
+ }
+
+ // Calculate all the mid-points of the line segments
+ //----------------------
+ double x12 = (x1 + x2) / 2;
+ double y12 = (y1 + y2) / 2;
+ double x23 = (x2 + x3) / 2;
+ double y23 = (y2 + y3) / 2;
+ double x123 = (x12 + x23) / 2;
+ double y123 = (y12 + y23) / 2;
+
+ double dx = x3-x1;
+ double dy = y3-y1;
+ double d = fabs(((x2 - x3) * dy - (y2 - y3) * dx));
+ double da;
+
+ if(d > curve_collinearity_epsilon)
+ {
+ // Regular case
+ //-----------------
+ if(d * d <= m_distance_tolerance_square * (dx*dx + dy*dy))
+ {
+ // If the curvature doesn't exceed the distance_tolerance value
+ // we tend to finish subdivisions.
+ //----------------------
+ if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+ {
+ m_points.add(point_d(x123, y123));
+ return;
+ }
+
+ // Angle & Cusp Condition
+ //----------------------
+ da = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
+ if(da >= pi) da = 2*pi - da;
+
+ if(da < m_angle_tolerance)
+ {
+ // Finally we can stop the recursion
+ //----------------------
+ m_points.add(point_d(x123, y123));
+ return;
+ }
+ }
+ }
+ else
+ {
+ // Collinear case
+ //------------------
+ da = dx*dx + dy*dy;
+ if(da == 0)
+ {
+ d = calc_sq_distance(x1, y1, x2, y2);
+ }
+ else
+ {
+ d = ((x2 - x1)*dx + (y2 - y1)*dy) / da;
+ if(d > 0 && d < 1)
+ {
+ // Simple collinear case, 1---2---3
+ // We can leave just two endpoints
+ return;
+ }
+ if(d <= 0) d = calc_sq_distance(x2, y2, x1, y1);
+ else if(d >= 1) d = calc_sq_distance(x2, y2, x3, y3);
+ else d = calc_sq_distance(x2, y2, x1 + d*dx, y1 + d*dy);
+ }
+ if(d < m_distance_tolerance_square)
+ {
+ m_points.add(point_d(x2, y2));
+ return;
+ }
+ }
+
+ // Continue subdivision
+ //----------------------
+ recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1);
+ recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1);
+ }
+
+ //------------------------------------------------------------------------
+ void curve3_div::bezier(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3)
+ {
+ m_points.add(point_d(x1, y1));
+ recursive_bezier(x1, y1, x2, y2, x3, y3, 0);
+ m_points.add(point_d(x3, y3));
+ }
+
+
+
+
+
+ //------------------------------------------------------------------------
+ void curve4_inc::approximation_scale(double s)
+ {
+ m_scale = s;
+ }
+
+ //------------------------------------------------------------------------
+ double curve4_inc::approximation_scale() const
+ {
+ return m_scale;
+ }
+
+ //------------------------------------------------------------------------
+ static double MSC60_fix_ICE(double v) { return v; }
+
+ //------------------------------------------------------------------------
+ void curve4_inc::init(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ double x4, double y4)
+ {
+ m_start_x = x1;
+ m_start_y = y1;
+ m_end_x = x4;
+ m_end_y = y4;
+
+ double dx1 = x2 - x1;
+ double dy1 = y2 - y1;
+ double dx2 = x3 - x2;
+ double dy2 = y3 - y2;
+ double dx3 = x4 - x3;
+ double dy3 = y4 - y3;
+
+ double len = (sqrt(dx1 * dx1 + dy1 * dy1) +
+ sqrt(dx2 * dx2 + dy2 * dy2) +
+ sqrt(dx3 * dx3 + dy3 * dy3)) * 0.25 * m_scale;
+
+#if defined(_MSC_VER) && _MSC_VER <= 1200
+ m_num_steps = uround(MSC60_fix_ICE(len));
+#else
+ m_num_steps = uround(len);
+#endif
+
+ if(m_num_steps < 4)
+ {
+ m_num_steps = 4;
+ }
+
+ double subdivide_step = 1.0 / m_num_steps;
+ double subdivide_step2 = subdivide_step * subdivide_step;
+ double subdivide_step3 = subdivide_step * subdivide_step * subdivide_step;
+
+ double pre1 = 3.0 * subdivide_step;
+ double pre2 = 3.0 * subdivide_step2;
+ double pre4 = 6.0 * subdivide_step2;
+ double pre5 = 6.0 * subdivide_step3;
+
+ double tmp1x = x1 - x2 * 2.0 + x3;
+ double tmp1y = y1 - y2 * 2.0 + y3;
+
+ double tmp2x = (x2 - x3) * 3.0 - x1 + x4;
+ double tmp2y = (y2 - y3) * 3.0 - y1 + y4;
+
+ m_saved_fx = m_fx = x1;
+ m_saved_fy = m_fy = y1;
+
+ m_saved_dfx = m_dfx = (x2 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdivide_step3;
+ m_saved_dfy = m_dfy = (y2 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdivide_step3;
+
+ m_saved_ddfx = m_ddfx = tmp1x * pre4 + tmp2x * pre5;
+ m_saved_ddfy = m_ddfy = tmp1y * pre4 + tmp2y * pre5;
+
+ m_dddfx = tmp2x * pre5;
+ m_dddfy = tmp2y * pre5;
+
+ m_step = m_num_steps;
+ }
+
+ //------------------------------------------------------------------------
+ void curve4_inc::rewind(unsigned)
+ {
+ if(m_num_steps == 0)
+ {
+ m_step = -1;
+ return;
+ }
+ m_step = m_num_steps;
+ m_fx = m_saved_fx;
+ m_fy = m_saved_fy;
+ m_dfx = m_saved_dfx;
+ m_dfy = m_saved_dfy;
+ m_ddfx = m_saved_ddfx;
+ m_ddfy = m_saved_ddfy;
+ }
+
+ //------------------------------------------------------------------------
+ unsigned curve4_inc::vertex(double* x, double* y)
+ {
+ if(m_step < 0) return path_cmd_stop;
+ if(m_step == m_num_steps)
+ {
+ *x = m_start_x;
+ *y = m_start_y;
+ --m_step;
+ return path_cmd_move_to;
+ }
+
+ if(m_step == 0)
+ {
+ *x = m_end_x;
+ *y = m_end_y;
+ --m_step;
+ return path_cmd_line_to;
+ }
+
+ m_fx += m_dfx;
+ m_fy += m_dfy;
+ m_dfx += m_ddfx;
+ m_dfy += m_ddfy;
+ m_ddfx += m_dddfx;
+ m_ddfy += m_dddfy;
+
+ *x = m_fx;
+ *y = m_fy;
+ --m_step;
+ return path_cmd_line_to;
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ void curve4_div::init(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ double x4, double y4)
+ {
+ m_points.remove_all();
+ m_distance_tolerance_square = 0.5 / m_approximation_scale;
+ m_distance_tolerance_square *= m_distance_tolerance_square;
+ bezier(x1, y1, x2, y2, x3, y3, x4, y4);
+ m_count = 0;
+ }
+
+ //------------------------------------------------------------------------
+ void curve4_div::recursive_bezier(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ double x4, double y4,
+ unsigned level)
+ {
+ if(level > curve_recursion_limit)
+ {
+ return;
+ }
+
+ // Calculate all the mid-points of the line segments
+ //----------------------
+ double x12 = (x1 + x2) / 2;
+ double y12 = (y1 + y2) / 2;
+ double x23 = (x2 + x3) / 2;
+ double y23 = (y2 + y3) / 2;
+ double x34 = (x3 + x4) / 2;
+ double y34 = (y3 + y4) / 2;
+ double x123 = (x12 + x23) / 2;
+ double y123 = (y12 + y23) / 2;
+ double x234 = (x23 + x34) / 2;
+ double y234 = (y23 + y34) / 2;
+ double x1234 = (x123 + x234) / 2;
+ double y1234 = (y123 + y234) / 2;
+
+
+ // Try to approximate the full cubic curve by a single straight line
+ //------------------
+ double dx = x4-x1;
+ double dy = y4-y1;
+
+ double d2 = fabs(((x2 - x4) * dy - (y2 - y4) * dx));
+ double d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx));
+ double da1, da2, k;
+
+ switch((int(d2 > curve_collinearity_epsilon) << 1) +
+ int(d3 > curve_collinearity_epsilon))
+ {
+ case 0:
+ // All collinear OR p1==p4
+ //----------------------
+ k = dx*dx + dy*dy;
+ if(k == 0)
+ {
+ d2 = calc_sq_distance(x1, y1, x2, y2);
+ d3 = calc_sq_distance(x4, y4, x3, y3);
+ }
+ else
+ {
+ k = 1 / k;
+ da1 = x2 - x1;
+ da2 = y2 - y1;
+ d2 = k * (da1*dx + da2*dy);
+ da1 = x3 - x1;
+ da2 = y3 - y1;
+ d3 = k * (da1*dx + da2*dy);
+ if(d2 > 0 && d2 < 1 && d3 > 0 && d3 < 1)
+ {
+ // Simple collinear case, 1---2---3---4
+ // We can leave just two endpoints
+ return;
+ }
+ if(d2 <= 0) d2 = calc_sq_distance(x2, y2, x1, y1);
+ else if(d2 >= 1) d2 = calc_sq_distance(x2, y2, x4, y4);
+ else d2 = calc_sq_distance(x2, y2, x1 + d2*dx, y1 + d2*dy);
+
+ if(d3 <= 0) d3 = calc_sq_distance(x3, y3, x1, y1);
+ else if(d3 >= 1) d3 = calc_sq_distance(x3, y3, x4, y4);
+ else d3 = calc_sq_distance(x3, y3, x1 + d3*dx, y1 + d3*dy);
+ }
+ if(d2 > d3)
+ {
+ if(d2 < m_distance_tolerance_square)
+ {
+ m_points.add(point_d(x2, y2));
+ return;
+ }
+ }
+ else
+ {
+ if(d3 < m_distance_tolerance_square)
+ {
+ m_points.add(point_d(x3, y3));
+ return;
+ }
+ }
+ break;
+
+ case 1:
+ // p1,p2,p4 are collinear, p3 is significant
+ //----------------------
+ if(d3 * d3 <= m_distance_tolerance_square * (dx*dx + dy*dy))
+ {
+ if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+ {
+ m_points.add(point_d(x23, y23));
+ return;
+ }
+
+ // Angle Condition
+ //----------------------
+ da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
+ if(da1 >= pi) da1 = 2*pi - da1;
+
+ if(da1 < m_angle_tolerance)
+ {
+ m_points.add(point_d(x2, y2));
+ m_points.add(point_d(x3, y3));
+ return;
+ }
+
+ if(m_cusp_limit != 0.0)
+ {
+ if(da1 > m_cusp_limit)
+ {
+ m_points.add(point_d(x3, y3));
+ return;
+ }
+ }
+ }
+ break;
+
+ case 2:
+ // p1,p3,p4 are collinear, p2 is significant
+ //----------------------
+ if(d2 * d2 <= m_distance_tolerance_square * (dx*dx + dy*dy))
+ {
+ if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+ {
+ m_points.add(point_d(x23, y23));
+ return;
+ }
+
+ // Angle Condition
+ //----------------------
+ da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
+ if(da1 >= pi) da1 = 2*pi - da1;
+
+ if(da1 < m_angle_tolerance)
+ {
+ m_points.add(point_d(x2, y2));
+ m_points.add(point_d(x3, y3));
+ return;
+ }
+
+ if(m_cusp_limit != 0.0)
+ {
+ if(da1 > m_cusp_limit)
+ {
+ m_points.add(point_d(x2, y2));
+ return;
+ }
+ }
+ }
+ break;
+
+ case 3:
+ // Regular case
+ //-----------------
+ if((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy))
+ {
+ // If the curvature doesn't exceed the distance_tolerance value
+ // we tend to finish subdivisions.
+ //----------------------
+ if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+ {
+ m_points.add(point_d(x23, y23));
+ return;
+ }
+
+ // Angle & Cusp Condition
+ //----------------------
+ k = atan2(y3 - y2, x3 - x2);
+ da1 = fabs(k - atan2(y2 - y1, x2 - x1));
+ da2 = fabs(atan2(y4 - y3, x4 - x3) - k);
+ if(da1 >= pi) da1 = 2*pi - da1;
+ if(da2 >= pi) da2 = 2*pi - da2;
+
+ if(da1 + da2 < m_angle_tolerance)
+ {
+ // Finally we can stop the recursion
+ //----------------------
+ m_points.add(point_d(x23, y23));
+ return;
+ }
+
+ if(m_cusp_limit != 0.0)
+ {
+ if(da1 > m_cusp_limit)
+ {
+ m_points.add(point_d(x2, y2));
+ return;
+ }
+
+ if(da2 > m_cusp_limit)
+ {
+ m_points.add(point_d(x3, y3));
+ return;
+ }
+ }
+ }
+ break;
+ }
+
+ // Continue subdivision
+ //----------------------
+ recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
+ recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
+ }
+
+ //------------------------------------------------------------------------
+ void curve4_div::bezier(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ double x4, double y4)
+ {
+ m_points.add(point_d(x1, y1));
+ recursive_bezier(x1, y1, x2, y2, x3, y3, x4, y4, 0);
+ m_points.add(point_d(x4, y4));
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_font_win32_tt.cpp b/plugins/Clist_ng/AGG/src/agg_font_win32_tt.cpp new file mode 100644 index 0000000000..d2cf10aee1 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_font_win32_tt.cpp @@ -0,0 +1,946 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <stdio.h>
+#include "agg_font_win32_tt.h"
+#include "agg_bitset_iterator.h"
+#include "agg_renderer_scanline.h"
+
+#ifdef AGG_WIN9X_COMPLIANT
+#define GetGlyphOutlineX GetGlyphOutline
+#else
+#define GetGlyphOutlineX GetGlyphOutlineW
+#endif
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------------
+ //
+ // This code implements the AUTODIN II polynomial
+ // The variable corresponding to the macro argument "crc" should
+ // be an unsigned long.
+ // Oroginal code by Spencer Garrett <srg@quick.com>
+ //
+
+ // generated using the AUTODIN II polynomial
+ // x^32 + x^26 + x^23 + x^22 + x^16 +
+ // x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1
+ //
+ //------------------------------------------------------------------------------
+
+ static const unsigned crc32tab[256] =
+ {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
+ };
+
+ //------------------------------------------------------------------------------
+ static unsigned calc_crc32(const unsigned char* buf, unsigned size)
+ {
+ unsigned crc = (unsigned)~0;
+ const unsigned char* p;
+ unsigned len = 0;
+ unsigned nr = size;
+
+ for (len += nr, p = buf; nr--; ++p)
+ {
+ crc = (crc >> 8) ^ crc32tab[(crc ^ *p) & 0xff];
+ }
+ return ~crc;
+ }
+
+ //------------------------------------------------------------------------
+ static inline FIXED dbl_to_fx(double d)
+ {
+ int l;
+ l = int(d * 65536.0);
+ return *(FIXED*)&l;
+ }
+
+ //------------------------------------------------------------------------
+ static inline int dbl_to_plain_fx(double d)
+ {
+ return int(d * 65536.0);
+ }
+
+ //------------------------------------------------------------------------
+ static inline FIXED negate_fx(const FIXED& fx)
+ {
+ int l = -(*(int*)(&fx));
+ return *(FIXED*)&l;
+ }
+
+ //------------------------------------------------------------------------
+ static inline double fx_to_dbl(const FIXED& p)
+ {
+ return double(p.value) + double(p.fract) * (1.0 / 65536.0);
+ }
+
+ //------------------------------------------------------------------------
+ static inline int fx_to_plain_int(const FIXED& fx)
+ {
+ return *(int*)(&fx);
+ }
+
+ //------------------------------------------------------------------------
+ static inline int fx_to_int26p6(const FIXED& p)
+ {
+ return (int(p.value) << 6) + (int(p.fract) >> 10);
+ }
+
+ //------------------------------------------------------------------------
+ static inline int dbl_to_int26p6(double p)
+ {
+ return int(p * 64.0 + 0.5);
+ }
+
+ //------------------------------------------------------------------------
+ template<class Scanline, class ScanlineStorage>
+ void decompose_win32_glyph_bitmap_mono(const char* gbuf,
+ int w, int h,
+ int x, int y,
+ bool flip_y,
+ Scanline& sl,
+ ScanlineStorage& storage)
+ {
+ int i;
+ int pitch = ((w + 31) >> 5) << 2;
+ const int8u* buf = (const int8u*)gbuf;
+ sl.reset(x, x + w);
+ storage.prepare();
+ if(flip_y)
+ {
+ buf += pitch * (h - 1);
+ y += h;
+ pitch = -pitch;
+ }
+ for(i = 0; i < h; i++)
+ {
+ sl.reset_spans();
+ bitset_iterator bits(buf, 0);
+ int j;
+ for(j = 0; j < w; j++)
+ {
+ if(bits.bit()) sl.add_cell(x + j, cover_full);
+ ++bits;
+ }
+ buf += pitch;
+ if(sl.num_spans())
+ {
+ sl.finalize(y - i - 1);
+ storage.render(sl);
+ }
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ template<class Rasterizer, class Scanline, class ScanlineStorage>
+ void decompose_win32_glyph_bitmap_gray8(const char* gbuf,
+ int w, int h,
+ int x, int y,
+ bool flip_y,
+ Rasterizer& ras,
+ Scanline& sl,
+ ScanlineStorage& storage)
+ {
+ int i, j;
+ int pitch = ((w + 3) >> 2) << 2;
+ const int8u* buf = (const int8u*)gbuf;
+ sl.reset(x, x + w);
+ storage.prepare();
+ if(flip_y)
+ {
+ buf += pitch * (h - 1);
+ y += h;
+ pitch = -pitch;
+ }
+ for(i = 0; i < h; i++)
+ {
+ sl.reset_spans();
+ const int8u* p = buf;
+ for(j = 0; j < w; j++)
+ {
+ if(*p)
+ {
+ unsigned v = *p;
+ if(v == 64) v = 255;
+ else v <<= 2;
+ sl.add_cell(x + j, ras.apply_gamma(v));
+ }
+ ++p;
+ }
+ buf += pitch;
+ if(sl.num_spans())
+ {
+ sl.finalize(y - i - 1);
+ storage.render(sl);
+ }
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ template<class PathStorage>
+ bool decompose_win32_glyph_outline(const char* gbuf,
+ unsigned total_size,
+ bool flip_y,
+ const trans_affine& mtx,
+ PathStorage& path)
+ {
+ const char* cur_glyph = gbuf;
+ const char* end_glyph = gbuf + total_size;
+ double x, y;
+ typedef typename PathStorage::value_type value_type;
+
+ while(cur_glyph < end_glyph)
+ {
+ const TTPOLYGONHEADER* th = (TTPOLYGONHEADER*)cur_glyph;
+
+ const char* end_poly = cur_glyph + th->cb;
+ const char* cur_poly = cur_glyph + sizeof(TTPOLYGONHEADER);
+
+ x = fx_to_dbl(th->pfxStart.x);
+ y = fx_to_dbl(th->pfxStart.y);
+ if(flip_y) y = -y;
+ mtx.transform(&x, &y);
+ path.move_to(value_type(dbl_to_int26p6(x)),
+ value_type(dbl_to_int26p6(y)));
+
+ while(cur_poly < end_poly)
+ {
+ const TTPOLYCURVE* pc = (const TTPOLYCURVE*)cur_poly;
+
+ if (pc->wType == TT_PRIM_LINE)
+ {
+ int i;
+ for (i = 0; i < pc->cpfx; i++)
+ {
+ x = fx_to_dbl(pc->apfx[i].x);
+ y = fx_to_dbl(pc->apfx[i].y);
+ if(flip_y) y = -y;
+ mtx.transform(&x, &y);
+ path.line_to(value_type(dbl_to_int26p6(x)),
+ value_type(dbl_to_int26p6(y)));
+ }
+ }
+
+ if (pc->wType == TT_PRIM_QSPLINE)
+ {
+ int u;
+ for (u = 0; u < pc->cpfx - 1; u++) // Walk through points in spline
+ {
+ POINTFX pnt_b = pc->apfx[u]; // B is always the current point
+ POINTFX pnt_c = pc->apfx[u+1];
+
+ if (u < pc->cpfx - 2) // If not on last spline, compute C
+ {
+ // midpoint (x,y)
+ *(int*)&pnt_c.x = (*(int*)&pnt_b.x + *(int*)&pnt_c.x) / 2;
+ *(int*)&pnt_c.y = (*(int*)&pnt_b.y + *(int*)&pnt_c.y) / 2;
+ }
+
+ double x2, y2;
+ x = fx_to_dbl(pnt_b.x);
+ y = fx_to_dbl(pnt_b.y);
+ x2 = fx_to_dbl(pnt_c.x);
+ y2 = fx_to_dbl(pnt_c.y);
+ if(flip_y) { y = -y; y2 = -y2; }
+ mtx.transform(&x, &y);
+ mtx.transform(&x2, &y2);
+ path.curve3(value_type(dbl_to_int26p6(x)),
+ value_type(dbl_to_int26p6(y)),
+ value_type(dbl_to_int26p6(x2)),
+ value_type(dbl_to_int26p6(y2)));
+ }
+ }
+ cur_poly += sizeof(WORD) * 2 + sizeof(POINTFX) * pc->cpfx;
+ }
+ cur_glyph += th->cb;
+ }
+ return true;
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ font_engine_win32_tt_base::~font_engine_win32_tt_base()
+ {
+ delete [] m_kerning_pairs;
+ delete [] m_gbuf;
+ delete [] m_signature;
+ delete [] m_typeface;
+ if(m_dc && m_old_font) ::SelectObject(m_dc, m_old_font);
+ unsigned i;
+ for(i = 0; i < m_num_fonts; ++i)
+ {
+ delete [] m_font_names[i];
+ ::DeleteObject(m_fonts[i]);
+ }
+ delete [] m_font_names;
+ delete [] m_fonts;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ font_engine_win32_tt_base::font_engine_win32_tt_base(bool flag32,
+ HDC dc,
+ unsigned max_fonts) :
+ m_flag32(flag32),
+ m_dc(dc),
+ m_old_font(m_dc ? (HFONT)::GetCurrentObject(m_dc, OBJ_FONT) : 0),
+ m_fonts(new HFONT [max_fonts]),
+ m_num_fonts(0),
+ m_max_fonts(max_fonts),
+ m_font_names(new char* [max_fonts]),
+ m_cur_font(0),
+
+ m_change_stamp(0),
+ m_typeface(new char [256-16]),
+ m_typeface_len(256-16-1),
+ m_signature(new char [256+256-16]),
+ m_height(0),
+ m_width(0),
+ m_weight(FW_REGULAR),
+ m_italic(false),
+ m_char_set(DEFAULT_CHARSET),
+ m_pitch_and_family(FF_DONTCARE),
+ m_hinting(true),
+ m_flip_y(false),
+ m_font_created(false),
+ m_resolution(0),
+ m_glyph_rendering(glyph_ren_native_gray8),
+ m_glyph_index(0),
+ m_data_size(0),
+ m_data_type(glyph_data_invalid),
+ m_bounds(1,1,0,0),
+ m_advance_x(0.0),
+ m_advance_y(0.0),
+ m_gbuf(new char [buf_size]),
+ m_kerning_pairs(0),
+ m_num_kerning_pairs(0),
+ m_max_kerning_pairs(0),
+
+ m_path16(),
+ m_path32(),
+ m_curves16(m_path16),
+ m_curves32(m_path32),
+ m_scanline_aa(),
+ m_scanline_bin(),
+ m_scanlines_aa(),
+ m_scanlines_bin(),
+ m_rasterizer()
+ {
+ m_curves16.approximation_scale(4.0);
+ m_curves32.approximation_scale(4.0);
+ memset(&m_matrix, 0, sizeof(m_matrix));
+ m_matrix.eM11.value = 1;
+ m_matrix.eM22.value = 1;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ int font_engine_win32_tt_base::find_font(const char* name) const
+ {
+ unsigned i;
+ for(i = 0; i < m_num_fonts; ++i)
+ {
+ if(strcmp(name, m_font_names[i]) == 0) return i;
+ }
+ return -1;
+ }
+
+ //------------------------------------------------------------------------
+ bool font_engine_win32_tt_base::create_font(const char* typeface_,
+ glyph_rendering ren_type)
+ {
+ if(m_dc)
+ {
+ unsigned len = strlen(typeface_);
+ if(len > m_typeface_len)
+ {
+ delete [] m_signature;
+ delete [] m_typeface;
+ m_typeface = new char [len + 32];
+ m_signature = new char [len + 32 + 256];
+ m_typeface_len = len + 32 - 1;
+ }
+
+ strcpy(m_typeface, typeface_);
+
+ int h = m_height;
+ int w = m_width;
+
+ if(m_resolution)
+ {
+ h = ::MulDiv(m_height, m_resolution, 72);
+ w = ::MulDiv(m_width, m_resolution, 72);
+ }
+
+ m_glyph_rendering = ren_type;
+ update_signature();
+ int idx = find_font(m_signature);
+ if(idx >= 0)
+ {
+ m_cur_font = m_fonts[idx];
+ ::SelectObject(m_dc, m_cur_font);
+ m_num_kerning_pairs = 0;
+ return true;
+ }
+ else
+ {
+ m_cur_font = ::CreateFontA(-h, // height of font
+ w, // average character width
+ 0, // angle of escapement
+ 0, // base-line orientation angle
+ m_weight, // font weight
+ m_italic, // italic attribute option
+ 0, // underline attribute option
+ 0, // strikeout attribute option
+ m_char_set, // character set identifier
+ OUT_DEFAULT_PRECIS, // output precision
+ CLIP_DEFAULT_PRECIS, // clipping precision
+ ANTIALIASED_QUALITY, // output quality
+ m_pitch_and_family, // pitch and family
+ m_typeface); // typeface name
+ if(m_cur_font)
+ {
+ if(m_num_fonts >= m_max_fonts)
+ {
+ delete [] m_font_names[0];
+ if(m_old_font) ::SelectObject(m_dc, m_old_font);
+ ::DeleteObject(m_fonts[0]);
+ memcpy(m_fonts,
+ m_fonts + 1,
+ (m_max_fonts - 1) * sizeof(HFONT));
+ memcpy(m_font_names,
+ m_font_names + 1,
+ (m_max_fonts - 1) * sizeof(char*));
+ m_num_fonts = m_max_fonts - 1;
+ }
+
+ update_signature();
+ m_font_names[m_num_fonts] = new char[strlen(m_signature) + 1];
+ strcpy(m_font_names[m_num_fonts], m_signature);
+ m_fonts[m_num_fonts] = m_cur_font;
+ ++m_num_fonts;
+ ::SelectObject(m_dc, m_cur_font);
+ m_num_kerning_pairs = 0;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+
+
+
+ //------------------------------------------------------------------------
+ bool font_engine_win32_tt_base::create_font(const char* typeface_,
+ glyph_rendering ren_type,
+ double height_,
+ double width_,
+ int weight_,
+ bool italic_,
+ DWORD char_set_,
+ DWORD pitch_and_family_)
+ {
+ height(height_);
+ width(width_);
+ weight(weight_);
+ italic(italic_);
+ char_set(char_set_);
+ pitch_and_family(pitch_and_family_);
+ return create_font(typeface_, ren_type);
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ void font_engine_win32_tt_base::update_signature()
+ {
+ m_signature[0] = 0;
+ if(m_dc && m_cur_font)
+ {
+ unsigned gamma_hash = 0;
+ if(m_glyph_rendering == glyph_ren_native_gray8 ||
+ m_glyph_rendering == glyph_ren_agg_mono ||
+ m_glyph_rendering == glyph_ren_agg_gray8)
+ {
+ unsigned char gamma_table[rasterizer_scanline_aa<>::aa_scale];
+ unsigned i;
+ for(i = 0; i < rasterizer_scanline_aa<>::aa_scale; ++i)
+ {
+ gamma_table[i] = m_rasterizer.apply_gamma(i);
+ }
+ gamma_hash = calc_crc32(gamma_table, sizeof(gamma_table));
+ }
+
+ sprintf(m_signature,
+ "%s,%u,%d,%d:%dx%d,%d,%d,%d,%d,%d,%08X",
+ m_typeface,
+ m_char_set,
+ int(m_glyph_rendering),
+ m_resolution,
+ m_height,
+ m_width,
+ m_weight,
+ int(m_italic),
+ int(m_hinting),
+ int(m_flip_y),
+ int(m_pitch_and_family),
+ gamma_hash);
+
+ if(m_glyph_rendering == glyph_ren_outline ||
+ m_glyph_rendering == glyph_ren_agg_mono ||
+ m_glyph_rendering == glyph_ren_agg_gray8)
+ {
+ double mtx[6];
+ char buf[100];
+ m_affine.store_to(mtx);
+ sprintf(buf, ",%08X%08X%08X%08X%08X%08X",
+ dbl_to_plain_fx(mtx[0]),
+ dbl_to_plain_fx(mtx[1]),
+ dbl_to_plain_fx(mtx[2]),
+ dbl_to_plain_fx(mtx[3]),
+ dbl_to_plain_fx(mtx[4]),
+ dbl_to_plain_fx(mtx[5]));
+ strcat(m_signature, buf);
+ }
+ ++m_change_stamp;
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool font_engine_win32_tt_base::prepare_glyph(unsigned glyph_code)
+ {
+ if(m_dc && m_cur_font)
+ {
+ int format = GGO_BITMAP;
+
+ switch(m_glyph_rendering)
+ {
+ case glyph_ren_native_gray8:
+ format = GGO_GRAY8_BITMAP;
+ break;
+
+ case glyph_ren_outline:
+ case glyph_ren_agg_mono:
+ case glyph_ren_agg_gray8:
+ format = GGO_NATIVE;
+ break;
+ }
+
+#ifndef GGO_UNHINTED // For compatibility with old SDKs.
+#define GGO_UNHINTED 0x0100
+#endif
+ if(!m_hinting) format |= GGO_UNHINTED;
+
+ GLYPHMETRICS gm;
+ int total_size = GetGlyphOutlineX(m_dc,
+ glyph_code,
+ format,
+ &gm,
+ buf_size,
+ (void*)m_gbuf,
+ &m_matrix);
+
+ if(total_size < 0)
+ {
+ // GetGlyphOutline() fails when being called for
+ // GGO_GRAY8_BITMAP and white space (stupid Microsoft).
+ // It doesn't even initialize the glyph metrics
+ // structure. So, we have to query the metrics
+ // separately (basically we need gmCellIncX).
+ int total_size = GetGlyphOutlineX(m_dc,
+ glyph_code,
+ GGO_METRICS,
+ &gm,
+ buf_size,
+ (void*)m_gbuf,
+ &m_matrix);
+
+ if(total_size < 0) return false;
+ gm.gmBlackBoxX = gm.gmBlackBoxY = 0;
+ total_size = 0;
+ }
+
+ m_glyph_index = glyph_code;
+ m_advance_x = gm.gmCellIncX;
+ m_advance_y = -gm.gmCellIncY;
+
+ switch(m_glyph_rendering)
+ {
+ case glyph_ren_native_mono:
+ decompose_win32_glyph_bitmap_mono(m_gbuf,
+ gm.gmBlackBoxX,
+ gm.gmBlackBoxY,
+ gm.gmptGlyphOrigin.x,
+ m_flip_y ? -gm.gmptGlyphOrigin.y :
+ gm.gmptGlyphOrigin.y,
+ m_flip_y,
+ m_scanline_bin,
+ m_scanlines_bin);
+ m_bounds.x1 = m_scanlines_bin.min_x();
+ m_bounds.y1 = m_scanlines_bin.min_y();
+ m_bounds.x2 = m_scanlines_bin.max_x() + 1;
+ m_bounds.y2 = m_scanlines_bin.max_y() + 1;
+ m_data_size = m_scanlines_bin.byte_size();
+ m_data_type = glyph_data_mono;
+ return true;
+
+ case glyph_ren_native_gray8:
+ decompose_win32_glyph_bitmap_gray8(m_gbuf,
+ gm.gmBlackBoxX,
+ gm.gmBlackBoxY,
+ gm.gmptGlyphOrigin.x,
+ m_flip_y ? -gm.gmptGlyphOrigin.y :
+ gm.gmptGlyphOrigin.y,
+ m_flip_y,
+ m_rasterizer,
+ m_scanline_aa,
+ m_scanlines_aa);
+ m_bounds.x1 = m_scanlines_aa.min_x();
+ m_bounds.y1 = m_scanlines_aa.min_y();
+ m_bounds.x2 = m_scanlines_aa.max_x() + 1;
+ m_bounds.y2 = m_scanlines_aa.max_y() + 1;
+ m_data_size = m_scanlines_aa.byte_size();
+ m_data_type = glyph_data_gray8;
+ return true;
+
+ case glyph_ren_outline:
+ m_affine.transform(&m_advance_x, &m_advance_y);
+ if(m_flag32)
+ {
+ m_path32.remove_all();
+ if(decompose_win32_glyph_outline(m_gbuf,
+ total_size,
+ m_flip_y,
+ m_affine,
+ m_path32))
+ {
+ rect_d bnd = m_path32.bounding_rect();
+ m_data_size = m_path32.byte_size();
+ m_data_type = glyph_data_outline;
+ m_bounds.x1 = int(floor(bnd.x1));
+ m_bounds.y1 = int(floor(bnd.y1));
+ m_bounds.x2 = int(ceil(bnd.x2));
+ m_bounds.y2 = int(ceil(bnd.y2));
+ return true;
+ }
+ }
+ else
+ {
+ m_path16.remove_all();
+ if(decompose_win32_glyph_outline(m_gbuf,
+ total_size,
+ m_flip_y,
+ m_affine,
+ m_path16))
+ {
+ rect_d bnd = m_path16.bounding_rect();
+ m_data_size = m_path16.byte_size();
+ m_data_type = glyph_data_outline;
+ m_bounds.x1 = int(floor(bnd.x1));
+ m_bounds.y1 = int(floor(bnd.y1));
+ m_bounds.x2 = int(ceil(bnd.x2));
+ m_bounds.y2 = int(ceil(bnd.y2));
+ return true;
+ }
+ }
+ break;
+
+ case glyph_ren_agg_mono:
+ m_rasterizer.reset();
+ m_affine.transform(&m_advance_x, &m_advance_y);
+ if(m_flag32)
+ {
+ m_path32.remove_all();
+ decompose_win32_glyph_outline(m_gbuf,
+ total_size,
+ m_flip_y,
+ m_affine,
+ m_path32);
+ m_rasterizer.add_path(m_curves32);
+ }
+ else
+ {
+ m_path16.remove_all();
+ decompose_win32_glyph_outline(m_gbuf,
+ total_size,
+ m_flip_y,
+ m_affine,
+ m_path16);
+ m_rasterizer.add_path(m_curves16);
+ }
+ m_scanlines_bin.prepare(); // Remove all
+ render_scanlines(m_rasterizer, m_scanline_bin, m_scanlines_bin);
+ m_bounds.x1 = m_scanlines_bin.min_x();
+ m_bounds.y1 = m_scanlines_bin.min_y();
+ m_bounds.x2 = m_scanlines_bin.max_x() + 1;
+ m_bounds.y2 = m_scanlines_bin.max_y() + 1;
+ m_data_size = m_scanlines_bin.byte_size();
+ m_data_type = glyph_data_mono;
+ return true;
+
+ case glyph_ren_agg_gray8:
+ m_rasterizer.reset();
+ m_affine.transform(&m_advance_x, &m_advance_y);
+ if(m_flag32)
+ {
+ m_path32.remove_all();
+ decompose_win32_glyph_outline(m_gbuf,
+ total_size,
+ m_flip_y,
+ m_affine,
+ m_path32);
+ m_rasterizer.add_path(m_curves32);
+ }
+ else
+ {
+ m_path16.remove_all();
+ decompose_win32_glyph_outline(m_gbuf,
+ total_size,
+ m_flip_y,
+ m_affine,
+ m_path16);
+ m_rasterizer.add_path(m_curves16);
+ }
+ m_scanlines_aa.prepare(); // Remove all
+ render_scanlines(m_rasterizer, m_scanline_aa, m_scanlines_aa);
+ m_bounds.x1 = m_scanlines_aa.min_x();
+ m_bounds.y1 = m_scanlines_aa.min_y();
+ m_bounds.x2 = m_scanlines_aa.max_x() + 1;
+ m_bounds.y2 = m_scanlines_aa.max_y() + 1;
+ m_data_size = m_scanlines_aa.byte_size();
+ m_data_type = glyph_data_gray8;
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void font_engine_win32_tt_base::write_glyph_to(int8u* data) const
+ {
+ if(data && m_data_size)
+ {
+ switch(m_data_type)
+ {
+ case glyph_data_mono: m_scanlines_bin.serialize(data); break;
+ case glyph_data_gray8: m_scanlines_aa.serialize(data); break;
+ case glyph_data_outline:
+ if(m_flag32)
+ {
+ m_path32.serialize(data);
+ }
+ else
+ {
+ m_path16.serialize(data);
+ }
+ break;
+ }
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ static bool pair_less(const KERNINGPAIR& v1, const KERNINGPAIR& v2)
+ {
+ if(v1.wFirst != v2.wFirst) return v1.wFirst < v2.wFirst;
+ return v1.wSecond < v2.wSecond;
+ }
+
+
+ //------------------------------------------------------------------------
+ void font_engine_win32_tt_base::sort_kerning_pairs()
+ {
+ pod_array_adaptor<KERNINGPAIR> pairs(m_kerning_pairs, m_num_kerning_pairs);
+ quick_sort(pairs, pair_less);
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void font_engine_win32_tt_base::load_kerning_pairs()
+ {
+ if(m_dc && m_cur_font)
+ {
+ if(m_kerning_pairs == 0)
+ {
+ m_kerning_pairs = new KERNINGPAIR [16384-16];
+ m_max_kerning_pairs = 16384-16;
+ }
+ m_num_kerning_pairs = ::GetKerningPairs(m_dc,
+ m_max_kerning_pairs,
+ m_kerning_pairs);
+
+ if(m_num_kerning_pairs)
+ {
+ // Check to see if the kerning pairs are sorted and
+ // sort them if they are not.
+ //----------------
+ unsigned i;
+ for(i = 1; i < m_num_kerning_pairs; ++i)
+ {
+ if(!pair_less(m_kerning_pairs[i - 1], m_kerning_pairs[i]))
+ {
+ sort_kerning_pairs();
+ break;
+ }
+ }
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ bool font_engine_win32_tt_base::add_kerning(unsigned first, unsigned second,
+ double* x, double* y)
+ {
+ if(m_dc && m_cur_font)
+ {
+ if(m_num_kerning_pairs == 0)
+ {
+ load_kerning_pairs();
+ }
+
+ int end = m_num_kerning_pairs - 1;
+ int beg = 0;
+ KERNINGPAIR t;
+ t.wFirst = (WORD)first;
+ t.wSecond = (WORD)second;
+ while(beg <= end)
+ {
+ int mid = (end + beg) / 2;
+ if(m_kerning_pairs[mid].wFirst == t.wFirst &&
+ m_kerning_pairs[mid].wSecond == t.wSecond)
+ {
+ double dx = m_kerning_pairs[mid].iKernAmount;
+ double dy = 0.0;
+ if(m_glyph_rendering == glyph_ren_outline ||
+ m_glyph_rendering == glyph_ren_agg_mono ||
+ m_glyph_rendering == glyph_ren_agg_gray8)
+ {
+ m_affine.transform_2x2(&dx, &dy);
+ }
+ *x += dx;
+ *y += dy;
+ return true;
+ }
+ else
+ if(pair_less(t, m_kerning_pairs[mid]))
+ {
+ end = mid - 1;
+ }
+ else
+ {
+ beg = mid + 1;
+ }
+ }
+ return false;
+ }
+ return false;
+ }
+
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_gsv_text.cpp b/plugins/Clist_ng/AGG/src/agg_gsv_text.cpp new file mode 100644 index 0000000000..bc54ef7cb3 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_gsv_text.cpp @@ -0,0 +1,681 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <string.h>
+#include <stdio.h>
+#include "agg_gsv_text.h"
+#include "agg_bounding_rect.h"
+
+
+
+namespace agg
+{
+ int8u gsv_default_font[] =
+ {
+ 0x40,0x00,0x6c,0x0f,0x15,0x00,0x0e,0x00,0xf9,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x0d,0x0a,0x0d,0x0a,0x46,0x6f,0x6e,0x74,0x20,0x28,
+ 0x63,0x29,0x20,0x4d,0x69,0x63,0x72,0x6f,0x50,0x72,
+ 0x6f,0x66,0x20,0x32,0x37,0x20,0x53,0x65,0x70,0x74,
+ 0x65,0x6d,0x62,0x2e,0x31,0x39,0x38,0x39,0x00,0x0d,
+ 0x0a,0x0d,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x00,0x12,0x00,0x34,0x00,0x46,0x00,0x94,0x00,
+ 0xd0,0x00,0x2e,0x01,0x3e,0x01,0x64,0x01,0x8a,0x01,
+ 0x98,0x01,0xa2,0x01,0xb4,0x01,0xba,0x01,0xc6,0x01,
+ 0xcc,0x01,0xf0,0x01,0xfa,0x01,0x18,0x02,0x38,0x02,
+ 0x44,0x02,0x68,0x02,0x98,0x02,0xa2,0x02,0xde,0x02,
+ 0x0e,0x03,0x24,0x03,0x40,0x03,0x48,0x03,0x52,0x03,
+ 0x5a,0x03,0x82,0x03,0xec,0x03,0xfa,0x03,0x26,0x04,
+ 0x4c,0x04,0x6a,0x04,0x7c,0x04,0x8a,0x04,0xb6,0x04,
+ 0xc4,0x04,0xca,0x04,0xe0,0x04,0xee,0x04,0xf8,0x04,
+ 0x0a,0x05,0x18,0x05,0x44,0x05,0x5e,0x05,0x8e,0x05,
+ 0xac,0x05,0xd6,0x05,0xe0,0x05,0xf6,0x05,0x00,0x06,
+ 0x12,0x06,0x1c,0x06,0x28,0x06,0x36,0x06,0x48,0x06,
+ 0x4e,0x06,0x60,0x06,0x6e,0x06,0x74,0x06,0x84,0x06,
+ 0xa6,0x06,0xc8,0x06,0xe6,0x06,0x08,0x07,0x2c,0x07,
+ 0x3c,0x07,0x68,0x07,0x7c,0x07,0x8c,0x07,0xa2,0x07,
+ 0xb0,0x07,0xb6,0x07,0xd8,0x07,0xec,0x07,0x10,0x08,
+ 0x32,0x08,0x54,0x08,0x64,0x08,0x88,0x08,0x98,0x08,
+ 0xac,0x08,0xb6,0x08,0xc8,0x08,0xd2,0x08,0xe4,0x08,
+ 0xf2,0x08,0x3e,0x09,0x48,0x09,0x94,0x09,0xc2,0x09,
+ 0xc4,0x09,0xd0,0x09,0xe2,0x09,0x04,0x0a,0x0e,0x0a,
+ 0x26,0x0a,0x34,0x0a,0x4a,0x0a,0x66,0x0a,0x70,0x0a,
+ 0x7e,0x0a,0x8e,0x0a,0x9a,0x0a,0xa6,0x0a,0xb4,0x0a,
+ 0xd8,0x0a,0xe2,0x0a,0xf6,0x0a,0x18,0x0b,0x22,0x0b,
+ 0x32,0x0b,0x56,0x0b,0x60,0x0b,0x6e,0x0b,0x7c,0x0b,
+ 0x8a,0x0b,0x9c,0x0b,0x9e,0x0b,0xb2,0x0b,0xc2,0x0b,
+ 0xd8,0x0b,0xf4,0x0b,0x08,0x0c,0x30,0x0c,0x56,0x0c,
+ 0x72,0x0c,0x90,0x0c,0xb2,0x0c,0xce,0x0c,0xe2,0x0c,
+ 0xfe,0x0c,0x10,0x0d,0x26,0x0d,0x36,0x0d,0x42,0x0d,
+ 0x4e,0x0d,0x5c,0x0d,0x78,0x0d,0x8c,0x0d,0x8e,0x0d,
+ 0x90,0x0d,0x92,0x0d,0x94,0x0d,0x96,0x0d,0x98,0x0d,
+ 0x9a,0x0d,0x9c,0x0d,0x9e,0x0d,0xa0,0x0d,0xa2,0x0d,
+ 0xa4,0x0d,0xa6,0x0d,0xa8,0x0d,0xaa,0x0d,0xac,0x0d,
+ 0xae,0x0d,0xb0,0x0d,0xb2,0x0d,0xb4,0x0d,0xb6,0x0d,
+ 0xb8,0x0d,0xba,0x0d,0xbc,0x0d,0xbe,0x0d,0xc0,0x0d,
+ 0xc2,0x0d,0xc4,0x0d,0xc6,0x0d,0xc8,0x0d,0xca,0x0d,
+ 0xcc,0x0d,0xce,0x0d,0xd0,0x0d,0xd2,0x0d,0xd4,0x0d,
+ 0xd6,0x0d,0xd8,0x0d,0xda,0x0d,0xdc,0x0d,0xde,0x0d,
+ 0xe0,0x0d,0xe2,0x0d,0xe4,0x0d,0xe6,0x0d,0xe8,0x0d,
+ 0xea,0x0d,0xec,0x0d,0x0c,0x0e,0x26,0x0e,0x48,0x0e,
+ 0x64,0x0e,0x88,0x0e,0x92,0x0e,0xa6,0x0e,0xb4,0x0e,
+ 0xd0,0x0e,0xee,0x0e,0x02,0x0f,0x16,0x0f,0x26,0x0f,
+ 0x3c,0x0f,0x58,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,
+ 0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,
+ 0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,
+ 0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x10,0x80,
+ 0x05,0x95,0x00,0x72,0x00,0xfb,0xff,0x7f,0x01,0x7f,
+ 0x01,0x01,0xff,0x01,0x05,0xfe,0x05,0x95,0xff,0x7f,
+ 0x00,0x7a,0x01,0x86,0xff,0x7a,0x01,0x87,0x01,0x7f,
+ 0xfe,0x7a,0x0a,0x87,0xff,0x7f,0x00,0x7a,0x01,0x86,
+ 0xff,0x7a,0x01,0x87,0x01,0x7f,0xfe,0x7a,0x05,0xf2,
+ 0x0b,0x95,0xf9,0x64,0x0d,0x9c,0xf9,0x64,0xfa,0x91,
+ 0x0e,0x00,0xf1,0xfa,0x0e,0x00,0x04,0xfc,0x08,0x99,
+ 0x00,0x63,0x04,0x9d,0x00,0x63,0x04,0x96,0xff,0x7f,
+ 0x01,0x7f,0x01,0x01,0x00,0x01,0xfe,0x02,0xfd,0x01,
+ 0xfc,0x00,0xfd,0x7f,0xfe,0x7e,0x00,0x7e,0x01,0x7e,
+ 0x01,0x7f,0x02,0x7f,0x06,0x7e,0x02,0x7f,0x02,0x7e,
+ 0xf2,0x89,0x02,0x7e,0x02,0x7f,0x06,0x7e,0x02,0x7f,
+ 0x01,0x7f,0x01,0x7e,0x00,0x7c,0xfe,0x7e,0xfd,0x7f,
+ 0xfc,0x00,0xfd,0x01,0xfe,0x02,0x00,0x01,0x01,0x01,
+ 0x01,0x7f,0xff,0x7f,0x10,0xfd,0x15,0x95,0xee,0x6b,
+ 0x05,0x95,0x02,0x7e,0x00,0x7e,0xff,0x7e,0xfe,0x7f,
+ 0xfe,0x00,0xfe,0x02,0x00,0x02,0x01,0x02,0x02,0x01,
+ 0x02,0x00,0x02,0x7f,0x03,0x7f,0x03,0x00,0x03,0x01,
+ 0x02,0x01,0xfc,0xf2,0xfe,0x7f,0xff,0x7e,0x00,0x7e,
+ 0x02,0x7e,0x02,0x00,0x02,0x01,0x01,0x02,0x00,0x02,
+ 0xfe,0x02,0xfe,0x00,0x07,0xf9,0x15,0x8d,0xff,0x7f,
+ 0x01,0x7f,0x01,0x01,0x00,0x01,0xff,0x01,0xff,0x00,
+ 0xff,0x7f,0xff,0x7e,0xfe,0x7b,0xfe,0x7d,0xfe,0x7e,
+ 0xfe,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x02,0x00,0x03,
+ 0x01,0x02,0x06,0x04,0x02,0x02,0x01,0x02,0x00,0x02,
+ 0xff,0x02,0xfe,0x01,0xfe,0x7f,0xff,0x7e,0x00,0x7e,
+ 0x01,0x7d,0x02,0x7d,0x05,0x79,0x02,0x7e,0x03,0x7f,
+ 0x01,0x00,0x01,0x01,0x00,0x01,0xf1,0xfe,0xfe,0x01,
+ 0xff,0x02,0x00,0x03,0x01,0x02,0x02,0x02,0x00,0x86,
+ 0x01,0x7e,0x08,0x75,0x02,0x7e,0x02,0x7f,0x05,0x80,
+ 0x05,0x93,0xff,0x01,0x01,0x01,0x01,0x7f,0x00,0x7e,
+ 0xff,0x7e,0xff,0x7f,0x06,0xf1,0x0b,0x99,0xfe,0x7e,
+ 0xfe,0x7d,0xfe,0x7c,0xff,0x7b,0x00,0x7c,0x01,0x7b,
+ 0x02,0x7c,0x02,0x7d,0x02,0x7e,0xfe,0x9e,0xfe,0x7c,
+ 0xff,0x7d,0xff,0x7b,0x00,0x7c,0x01,0x7b,0x01,0x7d,
+ 0x02,0x7c,0x05,0x85,0x03,0x99,0x02,0x7e,0x02,0x7d,
+ 0x02,0x7c,0x01,0x7b,0x00,0x7c,0xff,0x7b,0xfe,0x7c,
+ 0xfe,0x7d,0xfe,0x7e,0x02,0x9e,0x02,0x7c,0x01,0x7d,
+ 0x01,0x7b,0x00,0x7c,0xff,0x7b,0xff,0x7d,0xfe,0x7c,
+ 0x09,0x85,0x08,0x95,0x00,0x74,0xfb,0x89,0x0a,0x7a,
+ 0x00,0x86,0xf6,0x7a,0x0d,0xf4,0x0d,0x92,0x00,0x6e,
+ 0xf7,0x89,0x12,0x00,0x04,0xf7,0x06,0x81,0xff,0x7f,
+ 0xff,0x01,0x01,0x01,0x01,0x7f,0x00,0x7e,0xff,0x7e,
+ 0xff,0x7f,0x06,0x84,0x04,0x89,0x12,0x00,0x04,0xf7,
+ 0x05,0x82,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01,
+ 0x05,0xfe,0x00,0xfd,0x0e,0x18,0x00,0xeb,0x09,0x95,
+ 0xfd,0x7f,0xfe,0x7d,0xff,0x7b,0x00,0x7d,0x01,0x7b,
+ 0x02,0x7d,0x03,0x7f,0x02,0x00,0x03,0x01,0x02,0x03,
+ 0x01,0x05,0x00,0x03,0xff,0x05,0xfe,0x03,0xfd,0x01,
+ 0xfe,0x00,0x0b,0xeb,0x06,0x91,0x02,0x01,0x03,0x03,
+ 0x00,0x6b,0x09,0x80,0x04,0x90,0x00,0x01,0x01,0x02,
+ 0x01,0x01,0x02,0x01,0x04,0x00,0x02,0x7f,0x01,0x7f,
+ 0x01,0x7e,0x00,0x7e,0xff,0x7e,0xfe,0x7d,0xf6,0x76,
+ 0x0e,0x00,0x03,0x80,0x05,0x95,0x0b,0x00,0xfa,0x78,
+ 0x03,0x00,0x02,0x7f,0x01,0x7f,0x01,0x7d,0x00,0x7e,
+ 0xff,0x7d,0xfe,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,
+ 0xff,0x01,0xff,0x02,0x11,0xfc,0x0d,0x95,0xf6,0x72,
+ 0x0f,0x00,0xfb,0x8e,0x00,0x6b,0x07,0x80,0x0f,0x95,
+ 0xf6,0x00,0xff,0x77,0x01,0x01,0x03,0x01,0x03,0x00,
+ 0x03,0x7f,0x02,0x7e,0x01,0x7d,0x00,0x7e,0xff,0x7d,
+ 0xfe,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x01,
+ 0xff,0x02,0x11,0xfc,0x10,0x92,0xff,0x02,0xfd,0x01,
+ 0xfe,0x00,0xfd,0x7f,0xfe,0x7d,0xff,0x7b,0x00,0x7b,
+ 0x01,0x7c,0x02,0x7e,0x03,0x7f,0x01,0x00,0x03,0x01,
+ 0x02,0x02,0x01,0x03,0x00,0x01,0xff,0x03,0xfe,0x02,
+ 0xfd,0x01,0xff,0x00,0xfd,0x7f,0xfe,0x7e,0xff,0x7d,
+ 0x10,0xf9,0x11,0x95,0xf6,0x6b,0xfc,0x95,0x0e,0x00,
+ 0x03,0xeb,0x08,0x95,0xfd,0x7f,0xff,0x7e,0x00,0x7e,
+ 0x01,0x7e,0x02,0x7f,0x04,0x7f,0x03,0x7f,0x02,0x7e,
+ 0x01,0x7e,0x00,0x7d,0xff,0x7e,0xff,0x7f,0xfd,0x7f,
+ 0xfc,0x00,0xfd,0x01,0xff,0x01,0xff,0x02,0x00,0x03,
+ 0x01,0x02,0x02,0x02,0x03,0x01,0x04,0x01,0x02,0x01,
+ 0x01,0x02,0x00,0x02,0xff,0x02,0xfd,0x01,0xfc,0x00,
+ 0x0c,0xeb,0x10,0x8e,0xff,0x7d,0xfe,0x7e,0xfd,0x7f,
+ 0xff,0x00,0xfd,0x01,0xfe,0x02,0xff,0x03,0x00,0x01,
+ 0x01,0x03,0x02,0x02,0x03,0x01,0x01,0x00,0x03,0x7f,
+ 0x02,0x7e,0x01,0x7c,0x00,0x7b,0xff,0x7b,0xfe,0x7d,
+ 0xfd,0x7f,0xfe,0x00,0xfd,0x01,0xff,0x02,0x10,0xfd,
+ 0x05,0x8e,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01,
+ 0x00,0xf4,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01,
+ 0x05,0xfe,0x05,0x8e,0xff,0x7f,0x01,0x7f,0x01,0x01,
+ 0xff,0x01,0x01,0xf3,0xff,0x7f,0xff,0x01,0x01,0x01,
+ 0x01,0x7f,0x00,0x7e,0xff,0x7e,0xff,0x7f,0x06,0x84,
+ 0x14,0x92,0xf0,0x77,0x10,0x77,0x04,0x80,0x04,0x8c,
+ 0x12,0x00,0xee,0xfa,0x12,0x00,0x04,0xfa,0x04,0x92,
+ 0x10,0x77,0xf0,0x77,0x14,0x80,0x03,0x90,0x00,0x01,
+ 0x01,0x02,0x01,0x01,0x02,0x01,0x04,0x00,0x02,0x7f,
+ 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,
+ 0xfc,0x7e,0x00,0x7d,0x00,0xfb,0xff,0x7f,0x01,0x7f,
+ 0x01,0x01,0xff,0x01,0x09,0xfe,0x12,0x8d,0xff,0x02,
+ 0xfe,0x01,0xfd,0x00,0xfe,0x7f,0xff,0x7f,0xff,0x7d,
+ 0x00,0x7d,0x01,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
+ 0x01,0x02,0xfb,0x88,0xfe,0x7e,0xff,0x7d,0x00,0x7d,
+ 0x01,0x7e,0x01,0x7f,0x07,0x8b,0xff,0x78,0x00,0x7e,
+ 0x02,0x7f,0x02,0x00,0x02,0x02,0x01,0x03,0x00,0x02,
+ 0xff,0x03,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfd,0x01,
+ 0xfd,0x00,0xfd,0x7f,0xfe,0x7f,0xfe,0x7e,0xff,0x7e,
+ 0xff,0x7d,0x00,0x7d,0x01,0x7d,0x01,0x7e,0x02,0x7e,
+ 0x02,0x7f,0x03,0x7f,0x03,0x00,0x03,0x01,0x02,0x01,
+ 0x01,0x01,0xfe,0x8d,0xff,0x78,0x00,0x7e,0x01,0x7f,
+ 0x08,0xfb,0x09,0x95,0xf8,0x6b,0x08,0x95,0x08,0x6b,
+ 0xf3,0x87,0x0a,0x00,0x04,0xf9,0x04,0x95,0x00,0x6b,
+ 0x00,0x95,0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,
+ 0x00,0x7e,0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x80,
+ 0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,0x00,0x7d,
+ 0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x00,0x11,0x80,
+ 0x12,0x90,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfc,0x00,
+ 0xfe,0x7f,0xfe,0x7e,0xff,0x7e,0xff,0x7d,0x00,0x7b,
+ 0x01,0x7d,0x01,0x7e,0x02,0x7e,0x02,0x7f,0x04,0x00,
+ 0x02,0x01,0x02,0x02,0x01,0x02,0x03,0xfb,0x04,0x95,
+ 0x00,0x6b,0x00,0x95,0x07,0x00,0x03,0x7f,0x02,0x7e,
+ 0x01,0x7e,0x01,0x7d,0x00,0x7b,0xff,0x7d,0xff,0x7e,
+ 0xfe,0x7e,0xfd,0x7f,0xf9,0x00,0x11,0x80,0x04,0x95,
+ 0x00,0x6b,0x00,0x95,0x0d,0x00,0xf3,0xf6,0x08,0x00,
+ 0xf8,0xf5,0x0d,0x00,0x02,0x80,0x04,0x95,0x00,0x6b,
+ 0x00,0x95,0x0d,0x00,0xf3,0xf6,0x08,0x00,0x06,0xf5,
+ 0x12,0x90,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfc,0x00,
+ 0xfe,0x7f,0xfe,0x7e,0xff,0x7e,0xff,0x7d,0x00,0x7b,
+ 0x01,0x7d,0x01,0x7e,0x02,0x7e,0x02,0x7f,0x04,0x00,
+ 0x02,0x01,0x02,0x02,0x01,0x02,0x00,0x03,0xfb,0x80,
+ 0x05,0x00,0x03,0xf8,0x04,0x95,0x00,0x6b,0x0e,0x95,
+ 0x00,0x6b,0xf2,0x8b,0x0e,0x00,0x04,0xf5,0x04,0x95,
+ 0x00,0x6b,0x04,0x80,0x0c,0x95,0x00,0x70,0xff,0x7d,
+ 0xff,0x7f,0xfe,0x7f,0xfe,0x00,0xfe,0x01,0xff,0x01,
+ 0xff,0x03,0x00,0x02,0x0e,0xf9,0x04,0x95,0x00,0x6b,
+ 0x0e,0x95,0xf2,0x72,0x05,0x85,0x09,0x74,0x03,0x80,
+ 0x04,0x95,0x00,0x6b,0x00,0x80,0x0c,0x00,0x01,0x80,
+ 0x04,0x95,0x00,0x6b,0x00,0x95,0x08,0x6b,0x08,0x95,
+ 0xf8,0x6b,0x08,0x95,0x00,0x6b,0x04,0x80,0x04,0x95,
+ 0x00,0x6b,0x00,0x95,0x0e,0x6b,0x00,0x95,0x00,0x6b,
+ 0x04,0x80,0x09,0x95,0xfe,0x7f,0xfe,0x7e,0xff,0x7e,
+ 0xff,0x7d,0x00,0x7b,0x01,0x7d,0x01,0x7e,0x02,0x7e,
+ 0x02,0x7f,0x04,0x00,0x02,0x01,0x02,0x02,0x01,0x02,
+ 0x01,0x03,0x00,0x05,0xff,0x03,0xff,0x02,0xfe,0x02,
+ 0xfe,0x01,0xfc,0x00,0x0d,0xeb,0x04,0x95,0x00,0x6b,
+ 0x00,0x95,0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,
+ 0x00,0x7d,0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x00,
+ 0x11,0xf6,0x09,0x95,0xfe,0x7f,0xfe,0x7e,0xff,0x7e,
+ 0xff,0x7d,0x00,0x7b,0x01,0x7d,0x01,0x7e,0x02,0x7e,
+ 0x02,0x7f,0x04,0x00,0x02,0x01,0x02,0x02,0x01,0x02,
+ 0x01,0x03,0x00,0x05,0xff,0x03,0xff,0x02,0xfe,0x02,
+ 0xfe,0x01,0xfc,0x00,0x03,0xef,0x06,0x7a,0x04,0x82,
+ 0x04,0x95,0x00,0x6b,0x00,0x95,0x09,0x00,0x03,0x7f,
+ 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,
+ 0xfd,0x7f,0xf7,0x00,0x07,0x80,0x07,0x75,0x03,0x80,
+ 0x11,0x92,0xfe,0x02,0xfd,0x01,0xfc,0x00,0xfd,0x7f,
+ 0xfe,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x02,0x7f,
+ 0x06,0x7e,0x02,0x7f,0x01,0x7f,0x01,0x7e,0x00,0x7d,
+ 0xfe,0x7e,0xfd,0x7f,0xfc,0x00,0xfd,0x01,0xfe,0x02,
+ 0x11,0xfd,0x08,0x95,0x00,0x6b,0xf9,0x95,0x0e,0x00,
+ 0x01,0xeb,0x04,0x95,0x00,0x71,0x01,0x7d,0x02,0x7e,
+ 0x03,0x7f,0x02,0x00,0x03,0x01,0x02,0x02,0x01,0x03,
+ 0x00,0x0f,0x04,0xeb,0x01,0x95,0x08,0x6b,0x08,0x95,
+ 0xf8,0x6b,0x09,0x80,0x02,0x95,0x05,0x6b,0x05,0x95,
+ 0xfb,0x6b,0x05,0x95,0x05,0x6b,0x05,0x95,0xfb,0x6b,
+ 0x07,0x80,0x03,0x95,0x0e,0x6b,0x00,0x95,0xf2,0x6b,
+ 0x11,0x80,0x01,0x95,0x08,0x76,0x00,0x75,0x08,0x95,
+ 0xf8,0x76,0x09,0xf5,0x11,0x95,0xf2,0x6b,0x00,0x95,
+ 0x0e,0x00,0xf2,0xeb,0x0e,0x00,0x03,0x80,0x03,0x93,
+ 0x00,0x6c,0x01,0x94,0x00,0x6c,0xff,0x94,0x05,0x00,
+ 0xfb,0xec,0x05,0x00,0x02,0x81,0x00,0x95,0x0e,0x68,
+ 0x00,0x83,0x06,0x93,0x00,0x6c,0x01,0x94,0x00,0x6c,
+ 0xfb,0x94,0x05,0x00,0xfb,0xec,0x05,0x00,0x03,0x81,
+ 0x03,0x87,0x08,0x05,0x08,0x7b,0xf0,0x80,0x08,0x04,
+ 0x08,0x7c,0x03,0xf9,0x01,0x80,0x10,0x00,0x01,0x80,
+ 0x06,0x95,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7f,
+ 0x01,0x01,0xff,0x01,0x05,0xef,0x0f,0x8e,0x00,0x72,
+ 0x00,0x8b,0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,
+ 0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,
+ 0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,
+ 0x04,0x95,0x00,0x6b,0x00,0x8b,0x02,0x02,0x02,0x01,
+ 0x03,0x00,0x02,0x7f,0x02,0x7e,0x01,0x7d,0x00,0x7e,
+ 0xff,0x7d,0xfe,0x7e,0xfe,0x7f,0xfd,0x00,0xfe,0x01,
+ 0xfe,0x02,0x0f,0xfd,0x0f,0x8b,0xfe,0x02,0xfe,0x01,
+ 0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e,
+ 0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
+ 0x02,0x02,0x03,0xfd,0x0f,0x95,0x00,0x6b,0x00,0x8b,
+ 0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,0xfe,0x7e,
+ 0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,0x02,0x7f,
+ 0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,0x03,0x88,
+ 0x0c,0x00,0x00,0x02,0xff,0x02,0xff,0x01,0xfe,0x01,
+ 0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e,
+ 0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
+ 0x02,0x02,0x03,0xfd,0x0a,0x95,0xfe,0x00,0xfe,0x7f,
+ 0xff,0x7d,0x00,0x6f,0xfd,0x8e,0x07,0x00,0x03,0xf2,
+ 0x0f,0x8e,0x00,0x70,0xff,0x7d,0xff,0x7f,0xfe,0x7f,
+ 0xfd,0x00,0xfe,0x01,0x09,0x91,0xfe,0x02,0xfe,0x01,
+ 0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e,
+ 0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
+ 0x02,0x02,0x04,0xfd,0x04,0x95,0x00,0x6b,0x00,0x8a,
+ 0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,0x01,0x7d,
+ 0x00,0x76,0x04,0x80,0x03,0x95,0x01,0x7f,0x01,0x01,
+ 0xff,0x01,0xff,0x7f,0x01,0xf9,0x00,0x72,0x04,0x80,
+ 0x05,0x95,0x01,0x7f,0x01,0x01,0xff,0x01,0xff,0x7f,
+ 0x01,0xf9,0x00,0x6f,0xff,0x7d,0xfe,0x7f,0xfe,0x00,
+ 0x09,0x87,0x04,0x95,0x00,0x6b,0x0a,0x8e,0xf6,0x76,
+ 0x04,0x84,0x07,0x78,0x02,0x80,0x04,0x95,0x00,0x6b,
+ 0x04,0x80,0x04,0x8e,0x00,0x72,0x00,0x8a,0x03,0x03,
+ 0x02,0x01,0x03,0x00,0x02,0x7f,0x01,0x7d,0x00,0x76,
+ 0x00,0x8a,0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,
+ 0x01,0x7d,0x00,0x76,0x04,0x80,0x04,0x8e,0x00,0x72,
+ 0x00,0x8a,0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,
+ 0x01,0x7d,0x00,0x76,0x04,0x80,0x08,0x8e,0xfe,0x7f,
+ 0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,
+ 0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x01,0x03,
+ 0x00,0x02,0xff,0x03,0xfe,0x02,0xfe,0x01,0xfd,0x00,
+ 0x0b,0xf2,0x04,0x8e,0x00,0x6b,0x00,0x92,0x02,0x02,
+ 0x02,0x01,0x03,0x00,0x02,0x7f,0x02,0x7e,0x01,0x7d,
+ 0x00,0x7e,0xff,0x7d,0xfe,0x7e,0xfe,0x7f,0xfd,0x00,
+ 0xfe,0x01,0xfe,0x02,0x0f,0xfd,0x0f,0x8e,0x00,0x6b,
+ 0x00,0x92,0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,
+ 0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,
+ 0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,
+ 0x04,0x8e,0x00,0x72,0x00,0x88,0x01,0x03,0x02,0x02,
+ 0x02,0x01,0x03,0x00,0x01,0xf2,0x0e,0x8b,0xff,0x02,
+ 0xfd,0x01,0xfd,0x00,0xfd,0x7f,0xff,0x7e,0x01,0x7e,
+ 0x02,0x7f,0x05,0x7f,0x02,0x7f,0x01,0x7e,0x00,0x7f,
+ 0xff,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x02,
+ 0x0e,0xfd,0x05,0x95,0x00,0x6f,0x01,0x7d,0x02,0x7f,
+ 0x02,0x00,0xf8,0x8e,0x07,0x00,0x03,0xf2,0x04,0x8e,
+ 0x00,0x76,0x01,0x7d,0x02,0x7f,0x03,0x00,0x02,0x01,
+ 0x03,0x03,0x00,0x8a,0x00,0x72,0x04,0x80,0x02,0x8e,
+ 0x06,0x72,0x06,0x8e,0xfa,0x72,0x08,0x80,0x03,0x8e,
+ 0x04,0x72,0x04,0x8e,0xfc,0x72,0x04,0x8e,0x04,0x72,
+ 0x04,0x8e,0xfc,0x72,0x07,0x80,0x03,0x8e,0x0b,0x72,
+ 0x00,0x8e,0xf5,0x72,0x0e,0x80,0x02,0x8e,0x06,0x72,
+ 0x06,0x8e,0xfa,0x72,0xfe,0x7c,0xfe,0x7e,0xfe,0x7f,
+ 0xff,0x00,0x0f,0x87,0x0e,0x8e,0xf5,0x72,0x00,0x8e,
+ 0x0b,0x00,0xf5,0xf2,0x0b,0x00,0x03,0x80,0x09,0x99,
+ 0xfe,0x7f,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,
+ 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xfe,0x7e,0x01,0x8e,
+ 0xff,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x01,0x7e,
+ 0x00,0x7e,0xff,0x7e,0xfc,0x7e,0x04,0x7e,0x01,0x7e,
+ 0x00,0x7e,0xff,0x7e,0xff,0x7f,0xff,0x7e,0x00,0x7e,
+ 0x01,0x7e,0xff,0x8e,0x02,0x7e,0x00,0x7e,0xff,0x7e,
+ 0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,
+ 0x02,0x7f,0x05,0x87,0x04,0x95,0x00,0x77,0x00,0xfd,
+ 0x00,0x77,0x04,0x80,0x05,0x99,0x02,0x7f,0x01,0x7f,
+ 0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,0xff,0x7e,
+ 0x00,0x7e,0x02,0x7e,0xff,0x8e,0x01,0x7e,0x00,0x7e,
+ 0xff,0x7e,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,
+ 0x04,0x7e,0xfc,0x7e,0xff,0x7e,0x00,0x7e,0x01,0x7e,
+ 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0x01,0x8e,
+ 0xfe,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x01,0x7e,
+ 0x00,0x7e,0xff,0x7e,0xff,0x7f,0xfe,0x7f,0x09,0x87,
+ 0x03,0x86,0x00,0x02,0x01,0x03,0x02,0x01,0x02,0x00,
+ 0x02,0x7f,0x04,0x7d,0x02,0x7f,0x02,0x00,0x02,0x01,
+ 0x01,0x02,0xee,0xfe,0x01,0x02,0x02,0x01,0x02,0x00,
+ 0x02,0x7f,0x04,0x7d,0x02,0x7f,0x02,0x00,0x02,0x01,
+ 0x01,0x03,0x00,0x02,0x03,0xf4,0x10,0x80,0x03,0x80,
+ 0x07,0x15,0x08,0x6b,0xfe,0x85,0xf5,0x00,0x10,0xfb,
+ 0x0d,0x95,0xf6,0x00,0x00,0x6b,0x0a,0x00,0x02,0x02,
+ 0x00,0x08,0xfe,0x02,0xf6,0x00,0x0e,0xf4,0x03,0x80,
+ 0x00,0x15,0x0a,0x00,0x02,0x7e,0x00,0x7e,0x00,0x7d,
+ 0x00,0x7e,0xfe,0x7f,0xf6,0x00,0x0a,0x80,0x02,0x7e,
+ 0x01,0x7e,0x00,0x7d,0xff,0x7d,0xfe,0x7f,0xf6,0x00,
+ 0x10,0x80,0x03,0x80,0x00,0x15,0x0c,0x00,0xff,0x7e,
+ 0x03,0xed,0x03,0xfd,0x00,0x03,0x02,0x00,0x00,0x12,
+ 0x02,0x03,0x0a,0x00,0x00,0x6b,0x02,0x00,0x00,0x7d,
+ 0xfe,0x83,0xf4,0x00,0x11,0x80,0x0f,0x80,0xf4,0x00,
+ 0x00,0x15,0x0c,0x00,0xff,0xf6,0xf5,0x00,0x0f,0xf5,
+ 0x04,0x95,0x07,0x76,0x00,0x0a,0x07,0x80,0xf9,0x76,
+ 0x00,0x75,0xf8,0x80,0x07,0x0c,0x09,0xf4,0xf9,0x0c,
+ 0x09,0xf4,0x03,0x92,0x02,0x03,0x07,0x00,0x03,0x7d,
+ 0x00,0x7b,0xfc,0x7e,0x04,0x7d,0x00,0x7a,0xfd,0x7e,
+ 0xf9,0x00,0xfe,0x02,0x06,0x89,0x02,0x00,0x06,0xf5,
+ 0x03,0x95,0x00,0x6b,0x0c,0x15,0x00,0x6b,0x02,0x80,
+ 0x03,0x95,0x00,0x6b,0x0c,0x15,0x00,0x6b,0xf8,0x96,
+ 0x03,0x00,0x07,0xea,0x03,0x80,0x00,0x15,0x0c,0x80,
+ 0xf7,0x76,0xfd,0x00,0x03,0x80,0x0a,0x75,0x03,0x80,
+ 0x03,0x80,0x07,0x13,0x02,0x02,0x03,0x00,0x00,0x6b,
+ 0x02,0x80,0x03,0x80,0x00,0x15,0x09,0x6b,0x09,0x15,
+ 0x00,0x6b,0x03,0x80,0x03,0x80,0x00,0x15,0x00,0xf6,
+ 0x0d,0x00,0x00,0x8a,0x00,0x6b,0x03,0x80,0x07,0x80,
+ 0xfd,0x00,0xff,0x03,0x00,0x04,0x00,0x07,0x00,0x04,
+ 0x01,0x02,0x03,0x01,0x06,0x00,0x03,0x7f,0x01,0x7e,
+ 0x01,0x7c,0x00,0x79,0xff,0x7c,0xff,0x7d,0xfd,0x00,
+ 0xfa,0x00,0x0e,0x80,0x03,0x80,0x00,0x15,0x0c,0x00,
+ 0x00,0x6b,0x02,0x80,0x03,0x80,0x00,0x15,0x0a,0x00,
+ 0x02,0x7f,0x01,0x7d,0x00,0x7b,0xff,0x7e,0xfe,0x7f,
+ 0xf6,0x00,0x10,0xf7,0x11,0x8f,0xff,0x03,0xff,0x02,
+ 0xfe,0x01,0xfa,0x00,0xfd,0x7f,0xff,0x7e,0x00,0x7c,
+ 0x00,0x79,0x00,0x7b,0x01,0x7e,0x03,0x00,0x06,0x00,
+ 0x02,0x00,0x01,0x03,0x01,0x02,0x03,0xfb,0x03,0x95,
+ 0x0c,0x00,0xfa,0x80,0x00,0x6b,0x09,0x80,0x03,0x95,
+ 0x00,0x77,0x06,0x7a,0x06,0x06,0x00,0x09,0xfa,0xf1,
+ 0xfa,0x7a,0x0e,0x80,0x03,0x87,0x00,0x0b,0x02,0x02,
+ 0x03,0x00,0x02,0x7e,0x01,0x02,0x04,0x00,0x02,0x7e,
+ 0x00,0x75,0xfe,0x7e,0xfc,0x00,0xff,0x01,0xfe,0x7f,
+ 0xfd,0x00,0xfe,0x02,0x07,0x8e,0x00,0x6b,0x09,0x80,
+ 0x03,0x80,0x0e,0x15,0xf2,0x80,0x0e,0x6b,0x03,0x80,
+ 0x03,0x95,0x00,0x6b,0x0e,0x00,0x00,0x7d,0xfe,0x98,
+ 0x00,0x6b,0x05,0x80,0x03,0x95,0x00,0x75,0x02,0x7d,
+ 0x0a,0x00,0x00,0x8e,0x00,0x6b,0x02,0x80,0x03,0x95,
+ 0x00,0x6b,0x10,0x00,0x00,0x15,0xf8,0x80,0x00,0x6b,
+ 0x0a,0x80,0x03,0x95,0x00,0x6b,0x10,0x00,0x00,0x15,
+ 0xf8,0x80,0x00,0x6b,0x0a,0x00,0x00,0x7d,0x02,0x83,
+ 0x10,0x80,0x03,0x95,0x00,0x6b,0x09,0x00,0x03,0x02,
+ 0x00,0x08,0xfd,0x02,0xf7,0x00,0x0e,0x89,0x00,0x6b,
+ 0x03,0x80,0x03,0x95,0x00,0x6b,0x09,0x00,0x03,0x02,
+ 0x00,0x08,0xfd,0x02,0xf7,0x00,0x0e,0xf4,0x03,0x92,
+ 0x02,0x03,0x07,0x00,0x03,0x7d,0x00,0x70,0xfd,0x7e,
+ 0xf9,0x00,0xfe,0x02,0x03,0x89,0x09,0x00,0x02,0xf5,
+ 0x03,0x80,0x00,0x15,0x00,0xf5,0x07,0x00,0x00,0x08,
+ 0x02,0x03,0x06,0x00,0x02,0x7d,0x00,0x70,0xfe,0x7e,
+ 0xfa,0x00,0xfe,0x02,0x00,0x08,0x0c,0xf6,0x0f,0x80,
+ 0x00,0x15,0xf6,0x00,0xfe,0x7d,0x00,0x79,0x02,0x7e,
+ 0x0a,0x00,0xf4,0xf7,0x07,0x09,0x07,0xf7,0x03,0x8c,
+ 0x01,0x02,0x01,0x01,0x05,0x00,0x02,0x7f,0x01,0x7e,
+ 0x00,0x74,0x00,0x86,0xff,0x01,0xfe,0x01,0xfb,0x00,
+ 0xff,0x7f,0xff,0x7f,0x00,0x7c,0x01,0x7e,0x01,0x00,
+ 0x05,0x00,0x02,0x00,0x01,0x02,0x03,0xfe,0x04,0x8e,
+ 0x02,0x01,0x04,0x00,0x02,0x7f,0x01,0x7e,0x00,0x77,
+ 0xff,0x7e,0xfe,0x7f,0xfc,0x00,0xfe,0x01,0xff,0x02,
+ 0x00,0x09,0x01,0x02,0x02,0x02,0x03,0x01,0x02,0x01,
+ 0x01,0x01,0x01,0x02,0x02,0xeb,0x03,0x80,0x00,0x15,
+ 0x03,0x00,0x02,0x7e,0x00,0x7b,0xfe,0x7e,0xfd,0x00,
+ 0x03,0x80,0x04,0x00,0x03,0x7e,0x00,0x78,0xfd,0x7e,
+ 0xf9,0x00,0x0c,0x80,0x03,0x8c,0x02,0x02,0x02,0x01,
+ 0x03,0x00,0x02,0x7f,0x01,0x7d,0xfe,0x7e,0xf9,0x7d,
+ 0xff,0x7e,0x00,0x7d,0x03,0x7f,0x02,0x00,0x03,0x01,
+ 0x02,0x01,0x02,0xfe,0x0d,0x8c,0xff,0x02,0xfe,0x01,
+ 0xfc,0x00,0xfe,0x7f,0xff,0x7e,0x00,0x77,0x01,0x7e,
+ 0x02,0x7f,0x04,0x00,0x02,0x01,0x01,0x02,0x00,0x0f,
+ 0xff,0x02,0xfe,0x01,0xf9,0x00,0x0c,0xeb,0x03,0x88,
+ 0x0a,0x00,0x00,0x02,0x00,0x03,0xfe,0x02,0xfa,0x00,
+ 0xff,0x7e,0xff,0x7d,0x00,0x7b,0x01,0x7c,0x01,0x7f,
+ 0x06,0x00,0x02,0x02,0x03,0xfe,0x03,0x8f,0x06,0x77,
+ 0x06,0x09,0xfa,0x80,0x00,0x71,0xff,0x87,0xfb,0x79,
+ 0x07,0x87,0x05,0x79,0x02,0x80,0x03,0x8d,0x02,0x02,
+ 0x06,0x00,0x02,0x7e,0x00,0x7d,0xfc,0x7d,0x04,0x7e,
+ 0x00,0x7d,0xfe,0x7e,0xfa,0x00,0xfe,0x02,0x04,0x85,
+ 0x02,0x00,0x06,0xf9,0x03,0x8f,0x00,0x73,0x01,0x7e,
+ 0x07,0x00,0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,
+ 0x03,0x80,0x03,0x8f,0x00,0x73,0x01,0x7e,0x07,0x00,
+ 0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0xf8,0x90,
+ 0x03,0x00,0x08,0xf0,0x03,0x80,0x00,0x15,0x00,0xf3,
+ 0x02,0x00,0x06,0x07,0xfa,0xf9,0x07,0x78,0x03,0x80,
+ 0x03,0x80,0x04,0x0c,0x02,0x03,0x04,0x00,0x00,0x71,
+ 0x02,0x80,0x03,0x80,0x00,0x0f,0x06,0x77,0x06,0x09,
+ 0x00,0x71,0x02,0x80,0x03,0x80,0x00,0x0f,0x0a,0xf1,
+ 0x00,0x0f,0xf6,0xf8,0x0a,0x00,0x02,0xf9,0x05,0x80,
+ 0xff,0x01,0xff,0x04,0x00,0x05,0x01,0x03,0x01,0x02,
+ 0x06,0x00,0x02,0x7e,0x00,0x7d,0x00,0x7b,0x00,0x7c,
+ 0xfe,0x7f,0xfa,0x00,0x0b,0x80,0x03,0x80,0x00,0x0f,
+ 0x00,0xfb,0x01,0x03,0x01,0x02,0x05,0x00,0x02,0x7e,
+ 0x01,0x7d,0x00,0x76,0x03,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
+ 0x10,0x80,0x0a,0x8f,0x02,0x7f,0x01,0x7e,0x00,0x76,
+ 0xff,0x7f,0xfe,0x7f,0xfb,0x00,0xff,0x01,0xff,0x01,
+ 0x00,0x0a,0x01,0x02,0x01,0x01,0x05,0x00,0xf9,0x80,
+ 0x00,0x6b,0x0c,0x86,0x0d,0x8a,0xff,0x03,0xfe,0x02,
+ 0xfb,0x00,0xff,0x7e,0xff,0x7d,0x00,0x7b,0x01,0x7c,
+ 0x01,0x7f,0x05,0x00,0x02,0x01,0x01,0x03,0x03,0xfc,
+ 0x03,0x80,0x00,0x0f,0x00,0xfb,0x01,0x03,0x01,0x02,
+ 0x04,0x00,0x01,0x7e,0x01,0x7d,0x00,0x76,0x00,0x8a,
+ 0x01,0x03,0x02,0x02,0x03,0x00,0x02,0x7e,0x01,0x7d,
+ 0x00,0x76,0x03,0x80,0x03,0x8f,0x00,0x74,0x01,0x7e,
+ 0x02,0x7f,0x04,0x00,0x02,0x01,0x01,0x01,0x00,0x8d,
+ 0x00,0x6e,0xff,0x7e,0xfe,0x7f,0xfb,0x00,0xfe,0x01,
+ 0x0c,0x85,0x03,0x8d,0x01,0x02,0x03,0x00,0x02,0x7e,
+ 0x01,0x02,0x03,0x00,0x02,0x7e,0x00,0x74,0xfe,0x7f,
+ 0xfd,0x00,0xff,0x01,0xfe,0x7f,0xfd,0x00,0xff,0x01,
+ 0x00,0x0c,0x06,0x82,0x00,0x6b,0x08,0x86,0x03,0x80,
+ 0x0a,0x0f,0xf6,0x80,0x0a,0x71,0x03,0x80,0x03,0x8f,
+ 0x00,0x73,0x01,0x7e,0x07,0x00,0x02,0x02,0x00,0x0d,
+ 0x00,0xf3,0x01,0x7e,0x00,0x7e,0x03,0x82,0x03,0x8f,
+ 0x00,0x79,0x02,0x7e,0x08,0x00,0x00,0x89,0x00,0x71,
+ 0x02,0x80,0x03,0x8f,0x00,0x73,0x01,0x7e,0x03,0x00,
+ 0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x00,
+ 0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x80,
+ 0x03,0x8f,0x00,0x73,0x01,0x7e,0x03,0x00,0x02,0x02,
+ 0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x00,0x02,0x02,
+ 0x00,0x0d,0x00,0xf3,0x01,0x7e,0x00,0x7e,0x03,0x82,
+ 0x03,0x8d,0x00,0x02,0x02,0x00,0x00,0x71,0x08,0x00,
+ 0x02,0x02,0x00,0x06,0xfe,0x02,0xf8,0x00,0x0c,0xf6,
+ 0x03,0x8f,0x00,0x71,0x07,0x00,0x02,0x02,0x00,0x06,
+ 0xfe,0x02,0xf9,0x00,0x0c,0x85,0x00,0x71,0x02,0x80,
+ 0x03,0x8f,0x00,0x71,0x07,0x00,0x03,0x02,0x00,0x06,
+ 0xfd,0x02,0xf9,0x00,0x0c,0xf6,0x03,0x8d,0x02,0x02,
+ 0x06,0x00,0x02,0x7e,0x00,0x75,0xfe,0x7e,0xfa,0x00,
+ 0xfe,0x02,0x04,0x85,0x06,0x00,0x02,0xf9,0x03,0x80,
+ 0x00,0x0f,0x00,0xf8,0x04,0x00,0x00,0x06,0x02,0x02,
+ 0x04,0x00,0x02,0x7e,0x00,0x75,0xfe,0x7e,0xfc,0x00,
+ 0xfe,0x02,0x00,0x05,0x0a,0xf9,0x0d,0x80,0x00,0x0f,
+ 0xf7,0x00,0xff,0x7e,0x00,0x7b,0x01,0x7e,0x09,0x00,
+ 0xf6,0xfa,0x04,0x06,0x08,0xfa
+ };
+
+ //-------------------------------------------------------------------------
+ gsv_text::gsv_text() :
+ m_x(0.0),
+ m_y(0.0),
+ m_start_x(0.0),
+ m_width(10.0),
+ m_height(0.0),
+ m_space(0.0),
+ m_line_space(0.0),
+ m_text(m_chr),
+ m_text_buf(),
+ m_cur_chr(m_chr),
+ m_font(gsv_default_font),
+ m_loaded_font(),
+ m_status(initial),
+ m_big_endian(false),
+ m_flip(false)
+ {
+ m_chr[0] = m_chr[1] = 0;
+
+ int t = 1;
+ if(*(char*)&t == 0) m_big_endian = true;
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::font(const void* font)
+ {
+ m_font = font;
+ if(m_font == 0) m_font = &m_loaded_font[0];
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::size(double height, double width)
+ {
+ m_height = height;
+ m_width = width;
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::space(double space)
+ {
+ m_space = space;
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::line_space(double line_space)
+ {
+ m_line_space = line_space;
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::start_point(double x, double y)
+ {
+ m_x = m_start_x = x;
+ m_y = y;
+ //if(m_flip) m_y += m_height;
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::load_font(const char* file)
+ {
+ m_loaded_font.resize(0);
+ FILE* fd = fopen(file, "rb");
+ if(fd)
+ {
+ unsigned len;
+
+ fseek(fd, 0l, SEEK_END);
+ len = ftell(fd);
+ fseek(fd, 0l, SEEK_SET);
+ if(len > 0)
+ {
+ m_loaded_font.resize(len);
+ fread(&m_loaded_font[0], 1, len, fd);
+ m_font = &m_loaded_font[0];
+ }
+ fclose(fd);
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::text(const char* text)
+ {
+ if(text == 0)
+ {
+ m_chr[0] = 0;
+ m_text = m_chr;
+ return;
+ }
+ unsigned new_size = strlen(text) + 1;
+ if(new_size > m_text_buf.size())
+ {
+ m_text_buf.resize(new_size);
+ }
+ memcpy(&m_text_buf[0], text, new_size);
+ m_text = &m_text_buf[0];
+ }
+
+ //-------------------------------------------------------------------------
+ void gsv_text::rewind(unsigned)
+ {
+ m_status = initial;
+ if(m_font == 0) return;
+
+ m_indices = (int8u*)m_font;
+ double base_height = value(m_indices + 4);
+ m_indices += value(m_indices);
+ m_glyphs = (int8*)(m_indices + 257*2);
+ m_h = m_height / base_height;
+ m_w = (m_width == 0.0) ? m_h : m_width / base_height;
+ if(m_flip) m_h = -m_h;
+ m_cur_chr = m_text;
+ }
+
+ //-------------------------------------------------------------------------
+ unsigned gsv_text::vertex(double* x, double* y)
+ {
+ unsigned idx;
+ int8 yc, yf;
+ int dx, dy;
+ bool quit = false;
+
+ while(!quit)
+ {
+ switch(m_status)
+ {
+ case initial:
+ if(m_font == 0)
+ {
+ quit = true;
+ break;
+ }
+ m_status = next_char;
+
+ case next_char:
+ if(*m_cur_chr == 0)
+ {
+ quit = true;
+ break;
+ }
+ idx = (*m_cur_chr++) & 0xFF;
+ if(idx == '\n')
+ {
+ m_x = m_start_x;
+ m_y -= m_flip ? -m_height - m_line_space : m_height + m_line_space;
+ break;
+ }
+ idx <<= 1;
+ m_bglyph = m_glyphs + value(m_indices + idx);
+ m_eglyph = m_glyphs + value(m_indices + idx + 2);
+ m_status = start_glyph;
+
+ case start_glyph:
+ *x = m_x;
+ *y = m_y;
+ m_status = glyph;
+ return path_cmd_move_to;
+
+ case glyph:
+ if(m_bglyph >= m_eglyph)
+ {
+ m_status = next_char;
+ m_x += m_space;
+ break;
+ }
+ dx = int(*m_bglyph++);
+ yf = (yc = *m_bglyph++) & 0x80;
+ yc <<= 1;
+ yc >>= 1;
+ dy = int(yc);
+ m_x += double(dx) * m_w;
+ m_y += double(dy) * m_h;
+ *x = m_x;
+ *y = m_y;
+ return yf ? path_cmd_move_to : path_cmd_line_to;
+ }
+
+ }
+ return path_cmd_stop;
+ }
+
+ //-------------------------------------------------------------------------
+ double gsv_text::text_width()
+ {
+ double x1, y1, x2, y2;
+ bounding_rect_single(*this, 0, &x1, &y1, &x2, &y2);
+ return x2 - x1;
+ }
+
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_image_filters.cpp b/plugins/Clist_ng/AGG/src/agg_image_filters.cpp new file mode 100644 index 0000000000..fb508f61d7 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_image_filters.cpp @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_image_filters.h"
+
+
+namespace agg
+{
+ //--------------------------------------------------------------------
+ void image_filter_lut::realloc_lut(double radius)
+ {
+ m_radius = radius;
+ m_diameter = uceil(radius) * 2;
+ m_start = -int(m_diameter / 2 - 1);
+ unsigned size = m_diameter << image_subpixel_shift;
+ if(size > m_weight_array.size())
+ {
+ m_weight_array.resize(size);
+ }
+ }
+
+
+
+ //--------------------------------------------------------------------
+ // This function normalizes integer values and corrects the rounding
+ // errors. It doesn't do anything with the source floating point values
+ // (m_weight_array_dbl), it corrects only integers according to the rule
+ // of 1.0 which means that any sum of pixel weights must be equal to 1.0.
+ // So, the filter function must produce a graph of the proper shape.
+ //--------------------------------------------------------------------
+ void image_filter_lut::normalize()
+ {
+ unsigned i;
+ int flip = 1;
+
+ for(i = 0; i < image_subpixel_scale; i++)
+ {
+ for(;;)
+ {
+ int sum = 0;
+ unsigned j;
+ for(j = 0; j < m_diameter; j++)
+ {
+ sum += m_weight_array[j * image_subpixel_scale + i];
+ }
+
+ if(sum == image_filter_scale) break;
+
+ double k = double(image_filter_scale) / double(sum);
+ sum = 0;
+ for(j = 0; j < m_diameter; j++)
+ {
+ sum += m_weight_array[j * image_subpixel_scale + i] =
+ iround(m_weight_array[j * image_subpixel_scale + i] * k);
+ }
+
+ sum -= image_filter_scale;
+ int inc = (sum > 0) ? -1 : 1;
+
+ for(j = 0; j < m_diameter && sum; j++)
+ {
+ flip ^= 1;
+ unsigned idx = flip ? m_diameter/2 + j/2 : m_diameter/2 - j/2;
+ int v = m_weight_array[idx * image_subpixel_scale + i];
+ if(v < image_filter_scale)
+ {
+ m_weight_array[idx * image_subpixel_scale + i] += inc;
+ sum += inc;
+ }
+ }
+ }
+ }
+
+ unsigned pivot = m_diameter << (image_subpixel_shift - 1);
+
+ for(i = 0; i < pivot; i++)
+ {
+ m_weight_array[pivot + i] = m_weight_array[pivot - i];
+ }
+ unsigned end = (diameter() << image_subpixel_shift) - 1;
+ m_weight_array[0] = m_weight_array[end];
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_line_aa_basics.cpp b/plugins/Clist_ng/AGG/src/agg_line_aa_basics.cpp new file mode 100644 index 0000000000..8570e5c717 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_line_aa_basics.cpp @@ -0,0 +1,91 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_line_aa_basics.h"
+
+namespace agg
+{
+ //-------------------------------------------------------------------------
+ // The number of the octant is determined as a 3-bit value as follows:
+ // bit 0 = vertical flag
+ // bit 1 = sx < 0
+ // bit 2 = sy < 0
+ //
+ // [N] shows the number of the orthogonal quadrant
+ // <M> shows the number of the diagonal quadrant
+ // <1>
+ // [1] | [0]
+ // . (3)011 | 001(1) .
+ // . | .
+ // . | .
+ // . | .
+ // (2)010 .|. 000(0)
+ // <2> ----------.+.----------- <0>
+ // (6)110 . | . 100(4)
+ // . | .
+ // . | .
+ // . | .
+ // (7)111 | 101(5)
+ // [2] | [3]
+ // <3>
+ // 0,1,2,3,4,5,6,7
+ const int8u line_parameters::s_orthogonal_quadrant[8] = { 0,0,1,1,3,3,2,2 };
+ const int8u line_parameters::s_diagonal_quadrant[8] = { 0,1,2,1,0,3,2,3 };
+
+
+
+ //-------------------------------------------------------------------------
+ void bisectrix(const line_parameters& l1,
+ const line_parameters& l2,
+ int* x, int* y)
+ {
+ double k = double(l2.len) / double(l1.len);
+ double tx = l2.x2 - (l2.x1 - l1.x1) * k;
+ double ty = l2.y2 - (l2.y1 - l1.y1) * k;
+
+ //All bisectrices must be on the right of the line
+ //If the next point is on the left (l1 => l2.2)
+ //then the bisectix should be rotated by 180 degrees.
+ if(double(l2.x2 - l2.x1) * double(l2.y1 - l1.y1) <
+ double(l2.y2 - l2.y1) * double(l2.x1 - l1.x1) + 100.0)
+ {
+ tx -= (tx - l2.x1) * 2.0;
+ ty -= (ty - l2.y1) * 2.0;
+ }
+
+ // Check if the bisectrix is too short
+ double dx = tx - l2.x1;
+ double dy = ty - l2.y1;
+ if((int)sqrt(dx * dx + dy * dy) < line_subpixel_scale)
+ {
+ *x = (l2.x1 + l2.x1 + (l2.y1 - l1.y1) + (l2.y2 - l2.y1)) >> 1;
+ *y = (l2.y1 + l2.y1 - (l2.x1 - l1.x1) - (l2.x2 - l2.x1)) >> 1;
+ return;
+ }
+ *x = iround(tx);
+ *y = iround(ty);
+ }
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_line_profile_aa.cpp b/plugins/Clist_ng/AGG/src/agg_line_profile_aa.cpp new file mode 100644 index 0000000000..1df9e2cb82 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_line_profile_aa.cpp @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_renderer_outline_aa.h"
+
+namespace agg
+{
+
+ //---------------------------------------------------------------------
+ void line_profile_aa::width(double w)
+ {
+ if(w < 0.0) w = 0.0;
+
+ if(w < m_smoother_width) w += w;
+ else w += m_smoother_width;
+
+ w *= 0.5;
+
+ w -= m_smoother_width;
+ double s = m_smoother_width;
+ if(w < 0.0)
+ {
+ s += w;
+ w = 0.0;
+ }
+ set(w, s);
+ }
+
+
+ //---------------------------------------------------------------------
+ line_profile_aa::value_type* line_profile_aa::profile(double w)
+ {
+ m_subpixel_width = uround(w * subpixel_scale);
+ unsigned size = m_subpixel_width + subpixel_scale * 6;
+ if(size > m_profile.size())
+ {
+ m_profile.resize(size);
+ }
+ return &m_profile[0];
+ }
+
+
+ //---------------------------------------------------------------------
+ void line_profile_aa::set(double center_width, double smoother_width)
+ {
+ double base_val = 1.0;
+ if(center_width == 0.0) center_width = 1.0 / subpixel_scale;
+ if(smoother_width == 0.0) smoother_width = 1.0 / subpixel_scale;
+
+ double width = center_width + smoother_width;
+ if(width < m_min_width)
+ {
+ double k = width / m_min_width;
+ base_val *= k;
+ center_width /= k;
+ smoother_width /= k;
+ }
+
+ value_type* ch = profile(center_width + smoother_width);
+
+ unsigned subpixel_center_width = unsigned(center_width * subpixel_scale);
+ unsigned subpixel_smoother_width = unsigned(smoother_width * subpixel_scale);
+
+ value_type* ch_center = ch + subpixel_scale*2;
+ value_type* ch_smoother = ch_center + subpixel_center_width;
+
+ unsigned i;
+
+ unsigned val = m_gamma[unsigned(base_val * aa_mask)];
+ ch = ch_center;
+ for(i = 0; i < subpixel_center_width; i++)
+ {
+ *ch++ = (value_type)val;
+ }
+
+ for(i = 0; i < subpixel_smoother_width; i++)
+ {
+ *ch_smoother++ =
+ m_gamma[unsigned((base_val -
+ base_val *
+ (double(i) / subpixel_smoother_width)) * aa_mask)];
+ }
+
+ unsigned n_smoother = profile_size() -
+ subpixel_smoother_width -
+ subpixel_center_width -
+ subpixel_scale*2;
+
+ val = m_gamma[0];
+ for(i = 0; i < n_smoother; i++)
+ {
+ *ch_smoother++ = (value_type)val;
+ }
+
+ ch = ch_center;
+ for(i = 0; i < subpixel_scale*2; i++)
+ {
+ *--ch = *ch_center++;
+ }
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_rounded_rect.cpp b/plugins/Clist_ng/AGG/src/agg_rounded_rect.cpp new file mode 100644 index 0000000000..a480043a3d --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_rounded_rect.cpp @@ -0,0 +1,169 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_rounded_rect.h"
+
+
+namespace agg
+{
+ //------------------------------------------------------------------------
+ rounded_rect::rounded_rect(double x1, double y1, double x2, double y2, double r) :
+ m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2),
+ m_rx1(r), m_ry1(r), m_rx2(r), m_ry2(r),
+ m_rx3(r), m_ry3(r), m_rx4(r), m_ry4(r)
+ {
+ if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
+ if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::rect(double x1, double y1, double x2, double y2)
+ {
+ m_x1 = x1;
+ m_y1 = y1;
+ m_x2 = x2;
+ m_y2 = y2;
+ if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
+ if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::radius(double r)
+ {
+ m_rx1 = m_ry1 = m_rx2 = m_ry2 = m_rx3 = m_ry3 = m_rx4 = m_ry4 = r;
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::radius(double rx, double ry)
+ {
+ m_rx1 = m_rx2 = m_rx3 = m_rx4 = rx;
+ m_ry1 = m_ry2 = m_ry3 = m_ry4 = ry;
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::radius(double rx_bottom, double ry_bottom,
+ double rx_top, double ry_top)
+ {
+ m_rx1 = m_rx2 = rx_bottom;
+ m_rx3 = m_rx4 = rx_top;
+ m_ry1 = m_ry2 = ry_bottom;
+ m_ry3 = m_ry4 = ry_top;
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::radius(double rx1, double ry1, double rx2, double ry2,
+ double rx3, double ry3, double rx4, double ry4)
+ {
+ m_rx1 = rx1; m_ry1 = ry1; m_rx2 = rx2; m_ry2 = ry2;
+ m_rx3 = rx3; m_ry3 = ry3; m_rx4 = rx4; m_ry4 = ry4;
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::normalize_radius()
+ {
+ double dx = fabs(m_x2 - m_x1);
+ double dy = fabs(m_y2 - m_y1);
+
+ double k = 1.0;
+ double t;
+ t = dx / (m_rx1 + m_rx2); if(t < k) k = t;
+ t = dx / (m_rx3 + m_rx4); if(t < k) k = t;
+ t = dy / (m_ry1 + m_ry2); if(t < k) k = t;
+ t = dy / (m_ry3 + m_ry4); if(t < k) k = t;
+
+ if(k < 1.0)
+ {
+ m_rx1 *= k; m_ry1 *= k; m_rx2 *= k; m_ry2 *= k;
+ m_rx3 *= k; m_ry3 *= k; m_rx4 *= k; m_ry4 *= k;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void rounded_rect::rewind(unsigned)
+ {
+ m_status = 0;
+ }
+
+ //--------------------------------------------------------------------
+ unsigned rounded_rect::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_stop;
+ switch(m_status)
+ {
+ case 0:
+ m_arc.init(m_x1 + m_rx1, m_y1 + m_ry1, m_rx1, m_ry1,
+ pi, pi+pi*0.5);
+ m_arc.rewind(0);
+ m_status++;
+
+ case 1:
+ cmd = m_arc.vertex(x, y);
+ if(is_stop(cmd)) m_status++;
+ else return cmd;
+
+ case 2:
+ m_arc.init(m_x2 - m_rx2, m_y1 + m_ry2, m_rx2, m_ry2,
+ pi+pi*0.5, 0.0);
+ m_arc.rewind(0);
+ m_status++;
+
+ case 3:
+ cmd = m_arc.vertex(x, y);
+ if(is_stop(cmd)) m_status++;
+ else return path_cmd_line_to;
+
+ case 4:
+ m_arc.init(m_x2 - m_rx3, m_y2 - m_ry3, m_rx3, m_ry3,
+ 0.0, pi*0.5);
+ m_arc.rewind(0);
+ m_status++;
+
+ case 5:
+ cmd = m_arc.vertex(x, y);
+ if(is_stop(cmd)) m_status++;
+ else return path_cmd_line_to;
+
+ case 6:
+ m_arc.init(m_x1 + m_rx4, m_y2 - m_ry4, m_rx4, m_ry4,
+ pi*0.5, pi);
+ m_arc.rewind(0);
+ m_status++;
+
+ case 7:
+ cmd = m_arc.vertex(x, y);
+ if(is_stop(cmd)) m_status++;
+ else return path_cmd_line_to;
+
+ case 8:
+ cmd = path_cmd_end_poly | path_flags_close | path_flags_ccw;
+ m_status++;
+ break;
+ }
+ return cmd;
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_sqrt_tables.cpp b/plugins/Clist_ng/AGG/src/agg_sqrt_tables.cpp new file mode 100644 index 0000000000..52c311c5f9 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_sqrt_tables.cpp @@ -0,0 +1,120 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_basics.h"
+
+namespace agg
+{
+ int16u g_sqrt_table[1024] = //----------g_sqrt_table
+ {
+ 0,
+ 2048,2896,3547,4096,4579,5017,5418,5793,6144,6476,6792,7094,7384,7663,7932,8192,8444,
+ 8689,8927,9159,9385,9606,9822,10033,10240,10443,10642,10837,11029,11217,11403,11585,
+ 11765,11942,12116,12288,12457,12625,12790,12953,13114,13273,13430,13585,13738,13890,
+ 14040,14189,14336,14482,14626,14768,14910,15050,15188,15326,15462,15597,15731,15864,
+ 15995,16126,16255,16384,16512,16638,16764,16888,17012,17135,17257,17378,17498,17618,
+ 17736,17854,17971,18087,18203,18318,18432,18545,18658,18770,18882,18992,19102,19212,
+ 19321,19429,19537,19644,19750,19856,19961,20066,20170,20274,20377,20480,20582,20684,
+ 20785,20886,20986,21085,21185,21283,21382,21480,21577,21674,21771,21867,21962,22058,
+ 22153,22247,22341,22435,22528,22621,22713,22806,22897,22989,23080,23170,23261,23351,
+ 23440,23530,23619,23707,23796,23884,23971,24059,24146,24232,24319,24405,24491,24576,
+ 24661,24746,24831,24915,24999,25083,25166,25249,25332,25415,25497,25580,25661,25743,
+ 25824,25905,25986,26067,26147,26227,26307,26387,26466,26545,26624,26703,26781,26859,
+ 26937,27015,27092,27170,27247,27324,27400,27477,27553,27629,27705,27780,27856,27931,
+ 28006,28081,28155,28230,28304,28378,28452,28525,28599,28672,28745,28818,28891,28963,
+ 29035,29108,29180,29251,29323,29394,29466,29537,29608,29678,29749,29819,29890,29960,
+ 30030,30099,30169,30238,30308,30377,30446,30515,30583,30652,30720,30788,30856,30924,
+ 30992,31059,31127,31194,31261,31328,31395,31462,31529,31595,31661,31727,31794,31859,
+ 31925,31991,32056,32122,32187,32252,32317,32382,32446,32511,32575,32640,32704,32768,
+ 32832,32896,32959,33023,33086,33150,33213,33276,33339,33402,33465,33527,33590,33652,
+ 33714,33776,33839,33900,33962,34024,34086,34147,34208,34270,34331,34392,34453,34514,
+ 34574,34635,34695,34756,34816,34876,34936,34996,35056,35116,35176,35235,35295,35354,
+ 35413,35472,35531,35590,35649,35708,35767,35825,35884,35942,36001,36059,36117,36175,
+ 36233,36291,36348,36406,36464,36521,36578,36636,36693,36750,36807,36864,36921,36978,
+ 37034,37091,37147,37204,37260,37316,37372,37429,37485,37540,37596,37652,37708,37763,
+ 37819,37874,37929,37985,38040,38095,38150,38205,38260,38315,38369,38424,38478,38533,
+ 38587,38642,38696,38750,38804,38858,38912,38966,39020,39073,39127,39181,39234,39287,
+ 39341,39394,39447,39500,39553,39606,39659,39712,39765,39818,39870,39923,39975,40028,
+ 40080,40132,40185,40237,40289,40341,40393,40445,40497,40548,40600,40652,40703,40755,
+ 40806,40857,40909,40960,41011,41062,41113,41164,41215,41266,41317,41368,41418,41469,
+ 41519,41570,41620,41671,41721,41771,41821,41871,41922,41972,42021,42071,42121,42171,
+ 42221,42270,42320,42369,42419,42468,42518,42567,42616,42665,42714,42763,42813,42861,
+ 42910,42959,43008,43057,43105,43154,43203,43251,43300,43348,43396,43445,43493,43541,
+ 43589,43637,43685,43733,43781,43829,43877,43925,43972,44020,44068,44115,44163,44210,
+ 44258,44305,44352,44400,44447,44494,44541,44588,44635,44682,44729,44776,44823,44869,
+ 44916,44963,45009,45056,45103,45149,45195,45242,45288,45334,45381,45427,45473,45519,
+ 45565,45611,45657,45703,45749,45795,45840,45886,45932,45977,46023,46069,46114,46160,
+ 46205,46250,46296,46341,46386,46431,46477,46522,46567,46612,46657,46702,46746,46791,
+ 46836,46881,46926,46970,47015,47059,47104,47149,47193,47237,47282,47326,47370,47415,
+ 47459,47503,47547,47591,47635,47679,47723,47767,47811,47855,47899,47942,47986,48030,
+ 48074,48117,48161,48204,48248,48291,48335,48378,48421,48465,48508,48551,48594,48637,
+ 48680,48723,48766,48809,48852,48895,48938,48981,49024,49067,49109,49152,49195,49237,
+ 49280,49322,49365,49407,49450,49492,49535,49577,49619,49661,49704,49746,49788,49830,
+ 49872,49914,49956,49998,50040,50082,50124,50166,50207,50249,50291,50332,50374,50416,
+ 50457,50499,50540,50582,50623,50665,50706,50747,50789,50830,50871,50912,50954,50995,
+ 51036,51077,51118,51159,51200,51241,51282,51323,51364,51404,51445,51486,51527,51567,
+ 51608,51649,51689,51730,51770,51811,51851,51892,51932,51972,52013,52053,52093,52134,
+ 52174,52214,52254,52294,52334,52374,52414,52454,52494,52534,52574,52614,52654,52694,
+ 52734,52773,52813,52853,52892,52932,52972,53011,53051,53090,53130,53169,53209,53248,
+ 53287,53327,53366,53405,53445,53484,53523,53562,53601,53640,53679,53719,53758,53797,
+ 53836,53874,53913,53952,53991,54030,54069,54108,54146,54185,54224,54262,54301,54340,
+ 54378,54417,54455,54494,54532,54571,54609,54647,54686,54724,54762,54801,54839,54877,
+ 54915,54954,54992,55030,55068,55106,55144,55182,55220,55258,55296,55334,55372,55410,
+ 55447,55485,55523,55561,55599,55636,55674,55712,55749,55787,55824,55862,55900,55937,
+ 55975,56012,56049,56087,56124,56162,56199,56236,56273,56311,56348,56385,56422,56459,
+ 56497,56534,56571,56608,56645,56682,56719,56756,56793,56830,56867,56903,56940,56977,
+ 57014,57051,57087,57124,57161,57198,57234,57271,57307,57344,57381,57417,57454,57490,
+ 57527,57563,57599,57636,57672,57709,57745,57781,57817,57854,57890,57926,57962,57999,
+ 58035,58071,58107,58143,58179,58215,58251,58287,58323,58359,58395,58431,58467,58503,
+ 58538,58574,58610,58646,58682,58717,58753,58789,58824,58860,58896,58931,58967,59002,
+ 59038,59073,59109,59144,59180,59215,59251,59286,59321,59357,59392,59427,59463,59498,
+ 59533,59568,59603,59639,59674,59709,59744,59779,59814,59849,59884,59919,59954,59989,
+ 60024,60059,60094,60129,60164,60199,60233,60268,60303,60338,60373,60407,60442,60477,
+ 60511,60546,60581,60615,60650,60684,60719,60753,60788,60822,60857,60891,60926,60960,
+ 60995,61029,61063,61098,61132,61166,61201,61235,61269,61303,61338,61372,61406,61440,
+ 61474,61508,61542,61576,61610,61644,61678,61712,61746,61780,61814,61848,61882,61916,
+ 61950,61984,62018,62051,62085,62119,62153,62186,62220,62254,62287,62321,62355,62388,
+ 62422,62456,62489,62523,62556,62590,62623,62657,62690,62724,62757,62790,62824,62857,
+ 62891,62924,62957,62991,63024,63057,63090,63124,63157,63190,63223,63256,63289,63323,
+ 63356,63389,63422,63455,63488,63521,63554,63587,63620,63653,63686,63719,63752,63785,
+ 63817,63850,63883,63916,63949,63982,64014,64047,64080,64113,64145,64178,64211,64243,
+ 64276,64309,64341,64374,64406,64439,64471,64504,64536,64569,64601,64634,64666,64699,
+ 64731,64763,64796,64828,64861,64893,64925,64957,64990,65022,65054,65086,65119,65151,
+ 65183,65215,65247,65279,65312,65344,65376,65408,65440,65472,65504
+ };
+
+
+ int8 g_elder_bit_table[256] = //---------g_elder_bit_table
+ {
+ 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
+ };
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_trans_affine.cpp b/plugins/Clist_ng/AGG/src/agg_trans_affine.cpp new file mode 100644 index 0000000000..489c056cce --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_trans_affine.cpp @@ -0,0 +1,200 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_trans_affine.h"
+
+
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::parl_to_parl(const double* src,
+ const double* dst)
+ {
+ sx = src[2] - src[0];
+ shy = src[3] - src[1];
+ shx = src[4] - src[0];
+ sy = src[5] - src[1];
+ tx = src[0];
+ ty = src[1];
+ invert();
+ multiply(trans_affine(dst[2] - dst[0], dst[3] - dst[1],
+ dst[4] - dst[0], dst[5] - dst[1],
+ dst[0], dst[1]));
+ return *this;
+ }
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::rect_to_parl(double x1, double y1,
+ double x2, double y2,
+ const double* parl)
+ {
+ double src[6];
+ src[0] = x1; src[1] = y1;
+ src[2] = x2; src[3] = y1;
+ src[4] = x2; src[5] = y2;
+ parl_to_parl(src, parl);
+ return *this;
+ }
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::parl_to_rect(const double* parl,
+ double x1, double y1,
+ double x2, double y2)
+ {
+ double dst[6];
+ dst[0] = x1; dst[1] = y1;
+ dst[2] = x2; dst[3] = y1;
+ dst[4] = x2; dst[5] = y2;
+ parl_to_parl(parl, dst);
+ return *this;
+ }
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::multiply(const trans_affine& m)
+ {
+ double t0 = sx * m.sx + shy * m.shx;
+ double t2 = shx * m.sx + sy * m.shx;
+ double t4 = tx * m.sx + ty * m.shx + m.tx;
+ shy = sx * m.shy + shy * m.sy;
+ sy = shx * m.shy + sy * m.sy;
+ ty = tx * m.shy + ty * m.sy + m.ty;
+ sx = t0;
+ shx = t2;
+ tx = t4;
+ return *this;
+ }
+
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::invert()
+ {
+ double d = determinant_reciprocal();
+
+ double t0 = sy * d;
+ sy = sx * d;
+ shy = -shy * d;
+ shx = -shx * d;
+
+ double t4 = -tx * t0 - ty * shx;
+ ty = -tx * shy - ty * sy;
+
+ sx = t0;
+ tx = t4;
+ return *this;
+ }
+
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::flip_x()
+ {
+ sx = -sx;
+ shy = -shy;
+ tx = -tx;
+ return *this;
+ }
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::flip_y()
+ {
+ shx = -shx;
+ sy = -sy;
+ ty = -ty;
+ return *this;
+ }
+
+ //------------------------------------------------------------------------
+ const trans_affine& trans_affine::reset()
+ {
+ sx = sy = 1.0;
+ shy = shx = tx = ty = 0.0;
+ return *this;
+ }
+
+ //------------------------------------------------------------------------
+ bool trans_affine::is_identity(double epsilon) const
+ {
+ return is_equal_eps(sx, 1.0, epsilon) &&
+ is_equal_eps(shy, 0.0, epsilon) &&
+ is_equal_eps(shx, 0.0, epsilon) &&
+ is_equal_eps(sy, 1.0, epsilon) &&
+ is_equal_eps(tx, 0.0, epsilon) &&
+ is_equal_eps(ty, 0.0, epsilon);
+ }
+
+ //------------------------------------------------------------------------
+ bool trans_affine::is_valid(double epsilon) const
+ {
+ return fabs(sx) > epsilon && fabs(sy) > epsilon;
+ }
+
+ //------------------------------------------------------------------------
+ bool trans_affine::is_equal(const trans_affine& m, double epsilon) const
+ {
+ return is_equal_eps(sx, m.sx, epsilon) &&
+ is_equal_eps(shy, m.shy, epsilon) &&
+ is_equal_eps(shx, m.shx, epsilon) &&
+ is_equal_eps(sy, m.sy, epsilon) &&
+ is_equal_eps(tx, m.tx, epsilon) &&
+ is_equal_eps(ty, m.ty, epsilon);
+ }
+
+ //------------------------------------------------------------------------
+ double trans_affine::rotation() const
+ {
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double x2 = 1.0;
+ double y2 = 0.0;
+ transform(&x1, &y1);
+ transform(&x2, &y2);
+ return atan2(y2-y1, x2-x1);
+ }
+
+ //------------------------------------------------------------------------
+ void trans_affine::translation(double* dx, double* dy) const
+ {
+ *dx = tx;
+ *dy = ty;
+ }
+
+ //------------------------------------------------------------------------
+ void trans_affine::scaling(double* x, double* y) const
+ {
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double x2 = 1.0;
+ double y2 = 1.0;
+ trans_affine t(*this);
+ t *= trans_affine_rotation(-rotation());
+ t.transform(&x1, &y1);
+ t.transform(&x2, &y2);
+ *x = x2 - x1;
+ *y = y2 - y1;
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_trans_double_path.cpp b/plugins/Clist_ng/AGG/src/agg_trans_double_path.cpp new file mode 100644 index 0000000000..fc3d184e5b --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_trans_double_path.cpp @@ -0,0 +1,282 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_math.h"
+#include "agg_trans_double_path.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ trans_double_path::trans_double_path() :
+ m_kindex1(0.0),
+ m_kindex2(0.0),
+ m_base_length(0.0),
+ m_base_height(1.0),
+ m_status1(initial),
+ m_status2(initial),
+ m_preserve_x_scale(true)
+ {
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::reset()
+ {
+ m_src_vertices1.remove_all();
+ m_src_vertices2.remove_all();
+ m_kindex1 = 0.0;
+ m_kindex1 = 0.0;
+ m_status1 = initial;
+ m_status2 = initial;
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::move_to1(double x, double y)
+ {
+ if(m_status1 == initial)
+ {
+ m_src_vertices1.modify_last(vertex_dist(x, y));
+ m_status1 = making_path;
+ }
+ else
+ {
+ line_to1(x, y);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::line_to1(double x, double y)
+ {
+ if(m_status1 == making_path)
+ {
+ m_src_vertices1.add(vertex_dist(x, y));
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::move_to2(double x, double y)
+ {
+ if(m_status2 == initial)
+ {
+ m_src_vertices2.modify_last(vertex_dist(x, y));
+ m_status2 = making_path;
+ }
+ else
+ {
+ line_to2(x, y);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::line_to2(double x, double y)
+ {
+ if(m_status2 == making_path)
+ {
+ m_src_vertices2.add(vertex_dist(x, y));
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ double trans_double_path::finalize_path(vertex_storage& vertices)
+ {
+ unsigned i;
+ double dist;
+ double d;
+
+ vertices.close(false);
+ if(vertices.size() > 2)
+ {
+ if(vertices[vertices.size() - 2].dist * 10.0 <
+ vertices[vertices.size() - 3].dist)
+ {
+ d = vertices[vertices.size() - 3].dist +
+ vertices[vertices.size() - 2].dist;
+
+ vertices[vertices.size() - 2] =
+ vertices[vertices.size() - 1];
+
+ vertices.remove_last();
+ vertices[vertices.size() - 2].dist = d;
+ }
+ }
+
+ dist = 0;
+ for(i = 0; i < vertices.size(); i++)
+ {
+ vertex_dist& v = vertices[i];
+ d = v.dist;
+ v.dist = dist;
+ dist += d;
+ }
+
+ return (vertices.size() - 1) / dist;
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::finalize_paths()
+ {
+ if(m_status1 == making_path && m_src_vertices1.size() > 1 &&
+ m_status2 == making_path && m_src_vertices2.size() > 1)
+ {
+ m_kindex1 = finalize_path(m_src_vertices1);
+ m_kindex2 = finalize_path(m_src_vertices2);
+ m_status1 = ready;
+ m_status2 = ready;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ double trans_double_path::total_length1() const
+ {
+ if(m_base_length >= 1e-10) return m_base_length;
+ return (m_status1 == ready) ?
+ m_src_vertices1[m_src_vertices1.size() - 1].dist :
+ 0.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ double trans_double_path::total_length2() const
+ {
+ if(m_base_length >= 1e-10) return m_base_length;
+ return (m_status2 == ready) ?
+ m_src_vertices2[m_src_vertices2.size() - 1].dist :
+ 0.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::transform1(const vertex_storage& vertices,
+ double kindex, double kx,
+ double *x, double* y) const
+ {
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double dx = 1.0;
+ double dy = 1.0;
+ double d = 0.0;
+ double dd = 1.0;
+ *x *= kx;
+ if(*x < 0.0)
+ {
+ // Extrapolation on the left
+ //--------------------------
+ x1 = vertices[0].x;
+ y1 = vertices[0].y;
+ dx = vertices[1].x - x1;
+ dy = vertices[1].y - y1;
+ dd = vertices[1].dist - vertices[0].dist;
+ d = *x;
+ }
+ else
+ if(*x > vertices[vertices.size() - 1].dist)
+ {
+ // Extrapolation on the right
+ //--------------------------
+ unsigned i = vertices.size() - 2;
+ unsigned j = vertices.size() - 1;
+ x1 = vertices[j].x;
+ y1 = vertices[j].y;
+ dx = x1 - vertices[i].x;
+ dy = y1 - vertices[i].y;
+ dd = vertices[j].dist - vertices[i].dist;
+ d = *x - vertices[j].dist;
+ }
+ else
+ {
+ // Interpolation
+ //--------------------------
+ unsigned i = 0;
+ unsigned j = vertices.size() - 1;
+ if(m_preserve_x_scale)
+ {
+ unsigned k;
+ for(i = 0; (j - i) > 1; )
+ {
+ if(*x < vertices[k = (i + j) >> 1].dist)
+ {
+ j = k;
+ }
+ else
+ {
+ i = k;
+ }
+ }
+ d = vertices[i].dist;
+ dd = vertices[j].dist - d;
+ d = *x - d;
+ }
+ else
+ {
+ i = unsigned(*x * kindex);
+ j = i + 1;
+ dd = vertices[j].dist - vertices[i].dist;
+ d = ((*x * kindex) - i) * dd;
+ }
+ x1 = vertices[i].x;
+ y1 = vertices[i].y;
+ dx = vertices[j].x - x1;
+ dy = vertices[j].y - y1;
+ }
+ *x = x1 + dx * d / dd;
+ *y = y1 + dy * d / dd;
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_double_path::transform(double *x, double *y) const
+ {
+ if(m_status1 == ready && m_status2 == ready)
+ {
+ if(m_base_length > 1e-10)
+ {
+ *x *= m_src_vertices1[m_src_vertices1.size() - 1].dist /
+ m_base_length;
+ }
+
+ double x1 = *x;
+ double y1 = *y;
+ double x2 = *x;
+ double y2 = *y;
+ double dd = m_src_vertices2[m_src_vertices2.size() - 1].dist /
+ m_src_vertices1[m_src_vertices1.size() - 1].dist;
+
+ transform1(m_src_vertices1, m_kindex1, 1.0, &x1, &y1);
+ transform1(m_src_vertices2, m_kindex2, dd, &x2, &y2);
+
+ *x = x1 + *y * (x2 - x1) / m_base_height;
+ *y = y1 + *y * (y2 - y1) / m_base_height;
+ }
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_trans_single_path.cpp b/plugins/Clist_ng/AGG/src/agg_trans_single_path.cpp new file mode 100644 index 0000000000..368ab883a0 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_trans_single_path.cpp @@ -0,0 +1,211 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_math.h"
+#include "agg_vertex_sequence.h"
+#include "agg_trans_single_path.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ trans_single_path::trans_single_path() :
+ m_base_length(0.0),
+ m_kindex(0.0),
+ m_status(initial),
+ m_preserve_x_scale(true)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void trans_single_path::reset()
+ {
+ m_src_vertices.remove_all();
+ m_kindex = 0.0;
+ m_status = initial;
+ }
+
+ //------------------------------------------------------------------------
+ void trans_single_path::move_to(double x, double y)
+ {
+ if(m_status == initial)
+ {
+ m_src_vertices.modify_last(vertex_dist(x, y));
+ m_status = making_path;
+ }
+ else
+ {
+ line_to(x, y);
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void trans_single_path::line_to(double x, double y)
+ {
+ if(m_status == making_path)
+ {
+ m_src_vertices.add(vertex_dist(x, y));
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_single_path::finalize_path()
+ {
+ if(m_status == making_path && m_src_vertices.size() > 1)
+ {
+ unsigned i;
+ double dist;
+ double d;
+
+ m_src_vertices.close(false);
+ if(m_src_vertices.size() > 2)
+ {
+ if(m_src_vertices[m_src_vertices.size() - 2].dist * 10.0 <
+ m_src_vertices[m_src_vertices.size() - 3].dist)
+ {
+ d = m_src_vertices[m_src_vertices.size() - 3].dist +
+ m_src_vertices[m_src_vertices.size() - 2].dist;
+
+ m_src_vertices[m_src_vertices.size() - 2] =
+ m_src_vertices[m_src_vertices.size() - 1];
+
+ m_src_vertices.remove_last();
+ m_src_vertices[m_src_vertices.size() - 2].dist = d;
+ }
+ }
+
+ dist = 0.0;
+ for(i = 0; i < m_src_vertices.size(); i++)
+ {
+ vertex_dist& v = m_src_vertices[i];
+ double d = v.dist;
+ v.dist = dist;
+ dist += d;
+ }
+ m_kindex = (m_src_vertices.size() - 1) / dist;
+ m_status = ready;
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ double trans_single_path::total_length() const
+ {
+ if(m_base_length >= 1e-10) return m_base_length;
+ return (m_status == ready) ?
+ m_src_vertices[m_src_vertices.size() - 1].dist :
+ 0.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void trans_single_path::transform(double *x, double *y) const
+ {
+ if(m_status == ready)
+ {
+ if(m_base_length > 1e-10)
+ {
+ *x *= m_src_vertices[m_src_vertices.size() - 1].dist /
+ m_base_length;
+ }
+
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double dx = 1.0;
+ double dy = 1.0;
+ double d = 0.0;
+ double dd = 1.0;
+ if(*x < 0.0)
+ {
+ // Extrapolation on the left
+ //--------------------------
+ x1 = m_src_vertices[0].x;
+ y1 = m_src_vertices[0].y;
+ dx = m_src_vertices[1].x - x1;
+ dy = m_src_vertices[1].y - y1;
+ dd = m_src_vertices[1].dist - m_src_vertices[0].dist;
+ d = *x;
+ }
+ else
+ if(*x > m_src_vertices[m_src_vertices.size() - 1].dist)
+ {
+ // Extrapolation on the right
+ //--------------------------
+ unsigned i = m_src_vertices.size() - 2;
+ unsigned j = m_src_vertices.size() - 1;
+ x1 = m_src_vertices[j].x;
+ y1 = m_src_vertices[j].y;
+ dx = x1 - m_src_vertices[i].x;
+ dy = y1 - m_src_vertices[i].y;
+ dd = m_src_vertices[j].dist - m_src_vertices[i].dist;
+ d = *x - m_src_vertices[j].dist;
+ }
+ else
+ {
+ // Interpolation
+ //--------------------------
+ unsigned i = 0;
+ unsigned j = m_src_vertices.size() - 1;
+ if(m_preserve_x_scale)
+ {
+ unsigned k;
+ for(i = 0; (j - i) > 1; )
+ {
+ if(*x < m_src_vertices[k = (i + j) >> 1].dist)
+ {
+ j = k;
+ }
+ else
+ {
+ i = k;
+ }
+ }
+ d = m_src_vertices[i].dist;
+ dd = m_src_vertices[j].dist - d;
+ d = *x - d;
+ }
+ else
+ {
+ i = unsigned(*x * m_kindex);
+ j = i + 1;
+ dd = m_src_vertices[j].dist - m_src_vertices[i].dist;
+ d = ((*x * m_kindex) - i) * dd;
+ }
+ x1 = m_src_vertices[i].x;
+ y1 = m_src_vertices[i].y;
+ dx = m_src_vertices[j].x - x1;
+ dy = m_src_vertices[j].y - y1;
+ }
+ double x2 = x1 + dx * d / dd;
+ double y2 = y1 + dy * d / dd;
+ *x = x2 - *y * dy / dd;
+ *y = y2 + *y * dx / dd;
+ }
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_trans_warp_magnifier.cpp b/plugins/Clist_ng/AGG/src/agg_trans_warp_magnifier.cpp new file mode 100644 index 0000000000..0854d06ce7 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_trans_warp_magnifier.cpp @@ -0,0 +1,79 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_trans_warp_magnifier.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ void trans_warp_magnifier::transform(double* x, double* y) const
+ {
+ double dx = *x - m_xc;
+ double dy = *y - m_yc;
+ double r = sqrt(dx * dx + dy * dy);
+ if(r < m_radius)
+ {
+ *x = m_xc + dx * m_magn;
+ *y = m_yc + dy * m_magn;
+ return;
+ }
+
+ double m = (r + m_radius * (m_magn - 1.0)) / r;
+ *x = m_xc + dx * m;
+ *y = m_yc + dy * m;
+ }
+
+ //------------------------------------------------------------------------
+ void trans_warp_magnifier::inverse_transform(double* x, double* y) const
+ {
+ // New version by Andrew Skalkin
+ //-----------------
+ double dx = *x - m_xc;
+ double dy = *y - m_yc;
+ double r = sqrt(dx * dx + dy * dy);
+
+ if(r < m_radius * m_magn)
+ {
+ *x = m_xc + dx / m_magn;
+ *y = m_yc + dy / m_magn;
+ }
+ else
+ {
+ double rnew = r - m_radius * (m_magn - 1.0);
+ *x = m_xc + rnew * dx / r;
+ *y = m_yc + rnew * dy / r;
+ }
+
+ // Old version
+ //-----------------
+ //trans_warp_magnifier t(*this);
+ //t.magnification(1.0 / m_magn);
+ //t.radius(m_radius * m_magn);
+ //t.transform(x, y);
+ }
+
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_vcgen_bspline.cpp b/plugins/Clist_ng/AGG/src/agg_vcgen_bspline.cpp new file mode 100644 index 0000000000..4483f612ee --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vcgen_bspline.cpp @@ -0,0 +1,203 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_vcgen_bspline.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ vcgen_bspline::vcgen_bspline() :
+ m_src_vertices(),
+ m_spline_x(),
+ m_spline_y(),
+ m_interpolation_step(1.0/50.0),
+ m_closed(0),
+ m_status(initial),
+ m_src_vertex(0)
+ {
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_bspline::remove_all()
+ {
+ m_src_vertices.remove_all();
+ m_closed = 0;
+ m_status = initial;
+ m_src_vertex = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_bspline::add_vertex(double x, double y, unsigned cmd)
+ {
+ m_status = initial;
+ if(is_move_to(cmd))
+ {
+ m_src_vertices.modify_last(point_d(x, y));
+ }
+ else
+ {
+ if(is_vertex(cmd))
+ {
+ m_src_vertices.add(point_d(x, y));
+ }
+ else
+ {
+ m_closed = get_close_flag(cmd);
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_bspline::rewind(unsigned)
+ {
+ m_cur_abscissa = 0.0;
+ m_max_abscissa = 0.0;
+ m_src_vertex = 0;
+ if(m_status == initial && m_src_vertices.size() > 2)
+ {
+ if(m_closed)
+ {
+ m_spline_x.init(m_src_vertices.size() + 8);
+ m_spline_y.init(m_src_vertices.size() + 8);
+ m_spline_x.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).x);
+ m_spline_y.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).y);
+ m_spline_x.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].x);
+ m_spline_y.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].y);
+ m_spline_x.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].x);
+ m_spline_y.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].y);
+ m_spline_x.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].x);
+ m_spline_y.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].y);
+ }
+ else
+ {
+ m_spline_x.init(m_src_vertices.size());
+ m_spline_y.init(m_src_vertices.size());
+ }
+ unsigned i;
+ for(i = 0; i < m_src_vertices.size(); i++)
+ {
+ double x = m_closed ? i + 4 : i;
+ m_spline_x.add_point(x, m_src_vertices[i].x);
+ m_spline_y.add_point(x, m_src_vertices[i].y);
+ }
+ m_cur_abscissa = 0.0;
+ m_max_abscissa = m_src_vertices.size() - 1;
+ if(m_closed)
+ {
+ m_cur_abscissa = 4.0;
+ m_max_abscissa += 5.0;
+ m_spline_x.add_point(m_src_vertices.size() + 4, m_src_vertices[0].x);
+ m_spline_y.add_point(m_src_vertices.size() + 4, m_src_vertices[0].y);
+ m_spline_x.add_point(m_src_vertices.size() + 5, m_src_vertices[1].x);
+ m_spline_y.add_point(m_src_vertices.size() + 5, m_src_vertices[1].y);
+ m_spline_x.add_point(m_src_vertices.size() + 6, m_src_vertices[2].x);
+ m_spline_y.add_point(m_src_vertices.size() + 6, m_src_vertices[2].y);
+ m_spline_x.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).x);
+ m_spline_y.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).y);
+ }
+ m_spline_x.prepare();
+ m_spline_y.prepare();
+ }
+ m_status = ready;
+ }
+
+
+
+
+
+
+ //------------------------------------------------------------------------
+ unsigned vcgen_bspline::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ while(!is_stop(cmd))
+ {
+ switch(m_status)
+ {
+ case initial:
+ rewind(0);
+
+ case ready:
+ if(m_src_vertices.size() < 2)
+ {
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(m_src_vertices.size() == 2)
+ {
+ *x = m_src_vertices[m_src_vertex].x;
+ *y = m_src_vertices[m_src_vertex].y;
+ m_src_vertex++;
+ if(m_src_vertex == 1) return path_cmd_move_to;
+ if(m_src_vertex == 2) return path_cmd_line_to;
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ cmd = path_cmd_move_to;
+ m_status = polygon;
+ m_src_vertex = 0;
+
+ case polygon:
+ if(m_cur_abscissa >= m_max_abscissa)
+ {
+ if(m_closed)
+ {
+ m_status = end_poly;
+ break;
+ }
+ else
+ {
+ *x = m_src_vertices[m_src_vertices.size() - 1].x;
+ *y = m_src_vertices[m_src_vertices.size() - 1].y;
+ m_status = end_poly;
+ return path_cmd_line_to;
+ }
+ }
+
+ *x = m_spline_x.get_stateful(m_cur_abscissa);
+ *y = m_spline_y.get_stateful(m_cur_abscissa);
+ m_src_vertex++;
+ m_cur_abscissa += m_interpolation_step;
+ return (m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
+
+ case end_poly:
+ m_status = stop;
+ return path_cmd_end_poly | m_closed;
+
+ case stop:
+ return path_cmd_stop;
+ }
+ }
+ return cmd;
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_vcgen_contour.cpp b/plugins/Clist_ng/AGG/src/agg_vcgen_contour.cpp new file mode 100644 index 0000000000..02c8b73ff8 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vcgen_contour.cpp @@ -0,0 +1,170 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_vcgen_contour.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ vcgen_contour::vcgen_contour() :
+ m_stroker(),
+ m_width(1),
+ m_src_vertices(),
+ m_out_vertices(),
+ m_status(initial),
+ m_src_vertex(0),
+ m_closed(0),
+ m_orientation(0),
+ m_auto_detect(false)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void vcgen_contour::remove_all()
+ {
+ m_src_vertices.remove_all();
+ m_closed = 0;
+ m_orientation = 0;
+ m_status = initial;
+ }
+
+ //------------------------------------------------------------------------
+ void vcgen_contour::add_vertex(double x, double y, unsigned cmd)
+ {
+ m_status = initial;
+ if(is_move_to(cmd))
+ {
+ m_src_vertices.modify_last(vertex_dist(x, y));
+ }
+ else
+ {
+ if(is_vertex(cmd))
+ {
+ m_src_vertices.add(vertex_dist(x, y));
+ }
+ else
+ {
+ if(is_end_poly(cmd))
+ {
+ m_closed = get_close_flag(cmd);
+ if(m_orientation == path_flags_none)
+ {
+ m_orientation = get_orientation(cmd);
+ }
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void vcgen_contour::rewind(unsigned)
+ {
+ if(m_status == initial)
+ {
+ m_src_vertices.close(true);
+ if(m_auto_detect)
+ {
+ if(!is_oriented(m_orientation))
+ {
+ m_orientation = (calc_polygon_area(m_src_vertices) > 0.0) ?
+ path_flags_ccw :
+ path_flags_cw;
+ }
+ }
+ if(is_oriented(m_orientation))
+ {
+ m_stroker.width(is_ccw(m_orientation) ? m_width : -m_width);
+ }
+ }
+ m_status = ready;
+ m_src_vertex = 0;
+ }
+
+ //------------------------------------------------------------------------
+ unsigned vcgen_contour::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ while(!is_stop(cmd))
+ {
+ switch(m_status)
+ {
+ case initial:
+ rewind(0);
+
+ case ready:
+ if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
+ {
+ cmd = path_cmd_stop;
+ break;
+ }
+ m_status = outline;
+ cmd = path_cmd_move_to;
+ m_src_vertex = 0;
+ m_out_vertex = 0;
+
+ case outline:
+ if(m_src_vertex >= m_src_vertices.size())
+ {
+ m_status = end_poly;
+ break;
+ }
+ m_stroker.calc_join(m_out_vertices,
+ m_src_vertices.prev(m_src_vertex),
+ m_src_vertices.curr(m_src_vertex),
+ m_src_vertices.next(m_src_vertex),
+ m_src_vertices.prev(m_src_vertex).dist,
+ m_src_vertices.curr(m_src_vertex).dist);
+ ++m_src_vertex;
+ m_status = out_vertices;
+ m_out_vertex = 0;
+
+ case out_vertices:
+ if(m_out_vertex >= m_out_vertices.size())
+ {
+ m_status = outline;
+ }
+ else
+ {
+ const point_d& c = m_out_vertices[m_out_vertex++];
+ *x = c.x;
+ *y = c.y;
+ return cmd;
+ }
+ break;
+
+ case end_poly:
+ if(!m_closed) return path_cmd_stop;
+ m_status = stop;
+ return path_cmd_end_poly | path_flags_close | path_flags_ccw;
+
+ case stop:
+ return path_cmd_stop;
+ }
+ }
+ return cmd;
+ }
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_vcgen_dash.cpp b/plugins/Clist_ng/AGG/src/agg_vcgen_dash.cpp new file mode 100644 index 0000000000..60d2f9ac98 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vcgen_dash.cpp @@ -0,0 +1,240 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_vcgen_dash.h"
+#include "agg_shorten_path.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ vcgen_dash::vcgen_dash() :
+ m_total_dash_len(0.0),
+ m_num_dashes(0),
+ m_dash_start(0.0),
+ m_shorten(0.0),
+ m_curr_dash_start(0.0),
+ m_curr_dash(0),
+ m_src_vertices(),
+ m_closed(0),
+ m_status(initial),
+ m_src_vertex(0)
+ {
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::remove_all_dashes()
+ {
+ m_total_dash_len = 0.0;
+ m_num_dashes = 0;
+ m_curr_dash_start = 0.0;
+ m_curr_dash = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::add_dash(double dash_len, double gap_len)
+ {
+ if(m_num_dashes < max_dashes)
+ {
+ m_total_dash_len += dash_len + gap_len;
+ m_dashes[m_num_dashes++] = dash_len;
+ m_dashes[m_num_dashes++] = gap_len;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::dash_start(double ds)
+ {
+ m_dash_start = ds;
+ calc_dash_start(fabs(ds));
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::calc_dash_start(double ds)
+ {
+ m_curr_dash = 0;
+ m_curr_dash_start = 0.0;
+ while(ds > 0.0)
+ {
+ if(ds > m_dashes[m_curr_dash])
+ {
+ ds -= m_dashes[m_curr_dash];
+ ++m_curr_dash;
+ m_curr_dash_start = 0.0;
+ if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
+ }
+ else
+ {
+ m_curr_dash_start = ds;
+ ds = 0.0;
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::remove_all()
+ {
+ m_status = initial;
+ m_src_vertices.remove_all();
+ m_closed = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::add_vertex(double x, double y, unsigned cmd)
+ {
+ m_status = initial;
+ if(is_move_to(cmd))
+ {
+ m_src_vertices.modify_last(vertex_dist(x, y));
+ }
+ else
+ {
+ if(is_vertex(cmd))
+ {
+ m_src_vertices.add(vertex_dist(x, y));
+ }
+ else
+ {
+ m_closed = get_close_flag(cmd);
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_dash::rewind(unsigned)
+ {
+ if(m_status == initial)
+ {
+ m_src_vertices.close(m_closed != 0);
+ shorten_path(m_src_vertices, m_shorten, m_closed);
+ }
+ m_status = ready;
+ m_src_vertex = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned vcgen_dash::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_move_to;
+ while(!is_stop(cmd))
+ {
+ switch(m_status)
+ {
+ case initial:
+ rewind(0);
+
+ case ready:
+ if(m_num_dashes < 2 || m_src_vertices.size() < 2)
+ {
+ cmd = path_cmd_stop;
+ break;
+ }
+ m_status = polyline;
+ m_src_vertex = 1;
+ m_v1 = &m_src_vertices[0];
+ m_v2 = &m_src_vertices[1];
+ m_curr_rest = m_v1->dist;
+ *x = m_v1->x;
+ *y = m_v1->y;
+ if(m_dash_start >= 0.0) calc_dash_start(m_dash_start);
+ return path_cmd_move_to;
+
+ case polyline:
+ {
+ double dash_rest = m_dashes[m_curr_dash] - m_curr_dash_start;
+
+ unsigned cmd = (m_curr_dash & 1) ?
+ path_cmd_move_to :
+ path_cmd_line_to;
+
+ if(m_curr_rest > dash_rest)
+ {
+ m_curr_rest -= dash_rest;
+ ++m_curr_dash;
+ if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
+ m_curr_dash_start = 0.0;
+ *x = m_v2->x - (m_v2->x - m_v1->x) * m_curr_rest / m_v1->dist;
+ *y = m_v2->y - (m_v2->y - m_v1->y) * m_curr_rest / m_v1->dist;
+ }
+ else
+ {
+ m_curr_dash_start += m_curr_rest;
+ *x = m_v2->x;
+ *y = m_v2->y;
+ ++m_src_vertex;
+ m_v1 = m_v2;
+ m_curr_rest = m_v1->dist;
+ if(m_closed)
+ {
+ if(m_src_vertex > m_src_vertices.size())
+ {
+ m_status = stop;
+ }
+ else
+ {
+ m_v2 = &m_src_vertices
+ [
+ (m_src_vertex >= m_src_vertices.size()) ? 0 :
+ m_src_vertex
+ ];
+ }
+ }
+ else
+ {
+ if(m_src_vertex >= m_src_vertices.size())
+ {
+ m_status = stop;
+ }
+ else
+ {
+ m_v2 = &m_src_vertices[m_src_vertex];
+ }
+ }
+ }
+ return cmd;
+ }
+ break;
+
+ case stop:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ }
+ return path_cmd_stop;
+ }
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_vcgen_markers_term.cpp b/plugins/Clist_ng/AGG/src/agg_vcgen_markers_term.cpp new file mode 100644 index 0000000000..5863691f69 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vcgen_markers_term.cpp @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_vcgen_markers_term.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ void vcgen_markers_term::remove_all()
+ {
+ m_markers.remove_all();
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_markers_term::add_vertex(double x, double y, unsigned cmd)
+ {
+ if(is_move_to(cmd))
+ {
+ if(m_markers.size() & 1)
+ {
+ // Initial state, the first coordinate was added.
+ // If two of more calls of start_vertex() occures
+ // we just modify the last one.
+ m_markers.modify_last(coord_type(x, y));
+ }
+ else
+ {
+ m_markers.add(coord_type(x, y));
+ }
+ }
+ else
+ {
+ if(is_vertex(cmd))
+ {
+ if(m_markers.size() & 1)
+ {
+ // Initial state, the first coordinate was added.
+ // Add three more points, 0,1,1,0
+ m_markers.add(coord_type(x, y));
+ m_markers.add(m_markers[m_markers.size() - 1]);
+ m_markers.add(m_markers[m_markers.size() - 3]);
+ }
+ else
+ {
+ if(m_markers.size())
+ {
+ // Replace two last points: 0,1,1,0 -> 0,1,2,1
+ m_markers[m_markers.size() - 1] = m_markers[m_markers.size() - 2];
+ m_markers[m_markers.size() - 2] = coord_type(x, y);
+ }
+ }
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_markers_term::rewind(unsigned path_id)
+ {
+ m_curr_id = path_id * 2;
+ m_curr_idx = m_curr_id;
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned vcgen_markers_term::vertex(double* x, double* y)
+ {
+ if(m_curr_id > 2 || m_curr_idx >= m_markers.size())
+ {
+ return path_cmd_stop;
+ }
+ const coord_type& c = m_markers[m_curr_idx];
+ *x = c.x;
+ *y = c.y;
+ if(m_curr_idx & 1)
+ {
+ m_curr_idx += 3;
+ return path_cmd_line_to;
+ }
+ ++m_curr_idx;
+ return path_cmd_move_to;
+ }
+
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_vcgen_smooth_poly1.cpp b/plugins/Clist_ng/AGG/src/agg_vcgen_smooth_poly1.cpp new file mode 100644 index 0000000000..359768aa78 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vcgen_smooth_poly1.cpp @@ -0,0 +1,230 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_vcgen_smooth_poly1.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ vcgen_smooth_poly1::vcgen_smooth_poly1() :
+ m_src_vertices(),
+ m_smooth_value(0.5),
+ m_closed(0),
+ m_status(initial),
+ m_src_vertex(0)
+ {
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_smooth_poly1::remove_all()
+ {
+ m_src_vertices.remove_all();
+ m_closed = 0;
+ m_status = initial;
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_smooth_poly1::add_vertex(double x, double y, unsigned cmd)
+ {
+ m_status = initial;
+ if(is_move_to(cmd))
+ {
+ m_src_vertices.modify_last(vertex_dist(x, y));
+ }
+ else
+ {
+ if(is_vertex(cmd))
+ {
+ m_src_vertices.add(vertex_dist(x, y));
+ }
+ else
+ {
+ m_closed = get_close_flag(cmd);
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_smooth_poly1::rewind(unsigned)
+ {
+ if(m_status == initial)
+ {
+ m_src_vertices.close(m_closed != 0);
+ }
+ m_status = ready;
+ m_src_vertex = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_smooth_poly1::calculate(const vertex_dist& v0,
+ const vertex_dist& v1,
+ const vertex_dist& v2,
+ const vertex_dist& v3)
+ {
+
+ double k1 = v0.dist / (v0.dist + v1.dist);
+ double k2 = v1.dist / (v1.dist + v2.dist);
+
+ double xm1 = v0.x + (v2.x - v0.x) * k1;
+ double ym1 = v0.y + (v2.y - v0.y) * k1;
+ double xm2 = v1.x + (v3.x - v1.x) * k2;
+ double ym2 = v1.y + (v3.y - v1.y) * k2;
+
+ m_ctrl1_x = v1.x + m_smooth_value * (v2.x - xm1);
+ m_ctrl1_y = v1.y + m_smooth_value * (v2.y - ym1);
+ m_ctrl2_x = v2.x + m_smooth_value * (v1.x - xm2);
+ m_ctrl2_y = v2.y + m_smooth_value * (v1.y - ym2);
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned vcgen_smooth_poly1::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ while(!is_stop(cmd))
+ {
+ switch(m_status)
+ {
+ case initial:
+ rewind(0);
+
+ case ready:
+ if(m_src_vertices.size() < 2)
+ {
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(m_src_vertices.size() == 2)
+ {
+ *x = m_src_vertices[m_src_vertex].x;
+ *y = m_src_vertices[m_src_vertex].y;
+ m_src_vertex++;
+ if(m_src_vertex == 1) return path_cmd_move_to;
+ if(m_src_vertex == 2) return path_cmd_line_to;
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ cmd = path_cmd_move_to;
+ m_status = polygon;
+ m_src_vertex = 0;
+
+ case polygon:
+ if(m_closed)
+ {
+ if(m_src_vertex >= m_src_vertices.size())
+ {
+ *x = m_src_vertices[0].x;
+ *y = m_src_vertices[0].y;
+ m_status = end_poly;
+ return path_cmd_curve4;
+ }
+ }
+ else
+ {
+ if(m_src_vertex >= m_src_vertices.size() - 1)
+ {
+ *x = m_src_vertices[m_src_vertices.size() - 1].x;
+ *y = m_src_vertices[m_src_vertices.size() - 1].y;
+ m_status = end_poly;
+ return path_cmd_curve3;
+ }
+ }
+
+ calculate(m_src_vertices.prev(m_src_vertex),
+ m_src_vertices.curr(m_src_vertex),
+ m_src_vertices.next(m_src_vertex),
+ m_src_vertices.next(m_src_vertex + 1));
+
+ *x = m_src_vertices[m_src_vertex].x;
+ *y = m_src_vertices[m_src_vertex].y;
+ m_src_vertex++;
+
+ if(m_closed)
+ {
+ m_status = ctrl1;
+ return ((m_src_vertex == 1) ?
+ path_cmd_move_to :
+ path_cmd_curve4);
+ }
+ else
+ {
+ if(m_src_vertex == 1)
+ {
+ m_status = ctrl_b;
+ return path_cmd_move_to;
+ }
+ if(m_src_vertex >= m_src_vertices.size() - 1)
+ {
+ m_status = ctrl_e;
+ return path_cmd_curve3;
+ }
+ m_status = ctrl1;
+ return path_cmd_curve4;
+ }
+ break;
+
+ case ctrl_b:
+ *x = m_ctrl2_x;
+ *y = m_ctrl2_y;
+ m_status = polygon;
+ return path_cmd_curve3;
+
+ case ctrl_e:
+ *x = m_ctrl1_x;
+ *y = m_ctrl1_y;
+ m_status = polygon;
+ return path_cmd_curve3;
+
+ case ctrl1:
+ *x = m_ctrl1_x;
+ *y = m_ctrl1_y;
+ m_status = ctrl2;
+ return path_cmd_curve4;
+
+ case ctrl2:
+ *x = m_ctrl2_x;
+ *y = m_ctrl2_y;
+ m_status = polygon;
+ return path_cmd_curve4;
+
+ case end_poly:
+ m_status = stop;
+ return path_cmd_end_poly | m_closed;
+
+ case stop:
+ return path_cmd_stop;
+ }
+ }
+ return cmd;
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/agg_vcgen_stroke.cpp b/plugins/Clist_ng/AGG/src/agg_vcgen_stroke.cpp new file mode 100644 index 0000000000..b36927bf31 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vcgen_stroke.cpp @@ -0,0 +1,219 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_vcgen_stroke.h"
+#include "agg_shorten_path.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ vcgen_stroke::vcgen_stroke() :
+ m_stroker(),
+ m_src_vertices(),
+ m_out_vertices(),
+ m_shorten(0.0),
+ m_closed(0),
+ m_status(initial),
+ m_src_vertex(0),
+ m_out_vertex(0)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void vcgen_stroke::remove_all()
+ {
+ m_src_vertices.remove_all();
+ m_closed = 0;
+ m_status = initial;
+ }
+
+
+ //------------------------------------------------------------------------
+ void vcgen_stroke::add_vertex(double x, double y, unsigned cmd)
+ {
+ m_status = initial;
+ if(is_move_to(cmd))
+ {
+ m_src_vertices.modify_last(vertex_dist(x, y));
+ }
+ else
+ {
+ if(is_vertex(cmd))
+ {
+ m_src_vertices.add(vertex_dist(x, y));
+ }
+ else
+ {
+ m_closed = get_close_flag(cmd);
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void vcgen_stroke::rewind(unsigned)
+ {
+ if(m_status == initial)
+ {
+ m_src_vertices.close(m_closed != 0);
+ shorten_path(m_src_vertices, m_shorten, m_closed);
+ if(m_src_vertices.size() < 3) m_closed = 0;
+ }
+ m_status = ready;
+ m_src_vertex = 0;
+ m_out_vertex = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned vcgen_stroke::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ while(!is_stop(cmd))
+ {
+ switch(m_status)
+ {
+ case initial:
+ rewind(0);
+
+ case ready:
+ if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
+ {
+ cmd = path_cmd_stop;
+ break;
+ }
+ m_status = m_closed ? outline1 : cap1;
+ cmd = path_cmd_move_to;
+ m_src_vertex = 0;
+ m_out_vertex = 0;
+ break;
+
+ case cap1:
+ m_stroker.calc_cap(m_out_vertices,
+ m_src_vertices[0],
+ m_src_vertices[1],
+ m_src_vertices[0].dist);
+ m_src_vertex = 1;
+ m_prev_status = outline1;
+ m_status = out_vertices;
+ m_out_vertex = 0;
+ break;
+
+ case cap2:
+ m_stroker.calc_cap(m_out_vertices,
+ m_src_vertices[m_src_vertices.size() - 1],
+ m_src_vertices[m_src_vertices.size() - 2],
+ m_src_vertices[m_src_vertices.size() - 2].dist);
+ m_prev_status = outline2;
+ m_status = out_vertices;
+ m_out_vertex = 0;
+ break;
+
+ case outline1:
+ if(m_closed)
+ {
+ if(m_src_vertex >= m_src_vertices.size())
+ {
+ m_prev_status = close_first;
+ m_status = end_poly1;
+ break;
+ }
+ }
+ else
+ {
+ if(m_src_vertex >= m_src_vertices.size() - 1)
+ {
+ m_status = cap2;
+ break;
+ }
+ }
+ m_stroker.calc_join(m_out_vertices,
+ m_src_vertices.prev(m_src_vertex),
+ m_src_vertices.curr(m_src_vertex),
+ m_src_vertices.next(m_src_vertex),
+ m_src_vertices.prev(m_src_vertex).dist,
+ m_src_vertices.curr(m_src_vertex).dist);
+ ++m_src_vertex;
+ m_prev_status = m_status;
+ m_status = out_vertices;
+ m_out_vertex = 0;
+ break;
+
+ case close_first:
+ m_status = outline2;
+ cmd = path_cmd_move_to;
+
+ case outline2:
+ if(m_src_vertex <= unsigned(m_closed == 0))
+ {
+ m_status = end_poly2;
+ m_prev_status = stop;
+ break;
+ }
+
+ --m_src_vertex;
+ m_stroker.calc_join(m_out_vertices,
+ m_src_vertices.next(m_src_vertex),
+ m_src_vertices.curr(m_src_vertex),
+ m_src_vertices.prev(m_src_vertex),
+ m_src_vertices.curr(m_src_vertex).dist,
+ m_src_vertices.prev(m_src_vertex).dist);
+
+ m_prev_status = m_status;
+ m_status = out_vertices;
+ m_out_vertex = 0;
+ break;
+
+ case out_vertices:
+ if(m_out_vertex >= m_out_vertices.size())
+ {
+ m_status = m_prev_status;
+ }
+ else
+ {
+ const point_d& c = m_out_vertices[m_out_vertex++];
+ *x = c.x;
+ *y = c.y;
+ return cmd;
+ }
+ break;
+
+ case end_poly1:
+ m_status = m_prev_status;
+ return path_cmd_end_poly | path_flags_close | path_flags_ccw;
+
+ case end_poly2:
+ m_status = m_prev_status;
+ return path_cmd_end_poly | path_flags_close | path_flags_cw;
+
+ case stop:
+ cmd = path_cmd_stop;
+ break;
+ }
+ }
+ return cmd;
+ }
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_vpgen_clip_polygon.cpp b/plugins/Clist_ng/AGG/src/agg_vpgen_clip_polygon.cpp new file mode 100644 index 0000000000..2e9502ce06 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vpgen_clip_polygon.cpp @@ -0,0 +1,142 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_vpgen_clip_polygon.h"
+#include "agg_clip_liang_barsky.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ // Determine the clipping code of the vertex according to the
+ // Cyrus-Beck line clipping algorithm
+ //
+ // | |
+ // 0110 | 0010 | 0011
+ // | |
+ // -------+--------+-------- clip_box.y2
+ // | |
+ // 0100 | 0000 | 0001
+ // | |
+ // -------+--------+-------- clip_box.y1
+ // | |
+ // 1100 | 1000 | 1001
+ // | |
+ // clip_box.x1 clip_box.x2
+ //
+ //
+ unsigned vpgen_clip_polygon::clipping_flags(double x, double y)
+ {
+ if(x < m_clip_box.x1)
+ {
+ if(y > m_clip_box.y2) return 6;
+ if(y < m_clip_box.y1) return 12;
+ return 4;
+ }
+
+ if(x > m_clip_box.x2)
+ {
+ if(y > m_clip_box.y2) return 3;
+ if(y < m_clip_box.y1) return 9;
+ return 1;
+ }
+
+ if(y > m_clip_box.y2) return 2;
+ if(y < m_clip_box.y1) return 8;
+
+ return 0;
+ }
+
+ //----------------------------------------------------------------------------
+ void vpgen_clip_polygon::reset()
+ {
+ m_vertex = 0;
+ m_num_vertices = 0;
+ }
+
+ //----------------------------------------------------------------------------
+ void vpgen_clip_polygon::move_to(double x, double y)
+ {
+ m_vertex = 0;
+ m_num_vertices = 0;
+ m_clip_flags = clipping_flags(x, y);
+ if(m_clip_flags == 0)
+ {
+ m_x[0] = x;
+ m_y[0] = y;
+ m_num_vertices = 1;
+ }
+ m_x1 = x;
+ m_y1 = y;
+ m_cmd = path_cmd_move_to;
+ }
+
+
+ //----------------------------------------------------------------------------
+ void vpgen_clip_polygon::line_to(double x, double y)
+ {
+ m_vertex = 0;
+ m_num_vertices = 0;
+ unsigned flags = clipping_flags(x, y);
+
+ if(m_clip_flags == flags)
+ {
+ if(flags == 0)
+ {
+ m_x[0] = x;
+ m_y[0] = y;
+ m_num_vertices = 1;
+ }
+ }
+ else
+ {
+ m_num_vertices = clip_liang_barsky(m_x1, m_y1,
+ x, y,
+ m_clip_box,
+ m_x, m_y);
+ }
+
+ m_clip_flags = flags;
+ m_x1 = x;
+ m_y1 = y;
+ }
+
+
+ //----------------------------------------------------------------------------
+ unsigned vpgen_clip_polygon::vertex(double* x, double* y)
+ {
+ if(m_vertex < m_num_vertices)
+ {
+ *x = m_x[m_vertex];
+ *y = m_y[m_vertex];
+ ++m_vertex;
+ unsigned cmd = m_cmd;
+ m_cmd = path_cmd_line_to;
+ return cmd;
+ }
+ return path_cmd_stop;
+ }
+
+
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_vpgen_clip_polyline.cpp b/plugins/Clist_ng/AGG/src/agg_vpgen_clip_polyline.cpp new file mode 100644 index 0000000000..9b2f726807 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vpgen_clip_polyline.cpp @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "agg_vpgen_clip_polyline.h"
+#include "agg_clip_liang_barsky.h"
+
+namespace agg
+{
+ //----------------------------------------------------------------------------
+ void vpgen_clip_polyline::reset()
+ {
+ m_vertex = 0;
+ m_num_vertices = 0;
+ m_move_to = false;
+ }
+
+ //----------------------------------------------------------------------------
+ void vpgen_clip_polyline::move_to(double x, double y)
+ {
+ m_vertex = 0;
+ m_num_vertices = 0;
+ m_x1 = x;
+ m_y1 = y;
+ m_move_to = true;
+ }
+
+ //----------------------------------------------------------------------------
+ void vpgen_clip_polyline::line_to(double x, double y)
+ {
+ double x2 = x;
+ double y2 = y;
+ unsigned flags = clip_line_segment(&m_x1, &m_y1, &x2, &y2, m_clip_box);
+
+ m_vertex = 0;
+ m_num_vertices = 0;
+ if((flags & 4) == 0)
+ {
+ if((flags & 1) != 0 || m_move_to)
+ {
+ m_x[0] = m_x1;
+ m_y[0] = m_y1;
+ m_cmd[0] = path_cmd_move_to;
+ m_num_vertices = 1;
+ }
+ m_x[m_num_vertices] = x2;
+ m_y[m_num_vertices] = y2;
+ m_cmd[m_num_vertices++] = path_cmd_line_to;
+ m_move_to = (flags & 2) != 0;
+ }
+ m_x1 = x;
+ m_y1 = y;
+ }
+
+ //----------------------------------------------------------------------------
+ unsigned vpgen_clip_polyline::vertex(double* x, double* y)
+ {
+ if(m_vertex < m_num_vertices)
+ {
+ *x = m_x[m_vertex];
+ *y = m_y[m_vertex];
+ return m_cmd[m_vertex++];
+ }
+ return path_cmd_stop;
+ }
+}
diff --git a/plugins/Clist_ng/AGG/src/agg_vpgen_segmentator.cpp b/plugins/Clist_ng/AGG/src/agg_vpgen_segmentator.cpp new file mode 100644 index 0000000000..eb5df3f34a --- /dev/null +++ b/plugins/Clist_ng/AGG/src/agg_vpgen_segmentator.cpp @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <math.h>
+#include "agg_vpgen_segmentator.h"
+
+namespace agg
+{
+
+ void vpgen_segmentator::move_to(double x, double y)
+ {
+ m_x1 = x;
+ m_y1 = y;
+ m_dx = 0.0;
+ m_dy = 0.0;
+ m_dl = 2.0;
+ m_ddl = 2.0;
+ m_cmd = path_cmd_move_to;
+ }
+
+ void vpgen_segmentator::line_to(double x, double y)
+ {
+ m_x1 += m_dx;
+ m_y1 += m_dy;
+ m_dx = x - m_x1;
+ m_dy = y - m_y1;
+ double len = sqrt(m_dx * m_dx + m_dy * m_dy) * m_approximation_scale;
+ if(len < 1e-30) len = 1e-30;
+ m_ddl = 1.0 / len;
+ m_dl = (m_cmd == path_cmd_move_to) ? 0.0 : m_ddl;
+ if(m_cmd == path_cmd_stop) m_cmd = path_cmd_line_to;
+ }
+
+ unsigned vpgen_segmentator::vertex(double* x, double* y)
+ {
+ if(m_cmd == path_cmd_stop) return path_cmd_stop;
+
+ unsigned cmd = m_cmd;
+ m_cmd = path_cmd_line_to;
+ if(m_dl >= 1.0 - m_ddl)
+ {
+ m_dl = 1.0;
+ m_cmd = path_cmd_stop;
+ *x = m_x1 + m_dx;
+ *y = m_y1 + m_dy;
+ return cmd;
+ }
+ *x = m_x1 + m_dx * m_dl;
+ *y = m_y1 + m_dy * m_dl;
+ m_dl += m_ddl;
+ return cmd;
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/authors b/plugins/Clist_ng/AGG/src/authors new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/authors diff --git a/plugins/Clist_ng/AGG/src/autogen.sh b/plugins/Clist_ng/AGG/src/autogen.sh new file mode 100644 index 0000000000..d37d8e2b9f --- /dev/null +++ b/plugins/Clist_ng/AGG/src/autogen.sh @@ -0,0 +1,20 @@ +# autogen.sh
+#
+# invoke the auto* tools to create the configureation system
+
+# build aclocal.m4
+aclocal
+
+# build the configure script
+autoconf
+
+# set up libtool
+libtoolize --force
+
+# invoke automake
+automake --foreign --add-missing
+
+# and finally invoke our new configure
+./configure $*
+
+# end
diff --git a/plugins/Clist_ng/AGG/src/configure.in b/plugins/Clist_ng/AGG/src/configure.in new file mode 100644 index 0000000000..fe58b42909 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/configure.in @@ -0,0 +1,15 @@ +AC_INIT(src/agg_arc.cpp) # give me a source file, any source file...
+AM_INIT_AUTOMAKE(agg, 2.0.0)
+
+AC_PROG_LN_S
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+
+AC_OUTPUT(
+ Makefile
+ gpc/Makefile
+ src/Makefile
+ src/ctrl/Makefile
+)
diff --git a/plugins/Clist_ng/AGG/src/copying b/plugins/Clist_ng/AGG/src/copying new file mode 100644 index 0000000000..a88fd34d76 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/copying @@ -0,0 +1,21 @@ +Anti-Grain Geometry (AGG) - Version 2.5
+A high quality rendering engine for C++
+Copyright (C) 2002-2006 Maxim Shemanarev
+Contact: mcseem@antigrain.com
+ mcseemagg@yahoo.com
+ http://antigrain.com
+
+AGG is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+AGG is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with AGG; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+MA 02110-1301, USA.
diff --git a/plugins/Clist_ng/AGG/src/ctrl/Makefile.am b/plugins/Clist_ng/AGG/src/ctrl/Makefile.am new file mode 100644 index 0000000000..2930b9dd5e --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/Makefile.am @@ -0,0 +1,11 @@ +if ENABLE_CTRL
+INCLUDES = -I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = libaggctrl.la
+
+libaggctrl_la_LDFLAGS = -no-undefined -version-info @AGG_LIB_VERSION@
+libaggctrl_la_SOURCES = agg_cbox_ctrl.cpp agg_gamma_ctrl.cpp agg_gamma_spline.cpp agg_rbox_ctrl.cpp \
+ agg_slider_ctrl.cpp agg_spline_ctrl.cpp agg_scale_ctrl.cpp \
+ agg_bezier_ctrl.cpp agg_polygon_ctrl.cpp
+
+endif
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_bezier_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_bezier_ctrl.cpp new file mode 100644 index 0000000000..ff278bd49a --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_bezier_ctrl.cpp @@ -0,0 +1,375 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <string.h>
+#include <stdio.h>
+#include "ctrl/agg_bezier_ctrl.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ bezier_ctrl_impl::bezier_ctrl_impl() :
+ ctrl(0,0,1,1,false),
+ m_stroke(m_curve),
+ m_poly(4, 5.0),
+ m_idx(0)
+ {
+ m_poly.in_polygon_check(false);
+ m_poly.xn(0) = 100.0;
+ m_poly.yn(0) = 0.0;
+ m_poly.xn(1) = 100.0;
+ m_poly.yn(1) = 50.0;
+ m_poly.xn(2) = 50.0;
+ m_poly.yn(2) = 100.0;
+ m_poly.xn(3) = 0.0;
+ m_poly.yn(3) = 100.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void bezier_ctrl_impl::curve(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ double x4, double y4)
+ {
+ m_poly.xn(0) = x1;
+ m_poly.yn(0) = y1;
+ m_poly.xn(1) = x2;
+ m_poly.yn(1) = y2;
+ m_poly.xn(2) = x3;
+ m_poly.yn(2) = y3;
+ m_poly.xn(3) = x4;
+ m_poly.yn(3) = y4;
+ curve();
+ }
+
+ //------------------------------------------------------------------------
+ curve4& bezier_ctrl_impl::curve()
+ {
+ m_curve.init(m_poly.xn(0), m_poly.yn(0),
+ m_poly.xn(1), m_poly.yn(1),
+ m_poly.xn(2), m_poly.yn(2),
+ m_poly.xn(3), m_poly.yn(3));
+ return m_curve;
+ }
+
+ //------------------------------------------------------------------------
+ void bezier_ctrl_impl::rewind(unsigned idx)
+ {
+ m_idx = idx;
+
+ m_curve.approximation_scale(scale());
+ switch(idx)
+ {
+ default:
+ case 0: // Control line 1
+ m_curve.init(m_poly.xn(0), m_poly.yn(0),
+ (m_poly.xn(0) + m_poly.xn(1)) * 0.5,
+ (m_poly.yn(0) + m_poly.yn(1)) * 0.5,
+ (m_poly.xn(0) + m_poly.xn(1)) * 0.5,
+ (m_poly.yn(0) + m_poly.yn(1)) * 0.5,
+ m_poly.xn(1), m_poly.yn(1));
+ m_stroke.rewind(0);
+ break;
+
+ case 1: // Control line 2
+ m_curve.init(m_poly.xn(2), m_poly.yn(2),
+ (m_poly.xn(2) + m_poly.xn(3)) * 0.5,
+ (m_poly.yn(2) + m_poly.yn(3)) * 0.5,
+ (m_poly.xn(2) + m_poly.xn(3)) * 0.5,
+ (m_poly.yn(2) + m_poly.yn(3)) * 0.5,
+ m_poly.xn(3), m_poly.yn(3));
+ m_stroke.rewind(0);
+ break;
+
+ case 2: // Curve itself
+ m_curve.init(m_poly.xn(0), m_poly.yn(0),
+ m_poly.xn(1), m_poly.yn(1),
+ m_poly.xn(2), m_poly.yn(2),
+ m_poly.xn(3), m_poly.yn(3));
+ m_stroke.rewind(0);
+ break;
+
+ case 3: // Point 1
+ m_ellipse.init(m_poly.xn(0), m_poly.yn(0), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+
+ case 4: // Point 2
+ m_ellipse.init(m_poly.xn(1), m_poly.yn(1), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+
+ case 5: // Point 3
+ m_ellipse.init(m_poly.xn(2), m_poly.yn(2), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+
+ case 6: // Point 4
+ m_ellipse.init(m_poly.xn(3), m_poly.yn(3), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned bezier_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_stop;
+ switch(m_idx)
+ {
+ case 0:
+ case 1:
+ case 2:
+ cmd = m_stroke.vertex(x, y);
+ break;
+
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ cmd = m_ellipse.vertex(x, y);
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+ return cmd;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool bezier_ctrl_impl::in_rect(double x, double y) const
+ {
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool bezier_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+ return m_poly.on_mouse_button_down(x, y);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool bezier_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ inverse_transform_xy(&x, &y);
+ return m_poly.on_mouse_move(x, y, button_flag);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool bezier_ctrl_impl::on_mouse_button_up(double x, double y)
+ {
+ return m_poly.on_mouse_button_up(x, y);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool bezier_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ return m_poly.on_arrow_keys(left, right, down, up);
+ }
+
+
+
+
+
+
+ //------------------------------------------------------------------------
+ curve3_ctrl_impl::curve3_ctrl_impl() :
+ ctrl(0,0,1,1,false),
+ m_stroke(m_curve),
+ m_poly(3, 5.0),
+ m_idx(0)
+ {
+ m_poly.in_polygon_check(false);
+ m_poly.xn(0) = 100.0;
+ m_poly.yn(0) = 0.0;
+ m_poly.xn(1) = 100.0;
+ m_poly.yn(1) = 50.0;
+ m_poly.xn(2) = 50.0;
+ m_poly.yn(2) = 100.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void curve3_ctrl_impl::curve(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3)
+ {
+ m_poly.xn(0) = x1;
+ m_poly.yn(0) = y1;
+ m_poly.xn(1) = x2;
+ m_poly.yn(1) = y2;
+ m_poly.xn(2) = x3;
+ m_poly.yn(2) = y3;
+ curve();
+ }
+
+ //------------------------------------------------------------------------
+ curve3& curve3_ctrl_impl::curve()
+ {
+ m_curve.init(m_poly.xn(0), m_poly.yn(0),
+ m_poly.xn(1), m_poly.yn(1),
+ m_poly.xn(2), m_poly.yn(2));
+ return m_curve;
+ }
+
+ //------------------------------------------------------------------------
+ void curve3_ctrl_impl::rewind(unsigned idx)
+ {
+ m_idx = idx;
+
+ switch(idx)
+ {
+ default:
+ case 0: // Control line
+ m_curve.init(m_poly.xn(0), m_poly.yn(0),
+ (m_poly.xn(0) + m_poly.xn(1)) * 0.5,
+ (m_poly.yn(0) + m_poly.yn(1)) * 0.5,
+ m_poly.xn(1), m_poly.yn(1));
+ m_stroke.rewind(0);
+ break;
+
+ case 1: // Control line 2
+ m_curve.init(m_poly.xn(1), m_poly.yn(1),
+ (m_poly.xn(1) + m_poly.xn(2)) * 0.5,
+ (m_poly.yn(1) + m_poly.yn(2)) * 0.5,
+ m_poly.xn(2), m_poly.yn(2));
+ m_stroke.rewind(0);
+ break;
+
+ case 2: // Curve itself
+ m_curve.init(m_poly.xn(0), m_poly.yn(0),
+ m_poly.xn(1), m_poly.yn(1),
+ m_poly.xn(2), m_poly.yn(2));
+ m_stroke.rewind(0);
+ break;
+
+ case 3: // Point 1
+ m_ellipse.init(m_poly.xn(0), m_poly.yn(0), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+
+ case 4: // Point 2
+ m_ellipse.init(m_poly.xn(1), m_poly.yn(1), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+
+ case 5: // Point 3
+ m_ellipse.init(m_poly.xn(2), m_poly.yn(2), point_radius(), point_radius(), 20);
+ m_ellipse.rewind(0);
+ break;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned curve3_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_stop;
+ switch(m_idx)
+ {
+ case 0:
+ case 1:
+ case 2:
+ cmd = m_stroke.vertex(x, y);
+ break;
+
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ cmd = m_ellipse.vertex(x, y);
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+ return cmd;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool curve3_ctrl_impl::in_rect(double x, double y) const
+ {
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool curve3_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+ return m_poly.on_mouse_button_down(x, y);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool curve3_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ inverse_transform_xy(&x, &y);
+ return m_poly.on_mouse_move(x, y, button_flag);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool curve3_ctrl_impl::on_mouse_button_up(double x, double y)
+ {
+ return m_poly.on_mouse_button_up(x, y);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool curve3_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ return m_poly.on_arrow_keys(left, right, down, up);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_cbox_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_cbox_ctrl.cpp new file mode 100644 index 0000000000..3753475ca6 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_cbox_ctrl.cpp @@ -0,0 +1,219 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <string.h>
+#include "ctrl/agg_cbox_ctrl.h"
+
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ cbox_ctrl_impl::cbox_ctrl_impl(double x, double y,
+ const char* l,
+ bool flip_y) :
+ ctrl(x, y, x + 9.0 * 1.5, y + 9.0 * 1.5, flip_y),
+ m_text_thickness(1.5),
+ m_text_height(9.0),
+ m_text_width(0.0),
+ m_status(false),
+ m_text_poly(m_text)
+ {
+ label(l);
+ }
+
+
+ //------------------------------------------------------------------------
+ void cbox_ctrl_impl::text_size(double h, double w)
+ {
+ m_text_width = w;
+ m_text_height = h;
+ }
+
+ //------------------------------------------------------------------------
+ void cbox_ctrl_impl::label(const char* l)
+ {
+ unsigned len = strlen(l);
+ if(len > 127) len = 127;
+ memcpy(m_label, l, len);
+ m_label[len] = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool cbox_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+ if(x >= m_x1 && y >= m_y1 && x <= m_x2 && y <= m_y2)
+ {
+ m_status = !m_status;
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool cbox_ctrl_impl::on_mouse_move(double, double, bool)
+ {
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ bool cbox_ctrl_impl::in_rect(double x, double y) const
+ {
+ inverse_transform_xy(&x, &y);
+ return x >= m_x1 && y >= m_y1 && x <= m_x2 && y <= m_y2;
+ }
+
+ //------------------------------------------------------------------------
+ bool cbox_ctrl_impl::on_mouse_button_up(double, double)
+ {
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ bool cbox_ctrl_impl::on_arrow_keys(bool, bool, bool, bool)
+ {
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ void cbox_ctrl_impl::rewind(unsigned idx)
+ {
+ m_idx = idx;
+
+ double d2;
+ double t;
+
+ switch(idx)
+ {
+ default:
+ case 0: // Border
+ m_vertex = 0;
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x2;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y2;
+ m_vx[4] = m_x1 + m_text_thickness;
+ m_vy[4] = m_y1 + m_text_thickness;
+ m_vx[5] = m_x1 + m_text_thickness;
+ m_vy[5] = m_y2 - m_text_thickness;
+ m_vx[6] = m_x2 - m_text_thickness;
+ m_vy[6] = m_y2 - m_text_thickness;
+ m_vx[7] = m_x2 - m_text_thickness;
+ m_vy[7] = m_y1 + m_text_thickness;
+ break;
+
+ case 1: // Text
+ m_text.text(m_label);
+ m_text.start_point(m_x1 + m_text_height * 2.0, m_y1 + m_text_height / 5.0);
+ m_text.size(m_text_height, m_text_width);
+ m_text_poly.width(m_text_thickness);
+ m_text_poly.line_join(round_join);
+ m_text_poly.line_cap(round_cap);
+ m_text_poly.rewind(0);
+ break;
+
+ case 2: // Active item
+ m_vertex = 0;
+ d2 = (m_y2 - m_y1) / 2.0;
+ t = m_text_thickness * 1.5;
+ m_vx[0] = m_x1 + m_text_thickness;
+ m_vy[0] = m_y1 + m_text_thickness;
+ m_vx[1] = m_x1 + d2;
+ m_vy[1] = m_y1 + d2 - t;
+ m_vx[2] = m_x2 - m_text_thickness;
+ m_vy[2] = m_y1 + m_text_thickness;
+ m_vx[3] = m_x1 + d2 + t;
+ m_vy[3] = m_y1 + d2;
+ m_vx[4] = m_x2 - m_text_thickness;
+ m_vy[4] = m_y2 - m_text_thickness;
+ m_vx[5] = m_x1 + d2;
+ m_vy[5] = m_y1 + d2 + t;
+ m_vx[6] = m_x1 + m_text_thickness;
+ m_vy[6] = m_y2 - m_text_thickness;
+ m_vx[7] = m_x1 + d2 - t;
+ m_vy[7] = m_y1 + d2;
+ break;
+
+ }
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ unsigned cbox_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ switch(m_idx)
+ {
+ case 0:
+ if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to;
+ if(m_vertex >= 8) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 1:
+ cmd = m_text_poly.vertex(x, y);
+ break;
+
+ case 2:
+ if(m_status)
+ {
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 8) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ }
+ else
+ {
+ cmd = path_cmd_stop;
+ }
+ break;
+
+ default:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+ return cmd;
+ }
+}
+
+
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_gamma_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_gamma_ctrl.cpp new file mode 100644 index 0000000000..9521bab9fd --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_gamma_ctrl.cpp @@ -0,0 +1,438 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <stdio.h>
+#include "agg_math.h"
+#include "ctrl/agg_gamma_ctrl.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ gamma_ctrl_impl::gamma_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y) :
+ ctrl(x1, y1, x2, y2, flip_y),
+ m_border_width(2.0),
+ m_border_extra(0.0),
+ m_curve_width(2.0),
+ m_grid_width(0.2),
+ m_text_thickness(1.5),
+ m_point_size(5.0),
+ m_text_height(9.0),
+ m_text_width(0.0),
+ m_xc1(x1),
+ m_yc1(y1),
+ m_xc2(x2),
+ m_yc2(y2 - m_text_height * 2.0),
+ m_xt1(x1),
+ m_yt1(y2 - m_text_height * 2.0),
+ m_xt2(x2),
+ m_yt2(y2),
+ m_curve_poly(m_gamma_spline),
+ m_text_poly(m_text),
+ m_idx(0),
+ m_vertex(0),
+ m_p1_active(true),
+ m_mouse_point(0),
+ m_pdx(0.0),
+ m_pdy(0.0)
+ {
+ calc_spline_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::calc_spline_box()
+ {
+ m_xs1 = m_xc1 + m_border_width;
+ m_ys1 = m_yc1 + m_border_width;
+ m_xs2 = m_xc2 - m_border_width;
+ m_ys2 = m_yc2 - m_border_width * 0.5;
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::calc_points()
+ {
+ double kx1, ky1, kx2, ky2;
+ m_gamma_spline.values(&kx1, &ky1, &kx2, &ky2);
+ m_xp1 = m_xs1 + (m_xs2 - m_xs1) * kx1 * 0.25;
+ m_yp1 = m_ys1 + (m_ys2 - m_ys1) * ky1 * 0.25;
+ m_xp2 = m_xs2 - (m_xs2 - m_xs1) * kx2 * 0.25;
+ m_yp2 = m_ys2 - (m_ys2 - m_ys1) * ky2 * 0.25;
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::calc_values()
+ {
+ double kx1, ky1, kx2, ky2;
+
+ kx1 = (m_xp1 - m_xs1) * 4.0 / (m_xs2 - m_xs1);
+ ky1 = (m_yp1 - m_ys1) * 4.0 / (m_ys2 - m_ys1);
+ kx2 = (m_xs2 - m_xp2) * 4.0 / (m_xs2 - m_xs1);
+ ky2 = (m_ys2 - m_yp2) * 4.0 / (m_ys2 - m_ys1);
+ m_gamma_spline.values(kx1, ky1, kx2, ky2);
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::text_size(double h, double w)
+ {
+ m_text_width = w;
+ m_text_height = h;
+ m_yc2 = m_y2 - m_text_height * 2.0;
+ m_yt1 = m_y2 - m_text_height * 2.0;
+ calc_spline_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::border_width(double t, double extra)
+ {
+ m_border_width = t;
+ m_border_extra = extra;
+ calc_spline_box();
+ }
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::values(double kx1, double ky1, double kx2, double ky2)
+ {
+ m_gamma_spline.values(kx1, ky1, kx2, ky2);
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::values(double* kx1, double* ky1, double* kx2, double* ky2) const
+ {
+ m_gamma_spline.values(kx1, ky1, kx2, ky2);
+ }
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::rewind(unsigned idx)
+ {
+ double kx1, ky1, kx2, ky2;
+ char tbuf[32];
+
+ m_idx = idx;
+
+ switch(idx)
+ {
+ default:
+
+ case 0: // Background
+ m_vertex = 0;
+ m_vx[0] = m_x1 - m_border_extra;
+ m_vy[0] = m_y1 - m_border_extra;
+ m_vx[1] = m_x2 + m_border_extra;
+ m_vy[1] = m_y1 - m_border_extra;
+ m_vx[2] = m_x2 + m_border_extra;
+ m_vy[2] = m_y2 + m_border_extra;
+ m_vx[3] = m_x1 - m_border_extra;
+ m_vy[3] = m_y2 + m_border_extra;
+ break;
+
+ case 1: // Border
+ m_vertex = 0;
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x2;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y2;
+ m_vx[4] = m_x1 + m_border_width;
+ m_vy[4] = m_y1 + m_border_width;
+ m_vx[5] = m_x1 + m_border_width;
+ m_vy[5] = m_y2 - m_border_width;
+ m_vx[6] = m_x2 - m_border_width;
+ m_vy[6] = m_y2 - m_border_width;
+ m_vx[7] = m_x2 - m_border_width;
+ m_vy[7] = m_y1 + m_border_width;
+ m_vx[8] = m_xc1 + m_border_width;
+ m_vy[8] = m_yc2 - m_border_width * 0.5;
+ m_vx[9] = m_xc2 - m_border_width;
+ m_vy[9] = m_yc2 - m_border_width * 0.5;
+ m_vx[10] = m_xc2 - m_border_width;
+ m_vy[10] = m_yc2 + m_border_width * 0.5;
+ m_vx[11] = m_xc1 + m_border_width;
+ m_vy[11] = m_yc2 + m_border_width * 0.5;
+ break;
+
+ case 2: // Curve
+ m_gamma_spline.box(m_xs1, m_ys1, m_xs2, m_ys2);
+ m_curve_poly.width(m_curve_width);
+ m_curve_poly.rewind(0);
+ break;
+
+ case 3: // Grid
+ m_vertex = 0;
+ m_vx[0] = m_xs1;
+ m_vy[0] = (m_ys1 + m_ys2) * 0.5 - m_grid_width * 0.5;
+ m_vx[1] = m_xs2;
+ m_vy[1] = (m_ys1 + m_ys2) * 0.5 - m_grid_width * 0.5;
+ m_vx[2] = m_xs2;
+ m_vy[2] = (m_ys1 + m_ys2) * 0.5 + m_grid_width * 0.5;
+ m_vx[3] = m_xs1;
+ m_vy[3] = (m_ys1 + m_ys2) * 0.5 + m_grid_width * 0.5;
+ m_vx[4] = (m_xs1 + m_xs2) * 0.5 - m_grid_width * 0.5;
+ m_vy[4] = m_ys1;
+ m_vx[5] = (m_xs1 + m_xs2) * 0.5 - m_grid_width * 0.5;
+ m_vy[5] = m_ys2;
+ m_vx[6] = (m_xs1 + m_xs2) * 0.5 + m_grid_width * 0.5;
+ m_vy[6] = m_ys2;
+ m_vx[7] = (m_xs1 + m_xs2) * 0.5 + m_grid_width * 0.5;
+ m_vy[7] = m_ys1;
+ calc_points();
+ m_vx[8] = m_xs1;
+ m_vy[8] = m_yp1 - m_grid_width * 0.5;
+ m_vx[9] = m_xp1 - m_grid_width * 0.5;
+ m_vy[9] = m_yp1 - m_grid_width * 0.5;
+ m_vx[10] = m_xp1 - m_grid_width * 0.5;
+ m_vy[10] = m_ys1;
+ m_vx[11] = m_xp1 + m_grid_width * 0.5;
+ m_vy[11] = m_ys1;
+ m_vx[12] = m_xp1 + m_grid_width * 0.5;
+ m_vy[12] = m_yp1 + m_grid_width * 0.5;
+ m_vx[13] = m_xs1;
+ m_vy[13] = m_yp1 + m_grid_width * 0.5;
+ m_vx[14] = m_xs2;
+ m_vy[14] = m_yp2 + m_grid_width * 0.5;
+ m_vx[15] = m_xp2 + m_grid_width * 0.5;
+ m_vy[15] = m_yp2 + m_grid_width * 0.5;
+ m_vx[16] = m_xp2 + m_grid_width * 0.5;
+ m_vy[16] = m_ys2;
+ m_vx[17] = m_xp2 - m_grid_width * 0.5;
+ m_vy[17] = m_ys2;
+ m_vx[18] = m_xp2 - m_grid_width * 0.5;
+ m_vy[18] = m_yp2 - m_grid_width * 0.5;
+ m_vx[19] = m_xs2;
+ m_vy[19] = m_yp2 - m_grid_width * 0.5;
+ break;
+
+ case 4: // Point1
+ calc_points();
+ if(m_p1_active) m_ellipse.init(m_xp2, m_yp2, m_point_size, m_point_size, 32);
+ else m_ellipse.init(m_xp1, m_yp1, m_point_size, m_point_size, 32);
+ break;
+
+ case 5: // Point2
+ calc_points();
+ if(m_p1_active) m_ellipse.init(m_xp1, m_yp1, m_point_size, m_point_size, 32);
+ else m_ellipse.init(m_xp2, m_yp2, m_point_size, m_point_size, 32);
+ break;
+
+ case 6: // Text
+ m_gamma_spline.values(&kx1, &ky1, &kx2, &ky2);
+ sprintf(tbuf, "%5.3f %5.3f %5.3f %5.3f", kx1, ky1, kx2, ky2);
+ m_text.text(tbuf);
+ m_text.size(m_text_height, m_text_width);
+ m_text.start_point(m_xt1 + m_border_width * 2.0, (m_yt1 + m_yt2) * 0.5 - m_text_height * 0.5);
+ m_text_poly.width(m_text_thickness);
+ m_text_poly.line_join(round_join);
+ m_text_poly.line_cap(round_cap);
+ m_text_poly.rewind(0);
+ break;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned gamma_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ switch(m_idx)
+ {
+ case 0:
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 4) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 1:
+ if(m_vertex == 0 || m_vertex == 4 || m_vertex == 8) cmd = path_cmd_move_to;
+ if(m_vertex >= 12) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 2:
+ cmd = m_curve_poly.vertex(x, y);
+ break;
+
+ case 3:
+ if(m_vertex == 0 ||
+ m_vertex == 4 ||
+ m_vertex == 8 ||
+ m_vertex == 14) cmd = path_cmd_move_to;
+
+ if(m_vertex >= 20) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 4: // Point1
+ case 5: // Point2
+ cmd = m_ellipse.vertex(x, y);
+ break;
+
+ case 6:
+ cmd = m_text_poly.vertex(x, y);
+ break;
+
+ default:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+
+ return cmd;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool gamma_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ double kx1, ky1, kx2, ky2;
+ bool ret = false;
+ m_gamma_spline.values(&kx1, &ky1, &kx2, &ky2);
+ if(m_p1_active)
+ {
+ if(left) { kx1 -= 0.005; ret = true; }
+ if(right) { kx1 += 0.005; ret = true; }
+ if(down) { ky1 -= 0.005; ret = true; }
+ if(up) { ky1 += 0.005; ret = true; }
+ }
+ else
+ {
+ if(left) { kx2 += 0.005; ret = true; }
+ if(right) { kx2 -= 0.005; ret = true; }
+ if(down) { ky2 += 0.005; ret = true; }
+ if(up) { ky2 -= 0.005; ret = true; }
+ }
+ if(ret)
+ {
+ m_gamma_spline.values(kx1, ky1, kx2, ky2);
+ }
+ return ret;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void gamma_ctrl_impl::change_active_point()
+ {
+ m_p1_active = m_p1_active ? false : true;
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ bool gamma_ctrl_impl::in_rect(double x, double y) const
+ {
+ inverse_transform_xy(&x, &y);
+ return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool gamma_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+ calc_points();
+
+ if(calc_distance(x, y, m_xp1, m_yp1) <= m_point_size + 1)
+ {
+ m_mouse_point = 1;
+ m_pdx = m_xp1 - x;
+ m_pdy = m_yp1 - y;
+ m_p1_active = true;
+ return true;
+ }
+
+ if(calc_distance(x, y, m_xp2, m_yp2) <= m_point_size + 1)
+ {
+ m_mouse_point = 2;
+ m_pdx = m_xp2 - x;
+ m_pdy = m_yp2 - y;
+ m_p1_active = false;
+ return true;
+ }
+
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool gamma_ctrl_impl::on_mouse_button_up(double, double)
+ {
+ if(m_mouse_point)
+ {
+ m_mouse_point = 0;
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool gamma_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ inverse_transform_xy(&x, &y);
+ if(!button_flag)
+ {
+ return on_mouse_button_up(x, y);
+ }
+
+ if(m_mouse_point == 1)
+ {
+ m_xp1 = x + m_pdx;
+ m_yp1 = y + m_pdy;
+ calc_values();
+ return true;
+ }
+ if(m_mouse_point == 2)
+ {
+ m_xp2 = x + m_pdx;
+ m_yp2 = y + m_pdy;
+ calc_values();
+ return true;
+ }
+ return false;
+ }
+
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_gamma_spline.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_gamma_spline.cpp new file mode 100644 index 0000000000..10de9c397e --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_gamma_spline.cpp @@ -0,0 +1,135 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "ctrl/agg_gamma_spline.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ gamma_spline::gamma_spline() :
+ m_x1(0), m_y1(0), m_x2(10), m_y2(10), m_cur_x(0.0)
+ {
+ values(1.0, 1.0, 1.0, 1.0);
+ }
+
+
+ //------------------------------------------------------------------------
+ double gamma_spline::y(double x) const
+ {
+ if(x < 0.0) x = 0.0;
+ if(x > 1.0) x = 1.0;
+ double val = m_spline.get(x);
+ if(val < 0.0) val = 0.0;
+ if(val > 1.0) val = 1.0;
+ return val;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void gamma_spline::values(double kx1, double ky1, double kx2, double ky2)
+ {
+ if(kx1 < 0.001) kx1 = 0.001;
+ if(kx1 > 1.999) kx1 = 1.999;
+ if(ky1 < 0.001) ky1 = 0.001;
+ if(ky1 > 1.999) ky1 = 1.999;
+ if(kx2 < 0.001) kx2 = 0.001;
+ if(kx2 > 1.999) kx2 = 1.999;
+ if(ky2 < 0.001) ky2 = 0.001;
+ if(ky2 > 1.999) ky2 = 1.999;
+
+ m_x[0] = 0.0;
+ m_y[0] = 0.0;
+ m_x[1] = kx1 * 0.25;
+ m_y[1] = ky1 * 0.25;
+ m_x[2] = 1.0 - kx2 * 0.25;
+ m_y[2] = 1.0 - ky2 * 0.25;
+ m_x[3] = 1.0;
+ m_y[3] = 1.0;
+
+ m_spline.init(4, m_x, m_y);
+
+ int i;
+ for(i = 0; i < 256; i++)
+ {
+ m_gamma[i] = (unsigned char)(y(double(i) / 255.0) * 255.0);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_spline::values(double* kx1, double* ky1, double* kx2, double* ky2) const
+ {
+ *kx1 = m_x[1] * 4.0;
+ *ky1 = m_y[1] * 4.0;
+ *kx2 = (1.0 - m_x[2]) * 4.0;
+ *ky2 = (1.0 - m_y[2]) * 4.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_spline::box(double x1, double y1, double x2, double y2)
+ {
+ m_x1 = x1;
+ m_y1 = y1;
+ m_x2 = x2;
+ m_y2 = y2;
+ }
+
+
+ //------------------------------------------------------------------------
+ void gamma_spline::rewind(unsigned)
+ {
+ m_cur_x = 0.0;
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned gamma_spline::vertex(double* vx, double* vy)
+ {
+ if(m_cur_x == 0.0)
+ {
+ *vx = m_x1;
+ *vy = m_y1;
+ m_cur_x += 1.0 / (m_x2 - m_x1);
+ return path_cmd_move_to;
+ }
+
+ if(m_cur_x > 1.0)
+ {
+ return path_cmd_stop;
+ }
+
+ *vx = m_x1 + m_cur_x * (m_x2 - m_x1);
+ *vy = m_y1 + y(m_cur_x) * (m_y2 - m_y1);
+
+ m_cur_x += 1.0 / (m_x2 - m_x1);
+ return path_cmd_line_to;
+ }
+
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_polygon_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_polygon_ctrl.cpp new file mode 100644 index 0000000000..4dde1b7f89 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_polygon_ctrl.cpp @@ -0,0 +1,337 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "ctrl/agg_polygon_ctrl.h"
+
+namespace agg
+{
+
+ polygon_ctrl_impl::polygon_ctrl_impl(unsigned np, double point_radius) :
+ ctrl(0, 0, 1, 1, false),
+ m_polygon(np * 2),
+ m_num_points(np),
+ m_node(-1),
+ m_edge(-1),
+ m_vs(&m_polygon[0], m_num_points, false),
+ m_stroke(m_vs),
+ m_point_radius(point_radius),
+ m_status(0),
+ m_dx(0.0),
+ m_dy(0.0),
+ m_in_polygon_check(true)
+ {
+ m_stroke.width(1.0);
+ }
+
+
+ void polygon_ctrl_impl::rewind(unsigned)
+ {
+ m_status = 0;
+ m_stroke.rewind(0);
+ }
+
+ unsigned polygon_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_stop;
+ double r = m_point_radius;
+ if(m_status == 0)
+ {
+ cmd = m_stroke.vertex(x, y);
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ return cmd;
+ }
+ if(m_node >= 0 && m_node == int(m_status)) r *= 1.2;
+ m_ellipse.init(xn(m_status), yn(m_status), r, r, 32);
+ ++m_status;
+ }
+ cmd = m_ellipse.vertex(x, y);
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ return cmd;
+ }
+ if(m_status >= m_num_points) return path_cmd_stop;
+ if(m_node >= 0 && m_node == int(m_status)) r *= 1.2;
+ m_ellipse.init(xn(m_status), yn(m_status), r, r, 32);
+ ++m_status;
+ cmd = m_ellipse.vertex(x, y);
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+ return cmd;
+ }
+
+
+ bool polygon_ctrl_impl::check_edge(unsigned i, double x, double y) const
+ {
+ bool ret = false;
+
+ unsigned n1 = i;
+ unsigned n2 = (i + m_num_points - 1) % m_num_points;
+ double x1 = xn(n1);
+ double y1 = yn(n1);
+ double x2 = xn(n2);
+ double y2 = yn(n2);
+
+ double dx = x2 - x1;
+ double dy = y2 - y1;
+
+ if(sqrt(dx*dx + dy*dy) > 0.0000001)
+ {
+ double x3 = x;
+ double y3 = y;
+ double x4 = x3 - dy;
+ double y4 = y3 + dx;
+
+ double den = (y4-y3) * (x2-x1) - (x4-x3) * (y2-y1);
+ double u1 = ((x4-x3) * (y1-y3) - (y4-y3) * (x1-x3)) / den;
+
+ double xi = x1 + u1 * (x2 - x1);
+ double yi = y1 + u1 * (y2 - y1);
+
+ dx = xi - x;
+ dy = yi - y;
+
+ if (u1 > 0.0 && u1 < 1.0 && sqrt(dx*dx + dy*dy) <= m_point_radius)
+ {
+ ret = true;
+ }
+ }
+ return ret;
+ }
+
+
+
+ bool polygon_ctrl_impl::in_rect(double x, double y) const
+ {
+ return false;
+ }
+
+
+ bool polygon_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ unsigned i;
+ bool ret = false;
+ m_node = -1;
+ m_edge = -1;
+ inverse_transform_xy(&x, &y);
+ for (i = 0; i < m_num_points; i++)
+ {
+ if(sqrt( (x-xn(i)) * (x-xn(i)) + (y-yn(i)) * (y-yn(i)) ) < m_point_radius)
+ {
+ m_dx = x - xn(i);
+ m_dy = y - yn(i);
+ m_node = int(i);
+ ret = true;
+ break;
+ }
+ }
+
+ if(!ret)
+ {
+ for (i = 0; i < m_num_points; i++)
+ {
+ if(check_edge(i, x, y))
+ {
+ m_dx = x;
+ m_dy = y;
+ m_edge = int(i);
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ if(!ret)
+ {
+ if(point_in_polygon(x, y))
+ {
+ m_dx = x;
+ m_dy = y;
+ m_node = int(m_num_points);
+ ret = true;
+ }
+ }
+ return ret;
+ }
+
+
+ bool polygon_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ bool ret = false;
+ double dx;
+ double dy;
+ inverse_transform_xy(&x, &y);
+ if(m_node == int(m_num_points))
+ {
+ dx = x - m_dx;
+ dy = y - m_dy;
+ unsigned i;
+ for(i = 0; i < m_num_points; i++)
+ {
+ xn(i) += dx;
+ yn(i) += dy;
+ }
+ m_dx = x;
+ m_dy = y;
+ ret = true;
+ }
+ else
+ {
+ if(m_edge >= 0)
+ {
+ unsigned n1 = m_edge;
+ unsigned n2 = (n1 + m_num_points - 1) % m_num_points;
+ dx = x - m_dx;
+ dy = y - m_dy;
+ xn(n1) += dx;
+ yn(n1) += dy;
+ xn(n2) += dx;
+ yn(n2) += dy;
+ m_dx = x;
+ m_dy = y;
+ ret = true;
+ }
+ else
+ {
+ if(m_node >= 0)
+ {
+ xn(m_node) = x - m_dx;
+ yn(m_node) = y - m_dy;
+ ret = true;
+ }
+ }
+ }
+ return ret;
+ }
+
+ bool polygon_ctrl_impl::on_mouse_button_up(double x, double y)
+ {
+ bool ret = (m_node >= 0) || (m_edge >= 0);
+ m_node = -1;
+ m_edge = -1;
+ return ret;
+ }
+
+
+ bool polygon_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ return false;
+ }
+
+
+ //======= Crossings Multiply algorithm of InsideTest ========================
+ //
+ // By Eric Haines, 3D/Eye Inc, erich@eye.com
+ //
+ // This version is usually somewhat faster than the original published in
+ // Graphics Gems IV; by turning the division for testing the X axis crossing
+ // into a tricky multiplication test this part of the test became faster,
+ // which had the additional effect of making the test for "both to left or
+ // both to right" a bit slower for triangles than simply computing the
+ // intersection each time. The main increase is in triangle testing speed,
+ // which was about 15% faster; all other polygon complexities were pretty much
+ // the same as before. On machines where division is very expensive (not the
+ // case on the HP 9000 series on which I tested) this test should be much
+ // faster overall than the old code. Your mileage may (in fact, will) vary,
+ // depending on the machine and the test data, but in general I believe this
+ // code is both shorter and faster. This test was inspired by unpublished
+ // Graphics Gems submitted by Joseph Samosky and Mark Haigh-Hutchinson.
+ // Related work by Samosky is in:
+ //
+ // Samosky, Joseph, "SectionView: A system for interactively specifying and
+ // visualizing sections through three-dimensional medical image data",
+ // M.S. Thesis, Department of Electrical Engineering and Computer Science,
+ // Massachusetts Institute of Technology, 1993.
+ //
+ // Shoot a test ray along +X axis. The strategy is to compare vertex Y values
+ // to the testing point's Y and quickly discard edges which are entirely to one
+ // side of the test ray. Note that CONVEX and WINDING code can be added as
+ // for the CrossingsTest() code; it is left out here for clarity.
+ //
+ // Input 2D polygon _pgon_ with _numverts_ number of vertices and test point
+ // _point_, returns 1 if inside, 0 if outside.
+ bool polygon_ctrl_impl::point_in_polygon(double tx, double ty) const
+ {
+ if(m_num_points < 3) return false;
+ if(!m_in_polygon_check) return false;
+
+ unsigned j;
+ int yflag0, yflag1, inside_flag;
+ double vtx0, vty0, vtx1, vty1;
+
+ vtx0 = xn(m_num_points - 1);
+ vty0 = yn(m_num_points - 1);
+
+ // get test bit for above/below X axis
+ yflag0 = (vty0 >= ty);
+
+ vtx1 = xn(0);
+ vty1 = yn(0);
+
+ inside_flag = 0;
+ for (j = 1; j <= m_num_points; ++j)
+ {
+ yflag1 = (vty1 >= ty);
+ // Check if endpoints straddle (are on opposite sides) of X axis
+ // (i.e. the Y's differ); if so, +X ray could intersect this edge.
+ // The old test also checked whether the endpoints are both to the
+ // right or to the left of the test point. However, given the faster
+ // intersection point computation used below, this test was found to
+ // be a break-even proposition for most polygons and a loser for
+ // triangles (where 50% or more of the edges which survive this test
+ // will cross quadrants and so have to have the X intersection computed
+ // anyway). I credit Joseph Samosky with inspiring me to try dropping
+ // the "both left or both right" part of my code.
+ if (yflag0 != yflag1)
+ {
+ // Check intersection of pgon segment with +X ray.
+ // Note if >= point's X; if so, the ray hits it.
+ // The division operation is avoided for the ">=" test by checking
+ // the sign of the first vertex wrto the test point; idea inspired
+ // by Joseph Samosky's and Mark Haigh-Hutchinson's different
+ // polygon inclusion tests.
+ if ( ((vty1-ty) * (vtx0-vtx1) >=
+ (vtx1-tx) * (vty0-vty1)) == yflag1 )
+ {
+ inside_flag ^= 1;
+ }
+ }
+
+ // Move to the next pair of vertices, retaining info as possible.
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ vty0 = vty1;
+
+ unsigned k = (j >= m_num_points) ? j - m_num_points : j;
+ vtx1 = xn(k);
+ vty1 = yn(k);
+ }
+ return inside_flag != 0;
+ }
+}
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_rbox_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_rbox_ctrl.cpp new file mode 100644 index 0000000000..c643fec387 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_rbox_ctrl.cpp @@ -0,0 +1,330 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <string.h>
+#include "ctrl/agg_rbox_ctrl.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ rbox_ctrl_impl::rbox_ctrl_impl(double x1, double y1,
+ double x2, double y2, bool flip_y) :
+ ctrl(x1, y1, x2, y2, flip_y),
+ m_border_width(1.0),
+ m_border_extra(0.0),
+ m_text_thickness(1.5),
+ m_text_height(9.0),
+ m_text_width(0.0),
+ m_num_items(0),
+ m_cur_item(-1),
+ m_ellipse_poly(m_ellipse),
+ m_text_poly(m_text),
+ m_idx(0),
+ m_vertex(0)
+ {
+ calc_rbox();
+ }
+
+
+ //------------------------------------------------------------------------
+ void rbox_ctrl_impl::calc_rbox()
+ {
+ m_xs1 = m_x1 + m_border_width;
+ m_ys1 = m_y1 + m_border_width;
+ m_xs2 = m_x2 - m_border_width;
+ m_ys2 = m_y2 - m_border_width;
+ }
+
+
+ //------------------------------------------------------------------------
+ void rbox_ctrl_impl::add_item(const char* text)
+ {
+ if(m_num_items < 32)
+ {
+ m_items[m_num_items].resize(strlen(text) + 1);
+ strcpy(&m_items[m_num_items][0], text);
+ m_num_items++;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void rbox_ctrl_impl::border_width(double t, double extra)
+ {
+ m_border_width = t;
+ m_border_extra = extra;
+ calc_rbox();
+ }
+
+
+ //------------------------------------------------------------------------
+ void rbox_ctrl_impl::text_size(double h, double w)
+ {
+ m_text_width = w;
+ m_text_height = h;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void rbox_ctrl_impl::rewind(unsigned idx)
+ {
+ m_idx = idx;
+ m_dy = m_text_height * 2.0;
+ m_draw_item = 0;
+
+ switch(idx)
+ {
+ default:
+
+ case 0: // Background
+ m_vertex = 0;
+ m_vx[0] = m_x1 - m_border_extra;
+ m_vy[0] = m_y1 - m_border_extra;
+ m_vx[1] = m_x2 + m_border_extra;
+ m_vy[1] = m_y1 - m_border_extra;
+ m_vx[2] = m_x2 + m_border_extra;
+ m_vy[2] = m_y2 + m_border_extra;
+ m_vx[3] = m_x1 - m_border_extra;
+ m_vy[3] = m_y2 + m_border_extra;
+ break;
+
+ case 1: // Border
+ m_vertex = 0;
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x2;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y2;
+ m_vx[4] = m_x1 + m_border_width;
+ m_vy[4] = m_y1 + m_border_width;
+ m_vx[5] = m_x1 + m_border_width;
+ m_vy[5] = m_y2 - m_border_width;
+ m_vx[6] = m_x2 - m_border_width;
+ m_vy[6] = m_y2 - m_border_width;
+ m_vx[7] = m_x2 - m_border_width;
+ m_vy[7] = m_y1 + m_border_width;
+ break;
+
+ case 2: // Text
+ m_text.text(&m_items[0][0]);
+ m_text.start_point(m_xs1 + m_dy * 1.5, m_ys1 + m_dy / 2.0);
+ m_text.size(m_text_height, m_text_width);
+ m_text_poly.width(m_text_thickness);
+ m_text_poly.line_join(round_join);
+ m_text_poly.line_cap(round_cap);
+ m_text_poly.rewind(0);
+ break;
+
+ case 3: // Inactive items
+ m_ellipse.init(m_xs1 + m_dy / 1.3,
+ m_ys1 + m_dy / 1.3,
+ m_text_height / 1.5,
+ m_text_height / 1.5, 32);
+ m_ellipse_poly.width(m_text_thickness);
+ m_ellipse_poly.rewind(0);
+ break;
+
+
+ case 4: // Active Item
+ if(m_cur_item >= 0)
+ {
+ m_ellipse.init(m_xs1 + m_dy / 1.3,
+ m_ys1 + m_dy * m_cur_item + m_dy / 1.3,
+ m_text_height / 2.0,
+ m_text_height / 2.0, 32);
+ m_ellipse.rewind(0);
+ }
+ break;
+
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned rbox_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ switch(m_idx)
+ {
+ case 0:
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 4) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 1:
+ if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to;
+ if(m_vertex >= 8) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 2:
+ cmd = m_text_poly.vertex(x, y);
+ if(is_stop(cmd))
+ {
+ m_draw_item++;
+ if(m_draw_item >= m_num_items)
+ {
+ break;
+ }
+ else
+ {
+ m_text.text(&m_items[m_draw_item][0]);
+ m_text.start_point(m_xs1 + m_dy * 1.5,
+ m_ys1 + m_dy * (m_draw_item + 1) - m_dy / 2.0);
+
+ m_text_poly.rewind(0);
+ cmd = m_text_poly.vertex(x, y);
+ }
+ }
+ break;
+
+ case 3:
+ cmd = m_ellipse_poly.vertex(x, y);
+ if(is_stop(cmd))
+ {
+ m_draw_item++;
+ if(m_draw_item >= m_num_items)
+ {
+ break;
+ }
+ else
+ {
+ m_ellipse.init(m_xs1 + m_dy / 1.3,
+ m_ys1 + m_dy * m_draw_item + m_dy / 1.3,
+ m_text_height / 1.5,
+ m_text_height / 1.5, 32);
+ m_ellipse_poly.rewind(0);
+ cmd = m_ellipse_poly.vertex(x, y);
+ }
+ }
+ break;
+
+
+ case 4:
+ if(m_cur_item >= 0)
+ {
+ cmd = m_ellipse.vertex(x, y);
+ }
+ else
+ {
+ cmd = path_cmd_stop;
+ }
+ break;
+
+ default:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+
+ return cmd;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool rbox_ctrl_impl::in_rect(double x, double y) const
+ {
+ inverse_transform_xy(&x, &y);
+ return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool rbox_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+ unsigned i;
+ for(i = 0; i < m_num_items; i++)
+ {
+ double xp = m_xs1 + m_dy / 1.3;
+ double yp = m_ys1 + m_dy * i + m_dy / 1.3;
+ if(calc_distance(x, y, xp, yp) <= m_text_height / 1.5)
+ {
+ m_cur_item = int(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool rbox_ctrl_impl::on_mouse_move(double, double, bool)
+ {
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ bool rbox_ctrl_impl::on_mouse_button_up(double, double)
+ {
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ bool rbox_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ if(m_cur_item >= 0)
+ {
+ if(up || right)
+ {
+ m_cur_item++;
+ if(m_cur_item >= int(m_num_items))
+ {
+ m_cur_item = 0;
+ }
+ return true;
+ }
+
+ if(down || left)
+ {
+ m_cur_item--;
+ if(m_cur_item < 0)
+ {
+ m_cur_item = m_num_items - 1;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+}
+
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_scale_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_scale_ctrl.cpp new file mode 100644 index 0000000000..974a4fc727 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_scale_ctrl.cpp @@ -0,0 +1,459 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "ctrl/agg_scale_ctrl.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ scale_ctrl_impl::scale_ctrl_impl(double x1, double y1,
+ double x2, double y2, bool flip_y) :
+ ctrl(x1, y1, x2, y2, flip_y),
+ m_border_thickness(1.0),
+ m_border_extra((fabs(x2 - x1) > fabs(y2 - y1)) ? (y2 - y1) / 2 : (x2 - x1) / 2),
+ m_pdx(0.0),
+ m_pdy(0.0),
+ m_move_what(move_nothing),
+ m_value1(0.3),
+ m_value2(0.7),
+ m_min_d(0.01)
+ {
+ calc_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::calc_box()
+ {
+ m_xs1 = m_x1 + m_border_thickness;
+ m_ys1 = m_y1 + m_border_thickness;
+ m_xs2 = m_x2 - m_border_thickness;
+ m_ys2 = m_y2 - m_border_thickness;
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::border_thickness(double t, double extra)
+ {
+ m_border_thickness = t;
+ m_border_extra = extra;
+ calc_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::resize(double x1, double y1, double x2, double y2)
+ {
+ m_x1 = x1;
+ m_y1 = y1;
+ m_x2 = x2;
+ m_y2 = y2;
+ calc_box();
+ m_border_extra = (fabs(x2 - x1) > fabs(y2 - y1)) ?
+ (y2 - y1) / 2 :
+ (x2 - x1) / 2;
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::value1(double value)
+ {
+ if(value < 0.0) value = 0.0;
+ if(value > 1.0) value = 1.0;
+ if(m_value2 - value < m_min_d) value = m_value2 - m_min_d;
+ m_value1 = value;
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::value2(double value)
+ {
+ if(value < 0.0) value = 0.0;
+ if(value > 1.0) value = 1.0;
+ if(m_value1 + value < m_min_d) value = m_value1 + m_min_d;
+ m_value2 = value;
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::move(double d)
+ {
+ m_value1 += d;
+ m_value2 += d;
+ if(m_value1 < 0.0)
+ {
+ m_value2 -= m_value1;
+ m_value1 = 0.0;
+ }
+ if(m_value2 > 1.0)
+ {
+ m_value1 -= m_value2 - 1.0;
+ m_value2 = 1.0;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void scale_ctrl_impl::rewind(unsigned idx)
+ {
+ m_idx = idx;
+
+ switch(idx)
+ {
+ default:
+
+ case 0: // Background
+ m_vertex = 0;
+ m_vx[0] = m_x1 - m_border_extra;
+ m_vy[0] = m_y1 - m_border_extra;
+ m_vx[1] = m_x2 + m_border_extra;
+ m_vy[1] = m_y1 - m_border_extra;
+ m_vx[2] = m_x2 + m_border_extra;
+ m_vy[2] = m_y2 + m_border_extra;
+ m_vx[3] = m_x1 - m_border_extra;
+ m_vy[3] = m_y2 + m_border_extra;
+ break;
+
+ case 1: // Border
+ m_vertex = 0;
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x2;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y2;
+ m_vx[4] = m_x1 + m_border_thickness;
+ m_vy[4] = m_y1 + m_border_thickness;
+ m_vx[5] = m_x1 + m_border_thickness;
+ m_vy[5] = m_y2 - m_border_thickness;
+ m_vx[6] = m_x2 - m_border_thickness;
+ m_vy[6] = m_y2 - m_border_thickness;
+ m_vx[7] = m_x2 - m_border_thickness;
+ m_vy[7] = m_y1 + m_border_thickness;
+ break;
+
+ case 2: // pointer1
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_value1,
+ (m_ys1 + m_ys2) / 2.0,
+ m_y2 - m_y1,
+ m_y2 - m_y1,
+ 32);
+ }
+ else
+ {
+ m_ellipse.init((m_xs1 + m_xs2) / 2.0,
+ m_ys1 + (m_ys2 - m_ys1) * m_value1,
+ m_x2 - m_x1,
+ m_x2 - m_x1,
+ 32);
+ }
+ m_ellipse.rewind(0);
+ break;
+
+ case 3: // pointer2
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_value2,
+ (m_ys1 + m_ys2) / 2.0,
+ m_y2 - m_y1,
+ m_y2 - m_y1,
+ 32);
+ }
+ else
+ {
+ m_ellipse.init((m_xs1 + m_xs2) / 2.0,
+ m_ys1 + (m_ys2 - m_ys1) * m_value2,
+ m_x2 - m_x1,
+ m_x2 - m_x1,
+ 32);
+ }
+ m_ellipse.rewind(0);
+ break;
+
+ case 4: // slider
+ m_vertex = 0;
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ m_vx[0] = m_xs1 + (m_xs2 - m_xs1) * m_value1;
+ m_vy[0] = m_y1 - m_border_extra / 2.0;
+ m_vx[1] = m_xs1 + (m_xs2 - m_xs1) * m_value2;
+ m_vy[1] = m_vy[0];
+ m_vx[2] = m_vx[1];
+ m_vy[2] = m_y2 + m_border_extra / 2.0;
+ m_vx[3] = m_vx[0];
+ m_vy[3] = m_vy[2];
+ }
+ else
+ {
+ m_vx[0] = m_x1 - m_border_extra / 2.0;
+ m_vy[0] = m_ys1 + (m_ys2 - m_ys1) * m_value1;
+ m_vx[1] = m_vx[0];
+ m_vy[1] = m_ys1 + (m_ys2 - m_ys1) * m_value2;
+ m_vx[2] = m_x2 + m_border_extra / 2.0;
+ m_vy[2] = m_vy[1];
+ m_vx[3] = m_vx[2];
+ m_vy[3] = m_vy[0];
+ }
+ break;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned scale_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ switch(m_idx)
+ {
+ case 0:
+ case 4:
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 4) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 1:
+ if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to;
+ if(m_vertex >= 8) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 2:
+ case 3:
+ cmd = m_ellipse.vertex(x, y);
+ break;
+
+ default:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+
+ return cmd;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool scale_ctrl_impl::in_rect(double x, double y) const
+ {
+ inverse_transform_xy(&x, &y);
+ return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool scale_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+
+ double xp1;
+ double xp2;
+ double ys1;
+ double ys2;
+ double xp;
+ double yp;
+
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ xp1 = m_xs1 + (m_xs2 - m_xs1) * m_value1;
+ xp2 = m_xs1 + (m_xs2 - m_xs1) * m_value2;
+ ys1 = m_y1 - m_border_extra / 2.0;
+ ys2 = m_y2 + m_border_extra / 2.0;
+ yp = (m_ys1 + m_ys2) / 2.0;
+
+ if(x > xp1 && y > ys1 && x < xp2 && y < ys2)
+ {
+ m_pdx = xp1 - x;
+ m_move_what = move_slider;
+ return true;
+ }
+
+ //if(x < xp1 && calc_distance(x, y, xp1, yp) <= m_y2 - m_y1)
+ if(calc_distance(x, y, xp1, yp) <= m_y2 - m_y1)
+ {
+ m_pdx = xp1 - x;
+ m_move_what = move_value1;
+ return true;
+ }
+
+ //if(x > xp2 && calc_distance(x, y, xp2, yp) <= m_y2 - m_y1)
+ if(calc_distance(x, y, xp2, yp) <= m_y2 - m_y1)
+ {
+ m_pdx = xp2 - x;
+ m_move_what = move_value2;
+ return true;
+ }
+ }
+ else
+ {
+ xp1 = m_x1 - m_border_extra / 2.0;
+ xp2 = m_x2 + m_border_extra / 2.0;
+ ys1 = m_ys1 + (m_ys2 - m_ys1) * m_value1;
+ ys2 = m_ys1 + (m_ys2 - m_ys1) * m_value2;
+ xp = (m_xs1 + m_xs2) / 2.0;
+
+ if(x > xp1 && y > ys1 && x < xp2 && y < ys2)
+ {
+ m_pdy = ys1 - y;
+ m_move_what = move_slider;
+ return true;
+ }
+
+ //if(y < ys1 && calc_distance(x, y, xp, ys1) <= m_x2 - m_x1)
+ if(calc_distance(x, y, xp, ys1) <= m_x2 - m_x1)
+ {
+ m_pdy = ys1 - y;
+ m_move_what = move_value1;
+ return true;
+ }
+
+ //if(y > ys2 && calc_distance(x, y, xp, ys2) <= m_x2 - m_x1)
+ if(calc_distance(x, y, xp, ys2) <= m_x2 - m_x1)
+ {
+ m_pdy = ys2 - y;
+ m_move_what = move_value2;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool scale_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ inverse_transform_xy(&x, &y);
+ if(!button_flag)
+ {
+ return on_mouse_button_up(x, y);
+ }
+
+ double xp = x + m_pdx;
+ double yp = y + m_pdy;
+ double dv;
+
+ switch(m_move_what)
+ {
+ case move_value1:
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ m_value1 = (xp - m_xs1) / (m_xs2 - m_xs1);
+ }
+ else
+ {
+ m_value1 = (yp - m_ys1) / (m_ys2 - m_ys1);
+ }
+ if(m_value1 < 0.0) m_value1 = 0.0;
+ if(m_value1 > m_value2 - m_min_d) m_value1 = m_value2 - m_min_d;
+ return true;
+
+ case move_value2:
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ m_value2 = (xp - m_xs1) / (m_xs2 - m_xs1);
+ }
+ else
+ {
+ m_value2 = (yp - m_ys1) / (m_ys2 - m_ys1);
+ }
+ if(m_value2 > 1.0) m_value2 = 1.0;
+ if(m_value2 < m_value1 + m_min_d) m_value2 = m_value1 + m_min_d;
+ return true;
+
+ case move_slider:
+ dv = m_value2 - m_value1;
+ if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1))
+ {
+ m_value1 = (xp - m_xs1) / (m_xs2 - m_xs1);
+ }
+ else
+ {
+ m_value1 = (yp - m_ys1) / (m_ys2 - m_ys1);
+ }
+ m_value2 = m_value1 + dv;
+ if(m_value1 < 0.0)
+ {
+ dv = m_value2 - m_value1;
+ m_value1 = 0.0;
+ m_value2 = m_value1 + dv;
+ }
+ if(m_value2 > 1.0)
+ {
+ dv = m_value2 - m_value1;
+ m_value2 = 1.0;
+ m_value1 = m_value2 - dv;
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool scale_ctrl_impl::on_mouse_button_up(double, double)
+ {
+ m_move_what = move_nothing;
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool scale_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+/*
+ if(right || up)
+ {
+ m_value += 0.005;
+ if(m_value > 1.0) m_value = 1.0;
+ return true;
+ }
+
+ if(left || down)
+ {
+ m_value -= 0.005;
+ if(m_value < 0.0) m_value = 0.0;
+ return true;
+ }
+*/
+ return false;
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_slider_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_slider_ctrl.cpp new file mode 100644 index 0000000000..113b7ac08e --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_slider_ctrl.cpp @@ -0,0 +1,354 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <string.h>
+#include <stdio.h>
+#include "ctrl/agg_slider_ctrl.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ slider_ctrl_impl::slider_ctrl_impl(double x1, double y1,
+ double x2, double y2, bool flip_y) :
+ ctrl(x1, y1, x2, y2, flip_y),
+ m_border_width(1.0),
+ m_border_extra((y2 - y1) / 2),
+ m_text_thickness(1.0),
+ m_pdx(0.0),
+ m_mouse_move(false),
+ m_value(0.5),
+ m_preview_value(0.5),
+ m_min(0.0),
+ m_max(1.0),
+ m_num_steps(0),
+ m_descending(false),
+ m_text_poly(m_text)
+ {
+ m_label[0] = 0;
+ calc_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void slider_ctrl_impl::calc_box()
+ {
+ m_xs1 = m_x1 + m_border_width;
+ m_ys1 = m_y1 + m_border_width;
+ m_xs2 = m_x2 - m_border_width;
+ m_ys2 = m_y2 - m_border_width;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool slider_ctrl_impl::normalize_value(bool preview_value_flag)
+ {
+ bool ret = true;
+ if(m_num_steps)
+ {
+ int step = int(m_preview_value * m_num_steps + 0.5);
+ ret = m_value != step / double(m_num_steps);
+ m_value = step / double(m_num_steps);
+ }
+ else
+ {
+ m_value = m_preview_value;
+ }
+
+ if(preview_value_flag)
+ {
+ m_preview_value = m_value;
+ }
+ return ret;
+ }
+
+
+ //------------------------------------------------------------------------
+ void slider_ctrl_impl::border_width(double t, double extra)
+ {
+ m_border_width = t;
+ m_border_extra = extra;
+ calc_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void slider_ctrl_impl::value(double value)
+ {
+ m_preview_value = (value - m_min) / (m_max - m_min);
+ if(m_preview_value > 1.0) m_preview_value = 1.0;
+ if(m_preview_value < 0.0) m_preview_value = 0.0;
+ normalize_value(true);
+ }
+
+ //------------------------------------------------------------------------
+ void slider_ctrl_impl::label(const char* fmt)
+ {
+ m_label[0] = 0;
+ if(fmt)
+ {
+ unsigned len = strlen(fmt);
+ if(len > 63) len = 63;
+ memcpy(m_label, fmt, len);
+ m_label[len] = 0;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void slider_ctrl_impl::rewind(unsigned idx)
+ {
+ m_idx = idx;
+
+ switch(idx)
+ {
+ default:
+
+ case 0: // Background
+ m_vertex = 0;
+ m_vx[0] = m_x1 - m_border_extra;
+ m_vy[0] = m_y1 - m_border_extra;
+ m_vx[1] = m_x2 + m_border_extra;
+ m_vy[1] = m_y1 - m_border_extra;
+ m_vx[2] = m_x2 + m_border_extra;
+ m_vy[2] = m_y2 + m_border_extra;
+ m_vx[3] = m_x1 - m_border_extra;
+ m_vy[3] = m_y2 + m_border_extra;
+ break;
+
+ case 1: // Triangle
+ m_vertex = 0;
+ if(m_descending)
+ {
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x1;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y1;
+ }
+ else
+ {
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x2;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y1;
+ }
+ break;
+
+ case 2:
+ m_text.text(m_label);
+ if(m_label[0])
+ {
+ char buf[256];
+ sprintf(buf, m_label, value());
+ m_text.text(buf);
+ }
+ m_text.start_point(m_x1, m_y1);
+ m_text.size((m_y2 - m_y1) * 1.2, m_y2 - m_y1);
+ m_text_poly.width(m_text_thickness);
+ m_text_poly.line_join(round_join);
+ m_text_poly.line_cap(round_cap);
+ m_text_poly.rewind(0);
+ break;
+
+ case 3: // pointer preview
+ m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_preview_value,
+ (m_ys1 + m_ys2) / 2.0,
+ m_y2 - m_y1,
+ m_y2 - m_y1,
+ 32);
+ break;
+
+
+ case 4: // pointer
+ normalize_value(false);
+ m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_value,
+ (m_ys1 + m_ys2) / 2.0,
+ m_y2 - m_y1,
+ m_y2 - m_y1,
+ 32);
+ m_ellipse.rewind(0);
+ break;
+
+ case 5:
+ m_storage.remove_all();
+ if(m_num_steps)
+ {
+ unsigned i;
+ double d = (m_xs2 - m_xs1) / m_num_steps;
+ if(d > 0.004) d = 0.004;
+ for(i = 0; i < m_num_steps + 1; i++)
+ {
+ double x = m_xs1 + (m_xs2 - m_xs1) * i / m_num_steps;
+ m_storage.move_to(x, m_y1);
+ m_storage.line_to(x - d * (m_x2 - m_x1), m_y1 - m_border_extra);
+ m_storage.line_to(x + d * (m_x2 - m_x1), m_y1 - m_border_extra);
+ }
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned slider_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ switch(m_idx)
+ {
+ case 0:
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 4) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 1:
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 4) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 2:
+ cmd = m_text_poly.vertex(x, y);
+ break;
+
+ case 3:
+ case 4:
+ cmd = m_ellipse.vertex(x, y);
+ break;
+
+ case 5:
+ cmd = m_storage.vertex(x, y);
+ break;
+
+ default:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+
+ return cmd;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool slider_ctrl_impl::in_rect(double x, double y) const
+ {
+ inverse_transform_xy(&x, &y);
+ return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool slider_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+
+ double xp = m_xs1 + (m_xs2 - m_xs1) * m_value;
+ double yp = (m_ys1 + m_ys2) / 2.0;
+
+ if(calc_distance(x, y, xp, yp) <= m_y2 - m_y1)
+ {
+ m_pdx = xp - x;
+ m_mouse_move = true;
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool slider_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ inverse_transform_xy(&x, &y);
+ if(!button_flag)
+ {
+ on_mouse_button_up(x, y);
+ return false;
+ }
+
+ if(m_mouse_move)
+ {
+ double xp = x + m_pdx;
+ m_preview_value = (xp - m_xs1) / (m_xs2 - m_xs1);
+ if(m_preview_value < 0.0) m_preview_value = 0.0;
+ if(m_preview_value > 1.0) m_preview_value = 1.0;
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool slider_ctrl_impl::on_mouse_button_up(double, double)
+ {
+ m_mouse_move = false;
+ normalize_value(true);
+ return true;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool slider_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ double d = 0.005;
+ if(m_num_steps)
+ {
+ d = 1.0 / m_num_steps;
+ }
+
+ if(right || up)
+ {
+ m_preview_value += d;
+ if(m_preview_value > 1.0) m_preview_value = 1.0;
+ normalize_value(true);
+ return true;
+ }
+
+ if(left || down)
+ {
+ m_preview_value -= d;
+ if(m_preview_value < 0.0) m_preview_value = 0.0;
+ normalize_value(true);
+ return true;
+ }
+ return false;
+ }
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/ctrl/agg_spline_ctrl.cpp b/plugins/Clist_ng/AGG/src/ctrl/agg_spline_ctrl.cpp new file mode 100644 index 0000000000..6716607c65 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/ctrl/agg_spline_ctrl.cpp @@ -0,0 +1,412 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include "ctrl/agg_spline_ctrl.h"
+
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ spline_ctrl_impl::spline_ctrl_impl(double x1, double y1, double x2, double y2,
+ unsigned num_pnt, bool flip_y) :
+ ctrl(x1, y1, x2, y2, flip_y),
+ m_num_pnt(num_pnt),
+ m_border_width(1.0),
+ m_border_extra(0.0),
+ m_curve_width(1.0),
+ m_point_size(3.0),
+ m_curve_poly(m_curve_pnt),
+ m_idx(0),
+ m_vertex(0),
+ m_active_pnt(-1),
+ m_move_pnt(-1),
+ m_pdx(0.0),
+ m_pdy(0.0)
+ {
+ if(m_num_pnt < 4) m_num_pnt = 4;
+ if(m_num_pnt > 32) m_num_pnt = 32;
+
+ unsigned i;
+ for(i = 0; i < m_num_pnt; i++)
+ {
+ m_xp[i] = double(i) / double(m_num_pnt - 1);
+ m_yp[i] = 0.5;
+ }
+ calc_spline_box();
+ update_spline();
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::border_width(double t, double extra)
+ {
+ m_border_width = t;
+ m_border_extra = extra;
+ calc_spline_box();
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::calc_spline_box()
+ {
+ m_xs1 = m_x1 + m_border_width;
+ m_ys1 = m_y1 + m_border_width;
+ m_xs2 = m_x2 - m_border_width;
+ m_ys2 = m_y2 - m_border_width;
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::update_spline()
+ {
+ int i;
+ m_spline.init(m_num_pnt, m_xp, m_yp);
+ for(i = 0; i < 256; i++)
+ {
+ m_spline_values[i] = m_spline.get(double(i) / 255.0);
+ if(m_spline_values[i] < 0.0) m_spline_values[i] = 0.0;
+ if(m_spline_values[i] > 1.0) m_spline_values[i] = 1.0;
+ m_spline_values8[i] = (int8u)(m_spline_values[i] * 255.0);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::calc_curve()
+ {
+ int i;
+ m_curve_pnt.remove_all();
+ m_curve_pnt.move_to(m_xs1, m_ys1 + (m_ys2 - m_ys1) * m_spline_values[0]);
+ for(i = 1; i < 256; i++)
+ {
+ m_curve_pnt.line_to(m_xs1 + (m_xs2 - m_xs1) * double(i) / 255.0,
+ m_ys1 + (m_ys2 - m_ys1) * m_spline_values[i]);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ double spline_ctrl_impl::calc_xp(unsigned idx)
+ {
+ return m_xs1 + (m_xs2 - m_xs1) * m_xp[idx];
+ }
+
+
+ //------------------------------------------------------------------------
+ double spline_ctrl_impl::calc_yp(unsigned idx)
+ {
+ return m_ys1 + (m_ys2 - m_ys1) * m_yp[idx];
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::set_xp(unsigned idx, double val)
+ {
+ if(val < 0.0) val = 0.0;
+ if(val > 1.0) val = 1.0;
+
+ if(idx == 0)
+ {
+ val = 0.0;
+ }
+ else if(idx == m_num_pnt - 1)
+ {
+ val = 1.0;
+ }
+ else
+ {
+ if(val < m_xp[idx - 1] + 0.001) val = m_xp[idx - 1] + 0.001;
+ if(val > m_xp[idx + 1] - 0.001) val = m_xp[idx + 1] - 0.001;
+ }
+ m_xp[idx] = val;
+ }
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::set_yp(unsigned idx, double val)
+ {
+ if(val < 0.0) val = 0.0;
+ if(val > 1.0) val = 1.0;
+ m_yp[idx] = val;
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::point(unsigned idx, double x, double y)
+ {
+ if(idx < m_num_pnt)
+ {
+ set_xp(idx, x);
+ set_yp(idx, y);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::value(unsigned idx, double y)
+ {
+ if(idx < m_num_pnt)
+ {
+ set_yp(idx, y);
+ }
+ }
+
+ //------------------------------------------------------------------------
+ double spline_ctrl_impl::value(double x) const
+ {
+ x = m_spline.get(x);
+ if(x < 0.0) x = 0.0;
+ if(x > 1.0) x = 1.0;
+ return x;
+ }
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::rewind(unsigned idx)
+ {
+ unsigned i;
+
+ m_idx = idx;
+
+ switch(idx)
+ {
+ default:
+
+ case 0: // Background
+ m_vertex = 0;
+ m_vx[0] = m_x1 - m_border_extra;
+ m_vy[0] = m_y1 - m_border_extra;
+ m_vx[1] = m_x2 + m_border_extra;
+ m_vy[1] = m_y1 - m_border_extra;
+ m_vx[2] = m_x2 + m_border_extra;
+ m_vy[2] = m_y2 + m_border_extra;
+ m_vx[3] = m_x1 - m_border_extra;
+ m_vy[3] = m_y2 + m_border_extra;
+ break;
+
+ case 1: // Border
+ m_vertex = 0;
+ m_vx[0] = m_x1;
+ m_vy[0] = m_y1;
+ m_vx[1] = m_x2;
+ m_vy[1] = m_y1;
+ m_vx[2] = m_x2;
+ m_vy[2] = m_y2;
+ m_vx[3] = m_x1;
+ m_vy[3] = m_y2;
+ m_vx[4] = m_x1 + m_border_width;
+ m_vy[4] = m_y1 + m_border_width;
+ m_vx[5] = m_x1 + m_border_width;
+ m_vy[5] = m_y2 - m_border_width;
+ m_vx[6] = m_x2 - m_border_width;
+ m_vy[6] = m_y2 - m_border_width;
+ m_vx[7] = m_x2 - m_border_width;
+ m_vy[7] = m_y1 + m_border_width;
+ break;
+
+ case 2: // Curve
+ calc_curve();
+ m_curve_poly.width(m_curve_width);
+ m_curve_poly.rewind(0);
+ break;
+
+
+ case 3: // Inactive points
+ m_curve_pnt.remove_all();
+ for(i = 0; i < m_num_pnt; i++)
+ {
+ if(int(i) != m_active_pnt)
+ {
+ m_ellipse.init(calc_xp(i), calc_yp(i),
+ m_point_size, m_point_size, 32);
+ m_curve_pnt.concat_path(m_ellipse);
+ }
+ }
+ m_curve_poly.rewind(0);
+ break;
+
+
+ case 4: // Active point
+ m_curve_pnt.remove_all();
+ if(m_active_pnt >= 0)
+ {
+ m_ellipse.init(calc_xp(m_active_pnt), calc_yp(m_active_pnt),
+ m_point_size, m_point_size, 32);
+
+ m_curve_pnt.concat_path(m_ellipse);
+ }
+ m_curve_poly.rewind(0);
+ break;
+
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned spline_ctrl_impl::vertex(double* x, double* y)
+ {
+ unsigned cmd = path_cmd_line_to;
+ switch(m_idx)
+ {
+ case 0:
+ if(m_vertex == 0) cmd = path_cmd_move_to;
+ if(m_vertex >= 4) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 1:
+ if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to;
+ if(m_vertex >= 8) cmd = path_cmd_stop;
+ *x = m_vx[m_vertex];
+ *y = m_vy[m_vertex];
+ m_vertex++;
+ break;
+
+ case 2:
+ cmd = m_curve_poly.vertex(x, y);
+ break;
+
+ case 3:
+ case 4:
+ cmd = m_curve_pnt.vertex(x, y);
+ break;
+
+ default:
+ cmd = path_cmd_stop;
+ break;
+ }
+
+ if(!is_stop(cmd))
+ {
+ transform_xy(x, y);
+ }
+
+ return cmd;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void spline_ctrl_impl::active_point(int i)
+ {
+ m_active_pnt = i;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool spline_ctrl_impl::in_rect(double x, double y) const
+ {
+ inverse_transform_xy(&x, &y);
+ return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool spline_ctrl_impl::on_mouse_button_down(double x, double y)
+ {
+ inverse_transform_xy(&x, &y);
+ unsigned i;
+ for(i = 0; i < m_num_pnt; i++)
+ {
+ double xp = calc_xp(i);
+ double yp = calc_yp(i);
+ if(calc_distance(x, y, xp, yp) <= m_point_size + 1)
+ {
+ m_pdx = xp - x;
+ m_pdy = yp - y;
+ m_active_pnt = m_move_pnt = int(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool spline_ctrl_impl::on_mouse_button_up(double, double)
+ {
+ if(m_move_pnt >= 0)
+ {
+ m_move_pnt = -1;
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool spline_ctrl_impl::on_mouse_move(double x, double y, bool button_flag)
+ {
+ inverse_transform_xy(&x, &y);
+ if(!button_flag)
+ {
+ return on_mouse_button_up(x, y);
+ }
+
+ if(m_move_pnt >= 0)
+ {
+ double xp = x + m_pdx;
+ double yp = y + m_pdy;
+
+ set_xp(m_move_pnt, (xp - m_xs1) / (m_xs2 - m_xs1));
+ set_yp(m_move_pnt, (yp - m_ys1) / (m_ys2 - m_ys1));
+
+ update_spline();
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool spline_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up)
+ {
+ double kx = 0.0;
+ double ky = 0.0;
+ bool ret = false;
+ if(m_active_pnt >= 0)
+ {
+ kx = m_xp[m_active_pnt];
+ ky = m_yp[m_active_pnt];
+ if(left) { kx -= 0.001; ret = true; }
+ if(right) { kx += 0.001; ret = true; }
+ if(down) { ky -= 0.001; ret = true; }
+ if(up) { ky += 0.001; ret = true; }
+ }
+ if(ret)
+ {
+ set_xp(m_active_pnt, kx);
+ set_yp(m_active_pnt, ky);
+ update_spline();
+ }
+ return ret;
+ }
+
+
+
+
+}
+
diff --git a/plugins/Clist_ng/AGG/src/install b/plugins/Clist_ng/AGG/src/install new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/install diff --git a/plugins/Clist_ng/AGG/src/news b/plugins/Clist_ng/AGG/src/news new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/news diff --git a/plugins/Clist_ng/AGG/src/platform/Makefile.am b/plugins/Clist_ng/AGG/src/platform/Makefile.am new file mode 100644 index 0000000000..b68cc62b07 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/platform/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = X11 sdl win32 AmigaOS BeOS mac
diff --git a/plugins/Clist_ng/AGG/src/platform/sdl/Makefile.am b/plugins/Clist_ng/AGG/src/platform/sdl/Makefile.am new file mode 100644 index 0000000000..4394edf15f --- /dev/null +++ b/plugins/Clist_ng/AGG/src/platform/sdl/Makefile.am @@ -0,0 +1,10 @@ +if ENABLE_SDL
+
+lib_LTLIBRARIES = libaggplatformsdl.la
+
+libaggplatformsdl_la_LDFLAGS = -version-info @AGG_LIB_VERSION@
+libaggplatformsdl_la_SOURCES = agg_platform_support.cpp
+libaggplatformsdl_la_CXXFLAGS = -I$(top_srcdir)/include @SDL_CFLAGS@
+libaggplatformsdl_la_LIBADD = @SDL_LIBS@
+endif
+
diff --git a/plugins/Clist_ng/AGG/src/platform/sdl/agg_platform_support.cpp b/plugins/Clist_ng/AGG/src/platform/sdl/agg_platform_support.cpp new file mode 100644 index 0000000000..357230b3ef --- /dev/null +++ b/plugins/Clist_ng/AGG/src/platform/sdl/agg_platform_support.cpp @@ -0,0 +1,714 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Copyright (C) 2004 Mauricio Piacentini (SDL Support)
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <string.h>
+#include "platform/agg_platform_support.h"
+#include "SDL.h"
+#include "SDL_byteorder.h"
+
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ class platform_specific
+ {
+ public:
+ platform_specific(pix_format_e format, bool flip_y);
+ ~platform_specific();
+
+ pix_format_e m_format;
+ pix_format_e m_sys_format;
+ bool m_flip_y;
+ unsigned m_bpp;
+ unsigned m_sys_bpp;
+ unsigned m_rmask;
+ unsigned m_gmask;
+ unsigned m_bmask;
+ unsigned m_amask;
+ bool m_update_flag;
+ bool m_resize_flag;
+ bool m_initialized;
+ SDL_Surface* m_surf_screen;
+ SDL_Surface* m_surf_window;
+ SDL_Surface* m_surf_img[platform_support::max_images];
+ int m_cur_x;
+ int m_cur_y;
+ int m_sw_start;
+ };
+
+
+
+ //------------------------------------------------------------------------
+ platform_specific::platform_specific(pix_format_e format, bool flip_y) :
+ m_format(format),
+ m_sys_format(pix_format_undefined),
+ m_flip_y(flip_y),
+ m_bpp(0),
+ m_sys_bpp(0),
+ m_update_flag(true),
+ m_resize_flag(true),
+ m_initialized(false),
+ m_surf_screen(0),
+ m_surf_window(0),
+ m_cur_x(0),
+ m_cur_y(0)
+ {
+ memset(m_surf_img, 0, sizeof(m_surf_img));
+
+ switch(m_format)
+ {
+ case pix_format_gray8:
+ m_bpp = 8;
+ break;
+
+ case pix_format_rgb565:
+ m_rmask = 0xF800;
+ m_gmask = 0x7E0;
+ m_bmask = 0x1F;
+ m_amask = 0;
+ m_bpp = 16;
+ break;
+
+ case pix_format_rgb555:
+ m_rmask = 0x7C00;
+ m_gmask = 0x3E0;
+ m_bmask = 0x1F;
+ m_amask = 0;
+ m_bpp = 16;
+ break;
+
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ case pix_format_rgb24:
+ m_rmask = 0xFF;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF0000;
+ m_amask = 0;
+ m_bpp = 24;
+ break;
+
+ case pix_format_bgr24:
+ m_rmask = 0xFF0000;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF;
+ m_amask = 0;
+ m_bpp = 24;
+ break;
+
+ case pix_format_bgra32:
+ m_rmask = 0xFF0000;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF;
+ m_amask = 0xFF000000;
+ m_bpp = 32;
+ break;
+
+ case pix_format_abgr32:
+ m_rmask = 0xFF000000;
+ m_gmask = 0xFF0000;
+ m_bmask = 0xFF00;
+ m_amask = 0xFF;
+ m_bpp = 32;
+ break;
+
+ case pix_format_argb32:
+ m_rmask = 0xFF00;
+ m_gmask = 0xFF0000;
+ m_bmask = 0xFF000000;
+ m_amask = 0xFF;
+ m_bpp = 32;
+ break;
+
+ case pix_format_rgba32:
+ m_rmask = 0xFF;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF0000;
+ m_amask = 0xFF000000;
+ m_bpp = 32;
+ break;
+#else //SDL_BIG_ENDIAN (PPC)
+ case pix_format_rgb24:
+ m_rmask = 0xFF0000;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF;
+ m_amask = 0;
+ m_bpp = 24;
+ break;
+
+ case pix_format_bgr24:
+ m_rmask = 0xFF;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF0000;
+ m_amask = 0;
+ m_bpp = 24;
+ break;
+
+ case pix_format_bgra32:
+ m_rmask = 0xFF00;
+ m_gmask = 0xFF0000;
+ m_bmask = 0xFF000000;
+ m_amask = 0xFF;
+ m_bpp = 32;
+ break;
+
+ case pix_format_abgr32:
+ m_rmask = 0xFF;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF0000;
+ m_amask = 0xFF000000;
+ m_bpp = 32;
+ break;
+
+ case pix_format_argb32:
+ m_rmask = 0xFF0000;
+ m_gmask = 0xFF00;
+ m_bmask = 0xFF;
+ m_amask = 0xFF000000;
+ m_bpp = 32;
+ break;
+
+ case pix_format_rgba32:
+ m_rmask = 0xFF000000;
+ m_gmask = 0xFF0000;
+ m_bmask = 0xFF00;
+ m_amask = 0xFF;
+ m_bpp = 32;
+ break;
+#endif
+ }
+ }
+
+ //------------------------------------------------------------------------
+ platform_specific::~platform_specific()
+ {
+ int i;
+ for(i = platform_support::max_images - 1; i >= 0; --i)
+ {
+ if(m_surf_img[i]) SDL_FreeSurface(m_surf_img[i]);
+ }
+ if(m_surf_window) SDL_FreeSurface(m_surf_window);
+ if(m_surf_screen) SDL_FreeSurface(m_surf_screen);
+ }
+
+
+
+ //------------------------------------------------------------------------
+ platform_support::platform_support(pix_format_e format, bool flip_y) :
+ m_specific(new platform_specific(format, flip_y)),
+ m_format(format),
+ m_bpp(m_specific->m_bpp),
+ m_window_flags(0),
+ m_wait_mode(true),
+ m_flip_y(flip_y)
+ {
+ SDL_Init(SDL_INIT_VIDEO);
+ strcpy(m_caption, "Anti-Grain Geometry Application");
+ }
+
+
+ //------------------------------------------------------------------------
+ platform_support::~platform_support()
+ {
+ delete m_specific;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void platform_support::caption(const char* cap)
+ {
+ strcpy(m_caption, cap);
+ if(m_specific->m_initialized)
+ {
+ SDL_WM_SetCaption(cap, 0);
+ }
+ }
+
+
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_support::init(unsigned width, unsigned height, unsigned flags)
+ {
+ m_window_flags = flags;
+ unsigned wflags = SDL_SWSURFACE;
+
+ if(m_window_flags & window_hw_buffer)
+ {
+ wflags = SDL_HWSURFACE;
+ }
+
+ if(m_window_flags & window_resize)
+ {
+ wflags |= SDL_RESIZABLE;
+ }
+
+ if(m_specific->m_surf_screen) SDL_FreeSurface(m_specific->m_surf_screen);
+
+ m_specific->m_surf_screen = SDL_SetVideoMode(width, height, m_bpp, wflags);
+ if(m_specific->m_surf_screen == 0)
+ {
+ fprintf(stderr,
+ "Unable to set %dx%d %d bpp video: %s\n",
+ width,
+ height,
+ m_bpp,
+ ::SDL_GetError());
+ return false;
+ }
+
+ SDL_WM_SetCaption(m_caption, 0);
+
+ if(m_specific->m_surf_window) SDL_FreeSurface(m_specific->m_surf_window);
+
+ m_specific->m_surf_window =
+ SDL_CreateRGBSurface(SDL_HWSURFACE,
+ m_specific->m_surf_screen->w,
+ m_specific->m_surf_screen->h,
+ m_specific->m_surf_screen->format->BitsPerPixel,
+ m_specific->m_rmask,
+ m_specific->m_gmask,
+ m_specific->m_bmask,
+ m_specific->m_amask);
+
+ if(m_specific->m_surf_window == 0)
+ {
+ fprintf(stderr,
+ "Unable to create image buffer %dx%d %d bpp: %s\n",
+ width,
+ height,
+ m_bpp,
+ SDL_GetError());
+ return false;
+ }
+
+ m_rbuf_window.attach((unsigned char*)m_specific->m_surf_window->pixels,
+ m_specific->m_surf_window->w,
+ m_specific->m_surf_window->h,
+ m_flip_y ? -m_specific->m_surf_window->pitch :
+ m_specific->m_surf_window->pitch);
+
+ if(!m_specific->m_initialized)
+ {
+ m_initial_width = width;
+ m_initial_height = height;
+ on_init();
+ m_specific->m_initialized = true;
+ }
+ on_resize(m_rbuf_window.width(), m_rbuf_window.height());
+ m_specific->m_update_flag = true;
+ return true;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void platform_support::update_window()
+ {
+ SDL_BlitSurface(m_specific->m_surf_window, 0, m_specific->m_surf_screen, 0);
+ SDL_UpdateRect(m_specific->m_surf_screen, 0, 0, 0, 0);
+ }
+
+
+ //------------------------------------------------------------------------
+ int platform_support::run()
+ {
+ SDL_Event event;
+ bool ev_flag = false;
+
+ for(;;)
+ {
+ if(m_specific->m_update_flag)
+ {
+ on_draw();
+ update_window();
+ m_specific->m_update_flag = false;
+ }
+
+ ev_flag = false;
+ if(m_wait_mode)
+ {
+ SDL_WaitEvent(&event);
+ ev_flag = true;
+ }
+ else
+ {
+ if(SDL_PollEvent(&event))
+ {
+ ev_flag = true;
+ }
+ else
+ {
+ on_idle();
+ }
+ }
+
+ if(ev_flag)
+ {
+ if(event.type == SDL_QUIT)
+ {
+ break;
+ }
+
+ int y;
+ unsigned flags = 0;
+
+ switch (event.type)
+ {
+ case SDL_VIDEORESIZE:
+ if(!init(event.resize.w, event.resize.h, m_window_flags)) return false;
+ on_resize(m_rbuf_window.width(), m_rbuf_window.height());
+ trans_affine_resizing(event.resize.w, event.resize.h);
+ m_specific->m_update_flag = true;
+ break;
+
+ case SDL_KEYDOWN:
+ {
+ flags = 0;
+ if(event.key.keysym.mod & KMOD_SHIFT) flags |= kbd_shift;
+ if(event.key.keysym.mod & KMOD_CTRL) flags |= kbd_ctrl;
+
+ bool left = false;
+ bool up = false;
+ bool right = false;
+ bool down = false;
+
+ switch(event.key.keysym.sym)
+ {
+ case key_left:
+ left = true;
+ break;
+
+ case key_up:
+ up = true;
+ break;
+
+ case key_right:
+ right = true;
+ break;
+
+ case key_down:
+ down = true;
+ break;
+ }
+
+ if(m_ctrls.on_arrow_keys(left, right, down, up))
+ {
+ on_ctrl_change();
+ force_redraw();
+ }
+ else
+ {
+ on_key(m_specific->m_cur_x,
+ m_specific->m_cur_y,
+ event.key.keysym.sym,
+ flags);
+ }
+ }
+ break;
+
+ case SDL_MOUSEMOTION:
+ y = m_flip_y ?
+ m_rbuf_window.height() - event.motion.y :
+ event.motion.y;
+
+ m_specific->m_cur_x = event.motion.x;
+ m_specific->m_cur_y = y;
+ flags = 0;
+ if(event.motion.state & SDL_BUTTON_LMASK) flags |= mouse_left;
+ if(event.motion.state & SDL_BUTTON_RMASK) flags |= mouse_right;
+
+ if(m_ctrls.on_mouse_move(m_specific->m_cur_x,
+ m_specific->m_cur_y,
+ (flags & mouse_left) != 0))
+ {
+ on_ctrl_change();
+ force_redraw();
+ }
+ else
+ {
+ on_mouse_move(m_specific->m_cur_x,
+ m_specific->m_cur_y,
+ flags);
+ }
+ SDL_Event eventtrash;
+ while (SDL_PeepEvents(&eventtrash, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION))!=0){;}
+ break;
+
+ case SDL_MOUSEBUTTONDOWN:
+ y = m_flip_y
+ ? m_rbuf_window.height() - event.button.y
+ : event.button.y;
+
+ m_specific->m_cur_x = event.button.x;
+ m_specific->m_cur_y = y;
+ flags = 0;
+ switch(event.button.button)
+ {
+ case SDL_BUTTON_LEFT:
+ {
+ flags = mouse_left;
+
+if(m_ctrls.on_mouse_button_down(m_specific->m_cur_x,
+ m_specific->m_cur_y))
+ {
+ m_ctrls.set_cur(m_specific->m_cur_x,
+ m_specific->m_cur_y);
+ on_ctrl_change();
+ force_redraw();
+ }
+ else
+ {
+ if(m_ctrls.in_rect(m_specific->m_cur_x,
+ m_specific->m_cur_y))
+ {
+ if(m_ctrls.set_cur(m_specific->m_cur_x,
+ m_specific->m_cur_y))
+ {
+ on_ctrl_change();
+ force_redraw();
+ }
+ }
+ else
+ {
+ on_mouse_button_down(m_specific->m_cur_x,
+ m_specific->m_cur_y,
+ flags);
+ }
+ }
+ }
+ break;
+ case SDL_BUTTON_RIGHT:
+ flags = mouse_right;
+ on_mouse_button_down(m_specific->m_cur_x,
+ m_specific->m_cur_y,
+ flags);
+ break;
+ } //switch(event.button.button)
+ break;
+
+ case SDL_MOUSEBUTTONUP:
+ y = m_flip_y
+ ? m_rbuf_window.height() - event.button.y
+ : event.button.y;
+
+ m_specific->m_cur_x = event.button.x;
+ m_specific->m_cur_y = y;
+ flags = 0;
+ if(m_ctrls.on_mouse_button_up(m_specific->m_cur_x,
+ m_specific->m_cur_y))
+ {
+ on_ctrl_change();
+ force_redraw();
+ }
+ on_mouse_button_up(m_specific->m_cur_x,
+ m_specific->m_cur_y,
+ flags);
+ break;
+ }
+ }
+ }
+ return 0;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ const char* platform_support::img_ext() const { return ".bmp"; }
+
+ //------------------------------------------------------------------------
+ const char* platform_support::full_file_name(const char* file_name)
+ {
+ return file_name;
+ }
+
+ //------------------------------------------------------------------------
+ bool platform_support::load_img(unsigned idx, const char* file)
+ {
+ if(idx < max_images)
+ {
+ if(m_specific->m_surf_img[idx]) SDL_FreeSurface(m_specific->m_surf_img[idx]);
+
+ char fn[1024];
+ strcpy(fn, file);
+ int len = strlen(fn);
+ if(len < 4 || strcmp(fn + len - 4, ".bmp") != 0)
+ {
+ strcat(fn, ".bmp");
+ }
+
+ SDL_Surface* tmp_surf = SDL_LoadBMP(fn);
+ if (tmp_surf == 0)
+ {
+ fprintf(stderr, "Couldn't load %s: %s\n", fn, SDL_GetError());
+ return false;
+ }
+
+ SDL_PixelFormat format;
+ format.palette = 0;
+ format.BitsPerPixel = m_bpp;
+ format.BytesPerPixel = m_bpp >> 8;
+ format.Rmask = m_specific->m_rmask;
+ format.Gmask = m_specific->m_gmask;
+ format.Bmask = m_specific->m_bmask;
+ format.Amask = m_specific->m_amask;
+ format.Rshift = 0;
+ format.Gshift = 0;
+ format.Bshift = 0;
+ format.Ashift = 0;
+ format.Rloss = 0;
+ format.Gloss = 0;
+ format.Bloss = 0;
+ format.Aloss = 0;
+ format.colorkey = 0;
+ format.alpha = 0;
+
+ m_specific->m_surf_img[idx] =
+ SDL_ConvertSurface(tmp_surf,
+ &format,
+ SDL_SWSURFACE);
+
+ SDL_FreeSurface(tmp_surf);
+
+ if(m_specific->m_surf_img[idx] == 0) return false;
+
+ m_rbuf_img[idx].attach((unsigned char*)m_specific->m_surf_img[idx]->pixels,
+ m_specific->m_surf_img[idx]->w,
+ m_specific->m_surf_img[idx]->h,
+ m_flip_y ? -m_specific->m_surf_img[idx]->pitch :
+ m_specific->m_surf_img[idx]->pitch);
+ return true;
+
+ }
+ return false;
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_support::save_img(unsigned idx, const char* file)
+ {
+ if(idx < max_images && m_specific->m_surf_img[idx])
+ {
+ char fn[1024];
+ strcpy(fn, file);
+ int len = strlen(fn);
+ if(len < 4 || strcmp(fn + len - 4, ".bmp") != 0)
+ {
+ strcat(fn, ".bmp");
+ }
+ return SDL_SaveBMP(m_specific->m_surf_img[idx], fn) == 0;
+ }
+ return false;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height)
+ {
+ if(idx < max_images)
+ {
+
+ if(m_specific->m_surf_img[idx]) SDL_FreeSurface(m_specific->m_surf_img[idx]);
+
+ m_specific->m_surf_img[idx] =
+ SDL_CreateRGBSurface(SDL_SWSURFACE,
+ width,
+ height,
+ m_specific->m_surf_screen->format->BitsPerPixel,
+ m_specific->m_rmask,
+ m_specific->m_gmask,
+ m_specific->m_bmask,
+ m_specific->m_amask);
+ if(m_specific->m_surf_img[idx] == 0)
+ {
+ fprintf(stderr, "Couldn't create image: %s\n", SDL_GetError());
+ return false;
+ }
+
+ m_rbuf_img[idx].attach((unsigned char*)m_specific->m_surf_img[idx]->pixels,
+ m_specific->m_surf_img[idx]->w,
+ m_specific->m_surf_img[idx]->h,
+ m_flip_y ? -m_specific->m_surf_img[idx]->pitch :
+ m_specific->m_surf_img[idx]->pitch);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ void platform_support::start_timer()
+ {
+ m_specific->m_sw_start = SDL_GetTicks();
+ }
+
+ //------------------------------------------------------------------------
+ double platform_support::elapsed_time() const
+ {
+ int stop = SDL_GetTicks();
+ return double(stop - m_specific->m_sw_start);
+ }
+
+ //------------------------------------------------------------------------
+ void platform_support::message(const char* msg)
+ {
+ fprintf(stderr, "%s\n", msg);
+ }
+
+ //------------------------------------------------------------------------
+ void platform_support::force_redraw()
+ {
+ m_specific->m_update_flag = true;
+ }
+
+
+ //------------------------------------------------------------------------
+ void platform_support::on_init() {}
+ void platform_support::on_resize(int sx, int sy) {}
+ void platform_support::on_idle() {}
+ void platform_support::on_mouse_move(int x, int y, unsigned flags) {}
+ void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {}
+ void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {}
+ void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {}
+ void platform_support::on_ctrl_change() {}
+ void platform_support::on_draw() {}
+ void platform_support::on_post_draw(void* raw_handler) {}
+
+
+}
+
+
+int agg_main(int argc, char* argv[]);
+
+int main(int argc, char* argv[])
+{
+ return agg_main(argc, argv);
+}
+
diff --git a/plugins/Clist_ng/AGG/src/platform/win32/Makefile.am b/plugins/Clist_ng/AGG/src/platform/win32/Makefile.am new file mode 100644 index 0000000000..5ad695a09c --- /dev/null +++ b/plugins/Clist_ng/AGG/src/platform/win32/Makefile.am @@ -0,0 +1,13 @@ +
+
+if ENABLE_WIN32
+lib_LTLIBRARIES = libaggplatformwin32.la
+
+libaggplatformwin32_la_LDFLAGS = -version-info @AGG_LIB_VERSION@
+libaggplatformwin32_la_SOURCES = agg_platform_support.cpp \
+ agg_win32_bmp.cpp
+
+libaggplatformwin32_la_CXXFLAGS = -I$(top_srcdir)/include @WINDOWS_CFLAGS@
+libaggplatformwin32_la_LIBADD = @WINDOWS_LIBS@ $(top_builddir)/src/libagg.la
+endif
+
diff --git a/plugins/Clist_ng/AGG/src/platform/win32/agg_platform_support.cpp b/plugins/Clist_ng/AGG/src/platform/win32/agg_platform_support.cpp new file mode 100644 index 0000000000..bf84a6c50c --- /dev/null +++ b/plugins/Clist_ng/AGG/src/platform/win32/agg_platform_support.cpp @@ -0,0 +1,1478 @@ +//----------------------------------------------------------------------------
+// Anti-Grain Geometry (AGG) - Version 2.5
+// A high quality rendering engine for C++
+// Copyright (C) 2002-2006 Maxim Shemanarev
+// Contact: mcseem@antigrain.com
+// mcseemagg@yahoo.com
+// http://antigrain.com
+//
+// AGG is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// AGG is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with AGG; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+//----------------------------------------------------------------------------
+
+#include <windows.h>
+#include <string.h>
+#include "platform/agg_platform_support.h"
+#include "platform/win32/agg_win32_bmp.h"
+#include "util/agg_color_conv_rgb8.h"
+#include "util/agg_color_conv_rgb16.h"
+
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ HINSTANCE g_windows_instance = 0;
+ int g_windows_cmd_show = 0;
+
+
+ //------------------------------------------------------------------------
+ class platform_specific
+ {
+ public:
+ platform_specific(pix_format_e format, bool flip_y);
+
+ void create_pmap(unsigned width, unsigned height,
+ rendering_buffer* wnd);
+
+ void display_pmap(HDC dc, const rendering_buffer* src);
+ bool load_pmap(const char* fn, unsigned idx,
+ rendering_buffer* dst);
+
+ bool save_pmap(const char* fn, unsigned idx,
+ const rendering_buffer* src);
+
+ unsigned translate(unsigned keycode);
+
+ pix_format_e m_format;
+ pix_format_e m_sys_format;
+ bool m_flip_y;
+ unsigned m_bpp;
+ unsigned m_sys_bpp;
+ HWND m_hwnd;
+ pixel_map m_pmap_window;
+ pixel_map m_pmap_img[platform_support::max_images];
+ unsigned m_keymap[256];
+ unsigned m_last_translated_key;
+ int m_cur_x;
+ int m_cur_y;
+ unsigned m_input_flags;
+ bool m_redraw_flag;
+ HDC m_current_dc;
+ LARGE_INTEGER m_sw_freq;
+ LARGE_INTEGER m_sw_start;
+ };
+
+
+ //------------------------------------------------------------------------
+ platform_specific::platform_specific(pix_format_e format, bool flip_y) :
+ m_format(format),
+ m_sys_format(pix_format_undefined),
+ m_flip_y(flip_y),
+ m_bpp(0),
+ m_sys_bpp(0),
+ m_hwnd(0),
+ m_last_translated_key(0),
+ m_cur_x(0),
+ m_cur_y(0),
+ m_input_flags(0),
+ m_redraw_flag(true),
+ m_current_dc(0)
+ {
+ memset(m_keymap, 0, sizeof(m_keymap));
+
+ m_keymap[VK_PAUSE] = key_pause;
+ m_keymap[VK_CLEAR] = key_clear;
+
+ m_keymap[VK_NUMPAD0] = key_kp0;
+ m_keymap[VK_NUMPAD1] = key_kp1;
+ m_keymap[VK_NUMPAD2] = key_kp2;
+ m_keymap[VK_NUMPAD3] = key_kp3;
+ m_keymap[VK_NUMPAD4] = key_kp4;
+ m_keymap[VK_NUMPAD5] = key_kp5;
+ m_keymap[VK_NUMPAD6] = key_kp6;
+ m_keymap[VK_NUMPAD7] = key_kp7;
+ m_keymap[VK_NUMPAD8] = key_kp8;
+ m_keymap[VK_NUMPAD9] = key_kp9;
+ m_keymap[VK_DECIMAL] = key_kp_period;
+ m_keymap[VK_DIVIDE] = key_kp_divide;
+ m_keymap[VK_MULTIPLY] = key_kp_multiply;
+ m_keymap[VK_SUBTRACT] = key_kp_minus;
+ m_keymap[VK_ADD] = key_kp_plus;
+
+ m_keymap[VK_UP] = key_up;
+ m_keymap[VK_DOWN] = key_down;
+ m_keymap[VK_RIGHT] = key_right;
+ m_keymap[VK_LEFT] = key_left;
+ m_keymap[VK_INSERT] = key_insert;
+ m_keymap[VK_DELETE] = key_delete;
+ m_keymap[VK_HOME] = key_home;
+ m_keymap[VK_END] = key_end;
+ m_keymap[VK_PRIOR] = key_page_up;
+ m_keymap[VK_NEXT] = key_page_down;
+
+ m_keymap[VK_F1] = key_f1;
+ m_keymap[VK_F2] = key_f2;
+ m_keymap[VK_F3] = key_f3;
+ m_keymap[VK_F4] = key_f4;
+ m_keymap[VK_F5] = key_f5;
+ m_keymap[VK_F6] = key_f6;
+ m_keymap[VK_F7] = key_f7;
+ m_keymap[VK_F8] = key_f8;
+ m_keymap[VK_F9] = key_f9;
+ m_keymap[VK_F10] = key_f10;
+ m_keymap[VK_F11] = key_f11;
+ m_keymap[VK_F12] = key_f12;
+ m_keymap[VK_F13] = key_f13;
+ m_keymap[VK_F14] = key_f14;
+ m_keymap[VK_F15] = key_f15;
+
+ m_keymap[VK_NUMLOCK] = key_numlock;
+ m_keymap[VK_CAPITAL] = key_capslock;
+ m_keymap[VK_SCROLL] = key_scrollock;
+
+
+ switch(m_format)
+ {
+ case pix_format_bw:
+ m_sys_format = pix_format_bw;
+ m_bpp = 1;
+ m_sys_bpp = 1;
+ break;
+
+ case pix_format_gray8:
+ m_sys_format = pix_format_gray8;
+ m_bpp = 8;
+ m_sys_bpp = 8;
+ break;
+
+ case pix_format_gray16:
+ m_sys_format = pix_format_gray8;
+ m_bpp = 16;
+ m_sys_bpp = 8;
+ break;
+
+ case pix_format_rgb565:
+ case pix_format_rgb555:
+ m_sys_format = pix_format_rgb555;
+ m_bpp = 16;
+ m_sys_bpp = 16;
+ break;
+
+ case pix_format_rgbAAA:
+ case pix_format_bgrAAA:
+ case pix_format_rgbBBA:
+ case pix_format_bgrABB:
+ m_sys_format = pix_format_bgr24;
+ m_bpp = 32;
+ m_sys_bpp = 24;
+ break;
+
+ case pix_format_rgb24:
+ case pix_format_bgr24:
+ m_sys_format = pix_format_bgr24;
+ m_bpp = 24;
+ m_sys_bpp = 24;
+ break;
+
+ case pix_format_rgb48:
+ case pix_format_bgr48:
+ m_sys_format = pix_format_bgr24;
+ m_bpp = 48;
+ m_sys_bpp = 24;
+ break;
+
+ case pix_format_bgra32:
+ case pix_format_abgr32:
+ case pix_format_argb32:
+ case pix_format_rgba32:
+ m_sys_format = pix_format_bgra32;
+ m_bpp = 32;
+ m_sys_bpp = 32;
+ break;
+
+ case pix_format_bgra64:
+ case pix_format_abgr64:
+ case pix_format_argb64:
+ case pix_format_rgba64:
+ m_sys_format = pix_format_bgra32;
+ m_bpp = 64;
+ m_sys_bpp = 32;
+ break;
+ }
+ ::QueryPerformanceFrequency(&m_sw_freq);
+ ::QueryPerformanceCounter(&m_sw_start);
+ }
+
+
+ //------------------------------------------------------------------------
+ void platform_specific::create_pmap(unsigned width,
+ unsigned height,
+ rendering_buffer* wnd)
+ {
+ m_pmap_window.create(width, height, org_e(m_bpp));
+ wnd->attach(m_pmap_window.buf(),
+ m_pmap_window.width(),
+ m_pmap_window.height(),
+ m_flip_y ?
+ m_pmap_window.stride() :
+ -m_pmap_window.stride());
+ }
+
+
+ //------------------------------------------------------------------------
+ static void convert_pmap(rendering_buffer* dst,
+ const rendering_buffer* src,
+ pix_format_e format)
+ {
+ switch(format)
+ {
+ case pix_format_gray8:
+ break;
+
+ case pix_format_gray16:
+ color_conv(dst, src, color_conv_gray16_to_gray8());
+ break;
+
+ case pix_format_rgb565:
+ color_conv(dst, src, color_conv_rgb565_to_rgb555());
+ break;
+
+ case pix_format_rgbAAA:
+ color_conv(dst, src, color_conv_rgbAAA_to_bgr24());
+ break;
+
+ case pix_format_bgrAAA:
+ color_conv(dst, src, color_conv_bgrAAA_to_bgr24());
+ break;
+
+ case pix_format_rgbBBA:
+ color_conv(dst, src, color_conv_rgbBBA_to_bgr24());
+ break;
+
+ case pix_format_bgrABB:
+ color_conv(dst, src, color_conv_bgrABB_to_bgr24());
+ break;
+
+ case pix_format_rgb24:
+ color_conv(dst, src, color_conv_rgb24_to_bgr24());
+ break;
+
+ case pix_format_rgb48:
+ color_conv(dst, src, color_conv_rgb48_to_bgr24());
+ break;
+
+ case pix_format_bgr48:
+ color_conv(dst, src, color_conv_bgr48_to_bgr24());
+ break;
+
+ case pix_format_abgr32:
+ color_conv(dst, src, color_conv_abgr32_to_bgra32());
+ break;
+
+ case pix_format_argb32:
+ color_conv(dst, src, color_conv_argb32_to_bgra32());
+ break;
+
+ case pix_format_rgba32:
+ color_conv(dst, src, color_conv_rgba32_to_bgra32());
+ break;
+
+ case pix_format_bgra64:
+ color_conv(dst, src, color_conv_bgra64_to_bgra32());
+ break;
+
+ case pix_format_abgr64:
+ color_conv(dst, src, color_conv_abgr64_to_bgra32());
+ break;
+
+ case pix_format_argb64:
+ color_conv(dst, src, color_conv_argb64_to_bgra32());
+ break;
+
+ case pix_format_rgba64:
+ color_conv(dst, src, color_conv_rgba64_to_bgra32());
+ break;
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void platform_specific::display_pmap(HDC dc, const rendering_buffer* src)
+ {
+ if(m_sys_format == m_format)
+ {
+ m_pmap_window.draw(dc);
+ }
+ else
+ {
+ pixel_map pmap_tmp;
+ pmap_tmp.create(m_pmap_window.width(),
+ m_pmap_window.height(),
+ org_e(m_sys_bpp));
+
+ rendering_buffer rbuf_tmp;
+ rbuf_tmp.attach(pmap_tmp.buf(),
+ pmap_tmp.width(),
+ pmap_tmp.height(),
+ m_flip_y ?
+ pmap_tmp.stride() :
+ -pmap_tmp.stride());
+
+ convert_pmap(&rbuf_tmp, src, m_format);
+ pmap_tmp.draw(dc);
+ }
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_specific::save_pmap(const char* fn, unsigned idx,
+ const rendering_buffer* src)
+ {
+ if(m_sys_format == m_format)
+ {
+ return m_pmap_img[idx].save_as_bmp(fn);
+ }
+
+ pixel_map pmap_tmp;
+ pmap_tmp.create(m_pmap_img[idx].width(),
+ m_pmap_img[idx].height(),
+ org_e(m_sys_bpp));
+
+ rendering_buffer rbuf_tmp;
+ rbuf_tmp.attach(pmap_tmp.buf(),
+ pmap_tmp.width(),
+ pmap_tmp.height(),
+ m_flip_y ?
+ pmap_tmp.stride() :
+ -pmap_tmp.stride());
+
+ convert_pmap(&rbuf_tmp, src, m_format);
+ return pmap_tmp.save_as_bmp(fn);
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_specific::load_pmap(const char* fn, unsigned idx,
+ rendering_buffer* dst)
+ {
+ pixel_map pmap_tmp;
+ if(!pmap_tmp.load_from_bmp(fn)) return false;
+
+ rendering_buffer rbuf_tmp;
+ rbuf_tmp.attach(pmap_tmp.buf(),
+ pmap_tmp.width(),
+ pmap_tmp.height(),
+ m_flip_y ?
+ pmap_tmp.stride() :
+ -pmap_tmp.stride());
+
+ m_pmap_img[idx].create(pmap_tmp.width(),
+ pmap_tmp.height(),
+ org_e(m_bpp),
+ 0);
+
+ dst->attach(m_pmap_img[idx].buf(),
+ m_pmap_img[idx].width(),
+ m_pmap_img[idx].height(),
+ m_flip_y ?
+ m_pmap_img[idx].stride() :
+ -m_pmap_img[idx].stride());
+
+ switch(m_format)
+ {
+ case pix_format_gray8:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_gray8()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_gray8()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray8()); break;
+ }
+ break;
+
+ case pix_format_gray16:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_gray16()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_gray16()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray16()); break;
+ }
+ break;
+
+ case pix_format_rgb555:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb555()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb555()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb555()); break;
+ }
+ break;
+
+ case pix_format_rgb565:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb565()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb565()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb565()); break;
+ }
+ break;
+
+ case pix_format_rgb24:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb24()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb24()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb24()); break;
+ }
+ break;
+
+ case pix_format_bgr24:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr24()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgr24()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr24()); break;
+ }
+ break;
+
+ case pix_format_rgb48:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb48()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb48()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb48()); break;
+ }
+ break;
+
+ case pix_format_bgr48:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr48()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgr48()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr48()); break;
+ }
+ break;
+
+ case pix_format_abgr32:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr32()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_abgr32()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_abgr32()); break;
+ }
+ break;
+
+ case pix_format_argb32:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb32()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_argb32()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_argb32()); break;
+ }
+ break;
+
+ case pix_format_bgra32:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra32()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgra32()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgra32()); break;
+ }
+ break;
+
+ case pix_format_rgba32:
+ switch(pmap_tmp.bpp())
+ {
+ case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba32()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba32()); break;
+ case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba32()); break;
+ }
+ break;
+
+ case pix_format_abgr64:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr64()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_abgr64()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_abgr64()); break;
+ }
+ break;
+
+ case pix_format_argb64:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb64()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_argb64()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_argb64()); break;
+ }
+ break;
+
+ case pix_format_bgra64:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra64()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgra64()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgra64()); break;
+ }
+ break;
+
+ case pix_format_rgba64:
+ switch(pmap_tmp.bpp())
+ {
+ //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba64()); break;
+ case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba64()); break;
+ //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba64()); break;
+ }
+ break;
+
+ }
+
+ return true;
+ }
+
+
+
+
+
+
+
+
+ //------------------------------------------------------------------------
+ unsigned platform_specific::translate(unsigned keycode)
+ {
+ return m_last_translated_key = (keycode > 255) ? 0 : m_keymap[keycode];
+ }
+
+
+
+ //------------------------------------------------------------------------
+ platform_support::platform_support(pix_format_e format, bool flip_y) :
+ m_specific(new platform_specific(format, flip_y)),
+ m_format(format),
+ m_bpp(m_specific->m_bpp),
+ m_window_flags(0),
+ m_wait_mode(true),
+ m_flip_y(flip_y),
+ m_initial_width(10),
+ m_initial_height(10)
+ {
+ strcpy(m_caption, "Anti-Grain Geometry Application");
+ }
+
+
+ //------------------------------------------------------------------------
+ platform_support::~platform_support()
+ {
+ delete m_specific;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void platform_support::caption(const char* cap)
+ {
+ strcpy(m_caption, cap);
+ if(m_specific->m_hwnd)
+ {
+ SetWindowTextA(m_specific->m_hwnd, m_caption);
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void platform_support::start_timer()
+ {
+ ::QueryPerformanceCounter(&(m_specific->m_sw_start));
+ }
+
+ //------------------------------------------------------------------------
+ double platform_support::elapsed_time() const
+ {
+ LARGE_INTEGER stop;
+ ::QueryPerformanceCounter(&stop);
+ return double(stop.QuadPart -
+ m_specific->m_sw_start.QuadPart) * 1000.0 /
+ double(m_specific->m_sw_freq.QuadPart);
+ }
+
+
+
+ //------------------------------------------------------------------------
+ static unsigned get_key_flags(int wflags)
+ {
+ unsigned flags = 0;
+ if(wflags & MK_LBUTTON) flags |= mouse_left;
+ if(wflags & MK_RBUTTON) flags |= mouse_right;
+ if(wflags & MK_SHIFT) flags |= kbd_shift;
+ if(wflags & MK_CONTROL) flags |= kbd_ctrl;
+ return flags;
+ }
+
+
+ void* platform_support::raw_display_handler()
+ {
+ return m_specific->m_current_dc;
+ }
+
+
+ //------------------------------------------------------------------------
+ LRESULT CALLBACK window_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ PAINTSTRUCT ps;
+ HDC paintDC;
+
+
+ void* user_data = reinterpret_cast<void*>(::GetWindowLongPtr(hWnd, GWLP_USERDATA));
+ platform_support* app = 0;
+
+ if(user_data)
+ {
+ app = reinterpret_cast<platform_support*>(user_data);
+ }
+
+ if(app == 0)
+ {
+ if(msg == WM_DESTROY)
+ {
+ ::PostQuitMessage(0);
+ return 0;
+ }
+ return ::DefWindowProc(hWnd, msg, wParam, lParam);
+ }
+
+ HDC dc = ::GetDC(app->m_specific->m_hwnd);
+ app->m_specific->m_current_dc = dc;
+ LRESULT ret = 0;
+
+ switch(msg)
+ {
+ //--------------------------------------------------------------------
+ case WM_CREATE:
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_SIZE:
+ app->m_specific->create_pmap(LOWORD(lParam),
+ HIWORD(lParam),
+ &app->rbuf_window());
+
+ app->trans_affine_resizing(LOWORD(lParam), HIWORD(lParam));
+ app->on_resize(LOWORD(lParam), HIWORD(lParam));
+ app->force_redraw();
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_ERASEBKGND:
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_LBUTTONDOWN:
+ ::SetCapture(app->m_specific->m_hwnd);
+ app->m_specific->m_cur_x = int16(LOWORD(lParam));
+ if(app->flip_y())
+ {
+ app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam));
+ }
+ else
+ {
+ app->m_specific->m_cur_y = int16(HIWORD(lParam));
+ }
+ app->m_specific->m_input_flags = mouse_left | get_key_flags(wParam);
+
+ app->m_ctrls.set_cur(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y);
+ if(app->m_ctrls.on_mouse_button_down(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y))
+ {
+ app->on_ctrl_change();
+ app->force_redraw();
+ }
+ else
+ {
+ if(app->m_ctrls.in_rect(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y))
+ {
+ if(app->m_ctrls.set_cur(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y))
+ {
+ app->on_ctrl_change();
+ app->force_redraw();
+ }
+ }
+ else
+ {
+ app->on_mouse_button_down(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_input_flags);
+ }
+ }
+/*
+ if(!app->wait_mode())
+ {
+ app->on_idle();
+ }
+*/
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_LBUTTONUP:
+ ::ReleaseCapture();
+ app->m_specific->m_cur_x = int16(LOWORD(lParam));
+ if(app->flip_y())
+ {
+ app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam));
+ }
+ else
+ {
+ app->m_specific->m_cur_y = int16(HIWORD(lParam));
+ }
+ app->m_specific->m_input_flags = mouse_left | get_key_flags(wParam);
+
+ if(app->m_ctrls.on_mouse_button_up(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y))
+ {
+ app->on_ctrl_change();
+ app->force_redraw();
+ }
+ app->on_mouse_button_up(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_input_flags);
+/*
+ if(!app->wait_mode())
+ {
+ app->on_idle();
+ }
+*/
+ break;
+
+
+ //--------------------------------------------------------------------
+ case WM_RBUTTONDOWN:
+ ::SetCapture(app->m_specific->m_hwnd);
+ app->m_specific->m_cur_x = int16(LOWORD(lParam));
+ if(app->flip_y())
+ {
+ app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam));
+ }
+ else
+ {
+ app->m_specific->m_cur_y = int16(HIWORD(lParam));
+ }
+ app->m_specific->m_input_flags = mouse_right | get_key_flags(wParam);
+ app->on_mouse_button_down(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_input_flags);
+/*
+ if(!app->wait_mode())
+ {
+ app->on_idle();
+ }
+*/
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_RBUTTONUP:
+ ::ReleaseCapture();
+ app->m_specific->m_cur_x = int16(LOWORD(lParam));
+ if(app->flip_y())
+ {
+ app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam));
+ }
+ else
+ {
+ app->m_specific->m_cur_y = int16(HIWORD(lParam));
+ }
+ app->m_specific->m_input_flags = mouse_right | get_key_flags(wParam);
+ app->on_mouse_button_up(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_input_flags);
+/*
+ if(!app->wait_mode())
+ {
+ app->on_idle();
+ }
+*/
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_MOUSEMOVE:
+ app->m_specific->m_cur_x = int16(LOWORD(lParam));
+ if(app->flip_y())
+ {
+ app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam));
+ }
+ else
+ {
+ app->m_specific->m_cur_y = int16(HIWORD(lParam));
+ }
+ app->m_specific->m_input_flags = get_key_flags(wParam);
+
+
+ if(app->m_ctrls.on_mouse_move(
+ app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ (app->m_specific->m_input_flags & mouse_left) != 0))
+ {
+ app->on_ctrl_change();
+ app->force_redraw();
+ }
+ else
+ {
+ if(!app->m_ctrls.in_rect(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y))
+ {
+ app->on_mouse_move(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_input_flags);
+ }
+ }
+/*
+ if(!app->wait_mode())
+ {
+ app->on_idle();
+ }
+*/
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ app->m_specific->m_last_translated_key = 0;
+ switch(wParam)
+ {
+ case VK_CONTROL:
+ app->m_specific->m_input_flags |= kbd_ctrl;
+ break;
+
+ case VK_SHIFT:
+ app->m_specific->m_input_flags |= kbd_shift;
+ break;
+
+ default:
+ app->m_specific->translate(wParam);
+ break;
+ }
+
+ if(app->m_specific->m_last_translated_key)
+ {
+ bool left = false;
+ bool up = false;
+ bool right = false;
+ bool down = false;
+
+ switch(app->m_specific->m_last_translated_key)
+ {
+ case key_left:
+ left = true;
+ break;
+
+ case key_up:
+ up = true;
+ break;
+
+ case key_right:
+ right = true;
+ break;
+
+ case key_down:
+ down = true;
+ break;
+
+ case key_f2:
+ app->copy_window_to_img(agg::platform_support::max_images - 1);
+ app->save_img(agg::platform_support::max_images - 1, "screenshot");
+ break;
+ }
+
+ if(app->window_flags() & window_process_all_keys)
+ {
+ app->on_key(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_last_translated_key,
+ app->m_specific->m_input_flags);
+ }
+ else
+ {
+ if(app->m_ctrls.on_arrow_keys(left, right, down, up))
+ {
+ app->on_ctrl_change();
+ app->force_redraw();
+ }
+ else
+ {
+ app->on_key(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ app->m_specific->m_last_translated_key,
+ app->m_specific->m_input_flags);
+ }
+ }
+ }
+/*
+ if(!app->wait_mode())
+ {
+ app->on_idle();
+ }
+*/
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ app->m_specific->m_last_translated_key = 0;
+ switch(wParam)
+ {
+ case VK_CONTROL:
+ app->m_specific->m_input_flags &= ~kbd_ctrl;
+ break;
+
+ case VK_SHIFT:
+ app->m_specific->m_input_flags &= ~kbd_shift;
+ break;
+ }
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_CHAR:
+ case WM_SYSCHAR:
+ if(app->m_specific->m_last_translated_key == 0)
+ {
+ app->on_key(app->m_specific->m_cur_x,
+ app->m_specific->m_cur_y,
+ wParam,
+ app->m_specific->m_input_flags);
+ }
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_PAINT:
+ paintDC = ::BeginPaint(hWnd, &ps);
+ app->m_specific->m_current_dc = paintDC;
+ if(app->m_specific->m_redraw_flag)
+ {
+ app->on_draw();
+ app->m_specific->m_redraw_flag = false;
+ }
+ app->m_specific->display_pmap(paintDC, &app->rbuf_window());
+ app->on_post_draw(paintDC);
+ app->m_specific->m_current_dc = 0;
+ ::EndPaint(hWnd, &ps);
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_COMMAND:
+ break;
+
+ //--------------------------------------------------------------------
+ case WM_DESTROY:
+ ::PostQuitMessage(0);
+ break;
+
+ //--------------------------------------------------------------------
+ default:
+ ret = ::DefWindowProc(hWnd, msg, wParam, lParam);
+ break;
+ }
+ app->m_specific->m_current_dc = 0;
+ ::ReleaseDC(app->m_specific->m_hwnd, dc);
+ return ret;
+ }
+
+
+ //------------------------------------------------------------------------
+ void platform_support::message(const char* msg)
+ {
+ ::MessageBoxA(m_specific->m_hwnd, msg, "AGG Message", MB_OK);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool platform_support::init(unsigned width, unsigned height, unsigned flags)
+ {
+ if(m_specific->m_sys_format == pix_format_undefined)
+ {
+ return false;
+ }
+
+ m_window_flags = flags;
+
+ int wflags = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
+
+ WNDCLASSA wc;
+ wc.lpszClassName = "AGGAppClass";
+ wc.lpfnWndProc = window_proc;
+ wc.style = wflags;
+ wc.hInstance = g_windows_instance;
+ wc.hIcon = LoadIcon(0, IDI_APPLICATION);
+ wc.hCursor = LoadCursor(0, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wc.lpszMenuName = "AGGAppMenu";
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ ::RegisterClassA(&wc);
+
+ wflags = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
+
+ if(m_window_flags & window_resize)
+ {
+ wflags |= WS_THICKFRAME | WS_MAXIMIZEBOX;
+ }
+
+ m_specific->m_hwnd = ::CreateWindowA("AGGAppClass",
+ m_caption,
+ wflags,
+ 100,
+ 100,
+ width,
+ height,
+ 0,
+ 0,
+ g_windows_instance,
+ 0);
+
+ if(m_specific->m_hwnd == 0)
+ {
+ return false;
+ }
+
+
+ RECT rct;
+ ::GetClientRect(m_specific->m_hwnd, &rct);
+
+ ::MoveWindow(m_specific->m_hwnd, // handle to window
+ 100, // horizontal position
+ 100, // vertical position
+ width + (width - (rct.right - rct.left)),
+ height + (height - (rct.bottom - rct.top)),
+ FALSE);
+
+ ::SetWindowLongPtr(m_specific->m_hwnd, GWLP_USERDATA, (LONG)this);
+ m_specific->create_pmap(width, height, &m_rbuf_window);
+ m_initial_width = width;
+ m_initial_height = height;
+ on_init();
+ m_specific->m_redraw_flag = true;
+ ::ShowWindow(m_specific->m_hwnd, g_windows_cmd_show);
+ return true;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ int platform_support::run()
+ {
+ MSG msg;
+
+ for(;;)
+ {
+ if(m_wait_mode)
+ {
+ if(!::GetMessage(&msg, 0, 0, 0))
+ {
+ break;
+ }
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+ else
+ {
+ if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ ::TranslateMessage(&msg);
+ if(msg.message == WM_QUIT)
+ {
+ break;
+ }
+ ::DispatchMessage(&msg);
+ }
+ else
+ {
+ on_idle();
+ }
+ }
+ }
+ return (int)msg.wParam;
+ }
+
+
+ //------------------------------------------------------------------------
+ const char* platform_support::img_ext() const { return ".bmp"; }
+
+
+ //------------------------------------------------------------------------
+ const char* platform_support::full_file_name(const char* file_name)
+ {
+ return file_name;
+ }
+
+ //------------------------------------------------------------------------
+ bool platform_support::load_img(unsigned idx, const char* file)
+ {
+ if(idx < max_images)
+ {
+ char fn[1024];
+ strcpy(fn, file);
+ int len = strlen(fn);
+ if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0)
+ {
+ strcat(fn, ".bmp");
+ }
+ return m_specific->load_pmap(fn, idx, &m_rbuf_img[idx]);
+ }
+ return true;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_support::save_img(unsigned idx, const char* file)
+ {
+ if(idx < max_images)
+ {
+ char fn[1024];
+ strcpy(fn, file);
+ int len = strlen(fn);
+ if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0)
+ {
+ strcat(fn, ".bmp");
+ }
+ return m_specific->save_pmap(fn, idx, &m_rbuf_img[idx]);
+ }
+ return true;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height)
+ {
+ if(idx < max_images)
+ {
+ if(width == 0) width = m_specific->m_pmap_window.width();
+ if(height == 0) height = m_specific->m_pmap_window.height();
+ m_specific->m_pmap_img[idx].create(width, height, org_e(m_specific->m_bpp));
+ m_rbuf_img[idx].attach(m_specific->m_pmap_img[idx].buf(),
+ m_specific->m_pmap_img[idx].width(),
+ m_specific->m_pmap_img[idx].height(),
+ m_flip_y ?
+ m_specific->m_pmap_img[idx].stride() :
+ -m_specific->m_pmap_img[idx].stride());
+ return true;
+ }
+ return false;
+ }
+
+
+ //------------------------------------------------------------------------
+ void platform_support::force_redraw()
+ {
+ m_specific->m_redraw_flag = true;
+ ::InvalidateRect(m_specific->m_hwnd, 0, FALSE);
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void platform_support::update_window()
+ {
+ HDC dc = ::GetDC(m_specific->m_hwnd);
+ m_specific->display_pmap(dc, &m_rbuf_window);
+ ::ReleaseDC(m_specific->m_hwnd, dc);
+ }
+
+
+ //------------------------------------------------------------------------
+ void platform_support::on_init() {}
+ void platform_support::on_resize(int sx, int sy) {}
+ void platform_support::on_idle() {}
+ void platform_support::on_mouse_move(int x, int y, unsigned flags) {}
+ void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {}
+ void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {}
+ void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {}
+ void platform_support::on_ctrl_change() {}
+ void platform_support::on_draw() {}
+ void platform_support::on_post_draw(void* raw_handler) {}
+}
+
+
+
+
+namespace agg
+{
+ // That's ridiculous. I have to parse the command line by myself
+ // because Windows doesn't provide a method of getting the command
+ // line arguments in a form of argc, argv. Of course, there's
+ // CommandLineToArgv() but first, it returns Unicode that I don't
+ // need to deal with, but most of all, it's not compatible with Win98.
+ //-----------------------------------------------------------------------
+ class tokenizer
+ {
+ public:
+ enum sep_flag
+ {
+ single,
+ multiple,
+ whole_str
+ };
+
+ struct token
+ {
+ const char* ptr;
+ unsigned len;
+ };
+
+ public:
+ tokenizer(const char* sep,
+ const char* trim=0,
+ const char* quote="\"",
+ char mask_chr='\\',
+ sep_flag sf=multiple);
+
+ void set_str(const char* str);
+ token next_token();
+
+ private:
+ int check_chr(const char *str, char chr);
+
+ private:
+ const char* m_src_string;
+ int m_start;
+ const char* m_sep;
+ const char* m_trim;
+ const char* m_quote;
+ char m_mask_chr;
+ unsigned m_sep_len;
+ sep_flag m_sep_flag;
+ };
+
+
+
+ //-----------------------------------------------------------------------
+ inline void tokenizer::set_str(const char* str)
+ {
+ m_src_string = str;
+ m_start = 0;
+ }
+
+
+ //-----------------------------------------------------------------------
+ inline int tokenizer::check_chr(const char *str, char chr)
+ {
+ return int(strchr(str, chr));
+ }
+
+
+ //-----------------------------------------------------------------------
+ tokenizer::tokenizer(const char* sep,
+ const char* trim,
+ const char* quote,
+ char mask_chr,
+ sep_flag sf) :
+ m_src_string(0),
+ m_start(0),
+ m_sep(sep),
+ m_trim(trim),
+ m_quote(quote),
+ m_mask_chr(mask_chr),
+ m_sep_len(sep ? strlen(sep) : 0),
+ m_sep_flag(sep ? sf : single)
+ {
+ }
+
+
+ //-----------------------------------------------------------------------
+ tokenizer::token tokenizer::next_token()
+ {
+ unsigned count = 0;
+ char quote_chr = 0;
+ token tok;
+
+ tok.ptr = 0;
+ tok.len = 0;
+ if(m_src_string == 0 || m_start == -1) return tok;
+
+ register const char *pstr = m_src_string + m_start;
+
+ if(*pstr == 0)
+ {
+ m_start = -1;
+ return tok;
+ }
+
+ int sep_len = 1;
+ if(m_sep_flag == whole_str) sep_len = m_sep_len;
+
+ if(m_sep_flag == multiple)
+ {
+ //Pass all the separator symbols at the begin of the string
+ while(*pstr && check_chr(m_sep, *pstr))
+ {
+ ++pstr;
+ ++m_start;
+ }
+ }
+
+ if(*pstr == 0)
+ {
+ m_start = -1;
+ return tok;
+ }
+
+ for(count = 0;; ++count)
+ {
+ char c = *pstr;
+ int found = 0;
+
+ //We are outside of qotation: find one of separator symbols
+ if(quote_chr == 0)
+ {
+ if(sep_len == 1)
+ {
+ found = check_chr(m_sep, c);
+ }
+ else
+ {
+ found = strncmp(m_sep, pstr, m_sep_len) == 0;
+ }
+ }
+
+ ++pstr;
+
+ if(c == 0 || found)
+ {
+ if(m_trim)
+ {
+ while(count &&
+ check_chr(m_trim, m_src_string[m_start]))
+ {
+ ++m_start;
+ --count;
+ }
+
+ while(count &&
+ check_chr(m_trim, m_src_string[m_start + count - 1]))
+ {
+ --count;
+ }
+ }
+
+ tok.ptr = m_src_string + m_start;
+ tok.len = count;
+
+ //Next time it will be the next separator character
+ //But we must check, whether it is NOT the end of the string.
+ m_start += count;
+ if(c)
+ {
+ m_start += sep_len;
+ if(m_sep_flag == multiple)
+ {
+ //Pass all the separator symbols
+ //after the end of the string
+ while(check_chr(m_sep, m_src_string[m_start]))
+ {
+ ++m_start;
+ }
+ }
+ }
+ break;
+ }
+
+ //Switch quote. If it is not a quote yet, try to check any of
+ //quote symbols. Otherwise quote must be finished with quote_symb
+ if(quote_chr == 0)
+ {
+ if(check_chr(m_quote, c))
+ {
+ quote_chr = c;
+ continue;
+ }
+ }
+ else
+ {
+ //We are inside quote: pass all the mask symbols
+ if(m_mask_chr && c == m_mask_chr)
+ {
+ if(*pstr)
+ {
+ ++count;
+ ++pstr;
+ }
+ continue;
+ }
+ if(c == quote_chr)
+ {
+ quote_chr = 0;
+ continue;
+ }
+ }
+ }
+ return tok;
+ }
+
+
+}
+
+
+
+//----------------------------------------------------------------------------
+int agg_main(int argc, char* argv[]);
+
+
+
+//----------------------------------------------------------------------------
+int PASCAL WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpszCmdLine,
+ int nCmdShow)
+{
+ agg::g_windows_instance = hInstance;
+ agg::g_windows_cmd_show = nCmdShow;
+
+ char* argv_str = new char [strlen(lpszCmdLine) + 3];
+ char* argv_ptr = argv_str;
+
+ char* argv[64];
+ memset(argv, 0, sizeof(argv));
+
+ agg::tokenizer cmd_line(" ", "\"' ", "\"'", '\\', agg::tokenizer::multiple);
+ cmd_line.set_str(lpszCmdLine);
+
+ int argc = 0;
+ argv[argc++] = argv_ptr;
+ *argv_ptr++ = 0;
+
+ while(argc < 64)
+ {
+ agg::tokenizer::token tok = cmd_line.next_token();
+ if(tok.ptr == 0) break;
+ if(tok.len)
+ {
+ memcpy(argv_ptr, tok.ptr, tok.len);
+ argv[argc++] = argv_ptr;
+ argv_ptr += tok.len;
+ *argv_ptr++ = 0;
+ }
+ }
+
+ int ret = agg_main(argc, argv);
+ delete [] argv_str;
+
+ return ret;
+}
+
+
+
+
diff --git a/plugins/Clist_ng/AGG/src/platform/win32/agg_win32_bmp.cpp b/plugins/Clist_ng/AGG/src/platform/win32/agg_win32_bmp.cpp new file mode 100644 index 0000000000..249eac9470 --- /dev/null +++ b/plugins/Clist_ng/AGG/src/platform/win32/agg_win32_bmp.cpp @@ -0,0 +1,625 @@ +//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
+// Contact: mcseemagg@yahoo.com
+//----------------------------------------------------------------------------
+//
+// class pixel_map
+//
+//----------------------------------------------------------------------------
+
+#include "platform/win32/agg_win32_bmp.h"
+#include "agg_basics.h"
+
+namespace agg
+{
+
+ //------------------------------------------------------------------------
+ pixel_map::~pixel_map()
+ {
+ destroy();
+ }
+
+
+ //------------------------------------------------------------------------
+ pixel_map::pixel_map() :
+ m_bmp(0),
+ m_buf(0),
+ m_bpp(0),
+ m_is_internal(false),
+ m_img_size(0),
+ m_full_size(0)
+
+ {
+ }
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::destroy()
+ {
+ if(m_bmp && m_is_internal) delete [] (unsigned char*)m_bmp;
+ m_bmp = 0;
+ m_is_internal = false;
+ m_buf = 0;
+ }
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::create(unsigned width,
+ unsigned height,
+ org_e org,
+ unsigned clear_val)
+ {
+ destroy();
+ if(width == 0) width = 1;
+ if(height == 0) height = 1;
+ m_bpp = org;
+ create_from_bmp(create_bitmap_info(width, height, m_bpp));
+ create_gray_scale_palette(m_bmp);
+ m_is_internal = true;
+ if(clear_val <= 255)
+ {
+ memset(m_buf, clear_val, m_img_size);
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ HBITMAP pixel_map::create_dib_section(HDC h_dc,
+ unsigned width,
+ unsigned height,
+ org_e org,
+ unsigned clear_val)
+ {
+ destroy();
+ if(width == 0) width = 1;
+ if(height == 0) height = 1;
+ m_bpp = org;
+ HBITMAP h_bitmap = create_dib_section_from_args(h_dc, width, height, m_bpp);
+ create_gray_scale_palette(m_bmp);
+ m_is_internal = true;
+ if(clear_val <= 255)
+ {
+ memset(m_buf, clear_val, m_img_size);
+ }
+ return h_bitmap;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::clear(unsigned clear_val)
+ {
+ if(m_buf) memset(m_buf, clear_val, m_img_size);
+ }
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::attach_to_bmp(BITMAPINFO *bmp)
+ {
+ if(bmp)
+ {
+ destroy();
+ create_from_bmp(bmp);
+ m_is_internal = false;
+ }
+ }
+
+
+
+ //static
+ //------------------------------------------------------------------------
+ unsigned pixel_map::calc_full_size(BITMAPINFO *bmp)
+ {
+ if(bmp == 0) return 0;
+
+ return sizeof(BITMAPINFOHEADER) +
+ sizeof(RGBQUAD) * calc_palette_size(bmp) +
+ bmp->bmiHeader.biSizeImage;
+ }
+
+ //static
+ //------------------------------------------------------------------------
+ unsigned pixel_map::calc_header_size(BITMAPINFO *bmp)
+ {
+ if(bmp == 0) return 0;
+ return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * calc_palette_size(bmp);
+ }
+
+
+ //static
+ //------------------------------------------------------------------------
+ unsigned pixel_map::calc_palette_size(unsigned clr_used, unsigned bits_per_pixel)
+ {
+ int palette_size = 0;
+
+ if(bits_per_pixel <= 8)
+ {
+ palette_size = clr_used;
+ if(palette_size == 0)
+ {
+ palette_size = 1 << bits_per_pixel;
+ }
+ }
+ return palette_size;
+ }
+
+ //static
+ //------------------------------------------------------------------------
+ unsigned pixel_map::calc_palette_size(BITMAPINFO *bmp)
+ {
+ if(bmp == 0) return 0;
+ return calc_palette_size(bmp->bmiHeader.biClrUsed, bmp->bmiHeader.biBitCount);
+ }
+
+
+ //static
+ //------------------------------------------------------------------------
+ unsigned char * pixel_map::calc_img_ptr(BITMAPINFO *bmp)
+ {
+ if(bmp == 0) return 0;
+ return ((unsigned char*)bmp) + calc_header_size(bmp);
+ }
+
+ //static
+ //------------------------------------------------------------------------
+ BITMAPINFO* pixel_map::create_bitmap_info(unsigned width,
+ unsigned height,
+ unsigned bits_per_pixel)
+ {
+ unsigned line_len = calc_row_len(width, bits_per_pixel);
+ unsigned img_size = line_len * height;
+ unsigned rgb_size = calc_palette_size(0, bits_per_pixel) * sizeof(RGBQUAD);
+ unsigned full_size = sizeof(BITMAPINFOHEADER) + rgb_size + img_size;
+
+ BITMAPINFO *bmp = (BITMAPINFO *) new unsigned char[full_size];
+
+ bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmp->bmiHeader.biWidth = width;
+ bmp->bmiHeader.biHeight = height;
+ bmp->bmiHeader.biPlanes = 1;
+ bmp->bmiHeader.biBitCount = (unsigned short)bits_per_pixel;
+ bmp->bmiHeader.biCompression = 0;
+ bmp->bmiHeader.biSizeImage = img_size;
+ bmp->bmiHeader.biXPelsPerMeter = 0;
+ bmp->bmiHeader.biYPelsPerMeter = 0;
+ bmp->bmiHeader.biClrUsed = 0;
+ bmp->bmiHeader.biClrImportant = 0;
+
+ return bmp;
+ }
+
+
+ //static
+ //------------------------------------------------------------------------
+ void pixel_map::create_gray_scale_palette(BITMAPINFO *bmp)
+ {
+ if(bmp == 0) return;
+
+ unsigned rgb_size = calc_palette_size(bmp);
+ RGBQUAD *rgb = (RGBQUAD*)(((unsigned char*)bmp) + sizeof(BITMAPINFOHEADER));
+ unsigned brightness;
+ unsigned i;
+
+ for(i = 0; i < rgb_size; i++)
+ {
+ brightness = (255 * i) / (rgb_size - 1);
+ rgb->rgbBlue =
+ rgb->rgbGreen =
+ rgb->rgbRed = (unsigned char)brightness;
+ rgb->rgbReserved = 0;
+ rgb++;
+ }
+ }
+
+
+
+ //static
+ //------------------------------------------------------------------------
+ unsigned pixel_map::calc_row_len(unsigned width, unsigned bits_per_pixel)
+ {
+ unsigned n = width;
+ unsigned k;
+
+ switch(bits_per_pixel)
+ {
+ case 1: k = n;
+ n = n >> 3;
+ if(k & 7) n++;
+ break;
+
+ case 4: k = n;
+ n = n >> 1;
+ if(k & 3) n++;
+ break;
+
+ case 8:
+ break;
+
+ case 16: n *= 2;
+ break;
+
+ case 24: n *= 3;
+ break;
+
+ case 32: n *= 4;
+ break;
+
+ case 48: n *= 6;
+ break;
+
+ case 64: n *= 8;
+ break;
+
+ default: n = 0;
+ break;
+ }
+ return ((n + 3) >> 2) << 2;
+ }
+
+
+
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::draw(HDC h_dc, const RECT *device_rect, const RECT *bmp_rect) const
+ {
+ if(m_bmp == 0 || m_buf == 0) return;
+
+ unsigned bmp_x = 0;
+ unsigned bmp_y = 0;
+ unsigned bmp_width = m_bmp->bmiHeader.biWidth;
+ unsigned bmp_height = m_bmp->bmiHeader.biHeight;
+ unsigned dvc_x = 0;
+ unsigned dvc_y = 0;
+ unsigned dvc_width = m_bmp->bmiHeader.biWidth;
+ unsigned dvc_height = m_bmp->bmiHeader.biHeight;
+
+ if(bmp_rect)
+ {
+ bmp_x = bmp_rect->left;
+ bmp_y = bmp_rect->top;
+ bmp_width = bmp_rect->right - bmp_rect->left;
+ bmp_height = bmp_rect->bottom - bmp_rect->top;
+ }
+
+ dvc_x = bmp_x;
+ dvc_y = bmp_y;
+ dvc_width = bmp_width;
+ dvc_height = bmp_height;
+
+ if(device_rect)
+ {
+ dvc_x = device_rect->left;
+ dvc_y = device_rect->top;
+ dvc_width = device_rect->right - device_rect->left;
+ dvc_height = device_rect->bottom - device_rect->top;
+ }
+
+ if(dvc_width != bmp_width || dvc_height != bmp_height)
+ {
+ ::SetStretchBltMode(h_dc, COLORONCOLOR);
+ ::StretchDIBits(
+ h_dc, // handle of device context
+ dvc_x, // x-coordinate of upper-left corner of source rect.
+ dvc_y, // y-coordinate of upper-left corner of source rect.
+ dvc_width, // width of source rectangle
+ dvc_height, // height of source rectangle
+ bmp_x,
+ bmp_y, // x, y -coordinates of upper-left corner of dest. rect.
+ bmp_width, // width of destination rectangle
+ bmp_height, // height of destination rectangle
+ m_buf, // address of bitmap bits
+ m_bmp, // address of bitmap data
+ DIB_RGB_COLORS, // usage
+ SRCCOPY // raster operation code
+ );
+ }
+ else
+ {
+ ::SetDIBitsToDevice(
+ h_dc, // handle to device context
+ dvc_x, // x-coordinate of upper-left corner of
+ dvc_y, // y-coordinate of upper-left corner of
+ dvc_width, // source rectangle width
+ dvc_height, // source rectangle height
+ bmp_x, // x-coordinate of lower-left corner of
+ bmp_y, // y-coordinate of lower-left corner of
+ 0, // first scan line in array
+ bmp_height, // number of scan lines
+ m_buf, // address of array with DIB bits
+ m_bmp, // address of structure with bitmap info.
+ DIB_RGB_COLORS // RGB or palette indexes
+ );
+ }
+ }
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::draw(HDC h_dc, int x, int y, double scale) const
+ {
+ if(m_bmp == 0 || m_buf == 0) return;
+
+ unsigned width = unsigned(m_bmp->bmiHeader.biWidth * scale);
+ unsigned height = unsigned(m_bmp->bmiHeader.biHeight * scale);
+ RECT rect;
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + width;
+ rect.bottom = y + height;
+ draw(h_dc, &rect);
+ }
+
+
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::blend(HDC h_dc, const RECT *device_rect, const RECT *bmp_rect) const
+ {
+#if !defined(AGG_BMP_ALPHA_BLEND)
+ draw(h_dc, device_rect, bmp_rect);
+ return;
+#else
+ if(m_bpp != 32)
+ {
+ draw(h_dc, device_rect, bmp_rect);
+ return;
+ }
+
+ if(m_bmp == 0 || m_buf == 0) return;
+
+ unsigned bmp_x = 0;
+ unsigned bmp_y = 0;
+ unsigned bmp_width = m_bmp->bmiHeader.biWidth;
+ unsigned bmp_height = m_bmp->bmiHeader.biHeight;
+ unsigned dvc_x = 0;
+ unsigned dvc_y = 0;
+ unsigned dvc_width = m_bmp->bmiHeader.biWidth;
+ unsigned dvc_height = m_bmp->bmiHeader.biHeight;
+
+ if(bmp_rect)
+ {
+ bmp_x = bmp_rect->left;
+ bmp_y = bmp_rect->top;
+ bmp_width = bmp_rect->right - bmp_rect->left;
+ bmp_height = bmp_rect->bottom - bmp_rect->top;
+ }
+
+ dvc_x = bmp_x;
+ dvc_y = bmp_y;
+ dvc_width = bmp_width;
+ dvc_height = bmp_height;
+
+ if(device_rect)
+ {
+ dvc_x = device_rect->left;
+ dvc_y = device_rect->top;
+ dvc_width = device_rect->right - device_rect->left;
+ dvc_height = device_rect->bottom - device_rect->top;
+ }
+
+ HDC mem_dc = ::CreateCompatibleDC(h_dc);
+ void* buf = 0;
+ HBITMAP bmp = ::CreateDIBSection(
+ mem_dc,
+ m_bmp,
+ DIB_RGB_COLORS,
+ &buf,
+ 0,
+ 0
+ );
+ memcpy(buf, m_buf, m_bmp->bmiHeader.biSizeImage);
+
+ HBITMAP temp = (HBITMAP)::SelectObject(mem_dc, bmp);
+
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+
+#if defined(AC_SRC_ALPHA)
+ blend.AlphaFormat = AC_SRC_ALPHA;
+//#elif defined(AC_SRC_NO_PREMULT_ALPHA)
+// blend.AlphaFormat = AC_SRC_NO_PREMULT_ALPHA;
+#else
+#error "No appropriate constant for alpha format. Check version of wingdi.h, There must be AC_SRC_ALPHA or AC_SRC_NO_PREMULT_ALPHA"
+#endif
+
+ blend.SourceConstantAlpha = 255;
+ ::AlphaBlend(
+ h_dc,
+ dvc_x,
+ dvc_y,
+ dvc_width,
+ dvc_height,
+ mem_dc,
+ bmp_x,
+ bmp_y,
+ bmp_width,
+ bmp_height,
+ blend
+ );
+
+ ::SelectObject(mem_dc, temp);
+ ::DeleteObject(bmp);
+ ::DeleteObject(mem_dc);
+#endif //defined(AGG_BMP_ALPHA_BLEND)
+ }
+
+
+ //------------------------------------------------------------------------
+ void pixel_map::blend(HDC h_dc, int x, int y, double scale) const
+ {
+ if(m_bmp == 0 || m_buf == 0) return;
+ unsigned width = unsigned(m_bmp->bmiHeader.biWidth * scale);
+ unsigned height = unsigned(m_bmp->bmiHeader.biHeight * scale);
+ RECT rect;
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + width;
+ rect.bottom = y + height;
+ blend(h_dc, &rect);
+ }
+
+
+ //------------------------------------------------------------------------
+ bool pixel_map::load_from_bmp(FILE *fd)
+ {
+ BITMAPFILEHEADER bmf;
+ BITMAPINFO *bmi = 0;
+ unsigned bmp_size;
+
+ fread(&bmf, sizeof(bmf), 1, fd);
+ if(bmf.bfType != 0x4D42) goto bmperr;
+
+ bmp_size = bmf.bfSize - sizeof(BITMAPFILEHEADER);
+
+ bmi = (BITMAPINFO*) new unsigned char [bmp_size];
+ if(fread(bmi, 1, bmp_size, fd) != bmp_size) goto bmperr;
+ destroy();
+ m_bpp = bmi->bmiHeader.biBitCount;
+ create_from_bmp(bmi);
+ m_is_internal = 1;
+ return true;
+
+ bmperr:
+ if(bmi) delete [] (unsigned char*) bmi;
+ return false;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool pixel_map::load_from_bmp(const char *filename)
+ {
+ FILE *fd = fopen(filename, "rb");
+ bool ret = false;
+ if(fd)
+ {
+ ret = load_from_bmp(fd);
+ fclose(fd);
+ }
+ return ret;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool pixel_map::save_as_bmp(FILE *fd) const
+ {
+ if(m_bmp == 0) return 0;
+
+ BITMAPFILEHEADER bmf;
+
+ bmf.bfType = 0x4D42;
+ bmf.bfOffBits = calc_header_size(m_bmp) + sizeof(bmf);
+ bmf.bfSize = bmf.bfOffBits + m_img_size;
+ bmf.bfReserved1 = 0;
+ bmf.bfReserved2 = 0;
+
+ fwrite(&bmf, sizeof(bmf), 1, fd);
+ fwrite(m_bmp, m_full_size, 1, fd);
+ return true;
+ }
+
+
+
+ //------------------------------------------------------------------------
+ bool pixel_map::save_as_bmp(const char *filename) const
+ {
+ FILE *fd = fopen(filename, "wb");
+ bool ret = false;
+ if(fd)
+ {
+ ret = save_as_bmp(fd);
+ fclose(fd);
+ }
+ return ret;
+ }
+
+
+ //------------------------------------------------------------------------
+ unsigned char* pixel_map::buf()
+ {
+ return m_buf;
+ }
+
+ //------------------------------------------------------------------------
+ unsigned pixel_map::width() const
+ {
+ return m_bmp->bmiHeader.biWidth;
+ }
+
+ //------------------------------------------------------------------------
+ unsigned pixel_map::height() const
+ {
+ return m_bmp->bmiHeader.biHeight;
+ }
+
+ //------------------------------------------------------------------------
+ int pixel_map::stride() const
+ {
+ return calc_row_len(m_bmp->bmiHeader.biWidth,
+ m_bmp->bmiHeader.biBitCount);
+ }
+
+
+ //private
+ //------------------------------------------------------------------------
+ void pixel_map::create_from_bmp(BITMAPINFO *bmp)
+ {
+ if(bmp)
+ {
+ m_img_size = calc_row_len(bmp->bmiHeader.biWidth,
+ bmp->bmiHeader.biBitCount) *
+ bmp->bmiHeader.biHeight;
+
+ m_full_size = calc_full_size(bmp);
+ m_bmp = bmp;
+ m_buf = calc_img_ptr(bmp);
+ }
+ }
+
+
+ //private
+ //------------------------------------------------------------------------
+ HBITMAP pixel_map::create_dib_section_from_args(HDC h_dc,
+ unsigned width,
+ unsigned height,
+ unsigned bits_per_pixel)
+ {
+ unsigned line_len = calc_row_len(width, bits_per_pixel);
+ unsigned img_size = line_len * height;
+ unsigned rgb_size = calc_palette_size(0, bits_per_pixel) * sizeof(RGBQUAD);
+ unsigned full_size = sizeof(BITMAPINFOHEADER) + rgb_size;
+
+ BITMAPINFO *bmp = (BITMAPINFO *) new unsigned char[full_size];
+
+ bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmp->bmiHeader.biWidth = width;
+ bmp->bmiHeader.biHeight = height;
+ bmp->bmiHeader.biPlanes = 1;
+ bmp->bmiHeader.biBitCount = (unsigned short)bits_per_pixel;
+ bmp->bmiHeader.biCompression = 0;
+ bmp->bmiHeader.biSizeImage = img_size;
+ bmp->bmiHeader.biXPelsPerMeter = 0;
+ bmp->bmiHeader.biYPelsPerMeter = 0;
+ bmp->bmiHeader.biClrUsed = 0;
+ bmp->bmiHeader.biClrImportant = 0;
+
+ void* img_ptr = 0;
+ HBITMAP h_bitmap = ::CreateDIBSection(h_dc, bmp, DIB_RGB_COLORS, &img_ptr, NULL, 0);
+
+ if(img_ptr)
+ {
+ m_img_size = calc_row_len(width, bits_per_pixel) * height;
+ m_full_size = 0;
+ m_bmp = bmp;
+ m_buf = (unsigned char *) img_ptr;
+ }
+
+ return h_bitmap;
+ }
+}
+
+
+
diff --git a/plugins/Clist_ng/AGG/src/readme b/plugins/Clist_ng/AGG/src/readme new file mode 100644 index 0000000000..d565c28a6b --- /dev/null +++ b/plugins/Clist_ng/AGG/src/readme @@ -0,0 +1,5 @@ +Use automake to build the library.
+
+If automake is not available you still can use the old make.
+There is a very simple Makefile that can be used. Note that
+if you use automake it will overwrite Makefile.
|