diff --git a/common/tool/selection.cpp b/common/tool/selection.cpp index 8c4e00e05f..c53126e887 100644 --- a/common/tool/selection.cpp +++ b/common/tool/selection.cpp @@ -201,28 +201,28 @@ const std::vector SELECTION::updateDrawList() const bool SELECTION::AreAllItemsIdentical() const { - return ( std::all_of( m_items.begin() + 1, m_items.end(), - [&]( const EDA_ITEM* r ) - { - return r->Type() == m_items.front()->Type(); - } ) ); + return std::all_of( m_items.begin() + 1, m_items.end(), + [&]( const EDA_ITEM* r ) + { + return r->Type() == m_items.front()->Type(); + } ); } bool SELECTION::OnlyContains( std::vector aList ) const { - return ( std::all_of( m_items.begin(), m_items.end(), + return std::all_of( m_items.begin(), m_items.end(), [&]( const EDA_ITEM* r ) { return r->IsType( aList ); - } ) ); + } ); } const std::vector SELECTION::GetItemsSortedBySelectionOrder() const { - using pairedIterators = - std::pair; + using pairedIterators = std::pair; // Create a vector of all {selection item, selection order} iterator pairs std::vector pairs; diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp index eab94fe6ac..a0c87c3b80 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp @@ -174,9 +174,11 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT aFormatter.Print( 0, " (pin_names" ); if( aSymbol->GetPinNameOffset() != schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET ) ) + { aFormatter.Print( 0, " (offset %s)", EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSymbol->GetPinNameOffset() ).c_str() ); + } if( !aSymbol->GetShowPinNames() ) aFormatter.Print( 0, " hide" ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index 9b742750e5..942a088536 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -498,7 +498,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi case T_rectangle: case T_text: case T_text_box: - item = ParseDrawItem(); + item = ParseSymbolDrawItem(); wxCHECK_MSG( item, nullptr, "Invalid draw item pointer." ); @@ -524,7 +524,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi case T_rectangle: case T_text: case T_text_box: - item = ParseDrawItem(); + item = ParseSymbolDrawItem(); wxCHECK_MSG( item, nullptr, "Invalid draw item pointer." ); @@ -545,7 +545,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi } -SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() +SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseSymbolDrawItem() { switch( CurTok() ) { @@ -562,7 +562,7 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() break; case T_pin: - return parsePin(); + return parseSymbolPin(); break; case T_polyline: @@ -796,7 +796,7 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOve NeedSYMBOL(); wxString hyperlink = FromUTF8(); - if( !aText->ValidateHyperlink( hyperlink ) ) + if( !EDA_TEXT::ValidateHyperlink( hyperlink ) ) { THROW_PARSE_ERROR( wxString::Format( _( "Invalid hyperlink url '%s'" ), hyperlink ), CurSource(), CurLine(), CurLineNumber(), CurOffset() ); @@ -1415,54 +1415,56 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolCircle() } -SCH_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin() +SCH_PIN* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolPin() { - auto parseType = [&]( T token ) -> ELECTRICAL_PINTYPE - { - switch( token ) - { - case T_input: return ELECTRICAL_PINTYPE::PT_INPUT; - case T_output: return ELECTRICAL_PINTYPE::PT_OUTPUT; - case T_bidirectional: return ELECTRICAL_PINTYPE::PT_BIDI; - case T_tri_state: return ELECTRICAL_PINTYPE::PT_TRISTATE; - case T_passive: return ELECTRICAL_PINTYPE::PT_PASSIVE; - case T_unspecified: return ELECTRICAL_PINTYPE::PT_UNSPECIFIED; - case T_power_in: return ELECTRICAL_PINTYPE::PT_POWER_IN; - case T_power_out: return ELECTRICAL_PINTYPE::PT_POWER_OUT; - case T_open_collector: return ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR; - case T_open_emitter: return ELECTRICAL_PINTYPE::PT_OPENEMITTER; - case T_unconnected: - case T_no_connect: return ELECTRICAL_PINTYPE::PT_NC; - case T_free: return ELECTRICAL_PINTYPE::PT_NIC; + auto parseType = + [&]( T token ) -> ELECTRICAL_PINTYPE + { + switch( token ) + { + case T_input: return ELECTRICAL_PINTYPE::PT_INPUT; + case T_output: return ELECTRICAL_PINTYPE::PT_OUTPUT; + case T_bidirectional: return ELECTRICAL_PINTYPE::PT_BIDI; + case T_tri_state: return ELECTRICAL_PINTYPE::PT_TRISTATE; + case T_passive: return ELECTRICAL_PINTYPE::PT_PASSIVE; + case T_unspecified: return ELECTRICAL_PINTYPE::PT_UNSPECIFIED; + case T_power_in: return ELECTRICAL_PINTYPE::PT_POWER_IN; + case T_power_out: return ELECTRICAL_PINTYPE::PT_POWER_OUT; + case T_open_collector: return ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR; + case T_open_emitter: return ELECTRICAL_PINTYPE::PT_OPENEMITTER; + case T_unconnected: + case T_no_connect: return ELECTRICAL_PINTYPE::PT_NC; + case T_free: return ELECTRICAL_PINTYPE::PT_NIC; - default: - Expecting( "input, output, bidirectional, tri_state, passive, " - "unspecified, power_in, power_out, open_collector, " - "open_emitter, free or no_connect" ); - return ELECTRICAL_PINTYPE::PT_UNSPECIFIED; - } - }; + default: + Expecting( "input, output, bidirectional, tri_state, passive, unspecified, " + "power_in, power_out, open_collector, open_emitter, free or " + "no_connect" ); + return ELECTRICAL_PINTYPE::PT_UNSPECIFIED; + } + }; - auto parseShape = [&]( T token ) -> GRAPHIC_PINSHAPE - { - switch( token ) - { - case T_line: return GRAPHIC_PINSHAPE::LINE; - case T_inverted: return GRAPHIC_PINSHAPE::INVERTED; - case T_clock: return GRAPHIC_PINSHAPE::CLOCK; - case T_inverted_clock: return GRAPHIC_PINSHAPE::INVERTED_CLOCK; - case T_input_low: return GRAPHIC_PINSHAPE::INPUT_LOW; - case T_clock_low: return GRAPHIC_PINSHAPE::CLOCK_LOW; - case T_output_low: return GRAPHIC_PINSHAPE::OUTPUT_LOW; - case T_edge_clock_high: return GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK; - case T_non_logic: return GRAPHIC_PINSHAPE::NONLOGIC; + auto parseShape = + [&]( T token ) -> GRAPHIC_PINSHAPE + { + switch( token ) + { + case T_line: return GRAPHIC_PINSHAPE::LINE; + case T_inverted: return GRAPHIC_PINSHAPE::INVERTED; + case T_clock: return GRAPHIC_PINSHAPE::CLOCK; + case T_inverted_clock: return GRAPHIC_PINSHAPE::INVERTED_CLOCK; + case T_input_low: return GRAPHIC_PINSHAPE::INPUT_LOW; + case T_clock_low: return GRAPHIC_PINSHAPE::CLOCK_LOW; + case T_output_low: return GRAPHIC_PINSHAPE::OUTPUT_LOW; + case T_edge_clock_high: return GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK; + case T_non_logic: return GRAPHIC_PINSHAPE::NONLOGIC; - default: - Expecting( "line, inverted, clock, inverted_clock, input_low, " - "clock_low, output_low, edge_clock_high, non_logic" ); - return GRAPHIC_PINSHAPE::LINE; - } - }; + default: + Expecting( "line, inverted, clock, inverted_clock, input_low, clock_low, " + "output_low, edge_clock_high, non_logic" ); + return GRAPHIC_PINSHAPE::LINE; + } + }; wxCHECK_MSG( CurTok() == T_pin, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a pin token." ) ); @@ -2364,7 +2366,7 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, S else { // Whitespaces are not permitted - for( wxString ch : whitespaces ) + for( const wxString& ch : whitespaces ) numReplacements += instance.m_PageNumber.Replace( ch, wxEmptyString ); } diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h index 595c5b2a6b..bcac0b91ab 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h @@ -87,7 +87,7 @@ public: LIB_SYMBOL* ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION ); - SCH_ITEM* ParseDrawItem(); + SCH_ITEM* ParseSymbolDrawItem(); /** * Parse the internal #LINE_READER object into \a aSheet. @@ -139,12 +139,12 @@ private: int parseInternalUnits( const char* aExpected ); - inline int parseInternalUnits( TSCHEMATIC_T::T aToken ) + int parseInternalUnits( TSCHEMATIC_T::T aToken ) { return parseInternalUnits( GetTokenText( aToken ) ); } - inline VECTOR2I parseXY() + VECTOR2I parseXY() { VECTOR2I xy; @@ -196,7 +196,7 @@ private: SCH_SHAPE* parseSymbolArc(); SCH_SHAPE* parseSymbolBezier(); SCH_SHAPE* parseSymbolCircle(); - SCH_PIN* parsePin(); + SCH_PIN* parseSymbolPin(); SCH_SHAPE* parseSymbolPolyLine(); SCH_SHAPE* parseSymbolRectangle(); SCH_TEXT* parseSymbolText(); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 02f945dcae..7888b56d7f 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -250,6 +250,12 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed ) void SCH_PAINTER::drawItemBoundingBox( const EDA_ITEM* aItem ) { + if( const SCH_ITEM* item = dynamic_cast( aItem ) ) + { + if( item->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + } + BOX2I box = aItem->GetBoundingBox(); if( aItem->Type() == SCH_SYMBOL_T ) @@ -2191,7 +2197,7 @@ static void orientSymbol( LIB_SYMBOL* symbol, int orientation ) for( SCH_ITEM& item : symbol->GetDrawItems() ) { for( int i = 0; i < o.n_rots; i++ ) - item.Rotate( VECTOR2I(0, 0 ), true ); + item.Rotate( VECTOR2I( 0, 0 ), true ); if( o.mirror_x ) item.MirrorVertically( 0 ); diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index a55a022561..86e10157f0 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -1711,7 +1711,7 @@ wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoC const BOX2I SCH_PIN::ViewBBox() const { - return GetBoundingBox( false, true, true ); + return GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE ); } diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index d860ad58cf..7d628921e1 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -161,7 +161,7 @@ public: /* Cannot use a default parameter here as it will not be compatible with the virtual. */ const BOX2I GetBoundingBox() const override { - return GetBoundingBox( false, true, m_layer == LAYER_DEVICE ); + return GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE ); } /** diff --git a/libs/kimath/include/transform.h b/libs/kimath/include/transform.h index a0f7ff843a..7cfb4a6202 100644 --- a/libs/kimath/include/transform.h +++ b/libs/kimath/include/transform.h @@ -53,9 +53,19 @@ public: /** * The default construct creates a transform that draws object is the normal orientation. */ - TRANSFORM() : x1( 1 ), y1( 0 ), x2( 0 ), y2( -1 ) {} + TRANSFORM() : + x1( 1 ), + y1( 0 ), + x2( 0 ), + y2( -1 ) + {} - TRANSFORM( int ax1, int ay1, int ax2, int ay2 ) : x1( ax1 ), y1( ay1 ), x2( ax2 ), y2( ay2 ) {} + TRANSFORM( int ax1, int ay1, int ax2, int ay2 ) : + x1( ax1 ), + y1( ay1 ), + x2( ax2 ), + y2( ay2 ) + {} bool operator==( const TRANSFORM& aTransform ) const; diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp index 316029b425..06853856ab 100644 --- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp +++ b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp @@ -286,9 +286,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer( } else if( elType == wxS( "CIRCLE" ) ) { - std::unique_ptr shape = - std::make_unique( aContainer, SHAPE_T::CIRCLE ); - + auto shape = std::make_unique( aContainer, SHAPE_T::CIRCLE ); double width = ConvertSize( arr[4] ); shape->SetWidth( width ); @@ -311,9 +309,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer( } else if( elType == wxS( "RECT" ) ) { - std::unique_ptr shape = - std::make_unique( aContainer, SHAPE_T::RECTANGLE ); - + auto shape = std::make_unique( aContainer, SHAPE_T::RECTANGLE ); double width = ConvertSize( arr[8] ); shape->SetWidth( width ); @@ -447,10 +443,8 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer( { for( int segId = 0; segId < chain.SegmentCount(); segId++ ) { - SEG seg = chain.CSegment( segId ); - - std::unique_ptr shape = - std::make_unique( aContainer, SHAPE_T::SEGMENT ); + SEG seg = chain.CSegment( segId ); + auto shape = std::make_unique( aContainer, SHAPE_T::SEGMENT ); shape->SetLayer( layer ); shape->SetWidth( lineWidth ); @@ -476,8 +470,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer( { for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() ) { - std::unique_ptr shape = - std::make_unique( aContainer, SHAPE_T::POLY ); + auto shape = std::make_unique( aContainer, SHAPE_T::POLY ); shape->SetLayer( Edge_Cuts ); shape->SetFilled( false ); @@ -600,19 +593,20 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer( else { // arr[1] is "stroke Width" per docs - int minThickness = - std::max( pcbIUScale.mmToIU( 0.03 ), int( ConvertSize( arr[1] ) ) ); + int minThickness = std::max( pcbIUScale.mmToIU( 0.03 ), + int( ConvertSize( arr[1] ) ) ); zone->SetMinThickness( minThickness ); } if( arr.size() > 18 ) { - zone->SetThermalReliefSpokeWidth( - std::max( int( ConvertSize( arr[18] ) ), zone->GetMinThickness() ) ); + zone->SetThermalReliefSpokeWidth( std::max( int( ConvertSize( arr[18] ) ), + zone->GetMinThickness() ) ); } else { - wxFAIL_MSG( wxString::Format( "COPPERAREA unexpected size %d: %s ", arr.size(), + wxFAIL_MSG( wxString::Format( "COPPERAREA unexpected size %d: %s ", + arr.size(), shape ) ); zone->SetThermalReliefSpokeWidth( zone->GetMinThickness() ); @@ -760,8 +754,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer( for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() ) { - std::unique_ptr shape = - std::make_unique( aContainer, SHAPE_T::POLY ); + auto shape = std::make_unique( aContainer, SHAPE_T::POLY ); shape->SetFilled( true ); shape->SetPolyShape( poly );