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.

123 lines
3.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2019 Ian McInerney <Ian.S.McInerney@ieee.org>
  5. * Copyright The 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 CVPCB_ASSOCIATION_H
  21. #define CVPCB_ASSOCIATION_H
  22. #include <lib_id.h>
  23. #include <core/utf8.h>
  24. /**
  25. * A class to define a footprint association to be made in cvpcb.
  26. */
  27. class CVPCB_ASSOCIATION
  28. {
  29. public:
  30. /**
  31. * Create an association event that contains all the information needed to modify the footprint
  32. * association of a component in cvpcb.
  33. *
  34. * @param aComponentIndex is the index of the component to change
  35. * @param aNewFootprint is the new footprint to give to the component
  36. * @param aOldFootprint is the old footprint from the component
  37. */
  38. CVPCB_ASSOCIATION( unsigned int aComponentIndex, const LIB_ID& aNewFootprint,
  39. const LIB_ID& aOldFootprint = LIB_ID() ) :
  40. m_componentIndex( aComponentIndex ),
  41. m_newFootprint( aNewFootprint ),
  42. m_oldFootprint( aOldFootprint )
  43. {}
  44. CVPCB_ASSOCIATION( unsigned int aComponentIndex, const wxString& aNewFootprint,
  45. const wxString& aOldFootprint = "" ) :
  46. m_componentIndex( aComponentIndex )
  47. {
  48. m_newFootprint.Parse( aNewFootprint );
  49. m_oldFootprint.Parse( aOldFootprint );
  50. }
  51. /**
  52. * Reverse the association.
  53. *
  54. * @return the reversed association
  55. */
  56. CVPCB_ASSOCIATION Reverse() const
  57. {
  58. return CVPCB_ASSOCIATION( m_componentIndex, m_oldFootprint, m_newFootprint );
  59. }
  60. /**
  61. * Get the index of the component to modify the association of.
  62. *
  63. * @return the index of the component
  64. */
  65. unsigned int GetComponentIndex() const
  66. {
  67. return m_componentIndex;
  68. }
  69. /**
  70. * Get the new footprint to associate to the component.
  71. *
  72. * @return the LIB_ID of the new footprint
  73. */
  74. LIB_ID GetNewFootprint() const
  75. {
  76. return m_newFootprint;
  77. }
  78. /**
  79. * Get the old footprint of the component
  80. *
  81. * @return the LIB_ID of the old footprint
  82. */
  83. LIB_ID GetOldFootprint() const
  84. {
  85. return m_oldFootprint;
  86. }
  87. /**
  88. * Set the footprint that should be associated with the component
  89. *
  90. * @param aNewFootprint is the LIB_ID of the new footprint
  91. */
  92. void SetNewFootprint( const LIB_ID& aNewFootprint )
  93. {
  94. m_newFootprint = aNewFootprint;
  95. }
  96. /**
  97. * Set the footprint that was associated with the component before this association event
  98. *
  99. * @param aOldFootprint is the LIB_ID of the old footprint
  100. */
  101. void SetOldFootprint( const LIB_ID& aOldFootprint )
  102. {
  103. m_oldFootprint = aOldFootprint;
  104. }
  105. private:
  106. unsigned int m_componentIndex;
  107. LIB_ID m_newFootprint;
  108. LIB_ID m_oldFootprint;
  109. };
  110. #endif