1
//----------------------------------------------------------------------------
2
// Anti-Grain Geometry - Version 2.4
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5
// Permission to copy, use, modify, sell and distribute this software
6
// is granted provided this copyright notice appears in all copies.
7
// This software is provided "as is" without express or implied
8
// warranty, and with no claim as to its suitability for any purpose.
10
//----------------------------------------------------------------------------
11
// Contact: mcseem@antigrain.com
12
// mcseemagg@yahoo.com
13
// http://www.antigrain.com
14
//----------------------------------------------------------------------------
16
// Function render_ctrl
18
//----------------------------------------------------------------------------
20
#ifndef AGG_CTRL_INCLUDED
21
#define AGG_CTRL_INCLUDED
23
#include "agg_trans_affine.h"
24
#include "agg_renderer_scanline.h"
29
//--------------------------------------------------------------------ctrl
33
//--------------------------------------------------------------------
35
ctrl(double x1, double y1, double x2, double y2, bool flip_y) :
36
m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2),
42
//--------------------------------------------------------------------
43
virtual bool in_rect(double x, double y) const = 0;
44
virtual bool on_mouse_button_down(double x, double y) = 0;
45
virtual bool on_mouse_button_up(double x, double y) = 0;
46
virtual bool on_mouse_move(double x, double y, bool button_flag) = 0;
47
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up) = 0;
49
//--------------------------------------------------------------------
50
void transform(const trans_affine& mtx) { m_mtx = &mtx; }
51
void no_transform() { m_mtx = 0; }
53
//--------------------------------------------------------------------
54
void transform_xy(double* x, double* y) const
56
if(m_flip_y) *y = m_y1 + m_y2 - *y;
57
if(m_mtx) m_mtx->transform(x, y);
60
//--------------------------------------------------------------------
61
void inverse_transform_xy(double* x, double* y) const
63
if(m_mtx) m_mtx->inverse_transform(x, y);
64
if(m_flip_y) *y = m_y1 + m_y2 - *y;
67
//--------------------------------------------------------------------
68
double scale() const { return m_mtx ? m_mtx->scale() : 1.0; }
72
const ctrl& operator = (const ctrl&);
82
const trans_affine* m_mtx;
86
//--------------------------------------------------------------------
87
template<class Rasterizer, class Scanline, class Renderer, class Ctrl>
88
void render_ctrl(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c)
91
for(i = 0; i < c.num_paths(); i++)
95
render_scanlines_aa_solid(ras, sl, r, c.color(i));
100
//--------------------------------------------------------------------
101
template<class Rasterizer, class Scanline, class Renderer, class Ctrl>
102
void render_ctrl_rs(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c)
105
for(i = 0; i < c.num_paths(); i++)
110
render_scanlines(ras, sl, r);