From c311e63f0d9ad014080afc5b4bbfdeb35b0e07de Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 1 Jul 2017 15:16:51 +0200 Subject: [PATCH] fix minor issues, and change ZONE_CONTAINER::GetDefaultHatchPitchMils() to ZONE_CONTAINER::GetDefaultHatchPitch() as using mil in a value has no meaning now in pcbnew --- pcbnew/class_zone.cpp | 13 +++- pcbnew/class_zone.h | 10 ++- pcbnew/class_zone_settings.cpp | 2 +- pcbnew/eagle_plugin.cpp | 70 ++++++++++++--------- pcbnew/legacy_plugin.cpp | 2 +- pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp | 2 +- pcbnew/pcb_parser.cpp | 20 +++--- 7 files changed, 70 insertions(+), 49 deletions(-) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index babed06f0a..ec780f5255 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 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 @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -946,7 +947,7 @@ bool sortEndsByDescendingX( const VECTOR2I& ref, const VECTOR2I& tst ) return tst.x < ref.x; } -// Implementation copied from old CPolyLine + void ZONE_CONTAINER::Hatch() { UnHatch(); @@ -1109,6 +1110,12 @@ void ZONE_CONTAINER::Hatch() } +int ZONE_CONTAINER::GetDefaultHatchPitch() +{ + return Mils2iu( 20 ); +} + + BITMAP_DEF ZONE_CONTAINER::GetMenuImage() const { return add_zone_xpm; diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index b388db293b..0352cc7c81 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2017 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 @@ -673,11 +673,9 @@ public: /** * Function GetDefaultHatchPitchMils - * @return int - the default hatch pitch in mils. - * - * \todo This value is hardcoded, but it should be user configurable. + * @return int - the default hatch pitch in internal units. */ - static int GetDefaultHatchPitchMils() { return 20; } + static int GetDefaultHatchPitch(); /** * Function SetHatch diff --git a/pcbnew/class_zone_settings.cpp b/pcbnew/class_zone_settings.cpp index 7aa2fc7084..1438482687 100644 --- a/pcbnew/class_zone_settings.cpp +++ b/pcbnew/class_zone_settings.cpp @@ -119,7 +119,7 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c // call SetHatch last, because hatch lines will be rebuilt, // using new parameters values - aTarget.SetHatch( m_Zone_HatchingStyle, Mils2iu( aTarget.GetDefaultHatchPitchMils() ), true ); + aTarget.SetHatch( m_Zone_HatchingStyle, aTarget.GetDefaultHatchPitch(), true ); } diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 35c893141c..eac2185a22 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012-2017 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 @@ -628,7 +628,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y2 ) ), outlineIdx ); // this is not my fault: - zone->SetHatch( outline_hatch, Mils2iu( zone->GetDefaultHatchPitchMils() ), true ); + zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true ); } m_xpath->pop(); @@ -1837,8 +1837,10 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals ) } // if spacing is set the zone should be hatched + // However, use the default hatch step, p.spacing value has no meaning for Kicad + // TODO: see if this parameter is related to a grid fill option. if( p.spacing ) - zone->SetHatch( ZONE_CONTAINER::DIAGONAL_EDGE, *p.spacing, true ); + zone->SetHatch( ZONE_CONTAINER::DIAGONAL_EDGE, zone->GetDefaultHatchPitch(), true ); // clearances, etc. zone->SetArcSegmentCount( 32 ); // @todo: should be a constructor default? @@ -1850,7 +1852,8 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals ) if( p.isolate ) { zone->SetZoneClearance( kicad( *p.isolate ) ); - } else { + } else + { zone->SetZoneClearance( 0 ); } @@ -1912,41 +1915,50 @@ PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const // translate non-copper eagle layer to pcbnew layer switch( aEagleLayer ) { - // Eagle says "Dimension" layer, but it's for board perimeter - case EAGLE_LAYER::DIMENSION: kiLayer = Edge_Cuts; break; - case EAGLE_LAYER::TPLACE: kiLayer = F_SilkS; break; - case EAGLE_LAYER::BPLACE: kiLayer = B_SilkS; break; - case EAGLE_LAYER::TNAMES: kiLayer = F_SilkS; break; - case EAGLE_LAYER::BNAMES: kiLayer = B_SilkS; break; - case EAGLE_LAYER::TVALUES: kiLayer = F_SilkS; break; - case EAGLE_LAYER::BVALUES: kiLayer = B_SilkS; break; - case EAGLE_LAYER::TSTOP: kiLayer = F_Mask; break; - case EAGLE_LAYER::BSTOP: kiLayer = B_Mask; break; - case EAGLE_LAYER::TCREAM: kiLayer = F_Paste; break; - case EAGLE_LAYER::BCREAM: kiLayer = B_Paste; break; - case EAGLE_LAYER::TFINISH: kiLayer = F_Mask; break; - case EAGLE_LAYER::BFINISH: kiLayer = B_Mask; break; - case EAGLE_LAYER::TGLUE: kiLayer = F_Adhes; break; - case EAGLE_LAYER::BGLUE: kiLayer = B_Adhes; break; - case EAGLE_LAYER::DOCUMENT: kiLayer = Cmts_User; break; - case EAGLE_LAYER::REFERENCELC: kiLayer = Cmts_User; break; - case EAGLE_LAYER::REFERENCELS: kiLayer = Cmts_User; break; + // Eagle says "Dimension" layer, but it's for board perimeter + case EAGLE_LAYER::DIMENSION: kiLayer = Edge_Cuts; break; + case EAGLE_LAYER::TPLACE: kiLayer = F_SilkS; break; + case EAGLE_LAYER::BPLACE: kiLayer = B_SilkS; break; + case EAGLE_LAYER::TNAMES: kiLayer = F_SilkS; break; + case EAGLE_LAYER::BNAMES: kiLayer = B_SilkS; break; + case EAGLE_LAYER::TVALUES: kiLayer = F_SilkS; break; + case EAGLE_LAYER::BVALUES: kiLayer = B_SilkS; break; + case EAGLE_LAYER::TSTOP: kiLayer = F_Mask; break; + case EAGLE_LAYER::BSTOP: kiLayer = B_Mask; break; + case EAGLE_LAYER::TCREAM: kiLayer = F_Paste; break; + case EAGLE_LAYER::BCREAM: kiLayer = B_Paste; break; + case EAGLE_LAYER::TFINISH: kiLayer = F_Mask; break; + case EAGLE_LAYER::BFINISH: kiLayer = B_Mask; break; + case EAGLE_LAYER::TGLUE: kiLayer = F_Adhes; break; + case EAGLE_LAYER::BGLUE: kiLayer = B_Adhes; break; + case EAGLE_LAYER::DOCUMENT: kiLayer = Cmts_User; break; + case EAGLE_LAYER::REFERENCELC: kiLayer = Cmts_User; break; + case EAGLE_LAYER::REFERENCELS: kiLayer = Cmts_User; break; // Packages show the future chip pins on SMD parts using layer 51. // This is an area slightly smaller than the PAD/SMD copper area. // Carry those visual aids into the MODULE on the fabrication layer, // not silkscreen. This is perhaps not perfect, but there is not a lot // of other suitable paired layers - case EAGLE_LAYER::TDOCU: kiLayer = F_Fab; break; - case EAGLE_LAYER::BDOCU: kiLayer = B_Fab; break; + case EAGLE_LAYER::TDOCU: kiLayer = F_Fab; break; + case EAGLE_LAYER::BDOCU: kiLayer = B_Fab; break; // thes layers are defined as user layers. put them on ECO layers - case EAGLE_LAYER::USERLAYER1: kiLayer = Eco1_User; break; - case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break; + case EAGLE_LAYER::USERLAYER1: kiLayer = Eco1_User; break; + case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break; + + case EAGLE_LAYER::UNROUTED: + case EAGLE_LAYER::TKEEPOUT: + case EAGLE_LAYER::BKEEPOUT: + case EAGLE_LAYER::TTEST: + case EAGLE_LAYER::BTEST: + case EAGLE_LAYER::MILLING: + case EAGLE_LAYER::HOLES: default: // some layers do not map to KiCad - wxASSERT_MSG( false, wxString::Format( "Unsupported Eagle layer %d", aEagleLayer ) ); - kiLayer = UNDEFINED_LAYER; break; + wxLogMessage( wxString::Format( "Unsupported Eagle layer %d. Use drawings layer", + aEagleLayer ) ); + kiLayer = Dwgs_User; break; } } diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index a34dc71d4f..044adb9307 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -2730,7 +2730,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() // Hatch here, after outlines corners are read // Set hatch here, after outlines corners are read - zc->SetHatch( outline_hatch, Mils2iu( ZONE_CONTAINER::GetDefaultHatchPitchMils() ), + zc->SetHatch( outline_hatch, ZONE_CONTAINER::GetDefaultHatchPitch(), true ); m_board->Add( zc.release() ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp index a644edd9c9..9a5f2530bb 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp @@ -189,7 +189,7 @@ void PCB_POLYGON::AddToBoard() zone->SetPriority( m_priority ); - zone->SetHatch( outline_hatch, Mils2iu( zone->GetDefaultHatchPitchMils() ), true ); + zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true ); if ( m_objType == wxT( 'K' ) ) { diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 1f318ac8cc..bbdf4364ba 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -1350,22 +1350,24 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() NeedLEFT(); token = NextTok(); - if( token != T_start ) + // the start keyword actually gives the arc center + // Allows also T_center for future change + if( token != T_start && token != T_center ) Expecting( T_start ); pt.x = parseBoardUnits( "X coordinate" ); pt.y = parseBoardUnits( "Y coordinate" ); - segment->SetStart( pt ); + segment->SetCenter( pt ); NeedRIGHT(); NeedLEFT(); token = NextTok(); - if( token != T_end ) + if( token != T_end ) // the end keyword actually gives the starting point of the arc Expecting( T_end ); pt.x = parseBoardUnits( "X coordinate" ); pt.y = parseBoardUnits( "Y coordinate" ); - segment->SetEnd( pt ); + segment->SetArcStart( pt ); NeedRIGHT(); break; @@ -1379,7 +1381,7 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() pt.x = parseBoardUnits( "X coordinate" ); pt.y = parseBoardUnits( "Y coordinate" ); - segment->SetStart( pt ); + segment->SetCenter( pt ); NeedRIGHT(); NeedLEFT(); @@ -2085,7 +2087,9 @@ EDGE_MODULE* PCB_PARSER::parseEDGE_MODULE() NeedLEFT(); token = NextTok(); - if( token != T_start ) + // the start keyword actually gives the arc center + // Allows also T_center for future change + if( token != T_start && token != T_center ) Expecting( T_start ); pt.x = parseBoardUnits( "X coordinate" ); @@ -2095,7 +2099,7 @@ EDGE_MODULE* PCB_PARSER::parseEDGE_MODULE() NeedLEFT(); token = NextTok(); - if( token != T_end ) + if( token != T_end ) // end keyword actually gives the starting point of the arc Expecting( T_end ); pt.x = parseBoardUnits( "X coordinate" ); @@ -2645,7 +2649,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() ZONE_CONTAINER::HATCH_STYLE hatchStyle = ZONE_CONTAINER::NO_HATCH; - int hatchPitch = Mils2iu( ZONE_CONTAINER::GetDefaultHatchPitchMils() ); + int hatchPitch = ZONE_CONTAINER::GetDefaultHatchPitch(); wxPoint pt; T token; int tmp;