From 608de9970bf33f75baf724725066fbf3d4125731 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 26 Jan 2014 15:20:58 +0100 Subject: [PATCH] Pcbnew: fix bug #1272714 . Code cleanup: use 2 different enums for pad shapes and pad drill shapes. Remove never used pad shape. --- common/dialog_about/AboutDialog_main.cpp | 14 +++--- include/pad_shapes.h | 14 ++++-- ...board_items_to_polygon_shape_transform.cpp | 6 +-- pcbnew/class_pad.cpp | 43 ++++++++++++++----- pcbnew/class_pad.h | 16 ++++--- pcbnew/class_pad_draw_functions.cpp | 6 +-- pcbnew/dialogs/dialog_gendrill.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 6 +-- pcbnew/drc.cpp | 8 ++-- pcbnew/drc_clearance_test_functions.cpp | 3 +- pcbnew/exporters/export_idf.cpp | 7 +-- pcbnew/exporters/export_vrml.cpp | 2 +- pcbnew/exporters/gendrill_Excellon_writer.cpp | 2 +- pcbnew/kicad_plugin.cpp | 2 +- pcbnew/legacy_plugin.cpp | 6 +-- pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp | 4 +- pcbnew/pcb_painter.cpp | 8 +--- pcbnew/pcb_parser.cpp | 2 +- pcbnew/pcbplot.h | 2 +- pcbnew/plot_brditems_plotter.cpp | 8 ++-- ...nvert_brd_items_to_polygons_with_Boost.cpp | 3 +- 21 files changed, 97 insertions(+), 67 deletions(-) diff --git a/common/dialog_about/AboutDialog_main.cpp b/common/dialog_about/AboutDialog_main.cpp index b3957846c5..d66561fe5d 100644 --- a/common/dialog_about/AboutDialog_main.cpp +++ b/common/dialog_about/AboutDialog_main.cpp @@ -203,7 +203,7 @@ static void InitKiCadAboutNew( AboutAppInfo& info ) * which should be represented by the same icon. */ - // The developers + // The core developers info.AddDeveloper( new Contributor( wxT( "Jean-Pierre Charras" ), wxT( "jp.charras@wanadoo.fr" ) ) ); info.AddDeveloper( @@ -214,6 +214,8 @@ static void InitKiCadAboutNew( AboutAppInfo& info ) // alphabetically by last name after main 3 above: info.AddDeveloper( new Contributor( wxT( "Frank Bennett" ), wxT( "bennett78@lpbroadband.net" ) ) ); + info.AddDeveloper( + new Contributor( wxT( "Cirilo Bernardo" ), wxT( "cirilo_bernardo@yahoo.com" ) ) ); info.AddDeveloper( new Contributor( wxT( "Jonas Diemer" ), wxT( "diemer@gmx.de" ) ) ); info.AddDeveloper( @@ -222,12 +224,6 @@ static void InitKiCadAboutNew( AboutAppInfo& info ) new Contributor( wxT( "Hauptmech" ), wxT( "hauptmech@gmail.com" ) ) ); info.AddDeveloper( new Contributor( wxT( "Jerry Jacobs" ), wxT( "xor.gate.engineering@gmail.com" ) ) ); - - /* - info.AddDeveloper( - new Contributor( wxT( "KBool Library" ), wxT( "http://boolean.klaasholwerda.nl/bool.html" ) ) ); - */ - info.AddDeveloper( new Contributor( wxT( "Lorenzo Marcantonio" ), wxT( "lomarcan@tin.it" ) ) ); info.AddDeveloper( @@ -240,10 +236,14 @@ static void InitKiCadAboutNew( AboutAppInfo& info ) new Contributor( wxT( "Marco Serantoni" ), wxT( "marco.serantoni@gmail.com" ) ) ); info.AddDeveloper( new Contributor( wxT( "Brian Sidebotham" ), wxT( "brian.sidebotham@gmail.com" ) ) ); + info.AddDeveloper( + new Contributor( wxT( "Orson (Maciej Suminski)" ), wxT( "maciej.suminski@cern.ch" ) ) ); info.AddDeveloper( new Contributor( wxT( "Rafael Sokolowski" ), wxT( "rafael.sokolowski@web.de" ) ) ); info.AddDeveloper( new Contributor( wxT( "Vesa Solonen" ), wxT( "vesa.solonen@hut.fi" ) ) ); + info.AddDeveloper( + new Contributor( wxT( "Tomasz Wlostowski" ), wxT( "tomasz.wlostowski@cern.ch" ) ) ); // The document writers info.AddDocWriter( diff --git a/include/pad_shapes.h b/include/pad_shapes.h index e372795903..23a491e591 100644 --- a/include/pad_shapes.h +++ b/include/pad_shapes.h @@ -11,13 +11,21 @@ */ enum PAD_SHAPE_T { - PAD_NONE, PAD_CIRCLE, PAD_ROUND = PAD_CIRCLE, PAD_RECT, PAD_OVAL, - PAD_TRAPEZOID, - PAD_OCTAGON // Provided, but not existing in Pcbnew. waiting for a volunteer + PAD_TRAPEZOID +}; + +/** + * Enum PAD_DRILL_SHAPE_T + * is the set of pad dtill shapes, used with D_PAD::{Set,Get}DrillShape() + */ +enum PAD_DRILL_SHAPE_T +{ + PAD_DRILL_CIRCLE, + PAD_DRILL_OBLONG }; diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 66c5c7afa6..68059370d1 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -424,7 +424,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer * trapezoidal pads are considered as rect * pad shape having they boudary box size */ - switch( m_PadShape ) + switch( GetShape() ) { case PAD_CIRCLE: dx = KiROUND( dx * aCorrectionFactor ); @@ -459,7 +459,6 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer } break; - default: case PAD_TRAPEZOID: psize.x += std::abs( m_DeltaSize.y ); psize.y += std::abs( m_DeltaSize.x ); @@ -550,7 +549,7 @@ void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer, wxPoint corners[4]; wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset, * the pad position is NOT the shape position */ - switch( m_PadShape ) + switch( GetShape() ) { case PAD_CIRCLE: case PAD_OVAL: @@ -558,7 +557,6 @@ void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer, aSegmentsPerCircle, aCorrectionFactor ); break; - default: case PAD_TRAPEZOID: case PAD_RECT: BuildPadPolygon( corners, aInflateValue, m_Orient ); diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index f984e4aa9b..5a48ac461a 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -66,9 +66,9 @@ D_PAD::D_PAD( MODULE* parent ) : m_Pos = GetParent()->GetPosition(); } - m_PadShape = PAD_CIRCLE; // Default pad shape is PAD_CIRCLE. - m_Attribute = PAD_STANDARD; // Default pad type is NORMAL (thru hole) - m_DrillShape = PAD_CIRCLE; // Default pad drill shape is a circle. + SetShape( PAD_CIRCLE ); // Default pad shape is PAD_CIRCLE. + SetDrillShape( PAD_DRILL_CIRCLE ); // Default pad drill shape is a circle. + m_Attribute = PAD_STANDARD; // Default pad type is NORMAL (thru hole) m_LocalClearance = 0; m_LocalSolderMaskMargin = 0; m_LocalSolderPasteMargin = 0; @@ -382,13 +382,13 @@ void D_PAD::Copy( D_PAD* source ) m_NumPadName = source->m_NumPadName; SetNet( source->GetNet() ); m_Drill = source->m_Drill; - m_DrillShape = source->m_DrillShape; + m_drillShape = source->m_drillShape; m_Offset = source->m_Offset; m_Size = source->m_Size; m_DeltaSize = source->m_DeltaSize; m_Pos0 = source->m_Pos0; m_boundingRadius = source->m_boundingRadius; - m_PadShape = source->m_PadShape; + m_padShape = source->m_padShape; m_Attribute = source->m_Attribute; m_Orient = source->m_Orient; m_LengthPadToDie = source->m_LengthPadToDie; @@ -601,7 +601,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) Line = ::CoordinateToString( (unsigned) m_Drill.x ); - if( m_DrillShape == PAD_CIRCLE ) + if( GetDrillShape() == PAD_DRILL_CIRCLE ) { aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), Line, RED ) ); } @@ -663,7 +663,7 @@ bool D_PAD::HitTest( const wxPoint& aPosition ) dx = m_Size.x >> 1; // dx also is the radius for rounded pads dy = m_Size.y >> 1; - switch( m_PadShape & 0x7F ) + switch( GetShape() ) { case PAD_CIRCLE: if( KiROUND( EuclideanNorm( delta ) ) <= dx ) @@ -679,7 +679,28 @@ bool D_PAD::HitTest( const wxPoint& aPosition ) return TestPointInsidePolygon( poly, 4, delta ); } - default: + case PAD_OVAL: + { + RotatePoint( &delta, -m_Orient ); + // An oval pad has the same shape as a segment with rounded ends + // After rotation, the test point is relative to an horizontal pad + int dist; + wxPoint offset; + if( dy > dx ) // shape is a vertical oval + { + offset.y = dy - dx; + dist = dx; + } + else //if( dy <= dx ) shape is an horizontal oval + { + offset.x = dy - dx; + dist = dy; + } + return TestSegmentHit( delta, - offset, offset, dist ); + } + break; + + case PAD_RECT: RotatePoint( &delta, -m_Orient ); if( (abs( delta.x ) <= dx ) && (abs( delta.y ) <= dy) ) @@ -696,10 +717,10 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) { int diff; - if( ( diff = padref->m_PadShape - padcmp->m_PadShape ) != 0 ) + if( ( diff = padref->GetShape() - padcmp->GetShape() ) != 0 ) return diff; - if( ( diff = padref->m_DrillShape - padcmp->m_DrillShape ) != 0) + if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0) return diff; if( ( diff = padref->m_Drill.x - padcmp->m_Drill.x ) != 0 ) @@ -737,7 +758,7 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) wxString D_PAD::ShowPadShape() const { - switch( m_PadShape ) + switch( GetShape() ) { case PAD_CIRCLE: return _( "Circle" ); diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 5a385ea917..0391d92b4b 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -140,8 +140,8 @@ public: * Function GetShape * @return the shape of this pad. */ - PAD_SHAPE_T GetShape() const { return m_PadShape; } - void SetShape( PAD_SHAPE_T aShape ) { m_PadShape = aShape; m_boundingRadius = -1; } + PAD_SHAPE_T GetShape() const { return m_padShape; } + void SetShape( PAD_SHAPE_T aShape ) { m_padShape = aShape; m_boundingRadius = -1; } void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; } // was overload const wxPoint& GetPosition() const { return m_Pos; } // was overload @@ -183,8 +183,9 @@ public: */ double GetOrientation() const { return m_Orient; } - void SetDrillShape( PAD_SHAPE_T aDrillShape ) { m_DrillShape = aDrillShape; } - PAD_SHAPE_T GetDrillShape() const { return m_DrillShape; } + void SetDrillShape( PAD_DRILL_SHAPE_T aDrillShape ) + { m_drillShape = aDrillShape; } + PAD_DRILL_SHAPE_T GetDrillShape() const { return m_drillShape; } void SetLayerMask( LAYER_MSK aLayerMask ) { m_layerMask = aLayerMask; } LAYER_MSK GetLayerMask() const { return m_layerMask; } @@ -362,7 +363,7 @@ public: { // Any member function which would affect this calculation should set // m_boundingRadius to -1 to re-trigger the calculation from here. - // Currently that is only m_Size, m_DeltaSize, and m_PadShape accessors. + // Currently that is only m_Size, m_DeltaSize, and m_padShape accessors. if( m_boundingRadius == -1 ) { m_boundingRadius = boundingRadius(); @@ -484,7 +485,7 @@ private: wxPoint m_Pos; ///< pad Position on board - PAD_SHAPE_T m_PadShape; ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID + PAD_SHAPE_T m_padShape; ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID int m_SubRatsnest; ///< variable used in rats nest computations @@ -496,7 +497,8 @@ private: wxSize m_Size; ///< X and Y size ( relative to orient 0) - PAD_SHAPE_T m_DrillShape; ///< Shape PAD_CIRCLE, PAD_OVAL + PAD_DRILL_SHAPE_T m_drillShape; ///< PAD_DRILL_NONE, PAD_DRILL_CIRCLE, PAD_DRILL_OBLONG + /** * m_Offset is useful only for oblong pads (it can be used for other diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index c590d55e99..56f60c2eee 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -430,15 +430,15 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( aDrawInfo. m_ShowNotPlatedHole ) // Draw a specific hole color hole_color = aDrawInfo.m_NPHoleColor; - switch( m_DrillShape ) + switch( GetDrillShape() ) { - case PAD_CIRCLE: + case PAD_DRILL_CIRCLE: if( aDC->LogicalToDeviceXRel( hole ) > MIN_DRAW_WIDTH ) GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0, hole_color, hole_color ); break; - case PAD_OVAL: + case PAD_DRILL_OBLONG: halfsize.x = m_Drill.x >> 1; halfsize.y = m_Drill.y >> 1; diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index c8a4b81c2c..c46e1f8e37 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -157,7 +157,7 @@ void DIALOG_GENDRILL::InitDisplayParams() { for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() ) { - if( pad->GetDrillShape() == PAD_CIRCLE ) + if( pad->GetDrillShape() == PAD_DRILL_CIRCLE ) { if( pad->GetDrillSize().x != 0 ) { diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 7dc306a063..0ab2b700ca 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -473,7 +473,7 @@ void DIALOG_PAD_PROPERTIES::initValues() m_PadNetNameCtrl->Enable( enable ); m_LengthPadToDieCtrl->Enable( enable ); - if( m_dummyPad->GetDrillShape() != PAD_OVAL ) + if( m_dummyPad->GetDrillShape() != PAD_DRILL_OBLONG ) m_DrillShapeCtrl->SetSelection( 0 ); else m_DrillShapeCtrl->SetSelection( 1 ); @@ -915,11 +915,11 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) if( m_DrillShapeCtrl->GetSelection() == 0 ) { - aPad->SetDrillShape( PAD_CIRCLE ); + aPad->SetDrillShape( PAD_DRILL_CIRCLE ); y = x; } else - aPad->SetDrillShape( PAD_OVAL ); + aPad->SetDrillShape( PAD_DRILL_OBLONG ); aPad->SetDrillSize( wxSize( x, y ) ); diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 42e432e3c4..bad9f65fd7 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -705,7 +705,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li && pad->GetDrillSize() == aRefPad->GetDrillSize() && pad->GetDrillShape() == aRefPad->GetDrillShape() ) { - if( aRefPad->GetDrillShape() == PAD_CIRCLE ) + if( aRefPad->GetDrillShape() == PAD_DRILL_CIRCLE ) continue; // for oval holes: must also have the same orientation @@ -721,7 +721,8 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li // pad under testing has a hole, test this hole against pad reference dummypad.SetPosition( pad->GetPosition() ); dummypad.SetSize( pad->GetDrillSize() ); - dummypad.SetShape( pad->GetDrillShape() == PAD_OVAL ? PAD_OVAL : PAD_CIRCLE ); + dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_OBLONG ? + PAD_OVAL : PAD_CIRCLE ); dummypad.SetOrientation( pad->GetOrientation() ); if( !checkClearancePadToPad( aRefPad, &dummypad ) ) @@ -737,7 +738,8 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li { dummypad.SetPosition( aRefPad->GetPosition() ); dummypad.SetSize( aRefPad->GetDrillSize() ); - dummypad.SetShape( aRefPad->GetDrillShape() == PAD_OVAL ? PAD_OVAL : PAD_CIRCLE ); + dummypad.SetShape( aRefPad->GetDrillShape() == PAD_DRILL_OBLONG ? + PAD_OVAL : PAD_CIRCLE ); dummypad.SetOrientation( aRefPad->GetOrientation() ); if( !checkClearancePadToPad( pad, &dummypad ) ) diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index c141b1eaea..1fd8a94ccd 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -291,7 +291,8 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) dummypad.SetSize( pad->GetDrillSize() ); dummypad.SetPosition( pad->GetPosition() ); - dummypad.SetShape( pad->GetDrillShape() ); + dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_OBLONG ? + PAD_OVAL : PAD_CIRCLE ); dummypad.SetOrientation( pad->GetOrientation() ); m_padToTestPos = dummypad.GetPosition() - origin; diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index 65e579b488..c6aadba5e0 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -200,7 +200,7 @@ UseBoundingBox: p1.y = py[i - 1]; p2.x = px[i]; p2.y = py[i]; - + outline.push( new IDF_SEGMENT( p1, p2 ) ); } @@ -271,7 +271,8 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, tstr = TO_UTF8( pad->GetPadName() ); if( tstr.empty() || !tstr.compare( "0" ) || !tstr.compare( "~" ) - || ( kplate == IDF3::NPTH ) || ( pad->GetDrillShape() == PAD_OVAL ) ) + || ( kplate == IDF3::NPTH ) + ||( pad->GetDrillShape() == PAD_DRILL_OBLONG ) ) pintype = "MTG"; else pintype = "PIN"; @@ -284,7 +285,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, // 5. Assoc. part : BOARD | NOREFDES | PANEL | {"refdes"} // 6. type : PIN | VIA | MTG | TOOL | { "other" } // 7. owner : MCAD | ECAD | UNOWNED - if( ( pad->GetDrillShape() == PAD_OVAL ) + if( ( pad->GetDrillShape() == PAD_DRILL_OBLONG ) && ( pad->GetDrillSize().x != pad->GetDrillSize().y ) ) { // NOTE: IDF does not have direct support for slots; diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 460240ceb6..b57c5da27d 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1043,7 +1043,7 @@ static void export_vrml_pad( MODEL_VRML& aModel, BOARD* pcb, D_PAD* aPad ) // Export the hole on the edge layer if( hole_drill > 0 ) { - if( aPad->GetDrillShape() == PAD_OVAL ) + if( aPad->GetDrillShape() == PAD_DRILL_OBLONG ) { // Oblong hole (slot) aModel.holes.AddSlot( hole_x, -hole_y, hole_drill_w * 2.0, hole_drill_h * 2.0, diff --git a/pcbnew/exporters/gendrill_Excellon_writer.cpp b/pcbnew/exporters/gendrill_Excellon_writer.cpp index 1a83dfafba..7ad2293b95 100644 --- a/pcbnew/exporters/gendrill_Excellon_writer.cpp +++ b/pcbnew/exporters/gendrill_Excellon_writer.cpp @@ -523,7 +523,7 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer, new_hole.m_Hole_Diameter = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y ); new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter; - if( pad->GetDrillShape() != PAD_CIRCLE ) + if( pad->GetDrillShape() != PAD_DRILL_CIRCLE ) new_hole.m_Hole_Shape = 1; // oval flag set new_hole.m_Hole_Size = pad->GetDrillSize(); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index b39b6c6186..99211a7e4d 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1208,7 +1208,7 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const { m_out->Print( 0, " (drill" ); - if( aPad->GetDrillShape() == PAD_OVAL ) + if( aPad->GetDrillShape() == PAD_DRILL_OBLONG ) m_out->Print( 0, " oval" ); if( sz.GetWidth() > 0 ) diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index aa40a8b9ed..a1fd78a9b0 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1243,14 +1243,14 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) BIU offs_x = biuParse( data, &data ); BIU offs_y = biuParse( data, &data ); - PAD_SHAPE_T drShape = PAD_CIRCLE; + PAD_DRILL_SHAPE_T drShape = PAD_DRILL_CIRCLE; data = strtok_r( (char*) data, delims, &saveptr ); if( data ) // optional shape { if( data[0] == 'O' ) { - drShape = PAD_OVAL; + drShape = PAD_DRILL_OBLONG; data = strtok_r( NULL, delims, &saveptr ); drill_x = biuParse( data ); @@ -3348,7 +3348,7 @@ void LEGACY_PLUGIN::savePAD( const D_PAD* me ) const fmtBIU( me->GetDrillSize().x ).c_str(), fmtBIUPoint( me->GetOffset() ).c_str() ); - if( me->GetDrillShape() == PAD_OVAL ) + if( me->GetDrillShape() == PAD_DRILL_OBLONG ) { fprintf( m_fp, " %c %s", 'O', fmtBIUSize( me->GetDrillSize() ).c_str() ); } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp index 4ec4338efa..c757d124c2 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp @@ -202,7 +202,7 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad pad->SetShape( PAD_CIRCLE ); pad->SetAttribute( PAD_HOLE_NOT_PLATED ); - pad->SetDrillShape( PAD_CIRCLE ); + pad->SetDrillShape( PAD_DRILL_CIRCLE ); pad->SetDrillSize( wxSize( m_hole, m_hole ) ); pad->SetSize( wxSize( m_hole, m_hole ) ); @@ -267,7 +267,7 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad pad->SetDelta( wxSize( 0, 0 ) ); pad->SetOrientation( m_rotation + aRotation ); - pad->SetDrillShape( PAD_CIRCLE ); + pad->SetDrillShape( PAD_DRILL_CIRCLE ); pad->SetOffset( wxPoint( 0, 0 ) ); pad->SetDrillSize( wxSize( m_hole, m_hole ) ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index b45a58fab0..105362f83c 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -507,9 +507,9 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) // Choose drawing settings depending on if we are drawing a pad itself or a hole if( aLayer == ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ) ) { - // Drawing hole + // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL size = VECTOR2D( aPad->GetDrillSize() ) / 2.0; - shape = aPad->GetDrillShape(); + shape = aPad->GetDrillShape() == PAD_DRILL_OBLONG ? PAD_OVAL : PAD_CIRCLE; } else if( aLayer == SOLDERMASK_N_FRONT || aLayer == SOLDERMASK_N_BACK ) { @@ -620,10 +620,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) case PAD_CIRCLE: m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x ); break; - - case PAD_OCTAGON: // it is not used anywhere, neither you can set it using pcbnew.. - case PAD_NONE: - break; } m_gal->Restore(); diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 39b00186a0..82db9a5aca 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2138,7 +2138,7 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR ) switch( token ) { case T_oval: - pad->SetDrillShape( PAD_OVAL ); + pad->SetDrillShape( PAD_DRILL_OBLONG ); break; case T_NUMBER: diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 03f1c5d3e0..f42ef156bc 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -155,7 +155,7 @@ private: /** Helper function to plot a single drill mark. It compensate and clamp * the drill mark size depending on the current plot options */ - void plotOneDrillMark( PAD_SHAPE_T aDrillShape, + void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint& aDrillPos, wxSize aDrillSize, const wxSize& aPadSize, double aOrientation, int aSmallDrill ); diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index e9272f1ca8..5cc2e4fd5c 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -638,20 +638,20 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg ) /** Helper function to plot a single drill mark. It compensate and clamp * the drill mark size depending on the current plot options */ -void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_SHAPE_T aDrillShape, +void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos, wxSize aDrillSize, const wxSize &aPadSize, double aOrientation, int aSmallDrill ) { // Small drill marks have no significance when applied to slots - if( aSmallDrill && aDrillShape == PAD_ROUND ) + if( aSmallDrill && aDrillShape == PAD_DRILL_CIRCLE ) aDrillSize.x = std::min( aSmallDrill, aDrillSize.x ); // Round holes only have x diameter, slots have both aDrillSize.x -= getFineWidthAdj(); aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 ); - if( aDrillShape == PAD_OVAL ) + if( aDrillShape == PAD_DRILL_OBLONG ) { aDrillSize.y -= getFineWidthAdj(); aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 ); @@ -688,7 +688,7 @@ void BRDITEMS_PLOTTER::PlotDrillMarks() if( pts->Type() != PCB_VIA_T ) continue; - plotOneDrillMark( PAD_CIRCLE, pts->GetStart(), wxSize( pts->GetDrillValue(), 0 ), + plotOneDrillMark( PAD_DRILL_CIRCLE, pts->GetStart(), wxSize( pts->GetDrillValue(), 0 ), wxSize( pts->GetWidth(), 0 ), 0, small_drill ); } diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index 26a6cb67c1..eaef234893 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -221,7 +221,8 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) // the pad hole dummypad.SetSize( pad->GetDrillSize() ); dummypad.SetOrientation( pad->GetOrientation() ); - dummypad.SetShape( pad->GetDrillShape() ); + dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_OBLONG ? + PAD_OVAL : PAD_CIRCLE ); dummypad.SetPosition( pad->GetPosition() ); pad = &dummypad;