Move zone hatch orientation to EDA_ANGLE.

This commit is contained in:
Jeff Young 2022-01-19 00:22:40 +00:00
parent 2a60017ffa
commit 038db715a3
13 changed files with 37 additions and 34 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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() );

View File

@ -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,

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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

View File

@ -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 ) );

View File

@ -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 )
{

View File

@ -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

View File

@ -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" );

View File

@ -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

View File

@ -32,6 +32,7 @@
#include <layer_ids.h>
#include <zones.h>
#include <geometry/eda_angle.h>
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