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.

142 lines
3.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
  5. * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
  6. * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file pcb_pad_shape.cpp
  27. */
  28. #include <wx/wx.h>
  29. #include <wx/config.h>
  30. #include <common.h>
  31. #include <pcb_pad_shape.h>
  32. namespace PCAD2KICAD {
  33. PCB_PAD_SHAPE::PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks,
  34. BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
  35. {
  36. m_shape = wxEmptyString;
  37. m_width = 0;
  38. m_height = 0;
  39. }
  40. PCB_PAD_SHAPE::~PCB_PAD_SHAPE()
  41. {
  42. }
  43. void PCB_PAD_SHAPE::Parse( XNODE* aNode,
  44. wxString aDefaultMeasurementUnit,
  45. wxString aActualConversion )
  46. {
  47. wxString str, s;
  48. long num;
  49. int minX, maxX, minY, maxY, x, y;
  50. XNODE* lNode;
  51. lNode = FindNode( aNode, wxT( "padShapeType" ) );
  52. if( lNode )
  53. {
  54. str = lNode->GetNodeContent();
  55. str.Trim( false );
  56. m_shape = str;
  57. }
  58. lNode = FindNode( aNode, wxT( "layerNumRef" ) );
  59. if( lNode )
  60. {
  61. lNode->GetNodeContent().ToLong( &num );
  62. m_PCadLayer = (int) num;
  63. }
  64. m_KiCadLayer = GetKiCadLayer();
  65. if( m_shape == wxT( "Oval" )
  66. || m_shape == wxT( "Rect" )
  67. || m_shape == wxT( "Ellipse" )
  68. || m_shape == wxT( "MtHole" )
  69. || m_shape == wxT( "RndRect" ) )
  70. {
  71. lNode = FindNode( aNode, wxT( "shapeWidth" ) );
  72. if( lNode )
  73. SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width,
  74. aActualConversion );
  75. lNode = FindNode( aNode, wxT( "shapeHeight" ) );
  76. if( lNode )
  77. SetWidth(
  78. lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_height, aActualConversion );
  79. }
  80. else if( m_shape == wxT( "Polygon" ) )
  81. {
  82. // aproximation to simplier pad shape .....
  83. lNode = FindNode( aNode, wxT( "shapeOutline" ) );
  84. if( lNode )
  85. lNode = FindNode( lNode, wxT( "pt" ) );
  86. minX = 0;
  87. maxX = 0;
  88. minY = 0;
  89. maxY = 0;
  90. while( lNode )
  91. {
  92. s = lNode->GetNodeContent();
  93. SetPosition( s, aDefaultMeasurementUnit, &x, &y, aActualConversion );
  94. if( minX > x )
  95. minX = x;
  96. if( maxX < x )
  97. maxX = x;
  98. if( minY > y )
  99. minY = y;
  100. if( maxY < y )
  101. maxY = y;
  102. lNode = lNode->GetNext();
  103. }
  104. m_width = maxX - minX;
  105. m_height = maxY - minY;
  106. }
  107. }
  108. void PCB_PAD_SHAPE::AddToBoard()
  109. {
  110. }
  111. } // namespace PCAD2KICAD