Fix copy constructors for BOARD_DESIGN_SETTINGS and ZONE_CONTAINER

This commit is contained in:
Ian McInerney 2020-07-18 23:55:06 +01:00
parent a253c53fe7
commit 2542d41481
2 changed files with 67 additions and 73 deletions

View File

@ -42,7 +42,6 @@ const int bdsSchemaVersion = 0;
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aParent, aPath ),
m_Pad_Master( NULL )
{
// We want to leave alone parameters that aren't found in the project JSON as they may be
// initialized by the board file parser before NESTED_SETTINGS::LoadFromFile is called.
@ -593,6 +592,7 @@ void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther )
m_DiffPairDimensionsList = aOther.m_DiffPairDimensionsList;
m_DRCRuleSelectors = aOther.m_DRCRuleSelectors;
m_DRCRules = aOther.m_DRCRules;
m_matched = aOther.m_matched;
m_MicroViasAllowed = aOther.m_MicroViasAllowed;
m_BlindBuriedViaAllowed = aOther.m_BlindBuriedViaAllowed;
m_CurrentViaType = aOther.m_CurrentViaType;
@ -612,12 +612,9 @@ void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther )
m_MaxError = aOther.m_MaxError;
m_SolderMaskMargin = aOther.m_SolderMaskMargin;
m_SolderMaskMinWidth = aOther.m_SolderMaskMinWidth;
m_SolderPasteMargin = aOther.m_SolderPasteMargin;
m_SolderPasteMarginRatio = aOther.m_SolderPasteMarginRatio;
m_DefaultFPTextItems = aOther.m_DefaultFPTextItems;
m_DimensionUnits = aOther.m_DimensionUnits;
m_DimensionPrecision = aOther.m_DimensionPrecision;
m_AuxOrigin = aOther.m_AuxOrigin;
m_GridOrigin = aOther.m_GridOrigin;
std::copy( std::begin( aOther.m_LineThickness ), std::end( aOther.m_LineThickness ),
std::begin( m_LineThickness ) );
@ -633,6 +630,34 @@ void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther )
std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ),
std::begin( m_TextUpright ) );
m_DimensionUnits = aOther.m_DimensionUnits;
m_DimensionPrecision = aOther.m_DimensionPrecision;
m_AuxOrigin = aOther.m_AuxOrigin;
m_GridOrigin = aOther.m_GridOrigin;
m_HasStackup = aOther.m_HasStackup;
m_trackWidthIndex = aOther.m_trackWidthIndex;
m_viaSizeIndex = aOther.m_viaSizeIndex;
m_diffPairIndex = aOther.m_diffPairIndex;
m_useCustomTrackVia = aOther.m_useCustomTrackVia;
m_customTrackWidth = aOther.m_customTrackWidth;
m_customViaSize = aOther.m_customViaSize;
m_useCustomDiffPair = aOther.m_useCustomDiffPair;
m_customDiffPair = aOther.m_customDiffPair;
m_copperLayerCount = aOther.m_copperLayerCount;
m_enabledLayers = aOther.m_enabledLayers;
m_boardThickness = aOther.m_boardThickness;
m_currentNetClassName = aOther.m_currentNetClassName;
m_stackup = aOther.m_stackup;
// Only take the pointer from the other if it isn't the default
if( aOther.m_netClasses == &aOther.m_internalNetClasses )
m_netClasses = &m_internalNetClasses;
else
m_netClasses = aOther.m_netClasses;
m_defaultZoneSettings = aOther.m_defaultZoneSettings;
}

View File

@ -82,41 +82,7 @@ ZONE_CONTAINER& ZONE_CONTAINER::operator=( const ZONE_CONTAINER& aOther )
{
BOARD_CONNECTED_ITEM::operator=( aOther );
// Replace the outlines for aOther outlines.
delete m_Poly;
m_Poly = new SHAPE_POLY_SET( *aOther.m_Poly );
m_isKeepout = aOther.m_isKeepout;
SetLayerSet( aOther.GetLayerSet() );
m_zoneName = aOther.m_zoneName;
m_IsFilled = aOther.m_IsFilled;
m_CornerSelection = nullptr; // for corner moving, corner index to (null if no selection)
m_ZoneClearance = aOther.m_ZoneClearance; // clearance value
m_ZoneMinThickness = aOther.m_ZoneMinThickness;
m_FilledPolysUseThickness = aOther.m_FilledPolysUseThickness;
m_FillMode = aOther.m_FillMode; // filling mode (segments/polygons)
m_PadConnection = aOther.m_PadConnection;
m_ThermalReliefGap = aOther.m_ThermalReliefGap;
m_ThermalReliefCopperBridge = aOther.m_ThermalReliefCopperBridge;
SetHatchStyle( aOther.GetHatchStyle() );
SetHatchPitch( aOther.GetHatchPitch() );
m_HatchLines = aOther.m_HatchLines; // copy vector <SEG>
for( PCB_LAYER_ID layer : aOther.GetLayerSet().Seq() )
{
m_FilledPolysList[layer] = aOther.m_FilledPolysList.at( layer );
m_RawPolysList[layer] = aOther.m_RawPolysList.at( layer );
m_filledPolysHash[layer] = aOther.m_filledPolysHash.at( layer );
m_FillSegmList[layer] = aOther.m_FillSegmList.at( layer ); // vector <> copy
m_insulatedIslands[layer] = aOther.m_insulatedIslands.at( layer );
}
m_HatchFillTypeThickness = aOther.m_HatchFillTypeThickness;
m_HatchFillTypeGap = aOther.m_HatchFillTypeGap;
m_HatchFillTypeOrientation = aOther.m_HatchFillTypeOrientation;
m_HatchFillTypeSmoothingLevel = aOther.m_HatchFillTypeSmoothingLevel;
m_HatchFillTypeSmoothingValue = aOther.m_HatchFillTypeSmoothingValue;
initDataFromSrcInCopyCtor( aOther );
return *this;
}
@ -139,25 +105,45 @@ void ZONE_CONTAINER::initDataFromSrcInCopyCtor( const ZONE_CONTAINER& aZone )
m_Flags = aZone.m_Flags;
m_forceVisible = aZone.m_forceVisible;
m_isKeepout = aZone.m_isKeepout;
SetLayerSet( aZone.GetLayerSet() );
m_zoneName = aZone.m_zoneName;
// Replace the outlines for aZone outlines.
delete m_Poly;
m_Poly = new SHAPE_POLY_SET( *aZone.m_Poly );
m_cornerSmoothingType = aZone.m_cornerSmoothingType;
m_cornerRadius = aZone.m_cornerRadius;
m_zoneName = aZone.m_zoneName;
SetLayerSet( aZone.GetLayerSet() );
m_priority = aZone.m_priority;
m_isKeepout = aZone.m_isKeepout;
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
m_doNotAllowVias = aZone.m_doNotAllowVias;
m_doNotAllowTracks = aZone.m_doNotAllowTracks;
m_doNotAllowPads = aZone.m_doNotAllowPads;
m_doNotAllowFootprints = aZone.m_doNotAllowFootprints;
m_PadConnection = aZone.m_PadConnection;
m_ZoneClearance = aZone.m_ZoneClearance; // clearance value
m_ZoneMinThickness = aZone.m_ZoneMinThickness;
m_FilledPolysUseThickness = aZone.m_FilledPolysUseThickness;
m_islandRemovalMode = aZone.m_islandRemovalMode;
m_minIslandArea = aZone.m_minIslandArea;
m_IsFilled = aZone.m_IsFilled;
m_needRefill = aZone.m_needRefill;
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
m_FillMode = aZone.m_FillMode; // Filling mode (segments/polygons)
m_HatchFillTypeThickness = aZone.m_HatchFillTypeThickness;
m_HatchFillTypeGap = aZone.m_HatchFillTypeGap;
m_HatchFillTypeOrientation = aZone.m_HatchFillTypeOrientation;
m_HatchFillTypeSmoothingLevel = aZone.m_HatchFillTypeSmoothingLevel;
m_HatchFillTypeSmoothingValue = aZone.m_HatchFillTypeSmoothingValue;
// For corner moving, corner index to drag, or nullptr if no selection
m_CornerSelection = nullptr;
m_IsFilled = aZone.m_IsFilled;
m_ZoneClearance = aZone.m_ZoneClearance; // clearance value
m_ZoneMinThickness = aZone.m_ZoneMinThickness;
m_FilledPolysUseThickness = aZone.m_FilledPolysUseThickness;
m_FillMode = aZone.m_FillMode; // Filling mode (segments/polygons)
m_hv45 = aZone.m_hv45;
m_priority = aZone.m_priority;
m_PadConnection = aZone.m_PadConnection;
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
for( PCB_LAYER_ID layer : aZone.GetLayerSet().Seq() )
{
@ -168,34 +154,17 @@ void ZONE_CONTAINER::initDataFromSrcInCopyCtor( const ZONE_CONTAINER& aZone )
m_insulatedIslands[layer] = aZone.m_insulatedIslands.at( layer );
}
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
m_doNotAllowVias = aZone.m_doNotAllowVias;
m_doNotAllowTracks = aZone.m_doNotAllowTracks;
m_doNotAllowPads = aZone.m_doNotAllowPads;
m_doNotAllowFootprints = aZone.m_doNotAllowFootprints;
m_cornerSmoothingType = aZone.m_cornerSmoothingType;
m_cornerRadius = aZone.m_cornerRadius;
m_hatchStyle = aZone.m_hatchStyle;
m_hatchPitch = aZone.m_hatchPitch;
m_HatchLines = aZone.m_HatchLines;
m_HatchFillTypeThickness = aZone.m_HatchFillTypeThickness;
m_HatchFillTypeGap = aZone.m_HatchFillTypeGap;
m_HatchFillTypeOrientation = aZone.m_HatchFillTypeOrientation;
m_HatchFillTypeSmoothingLevel = aZone.m_HatchFillTypeSmoothingLevel;
m_HatchFillTypeSmoothingValue = aZone.m_HatchFillTypeSmoothingValue;
SetLocalFlags( aZone.GetLocalFlags() );
// Now zone type and layer are set, transfer net info
// (has meaning only for copper zones)
m_netinfo = aZone.m_netinfo;
m_hv45 = aZone.m_hv45;
m_area = aZone.m_area;
SetNeedRefill( aZone.NeedRefill() );
}