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.

129 lines
3.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
  5. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2004-2015 KiCad Developers, see change_log.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 lib_draw_item.cpp
  27. */
  28. #include <fctsys.h>
  29. #include <gr_basic.h>
  30. #include <sch_draw_panel.h>
  31. #include <msgpanel.h>
  32. #include <general.h>
  33. #include <lib_draw_item.h>
  34. const int fill_tab[3] = { 'N', 'F', 'f' };
  35. LIB_ITEM::LIB_ITEM( KICAD_T aType,
  36. LIB_PART* aComponent,
  37. int aUnit,
  38. int aConvert,
  39. FILL_T aFillType ) :
  40. EDA_ITEM( aType )
  41. {
  42. m_Unit = aUnit;
  43. m_Convert = aConvert;
  44. m_Fill = aFillType;
  45. m_Parent = (EDA_ITEM*) aComponent;
  46. m_isFillable = false;
  47. }
  48. void LIB_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
  49. {
  50. wxString msg;
  51. aList.push_back( MSG_PANEL_ITEM( _( "Type" ), GetTypeName(), CYAN ) );
  52. if( m_Unit == 0 )
  53. msg = _( "All" );
  54. else
  55. msg.Printf( wxT( "%d" ), m_Unit );
  56. aList.push_back( MSG_PANEL_ITEM( _( "Unit" ), msg, BROWN ) );
  57. if( m_Convert == LIB_ITEM::LIB_CONVERT::BASE )
  58. msg = _( "no" );
  59. else if( m_Convert == LIB_ITEM::LIB_CONVERT::DEMORGAN )
  60. msg = _( "yes" );
  61. else
  62. msg = wxT( "?" );
  63. aList.push_back( MSG_PANEL_ITEM( _( "Converted" ), msg, BROWN ) );
  64. }
  65. bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const
  66. {
  67. return ( ( Type() == aOther.Type() )
  68. && ( m_Unit == aOther.m_Unit )
  69. && ( m_Convert == aOther.m_Convert )
  70. && compare( aOther ) == 0 );
  71. }
  72. bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
  73. {
  74. int result = m_Convert - aOther.m_Convert;
  75. if( result != 0 )
  76. return result < 0;
  77. result = m_Unit - aOther.m_Unit;
  78. if( result != 0 )
  79. return result < 0;
  80. result = Type() - aOther.Type();
  81. if( result != 0 )
  82. return result < 0;
  83. return ( compare( aOther ) < 0 );
  84. }
  85. void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
  86. const TRANSFORM& aTransform )
  87. {
  88. drawGraphic( aPanel, aDC, aOffset, aData, aTransform );
  89. }
  90. void LIB_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
  91. {
  92. // Basic fallback
  93. aCount = 2;
  94. aLayers[0] = LAYER_DEVICE;
  95. aLayers[1] = LAYER_DEVICE_BACKGROUND;
  96. }
  97. COLOR4D LIB_ITEM::GetDefaultColor()
  98. {
  99. return GetLayerColor( LAYER_DEVICE );
  100. }