Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
196
3party/agg/ctrl/agg_bezier_ctrl.h
Normal file
196
3party/agg/ctrl/agg_bezier_ctrl.h
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes bezier_ctrl_impl, bezier_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_BEZIER_CTRL_INCLUDED
|
||||
#define AGG_BEZIER_CTRL_INCLUDED
|
||||
|
||||
#include "agg_math.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_conv_curve.h"
|
||||
#include "agg_polygon_ctrl.h"
|
||||
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//--------------------------------------------------------bezier_ctrl_impl
|
||||
class bezier_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
bezier_ctrl_impl();
|
||||
|
||||
void curve(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4);
|
||||
curve4& curve();
|
||||
|
||||
double x1() const { return m_poly.xn(0); }
|
||||
double y1() const { return m_poly.yn(0); }
|
||||
double x2() const { return m_poly.xn(1); }
|
||||
double y2() const { return m_poly.yn(1); }
|
||||
double x3() const { return m_poly.xn(2); }
|
||||
double y3() const { return m_poly.yn(2); }
|
||||
double x4() const { return m_poly.xn(3); }
|
||||
double y4() const { return m_poly.yn(3); }
|
||||
|
||||
void x1(double x) { m_poly.xn(0) = x; }
|
||||
void y1(double y) { m_poly.yn(0) = y; }
|
||||
void x2(double x) { m_poly.xn(1) = x; }
|
||||
void y2(double y) { m_poly.yn(1) = y; }
|
||||
void x3(double x) { m_poly.xn(2) = x; }
|
||||
void y3(double y) { m_poly.yn(2) = y; }
|
||||
void x4(double x) { m_poly.xn(3) = x; }
|
||||
void y4(double y) { m_poly.yn(3) = y; }
|
||||
|
||||
void line_width(double w) { m_stroke.width(w); }
|
||||
double line_width() const { return m_stroke.width(); }
|
||||
|
||||
void point_radius(double r) { m_poly.point_radius(r); }
|
||||
double point_radius() const { return m_poly.point_radius(); }
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
// Vertex source interface
|
||||
unsigned num_paths() { return 7; };
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
|
||||
private:
|
||||
curve4 m_curve;
|
||||
ellipse m_ellipse;
|
||||
conv_stroke<curve4> m_stroke;
|
||||
polygon_ctrl_impl m_poly;
|
||||
unsigned m_idx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------bezier_ctrl
|
||||
template<class ColorT> class bezier_ctrl : public bezier_ctrl_impl
|
||||
{
|
||||
public:
|
||||
bezier_ctrl() :
|
||||
m_color(rgba(0.0, 0.0, 0.0))
|
||||
{
|
||||
}
|
||||
|
||||
void line_color(const ColorT& c) { m_color = c; }
|
||||
const ColorT& color(unsigned i) const { return m_color; }
|
||||
|
||||
private:
|
||||
bezier_ctrl(const bezier_ctrl<ColorT>&);
|
||||
const bezier_ctrl<ColorT>& operator = (const bezier_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------curve3_ctrl_impl
|
||||
class curve3_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
curve3_ctrl_impl();
|
||||
|
||||
void curve(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3);
|
||||
curve3& curve();
|
||||
|
||||
double x1() const { return m_poly.xn(0); }
|
||||
double y1() const { return m_poly.yn(0); }
|
||||
double x2() const { return m_poly.xn(1); }
|
||||
double y2() const { return m_poly.yn(1); }
|
||||
double x3() const { return m_poly.xn(2); }
|
||||
double y3() const { return m_poly.yn(2); }
|
||||
|
||||
void x1(double x) { m_poly.xn(0) = x; }
|
||||
void y1(double y) { m_poly.yn(0) = y; }
|
||||
void x2(double x) { m_poly.xn(1) = x; }
|
||||
void y2(double y) { m_poly.yn(1) = y; }
|
||||
void x3(double x) { m_poly.xn(2) = x; }
|
||||
void y3(double y) { m_poly.yn(2) = y; }
|
||||
|
||||
void line_width(double w) { m_stroke.width(w); }
|
||||
double line_width() const { return m_stroke.width(); }
|
||||
|
||||
void point_radius(double r) { m_poly.point_radius(r); }
|
||||
double point_radius() const { return m_poly.point_radius(); }
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
// Vertex source interface
|
||||
unsigned num_paths() { return 6; };
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
|
||||
private:
|
||||
curve3 m_curve;
|
||||
ellipse m_ellipse;
|
||||
conv_stroke<curve3> m_stroke;
|
||||
polygon_ctrl_impl m_poly;
|
||||
unsigned m_idx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------curve3_ctrl
|
||||
template<class ColorT> class curve3_ctrl : public curve3_ctrl_impl
|
||||
{
|
||||
public:
|
||||
curve3_ctrl() :
|
||||
m_color(rgba(0.0, 0.0, 0.0))
|
||||
{
|
||||
}
|
||||
|
||||
void line_color(const ColorT& c) { m_color = c; }
|
||||
const ColorT& color(unsigned i) const { return m_color; }
|
||||
|
||||
private:
|
||||
curve3_ctrl(const curve3_ctrl<ColorT>&);
|
||||
const curve3_ctrl<ColorT>& operator = (const curve3_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
112
3party/agg/ctrl/agg_cbox_ctrl.h
Normal file
112
3party/agg/ctrl/agg_cbox_ctrl.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes cbox_ctrl_impl, cbox_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_CBOX_CTRL_INCLUDED
|
||||
#define AGG_CBOX_CTRL_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_gsv_text.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//----------------------------------------------------------cbox_ctrl_impl
|
||||
class cbox_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
cbox_ctrl_impl(double x, double y, const char* label, bool flip_y=false);
|
||||
|
||||
void text_thickness(double t) { m_text_thickness = t; }
|
||||
void text_size(double h, double w=0.0);
|
||||
|
||||
const char* label() { return m_label; }
|
||||
void label(const char* l);
|
||||
|
||||
bool status() const { return m_status; }
|
||||
void status(bool st) { m_status = st; }
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
// Vertex soutce interface
|
||||
unsigned num_paths() { return 3; };
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
double m_text_thickness;
|
||||
double m_text_height;
|
||||
double m_text_width;
|
||||
char m_label[128];
|
||||
bool m_status;
|
||||
double m_vx[32];
|
||||
double m_vy[32];
|
||||
|
||||
gsv_text m_text;
|
||||
conv_stroke<gsv_text> m_text_poly;
|
||||
|
||||
unsigned m_idx;
|
||||
unsigned m_vertex;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------cbox_ctrl_impl
|
||||
template<class ColorT> class cbox_ctrl : public cbox_ctrl_impl
|
||||
{
|
||||
public:
|
||||
cbox_ctrl(double x, double y, const char* label, bool flip_y=false) :
|
||||
cbox_ctrl_impl(x, y, label, flip_y),
|
||||
m_text_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_inactive_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_active_color(rgba(0.4, 0.0, 0.0))
|
||||
{
|
||||
m_colors[0] = &m_inactive_color;
|
||||
m_colors[1] = &m_text_color;
|
||||
m_colors[2] = &m_active_color;
|
||||
}
|
||||
|
||||
void text_color(const ColorT& c) { m_text_color = c; }
|
||||
void inactive_color(const ColorT& c) { m_inactive_color = c; }
|
||||
void active_color(const ColorT& c) { m_active_color = c; }
|
||||
|
||||
const ColorT& color(unsigned i) const { return *m_colors[i]; }
|
||||
|
||||
private:
|
||||
cbox_ctrl(const cbox_ctrl<ColorT>&);
|
||||
const cbox_ctrl<ColorT>& operator = (const cbox_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_text_color;
|
||||
ColorT m_inactive_color;
|
||||
ColorT m_active_color;
|
||||
ColorT* m_colors[3];
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
118
3party/agg/ctrl/agg_ctrl.h
Normal file
118
3party/agg/ctrl/agg_ctrl.h
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Function render_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_CTRL_INCLUDED
|
||||
#define AGG_CTRL_INCLUDED
|
||||
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------ctrl
|
||||
class ctrl
|
||||
{
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
virtual ~ctrl() {}
|
||||
ctrl(double x1, double y1, double x2, double y2, bool flip_y) :
|
||||
m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2),
|
||||
m_flip_y(flip_y),
|
||||
m_mtx(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
virtual bool in_rect(double x, double y) const = 0;
|
||||
virtual bool on_mouse_button_down(double x, double y) = 0;
|
||||
virtual bool on_mouse_button_up(double x, double y) = 0;
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag) = 0;
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up) = 0;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void transform(const trans_affine& mtx) { m_mtx = &mtx; }
|
||||
void no_transform() { m_mtx = 0; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void transform_xy(double* x, double* y) const
|
||||
{
|
||||
if(m_flip_y) *y = m_y1 + m_y2 - *y;
|
||||
if(m_mtx) m_mtx->transform(x, y);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void inverse_transform_xy(double* x, double* y) const
|
||||
{
|
||||
if(m_mtx) m_mtx->inverse_transform(x, y);
|
||||
if(m_flip_y) *y = m_y1 + m_y2 - *y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double scale() const { return m_mtx ? m_mtx->scale() : 1.0; }
|
||||
|
||||
private:
|
||||
ctrl(const ctrl&);
|
||||
const ctrl& operator = (const ctrl&);
|
||||
|
||||
protected:
|
||||
double m_x1;
|
||||
double m_y1;
|
||||
double m_x2;
|
||||
double m_y2;
|
||||
|
||||
private:
|
||||
bool m_flip_y;
|
||||
const trans_affine* m_mtx;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Rasterizer, class Scanline, class Renderer, class Ctrl>
|
||||
void render_ctrl(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < c.num_paths(); i++)
|
||||
{
|
||||
ras.reset();
|
||||
ras.add_path(c, i);
|
||||
render_scanlines_aa_solid(ras, sl, r, c.color(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Rasterizer, class Scanline, class Renderer, class Ctrl>
|
||||
void render_ctrl_rs(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < c.num_paths(); i++)
|
||||
{
|
||||
ras.reset();
|
||||
ras.add_path(c, i);
|
||||
r.color(c.color(i));
|
||||
render_scanlines(ras, sl, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
170
3party/agg/ctrl/agg_gamma_ctrl.h
Normal file
170
3party/agg/ctrl/agg_gamma_ctrl.h
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// class gamma_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_GAMMA_CTRL_INCLUDED
|
||||
#define AGG_GAMMA_CTRL_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_gamma_spline.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_gsv_text.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
//------------------------------------------------------------------------
|
||||
// Class that can be used to create an interactive control to set up
|
||||
// gamma arrays.
|
||||
//------------------------------------------------------------------------
|
||||
class gamma_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
gamma_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false);
|
||||
|
||||
// Set other parameters
|
||||
void border_width(double t, double extra=0.0);
|
||||
void curve_width(double t) { m_curve_width = t; }
|
||||
void grid_width(double t) { m_grid_width = t; }
|
||||
void text_thickness(double t) { m_text_thickness = t; }
|
||||
void text_size(double h, double w=0.0);
|
||||
void point_size(double s) { m_point_size = s; }
|
||||
|
||||
// Event handlers. Just call them if the respective events
|
||||
// in your system occure. The functions return true if redrawing
|
||||
// is required.
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
void change_active_point();
|
||||
|
||||
// A copy of agg::gamma_spline interface
|
||||
void values(double kx1, double ky1, double kx2, double ky2);
|
||||
void values(double* kx1, double* ky1, double* kx2, double* ky2) const;
|
||||
const unsigned char* gamma() const { return m_gamma_spline.gamma(); }
|
||||
double y(double x) const { return m_gamma_spline.y(x); }
|
||||
double operator() (double x) const { return m_gamma_spline.y(x); }
|
||||
const gamma_spline& get_gamma_spline() const { return m_gamma_spline; }
|
||||
|
||||
// Vertex soutce interface
|
||||
unsigned num_paths() { return 7; }
|
||||
void rewind(unsigned idx);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
void calc_spline_box();
|
||||
void calc_points();
|
||||
void calc_values();
|
||||
|
||||
gamma_spline m_gamma_spline;
|
||||
double m_border_width;
|
||||
double m_border_extra;
|
||||
double m_curve_width;
|
||||
double m_grid_width;
|
||||
double m_text_thickness;
|
||||
double m_point_size;
|
||||
double m_text_height;
|
||||
double m_text_width;
|
||||
double m_xc1;
|
||||
double m_yc1;
|
||||
double m_xc2;
|
||||
double m_yc2;
|
||||
double m_xs1;
|
||||
double m_ys1;
|
||||
double m_xs2;
|
||||
double m_ys2;
|
||||
double m_xt1;
|
||||
double m_yt1;
|
||||
double m_xt2;
|
||||
double m_yt2;
|
||||
conv_stroke<gamma_spline> m_curve_poly;
|
||||
ellipse m_ellipse;
|
||||
gsv_text m_text;
|
||||
conv_stroke<gsv_text> m_text_poly;
|
||||
unsigned m_idx;
|
||||
unsigned m_vertex;
|
||||
double m_vx[32];
|
||||
double m_vy[32];
|
||||
double m_xp1;
|
||||
double m_yp1;
|
||||
double m_xp2;
|
||||
double m_yp2;
|
||||
bool m_p1_active;
|
||||
unsigned m_mouse_point;
|
||||
double m_pdx;
|
||||
double m_pdy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class ColorT> class gamma_ctrl : public gamma_ctrl_impl
|
||||
{
|
||||
public:
|
||||
gamma_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) :
|
||||
gamma_ctrl_impl(x1, y1, x2, y2, flip_y),
|
||||
m_background_color(rgba(1.0, 1.0, 0.9)),
|
||||
m_border_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_curve_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_grid_color(rgba(0.2, 0.2, 0.0)),
|
||||
m_inactive_pnt_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_active_pnt_color(rgba(1.0, 0.0, 0.0)),
|
||||
m_text_color(rgba(0.0, 0.0, 0.0))
|
||||
{
|
||||
m_colors[0] = &m_background_color;
|
||||
m_colors[1] = &m_border_color;
|
||||
m_colors[2] = &m_curve_color;
|
||||
m_colors[3] = &m_grid_color;
|
||||
m_colors[4] = &m_inactive_pnt_color;
|
||||
m_colors[5] = &m_active_pnt_color;
|
||||
m_colors[6] = &m_text_color;
|
||||
}
|
||||
|
||||
// Set colors
|
||||
void background_color(const ColorT& c) { m_background_color = c; }
|
||||
void border_color(const ColorT& c) { m_border_color = c; }
|
||||
void curve_color(const ColorT& c) { m_curve_color = c; }
|
||||
void grid_color(const ColorT& c) { m_grid_color = c; }
|
||||
void inactive_pnt_color(const ColorT& c) { m_inactive_pnt_color = c; }
|
||||
void active_pnt_color(const ColorT& c) { m_active_pnt_color = c; }
|
||||
void text_color(const ColorT& c) { m_text_color = c; }
|
||||
const ColorT& color(unsigned i) const { return *m_colors[i]; }
|
||||
|
||||
private:
|
||||
gamma_ctrl(const gamma_ctrl<ColorT>&);
|
||||
const gamma_ctrl<ColorT>& operator = (const gamma_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_background_color;
|
||||
ColorT m_border_color;
|
||||
ColorT m_curve_color;
|
||||
ColorT m_grid_color;
|
||||
ColorT m_inactive_pnt_color;
|
||||
ColorT m_active_pnt_color;
|
||||
ColorT m_text_color;
|
||||
ColorT* m_colors[7];
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
95
3party/agg/ctrl/agg_gamma_spline.h
Normal file
95
3party/agg/ctrl/agg_gamma_spline.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// class gamma_spline
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_GAMMA_SPLINE_INCLUDED
|
||||
#define AGG_GAMMA_SPLINE_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_bspline.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Class-helper for calculation gamma-correction arrays. A gamma-correction
|
||||
// array is an array of 256 unsigned chars that determine the actual values
|
||||
// of Anti-Aliasing for each pixel coverage value from 0 to 255. If all the
|
||||
// values in the array are equal to its index, i.e. 0,1,2,3,... there's
|
||||
// no gamma-correction. Class agg::polyfill allows you to use custom
|
||||
// gamma-correction arrays. You can calculate it using any approach, and
|
||||
// class gamma_spline allows you to calculate almost any reasonable shape
|
||||
// of the gamma-curve with using only 4 values - kx1, ky1, kx2, ky2.
|
||||
//
|
||||
// kx2
|
||||
// +----------------------------------+
|
||||
// | | | . |
|
||||
// | | | . | ky2
|
||||
// | | . ------|
|
||||
// | | . |
|
||||
// | | . |
|
||||
// |----------------.|----------------|
|
||||
// | . | |
|
||||
// | . | |
|
||||
// |-------. | |
|
||||
// ky1 | . | | |
|
||||
// | . | | |
|
||||
// +----------------------------------+
|
||||
// kx1
|
||||
//
|
||||
// Each value can be in range [0...2]. Value 1.0 means one quarter of the
|
||||
// bounding rectangle. Function values() calculates the curve by these
|
||||
// 4 values. After calling it one can get the gamma-array with call gamma().
|
||||
// Class also supports the vertex source interface, i.e rewind() and
|
||||
// vertex(). It's made for convinience and used in class gamma_ctrl.
|
||||
// Before calling rewind/vertex one must set the bounding box
|
||||
// box() using pixel coordinates.
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
class gamma_spline
|
||||
{
|
||||
public:
|
||||
gamma_spline();
|
||||
|
||||
void values(double kx1, double ky1, double kx2, double ky2);
|
||||
const unsigned char* gamma() const { return m_gamma; }
|
||||
double y(double x) const;
|
||||
void values(double* kx1, double* ky1, double* kx2, double* ky2) const;
|
||||
void box(double x1, double y1, double x2, double y2);
|
||||
|
||||
void rewind(unsigned);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
unsigned char m_gamma[256];
|
||||
double m_x[4];
|
||||
double m_y[4];
|
||||
bspline m_spline;
|
||||
double m_x1;
|
||||
double m_y1;
|
||||
double m_x2;
|
||||
double m_y2;
|
||||
double m_cur_x;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
166
3party/agg/ctrl/agg_polygon_ctrl.h
Normal file
166
3party/agg/ctrl/agg_polygon_ctrl.h
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes polygon_ctrl_impl, polygon_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef POLYGON_CTRL_INCLUDED
|
||||
#define POLYGON_CTRL_INCLUDED
|
||||
|
||||
#include "agg_array.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
class simple_polygon_vertex_source
|
||||
{
|
||||
public:
|
||||
simple_polygon_vertex_source(const double* polygon, unsigned np,
|
||||
bool roundoff = false,
|
||||
bool close = true) :
|
||||
m_polygon(polygon),
|
||||
m_num_points(np),
|
||||
m_vertex(0),
|
||||
m_roundoff(roundoff),
|
||||
m_close(close)
|
||||
{
|
||||
}
|
||||
|
||||
void close(bool f) { m_close = f; }
|
||||
bool close() const { return m_close; }
|
||||
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_vertex = 0;
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
if(m_vertex > m_num_points) return path_cmd_stop;
|
||||
if(m_vertex == m_num_points)
|
||||
{
|
||||
++m_vertex;
|
||||
return path_cmd_end_poly | (m_close ? path_flags_close : 0);
|
||||
}
|
||||
*x = m_polygon[m_vertex * 2];
|
||||
*y = m_polygon[m_vertex * 2 + 1];
|
||||
if(m_roundoff)
|
||||
{
|
||||
*x = floor(*x) + 0.5;
|
||||
*y = floor(*y) + 0.5;
|
||||
}
|
||||
++m_vertex;
|
||||
return (m_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
|
||||
}
|
||||
|
||||
private:
|
||||
const double* m_polygon;
|
||||
unsigned m_num_points;
|
||||
unsigned m_vertex;
|
||||
bool m_roundoff;
|
||||
bool m_close;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class polygon_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
polygon_ctrl_impl(unsigned np, double point_radius=5);
|
||||
|
||||
unsigned num_points() const { return m_num_points; }
|
||||
double xn(unsigned n) const { return m_polygon[n * 2]; }
|
||||
double yn(unsigned n) const { return m_polygon[n * 2 + 1]; }
|
||||
double& xn(unsigned n) { return m_polygon[n * 2]; }
|
||||
double& yn(unsigned n) { return m_polygon[n * 2 + 1]; }
|
||||
|
||||
const double* polygon() const { return &m_polygon[0]; }
|
||||
|
||||
void line_width(double w) { m_stroke.width(w); }
|
||||
double line_width() const { return m_stroke.width(); }
|
||||
|
||||
void point_radius(double r) { m_point_radius = r; }
|
||||
double point_radius() const { return m_point_radius; }
|
||||
|
||||
void in_polygon_check(bool f) { m_in_polygon_check = f; }
|
||||
bool in_polygon_check() const { return m_in_polygon_check; }
|
||||
|
||||
void close(bool f) { m_vs.close(f); }
|
||||
bool close() const { return m_vs.close(); }
|
||||
|
||||
// Vertex source interface
|
||||
unsigned num_paths() { return 1; }
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
|
||||
private:
|
||||
bool check_edge(unsigned i, double x, double y) const;
|
||||
bool point_in_polygon(double x, double y) const;
|
||||
|
||||
pod_array<double> m_polygon;
|
||||
unsigned m_num_points;
|
||||
int m_node;
|
||||
int m_edge;
|
||||
simple_polygon_vertex_source m_vs;
|
||||
conv_stroke<simple_polygon_vertex_source> m_stroke;
|
||||
ellipse m_ellipse;
|
||||
double m_point_radius;
|
||||
unsigned m_status;
|
||||
double m_dx;
|
||||
double m_dy;
|
||||
bool m_in_polygon_check;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------polygon_ctrl
|
||||
template<class ColorT> class polygon_ctrl : public polygon_ctrl_impl
|
||||
{
|
||||
public:
|
||||
polygon_ctrl(unsigned np, double point_radius=5) :
|
||||
polygon_ctrl_impl(np, point_radius),
|
||||
m_color(rgba(0.0, 0.0, 0.0))
|
||||
{
|
||||
}
|
||||
|
||||
void line_color(const ColorT& c) { m_color = c; }
|
||||
const ColorT& color(unsigned i) const { return m_color; }
|
||||
|
||||
private:
|
||||
polygon_ctrl(const polygon_ctrl<ColorT>&);
|
||||
const polygon_ctrl<ColorT>& operator = (const polygon_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
141
3party/agg/ctrl/agg_rbox_ctrl.h
Normal file
141
3party/agg/ctrl/agg_rbox_ctrl.h
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes rbox_ctrl_impl, rbox_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_RBOX_CTRL_INCLUDED
|
||||
#define AGG_RBOX_CTRL_INCLUDED
|
||||
|
||||
#include "agg_array.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_gsv_text.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
class rbox_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
rbox_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false);
|
||||
|
||||
void border_width(double t, double extra=0.0);
|
||||
void text_thickness(double t) { m_text_thickness = t; }
|
||||
void text_size(double h, double w=0.0);
|
||||
|
||||
void add_item(const char* text);
|
||||
int cur_item() const { return m_cur_item; }
|
||||
void cur_item(int i) { m_cur_item = i; }
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
// Vertex soutce interface
|
||||
unsigned num_paths() { return 5; };
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
void calc_rbox();
|
||||
|
||||
double m_border_width;
|
||||
double m_border_extra;
|
||||
double m_text_thickness;
|
||||
double m_text_height;
|
||||
double m_text_width;
|
||||
pod_array<char> m_items[32];
|
||||
unsigned m_num_items;
|
||||
int m_cur_item;
|
||||
|
||||
double m_xs1;
|
||||
double m_ys1;
|
||||
double m_xs2;
|
||||
double m_ys2;
|
||||
|
||||
double m_vx[32];
|
||||
double m_vy[32];
|
||||
unsigned m_draw_item;
|
||||
double m_dy;
|
||||
|
||||
ellipse m_ellipse;
|
||||
conv_stroke<ellipse> m_ellipse_poly;
|
||||
gsv_text m_text;
|
||||
conv_stroke<gsv_text> m_text_poly;
|
||||
|
||||
unsigned m_idx;
|
||||
unsigned m_vertex;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class ColorT> class rbox_ctrl : public rbox_ctrl_impl
|
||||
{
|
||||
public:
|
||||
rbox_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) :
|
||||
rbox_ctrl_impl(x1, y1, x2, y2, flip_y),
|
||||
m_background_color(rgba(1.0, 1.0, 0.9)),
|
||||
m_border_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_text_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_inactive_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_active_color(rgba(0.4, 0.0, 0.0))
|
||||
{
|
||||
m_colors[0] = &m_background_color;
|
||||
m_colors[1] = &m_border_color;
|
||||
m_colors[2] = &m_text_color;
|
||||
m_colors[3] = &m_inactive_color;
|
||||
m_colors[4] = &m_active_color;
|
||||
}
|
||||
|
||||
|
||||
void background_color(const ColorT& c) { m_background_color = c; }
|
||||
void border_color(const ColorT& c) { m_border_color = c; }
|
||||
void text_color(const ColorT& c) { m_text_color = c; }
|
||||
void inactive_color(const ColorT& c) { m_inactive_color = c; }
|
||||
void active_color(const ColorT& c) { m_active_color = c; }
|
||||
|
||||
const ColorT& color(unsigned i) const { return *m_colors[i]; }
|
||||
|
||||
private:
|
||||
rbox_ctrl(const rbox_ctrl<ColorT>&);
|
||||
const rbox_ctrl<ColorT>& operator = (const rbox_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_background_color;
|
||||
ColorT m_border_color;
|
||||
ColorT m_text_color;
|
||||
ColorT m_inactive_color;
|
||||
ColorT m_active_color;
|
||||
ColorT* m_colors[5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
146
3party/agg/ctrl/agg_scale_ctrl.h
Normal file
146
3party/agg/ctrl/agg_scale_ctrl.h
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes scale_ctrl_impl, scale_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_SCALE_CTRL_INCLUDED
|
||||
#define AGG_SCALE_CTRL_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_math.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
class scale_ctrl_impl : public ctrl
|
||||
{
|
||||
enum move_e
|
||||
{
|
||||
move_nothing,
|
||||
move_value1,
|
||||
move_value2,
|
||||
move_slider
|
||||
};
|
||||
|
||||
public:
|
||||
scale_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false);
|
||||
|
||||
void border_thickness(double t, double extra=0.0);
|
||||
void resize(double x1, double y1, double x2, double y2);
|
||||
|
||||
double min_delta() const { return m_min_d; }
|
||||
void min_delta(double d) { m_min_d = d; }
|
||||
|
||||
double value1() const { return m_value1; }
|
||||
void value1(double value);
|
||||
|
||||
double value2() const { return m_value2; }
|
||||
void value2(double value);
|
||||
|
||||
void move(double d);
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
// Vertex soutce interface
|
||||
unsigned num_paths() { return 5; };
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
void calc_box();
|
||||
|
||||
double m_border_thickness;
|
||||
double m_border_extra;
|
||||
double m_value1;
|
||||
double m_value2;
|
||||
double m_min_d;
|
||||
double m_xs1;
|
||||
double m_ys1;
|
||||
double m_xs2;
|
||||
double m_ys2;
|
||||
double m_pdx;
|
||||
double m_pdy;
|
||||
move_e m_move_what;
|
||||
double m_vx[32];
|
||||
double m_vy[32];
|
||||
|
||||
ellipse m_ellipse;
|
||||
|
||||
unsigned m_idx;
|
||||
unsigned m_vertex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class ColorT> class scale_ctrl : public scale_ctrl_impl
|
||||
{
|
||||
public:
|
||||
scale_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) :
|
||||
scale_ctrl_impl(x1, y1, x2, y2, flip_y),
|
||||
m_background_color(rgba(1.0, 0.9, 0.8)),
|
||||
m_border_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_pointers_color(rgba(0.8, 0.0, 0.0, 0.8)),
|
||||
m_slider_color(rgba(0.2, 0.1, 0.0, 0.6))
|
||||
{
|
||||
m_colors[0] = &m_background_color;
|
||||
m_colors[1] = &m_border_color;
|
||||
m_colors[2] = &m_pointers_color;
|
||||
m_colors[3] = &m_pointers_color;
|
||||
m_colors[4] = &m_slider_color;
|
||||
}
|
||||
|
||||
|
||||
void background_color(const ColorT& c) { m_background_color = c; }
|
||||
void border_color(const ColorT& c) { m_border_color = c; }
|
||||
void pointers_color(const ColorT& c) { m_pointers_color = c; }
|
||||
void slider_color(const ColorT& c) { m_slider_color = c; }
|
||||
|
||||
const ColorT& color(unsigned i) const { return *m_colors[i]; }
|
||||
|
||||
private:
|
||||
scale_ctrl(const scale_ctrl<ColorT>&);
|
||||
const scale_ctrl<ColorT>& operator = (const scale_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_background_color;
|
||||
ColorT m_border_color;
|
||||
ColorT m_pointers_color;
|
||||
ColorT m_slider_color;
|
||||
ColorT* m_colors[5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
150
3party/agg/ctrl/agg_slider_ctrl.h
Normal file
150
3party/agg/ctrl/agg_slider_ctrl.h
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes slider_ctrl_impl, slider_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_SLIDER_CTRL_INCLUDED
|
||||
#define AGG_SLIDER_CTRL_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_math.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_gsv_text.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_path_storage.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//--------------------------------------------------------slider_ctrl_impl
|
||||
class slider_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
slider_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false);
|
||||
|
||||
void border_width(double t, double extra=0.0);
|
||||
|
||||
void range(double min, double max) { m_min = min; m_max = max; }
|
||||
void num_steps(unsigned num) { m_num_steps = num; }
|
||||
void label(const char* fmt);
|
||||
void text_thickness(double t) { m_text_thickness = t; }
|
||||
|
||||
bool descending() const { return m_descending; }
|
||||
void descending(bool v) { m_descending = v; }
|
||||
|
||||
double value() const { return m_value * (m_max - m_min) + m_min; }
|
||||
void value(double value);
|
||||
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
// Vertex source interface
|
||||
unsigned num_paths() { return 6; };
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
void calc_box();
|
||||
bool normalize_value(bool preview_value_flag);
|
||||
|
||||
double m_border_width;
|
||||
double m_border_extra;
|
||||
double m_text_thickness;
|
||||
double m_value;
|
||||
double m_preview_value;
|
||||
double m_min;
|
||||
double m_max;
|
||||
unsigned m_num_steps;
|
||||
bool m_descending;
|
||||
char m_label[64];
|
||||
double m_xs1;
|
||||
double m_ys1;
|
||||
double m_xs2;
|
||||
double m_ys2;
|
||||
double m_pdx;
|
||||
bool m_mouse_move;
|
||||
double m_vx[32];
|
||||
double m_vy[32];
|
||||
|
||||
ellipse m_ellipse;
|
||||
|
||||
unsigned m_idx;
|
||||
unsigned m_vertex;
|
||||
|
||||
gsv_text m_text;
|
||||
conv_stroke<gsv_text> m_text_poly;
|
||||
path_storage m_storage;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------slider_ctrl
|
||||
template<class ColorT> class slider_ctrl : public slider_ctrl_impl
|
||||
{
|
||||
public:
|
||||
slider_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) :
|
||||
slider_ctrl_impl(x1, y1, x2, y2, flip_y),
|
||||
m_background_color(rgba(1.0, 0.9, 0.8)),
|
||||
m_triangle_color(rgba(0.7, 0.6, 0.6)),
|
||||
m_text_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_pointer_preview_color(rgba(0.6, 0.4, 0.4, 0.4)),
|
||||
m_pointer_color(rgba(0.8, 0.0, 0.0, 0.6))
|
||||
{
|
||||
m_colors[0] = &m_background_color;
|
||||
m_colors[1] = &m_triangle_color;
|
||||
m_colors[2] = &m_text_color;
|
||||
m_colors[3] = &m_pointer_preview_color;
|
||||
m_colors[4] = &m_pointer_color;
|
||||
m_colors[5] = &m_text_color;
|
||||
}
|
||||
|
||||
|
||||
void background_color(const ColorT& c) { m_background_color = c; }
|
||||
void pointer_color(const ColorT& c) { m_pointer_color = c; }
|
||||
|
||||
const ColorT& color(unsigned i) const { return *m_colors[i]; }
|
||||
|
||||
private:
|
||||
slider_ctrl(const slider_ctrl<ColorT>&);
|
||||
const slider_ctrl<ColorT>& operator = (const slider_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_background_color;
|
||||
ColorT m_triangle_color;
|
||||
ColorT m_text_color;
|
||||
ColorT m_pointer_preview_color;
|
||||
ColorT m_pointer_color;
|
||||
ColorT* m_colors[6];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
159
3party/agg/ctrl/agg_spline_ctrl.h
Normal file
159
3party/agg/ctrl/agg_spline_ctrl.h
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// classes spline_ctrl_impl, spline_ctrl
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_SPLINE_CTRL_INCLUDED
|
||||
#define AGG_SPLINE_CTRL_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_bspline.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
#include "agg_path_storage.h"
|
||||
#include "agg_trans_affine.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_ctrl.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Class that can be used to create an interactive control to set up
|
||||
// gamma arrays.
|
||||
//------------------------------------------------------------------------
|
||||
class spline_ctrl_impl : public ctrl
|
||||
{
|
||||
public:
|
||||
spline_ctrl_impl(double x1, double y1, double x2, double y2,
|
||||
unsigned num_pnt, bool flip_y=false);
|
||||
|
||||
// Set other parameters
|
||||
void border_width(double t, double extra=0.0);
|
||||
void curve_width(double t) { m_curve_width = t; }
|
||||
void point_size(double s) { m_point_size = s; }
|
||||
|
||||
// Event handlers. Just call them if the respective events
|
||||
// in your system occure. The functions return true if redrawing
|
||||
// is required.
|
||||
virtual bool in_rect(double x, double y) const;
|
||||
virtual bool on_mouse_button_down(double x, double y);
|
||||
virtual bool on_mouse_button_up(double x, double y);
|
||||
virtual bool on_mouse_move(double x, double y, bool button_flag);
|
||||
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
|
||||
|
||||
void active_point(int i);
|
||||
|
||||
const double* spline() const { return m_spline_values; }
|
||||
const int8u* spline8() const { return m_spline_values8; }
|
||||
double value(double x) const;
|
||||
void value(unsigned idx, double y);
|
||||
void point(unsigned idx, double x, double y);
|
||||
void x(unsigned idx, double x) { m_xp[idx] = x; }
|
||||
void y(unsigned idx, double y) { m_yp[idx] = y; }
|
||||
double x(unsigned idx) const { return m_xp[idx]; }
|
||||
double y(unsigned idx) const { return m_yp[idx]; }
|
||||
void update_spline();
|
||||
|
||||
// Vertex soutce interface
|
||||
unsigned num_paths() { return 5; }
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
private:
|
||||
void calc_spline_box();
|
||||
void calc_curve();
|
||||
double calc_xp(unsigned idx);
|
||||
double calc_yp(unsigned idx);
|
||||
void set_xp(unsigned idx, double val);
|
||||
void set_yp(unsigned idx, double val);
|
||||
|
||||
unsigned m_num_pnt;
|
||||
double m_xp[32];
|
||||
double m_yp[32];
|
||||
bspline m_spline;
|
||||
double m_spline_values[256];
|
||||
int8u m_spline_values8[256];
|
||||
double m_border_width;
|
||||
double m_border_extra;
|
||||
double m_curve_width;
|
||||
double m_point_size;
|
||||
double m_xs1;
|
||||
double m_ys1;
|
||||
double m_xs2;
|
||||
double m_ys2;
|
||||
path_storage m_curve_pnt;
|
||||
conv_stroke<path_storage> m_curve_poly;
|
||||
ellipse m_ellipse;
|
||||
unsigned m_idx;
|
||||
unsigned m_vertex;
|
||||
double m_vx[32];
|
||||
double m_vy[32];
|
||||
int m_active_pnt;
|
||||
int m_move_pnt;
|
||||
double m_pdx;
|
||||
double m_pdy;
|
||||
const trans_affine* m_mtx;
|
||||
};
|
||||
|
||||
|
||||
template<class ColorT> class spline_ctrl : public spline_ctrl_impl
|
||||
{
|
||||
public:
|
||||
spline_ctrl(double x1, double y1, double x2, double y2,
|
||||
unsigned num_pnt, bool flip_y=false) :
|
||||
spline_ctrl_impl(x1, y1, x2, y2, num_pnt, flip_y),
|
||||
m_background_color(rgba(1.0, 1.0, 0.9)),
|
||||
m_border_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_curve_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_inactive_pnt_color(rgba(0.0, 0.0, 0.0)),
|
||||
m_active_pnt_color(rgba(1.0, 0.0, 0.0))
|
||||
{
|
||||
m_colors[0] = &m_background_color;
|
||||
m_colors[1] = &m_border_color;
|
||||
m_colors[2] = &m_curve_color;
|
||||
m_colors[3] = &m_inactive_pnt_color;
|
||||
m_colors[4] = &m_active_pnt_color;
|
||||
}
|
||||
|
||||
// Set colors
|
||||
void background_color(const ColorT& c) { m_background_color = c; }
|
||||
void border_color(const ColorT& c) { m_border_color = c; }
|
||||
void curve_color(const ColorT& c) { m_curve_color = c; }
|
||||
void inactive_pnt_color(const ColorT& c) { m_inactive_pnt_color = c; }
|
||||
void active_pnt_color(const ColorT& c) { m_active_pnt_color = c; }
|
||||
const ColorT& color(unsigned i) const { return *m_colors[i]; }
|
||||
|
||||
private:
|
||||
spline_ctrl(const spline_ctrl<ColorT>&);
|
||||
const spline_ctrl<ColorT>& operator = (const spline_ctrl<ColorT>&);
|
||||
|
||||
ColorT m_background_color;
|
||||
ColorT m_border_color;
|
||||
ColorT m_curve_color;
|
||||
ColorT m_inactive_pnt_color;
|
||||
ColorT m_active_pnt_color;
|
||||
ColorT* m_colors[5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue