agg_conv_concat.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef AGG_CONV_CONCAT_INCLUDED
  16. #define AGG_CONV_CONCAT_INCLUDED
  17. #include "agg_basics.h"
  18. namespace agg
  19. {
  20. //=============================================================conv_concat
  21. // Concatenation of two paths. Usually used to combine lines or curves
  22. // with markers such as arrowheads
  23. template<class VS1, class VS2> class conv_concat
  24. {
  25. public:
  26. conv_concat(VS1& source1, VS2& source2) :
  27. m_source1(&source1), m_source2(&source2), m_status(2) {}
  28. void attach1(VS1& source) { m_source1 = &source; }
  29. void attach2(VS2& source) { m_source2 = &source; }
  30. void rewind(unsigned path_id)
  31. {
  32. m_source1->rewind(path_id);
  33. m_source2->rewind(0);
  34. m_status = 0;
  35. }
  36. unsigned vertex(double* x, double* y)
  37. {
  38. unsigned cmd;
  39. if(m_status == 0)
  40. {
  41. cmd = m_source1->vertex(x, y);
  42. if(!is_stop(cmd)) return cmd;
  43. m_status = 1;
  44. }
  45. if(m_status == 1)
  46. {
  47. cmd = m_source2->vertex(x, y);
  48. if(!is_stop(cmd)) return cmd;
  49. m_status = 2;
  50. }
  51. return path_cmd_stop;
  52. }
  53. private:
  54. conv_concat(const conv_concat<VS1, VS2>&);
  55. const conv_concat<VS1, VS2>&
  56. operator = (const conv_concat<VS1, VS2>&);
  57. VS1* m_source1;
  58. VS2* m_source2;
  59. int m_status;
  60. };
  61. }
  62. #endif