You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.8 KiB

11 years ago
  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2013-2014 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __PNS_LOGGER_H
  22. #define __PNS_LOGGER_H
  23. #include <cstdio>
  24. #include <vector>
  25. #include <string>
  26. #include <sstream>
  27. #include <math/vector2d.h>
  28. #include <kiid.h>
  29. #include "pns_sizes_settings.h"
  30. class SHAPE_LINE_CHAIN;
  31. class SHAPE;
  32. namespace PNS {
  33. class ITEM;
  34. class LOGGER
  35. {
  36. public:
  37. enum EVENT_TYPE {
  38. EVT_START_ROUTE = 0,
  39. EVT_START_DRAG,
  40. EVT_FIX,
  41. EVT_MOVE,
  42. EVT_ABORT,
  43. EVT_TOGGLE_VIA,
  44. EVT_UNFIX,
  45. EVT_START_MULTIDRAG
  46. };
  47. struct EVENT_ENTRY {
  48. VECTOR2I p;
  49. EVENT_TYPE type;
  50. std::vector<KIID> uuids;
  51. SIZES_SETTINGS sizes;
  52. int layer;
  53. EVENT_ENTRY() :
  54. layer( 0 ),
  55. type( EVT_START_ROUTE )
  56. {
  57. }
  58. EVENT_ENTRY( const EVENT_ENTRY& aE ) :
  59. p( aE.p ),
  60. type( aE.type ),
  61. uuids( aE.uuids ),
  62. sizes( aE.sizes ),
  63. layer( aE.layer )
  64. {
  65. }
  66. };
  67. LOGGER();
  68. ~LOGGER();
  69. void Clear();
  70. void LogM( EVENT_TYPE evt, const VECTOR2I& pos = VECTOR2I(), std::vector<ITEM*> items = {},
  71. const SIZES_SETTINGS* sizes = nullptr, int aLayer = 0 );
  72. void Log( EVENT_TYPE evt, const VECTOR2I& pos = VECTOR2I(), const ITEM* item = nullptr,
  73. const SIZES_SETTINGS* sizes = nullptr, int aLayer = 0 );
  74. const std::vector<EVENT_ENTRY>& GetEvents()
  75. {
  76. return m_events;
  77. }
  78. static wxString FormatLogFileAsString( int aMode,
  79. const std::vector<ITEM*>& aAddedItems,
  80. const std::set<KIID>& aRemovedItems,
  81. const std::vector<ITEM*>& aHeads,
  82. const std::vector<EVENT_ENTRY>& aEvents );
  83. static wxString FormatEvent( const EVENT_ENTRY& aEvent );
  84. static EVENT_ENTRY ParseEvent( const wxString& aLine );
  85. private:
  86. std::vector<EVENT_ENTRY> m_events;
  87. };
  88. }
  89. #endif