1//----------------------------------------------------------------------------
2// Anti-Grain Geometry - Version 2.4
3// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4//
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.
9//
10//----------------------------------------------------------------------------
11// Contact: mcseem@antigrain.com
12//          mcseemagg@yahoo.com
13//          http://www.antigrain.com
14//----------------------------------------------------------------------------
15//
16// Line dash generator
17//
18//----------------------------------------------------------------------------
19#ifndef AGG_VCGEN_DASH_INCLUDED
20#define AGG_VCGEN_DASH_INCLUDED
21
22#include "agg_basics.h"
23#include "agg_vertex_sequence.h"
24
25namespace agg
26{
27
28    //---------------------------------------------------------------vcgen_dash
29    //
30    // See Implementation agg_vcgen_dash.cpp
31    //
32    class vcgen_dash
33    {
34        enum max_dashes_e
35        {
36            max_dashes = 32
37        };
38
39        enum status_e
40        {
41            initial,
42            ready,
43            polyline,
44            stop
45        };
46
47    public:
48        typedef vertex_sequence<vertex_dist, 6> vertex_storage;
49
50        vcgen_dash();
51
52        void remove_all_dashes();
53        void add_dash(double dash_len, double gap_len);
54        void dash_start(double ds);
55
56        void shorten(double s) { m_shorten = s; }
57        double shorten() const { return m_shorten; }
58
59        // Vertex Generator Interface
60        void remove_all();
61        void add_vertex(double x, double y, unsigned cmd);
62
63        // Vertex Source Interface
64        void     rewind(unsigned path_id);
65        unsigned vertex(double* x, double* y);
66
67    private:
68        vcgen_dash(const vcgen_dash&);
69        const vcgen_dash& operator = (const vcgen_dash&);
70
71        void calc_dash_start(double ds);
72
73        double             m_dashes[max_dashes];
74        double             m_total_dash_len;
75        unsigned           m_num_dashes;
76        double             m_dash_start;
77        double             m_shorten;
78        double             m_curr_dash_start;
79        unsigned           m_curr_dash;
80        double             m_curr_rest;
81        const vertex_dist* m_v1;
82        const vertex_dist* m_v2;
83
84        vertex_storage m_src_vertices;
85        unsigned       m_closed;
86        status_e       m_status;
87        unsigned       m_src_vertex;
88    };
89
90
91}
92
93#endif
94