From 7a00e01b3e33f33e5d26839cafea1b1652335276 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 4 Mar 2021 17:59:24 -0500 Subject: [PATCH] Eeschema: fix false positive library symbol changed ERC errors. This fix required sorting all of the LIB_PART draw items to ensure accurate comparison between the symbols stored in the schematic and the original library symbols. This has a noticeable impact on symbol library load performance. It may also cause significant changes the next time the library is saved due to changes in the draw item sorting. Hashing may be a better solution here but this addressed the immediate problem. A skeleton method SCH_SCREEN::SwapSymbolLinks() was added because there is most likely an issue with orphaned symbols in the schematic library symbol cache during undo/redo operations. More testing is required to verify this. Fixes https://gitlab.com/kicad/code/kicad/-/issues/7263 --- demos/ecc83/ecc83-pp.kicad_pro | 32 ++- demos/ecc83/ecc83-pp.kicad_sch | 225 ++++++++++++------ demos/ecc83/ecc83_schlib.kicad_sym | 82 +++---- eeschema/dialogs/dialog_change_symbols.cpp | 1 + eeschema/erc.cpp | 3 +- eeschema/lib_item.cpp | 15 -- eeschema/lib_symbol.cpp | 30 ++- eeschema/lib_symbol.h | 7 +- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 7 +- .../sch_plugins/legacy/sch_legacy_plugin.cpp | 19 +- eeschema/sch_screen.cpp | 15 ++ eeschema/sch_screen.h | 2 + eeschema/sch_symbol.cpp | 2 + eeschema/schematic_undo_redo.cpp | 25 +- eeschema/tools/symbol_editor_edit_tool.cpp | 4 +- qa/eeschema/test_lib_part.cpp | 6 +- 16 files changed, 312 insertions(+), 163 deletions(-) diff --git a/demos/ecc83/ecc83-pp.kicad_pro b/demos/ecc83/ecc83-pp.kicad_pro index da919b608a..0be61309c2 100644 --- a/demos/ecc83/ecc83-pp.kicad_pro +++ b/demos/ecc83/ecc83-pp.kicad_pro @@ -137,6 +137,7 @@ "equivalence_files": [] }, "erc": { + "erc_exclusions": [], "meta": { "version": 0 }, @@ -147,6 +148,7 @@ 0, 0, 0, + 0, 1, 0, 0, @@ -160,6 +162,7 @@ 0, 1, 0, + 0, 1, 0, 2, @@ -173,6 +176,7 @@ 0, 0, 0, + 0, 1, 0, 1, @@ -186,6 +190,7 @@ 0, 0, 0, + 0, 1, 1, 2, @@ -199,6 +204,7 @@ 0, 0, 0, + 0, 1, 0, 0, @@ -206,12 +212,27 @@ 0, 2 ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2 + ], [ 1, 1, 1, 1, 1, + 0, 1, 1, 1, @@ -225,6 +246,7 @@ 0, 1, 0, + 0, 1, 0, 0, @@ -238,6 +260,7 @@ 1, 2, 0, + 0, 1, 0, 2, @@ -251,6 +274,7 @@ 0, 1, 0, + 0, 1, 0, 2, @@ -264,6 +288,7 @@ 1, 1, 0, + 0, 1, 0, 2, @@ -282,6 +307,7 @@ 2, 2, 2, + 2, 2 ] ], @@ -292,7 +318,9 @@ "bus_to_net_conflict": "error", "different_unit_footprint": "error", "different_unit_net": "error", + "duplicate_reference": "error", "duplicate_sheet_names": "error", + "extra_units": "error", "global_label_dangling": "warning", "hier_label_mismatch": "error", "label_dangling": "error", @@ -306,6 +334,8 @@ "pin_to_pin": "warning", "power_pin_not_driven": "error", "similar_labels": "warning", + "unannotated": "error", + "unit_value_mismatch": "error", "unresolved_variable": "error", "wire_dangling": "error" } @@ -390,7 +420,7 @@ }, "sheets": [ [ - "1c1f9e97-d6f4-4031-b617-d6bb06687375", + "1ce0043a-34b3-4db0-bd6b-9ae47c2acb93", "" ] ], diff --git a/demos/ecc83/ecc83-pp.kicad_sch b/demos/ecc83/ecc83-pp.kicad_sch index b7483c36d8..5e0586af14 100644 --- a/demos/ecc83/ecc83-pp.kicad_sch +++ b/demos/ecc83/ecc83-pp.kicad_sch @@ -1,6 +1,4 @@ -(kicad_sch (version 20201015) (generator eeschema) - - (page 1 1) +(kicad_sch (version 20210126) (generator eeschema) (paper "A4") @@ -142,15 +140,15 @@ (rectangle (start -2.286 0.508) (end 2.286 0.508) (stroke (width 0)) (fill (type none)) ) - (rectangle (start 2.286 -0.508) (end -2.286 -1.016) - (stroke (width 0)) (fill (type outline)) - ) (rectangle (start 2.286 1.016) (end -2.286 1.016) (stroke (width 0)) (fill (type none)) ) (rectangle (start 2.286 1.016) (end 2.286 0.508) (stroke (width 0)) (fill (type none)) ) + (rectangle (start 2.286 -0.508) (end -2.286 -1.016) + (stroke (width 0)) (fill (type outline)) + ) (polyline (pts (xy -1.778 2.286) @@ -216,6 +214,22 @@ (stroke (width 0)) (fill (type none)) ) ) + (symbol "ECC83_1_0" + (polyline + (pts + (xy -2.54 -5.08) + (xy -2.54 -7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + (polyline + (pts + (xy 0 5.08) + (xy 0 7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + ) (symbol "ECC83_1_1" (arc (start 2.54 -5.08) (end -2.54 -5.08) (radius (at 0 -5.715) (length 2.6162) (angles 14.2 165.9)) (stroke (width 0.254)) (fill (type none)) @@ -269,6 +283,22 @@ (number "8" (effects (font (size 1.016 1.016)))) ) ) + (symbol "ECC83_2_0" + (polyline + (pts + (xy -2.54 -5.08) + (xy -2.54 -7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + (polyline + (pts + (xy 0 5.08) + (xy 0 7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + ) (symbol "ECC83_2_1" (arc (start 2.54 -5.08) (end -2.54 -5.08) (radius (at 0 -5.715) (length 2.6162) (angles 14.2 165.9)) (stroke (width 0.254)) (fill (type none)) @@ -342,38 +372,6 @@ (number "9" (effects (font (size 1.016 1.016)))) ) ) - (symbol "ECC83_1_0" - (polyline - (pts - (xy -2.54 -5.08) - (xy -2.54 -7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - (polyline - (pts - (xy 0 5.08) - (xy 0 7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - ) - (symbol "ECC83_2_0" - (polyline - (pts - (xy -2.54 -5.08) - (xy -2.54 -7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - (polyline - (pts - (xy 0 5.08) - (xy 0 7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - ) ) (symbol "ecc83_schlib:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes) (property "Reference" "#PWR" (id 0) (at 0 -6.35 0) @@ -421,6 +419,12 @@ (property "Datasheet" "" (id 3) (at 0 0 0) (effects (font (size 1.524 1.524))) ) + (symbol "PWR_FLAG_0_0" + (pin power_out line (at 0 0 90) (length 0) + (name "pwr" (effects (font (size 0.508 0.508)))) + (number "1" (effects (font (size 0.508 0.508)))) + ) + ) (symbol "PWR_FLAG_0_1" (polyline (pts @@ -434,12 +438,6 @@ (stroke (width 0)) (fill (type none)) ) ) - (symbol "PWR_FLAG_0_0" - (pin power_out line (at 0 0 90) (length 0) - (name "pwr" (effects (font (size 0.508 0.508)))) - (number "1" (effects (font (size 0.508 0.508)))) - ) - ) ) (symbol "ecc83_schlib:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes) (property "Reference" "R" (id 0) (at 2.032 0 90) @@ -484,126 +482,163 @@ (junction (at 157.48 93.98) (diameter 1.016) (color 0 0 0 0)) (junction (at 185.42 76.2) (diameter 1.016) (color 0 0 0 0)) - (no_connect (at 154.94 182.88)) - (no_connect (at 154.94 185.42)) - (no_connect (at 154.94 177.8)) - (no_connect (at 154.94 180.34)) + (no_connect (at 154.94 177.8) (uuid 07e6e92c-c8a8-42b9-a8a3-099796ec9615)) + (no_connect (at 154.94 180.34) (uuid 230887ce-f305-4883-86d7-72df3a1a2372)) + (no_connect (at 154.94 182.88) (uuid 517db1d3-5d33-4d54-a6be-6a1fc40799a4)) + (no_connect (at 154.94 185.42) (uuid 4102cf29-cf4e-42c4-96cb-330b1b756d96)) (wire (pts (xy 50.8 50.8) (xy 76.2 50.8)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 67a136ce-9a43-4815-bf37-5a48e3c5ba88) ) (wire (pts (xy 50.8 57.15) (xy 50.8 55.88)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 38870f5c-4bbe-464a-b4a4-7b080932d227) ) (wire (pts (xy 50.8 88.9) (xy 60.96 88.9)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 986dd788-f18e-4db3-a5a5-6a0a989a7f34) ) (wire (pts (xy 53.34 55.88) (xy 50.8 55.88)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 936bde2e-ed95-450c-9794-94948f30b67d) ) (wire (pts (xy 60.96 88.9) (xy 60.96 86.36)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 7b559062-4412-4d9e-9c3b-32723558239a) ) (wire (pts (xy 60.96 88.9) (xy 66.04 88.9)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid eb2a78d6-b4d5-4ef8-9a1a-3d9ed3db2fee) ) (wire (pts (xy 63.5 86.36) (xy 63.5 93.98)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 96d8a739-fd6e-4a71-af88-21b52a62647d) ) (wire (pts (xy 63.5 93.98) (xy 50.8 93.98)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 8e3fe7d9-4894-46e6-9f30-60c30a67eb4d) ) (wire (pts (xy 66.04 88.9) (xy 66.04 86.36)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid df86ea1e-527e-4c0f-b20e-3a0e986faf20) ) (wire (pts (xy 76.2 49.53) (xy 76.2 50.8)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 84963a83-b6da-4751-9910-f093c3a03bee) ) (wire (pts (xy 76.2 50.8) (xy 86.36 50.8)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid dd8fad86-da9c-4a52-b908-cd4a2e7bd87e) ) (wire (pts (xy 86.36 50.8) (xy 160.02 50.8)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 5cb2363c-c774-4f15-8526-d847a6a0f944) ) (wire (pts (xy 86.36 53.34) (xy 86.36 50.8)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 1a7e2049-1cef-423f-9044-882a24cd3080) ) (wire (pts (xy 86.36 62.23) (xy 86.36 60.96)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 93661ccf-845f-4e28-a2f3-792cd2d0f455) ) (wire (pts (xy 135.89 107.95) (xy 144.78 107.95)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid ac0e9f32-a4a3-4405-b25f-0b2daa84fbf8) ) (wire (pts (xy 138.43 113.03) (xy 135.89 113.03)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 7573f100-0025-455b-9269-cc3c743be43c) ) (wire (pts (xy 138.43 116.84) (xy 138.43 113.03)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 31e24174-4181-446f-9f24-5cffc59c241d) ) (wire (pts (xy 144.78 107.95) (xy 144.78 123.19)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 3211000a-11bc-4174-b47e-920409d772ed) ) (wire (pts (xy 144.78 107.95) (xy 149.86 107.95)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid eb6832ef-d0fe-479d-8f32-b253c6621b1a) ) (wire (pts (xy 144.78 130.81) (xy 144.78 132.08)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid dc9271ea-f970-4a19-a75f-7e6f5ed9c7b4) ) (wire (pts (xy 149.86 64.77) (xy 149.86 93.98)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 492f5cda-ba4e-4ac1-9675-e6be96092062) ) (wire (pts (xy 149.86 93.98) (xy 157.48 93.98)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 9b04edba-dede-4967-8f9b-38a56988a081) ) (wire (pts (xy 152.4 64.77) (xy 149.86 64.77)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid b9ea24f5-9437-4489-8f03-fb33f32ab984) ) (wire (pts (xy 154.94 118.11) (xy 154.94 123.19)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid e35a19d0-80c7-4a83-8507-037b6833d50c) ) (wire (pts (xy 154.94 130.81) (xy 154.94 132.08)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid b7a0ea88-eaff-457a-afff-3c743cbd7651) ) (wire (pts (xy 157.48 74.93) (xy 157.48 76.2)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 87a9b2c0-1c64-462f-bd1f-2bce76398152) ) (wire (pts (xy 157.48 76.2) (xy 157.48 81.28)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 43ff79b9-e7f1-4ce8-8f5d-a3e328a0951b) ) (wire (pts (xy 157.48 88.9) (xy 157.48 93.98)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid c3e30b89-963c-45be-9c7c-93532b58206c) ) (wire (pts (xy 157.48 93.98) (xy 157.48 97.79)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 9edfba25-39d5-4b5e-a81e-c68bb365f583) ) (wire (pts (xy 160.02 50.8) (xy 160.02 54.61)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid af9c8561-1608-47a7-8aa7-1d378b72d4c1) ) (wire (pts (xy 171.45 76.2) (xy 157.48 76.2)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 6e244d34-c7f4-4b73-b2e4-7cd6a9e68746) ) (wire (pts (xy 179.07 76.2) (xy 185.42 76.2)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 78e27532-fd91-4f5a-a2d8-e6fdf5d8048d) ) (wire (pts (xy 185.42 76.2) (xy 185.42 81.28)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 58ca8983-4450-4fe2-8e2b-0e30d48402fa) ) (wire (pts (xy 185.42 76.2) (xy 198.12 76.2)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 06655b90-3a73-4865-8781-04208e869f47) ) (wire (pts (xy 185.42 90.17) (xy 185.42 88.9)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid e9c31df6-6f42-45a2-8981-394de7ce2e5a) ) (wire (pts (xy 195.58 81.28) (xy 195.58 83.82)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 1bfc9e1d-9730-4ad2-b53c-049bbdc4f2eb) ) (wire (pts (xy 198.12 81.28) (xy 195.58 81.28)) (stroke (width 0) (type solid) (color 0 0 0 0)) + (uuid 10537025-ad57-4a68-a3ad-97783b6e906f) ) (symbol (lib_id "ecc83_schlib:CONN_1") (at 158.75 177.8 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000054a5890a") + (uuid 00000000-0000-0000-0000-000054a5890a) (property "Reference" "P5" (id 0) (at 160.782 177.8 0) (effects (font (size 1.016 1.016)) (justify left)) ) @@ -616,11 +651,12 @@ (property "Datasheet" "" (id 3) (at 158.75 177.8 0) (effects (font (size 1.524 1.524))) ) + (pin "1" (uuid b47c1d61-902c-48ae-8802-734a54efb1a1)) ) (symbol (lib_id "ecc83_schlib:CONN_1") (at 158.75 180.34 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000054a58c65") + (uuid 00000000-0000-0000-0000-000054a58c65) (property "Reference" "P6" (id 0) (at 160.782 180.34 0) (effects (font (size 1.016 1.016)) (justify left)) ) @@ -633,11 +669,12 @@ (property "Datasheet" "" (id 3) (at 158.75 180.34 0) (effects (font (size 1.524 1.524))) ) + (pin "1" (uuid f56a8913-ef96-4f3b-aa8b-1a13f8229c54)) ) (symbol (lib_id "ecc83_schlib:CONN_1") (at 158.75 182.88 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000054a58c8a") + (uuid 00000000-0000-0000-0000-000054a58c8a) (property "Reference" "P7" (id 0) (at 160.782 182.88 0) (effects (font (size 1.016 1.016)) (justify left)) ) @@ -650,11 +687,12 @@ (property "Datasheet" "" (id 3) (at 158.75 182.88 0) (effects (font (size 1.524 1.524))) ) + (pin "1" (uuid ca1e588f-0267-46c9-b6cd-66fd0b13056c)) ) (symbol (lib_id "ecc83_schlib:CONN_1") (at 158.75 185.42 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000054a58ca3") + (uuid 00000000-0000-0000-0000-000054a58ca3) (property "Reference" "P8" (id 0) (at 160.782 185.42 0) (effects (font (size 1.016 1.016)) (justify left)) ) @@ -667,11 +705,12 @@ (property "Datasheet" "" (id 3) (at 158.75 185.42 0) (effects (font (size 1.524 1.524))) ) + (pin "1" (uuid 37f3c682-6c02-4995-a68d-ba2bc9fac1ab)) ) (symbol (lib_id "ecc83_schlib:GND") (at 50.8 57.15 0) (mirror y) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000550eab37") + (uuid 00000000-0000-0000-0000-0000550eab37) (property "Reference" "#PWR08" (id 0) (at 50.8 57.15 0) (effects (font (size 0.762 0.762)) hide) ) @@ -684,11 +723,12 @@ (property "Datasheet" "" (id 3) (at 50.8 57.15 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 2441dfd7-a2b0-441b-ab95-dc80d3bfb10c)) ) (symbol (lib_id "ecc83_schlib:GND") (at 86.36 62.23 0) (mirror y) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000053b6f370") + (uuid 00000000-0000-0000-0000-000053b6f370) (property "Reference" "#PWR06" (id 0) (at 86.36 62.23 0) (effects (font (size 0.762 0.762)) hide) ) @@ -701,11 +741,12 @@ (property "Datasheet" "" (id 3) (at 86.36 62.23 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 0925899f-4041-41ea-abb1-12963c2e5446)) ) (symbol (lib_id "ecc83_schlib:GND") (at 138.43 116.84 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000550eaf5a") + (uuid 00000000-0000-0000-0000-0000550eaf5a) (property "Reference" "#PWR09" (id 0) (at 138.43 116.84 0) (effects (font (size 0.762 0.762)) hide) ) @@ -718,11 +759,12 @@ (property "Datasheet" "" (id 3) (at 138.43 116.84 0) (effects (font (size 1.524 1.524))) ) + (pin "1" (uuid a8c7d88f-5a85-486a-8858-7ed63775f7db)) ) (symbol (lib_id "ecc83_schlib:GND") (at 144.78 132.08 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000457dbaef") + (uuid 00000000-0000-0000-0000-0000457dbaef) (property "Reference" "#PWR04" (id 0) (at 144.78 132.08 0) (effects (font (size 0.762 0.762)) hide) ) @@ -735,11 +777,12 @@ (property "Datasheet" "" (id 3) (at 144.78 132.08 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 7b3ac387-2d8f-4fc2-98a0-74502639828d)) ) (symbol (lib_id "ecc83_schlib:GND") (at 154.94 132.08 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000457dbaf1") + (uuid 00000000-0000-0000-0000-0000457dbaf1) (property "Reference" "#PWR03" (id 0) (at 154.94 132.08 0) (effects (font (size 0.762 0.762)) hide) ) @@ -752,11 +795,12 @@ (property "Datasheet" "" (id 3) (at 154.94 132.08 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 1f35e760-d662-44a6-8970-5b1f4f0c5299)) ) (symbol (lib_id "ecc83_schlib:GND") (at 185.42 90.17 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000457dbaf5") + (uuid 00000000-0000-0000-0000-0000457dbaf5) (property "Reference" "#PWR02" (id 0) (at 185.42 90.17 0) (effects (font (size 0.762 0.762)) hide) ) @@ -769,11 +813,12 @@ (property "Datasheet" "" (id 3) (at 185.42 90.17 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 45409752-92eb-492b-8722-9657988f10c8)) ) (symbol (lib_id "ecc83_schlib:GND") (at 195.58 83.82 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000457dbaf8") + (uuid 00000000-0000-0000-0000-0000457dbaf8) (property "Reference" "#PWR01" (id 0) (at 195.58 83.82 0) (effects (font (size 0.762 0.762)) hide) ) @@ -786,11 +831,12 @@ (property "Datasheet" "" (id 3) (at 195.58 83.82 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid ffd8d9c0-407c-42f3-9854-4c5baebeb6bc)) ) (symbol (lib_id "ecc83_schlib:PWR_FLAG") (at 53.34 55.88 270) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000457dbac0") + (uuid 00000000-0000-0000-0000-0000457dbac0) (property "Reference" "#FLG05" (id 0) (at 60.198 55.88 0) (effects (font (size 0.762 0.762)) hide) ) @@ -803,11 +849,12 @@ (property "Datasheet" "" (id 3) (at 53.34 55.88 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 8508cfae-2f39-4086-9b3c-8362f92ce148)) ) (symbol (lib_id "ecc83_schlib:PWR_FLAG") (at 76.2 49.53 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000550ea992") + (uuid 00000000-0000-0000-0000-0000550ea992) (property "Reference" "#FLG07" (id 0) (at 76.2 42.672 0) (effects (font (size 0.762 0.762)) hide) ) @@ -820,11 +867,12 @@ (property "Datasheet" "" (id 3) (at 76.2 49.53 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid b1b98e40-b69b-4b60-8486-e01c25c7ae90)) ) (symbol (lib_id "ecc83_schlib:R") (at 144.78 127 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f3a2") + (uuid 00000000-0000-0000-0000-00004549f3a2) (property "Reference" "R4" (id 0) (at 142.24 125.73 0)) (property "Value" "47K" (id 1) (at 144.78 127 90)) (property "Footprint" "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal" (id 2) (at 146.7104 127.0508 90) @@ -833,11 +881,13 @@ (property "Datasheet" "" (id 3) (at 144.78 127 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid c270f478-7e23-4604-bfdf-038c11b27bdf)) + (pin "2" (uuid 0ad09d20-5006-493e-8278-f356e26f66f7)) ) (symbol (lib_id "ecc83_schlib:R") (at 154.94 127 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f39d") + (uuid 00000000-0000-0000-0000-00004549f39d) (property "Reference" "R2" (id 0) (at 152.4 127 0)) (property "Value" "1.5K" (id 1) (at 154.94 127 90)) (property "Footprint" "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal" (id 2) (at 156.8196 127 90) @@ -846,11 +896,13 @@ (property "Datasheet" "" (id 3) (at 154.94 127 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid d54c7402-b55e-42a6-b24e-c8231bb401fe)) + (pin "2" (uuid e7039a2b-a55a-45c3-8a0e-2abf3a015549)) ) (symbol (lib_id "ecc83_schlib:R") (at 157.48 85.09 180) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f38a") + (uuid 00000000-0000-0000-0000-00004549f38a) (property "Reference" "R1" (id 0) (at 154.94 85.09 0)) (property "Value" "1.5K" (id 1) (at 157.48 85.09 90)) (property "Footprint" "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal" (id 2) (at 159.512 85.0392 90) @@ -859,11 +911,13 @@ (property "Datasheet" "" (id 3) (at 157.48 85.09 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 490a35ba-1ba2-44c5-adce-e27a045257ab)) + (pin "2" (uuid 51355c82-d1cf-445b-b079-21c660dd8989)) ) (symbol (lib_id "ecc83_schlib:R") (at 185.42 85.09 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f3ad") + (uuid 00000000-0000-0000-0000-00004549f3ad) (property "Reference" "R3" (id 0) (at 182.88 85.09 0)) (property "Value" "100K" (id 1) (at 185.42 85.09 90)) (property "Footprint" "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal" (id 2) (at 187.4266 85.09 90) @@ -872,11 +926,13 @@ (property "Datasheet" "" (id 3) (at 185.42 85.09 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 39435a49-8935-4ddf-b360-6a015d358cfb)) + (pin "2" (uuid 3f332333-6f91-4a13-8c53-eebb9573b799)) ) (symbol (lib_id "ecc83_schlib:CP") (at 86.36 57.15 0) (mirror y) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f4be") + (uuid 00000000-0000-0000-0000-00004549f4be) (property "Reference" "C1" (id 0) (at 92.71 55.88 0) (effects (font (size 1.27 1.27)) (justify left)) ) @@ -889,11 +945,13 @@ (property "Datasheet" "" (id 3) (at 86.36 57.15 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 6f18cb93-a67b-4a40-887d-5dbe82da9cf7)) + (pin "2" (uuid f905ad9c-2fd8-4770-9c67-d7f99b1c26af)) ) (symbol (lib_id "ecc83_schlib:C") (at 175.26 76.2 270) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f3be") + (uuid 00000000-0000-0000-0000-00004549f3be) (property "Reference" "C2" (id 0) (at 175.26 72.39 90)) (property "Value" "680nF" (id 1) (at 175.26 80.01 90)) (property "Footprint" "Capacitor_THT:C_Disc_D4.7mm_W2.5mm_P5.00mm" (id 2) (at 175.26 81.28 90) @@ -902,11 +960,13 @@ (property "Datasheet" "" (id 3) (at 175.26 76.2 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid eadc305d-a101-4c9c-94d9-1ecaf23352ac)) + (pin "2" (uuid 44dabcab-6c7b-4e96-b86a-4fb6dd8f5b97)) ) (symbol (lib_id "ecc83_schlib:CONN_2") (at 41.91 53.34 0) (mirror y) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f4a5") + (uuid 00000000-0000-0000-0000-00004549f4a5) (property "Reference" "P3" (id 0) (at 41.91 48.26 0) (effects (font (size 1.016 1.016))) ) @@ -919,11 +979,13 @@ (property "Datasheet" "" (id 3) (at 41.91 53.34 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 54a114eb-3233-4517-9c5d-b1447c552b5c)) + (pin "2" (uuid 357ce97b-c23c-459c-af19-1a501705cbb4)) ) (symbol (lib_id "ecc83_schlib:CONN_2") (at 41.91 91.44 180) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-0000456a8acc") + (uuid 00000000-0000-0000-0000-0000456a8acc) (property "Reference" "P4" (id 0) (at 43.18 91.44 90) (effects (font (size 1.016 1.016))) ) @@ -936,11 +998,13 @@ (property "Datasheet" "" (id 3) (at 41.91 91.44 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 0b2cb6e8-aee2-426a-a772-436c4f8fd1de)) + (pin "2" (uuid f4c26ce8-3b51-4b5c-839b-1fa8af9cd764)) ) (symbol (lib_id "ecc83_schlib:CONN_2") (at 127 110.49 180) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f464") + (uuid 00000000-0000-0000-0000-00004549f464) (property "Reference" "P1" (id 0) (at 127 105.41 0) (effects (font (size 1.016 1.016))) ) @@ -953,11 +1017,13 @@ (property "Datasheet" "" (id 3) (at 127 110.49 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 4e008eff-1d48-4641-80fd-f3bdec030729)) + (pin "2" (uuid 7bc904bf-18da-4a24-be4f-4a6e9fd74076)) ) (symbol (lib_id "ecc83_schlib:CONN_2") (at 207.01 78.74 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-00004549f46c") + (uuid 00000000-0000-0000-0000-00004549f46c) (property "Reference" "P2" (id 0) (at 207.01 73.66 0) (effects (font (size 1.016 1.016))) ) @@ -970,11 +1036,13 @@ (property "Datasheet" "" (id 3) (at 207.01 78.74 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid 5052135e-1b72-4faa-add1-da0cf01aa026)) + (pin "2" (uuid 0a09657c-35de-4de7-9dfe-7d3a0d792dc3)) ) (symbol (lib_id "ecc83_schlib:ECC83") (at 63.5 74.93 0) (unit 3) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000048b4f266") + (uuid 00000000-0000-0000-0000-000048b4f266) (property "Reference" "U1" (id 0) (at 63.5 63.5 0)) (property "Value" "ECC83" (id 1) (at 63.5 66.04 0)) (property "Footprint" "Valve:Valve_ECC-83-1" (id 2) (at 57.15 74.93 90) @@ -983,11 +1051,14 @@ (property "Datasheet" "" (id 3) (at 63.5 74.93 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "4" (uuid 56134f29-7f2f-477b-abd3-d6e4f4f2aaee)) + (pin "5" (uuid 1e32fa54-428c-48ea-9e6b-4079fc50a9f0)) + (pin "9" (uuid 3eae7415-148a-4ee7-906a-fc6d82bc3f3d)) ) (symbol (lib_id "ecc83_schlib:ECC83") (at 157.48 107.95 0) (unit 2) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000048b4f263") + (uuid 00000000-0000-0000-0000-000048b4f263) (property "Reference" "U1" (id 0) (at 161.29 99.06 0)) (property "Value" "ECC83" (id 1) (at 162.56 116.84 0)) (property "Footprint" "Valve:Valve_ECC-83-1" (id 2) (at 162.56 118.11 0) @@ -996,11 +1067,14 @@ (property "Datasheet" "" (id 3) (at 157.48 107.95 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "1" (uuid c6b51030-b7bc-4938-bc00-7984141d6fc7)) + (pin "2" (uuid 288852d3-f6be-4f19-b085-d2f3120b33e5)) + (pin "3" (uuid 6f1cbeb6-bf97-42be-9d8e-ce07a855afc7)) ) (symbol (lib_id "ecc83_schlib:ECC83") (at 160.02 64.77 0) (unit 1) (in_bom yes) (on_board yes) - (uuid "00000000-0000-0000-0000-000048b4f256") + (uuid 00000000-0000-0000-0000-000048b4f256) (property "Reference" "U1" (id 0) (at 163.83 55.88 0)) (property "Value" "ECC83" (id 1) (at 153.67 72.39 0)) (property "Footprint" "Valve:Valve_ECC-83-1" (id 2) (at 166.37 64.77 90) @@ -1009,6 +1083,9 @@ (property "Datasheet" "" (id 3) (at 160.02 64.77 0) (effects (font (size 1.524 1.524)) hide) ) + (pin "6" (uuid 290267e7-4016-4193-aa9b-8e119f086579)) + (pin "7" (uuid 57816012-691f-43c4-891a-0a9875701932)) + (pin "8" (uuid dfa2a830-6e8c-46c0-9986-7a866e30ad89)) ) (sheet_instances diff --git a/demos/ecc83/ecc83_schlib.kicad_sym b/demos/ecc83/ecc83_schlib.kicad_sym index e38ae0848e..7556e29fa4 100644 --- a/demos/ecc83/ecc83_schlib.kicad_sym +++ b/demos/ecc83/ecc83_schlib.kicad_sym @@ -130,15 +130,15 @@ (rectangle (start -2.286 0.508) (end 2.286 0.508) (stroke (width 0)) (fill (type none)) ) - (rectangle (start 2.286 -0.508) (end -2.286 -1.016) - (stroke (width 0)) (fill (type outline)) - ) (rectangle (start 2.286 1.016) (end -2.286 1.016) (stroke (width 0)) (fill (type none)) ) (rectangle (start 2.286 1.016) (end 2.286 0.508) (stroke (width 0)) (fill (type none)) ) + (rectangle (start 2.286 -0.508) (end -2.286 -1.016) + (stroke (width 0)) (fill (type outline)) + ) (polyline (pts (xy -1.778 2.286) @@ -204,6 +204,22 @@ (stroke (width 0)) (fill (type none)) ) ) + (symbol "ECC81_1_0" + (polyline + (pts + (xy -2.54 -5.08) + (xy -2.54 -7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + (polyline + (pts + (xy 0 5.08) + (xy 0 7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + ) (symbol "ECC81_1_1" (arc (start 2.54 -5.08) (end -2.54 -5.08) (radius (at 0 -5.715) (length 2.6162) (angles 14.2 165.9)) (stroke (width 0.254)) (fill (type none)) @@ -257,6 +273,22 @@ (number "8" (effects (font (size 1.016 1.016)))) ) ) + (symbol "ECC81_2_0" + (polyline + (pts + (xy -2.54 -5.08) + (xy -2.54 -7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + (polyline + (pts + (xy 0 5.08) + (xy 0 7.62) + ) + (stroke (width 0)) (fill (type none)) + ) + ) (symbol "ECC81_2_1" (arc (start 2.54 -5.08) (end -2.54 -5.08) (radius (at 0 -5.715) (length 2.6162) (angles 14.2 165.9)) (stroke (width 0.254)) (fill (type none)) @@ -330,38 +362,6 @@ (number "9" (effects (font (size 1.016 1.016)))) ) ) - (symbol "ECC81_1_0" - (polyline - (pts - (xy -2.54 -5.08) - (xy -2.54 -7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - (polyline - (pts - (xy 0 5.08) - (xy 0 7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - ) - (symbol "ECC81_2_0" - (polyline - (pts - (xy -2.54 -5.08) - (xy -2.54 -7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - (polyline - (pts - (xy 0 5.08) - (xy 0 7.62) - ) - (stroke (width 0)) (fill (type none)) - ) - ) ) (symbol "ecc83_schlib:ECC83" (extends "ECC81") (property "Reference" "U" (id 0) (at 3.302 7.874 0) @@ -423,6 +423,12 @@ (property "Datasheet" "" (id 3) (at 0 0 0) (effects (font (size 1.524 1.524))) ) + (symbol "PWR_FLAG_0_0" + (pin power_out line (at 0 0 90) (length 0) + (name "pwr" (effects (font (size 0.508 0.508)))) + (number "1" (effects (font (size 0.508 0.508)))) + ) + ) (symbol "PWR_FLAG_0_1" (polyline (pts @@ -436,12 +442,6 @@ (stroke (width 0)) (fill (type none)) ) ) - (symbol "PWR_FLAG_0_0" - (pin power_out line (at 0 0 90) (length 0) - (name "pwr" (effects (font (size 0.508 0.508)))) - (number "1" (effects (font (size 0.508 0.508)))) - ) - ) ) (symbol "ecc83_schlib:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes) (property "Reference" "R" (id 0) (at 2.032 0 90) diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 4399777c5f..eff312f7b2 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -648,6 +648,7 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_COMPONENT* aSymbol, const SCH_SHE } } + aSymbol->SetSchSymbolLibraryName( wxEmptyString ); screen->Append( aSymbol ); frame->GetCanvas()->GetView()->Update( aSymbol ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index a52bddcf99..d2f17b500b 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -683,8 +683,7 @@ int ERC_TESTER::TestLibSymbolIssues() wxCHECK2( symbol, continue ); - wxString libIdStr = symbol->GetSchSymbolLibraryName(); - LIB_PART* libSymbolInSchematic = screen->GetLibSymbols()[ libIdStr ]; + LIB_PART* libSymbolInSchematic = symbol->GetPartRef().get(); wxCHECK2( libSymbolInSchematic, continue ); diff --git a/eeschema/lib_item.cpp b/eeschema/lib_item.cpp index b3e3a0f3c9..2d282b8d62 100644 --- a/eeschema/lib_item.cpp +++ b/eeschema/lib_item.cpp @@ -98,21 +98,6 @@ bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const { - int result = m_convert - aOther.m_convert; - - if( result != 0 ) - return result < 0; - - result = m_unit - aOther.m_unit; - - if( result != 0 ) - return result < 0; - - result = Type() - aOther.Type(); - - if( result != 0 ) - return result < 0; - return ( compare( aOther ) < 0 ); } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 8c4ab80c23..0dbf15065c 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -199,6 +199,8 @@ const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart ) m_drawings.push_back( newItem ); } + m_drawings.sort(); + PART_SPTR parent = aPart.m_parent.lock(); if( parent ) @@ -238,11 +240,16 @@ int LIB_PART::Compare( const LIB_PART& aRhs ) const if( m_drawings.size() != aRhs.m_drawings.size() ) return m_drawings.size() - aRhs.m_drawings.size(); - LIB_ITEMS_CONTAINER::CONST_ITERATOR lhsItem = m_drawings.begin(); - LIB_ITEMS_CONTAINER::CONST_ITERATOR rhsItem = aRhs.m_drawings.begin(); + LIB_ITEMS_CONTAINER::CONST_ITERATOR lhsItemIt = m_drawings.begin(); + LIB_ITEMS_CONTAINER::CONST_ITERATOR rhsItemIt = aRhs.m_drawings.begin(); - while( lhsItem != m_drawings.end() ) + while( lhsItemIt != m_drawings.end() ) { + const LIB_ITEM* lhsItem = static_cast( &(*lhsItemIt) ); + const LIB_ITEM* rhsItem = static_cast( &(*rhsItemIt) ); + + wxCHECK( lhsItem && rhsItem, lhsItem - rhsItem ); + if( lhsItem->Type() != rhsItem->Type() ) return lhsItem->Type() - rhsItem->Type(); @@ -251,8 +258,8 @@ int LIB_PART::Compare( const LIB_PART& aRhs ) const if( retv ) return retv; - ++lhsItem; - ++rhsItem; + ++lhsItemIt; + ++rhsItemIt; } if( m_fpFilters.GetCount() != aRhs.m_fpFilters.GetCount() ) @@ -645,12 +652,14 @@ void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem ) } -void LIB_PART::AddDrawItem( LIB_ITEM* aItem ) +void LIB_PART::AddDrawItem( LIB_ITEM* aItem, bool aSort ) { - if( !aItem ) - return; + wxCHECK( aItem, /* void */ ); m_drawings.push_back( aItem ); + + if( aSort ) + m_drawings.sort(); } @@ -888,6 +897,8 @@ void LIB_PART::SetFields( const std::vector & aFields ) field->SetParent( this ); m_drawings.push_back( field ); } + + m_drawings.sort(); } @@ -1143,6 +1154,7 @@ void LIB_PART::SetUnitCount( int aCount, bool aDuplicateDrawItems ) m_drawings.push_back( item ); } + m_drawings.sort(); m_unitCount = aCount; } @@ -1201,6 +1213,8 @@ void LIB_PART::SetConversion( bool aSetConvert, bool aDuplicatePins ) ++i; } } + + m_drawings.sort(); } diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 243cde6962..f79bd61e5a 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -327,11 +327,12 @@ public: const TRANSFORM& aTransform ); /** - * Add a new draw \a aItem to the draw object list. + * Add a new draw \a aItem to the draw object list and sort according to \a aSort. * - * @param aItem - New draw object to add to part. + * @param aItem is the new draw object to add to the symbol. + * @param aSort is the flag to determine if the newly added item should be sorted. */ - void AddDrawItem( LIB_ITEM* aItem ); + void AddDrawItem( LIB_ITEM* aItem, bool aSort = true ); /** * Remove draw \a aItem from list. diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 242715e1f9..8cef609f79 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -311,7 +311,7 @@ LIB_PART* SCH_SEXPR_PARSER::ParseSymbol( LIB_PART_MAP& aSymbolLibMap, int aFileV wxCHECK_MSG( item, nullptr, "Invalid draw item pointer." ); item->SetParent( symbol.get() ); - symbol->AddDrawItem( item ); + symbol->AddDrawItem( item, false ); break; default: @@ -336,7 +336,7 @@ LIB_PART* SCH_SEXPR_PARSER::ParseSymbol( LIB_PART_MAP& aSymbolLibMap, int aFileV wxCHECK_MSG( item, nullptr, "Invalid draw item pointer." ); item->SetParent( symbol.get() ); - symbol->AddDrawItem( item ); + symbol->AddDrawItem( item, false ); break; default: @@ -345,6 +345,7 @@ LIB_PART* SCH_SEXPR_PARSER::ParseSymbol( LIB_PART_MAP& aSymbolLibMap, int aFileV } } + symbol->GetDrawItems().sort(); m_symbolName.clear(); return symbol.release(); @@ -834,7 +835,7 @@ void SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol ) if( !existingField ) { - aSymbol->AddDrawItem( field.release() ); + aSymbol->AddDrawItem( field.release(), false ); } else { diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index 7db898c926..c6c9e410ff 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -3017,7 +3017,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, else { field = new LIB_FIELD( aPart.get(), id ); - aPart->AddDrawItem( field ); + aPart->AddDrawItem( field, false ); } // Skip to the first double quote. @@ -3152,36 +3152,39 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr& aPart, while( line ) { if( strCompare( "ENDDRAW", line, &line ) ) + { + aPart->GetDrawItems().sort(); return; + } switch( line[0] ) { case 'A': // Arc - aPart->AddDrawItem( loadArc( aPart, aReader ) ); + aPart->AddDrawItem( loadArc( aPart, aReader ), false ); break; case 'C': // Circle - aPart->AddDrawItem( loadCircle( aPart, aReader ) ); + aPart->AddDrawItem( loadCircle( aPart, aReader ), false ); break; case 'T': // Text - aPart->AddDrawItem( loadText( aPart, aReader, aMajorVersion, aMinorVersion ) ); + aPart->AddDrawItem( loadText( aPart, aReader, aMajorVersion, aMinorVersion ), false ); break; case 'S': // Square - aPart->AddDrawItem( loadRectangle( aPart, aReader ) ); + aPart->AddDrawItem( loadRectangle( aPart, aReader ), false ); break; case 'X': // Pin Description - aPart->AddDrawItem( loadPin( aPart, aReader ) ); + aPart->AddDrawItem( loadPin( aPart, aReader ), false ); break; case 'P': // Polyline - aPart->AddDrawItem( loadPolyLine( aPart, aReader ) ); + aPart->AddDrawItem( loadPolyLine( aPart, aReader ), false ); break; case 'B': // Bezier Curves - aPart->AddDrawItem( loadBezier( aPart, aReader ) ); + aPart->AddDrawItem( loadBezier( aPart, aReader ), false ); break; case '#': // Comment diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 064cd9d73a..a21760054a 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -137,6 +137,8 @@ void SCH_SCREEN::Append( SCH_ITEM* aItem ) if( symbol->GetPartRef() ) { + symbol->GetPartRef()->GetDrawItems().sort(); + auto it = m_libSymbols.find( symbol->GetSchSymbolLibraryName() ); if( it == m_libSymbols.end() || !it->second ) @@ -152,6 +154,8 @@ void SCH_SCREEN::Append( SCH_ITEM* aItem ) // other schematic symbols referencing that library symbol from changing. LIB_PART* foundSymbol = it->second; + foundSymbol->GetDrawItems().sort(); + if( *foundSymbol != *symbol->GetPartRef() ) { int cnt = 1; @@ -734,6 +738,17 @@ void SCH_SCREEN::UpdateLocalLibSymbolLinks() } +void SCH_SCREEN::SwapSymbolLinks( const SCH_COMPONENT* aOriginalSymbol, + const SCH_COMPONENT* aNewSymbol ) +{ + wxCHECK( aOriginalSymbol && aNewSymbol /* && m_rtree.contains( aOriginalSymbol, true ) */, + /* void */ ); + + if( aOriginalSymbol->GetSchSymbolLibraryName() == aNewSymbol->GetSchSymbolLibraryName() ) + return; +} + + void SCH_SCREEN::Print( const RENDER_SETTINGS* aSettings ) { // Ensure links are up to date, even if a library was reloaded for some reason: diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index bd2ed673f0..5422c414b4 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -276,6 +276,8 @@ public: */ void UpdateLocalLibSymbolLinks(); + void SwapSymbolLinks( const SCH_COMPONENT* aOriginalSymbol, const SCH_COMPONENT* aNewSymbol ); + /** * Print all the items in the screen to \a aDC. * diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 7ded7a2b6d..479e074782 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -173,6 +173,7 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) : field.SetParent( this ); m_fieldsAutoplaced = aComponent.m_fieldsAutoplaced; + m_schLibSymbolName = aComponent.m_schLibSymbolName; } @@ -917,6 +918,7 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem ) component->m_transform = tmp; std::swap( m_instanceReferences, component->m_instanceReferences ); + std::swap( m_schLibSymbolName, component->m_schLibSymbolName ); } diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index e4fa729914..6184032f26 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -268,6 +268,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) { UNDO_REDO status = aList->GetPickedItemStatus((unsigned) ii ); EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii ); + SCH_SCREEN* screen = + dynamic_cast< SCH_SCREEN* >( aList->GetScreenForItem( (unsigned) ii ) ); + + wxCHECK( screen, /* void */ ); eda_item->SetFlags( aList->GetPickerFlags( (unsigned) ii ) ); eda_item->ClearEditFlags(); @@ -280,13 +284,13 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) if( status == UNDO_REDO::NEWITEM ) { // new items are deleted on undo - RemoveFromScreen( eda_item, (SCH_SCREEN*) aList->GetScreenForItem( (unsigned) ii ) ); + RemoveFromScreen( eda_item, screen ); aList->SetPickedItemStatus( UNDO_REDO::DELETED, (unsigned) ii ); } else if( status == UNDO_REDO::DELETED ) { // deleted items are re-inserted on undo - AddToScreen( eda_item, (SCH_SCREEN*) aList->GetScreenForItem( (unsigned) ii ) ); + AddToScreen( eda_item, screen ); aList->SetPickedItemStatus( UNDO_REDO::NEWITEM, (unsigned) ii ); } else if( status == UNDO_REDO::PAGESETTINGS ) @@ -307,11 +311,22 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) // The root sheet is a pseudo object that owns the root screen object but is not on // the root screen so do not attempt to remove it from the screen it owns. if( item != &Schematic().Root() ) - RemoveFromScreen( item, (SCH_SCREEN*) aList->GetScreenForItem( (unsigned) ii ) ); + RemoveFromScreen( item, screen ); switch( status ) { case UNDO_REDO::CHANGED: + if( item->Type() == SCH_COMPONENT_T ) + { + // Update the schematic library cache in case that was the change. + SCH_COMPONENT* symbol = dynamic_cast( item ); + SCH_COMPONENT* altSymbol = dynamic_cast( alt_item ); + + wxCHECK( symbol && altSymbol, /* void */ ); + + screen->SwapSymbolLinks( symbol, altSymbol ); + } + item->SwapData( alt_item ); if( item->Type() == SCH_COMPONENT_T ) @@ -332,7 +347,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) } if( item != &Schematic().Root() ) - AddToScreen( item, (SCH_SCREEN*) aList->GetScreenForItem( (unsigned) ii ) ); + AddToScreen( item, screen ); } } diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index f77cf56f8c..e1e57f4775 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -768,7 +768,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 ); newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 ); - part->GetDrawItems().push_back( newItem ); + part->AddDrawItem( newItem ); getView()->Add( newItem ); } @@ -815,7 +815,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) newItem->SetParent( part ); newItems.push_back( newItem ); - part->GetDrawItems().push_back( newItem ); + part->AddDrawItem( newItem ); getView()->Add( newItem ); } diff --git a/qa/eeschema/test_lib_part.cpp b/qa/eeschema/test_lib_part.cpp index 01c9a12f3e..381d3ebc3f 100644 --- a/qa/eeschema/test_lib_part.cpp +++ b/qa/eeschema/test_lib_part.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -370,6 +370,10 @@ BOOST_AUTO_TEST_CASE( Compare ) testPart.SetShowPinNumbers( true ); // Time stamp comparison tests. + + // Check to see if we broke the copy ctor. + LIB_PART* copy = new LIB_PART( testPart ); + BOOST_CHECK( testPart.Compare( *copy ) == 0 ); }