From 038db715a3dd5c6a29ebef9858d8614d4f330ee8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 19 Jan 2022 00:22:40 +0000 Subject: [PATCH] Move zone hatch orientation to EDA_ANGLE. --- pcbnew/dialogs/dialog_copper_zones.cpp | 4 ++-- .../dialog_non_copper_zones_properties.cpp | 4 ++-- pcbnew/drc/drc_test_provider_library_parity.cpp | 2 +- pcbnew/plugins/altium/altium_pcb.cpp | 3 ++- .../cadstar/cadstar_pcb_archive_loader.cpp | 9 ++++----- .../plugins/cadstar/cadstar_pcb_archive_loader.h | 2 +- pcbnew/plugins/eagle/eagle_plugin.cpp | 2 +- pcbnew/plugins/kicad/pcb_parser.cpp | 5 ++++- pcbnew/plugins/kicad/pcb_plugin.cpp | 2 +- pcbnew/zone.h | 6 +++--- pcbnew/zone_filler.cpp | 13 ++++++------- pcbnew/zone_settings.cpp | 16 ++++++++-------- pcbnew/zone_settings.h | 3 ++- 13 files changed, 37 insertions(+), 34 deletions(-) diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index dcac44e8e1..f244fb2a67 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -270,7 +270,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow() } m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES ); - m_gridStyleRotation.SetAngleValue( EDA_ANGLE( m_settings.m_HatchOrientation, DEGREES_T ) ); + m_gridStyleRotation.SetAngleValue( m_settings.m_HatchOrientation ); // Gives a reasonable value to grid style parameters, if currently there are no defined // parameters for grid pattern thickness and gap (if the value is 0) @@ -419,7 +419,7 @@ bool DIALOG_COPPER_ZONE::TransferDataFromWindow() if( !AcceptOptions() ) return false; - m_settings.m_HatchOrientation = m_gridStyleRotation.GetAngleValue().AsDegrees(); + m_settings.m_HatchOrientation = m_gridStyleRotation.GetAngleValue(); m_settings.m_HatchThickness = m_gridStyleThickness.GetValue(); m_settings.m_HatchGap = m_gridStyleGap.GetValue(); m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue(); diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index 6bdb3065c6..a7a35dfbea 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -130,7 +130,7 @@ bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow() } m_hatchRotation.SetUnits( EDA_UNITS::DEGREES ); - m_hatchRotation.SetAngleValue( EDA_ANGLE( m_settings.m_HatchOrientation, DEGREES_T ) ); + m_hatchRotation.SetAngleValue( m_settings.m_HatchOrientation ); // Gives a reasonable value to grid style parameters, if currently there are no defined // parameters for grid pattern thickness and gap (if the value is 0) @@ -224,7 +224,7 @@ bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow() } - m_settings.m_HatchOrientation = m_hatchRotation.GetAngleValue().AsDegrees(); + m_settings.m_HatchOrientation = m_hatchRotation.GetAngleValue(); m_settings.m_HatchThickness = m_hatchWidth.GetValue(); m_settings.m_HatchGap = m_hatchGap.GetValue(); m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue(); diff --git a/pcbnew/drc/drc_test_provider_library_parity.cpp b/pcbnew/drc/drc_test_provider_library_parity.cpp index d7879af788..eab9459ca6 100644 --- a/pcbnew/drc/drc_test_provider_library_parity.cpp +++ b/pcbnew/drc/drc_test_provider_library_parity.cpp @@ -285,7 +285,7 @@ bool zonesNeedUpdate( const FP_ZONE* a, const FP_ZONE* b ) TEST( a->GetFillMode(), b->GetFillMode() ); TEST( a->GetHatchThickness(), b->GetHatchThickness() ); TEST( a->GetHatchGap(), b->GetHatchGap() ); - TEST_D( a->GetHatchOrientation(), b->GetHatchOrientation() ); + TEST_D( a->GetHatchOrientation().AsDegrees(), b->GetHatchOrientation().AsDegrees() ); TEST( a->GetHatchSmoothingLevel(), b->GetHatchSmoothingLevel() ); TEST( a->GetHatchSmoothingValue(), b->GetHatchSmoothingValue() ); TEST( a->GetHatchBorderAlgorithm(), b->GetHatchBorderAlgorithm() ); diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index c2bb842ada..8d7f42c805 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -1753,7 +1753,8 @@ void ALTIUM_PCB::ParsePolygons6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbF zone->SetHatchGap( elem.gridsize - elem.trackwidth ); } - zone->SetHatchOrientation( elem.hatchstyle == ALTIUM_POLYGON_HATCHSTYLE::DEGREE_45 ? 45 : 0 ); + if( elem.hatchstyle == ALTIUM_POLYGON_HATCHSTYLE::DEGREE_45 ) + zone->SetHatchOrientation( ANGLE_45 ); } zone->SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE, diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index 6dac8256c5..549146b8da 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -1900,7 +1900,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadTemplates() zone->SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN ); zone->SetHatchGap( getKiCadHatchCodeGap( csTemplate.Pouring.HatchCodeID ) ); zone->SetHatchThickness( getKiCadHatchCodeThickness( csTemplate.Pouring.HatchCodeID ) ); - zone->SetHatchOrientation( getHatchCodeAngleDegrees( csTemplate.Pouring.HatchCodeID ) ); + zone->SetHatchOrientation( getHatchCodeAngle( csTemplate.Pouring.HatchCodeID ) ); } else { @@ -2134,7 +2134,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers() zone->SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN ); zone->SetHatchGap( getKiCadHatchCodeGap( csCopper.Shape.HatchCodeID ) ); zone->SetHatchThickness( getKiCadHatchCodeThickness( csCopper.Shape.HatchCodeID ) ); - zone->SetHatchOrientation( getHatchCodeAngleDegrees( csCopper.Shape.HatchCodeID ) ); + zone->SetHatchOrientation( getHatchCodeAngle( csCopper.Shape.HatchCodeID ) ); } else { @@ -3470,8 +3470,7 @@ CADSTAR_PCB_ARCHIVE_LOADER::HATCHCODE CADSTAR_PCB_ARCHIVE_LOADER::getHatchCode( } -double CADSTAR_PCB_ARCHIVE_LOADER::getHatchCodeAngleDegrees( - const HATCHCODE_ID& aCadstarHatchcodeID ) +EDA_ANGLE CADSTAR_PCB_ARCHIVE_LOADER::getHatchCodeAngle( const HATCHCODE_ID& aCadstarHatchcodeID ) { checkAndLogHatchCode( aCadstarHatchcodeID ); HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID ); @@ -3479,7 +3478,7 @@ double CADSTAR_PCB_ARCHIVE_LOADER::getHatchCodeAngleDegrees( if( hcode.Hatches.size() < 1 ) return m_board->GetDesignSettings().GetDefaultZoneSettings().m_HatchOrientation; else - return getAngle( hcode.Hatches.at( 0 ).OrientAngle ).AsDegrees(); + return getAngle( hcode.Hatches.at( 0 ).OrientAngle ); } diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h index ed4ff5f529..26d970d0d2 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h @@ -414,7 +414,7 @@ private: LAYER_TYPE getLayerType( const LAYER_ID aCadstarLayerID ); // Helper Functions for obtaining individual elements as KiCad elements: - double getHatchCodeAngleDegrees( const HATCHCODE_ID& aCadstarHatchcodeID ); + EDA_ANGLE getHatchCodeAngle( const HATCHCODE_ID& aCadstarHatchcodeID ); PAD* getKiCadPad( const COMPONENT_PAD& aCadstarPad, FOOTPRINT* aParent ); PAD*& getPadReference( FOOTPRINT* aFootprint, const PAD_ID aCadstarPadID ); FOOTPRINT* getFootprintFromCadstarID( const COMPONENT_ID& aCadstarComponentID ); diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index e2b6be2d05..517dbc929e 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -1494,7 +1494,7 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode ) zone->SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN ); zone->SetHatchThickness( p.width.ToPcbUnits() ); zone->SetHatchGap( spacing - p.width.ToPcbUnits() ); - zone->SetHatchOrientation( 0 ); + zone->SetHatchOrientation( ANGLE_0 ); } // We divide the thickness by half because we are tracing _inside_ the zone outline diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 073159cf69..2622157b62 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -5256,9 +5256,12 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) break; case T_hatch_orientation: - zone->SetHatchOrientation( parseDouble( T_hatch_orientation ) ); + { + EDA_ANGLE orientation( parseDouble( T_hatch_orientation ), DEGREES_T ); + zone->SetHatchOrientation( orientation ); NeedRIGHT(); break; + } case T_hatch_smoothing_level: zone->SetHatchSmoothingLevel( parseDouble( T_hatch_smoothing_level ) ); diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index ec355dda2c..79ec1d6487 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -2077,7 +2077,7 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)", FormatInternalUnits( aZone->GetHatchThickness() ).c_str(), FormatInternalUnits( aZone->GetHatchGap() ).c_str(), - Double2Str( aZone->GetHatchOrientation() ).c_str() ); + Double2Str( aZone->GetHatchOrientation().AsDegrees() ).c_str() ); if( aZone->GetHatchSmoothingLevel() > 0 ) { diff --git a/pcbnew/zone.h b/pcbnew/zone.h index c48ddb0325..3d05bd41d4 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -282,8 +282,8 @@ public: int GetHatchGap() const { return m_hatchGap; } void SetHatchGap( int aStep ) { m_hatchGap = aStep; } - double GetHatchOrientation() const { return m_hatchOrientation; } - void SetHatchOrientation( double aStep ) { m_hatchOrientation = aStep; } + EDA_ANGLE GetHatchOrientation() const { return m_hatchOrientation; } + void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; } int GetHatchSmoothingLevel() const { return m_hatchSmoothingLevel; } void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; } @@ -931,7 +931,7 @@ protected: ZONE_FILL_MODE m_fillMode; int m_hatchThickness; // thickness of lines (if 0 -> solid shape) int m_hatchGap; // gap between lines (0 -> solid shape - double m_hatchOrientation; // orientation in degrees of grid lines + EDA_ANGLE m_hatchOrientation; // orientation of grid lines int m_hatchSmoothingLevel; // 0 = no smoothing // 1 = fillet // 2 = arc low def diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 73daafd8f8..b6ccfd23d7 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -1431,13 +1431,12 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer int linethickness = thickness - aZone->GetMinThickness(); int gridsize = thickness + aZone->GetHatchGap(); - double orientation = aZone->GetHatchOrientation(); SHAPE_POLY_SET filledPolys = aRawPolys; - // Use a area that contains the rotated bbox by orientation, - // and after rotate the result by -orientation. - if( orientation != 0.0 ) - filledPolys.Rotate( M_PI / 180.0 * orientation, VECTOR2I( 0, 0 ) ); + // Use a area that contains the rotated bbox by orientation, and after rotate the result + // by -orientation. + if( !aZone->GetHatchOrientation().IsZero() ) + filledPolys.Rotate( aZone->GetHatchOrientation().AsRadians(), VECTOR2I( 0, 0 ) ); BOX2I bbox = filledPolys.BBox( 0 ); @@ -1542,8 +1541,8 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer holes.Move( bbox.GetPosition() ); - if( orientation != 0.0 ) - holes.Rotate( -M_PI/180.0 * orientation, VECTOR2I( 0,0 ) ); + if( !aZone->GetHatchOrientation().IsZero() ) + holes.Rotate( -aZone->GetHatchOrientation().AsRadians(), VECTOR2I( 0, 0 ) ); DUMP_POLYS_TO_COPPER_LAYER( holes, In10_Cu, "hatch-holes" ); diff --git a/pcbnew/zone_settings.cpp b/pcbnew/zone_settings.cpp index 13d2a1abee..12b9f182bb 100644 --- a/pcbnew/zone_settings.cpp +++ b/pcbnew/zone_settings.cpp @@ -48,14 +48,14 @@ ZONE_SETTINGS::ZONE_SETTINGS() m_ZoneClearance = Mils2iu( ZONE_CLEARANCE_MIL ); // Min thickness value in filled areas (this is the minimum width of copper to fill solid areas) : m_ZoneMinThickness = Mils2iu( ZONE_THICKNESS_MIL ); - m_HatchThickness = 0; // good value of grid line thickness if m_FillMode = ZFM_GRID_PATTERN - m_HatchGap = 0; // good value of grid line gap if m_FillMode = ZFM_GRID_PATTERN - m_HatchOrientation = 0.0; // Grid style: orientation of grid lines in degrees - m_HatchSmoothingLevel = 0; // Grid pattern smoothing type. 0 = no smoothing - m_HatchSmoothingValue = 0.1; // Grid pattern chamfer value relative to the gap value - m_HatchHoleMinArea = 0.3; // Min size before holes are dropped (ratio of hole size) - m_HatchBorderAlgorithm = 1; // 0 = use zone min thickness; 1 = use hatch width - m_NetcodeSelection = 0; // Net code selection for the current zone + m_HatchThickness = 0; // good value of grid line thickness for ZFM_GRID_PATTERN + m_HatchGap = 0; // good value of grid line gap for ZFM_GRID_PATTERN + m_HatchOrientation = ANGLE_0; // Grid style: orientation of grid lines + m_HatchSmoothingLevel = 0; // Grid pattern smoothing type. 0 = no smoothing + m_HatchSmoothingValue = 0.1; // Grid pattern chamfer value relative to the gap value + m_HatchHoleMinArea = 0.3; // Min size before holes are dropped (ratio of hole size) + m_HatchBorderAlgorithm = 1; // 0 = use zone min thickness; 1 = use hatch width + m_NetcodeSelection = 0; // Net code selection for the current zone m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; // Option to show the zone // outlines only, short // hatches or full hatches diff --git a/pcbnew/zone_settings.h b/pcbnew/zone_settings.h index c33151eeda..90f07780cb 100644 --- a/pcbnew/zone_settings.h +++ b/pcbnew/zone_settings.h @@ -32,6 +32,7 @@ #include #include +#include class wxDataViewListCtrl; @@ -83,7 +84,7 @@ public: int m_ZoneMinThickness; // Min thickness value in filled areas int m_HatchThickness; // HatchBorder thickness of lines (if 0 -> solid shape) int m_HatchGap; // HatchBorder clearance between lines (0 -> solid shape) - double m_HatchOrientation; // HatchBorder orientation of grid lines in degrees + EDA_ANGLE m_HatchOrientation; // HatchBorder orientation of grid lines int m_HatchSmoothingLevel; // HatchBorder smoothing type, similar to corner smoothing type // 0 = no smoothing, 1 = fillet, >= 2 = arc double m_HatchSmoothingValue; // HatchBorder chamfer/fillet size as a ratio of hole size