mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
API: Implement Deserialize for ZONE
This commit is contained in:
parent
4ab8c23851
commit
af91519e06
@ -635,6 +635,8 @@ message Zone
|
||||
repeated ZoneFilledPolygons filled_polygons = 10;
|
||||
|
||||
ZoneBorderSettings border = 11;
|
||||
|
||||
kiapi.common.types.LockedState locked = 12;
|
||||
}
|
||||
|
||||
message Dimension
|
||||
|
@ -216,7 +216,6 @@ void ZONE::Serialize( google::protobuf::Any& aContainer ) const
|
||||
types::Zone zone;
|
||||
|
||||
zone.mutable_id()->set_value( m_Uuid.AsStdString() );
|
||||
zone.set_filled( IsFilled() );
|
||||
PackLayerSet( *zone.mutable_layers(), GetLayerSet() );
|
||||
|
||||
if( m_isRuleArea )
|
||||
@ -312,12 +311,76 @@ bool ZONE::Deserialize( const google::protobuf::Any& aContainer )
|
||||
|
||||
const_cast<KIID&>( m_Uuid ) = KIID( zone.id().value() );
|
||||
SetLayerSet( UnpackLayerSet( zone.layers() ) );
|
||||
SetAssignedPriority( zone.priority() );
|
||||
SetZoneName( wxString::FromUTF8( zone.name() ) );
|
||||
|
||||
if( zone.type() == types::ZoneType::ZT_RULE_AREA )
|
||||
m_isRuleArea = true;
|
||||
|
||||
if( !m_Poly )
|
||||
SetOutline( new SHAPE_POLY_SET );
|
||||
|
||||
*m_Poly = kiapi::common::UnpackPolySet( zone.outline() );
|
||||
|
||||
if( m_isRuleArea )
|
||||
{
|
||||
const types::RuleAreaSettings& ra = zone.rule_area_settings();
|
||||
m_doNotAllowCopperPour = ra.keepout_copper();
|
||||
m_doNotAllowFootprints = ra.keepout_footprints();
|
||||
m_doNotAllowPads = ra.keepout_pads();
|
||||
m_doNotAllowTracks = ra.keepout_tracks();
|
||||
m_doNotAllowVias = ra.keepout_vias();
|
||||
|
||||
m_ruleAreaPlacementEnabled = ra.placement_enabled();
|
||||
m_ruleAreaPlacementSource = wxString::FromUTF8( ra.placement_source() );
|
||||
m_ruleAreaPlacementSourceType =
|
||||
FromProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE>( ra.placement_source_type() );
|
||||
}
|
||||
else
|
||||
{
|
||||
const types::CopperZoneSettings& cu = zone.copper_settings();
|
||||
m_PadConnection = FromProtoEnum<ZONE_CONNECTION>( cu.connection().zone_connection() );
|
||||
m_thermalReliefSpokeWidth = cu.connection().thermal_spokes().width();
|
||||
m_thermalReliefGap = cu.connection().thermal_spokes().gap();
|
||||
m_ZoneClearance = cu.clearance().value_nm();
|
||||
m_ZoneMinThickness = cu.min_thickness().value_nm();
|
||||
m_islandRemovalMode = FromProtoEnum<ISLAND_REMOVAL_MODE>( cu.island_mode() );
|
||||
m_minIslandArea = cu.min_island_area();
|
||||
m_fillMode = FromProtoEnum<ZONE_FILL_MODE>( cu.fill_mode() );
|
||||
|
||||
m_hatchThickness = cu.hatch_settings().thickness().value_nm();
|
||||
m_hatchGap = cu.hatch_settings().gap().value_nm();
|
||||
m_hatchOrientation =
|
||||
EDA_ANGLE( cu.hatch_settings().orientation().value_degrees(), DEGREES_T );
|
||||
m_hatchSmoothingValue = cu.hatch_settings().hatch_smoothing_ratio();
|
||||
m_hatchHoleMinArea = cu.hatch_settings().hatch_hole_min_area_ratio();
|
||||
|
||||
switch( cu.hatch_settings().border_mode() )
|
||||
{
|
||||
default:
|
||||
case types::ZHFBM_USE_MIN_ZONE_THICKNESS: m_hatchBorderAlgorithm = 0; break;
|
||||
case types::ZHFBM_USE_HATCH_THICKNESS: m_hatchBorderAlgorithm = 1; break;
|
||||
}
|
||||
|
||||
SetNetCode( cu.net().code().value() );
|
||||
m_teardropType = FromProtoEnum<TEARDROP_TYPE>( cu.teardrop().type() );
|
||||
}
|
||||
|
||||
m_borderStyle = FromProtoEnum<ZONE_BORDER_DISPLAY_STYLE>( zone.border().style() );
|
||||
m_borderHatchPitch = zone.border().pitch().value_nm();
|
||||
|
||||
if( zone.filled() )
|
||||
{
|
||||
// TODO(JE) check what else has to happen here
|
||||
SetIsFilled( true );
|
||||
SetNeedRefill( false );
|
||||
|
||||
for( const types::ZoneFilledPolygons& fillLayer : zone.filled_polygons() )
|
||||
{
|
||||
PCB_LAYER_ID layer = FromProtoEnum<PCB_LAYER_ID>( fillLayer.layer() );
|
||||
SHAPE_POLY_SET shape = kiapi::common::UnpackPolySet( fillLayer.shapes() );
|
||||
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>( shape );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
(kicad_pcb
|
||||
(version 20240225)
|
||||
(version 20241030)
|
||||
(generator "pcbnew")
|
||||
(generator_version "8.99")
|
||||
(general
|
||||
@ -9,41 +9,42 @@
|
||||
(paper "A4")
|
||||
(layers
|
||||
(0 "F.Cu" signal)
|
||||
(31 "B.Cu" signal)
|
||||
(32 "B.Adhes" user "B.Adhesive")
|
||||
(33 "F.Adhes" user "F.Adhesive")
|
||||
(34 "B.Paste" user)
|
||||
(35 "F.Paste" user)
|
||||
(36 "B.SilkS" user "B.Silkscreen")
|
||||
(37 "F.SilkS" user "F.Silkscreen")
|
||||
(38 "B.Mask" user)
|
||||
(39 "F.Mask" user)
|
||||
(40 "Dwgs.User" user "User.Drawings")
|
||||
(41 "Cmts.User" user "User.Comments")
|
||||
(42 "Eco1.User" user "User.Eco1")
|
||||
(43 "Eco2.User" user "User.Eco2")
|
||||
(44 "Edge.Cuts" user)
|
||||
(45 "Margin" user)
|
||||
(46 "B.CrtYd" user "B.Courtyard")
|
||||
(47 "F.CrtYd" user "F.Courtyard")
|
||||
(48 "B.Fab" user)
|
||||
(49 "F.Fab" user)
|
||||
(50 "User.1" user)
|
||||
(51 "User.2" user)
|
||||
(52 "User.3" user)
|
||||
(53 "User.4" user)
|
||||
(54 "User.5" user)
|
||||
(55 "User.6" user)
|
||||
(56 "User.7" user)
|
||||
(57 "User.8" user)
|
||||
(58 "User.9" user)
|
||||
(2 "B.Cu" signal)
|
||||
(9 "F.Adhes" user)
|
||||
(11 "B.Adhes" user)
|
||||
(13 "F.Paste" user)
|
||||
(15 "B.Paste" user)
|
||||
(5 "F.SilkS" user)
|
||||
(7 "B.SilkS" user)
|
||||
(1 "F.Mask" user)
|
||||
(3 "B.Mask" user)
|
||||
(17 "Dwgs.User" user)
|
||||
(19 "Cmts.User" user)
|
||||
(21 "Eco1.User" user)
|
||||
(23 "Eco2.User" user)
|
||||
(25 "Edge.Cuts" user)
|
||||
(27 "Margin" user)
|
||||
(31 "F.CrtYd" user)
|
||||
(29 "B.CrtYd" user)
|
||||
(35 "F.Fab" user)
|
||||
(33 "B.Fab" user)
|
||||
(39 "User.1" signal)
|
||||
(41 "User.2" signal)
|
||||
(43 "User.3" signal)
|
||||
(45 "User.4" signal)
|
||||
(47 "User.5" signal)
|
||||
(49 "User.6" signal)
|
||||
(51 "User.7" signal)
|
||||
(53 "User.8" signal)
|
||||
(55 "User.9" signal)
|
||||
)
|
||||
(setup
|
||||
(pad_to_mask_clearance 0)
|
||||
(allow_soldermask_bridges_in_footprints no)
|
||||
(tenting front back)
|
||||
(pcbplotparams
|
||||
(layerselection 0x00010fc_ffffffff)
|
||||
(plot_on_all_layers_selection 0x0000000_00000000)
|
||||
(layerselection 0x000010fc_ffffffff)
|
||||
(plot_on_all_layers_selection 0x00000000_00000000)
|
||||
(disableapertmacros no)
|
||||
(usegerberextensions no)
|
||||
(usegerberattributes yes)
|
||||
@ -53,7 +54,6 @@
|
||||
(dashed_line_gap_ratio 3.000000)
|
||||
(svgprecision 4)
|
||||
(plotframeref no)
|
||||
(viasonmask no)
|
||||
(mode 1)
|
||||
(useauxorigin no)
|
||||
(hpglpennumber 1)
|
||||
@ -67,11 +67,12 @@
|
||||
(dxfusepcbnewfont yes)
|
||||
(psnegative no)
|
||||
(psa4output no)
|
||||
(plotreference yes)
|
||||
(plotvalue yes)
|
||||
(plotfptext yes)
|
||||
(plotinvisibletext no)
|
||||
(sketchpadsonfab no)
|
||||
(plotpadnumbers no)
|
||||
(hidednponfab no)
|
||||
(sketchdnponfab yes)
|
||||
(crossoutdnponfab yes)
|
||||
(subtractmaskfromsilk no)
|
||||
(outputformat 1)
|
||||
(mirror no)
|
||||
@ -120,6 +121,7 @@
|
||||
(effects
|
||||
(font
|
||||
(size 1.27 1.27)
|
||||
(thickness 0.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -132,6 +134,7 @@
|
||||
(effects
|
||||
(font
|
||||
(size 1.27 1.27)
|
||||
(thickness 0.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -144,6 +147,7 @@
|
||||
(effects
|
||||
(font
|
||||
(size 1.27 1.27)
|
||||
(thickness 0.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -284,6 +288,7 @@
|
||||
)
|
||||
(uuid "b38f2485-6695-4057-bc99-fba8492caea0")
|
||||
)
|
||||
(embedded_fonts no)
|
||||
(model "discret/diode.wrl"
|
||||
(offset
|
||||
(xyz 0 0 0)
|
||||
@ -333,6 +338,7 @@
|
||||
(effects
|
||||
(font
|
||||
(size 1.27 1.27)
|
||||
(thickness 0.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -345,6 +351,7 @@
|
||||
(effects
|
||||
(font
|
||||
(size 1.27 1.27)
|
||||
(thickness 0.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -357,6 +364,7 @@
|
||||
(effects
|
||||
(font
|
||||
(size 1.27 1.27)
|
||||
(thickness 0.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -428,6 +436,7 @@
|
||||
(remove_unused_layers no)
|
||||
(uuid "d615d510-9f7d-4da4-907d-b271da602bbf")
|
||||
)
|
||||
(embedded_fonts no)
|
||||
(model "device/bornier_2.wrl"
|
||||
(offset
|
||||
(xyz 0 0 0)
|
||||
@ -638,6 +647,109 @@
|
||||
(net 1)
|
||||
(uuid "fabfab7b-4ea2-487a-a340-e24bbc4c982e")
|
||||
)
|
||||
(zone
|
||||
(net 0)
|
||||
(net_name "")
|
||||
(locked yes)
|
||||
(layers "F&B.Cu")
|
||||
(uuid "0f5227b8-34f3-4302-949f-9de38b16fecf")
|
||||
(name "MyKeepout")
|
||||
(hatch full 0.65)
|
||||
(connect_pads
|
||||
(clearance 0)
|
||||
)
|
||||
(min_thickness 0.25)
|
||||
(filled_areas_thickness no)
|
||||
(keepout
|
||||
(tracks allowed)
|
||||
(vias not_allowed)
|
||||
(pads not_allowed)
|
||||
(copperpour allowed)
|
||||
(footprints allowed)
|
||||
)
|
||||
(placement
|
||||
(enabled no)
|
||||
(sheetname "")
|
||||
)
|
||||
(fill
|
||||
(thermal_gap 0.5)
|
||||
(thermal_bridge_width 0.5)
|
||||
)
|
||||
(polygon
|
||||
(pts
|
||||
(xy 81 107.15) (xy 88.35 111.05) (xy 93 100.4) (xy 82.85 91.75) (xy 76.1 98.9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(zone
|
||||
(net 0)
|
||||
(net_name "")
|
||||
(layers "F&B.Cu")
|
||||
(uuid "9c3e186b-0f1d-48ef-8724-baad4fa44742")
|
||||
(hatch edge 1)
|
||||
(connect_pads
|
||||
(clearance 0)
|
||||
)
|
||||
(min_thickness 0.25)
|
||||
(filled_areas_thickness no)
|
||||
(keepout
|
||||
(tracks allowed)
|
||||
(vias allowed)
|
||||
(pads allowed)
|
||||
(copperpour not_allowed)
|
||||
(footprints not_allowed)
|
||||
)
|
||||
(placement
|
||||
(enabled no)
|
||||
(sheetname "")
|
||||
)
|
||||
(fill
|
||||
(thermal_gap 0.5)
|
||||
(thermal_bridge_width 0.5)
|
||||
)
|
||||
(polygon
|
||||
(pts
|
||||
(xy 71 106.5) (xy 63.7 111.45) (xy 53.05 106.8) (xy 56.95 99.45) (xy 65.2 94.55)
|
||||
)
|
||||
)
|
||||
(polygon
|
||||
(pts
|
||||
(xy 62.45 100.8) (xy 62.6 102.35) (xy 65.4 103.05) (xy 65.75 101.35) (xy 64.05 100.15)
|
||||
)
|
||||
)
|
||||
)
|
||||
(zone
|
||||
(net 0)
|
||||
(net_name "")
|
||||
(layers "F&B.Cu")
|
||||
(uuid "f52cce18-23b9-4645-b87a-21d0716548c2")
|
||||
(hatch none 0.65)
|
||||
(connect_pads
|
||||
(clearance 0)
|
||||
)
|
||||
(min_thickness 0.25)
|
||||
(filled_areas_thickness no)
|
||||
(keepout
|
||||
(tracks allowed)
|
||||
(vias allowed)
|
||||
(pads allowed)
|
||||
(copperpour not_allowed)
|
||||
(footprints not_allowed)
|
||||
)
|
||||
(placement
|
||||
(enabled no)
|
||||
(sheetname "")
|
||||
)
|
||||
(fill
|
||||
(thermal_gap 0.5)
|
||||
(thermal_bridge_width 0.5)
|
||||
)
|
||||
(polygon
|
||||
(pts
|
||||
(xy 67.85 85.1) (xy 63.95 92.45) (xy 74.6 97.1) (xy 83.25 86.95) (xy 76.1 80.2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(zone
|
||||
(net 0)
|
||||
(net_name "")
|
||||
@ -3875,4 +3987,5 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(embedded_fonts no)
|
||||
)
|
||||
|
@ -48,7 +48,7 @@
|
||||
"silk_text_thickness": 0.1,
|
||||
"silk_text_upright": false,
|
||||
"zones": {
|
||||
"min_clearance": 0.5
|
||||
"min_clearance": 0.0
|
||||
}
|
||||
},
|
||||
"diff_pair_dimensions": [],
|
||||
@ -63,16 +63,20 @@
|
||||
"copper_edge_clearance": "error",
|
||||
"copper_sliver": "warning",
|
||||
"courtyards_overlap": "error",
|
||||
"creepage": "error",
|
||||
"diff_pair_gap_out_of_range": "error",
|
||||
"diff_pair_uncoupled_length_too_long": "error",
|
||||
"drill_out_of_range": "error",
|
||||
"duplicate_footprints": "warning",
|
||||
"extra_footprint": "warning",
|
||||
"footprint": "error",
|
||||
"footprint_filters_mismatch": "ignore",
|
||||
"footprint_symbol_mismatch": "warning",
|
||||
"footprint_type_mismatch": "ignore",
|
||||
"hole_clearance": "error",
|
||||
"hole_near_hole": "error",
|
||||
"hole_to_hole": "warning",
|
||||
"holes_co_located": "warning",
|
||||
"invalid_outline": "error",
|
||||
"isolated_copper": "warning",
|
||||
"item_on_disabled_layer": "error",
|
||||
@ -99,7 +103,9 @@
|
||||
"text_thickness": "warning",
|
||||
"through_hole_pad_without_hole": "error",
|
||||
"too_many_vias": "error",
|
||||
"track_angle": "error",
|
||||
"track_dangling": "warning",
|
||||
"track_segment_length": "error",
|
||||
"track_width": "error",
|
||||
"tracks_crossing": "error",
|
||||
"unconnected_items": "error",
|
||||
@ -112,6 +118,7 @@
|
||||
"min_clearance": 0.0,
|
||||
"min_connection": 0.0,
|
||||
"min_copper_edge_clearance": 0.5,
|
||||
"min_groove_width": 0.0,
|
||||
"min_hole_clearance": 0.25,
|
||||
"min_hole_to_hole": 0.25,
|
||||
"min_microvia_diameter": 0.2,
|
||||
@ -129,10 +136,11 @@
|
||||
},
|
||||
"teardrop_options": [
|
||||
{
|
||||
"td_onpadsmd": true,
|
||||
"td_onpthpad": true,
|
||||
"td_onroundshapesonly": false,
|
||||
"td_onsmdpad": true,
|
||||
"td_ontrackend": false,
|
||||
"td_onviapad": true
|
||||
"td_onvia": true
|
||||
}
|
||||
],
|
||||
"teardrop_parameters": [
|
||||
@ -207,6 +215,7 @@
|
||||
"mfg": "",
|
||||
"mpn": ""
|
||||
},
|
||||
"layer_pairs": [],
|
||||
"layer_presets": [],
|
||||
"viewports": []
|
||||
},
|
||||
@ -220,7 +229,7 @@
|
||||
},
|
||||
"meta": {
|
||||
"filename": "api_kitchen_sink.kicad_pro",
|
||||
"version": 1
|
||||
"version": 2
|
||||
},
|
||||
"net_settings": {
|
||||
"classes": [
|
||||
@ -235,6 +244,7 @@
|
||||
"microvia_drill": 0.1,
|
||||
"name": "Default",
|
||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||
"priority": 2147483647,
|
||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||
"track_width": 0.2,
|
||||
"via_diameter": 0.6,
|
||||
@ -243,7 +253,7 @@
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"version": 3
|
||||
"version": 4
|
||||
},
|
||||
"net_colors": null,
|
||||
"netclass_assignments": null,
|
||||
|
@ -113,9 +113,14 @@ BOOST_FIXTURE_TEST_CASE( BoardTypes, PROTO_TEST_FIXTURE )
|
||||
for( FOOTPRINT* footprint : m_board->Footprints() )
|
||||
testProtoFromKiCadObject<kiapi::board::types::FootprintInstance>( footprint );
|
||||
|
||||
// Not yet
|
||||
// for( ZONE* zone : m_board->Zones() )
|
||||
// testProtoFromKiCadObject<kiapi::board::types::Zone>( zone );
|
||||
for( ZONE* zone : m_board->Zones() )
|
||||
testProtoFromKiCadObject<kiapi::board::types::Zone>( zone );
|
||||
|
||||
// TODO(JE) Shapes
|
||||
|
||||
// TODO(JE) Text
|
||||
|
||||
// TODO(JE) Dimensions
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user