agg_vcgen_dash.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #include "agg_basics.h"
  22. #include "agg_vertex_sequence.h"
  23. namespace agg
  24. {
  25. //---------------------------------------------------------------vcgen_dash
  26. //
  27. // See Implementation agg_vcgen_dash.cpp
  28. //
  29. class vcgen_dash
  30. {
  31. enum max_dashes_e
  32. {
  33. max_dashes = 32
  34. };
  35. enum status_e
  36. {
  37. initial,
  38. ready,
  39. polyline,
  40. stop
  41. };
  42. public:
  43. typedef vertex_sequence<vertex_dist, 6> vertex_storage;
  44. vcgen_dash();
  45. void remove_all_dashes();
  46. void add_dash(double dash_len, double gap_len);
  47. void dash_start(double ds);
  48. void shorten(double s) { m_shorten = s; }
  49. double shorten() const { return m_shorten; }
  50. // Vertex Generator Interface
  51. void remove_all();
  52. void add_vertex(double x, double y, unsigned cmd);
  53. // Vertex Source Interface
  54. void rewind(unsigned path_id);
  55. unsigned vertex(double* x, double* y);
  56. private:
  57. vcgen_dash(const vcgen_dash&);
  58. const vcgen_dash& operator = (const vcgen_dash&);
  59. void calc_dash_start(double ds);
  60. double m_dashes[max_dashes];
  61. double m_total_dash_len;
  62. unsigned m_num_dashes;
  63. double m_dash_start;
  64. double m_shorten;
  65. double m_curr_dash_start;
  66. unsigned m_curr_dash;
  67. double m_curr_rest;
  68. const vertex_dist* m_v1;
  69. const vertex_dist* m_v2;
  70. vertex_storage m_src_vertices;
  71. unsigned m_closed;
  72. status_e m_status;
  73. unsigned m_src_vertex;
  74. };
  75. }
  76. #endif