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.

96 lines
2.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 CERN
  5. * @author Jon Evans <jon@craftyjon.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU 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. #include <lib_pin.h>
  21. #include <sch_component.h>
  22. #include <sch_pin.h>
  23. #include <sch_sheet_path.h>
  24. SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) :
  25. SCH_ITEM( nullptr, SCH_PIN_T ),
  26. m_pin( aLibPin ),
  27. m_comp( aParentComponent )
  28. {
  29. SetPosition( aLibPin->GetPosition() );
  30. m_isDangling = true;
  31. }
  32. SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) :
  33. SCH_ITEM( aPin )
  34. {
  35. m_pin = aPin.m_pin;
  36. m_comp = aPin.m_comp;
  37. m_position = aPin.m_position;
  38. m_isDangling = aPin.m_isDangling;
  39. }
  40. wxString SCH_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const
  41. {
  42. wxString tmp;
  43. #ifdef DEBUG
  44. tmp.Printf( "SCH_PIN for %s %s",
  45. m_comp->GetSelectMenuText( aUnits ),
  46. m_pin->GetSelectMenuText( aUnits ) );
  47. #else
  48. tmp.Printf( "%s %s",
  49. m_comp->GetSelectMenuText( aUnits ),
  50. m_pin->GetSelectMenuText( aUnits ) );
  51. #endif
  52. return tmp;
  53. }
  54. wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH aPath )
  55. {
  56. if( m_pin->IsPowerConnection() )
  57. return m_pin->GetName();
  58. std::lock_guard<std::mutex> lock( m_netmap_mutex );
  59. if( m_net_name_map.count( aPath ) > 0 )
  60. return m_net_name_map.at( aPath );
  61. wxString name = "Net-(";
  62. name << m_comp->GetRef( &aPath );
  63. // TODO(JE) do we need adoptTimestamp?
  64. if( /* adoptTimestamp && */ name.Last() == '?' )
  65. name << m_comp->GetTimeStamp();
  66. name << "-Pad" << m_pin->GetNumber() << ")";
  67. m_net_name_map[ aPath ] = name;
  68. return name;
  69. }
  70. wxPoint SCH_PIN::GetTransformedPosition() const
  71. {
  72. auto t = m_comp->GetTransform();
  73. return ( t.TransformCoordinate( GetPosition() ) +
  74. m_comp->GetPosition() );
  75. }