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.

99 lines
3.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 Mike Williams <mike@mikebwilliams.com>
  5. * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef _BOM_SETTINGS_H
  21. #define _BOM_SETTINGS_H
  22. #include <settings/json_settings.h>
  23. #include <settings/parameters.h>
  24. #include <i18n_utility.h>
  25. // A single field within a BOM, e.g. Reference, Value, Footprint
  26. struct BOM_FIELD
  27. {
  28. wxString name;
  29. wxString label;
  30. bool show = false;
  31. bool groupBy = false;
  32. bool operator==( const BOM_FIELD& rhs ) const;
  33. };
  34. bool operator!=( const BOM_FIELD& lhs, const BOM_FIELD& rhs );
  35. bool operator<( const BOM_FIELD& lhs, const BOM_FIELD& rhs );
  36. void to_json( nlohmann::json& j, const BOM_FIELD& f );
  37. void from_json( const nlohmann::json& j, BOM_FIELD& f );
  38. // A complete preset defining a BOM "View" with a list of all the fields to show,
  39. // group by, order, filtering settings, etc.
  40. struct BOM_PRESET
  41. {
  42. wxString name;
  43. bool readOnly = false;
  44. std::vector<BOM_FIELD> fieldsOrdered;
  45. wxString sortField;
  46. bool sortAsc = true;
  47. wxString filterString;
  48. bool groupSymbols = false;
  49. bool excludeDNP = false;
  50. bool operator==( const BOM_PRESET& rhs ) const;
  51. static BOM_PRESET GroupedByValue();
  52. static BOM_PRESET GroupedByValueFootprint();
  53. };
  54. bool operator!=( const BOM_PRESET& lhs, const BOM_PRESET& rhs );
  55. bool operator<( const BOM_PRESET& lhs, const BOM_PRESET& rhs );
  56. void to_json( nlohmann::json& j, const BOM_PRESET& f );
  57. void from_json( const nlohmann::json& j, BOM_PRESET& f );
  58. // A formatting preset, like CSV (Comma Separated Values)
  59. struct BOM_FMT_PRESET
  60. {
  61. wxString name;
  62. bool readOnly = false;
  63. wxString fieldDelimiter;
  64. wxString stringDelimiter;
  65. wxString refDelimiter;
  66. wxString refRangeDelimiter;
  67. bool keepTabs = false;
  68. bool keepLineBreaks = false;
  69. bool operator==( const BOM_FMT_PRESET& rhs ) const;
  70. static BOM_FMT_PRESET CSV();
  71. static BOM_FMT_PRESET TSV();
  72. static BOM_FMT_PRESET Semicolons();
  73. };
  74. bool operator!=( const BOM_FMT_PRESET& lhs, const BOM_FMT_PRESET& rhs );
  75. bool operator<( const BOM_FMT_PRESET& lhs, const BOM_FMT_PRESET& rhs );
  76. void to_json( nlohmann::json& j, const BOM_FMT_PRESET& f );
  77. void from_json( const nlohmann::json& j, BOM_FMT_PRESET& f );
  78. #endif