From add53213288af884b45a39c666ab4f88f4307eb2 Mon Sep 17 00:00:00 2001 From: lajos kamocsay Date: Sun, 15 Apr 2012 12:33:35 +0200 Subject: [PATCH 01/16] Commit patch fixing an issue in pan with middle mouse button (from lajos kamocsay) Other minor fixes. --- common/drawframe.cpp | 12 +- .../dialogs/dialog_eeschema_options_base.cpp | 6 +- .../dialogs/dialog_eeschema_options_base.fbp | 6 +- eeschema/pinedit.cpp | 2 +- include/common.h | 6 +- include/convert_to_biu.h | 8 + .../dialogs/dialog_display_options_base.fbp | 2134 ++++++++--------- ...ialog_general_options_BoardEditor_base.cpp | 4 +- ...ialog_general_options_BoardEditor_base.fbp | 4 +- 9 files changed, 1095 insertions(+), 1087 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 0f9efa3095..14ca16430d 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -575,7 +575,7 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) else virtualSize.x = logicalClientRect.width; } - else if( logicalClientRect.width < drawingRect.width ) + else { if( drawingCenterX > clientCenterX ) virtualSize.x = drawingRect.width + @@ -586,10 +586,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) else virtualSize.x = drawingRect.width; } - else - { - virtualSize.x = drawingRect.width; - } } if( drawingRect.GetTop() < logicalClientRect.GetTop() && drawingRect.GetBottom() > logicalClientRect.GetBottom() ) @@ -610,7 +606,7 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) else virtualSize.y = logicalClientRect.height; } - else if( logicalClientRect.height < drawingRect.height ) + else { if( drawingCenterY > clientCenterY ) virtualSize.y = drawingRect.height + @@ -621,10 +617,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) else virtualSize.y = drawingRect.height; } - else - { - virtualSize.y = drawingRect.height; - } } } diff --git a/eeschema/dialogs/dialog_eeschema_options_base.cpp b/eeschema/dialogs/dialog_eeschema_options_base.cpp index 025fd1a605..40ab44fa00 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.cpp +++ b/eeschema/dialogs/dialog_eeschema_options_base.cpp @@ -145,9 +145,13 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx bSizer2->Add( m_checkShowHiddenPins, 0, wxALL|wxEXPAND, 3 ); m_checkEnableMiddleButtonPan = new wxCheckBox( m_panel1, xwID_ANY, _("Enable middle mouse button panning"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkEnableMiddleButtonPan->SetToolTip( _("Use middle mouse button dragging to pan") ); + bSizer2->Add( m_checkEnableMiddleButtonPan, 0, wxALL, 3 ); - m_checkMiddleButtonPanLimited = new wxCheckBox( m_panel1, wxID_ANY, _("Middle mouse button panning limited by current toolbar panning"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkMiddleButtonPanLimited = new wxCheckBox( m_panel1, wxID_ANY, _("Middle mouse button panning limited"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkMiddleButtonPanLimited->SetToolTip( _("Middle mouse button panning limited by current scrollbar size") ); + bSizer2->Add( m_checkMiddleButtonPanLimited, 0, wxALL, 3 ); m_checkAutoPan = new wxCheckBox( m_panel1, wxID_ANY, _("Enable automatic &panning"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/eeschema/dialogs/dialog_eeschema_options_base.fbp b/eeschema/dialogs/dialog_eeschema_options_base.fbp index ca9fb73e2f..0c037e12aa 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.fbp +++ b/eeschema/dialogs/dialog_eeschema_options_base.fbp @@ -2533,7 +2533,7 @@ 0 - + Use middle mouse button dragging to pan wxFILTER_NONE wxDefaultValidator @@ -2600,7 +2600,7 @@ 0 0 wxID_ANY - Middle mouse button panning limited by current toolbar panning + Middle mouse button panning limited 0 @@ -2621,7 +2621,7 @@ 0 - + Middle mouse button panning limited by current scrollbar size wxFILTER_NONE wxDefaultValidator diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index e7da98dd30..b7b3a845b9 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -91,7 +91,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) dlg.SetPadNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNumberTextSize() ) ); dlg.SetPadNameTextSizeUnits( units ); - dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength(), m_internalUnits ) ); + dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength() ) ); dlg.SetLengthUnits( units ); dlg.SetAddToAllParts( pin->GetUnit() == 0 ); dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 ); diff --git a/include/common.h b/include/common.h index 5952c13635..0d5b4032e4 100644 --- a/include/common.h +++ b/include/common.h @@ -220,9 +220,13 @@ public: /** * Function GetWxOrientation. - * @return int - ws' style printing orientation. + * @return ws' style printing orientation (wxPORTRAIT or wxLANDSCAPE). */ +#if wxCHECK_VERSION( 2, 9, 0 ) + wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } +#else int GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } +#endif /** * Function GetPaperId diff --git a/include/convert_to_biu.h b/include/convert_to_biu.h index 2867c9abbe..c6c537c6e7 100644 --- a/include/convert_to_biu.h +++ b/include/convert_to_biu.h @@ -14,6 +14,7 @@ * depending on compil option */ +#if defined(PCBNEW) || defined(CVPCB) /// Convert mils to PCBNEW internal units (iu). inline int Mils2iu( int mils ) { @@ -36,4 +37,11 @@ inline int DMils2iu( int dmils ) #endif } +#elif defined(EESCHEMA) +inline int Mils2iu( int mils ) +{ + return mils; +} +#endif + #endif // #define CONVERT_TO_BIU_H diff --git a/pcbnew/dialogs/dialog_display_options_base.fbp b/pcbnew/dialogs/dialog_display_options_base.fbp index 50d1007ad5..b0b2cb40bb 100644 --- a/pcbnew/dialogs/dialog_display_options_base.fbp +++ b/pcbnew/dialogs/dialog_display_options_base.fbp @@ -1,1067 +1,1067 @@ - - - - - - C++ - 1 - source_name - 0 - UTF-8 - connect - dialog_display_options_base - 1000 - none - 1 - DialogDisplayOptions_base - - . - - 1 - 1 - 1 - 0 - - - - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_DISPLAY_OPTIONS_BASE - - 731,291 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - Display options - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxHORIZONTAL - none - - 5 - wxEXPAND|wxALL - 0 - - wxID_ANY - Tracks and vias: - - sLeftBoxSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - "Sketch" "Filled" - - 1 - 1 - - - 0 - wxID_DISPLAY_TRACK - Tracks: - 1 - - - m_OptDisplayTracks - protected - - 1 - - wxRA_SPECIFY_COLS - - Select how tracks are displayed - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Sketch" "Filled" - - 1 - 1 - - - 0 - ID_VIAS_SHAPES - Via Shapes: - 1 - - - m_OptDisplayVias - protected - - 1 - - wxRA_SPECIFY_COLS - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Never" "Defined holes" "Always" - - 1 - 1 - - - 0 - ID_VIAS_HOLES - Show Via Holes: - 1 - - - m_OptDisplayViaHole - protected - - 1 - - wxRA_SPECIFY_COLS - - Show (or not) via holes. If Defined Holes is selected, only the non default size holes are shown - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - wxID_ANY - Routing help: - - sbMiddleLeftSizer - wxVERTICAL - none - - - 5 - wxALL - 0 - - - "Do not show" "On pads" "On tracks" "On pads and tracks" - - 1 - 1 - - - 0 - wxID_ANY - Show Net Names: - 1 - - - m_ShowNetNamesOption - protected - - 3 - - wxRA_SPECIFY_COLS - - Show or not net names on pads and/or tracks - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Never" "New track" "New track with via area" "New and edited tracks with via area" "Always" - - 1 - 1 - - - 0 - ID_SHOW_CLEARANCE - Show Tracks Clearance: - 1 - - - m_OptDisplayTracksClearance - protected - - 3 - - wxRA_SPECIFY_COLS - - Show( or not) tracks clearance area. If New track is selected, track clearance area is shown only when creating the track. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - wxID_ANY - Footprints: - - sMiddleRightSizer - wxHORIZONTAL - none - - - 5 - - 0 - - - bLModuleSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - - "Line" "Filled" "Sketch" - - 1 - 1 - - - 0 - ID_EDGES_MODULES - Module Edges: - 1 - - - m_OptDisplayModEdges - protected - - 1 - - wxRA_SPECIFY_COLS - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Line" "Filled" "Sketch" - - 1 - 1 - - - 0 - ID_TEXT_MODULES - Texts: - 1 - - - m_OptDisplayModTexts - protected - - 1 - - wxRA_SPECIFY_COLS - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - - 0 - - wxID_ANY - Pad Options: - - bRModuleSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - "Sketch" "Filled" - - 1 - 1 - - - 0 - ID_PADS_SHAPES - Pad Shapes: - 1 - - - m_OptDisplayPads - protected - - 1 - - wxRA_SPECIFY_COLS - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - 1 - - - 0 - wxID_ANY - Show pad clearance - - - m_OptDisplayPadClearence - protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 1 - - 1 - 1 - - - 0 - wxID_ANY - Show pad number - - - m_OptDisplayPadNumber - protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 1 - - 1 - 1 - - - 0 - wxID_ANY - Show pad NoConnect - - - m_OptDisplayPadNoConn - protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - - bRightSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - wxID_ANY - Others: - - sRightUpperSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - "Line" "Filled" "Sketch" - - 1 - 1 - - - 0 - wxID_ANY - Display other items: - 1 - - - m_OptDisplayDrawings - protected - - 1 - - wxRA_SPECIFY_COLS - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Yes" "No" - - 1 - 1 - - - 0 - wxID_ANY - Show page limits - 1 - - - m_Show_Page_Limits - protected - - 0 - - wxRA_SPECIFY_COLS - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - - 0 - - 10 - protected - 10 - - - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND - 0 - - - - 1 - 0 - 1 - - - 0 - wxID_OK - OK - - - m_buttonOK - protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnOkClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND - 0 - - - - 1 - 0 - 1 - - - 0 - wxID_CANCEL - Cancel - - - m_buttonCANCEL - protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCancelClick - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_display_options_base + 1000 + none + 1 + DialogDisplayOptions_base + + . + + 1 + 1 + 1 + 0 + + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_DISPLAY_OPTIONS_BASE + + 731,291 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + Display options + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxHORIZONTAL + none + + 5 + wxEXPAND|wxALL + 0 + + wxID_ANY + Tracks and vias: + + sLeftBoxSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + "Sketch" "Filled" + + 1 + 1 + + + 0 + wxID_DISPLAY_TRACK + Tracks: + 1 + + + m_OptDisplayTracks + protected + + 1 + + wxRA_SPECIFY_COLS + + Select how tracks are displayed + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Sketch" "Filled" + + 1 + 1 + + + 0 + ID_VIAS_SHAPES + Via Shapes: + 1 + + + m_OptDisplayVias + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Never" "Defined holes" "Always" + + 1 + 1 + + + 0 + ID_VIAS_HOLES + Show Via Holes: + 1 + + + m_OptDisplayViaHole + protected + + 1 + + wxRA_SPECIFY_COLS + + Show (or not) via holes. If Defined Holes is selected, only the non default size holes are shown + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + wxID_ANY + Routing help: + + sbMiddleLeftSizer + wxVERTICAL + none + + + 5 + wxALL + 0 + + + "Do not show" "On pads" "On tracks" "On pads and tracks" + + 1 + 1 + + + 0 + wxID_ANY + Show Net Names: + 1 + + + m_ShowNetNamesOption + protected + + 3 + + wxRA_SPECIFY_COLS + + Show or not net names on pads and/or tracks + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Never" "New track" "New track with via area" "New and edited tracks with via area" "Always" + + 1 + 1 + + + 0 + ID_SHOW_CLEARANCE + Show Tracks Clearance: + 1 + + + m_OptDisplayTracksClearance + protected + + 3 + + wxRA_SPECIFY_COLS + + Show( or not) tracks clearance area. If New track is selected, track clearance area is shown only when creating the track. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + wxID_ANY + Footprints: + + sMiddleRightSizer + wxHORIZONTAL + none + + + 5 + + 0 + + + bLModuleSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "Line" "Filled" "Sketch" + + 1 + 1 + + + 0 + ID_EDGES_MODULES + Module Edges: + 1 + + + m_OptDisplayModEdges + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Line" "Filled" "Sketch" + + 1 + 1 + + + 0 + ID_TEXT_MODULES + Texts: + 1 + + + m_OptDisplayModTexts + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + wxID_ANY + Pad Options: + + bRModuleSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + "Sketch" "Filled" + + 1 + 1 + + + 0 + ID_PADS_SHAPES + Pad Shapes: + 1 + + + m_OptDisplayPads + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Show pad clearance + + + m_OptDisplayPadClearence + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 1 + + 1 + 1 + + + 0 + wxID_ANY + Show pad number + + + m_OptDisplayPadNumber + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 1 + + 1 + 1 + + + 0 + wxID_ANY + Show pad NoConnect + + + m_OptDisplayPadNoConn + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + + bRightSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Others: + + sRightUpperSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + "Line" "Filled" "Sketch" + + 1 + 1 + + + 0 + wxID_ANY + Display other items: + 1 + + + m_OptDisplayDrawings + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Yes" "No" + + 1 + 1 + + + 0 + wxID_ANY + Show page limits + 1 + + + m_Show_Page_Limits + protected + + 0 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 10 + protected + 10 + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_OK + OK + + + m_buttonOK + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_CANCEL + Cancel + + + m_buttonCANCEL + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp index a338d0a973..c0c475ab80 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp @@ -150,12 +150,12 @@ DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE::DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE( sbSizer2PAN = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pan:") ), wxVERTICAL ); m_MiddleButtonPANOpt = new wxCheckBox( this, wxID_MIDDLEBUTTONPAN, _("Middle Button PAN Enabled"), wxDefaultPosition, wxDefaultSize, 0 ); - m_MiddleButtonPANOpt->SetToolTip( _("Allows auto pan when creating a track, or moving an item.") ); + m_MiddleButtonPANOpt->SetToolTip( _("Use middle mouse button dragging to pan") ); sbSizer2PAN->Add( m_MiddleButtonPANOpt, 0, wxALL, 5 ); m_OptMiddleButtonPanLimited = new wxCheckBox( this, wxID_MIDDLEBUTTONPAN, _("Middle Button PAN Limited"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptMiddleButtonPanLimited->SetToolTip( _("Allows auto pan when creating a track, or moving an item.") ); + m_OptMiddleButtonPanLimited->SetToolTip( _("Middle mouse button panning limited by current scrollbar size") ); sbSizer2PAN->Add( m_OptMiddleButtonPanLimited, 0, wxALL, 5 ); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp index ed370978d2..fa0465708d 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp @@ -1842,7 +1842,7 @@ 0 - Allows auto pan when creating a track, or moving an item. + Use middle mouse button dragging to pan wxFILTER_NONE wxDefaultValidator @@ -1930,7 +1930,7 @@ 0 - Allows auto pan when creating a track, or moving an item. + Middle mouse button panning limited by current scrollbar size wxFILTER_NONE wxDefaultValidator From 8c0dc01fdd3bf275fb7d18e5660bf4ed95452ad2 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 15 Apr 2012 21:25:26 -0400 Subject: [PATCH 02/16] Pcbnew nanometer internal unit fixes. * Scale page reference border and title block, grid sizes, and zoom factors correctly for nanometers. --- common/worksheet.cpp | 125 +++++++++--------- eeschema/dialogs/dialog_SVG_print.cpp | 2 +- .../dialogs/dialog_print_using_printer.cpp | 2 +- eeschema/eeredraw.cpp | 3 +- eeschema/schframe.cpp | 3 +- gerbview/draw_gerber_screen.cpp | 3 +- include/base_units.h | 13 ++ include/wxstruct.h | 9 +- pcbnew/classpcb.cpp | 86 ++++++++---- pcbnew/dialogs/dialog_SVG_print.cpp | 2 +- pcbnew/printout_controler.cpp | 4 +- pcbnew/tracepcb.cpp | 5 +- 12 files changed, 151 insertions(+), 106 deletions(-) diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 517eee5e0a..5a6ff6f28d 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -1003,7 +1003,8 @@ Ki_WorkSheetData WS_Segm5_LT = }; -void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width ) +void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, + double aScalar ) { if( !m_showBorderAndTitleBlock ) return; @@ -1012,41 +1013,39 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid wxSize pageSize = pageInfo.GetSizeMils(); // if not printing, draw the page limits: - if( !screen->m_IsPrinting && g_ShowPageLimits ) + if( !aScreen->m_IsPrinting && g_ShowPageLimits ) { - int scale = m_internalUnits / 1000; - GRSetDrawMode( DC, GR_COPY ); - GRRect( m_canvas->GetClipBox(), DC, 0, 0, - pageSize.x * scale, pageSize.y * scale, line_width, + GRSetDrawMode( aDC, GR_COPY ); + GRRect( m_canvas->GetClipBox(), aDC, 0, 0, + pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth, g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); } wxPoint margin_left_top( pageInfo.GetLeftMarginMils(), pageInfo.GetTopMarginMils() ); wxPoint margin_right_bottom( pageInfo.GetRightMarginMils(), pageInfo.GetBottomMarginMils() ); wxString paper = pageInfo.GetType(); - wxString file = screen->GetFileName(); + wxString file = aScreen->GetFileName(); TITLE_BLOCK t_block = GetTitleBlock(); - int number_of_screens = screen->m_NumberOfScreen; - int screen_to_draw = screen->m_ScreenNumber; + int number_of_screens = aScreen->m_NumberOfScreen; + int screen_to_draw = aScreen->m_ScreenNumber; - TraceWorkSheet( ( wxDC* )DC, pageSize, margin_left_top, margin_right_bottom, - paper, file, t_block, number_of_screens, screen_to_draw, - ( int )line_width ); + TraceWorkSheet( aDC, pageSize, margin_left_top, margin_right_bottom, + paper, file, t_block, number_of_screens, screen_to_draw, + aLineWidth, aScalar ); } void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoint& aRB, - wxString& aType, wxString& aFlNm, TITLE_BLOCK& aTb, - int aNScr, int aScr, int aLnW, EDA_COLOR_T aClr1, - EDA_COLOR_T aClr2 ) + wxString& aType, wxString& aFlNm, TITLE_BLOCK& aTb, + int aNScr, int aScr, int aLnW, double aScalar, + EDA_COLOR_T aClr1, EDA_COLOR_T aClr2 ) { wxPoint pos; int refx, refy; wxString Line; Ki_WorkSheetData* WsItem; - int scale = m_internalUnits / 1000; - wxSize size( SIZETEXT * scale, SIZETEXT * scale ); - wxSize size_ref( SIZETEXT_REF * scale, SIZETEXT_REF * scale ); + wxSize size( SIZETEXT * aScalar, SIZETEXT * aScalar ); + wxSize size_ref( SIZETEXT_REF * aScalar, SIZETEXT_REF * aScalar ); wxString msg; GRSetDrawMode( aDC, GR_COPY ); @@ -1062,15 +1061,15 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi #if defined(KICAD_GOST) // Draw the border. - GRRect( m_canvas->GetClipBox(), aDC, refx * scale, refy * scale, - xg * scale, yg * scale, aLnW, aClr1 ); + GRRect( m_canvas->GetClipBox(), aDC, refx * aScalar, refy * aScalar, + xg * aScalar, yg * aScalar, aLnW, aClr1 ); refx = aLT.x; refy = aSz.y - aRB.y; // Lower left corner for( WsItem = &WS_Segm1_LU; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = ( refx - WsItem->m_Posx ) * scale; - pos.y = ( refy - WsItem->m_Posy ) * scale; + pos.x = ( refx - WsItem->m_Posx ) * aScalar; + pos.y = ( refy - WsItem->m_Posy ) * aScalar; msg.Empty(); switch( WsItem->m_Type ) { @@ -1090,7 +1089,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi xg = aLT.x - WsItem->m_Endx; yg = aSz.y - aRB.y - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), aDC, pos.x, pos.y, - xg * scale, yg * scale, aLnW, aClr1 ); + xg * aScalar, yg * aScalar, aLnW, aClr1 ); break; } } @@ -1098,8 +1097,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi refy = aRB.y; // Left Top corner for( WsItem = &WS_Segm1_LT; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = ( refx + WsItem->m_Posx ) * scale; - pos.y = ( refy + WsItem->m_Posy ) * scale; + pos.x = ( refx + WsItem->m_Posx ) * aScalar; + pos.y = ( refy + WsItem->m_Posy ) * aScalar; msg.Empty(); switch( WsItem->m_Type ) { @@ -1107,14 +1106,14 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi xg = aLT.x + WsItem->m_Endx; yg = aRB.y + WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), aDC, pos.x, pos.y, - xg * scale, yg * scale, aLnW, aClr1 ); + xg * aScalar, yg * aScalar, aLnW, aClr1 ); break; } } - wxSize size2( SIZETEXT * scale * 2, SIZETEXT * scale * 2); - wxSize size3( SIZETEXT * scale * 3, SIZETEXT * scale * 3); - wxSize size1_5( SIZETEXT * scale * 1.5, SIZETEXT * scale * 1.5); + wxSize size2( SIZETEXT * aScalar * 2, SIZETEXT * aScalar * 2); + wxSize size3( SIZETEXT * aScalar * 3, SIZETEXT * aScalar * 3); + wxSize size1_5( SIZETEXT * aScalar * 1.5, SIZETEXT * aScalar * 1.5); // lower right corner refx = aSz.x - aRB.x; refy = aSz.y - aRB.y; @@ -1123,8 +1122,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi { for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = (refx - WsItem->m_Posx) * scale; - pos.y = (refy - WsItem->m_Posy) * scale; + pos.x = (refx - WsItem->m_Posx) * aScalar; + pos.y = (refy - WsItem->m_Posy) * aScalar; msg.Empty(); switch( WsItem->m_Type ) { @@ -1198,8 +1197,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi msg, TEXT_ORIENT_HORIZ, size3, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, aLnW, false, false ); - pos.x = (aLT.x + 1260) * scale; - pos.y = (aLT.y + 270) * scale; + pos.x = (aLT.x + 1260) * aScalar; + pos.y = (aLT.y + 270) * aScalar; DrawGraphicText( m_canvas, aDC, pos, aClr2, msg, 1800, size2, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, @@ -1244,13 +1243,13 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi case WS_LEFT_SEGMENT: WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy = WS_MostLeftLine.m_Posy = STAMP_OY; - pos.y = ( refy - WsItem->m_Posy ) * scale; + pos.y = ( refy - WsItem->m_Posy ) * aScalar; case WS_SEGMENT: xg = aSz.x - aRB.x - WsItem->m_Endx; yg = aSz.y - aRB.y - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), aDC, pos.x, pos.y, - xg * scale, yg * scale, aLnW, aClr1 ); + xg * aScalar, yg * aScalar, aLnW, aClr1 ); break; } } @@ -1259,8 +1258,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi { for( WsItem = &WS_CADRE_D; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = ( refx - WsItem->m_Posx ) * scale; - pos.y = ( refy - WsItem->m_Posy ) * scale; + pos.x = ( refx - WsItem->m_Posx ) * aScalar; + pos.y = ( refy - WsItem->m_Posy ) * aScalar; msg.Empty(); switch( WsItem->m_Type ) @@ -1274,8 +1273,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi msg, TEXT_ORIENT_HORIZ, size3, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, aLnW, false, false ); - pos.x = (aLT.x + 1260) * scale; - pos.y = (aLT.y + 270) * scale; + pos.x = (aLT.x + 1260) * aScalar; + pos.y = (aLT.y + 270) * aScalar; DrawGraphicText( m_canvas, aDC, pos, aClr2, msg, 1800, size2, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, @@ -1303,13 +1302,13 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi break; case WS_LEFT_SEGMENT_D: - pos.y = ( refy - WsItem->m_Posy ) * scale; + pos.y = ( refy - WsItem->m_Posy ) * aScalar; case WS_SEGMENT_D: xg = aSz.x - aRB.x - WsItem->m_Endx; yg = aSz.y - aRB.y - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), aDC, pos.x, pos.y, - xg * scale, yg * scale, aLnW, aClr1 ); + xg * aScalar, yg * aScalar, aLnW, aClr1 ); break; } } @@ -1320,8 +1319,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi int ii, jj, ipas, gxpas, gypas; for( ii = 0; ii < 2; ii++ ) { - GRRect( m_canvas->GetClipBox(), aDC, refx * scale, refy * scale, - xg * scale, yg * scale, aLnW, aClr1 ); + GRRect( m_canvas->GetClipBox(), aDC, refx * aScalar, refy * aScalar, + xg * aScalar, yg * aScalar, aLnW, aClr1 ); refx += GRID_REF_W; refy += GRID_REF_W; xg -= GRID_REF_W; yg -= GRID_REF_W; @@ -1343,24 +1342,24 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi if( ii < xg - PAS_REF / 2 ) { - GRLine( m_canvas->GetClipBox(), aDC, ii * scale, refy * scale, - ii * scale, ( refy + GRID_REF_W ) * scale, aLnW, aClr1 ); + GRLine( m_canvas->GetClipBox(), aDC, ii * aScalar, refy * aScalar, + ii * aScalar, ( refy + GRID_REF_W ) * aScalar, aLnW, aClr1 ); } DrawGraphicText( m_canvas, aDC, - wxPoint( ( ii - gxpas / 2 ) * scale, - ( refy + GRID_REF_W / 2 ) * scale ), + wxPoint( ( ii - gxpas / 2 ) * aScalar, + ( refy + GRID_REF_W / 2 ) * aScalar ), aClr1, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, aLnW, false, false ); if( ii < xg - PAS_REF / 2 ) { - GRLine( m_canvas->GetClipBox(), aDC, ii * scale, yg * scale, - ii * scale, ( yg - GRID_REF_W ) * scale, aLnW, aClr1 ); + GRLine( m_canvas->GetClipBox(), aDC, ii * aScalar, yg * aScalar, + ii * aScalar, ( yg - GRID_REF_W ) * aScalar, aLnW, aClr1 ); } DrawGraphicText( m_canvas, aDC, - wxPoint( ( ii - gxpas / 2 ) * scale, - ( yg - GRID_REF_W / 2) * scale ), + wxPoint( ( ii - gxpas / 2 ) * aScalar, + ( yg - GRID_REF_W / 2) * aScalar ), aClr1, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, aLnW, false, false ); @@ -1378,25 +1377,25 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi if( ii < yg - PAS_REF / 2 ) { - GRLine( m_canvas->GetClipBox(), aDC, refx * scale, ii * scale, - ( refx + GRID_REF_W ) * scale, ii * scale, aLnW, aClr1 ); + GRLine( m_canvas->GetClipBox(), aDC, refx * aScalar, ii * aScalar, + ( refx + GRID_REF_W ) * aScalar, ii * aScalar, aLnW, aClr1 ); } DrawGraphicText( m_canvas, aDC, - wxPoint( ( refx + GRID_REF_W / 2 ) * scale, - ( ii - gypas / 2 ) * scale ), + wxPoint( ( refx + GRID_REF_W / 2 ) * aScalar, + ( ii - gypas / 2 ) * aScalar ), aClr1, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, aLnW, false, false ); if( ii < yg - PAS_REF / 2 ) { - GRLine( m_canvas->GetClipBox(), aDC, xg * scale, ii * scale, - ( xg - GRID_REF_W ) * scale, ii * scale, aLnW, aClr1 ); + GRLine( m_canvas->GetClipBox(), aDC, xg * aScalar, ii * aScalar, + ( xg - GRID_REF_W ) * aScalar, ii * aScalar, aLnW, aClr1 ); } DrawGraphicText( m_canvas, aDC, - wxPoint( ( xg - GRID_REF_W / 2 ) * scale, - ( ii - gxpas / 2 ) * scale ), + wxPoint( ( xg - GRID_REF_W / 2 ) * aScalar, + ( ii - gxpas / 2 ) * aScalar ), aClr1, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, aLnW, false, false ); @@ -1408,8 +1407,8 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = (refx - WsItem->m_Posx) * scale; - pos.y = (refy - WsItem->m_Posy) * scale; + pos.x = (refx - WsItem->m_Posx) * aScalar; + pos.y = (refy - WsItem->m_Posy) * aScalar; msg.Empty(); switch( WsItem->m_Type ) @@ -1592,13 +1591,13 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy = WS_MostLeftLine.m_Posy = UpperLimit; - pos.y = (refy - WsItem->m_Posy) * scale; + pos.y = (refy - WsItem->m_Posy) * aScalar; case WS_SEGMENT: xg = aSz.x - GRID_REF_W - aRB.x - WsItem->m_Endx; yg = aSz.y - GRID_REF_W - aRB.y - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), aDC, pos.x, pos.y, - xg * scale, yg * scale, aLnW, aClr1 ); + xg * aScalar, yg * aScalar, aLnW, aClr1 ); break; } } diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index eb321d5e33..c7b6f6c974 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -237,7 +237,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, sheetSize.y/2) ); if( aPrint_Sheet_Ref ) - frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness ); + frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); screen->m_IsPrinting = false; panel->SetClipBox( tmp ); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 7551f80e82..d9c787714f 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -378,7 +378,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE ); if( printReference ) - parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness ); + parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); g_DrawBgColor = bg_color; aScreen->m_IsPrinting = false; diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 2549a80c70..b571711594 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -70,7 +71,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE ); - TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness ); + TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); #ifdef USE_WX_OVERLAY if( IsShown() ) diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 29b495c46b..20d4adc4f4 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -862,7 +863,7 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData ) { GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); - TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness ); + TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); } diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index 4d9c3163d9..7a6821a4ab 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -106,7 +107,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) if( IsElementVisible( DCODES_VISIBLE ) ) DrawItemsDCodeID( DC, GR_COPY ); - TraceWorkSheet( DC, screen, 0 ); + TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR ); if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); diff --git a/include/base_units.h b/include/base_units.h index 06374608cb..e68a118d0f 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -37,6 +37,19 @@ #include + +/// Scalar to convert mils to internal units. +#if defined( PCBNEW ) +#if defined( USE_PCBNEW_NANOMETRES ) +#define MILS_TO_IU_SCALAR 25.4e3 // Pcbnew in nanometers. +#else +#define MILS_TO_IU_SCALAR 10.0 // Pcbnew in deci-mils. +#endif +#else +#define MILS_TO_IU_SCALAR 1.0 // Eeschema and anything else. +#endif + + /** * Function To_User_Unit * convert \a aValue in internal units to the appropriate user units defined by \a aUnit. diff --git a/include/wxstruct.h b/include/wxstruct.h index a59fdd9876..3439658654 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -667,7 +667,7 @@ public: */ double GetZoom(); - void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth ); + void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar ); /** * Function TraceWorkSheet is a core function for drawing of the page layout with @@ -682,13 +682,14 @@ public: * @param aNScr The number of screens (for basic inscriptions). * @param aScr The screen number (for basic inscriptions). * @param aLnW The line width for drawing. + * @param aScalar Scalar to convert from mils to internal units. * @param aClr1 The color for drawing. * @param aClr2 The colr for inscriptions. */ void TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoint& aRB, - wxString& aType, wxString& aFlNm, TITLE_BLOCK& aTb, - int aNScr, int aScr, int aLnW, EDA_COLOR_T aClr1 = RED, - EDA_COLOR_T aClr2 = RED ); + wxString& aType, wxString& aFlNm, TITLE_BLOCK& aTb, + int aNScr, int aScr, int aLnW, double aScalar, + EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED ); void PlotWorkSheet( PLOTTER* aPlotter, BASE_SCREEN* aScreen ); diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 26213ea229..2fe09eecbc 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -10,6 +10,7 @@ #include #include #include // FILLED +#include #include #include @@ -18,6 +19,19 @@ #include +#if defined( USE_PCBNEW_NANOMETRES ) +#define ZOOM_FACTOR( x ) ( x * 25.4e2 ) +#define DMIL_GRID( x ) wxRealPoint( x * 25.4e2, x * 25.4e2 ) +#define MM_GRID( x ) wxRealPoint( x * 1e6, x * 1e6 ) +#else +#define ZOOM_FACTOR( x ) x +#define DMIL_GRID( x ) wxRealPoint( x , x ) +#define MM_GRID( x ) wxRealPoint( x * 1e4 / 25.4, x * 1e4 / 25.4 ) +#endif + + + + /* Default Pcbnew zoom values. * Limited to 19 values to keep a decent size to menus * 15 it better but does not allow a sufficient number of values @@ -30,42 +44,56 @@ */ static const double pcbZoomList[] = { - 0.5, 1.0, 1.5, 2.0, 3.0, 4.5, 7.0, - 10.0, 15.0, 22.0, 35.0, 50.0, 80.0, 120.0, - 200.0, 350.0, 500.0, 1000.0, 2000.0 + ZOOM_FACTOR( 0.5 ), + ZOOM_FACTOR( 1.0 ), + ZOOM_FACTOR( 1.5 ), + ZOOM_FACTOR( 2.0 ), + ZOOM_FACTOR( 3.0 ), + ZOOM_FACTOR( 4.5 ), + ZOOM_FACTOR( 7.0 ), + ZOOM_FACTOR( 10.0 ), + ZOOM_FACTOR( 15.0 ), + ZOOM_FACTOR( 22.0 ), + ZOOM_FACTOR( 35.0 ), + ZOOM_FACTOR( 50.0 ), + ZOOM_FACTOR( 80.0 ), + ZOOM_FACTOR( 120.0 ), + ZOOM_FACTOR( 200.0 ), + ZOOM_FACTOR( 350.0 ), + ZOOM_FACTOR( 500.0 ), + ZOOM_FACTOR( 1000.0 ), + ZOOM_FACTOR( 2000.0 ) }; -#define MM_TO_PCB_UNITS (10000.0 / 25.4) - // Default grid sizes for PCB editor screens. static GRID_TYPE pcbGridList[] = { // predefined grid list in 0.0001 inches - { ID_POPUP_GRID_LEVEL_1000, wxRealPoint( 1000, 1000 ) }, - { ID_POPUP_GRID_LEVEL_500, wxRealPoint( 500, 500 ) }, - { ID_POPUP_GRID_LEVEL_250, wxRealPoint( 250, 250 ) }, - { ID_POPUP_GRID_LEVEL_200, wxRealPoint( 200, 200 ) }, - { ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) }, - { ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) }, - { ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) }, - { ID_POPUP_GRID_LEVEL_20, wxRealPoint( 20, 20 ) }, - { ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) }, - { ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) }, - { ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) }, - { ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) }, + { ID_POPUP_GRID_LEVEL_1000, DMIL_GRID( 1000 ) }, + { ID_POPUP_GRID_LEVEL_500, DMIL_GRID( 500 ) }, + { ID_POPUP_GRID_LEVEL_250, DMIL_GRID( 250 ) }, + { ID_POPUP_GRID_LEVEL_200, DMIL_GRID( 200 ) }, + { ID_POPUP_GRID_LEVEL_100, DMIL_GRID( 100 ) }, + { ID_POPUP_GRID_LEVEL_50, DMIL_GRID( 50 ) }, + { ID_POPUP_GRID_LEVEL_25, DMIL_GRID( 25 ) }, + { ID_POPUP_GRID_LEVEL_20, DMIL_GRID( 20 ) }, + { ID_POPUP_GRID_LEVEL_10, DMIL_GRID( 10 ) }, + { ID_POPUP_GRID_LEVEL_5, DMIL_GRID( 5 ) }, + { ID_POPUP_GRID_LEVEL_2, DMIL_GRID( 2 ) }, + { ID_POPUP_GRID_LEVEL_1, DMIL_GRID( 1 ) }, // predefined grid list in mm - { ID_POPUP_GRID_LEVEL_5MM, wxRealPoint( MM_TO_PCB_UNITS * 5.0, MM_TO_PCB_UNITS * 5.0 ) }, - { ID_POPUP_GRID_LEVEL_2_5MM, wxRealPoint( MM_TO_PCB_UNITS * 2.5, MM_TO_PCB_UNITS * 2.5 ) }, - { ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_PCB_UNITS, MM_TO_PCB_UNITS ) }, - { ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.5, MM_TO_PCB_UNITS * 0.5 ) }, - { ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) }, - { ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) }, - { ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) }, - { ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) }, - { ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) }, - { ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) } + { ID_POPUP_GRID_LEVEL_5MM, MM_GRID( 5.0 ) }, + { ID_POPUP_GRID_LEVEL_2_5MM, MM_GRID( 2.5 ) }, + { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) }, + { ID_POPUP_GRID_LEVEL_0_5MM, MM_GRID( 0.5 ) }, + { ID_POPUP_GRID_LEVEL_0_25MM, MM_GRID( 0.25 ) }, + { ID_POPUP_GRID_LEVEL_0_2MM, MM_GRID( 0.2 ) }, + { ID_POPUP_GRID_LEVEL_0_1MM, MM_GRID( 0.1 ) }, + { ID_POPUP_GRID_LEVEL_0_0_5MM, MM_GRID( 0.05 ) }, + { ID_POPUP_GRID_LEVEL_0_0_25MM, MM_GRID( 0.025 ) }, + { ID_POPUP_GRID_LEVEL_0_0_1MM, MM_GRID( 0.01 ) } }; @@ -79,13 +107,13 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) : AddGrid( pcbGridList[i] ); // Set the working grid size to a reasonnable value (in 1/10000 inch) - SetGrid( wxRealPoint( 500, 500 ) ); + SetGrid( DMIL_GRID( 500 ) ); m_Active_Layer = LAYER_N_BACK; // default active layer = bottom layer m_Route_Layer_TOP = LAYER_N_FRONT; // default layers pair for vias (bottom to top) m_Route_Layer_BOTTOM = LAYER_N_BACK; - SetZoom( 150 ); // a default value for zoom + SetZoom( ZOOM_FACTOR( 150 ) ); // a default value for zoom InitDataPoints( aPageSizeIU ); } diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 863b149bd6..571180f76c 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -265,7 +265,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, g_DrawBgColor = WHITE; if( aPrint_Frame_Ref ) - m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize ); + m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, MILS_TO_IU_SCALAR ); m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters); g_DrawBgColor = bg_color; diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 02c74afaf8..9df8d4b409 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -35,9 +35,9 @@ #include #include #include +#include #include - #include #include @@ -278,7 +278,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() int bg_color = g_DrawBgColor; if( m_PrintParams.m_Print_Sheet_Ref ) - m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize ); + m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, MILS_TO_IU_SCALAR ); if( printMirror ) { diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 937f82c238..e24b92a36e 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GRSetDrawMode( DC, GR_COPY ); m_canvas->DrawBackGround( DC ); - TraceWorkSheet( DC, screen, 0 ); + TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR ); // Redraw the footprints for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) @@ -104,7 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) m_canvas->DrawBackGround( DC ); - TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness ); + TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST); From a42490e0f35c9051d4fc12071190d5c4ab3afcf2 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 15 Apr 2012 22:18:41 -0500 Subject: [PATCH 03/16] work on footprint plugin API --- common/base_screen.cpp | 9 - common/drawframe.cpp | 2 +- common/footprint_info.cpp | 89 +- .../dialogs/dialog_edit_component_in_lib.cpp | 1 - .../dialog_edit_component_in_lib_base.cpp | 21 +- .../dialog_edit_component_in_lib_base.fbp | 6620 ++++++++--------- .../dialog_edit_component_in_lib_base.h | 7 +- ...dialog_edit_component_in_schematic_fbp.fbp | 5400 +++++++------- eeschema/dialogs/dialog_lib_new_component.fbp | 3206 ++++---- .../dialogs/dialog_lib_new_component_base.cpp | 473 +- .../dialogs/dialog_lib_new_component_base.h | 148 +- eeschema/libeditframe.cpp | 2 +- include/class_base_screen.h | 7 - include/dialog_helpers.h | 68 - include/footprint_info.h | 1 + include/pcbstruct.h | 11 +- pcbnew/CMakeLists.txt | 2 +- ...pp => class_footprint_library.cpp.notused} | 0 ...ry.h => class_footprint_library.h.notused} | 11 +- pcbnew/class_module.h | 6 + pcbnew/classpcb.cpp | 49 +- pcbnew/io_mgr.cpp | 63 +- pcbnew/io_mgr.h | 92 +- pcbnew/legacy_plugin.cpp | 443 +- pcbnew/legacy_plugin.h | 40 +- pcbnew/librairi.cpp | 120 +- pcbnew/loadcmp.cpp | 18 +- pcbnew/modview.cpp | 1 - pcbnew/modview_frame.h | 1 - pcbnew/specctra_export.cpp | 1 - 30 files changed, 8860 insertions(+), 8052 deletions(-) rename pcbnew/{class_footprint_library.cpp => class_footprint_library.cpp.notused} (100%) rename pcbnew/{class_footprint_library.h => class_footprint_library.h.notused} (90%) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 89c757134b..f9895a287c 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -116,15 +116,6 @@ void BASE_SCREEN::SetScalingFactor(double aScale ) } -void BASE_SCREEN::SetZoomList( const wxArrayDouble& zoomlist ) -{ - if( !m_ZoomList.IsEmpty() ) - m_ZoomList.Empty(); - - m_ZoomList = zoomlist; -} - - bool BASE_SCREEN::SetFirstZoom() { if( m_ZoomList.IsEmpty() ) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 14ca16430d..63cf484890 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -369,7 +369,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) else { id--; - int selectedZoom = GetScreen()->m_ZoomList[id]; + double selectedZoom = GetScreen()->m_ZoomList[id]; if( GetScreen()->GetZoom() == selectedZoom ) return; diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 7e4797fa73..a8af4e515d 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -39,9 +40,8 @@ * ...... other data (pads, outlines ..) * $Endmodule */ -bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) +bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) { - FILE* file; wxFileName filename; wxString libname; @@ -50,7 +50,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) m_filesInvalid.Empty(); m_List.clear(); - /* Parse Libraries Listed */ + PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); + + // Parse Libraries Listed for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) { filename = aFootprintsLibNames[ii]; @@ -64,82 +66,28 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) continue; } - /* Open library file */ - file = wxFopen( libname, wxT( "rt" ) ); - - if( file == NULL ) + try { - m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n"); - continue; - } + wxArrayString fpnames = pi->FootprintEnumerate( libname ); - FILE_LINE_READER fileReader( file, libname ); - FILTER_READER reader( fileReader ); - - /* Read header. */ - reader.ReadLine(); - char * line = reader.Line(); - StrPurge( line ); - - if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 ) - { - wxString msg; - msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library." ), - GetChars( libname ) ); - m_filesInvalid << msg << wxT("\n"); - continue; - } - - // Read library - bool end = false; - while( !end && reader.ReadLine() ) - { - line = reader.Line(); - StrPurge( line ); - if( strnicmp( line, "$EndLIBRARY", 11 ) == 0 ) - { - end = true; - break; - } - if( strnicmp( line, "$MODULE", 7 ) == 0 ) + for( unsigned i=0; i m( pi->FootprintLoad( libname, fpnames[i] ) ); - line += 7; - FOOTPRINT_INFO* ItemLib = new FOOTPRINT_INFO(); - ItemLib->m_Module = FROM_UTF8( StrPurge( line ) ); - ItemLib->m_LibName = libname; - AddItem( ItemLib ); + FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); - while( reader.ReadLine() ) - { - line = reader.Line(); - StrPurge( line ); - if( strnicmp( line, "$EndMODULE", 10 ) == 0 ) - break; + fpinfo->m_Module = fpnames[i]; + fpinfo->m_LibName = libname; + fpinfo->m_padCount = m->GetPadCount(); + fpinfo->m_KeyWord = m->GetKeywords(); + fpinfo->m_Doc = m->GetDescription(); - if( strnicmp( line, "$PAD", 4 ) == 0 ) - ItemLib->m_padCount++; - - int id = ((line[0] & 0xFF) << 8) + (line[1] & 0xFF); - switch( id ) - { - /* KeyWords */ - case (('K'<<8) + 'w'): - ItemLib->m_KeyWord = FROM_UTF8( StrPurge( line + 3 ) ); - break; - - /* Doc */ - case (('C'<<8) + 'd'): - ItemLib->m_Doc = FROM_UTF8( StrPurge( line + 3 ) ); - break; - } - } + AddItem( fpinfo ); } } - - if( !end ) + catch( IO_ERROR ioe ) { - m_filesInvalid << libname << _(" (Unexpected end of file)") << wxT("\n"); + m_filesInvalid << ioe.errorText << wxT("\n"); } } @@ -147,3 +95,4 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) return true; } + diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 2568908c28..262fd77d17 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -39,7 +39,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY() */ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() { - SetFocus(); m_AliasLocation = -1; LIB_COMPONENT* component = m_Parent->GetComponent(); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp index 8fff9d8f3c..11d0ce68eb 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 30 2011) +// C++ code generated with wxFormBuilder (version Apr 11 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -50,6 +50,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_OptionsBoxSizer->Add( m_PinsNameInsideButt, 0, wxALL, 5 ); + bSizerBasicPanel->Add( m_OptionsBoxSizer, 0, 0, 5 ); m_staticline3 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); @@ -70,6 +71,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_SelNumberOfUnits = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 26, 1 ); bSizernbunits->Add( m_SelNumberOfUnits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + bSizerMidBasicPanel->Add( bSizernbunits, 1, wxEXPAND, 5 ); wxBoxSizer* bSizer17; @@ -84,8 +86,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_SetSkew = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 ); bSizer17->Add( m_SetSkew, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerMidBasicPanel->Add( bSizer17, 1, wxEXPAND, 5 ); + bSizerBasicPanel->Add( bSizerMidBasicPanel, 0, wxEXPAND, 5 ); m_staticline1 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); @@ -101,6 +105,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx bSizerBasicPanel->Add( m_OptionPartsLocked, 0, wxALL, 5 ); + m_PanelBasic->SetSizer( bSizerBasicPanel ); m_PanelBasic->Layout(); bSizerBasicPanel->Fit( m_PanelBasic ); @@ -145,8 +150,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_buttonBrowseDocFiles = new wxButton( m_PanelDoc, ID_BROWSE_DOC_FILES, _("Browse DocFiles"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerPaneldocbutts->Add( m_buttonBrowseDocFiles, 0, wxALL, 5 ); + m_PanelDocBoxSizer->Add( bSizerPaneldocbutts, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + m_PanelDoc->SetSizer( m_PanelDocBoxSizer ); m_PanelDoc->Layout(); m_PanelDocBoxSizer->Fit( m_PanelDoc ); @@ -167,6 +174,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PartAliasListCtrl = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); bLeftBoxSizerPanelAlias->Add( m_PartAliasListCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 1, wxEXPAND, 5 ); wxBoxSizer* bRightBoxSizerPanelAlias; @@ -181,8 +189,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_ButtonDeleteAllAlias = new wxButton( m_PanelAlias, ID_DELETE_ALL_ALIAS, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 ); bRightBoxSizerPanelAlias->Add( m_ButtonDeleteAllAlias, 0, wxALL, 5 ); + bSizerMainPanelAlias->Add( bRightBoxSizerPanelAlias, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_PanelAlias->SetSizer( bSizerMainPanelAlias ); m_PanelAlias->Layout(); bSizerMainPanelAlias->Fit( m_PanelAlias ); @@ -203,6 +213,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND, 5 ); wxBoxSizer* bFpFilterRightBoxSizer; @@ -217,8 +228,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_ButtonDeleteAllFootprintFilter = new wxButton( m_PanelFootprintFilter, ID_DELETE_ALL_FOOTPRINT_FILTER, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 ); bFpFilterRightBoxSizer->Add( m_ButtonDeleteAllFootprintFilter, 0, wxALL|wxEXPAND, 5 ); + bPanelFpFilterBoxSizer->Add( bFpFilterRightBoxSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer ); m_PanelFootprintFilter->Layout(); bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter ); @@ -226,6 +239,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx bUpperSizer->Add( m_NoteBook, 1, wxEXPAND, 5 ); + bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); m_stdSizerButton = new wxStdDialogButtonSizer(); @@ -234,10 +248,13 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_stdSizerButtonCancel = new wxButton( this, wxID_CANCEL ); m_stdSizerButton->AddButton( m_stdSizerButtonCancel ); m_stdSizerButton->Realize(); + bMainSizer->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 ); + this->SetSizer( bMainSizer ); this->Layout(); + bMainSizer->Fit( this ); // Connect Events m_ButtonCopyDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::CopyDocToAlias ), NULL, this ); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp index a6079ef26a..05000dcfcb 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp @@ -1,3358 +1,3262 @@ - - - - - - C++ - 1 - source_name - 0 - res - UTF-8 - connect - dialog_edit_component_in_lib_base - 1000 - none - 1 - DIALOG_EDIT_COMPONENT_IN_LIBRARY_FBP - - . - - 1 - 1 - 0 - 0 - - 1 - 1 - 1 - 1 - 0 - - - - - 1 - - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - impl_virtual - - - 1 - - 0 - 0 - ID_LIBEDIT_NOTEBOOK - - - 0 - - - 0 - - 1 - DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE - 1 - - - 1 - - - Resizable - - 1 - 465,384 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - Lib Component Properties - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - bUpperSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_NoteBook - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Options - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_PanelBasic - 1 - - - protected - 1 - - - Resizable - - 1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - wxSUNKEN_BORDER|wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerBasicPanel - wxVERTICAL - none - - 5 - - 0 - - wxID_ANY - General : - - m_OptionsBoxSizer - wxVERTICAL - none - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - As Convert - - - 0 - - - 0 - - 1 - m_AsConvertButt - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Check this option for components that have a De Morgan representation. This is usual for gates. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show Pin Num - - - 0 - - - 0 - - 1 - m_ShowPinNumButt - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Show or hide pin numbers - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show Pin Name - - - 0 - - - 0 - - 1 - m_ShowPinNameButt - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Show or hide pin names - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Pin Name Inside - - - 0 - - - 0 - - 1 - m_PinsNameInsideButt - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Check this option to have pin names inside the body and pin number outside. If not checked pins names and pins numbers are outside. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_staticline3 - 1 - - - protected - 1 - - - Resizable - - 1 - - wxLI_HORIZONTAL - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - - bSizerMidBasicPanel - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - - bSizernbunits - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Number of Units: - - - 0 - - - 0 - - 1 - m_staticTextNbUnits - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - This is the number of parts in this component package. A 74LS00 gate has 4 parts per packages. - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 1 - - 26 - - 0 - - 1 - - 0 - - 1 - m_SelNumberOfUnits - 1 - - - protected - 1 - - - Resizable - - 1 - - wxSP_ARROW_KEYS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bSizer17 - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Skew: - - - 0 - - - 0 - - 1 - m_staticTextskew - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Margin (in 0.001 inches) between a pin name position and the component body. A value from 10 to 40 is usually good. - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 0 - - 100 - - 0 - - 1 - - 0 - - 1 - m_SetSkew - 1 - - - protected - 1 - - - Resizable - - 1 - - wxSP_ARROW_KEYS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - - Resizable - - 1 - - wxLI_HORIZONTAL - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Power Symbol - - - 0 - - - 0 - - 1 - m_OptionPower - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Check this option for power symbols. Power symbols have specific properties for Eeschema: - Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol - Reference is updated automatically when a netlist is created (no need to run Annotate) - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Parts are locked - - - 0 - - - 0 - - 1 - m_OptionPartsLocked - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Check this option if Eeschema cannot change parts selections inside a given package This happens when parts are different in this package. When this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Description - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_PanelDoc - 1 - - - protected - 1 - - - Resizable - - 1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - wxSUNKEN_BORDER|wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - m_PanelDocBoxSizer - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Description: - - - 0 - - - 0 - - 1 - m_staticTextDescription - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - A short description that is displayed in Eeschema. Can be a very good help when selecting components in libraries components lists. - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - m_DocCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Keywords: - - - 0 - - - 0 - - 1 - m_staticTextKeywords - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Enter key words that can be used to select this component. Key words cannot have spaces and are separated by a space. - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - m_KeywordsCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - DocFileName: - - - 0 - - - 0 - - 1 - m_staticTextDocFileName - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Enter the documentation file (a .pdf document) associated to the component. - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - m_DocfileCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - 400,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL - 0 - - - bSizerPaneldocbutts - wxHORIZONTAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_COPY_DOC_TO_ALIAS - Copy Doc - - - 0 - - - 0 - - 1 - m_ButtonCopyDoc - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - CopyDocToAlias - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_BROWSE_DOC_FILES - Browse DocFiles - - - 0 - - - 0 - - 1 - m_buttonBrowseDocFiles - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - BrowseAndSelectDocFile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Alias - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_PanelAlias - 1 - - - protected - 1 - - - Resizable - - 1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - wxSUNKEN_BORDER|wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMainPanelAlias - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - - bLeftBoxSizerPanelAlias - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Alias List: - - - 0 - - - 0 - - 1 - m_staticTextAlias - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - An alias is a component that uses the body of its root component. It has its own documentation and keywords. A fast way to extend a library with similar components - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_PartAliasListCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - - bRightBoxSizerPanelAlias - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_ADD_ALIAS - Add - - - 0 - - - 0 - - 1 - m_ButtonAddeAlias - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - AddAliasOfPart - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_DELETE_ONE_ALIAS - Delete - - - 0 - - - 0 - - 1 - m_ButtonDeleteOneAlias - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - DeleteAliasOfPart - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_DELETE_ALL_ALIAS - Delete All - - - 0 - - - 0 - - 1 - m_ButtonDeleteAllAlias - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - DeleteAllAliasOfPart - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Footprint Filter - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_PanelFootprintFilter - 1 - - - protected - 1 - - - Resizable - - 1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - wxSUNKEN_BORDER|wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - bPanelFpFilterBoxSizer - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - - bFpFilterLeftBoxSizer - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Footprints - - - 0 - - - 0 - - 1 - m_staticTextFootprints - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - A list of footprints names that can be used for this component. Footprints names can used jockers. (like sm* to allow all footprints names starting by sm). - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_FootprintFilterListBox - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - - bFpFilterRightBoxSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_ADD_FOOTPRINT_FILTER - Add - - - 0 - - - 0 - - 1 - m_buttonAddFpF - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - AddFootprintFilter - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_DELETE_ONE_FOOTPRINT_FILTER - Delete - - - 0 - - - 0 - - 1 - m_ButtonDeleteOneFootprintFilter - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - DeleteOneFootprintFilter - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_DELETE_ALL_FOOTPRINT_FILTER - Delete All - - - 0 - - - 0 - - 1 - m_ButtonDeleteAllFootprintFilter - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - DeleteAllFootprintFilter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_stdSizerButton - protected - - OnCancelClick - - - - OnOkClick - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_edit_component_in_lib_base + 1000 + none + 1 + DIALOG_EDIT_COMPONENT_IN_LIBRARY_FBP + + . + + 1 + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + ID_LIBEDIT_NOTEBOOK + + + DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Lib Component Properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bUpperSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_NoteBook + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Options + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_PanelBasic + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxSUNKEN_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerBasicPanel + wxVERTICAL + none + + 5 + + 0 + + wxID_ANY + General : + + m_OptionsBoxSizer + wxVERTICAL + none + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + As Convert + + 0 + + + 0 + + 1 + m_AsConvertButt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option for components that have a De Morgan representation. This is usual for gates. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show Pin Num + + 0 + + + 0 + + 1 + m_ShowPinNumButt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Show or hide pin numbers + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show Pin Name + + 0 + + + 0 + + 1 + m_ShowPinNameButt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Show or hide pin names + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pin Name Inside + + 0 + + + 0 + + 1 + m_PinsNameInsideButt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option to have pin names inside the body and pin number outside. If not checked pins names and pins numbers are outside. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline3 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizerMidBasicPanel + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizernbunits + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Number of Units: + + 0 + + + 0 + + 1 + m_staticTextNbUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + This is the number of parts in this component package. A 74LS00 gate has 4 parts per packages. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 1 + 26 + + 0 + + 1 + + 0 + + 1 + m_SelNumberOfUnits + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer17 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Skew: + + 0 + + + 0 + + 1 + m_staticTextskew + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Margin (in 0.001 inches) between a pin name position and the component body. A value from 10 to 40 is usually good. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0 + 100 + + 0 + + 1 + + 0 + + 1 + m_SetSkew + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Power Symbol + + 0 + + + 0 + + 1 + m_OptionPower + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option for power symbols. Power symbols have specific properties for Eeschema: - Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol - Reference is updated automatically when a netlist is created (no need to run Annotate) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Parts are locked + + 0 + + + 0 + + 1 + m_OptionPartsLocked + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option if Eeschema cannot change parts selections inside a given package This happens when parts are different in this package. When this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Description + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_PanelDoc + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxSUNKEN_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_PanelDocBoxSizer + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Description: + + 0 + + + 0 + + 1 + m_staticTextDescription + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + A short description that is displayed in Eeschema. Can be a very good help when selecting components in libraries components lists. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_DocCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Keywords: + + 0 + + + 0 + + 1 + m_staticTextKeywords + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter key words that can be used to select this component. Key words cannot have spaces and are separated by a space. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_KeywordsCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + DocFileName: + + 0 + + + 0 + + 1 + m_staticTextDocFileName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter the documentation file (a .pdf document) associated to the component. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_DocfileCtrl + 1 + + + protected + 1 + + Resizable + 1 + 400,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL + 0 + + + bSizerPaneldocbutts + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_COPY_DOC_TO_ALIAS + Copy Doc + + 0 + + + 0 + + 1 + m_ButtonCopyDoc + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + CopyDocToAlias + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_BROWSE_DOC_FILES + Browse DocFiles + + 0 + + + 0 + + 1 + m_buttonBrowseDocFiles + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + BrowseAndSelectDocFile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Alias + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_PanelAlias + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxSUNKEN_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMainPanelAlias + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bLeftBoxSizerPanelAlias + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Alias List: + + 0 + + + 0 + + 1 + m_staticTextAlias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + An alias is a component that uses the body of its root component. It has its own documentation and keywords. A fast way to extend a library with similar components + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_PartAliasListCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + + bRightBoxSizerPanelAlias + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_ADD_ALIAS + Add + + 0 + + + 0 + + 1 + m_ButtonAddeAlias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + AddAliasOfPart + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_DELETE_ONE_ALIAS + Delete + + 0 + + + 0 + + 1 + m_ButtonDeleteOneAlias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + DeleteAliasOfPart + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_DELETE_ALL_ALIAS + Delete All + + 0 + + + 0 + + 1 + m_ButtonDeleteAllAlias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + DeleteAllAliasOfPart + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Footprint Filter + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_PanelFootprintFilter + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxSUNKEN_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bPanelFpFilterBoxSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bFpFilterLeftBoxSizer + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Footprints + + 0 + + + 0 + + 1 + m_staticTextFootprints + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + A list of footprints names that can be used for this component. Footprints names can used jockers. (like sm* to allow all footprints names starting by sm). + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_FootprintFilterListBox + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + + bFpFilterRightBoxSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_ADD_FOOTPRINT_FILTER + Add + + 0 + + + 0 + + 1 + m_buttonAddFpF + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + AddFootprintFilter + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_DELETE_ONE_FOOTPRINT_FILTER + Delete + + 0 + + + 0 + + 1 + m_ButtonDeleteOneFootprintFilter + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + DeleteOneFootprintFilter + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_DELETE_ALL_FOOTPRINT_FILTER + Delete All + + 0 + + + 0 + + 1 + m_ButtonDeleteAllFootprintFilter + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + DeleteAllFootprintFilter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_stdSizerButton + protected + + OnCancelClick + + + + OnOkClick + + + + + + + + diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.h b/eeschema/dialogs/dialog_edit_component_in_lib_base.h index b45283b44d..202202e8d6 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 30 2011) +// C++ code generated with wxFormBuilder (version Apr 11 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,7 @@ #include #include #include +#include "dialog_shim.h" #include #include #include @@ -47,7 +48,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog +class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public DIALOG_SHIM { private: @@ -106,7 +107,7 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog public: - DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 465,384 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(); }; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp index b103568505..3a99632ae6 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp @@ -1,2700 +1,2700 @@ - - - - - ; - C++ - 1 - source_name - 0 - res - ANSI - connect - dialog_edit_component_in_schematic_fbp - 1000 - none - 1 - - - . - - 1 - 1 - 0 - 0 - - 1 - 1 - 1 - 1 - 0 - - - - - 1 - - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - impl_virtual - - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP - 1 - - - 1 - - - Resizable - - 1 - 700,521 - wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU - - Component Properties - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - upperSizer - wxHORIZONTAL - none - - 5 - wxALIGN_TOP|wxALL|wxEXPAND - 0 - - wxID_ANY - Options - - optionsSizer - wxVERTICAL - none - - - 8 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - wxID_ANY - Unit - - unitSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - unitChoice - 1 - - - protected - 1 - - - Resizable - - 0 - 1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxLEFT|wxRIGHT|wxTOP|wxEXPAND - 0 - - - orientationSizer - wxHORIZONTAL - none - - 8 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - "0" "+90" "180" "-90" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Orientation (Degrees) - - 1 - - 0 - - - 0 - - 1 - orientationRadioBox - 1 - - - protected - 1 - - - Resizable - - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Select if the component is to be rotated when drawn - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxLEFT|wxRIGHT|wxTOP|wxEXPAND - 0 - - - mirrorSizer - wxHORIZONTAL - none - - 8 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - "Normal" "Mirror ---" "Mirror |" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Mirror - - 1 - - 0 - - - 0 - - 1 - mirrorRadioBox - 1 - - - protected - 1 - - - Resizable - - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Pick the graphical transformation to be used when displaying the component, if any - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP - 0 - - wxID_ANY - Chip Name - - chipnameSizer - wxHORIZONTAL - none - - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 32 - - 0 - - 1 - chipnameTextCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - The name of the symbol in the library from which this component came - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Convert - - - 0 - - - 0 - - 1 - convertCheckBox - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Use the alternate shape of this component. For gates, this is the "De Morgan" conversion - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Parts are locked - - - 0 - - - 0 - - 1 - partsAreLockedLabel - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset to Library Defaults - - - 0 - - - 0 - - 1 - defaultsButton - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Set position and style of fields and component orientation to default lib value. Fields texts are not modified. - - wxFILTER_NONE - wxDefaultValidator - - - - - SetInitCmp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 1 - - wxID_ANY - Fields - - fieldsSizer - wxHORIZONTAL - none - - - 8 - wxEXPAND|wxRIGHT|wxLEFT - 3 - - wxID_ANY - - - gridStaticBoxSizer - wxVERTICAL - none - - - 8 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - 220,-1 - 1 - fieldListCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnListItemDeselected - - - - OnListItemSelected - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Add Field - - - 0 - - - 0 - - 1 - addFieldButton - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Add a new custom field - - wxFILTER_NONE - wxDefaultValidator - - - - - addFieldButtonHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Delete Field - - - 0 - - - 0 - - 1 - deleteFieldButton - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Delete one of the optional fields - - wxFILTER_NONE - wxDefaultValidator - - - - - deleteFieldButtonHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Move Up - - - 0 - - - 0 - - 1 - moveUpButton - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Move the selected optional fields up one position - - wxFILTER_NONE - wxDefaultValidator - - - - - moveUpButtonHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 2 - - - fieldEditBoxSizer - wxVERTICAL - none - - 5 - wxEXPAND - 0 - - wxID_ANY - Text Justification: - - sbSizerOptions - wxHORIZONTAL - none - - - 5 - wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - "Left" "Center" "Right" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Horiz. Justify - - 1 - - 0 - - - 0 - - 1 - m_FieldHJustifyCtrl - 1 - - - protected - 1 - - - Resizable - - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - "Bottom" "Center" "Top" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Vert. Justify - - 1 - - 0 - - - 0 - - 1 - m_FieldVJustifyCtrl - 1 - - - protected - 1 - - - Resizable - - 2 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - wxID_ANY - Visibility - - visibilitySizer - wxHORIZONTAL - none - - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - - bShowRotateSizer - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show - - - 0 - - - 0 - - 1 - showCheckBox - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Check if you want this field visible - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Rotate - - - 0 - - - 0 - - 1 - rotateCheckBox - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - Check if you want this field's text rotated 90 degrees - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - "Normal" "Italic" "Bold" "Bold Italic" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Style: - - 1 - - 0 - - - 0 - - 1 - m_StyleRadioBox - 1 - - - protected - 1 - - - Resizable - - 3 - 1 - - wxRA_SPECIFY_COLS - - 0 - The style of the currently selected field's text in the schemati - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - fieldNameBoxSizer - wxVERTICAL - none - - 5 - - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field Name - - - 0 - - - 0 - - 1 - fieldNameLabel - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - fieldNameTextCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - The name of the currently selected field Some fixed fields names are not editable - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - fieldTextBoxSizer - wxVERTICAL - none - - 5 - - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field Value - - - 0 - - - 0 - - 1 - fieldValueLabel - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - fieldValueTextCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - The text (or value) of the currently selected field - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - textSizeBoxSizer - wxVERTICAL - none - - 5 - - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Size(") - - - 0 - - - 0 - - 1 - textSizeLabel - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - textSizeTextCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - The size of the currently selected field's text in the schematic - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - - positionBoxSizer - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 1 - - - posXBoxSizer - wxVERTICAL - none - - 5 - - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - PosX(") - - - 0 - - - 0 - - 1 - posXLabel - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - posXTextCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - The X coordinate of the text relative to the component - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 1 - - - posYBoxSizer - wxVERTICAL - none - - 5 - - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - PosY(") - - - 0 - - - 0 - - 1 - posYLabel - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - 0 - - 1 - posYTextCtrl - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - The Y coordinate of the text relative to the component - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - stdDialogButtonSizer - protected - - OnCancelButtonClick - - - - OnOKButtonClick - - - - - - - - + + + + + ; + C++ + 1 + source_name + 0 + res + ANSI + connect + dialog_edit_component_in_schematic_fbp + 1000 + none + 1 + + + . + + 1 + 1 + 0 + 0 + + 1 + 1 + 1 + 1 + 0 + + + + + 1 + + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + impl_virtual + + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP + 1 + + + 1 + + + Resizable + + 1 + 700,521 + wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU + + Component Properties + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mainSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + upperSizer + wxHORIZONTAL + none + + 5 + wxALIGN_TOP|wxALL|wxEXPAND + 0 + + wxID_ANY + Options + + optionsSizer + wxVERTICAL + none + + + 8 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + wxID_ANY + Unit + + unitSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + unitChoice + 1 + + + protected + 1 + + + Resizable + + 0 + 1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxLEFT|wxRIGHT|wxTOP|wxEXPAND + 0 + + + orientationSizer + wxHORIZONTAL + none + + 8 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + "0" "+90" "180" "-90" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Orientation (Degrees) + + 1 + + 0 + + + 0 + + 1 + orientationRadioBox + 1 + + + protected + 1 + + + Resizable + + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Select if the component is to be rotated when drawn + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxLEFT|wxRIGHT|wxTOP|wxEXPAND + 0 + + + mirrorSizer + wxHORIZONTAL + none + + 8 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + "Normal" "Mirror ---" "Mirror |" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Mirror + + 1 + + 0 + + + 0 + + 1 + mirrorRadioBox + 1 + + + protected + 1 + + + Resizable + + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Pick the graphical transformation to be used when displaying the component, if any + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 0 + + wxID_ANY + Chip Name + + chipnameSizer + wxHORIZONTAL + none + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 32 + + 0 + + 1 + chipnameTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + The name of the symbol in the library from which this component came + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Convert + + + 0 + + + 0 + + 1 + convertCheckBox + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Use the alternate shape of this component. For gates, this is the "De Morgan" conversion + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Parts are locked + + + 0 + + + 0 + + 1 + partsAreLockedLabel + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reset to Library Defaults + + + 0 + + + 0 + + 1 + defaultsButton + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Set position and style of fields and component orientation to default lib value. Fields texts are not modified. + + wxFILTER_NONE + wxDefaultValidator + + + + + SetInitCmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + wxID_ANY + Fields + + fieldsSizer + wxHORIZONTAL + none + + + 8 + wxEXPAND|wxRIGHT|wxLEFT + 3 + + wxID_ANY + + + gridStaticBoxSizer + wxVERTICAL + none + + + 8 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + 220,-1 + 1 + fieldListCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnListItemDeselected + + + + OnListItemSelected + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Add Field + + + 0 + + + 0 + + 1 + addFieldButton + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Add a new custom field + + wxFILTER_NONE + wxDefaultValidator + + + + + addFieldButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Delete Field + + + 0 + + + 0 + + 1 + deleteFieldButton + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Delete one of the optional fields + + wxFILTER_NONE + wxDefaultValidator + + + + + deleteFieldButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move Up + + + 0 + + + 0 + + 1 + moveUpButton + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Move the selected optional fields up one position + + wxFILTER_NONE + wxDefaultValidator + + + + + moveUpButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 2 + + + fieldEditBoxSizer + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + wxID_ANY + Text Justification: + + sbSizerOptions + wxHORIZONTAL + none + + + 5 + wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + "Left" "Center" "Right" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Horiz. Justify + + 1 + + 0 + + + 0 + + 1 + m_FieldHJustifyCtrl + 1 + + + protected + 1 + + + Resizable + + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + "Bottom" "Center" "Top" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Vert. Justify + + 1 + + 0 + + + 0 + + 1 + m_FieldVJustifyCtrl + 1 + + + protected + 1 + + + Resizable + + 2 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP + 0 + + wxID_ANY + Visibility + + visibilitySizer + wxHORIZONTAL + none + + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + + bShowRotateSizer + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show + + + 0 + + + 0 + + 1 + showCheckBox + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Check if you want this field visible + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Rotate + + + 0 + + + 0 + + 1 + rotateCheckBox + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + Check if you want this field's text rotated 90 degrees + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + "Normal" "Italic" "Bold" "Bold Italic" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Style: + + 1 + + 0 + + + 0 + + 1 + m_StyleRadioBox + 1 + + + protected + 1 + + + Resizable + + 3 + 1 + + wxRA_SPECIFY_COLS + + 0 + The style of the currently selected field's text in the schemati + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + fieldNameBoxSizer + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field Name + + + 0 + + + 0 + + 1 + fieldNameLabel + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + 0 + + 1 + fieldNameTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + The name of the currently selected field Some fixed fields names are not editable + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + fieldTextBoxSizer + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field Value + + + 0 + + + 0 + + 1 + fieldValueLabel + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + 0 + + 1 + fieldValueTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + The text (or value) of the currently selected field + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + textSizeBoxSizer + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Size(") + + + 0 + + + 0 + + 1 + textSizeLabel + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + 0 + + 1 + textSizeTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + The size of the currently selected field's text in the schematic + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + positionBoxSizer + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 1 + + + posXBoxSizer + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + PosX(") + + + 0 + + + 0 + + 1 + posXLabel + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + 0 + + 1 + posXTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + The X coordinate of the text relative to the component + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + + posYBoxSizer + wxVERTICAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + PosY(") + + + 0 + + + 0 + + 1 + posYLabel + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + 0 + + 1 + posYTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + The Y coordinate of the text relative to the component + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + stdDialogButtonSizer + protected + + OnCancelButtonClick + + + + OnOKButtonClick + + + + + + + + diff --git a/eeschema/dialogs/dialog_lib_new_component.fbp b/eeschema/dialogs/dialog_lib_new_component.fbp index 21b0b26092..54660f05a6 100644 --- a/eeschema/dialogs/dialog_lib_new_component.fbp +++ b/eeschema/dialogs/dialog_lib_new_component.fbp @@ -1,1307 +1,1899 @@ - - - - - - C++ - 1 - UTF-8 - table - dialog_lib_new_component_base - 1000 - none - 1 - dialog_lib_new_component - - . - - 1 - 1 - 0 - - - wxBOTH - - 1 - - - - 0 - wxID_ANY - - - DIALOG_LIB_NEW_COMPONENT_BASE - - - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - Component Properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mainSizer - wxHORIZONTAL - none - - 12 - wxALL|wxEXPAND - 1 - - - bSizer5 - wxVERTICAL - none - - 3 - wxALIGN_LEFT - 0 - - - - 1 - - ,90,92,-1,70,0 - 0 - wxID_ANY - General Settings - - - m_staticText6 - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer2 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - Component &name: - - - m_staticText2 - protected - - - - - This is the component name in library, and also the default component value when loaded in the schematic. - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - - 0 - - m_textName - protected - - 100,-1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxEXPAND - 0 - - 0 - protected - 30 - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer3 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - Default &reference designator: - - - m_staticText3 - protected - - - - - This is the reference used in schematic for annotation. Do not use digits in reference. - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - - 0 - - m_textReference - protected - - 100,-1 - - - - U - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 0 - protected - 30 - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer4 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - Number of &parts per package: - - - m_staticText4 - protected - - - - - This is the number of parts in this component package. A 74LS00 gate has 4 parts per packages. - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - 0 - 26 - - 1 - - m_spinPartCount - protected - - 100,-1 - wxSP_ARROW_KEYS - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxEXPAND - 0 - - 0 - protected - 30 - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer7 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Create component with &alternate body style (DeMorgan) - - - m_checkHasConversion - protected - - - - - Check this option for components that have a De Morgan representation. This is usual for gates. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer8 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Create component as power &symbol - - - m_checkIsPowerSymbol - protected - - - - - Check this option for power symbols. Power symbols have specific properties for Eeschema: - Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol - Reference is updated automatically when a netlist is created (no need to run Annotate) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer9 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Parts in package locked (cannot be swapped) - - - m_checkLockItems - protected - - - - - Check this option if Eeschema cannot change parts selections inside a given package This happens when parts are different in this package. When this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 - wxALL|wxEXPAND - 0 - - 0 - protected - 0 - - - - 3 - wxALIGN_LEFT|wxBOTTOM - 0 - - - - 1 - - ,90,92,-1,70,0 - 0 - wxID_ANY - Global Pin Settings - - - m_staticText7 - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 1 - - - bSizer6 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - Pin text position &offset: - - - m_staticText41 - protected - - - - - Margin (in 0.001 inches) between a pin name position and the component body. A value from 10 to 40 is usually good. - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 0 - wxID_ANY - 40 - 100 - - 1 - - m_spinPinTextPosition - protected - - 100,-1 - wxSP_ARROW_KEYS - - - 40 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL - 0 - - - - 1 - - - 0 - wxID_ANY - mils - - - m_staticText5 - protected - - 30,-1 - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer10 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - 1 - - 1 - - - 0 - wxID_ANY - Show pin n&umber text - - - m_checkShowPinNumber - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer12 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - 1 - - 1 - - - 0 - wxID_ANY - Show pin name te&xt - - - m_checkShowPinName - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bSizer121 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - 1 - - 1 - - - 0 - wxID_ANY - Pin name &inside - - - m_checkShowPinNameInside - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 - wxALL|wxEXPAND - 0 - - 5 - protected - 0 - - - - 0 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + table + dialog_lib_new_component_base + 1000 + none + 1 + dialog_lib_new_component + + . + + 1 + 1 + 1 + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_LIB_NEW_COMPONENT_BASE + + + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Component Properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mainSizer + wxHORIZONTAL + none + + 12 + wxALL|wxEXPAND + 1 + + + bSizer5 + wxVERTICAL + none + + 3 + wxALIGN_LEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + General Settings + + 0 + + + 0 + + 1 + m_staticText6 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer2 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Component &name: + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + This is the component name in library, and also the default component value when loaded in the schematic. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textName + 1 + + + protected + 1 + + Resizable + 1 + 100,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxEXPAND + 0 + + 0 + protected + 30 + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer3 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Default &reference designator: + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + This is the reference used in schematic for annotation. Do not use digits in reference. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textReference + 1 + + + protected + 1 + + Resizable + 1 + 100,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + U + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 0 + protected + 30 + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer4 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Number of &parts per package: + + 0 + + + 0 + + 1 + m_staticText4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + This is the number of parts in this component package. A 74LS00 gate has 4 parts per packages. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0 + 26 + + 0 + + 1 + + 0 + + 1 + m_spinPartCount + 1 + + + protected + 1 + + Resizable + 1 + 100,-1 + wxSP_ARROW_KEYS + + 0 + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxEXPAND + 0 + + 0 + protected + 30 + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer7 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Create component with &alternate body style (DeMorgan) + + 0 + + + 0 + + 1 + m_checkHasConversion + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option for components that have a De Morgan representation. This is usual for gates. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer8 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Create component as power &symbol + + 0 + + + 0 + + 1 + m_checkIsPowerSymbol + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option for power symbols. Power symbols have specific properties for Eeschema: - Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol - Reference is updated automatically when a netlist is created (no need to run Annotate) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer9 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Parts in package locked (cannot be swapped) + + 0 + + + 0 + + 1 + m_checkLockItems + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option if Eeschema cannot change parts selections inside a given package This happens when parts are different in this package. When this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxALL|wxEXPAND + 0 + + 0 + protected + 0 + + + + 3 + wxALIGN_LEFT|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Global Pin Settings + + 0 + + + 0 + + 1 + m_staticText7 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxEXPAND + 1 + + + bSizer6 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pin text position &offset: + + 0 + + + 0 + + 1 + m_staticText41 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Margin (in 0.001 inches) between a pin name position and the component body. A value from 10 to 40 is usually good. + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 40 + 100 + + 0 + + 1 + + 0 + + 1 + m_spinPinTextPosition + 1 + + + protected + 1 + + Resizable + 1 + 100,-1 + wxSP_ARROW_KEYS + + 0 + + 40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mils + + 0 + + + 0 + + 1 + m_staticText5 + 1 + + + protected + 1 + + Resizable + 1 + 30,-1 + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer10 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show pin n&umber text + + 0 + + + 0 + + 1 + m_checkShowPinNumber + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxEXPAND + 0 + + + bSizer12 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show pin name te&xt + + 0 + + + 0 + + 1 + m_checkShowPinName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer121 + wxHORIZONTAL + none + + 3 + wxEXPAND + 0 + + 0 + protected + 12 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pin name &inside + + 0 + + + 0 + + 1 + m_checkShowPinNameInside + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxALL|wxEXPAND + 0 + + 5 + protected + 0 + + + + 0 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_lib_new_component_base.cpp b/eeschema/dialogs/dialog_lib_new_component_base.cpp index 350860ee53..37f30b736c 100644 --- a/eeschema/dialogs/dialog_lib_new_component_base.cpp +++ b/eeschema/dialogs/dialog_lib_new_component_base.cpp @@ -1,233 +1,240 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_lib_new_component_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* mainSizer; - mainSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxVERTICAL ); - - m_staticText6 = new wxStaticText( this, wxID_ANY, _("General Settings"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText6->Wrap( -1 ); - m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bSizer5->Add( m_staticText6, 0, wxALIGN_LEFT, 3 ); - - wxBoxSizer* bSizer2; - bSizer2 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer2->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Component &name:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - m_staticText2->SetToolTip( _("This is the component name in library,\nand also the default component value when loaded in the schematic.") ); - - bSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer2->Add( 0, 0, 1, wxEXPAND, 3 ); - - m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), 0 ); - bSizer2->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer2->Add( 30, 0, 0, wxEXPAND, 3 ); - - bSizer5->Add( bSizer2, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer3; - bSizer3 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer3->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_staticText3 = new wxStaticText( this, wxID_ANY, _("Default &reference designator:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText3->Wrap( -1 ); - m_staticText3->SetToolTip( _("This is the reference used in schematic for annotation.\nDo not use digits in reference.") ); - - bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_textReference = new wxTextCtrl( this, wxID_ANY, _("U"), wxDefaultPosition, wxSize( 100,-1 ), 0 ); - bSizer3->Add( m_textReference, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer3->Add( 30, 0, 0, wxEXPAND, 5 ); - - bSizer5->Add( bSizer3, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer4; - bSizer4 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer4->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_staticText4 = new wxStaticText( this, wxID_ANY, _("Number of &parts per package:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText4->Wrap( -1 ); - m_staticText4->SetToolTip( _("This is the number of parts in this component package.\nA 74LS00 gate has 4 parts per packages.") ); - - bSizer4->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer4->Add( 0, 0, 1, wxEXPAND, 3 ); - - m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 26, 0 ); - bSizer4->Add( m_spinPartCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer4->Add( 30, 0, 0, wxEXPAND, 3 ); - - bSizer5->Add( bSizer4, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer7->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkHasConversion = new wxCheckBox( this, wxID_ANY, _("Create component with &alternate body style (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_checkHasConversion->SetToolTip( _("Check this option for components that have a De Morgan representation.\nThis is usual for gates.") ); - - bSizer7->Add( m_checkHasConversion, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - bSizer5->Add( bSizer7, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer8->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkIsPowerSymbol = new wxCheckBox( this, wxID_ANY, _("Create component as power &symbol"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_checkIsPowerSymbol->SetToolTip( _("Check this option for power symbols.\nPower symbols have specific properties for Eeschema:\n- Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol\n- Reference is updated automatically when a netlist is created (no need to run Annotate)") ); - - bSizer8->Add( m_checkIsPowerSymbol, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - bSizer5->Add( bSizer8, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer9; - bSizer9 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer9->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Parts in package locked (cannot be swapped)"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_checkLockItems->SetToolTip( _("Check this option if Eeschema cannot change parts selections inside a given package\nThis happens when parts are different in this package.\nWhen this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count") ); - - bSizer9->Add( m_checkLockItems, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - bSizer5->Add( bSizer9, 0, wxALL|wxEXPAND, 0 ); - - - bSizer5->Add( 0, 0, 0, wxALL|wxEXPAND, 10 ); - - m_staticText7 = new wxStaticText( this, wxID_ANY, _("Global Pin Settings"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText7->Wrap( -1 ); - m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bSizer5->Add( m_staticText7, 0, wxALIGN_LEFT|wxBOTTOM, 3 ); - - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer6->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_staticText41 = new wxStaticText( this, wxID_ANY, _("Pin text position &offset:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText41->Wrap( -1 ); - m_staticText41->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") ); - - bSizer6->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer6->Add( 0, 0, 1, wxEXPAND, 3 ); - - m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 100, 40 ); - bSizer6->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - m_staticText5 = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxSize( 30,-1 ), 0 ); - m_staticText5->Wrap( -1 ); - bSizer6->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL, 3 ); - - bSizer5->Add( bSizer6, 1, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer10; - bSizer10 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer10->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkShowPinNumber = new wxCheckBox( this, wxID_ANY, _("Show pin n&umber text"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkShowPinNumber->SetValue(true); - - bSizer10->Add( m_checkShowPinNumber, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - bSizer5->Add( bSizer10, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer12; - bSizer12 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer12->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkShowPinName = new wxCheckBox( this, wxID_ANY, _("Show pin name te&xt"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkShowPinName->SetValue(true); - - bSizer12->Add( m_checkShowPinName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - bSizer5->Add( bSizer12, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer121; - bSizer121 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer121->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name &inside"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkShowPinNameInside->SetValue(true); - - bSizer121->Add( m_checkShowPinNameInside, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - bSizer5->Add( bSizer121, 1, wxEXPAND, 5 ); - - - bSizer5->Add( 0, 5, 0, wxALL|wxEXPAND, 10 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - bSizer5->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 0 ); - - mainSizer->Add( bSizer5, 1, wxALL|wxEXPAND, 12 ); - - this->SetSizer( mainSizer ); - this->Layout(); - mainSizer->Fit( this ); - - this->Centre( wxBOTH ); -} - -DIALOG_LIB_NEW_COMPONENT_BASE::~DIALOG_LIB_NEW_COMPONENT_BASE() -{ -} +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 11 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_lib_new_component_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* mainSizer; + mainSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxVERTICAL ); + + m_staticText6 = new wxStaticText( this, wxID_ANY, _("General Settings"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText6->Wrap( -1 ); + m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + + bSizer5->Add( m_staticText6, 0, wxALIGN_LEFT, 3 ); + + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer2->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_staticText2 = new wxStaticText( this, wxID_ANY, _("Component &name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText2->Wrap( -1 ); + m_staticText2->SetToolTip( _("This is the component name in library,\nand also the default component value when loaded in the schematic.") ); + + bSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer2->Add( 0, 0, 1, wxEXPAND, 3 ); + + m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), 0 ); + bSizer2->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer2->Add( 30, 0, 0, wxEXPAND, 3 ); + + + bSizer5->Add( bSizer2, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer3->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_staticText3 = new wxStaticText( this, wxID_ANY, _("Default &reference designator:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText3->Wrap( -1 ); + m_staticText3->SetToolTip( _("This is the reference used in schematic for annotation.\nDo not use digits in reference.") ); + + bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_textReference = new wxTextCtrl( this, wxID_ANY, _("U"), wxDefaultPosition, wxSize( 100,-1 ), 0 ); + bSizer3->Add( m_textReference, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer3->Add( 30, 0, 0, wxEXPAND, 5 ); + + + bSizer5->Add( bSizer3, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer4->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_staticText4 = new wxStaticText( this, wxID_ANY, _("Number of &parts per package:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText4->Wrap( -1 ); + m_staticText4->SetToolTip( _("This is the number of parts in this component package.\nA 74LS00 gate has 4 parts per packages.") ); + + bSizer4->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer4->Add( 0, 0, 1, wxEXPAND, 3 ); + + m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 26, 0 ); + bSizer4->Add( m_spinPartCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer4->Add( 30, 0, 0, wxEXPAND, 3 ); + + + bSizer5->Add( bSizer4, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer7->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_checkHasConversion = new wxCheckBox( this, wxID_ANY, _("Create component with &alternate body style (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkHasConversion->SetToolTip( _("Check this option for components that have a De Morgan representation.\nThis is usual for gates.") ); + + bSizer7->Add( m_checkHasConversion, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer5->Add( bSizer7, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer8; + bSizer8 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer8->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_checkIsPowerSymbol = new wxCheckBox( this, wxID_ANY, _("Create component as power &symbol"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkIsPowerSymbol->SetToolTip( _("Check this option for power symbols.\nPower symbols have specific properties for Eeschema:\n- Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol\n- Reference is updated automatically when a netlist is created (no need to run Annotate)") ); + + bSizer8->Add( m_checkIsPowerSymbol, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer5->Add( bSizer8, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer9->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Parts in package locked (cannot be swapped)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkLockItems->SetToolTip( _("Check this option if Eeschema cannot change parts selections inside a given package\nThis happens when parts are different in this package.\nWhen this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count") ); + + bSizer9->Add( m_checkLockItems, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer5->Add( bSizer9, 0, wxALL|wxEXPAND, 0 ); + + + bSizer5->Add( 0, 0, 0, wxALL|wxEXPAND, 10 ); + + m_staticText7 = new wxStaticText( this, wxID_ANY, _("Global Pin Settings"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText7->Wrap( -1 ); + m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + + bSizer5->Add( m_staticText7, 0, wxALIGN_LEFT|wxBOTTOM, 3 ); + + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer6->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_staticText41 = new wxStaticText( this, wxID_ANY, _("Pin text position &offset:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText41->Wrap( -1 ); + m_staticText41->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") ); + + bSizer6->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer6->Add( 0, 0, 1, wxEXPAND, 3 ); + + m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 100, 40 ); + bSizer6->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_staticText5 = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxSize( 30,-1 ), 0 ); + m_staticText5->Wrap( -1 ); + bSizer6->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL, 3 ); + + + bSizer5->Add( bSizer6, 1, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer10; + bSizer10 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer10->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_checkShowPinNumber = new wxCheckBox( this, wxID_ANY, _("Show pin n&umber text"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkShowPinNumber->SetValue(true); + bSizer10->Add( m_checkShowPinNumber, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer5->Add( bSizer10, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer12; + bSizer12 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer12->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_checkShowPinName = new wxCheckBox( this, wxID_ANY, _("Show pin name te&xt"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkShowPinName->SetValue(true); + bSizer12->Add( m_checkShowPinName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer5->Add( bSizer12, 0, wxALL|wxEXPAND, 0 ); + + wxBoxSizer* bSizer121; + bSizer121 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer121->Add( 12, 0, 0, wxEXPAND, 3 ); + + m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name &inside"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkShowPinNameInside->SetValue(true); + bSizer121->Add( m_checkShowPinNameInside, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + + bSizer5->Add( bSizer121, 1, wxEXPAND, 5 ); + + + bSizer5->Add( 0, 5, 0, wxALL|wxEXPAND, 10 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerOK = new wxButton( this, wxID_OK ); + m_sdbSizer->AddButton( m_sdbSizerOK ); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + bSizer5->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 0 ); + + + mainSizer->Add( bSizer5, 1, wxALL|wxEXPAND, 12 ); + + + this->SetSizer( mainSizer ); + this->Layout(); + mainSizer->Fit( this ); + + this->Centre( wxBOTH ); +} + +DIALOG_LIB_NEW_COMPONENT_BASE::~DIALOG_LIB_NEW_COMPONENT_BASE() +{ +} diff --git a/eeschema/dialogs/dialog_lib_new_component_base.h b/eeschema/dialogs/dialog_lib_new_component_base.h index d9b410610a..8c6846745e 100644 --- a/eeschema/dialogs/dialog_lib_new_component_base.h +++ b/eeschema/dialogs/dialog_lib_new_component_base.h @@ -1,82 +1,66 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __dialog_lib_new_component_base__ -#define __dialog_lib_new_component_base__ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LIB_NEW_COMPONENT_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_LIB_NEW_COMPONENT_BASE : public wxDialog -{ - private: - - protected: - wxStaticText* m_staticText6; - - wxStaticText* m_staticText2; - - wxTextCtrl* m_textName; - - - wxStaticText* m_staticText3; - - wxTextCtrl* m_textReference; - - - wxStaticText* m_staticText4; - - wxSpinCtrl* m_spinPartCount; - - - wxCheckBox* m_checkHasConversion; - - wxCheckBox* m_checkIsPowerSymbol; - - wxCheckBox* m_checkLockItems; - - wxStaticText* m_staticText7; - - wxStaticText* m_staticText41; - - wxSpinCtrl* m_spinPinTextPosition; - wxStaticText* m_staticText5; - - wxCheckBox* m_checkShowPinNumber; - - wxCheckBox* m_checkShowPinName; - - wxCheckBox* m_checkShowPinNameInside; - - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - public: - DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_LIB_NEW_COMPONENT_BASE(); - -}; - -#endif //__dialog_lib_new_component_base__ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 11 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_LIB_NEW_COMPONENT_BASE_H__ +#define __DIALOG_LIB_NEW_COMPONENT_BASE_H__ + +#include +#include +#include +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_LIB_NEW_COMPONENT_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_LIB_NEW_COMPONENT_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxStaticText* m_staticText6; + wxStaticText* m_staticText2; + wxTextCtrl* m_textName; + wxStaticText* m_staticText3; + wxTextCtrl* m_textReference; + wxStaticText* m_staticText4; + wxSpinCtrl* m_spinPartCount; + wxCheckBox* m_checkHasConversion; + wxCheckBox* m_checkIsPowerSymbol; + wxCheckBox* m_checkLockItems; + wxStaticText* m_staticText7; + wxStaticText* m_staticText41; + wxSpinCtrl* m_spinPinTextPosition; + wxStaticText* m_staticText5; + wxCheckBox* m_checkShowPinNumber; + wxCheckBox* m_checkShowPinName; + wxCheckBox* m_checkShowPinNameInside; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; + + public: + + DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_LIB_NEW_COMPONENT_BASE(); + +}; + +#endif //__DIALOG_LIB_NEW_COMPONENT_BASE_H__ diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index fe4d61ef63..b130655020 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -50,7 +50,7 @@ #include #include -#include +//#include #include #include diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 3c8abc128f..43b46d5c16 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -296,13 +296,6 @@ public: */ bool SetZoom( double coeff ); - /** - * Function SetZoomList - * sets the list of zoom factors. - * @param aZoomList An array of zoom factors in ascending order, zero terminated - */ - void SetZoomList( const wxArrayDouble& aZoomList ); - bool SetNextZoom(); bool SetPreviousZoom(); bool SetFirstZoom(); diff --git a/include/dialog_helpers.h b/include/dialog_helpers.h index 720fa2b498..380f3f9096 100644 --- a/include/dialog_helpers.h +++ b/include/dialog_helpers.h @@ -182,72 +182,4 @@ public: } }; - -/** - * Template DIALOG_SHIM - * is a way to have a common way of handling KiCad dialog windows: - *
    - *
  • class specific: static s_LastPos and static s_LastSize for retentative - * dialog window positioning, per class. - *
  • invocation of SetFocus() to allow ESC key to work on Linux. - *
  • future others... - *
- * by wedging in a class (a SHIM) between the wxFormbuilder coded base class and - * our derived dialog classes. Use it via the macro named DIALOG_EXTEND_WITH_SHIM - * and be sure to code your constructor to invoke *_SHIM() base class constructor, - * not the one from wxFormbuilder. - * @author Dick Hollenbeck - */ -template -class DIALOG_SHIM : public T -{ -public: - - DIALOG_SHIM( wxFrame* aParent ) : - T( aParent ) - { - wxDialog::SetFocus(); - } - - // overload wxDialog::Show - bool Show( bool show ) - { - bool ret; - - if( show ) - { - ret = wxDialog::Show( show ); - if( s_LastPos.x != -1 ) - wxDialog::SetSize( s_LastPos.x, s_LastPos.y, s_LastSize.x, s_LastSize.y, 0 ); - } - else - { - // Save the dialog's position before hiding - s_LastPos = wxDialog::GetPosition(); - s_LastSize = wxDialog::GetSize(); - ret = wxDialog::Show( show ); - } - return ret; - } - -private: - static wxPoint s_LastPos; - static wxSize s_LastSize; -}; - -template -wxPoint DIALOG_SHIM::s_LastPos( -1, -1 ); - -template -wxSize DIALOG_SHIM::s_LastSize( 0, 0 ); - -/** - * Macro DIALOG_EXTEND_WITH_SHIM - * instantiates the template DIALOG_SHIM<> and thereby declares a shim class. - * @author Dick Hollenbeck - */ -#define DIALOG_EXTEND_WITH_SHIM( DERRIVED, BASE ) \ - typedef DIALOG_SHIM BASE##_SHIM; \ - class DERRIVED : public BASE##_SHIM - #endif // DIALOG_HELPERS_H_ diff --git a/include/footprint_info.h b/include/footprint_info.h index dddefde175..4684e34092 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -32,6 +32,7 @@ public: } }; + class FOOTPRINT_LIST { public: diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 670dd11a38..20f339e4db 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -3,13 +3,8 @@ * @brief Classes and definitions used in Pcbnew. */ -#ifndef PCBSTRUCT_H -#define PCBSTRUCT_H - - -// Definitions relatives aux libraries -#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1" -#define FOOTPRINT_LIBRARY_HEADER_CNT 18 +#ifndef PCBSTRUCT_H_ +#define PCBSTRUCT_H_ /// Values for m_DisplayViaMode member: @@ -83,4 +78,4 @@ public: DISPLAY_OPTIONS(); }; -#endif // PCBSTRUCT_H +#endif // PCBSTRUCT_H_ diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 7911bfbb99..547a57beee 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -96,7 +96,7 @@ set(PCBNEW_SRCS block.cpp block_module_editor.cpp build_BOM_from_board.cpp - class_footprint_library.cpp +# class_footprint_library.cpp class_pcb_layer_widget.cpp clean.cpp connect.cpp diff --git a/pcbnew/class_footprint_library.cpp b/pcbnew/class_footprint_library.cpp.notused similarity index 100% rename from pcbnew/class_footprint_library.cpp rename to pcbnew/class_footprint_library.cpp.notused diff --git a/pcbnew/class_footprint_library.h b/pcbnew/class_footprint_library.h.notused similarity index 90% rename from pcbnew/class_footprint_library.h rename to pcbnew/class_footprint_library.h.notused index c834f53e90..e4a0090da4 100644 --- a/pcbnew/class_footprint_library.h +++ b/pcbnew/class_footprint_library.h.notused @@ -11,15 +11,16 @@ class FOOTPRINT_LIBRARY public: wxArrayString m_List; // list of footprints, used to read/write INDEX section wxString m_LibraryName; // the full library name - int m_LineNum; // the line count private: FILTER_READER * m_reader; // FILTER_READER to read file. If NULL, use m_file FILE * m_file; // footprint file to read/write. + int m_LineNum; // the line count public: + /** - * ctor + * Constructor FOOTPRINT_LIBRARY * @param aFile = a FILE * pointer used for write operations, * and read operations when aReader = NULL * @param aReader = a FILTER_READER pointer used for read operations @@ -27,7 +28,11 @@ public: */ FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader = NULL ); - ~FOOTPRINT_LIBRARY() { } + FOOTPRINT_LIBRARY() : + m_reader( 0 ), + m_file( 0 ), + m_LineNum( 0 ) + {} /** * function IsLibrary diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 24014e6ebc..246fc04953 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -332,6 +332,12 @@ public: */ D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS ); + /** + * GetPadCount + * returns the number of pads. + */ + unsigned GetPadCount() const { return m_Pads.GetCount() ; } + SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ); diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 26213ea229..21fdf370f9 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -18,23 +18,40 @@ #include -/* Default Pcbnew zoom values. - * Limited to 19 values to keep a decent size to menus - * 15 it better but does not allow a sufficient number of values - * roughtly a 1.5 progression. - * The last 2 values is handy when somebody uses a library import of a module - * (or foreign data) which has a bad coordinate - * Also useful in GerbView for this reason. - * Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic - * functions ) - */ +/** + Default Pcbnew zoom values. + Limited to 19 values to keep a decent size to menus. + Roughly a 1.5 progression. + The last 2 values are handy when somebody uses a library import of a module + (or foreign data) which has a bad coordinate. + Also useful in GerbView for this reason. + Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic + functions ) +*/ static const double pcbZoomList[] = { - 0.5, 1.0, 1.5, 2.0, 3.0, 4.5, 7.0, - 10.0, 15.0, 22.0, 35.0, 50.0, 80.0, 120.0, - 200.0, 350.0, 500.0, 1000.0, 2000.0 + 0.5, + 1.0, + 1.5, + 2.0, + 3.0, + 4.5, + 7.0, + 10.0, + 15.0, + 22.0, + 35.0, + 50.0, + 80.0, + 120.0, + 200.0, + 350.0, + 500.0, + 1000.0, + 2000.0 }; + #define MM_TO_PCB_UNITS (10000.0 / 25.4) @@ -63,9 +80,9 @@ static GRID_TYPE pcbGridList[] = { ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) }, { ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) }, { ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) }, - { ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) }, - { ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) }, - { ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) } + { ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) }, + { ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) }, + { ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) } }; diff --git a/pcbnew/io_mgr.cpp b/pcbnew/io_mgr.cpp index 8a262181d8..4b8e2fac40 100644 --- a/pcbnew/io_mgr.cpp +++ b/pcbnew/io_mgr.cpp @@ -28,6 +28,10 @@ #include +#define FMT_UNIMPLEMENTED _( "Plugin '%s' does not implement the '%s' function." ) +#define FMT_NOTFOUND _( "Plugin type '%s' is not found." ) + + // Some day plugins might be in separate DLL/DSOs, simply because of numbers of them // and code size. Until then, use the simplest method: @@ -40,8 +44,8 @@ // plugins coexisting. -// static LEGACY_PLUGIN kicad_plugin; // a secret -//static EAGLE_PLUGIN eagle_plugin; +// static LEGACY_PLUGIN kicad_plugin; +// static EAGLE_PLUGIN eagle_plugin; PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType ) { @@ -118,7 +122,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual } - THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) ); + THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) ); } @@ -133,25 +137,56 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar return; } - THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) ); + THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) ); } BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties ) { - // not pure virtual so that plugins only have to implement subset of the PLUGIN interface, - // e.g. Load() or Save() but not both. - - THROW_IO_ERROR( wxString::Format( - _( "Plugin %s does not implement the BOARD Load() function." ), PluginName().GetData() ) ); + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) ); } void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties ) { - // not pure virtual so that plugins only have to implement subset of the PLUGIN interface, - // e.g. Load() or Save() but not both. - - THROW_IO_ERROR( wxString::Format( - _( "Plugin %s does not implement the BOARD Save() function." ), PluginName().GetData() ) ); + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) ); } + + +wxArrayString PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + + +MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, + PROPERTIES* aProperties ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + + +void PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + + +void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + + +bool PLUGIN::IsLibraryWritable( const wxString& aLibraryPath ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 4acaa27940..67d88d2bf1 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -30,6 +30,7 @@ class BOARD; class PLUGIN; +class MODULE; /** @@ -237,13 +238,102 @@ public: virtual void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); + /** + * Function FootprintEnumerate + * returns a list of footprint names contained within the library at @a aLibraryPath. + * + * @param aLibraryPath is locator for the "library", usually a directory + * or file containing several footprints. + * + * @param aProperties is an associative array that can be used to tell the + * plugin how to access the library. + * The caller continues to own this object (plugin may not delete it), and + * plugins should expect it to be optionally NULL. + * + * @return wxArrayString - is the array of available footprint names inside + * a library + * + * @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded. + */ + virtual wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL); + + /** + * Function FootprintLoad + * loads a MODULE having @a aFootprintName from the @a aLibraryPath containing + * a library format that this PLUGIN knows about. + * + * @param aLibraryPath is locator for the "library", usually a directory + * or file containing several footprints. + * + * @param aFootprintName is the name of the footprint to load. + * + * @param aProperties is an associative array that can be used to tell the + * saver how to save the file, because it can take any number of + * additional named tuning arguments that the plugin is known to support. + * The caller continues to own this object (plugin may not delete it), and + * plugins should expect it to be optionally NULL. + * + * @return MODULE* - caller owns it. Never NULL because exception thrown if error. + * + * @throw IO_ERROR if the PLUGIN cannot be found, library cannot be found, + * or footprint cannot be loaded. + */ + virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, + PROPERTIES* aProperties = NULL ); + + /** + * Function FootprintSave + * will write @a aModule to an existing library located at @a aLibraryPath, + * and create the library if it doesn't exist then perform the write. If a + * footprint by the same name already exists, it is replaced. + * + * @param aLibraryPath is locator for the "library", usually a directory + * or file containing several footprints. This is where the footprint is + * to be stored. + * + * @param aFootprint is what to store in the library. + * The caller continues to own the footprint. + * + * @param aProperties is an associative array that can be used to tell the + * saver how to save the file, because it can take any number of + * additional named tuning arguments that the plugin is known to support. + * The caller continues to own this object (plugin may not delete it), and + * plugins should expect it to be optionally NULL. + * + * @throw IO_ERROR if there is a problem saving. + */ + virtual void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, + PROPERTIES* aProperties = NULL ); + + /** + * Function FootprintDelete + * deletes the @a aFootprintName from the library at @a aLibraryPath. + * + * @param aLibraryPath is locator for the "library", usually a directory + * or file containing several footprints. + * + * @param aFootprintName is the name of a footprint to delete from the specificed library. + * + * @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it. + */ + virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName ); + + /** + * Function IsLibraryWritable + * returns true iff the library at @a aLibraryPath is writable. (Often + * system libraries are read only because of where they are installed.) + */ + virtual bool IsLibraryWritable( const wxString& aLibraryPath ); + //----------------------------------------------------- + /* The compiler writes the "zero argument" constructor for a PLUGIN automatically if you do not provide one. If you decide you need to provide a zero argument constructor of your own design, that is allowed. It must be public, and it is what the IO_MGR uses. Parameters may be - passed into a PLUGIN via the PROPERTIES variable for either Save() and Load(). + passed into a PLUGIN via the PROPERTIES variable for any of the public + API functions which take one. */ virtual ~PLUGIN() {} diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 8f5626634c..e44f5c9105 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -106,7 +106,7 @@ #if 1 -#define READLINE() m_reader->ReadLine() +#define READLINE( rdr ) rdr->ReadLine() #else /// The function and macro which follow comprise a shim which can be a @@ -128,7 +128,7 @@ static inline unsigned ReadLine( LINE_READER* rdr, const char* caller ) return ret; } -#define READLINE() ReadLine( m_reader, __FUNCTION__ ) +#define READLINE( rdr ) ReadLine( rdr, __FUNCTION__ ) #endif static const char delims[] = " \t\r\n"; @@ -167,12 +167,14 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE { LOCALE_IO toggle; // toggles on, then off, the C locale. + init( aProperties ); + m_board = aAppendToMe ? aAppendToMe : new BOARD(); // delete on exception, iff I own m_board, according to aAppendToMe auto_ptr deleter( aAppendToMe ? NULL : m_board ); - FILE* fp = wxFopen( aFileName, wxT( "rt" ) ); + FILE* fp = wxFopen( aFileName, wxT( "r" ) ); if( !fp ) { m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() ); @@ -184,8 +186,6 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE m_reader = &reader; // member function accessibility - init( aProperties ); - checkVersion(); loadAllSections( bool( aAppendToMe ) ); @@ -205,7 +205,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) // Then follows $EQUIPOT and all the rest - while( READLINE() ) + while( READLINE( m_reader ) ) { char* line = m_reader->Line(); @@ -213,7 +213,8 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) if( TESTLINE( "$MODULE" ) ) { - loadMODULE(); + MODULE* m = LoadMODULE(); + m_board->Add( m, ADD_APPEND ); } else if( TESTLINE( "$DRAWSEGMENT" ) ) @@ -281,7 +282,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) } else { - while( READLINE() ) + while( READLINE( m_reader ) ) { line = m_reader->Line(); // gobble until $EndSetup @@ -332,7 +333,7 @@ void LEGACY_PLUGIN::checkVersion() void LEGACY_PLUGIN::loadGENERAL() { - while( READLINE() ) + while( READLINE( m_reader ) ) { char* line = m_reader->Line(); const char* data; @@ -460,7 +461,7 @@ void LEGACY_PLUGIN::loadSHEET() char buf[260]; TITLE_BLOCK tb; - while( READLINE() ) + while( READLINE( m_reader ) ) { char* line = m_reader->Line(); @@ -575,7 +576,7 @@ void LEGACY_PLUGIN::loadSETUP() BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings(); ZONE_SETTINGS zs = m_board->GetZoneSettings(); - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -863,15 +864,16 @@ void LEGACY_PLUGIN::loadSETUP() } -void LEGACY_PLUGIN::loadMODULE() +MODULE* LEGACY_PLUGIN::LoadMODULE() { auto_ptr module( new MODULE( m_board ) ); - while( READLINE() ) + while( READLINE( m_reader ) ) { - const char* data; char* line = m_reader->Line(); + const char* data; + // most frequently encountered ones at the top if( TESTSUBSTR( "D" ) ) // read a drawing item, e.g. "DS" @@ -1053,9 +1055,7 @@ void LEGACY_PLUGIN::loadMODULE() { module->CalculateBoundingBox(); - m_board->Add( module.release(), ADD_APPEND ); - - return; // preferred exit + return module.release(); // preferred exit } } @@ -1067,7 +1067,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) { auto_ptr pad( new D_PAD( aModule ) ); - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -1288,8 +1288,8 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) { - STROKE_T shape; - char* line = m_reader->Line(); // obtain current (old) line + STROKE_T shape; + char* line = m_reader->Line(); // obtain current (old) line switch( line[1] ) { @@ -1371,7 +1371,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) for( int ii = 0; iiLine(); @@ -1596,7 +1596,7 @@ void LEGACY_PLUGIN::loadPCB_LINE() auto_ptr dseg( new DRAWSEGMENT( m_board ) ); - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -1704,7 +1704,7 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM() NETINFO_ITEM* net = new NETINFO_ITEM( m_board ); m_board->AppendNet( net ); - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -1756,7 +1756,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board ); m_board->Add( pcbtxt, ADD_APPEND ); - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -1866,7 +1866,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) { - while( READLINE() ) + while( READLINE( m_reader ) ) { // read two lines per loop iteration, each loop is one TRACK or VIA // example first line: @@ -1899,7 +1899,7 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) // differentiates between PCB_TRACE_T and PCB_VIA_T. With virtual // functions in use, it is critical to instantiate the PCB_VIA_T // exactly. - READLINE(); + READLINE( m_reader ); line = m_reader->Line(); @@ -1989,7 +1989,7 @@ void LEGACY_PLUGIN::loadNETCLASS() // just before returning. auto_ptr nc( new NETCLASS( m_board, wxEmptyString ) ); - while( READLINE() ) + while( READLINE( m_reader ) ) { char* line = m_reader->Line(); @@ -2082,7 +2082,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() bool sawCorner = false; char buf[1024]; - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -2233,7 +2233,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() { // Read the PolysList (polygons used for fill areas in the zone) - while( READLINE() ) + while( READLINE( m_reader ) ) { line = m_reader->Line(); @@ -2253,7 +2253,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() else if( TESTLINE( "$FILLSEGMENTS" ) ) { - while( READLINE() ) + while( READLINE( m_reader ) ) { line = m_reader->Line(); @@ -2304,7 +2304,7 @@ void LEGACY_PLUGIN::loadDIMENSION() { auto_ptr dim( new DIMENSION( m_board ) ); - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -2498,7 +2498,7 @@ void LEGACY_PLUGIN::loadDIMENSION() void LEGACY_PLUGIN::loadPCB_TARGET() { - while( READLINE() ) + while( READLINE( m_reader ) ) { const char* data; char* line = m_reader->Line(); @@ -2675,6 +2675,7 @@ double LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr ) void LEGACY_PLUGIN::init( PROPERTIES* aProperties ) { + m_board = NULL; m_props = aProperties; // conversion factor for saving RAM BIUs to KICAD legacy file format. @@ -2706,9 +2707,11 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* { LOCALE_IO toggle; // toggles on, then off, the C locale. + init( aProperties ); + m_board = aBoard; - FILE* fp = wxFopen( aFileName, wxT( "wt" ) ); + FILE* fp = wxFopen( aFileName, wxT( "w" ) ); if( !fp ) { m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() ); @@ -2722,8 +2725,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* m_fp = fp; // member function accessibility - init( aProperties ); - if( m_props ) { wxString header = (*m_props)["header"]; @@ -2751,8 +2752,6 @@ do { \ void LEGACY_PLUGIN::saveAllSections() const { - - saveGENERAL(); saveSHEET(); @@ -3698,3 +3697,371 @@ void LEGACY_PLUGIN::savePCB_TEXT( const TEXTE_PCB* me ) const fprintf( m_fp, "$EndTEXTPCB\n" ); } + + +//------------------------------------------------- + +/* + + The legacy file format is being obsoleted and this code will have a short + lifetime, so it only needs to be good enough for a short duration of time. + Caching all the MODULEs is a bit memory intensive, but it is a considerably + faster way of fulfilling the API contract. Otherwise, without the cache, you + would have to re-read the file when searching for any MODULE, and this would + be very problematic filling a FOOTPRINT_LIST via this PLUGIN API. If memory + becomes a concern, consider the cache lifetime policy, which determines the + time that a FPL_CACHE is in RAM. Note PLUGIN lifetime also plays a role in + cache lifetime. + +*/ + + +#include + +typedef boost::ptr_map< wxString, MODULE > MODULE_MAP; +typedef MODULE_MAP::iterator MODULE_ITER; +typedef MODULE_MAP::const_iterator MODULE_CITER; + +#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1" + + +/** + * Class FPL_CACHE + * assists only for the footprint portion of the PLUGIN API, and only for the + * LEGACY_PLUGIN, so therefore is private to this implementation file, i.e. not placed + * into a header. + */ +struct FPL_CACHE +{ + LEGACY_PLUGIN* m_owner; // my owner, I need its LEGACY_PLUGIN::LoadMODULE() + wxString m_lib_name; + wxDateTime m_mod_time; + MODULE_MAP m_modules; // tuple of footprint name vs. MODULE* + bool m_writable; + + FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath ); + + // Most all functions in this class throw IO_ERROR exceptions. There is no + // error codes nor user interface calls from here. + // Catch these exceptions higher up please. + + /// save the entire legacy library to m_lib_name; + void Save(); + + void SaveHeader( FILE* aFile ); + + void SaveIndex( FILE* aFile ); + + void SaveModules( FILE* aFile ); + + void SaveEndOfFile( FILE* aFile ); + + void Load( LINE_READER* aReader ); + + void ReadAndVerifyHeader( LINE_READER* aReader ); + + void SkipIndex( LINE_READER* aReader ); + + void LoadModules( LINE_READER* aReader ); + + wxDateTime GetLibModificationTime(); +}; + + +FPL_CACHE::FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath ) : + m_owner( aOwner ), + m_lib_name( aLibraryPath ), + m_writable( false ) +{ + FILE* fp = wxFopen( aLibraryPath, wxT( "r" ) ); + if( !fp ) + { + THROW_IO_ERROR( wxString::Format( + _( "Unable to open legacy library file '%s'" ), aLibraryPath.GetData() ) ); + } + + // reader now owns fp, will close on exception or return + FILE_LINE_READER reader( fp, aLibraryPath ); + + Load( &reader ); +} + + +wxDateTime FPL_CACHE::GetLibModificationTime() +{ + wxFileName fn( m_lib_name ); + + m_writable = fn.IsFileWritable(); + + return fn.GetModificationTime(); +} + + +void FPL_CACHE::Load( LINE_READER* aReader ) +{ + ReadAndVerifyHeader( aReader ); + SkipIndex( aReader ); + LoadModules( aReader ); + + // Remember the file modification time of library file when the + // cache snapshot was made, so that in a networked environment we will + // reload the cache as needed. + m_mod_time = GetLibModificationTime(); +} + + +void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader ) +{ + if( !aReader->ReadLine() ) + { + L_not_library: + THROW_IO_ERROR( wxString::Format( _( "File %s is empty or is not a legacy library" ), + m_lib_name.GetData() ) ); + } + + char* line = aReader->Line(); + + if( !TESTLINE( "PCBNEW-LibModule-V1" ) ) + goto L_not_library; +} + + +void FPL_CACHE::SkipIndex( LINE_READER* aReader ) +{ + // Some broken INDEX sections have more than one section, due to prior bugs. + // So we must read the next line after $EndINDEX tag, + // to see if this is not a new $INDEX tag. + bool exit = false; + + while( aReader->ReadLine() ) + { + char* line = aReader->Line(); + + if( TESTLINE( "$INDEX" ) ) + { + exit = false; + + while( aReader->ReadLine() ) + { + line = aReader->Line(); + + if( TESTLINE( "$EndINDEX" ) ) + { + exit = true; + break; + } + } + } + else if( exit ) + break; + } +} + + +void FPL_CACHE::LoadModules( LINE_READER* aReader ) +{ + m_owner->SetReader( aReader ); + + do + { + // test first for the $MODULE, even before reading because of INDEX bug. + char* line = aReader->Line(); + + if( TESTLINE( "$MODULE" ) ) + { + MODULE* m = m_owner->LoadMODULE(); + + wxString reference = m->GetReference(); + + MODULE_CITER it = m_modules.find( reference ); + + if( it != m_modules.end() ) + { + THROW_IO_ERROR( wxString::Format( + _( "library %s has a duplicate footprint named %s" ), + m_lib_name.GetData(), reference.GetData() ) ); + } + m_modules.insert( reference, m ); + } + + } while( aReader->ReadLine() ); +} + + +void FPL_CACHE::Save() +{ + if( !m_writable ) + { + THROW_IO_ERROR( wxString::Format( + _( "Legacy library file '%s' is read only" ), m_lib_name.GetData() ) ); + } + + wxString tempFileName = wxFileName::CreateTempFileName( m_lib_name ); + + wxLogDebug( "tempFileName:'%s'\n", TO_UTF8( tempFileName ) ); + + FILE* fp = wxFopen( tempFileName, wxT( "w" ) ); + if( !fp ) + { + THROW_IO_ERROR( wxString::Format( + _( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) ); + } + + // wxf now owns fp, will close on exception or return + wxFFile wxf( fp ); + + SaveHeader( fp ); + SaveIndex( fp ); + SaveModules( fp ); + SaveEndOfFile( fp ); + + wxRemoveFile( m_lib_name ); + wxRenameFile( tempFileName, m_lib_name ); +} + + +void FPL_CACHE::SaveHeader( FILE* aFile ) +{ + fprintf( aFile, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) ); + fprintf( aFile, "# encoding utf-8\n" ); +} + + +void FPL_CACHE::SaveIndex( FILE* aFile ) +{ + fprintf( aFile, "$INDEX\n" ); + + for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it ) + { + fprintf( aFile, "%s\n", TO_UTF8( it->first ) ); + } + + fprintf( aFile, "$EndINDEX\n" ); +} + + +void FPL_CACHE::SaveModules( FILE* aFile ) +{ +} + + +void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath ) +{ + if( !m_cache || m_cache->m_lib_name != aLibraryPath || + m_cache->m_mod_time != m_cache->GetLibModificationTime() ) + { + // a spectacular episode in memory management. + delete m_cache; + m_cache = new FPL_CACHE( this, aLibraryPath ); + } +} + + +wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties ) +{ + wxArrayString ret; + + init( aProperties ); + + cacheLib( aLibraryPath ); + + const MODULE_MAP& mods = m_cache->m_modules; + + for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it ) + { + ret.Add( it->first ); + } + + return ret; +} + + +MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, + PROPERTIES* aProperties ) +{ + init( aProperties ); + + cacheLib( aLibraryPath ); + + const MODULE_MAP& mods = m_cache->m_modules; + + MODULE_CITER it = mods.find( aFootprintName ); + + if( it == mods.end() ) + { + THROW_IO_ERROR( wxString::Format( _( "No '%s' footprint in library '%s'" ), + aFootprintName.GetData(), aLibraryPath.GetData() ) ); + } + + // copy constructor to clone the already loaded MODULE + return new MODULE( *it->second ); +} + + +void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties ) +{ + init( aProperties ); + + cacheLib( aLibraryPath ); + + if( !m_cache->m_writable ) + { + } + + wxString reference = aFootprint->GetReference(); + + MODULE_MAP& mods = m_cache->m_modules; + + // quietly overwrite any by same name. + MODULE_CITER it = mods.find( reference ); + if( it != mods.end() ) + { + mods.erase( reference ); + } + + aFootprint->SetParent( 0 ); + + mods.insert( reference, aFootprint ); + + m_cache->Save(); +} + + +void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName ) +{ + init( NULL ); + + cacheLib( aLibraryPath ); + + if( !m_cache->m_writable ) + { + } + + size_t erasedCount = m_cache->m_modules.erase( aFootprintName ); + + if( erasedCount != 1 ) + { + THROW_IO_ERROR( wxString::Format( + _( "library '%s' has no footprint '%s' to delete" ), + aLibraryPath.GetData(), aFootprintName.GetData() ) ); + } + + m_cache->Save(); +} + + +bool LEGACY_PLUGIN::IsLibraryWritable( const wxString& aLibraryPath ) +{ + init( NULL ); + + cacheLib( aLibraryPath ); + + return m_cache->m_writable; +} + + +LEGACY_PLUGIN::~LEGACY_PLUGIN() +{ + delete m_cache; +} + diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h index fab6450741..b2011b8fe8 100644 --- a/pcbnew/legacy_plugin.h +++ b/pcbnew/legacy_plugin.h @@ -44,6 +44,8 @@ class EDGE_MODULE; class TRACK; class SEGZONE; class D_PAD; +class FPL_CACHE; + /** * Class LEGACY_PLUGIN @@ -55,7 +57,7 @@ class LEGACY_PLUGIN : public PLUGIN public: - //------------------------------------------------------------------ + //--------------------------------------------------- const wxString& PluginName() const { @@ -73,7 +75,35 @@ public: void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload - //----------------------------------------------------------------- + wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL); + + MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, + PROPERTIES* aProperties = NULL ); + + void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, + PROPERTIES* aProperties = NULL ); + + void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName ); + + bool IsLibraryWritable( const wxString& aLibraryPath ); + + //-------------------------------------------------- + + LEGACY_PLUGIN() : + m_board( 0 ), + m_props( 0 ), + m_reader( 0 ), + m_fp( 0 ), + m_cache( 0 ) + {} + + ~LEGACY_PLUGIN(); + + void SetReader( LINE_READER* aReader ) { m_reader = aReader; } + void SetFilePtr( FILE* aFile ) { m_fp = aFile; } + + MODULE* LoadMODULE(); + protected: @@ -87,6 +117,8 @@ protected: wxString m_field; ///< reused to stuff MODULE fields. int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing? + FPL_CACHE* m_cache; + /// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. void init( PROPERTIES* aProperties ); @@ -131,11 +163,11 @@ protected: void loadAllSections( bool doAppend ); + void loadGENERAL(); void loadSETUP(); void loadSHEET(); - void loadMODULE(); void load3D( MODULE* aModule ); void loadPAD( MODULE* aModule ); void loadMODULE_TEXT( TEXTE_MODULE* aText ); @@ -235,6 +267,8 @@ protected: //--------------------------------------------------------- + /// we only cache one footprint library for now, this determines which one. + void cacheLib( const wxString& aLibraryPath ); }; #endif // LEGACY_PLUGIN_H_ diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 37611da303..8845cda5a8 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -225,122 +224,15 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) if( !IsOK( this, msg ) ) return; - oldFileName = aLibname; - - if( ( lib_module = wxFopen( oldFileName.GetFullPath(), wxT( "rt" ) ) ) == NULL ) + try { - wxString msg; - msg.Printf( _( "Library <%s> not found" ), GetChars(oldFileName.GetFullPath() ) ); - DisplayError( NULL, msg ); - return; + PLUGIN::HOLDER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); + + pi->FootprintDelete( aLibname, CmpName ); } - - - FOOTPRINT_LIBRARY input_lib( lib_module ); - - // Read header. - if( ! input_lib.IsLibrary() ) + catch( IO_ERROR ioe ) { - fclose( lib_module ); - wxString msg; - msg.Printf( _( "<%s> is not a valid footprint library file" ), - GetChars( oldFileName.GetFullPath() ) ); - DisplayError( NULL, msg ); - return; - } - - // Read module names. - input_lib.RebuildIndex(); - bool found = input_lib.FindInList( CmpName ); - - if( !found ) - { - fclose( lib_module ); - msg.Printf( _( "Module [%s] not found" ), GetChars( CmpName ) ); - DisplayError( NULL, msg ); - return; - } - - // Create new library. - newFileName = oldFileName; - newFileName.SetExt( FILETMP_EXT ); - - if( ( out_file = wxFopen( newFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL ) - { - fclose( lib_module ); - msg.Printf( _( "Unable to create %s" ), GetChars( newFileName.GetFullPath() ) ); - DisplayError( NULL, msg ); - return; - } - - wxBeginBusyCursor(); - - FOOTPRINT_LIBRARY output_lib( out_file ); - output_lib.m_List = input_lib.m_List; - - output_lib.WriteHeader(); - output_lib.RemoveFromList( CmpName ); - output_lib.SortList(); - output_lib.WriteSectionIndex(); - - // Copy modules. - rewind( lib_module ); - LineNum = input_lib.m_LineNum; - - bool copylines = false; - while( GetLine( lib_module, Line, &LineNum ) ) - { - StrPurge( Line ); - - if( strnicmp( Line, "$MODULE", 7 ) == 0 ) - { - copylines = true; - sscanf( Line + 7, " %s", Name ); - msg = FROM_UTF8( Name ); - - if( msg.CmpNoCase( CmpName ) == 0 ) - { - // Delete old module (i.e. do not copy description to out_file). - while( GetLine( lib_module, Line, &LineNum ) ) - { - if( strnicmp( Line, "$EndMODULE", 9 ) == 0 ) - break; - } - - continue; - } - } - - if( copylines ) - fprintf( out_file, "%s\n", Line ); - } - - fclose( lib_module ); - fclose( out_file ); - - wxEndBusyCursor(); - - // The old library file is renamed .bak - wxFileName backupFileName = oldFileName; - backupFileName.SetExt( BACKUP_EXT ); - - if( backupFileName.FileExists() ) - wxRemoveFile( backupFileName.GetFullPath() ); - - if( !wxRenameFile( oldFileName.GetFullPath(), backupFileName.GetFullPath() ) ) - { - msg.Printf( _( "Could not create library back up file <%s>." ), - GetChars( backupFileName.GetFullName() ) ); - DisplayError( this, msg ); - return; - } - - // The temporary file is renamed as the previous library. - if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) ) - { - msg.Printf( _("Could not create temporary library file <%s>."), - GetChars( oldFileName.GetFullName() ) ); - DisplayError( this, msg ); + DisplayError( NULL, ioe.errorText ); return; } diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 95e4b04a08..b571f1176e 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -153,7 +153,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, static wxArrayString HistoryList; static wxString lastComponentName; - /* Ask for a component name or key words */ + // Ask for a component name or key words DIALOG_GET_COMPONENT dlg( this, GetComponentDialogPosition(), HistoryList, _( "Load Module" ), aUseFootprintViewer ); @@ -171,7 +171,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, moduleName = dlg.GetComponentName(); } - if( moduleName.IsEmpty() ) /* Cancel command */ + if( moduleName.IsEmpty() ) // Cancel command { m_canvas->MoveCursorToCrossHair(); return NULL; @@ -185,7 +185,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, keys = moduleName; moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys ); - if( moduleName.IsEmpty() ) /* Cancel command */ + if( moduleName.IsEmpty() ) // Cancel command { m_canvas->MoveCursorToCrossHair(); return NULL; @@ -200,13 +200,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, if( moduleName.IsEmpty() ) { m_canvas->MoveCursorToCrossHair(); - return NULL; /* Cancel command. */ + return NULL; // Cancel command. } } module = GetModuleLibrary( aLibrary, moduleName, false ); - if( ( module == NULL ) && AllowWildSeach ) /* Search with wild card */ + if( ( module == NULL ) && AllowWildSeach ) // Search with wild card { AllowWildSeach = false; wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' ); @@ -216,7 +216,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, if( moduleName.IsEmpty() ) { m_canvas->MoveCursorToCrossHair(); - return NULL; /* Cancel command. */ + return NULL; // Cancel command. } else { @@ -376,7 +376,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, const wxString& aMask, const wxString& aKeyWord ) { - static wxString OldName; /* Save the name of the last module loaded. */ + static wxString OldName; // Save the name of the last module loaded. wxString CmpName; wxString msg; wxArrayString libnames_list; @@ -386,7 +386,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, else libnames_list.Add( aLibraryFullFilename ); - /* Find modules in libraries. */ + // Find modules in libraries. MList.ReadFootprintFiles( libnames_list ); wxArrayString footprint_names_list; @@ -461,7 +461,7 @@ static void DisplayCmpDoc( wxString& Name ) MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb ) { MODULE* module; - static wxString OldName; /* Save name of last module selected. */ + static wxString OldName; // Save name of last module selected. wxString CmpName, msg; wxArrayString listnames; diff --git a/pcbnew/modview.cpp b/pcbnew/modview.cpp index df7f1065d7..5b30206376 100644 --- a/pcbnew/modview.cpp +++ b/pcbnew/modview.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index ec9706616c..5ef1bc3462 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -35,7 +35,6 @@ class wxSashLayoutWindow; class wxListBox; class wxSemaphore; -class FOOTPRINT_LIBRARY; /** diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 59efb6ee7a..d30579ad35 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -543,7 +543,6 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) /// data type used to ensure unique-ness of pin names, holding (wxString and int) -//typedef std::map PINMAP; typedef std::map PINMAP; From 5d5eb7d38c6a2a64c97946cb5c2c57a3c8764789 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 16 Apr 2012 14:56:01 +0200 Subject: [PATCH 04/16] Fix a serious bug in EDA_RECT::Intersects Kicad manager: code cleaning. Dead code removed and minor fixes. support of new .kicad_brd extension. --- common/base_struct.cpp | 4 +- kicad/class_treeproject_item.cpp | 9 +- kicad/class_treeprojectfiles.cpp | 27 +- kicad/commandframe.cpp | 25 + kicad/files-io.cpp | 29 +- kicad/kicad.h | 3 +- kicad/prjconfig.cpp | 2 +- kicad/tree_project_frame.cpp | 116 +- kicad/tree_project_frame.h | 59 +- pcbnew/class_drawsegment.cpp | 78 +- pcbnew/dialogs/dialog_block_options_base.fbp | 1054 ++++++++--------- ...ialog_general_options_BoardEditor_base.fbp | 60 +- pcbnew/dialogs/dialog_mask_clearance_base.fbp | 2 +- ...nvert_brd_items_to_polygons_with_Boost.cpp | 2 +- 14 files changed, 711 insertions(+), 759 deletions(-) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index c5cdb74ea1..c6c9e74fd7 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -344,11 +344,11 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const // calculate the left common area coordinate: int left = MAX( me.m_Pos.x, rect.m_Pos.x ); // calculate the right common area coordinate: - int right = MIN( me.m_Pos.x + m_Size.x, rect.m_Pos.x + rect.m_Size.x ); + int right = MIN( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x ); // calculate the upper common area coordinate: int top = MAX( me.m_Pos.y, aRect.m_Pos.y ); // calculate the lower common area coordinate: - int bottom = MIN( me.m_Pos.y + m_Size.y, rect.m_Pos.y + rect.m_Size.y ); + int bottom = MIN( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y ); // if a common area exists, it must have a positive (null accepted) size if( left <= right && top <= bottom ) diff --git a/kicad/class_treeproject_item.cpp b/kicad/class_treeproject_item.cpp index 0003280da3..1a86ba9a02 100644 --- a/kicad/class_treeproject_item.cpp +++ b/kicad/class_treeproject_item.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -214,8 +215,9 @@ bool TREEPROJECT_ITEM::Delete( bool check ) /*******************************************/ /* delete a file */ { - wxMessageDialog dialog( m_Parent, - _ ("Do you really want to delete ") + GetFileName(), + wxString msg; + msg.Printf( _("Do you really want to delete '%s'"), GetChars(GetFileName() ) ); + wxMessageDialog dialog( m_Parent, msg, _( "Delete File" ), wxYES_NO | wxICON_QUESTION ); if( !check || wxID_YES == dialog.ShowModal() ) @@ -264,7 +266,8 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ExecuteFile( m_Parent, EESCHEMA_EXE, FullFileName ); break; - case TREE_PCB: + case TREE_LEGACY_PCB: + case TREE_SEXP_PCB: ExecuteFile( m_Parent, PCBNEW_EXE, FullFileName ); break; diff --git a/kicad/class_treeprojectfiles.cpp b/kicad/class_treeprojectfiles.cpp index 9cf484db70..5c8ee42768 100644 --- a/kicad/class_treeprojectfiles.cpp +++ b/kicad/class_treeprojectfiles.cpp @@ -2,6 +2,30 @@ * @file class_treeprojectfiles.cpp * this is the wxTreeCtrl that shows a KiCad tree project files */ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004-2012 Jean-Pierre Charras + * Copyright (C) 2004-2012 KiCad Developers, see change_log.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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #include @@ -38,7 +62,8 @@ TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent ) : m_ImageList->Add( KiBitmap( kicad_icon_small_xpm ) ); // TREE_PROJECT m_ImageList->Add( KiBitmap( eeschema_xpm ) ); // TREE_SCHEMA - m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_PCB + m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_LEGACY_PCB + m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_SFMT_PCB m_ImageList->Add( KiBitmap( icon_gerbview_small_xpm ) ); // TREE_GERBER m_ImageList->Add( KiBitmap( datasheet_xpm ) ); // TREE_PDF m_ImageList->Add( KiBitmap( icon_txt_xpm ) ); // TREE_TXT diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index 51ed272674..c0aa77eda3 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -3,6 +3,31 @@ * @brief Frame showing fast launch buttons and messages box */ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004-2012 Jean-Pierre Charras + * Copyright (C) 2004-2012 KiCad Developers, see change_log.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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + #include #include diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 9aec929a5d..a3d54ee80f 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -2,9 +2,29 @@ /* files-io.cpp */ /****************/ -#ifdef __GNUG__ -#pragma implementation -#endif +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004-2012 Jean-Pierre Charras + * Copyright (C) 2004-2012 KiCad Developers, see change_log.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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ #include #include @@ -110,7 +130,8 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) { /* List of file extensions to save. */ static const wxChar* extentionList[] = { - wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), wxT( "*.brd" ), + wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), + wxT( "*.brd" ), wxT( "*.kicad_brd" ), wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ), wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ), NULL diff --git a/kicad/kicad.h b/kicad/kicad.h index d98c33406e..18d9729fa7 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -157,7 +157,8 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, enum TreeFileType { TREE_PROJECT = 1, TREE_SCHEMA, // Schematic file (.sch) - TREE_PCB, // board file (.brd) + TREE_LEGACY_PCB, // board file (.brd) legacy format + TREE_SEXP_PCB, // board file (.kicad_brd) new s expression format TREE_GERBER, // Gerber file (.pho, .g*) TREE_PDF, // PDF file (.pdf) TREE_TXT, // ascii text file (.txt) diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index ab2c33c116..95a0698f95 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -6,7 +6,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-2012 Jean-Pierre Charras * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index a50d2ecc74..e7e4dd7037 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -20,6 +21,8 @@ #include #include +// TODO: use the wxString defined in wildcards_and_files_ext.h, when exists +const wxString PcbSexpFileExtension( wxT("kicad_brd") ); /* Note about the tree project build process: * Building the tree project can be *very* long if there are a lot of subdirectories @@ -39,7 +42,8 @@ const wxChar* s_AllowedExtensionsToList[] = { wxT( "^.*\\.pro$" ), wxT( "^.*\\.pdf$" ), - wxT( "^[^$].*\\.brd$" ), // Pcbnew files + wxT( "^[^$].*\\.brd$" ), // Legacy Pcbnew files + wxT( "^[^$].*\\.kicad_brd$" ), // S format Pcbnew files wxT( "^.*\\.net$" ), wxT( "^.*\\.txt$" ), wxT( "^.*\\.pho$" ), // Gerber file (Kicad extension) @@ -89,7 +93,7 @@ BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow ) EVT_TREE_BEGIN_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragStart ) EVT_TREE_END_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragEnd ) EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnTxtEdit ) - EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnNewDirectory ) + EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory ) EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile ) EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile ) END_EVENT_TABLE() @@ -155,12 +159,11 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) : menu = m_ContextMenus[i]; // ID_PROJECT_RENAME - item = new wxMenuItem( menu, - ID_PROJECT_RENAME, + item = new wxMenuItem( menu, ID_PROJECT_RENAME, TREE_DIRECTORY != i ? _( "&Rename file" ) : _( "&Rename directory" ), TREE_DIRECTORY != i ? _( "Rename file" ) : - _( "&Rename directory" ) ); + _( "Rename directory" ) ); item->SetBitmap( KiBitmap( right_xpm ) ); menu->Append( item ); @@ -182,7 +185,7 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) : TREE_DIRECTORY != i ? _( "&Delete File" ) : _( "&Delete Directory" ), TREE_DIRECTORY != i ? _( "Delete the File" ) : - _( "&Delete the Directory and its content" ) ); + _( "Delete the Directory and its content" ) ); item->SetBitmap( KiBitmap( delete_xpm ) ); menu->Append( item ); } @@ -321,50 +324,17 @@ wxMenu* TREE_PROJECT_FRAME::GetContextMenu( int type ) /** - * @brief TODO + * Called by the popup menu in the tree frame + * Creates a new subdirectory inside the current kicad project directory + * the user is prompted to enter a directory name */ -/*****************************************************************************/ -void TREE_PROJECT_FRAME::OnNewDirectory( wxCommandEvent& event ) -/*****************************************************************************/ +void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event ) { - NewFile( TREE_DIRECTORY ); -} - - -/** - * @brief TODO - */ -/*****************************************************************************/ -void TREE_PROJECT_FRAME::NewFile( TreeFileType type ) -/*****************************************************************************/ -{ - wxString mask = GetFileExt( type ); - wxString wildcard = GetFileWildcard( type ); - - // Get the directory: - wxString dir; - wxString title; - - TREEPROJECT_ITEM* treeData; - - title = ( TREE_DIRECTORY != type ) ? _( "Create New File" ) : - _( "Create New Directory" ); - - treeData = GetSelectedData(); + // Get the root directory name: + TREEPROJECT_ITEM* treeData = GetSelectedData(); if( !treeData ) return; - dir = wxGetCwd() + wxFileName().GetPathSeparator() + treeData->GetDir(); - - // Ask for the new file name - wxString nameless_prj = NAMELESS_PROJECT; - nameless_prj += wxT(".") + mask; - wxFileDialog dlg( this, title, dir, nameless_prj, - wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - TreeFileType rootType = treeData->GetType(); wxTreeItemId root; @@ -375,34 +345,31 @@ void TREE_PROJECT_FRAME::NewFile( TreeFileType type ) else { root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() ); - if( !root.IsOk() ) root = m_TreeProject->GetSelection(); } - NewFile( dlg.GetPath(), type, root ); -} + // Ask for the new sub directory name + wxString curr_dir = treeData->GetDir(); - -/** - * @brief TODO - */ -/*****************************************************************************/ -void TREE_PROJECT_FRAME::NewFile( const wxString& name, - TreeFileType type, - wxTreeItemId& root ) -/*****************************************************************************/ -{ - if( TREE_DIRECTORY != type ) + // Make the current subdir relative to the current path: + if( !curr_dir.IsEmpty() ) // A subdir is selected { - wxFile( name, wxFile::write ); - } - else - { - wxMkdir( name ); + curr_dir += wxFileName::GetPathSeparator(); + curr_dir += wxT("dummy"); + wxFileName fn(curr_dir); + fn.MakeRelativeTo(); + curr_dir = fn.GetPath() + wxFileName::GetPathSeparator(); } + wxString msg; + msg.Printf( wxT("Current working directory:\n%s"), GetChars( wxGetCwd() ) ); + wxString subdir = wxGetTextFromUser( msg, _( "Create New Directory" ), curr_dir ); - AddFile( name, root ); + if( subdir.IsEmpty() ) + return; + + if( wxMkdir( subdir ) ) + AddFileToTree( subdir, root ); } @@ -425,10 +392,14 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type ) ext = SchematicFileExtension; break; - case TREE_PCB: + case TREE_LEGACY_PCB: ext = PcbFileExtension; break; + case TREE_SEXP_PCB: + ext = PcbSexpFileExtension; + break; + case TREE_GERBER: ext = GerberFileExtension; break; @@ -485,7 +456,8 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type ) ext = SchematicFileWildcard; break; - case TREE_PCB: + case TREE_LEGACY_PCB: + case TREE_SEXP_PCB: ext = PcbFileWildcard; break; @@ -530,7 +502,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type ) /** - * Function AddFile + * Function AddFileToTree * @brief Add filename "name" to the tree \n * if name is a directory, add the sub directory file names * @param aName = the filename or the dirctory name to add @@ -539,7 +511,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type ) * false to stop file add. * @return true if the file (or directory) is added. */ -bool TREE_PROJECT_FRAME::AddFile( const wxString& aName, +bool TREE_PROJECT_FRAME::AddFileToTree( const wxString& aName, wxTreeItemId& aRoot, bool aRecurse ) { wxTreeItemId cellule; @@ -681,7 +653,7 @@ bool TREE_PROJECT_FRAME::AddFile( const wxString& aName, { do // Add name in tree, but do not recurse { - AddFile( aName + sep + dir_filename, cellule, false ); + AddFileToTree( aName + sep + dir_filename, cellule, false ); } while( dir.GetNext( &dir_filename ) ); } @@ -743,7 +715,7 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj() while( cont ) { if( filename != fn.GetFullName() ) - AddFile( dir.GetName() + wxFileName::GetPathSeparator() + + AddFileToTree( dir.GetName() + wxFileName::GetPathSeparator() + filename, m_root ); cont = dir.GetNext( &filename ); @@ -980,7 +952,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event ) { do // Add name to tree item, but do not recurse in subdirs: { - AddFile( fileName + sep + dir_filename, kid, false ); + AddFileToTree( fileName + sep + dir_filename, kid, false ); } while( dir.GetNext( &dir_filename ) ); } itemData->m_WasPopulated = true; // set state to populated diff --git a/kicad/tree_project_frame.h b/kicad/tree_project_frame.h index dca3f49262..942c289f2f 100644 --- a/kicad/tree_project_frame.h +++ b/kicad/tree_project_frame.h @@ -47,9 +47,7 @@ private: protected: wxMenu* GetContextMenu( int type ); - void NewFile( TreeFileType type ); - void NewFile( const wxString& name, TreeFileType type, - wxTreeItemId& root ); + /** * Function GetSelectedData * return the item data from item currently selected (highlighted) @@ -91,63 +89,28 @@ public: void OnDeleteFile( wxCommandEvent& event ); void OnRenameFile( wxCommandEvent& event ); - void OnNewDirectory( wxCommandEvent& event ); - void OnNewPyFile( wxCommandEvent& event ); + /** + * Function OnCreateNewDirectory + * Creates a new subdirectory inside the current kicad project directory + * the user is prompted to enter a directory name + */ + void OnCreateNewDirectory( wxCommandEvent& event ); void ClearFilters(); const std::vector& GetFilters(); void RemoveFilter( const wxString& filter ); -#ifdef KICAD_PYTHON - boost::python::object ToWx(); - - TREE_PROJECT_FRAME() - { - } - - - TREE_PROJECT_FRAME( const TREE_PROJECT_FRAME& ) - { - } - - - void OnRunPy( wxCommandEvent& event ); - - boost::python::object GetMenuPy( TreeFileType ); - - boost::python::object GetFtExPy( TreeFileType ) const; - - void RemoveFilterPy( const boost::python::str& filter ); - void AddFilter( const boost::python::str& filter ); - - boost::python::object GetTreeCtrl(); - TREEPROJECT_ITEM* GetItemData( const boost::python::object& item ); - - void AddFilePy( const boost::python::str& name, - boost::python::object& root ); - void NewFilePy( const boost::python::str& name, - TreeFileType type, - boost::python::object& root ); - - TREEPROJECT_ITEM* FindItemData( const boost::python::str& name ); - - boost::python::object GetCurrentMenu(); - int AddStatePy( boost::python::object& bitmap ); - -#endif - /** - * Function AddFile - * @brief Add filename "name" to the tree \n - * if name is a directory, add the sub directory file names - * @param aName = the filename or the dirctory name to add + * Function AddFileToTree + * @brief Add the file or directory aName to the project tree + * @param aName = the filename or the directory name to add in tree * @param aRoot = the wxTreeItemId item where to add sub tree items * @param aRecurse = true to filenames or sub dir names to the current tree item * false to stop file add. * @return true if the file (or directory) is added. */ - bool AddFile( const wxString& aName, + bool AddFileToTree( const wxString& aName, wxTreeItemId& aRoot, bool aRecurse = true); DECLARE_EVENT_TABLE() diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index b8156747b8..9ec6f74941 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -386,55 +386,55 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const switch( m_Shape ) { - case S_SEGMENT: - bbox.SetEnd( m_End ); - bbox.Inflate( (m_Width / 2) + 1 ); - break; + case S_SEGMENT: + bbox.SetEnd( m_End ); + break; - case S_CIRCLE: - bbox.Inflate( GetRadius() + 1 ); - break; + case S_CIRCLE: + bbox.Inflate( GetRadius() ); + break; - case S_ARC: - { - bbox.Merge( m_End ); - wxPoint end = m_End; - RotatePoint( &end, m_Start, -m_Angle ); - bbox.Merge( end ); - } - break; - - case S_POLYGON: - { - wxPoint p_end; - MODULE* module = GetParentModule(); - - for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) + case S_ARC: { - wxPoint pt = m_PolyPoints[ii]; + bbox.Merge( m_End ); + wxPoint end = m_End; + RotatePoint( &end, m_Start, -m_Angle ); + bbox.Merge( end ); + } + break; - if( module ) // Transform, if we belong to a module + case S_POLYGON: + { + wxPoint p_end; + MODULE* module = GetParentModule(); + + for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { - RotatePoint( &pt, module->GetOrientation() ); - pt += module->m_Pos; + wxPoint pt = m_PolyPoints[ii]; + + if( module ) // Transform, if we belong to a module + { + RotatePoint( &pt, module->GetOrientation() ); + pt += module->m_Pos; + } + + if( ii == 0 ) + p_end = pt; + + bbox.SetX( MIN( bbox.GetX(), pt.x ) ); + bbox.SetY( MIN( bbox.GetY(), pt.y ) ); + p_end.x = MAX( p_end.x, pt.x ); + p_end.y = MAX( p_end.y, pt.y ); } - if( ii == 0 ) - p_end = pt; - - bbox.SetX( MIN( bbox.GetX(), pt.x ) ); - bbox.SetY( MIN( bbox.GetY(), pt.y ) ); - p_end.x = MAX( p_end.x, pt.x ); - p_end.y = MAX( p_end.y, pt.y ); + bbox.SetEnd( p_end ); + break; } - - bbox.SetEnd( p_end ); - bbox.Inflate( 1 ); - break; - } } - bbox.Inflate( (m_Width+1) / 2 ); + bbox.Inflate( ((m_Width+1) / 2) + 1 ); + bbox.Normalize(); + return bbox; } diff --git a/pcbnew/dialogs/dialog_block_options_base.fbp b/pcbnew/dialogs/dialog_block_options_base.fbp index afad8ab928..5dab3a6fdf 100644 --- a/pcbnew/dialogs/dialog_block_options_base.fbp +++ b/pcbnew/dialogs/dialog_block_options_base.fbp @@ -1,8 +1,8 @@ - + - + C++ 1 source_name @@ -14,9 +14,9 @@ none 1 dialog_block_options_base - + . - + 1 1 0 @@ -27,14 +27,14 @@ 1 1 0 - - - + + + 1 wxBOTH 0 1 - + 1 0 Dock @@ -42,74 +42,74 @@ Left 1 impl_virtual - - + + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 1 DIALOG_BLOCK_OPTIONS_BASE 1 - - + + 1 - - + + Resizable - + 1 397,226 wxDEFAULT_DIALOG_STYLE - - + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bSizerMain wxVERTICAL none @@ -120,11 +120,11 @@ wxID_ANY Options - + sbSizer1 wxVERTICAL none - + 5 wxEXPAND @@ -132,7 +132,7 @@ 2 0 - + gSizer1 none 4 @@ -146,80 +146,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include modules - + 0 - + 0 - + 1 m_Include_Modules 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -231,80 +231,80 @@ 1 1 1 - - - + + + 1 0 1 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include text items - + 0 - + 0 - + 1 m_Include_PcbTextes 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -316,80 +316,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include locked modules - + 0 - + 0 - + 1 m_IncludeLockedModules 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -401,80 +401,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include drawings - + 0 - + 0 - + 1 m_Include_Draw_Items 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -486,80 +486,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include tracks - + 0 - + 0 - + 1 m_Include_Tracks 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -571,80 +571,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include board outline layer - + 0 - + 0 - + 1 m_Include_Edges_Items 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -656,80 +656,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include zones - + 0 - + 0 - + 1 m_Include_Zones 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -741,80 +741,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Draw selected items while moving - + 0 - + 0 - + 1 m_DrawBlockItems 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -828,77 +828,77 @@ 1 1 1 - - - + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 1 m_staticline1 1 - - + + protected 1 - - + + Resizable - + 1 - + wxLI_HORIZONTAL - + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -910,80 +910,80 @@ 1 1 1 - - - + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Include items on invisible layers - + 0 - + 0 - + 1 m_checkBoxIncludeInvisible 1 - - + + protected 1 - - + + Resizable - + 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + + checkBoxClicked - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -1001,17 +1001,17 @@ 1 0 0 - + m_sdbSizer1 protected - + OnCancel - - - + + + ExecuteCommand - - + + diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp index fa0465708d..ec41ef731a 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp @@ -25,62 +25,28 @@ 1 0 - 1 - 1 - 1 - 1 - 0 - - - - + wxAUI_MGR_DEFAULT - - 1 - 0 - 1 1 - 0 - Dock - 0 - Left 1 impl_virtual - 1 - 0 0 wxID_ANY - - 0 - - 0 - 1 DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE - 1 - - - 1 - Resizable - 1 611,346 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER General settings - 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -478,10 +444,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -567,10 +529,6 @@ 0 Adjust the number of ratsnets shown from cursor to closest pads - - wxFILTER_NONE - wxDefaultValidator - 1 @@ -656,10 +614,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -745,10 +699,6 @@ 0 Delay after the first change to create a backup file of the board on disk. - - wxFILTER_NONE - wxDefaultValidator - 0 @@ -834,10 +784,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2111,10 +2057,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - diff --git a/pcbnew/dialogs/dialog_mask_clearance_base.fbp b/pcbnew/dialogs/dialog_mask_clearance_base.fbp index c4e8f1a9bf..08645184ce 100644 --- a/pcbnew/dialogs/dialog_mask_clearance_base.fbp +++ b/pcbnew/dialogs/dialog_mask_clearance_base.fbp @@ -1,6 +1,6 @@ - + C++ 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 d3fa83d413..24a34ad036 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -302,7 +302,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) } // Add graphic items (copper texts) and board edges - for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() ) + for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() ) { if( item->GetLayer() != GetLayer() && item->GetLayer() != EDGE_N ) continue; From 6468805c27d2861856bf83a925826169ac69aaff Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 16 Apr 2012 13:39:32 -0400 Subject: [PATCH 05/16] More internal unit improvements. * Move all convert from user to internal units into base_units.cpp. * Remove internal units parameters from all moved conversion functions. * Revise all source code that calls the moved conversion functions. * Remove internal units from all dialog text control helper classes. --- common/base_units.cpp | 102 ++++++++++++++++++ common/common.cpp | 97 ----------------- common/wxwineda.cpp | 72 +++++-------- eeschema/dialogs/dialog_SVG_print.cpp | 5 +- .../dialog_edit_component_in_schematic.cpp | 13 +-- eeschema/dialogs/dialog_edit_label.cpp | 2 +- .../dialog_edit_libentry_fields_in_lib.cpp | 12 +-- eeschema/dialogs/dialog_edit_one_field.cpp | 2 +- eeschema/dialogs/dialog_lib_edit_pin.cpp | 10 +- eeschema/dialogs/dialog_lib_edit_text.cpp | 2 +- .../dialogs/dialog_plot_schematic_HPGL.cpp | 12 +-- eeschema/dialogs/dialog_plot_schematic_PS.cpp | 4 +- eeschema/pinedit.cpp | 6 +- eeschema/sheet.cpp | 8 +- eeschema/sheetlab.cpp | 4 +- eeschema/symbdraw.cpp | 2 +- include/base_units.h | 21 ++++ include/common.h | 20 ---- include/dialog_helpers.h | 24 ++--- pcbnew/dialogs/dialog_SVG_print.cpp | 3 +- pcbnew/dialogs/dialog_copper_zones.cpp | 17 ++- pcbnew/dialogs/dialog_design_rules.cpp | 91 +++++++--------- pcbnew/dialogs/dialog_drc.cpp | 10 +- .../dialog_edit_module_for_BoardEditor.cpp | 13 +-- .../dialog_edit_module_for_Modedit.cpp | 11 +- pcbnew/dialogs/dialog_edit_module_text.cpp | 12 +-- .../dialog_graphic_item_properties.cpp | 12 +-- ...og_graphic_item_properties_for_Modedit.cpp | 12 +-- .../dialogs/dialog_graphic_items_options.cpp | 30 ++---- pcbnew/dialogs/dialog_mask_clearance.cpp | 6 +- pcbnew/dialogs/dialog_pad_properties.cpp | 38 +++---- pcbnew/dialogs/dialog_pcb_text_properties.cpp | 15 +-- pcbnew/dialogs/dialog_print_using_printer.cpp | 2 +- pcbnew/dimension.cpp | 15 +-- pcbnew/edgemod.cpp | 3 +- pcbnew/mirepcb.cpp | 6 +- pcbnew/muonde.cpp | 10 +- pcbnew/pcbplot.cpp | 10 +- pcbnew/set_grid.cpp | 4 +- pcbnew/zones_non_copper_type_functions.cpp | 3 +- 40 files changed, 323 insertions(+), 418 deletions(-) diff --git a/common/base_units.cpp b/common/base_units.cpp index 2c1a3fb794..985912e708 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -44,13 +44,19 @@ #if defined( USE_PCBNEW_NANOMETRES ) #define IU_TO_MM( x ) ( x * 1e-6 ) #define IU_TO_IN( x ) ( ( x * 1e-6 ) / 25.4 ) +#define MM_TO_IU( x ) ( x * 1e6 ) +#define IN_TO_IU( x ) ( ( x * 25.4 ) * 1e6 ) #else #define IU_TO_MM( x ) ( ( x * 0.0001 ) * 25.4 ) #define IU_TO_IN( x ) ( x * 0.0001 ) +#define MM_TO_IU( x ) ( ( x / 25.4 ) * 10000.0 ) +#define IN_TO_IU( x ) ( x * 10000.0 ) #endif #elif defined( EESCHEMA ) #define IU_TO_MM( x ) ( ( x * 0.001 ) * 25.4 ) #define IU_TO_IN( x ) ( x * 0.001 ) +#define MM_TO_IU( x ) ( ( x / 25.4 ) * 1000.0 ) +#define IN_TO_IU( x ) ( x * 1000.0 ) #else #error "Cannot resolve internal units due to no definition of EESCHEMA or PCBNEW." #endif @@ -159,3 +165,99 @@ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue ) aTextCtr.SetValue( msg ); } + + +int From_User_Unit( EDA_UNITS_T aUnit, double aValue ) +{ + double value; + + switch( aUnit ) + { + case MILLIMETRES: + value = MM_TO_IU( aValue ); + break; + + case INCHES: + value = IN_TO_IU( aValue ); + break; + + default: + case UNSCALED_UNITS: + + value = aValue; + } + + return wxRound( value ); +} + + + + +int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue ) +{ + int Value; + double dtmp = 0; + + // Acquire the 'right' decimal point separator + const struct lconv* lc = localeconv(); + wxChar decimal_point = lc->decimal_point[0]; + wxString buf( aTextValue.Strip( wxString::both ) ); + + // Convert the period in decimal point + buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) ); + + // An ugly fix needed by WxWidgets 2.9.1 that sometimes + // back to a point as separator, although the separator is the comma + // TODO: remove this line if WxWidgets 2.9.2 fixes this issue + buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) ); + + // Find the end of the numeric part + unsigned brk_point = 0; + + while( brk_point < buf.Len() ) + { + wxChar ch = buf[brk_point]; + + if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) ) + { + break; + } + + ++brk_point; + } + + // Extract the numeric part + buf.Left( brk_point ).ToDouble( &dtmp ); + + // Check the optional unit designator (2 ch significant) + wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() ); + + if( unit == wxT( "in" ) || unit == wxT( "\"" ) ) + { + aUnits = INCHES; + } + else if( unit == wxT( "mm" ) ) + { + aUnits = MILLIMETRES; + } + else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous + { + aUnits = INCHES; + dtmp /= 1000; + } + + Value = From_User_Unit( aUnits, dtmp ); + + return Value; +} + + +int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr ) +{ + int value; + wxString msg = aTextCtr.GetValue(); + + value = ReturnValueFromString( g_UserUnit, msg ); + + return value; +} diff --git a/common/common.cpp b/common/common.cpp index d9292d774c..be344278a3 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -253,76 +253,6 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit ) } -int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) -{ - int value; - wxString msg = TextCtr.GetValue(); - - value = ReturnValueFromString( g_UserUnit, msg, Internal_Unit ); - - return value; -} - - -int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit ) -{ - int Value; - double dtmp = 0; - - // Acquire the 'right' decimal point separator - const struct lconv* lc = localeconv(); - wxChar decimal_point = lc->decimal_point[0]; - wxString buf( TextValue.Strip( wxString::both ) ); - - // Convert the period in decimal point - buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) ); - - // An ugly fix needed by WxWidgets 2.9.1 that sometimes - // back to a point as separator, although the separator is the comma - // TODO: remove this line if WxWidgets 2.9.2 fixes this issue - buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) ); - - // Find the end of the numeric part - unsigned brk_point = 0; - - while( brk_point < buf.Len() ) - { - wxChar ch = buf[brk_point]; - - if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) ) - { - break; - } - - ++brk_point; - } - - // Extract the numeric part - buf.Left( brk_point ).ToDouble( &dtmp ); - - // Check the optional unit designator (2 ch significant) - wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() ); - - if( unit == wxT( "in" ) || unit == wxT( "\"" ) ) - { - aUnit = INCHES; - } - else if( unit == wxT( "mm" ) ) - { - aUnit = MILLIMETRES; - } - else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous - { - aUnit = INCHES; - dtmp /= 1000; - } - - Value = From_User_Unit( aUnit, dtmp, Internal_Unit ); - - return Value; -} - - wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ) { wxArrayString* list = new wxArrayString(); @@ -349,33 +279,6 @@ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ) } -/* - * Return in internal units the value "val" given in inch or mm - */ -int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) -{ - double value; - - switch( aUnit ) - { - case MILLIMETRES: - value = val * internal_unit_value / 25.4; - break; - - case INCHES: - value = val * internal_unit_value; - break; - - default: - case UNSCALED_UNITS: - - value = val; - } - - return wxRound( value ); -} - - /* * Return the string date "day month year" like "23 jun 2005" */ diff --git a/common/wxwineda.cpp b/common/wxwineda.cpp index b0105eaaa8..93192e28db 100644 --- a/common/wxwineda.cpp +++ b/common/wxwineda.cpp @@ -41,17 +41,14 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, int textsize, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, - int framelen, - int internal_unit ) + int framelen ) { m_UserUnit = user_unit; - m_Internal_Unit = internal_unit; m_Title = NULL; m_Title = new wxStaticText( parent, -1, Title ); - BoxSizer->Add( m_Title, 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); + BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit ); @@ -62,14 +59,12 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, wxString msg = _( "Size" ) + ReturnUnitSymbol( m_UserUnit ); wxStaticText* text = new wxStaticText( parent, -1, msg ); - BoxSizer->Add( text, 0, - wxGROW | wxLEFT | wxRIGHT, 5 ); + BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); } - wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textsize ); + wxString value = FormatSize( m_UserUnit, textsize ); - m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, - wxSize( 70, -1 ) ); + m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) ); BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); } @@ -84,11 +79,8 @@ EDA_GRAPHIC_TEXT_CTRL::~EDA_GRAPHIC_TEXT_CTRL() } -wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit, - int textSize ) +wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( EDA_UNITS_T aUnit, int textSize ) { - wxString value; - // Limiting the size of the text of reasonable values. if( textSize < 10 ) textSize = 10; @@ -96,10 +88,7 @@ wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit, if( textSize > 3000 ) textSize = 3000; - value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ), - To_User_Unit( aUnit, textSize ) ); - - return value; + return ReturnStringFromValue( aUnit, textSize ); } @@ -117,7 +106,7 @@ void EDA_GRAPHIC_TEXT_CTRL::SetValue( const wxString& value ) void EDA_GRAPHIC_TEXT_CTRL::SetValue( int textSize ) { - wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textSize ); + wxString value = FormatSize( m_UserUnit, textSize ); m_FrameSize->SetValue( value ); } @@ -129,12 +118,11 @@ const wxString EDA_GRAPHIC_TEXT_CTRL::GetText() const } -int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, - int internalUnit, EDA_UNITS_T aUnit ) +int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUnit ) { int textsize; - textsize = ReturnValueFromString( aUnit, sizeText, internalUnit ); + textsize = ReturnValueFromString( aUnit, sizeText ); // Limit to reasonable size if( textsize < 10 ) @@ -149,7 +137,7 @@ int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, int EDA_GRAPHIC_TEXT_CTRL::GetTextSize() { - return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_UserUnit ); + return ParseSize( m_FrameSize->GetValue(), m_UserUnit ); } @@ -166,13 +154,11 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit, EDA_UNITS_T user_unit, - wxBoxSizer* BoxSizer, - int internal_unit ) + wxBoxSizer* BoxSizer ) { wxString text; m_UserUnit = user_unit; - m_Internal_Unit = internal_unit; if( title.IsEmpty() ) text = _( "Pos " ); @@ -182,10 +168,8 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, text += _( "X" ) + ReturnUnitSymbol( m_UserUnit ); m_TextX = new wxStaticText( parent, -1, text ); - BoxSizer->Add( m_TextX, 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, - wxDefaultPosition ); + BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); + m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition ); BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); @@ -198,8 +182,7 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, m_TextY = new wxStaticText( parent, -1, text ); - BoxSizer->Add( m_TextY, 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); + BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString ); @@ -224,8 +207,8 @@ wxPoint EDA_POSITION_CTRL::GetValue() { wxPoint coord; - coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue(), m_Internal_Unit ); - coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue(), m_Internal_Unit ); + coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue() ); + coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue() ); return coord; } @@ -259,12 +242,10 @@ void EDA_POSITION_CTRL::SetValue( int x_value, int y_value ) /* EDA_SIZE_CTRL */ /*******************/ EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, - const wxSize& size_to_edit, - EDA_UNITS_T aUnit, wxBoxSizer* aBoxSizer, - int internal_unit ) : - EDA_POSITION_CTRL( parent, title, - wxPoint( size_to_edit.x, size_to_edit.y ), - aUnit, aBoxSizer, internal_unit ) + const wxSize& size_to_edit, EDA_UNITS_T aUnit, + wxBoxSizer* aBoxSizer ) : + EDA_POSITION_CTRL( parent, title, wxPoint( size_to_edit.x, size_to_edit.y ), + aUnit, aBoxSizer ) { } @@ -284,23 +265,20 @@ wxSize EDA_SIZE_CTRL::GetValue() /* Class to display and edit a dimension INCHES, MM, or other */ /**************************************************************/ EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, - int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, - int internal_unit ) + int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer ) { wxString label = title; m_UserUnit = user_unit; - m_Internal_Unit = internal_unit; m_Value = value; label += ReturnUnitSymbol( m_UserUnit ); m_Text = new wxStaticText( parent, -1, label ); - BoxSizer->Add( m_Text, 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); + BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value ); - m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue ); + m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue ); BoxSizer->Add( m_ValueCtrl, 0, @@ -321,7 +299,7 @@ int EDA_VALUE_CTRL::GetValue() int coord; wxString txtvalue = m_ValueCtrl->GetValue(); - coord = ReturnValueFromString( m_UserUnit, txtvalue, m_Internal_Unit ); + coord = ReturnValueFromString( m_UserUnit, txtvalue ); return coord; } diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index c7b6f6c974..ed26eb9ec1 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -92,8 +92,7 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) void DIALOG_SVG_PRINT::SetPenWidth() { - g_DrawDefaultLineThickness = - ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->GetInternalUnits() ); + g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DialogPenWidth ); if( g_DrawDefaultLineThickness > WIDTH_MAX_VALUE ) { @@ -118,7 +117,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) SetPenWidth(); g_DrawDefaultLineThickness = - ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->GetInternalUnits() ); + ReturnValueFromTextCtrl( *m_DialogPenWidth ); SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen(); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 0c7d971884..fed15cbe79 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -631,8 +631,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() else fieldValueTextCtrl->Enable( true ); - textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT, - g_UserUnit, field.m_Size.x ) ); + textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.m_Size.x ) ); wxPoint coord = field.m_Pos; wxPoint zero = -m_Cmp->m_Pos; // relative zero @@ -711,11 +710,11 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() setRowItem( fieldNdx, field ); // update fieldListCtrl - field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), - EESCHEMA_INTERNAL_UNIT, g_UserUnit ); + field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit ); field.m_Size.y = field.m_Size.x; int style = m_StyleRadioBox->GetSelection(); + if( (style & 1 ) != 0 ) field.m_Italic = true; else @@ -726,10 +725,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() else field.m_Bold = false; - field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(), - EESCHEMA_INTERNAL_UNIT ); - field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(), - EESCHEMA_INTERNAL_UNIT ); + field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() ); + field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() ); return true; } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 189603ca60..6c21700fa7 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -261,7 +261,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent ) m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); - value = ReturnValueFromString( g_UserUnit, text, m_Parent->GetInternalUnits() ); + value = ReturnValueFromString( g_UserUnit, text ); m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; if( m_TextShape ) diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index c1df45e904..df98b0f925 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -658,8 +658,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() fieldValueTextCtrl->SetValue( field.m_Text ); - textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT, - g_UserUnit, field.m_Size.x ) ); + textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.m_Size.x ) ); wxPoint coord = field.m_Pos; wxPoint zero; @@ -745,8 +744,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() setRowItem( fieldNdx, field ); // update fieldListCtrl - field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), - EESCHEMA_INTERNAL_UNIT, g_UserUnit ); + field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit ); field.m_Size.y = field.m_Size.x; @@ -761,10 +759,8 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() else field.m_Bold = false; - field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(), - EESCHEMA_INTERNAL_UNIT ); - field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(), - EESCHEMA_INTERNAL_UNIT ); + field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() ); + field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() ); // Note: the Y axis for components in lib is from bottom to top // and the screen axis is top to bottom: we must change the y coord sign for editing diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index 402f13557e..38e16bddd0 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -133,7 +133,7 @@ void DIALOG_EDIT_ONE_FIELD::TransfertDataToField() { m_textorient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; wxString msg = m_TextSize->GetValue(); - m_textsize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + m_textsize = ReturnValueFromString( g_UserUnit, msg ); switch( m_TextHJustificationOpt->GetSelection() ) { diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index c8676c2b8c..03a200498e 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -1,6 +1,8 @@ #include #include #include +#include + #include #include #include @@ -91,11 +93,11 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event ) { if( ! IsShown() ) // do nothing at init time return; - int units = ((LIB_EDIT_FRAME*)GetParent())->GetInternalUnits(); - int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize(), units ); - int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize(), units); + + int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize() ); + int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize()); int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() ); - int pinLength = ReturnValueFromString( g_UserUnit, GetLength(), units ); + int pinLength = ReturnValueFromString( g_UserUnit, GetLength() ); int pinShape = LIB_PIN::GetStyleCode( GetStyle() ); int pinType = GetElectricalType(); diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index c37ef9e0a9..17ad1d42fe 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -148,7 +148,7 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event ) Line = m_TextValue->GetValue(); m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; wxString msg = m_TextSize->GetValue(); - m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg ); m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; m_parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true; diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index f459b9d822..2308a4a8c4 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -207,19 +207,19 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptPlotOffset( wxCommandEvent& event ) { wxString msg = m_PlotOrgPosition_X->GetValue(); - s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT ); + s_Offset.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_PlotOrgPosition_Y->GetValue(); - s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT ); + s_Offset.y = ReturnValueFromString( g_UserUnit, msg ); } } void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( ) { - g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penWidthCtrl, - EESCHEMA_INTERNAL_UNIT); + g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penWidthCtrl ); + if( g_HPGL_Pen_Descr.m_Pen_Diam > 100 ) g_HPGL_Pen_Descr.m_Pen_Diam = 100; @@ -262,11 +262,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll ) { wxString msg = m_PlotOrgPosition_X->GetValue(); - s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT ); + s_Offset.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_PlotOrgPosition_Y->GetValue(); - s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT ); + s_Offset.y = ReturnValueFromString( g_UserUnit, msg ); } Plot_Schematic_HPGL( aPlotAll ); diff --git a/eeschema/dialogs/dialog_plot_schematic_PS.cpp b/eeschema/dialogs/dialog_plot_schematic_PS.cpp index 1e8f8a2888..9074b05ee2 100644 --- a/eeschema/dialogs/dialog_plot_schematic_PS.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_PS.cpp @@ -164,8 +164,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::initOptVars() m_plot_Sheet_Ref = m_Plot_Sheet_Ref_Ctrl->GetValue(); m_plotColorOpt = m_PlotPSColorOption->GetSelection(); m_pageSizeSelect = m_SizeOption->GetSelection(); - g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl, - EESCHEMA_INTERNAL_UNIT ); + g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl ); + if( g_DrawDefaultLineThickness < 1 ) g_DrawDefaultLineThickness = 1; } diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index b7b3a845b9..2bd61ae96e 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -119,10 +119,10 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) } // Save the pin properties to use for the next new pin. - LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize(), m_internalUnits ); - LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize(), m_internalUnits ); + LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize() ); + LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize() ); LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() ); - LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_internalUnits ); + LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength() ); LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() ); LastPinType = dlg.GetElectricalType(); LastPinCommonConvert = dlg.GetAddToAllBodyStyles(); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 149fef6578..c72a7c2898 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -189,13 +189,9 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) else if( loadFromFile ) aSheet->Load( this ); - aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit, - dlg.GetFileNameTextSize(), - m_internalUnits ) ); + aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit, dlg.GetFileNameTextSize() ) ); aSheet->SetName( dlg.GetSheetName() ); - aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit, - dlg.GetSheetNameTextSize(), - m_internalUnits ) ); + aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit, dlg.GetSheetNameTextSize() ) ); if( aSheet->GetName().IsEmpty() ) aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), aSheet->GetTimeStamp() ) ); diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index da16b9bae8..9e5b31ed34 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -85,8 +85,8 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ) } aSheetPin->m_Text = dlg.GetLabelName(); - aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_internalUnits ); - aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_internalUnits ); + aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight() ); + aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth() ); aSheetPin->SetShape( dlg.GetConnectionType() ); if( aDC ) diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 68d9ac2dd9..cf755624e2 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -82,7 +82,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) return; val = dialog.GetWidth(); - m_drawLineWidth = ReturnValueFromString( g_UserUnit, val, m_internalUnits ); + m_drawLineWidth = ReturnValueFromString( g_UserUnit, val ); m_drawSpecificConvert = !dialog.GetApplyToAllConversions(); m_drawSpecificUnit = !dialog.GetApplyToAllUnits(); diff --git a/include/base_units.h b/include/base_units.h index e68a118d0f..99f0301808 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -93,4 +93,25 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb */ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue ); +/** + * Return in internal units the value "val" given in inch or mm + */ +int From_User_Unit( EDA_UNITS_T aUnit, double aValue ); + +/** + * Function ReturnValueFromeString + * converts \a aTextValue in \a aUnits to internal units used by the application. + * + * @param aUnits The units of \a aTextValue. + * @param aTextValue A reference to a wxString object containing the string to convert. + * @return The string from Value, according to units (inch, mm ...) for display, + */ +int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue ); + +/** + * Convert the number Value in a string according to the internal units + * and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl + */ +int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr ); + #endif // _BASE_UNITS_H_ diff --git a/include/common.h b/include/common.h index 0d5b4032e4..4e10dc5f0e 100644 --- a/include/common.h +++ b/include/common.h @@ -557,23 +557,8 @@ wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit, wxString GetUnitsLabel( EDA_UNITS_T aUnits ); wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit ); -/** - * Function ReturnValueFromeString - * @return The string from Value, according to units (inch, mm ...) for display, - * and the initial unit for value - * Unit = display units (INCH, MM ..) - * Value = text - * Internal_Unit = units per inch for computed value - */ -int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit ); - void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit ); -/* Convert the number Value in a string according to the internal units - * and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl - **/ -int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ); - /** * Round to the nearest precision. * @@ -593,11 +578,6 @@ double RoundTo0( double x, double precision ); */ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ); -/** - * Return in internal units the value "val" given in inch or mm - */ -int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); - /** * Function GenDate * @return A wxString object containing the date in the format "day month year" like diff --git a/include/dialog_helpers.h b/include/dialog_helpers.h index 720fa2b498..6bfad7f7eb 100644 --- a/include/dialog_helpers.h +++ b/include/dialog_helpers.h @@ -70,7 +70,6 @@ class EDA_GRAPHIC_TEXT_CTRL { public: EDA_UNITS_T m_UserUnit; - int m_Internal_Unit; wxTextCtrl* m_FrameText; wxTextCtrl* m_FrameSize; @@ -80,8 +79,7 @@ private: public: EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title, const wxString& TextToEdit, int textsize, - EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200 ); ~EDA_GRAPHIC_TEXT_CTRL(); @@ -90,7 +88,7 @@ public: void Enable( bool state ); void SetTitle( const wxString& title ); - void SetFocus() { m_FrameText->SetFocus(); } + void SetFocus() { m_FrameText->SetFocus(); } void SetValue( const wxString& value ); void SetValue( int value ); @@ -98,10 +96,9 @@ public: * Function FormatSize * formats a string containing the size in the desired units. */ - static wxString FormatSize( int internalUnit, EDA_UNITS_T user_unit, int textSize ); + static wxString FormatSize( EDA_UNITS_T user_unit, int textSize ); - static int ParseSize( const wxString& sizeText, int internalUnit, - EDA_UNITS_T user_unit ); + static int ParseSize( const wxString& sizeText, EDA_UNITS_T user_unit ); }; @@ -113,7 +110,6 @@ class EDA_POSITION_CTRL { public: EDA_UNITS_T m_UserUnit; - int m_Internal_Unit; wxPoint m_Pos_To_Edit; wxTextCtrl* m_FramePosX; @@ -123,9 +119,7 @@ private: public: EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, - const wxPoint& pos_to_edit, - EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + const wxPoint& pos_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer ); ~EDA_POSITION_CTRL(); @@ -143,9 +137,7 @@ class EDA_SIZE_CTRL : public EDA_POSITION_CTRL { public: EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, - const wxSize& size_to_edit, - EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + const wxSize& size_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer ); ~EDA_SIZE_CTRL() { } wxSize GetValue(); @@ -162,13 +154,11 @@ public: int m_Value; wxTextCtrl* m_ValueCtrl; private: - int m_Internal_Unit; wxStaticText* m_Text; public: EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value, - EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer ); ~EDA_VALUE_CTRL(); diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 571180f76c..8b1196b269 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -135,8 +135,7 @@ void DIALOG_SVG_PRINT::initDialog( ) void DIALOG_SVG_PRINT::SetPenWidth() { - s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth, - m_Parent->GetInternalUnits() ); + s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth ); if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE ) { diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 252654a6ef..4a047dd6f0 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -382,8 +382,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab m_settings.m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1; wxString txtvalue = m_ZoneClearanceCtrl->GetValue(); - m_settings.m_ZoneClearance = - ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ); + m_settings.m_ZoneClearance = ReturnValueFromString( g_UserUnit, txtvalue ); // Test if this is a reasonnable value for this parameter // A too large value can hang Pcbnew @@ -395,18 +394,18 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab } txtvalue = m_ZoneMinThicknessCtrl->GetValue(); - m_settings.m_ZoneMinThickness = - ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ); + m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue ); + if( m_settings.m_ZoneMinThickness < 10 ) { DisplayError( this, - _( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) ); + _( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) ); return false; } m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() ); txtvalue = m_cornerSmoothingCtrl->GetValue(); - m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ) ); + m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue ) ); m_settings.m_ZonePriority = m_PriorityLevelCtrl->GetValue(); @@ -415,11 +414,9 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab else m_settings.m_Zone_45_Only = true; - m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue, PCB_INTERNAL_UNIT ); + m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue ); - m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( - *m_CopperWidthValue, - PCB_INTERNAL_UNIT ); + m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue ); m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (long) m_settings.m_ThermalReliefGap ); diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index 1913f65438..fb4f6b8827 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -531,7 +531,7 @@ void DIALOG_DESIGN_RULES::InitRulesList() static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units ) { #define MYCELL( col ) \ - ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ), units ) + ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ) ) nc->SetClearance( MYCELL( GRID_CLEARANCE ) ); nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) ); @@ -595,22 +595,17 @@ void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard() m_BrdSettings.m_CurrentViaType = VIA_BLIND_BURIED; // Update vias minimum values for DRC - m_BrdSettings.m_ViasMinSize = - ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->GetInternalUnits() ); - m_BrdSettings.m_ViasMinDrill = - ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->GetInternalUnits() ); + m_BrdSettings.m_ViasMinSize = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl ); + m_BrdSettings.m_ViasMinDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl ); m_BrdSettings.m_MicroViasAllowed = m_AllowMicroViaCtrl->GetSelection() == 1; // Update microvias minimum values for DRC - m_BrdSettings.m_MicroViasMinSize = - ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->GetInternalUnits() ); - m_BrdSettings.m_MicroViasMinDrill = - ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->GetInternalUnits() ); + m_BrdSettings.m_MicroViasMinSize = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl ); + m_BrdSettings.m_MicroViasMinDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl ); // Update tracks minimum values for DRC - m_BrdSettings.m_TrackMinWidth = - ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->GetInternalUnits() ); + m_BrdSettings.m_TrackMinWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl ); } @@ -625,9 +620,11 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard() for( int row = 0; row < m_gridTrackWidthList->GetNumberRows(); ++row ) { msg = m_gridTrackWidthList->GetCellValue( row, 0 ); + if( msg.IsEmpty() ) continue; - int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() ); + + int value = ReturnValueFromString( g_UserUnit, msg ); m_TracksWidthList.push_back( value ); } @@ -636,20 +633,25 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard() // Reinitialize m_TrackWidthList m_ViasDimensionsList.clear(); + for( int row = 0; row < m_gridViaSizeList->GetNumberRows(); ++row ) { msg = m_gridViaSizeList->GetCellValue( row, 0 ); + if( msg.IsEmpty() ) continue; - int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() ); + + int value = ReturnValueFromString( g_UserUnit, msg ); VIA_DIMENSION via_dim; via_dim.m_Diameter = value; msg = m_gridViaSizeList->GetCellValue( row, 1 ); + if( !msg.IsEmpty() ) { - value = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() ); + value = ReturnValueFromString( g_UserUnit, msg ); via_dim.m_Drill = value; } + m_ViasDimensionsList.push_back( via_dim ); } @@ -979,54 +981,46 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() wxString msg; - int minViaDia = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, - m_Parent->GetInternalUnits() ); - int minViaDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, - m_Parent->GetInternalUnits() ); - int minUViaDia = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, - m_Parent->GetInternalUnits() ); - int minUViaDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, - m_Parent->GetInternalUnits() ); - int minTrackWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, - m_Parent->GetInternalUnits() ); + int minViaDia = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl ); + int minViaDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl ); + int minUViaDia = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl ); + int minUViaDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl ); + int minTrackWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl ); for( int row = 0; row < m_grid->GetNumberRows(); row++ ) { int tracksize = ReturnValueFromString( g_UserUnit, - m_grid->GetCellValue( row, GRID_TRACKSIZE ), - m_Parent->GetInternalUnits() ); + m_grid->GetCellValue( row, GRID_TRACKSIZE ) ); if( tracksize < minTrackWidth ) { result = false; msg.Printf( _( "%s: Track Size < Min Track Size
" ), - GetChars( m_grid->GetRowLabelValue( row ) ) ); + GetChars( m_grid->GetRowLabelValue( row ) ) ); m_MessagesList->AppendToPage( msg ); } // Test vias int viadia = ReturnValueFromString( g_UserUnit, - m_grid->GetCellValue( row, GRID_VIASIZE ), - m_Parent->GetInternalUnits() ); + m_grid->GetCellValue( row, GRID_VIASIZE ) ); if( viadia < minViaDia ) { result = false; msg.Printf( _( "%s: Via Diameter < Minimun Via Diameter
" ), - GetChars( m_grid->GetRowLabelValue( row ) ) ); + GetChars( m_grid->GetRowLabelValue( row ) ) ); m_MessagesList->AppendToPage( msg ); } int viadrill = ReturnValueFromString( g_UserUnit, - m_grid->GetCellValue( row, GRID_VIADRILL ), - m_Parent->GetInternalUnits() ); + m_grid->GetCellValue( row, GRID_VIADRILL ) ); if( viadrill >= viadia ) { result = false; msg.Printf( _( "%s: Via DrillVia Dia
" ), - GetChars( m_grid->GetRowLabelValue( row ) ) ); + GetChars( m_grid->GetRowLabelValue( row ) ) ); m_MessagesList->AppendToPage( msg ); } @@ -1035,28 +1029,26 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() { result = false; msg.Printf( _( "%s: Via Drill < Min Via Drill
" ), - GetChars( m_grid->GetRowLabelValue( row ) ) ); + GetChars( m_grid->GetRowLabelValue( row ) ) ); m_MessagesList->AppendToPage( msg ); } // Test Micro vias int muviadia = ReturnValueFromString( g_UserUnit, - m_grid->GetCellValue( row, GRID_uVIASIZE ), - m_Parent->GetInternalUnits() ); + m_grid->GetCellValue( row, GRID_uVIASIZE ) ); if( muviadia < minUViaDia ) { result = false; msg.Printf( _( "%s: MicroVia Diameter < MicroVia Min Diameter
" ), - GetChars( m_grid->GetRowLabelValue( row ) ) ); + GetChars( m_grid->GetRowLabelValue( row ) ) ); m_MessagesList->AppendToPage( msg ); } int muviadrill = ReturnValueFromString( g_UserUnit, - m_grid->GetCellValue( row, GRID_uVIADRILL ), - m_Parent->GetInternalUnits() ); + m_grid->GetCellValue( row, GRID_uVIADRILL ) ); if( muviadrill >= muviadia ) { result = false; @@ -1084,14 +1076,13 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() if( tvalue.IsEmpty() ) continue; - int tracksize = ReturnValueFromString( g_UserUnit, - tvalue, - m_Parent->GetInternalUnits() ); + int tracksize = ReturnValueFromString( g_UserUnit, tvalue ); + if( tracksize < minTrackWidth ) { result = false; msg.Printf( _( "Extra Track %d Size %s < Min Track Size
" ), - row + 1, GetChars( tvalue ) ); + row + 1, GetChars( tvalue ) ); m_MessagesList->AppendToPage( msg ); } @@ -1112,18 +1103,18 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() if( tvalue.IsEmpty() ) continue; - int viadia = ReturnValueFromString( g_UserUnit, tvalue, - m_Parent->GetInternalUnits() ); + int viadia = ReturnValueFromString( g_UserUnit, tvalue ); int viadrill = 0; wxString drlvalue = m_gridViaSizeList->GetCellValue( row, 1 ); + if( !drlvalue.IsEmpty() ) - viadrill = ReturnValueFromString( g_UserUnit, drlvalue, - m_Parent->GetInternalUnits() ); + viadrill = ReturnValueFromString( g_UserUnit, drlvalue ); + if( viadia < minViaDia ) { result = false; msg.Printf( _( "Extra Via %d Size %s < Min Via Size
" ), - row + 1, GetChars( tvalue ) ); + row + 1, GetChars( tvalue ) ); m_MessagesList->AppendToPage( msg ); } @@ -1132,7 +1123,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() { result = false; msg.Printf( _( "Extra Via %d Size %s ≤ Drill Size %s
" ), - row + 1, GetChars( tvalue ), GetChars( drlvalue ) ); + row + 1, GetChars( tvalue ), GetChars( drlvalue ) ); m_MessagesList->AppendToPage( msg ); } @@ -1142,7 +1133,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() { result = false; msg.Printf( _( "Extra Via %d Size%s > 1 inch!
" ), - row + 1, GetChars( tvalue ) ); + row + 1, GetChars( tvalue ) ); m_MessagesList->AppendToPage( msg ); } diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 9c646fb400..d32cc939a8 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -130,12 +131,9 @@ void DIALOG_DRC_CONTROL::InitValues() */ void DIALOG_DRC_CONTROL::SetDrcParmeters( ) { - m_BrdSettings.m_TrackMinWidth = - ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->GetInternalUnits() ); - m_BrdSettings.m_ViasMinSize = - ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->GetInternalUnits() ); - m_BrdSettings.m_MicroViasMinSize = - ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->GetInternalUnits() ); + m_BrdSettings.m_TrackMinWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl ); + m_BrdSettings.m_ViasMinSize = ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl ); + m_BrdSettings.m_MicroViasMinSize = ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl ); m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings ); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 3c7652aea8..79b5cb2f27 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -479,12 +479,9 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) m_CurrentModule->m_Value->Copy( m_ValueCopy ); // Initialize masks clearances - m_CurrentModule->SetLocalClearance( - ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, m_Parent->GetInternalUnits() ) ); - m_CurrentModule->SetLocalSolderMaskMargin( - ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() ) ); - m_CurrentModule->SetLocalSolderPasteMargin( - ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() ) ); + m_CurrentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) ); + m_CurrentModule->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) ); + m_CurrentModule->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) ); double dtmp = 0.0; msg = m_SolderPasteMarginRatioCtrl->GetValue(); @@ -520,8 +517,8 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) } // Set Module Position - modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX, PCB_INTERNAL_UNIT ); - modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY, PCB_INTERNAL_UNIT ); + modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX ); + modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY ); m_CurrentModule->SetPosition( modpos ); if( m_AutoPlaceCtrl->GetSelection() == 1 ) diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 7b78f02849..8c2d9a3646 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -367,16 +367,11 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) m_CurrentModule->m_Value->Copy(m_ValueCopy ); // Initialize masks clearances - int internalUnit = m_Parent->GetInternalUnits(); + m_CurrentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) ); - m_CurrentModule->SetLocalClearance( - ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, internalUnit ) ); + m_CurrentModule->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) ); - m_CurrentModule->SetLocalSolderMaskMargin( - ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, internalUnit ) ); - - m_CurrentModule->SetLocalSolderPasteMargin( - ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, internalUnit ) ); + m_CurrentModule->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) ); double dtmp; wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); diff --git a/pcbnew/dialogs/dialog_edit_module_text.cpp b/pcbnew/dialogs/dialog_edit_module_text.cpp index 41b68095c9..b8024d1fcd 100644 --- a/pcbnew/dialogs/dialog_edit_module_text.cpp +++ b/pcbnew/dialogs/dialog_edit_module_text.cpp @@ -163,19 +163,17 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event ) wxPoint tmp; msg = m_TxtPosCtrlX->GetValue(); - tmp.x = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + tmp.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_TxtPosCtrlY->GetValue(); - tmp.y = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + tmp.y = ReturnValueFromString( g_UserUnit, msg ); m_currentText->SetPos0( tmp ); msg = m_TxtSizeCtrlX->GetValue(); - m_currentText->m_Size.x = ReturnValueFromString( g_UserUnit, msg, - m_parent->GetInternalUnits() ); + m_currentText->m_Size.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_TxtSizeCtrlY->GetValue(); - m_currentText->m_Size.y = ReturnValueFromString( g_UserUnit, msg, - m_parent->GetInternalUnits() ); + m_currentText->m_Size.y = ReturnValueFromString( g_UserUnit, msg ); // Test for a reasonnable size: if( m_currentText->m_Size.x< TEXTS_MIN_SIZE ) @@ -184,7 +182,7 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event ) m_currentText->m_Size.y = TEXTS_MIN_SIZE; msg = m_TxtWidthCtlr->GetValue(); - int width = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + int width = ReturnValueFromString( g_UserUnit, msg ); // Test for a reasonnable width: if( width <= 1 ) diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 02d1e49331..acb3c3925f 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -199,22 +199,22 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) m_Item->Draw( m_parent->GetCanvas(), m_DC, GR_XOR ); msg = m_Center_StartXCtrl->GetValue(); - m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); + m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_Center_StartYCtrl->GetValue(); - m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); + m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_EndX_Radius_Ctrl->GetValue(); - m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); + m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_EndY_Ctrl->GetValue(); - m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); + m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_ThicknessCtrl->GetValue(); - m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); + m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_DefaultThicknessCtrl->GetValue(); - int thickness = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + int thickness = ReturnValueFromString( g_UserUnit, msg ); m_Item->SetLayer( m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NO_COPPER_LAYER); diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp index 1d4da8117e..c524f4d461 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp @@ -213,24 +213,24 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) wxPoint coord; msg = m_Center_StartXCtrl->GetValue(); - coord.x = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + coord.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_Center_StartYCtrl->GetValue(); - coord.y = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + coord.y = ReturnValueFromString( g_UserUnit, msg ); m_item->SetStart( coord ); m_item->SetStart0( coord ); msg = m_EndX_Radius_Ctrl->GetValue(); - coord.x = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + coord.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_EndY_Ctrl->GetValue(); - coord.y = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + coord.y = ReturnValueFromString( g_UserUnit, msg ); m_item->SetEnd( coord ); m_item->SetEnd0( coord ); msg = m_ThicknessCtrl->GetValue(); - m_item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); + m_item->SetWidth( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_DefaultThicknessCtrl->GetValue(); - int thickness = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + int thickness = ReturnValueFromString( g_UserUnit, msg ); m_brdSettings.m_ModuleSegmentWidth = thickness; m_parent->SetDesignSettings( m_brdSettings ); diff --git a/pcbnew/dialogs/dialog_graphic_items_options.cpp b/pcbnew/dialogs/dialog_graphic_items_options.cpp index 2e364439b0..7b39406aa8 100644 --- a/pcbnew/dialogs/dialog_graphic_items_options.cpp +++ b/pcbnew/dialogs/dialog_graphic_items_options.cpp @@ -97,30 +97,20 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues() void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event ) { - m_brdSettings.m_DrawSegmentWidth = - ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT ); - m_brdSettings.m_EdgeSegmentWidth = - ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT ); - m_brdSettings.m_PcbTextWidth = - ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT ); - m_brdSettings.m_PcbTextSize.y = - ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT ); - m_brdSettings.m_PcbTextSize.x = - ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT ); + m_brdSettings.m_DrawSegmentWidth = ReturnValueFromTextCtrl( *m_OptPcbSegmWidth ); + m_brdSettings.m_EdgeSegmentWidth = ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth ); + m_brdSettings.m_PcbTextWidth = ReturnValueFromTextCtrl( *m_OptPcbTextWidth ); + m_brdSettings.m_PcbTextSize.y = ReturnValueFromTextCtrl( *m_OptPcbTextVSize ); + m_brdSettings.m_PcbTextSize.x = ReturnValueFromTextCtrl( *m_OptPcbTextHSize ); m_parent->GetBoard()->SetDesignSettings( m_brdSettings ); - m_brdSettings.m_ModuleSegmentWidth = - ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT ); - m_brdSettings.m_ModuleTextWidth = - ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT ); - m_brdSettings.m_ModuleTextSize.y = - ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT ); - m_brdSettings.m_ModuleTextSize.x = - ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT ); + m_brdSettings.m_ModuleSegmentWidth = ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth ); + m_brdSettings.m_ModuleTextWidth = ReturnValueFromTextCtrl( *m_OptModuleTextWidth ); + m_brdSettings.m_ModuleTextSize.y = ReturnValueFromTextCtrl( *m_OptModuleTextVSize ); + m_brdSettings.m_ModuleTextSize.x = ReturnValueFromTextCtrl( *m_OptModuleTextHSize ); - g_DrawDefaultLineThickness = - ReturnValueFromTextCtrl( *m_DefaultPenSizeCtrl, PCB_INTERNAL_UNIT ); + g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultPenSizeCtrl ); if( g_DrawDefaultLineThickness < 0 ) g_DrawDefaultLineThickness = 0; diff --git a/pcbnew/dialogs/dialog_mask_clearance.cpp b/pcbnew/dialogs/dialog_mask_clearance.cpp index eb862c6451..19a0b4ad38 100644 --- a/pcbnew/dialogs/dialog_mask_clearance.cpp +++ b/pcbnew/dialogs/dialog_mask_clearance.cpp @@ -83,11 +83,9 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit() void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event ) { - m_BrdSettings.m_SolderMaskMargin = - ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() ); + m_BrdSettings.m_SolderMaskMargin = ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ); - m_BrdSettings.m_SolderPasteMargin = - ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() ); + m_BrdSettings.m_SolderPasteMargin = ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ); double dtmp = 0; wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 18f7175157..3c26e9403d 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -848,7 +848,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) { long padLayerMask; - int internalUnits = m_Parent->GetInternalUnits(); wxString msg; int x, y; @@ -856,16 +855,11 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) aPad->SetShape( CodeShape[m_PadShape->GetSelection()] ); // Read pad clearances values: - aPad->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, - internalUnits ) ); - aPad->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, - internalUnits ) ); - aPad->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, - internalUnits ) ); - aPad->SetThermalWidth( ReturnValueFromTextCtrl( *m_ThermalWidthCtrl, - internalUnits ) ); - aPad->SetThermalGap( ReturnValueFromTextCtrl( *m_ThermalGapCtrl, - internalUnits ) ); + aPad->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) ); + aPad->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) ); + aPad->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) ); + aPad->SetThermalWidth( ReturnValueFromTextCtrl( *m_ThermalWidthCtrl ) ); + aPad->SetThermalGap( ReturnValueFromTextCtrl( *m_ThermalGapCtrl ) ); double dtmp = 0.0; msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); @@ -899,15 +893,15 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) } // Read pad position: - x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl, internalUnits ); - y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl, internalUnits ); + x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl ); + y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl ); aPad->SetPosition( wxPoint( x, y ) ); aPad->SetPos0( wxPoint( x, y ) ); // Read pad drill: - x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl, internalUnits ); - y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl, internalUnits ); + x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl ); + y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl ); if( m_DrillShapeCtrl->GetSelection() == 0 ) { @@ -920,24 +914,24 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) aPad->SetDrillSize( wxSize( x, y ) ); // Read pad shape size: - x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl, internalUnits ); - y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl, internalUnits ); + x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl ); + y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl ); if( aPad->GetShape() == PAD_CIRCLE ) y = x; aPad->SetSize( wxSize( x, y ) ); // Read pad length die - aPad->SetDieLength( ReturnValueFromTextCtrl( *m_LengthDieCtrl, internalUnits ) ); + aPad->SetDieLength( ReturnValueFromTextCtrl( *m_LengthDieCtrl ) ); // Read pad shape delta size: // m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid. wxSize delta; if( m_trapDeltaDirChoice->GetSelection() == 0 ) - delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits ); + delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl ); else - delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits ); + delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl ); // Test bad values (be sure delta values are not too large) // remember DeltaSize.x is the Y size variation @@ -970,8 +964,8 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) aPad->SetDelta( delta ); // Read pad shape offset: - x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits ); - y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits ); + x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl ); + y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl ); aPad->SetOffset( wxPoint( x, y ) ); double orient_value = 0; diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index 36cd766ef8..ded9a99770 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -219,17 +219,13 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) } // Set PCB Text position - newPosition.x = ReturnValueFromString( g_UserUnit, m_PositionXCtrl->GetValue(), - m_Parent->GetInternalUnits() ); - newPosition.y = ReturnValueFromString( g_UserUnit, m_PositionYCtrl->GetValue(), - m_Parent->GetInternalUnits() ); + newPosition.x = ReturnValueFromString( g_UserUnit, m_PositionXCtrl->GetValue() ); + newPosition.y = ReturnValueFromString( g_UserUnit, m_PositionYCtrl->GetValue() ); m_SelectedPCBText->m_Pos = newPosition; // Check constraints and set PCB Text size - newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue(), - m_Parent->GetInternalUnits() ); - newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue(), - m_Parent->GetInternalUnits() ); + newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue() ); + newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue() ); if( newSize.x < TEXTS_MIN_SIZE ) newSize.x = TEXTS_MIN_SIZE; @@ -247,8 +243,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) // Set the new thickness m_SelectedPCBText->m_Thickness = ReturnValueFromString( g_UserUnit, - m_ThicknessCtrl->GetValue(), - m_Parent->GetInternalUnits() ); + m_ThicknessCtrl->GetValue() ); // Test for acceptable values for thickness and size and clamp if fails int maxthickness = Clamp_Text_PenSize( m_SelectedPCBText->m_Thickness, diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp index 2824582bd0..56be0af084 100644 --- a/pcbnew/dialogs/dialog_print_using_printer.cpp +++ b/pcbnew/dialogs/dialog_print_using_printer.cpp @@ -385,7 +385,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth() // Get the new pen width value, and verify min et max value // NOTE: s_Parameters.m_PenDefaultSize is in internal units - s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_parent->GetInternalUnits() ); + s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth ); if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE ) { diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 235a7a4314..45d614ac3c 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -144,25 +144,20 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) // Get new size value: msg = m_TxtSizeXCtrl->GetValue(); - CurrentDimension->m_Text.m_Size.x = ReturnValueFromString( g_UserUnit, msg, - m_Parent->GetInternalUnits() ); + CurrentDimension->m_Text.m_Size.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_TxtSizeYCtrl->GetValue(); - CurrentDimension->m_Text.m_Size.y = ReturnValueFromString( g_UserUnit, msg, - m_Parent->GetInternalUnits() ); + CurrentDimension->m_Text.m_Size.y = ReturnValueFromString( g_UserUnit, msg ); // Get new position value: // It will be copied later in dimension, because msg = m_textCtrlPosX->GetValue(); - CurrentDimension->m_Text.m_Pos.x = ReturnValueFromString( g_UserUnit, msg, - m_Parent->GetInternalUnits() ); + CurrentDimension->m_Text.m_Pos.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_textCtrlPosY->GetValue(); - CurrentDimension->m_Text.m_Pos.y = ReturnValueFromString( g_UserUnit, msg, - m_Parent->GetInternalUnits() ); + CurrentDimension->m_Text.m_Pos.y = ReturnValueFromString( g_UserUnit, msg ); // Get new line thickness value: msg = m_TxtWidthCtrl->GetValue(); - int width = ReturnValueFromString( g_UserUnit, msg, - m_Parent->GetInternalUnits() ); + int width = ReturnValueFromString( g_UserUnit, msg ); int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text.m_Size ); if( width > maxthickness ) diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index d755ab1a50..f1d7b5beb9 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -246,8 +246,7 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) return; // canceled by user buffer = dlg.GetValue( ); - GetDesignSettings().m_ModuleSegmentWidth = - ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() ); + GetDesignSettings().m_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer ); if( aEdge ) { diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index c1a10f0981..61aa0f55ff 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -103,14 +103,12 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME // Size: m_MireSizeCtrl = new EDA_VALUE_CTRL( this, _( "Size" ), m_Target->GetSize(), - g_UserUnit, LeftBoxSizer, - m_Parent->GetInternalUnits() ); + g_UserUnit, LeftBoxSizer ); // Width: m_MireWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ), m_Target->GetWidth(), - g_UserUnit, LeftBoxSizer, - m_Parent->GetInternalUnits() ); + g_UserUnit, LeftBoxSizer ); // Shape wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) }; diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index ac8e31da57..8ae24e52fc 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -205,7 +205,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) return NULL; // canceled by user msg = dlg.GetValue(); - Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); + Mself.lng = ReturnValueFromString( g_UserUnit, msg ); // Control values (ii = minimum length) if( Mself.lng < min_len ) @@ -621,7 +621,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) } value = dlg.GetValue(); - gap_size = ReturnValueFromString( g_UserUnit, value, GetScreen()->GetInternalUnits() ); + gap_size = ReturnValueFromString( g_UserUnit, value ); bool abort = false; @@ -821,9 +821,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, wxRA_SPECIFY_COLS ); LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 ); - m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, - g_UserUnit, LeftBoxSizer, - PCB_INTERNAL_UNIT ); + m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, g_UserUnit, LeftBoxSizer ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); @@ -1094,7 +1092,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule ) return; // cancelled by user msg = dlg.GetValue(); - gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); + gap_size = ReturnValueFromString( g_UserUnit, msg ); // Updating sizes of pads forming the gap. int tw = GetBoard()->GetCurrentTrackWidth(); diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index da074ec1e2..57603b3ce8 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -450,7 +450,7 @@ void DIALOG_PLOT::applyPlotSettings() // since the values may have been constrained by the setters. // HPLG pen size wxString msg = m_HPGLPenSizeOpt->GetValue(); - int tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS ); + int tmp = ReturnValueFromString( g_UserUnit, msg ); if( !tempOptions.SetHpglPenDiameter( tmp ) ) { @@ -462,7 +462,7 @@ void DIALOG_PLOT::applyPlotSettings() // HPGL pen speed msg = m_HPGLPenSpeedOpt->GetValue(); - tmp = ReturnValueFromString( UNSCALED_UNITS, msg, 1 ); + tmp = ReturnValueFromString( UNSCALED_UNITS, msg ); if( !tempOptions.SetHpglPenSpeed( tmp ) ) { @@ -474,7 +474,7 @@ void DIALOG_PLOT::applyPlotSettings() // HPGL pen overlay msg = m_HPGLPenOverlayOpt->GetValue(); - tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS ); + tmp = ReturnValueFromString( g_UserUnit, msg ); if( !tempOptions.SetHpglPenOverlay( tmp ) ) { @@ -486,7 +486,7 @@ void DIALOG_PLOT::applyPlotSettings() // Default linewidth msg = m_linesWidth->GetValue(); - tmp = ReturnValueFromString( g_UserUnit, msg, PCB_INTERNAL_UNIT ); + tmp = ReturnValueFromString( g_UserUnit, msg ); if( !tempOptions.SetPlotLineWidth( tmp ) ) { @@ -527,7 +527,7 @@ void DIALOG_PLOT::applyPlotSettings() // PS Width correction msg = m_PSFineAdjustWidthOpt->GetValue(); - tmpDouble = ReturnValueFromString( g_UserUnit, msg, PCB_INTERNAL_UNIT ); + tmpDouble = ReturnValueFromString( g_UserUnit, msg ); if( !setDouble( &m_PSWidthAdjust, tmpDouble, m_WidthAdjustMinValue, m_WidthAdjustMaxValue ) ) { diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index a551eaef2f..1a230ad4ee 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -125,8 +125,8 @@ wxPoint DIALOG_SET_GRID::GetGridOrigin() wxPoint grid; /* TODO: Some error checking here would be a good thing. */ - grid.x = ReturnValueFromTextCtrl( *m_GridOriginXCtrl, m_internalUnits ); - grid.y = ReturnValueFromTextCtrl( *m_GridOriginYCtrl, m_internalUnits ); + grid.x = ReturnValueFromTextCtrl( *m_GridOriginXCtrl ); + grid.y = ReturnValueFromTextCtrl( *m_GridOriginYCtrl ); return grid; } diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp index 310343373c..9911a254be 100644 --- a/pcbnew/zones_non_copper_type_functions.cpp +++ b/pcbnew/zones_non_copper_type_functions.cpp @@ -128,8 +128,7 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::OnOkClick( wxCommandEvent& event ) { wxString txtvalue = m_ZoneMinThicknessCtrl->GetValue(); - m_settings.m_ZoneMinThickness = - ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ); + m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue ); if( m_settings.m_ZoneMinThickness < 10 ) { From bf5802f1f74a6d0753c098bb921ec353b00d433d Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 16 Apr 2012 19:31:29 -0400 Subject: [PATCH 06/16] Removal of internal units. * Remove internal units from BASE_SCREEN and it's derivatives. * Remove internal units from EDA_DRAW_FRAME and it's derivatives. * Use build time code to replace internal units conversions. * Fix scaling bug in page layout sample window that I created in my last commit. --- common/base_screen.cpp | 29 +++----------------- common/base_units.cpp | 4 +-- common/common_plot_functions.cpp | 5 ++-- common/copy_to_clipboard.cpp | 2 +- common/dialogs/dialog_page_settings.cpp | 36 +++++++++++++++++++------ common/drawframe.cpp | 1 - eeschema/dialogs/dialog_SVG_print.cpp | 3 ++- include/base_units.h | 2 +- include/class_base_screen.h | 12 ++++----- include/class_pcb_screen.h | 3 +-- include/wxstruct.h | 6 ----- pcbnew/basepcbframe.cpp | 1 - pcbnew/classpcb.cpp | 8 ++++-- pcbnew/dialogs/dialog_SVG_print.cpp | 9 ++++++- pcbnew/dialogs/dialog_design_rules.cpp | 14 +++++----- pcbnew/pcbframe.cpp | 2 -- pcbnew/set_grid.cpp | 4 --- 17 files changed, 68 insertions(+), 73 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 89c757134b..17dca59278 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #define CURSOR_SIZE 12 /// size of the cross cursor. @@ -86,12 +87,6 @@ void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU ) } -int BASE_SCREEN::GetInternalUnits( void ) -{ - return EESCHEMA_INTERNAL_UNIT; -} - - double BASE_SCREEN::GetScalingFactor() const { double scale = 1.0 / GetZoom(); @@ -320,30 +315,14 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id ) void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ) { - double x, y; wxRealPoint new_size; GRID_TYPE new_grid; - switch( aUnit ) - { - case MILLIMETRES: - x = size.x / 25.4; - y = size.y / 25.4; - break; - - default: - case INCHES: - case UNSCALED_UNITS: - x = size.x; - y = size.y; - break; - } - - new_size.x = x * GetInternalUnits(); - new_size.y = y * GetInternalUnits(); - + new_size.x = From_User_Unit( aUnit, size.x ); + new_size.y = From_User_Unit( aUnit, size.y ); new_grid.m_Id = id; new_grid.m_Size = new_size; + AddGrid( new_grid ); } diff --git a/common/base_units.cpp b/common/base_units.cpp index 985912e708..d020791fd7 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -167,7 +167,7 @@ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue ) } -int From_User_Unit( EDA_UNITS_T aUnit, double aValue ) +double From_User_Unit( EDA_UNITS_T aUnit, double aValue ) { double value; @@ -187,7 +187,7 @@ int From_User_Unit( EDA_UNITS_T aUnit, double aValue ) value = aValue; } - return wxRound( value ); + return value; } diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index cd140a1ae7..b74ac9f8ea 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -30,9 +30,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) wxPoint pos, ref; EDA_COLOR_T color; - // paper is sized in mils. Here is a conversion factor to - // scale mils to internal units. - int conv_unit = screen->GetInternalUnits() / 1000; + // Paper is sized in mils. Here is a conversion factor to scale mils to internal units. + int conv_unit = screen->MilsToIuScalar(); wxString msg; wxSize text_size; diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index e09e2a83a1..973768033f 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -72,7 +72,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame ) BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen(); /* scale is the ratio resolution/internal units */ - float scale = 82.0 / aFrame->GetInternalUnits(); + float scale = 82.0 / 1000.0 / (double) screen->MilsToIuScalar(); if( screen->IsBlockActive() ) { diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index e2421ac537..7adb5c73b0 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -26,7 +26,7 @@ */ #include -#include // DIM() +#include // DIM() #include #include #include @@ -34,6 +34,7 @@ #include #include #include +#include // MILS_TO_IU_SCALAR #include #include @@ -118,10 +119,12 @@ void DIALOG_PAGES_SETTINGS::initDialog() // initalize page format choice box and page format list. // The first shows translated strings, the second contains not tralated strings m_paperSizeComboBox->Clear(); + for( unsigned ii = 0; ; ii++ ) { if( pageFmts[ii].IsEmpty() ) break; + m_pageFmt.Add( pageFmts[ii] ); m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) ); } @@ -137,8 +140,8 @@ void DIALOG_PAGES_SETTINGS::initDialog() msg.Printf( format, m_Screen->m_ScreenNumber ); m_TextSheetNumber->SetLabel( msg ); #else - m_TextSheetCount->Show(false); - m_TextSheetNumber->Show(false); + m_TextSheetCount->Show( false ); + m_TextSheetNumber->Show( false ); #endif m_pageInfo = m_Parent->GetPageSettings(); @@ -251,10 +254,11 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event ) { m_save_flag = false; SavePageSettings( event ); + if( m_save_flag ) { - m_modified = true; - Close( true ); + m_modified = true; + Close( true ); } } @@ -268,9 +272,12 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event ) { int idx = m_paperSizeComboBox->GetSelection(); + if( idx < 0 ) idx = 0; + const wxString paperType = m_pageFmt[idx]; + if( paperType.Contains( PAGE_INFO::Custom ) ) { m_orientationComboBox->Enable( false ); @@ -280,14 +287,17 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event ) else { m_orientationComboBox->Enable( true ); + if( paperType.Contains( wxT( "A4" ) ) && IsGOST() ) { m_orientationComboBox->SetStringSelection( _( "Portrait" ) ); m_orientationComboBox->Enable( false ); - } + } + m_TextUserSizeX->Enable( false ); m_TextUserSizeY->Enable( false ); } + GetPageLayoutInfoFromDialog(); UpdatePageLayoutExample(); } @@ -407,8 +417,10 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) m_save_flag = true; int idx = m_paperSizeComboBox->GetSelection(); + if( idx < 0 ) idx = 0; + const wxString paperType = m_pageFmt[idx]; if( paperType.Contains( PAGE_INFO::Custom ) ) @@ -416,6 +428,7 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) GetCustomSizeMilsFromDialog(); retSuccess = m_pageInfo.SetType( PAGE_INFO::Custom ); + if( retSuccess ) { if( m_layout_size.x < MIN_PAGE_SIZE || m_layout_size.y < MIN_PAGE_SIZE || @@ -432,6 +445,7 @@ limits\n%.1f - %.1f %s!\nSelect another custom paper size?" ), m_save_flag = false; return; } + m_layout_size.x = Clamp( MIN_PAGE_SIZE, m_layout_size.x, MAX_PAGE_SIZE ); m_layout_size.y = Clamp( MIN_PAGE_SIZE, m_layout_size.y, MAX_PAGE_SIZE ); } @@ -595,6 +609,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() } m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 ); + if( m_page_bitmap->IsOk() ) { // Save current clip box and temporary expand it. @@ -602,7 +617,8 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() m_Parent->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( INT_MAX / 2, INT_MAX / 2 ) ) ); // Calculate layout preview scale. - int appScale = m_Parent->GetInternalUnits() / 1000; + int appScale = MILS_TO_IU_SCALAR; + double scaleW = (double) lyWidth / clamped_layout_size.x / appScale; double scaleH = (double) lyHeight / clamped_layout_size.y / appScale; @@ -630,7 +646,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() m_Parent->TraceWorkSheet( (wxDC*) &memDC, dummySize, pointLeftTop, pointRightBottom, emptyString, emptyString, m_tb, m_Screen->m_NumberOfScreen, - m_Screen->m_ScreenNumber, 1, LIGHTGRAY, RED ); + m_Screen->m_ScreenNumber, 1, appScale, LIGHTGRAY, RED ); memDC.SelectObject( wxNullBitmap ); m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap ); @@ -648,14 +664,17 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() { int idx = m_paperSizeComboBox->GetSelection(); + if( idx < 0 ) idx = 0; + const wxString paperType = m_pageFmt[idx]; // here we assume translators will keep original paper size spellings if( paperType.Contains( PAGE_INFO::Custom ) ) { GetCustomSizeMilsFromDialog(); + if( m_layout_size.x && m_layout_size.y ) { if( m_layout_size.x < m_layout_size.y ) @@ -687,6 +706,7 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() }; unsigned i; + for( i=0; i < DIM( papers ); ++i ) { if( paperType.Contains( *papers[i] ) ) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 14ca16430d..26bf5767b0 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -110,7 +110,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti m_snapToGrid = true; // Internal units per inch: = 1000 for schema, = 10000 for PCB - m_internalUnits = EESCHEMA_INTERNAL_UNIT; minsize.x = 470; minsize.y = 350 + m_MsgFrameHeight; diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index ed26eb9ec1..4dfb675f2e 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -215,7 +215,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, LOCALE_IO toggle; - float dpi = (float) frame->GetInternalUnits(); + float dpi = 1000.0; KicadSVGFileDC dc( FullFileName, sheetSize.x, sheetSize.y, dpi ); EDA_RECT tmp = *panel->GetClipBox(); @@ -227,6 +227,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) ); screen->m_IsPrinting = true; + if( frame->IsType( SCHEMATIC_FRAME ) ) screen->Draw( panel, &dc, GR_COPY ); diff --git a/include/base_units.h b/include/base_units.h index 99f0301808..0d505d81ec 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -96,7 +96,7 @@ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue ); /** * Return in internal units the value "val" given in inch or mm */ -int From_User_Unit( EDA_UNITS_T aUnit, double aValue ); +double From_User_Unit( EDA_UNITS_T aUnit, double aValue ); /** * Function ReturnValueFromeString diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 3c8abc128f..e3cac015de 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -158,14 +158,14 @@ public: wxString GetFileName() const { return m_fileName; } /** - * Function GetInternalUnits - * @return the screen units scalar. + * Function MilsToIuScalar + * returns the scalar required to convert mils to internal units. * - * Default implementation returns scalar used for schematic screen. The - * internal units used by the schematic screen is 1 mil (0.001"). Override - * this in derived classes that require internal units other than 1 mil. + * @note This is a temporary hack until the derived objects SCH_SCREEN and PCB_SCREEN + * no longer need to be derived from BASE_SCREEN. I does allow removal of the + * obsolete GetInternalUnits function. */ - virtual int GetInternalUnits( void ); + virtual int MilsToIuScalar() { return 1; } /** * Function GetCrossHairPosition diff --git a/include/class_pcb_screen.h b/include/class_pcb_screen.h index 46971bf64c..c7381f32af 100644 --- a/include/class_pcb_screen.h +++ b/include/class_pcb_screen.h @@ -37,7 +37,7 @@ public: void SetPreviousZoom(); void SetLastZoom(); - virtual int GetInternalUnits(); + virtual int MilsToIuScalar(); /** * Function GetCurItem @@ -57,7 +57,6 @@ public: */ void SetCurItem( BOARD_ITEM* aItem ) { BASE_SCREEN::SetCurItem( (EDA_ITEM*)aItem ); } - /* full undo redo management : */ // use BASE_SCREEN::ClearUndoRedoList() diff --git a/include/wxstruct.h b/include/wxstruct.h index 3439658654..0638ae84e2 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -387,10 +387,6 @@ protected: /// The area to draw on. EDA_DRAW_PANEL* m_canvas; - /// Internal units count that is equivalent to 1 inch. Set to 1000 (0.001") for - /// schematic drawing and 10000 (0.0001") for PCB drawing. - int m_internalUnits; - /// Tool ID of previously active draw tool bar button. int m_lastDrawToolId; @@ -477,8 +473,6 @@ public: void SetShowBorderAndTitleBlock( bool aShow ) { m_showBorderAndTitleBlock = aShow; } - int GetInternalUnits() const { return m_internalUnits; } - EDA_DRAW_PANEL* GetCanvas() { return m_canvas; } virtual wxString GetScreenDesc(); diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 3f0713e4e8..8e25126426 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -82,7 +82,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, long style) : EDA_DRAW_FRAME( father, idtype, title, pos, size, style ) { - m_internalUnits = PCB_INTERNAL_UNIT; // Internal unit = 1/10000 inch m_Pcb = NULL; m_DisplayPadFill = true; // How to draw pads diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 2fe09eecbc..b15e236ad4 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -125,9 +125,13 @@ PCB_SCREEN::~PCB_SCREEN() } -int PCB_SCREEN::GetInternalUnits() +int PCB_SCREEN::MilsToIuScalar() { - return PCB_INTERNAL_UNIT; +#if defined( USE_PCBNEW_NANOMETRES ) + return 25400; +#else + return 10; +#endif } diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 8b1196b269..19eea912fa 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -239,7 +239,14 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, screen->m_StartVisu.x = screen->m_StartVisu.y = 0; screen->SetScalingFactor( 1.0 ); - float dpi = (float)m_Parent->GetInternalUnits(); + + float dpi; + +#if defined( USE_PCBNEW_NANOMETRES ) + dpi = 25.4e6; +#else + dpi = 10000.0; +#endif EDA_DRAW_PANEL* panel = m_Parent->GetCanvas(); diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index fb4f6b8827..568d22149c 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -473,7 +473,7 @@ void DIALOG_DESIGN_RULES::InitializeRulesSelectionBoxes() /* Initialize the rules list from board */ -static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units ) +static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc ) { wxString msg; @@ -515,7 +515,7 @@ void DIALOG_DESIGN_RULES::InitRulesList() } // enter the Default NETCLASS. - class2gridRow( m_grid, 0, netclasses.GetDefault(), m_Parent->GetInternalUnits() ); + class2gridRow( m_grid, 0, netclasses.GetDefault() ); // enter others netclasses int row = 1; @@ -523,12 +523,12 @@ void DIALOG_DESIGN_RULES::InitRulesList() { NETCLASS* netclass = i->second; - class2gridRow( m_grid, row, netclass, m_Parent->GetInternalUnits() ); + class2gridRow( m_grid, row, netclass ); } } -static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units ) +static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc ) { #define MYCELL( col ) \ ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ) ) @@ -552,7 +552,7 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard() netclasses.Clear(); // Copy the default NetClass: - gridRow2class( m_grid, 0, netclasses.GetDefault(), m_Parent->GetInternalUnits() ); + gridRow2class( m_grid, 0, netclasses.GetDefault() ); // Copy other NetClasses : for( int row = 1; row < m_grid->GetNumberRows(); ++row ) @@ -565,13 +565,13 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard() // Should not occur because OnAddNetclassClick() tests for existing NetClass names wxString msg; msg.Printf( wxT( "CopyRulesListToBoard(): The NetClass \"%s\" already exists. Skip" ), - GetChars( m_grid->GetRowLabelValue( row ) ) ); + GetChars( m_grid->GetRowLabelValue( row ) ) ); wxMessageBox( msg ); delete nc; continue; } - gridRow2class( m_grid, row, nc, m_Parent->GetInternalUnits() ); + gridRow2class( m_grid, row, nc ); } // Now read all nets and push them in the corresponding netclass net buffer diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index c774239236..ed8e9d788d 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -315,8 +315,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); SetIcon( icon ); - m_internalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch - SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) ); // PCB drawings start in the upper left corner. diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index 1a230ad4ee..0ed158024a 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -16,9 +16,6 @@ class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE { -public: - int m_internalUnits; - public: DIALOG_SET_GRID( wxWindow* parent, const wxPoint& pos ); ~DIALOG_SET_GRID() { } @@ -41,7 +38,6 @@ void PCB_BASE_FRAME::InstallGridFrame( const wxPoint& pos ) { DIALOG_SET_GRID dlg( this, pos ); - dlg.m_internalUnits = m_internalUnits; dlg.SetGridUnits( m_UserGridUnit ); dlg.SetGridSize( m_UserGridSize ); dlg.SetGridOrigin( GetScreen()->m_GridOrigin ); From 3341669fc663df12f6606b4858cf3977e57428a6 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 16 Apr 2012 20:35:43 -0500 Subject: [PATCH 07/16] more footprint support for LEGACY_PLUGIN --- CMakeLists.txt | 2 - CMakeModules/config.h.cmake | 2 - common/CMakeLists.txt | 14 +- include/class_board_item.h | 30 -- include/wxBasePcbFrame.h | 44 +- pcbnew/CMakeLists.txt | 1 - pcbnew/class_board.h | 2 - pcbnew/class_board_connected_item.h | 6 - pcbnew/class_dimension.h | 4 - pcbnew/class_drawsegment.h | 4 - pcbnew/class_edge_mod.h | 4 - pcbnew/class_marker_pcb.h | 7 - pcbnew/class_mire.h | 4 - pcbnew/class_module.cpp | 1 + pcbnew/class_module.h | 31 +- pcbnew/class_netclass.h | 16 - pcbnew/class_netinfo.h | 12 - pcbnew/class_pad.cpp | 29 +- pcbnew/class_pad.h | 6 - pcbnew/class_pcb_text.h | 5 - pcbnew/class_text_mod.h | 10 - pcbnew/class_track.h | 2 - pcbnew/class_zone.h | 10 - .../dialog_edit_module_for_BoardEditor.cpp | 4 +- .../dialog_edit_module_for_Modedit.cpp | 5 +- pcbnew/files.cpp | 93 ---- pcbnew/gen_modules_placefile.cpp | 172 +++---- pcbnew/io_mgr.cpp | 18 +- pcbnew/io_mgr.h | 74 ++- pcbnew/{ioascii.cpp => ioascii.cpp.notused} | 0 pcbnew/{item_io.cpp => item_io.cpp.notused} | 0 pcbnew/legacy_plugin.cpp | 259 +++++++--- pcbnew/legacy_plugin.h | 20 +- pcbnew/librairi.cpp | 462 +++++++----------- pcbnew/loadcmp.cpp | 178 ++++--- 35 files changed, 698 insertions(+), 833 deletions(-) rename pcbnew/{ioascii.cpp => ioascii.cpp.notused} (100%) rename pcbnew/{item_io.cpp => item_io.cpp.notused} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20a86c8d9b..38a555006e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) option(USE_PCBNEW_SEXPR_FILE_FORMAT "Use s-expression Pcbnew file format support (default OFF)." ) -option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" ON) -option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" ON) option(USE_PCBNEW_NANOMETRES "Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).") diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake index 90e656c470..ff8454b84d 100644 --- a/CMakeModules/config.h.cmake +++ b/CMakeModules/config.h.cmake @@ -55,8 +55,6 @@ #cmakedefine USE_IMAGES_IN_MENUS 1 -#cmakedefine USE_NEW_PCBNEW_LOAD -#cmakedefine USE_NEW_PCBNEW_SAVE #cmakedefine USE_PCBNEW_NANOMETRES #cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 7320e92788..7f8b5ded35 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -116,21 +116,13 @@ set(PCB_COMMON_SRCS ../pcbnew/collectors.cpp ../pcbnew/sel_layer.cpp ../pcbnew/pcb_plot_params.cpp + ../pcbnew/io_mgr.cpp + ../pcbnew/legacy_plugin.cpp + ../pcbnew/kicad_plugin.cpp pcb_plot_params_keywords.cpp dialogs/dialog_page_settings.cpp ) -if( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE ) - set( PCB_COMMON_SRCS - ${PCB_COMMON_SRCS} - ../pcbnew/item_io.cpp - ../pcbnew/io_mgr.cpp - ../pcbnew/legacy_plugin.cpp - ../pcbnew/kicad_plugin.cpp - ) -else() - set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp ) -endif() # add -DPCBNEW to compilation of these PCBNEW sources set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES diff --git a/include/class_board_item.h b/include/class_board_item.h index bd7e5a6743..511760c2b3 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -98,26 +98,6 @@ public: BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; } BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; } -#if 0 - // DICK: there is no value in having a polymorphic {Get,Set}Position(). We never - // call GetPosition() using a generic pointer, and the virtual is slower and - // can never be inlined. - - /** - * Function GetPosition - * returns the position of this object. - * @return const wxPoint - The position of this object - */ - virtual const wxPoint GetPosition() const = 0; - - /** - * Function SetPosition - * sets the position of this object. - * @param aPos is the new position of this object - */ - virtual void SetPosition( const wxPoint& aPos ) = 0; -#endif - /** * Function GetLayer * returns the layer this item is on. @@ -173,7 +153,6 @@ public: return false; // only MODULEs can be locked at this time. } - /** * Function UnLink * detaches this object from its owner. This base class implementation @@ -191,21 +170,12 @@ public: delete this; } - /** * Function ShowShape * converts the enum STROKE_T integer value to a wxString. */ static wxString ShowShape( STROKE_T aShape ); - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - virtual bool Save( FILE* aFile ) const = 0; - // Some geometric transforms, that must be rewritten for derived classes /** * Function Move diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 60b3c438a9..75e2f781ae 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -373,20 +373,45 @@ public: // loading footprints /** - * Function GetModuleLibrary + * Function loadFootprintFromLibrary + * loads @a aFootprintName from @a aLibraryPath. + * If found add the module is also added to the BOARD, just for good measure. * - * Read active libraries or one library to find and load a given module - * If found the module is linked to the tail of linked list of modules * @param aLibraryFullFilename - the full filename of the library to read. If empty, * all active libraries are read - * @param aModuleName = module name to load - * @param aDisplayMessageError = true to display an error message if any. + * + * @param aFootprintName is the footprint to load + * + * @param aDisplayError = true to display an error message if any. + * + * @return MODULE* - new module, or NULL + */ + MODULE* loadFootprintFromLibrary( const wxString& aLibraryPath, + const wxString& aFootprintName, bool aDisplayError ); + + MODULE* loadFootprintFromLibraries( const wxString& aFootprintName, + bool aDisplayError ); + + /** + * Function GetModuleLibrary + * scans active libraries to find and load @a aFootprintName. + * If found add the module is also added to the BOARD, just for good measure. + * + * @param aFootprintName is the footprint to load + * + * @param aDisplayError = true to display an error message if any. + * * @return a pointer to the new module, or NULL * */ - MODULE* GetModuleLibrary( const wxString& aLibraryFullFilename, - const wxString& aModuleName, - bool aDisplayMessageError ); + MODULE* GetModuleLibrary( const wxString& aLibraryPath, const wxString& aFootprintName, + bool aDisplayError ) + { + if( !aLibraryPath ) + return loadFootprintFromLibraries( aFootprintName, aDisplayError ); + else + return loadFootprintFromLibrary( aLibraryPath, aFootprintName, aDisplayError ); + } /** * Function Select_1_Module_From_List @@ -409,7 +434,8 @@ public: /** * Function Load_Module_From_Library - * Open a dialog to select a footprint, and load in in current board + * opens a dialog to select a footprint, and loads it into current board. + * * @param aLibrary = the library name to use, or empty string to search * in all loaded libraries * @param aUseFootprintViewer = true to show the option diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 547a57beee..365cfa7971 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -136,7 +136,6 @@ set(PCBNEW_SRCS hotkeys_board_editor.cpp hotkeys_module_editor.cpp initpcb.cpp - ioascii.cpp layer_widget.cpp librairi.cpp loadcmp.cpp diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 3dae2934c3..115b2140e6 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -892,8 +892,6 @@ public: /***************************************************************************/ - bool Save( FILE* aFile ) const; - wxString GetClass() const { return wxT( "BOARD" ); diff --git a/pcbnew/class_board_connected_item.h b/pcbnew/class_board_connected_item.h index 431487c732..b2355ba249 100644 --- a/pcbnew/class_board_connected_item.h +++ b/pcbnew/class_board_connected_item.h @@ -135,14 +135,8 @@ public: */ } - bool Save( FILE* aFile ) const - { - return true; - } - //---------------------------------- - /** * Function GetCount * returns the number of BOARD_ITEMs. diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 648484ed8b..249cfd748b 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -88,10 +88,6 @@ public: */ void AdjustDimensionDetails( bool aDoNotChangeText = false ); - bool ReadDimensionDescr( LINE_READER* aReader ); - - bool Save( FILE* aFile ) const; - void SetText( const wxString& NewText ); const wxString GetText() const; diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 166c965763..fb32619e9c 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -152,10 +152,6 @@ public: m_PolyPoints = aPoints; } - bool Save( FILE* aFile ) const; - - bool ReadDrawSegmentDescr( LINE_READER* aReader ); - void Copy( DRAWSEGMENT* source ); void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 32cf0c00cd..f626fa35d0 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -64,10 +64,6 @@ public: void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; } const wxPoint& GetEnd0() const { return m_End0; } - bool Save( FILE* aFile ) const; - - int ReadDescr( LINE_READER* aReader ); - void SetDrawCoord(); /* drawing functions */ diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index a8d6b80129..05cd95e434 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -70,13 +70,6 @@ public: void DisplayInfo( EDA_DRAW_FRAME* frame ); - bool Save( FILE* aFile ) const - { - // not implemented, this is here to satisfy BOARD_ITEM::Save() - // "pure" virtual-ness - return true; - } - wxString GetSelectMenuText() const; BITMAP_DEF GetMenuImage() const { return drc_xpm; } diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index ab4aa42251..8d73f92163 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -86,10 +86,6 @@ public: void Flip( const wxPoint& aCentre ); - bool Save( FILE* aFile ) const; - - bool ReadMirePcbDescr( LINE_READER* aReader ); - void Copy( PCB_TARGET* source ); void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 27f0be46c7..bc5c615786 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -111,6 +111,7 @@ MODULE::MODULE( const MODULE& aModule ) : // Copy reference and value. m_Reference = new TEXTE_MODULE( *aModule.m_Reference ); m_Reference->SetParent( this ); + m_Value = new TEXTE_MODULE( *aModule.m_Value ); m_Value->SetParent( this ); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 246fc04953..135b0f8f1b 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -108,16 +108,6 @@ public: wxString m_Doc; // Module Description (info for users) wxString m_KeyWord; // Keywords to select the module in lib - // Local tolerances. When zero, this means the corresponding netclass value - // is used. Usually theses local tolerances zero, in deference to the - // corresponding netclass values. - int m_LocalClearance; - int m_LocalSolderMaskMargin; ///< Solder mask margin - int m_LocalSolderPasteMargin; ///< Solder paste margin - ///< absolute value - - double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio - ///< value of pad size // The final margin is the sum of these 2 values ZoneConnection m_ZoneConnection; @@ -236,14 +226,6 @@ public: void SetLastEditTime( long aTime ) { m_LastEdit_Time = aTime; } long GetLastEditTime() const { return m_LastEdit_Time; } - /* Reading and writing data on files */ - - bool Save( FILE* aFile ) const; - - int Write_3D_Descr( FILE* File ) const; - - int ReadDescr( LINE_READER* aReader ); - /** * Function Read_GPCB_Descr * reads a footprint description in GPCB format (newlib version) @@ -358,7 +340,18 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // overload #endif + +private: + // Local tolerances. When zero, this means the corresponding netclass value + // is used. Usually theses local tolerances zero, in deference to the + // corresponding netclass values. + int m_LocalClearance; + int m_LocalSolderMaskMargin; ///< Solder mask margin + int m_LocalSolderPasteMargin; ///< Solder paste margin + ///< absolute value + + double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio + ///< value of pad size }; - #endif // MODULE_H_ diff --git a/pcbnew/class_netclass.h b/pcbnew/class_netclass.h index e5f0923d4e..73fab5c8a1 100644 --- a/pcbnew/class_netclass.h +++ b/pcbnew/class_netclass.h @@ -198,22 +198,6 @@ public: */ void SetParams( const NETCLASS* defaults = NULL ); - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const; - - /** - * Function ReadDescr - * reads the data structures for this object from a LINE_READER in "*.brd" format. - * @param aReader is a pointer to a LINE_READER to read from. - * @return bool - true if success reading else false. - */ - bool ReadDescr( LINE_READER* aReader ); - /** * Function Format * outputs the net class to \a aFormatter in s-expression form. diff --git a/pcbnew/class_netinfo.h b/pcbnew/class_netinfo.h index 9df1b27c04..b5242a38b4 100644 --- a/pcbnew/class_netinfo.h +++ b/pcbnew/class_netinfo.h @@ -342,18 +342,6 @@ public: #endif - /* Reading and writing data on files */ - int ReadDescr( LINE_READER* aReader ); - - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" - * format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const; - /** * Function Draw * @todo we actually could show a NET, simply show all the tracks and diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 13cebb1509..cd9ae27c5f 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -332,9 +332,10 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const int clearance = m_LocalClearance; if( clearance == 0 ) - { // If local clearance is 0, use the parent footprint clearance value - if( GetParent() && ( (MODULE*) GetParent() )->m_LocalClearance ) - clearance = ( (MODULE*) GetParent() )->m_LocalClearance; + { + // If local clearance is 0, use the parent footprint clearance value + if( GetParent() && GetParent()->GetLocalClearance() ) + clearance = GetParent()->GetLocalClearance(); } if( clearance == 0 ) // If the parent footprint clearance value = 0, use NETCLASS value @@ -367,14 +368,14 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const int D_PAD::GetSolderMaskMargin() { int margin = m_LocalSolderMaskMargin; - MODULE* module = (MODULE*) GetParent(); + MODULE* module = GetParent(); if( module ) { if( margin == 0 ) { - if( module->m_LocalSolderMaskMargin ) - margin = module->m_LocalSolderMaskMargin; + if( module->GetLocalSolderMaskMargin() ) + margin = module->GetLocalSolderMaskMargin(); } if( margin == 0 ) @@ -408,26 +409,26 @@ int D_PAD::GetSolderMaskMargin() */ wxSize D_PAD::GetSolderPasteMargin() { - int margin = m_LocalSolderPasteMargin; - double mratio = m_LocalSolderPasteMarginRatio; - MODULE * module = (MODULE*) GetParent(); + int margin = m_LocalSolderPasteMargin; + double mratio = m_LocalSolderPasteMarginRatio; + MODULE* module = GetParent(); if( module ) { - if( margin == 0 ) - margin = module->m_LocalSolderPasteMargin; + if( margin == 0 ) + margin = module->GetLocalSolderPasteMargin(); BOARD * brd = GetBoard(); - if( margin == 0 ) + if( margin == 0 ) margin = brd->GetDesignSettings().m_SolderPasteMargin; if( mratio == 0.0 ) - mratio = module->m_LocalSolderPasteMarginRatio; + mratio = module->GetLocalSolderPasteMarginRatio(); if( mratio == 0.0 ) { - mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio; + mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio; } } diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index c2577d8f51..92b5c76e14 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -267,12 +267,6 @@ public: void SetThermalGap( int aGap ) { m_ThermalGap = aGap; } int GetThermalGap() const; - /* Reading and writing data on files */ - int ReadDescr( LINE_READER* aReader ); - - bool Save( FILE* aFile ) const; - - /* drawing functions */ void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset = ZeroOffset ); diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index c21bfca413..7df987a65e 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -73,11 +73,6 @@ public: void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset ); - // File Operations: - int ReadTextePcbDescr( LINE_READER* aReader ); - - bool Save( FILE* aFile ) const; - void DisplayInfo( EDA_DRAW_FRAME* frame ); bool HitTest( const wxPoint& aPosition ) diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index b64cd788be..e2f4136cbd 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -116,16 +116,6 @@ public: void SetLocalCoord(); // Set relative coordinates. - bool Save( FILE* aFile ) const; - - /** - * Function ReadDescr - * Read description from a given line in "*.brd" format. - * @param aReader is a pointer to a LINE_READER to read from. - * @return int - > 0 if success reading else 0. - */ - int ReadDescr( LINE_READER* aReader ); - /* drawing functions */ void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 7974d6ec24..328c1e0eb1 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -125,8 +125,6 @@ public: EDA_RECT GetBoundingBox() const; - bool Save( FILE* aFile ) const; - /** * Function GetBestInsertPoint * searches the "best" insertion point within the track linked list. diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index a3d93c5642..a7bea558d0 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -135,16 +135,6 @@ public: ~ZONE_CONTAINER(); - bool Save( FILE* aFile ) const; - - /** - * Function ReadDescr - * reads the data structures for this object from a LINE_READER in "*.brd" format. - * @param aReader is a pointer to a LINE_READER to read from. - * @return int - 1 if success, 0 if not. - */ - int ReadDescr( LINE_READER* aReader ); - /** * Function GetPosition * @return a wxPoint, position of the first point of the outline diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 3c7652aea8..227e8799f6 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -110,8 +110,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); - PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance ); - PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin ); + PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() ); // These 2 parameters are usually < 0, so prepare entering a negative // value, if current is 0 diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 7b78f02849..2f39cc06eb 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -149,8 +149,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); wxString msg; - PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance ); - PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin ); + PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() ); + // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0 PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 488ff3556f..803e07f8dd 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -202,70 +202,6 @@ the changes?" ) ) ) GetScreen()->SetFileName( fileName.GetFullPath() ); -#if !defined(USE_NEW_PCBNEW_LOAD) - - // Start read PCB file - FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) ); - - if( source == NULL ) - { - msg.Printf( _( "File <%s> not found" ), GetChars( GetScreen()->GetFileName() ) ); - DisplayError( this, msg ); - return false; - } - - FILE_LINE_READER fileReader( source, GetScreen()->GetFileName() ); - - FILTER_READER reader( fileReader ); - - // Read header and TEST if it is a PCB file format - reader.ReadLine(); - - if( strncmp( reader.Line(), "PCBNEW-BOARD", 12 ) != 0 ) - { - DisplayError( this, wxT( "Unknown file type" ) ); - return false; - } - - int ver; - sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver ); - - if ( ver > LEGACY_BOARD_FILE_VERSION ) - { - DisplayInfoMessage( this, _( "This file was created by a more recent \ -version of Pcbnew and may not load correctly. Please consider updating!" ) ); - } - else if ( ver < LEGACY_BOARD_FILE_VERSION ) - { - DisplayInfoMessage( this, _( "This file was created by an older \ -version of Pcbnew. It will be stored in the new file format when you save \ -this file again." ) ); - } - - // Reload the corresponding configuration file: - wxSetWorkingDirectory( wxPathOnly( GetScreen()->GetFileName() ) ); - - if( aAppend ) - { - ReadPcbFile( &reader, true ); - } - else - { - // Update the option toolbar - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - m_DisplayModText = DisplayOpt.DisplayModText; - m_DisplayModEdge = DisplayOpt.DisplayModEdge; - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - - // load project settings before BOARD, in case BOARD file has overrides. - LoadProjectSettings( GetScreen()->GetFileName() ); - - ReadPcbFile( &reader, false ); - } - -#else - if( !aAppend ) { // Update the option toolbar @@ -321,8 +257,6 @@ this file again." ) ); BestZoom(); } -#endif - GetScreen()->ClrModify(); // If append option: change the initial board name to -append.brd @@ -456,10 +390,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF pcbFileName = GetScreen()->GetFileName(); -#if defined( USE_NEW_PCBNEW_LOAD ) || defined( USE_NEW_PCBNEW_SAVE ) if( pcbFileName.GetExt().IsEmpty() ) pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) ); -#endif if( !IsWritable( pcbFileName ) ) return false; @@ -493,8 +425,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF } } -#if defined(USE_NEW_PCBNEW_SAVE) - GetBoard()->m_Status_Pcb &= ~CONNEXION_OK; GetBoard()->SynchronizeNetsAndNetClasses(); @@ -535,29 +465,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF UpdateTitle(); } -#else - // Create the file - FILE* dest; - dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) ); - - if( dest == 0 ) - { - msg = _( "Unable to create " ) + pcbFileName.GetFullPath(); - DisplayError( this, msg ); - saveok = false; - } - - if( dest ) - { - GetScreen()->SetFileName( pcbFileName.GetFullPath() ); - UpdateTitle(); - - SavePcbFormatAscii( dest ); - fclose( dest ); - } - -#endif - // Display the file names: m_messagePanel->EraseMsgBox(); diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 45334a7d4f..9d47667a62 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -532,7 +533,6 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) */ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM ) { - MODULE* Module; D_PAD* pad; char line[1024]; wxString fnFront, msg; @@ -550,9 +550,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool double conv_unit = aUnitsMM ? conv_unit_mm : conv_unit_inch; const char *unit_text = aUnitsMM ? unit_text_mm : unit_text_inch; - // Switch the locale to standard C (needed to print floating point - // numbers like 1.3) - SetLocaleTo_C_standard(); + LOCALE_IO toggle; // Generate header file comments.) sprintf( line, "## Module report - date %s\n", TO_UTF8( DateAndTime() ) ); @@ -584,103 +582,114 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool fputs( "$EndBOARD\n\n", rptfile ); - Module = (MODULE*) GetBoard()->m_Modules; - - for( ; Module != NULL; Module = Module->Next() ) + try { - sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() ); - fputs( line, rptfile ); + PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); - sprintf( line, "reference %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() ); - fputs( line, rptfile ); - sprintf( line, "value %s\n", EscapedUTF8( Module->m_Value->m_Text ).c_str() ); - fputs( line, rptfile ); - sprintf( line, "footprint %s\n", EscapedUTF8( Module->m_LibRef ).c_str() ); - fputs( line, rptfile ); + LEGACY_PLUGIN* legacy = (LEGACY_PLUGIN*) (PLUGIN*) pi; - msg = wxT( "attribut" ); + legacy->SetFilePtr( rptfile ); - if( Module->m_Attributs & MOD_VIRTUAL ) - msg += wxT( " virtual" ); - - if( Module->m_Attributs & MOD_CMS ) - msg += wxT( " smd" ); - - if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 ) - msg += wxT( " none" ); - - msg += wxT( "\n" ); - fputs( TO_UTF8( msg ), rptfile ); - - module_pos = Module->m_Pos; - module_pos.x -= File_Place_Offset.x; - module_pos.y -= File_Place_Offset.y; - - sprintf( line, "position %9.6f %9.6f\n", - module_pos.x * conv_unit, - module_pos.y * conv_unit ); - fputs( line, rptfile ); - - sprintf( line, "orientation %.2f\n", (double) Module->m_Orient / 10 ); - - if( Module->GetLayer() == LAYER_N_FRONT ) - strcat( line, "layer component\n" ); - else if( Module->GetLayer() == LAYER_N_BACK ) - strcat( line, "layer copper\n" ); - else - strcat( line, "layer other\n" ); - - fputs( line, rptfile ); - - Module->Write_3D_Descr( rptfile ); - - for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) + for( MODULE* Module = GetBoard()->m_Modules; Module; Module = Module->Next() ) { - fprintf( rptfile, "$PAD \"%s\"\n", TO_UTF8( pad->GetPadName() ) ); + sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() ); + fputs( line, rptfile ); + + sprintf( line, "reference %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() ); + fputs( line, rptfile ); + sprintf( line, "value %s\n", EscapedUTF8( Module->m_Value->m_Text ).c_str() ); + fputs( line, rptfile ); + sprintf( line, "footprint %s\n", EscapedUTF8( Module->m_LibRef ).c_str() ); + fputs( line, rptfile ); + + msg = wxT( "attribut" ); + + if( Module->m_Attributs & MOD_VIRTUAL ) + msg += wxT( " virtual" ); + + if( Module->m_Attributs & MOD_CMS ) + msg += wxT( " smd" ); + + if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 ) + msg += wxT( " none" ); + + msg += wxT( "\n" ); + fputs( TO_UTF8( msg ), rptfile ); + + module_pos = Module->m_Pos; + module_pos.x -= File_Place_Offset.x; + module_pos.y -= File_Place_Offset.y; + sprintf( line, "position %9.6f %9.6f\n", - pad->GetPos0().x * conv_unit, - pad->GetPos0().y * conv_unit ); + module_pos.x * conv_unit, + module_pos.y * conv_unit ); fputs( line, rptfile ); - sprintf( line, "size %9.6f %9.6f\n", - pad->GetSize().x * conv_unit, - pad->GetSize().y * conv_unit ); + sprintf( line, "orientation %.2f\n", (double) Module->m_Orient / 10 ); + + if( Module->GetLayer() == LAYER_N_FRONT ) + strcat( line, "layer component\n" ); + else if( Module->GetLayer() == LAYER_N_BACK ) + strcat( line, "layer copper\n" ); + else + strcat( line, "layer other\n" ); + fputs( line, rptfile ); - sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit ); - fputs( line, rptfile ); + legacy->SaveModule3D( Module ); - sprintf( line, "shape_offset %9.6f %9.6f\n", - pad->GetOffset().x * conv_unit, - pad->GetOffset().y * conv_unit ); - fputs( line, rptfile ); + for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) + { + fprintf( rptfile, "$PAD \"%s\"\n", TO_UTF8( pad->GetPadName() ) ); + sprintf( line, "position %9.6f %9.6f\n", + pad->GetPos0().x * conv_unit, + pad->GetPos0().y * conv_unit ); + fputs( line, rptfile ); - sprintf( line, "orientation %.2f\n", - double(pad->GetOrientation() - Module->GetOrientation()) / 10 ); - fputs( line, rptfile ); + sprintf( line, "size %9.6f %9.6f\n", + pad->GetSize().x * conv_unit, + pad->GetSize().y * conv_unit ); + fputs( line, rptfile ); - static const char* shape_name[6] = { "??? ", "Circ", "Rect", "Oval", "trap", "spec" }; + sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit ); + fputs( line, rptfile ); - sprintf( line, "Shape %s\n", shape_name[pad->GetShape()] ); - fputs( line, rptfile ); + sprintf( line, "shape_offset %9.6f %9.6f\n", + pad->GetOffset().x * conv_unit, + pad->GetOffset().y * conv_unit ); + fputs( line, rptfile ); - int layer = 0; + sprintf( line, "orientation %.2f\n", + double(pad->GetOrientation() - Module->GetOrientation()) / 10 ); + fputs( line, rptfile ); - if( pad->GetLayerMask() & LAYER_BACK ) - layer = 1; + static const char* shape_name[6] = { "??? ", "Circ", "Rect", "Oval", "trap", "spec" }; - if( pad->GetLayerMask() & LAYER_FRONT ) - layer |= 2; + sprintf( line, "Shape %s\n", shape_name[pad->GetShape()] ); + fputs( line, rptfile ); - static const char* layer_name[4] = { "??? ", "copper", "component", "all" }; + int layer = 0; - sprintf( line, "Layer %s\n", layer_name[layer] ); - fputs( line, rptfile ); - fprintf( rptfile, "$EndPAD\n" ); + if( pad->GetLayerMask() & LAYER_BACK ) + layer = 1; + + if( pad->GetLayerMask() & LAYER_FRONT ) + layer |= 2; + + static const char* layer_name[4] = { "??? ", "copper", "component", "all" }; + + sprintf( line, "Layer %s\n", layer_name[layer] ); + fputs( line, rptfile ); + fprintf( rptfile, "$EndPAD\n" ); + } + + fprintf( rptfile, "$EndMODULE %s\n\n", + TO_UTF8(Module->m_Reference->m_Text ) ); } - - fprintf( rptfile, "$EndMODULE %s\n\n", - TO_UTF8(Module->m_Reference->m_Text ) ); + } + catch( IO_ERROR ioe ) + { + DisplayError( NULL, ioe.errorText ); } // Write board Edges @@ -700,7 +709,6 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool // Generate EOF. fputs( "$EndDESCRIPTION\n", rptfile ); fclose( rptfile ); - SetLocaleTo_Default( ); // revert to the current locale return true; } diff --git a/pcbnew/io_mgr.cpp b/pcbnew/io_mgr.cpp index 4b8e2fac40..0112ae3978 100644 --- a/pcbnew/io_mgr.cpp +++ b/pcbnew/io_mgr.cpp @@ -170,7 +170,7 @@ MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFo } -void PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties ) +void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties ) { // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); @@ -184,7 +184,21 @@ void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo } -bool PLUGIN::IsLibraryWritable( const wxString& aLibraryPath ) +void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + + +void PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties ) +{ + // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. + THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); +} + + +bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) { // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) ); diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 67d88d2bf1..cf5b667033 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -153,7 +153,9 @@ public: * is a base class that BOARD loading and saving plugins should derive from. * Implementations can provide either Load() or Save() functions, or both. * PLUGINs throw exceptions, so it is best that you wrap your calls to these - * functions in a try catch block. + * functions in a try catch block. Plugins throw exceptions because it is illegal + * for them to have any user interface calls in them whatsoever, i.e. no windowing + * or screen printing at all. * *
  *   try
@@ -188,9 +190,9 @@ public:
 
     /**
      * Function Load
-     * loads a board file, or a portion of one, from some input file format
-     * that this PLUGIN implementation knows about. This may be used to load an
-     * entire new BOARD, or to augment an existing one if \a aAppendToMe is not NULL.
+     * loads information from some input file format that this PLUGIN implementation
+     * knows about, into either a new BOARD or an existing one. This may be used to load an
+     * entire new BOARD, or to augment an existing one if @a aAppendToMe is not NULL.
      *
      * @param aFileName is the name of the file to use as input and may be foreign in
      *  nature or native in nature.
@@ -217,7 +219,7 @@ public:
 
     /**
      * Function Save
-     * will write a full aBoard to a storage file in a format that this
+     * will write @a aBoard to a storage file in a format that this
      * PLUGIN implementation knows about, or it can be used to write a portion of
      * aBoard to a special kind of export file.
      *
@@ -242,7 +244,7 @@ public:
      * Function FootprintEnumerate
      * returns a list of footprint names contained within the library at @a aLibraryPath.
      *
-     * @param aLibraryPath is locator for the "library", usually a directory
+     * @param aLibraryPath is a locator for the "library", usually a directory
      *   or file containing several footprints.
      *
      * @param aProperties is an associative array that can be used to tell the
@@ -262,7 +264,7 @@ public:
      * loads a MODULE having @a aFootprintName from the @a aLibraryPath containing
      * a library format that this PLUGIN knows about.
      *
-     * @param aLibraryPath is locator for the "library", usually a directory
+     * @param aLibraryPath is a locator for the "library", usually a directory
      *   or file containing several footprints.
      *
      * @param aFootprintName is the name of the footprint to load.
@@ -273,21 +275,20 @@ public:
      *  The caller continues to own this object (plugin may not delete it), and
      *  plugins should expect it to be optionally NULL.
      *
-     * @return  MODULE* - caller owns it.  Never NULL because exception thrown if error.
+     * @return  MODULE* - if found caller owns it, else NULL if not found.
      *
-     * @throw   IO_ERROR if the PLUGIN cannot be found, library cannot be found,
-     *          or footprint cannot be loaded.
+     * @throw   IO_ERROR if the library cannot be found or read.  No exception
+     *          is thrown in the case where aFootprintName cannot be found.
      */
     virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
                                     PROPERTIES* aProperties = NULL );
 
     /**
      * Function FootprintSave
-     * will write @a aModule to an existing library located at @a aLibraryPath,
-     * and create the library if it doesn't exist then perform the write.  If a
-     * footprint by the same name already exists, it is replaced.
+     * will write @a aModule to an existing library located at @a aLibraryPath.
+     * If a footprint by the same name already exists, it is replaced.
      *
-     * @param aLibraryPath is locator for the "library", usually a directory
+     * @param aLibraryPath is a locator for the "library", usually a directory
      *      or file containing several footprints. This is where the footprint is
      *      to be stored.
      *
@@ -302,14 +303,14 @@ public:
      *
      * @throw IO_ERROR if there is a problem saving.
      */
-    virtual void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint,
+    virtual void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
                                     PROPERTIES* aProperties = NULL );
 
     /**
      * Function FootprintDelete
      * deletes the @a aFootprintName from the library at @a aLibraryPath.
      *
-     * @param aLibraryPath is locator for the "library", usually a directory
+     * @param aLibraryPath is a locator for the "library", usually a directory
      *   or file containing several footprints.
      *
      * @param aFootprintName is the name of a footprint to delete from the specificed library.
@@ -319,11 +320,48 @@ public:
     virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
 
     /**
-     * Function IsLibraryWritable
+     * Function FootprintLibCreate
+     * creates a new empty footprint library at @a aLibraryPath empty.  It is an
+     * error to attempt to create an existing library or to attempt to create
+     * on a "read only" location.
+     *
+     * @param aLibraryPath is a locator for the "library", usually a directory
+     *   or file which will contain footprints.
+     *
+     * @param aProperties is an associative array that can be used to tell the
+     *  library create function anything special, because it can take any number of
+     *  additional named tuning arguments that the plugin is known to support.
+     *  The caller continues to own this object (plugin may not delete it), and
+     *  plugins should expect it to be optionally NULL.
+     *
+     * @throw IO_ERROR if there is a problem finding the library, or creating it.
+     */
+    virtual void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
+
+    /**
+     * Function FootprintLibDelete
+     * deletes an existing footprint library, or complains if it cannot delete it or if it
+     * does not exist.
+     *
+     * @param aLibraryPath is a locator for the "library", usually a directory
+     *   or file which will contain footprints.
+     *
+     * @param aProperties is an associative array that can be used to tell the
+     *  library create function anything special, because it can take any number of
+     *  additional named tuning arguments that the plugin is known to support.
+     *  The caller continues to own this object (plugin may not delete it), and
+     *  plugins should expect it to be optionally NULL.
+     *
+     * @throw IO_ERROR if there is a problem finding the library, or deleting it.
+     */
+    virtual void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
+
+    /**
+     * Function IsFootprintLibWritable
      * returns true iff the library at @a aLibraryPath is writable.  (Often
      * system libraries are read only because of where they are installed.)
      */
-    virtual bool IsLibraryWritable( const wxString& aLibraryPath );
+    virtual bool IsFootprintLibWritable( const wxString& aLibraryPath );
 
     //-----------------------------------------------------
 
diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp.notused
similarity index 100%
rename from pcbnew/ioascii.cpp
rename to pcbnew/ioascii.cpp.notused
diff --git a/pcbnew/item_io.cpp b/pcbnew/item_io.cpp.notused
similarity index 100%
rename from pcbnew/item_io.cpp
rename to pcbnew/item_io.cpp.notused
diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp
index e44f5c9105..8caed9fe1c 100644
--- a/pcbnew/legacy_plugin.cpp
+++ b/pcbnew/legacy_plugin.cpp
@@ -2,7 +2,7 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck 
+ * Copyright (C) 2007-2012 SoftPLC Corporation, Dick Hollenbeck 
  * Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
  * Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
 
@@ -98,6 +98,8 @@
 #define SZ( x )         (sizeof(x)-1)
 
 
+//--------------------------------------------------------
+
 /// C string compare test for a specific length of characters.
 #define TESTLINE( x )   ( !strnicmp( line, x, SZ( x ) ) && isspace( line[SZ( x )] ) )
 
@@ -345,7 +347,7 @@ void LEGACY_PLUGIN::loadGENERAL()
 
             if( !strcmp( data, "mm" ) )
             {
-#if defined(USE_PCBNEW_NANOMETRES)
+#if defined( USE_PCBNEW_NANOMETRES )
                 diskToBiu = 1000000.0;
 
 #elif defined(DEBUG)
@@ -940,7 +942,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
 
         else if( TESTLINE( "Li" ) )         // Library name of footprint
         {
-            module->m_LibRef = FROM_UTF8( StrPurge( line + SZ( "Li" ) ) );
+            module->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
         }
 
         else if( TESTLINE( "Sc" ) )         // timestamp
@@ -2679,13 +2681,12 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
     m_props = aProperties;
 
     // conversion factor for saving RAM BIUs to KICAD legacy file format.
-#if defined(USE_PCBNEW_NANOMETRES)
+#if defined( USE_PCBNEW_NANOMETRES )
     biuToDisk = 1/1000000.0;        // BIUs are nanometers & file is mm
 #else
     biuToDisk = 1.0;                // BIUs are deci-mils
 #endif
 
-
     // conversion factor for loading KICAD legacy file format into BIUs in RAM
 
     // Start by assuming the *.brd file is in deci-mils.
@@ -2693,7 +2694,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
     // then, during the file loading process, to start a conversion from
     // mm to nanometers.
 
-#if defined(USE_PCBNEW_NANOMETRES)
+#if defined( USE_PCBNEW_NANOMETRES )
     diskToBiu = 2540.0;             // BIUs are nanometers
 #else
     diskToBiu = 1.0;                // BIUs are deci-mils
@@ -2701,7 +2702,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
 }
 
 
-//------------------------------------------------------------
+//--------------------------------------------------------
 
 void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
 {
@@ -2768,7 +2769,7 @@ void LEGACY_PLUGIN::saveGENERAL() const
     fprintf( m_fp, "encoding utf-8\n" );
 
     // tell folks the units used within the file, as early as possible here.
-#if defined(USE_PCBNEW_NANOMETRES)
+#if defined( USE_PCBNEW_NANOMETRES )
     fprintf( m_fp, "Units mm\n" );
 #else
     fprintf( m_fp, "Units deci-mils\n" );
@@ -2958,7 +2959,7 @@ void LEGACY_PLUGIN::saveBOARD() const
 
     // save the modules
     for( MODULE* m = m_board->m_Modules;  m;  m = (MODULE*) m->Next() )
-        saveMODULE( m );
+        SaveMODULE( m );
 
     // save the graphics owned by the board (not owned by a module)
     for( BOARD_ITEM* gr = m_board->m_Drawings;  gr;  gr = gr->Next() )
@@ -3231,8 +3232,9 @@ void LEGACY_PLUGIN::savePAD( const D_PAD* me ) const
     if( me->GetLocalSolderPasteMargin() != 0 )
         fprintf( m_fp, ".SolderPaste %s\n", fmtBIU( me->GetLocalSolderPasteMargin() ).c_str() );
 
-    if( me->GetLocalSolderPasteMarginRatio() != 0 )
-        fprintf( m_fp, ".SolderPasteRatio %g\n", me->GetLocalSolderPasteMarginRatio() );
+    double ratio = me->GetLocalSolderPasteMarginRatio();
+    if( ratio != 0.0 )
+        fprintf( m_fp, ".SolderPasteRatio %g\n", ratio );
 
     if( me->GetLocalClearance() != 0 )
         fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
@@ -3252,7 +3254,7 @@ void LEGACY_PLUGIN::savePAD( const D_PAD* me ) const
 }
 
 
-void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
+void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
 {
     char        statusTxt[3];
     double      orient = me->GetOrientation();
@@ -3293,8 +3295,9 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
     if( me->GetLocalSolderPasteMargin() != 0 )
         fprintf( m_fp, ".SolderPaste %s\n", fmtBIU( me->GetLocalSolderPasteMargin() ).c_str() );
 
-    if( me->GetLocalSolderPasteMarginRatio() != 0 )
-        fprintf( m_fp, ".SolderPasteRatio %g\n", me->GetLocalSolderPasteMarginRatio() );
+    double ratio = me->GetLocalSolderPasteMarginRatio();
+    if( ratio != 0.0 )
+        fprintf( m_fp, ".SolderPasteRatio %g\n", ratio );
 
     if( me->GetLocalClearance() != 0 )
         fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
@@ -3345,7 +3348,7 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
     for( D_PAD* pad = me->m_Pads;  pad;  pad = pad->Next() )
         savePAD( pad );
 
-    save3D( me );
+    SaveModule3D( me );
 
     fprintf( m_fp, "$EndMODULE %s\n", TO_UTF8( me->GetLibRef() ) );
 
@@ -3353,7 +3356,7 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const
 }
 
 
-void LEGACY_PLUGIN::save3D( const MODULE* me ) const
+void LEGACY_PLUGIN::SaveModule3D( const MODULE* me ) const
 {
     for( S3D_MASTER* t3D = me->m_3D_Drawings;  t3D;  t3D = t3D->Next() )
     {
@@ -3722,8 +3725,6 @@ typedef boost::ptr_map< wxString, MODULE >      MODULE_MAP;
 typedef MODULE_MAP::iterator                    MODULE_ITER;
 typedef MODULE_MAP::const_iterator              MODULE_CITER;
 
-#define FOOTPRINT_LIBRARY_HEADER       "PCBNEW-LibModule-V1"
-
 
 /**
  * Class FPL_CACHE
@@ -3736,13 +3737,13 @@ struct FPL_CACHE
     LEGACY_PLUGIN*  m_owner;        // my owner, I need its LEGACY_PLUGIN::LoadMODULE()
     wxString        m_lib_name;
     wxDateTime      m_mod_time;
-    MODULE_MAP      m_modules;      // tuple of footprint name vs. MODULE*
+    MODULE_MAP      m_modules;      // map or tuple of footprint_name vs. MODULE*
     bool            m_writable;
 
     FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath );
 
-    // Most all functions in this class throw IO_ERROR exceptions.  There is no
-    // error codes nor user interface calls from here.
+    // Most all functions in this class throw IO_ERROR exceptions.  There are no
+    // error codes nor user interface calls from here, nor in any PLUGIN.
     // Catch these exceptions higher up please.
 
     /// save the entire legacy library to m_lib_name;
@@ -3754,9 +3755,12 @@ struct FPL_CACHE
 
     void SaveModules( FILE* aFile );
 
-    void SaveEndOfFile( FILE* aFile );
+    void SaveEndOfFile( FILE* aFile )
+    {
+        fprintf( aFile, "$EndLIBRARY\n" );
+    }
 
-    void Load( LINE_READER* aReader );
+    void Load();
 
     void ReadAndVerifyHeader( LINE_READER* aReader );
 
@@ -3771,19 +3775,8 @@ struct FPL_CACHE
 FPL_CACHE::FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath ) :
     m_owner( aOwner ),
     m_lib_name( aLibraryPath ),
-    m_writable( false )
+    m_writable( true )
 {
-    FILE* fp = wxFopen( aLibraryPath, wxT( "r" ) );
-    if( !fp )
-    {
-        THROW_IO_ERROR( wxString::Format(
-            _( "Unable to open legacy library file '%s'" ), aLibraryPath.GetData() ) );
-    }
-
-    // reader now owns fp, will close on exception or return
-    FILE_LINE_READER    reader( fp, aLibraryPath );
-
-    Load( &reader );
 }
 
 
@@ -3791,17 +3784,29 @@ wxDateTime FPL_CACHE::GetLibModificationTime()
 {
     wxFileName  fn( m_lib_name );
 
+    // update the writable flag while we have a wxFileName, in a network this
+    // is possibly quite dynamic anyway.
     m_writable = fn.IsFileWritable();
 
     return fn.GetModificationTime();
 }
 
 
-void FPL_CACHE::Load( LINE_READER* aReader )
+void FPL_CACHE::Load()
 {
-    ReadAndVerifyHeader( aReader );
-    SkipIndex( aReader );
-    LoadModules( aReader );
+    FILE* fp = wxFopen( m_lib_name, wxT( "r" ) );
+    if( !fp )
+    {
+        THROW_IO_ERROR( wxString::Format(
+            _( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) );
+    }
+
+    // reader now owns fp, will close on exception or return
+    FILE_LINE_READER    reader( fp, m_lib_name );
+
+    ReadAndVerifyHeader( &reader );
+    SkipIndex( &reader );
+    LoadModules( &reader );
 
     // Remember the file modification time of library file when the
     // cache snapshot was made, so that in a networked environment we will
@@ -3812,17 +3817,45 @@ void FPL_CACHE::Load( LINE_READER* aReader )
 
 void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
 {
+    char* line;
+
     if( !aReader->ReadLine() )
+        goto L_bad_library;
+
+    line = aReader->Line();
+    if( !TESTLINE( "PCBNEW-LibModule-V1" ) )
+        goto L_bad_library;
+
+    while( aReader->ReadLine() )
     {
-    L_not_library:
-        THROW_IO_ERROR( wxString::Format( _( "File %s is empty or is not a legacy library" ),
-            m_lib_name.GetData() ) );
+        line = aReader->Line();
+        if( TESTLINE( "Units" ) )
+        {
+            const char* units = strtok( line + SZ( "Units" ), delims );
+
+            if( !strcmp( units, "mm" ) )
+            {
+#if defined( USE_PCBNEW_NANOMETRES )
+                m_owner->diskToBiu = 1000000.0;
+
+#elif defined(DEBUG)
+                // mm to deci-mils:
+                // advanced testing of round tripping only, not supported in non DEBUG build
+                m_owner->diskToBiu = 10000/25.4;
+
+#else
+                THROW_IO_ERROR( _( "May not load millimeter legacy library file into 'PCBNew compiled for deci-mils'" ) );
+#endif
+            }
+
+        }
+        else if( TESTLINE( "$INDEX" ) )
+            return;
     }
 
-    char* line = aReader->Line();
-
-    if( !TESTLINE( "PCBNEW-LibModule-V1" ) )
-        goto L_not_library;
+L_bad_library:
+    THROW_IO_ERROR( wxString::Format( _( "File '%s' is empty or is not a legacy library" ),
+        m_lib_name.GetData() ) );
 }
 
 
@@ -3833,7 +3866,7 @@ void FPL_CACHE::SkipIndex( LINE_READER* aReader )
     // to see if this is not a new $INDEX tag.
     bool exit = false;
 
-    while( aReader->ReadLine() )
+    do
     {
         char* line = aReader->Line();
 
@@ -3854,7 +3887,7 @@ void FPL_CACHE::SkipIndex( LINE_READER* aReader )
         }
         else if( exit )
             break;
-    }
+    } while( aReader->ReadLine() );
 }
 
 
@@ -3871,17 +3904,20 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader )
         {
             MODULE* m = m_owner->LoadMODULE();
 
-            wxString reference = m->GetReference();
+            // wxString footprintName = m->GetReference();
+            wxString footprintName = m->GetLibRef();
 
-            MODULE_CITER it = m_modules.find( reference );
+            std::pair r = m_modules.insert( footprintName, m );
 
-            if( it != m_modules.end() )
+            // m's module is gone here, both on success or failure of insertion.
+            // no memory leak, container deleted m on failure.
+
+            if( !r.second )
             {
                 THROW_IO_ERROR( wxString::Format(
-                    _( "library %s has a duplicate footprint named %s" ),
-                    m_lib_name.GetData(), reference.GetData() ) );
+                    _( "library '%s' has a duplicate footprint named '%s'" ),
+                    m_lib_name.GetData(), footprintName.GetData() ) );
             }
-            m_modules.insert( reference, m );
         }
 
     } while( aReader->ReadLine() );
@@ -3904,7 +3940,8 @@ void FPL_CACHE::Save()
     if( !fp )
     {
         THROW_IO_ERROR( wxString::Format(
-            _( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) );
+            _( "Unable to open or create legacy library file '%s'" ),
+            m_lib_name.GetData() ) );
     }
 
     // wxf now owns fp, will close on exception or return
@@ -3915,8 +3952,15 @@ void FPL_CACHE::Save()
     SaveModules( fp );
     SaveEndOfFile( fp );
 
-    wxRemoveFile( m_lib_name );
-    wxRenameFile( tempFileName, m_lib_name );
+    wxRemove( m_lib_name );     // it is not an error if this does not exist
+
+    if( wxRename( tempFileName, m_lib_name ) )
+    {
+        THROW_IO_ERROR( wxString::Format(
+            _( "Unable to rename tempfile '%s' to to library file '%s'" ),
+            tempFileName.GetData(),
+            m_lib_name.GetData() ) );
+    }
 }
 
 
@@ -3924,6 +3968,11 @@ void FPL_CACHE::SaveHeader( FILE* aFile )
 {
     fprintf( aFile, "%s  %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) );
     fprintf( aFile, "# encoding utf-8\n" );
+#if defined( USE_PCBNEW_NANOMETRES )
+    fprintf( aFile, "Units mm\n" );
+#else
+    fprintf( aFile, "Units deci-mils\n" );
+#endif
 }
 
 
@@ -3942,24 +3991,32 @@ void FPL_CACHE::SaveIndex( FILE* aFile )
 
 void FPL_CACHE::SaveModules( FILE* aFile )
 {
+    m_owner->SetFilePtr( aFile );
+
+    for( MODULE_CITER it = m_modules.begin();  it != m_modules.end();  ++it )
+    {
+        m_owner->SaveMODULE( it->second );
+    }
 }
 
 
 void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
 {
     if( !m_cache || m_cache->m_lib_name != aLibraryPath ||
+        // somebody else on a network touched the library:
         m_cache->m_mod_time != m_cache->GetLibModificationTime() )
     {
-        // a spectacular episode in memory management.
+        // a spectacular episode in memory management:
         delete m_cache;
         m_cache = new FPL_CACHE( this, aLibraryPath );
+        m_cache->Load();
     }
 }
 
 
 wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
 {
-    wxArrayString   ret;
+    LOCALE_IO   toggle;     // toggles on, then off, the C locale.
 
     init( aProperties );
 
@@ -3967,6 +4024,8 @@ wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, P
 
     const MODULE_MAP&   mods = m_cache->m_modules;
 
+    wxArrayString   ret;
+
     for( MODULE_CITER it = mods.begin();  it != mods.end();  ++it )
     {
         ret.Add( it->first );
@@ -3979,6 +4038,8 @@ wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, P
 MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
                                     PROPERTIES* aProperties )
 {
+    LOCALE_IO   toggle;     // toggles on, then off, the C locale.
+
     init( aProperties );
 
     cacheLib( aLibraryPath );
@@ -3989,8 +4050,12 @@ MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStri
 
     if( it == mods.end() )
     {
+        /*
         THROW_IO_ERROR( wxString::Format( _( "No '%s' footprint in library '%s'" ),
             aFootprintName.GetData(), aLibraryPath.GetData() ) );
+        */
+
+        return NULL;
     }
 
     // copy constructor to clone the already loaded MODULE
@@ -3998,30 +4063,45 @@ MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStri
 }
 
 
-void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties )
+void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
 {
+    LOCALE_IO   toggle;     // toggles on, then off, the C locale.
+
     init( aProperties );
 
     cacheLib( aLibraryPath );
 
     if( !m_cache->m_writable )
     {
+        THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ), aLibraryPath.GetData() ) );
     }
 
-    wxString reference = aFootprint->GetReference();
+    wxString footprintName = aFootprint->GetLibRef();
 
     MODULE_MAP&  mods = m_cache->m_modules;
 
     // quietly overwrite any by same name.
-    MODULE_CITER it = mods.find( reference );
+    MODULE_CITER it = mods.find( footprintName );
     if( it != mods.end() )
     {
-        mods.erase( reference );
+        mods.erase( footprintName );
     }
 
-    aFootprint->SetParent( 0 );
+    // I need my own copy for the cache
+    MODULE* my_module = new MODULE( *aFootprint );
 
-    mods.insert( reference, aFootprint );
+    // and it's time stamp must be 0, it should have no parent, orientation should
+    // be zero, and it should be on the front layer.
+
+    my_module->SetTimeStamp( 0 );
+    my_module->SetParent( 0 );
+
+    my_module->SetOrientation( 0 );
+
+    if( my_module->GetLayer() != LAYER_N_FRONT )
+        my_module->Flip( my_module->GetPosition() );
+
+    mods.insert( footprintName, my_module );
 
     m_cache->Save();
 }
@@ -4029,12 +4109,15 @@ void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootpr
 
 void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
 {
+    LOCALE_IO   toggle;     // toggles on, then off, the C locale.
+
     init( NULL );
 
     cacheLib( aLibraryPath );
 
     if( !m_cache->m_writable )
     {
+        THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ), aLibraryPath.GetData() ) );
     }
 
     size_t erasedCount = m_cache->m_modules.erase( aFootprintName );
@@ -4050,8 +4133,52 @@ void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin
 }
 
 
-bool LEGACY_PLUGIN::IsLibraryWritable( const wxString& aLibraryPath )
+void LEGACY_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
 {
+    if( wxFileExists( aLibraryPath ) )
+    {
+        THROW_IO_ERROR( wxString::Format(
+            _( "library '%s' already exists, will not create anew" ),
+            aLibraryPath.GetData() ) );
+    }
+
+    LOCALE_IO   toggle;
+
+    init( NULL );
+
+    delete m_cache;
+    m_cache = new FPL_CACHE( this, aLibraryPath );
+    m_cache->Save();
+    m_cache->Load();    // update m_writable and m_mod_time
+}
+
+
+void LEGACY_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
+{
+    wxFileName fn = aLibraryPath;
+
+    if( !fn.FileExists() )
+    {
+        THROW_IO_ERROR( wxString::Format(
+            _( "library '%s' does not exist, cannot be deleted" ),
+            aLibraryPath.GetData() ) );
+    }
+
+    // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
+    // we don't want that.  we want bare metal portability with no UI here.
+    if( wxRemove( aLibraryPath ) )
+    {
+        THROW_IO_ERROR( wxString::Format(
+            _( "library '%s' cannot be deleted" ),
+            aLibraryPath.GetData() ) );
+    }
+}
+
+
+bool LEGACY_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
+{
+    LOCALE_IO   toggle;
+
     init( NULL );
 
     cacheLib( aLibraryPath );
diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h
index b2011b8fe8..0aaa458208 100644
--- a/pcbnew/legacy_plugin.h
+++ b/pcbnew/legacy_plugin.h
@@ -27,6 +27,10 @@
 #include 
 #include 
 
+
+#define FOOTPRINT_LIBRARY_HEADER       "PCBNEW-LibModule-V1"
+#define FOOTPRINT_LIBRARY_HEADER_CNT   18
+
 typedef int     BIU;
 
 class PCB_TARGET;
@@ -44,7 +48,7 @@ class EDGE_MODULE;
 class TRACK;
 class SEGZONE;
 class D_PAD;
-class FPL_CACHE;
+struct FPL_CACHE;
 
 
 /**
@@ -54,6 +58,7 @@ class FPL_CACHE;
  */
 class LEGACY_PLUGIN : public PLUGIN
 {
+    friend struct FPL_CACHE;
 
 public:
 
@@ -80,12 +85,16 @@ public:
     MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
                                     PROPERTIES* aProperties = NULL );
 
-    void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint,
+    void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
                                     PROPERTIES* aProperties = NULL );
 
     void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
 
-    bool IsLibraryWritable( const wxString& aLibraryPath );
+    void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
+
+    void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
+
+    bool IsFootprintLibWritable( const wxString& aLibraryPath );
 
     //--------------------------------------------------
 
@@ -103,7 +112,8 @@ public:
     void SetFilePtr( FILE* aFile )              { m_fp = aFile; }
 
     MODULE* LoadMODULE();
-
+    void    SaveMODULE( const MODULE* aModule ) const;
+    void    SaveModule3D( const MODULE* aModule ) const;
 
 protected:
 
@@ -243,11 +253,9 @@ protected:
     void saveSETUP() const;
     void saveBOARD() const;
 
-    void saveMODULE( const MODULE* aModule ) const;
     void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
     void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
     void savePAD( const D_PAD* aPad ) const;
-    void save3D( const MODULE* aModule ) const;
 
     void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
     void saveNETCLASSES() const;
diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp
index 8845cda5a8..037f21afa5 100644
--- a/pcbnew/librairi.cpp
+++ b/pcbnew/librairi.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include               // temporarily, for LoadMODULE()
 
 
 /*
@@ -45,26 +46,24 @@ static const wxString ModImportFileWildcard( _( "GPcb foot print files (*)|*" )
 
 MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
 {
-    char*     Line;
-    FILE*     file;
-    MODULE*   module = NULL;
-    bool      Footprint_Is_GPCB_Format = false;
+    // use the clipboard for this in the future?
 
-    wxString  LastOpenedPathForLoading;
-    wxConfig* Config = wxGetApp().GetSettings();
+    wxString  lastOpenedPathForLoading;
+    wxConfig* config = wxGetApp().GetSettings();
 
-    if( Config )
-        Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
+    if( config )
+        config->Read( EXPORT_IMPORT_LASTPATH_KEY, &lastOpenedPathForLoading );
 
     wxString importWildCard = ModExportFileWildcard + wxT("|") + ModImportFileWildcard;
+
     wxFileDialog dlg( this, _( "Import Footprint Module" ),
-                      LastOpenedPathForLoading, wxEmptyString,
+                      lastOpenedPathForLoading, wxEmptyString,
                       importWildCard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
 
     if( dlg.ShowModal() == wxID_CANCEL )
         return NULL;
 
-    file = wxFopen( dlg.GetPath(), wxT( "rt" ) );
+    FILE* file = wxFopen( dlg.GetPath(), wxT( "rt" ) );
 
     if( file == NULL )
     {
@@ -74,28 +73,29 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
         return NULL;
     }
 
+    if( config )    // Save file path
+    {
+        lastOpenedPathForLoading = wxPathOnly( dlg.GetPath() );
+        config->Write( EXPORT_IMPORT_LASTPATH_KEY, lastOpenedPathForLoading );
+    }
+
+    LOCALE_IO   toggle;
+
     FILE_LINE_READER fileReader( file, dlg.GetPath() );
 
     FILTER_READER reader( fileReader );
 
-    if( Config )    // Save file path
-    {
-        LastOpenedPathForLoading = wxPathOnly( dlg.GetPath() );
-        Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
-    }
-
-    // Switch the locale to standard C (needed to print floating point numbers like 1.3)
-    SetLocaleTo_C_standard();
-
     // Read header and test file type
     reader.ReadLine();
-    Line = reader.Line();
+    char* line = reader.Line();
 
-    if( strnicmp( Line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
+    bool      footprint_Is_GPCB_Format = false;
+
+    if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
     {
-        if( strnicmp( Line, "Element", 7 ) == 0 )
+        if( strnicmp( line, "Element", 7 ) == 0 )
         {
-            Footprint_Is_GPCB_Format = true;
+            footprint_Is_GPCB_Format = true;
         }
         else
         {
@@ -105,27 +105,41 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
     }
 
     // Read file: Search the description starting line (skip lib header)
-    if( !Footprint_Is_GPCB_Format )
+    if( !footprint_Is_GPCB_Format )
     {
         while( reader.ReadLine() )
         {
-            if( strnicmp( Line, "$MODULE", 7 ) == 0 )
+            if( strnicmp( line, "$MODULE", 7 ) == 0 )
                 break;
         }
     }
 
-    module = new MODULE( GetBoard() );
+    MODULE*   module;
 
-    if( Footprint_Is_GPCB_Format )
+    if( footprint_Is_GPCB_Format )
     {
+        // @todo GEDA plugin
+        module = new MODULE( GetBoard() );
         module->Read_GPCB_Descr( dlg.GetPath() );
     }
     else
     {
-        module->ReadDescr( &reader );
-    }
+        try
+        {
+            PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-    SetLocaleTo_Default();       // revert to the current locale
+            LEGACY_PLUGIN*  lp = (LEGACY_PLUGIN*)(PLUGIN*)pi;
+
+            lp->SetReader( &reader );
+
+            module = lp->LoadMODULE();
+        }
+        catch( IO_ERROR ioe )
+        {
+            DisplayError( this, ioe.errorText );
+            return NULL;
+        }
+    }
 
     // Insert footprint in list
     GetBoard()->Add( module );
@@ -143,9 +157,8 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
 void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
 {
     wxFileName fn;
-    FILE*      file;
     wxString   msg, path, title, wildcard;
-    wxConfig*  Config = wxGetApp().GetSettings();
+    wxConfig*  config = wxGetApp().GetSettings();
 
     if( aModule == NULL )
         return;
@@ -155,12 +168,14 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
 
     if( aCreateSysLib )
         path = wxGetApp().ReturnLastVisitedLibraryPath();
-    else if( Config )
-        Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path );
+    else if( config )
+        config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path );
 
-    fn.SetPath( path );
     title    = aCreateSysLib ? _( "Create New Library" ) : _( "Export Module" );
     wildcard = aCreateSysLib ?  FootprintLibFileWildcard : ModExportFileWildcard;
+
+    fn.SetPath( path );
+
     wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(),
                       wxGetTranslation( wildcard ),
                       wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
@@ -171,64 +186,53 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
     fn = dlg.GetPath();
     wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
 
-    if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL )
+    if( !aCreateSysLib && config )  // Save file path
     {
-        msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
-        DisplayError( this, msg );
+        config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
+    }
+
+    wxString libName = fn.GetFullPath();
+
+    try
+    {
+        // @todo : hard code this as IO_MGR::KICAD plugin, what would be the reason to "export"
+        // any other single footprint type, with clipboard support coming?
+        // Use IO_MGR::LEGACY for now, until the IO_MGR::KICAD plugin is ready.
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
+
+        pi->FootprintLibCreate( libName );
+        pi->FootprintSave( libName, aModule );
+    }
+    catch( IO_ERROR ioe )
+    {
+        DisplayError( this, ioe.errorText );
         return;
     }
 
-    if( !aCreateSysLib && Config )  // Save file path
-    {
-        Config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
-    }
-
-    // Switch the locale to standard C (needed to read/write floating point numbers like 1.3)
-    SetLocaleTo_C_standard();
-
-    FOOTPRINT_LIBRARY libexport( file );
-    libexport.WriteHeader();
-    libexport.m_List.Add(aModule->m_LibRef);
-    libexport.WriteSectionIndex();
-
-    GetBoard()->m_Modules->Save( file );
-
-    libexport.WriteEndOfFile();
-    fclose( file );
-
-    SetLocaleTo_Default();       // revert to the current locale
-
-    msg.Printf( _( "Module exported in file <%s>" ), GetChars( fn.GetFullPath() ) );
+    msg.Printf( _( "Module exported in file <%s>" ), libName.GetData() );
     DisplayInfoMessage( this, msg );
 }
 
 
-void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
+void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibName )
 {
-    wxFileName newFileName;
-    wxFileName oldFileName;
-    int        LineNum = 0;
-    char       Line[1024], Name[256];
-    FILE*      out_file, * lib_module;
-    wxString   CmpName, msg;
+    wxString footprintName = Select_1_Module_From_List( this, aLibName, wxEmptyString, wxEmptyString );
 
-    CmpName = Select_1_Module_From_List( this, aLibname, wxEmptyString, wxEmptyString );
-
-    if( CmpName == wxEmptyString )
+    if( footprintName == wxEmptyString )
         return;
 
     // Confirmation
-    msg.Printf( _( "Ok to delete module %s in library %s" ),
-                GetChars( CmpName ), GetChars( aLibname ) );
+    wxString msg = wxString::Format( _( "Ok to delete module '%s' in library '%s'" ),
+                        footprintName.GetData(), aLibName.GetData() );
 
     if( !IsOK( this, msg ) )
         return;
 
     try
     {
-        PLUGIN::HOLDER  pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
+        PLUGIN::RELEASER  pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-        pi->FootprintDelete( aLibname, CmpName );
+        pi->FootprintDelete( aLibName, footprintName );
     }
     catch( IO_ERROR ioe )
     {
@@ -236,8 +240,9 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
         return;
     }
 
-    msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ),
-                GetChars( oldFileName.GetFullPath() ) );
+    msg.Printf( _( "Component '%s' deleted from library '%s'" ),
+                footprintName.GetData(), aLibName.GetData() );
+
     SetStatusText( msg );
 }
 
@@ -260,7 +265,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
 
     path = wxGetApp().ReturnLastVisitedLibraryPath();
 
-    if( aLibName.IsEmpty() )
+    if( !aLibName )
     {
         wxFileDialog dlg( this, _( "Library" ), path,
                           wxEmptyString,
@@ -275,12 +280,12 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
 
     wxFileName fn( fileName );
     wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
-    bool       file_exists = wxFileExists( fileName );
+    bool       lib_exists = wxFileExists( fileName );
 
-    if( !aNewModulesOnly && file_exists )
+    if( !aNewModulesOnly && lib_exists )
     {
         wxString msg;
-        msg.Printf( _( "File %s exists, OK to replace ?" ), GetChars( fileName ) );
+        msg.Printf( _( "Library %s exists, OK to replace ?" ), GetChars( fileName ) );
 
         if( !IsOK( this, msg ) )
             return;
@@ -288,51 +293,46 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM
 
     m_canvas->SetAbortRequest( false );
 
-    // Create a new, empty library if no old lib, or if archive all modules
-    if( !aNewModulesOnly || !file_exists )
+    try
     {
-        FILE* lib_module;
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-        if( ( lib_module = wxFopen( fileName, wxT( "w+t" ) ) )  == NULL )
+        // Delete old library if we're replacing it entirely.
+        if( lib_exists && !aNewModulesOnly )
         {
-            wxString msg;
-            msg.Printf( _( "Unable to create <%s>" ), GetChars(fileName) );
-            DisplayError( this, msg );
-            return;
+            pi->FootprintLibDelete( fileName );
+            lib_exists = false;
         }
 
-        FOOTPRINT_LIBRARY new_lib( lib_module );
-        new_lib.WriteHeader();
-        new_lib.WriteSectionIndex();
-        new_lib.WriteEndOfFile();
-        fclose( lib_module );
+        if( !lib_exists )
+        {
+            pi->FootprintLibCreate( fileName );
+        }
+
+        if( !aNewModulesOnly )
+        {
+            for( MODULE* m = GetBoard()->m_Modules;  m;  m = m->Next() )
+            {
+                pi->FootprintSave( fileName, m );
+            }
+        }
+        else
+        {
+            for( MODULE* m = GetBoard()->m_Modules;  m;  m = m->Next() )
+            {
+                if( !Save_Module_In_Library( fileName, m, false, false ) )
+                    break;
+
+                // Check for request to stop backup (ESCAPE key actuated)
+                if( m_canvas->GetAbortRequest() )
+                    break;
+            }
+        }
     }
-
-    MODULE*  module = (MODULE*) GetBoard()->m_Modules;
-    for( int ii = 1; module != NULL; ii++, module = module->Next() )
+    catch( IO_ERROR ioe )
     {
-        // Save footprints in default orientation (0.0) and default layer (FRONT layer)
-        int orient = module->GetOrientation();
-        if ( orient != 0 )
-            module->SetOrientation( 0 );
-        int layer = module->GetLayer();
-        if(layer != LAYER_N_FRONT )
-            module->Flip( module->m_Pos );
-
-        bool success = Save_Module_In_Library( fileName, module,
-                                    aNewModulesOnly ? false : true, false );
-        // Restore previous orientation and/or side
-        if(layer != module->GetLayer() )
-            module->Flip( module->m_Pos );
-        if ( orient != 0 )
-            module->SetOrientation( orient );
-
-        if( !success )
-            break;
-
-        // Check for request to stop backup (ESCAPE key actuated)
-        if( m_canvas->GetAbortRequest() )
-            break;
+        DisplayError( this, ioe.errorText );
+        return;
     }
 }
 
@@ -342,202 +342,84 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
                                              bool            aOverwrite,
                                              bool            aDisplayDialog )
 {
-    wxFileName oldFileName;
-    wxFileName newFileName;
-    int        LineNum = 0, tmp;
-    char       Name[256], Line[1024];
-    wxString   Name_Cmp;
-    wxString   msg;
-    FILE*      lib_module, * dest;
-
     if( aModule == NULL )
         return false;
 
     aModule->DisplayInfo( this );
 
-    newFileName = aLibName;
-
-    if( !newFileName.FileExists( aLibName ) )
+    if( !wxFileExists( aLibName ) )
     {
-        msg.Printf( _( "Library <%s> not found." ), GetChars( aLibName ) );
+        wxString msg = wxString::Format( _( "Library <%s> not found." ),
+                            aLibName.GetData() );
         DisplayError( this, msg );
         return false;
     }
 
-    if( !IsWritable( newFileName ) )
+    if( !IsWritable( aLibName ) )
         return false;
 
-    // Ask for the footprint name in lib
-    Name_Cmp = aModule->m_LibRef;
+    // Ask what to use as the footprint name in the library
+    wxString footprintName = aModule->GetLibRef();
 
     if( aDisplayDialog )
     {
-        wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
+        wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save Module" ), footprintName );
 
         if( dlg.ShowModal() != wxID_OK )
-            return false; // canceled by user
+            return false;                   // canceled by user
 
-        Name_Cmp = dlg.GetValue();
-        Name_Cmp.Trim( true );
-        Name_Cmp.Trim( false );
+        footprintName = dlg.GetValue();
+        footprintName.Trim( true );
+        footprintName.Trim( false );
 
-        if( Name_Cmp.IsEmpty() )
+        if( footprintName.IsEmpty() )
             return false;
 
-        aModule->m_LibRef = Name_Cmp;
+        aModule->SetLibRef( footprintName );
     }
 
     // Ensure this footprint has a libname
-    if( Name_Cmp.IsEmpty() )
+    if( footprintName.IsEmpty() )
     {
-        Name_Cmp = wxT("noname");
-        aModule->m_LibRef = Name_Cmp;
+        footprintName = wxT("noname");
+        aModule->SetLibRef( footprintName );
     }
 
-    if( ( lib_module = wxFopen( aLibName, wxT( "rt" ) ) ) == NULL )
+    MODULE*  module_exists = NULL;
+
+    try
     {
-        msg.Printf( _( "Unable to open <%s>" ), GetChars( aLibName ) );
-        DisplayError( this, msg );
-        return false;
-    }
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-    // Read library file
-    FOOTPRINT_LIBRARY input_lib( lib_module );
+        module_exists = pi->FootprintLoad( aLibName, footprintName );
 
-    if( ! input_lib.IsLibrary() )
-    {
-        fclose( lib_module );
-        msg.Printf( _( "File <%s> is not an Eeschema library" ), GetChars( aLibName ) );
-        DisplayError( this, msg );
-        return false;
-    }
-
-    // Read footprints in lib: - search for an existing footprint
-    input_lib.RebuildIndex();
-    bool module_exists = input_lib.FindInList( Name_Cmp );
-
-    if( module_exists )
-    {
-        // an existing footprint is found in current lib
-        if( aDisplayDialog )
+        if( module_exists )
         {
-            msg = _( "Module exists\n Line: " );
-            msg << LineNum;
-            SetStatusText( msg );
-        }
+            delete module_exists;
 
-        if( !aOverwrite )    // Do not save the given footprint: an old one exists
-        {
-            fclose( lib_module );
-            return true;
-        }
-    }
-
-    // Creates the new library
-
-    newFileName.SetExt( FILETMP_EXT );
-
-    if( ( dest = wxFopen( newFileName.GetFullPath(), wxT( "w+t" ) ) )  == NULL )
-    {
-        fclose( lib_module );
-        msg.Printf( _( "Unable to create <%s>" ), GetChars( newFileName.GetFullPath() ) );
-        DisplayError( this, msg );
-        return false;
-    }
-
-    wxBeginBusyCursor();
-
-    // Switch the locale to standard C (needed to print floating point numbers like 1.3)
-    SetLocaleTo_C_standard();
-
-    FOOTPRINT_LIBRARY output_lib( dest );
-    output_lib.m_List = input_lib.m_List;
-
-    if( ! module_exists )
-        output_lib.m_List.Add( Name_Cmp );
-
-    output_lib.SortList();
-
-    // Create the library header with a new date
-    output_lib.WriteHeader();
-    output_lib.WriteSectionIndex();
-
-    LineNum = 0;
-    rewind( lib_module);
-
-    // Copy footprints, until the old footprint to delete
-    bool skip_header = true;
-
-    while( GetLine( lib_module, Line, &LineNum ) )
-    {
-        StrPurge( Line );
-        if( strnicmp( Line, "$EndLIBRARY", 8 ) == 0 )
-            continue;
-
-        // Search for the beginning of module section:
-        if( skip_header )
-        {
-            if(  strnicmp( Line, "$MODULE", 7 ) == 0 )
-                skip_header = false;
-            else
-                continue;
-        }
-
-        if( strnicmp( Line, "$MODULE", 7 ) == 0 )
-        {
-            sscanf( Line + 7, " %s", Name );
-            msg = FROM_UTF8( Name );
-
-            if( msg.CmpNoCase( Name_Cmp ) == 0 )
+            // an existing footprint is found in current lib
+            if( aDisplayDialog )
             {
-                // skip old footprint descr (delete from the lib)
-                while( GetLine( lib_module, Line, &LineNum ) )
-                {
-                    if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
-                        break;
-                }
+                wxString msg = wxString::Format(
+                    _( "Footprint '%s' already exists in library '%s'" ),
+                    footprintName.GetData(), aLibName.GetData() );
 
-                continue;
+                SetStatusText( msg );
+            }
+
+            if( !aOverwrite )
+            {
+                // Do not save the given footprint: an old one exists
+                return true;
             }
         }
 
-        fprintf( dest, "%s\n", Line );
+        // this always overwrites any existing footprint
+        pi->FootprintSave( aLibName, aModule );
     }
-
-    // Write the new footprint ( append it to the list of footprint )
-    tmp = aModule->GetTimeStamp();
-    aModule->SetTimeStamp( 0 );
-    aModule->Save( dest );
-    aModule->SetTimeStamp( tmp );
-
-    output_lib.WriteEndOfFile();
-
-    fclose( dest );
-    fclose( lib_module );
-    SetLocaleTo_Default();       // revert to the current locale
-
-    wxEndBusyCursor();
-
-    // The old library file is renamed .bak
-    oldFileName = aLibName;
-    oldFileName.SetExt( BACKUP_EXT );
-
-    if( oldFileName.FileExists() )
-        wxRemoveFile( oldFileName.GetFullPath() );
-
-    if( !wxRenameFile( aLibName, oldFileName.GetFullPath() ) )
+    catch( IO_ERROR ioe )
     {
-        msg.Printf( _( "Could not create library back up file <%s>." ),
-                      GetChars( oldFileName.GetFullName() ) );
-        DisplayError( this, msg );
-    }
-
-    // The new library file is renamed
-    if( !wxRenameFile( newFileName.GetFullPath(), aLibName ) )
-    {
-        msg.Printf( _( "Could not create temporary library file <%s>." ),
-                      GetChars( aLibName ) );
-        DisplayError( this, msg );
+        DisplayError( this, ioe.errorText );
         return false;
     }
 
@@ -546,7 +428,8 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
         wxString fmt = module_exists ?
             _( "Component [%s] replaced in <%s>" ) :
             _( "Component [%s] added in  <%s>" );
-        msg.Printf( fmt, GetChars( Name_Cmp ), GetChars( aLibName ) );
+
+        wxString msg = wxString::Format( fmt, footprintName.GetData(), aLibName.GetData() );
         SetStatusText( msg );
     }
 
@@ -647,13 +530,14 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library()
 
 int FOOTPRINT_EDIT_FRAME::CreateLibrary( const wxString& aLibName )
 {
-    FILE*    lib_module;
-    wxString msg;
     wxFileName fileName = aLibName;
 
     if( fileName.FileExists() )
     {
-        msg.Printf( _( "Library <%s> already exists." ), GetChars( fileName.GetFullPath() ) );
+        wxString msg = wxString::Format(
+            _( "Library <%s> already exists." ),
+            aLibName.GetData() );
+
         DisplayError( this, msg );
         return 0;
     }
@@ -661,18 +545,18 @@ int FOOTPRINT_EDIT_FRAME::CreateLibrary( const wxString& aLibName )
     if( !IsWritable( fileName ) )
         return 0;
 
-    if( ( lib_module = wxFopen( fileName.GetFullPath(), wxT( "wt" ) ) )  == NULL )
+    try
     {
-        msg.Printf( _( "Unable to create library <%s>" ), GetChars( fileName.GetFullPath() ) );
-        DisplayError( this, msg );
-        return -1;
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
+
+        pi->FootprintLibCreate( aLibName );
+    }
+    catch( IO_ERROR ioe )
+    {
+        DisplayError( this, ioe.errorText );
+        return 0;
     }
 
-    FOOTPRINT_LIBRARY new_lib( lib_module );
-    new_lib.WriteHeader();
-    new_lib.WriteSectionIndex();
-    new_lib.WriteEndOfFile();
-    fclose( lib_module );
-
-    return 1;
+    return 1;       // remember how many times we succeeded
 }
+
diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp
index b571f1176e..615ac1a322 100644
--- a/pcbnew/loadcmp.cpp
+++ b/pcbnew/loadcmp.cpp
@@ -42,11 +42,11 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -141,6 +141,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
     return fpname;
 }
 
+
 MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
                                                   bool aUseFootprintViewer,
                                                   wxDC* aDC )
@@ -148,7 +149,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
     MODULE*     module;
     wxPoint     curspos = GetScreen()->GetCrossHairPosition();
     wxString    moduleName, keys;
-    bool        AllowWildSeach = true;
+    bool        allowWildSeach = true;
 
     static wxArrayString HistoryList;
     static wxString      lastComponentName;
@@ -181,7 +182,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
 
     if( dlg.IsKeyword() )   // Selection by keywords
     {
-        AllowWildSeach = false;
+        allowWildSeach = false;
         keys = moduleName;
         moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys );
 
@@ -194,7 +195,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
     else if( ( moduleName.Contains( wxT( "?" ) ) )
             || ( moduleName.Contains( wxT( "*" ) ) ) )  // Selection wild card
     {
-        AllowWildSeach = false;
+        allowWildSeach = false;
         moduleName     = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString );
 
         if( moduleName.IsEmpty() )
@@ -206,11 +207,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
 
     module = GetModuleLibrary( aLibrary, moduleName, false );
 
-    if( ( module == NULL ) && AllowWildSeach )    // Search with wild card
+    if( !module && allowWildSeach )    // Search with wild card
     {
-        AllowWildSeach = false;
+        allowWildSeach = false;
+
         wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
         moduleName = wildname;
+
         moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString );
 
         if( moduleName.IsEmpty() )
@@ -233,14 +236,18 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
         AddHistoryComponentName( HistoryList, moduleName );
 
         module->SetFlags( IS_NEW );
-        module->m_Link      = 0;
+        module->m_Link = 0;
+
         module->SetTimeStamp( GetNewTimeStamp() );
         GetBoard()->m_Status_Pcb = 0;
+
         module->SetPosition( curspos );
+
         // Put it on FRONT layer,
         // (Can be stored on BACK layer if the lib is an archive built from a board)
         if( module->GetLayer() != LAYER_N_FRONT )
             module->Flip( module->m_Pos );
+
         // Put in in orientation 0,
         // even if it is not saved with with orientation 0 in lib
         // (Can happen if the lib is an archive built from a board)
@@ -256,117 +263,102 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
 }
 
 
-MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename,
-                                          const wxString& aModuleName,
-                                          bool            aDisplayMessageError )
+MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
+            const wxString& aFootprintName, bool aDisplayError )
 {
-    wxFileName fn;
-    wxString   msg, tmp;
-    MODULE*    newModule;
-    FILE*      file = NULL;
-    bool       error_set = false;
-
-    bool       one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
-
-    for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
+    try
     {
-        if( one_lib )
-            fn = aLibraryFullFilename;
-        else
-            fn = wxFileName( wxEmptyString, g_LibraryNames[ii], FootprintLibFileExtension );
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-        tmp = wxGetApp().FindLibraryPath( fn );
+        wxString libPath = wxGetApp().FindLibraryPath( aLibraryPath );
 
-        if( !tmp )
+        MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
+
+        if( !footprint )
         {
-            if( aDisplayMessageError && !error_set )
+            if( aDisplayError )
             {
-                msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ),
-                            GetChars( fn.GetFullName() ) );
-                wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
-                error_set = true;
+                wxString msg = wxString::Format(
+                    _( "Footprint '%s' not found in library '%s'" ),
+                    aFootprintName.GetData(),
+                    libPath.GetData() );
+
+                DisplayError( NULL, msg );
             }
 
-            continue;
-        }
-
-        file = wxFopen( tmp, wxT( "rt" ) );
-
-        if( file == NULL )
-        {
-            msg.Printf( _( "Could not open PCB footprint library file <%s>." ),
-                        GetChars( tmp ) );
-            wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
-            continue;
-        }
-
-        FILE_LINE_READER fileReader( file, tmp );
-
-        FILTER_READER reader( fileReader );
-
-        msg.Printf( _( "Scan Lib: %s" ), GetChars( tmp ) );
-        SetStatusText( msg );
-
-        FOOTPRINT_LIBRARY curr_lib( file, &reader );
-
-        if( !curr_lib.IsLibrary() )
-        {
-            msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library file." ),
-                        GetChars( tmp ) );
-            wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
             return NULL;
         }
 
-        // Reading the list of modules in the library.
-        curr_lib.ReadSectionIndex();
-        bool found = curr_lib.FindInList( aModuleName );
+        GetBoard()->Add( footprint, ADD_APPEND );
+        SetStatusText( wxEmptyString );
+        return footprint;
+    }
+    catch( IO_ERROR ioe )
+    {
+        DisplayError( this, ioe.errorText );
+        return NULL;
+    }
+}
 
-        // Read library.
-        if( found  )
+
+MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
+        const wxString& aFootprintName, bool aDisplayError )
+{
+    bool    showed_error = false;
+    MODULE* footprint = NULL;
+
+    try
+    {
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
+
+        for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
         {
-            wxString   name;
+            wxFileName fn = wxFileName( wxEmptyString, g_LibraryNames[ii], FootprintLibFileExtension );
 
-            fileReader.Rewind();
+            wxString libPath = wxGetApp().FindLibraryPath( fn );
 
-            while( reader.ReadLine() )
+            if( !libPath )
             {
-                char* line = reader.Line();
-
-                StrPurge( line + 8 );
-
-                if( strnicmp( line, "$MODULE", 7 ) != 0 )
-                    continue;
-
-                // Read module name.
-                name = FROM_UTF8( line + 8 );
-
-                if( name.CmpNoCase( aModuleName ) == 0 )
+                if( aDisplayError && !showed_error )
                 {
-                    newModule = new MODULE( GetBoard() );
+                    wxString msg = wxString::Format(
+                        _( "PCB footprint library file <%s> not found in search paths." ),
+                        fn.GetFullName().GetData() );
 
-                    // Temporarily switch the locale to standard C (needed to print
-                    // floating point numbers like 1.3)
-                    LOCALE_IO   toggle;
-
-                    newModule->ReadDescr( &reader );
-
-                    GetBoard()->Add( newModule, ADD_APPEND );
-                    SetStatusText( wxEmptyString );
-                    return newModule;
+                    DisplayError( this, msg );
+                    showed_error = true;
                 }
+                continue;
+            }
+
+            footprint = pi->FootprintLoad( libPath, aFootprintName );
+
+            if( footprint )
+            {
+                GetBoard()->Add( footprint, ADD_APPEND );
+                SetStatusText( wxEmptyString );
+                return footprint;
             }
         }
 
-        if( one_lib )
-            break;
-    }
+        if( !footprint )
+        {
+            if( aDisplayError )
+            {
+                wxString msg = wxString::Format(
+                    _( "Footprint '%s' not found in any library" ),
+                    aFootprintName.GetData() );
 
-    if( aDisplayMessageError )
+                DisplayError( NULL, msg );
+            }
+
+            return NULL;
+        }
+    }
+    catch( IO_ERROR ioe )
     {
-        msg.Printf( _( "Module <%s> not found" ), GetChars( aModuleName ) );
-        DisplayError( NULL, msg );
+        DisplayError( this, ioe.errorText );
     }
-
     return NULL;
 }
 

From 51a83a7a663e88e1c63f0c3b9b685f0a2707d594 Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Mon, 16 Apr 2012 21:58:03 -0500
Subject: [PATCH 08/16] cvpcb LEGACY_PLUGIN usage factoring

---
 cvpcb/loadcmp.cpp             | 129 ++++++++--------------------------
 gerbview/export_to_pcbnew.cpp | 112 ++++++++---------------------
 pcbnew/class_board.h          |   2 +-
 pcbnew/legacy_plugin.cpp      | 112 +++++++++++++++--------------
 pcbnew/legacy_plugin.h        |  14 ++--
 5 files changed, 121 insertions(+), 248 deletions(-)

diff --git a/cvpcb/loadcmp.cpp b/cvpcb/loadcmp.cpp
index 0bd78719a9..e1fc09e639 100644
--- a/cvpcb/loadcmp.cpp
+++ b/cvpcb/loadcmp.cpp
@@ -17,8 +17,7 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 
 
@@ -29,122 +28,50 @@
  * @param CmpName - Module name
  * @return - a pointer to the loaded module or NULL.
  */
-MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& CmpName )
+MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
 {
-    int        Found = 0;
-    unsigned   ii;
-    char*      Line;
-    char       Name[255];
-    wxString   tmp, msg;
-    wxFileName fn;
-    MODULE*    Module = NULL;
     CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
 
-    for( ii = 0; ii < parent->m_ModuleLibNames.GetCount(); ii++ )
+    try
     {
-        fn = parent->m_ModuleLibNames[ii];
-        fn.SetExt( FootprintLibFileExtension );
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-        tmp = wxGetApp().FindLibraryPath( fn );
-
-        if( !tmp )
+        for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount();  ++i )
         {
-            msg.Printf( _( "PCB foot print library file <%s> could not be \
-found in the default search paths." ),
-                        GetChars( fn.GetFullName() ) );
-            wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
-            continue;
-        }
+            wxFileName fn = parent->m_ModuleLibNames[i];
 
-        FILE* file = wxFopen( tmp, wxT( "rt" ) );
+            fn.SetExt( FootprintLibFileExtension );
 
-        if( file == NULL )
-        {
-            msg.Printf( _( "Could not open PCB foot print library file <%s>." ),
-                        GetChars( tmp ) );
-            wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
-            continue;
-        }
+            wxString libPath = wxGetApp().FindLibraryPath( fn );
 
-        FILE_LINE_READER fileReader( file, tmp );
-
-        FILTER_READER reader( fileReader );
-
-        /* Read header. */
-        reader.ReadLine();
-        Line = reader.Line();
-        StrPurge( Line );
-
-        if( strnicmp( Line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
-        {
-            msg.Printf( _( "<%s> is not a valid KiCad PCB foot print library." ),
-                        GetChars( tmp ) );
-            wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
-            fclose( file );
-            return NULL;
-        }
-
-        Found = 0;
-
-        while( !Found && reader.ReadLine() )
-        {
-            Line = reader.Line();
-            if( strncmp( Line, "$MODULE", 6 ) == 0 )
-                break;
-
-            if( strnicmp( Line, "$INDEX", 6 ) == 0 )
+            if( !libPath )
             {
-                while( reader.ReadLine() )
-                {
-                    Line = reader.Line();
+                wxString msg = wxString::Format(
+                    _("PCB foot print library file <%s> could not be found in the default search paths." ),
+                    fn.GetFullName().GetData() );
 
-                    if( strnicmp( Line, "$EndINDEX", 9 ) == 0 )
-                        break;
+                // @todo we should not be using wxMessageBox directly.
+                wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
+                continue;
+            }
 
-                    StrPurge( Line );
+            MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
 
-                    if( stricmp( Line, TO_UTF8( CmpName ) ) == 0 )
-                    {
-                        Found = 1;
-                        break;
-                    }
-                }
+            if( footprint )
+            {
+                footprint->SetPosition( wxPoint( 0, 0 ) );
+                return footprint;
             }
         }
-
-        while( Found && reader.ReadLine() )
-        {
-            Line = reader.Line();
-            if( Line[0] != '$' )
-                continue;
-
-            if( Line[1] != 'M' )
-                continue;
-
-            if( strnicmp( Line, "$MODULE", 7 ) != 0 )
-                continue;
-
-            /* Read component name. */
-            sscanf( Line + 7, " %s", Name );
-
-            if( stricmp( Name, TO_UTF8( CmpName ) ) == 0 )
-            {
-                Module = new MODULE( GetBoard() );
-
-                // Switch the locale to standard C (needed to print floating
-                // point numbers like 1.3)
-                SetLocaleTo_C_standard();
-                Module->ReadDescr( &reader );
-                SetLocaleTo_Default();       // revert to the current locale
-                Module->SetPosition( wxPoint( 0, 0 ) );
-                return Module;
-            }
-        }
-
-        file = NULL;
+    }
+    catch( IO_ERROR ioe )
+    {
+        DisplayError( this, ioe.errorText );
+        return NULL;
     }
 
-    msg.Printf( _( "Module %s not found" ), CmpName.GetData() );
+    wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
     DisplayError( this, msg );
     return NULL;
 }
+
diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index 0e294a75b1..b59bd3e82b 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -15,6 +15,7 @@
 #include <../pcbnew/class_track.h>
 #include <../pcbnew/class_drawsegment.h>
 
+#include 
 #include 
 #include 
 #include 
@@ -26,32 +27,35 @@
 */
 class GBR_TO_PCB_EXPORTER
 {
-    GERBVIEW_FRAME* m_gerbview_frame;   // the maint gerber frame
-    FILE * m_file;      // .brd file to write to
-    BOARD* m_pcb;       // the board to populate and export
-
 public:
-    GBR_TO_PCB_EXPORTER(GERBVIEW_FRAME * aFrame, FILE * aFile );
+    GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
     ~GBR_TO_PCB_EXPORTER();
+
+    /**
+     * Function ExportPcb
+     * saves a board from a gerber load.
+     */
     bool ExportPcb( int* LayerLookUpTable );
     BOARD* GetBoard() { return m_pcb; }
 
 private:
-    bool WriteSetup( );  // Write the SETUP section data file
-    bool WriteGeneralDescrPcb( );
     void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
     void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
     void export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
     void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
     void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
     void cleanBoard();
+
+    GERBVIEW_FRAME* m_gerbview_frame;   // the maint gerber frame
+    wxString        m_file_name;        // BOARD file to write to
+    BOARD*          m_pcb;              // the board to populate and export
 };
 
 
-GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile )
+GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName )
 {
     m_gerbview_frame = aFrame;
-    m_file = aFile;
+    m_file_name = aFileName;
     m_pcb = new BOARD();
 }
 
@@ -84,12 +88,12 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
         return;
     }
 
-    wxString FullFileName, msg;
+    wxString fileName, msg;
 
     wxString PcbExt( wxT( ".brd" ) );
 
     msg = wxT( "*" ) + PcbExt;
-    FullFileName = EDA_FileSelector( _( "Board file name:" ),
+    fileName = EDA_FileSelector( _( "Board file name:" ),
                                      wxEmptyString,
                                      wxEmptyString,
                                      PcbExt,
@@ -98,7 +102,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
                                      wxFD_SAVE,
                                      false
                                      );
-    if( FullFileName == wxEmptyString )
+    if( fileName == wxEmptyString )
         return;
 
     /* Install a dialog frame to choose the mapping
@@ -111,24 +115,15 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
     if( ok != wxID_OK )
         return;
 
-    if( wxFileExists( FullFileName ) )
+    if( wxFileExists( fileName ) )
     {
         if( !IsOK( this, _( "Ok to change the existing file ?" ) ) )
             return;
     }
 
-    FILE * file = wxFopen( FullFileName, wxT( "wt" ) );
+    GBR_TO_PCB_EXPORTER     gbr_exporter( this, fileName );
 
-    if( file == NULL )
-    {
-        msg = _( "Unable to create " ) + FullFileName;
-        DisplayError( this, msg );
-        return;
-    }
-
-    GBR_TO_PCB_EXPORTER gbr_exporter( this, file );
     gbr_exporter.ExportPcb( dlg->GetLayersLookUpTable() );
-    fclose( file );
 }
 
 
@@ -162,54 +157,6 @@ void GBR_TO_PCB_EXPORTER::cleanBoard()
 }
 
 
-bool GBR_TO_PCB_EXPORTER::WriteSetup( )
-{
-    fprintf( m_file, "$SETUP\n" );
-    fprintf( m_file, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
-
-    fprintf( m_file, "Layers %d\n", m_pcb->GetCopperLayerCount() );
-
-    fprintf( m_file, "$EndSETUP\n\n" );
-    return true;
-}
-
-
-bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
-{
-    int nbLayers;
-
-    // Print the copper layer count
-    nbLayers = m_pcb->GetCopperLayerCount();
-
-    if( nbLayers <= 1 )  // Minimal layers count in Pcbnew is 2
-    {
-        nbLayers = 2;
-        m_pcb->SetCopperLayerCount(2);
-    }
-
-    fprintf( m_file, "$GENERAL\n" );
-    fprintf( m_file, "encoding utf-8\n");
-    fprintf( m_file, "LayerCount %d\n", nbLayers );
-
-    // Compute and print the board bounding box
-    EDA_RECT bbbox = m_pcb->ComputeBoundingBox();
-
-    fprintf( m_file, "Di %d %d %d %d\n",
-            bbbox.GetX(), bbbox.GetY(),
-            bbbox.GetRight(),
-            bbbox.GetBottom() );
-
-    fprintf( m_file, "$EndGENERAL\n\n" );
-    return true;
-}
-
-
-/* Routine to save the board
- * @param frame = pointer to the main frame
- * @param File = FILE * pointer to an already opened file
- * @param LayerLookUpTable = look up table: Pcbnew layer for each gerber layer
- * @return 1 if OK, 0 if fail
- */
 bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
 {
     BOARD* gerberPcb = m_gerbview_frame->GetBoard();
@@ -235,22 +182,21 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
     cleanBoard();
     m_pcb->SetCopperLayerCount( LayerLookUpTable[32] );
 
-    // Switch the locale to standard C (needed to print floating point numbers)
-    SetLocaleTo_C_standard();
+    try
+    {
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
+        pi->Save( m_file_name, m_pcb );
+    }
+    catch( IO_ERROR ioe )
+    {
+        DisplayError( m_gerbview_frame, ioe.errorText );
+        return false;
+    }
 
-    // write PCB header
-    fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", LEGACY_BOARD_FILE_VERSION,
-             TO_UTF8( DateAndTime() ) );
-    WriteGeneralDescrPcb( );
-    WriteSetup( );
-
-    // write items on file
-    m_pcb->Save( m_file );
-
-    SetLocaleTo_Default();       // revert to the current locale
     return true;
 }
 
+
 void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
 {
     DRAWSEGMENT* drawitem = new DRAWSEGMENT( m_pcb, PCB_LINE_T );
diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h
index 115b2140e6..bb13240a5f 100644
--- a/pcbnew/class_board.h
+++ b/pcbnew/class_board.h
@@ -848,7 +848,7 @@ public:
      * ( using the default netclass value or a preset value )
      * the default netclass is always in m_TrackWidthList[0]
      */
-    int GetCurrentTrackWidth()
+    int GetCurrentTrackWidth() const
     {
         return m_TrackWidthList[m_TrackWidthSelector];
     }
diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp
index 8caed9fe1c..75ddc95aeb 100644
--- a/pcbnew/legacy_plugin.cpp
+++ b/pcbnew/legacy_plugin.cpp
@@ -2710,8 +2710,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
 
     init( aProperties );
 
-    m_board = aBoard;
-
     FILE* fp = wxFopen( aFileName, wxT( "w" ) );
     if( !fp )
     {
@@ -2728,12 +2726,13 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
 
     if( m_props )
     {
+        // @todo move the header production into this source file.
         wxString header = (*m_props)["header"];
         // save a file header, if caller provided one (with trailing \n hopefully).
         fprintf( m_fp, "%s", TO_UTF8( header ) );
     }
 
-    saveAllSections();
+    SaveBOARD( aBoard );
 }
 
 
@@ -2751,19 +2750,19 @@ do { \
 } while(0)
 
 
-void LEGACY_PLUGIN::saveAllSections() const
+void LEGACY_PLUGIN::SaveBOARD( const BOARD* aBoard ) const
 {
-    saveGENERAL();
+    saveGENERAL( aBoard );
 
-    saveSHEET();
+    saveSHEET( aBoard );
 
-    saveSETUP();
+    saveSETUP( aBoard );
 
-    saveBOARD();
+    saveBOARD_ITEMS( aBoard );
 }
 
 
-void LEGACY_PLUGIN::saveGENERAL() const
+void LEGACY_PLUGIN::saveGENERAL( const BOARD* aBoard ) const
 {
     fprintf( m_fp, "$GENERAL\n" );
     fprintf( m_fp, "encoding utf-8\n" );
@@ -2776,7 +2775,7 @@ void LEGACY_PLUGIN::saveGENERAL() const
 #endif
 
     // Write copper layer count
-    fprintf( m_fp, "LayerCount %d\n", m_board->GetCopperLayerCount() );
+    fprintf( m_fp, "LayerCount %d\n", aBoard->GetCopperLayerCount() );
 
     /*  No, EnabledLayers has this information, plus g_TabAllCopperLayerMask is
         global and globals are not allowed in a plugin.
@@ -2785,34 +2784,35 @@ void LEGACY_PLUGIN::saveGENERAL() const
              g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
     */
 
-    fprintf( m_fp, "EnabledLayers %08X\n",  m_board->GetEnabledLayers() );
+    fprintf( m_fp, "EnabledLayers %08X\n",  aBoard->GetEnabledLayers() );
 
-    if( m_board->GetEnabledLayers() != m_board->GetVisibleLayers() )
-        fprintf( m_fp, "VisibleLayers %08X\n", m_board->GetVisibleLayers() );
+    if( aBoard->GetEnabledLayers() != aBoard->GetVisibleLayers() )
+        fprintf( m_fp, "VisibleLayers %08X\n", aBoard->GetVisibleLayers() );
 
-    fprintf( m_fp, "Links %d\n",            m_board->GetRatsnestsCount() );
-    fprintf( m_fp, "NoConn %d\n",           m_board->m_NbNoconnect );
+    fprintf( m_fp, "Links %d\n",            aBoard->GetRatsnestsCount() );
+    fprintf( m_fp, "NoConn %d\n",           aBoard->m_NbNoconnect );
 
     // Write Bounding box info
-    EDA_RECT bbbox = m_board->ComputeBoundingBox();
+    EDA_RECT bbbox = ((BOARD*)aBoard)->ComputeBoundingBox();
+
     fprintf( m_fp,  "Di %s %s\n",
                     fmtBIUPair( bbbox.GetX(), bbbox.GetY() ).c_str(),
                     fmtBIUPair( bbbox.GetRight(), bbbox.GetBottom() ).c_str() );
 
-    fprintf( m_fp, "Ndraw %d\n",            m_board->m_Drawings.GetCount() );
-    fprintf( m_fp, "Ntrack %d\n",           m_board->GetNumSegmTrack() );
-    fprintf( m_fp, "Nzone %d\n",            m_board->GetNumSegmZone() );
-    fprintf( m_fp, "BoardThickness %s\n",   fmtBIU( m_board->GetDesignSettings().m_BoardThickness ).c_str() );
-    fprintf( m_fp, "Nmodule %d\n",          m_board->m_Modules.GetCount() );
-    fprintf( m_fp, "Nnets %d\n",            m_board->GetNetCount() );
+    fprintf( m_fp, "Ndraw %d\n",            aBoard->m_Drawings.GetCount() );
+    fprintf( m_fp, "Ntrack %d\n",           aBoard->GetNumSegmTrack() );
+    fprintf( m_fp, "Nzone %d\n",            aBoard->GetNumSegmZone() );
+    fprintf( m_fp, "BoardThickness %s\n",   fmtBIU( aBoard->GetDesignSettings().m_BoardThickness ).c_str() );
+    fprintf( m_fp, "Nmodule %d\n",          aBoard->m_Modules.GetCount() );
+    fprintf( m_fp, "Nnets %d\n",            aBoard->GetNetCount() );
     fprintf( m_fp, "$EndGENERAL\n\n" );
 }
 
 
-void LEGACY_PLUGIN::saveSHEET() const
+void LEGACY_PLUGIN::saveSHEET( const BOARD* aBoard ) const
 {
-    const PAGE_INFO&    pageInfo = m_board->GetPageSettings();
-    const TITLE_BLOCK&  tb = m_board->GetTitleBlock();
+    const PAGE_INFO&    pageInfo = aBoard->GetPageSettings();
+    const TITLE_BLOCK&  tb = ((BOARD*)aBoard)->GetTitleBlock();
 
     fprintf( m_fp, "$SHEETDESCR\n" );
 
@@ -2837,10 +2837,10 @@ void LEGACY_PLUGIN::saveSHEET() const
 }
 
 
-void LEGACY_PLUGIN::saveSETUP() const
+void LEGACY_PLUGIN::saveSETUP( const BOARD* aBoard ) const
 {
-    NETCLASS* netclass_default       = m_board->m_NetClasses.GetDefault();
-    const BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
+    NETCLASS* netclass_default       = aBoard->m_NetClasses.GetDefault();
+    const BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
 
     fprintf( m_fp, "$SETUP\n" );
 
@@ -2849,32 +2849,32 @@ void LEGACY_PLUGIN::saveSETUP() const
     fprintf( m_fp,, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
     */
 
-    fprintf( m_fp, "Layers %d\n", m_board->GetCopperLayerCount() );
+    fprintf( m_fp, "Layers %d\n", aBoard->GetCopperLayerCount() );
 
-    unsigned layerMask = ALL_CU_LAYERS & m_board->GetEnabledLayers();
+    unsigned layerMask = ALL_CU_LAYERS & aBoard->GetEnabledLayers();
 
     for( int layer = 0;  layerMask;  ++layer, layerMask >>= 1 )
     {
         if( layerMask & 1 )
         {
             fprintf( m_fp, "Layer[%d] %s %s\n", layer,
-                     TO_UTF8( m_board->GetLayerName( layer ) ),
-                     LAYER::ShowType( m_board->GetLayerType( layer ) ) );
+                     TO_UTF8( aBoard->GetLayerName( layer ) ),
+                     LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
         }
     }
 
     // Save current default track width, for compatibility with older Pcbnew version;
-    fprintf( m_fp, "TrackWidth %s\n",  fmtBIU( m_board->GetCurrentTrackWidth() ).c_str() );
+    fprintf( m_fp, "TrackWidth %s\n",  fmtBIU( aBoard->GetCurrentTrackWidth() ).c_str() );
 
     // Save custom tracks width list (the first is not saved here: this is the netclass value
-    for( unsigned ii = 1; ii < m_board->m_TrackWidthList.size(); ii++ )
-        fprintf( m_fp, "TrackWidthList %s\n", fmtBIU( m_board->m_TrackWidthList[ii] ).c_str() );
+    for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ )
+        fprintf( m_fp, "TrackWidthList %s\n", fmtBIU( aBoard->m_TrackWidthList[ii] ).c_str() );
 
     fprintf( m_fp, "TrackClearence %s\n",  fmtBIU( netclass_default->GetClearance() ).c_str() );
 
     // ZONE_SETTINGS
-    fprintf( m_fp, "ZoneClearence %s\n", fmtBIU( m_board->GetZoneSettings().m_ZoneClearance ).c_str() );
-    fprintf( m_fp, "Zone_45_Only %d\n", m_board->GetZoneSettings().m_Zone_45_Only );
+    fprintf( m_fp, "ZoneClearence %s\n", fmtBIU( aBoard->GetZoneSettings().m_ZoneClearance ).c_str() );
+    fprintf( m_fp, "Zone_45_Only %d\n", aBoard->GetZoneSettings().m_Zone_45_Only );
 
     fprintf( m_fp, "TrackMinWidth %s\n", fmtBIU( bds.m_TrackMinWidth ).c_str() );
 
@@ -2889,10 +2889,10 @@ void LEGACY_PLUGIN::saveSETUP() const
 
     // Save custom vias diameters list (the first is not saved here: this is
     // the netclass value
-    for( unsigned ii = 1; ii < m_board->m_ViasDimensionsList.size(); ii++ )
+    for( unsigned ii = 1; ii < aBoard->m_ViasDimensionsList.size(); ii++ )
         fprintf( m_fp, "ViaSizeList %s %s\n",
-                 fmtBIU( m_board->m_ViasDimensionsList[ii].m_Diameter ).c_str(),
-                 fmtBIU( m_board->m_ViasDimensionsList[ii].m_Drill ).c_str() );
+                 fmtBIU( aBoard->m_ViasDimensionsList[ii].m_Diameter ).c_str(),
+                 fmtBIU( aBoard->m_ViasDimensionsList[ii].m_Drill ).c_str() );
 
     // for old versions compatibility:
     fprintf( m_fp, "MicroViaSize %s\n", fmtBIU( netclass_default->GetuViaDiameter() ).c_str() );
@@ -2926,14 +2926,14 @@ void LEGACY_PLUGIN::saveSETUP() const
     }
     */
 
-    fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( m_board->GetOriginAxisPosition() ).c_str() );
+    fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( aBoard->GetOriginAxisPosition() ).c_str() );
 
     fprintf( m_fp, "VisibleElements %X\n", bds.GetVisibleElements() );
 
     {
         STRING_FORMATTER sf;
 
-        m_board->GetPlotOptions().Format( &sf, 0 );
+        aBoard->GetPlotOptions().Format( &sf, 0 );
 
         wxString record = FROM_UTF8( sf.GetString().c_str() );
 
@@ -2947,22 +2947,22 @@ void LEGACY_PLUGIN::saveSETUP() const
 }
 
 
-void LEGACY_PLUGIN::saveBOARD() const
+void LEGACY_PLUGIN::saveBOARD_ITEMS( const BOARD* aBoard ) const
 {
     // save the nets
-    int netcount = m_board->GetNetCount();
+    int netcount = aBoard->GetNetCount();
     for( int i = 0; i < netcount;  ++i )
-        saveNETINFO_ITEM( m_board->FindNet( i ) );
+        saveNETINFO_ITEM( aBoard->FindNet( i ) );
 
     // Saved nets do not include netclass names, so save netclasses after nets.
-    saveNETCLASSES();
+    saveNETCLASSES( &aBoard->m_NetClasses );
 
     // save the modules
-    for( MODULE* m = m_board->m_Modules;  m;  m = (MODULE*) m->Next() )
+    for( MODULE* m = aBoard->m_Modules;  m;  m = (MODULE*) m->Next() )
         SaveMODULE( m );
 
     // save the graphics owned by the board (not owned by a module)
-    for( BOARD_ITEM* gr = m_board->m_Drawings;  gr;  gr = gr->Next() )
+    for( BOARD_ITEM* gr = aBoard->m_Drawings;  gr;  gr = gr->Next() )
     {
         switch( gr->Type() )
         {
@@ -2987,19 +2987,19 @@ void LEGACY_PLUGIN::saveBOARD() const
 
     // save the tracks & vias
     fprintf( m_fp, "$TRACK\n" );
-    for( TRACK* track = m_board->m_Track;  track; track = track->Next() )
+    for( TRACK* track = aBoard->m_Track;  track; track = track->Next() )
         saveTRACK( track );
     fprintf( m_fp, "$EndTRACK\n" );
 
     // save the old obsolete zones which were done by segments (tracks)
     fprintf( m_fp, "$ZONE\n" );
-    for( SEGZONE* zone = m_board->m_Zone;  zone;  zone = zone->Next() )
+    for( SEGZONE* zone = aBoard->m_Zone;  zone;  zone = zone->Next() )
         saveTRACK( zone );
     fprintf( m_fp, "$EndZONE\n" );
 
     // save the polygon (which are the newer technology) zones
-    for( int i=0;  i < m_board->GetAreaCount();  ++i )
-        saveZONE_CONTAINER( m_board->GetArea( i ) );
+    for( int i=0;  i < aBoard->GetAreaCount();  ++i )
+        saveZONE_CONTAINER( aBoard->GetArea( i ) );
 
     fprintf( m_fp, "$EndBOARD\n" );
 
@@ -3018,15 +3018,13 @@ void LEGACY_PLUGIN::saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const
 }
 
 
-void LEGACY_PLUGIN::saveNETCLASSES() const
+void LEGACY_PLUGIN::saveNETCLASSES( const NETCLASSES* aNetClasses ) const
 {
-    const NETCLASSES& nc = m_board->m_NetClasses;
-
     // save the default first.
-    saveNETCLASS( nc.GetDefault() );
+    saveNETCLASS( aNetClasses->GetDefault() );
 
     // the rest will be alphabetical in the *.brd file.
-    for( NETCLASSES::const_iterator it = nc.begin();  it != nc.end();  ++it )
+    for( NETCLASSES::const_iterator it = aNetClasses->begin();  it != aNetClasses->end();  ++it )
     {
         NETCLASS*   netclass = it->second;
         saveNETCLASS( netclass );
diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h
index 0aaa458208..ae19e59ede 100644
--- a/pcbnew/legacy_plugin.h
+++ b/pcbnew/legacy_plugin.h
@@ -40,6 +40,7 @@ class NETINFO;
 class TEXTE_PCB;
 class TRACK;
 class NETCLASS;
+class NETCLASSES;
 class ZONE_CONTAINER;
 class DIMENSION;
 class NETINFO_ITEM;
@@ -114,6 +115,8 @@ public:
     MODULE* LoadMODULE();
     void    SaveMODULE( const MODULE* aModule ) const;
     void    SaveModule3D( const MODULE* aModule ) const;
+    void    SaveBOARD( const BOARD* aBoard ) const;
+
 
 protected:
 
@@ -247,18 +250,17 @@ protected:
      */
     std::string fmtDEG( double aAngle ) const;
 
-    void saveAllSections() const;
-    void saveGENERAL() const;
-    void saveSHEET() const;
-    void saveSETUP() const;
-    void saveBOARD() const;
+    void saveGENERAL( const BOARD* aBoard ) const;
+    void saveSHEET( const BOARD* aBoard ) const;
+    void saveSETUP( const BOARD* aBoard ) const;
+    void saveBOARD_ITEMS( const BOARD* aBoard ) const;
 
     void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
     void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
     void savePAD( const D_PAD* aPad ) const;
 
     void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
-    void saveNETCLASSES() const;
+    void saveNETCLASSES( const NETCLASSES* aNetClasses ) const;
     void saveNETCLASS( const NETCLASS* aNetclass ) const;
 
     void savePCB_TEXT( const TEXTE_PCB* aText ) const;

From 597833b55e473fbf3cbcef83e16cc899fad23fb8 Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Tue, 17 Apr 2012 01:13:22 -0500
Subject: [PATCH 09/16] touch ups

---
 common/common.cpp         | 10 +++--
 common/footprint_info.cpp | 77 ++++++++++++++++++++++-----------------
 include/common.h          | 18 ++++++++-
 pcbnew/legacy_plugin.cpp  | 11 ++++++
 pcbnew/legacy_plugin.h    | 11 +-----
 5 files changed, 78 insertions(+), 49 deletions(-)

diff --git a/common/common.cpp b/common/common.cpp
index be344278a3..f23d111b09 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -120,15 +120,17 @@ StructColors ColorRefs[NBCOLOR] =
 bool g_DisableFloatingPointLocalNotation = false;
 
 
-void SetLocaleTo_C_standard( void )
+int LOCALE_IO::C_count;
+
+
+void SetLocaleTo_C_standard()
 {
     setlocale( LC_NUMERIC, "C" );    // Switch the locale to standard C
 }
 
-
-void SetLocaleTo_Default( void )
+void SetLocaleTo_Default()
 {
-    if( ! g_DisableFloatingPointLocalNotation )
+    if( !g_DisableFloatingPointLocalNotation )
         setlocale( LC_NUMERIC, "" );      // revert to the current locale
 }
 
diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp
index a8af4e515d..9b0602e25d 100644
--- a/common/footprint_info.cpp
+++ b/common/footprint_info.cpp
@@ -16,8 +16,6 @@
 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 
@@ -42,57 +40,68 @@
  */
 bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
 {
-    wxFileName  filename;
-    wxString    libname;
-
     // Clear data before reading files
     m_filesNotFound.Empty();
     m_filesInvalid.Empty();
     m_List.clear();
 
-    PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
-
-    // Parse Libraries Listed
-    for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
+    // try
     {
-        filename = aFootprintsLibNames[ii];
-        filename.SetExt( FootprintLibFileExtension );
+        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
 
-        libname = wxGetApp().FindLibraryPath( filename );
-
-        if( libname.IsEmpty() )
+        // Parse Libraries Listed
+        for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
         {
-            m_filesNotFound << filename.GetFullName() << wxT("\n");
-            continue;
-        }
+            wxFileName filename = aFootprintsLibNames[ii];
 
-        try
-        {
-            wxArrayString fpnames = pi->FootprintEnumerate( libname );
+            filename.SetExt( FootprintLibFileExtension );
 
-            for( unsigned i=0; i m( pi->FootprintLoad( libname, fpnames[i] ) );
+                m_filesNotFound << filename.GetFullName() << wxT("\n");
+                continue;
+            }
 
-                FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
+            try
+            {
+                wxArrayString fpnames = pi->FootprintEnumerate( libPath );
 
-                fpinfo->m_Module   = fpnames[i];
-                fpinfo->m_LibName  = libname;
-                fpinfo->m_padCount = m->GetPadCount();
-                fpinfo->m_KeyWord  = m->GetKeywords();
-                fpinfo->m_Doc      = m->GetDescription();
+                for( unsigned i=0; i m( pi->FootprintLoad( libPath, fpnames[i] ) );
 
-                AddItem( fpinfo );
+                    // we're loading what we enumerated, all must be there.
+                    wxASSERT( m.get() );
+
+                    FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
+
+                    fpinfo->m_Module   = fpnames[i];
+                    fpinfo->m_LibName  = libPath;
+                    fpinfo->m_padCount = m->GetPadCount();
+                    fpinfo->m_KeyWord  = m->GetKeywords();
+                    fpinfo->m_Doc      = m->GetDescription();
+
+                    AddItem( fpinfo );
+                }
+            }
+            catch( IO_ERROR ioe )
+            {
+                m_filesInvalid << ioe.errorText << wxT("\n");
             }
         }
-        catch( IO_ERROR ioe )
-        {
-            m_filesInvalid << ioe.errorText << wxT("\n");
-        }
     }
 
+    /*  caller should catch this, UI seems not wanted here.
+    catch( IO_ERROR ioe )
+    {
+        DisplayError( NULL, ioe.errorText );
+        return false;
+    }
+    */
+
     m_List.sort();
 
     return true;
 }
-
diff --git a/include/common.h b/include/common.h
index 4e10dc5f0e..12d8efe3f7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -454,6 +454,7 @@ void SetLocaleTo_C_standard();
  */
 void SetLocaleTo_Default();
 
+
 /**
  * Class LOCALE_IO
  * is a class that can be instantiated within a scope in which you are expecting
@@ -464,10 +465,23 @@ void SetLocaleTo_Default();
 class LOCALE_IO
 {
 public:
-    LOCALE_IO()     { SetLocaleTo_C_standard(); }
-    ~LOCALE_IO()    { SetLocaleTo_Default(); }
+    LOCALE_IO()
+    {
+        if( C_count++ == 0 )
+            SetLocaleTo_C_standard();
+    }
+
+    ~LOCALE_IO()
+    {
+        if( --C_count == 0 )
+            SetLocaleTo_Default();
+    }
+
+private:
+    static int C_count;     // allow for nesting of LOCALE_IO instantiations
 };
 
+
 /**
  * Function EnsureTextCtrlWidth
  * sets the minimum pixel width on a text control in order to make a text
diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp
index 81ffe64e71..52476367ac 100644
--- a/pcbnew/legacy_plugin.cpp
+++ b/pcbnew/legacy_plugin.cpp
@@ -4186,6 +4186,17 @@ bool LEGACY_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
 }
 
 
+LEGACY_PLUGIN::LEGACY_PLUGIN() :
+    m_board( 0 ),
+    m_props( 0 ),
+    m_reader( 0 ),
+    m_fp( 0 ),
+    m_cache( 0 )
+{
+    init( NULL );
+}
+
+
 LEGACY_PLUGIN::~LEGACY_PLUGIN()
 {
     delete m_cache;
diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h
index ae19e59ede..c62201c120 100644
--- a/pcbnew/legacy_plugin.h
+++ b/pcbnew/legacy_plugin.h
@@ -55,7 +55,7 @@ struct FPL_CACHE;
 /**
  * Class LEGACY_PLUGIN
  * is a PLUGIN derivation which could possibly be put into a DLL/DSO.
- * It is not thread safe, but it is re-entrant multiple times in sequence.
+ * As with any PLUGIN, there is no UI, i.e. windowing calls allowed.
  */
 class LEGACY_PLUGIN : public PLUGIN
 {
@@ -99,14 +99,7 @@ public:
 
     //--------------------------------------------------
 
-    LEGACY_PLUGIN() :
-        m_board( 0 ),
-        m_props( 0 ),
-        m_reader( 0 ),
-        m_fp( 0 ),
-        m_cache( 0 )
-    {}
-
+    LEGACY_PLUGIN();
     ~LEGACY_PLUGIN();
 
     void SetReader( LINE_READER* aReader )      { m_reader = aReader; }

From 72d4b2353b3939b97da7296ff46c2b5f5589a94c Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Tue, 17 Apr 2012 09:18:14 -0500
Subject: [PATCH 10/16] uncrustify math_for_graphics, add copyright
 legacy_plugin.h

---
 common/base_screen.cpp        |   6 +-
 pcbnew/legacy_plugin.h        |   7 +-
 polygon/math_for_graphics.cpp | 900 +++++++++++++++++++++-------------
 3 files changed, 561 insertions(+), 352 deletions(-)

diff --git a/common/base_screen.cpp b/common/base_screen.cpp
index cd0439c9ff..4a6e13cd7c 100644
--- a/common/base_screen.cpp
+++ b/common/base_screen.cpp
@@ -94,7 +94,7 @@ double BASE_SCREEN::GetScalingFactor() const
 }
 
 
-void BASE_SCREEN::SetScalingFactor(double aScale )
+void BASE_SCREEN::SetScalingFactor( double aScale )
 {
     double zoom = aScale;
 
@@ -150,12 +150,10 @@ bool BASE_SCREEN::SetZoom( double coeff )
 
 bool BASE_SCREEN::SetNextZoom()
 {
-    size_t i;
-
     if( m_ZoomList.IsEmpty() || m_Zoom >= m_ZoomList.Last() )
         return false;
 
-    for( i = 0; i < m_ZoomList.GetCount(); i++ )
+    for( unsigned i = 0; i < m_ZoomList.GetCount(); i++ )
     {
         if( m_Zoom < m_ZoomList[i] )
         {
diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h
index c62201c120..046395671b 100644
--- a/pcbnew/legacy_plugin.h
+++ b/pcbnew/legacy_plugin.h
@@ -4,7 +4,8 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck 
+ * Copyright (C) 2012 KiCad Developers, see change_log.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
@@ -59,8 +60,6 @@ struct FPL_CACHE;
  */
 class LEGACY_PLUGIN : public PLUGIN
 {
-    friend struct FPL_CACHE;
-
 public:
 
     //---------------------------------------------------
@@ -272,6 +271,8 @@ protected:
 
     /// we only cache one footprint library for now, this determines which one.
     void cacheLib( const wxString& aLibraryPath );
+
+    friend struct FPL_CACHE;
 };
 
 #endif  // LEGACY_PLUGIN_H_
diff --git a/polygon/math_for_graphics.cpp b/polygon/math_for_graphics.cpp
index 94f612a15f..10498b2fbc 100644
--- a/polygon/math_for_graphics.cpp
+++ b/polygon/math_for_graphics.cpp
@@ -29,14 +29,16 @@ bool TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist )
     if( xf==xi )
     {
         // vertical segment
-        dd = fabs( (double)(x-xi) );
+        dd = fabs( (double) (x - xi) );
+
         if( ddyi && yyi) || (yfyf && yxi && xxi) || (xfxf && x0.7 )
+        dd = sqrt( (x - xp) * (x - xp) + (y - yp) * (y - yp) );
+
+        if( fabs( b )>0.7 )
         {
             // line segment more vertical than horizontal
             if( ddyi && ypyi) || (yfyf && yp xxi && yyf > yyi )
     {
-        xo = xxf;
-        yo = yyi;
-        el->theta1 = M_PI;
-        el->theta2 = M_PI/2.0;
+        xo  = xxf;
+        yo  = yyi;
+        el->theta1  = M_PI;
+        el->theta2  = M_PI / 2.0;
     }
     else if( xxf < xxi && yyf > yyi )
     {
-        xo = xxi;
-        yo = yyf;
-        el->theta1 = -M_PI/2.0;
-        el->theta2 = -M_PI;
+        xo  = xxi;
+        yo  = yyf;
+        el->theta1  = -M_PI / 2.0;
+        el->theta2  = -M_PI;
     }
     else if( xxf < xxi && yyf < yyi )
     {
-        xo = xxf;
-        yo = yyi;
-        el->theta1 = 0.0;
-        el->theta2 = -M_PI/2.0;
+        xo  = xxf;
+        yo  = yyi;
+        el->theta1  = 0.0;
+        el->theta2  = -M_PI / 2.0;
     }
     else if( xxf > xxi && yyf < yyi )
     {
-        xo = xxi;
-        yo = yyf;
-        el->theta1 = M_PI/2.0;
-        el->theta2 = 0.0;
+        xo  = xxi;
+        yo  = yyf;
+        el->theta1  = M_PI / 2.0;
+        el->theta2  = 0.0;
     }
-    el->Center.X = xo;
-    el->Center.Y = yo;
-    el->xrad = abs(xf-xi);
-    el->yrad = abs(yf-yi);
+
+    el->Center.X    = xo;
+    el->Center.Y    = yo;
+    el->xrad        = abs( xf - xi );
+    el->yrad        = abs( yf - yi );
 #if 0
-    el->Phi = 0.0;
-    el->MaxRad = el->xrad;
-    el->MinRad = el->yrad;
+    el->Phi     = 0.0;
+    el->MaxRad  = el->xrad;
+    el->MinRad  = el->yrad;
+
     if( el->MaxRad < el->MinRad )
     {
-        el->MaxRad = el->yrad;
-        el->MinRad = el->xrad;
-        el->Phi = M_PI/2.0;
+        el->MaxRad  = el->yrad;
+        el->MinRad  = el->xrad;
+        el->Phi     = M_PI / 2.0;
     }
+
 #endif
     return 0;
 }
 
+
 // find intersections between line segment (xi,yi) to (xf,yf)
 // and line segment (xi2,yi2) to (xf2,yf2)
 // the line segments may be arcs (i.e. quadrant of an ellipse) or straight
@@ -147,16 +158,16 @@ int MakeEllipseFromArc( int xi, int yi, int xf, int yf, int style, EllipseKH * e
 // returns coords of intersections in arrays x[2], y[2]
 //
 int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
-                                 int xi2, int yi2, int xf2, int yf2, int style2,
-                                 double x[], double y[] )
+                              int xi2, int yi2, int xf2, int yf2, int style2,
+                              double x[], double y[] )
 {
-    double xr[12], yr[12];
-    int iret = 0;
+    double  xr[12], yr[12];
+    int     iret = 0;
 
-    if( max(xi,xf) < min(xi2,xf2)
-        || min(xi,xf) > max(xi2,xf2)
-        || max(yi,yf) < min(yi2,yf2)
-        || min(yi,yf) > max(yi2,yf2) )
+    if( max( xi, xf ) < min( xi2, xf2 )
+        || min( xi, xf ) > max( xi2, xf2 )
+        || max( yi, yf ) < min( yi2, yf2 )
+        || min( yi, yf ) > max( yi2, yf2 ) )
         return 0;
 
     if( style != CPolyLine::STRAIGHT && style2 != CPolyLine::STRAIGHT )
@@ -166,18 +177,20 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
         {
             if( x && y )
             {
-                x[0] = xi;
-                y[0] = yi;
+                x[0]    = xi;
+                y[0]    = yi;
             }
+
             return 1;
         }
         else if( style != style2 && xi == xf2 && yi == yf2 && xf == xi2 && yf == yi2 )
         {
             if( x && y )
             {
-                x[0] = xi;
-                y[0] = yi;
+                x[0]    = xi;
+                y[0]    = yi;
             }
+
             return 1;
         }
     }
@@ -185,48 +198,63 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
     if( style == CPolyLine::STRAIGHT && style2 == CPolyLine::STRAIGHT )
     {
         // both straight-line segments
-        int x, y;
-        bool bYes = TestForIntersectionOfStraightLineSegments( xi, yi, xf, yf, xi2, yi2, xf2, yf2, &x, &y );
+        int     x, y;
+        bool    bYes = TestForIntersectionOfStraightLineSegments( xi,
+                                                                  yi,
+                                                                  xf,
+                                                                  yf,
+                                                                  xi2,
+                                                                  yi2,
+                                                                  xf2,
+                                                                  yf2,
+                                                                  &x,
+                                                                  &y );
+
         if( !bYes )
             return 0;
-        xr[0] = x;
-        yr[0] = y;
-        iret = 1;
+
+        xr[0]   = x;
+        yr[0]   = y;
+        iret    = 1;
     }
     else if( style == CPolyLine::STRAIGHT )
     {
         // first segment is straight, second segment is an arc
-        int ret;
-        double x1r, y1r, x2r, y2r;
+        int     ret;
+        double  x1r, y1r, x2r, y2r;
+
         if( xf == xi )
         {
             // vertical first segment
-            double a = xi;
-            double b = DBL_MAX/2.0;
+            double  a   = xi;
+            double  b   = DBL_MAX / 2.0;
             ret = FindLineSegmentIntersection( a, b, xi2, yi2, xf2, yf2, style2,
-                &x1r, &y1r, &x2r, &y2r );
+                                               &x1r, &y1r, &x2r, &y2r );
         }
         else
         {
-            double b = (double)(yf-yi)/(double)(xf-xi);
-            double a = yf - b*xf;
+            double  b   = (double) (yf - yi) / (double) (xf - xi);
+            double  a   = yf - b * xf;
             ret = FindLineSegmentIntersection( a, b, xi2, yi2, xf2, yf2, style2,
-                &x1r, &y1r, &x2r, &y2r );
+                                               &x1r, &y1r, &x2r, &y2r );
         }
+
         if( ret == 0 )
             return 0;
+
         if( InRange( x1r, xi, xf ) && InRange( y1r, yi, yf ) )
         {
-            xr[iret] = x1r;
-            yr[iret] = y1r;
+            xr[iret]    = x1r;
+            yr[iret]    = y1r;
             iret++;
         }
+
         if( ret == 2 )
         {
             if( InRange( x2r, xi, xf ) && InRange( y2r, yi, yf ) )
             {
-                xr[iret] = x2r;
-                yr[iret] = y2r;
+                xr[iret]    = x2r;
+                yr[iret]    = y2r;
                 iret++;
             }
         }
@@ -234,37 +262,41 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
     else if( style2 == CPolyLine::STRAIGHT )
     {
         // first segment is an arc, second segment is straight
-        int ret;
-        double x1r, y1r, x2r, y2r;
+        int     ret;
+        double  x1r, y1r, x2r, y2r;
+
         if( xf2 == xi2 )
         {
             // vertical second segment
-            double a = xi2;
-            double b = DBL_MAX/2.0;
+            double  a   = xi2;
+            double  b   = DBL_MAX / 2.0;
             ret = FindLineSegmentIntersection( a, b, xi, yi, xf, yf, style,
-                &x1r, &y1r, &x2r, &y2r );
+                                               &x1r, &y1r, &x2r, &y2r );
         }
         else
         {
-            double b = (double)(yf2-yi2)/(double)(xf2-xi2);
-            double a = yf2 - b*xf2;
+            double  b   = (double) (yf2 - yi2) / (double) (xf2 - xi2);
+            double  a   = yf2 - b * xf2;
             ret = FindLineSegmentIntersection( a, b, xi, yi, xf, yf, style,
-                &x1r, &y1r, &x2r, &y2r );
+                                               &x1r, &y1r, &x2r, &y2r );
         }
+
         if( ret == 0 )
             return 0;
+
         if( InRange( x1r, xi2, xf2 ) && InRange( y1r, yi2, yf2 ) )
         {
-            xr[iret] = x1r;
-            yr[iret] = y1r;
+            xr[iret]    = x1r;
+            yr[iret]    = y1r;
             iret++;
         }
+
         if( ret == 2 )
         {
             if( InRange( x2r, xi2, xf2 ) && InRange( y2r, yi2, yf2 ) )
             {
-                xr[iret] = x2r;
-                yr[iret] = y2r;
+                xr[iret]    = x2r;
+                yr[iret]    = y2r;
                 iret++;
             }
         }
@@ -272,28 +304,33 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
     else
     {
         // both segments are arcs
-        EllipseKH el1;
-        EllipseKH el2;
+        EllipseKH   el1;
+        EllipseKH   el2;
         MakeEllipseFromArc( xi, yi, xf, yf, style, &el1 );
         MakeEllipseFromArc( xi2, yi2, xf2, yf2, style2, &el2 );
-        int n;
-        if( el1.xrad+el1.yrad > el2.xrad+el2.yrad )
+        int         n;
+
+        if( el1.xrad + el1.yrad > el2.xrad + el2.yrad )
             n = GetArcIntersections( &el1, &el2 );
         else
             n = GetArcIntersections( &el2, &el1 );
+
         iret = n;
     }
+
     if( x && y )
     {
-        for( int i=0; i DBL_MAX/10, assume vertical line at x = a
 // the line segment may be an arc (i.e. quadrant of an ellipse)
@@ -303,12 +340,13 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
 // if no intersection, returns min distance in dist
 //
 int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf, int style,
-                                double * x1, double * y1, double * x2, double * y2,
-                                double * dist )
+                                 double* x1, double* y1, double* x2, double* y2,
+                                 double* dist )
 {
-    double xx = 0, yy = 0;	//Init made to avoid C compil "uninitialized" warning
-    bool bVert = false;
-    if( b > DBL_MAX/10.0 )
+    double  xx = 0, yy = 0; // Init made to avoid C compil "uninitialized" warning
+    bool    bVert = false;
+
+    if( b > DBL_MAX / 10.0 )
         bVert = true;
 
     if( xf != xi )
@@ -318,36 +356,42 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int
         {
             // horizontal or oblique straight segment
             // put into form y = c + dx;
-            double d = (double)(yf-yi)/(double)(xf-xi);
-            double c = yf - d*xf;
+            double  d   = (double) (yf - yi) / (double) (xf - xi);
+            double  c   = yf - d * xf;
+
             if( bVert )
             {
                 // if vertical line, easy
                 if( InRange( a, xi, xf ) )
                 {
                     *x1 = a;
-                    *y1 = c + d*a;
+                    *y1 = c + d * a;
                     return 1;
                 }
                 else
                 {
                     if( dist )
-                        *dist = min( abs(a-xi), abs(a-xf) );
+                        *dist = min( abs( a - xi ), abs( a - xf ) );
+
                     return 0;
                 }
             }
-            if( fabs(b-d) < 1E-12 )
+
+            if( fabs( b - d ) < 1E-12 )
             {
                 // parallel lines
                 if( dist )
                 {
                     *dist = GetPointToLineDistance( a, b, xi, xf );
                 }
-                return 0;	// lines parallel
+
+                return 0;    // lines parallel
             }
+
             // calculate intersection
-            xx = (c-a)/(b-d);
-            yy = a + b*(xx);
+            xx  = (c - a) / (b - d);
+            yy  = a + b * (xx);
+
             // see if intersection is within the line segment
             if( yf == yi )
             {
@@ -368,6 +412,7 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int
             // arc (quadrant of ellipse)
             // convert to clockwise arc
             int xxi, xxf, yyi, yyf;
+
             if( style == CPolyLine::ARC_CCW )
             {
                 xxi = xf;
@@ -382,39 +427,45 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int
                 yyi = yi;
                 yyf = yf;
             }
+
             // find center and radii of ellipse
-            double xo = xxf, yo = yyi, rx, ry;		// Init made to avoid C compil warnings
+            double xo = xxf, yo = yyi, rx, ry;      // Init made to avoid C compil warnings
+
             if( xxf > xxi && yyf > yyi )
             {
-                xo = xxf;
-                yo = yyi;
+                xo  = xxf;
+                yo  = yyi;
             }
             else if( xxf < xxi && yyf > yyi )
             {
-                xo = xxi;
-                yo = yyf;
+                xo  = xxi;
+                yo  = yyf;
             }
             else if( xxf < xxi && yyf < yyi )
             {
-                xo = xxf;
-                yo = yyi;
+                xo  = xxf;
+                yo  = yyi;
             }
             else if( xxf > xxi && yyf < yyi )
             {
-                xo = xxi;
-                yo = yyf;
+                xo  = xxi;
+                yo  = yyf;
             }
-            rx = fabs( (double)(xxi-xxf) );
-            ry = fabs( (double)(yyi-yyf) );
-            bool test;
-            double xx1, xx2, yy1, yy2, aa;
+
+            rx  = fabs( (double) (xxi - xxf) );
+            ry  = fabs( (double) (yyi - yyf) );
+            bool    test;
+            double  xx1, xx2, yy1, yy2, aa;
+
             if( bVert )
             {
                 // shift vertical line to coordinate system of ellipse
                 aa = a - xo;
                 test = FindVerticalLineEllipseIntersections( rx, ry, aa, &yy1, &yy2 );
+
                 if( !test )
                     return 0;
+
                 // shift back to PCB coordinates
                 yy1 += yo;
                 yy2 += yo;
@@ -424,66 +475,76 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int
             else
             {
                 // shift line to coordinate system of ellipse
-                aa = a + b*xo - yo;
+                aa = a + b * xo - yo;
                 test = FindLineEllipseIntersections( rx, ry, aa, b, &xx1, &xx2 );
+
                 if( !test )
                     return 0;
+
                 // shift back to PCB coordinates
-                yy1 = aa + b*xx1;
+                yy1 = aa + b * xx1;
                 xx1 += xo;
                 yy1 += yo;
-                yy2 = aa + b*xx2;
+                yy2 = aa + b * xx2;
                 xx2 += xo;
                 yy2 += yo;
             }
+
             int npts = 0;
+
             if( (xxf>xxi && xx1xxi) || (xxfxxf) )
             {
                 if( (yyf>yyi && yy1yyi) || (yyfyyf) )
                 {
-                    *x1 = xx1;
-                    *y1 = yy1;
-                    npts = 1;
+                    *x1     = xx1;
+                    *y1     = yy1;
+                    npts    = 1;
                 }
             }
+
             if( (xxf>xxi && xx2xxi) || (xxfxxf) )
             {
                 if( (yyf>yyi && yy2yyi) || (yyfyyf) )
                 {
                     if( npts == 0 )
                     {
-                        *x1 = xx2;
-                        *y1 = yy2;
-                        npts = 1;
+                        *x1     = xx2;
+                        *y1     = yy2;
+                        npts    = 1;
                     }
                     else
                     {
-                        *x2 = xx2;
-                        *y2 = yy2;
-                        npts = 2;
+                        *x2     = xx2;
+                        *y2     = yy2;
+                        npts    = 2;
                     }
                 }
             }
+
             return npts;
         }
         else
-            wxASSERT(0);
+            wxASSERT( 0 );
     }
     else
     {
         // vertical line segment
         if( bVert )
             return 0;
-        xx = xi;
-        yy = a + b*xx;
+
+        xx  = xi;
+        yy  = a + b * xx;
+
         if( (yy>=yi && yy>yf) || (yy<=yi && yy max_cl, just returns max_cl and doesn't return x,y
 //
 int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, int w1,
-                                   int x2i, int y2i, int x2f, int y2f, int style2, int w2,
-                                   int max_cl, int * x, int * y )
+                                 int x2i, int y2i, int x2f, int y2f, int style2, int w2,
+                                 int max_cl, int* x, int* y )
 {
     // check clearance between bounding rectangles
-    int test = max_cl + w1/2 + w2/2;
-    if( min(x1i,x1f)-max(x2i,x2f) > test )
+    int test = max_cl + w1 / 2 + w2 / 2;
+
+    if( min( x1i, x1f ) - max( x2i, x2f ) > test )
         return max_cl;
-    if( min(x2i,x2f)-max(x1i,x1f) > test )
+
+    if( min( x2i, x2f ) - max( x1i, x1f ) > test )
         return max_cl;
-    if( min(y1i,y1f)-max(y2i,y2f) > test )
+
+    if( min( y1i, y1f ) - max( y2i, y2f ) > test )
         return max_cl;
-    if( min(y2i,y2f)-max(y1i,y1f) > test )
+
+    if( min( y2i, y2f ) - max( y1i, y1f ) > test )
         return max_cl;
 
     if( style1 == CPolyLine::STRAIGHT && style1 == CPolyLine::STRAIGHT )
     {
         // both segments are straight lines
-        int xx, yy;
-        double dd;
+        int     xx, yy;
+        double  dd;
         TestForIntersectionOfStraightLineSegments( x1i, y1i, x1f, y1f,
-            x2i, y2i, x2f, y2f, &xx, &yy, &dd );
-        int d = max( 0, (int)dd - w1/2 - w2/2 );
+                                                   x2i, y2i, x2f, y2f, &xx, &yy, &dd );
+        int     d = max( 0, (int) dd - w1 / 2 - w2 / 2 );
+
         if( x )
             *x = xx;
+
         if( y )
             *y = yy;
+
         return d;
     }
 
     // not both straight-line segments
     // see if segments intersect
-    double xr[2];
-    double yr[2];
-    test = FindSegmentIntersections( x1i, y1i, x1f, y1f, style1, x2i, y2i, x2f, y2f, style2, xr, yr );
+    double  xr[2];
+    double  yr[2];
+    test =
+        FindSegmentIntersections( x1i, y1i, x1f, y1f, style1, x2i, y2i, x2f, y2f, style2, xr, yr );
+
     if( test )
     {
         if( x )
             *x = (int) xr[0];
+
         if( y )
             *y = (int) yr[0];
+
         return 0;
     }
 
     // at least one segment is an arc
-    EllipseKH el1;
-    EllipseKH el2;
-    bool bArcs;
-    int xi=0, yi=0, xf=0, yf=0;
+    EllipseKH   el1;
+    EllipseKH   el2;
+    bool        bArcs;
+    int         xi = 0, yi = 0, xf = 0, yf = 0;
+
     if( style2 == CPolyLine::STRAIGHT )
     {
         // style1 = arc, style2 = straight
@@ -798,10 +930,10 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
     else if( style1 == CPolyLine::STRAIGHT )
     {
         // style2 = arc, style1 = straight
-        xi = x1i;
-        yi = y1i;
-        xf = x1f;
-        yf = y1f;
+        xi  = x1i;
+        yi  = y1i;
+        xf  = x1f;
+        yf  = y1f;
         MakeEllipseFromArc( x2i, y2i, x2f, y2f, style2, &el1 );
         bArcs = false;
     }
@@ -812,106 +944,127 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
         MakeEllipseFromArc( x2i, y2i, x2f, y2f, style2, &el2 );
         bArcs = true;
     }
+
     const int NSTEPS = 32;
 
     if( el1.theta2 > el1.theta1 )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
+
     if( bArcs && el2.theta2 > el2.theta1 )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
 
     // test multiple points in both segments
-    double th1;
-    double th2;
-    double len2;
+    double  th1;
+    double  th2;
+    double  len2;
+
     if( bArcs )
     {
-        th1 = el2.theta1;
-        th2 = el2.theta2;
-        len2 = max(el2.xrad, el2.yrad);
+        th1     = el2.theta1;
+        th2     = el2.theta2;
+        len2    = max( el2.xrad, el2.yrad );
     }
     else
     {
-        th1 = 1.0;
-        th2 = 0.0;
-        len2 = abs(xf-xi)+abs(yf-yi);
+        th1     = 1.0;
+        th2     = 0.0;
+        len2    = abs( xf - xi ) + abs( yf - yi );
     }
-    double s_start = el1.theta1;
-    double s_end = el1.theta2;
-    double s_start2 = th1;
-    double s_end2 = th2;
-    double dmin = DBL_MAX;
-    double xmin = 0, ymin = 0, smin = 0, smin2 = 0;		// Init made to avoid C compil warnings
 
-    int nsteps = NSTEPS;
-    int nsteps2 = NSTEPS;
-    double step = (s_start-s_end)/(nsteps-1);
-    double step2 = (s_start2-s_end2)/(nsteps2-1);
-    while( (step * max(el1.xrad, el1.yrad)) > 0.1*NM_PER_MIL
-        && (step2 * len2) > 0.1*NM_PER_MIL )
+    double  s_start     = el1.theta1;
+    double  s_end       = el1.theta2;
+    double  s_start2    = th1;
+    double  s_end2      = th2;
+    double  dmin        = DBL_MAX;
+    double  xmin        = 0, ymin = 0, smin = 0, smin2 = 0; // Init made to avoid C compil warnings
+
+    int     nsteps  = NSTEPS;
+    int     nsteps2 = NSTEPS;
+    double  step    = (s_start - s_end) / (nsteps - 1);
+    double  step2   = (s_start2 - s_end2) / (nsteps2 - 1);
+
+    while( ( step * max( el1.xrad, el1.yrad ) ) > 0.1 * NM_PER_MIL
+           && (step2 * len2) > 0.1 * NM_PER_MIL )
     {
-        step = (s_start-s_end)/(nsteps-1);
-        for( int i=0; i step2 )
         {
-            s_start = min(el1.theta1, smin + step);
-            s_end = max(el1.theta2, smin - step);
-            step = (s_start - s_end)/nsteps;
+            s_start = min( el1.theta1, smin + step );
+            s_end   = max( el1.theta2, smin - step );
+            step    = (s_start - s_end) / nsteps;
         }
         else
         {
-            s_start2 = min(th1, smin2 + step2);
-            s_end2 = max(th2, smin2 - step2);
-            step2 = (s_start2 - s_end2)/nsteps2;
+            s_start2    = min( th1, smin2 + step2 );
+            s_end2      = max( th2, smin2 - step2 );
+            step2       = (s_start2 - s_end2) / nsteps2;
         }
     }
+
     if( x )
         *x = (int) xmin;
+
     if( y )
         *y = (int) ymin;
-    return max(0, (int)dmin-w1/2-w2/2);	// allow for widths
+
+    return max( 0, (int) dmin - w1 / 2 - w2 / 2 );    // allow for widths
 }
 
 
@@ -919,33 +1072,39 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
 // if b > DBL_MAX/10, assume vertical line at x = a
 // returns closest point on line in xp, yp
 //
-double GetPointToLineDistance( double a, double b, int x, int y, double * xpp, double * ypp )
+double GetPointToLineDistance( double a, double b, int x, int y, double* xpp, double* ypp )
 {
-    if( b > DBL_MAX/10 )
+    if( b > DBL_MAX / 10 )
     {
         // vertical line
         if( xpp && ypp )
         {
-            *xpp = a;
-            *ypp = y;
+            *xpp    = a;
+            *ypp    = y;
         }
-        return abs(a-x);
+
+        return abs( a - x );
     }
+
     // find c,d such that (x,y) lies on y = c + dx where d=(-1/b)
-    double d = -1.0/b;
-    double c = (double)y-d*x;
+    double  d   = -1.0 / b;
+    double  c   = (double) y - d * x;
+
     // find nearest point to (x,y) on line through (xi,yi) to (xf,yf)
-    double xp = (a-c)/(d-b);
-    double yp = a + b*xp;
+    double  xp  = (a - c) / (d - b);
+    double  yp  = a + b * xp;
+
     if( xpp && ypp )
     {
-        *xpp = xp;
-        *ypp = yp;
+        *xpp    = xp;
+        *ypp    = yp;
     }
+
     // find distance
     return Distance( x, y, (int) xp, (int) yp );
 }
 
+
 /***********************************************************************************/
 double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int yf )
 /***********************************************************************************/
@@ -979,14 +1138,17 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
     {
         // oblique segment
         // find a,b such that (xi,yi) and (xf,yf) lie on y = a + bx
-        double b = (double)(yf-yi)/(xf-xi);
-        double a = (double)yi-b*xi;
+        double  b   = (double) (yf - yi) / (xf - xi);
+        double  a   = (double) yi - b * xi;
+
         // find c,d such that (x,y) lies on y = c + dx where d=(-1/b)
-        double d = -1.0/b;
-        double c = (double)y-d*x;
+        double  d   = -1.0 / b;
+        double  c   = (double) y - d * x;
+
         // find nearest point to (x,y) on line through (xi,yi) to (xf,yf)
-        double xp = (a-c)/(d-b);
-        double yp = a + b*xp;
+        double  xp  = (a - c) / (d - b);
+        double  yp  = a + b * xp;
+
         // find distance
         if( InRange( xp, xi, xf ) && InRange( yp, yi, yf ) )
             return Distance( x, y, (int) xp, (int) yp );
@@ -995,11 +1157,12 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
     }
 }
 
+
 // test for value within range
 //
 bool InRange( double x, double xi, double xf )
 {
-    if( xf>xi )
+    if( xf > xi )
     {
         if( x >= xi && x <= xf )
             return true;
@@ -1009,187 +1172,234 @@ bool InRange( double x, double xi, double xf )
         if( x >= xf && x <= xi )
             return true;
     }
+
     return false;
 }
 
+
 // Get distance between 2 points
 //
 double Distance( int x1, int y1, int x2, int y2 )
 {
-    double d;
-    d = sqrt( (double)(x1-x2)*(x1-x2) + (double)(y1-y2)*(y1-y2) );
+    double dx = x1 - x2;
+    double dy = y1 - y2;
+
+    double d  = sqrt( dx * dx + dy * dy );
+
     if( d > INT_MAX || d < INT_MIN )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
-    return (int)d;
+
+    // wxASSERT( d <= INT_MAX && d >= INT_MIN );
+
+    return int( d );
 }
 
+
 // this finds approximate solutions
 // note: this works best if el2 is smaller than el1
 //
-int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
-                        double * x1, double * y1, double * x2, double * y2 )
+int GetArcIntersections( EllipseKH* el1, EllipseKH* el2,
+                         double* x1, double* y1, double* x2, double* y2 )
 {
     if( el1->theta2 > el1->theta1 )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
+
     if( el2->theta2 > el2->theta1 )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
 
-    const int NSTEPS = 32;
-    double xret[2], yret[2];
+    const int   NSTEPS = 32;
+    double      xret[2], yret[2];
+
+    double      xscale  = 1.0 / el1->xrad;
+    double      yscale  = 1.0 / el1->yrad;
 
-    double xscale = 1.0/el1->xrad;
-    double yscale = 1.0/el1->yrad;
     // now transform params of second ellipse into reference frame
     // with origin at center if first ellipse,
     // scaled so the first ellipse is a circle of radius = 1.0
-    double xo = (el2->Center.X - el1->Center.X)*xscale;
-    double yo = (el2->Center.Y - el1->Center.Y)*yscale;
-    double xr = el2->xrad*xscale;
-    double yr = el2->yrad*yscale;
+    double  xo  = (el2->Center.X - el1->Center.X) * xscale;
+    double  yo  = (el2->Center.Y - el1->Center.Y) * yscale;
+    double  xr  = el2->xrad * xscale;
+    double  yr  = el2->yrad * yscale;
+
     // now test NSTEPS positions in arc, moving clockwise (ie. decreasing theta)
-    double step = M_PI/((NSTEPS-1)*2.0);
-    double d_prev=0;
-    double th_interp;
-    double th1;
-    int n = 0;
-    for( int i=0; itheta1 - i*step;
+
+        if( i < NSTEPS - 1 )
+            theta = el2->theta1 - i * step;
         else
             theta = el2->theta2;
-        double x = xo + xr*cos(theta);
-        double y = yo + yr*sin(theta);
-        double d = 1.0 - sqrt(x*x + y*y);
+
+        double  x = xo + xr * cos( theta );
+
+        double  y = yo + yr * sin( theta );
+
+        double  d = 1.0 - sqrt( x * x + y * y );
+
         if( i>0 )
         {
             bool bInt = false;
+
             if( d >= 0.0 && d_prev <= 0.0 )
             {
-                th_interp = theta + (step*(-d_prev))/(d-d_prev);
+                th_interp = theta + ( step * (-d_prev) ) / (d - d_prev);
                 bInt = true;
             }
             else if( d <= 0.0 && d_prev >= 0.0 )
             {
-                th_interp = theta + (step*d_prev)/(d_prev-d);
+                th_interp = theta + (step * d_prev) / (d_prev - d);
                 bInt = true;
             }
+
             if( bInt )
             {
-                x = xo + xr*cos(th_interp);
-                y = yo + yr*sin(th_interp);
+                x = xo + xr * cos( th_interp );
+
+                y = yo + yr * sin( th_interp );
+
                 th1 = atan2( y, x );
+
                 if( th1 <= el1->theta1 && th1 >= el1->theta2 )
                 {
-                    xret[n] = x*el1->xrad + el1->Center.X;
-                    yret[n] = y*el1->yrad + el1->Center.Y;
+                    xret[n] = x * el1->xrad + el1->Center.X;
+                    yret[n] = y * el1->yrad + el1->Center.Y;
                     n++;
+
                     if( n > 2 )
                     {
-                        wxASSERT(0);
+                        wxASSERT( 0 );
                     }
                 }
             }
         }
+
         d_prev = d;
     }
+
     if( x1 )
         *x1 = xret[0];
+
     if( y1 )
         *y1 = yret[0];
+
     if( x2 )
         *x2 = xret[1];
+
     if( y2 )
         *y2 = yret[1];
+
     return n;
 }
 
+
 // this finds approximate solution
 //
-//double GetSegmentClearance( EllipseKH * el1, EllipseKH * el2,
-double GetArcClearance( EllipseKH * el1, EllipseKH * el2,
-                     double * x1, double * y1 )
+// double GetSegmentClearance( EllipseKH * el1, EllipseKH * el2,
+double GetArcClearance( EllipseKH* el1, EllipseKH* el2,
+                        double* x1, double* y1 )
 {
     const int NSTEPS = 32;
 
     if( el1->theta2 > el1->theta1 )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
+
     if( el2->theta2 > el2->theta1 )
     {
-        wxASSERT(0);
+        wxASSERT( 0 );
     }
 
     // test multiple positions in both arcs, moving clockwise (ie. decreasing theta)
-    double th_start = el1->theta1;
-    double th_end = el1->theta2;
-    double th_start2 = el2->theta1;
-    double th_end2 = el2->theta2;
-    double dmin = DBL_MAX;
-    double xmin=0, ymin=0, thmin=0, thmin2=0;
+    double  th_start    = el1->theta1;
+    double  th_end      = el1->theta2;
+    double  th_start2   = el2->theta1;
+    double  th_end2     = el2->theta2;
+    double  dmin    = DBL_MAX;
+    double  xmin    = 0, ymin = 0, thmin = 0, thmin2 = 0;
 
-    int nsteps = NSTEPS;
-    int nsteps2 = NSTEPS;
-    double step = (th_start-th_end)/(nsteps-1);
-    double step2 = (th_start2-th_end2)/(nsteps2-1);
-    while( (step * max(el1->xrad, el1->yrad)) > 1.0*NM_PER_MIL
-        && (step2 * max(el2->xrad, el2->yrad)) > 1.0*NM_PER_MIL )
+    int     nsteps  = NSTEPS;
+    int     nsteps2 = NSTEPS;
+    double  step    = (th_start - th_end) / (nsteps - 1);
+    double  step2   = (th_start2 - th_end2) / (nsteps2 - 1);
+
+    while( ( step * max( el1->xrad, el1->yrad ) ) > 1.0 * NM_PER_MIL
+           && ( step2 * max( el2->xrad, el2->yrad ) ) > 1.0 * NM_PER_MIL )
     {
-        step = (th_start-th_end)/(nsteps-1);
-        for( int i=0; iCenter.X + el1->xrad*cos(theta);
-            double y = el1->Center.Y + el1->yrad*sin(theta);
-            step2 = (th_start2-th_end2)/(nsteps2-1);
-            for( int i2=0; i2Center.X + el1->xrad * cos( theta );
+
+            double  y = el1->Center.Y + el1->yrad * sin( theta );
+
+            step2 = (th_start2 - th_end2) / (nsteps2 - 1);
+
+            for( int i2 = 0; i2Center.X + el2->xrad*cos(theta2);
-                double y2 = el2->Center.Y + el2->yrad*sin(theta2);
-                double d = Distance( (int) x, (int) y, (int) x2, (int) y2 );
+
+                double  x2 = el2->Center.X + el2->xrad * cos( theta2 );
+                double  y2 = el2->Center.Y + el2->yrad * sin( theta2 );
+                double  d = Distance( (int) x, (int) y, (int) x2, (int) y2 );
+
                 if( d < dmin )
                 {
-                    dmin = d;
-                    xmin = x;
-                    ymin = y;
-                    thmin = theta;
-                    thmin2 = theta2;
+                    dmin    = d;
+                    xmin    = x;
+                    ymin    = y;
+                    thmin   = theta;
+                    thmin2  = theta2;
                 }
             }
         }
+
         if( step > step2 )
         {
-            th_start = min(el1->theta1, thmin + step);
-            th_end = max(el1->theta2, thmin - step);
-            step = (th_start - th_end)/nsteps;
+            th_start    = min( el1->theta1, thmin + step );
+            th_end      = max( el1->theta2, thmin - step );
+            step        = (th_start - th_end) / nsteps;
         }
         else
         {
-            th_start2 = min(el2->theta1, thmin2 + step2);
-            th_end2 = max(el2->theta2, thmin2 - step2);
-            step2 = (th_start2 - th_end2)/nsteps2;
+            th_start2   = min( el2->theta1, thmin2 + step2 );
+            th_end2     = max( el2->theta2, thmin2 - step2 );
+            step2       = (th_start2 - th_end2) / nsteps2;
         }
     }
+
     if( x1 )
         *x1 = xmin;
+
     if( y1 )
         *y1 = ymin;
+
     return dmin;
 }

From 47a41f9c66b58bff5719cfd3a2adbb6b0f17906f Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Tue, 17 Apr 2012 09:54:48 -0500
Subject: [PATCH 11/16] PLUGIN API Doxygen comments

---
 pcbnew/io_mgr.cpp |  2 +-
 pcbnew/io_mgr.h   | 75 +++++++++++------------------------------------
 2 files changed, 18 insertions(+), 59 deletions(-)

diff --git a/pcbnew/io_mgr.cpp b/pcbnew/io_mgr.cpp
index 0112ae3978..dd00e4027a 100644
--- a/pcbnew/io_mgr.cpp
+++ b/pcbnew/io_mgr.cpp
@@ -1,7 +1,7 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck 
+ * Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck 
  * Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h
index cf5b667033..c96381f0d9 100644
--- a/pcbnew/io_mgr.h
+++ b/pcbnew/io_mgr.h
@@ -4,7 +4,7 @@
 /*
  * This program source code file is part of KICAD, a free EDA CAD application.
  *
- * Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck 
+ * Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck 
  * Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
@@ -48,8 +48,9 @@ public:
      */
     enum PCB_FILE_T
     {
-        LEGACY,                         //< Legacy Pcbnew file formats prior to s-expression.
-        KICAD,                          //< S-expression Pcbnew file format.
+        LEGACY,             //< Legacy Pcbnew file formats prior to s-expression.
+        KICAD,              //< S-expression Pcbnew file format.
+
         // add your type here.
 
         // EAGLE,
@@ -261,7 +262,7 @@ public:
 
     /**
      * Function FootprintLoad
-     * loads a MODULE having @a aFootprintName from the @a aLibraryPath containing
+     * loads a footprint having @a aFootprintName from the @a aLibraryPath containing
      * a library format that this PLUGIN knows about.
      *
      * @param aLibraryPath is a locator for the "library", usually a directory
@@ -270,7 +271,7 @@ public:
      * @param aFootprintName is the name of the footprint to load.
      *
      * @param aProperties is an associative array that can be used to tell the
-     *  saver how to save the file, because it can take any number of
+     *  loader implementation to do something special, because it can take any number of
      *  additional named tuning arguments that the plugin is known to support.
      *  The caller continues to own this object (plugin may not delete it), and
      *  plugins should expect it to be optionally NULL.
@@ -292,11 +293,11 @@ public:
      *      or file containing several footprints. This is where the footprint is
      *      to be stored.
      *
-     * @param aFootprint is what to store in the library.
-     *   The caller continues to own the footprint.
+     * @param aFootprint is what to store in the library. The caller continues
+     *    to own the footprint after this call.
      *
      * @param aProperties is an associative array that can be used to tell the
-     *  saver how to save the file, because it can take any number of
+     *  saver how to save the footprint, because it can take any number of
      *  additional named tuning arguments that the plugin is known to support.
      *  The caller continues to own this object (plugin may not delete it), and
      *  plugins should expect it to be optionally NULL.
@@ -313,7 +314,7 @@ public:
      * @param aLibraryPath is a locator for the "library", usually a directory
      *   or file containing several footprints.
      *
-     * @param aFootprintName is the name of a footprint to delete from the specificed library.
+     * @param aFootprintName is the name of a footprint to delete from the specified library.
      *
      * @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it.
      */
@@ -340,19 +341,19 @@ public:
 
     /**
      * Function FootprintLibDelete
-     * deletes an existing footprint library, or complains if it cannot delete it or if it
-     * does not exist.
+     * deletes an existing footprint library, or complains if it cannot delete it
+     * or if it does not exist.
      *
      * @param aLibraryPath is a locator for the "library", usually a directory
      *   or file which will contain footprints.
      *
      * @param aProperties is an associative array that can be used to tell the
-     *  library create function anything special, because it can take any number of
-     *  additional named tuning arguments that the plugin is known to support.
-     *  The caller continues to own this object (plugin may not delete it), and
-     *  plugins should expect it to be optionally NULL.
+     *  library delete implementation function anything special, because it can
+     *  take any number of additional named tuning arguments that the plugin is
+     *  known to support. The caller continues to own this object (plugin may
+     *  not delete it), and plugins should expect it to be optionally NULL.
      *
-     * @throw IO_ERROR if there is a problem finding the library, or deleting it.
+     * @throw IO_ERROR if there is a problem finding the library or deleting it.
      */
     virtual void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
 
@@ -409,46 +410,4 @@ public:
     };
 };
 
-
-
-#if 0
-    //-----------------------------------------------------
-    // Should split into schematic specific PLUGIN base type
-
-class SCHEMATIC;
-
-    /**
-     * Function Load
-     * loads a file from some special input file format that
-     * only this implementation knows about.
-     * @param aFileName is the name of the file to load and may be foreign in nature or native in nature.
-     * @param aAppendToMe is an existing SCHEMATIC to append to but may be NULL.
-     */
-    virtual SCHEMATIC*  Load( const wxString& aFileName, SCHEMATIC* aAppendToMe,
-                            PROPERTIES* aProperties = NULL )
-    {
-        // not pure virtual so that plugins only have to implement
-        // Load() or Save() but not both.
-    }
-
-    /**
-     * Function Save
-     * will write aSchematic to a storage file in a format that only this
-     * implementation knows about.
-     *
-     * @param aFileName is the name of a file to save to on disk.
-     *
-     * @param aBoard is the SCHEMATIC document (ram data tree) to save or export to disk.
-     */
-    virtual void Save( const wxString* aFileName, SCHEMATIC* aSchematic,
-                    PROPERTIES* aProperties = NULL )
-    {
-        // not pure virtual so that plugins only have to implement
-        // Load() or Save() but not both.
-    }
-
-    //---------------------------------------------------
-#endif
-
-
 #endif // IO_MGR_H_

From f3e171797c55c7dfefa8064416b235466759557c Mon Sep 17 00:00:00 2001
From: jean-pierre charras 
Date: Wed, 18 Apr 2012 09:07:13 +0200
Subject: [PATCH 12/16] Make Gerbview working with USE_PCBNEW_NANOMETRES option
 ON

---
 gerbview/class_GERBER.cpp                     |  10 +-
 gerbview/class_aperture_macro.cpp             |  48 +--
 gerbview/dcode.cpp                            |   6 +-
 .../dialog_layers_select_to_pcb_base.fbp      | 120 +++---
 .../dialog_print_using_printer_base.fbp       | 366 +++++++++++++++++-
 .../dialogs/dialog_show_page_borders_base.fbp |  56 +--
 ...view_dialog_display_options_frame_base.fbp |  40 +-
 gerbview/excellon_read_drill_file.cpp         |   7 +-
 gerbview/export_to_pcbnew.cpp                 |  44 ++-
 gerbview/gerbview.cpp                         |  23 ++
 gerbview/gerbview_frame.cpp                   |   3 +-
 gerbview/rs274_read_XY_and_IJ_coordinates.cpp |  77 ++--
 gerbview/rs274d.cpp                           |  17 -
 gerbview/rs274x.cpp                           |   7 +-
 14 files changed, 564 insertions(+), 260 deletions(-)

diff --git a/gerbview/class_GERBER.cpp b/gerbview/class_GERBER.cpp
index c702f90586..47200fbfad 100644
--- a/gerbview/class_GERBER.cpp
+++ b/gerbview/class_GERBER.cpp
@@ -38,10 +38,10 @@
 
 
 /**
- * Function scale
- * converts a distance given in floating point to our deci-mils
+ * Function scaletoIU
+ * converts a distance given in floating point to our internal units
  */
-extern int scale( double aCoord, bool isMetric );       // defined it rs274d.cpp
+extern int scaletoIU( double aCoord, bool isMetric );       // defined it rs274d_read_XY_and_IJ_coordiantes.cpp
 
 /* Format Gerber: NOTES:
  * Tools and D_CODES
@@ -301,9 +301,9 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
                 continue;
             GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem );
             wxPoint           move_vector;
-            move_vector.x = scale( ii * GetLayerParams().m_StepForRepeat.x,
+            move_vector.x = scaletoIU( ii * GetLayerParams().m_StepForRepeat.x,
                                    GetLayerParams().m_StepForRepeatMetric );
-            move_vector.y = scale( jj * GetLayerParams().m_StepForRepeat.y,
+            move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y,
                                    GetLayerParams().m_StepForRepeatMetric );
             dupItem->MoveXY( move_vector );
             m_Parent->GetBoard()->m_Drawings.Append( dupItem );
diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp
index ce1886d104..12661308d9 100644
--- a/gerbview/class_aperture_macro.cpp
+++ b/gerbview/class_aperture_macro.cpp
@@ -39,10 +39,10 @@
 
 
 /**
- * Function scale
- * converts a distance given in floating point to our deci-mils
+ * Function scaletoIU
+ * converts a distance given in floating point to our internal units
  */
-extern int     scale( double aCoord, bool isMetric );       // defined it rs274d.cpp
+extern int scaletoIU( double aCoord, bool isMetric );       // defined it rs274d_read_XY_and_IJ_coordiantes.cpp
 
 /**
  * Function mapPt
@@ -52,7 +52,7 @@ extern int     scale( double aCoord, bool isMetric );       // defined it rs274d
  */
 static wxPoint mapPt( double x, double y, bool isMetric )
 {
-    wxPoint ret( scale( x, isMetric ), scale( y, isMetric ) );
+    wxPoint ret( scaletoIU( x, isMetric ), scaletoIU( y, isMetric ) );
 
     return ret;
 }
@@ -157,7 +157,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
          */
         curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric );
         curPos = aParent->GetABPosition( curPos );
-        int radius = scale( params[1].GetValue( tool ), m_GerbMetric ) / 2;
+        int radius = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ) / 2;
         if( !aFilledShape )
             GRCircle( aClipBox, aDC, curPos, radius, 0, aColor );
         else
@@ -300,9 +300,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
          * type(6), pos.x, pos.y, diam, penwidth, gap, circlecount, crosshair thickness, crosshaire len, rotation
          * type is not stored in parameters list, so the first parameter is pos.x
          */
-        int outerDiam    = scale( params[2].GetValue( tool ), m_GerbMetric );
-        int penThickness = scale( params[3].GetValue( tool ), m_GerbMetric );
-        int gap = scale( params[4].GetValue( tool ), m_GerbMetric );
+        int outerDiam    = scaletoIU( params[2].GetValue( tool ), m_GerbMetric );
+        int penThickness = scaletoIU( params[3].GetValue( tool ), m_GerbMetric );
+        int gap = scaletoIU( params[4].GetValue( tool ), m_GerbMetric );
         int numCircles = wxRound( params[5].GetValue( tool ) );
 
         // Draw circles:
@@ -358,8 +358,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         for( int i = 0; i
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -155,7 +156,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
 
 int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName )
 {
-    int      current_Dcode, ii, dcode_scale;
+    int      current_Dcode, ii;
     char*    ptcar;
     int      dimH, dimV, drill, dummy;
     float    fdimH, fdimV, fdrill;
@@ -174,8 +175,7 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
 
 
     /* Updating gerber scale: */
-    dcode_scale   = 10; /* By uniting dCode = mil, internal unit = 0.1 mil
-                         * -> 1 unite dcode = 10 unit PCB */
+    double dcode_scale = MILS_TO_IU_SCALAR; // By uniting dCode = mil, internal unit = MILS_TO_IU_SCALAR
     current_Dcode = 0;
 
     if( D_Code_FullFileName.IsEmpty() )
diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp
index 4856eb8d8a..dc710fe612 100644
--- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp
+++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp
@@ -1,12 +1,14 @@
 
 
-    
+    
     
         
         C++
         1
         source_name
+        0
         0
+        res
         UTF-8
         table
         dialog_layers_select_to_pcb_base
@@ -18,68 +20,44 @@
         .
         
         1
+        1
         1
         1
         0
         
-            1
-            1
-            1
-            1
             0
-            
+            wxAUI_MGR_DEFAULT
             
-            
-            1
             wxBOTH
-            0
-            1
             
             1
-            0
-            Dock
-            0
-            Left
             1
             impl_virtual
             
             
-            1
             
-            0
             0
             ID_LAYERS_MAP_DIALOG_BASE
-            
-            0
             
-            0
             
-            1
             LAYERS_MAP_DIALOG_BASE
-            1
-            
-            
-            1
             
-            
-            Resizable
-            
-            1
             400,286
             wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
             
             Layer selection:
-            0
             
-            
-            wxFILTER_NONE
-            wxDefaultValidator
-            
             
             
             
             
             
+            
+            
+            
+            
+            
+            
             
             
             
@@ -161,7 +139,11 @@
                                         1
                                         1
                                         1
+                                        
                                         
+                                        
+                                        
+                                        
                                         
                                         
                                         1
@@ -180,9 +162,10 @@
                                         0
                                         0
                                         ID_M_STATICLINESEP
-                                        
+                                        
                                         0
                                         
+                                        
                                         0
                                         
                                         1
@@ -193,19 +176,13 @@
                                         protected
                                         1
                                         
-                                        
                                         Resizable
-                                        
                                         1
                                         
                                         wxLI_VERTICAL
                                         
                                         0
                                         
-                                        
-                                        wxFILTER_NONE
-                                        wxDefaultValidator
-                                        
                                         
                                         
                                         
@@ -263,7 +240,11 @@
                                                 1
                                                 1
                                                 1
+                                                
                                                 
+                                                
+                                                
+                                                
                                                 
                                                 
                                                 1
@@ -283,9 +264,10 @@
                                                 0
                                                 ID_M_STATICTEXTCOPPERLAYERCOUNT
                                                 Copper layers count:
-                                                
+                                                
                                                 0
                                                 
+                                                
                                                 0
                                                 
                                                 1
@@ -296,19 +278,13 @@
                                                 protected
                                                 1
                                                 
-                                                
                                                 Resizable
-                                                
                                                 1
                                                 
                                                 
                                                 
                                                 0
                                                 
-                                                
-                                                wxFILTER_NONE
-                                                wxDefaultValidator
-                                                
                                                 
                                                 
                                                 
@@ -347,7 +323,11 @@
                                                 1
                                                 1
                                                 1
+                                                
                                                 
+                                                
+                                                
+                                                
                                                 
                                                 
                                                 1
@@ -367,9 +347,10 @@
                                                 0
                                                 0
                                                 ID_M_COMBOCOPPERLAYERSCOUNT
-                                                
+                                                
                                                 0
                                                 
+                                                
                                                 0
                                                 
                                                 1
@@ -380,9 +361,8 @@
                                                 protected
                                                 1
                                                 
-                                                
                                                 Resizable
-                                                
+                                                -1
                                                 1
                                                 
                                                 
@@ -455,7 +435,11 @@
                                                 1
                                                 1
                                                 1
+                                                
                                                 
+                                                
+                                                
+                                                
                                                 
                                                 
                                                 1
@@ -476,9 +460,10 @@
                                                 0
                                                 ID_STORE_CHOICE
                                                 Store Choice
-                                                
+                                                
                                                 0
                                                 
+                                                
                                                 0
                                                 
                                                 1
@@ -489,9 +474,7 @@
                                                 protected
                                                 1
                                                 
-                                                
                                                 Resizable
-                                                
                                                 1
                                                 
                                                 
@@ -540,7 +523,11 @@
                                                 1
                                                 1
                                                 1
+                                                
                                                 
+                                                
+                                                
+                                                
                                                 
                                                 
                                                 1
@@ -561,9 +548,10 @@
                                                 0
                                                 ID_GET_PREVIOUS_CHOICE
                                                 Get Stored Choice
-                                                
+                                                
                                                 0
                                                 
+                                                
                                                 0
                                                 
                                                 1
@@ -574,9 +562,7 @@
                                                 protected
                                                 1
                                                 
-                                                
                                                 Resizable
-                                                
                                                 1
                                                 
                                                 
@@ -625,7 +611,11 @@
                                                 1
                                                 1
                                                 1
+                                                
                                                 
+                                                
+                                                
+                                                
                                                 
                                                 
                                                 1
@@ -646,9 +636,10 @@
                                                 0
                                                 ID_RESET_CHOICE
                                                 Reset
-                                                
+                                                
                                                 0
                                                 
+                                                
                                                 0
                                                 
                                                 1
@@ -659,9 +650,7 @@
                                                 protected
                                                 1
                                                 
-                                                
                                                 Resizable
-                                                
                                                 1
                                                 
                                                 
@@ -716,7 +705,11 @@
                         1
                         1
                         1
+                        
                         
+                        
+                        
+                        
                         
                         
                         1
@@ -735,9 +728,10 @@
                         0
                         0
                         wxID_ANY
-                        
+                        
                         0
                         
+                        
                         0
                         
                         1
@@ -748,19 +742,13 @@
                         protected
                         1
                         
-                        
                         Resizable
-                        
                         1
                         
                         wxLI_HORIZONTAL
                         
                         0
                         
-                        
-                        wxFILTER_NONE
-                        wxDefaultValidator
-                        
                         
                         
                         
diff --git a/gerbview/dialogs/dialog_print_using_printer_base.fbp b/gerbview/dialogs/dialog_print_using_printer_base.fbp
index db3d6e6963..724b188815 100644
--- a/gerbview/dialogs/dialog_print_using_printer_base.fbp
+++ b/gerbview/dialogs/dialog_print_using_printer_base.fbp
@@ -1,12 +1,14 @@
 
 
-    
+    
     
         
         C++
         1
         source_name
+        0
         0
+        res
         UTF-8
         connect
         dialog_print_using_printer_base
@@ -18,10 +20,13 @@
         .
         
         1
+        1
         1
         1
         0
         
+            0
+            wxAUI_MGR_DEFAULT
             
             
             
@@ -42,15 +47,17 @@
             
             Print
             
-            
-            wxFILTER_NONE
-            wxDefaultValidator
-            
             
             
             
             
             
+            
+            
+            
+            
+            
+            
             
             OnCloseWindow
             
@@ -151,26 +158,57 @@
                             wxALL
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
                                 "fit in page" "Scale 0.5" "Scale 0.7" "Approx. Scale 1" "Accurate Scale 1" "Scale 1.4" "Scale 2" "Scale 3" "Scale 4"
+                                1
                                 
                                 1
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_ANY
                                 Approx. Scale:
                                 1
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_ScaleOption
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
                                 3
+                                1
                                 
                                 wxRA_SPECIFY_COLS
                                 
+                                0
                                 
                                 
                                 wxFILTER_NONE
@@ -210,28 +248,55 @@
                             wxRIGHT|wxLEFT
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_ANY
                                 X Scale Adjust
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_FineAdjustXscaleTitle
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 
-                                
-                                wxFILTER_NONE
-                                wxDefaultValidator
-                                
                                 
                                 
                                 
@@ -266,23 +331,54 @@
                             wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_ANY
+                                
+                                0
                                 
                                 0
+                                
+                                0
                                 
+                                1
                                 m_FineAdjustXscaleOpt
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 Set X scale adjust for exact scale plotting
                                 
                                 wxFILTER_NONE
@@ -326,28 +422,55 @@
                             wxRIGHT|wxLEFT
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_ANY
                                 Y Scale Adjust
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_FineAdjustYscaleTitle
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 
-                                
-                                wxFILTER_NONE
-                                wxDefaultValidator
-                                
                                 
                                 
                                 
@@ -382,23 +505,54 @@
                             wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_ANY
+                                
+                                0
                                 
                                 0
+                                
+                                0
                                 
+                                1
                                 m_FineAdjustYscaleOpt
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 Set Y scale adjust for exact scale plotting
                                 
                                 wxFILTER_NONE
@@ -465,24 +619,55 @@
                                     wxALL
                                     0
                                     
+                                        1
+                                        1
+                                        1
+                                        1
+                                        
+                                        
+                                        
+                                        
+                                        
                                         
+                                        
+                                        1
+                                        0
                                         0
+                                        1
                                         
                                         1
+                                        0
+                                        Dock
+                                        0
+                                        Left
                                         1
                                         
+                                        1
                                         
+                                        0
                                         0
                                         wxID_ANY
                                         Mirror
+                                        
+                                        0
                                         
+                                        
+                                        0
                                         
+                                        1
                                         m_Print_Mirror
+                                        1
+                                        
+                                        
                                         protected
+                                        1
                                         
+                                        Resizable
+                                        1
                                         
                                         
                                         
+                                        0
                                         
                                         
                                         wxFILTER_NONE
@@ -524,26 +709,57 @@
                             wxALL|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
                                 "Color" "Black and white"
+                                1
                                 
                                 1
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_PRINT_MODE
                                 Print Mode
                                 1
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_ModeColorOption
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
                                 0
+                                1
                                 
                                 wxRA_SPECIFY_COLS
                                 
+                                0
                                 Choose if you want to print sheets in color, or force the black and white mode.
                                 
                                 wxFILTER_NONE
@@ -594,24 +810,55 @@
                             wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
                                 0
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_PRINT_OPTIONS
                                 Page Options
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_buttonOption
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 
                                 
                                 wxFILTER_NONE
@@ -651,24 +898,55 @@
                             wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
                                 0
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_PREVIEW
                                 Preview
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_buttonPreview
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 
                                 
                                 wxFILTER_NONE
@@ -708,24 +986,55 @@
                             wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
                                 0
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_PRINT_ALL
                                 Print
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_buttonPrint
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 
                                 
                                 wxFILTER_NONE
@@ -765,24 +1074,55 @@
                             wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND
                             0
                             
+                                1
+                                1
+                                1
+                                1
+                                
+                                
+                                
+                                
+                                
                                 
+                                
+                                1
+                                0
+                                1
                                 
                                 1
                                 0
+                                0
+                                Dock
+                                0
+                                Left
                                 1
                                 
+                                1
                                 
+                                0
                                 0
                                 wxID_CANCEL
                                 Close
+                                
+                                0
                                 
+                                
+                                0
                                 
+                                1
                                 m_buttonQuit
+                                1
+                                
+                                
                                 protected
+                                1
                                 
+                                Resizable
+                                1
                                 
                                 
                                 
+                                0
                                 
                                 
                                 wxFILTER_NONE
diff --git a/gerbview/dialogs/dialog_show_page_borders_base.fbp b/gerbview/dialogs/dialog_show_page_borders_base.fbp
index a5235414bf..80828042e8 100644
--- a/gerbview/dialogs/dialog_show_page_borders_base.fbp
+++ b/gerbview/dialogs/dialog_show_page_borders_base.fbp
@@ -1,11 +1,12 @@
 
 
-    
+    
     
         
         C++
         1
         source_name
+        0
         0
         res
         UTF-8
@@ -19,66 +20,33 @@
         .
         
         1
+        1
         1
         0
         0
         
-            1
-            1
-            1
-            1
             0
-            
-            
+            wxAUI_MGR_DEFAULT
             
-            
-            1
             
-            0
-            1
             
             1
-            0
-            Dock
-            0
-            Left
             1
             impl_virtual
             
             
-            1
             
-            0
             0
             wxID_ANY
-            
-            
-            0
             
-            
-            0
             
-            1
             DIALOG_PAGE_SHOW_PAGE_BORDERS_BASE
-            1
-            
-            
-            1
             
-            
-            Resizable
-            
-            1
             263,254
             wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
             
             Page Borders
-            0
             
-            
-            wxFILTER_NONE
-            wxDefaultValidator
-            
             
             
             
@@ -150,7 +118,10 @@
                                         1
                                         1
                                         1
+                                        
                                         
+                                        
+                                        
                                         
                                         
                                         
@@ -172,7 +143,6 @@
                                         0
                                         wxID_ANY
                                         Show Page Limits:
-                                        
                                         1
                                         
                                         0
@@ -188,9 +158,7 @@
                                         protected
                                         1
                                         
-                                        
                                         Resizable
-                                        
                                         0
                                         1
                                         
@@ -244,7 +212,10 @@
                         1
                         1
                         1
+                        
                         
+                        
+                        
                         
                         
                         
@@ -264,7 +235,6 @@
                         0
                         0
                         wxID_ANY
-                        
                         
                         0
                         
@@ -279,19 +249,13 @@
                         protected
                         1
                         
-                        
                         Resizable
-                        
                         1
                         
                         wxLI_HORIZONTAL
                         
                         0
                         
-                        
-                        wxFILTER_NONE
-                        wxDefaultValidator
-                        
                         
                         
                         
diff --git a/gerbview/dialogs/gerbview_dialog_display_options_frame_base.fbp b/gerbview/dialogs/gerbview_dialog_display_options_frame_base.fbp
index f4560f63d1..00d74864b4 100644
--- a/gerbview/dialogs/gerbview_dialog_display_options_frame_base.fbp
+++ b/gerbview/dialogs/gerbview_dialog_display_options_frame_base.fbp
@@ -25,62 +25,28 @@
         0
         0
         
-            1
-            1
-            1
-            1
-            
             0
-            
-            
-            
-            
+            wxAUI_MGR_DEFAULT
             
-            
-            1
             
-            0
-            1
             
             1
-            0
-            Dock
-            0
-            Left
             1
             impl_virtual
             
             
-            1
             
-            0
             0
             wxID_ANY
-            
-            0
             
-            
-            0
             
-            1
             DIALOG_DISPLAY_OPTIONS_BASE
-            1
-            
-            
-            1
             
-            Resizable
-            1
             446,330
             wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
             
             Gerbview Options
-            0
             
-            
-            wxFILTER_NONE
-            wxDefaultValidator
-            
             
             
             
@@ -1140,10 +1106,6 @@
                         
                         0
                         
-                        
-                        wxFILTER_NONE
-                        wxDefaultValidator
-                        
                         
                         
                         
diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp
index bb15e13d20..4d3f01ce29 100644
--- a/gerbview/excellon_read_drill_file.cpp
+++ b/gerbview/excellon_read_drill_file.cpp
@@ -63,6 +63,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -430,7 +431,11 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
         dcode = GetDCODE( iprm + FIRST_DCODE );     // Remember: dcodes are >= FIRST_DCODE
         if( dcode == NULL )
             break;
-        double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT;
+        // conv_scale = scaling factor from inch to Internal Unit
+        double   conv_scale = MILS_TO_IU_SCALAR*1000;
+        if( m_GerbMetric )
+            conv_scale /= 25.4;
+
         dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale );
         dcode->m_Shape  = APT_CIRCLE;
         break;
diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index b59bd3e82b..23cefae601 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -20,7 +20,8 @@
 #include 
 #include 
 #include 
-#include           // BOARD_FILE_VERSION
+#include 
+#include 
 
 
 /* A helper class to export a Gerber set of files to Pcbnew
@@ -88,29 +89,24 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
         return;
     }
 
-    wxString fileName, msg;
+    wxString fileName;
+    wxString path = wxGetCwd();;
 
-    wxString PcbExt( wxT( ".brd" ) );
+    wxFileDialog filedlg( this, _( "Board file name:" ),
+                      path, fileName, LegacyPcbFileWildcard,
+                      wxFD_OPEN );
 
-    msg = wxT( "*" ) + PcbExt;
-    fileName = EDA_FileSelector( _( "Board file name:" ),
-                                     wxEmptyString,
-                                     wxEmptyString,
-                                     PcbExt,
-                                     msg,
-                                     this,
-                                     wxFD_SAVE,
-                                     false
-                                     );
-    if( fileName == wxEmptyString )
+    if( filedlg.ShowModal() == wxID_CANCEL )
         return;
 
+    fileName = filedlg.GetPath();
+
     /* Install a dialog frame to choose the mapping
      * between gerber layers and Pcbnew layers
      */
-    LAYERS_MAP_DIALOG* dlg = new LAYERS_MAP_DIALOG( this );
-    int ok = dlg->ShowModal();
-    dlg->Destroy();
+    LAYERS_MAP_DIALOG* layerdlg = new LAYERS_MAP_DIALOG( this );
+    int ok = layerdlg->ShowModal();
+    layerdlg->Destroy();
 
     if( ok != wxID_OK )
         return;
@@ -123,7 +119,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
 
     GBR_TO_PCB_EXPORTER     gbr_exporter( this, fileName );
 
-    gbr_exporter.ExportPcb( dlg->GetLayersLookUpTable() );
+    gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable() );
 }
 
 
@@ -184,8 +180,18 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
 
     try
     {
+        wxFileName  pcbFileName( m_file_name );
+        PROPERTIES props;
+
+        wxString header = wxString::Format(
+            wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by GerbView%s\n\n" ),
+            LEGACY_BOARD_FILE_VERSION, DateAndTime().GetData(),
+            GetBuildVersion().GetData() );
+
+        props["header"] = header;
+
         PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
-        pi->Save( m_file_name, m_pcb );
+        pi->Save( m_file_name, m_pcb, &props );
     }
     catch( IO_ERROR ioe )
     {
diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp
index c31dd68c20..1ee5148df8 100644
--- a/gerbview/gerbview.cpp
+++ b/gerbview/gerbview.cpp
@@ -3,6 +3,29 @@
  * @brief GERBVIEW main file.
  */
 
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 1992-2012 KiCad Developers, see change_log.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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
  #include 
 #include 
 #include 
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index adda132947..e922cf548c 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -407,7 +408,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
     D_CODE*           pt_D_code;
     wxString          Line;
     wxArrayString     list;
-    int               scale = 10000;
+    double            scale = MILS_TO_IU_SCALAR * 1000;
     int               curr_layer = getActiveLayer();
 
     for( int layer = 0; layer < 32; layer++ )
diff --git a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp
index 7453234730..001cd4947e 100644
--- a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp
+++ b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp
@@ -8,11 +8,50 @@
 #include 
 #include 
 #include 
+#include 
 
 
 /* These routines read the text string point from Text.
  * On exit, Text points the beginning of the sequence unread
  */
+
+// convertion scale from gerber file units to Gerbview internal units
+// depending on the gerber file format
+// this scale list assumes gerber units are imperial.
+// for metric gerber units, the imperial to metric conversion is made in read functions
+static double scale_list[10] =
+{
+    1000.0 * MILS_TO_IU_SCALAR,
+    100.0 * MILS_TO_IU_SCALAR,
+    10.0 * MILS_TO_IU_SCALAR,
+    1.0 * MILS_TO_IU_SCALAR,
+    0.1 * MILS_TO_IU_SCALAR,
+    0.01 * MILS_TO_IU_SCALAR,
+    0.001 * MILS_TO_IU_SCALAR,
+    0.0001 * MILS_TO_IU_SCALAR,
+    0.00001 * MILS_TO_IU_SCALAR,
+    0.000001 * MILS_TO_IU_SCALAR
+};
+
+
+/**
+ * Function scale
+ * converts a distance given in floating point to our internal units
+ * (deci-mils or nano units)
+ */
+int scaletoIU( double aCoord, bool isMetric )
+{
+    int ret;
+
+    if( isMetric )
+        ret = wxRound( aCoord * MILS_TO_IU_SCALAR / 0.00254 );
+    else
+        ret = wxRound( aCoord * MILS_TO_IU_SCALAR );
+
+    return ret;
+}
+
+
 wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
 {
     wxPoint pos;
@@ -53,10 +92,11 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
             *text = 0;
             if( is_float )
             {
-                if( m_GerbMetric )
-                    current_coord = wxRound( atof( line ) / 0.00254 );
-                else
-                    current_coord = wxRound( atof( line ) * PCB_INTERNAL_UNIT );
+                // When X or Y values are float numbers, they are given in mm or inches
+                if( m_GerbMetric )  // units are mm
+                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
+                else    // units are inches
+                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
             }
             else
             {
@@ -74,14 +114,7 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
                     *text = 0;
                 }
                 current_coord = atoi( line );
-                double real_scale     = 1.0;
-                double scale_list[10] =
-                {
-                    10000.0, 1000.0, 100.0, 10.0,
-                    1,
-                    0.1,     0.01,   0.001, 0.0001,0.00001
-                };
-                real_scale = scale_list[fmt_scale];
+                double real_scale = scale_list[fmt_scale];
 
                 if( m_GerbMetric )
                     real_scale = real_scale / 25.4;
@@ -150,10 +183,11 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
             *text = 0;
             if( is_float )
             {
-                if( m_GerbMetric )
-                    current_coord = wxRound( atof( line ) / 0.00254 );
-                else
-                    current_coord = wxRound( atof( line ) * PCB_INTERNAL_UNIT );
+                // When X or Y values are float numbers, they are given in mm or inches
+                if( m_GerbMetric )  // units are mm
+                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
+                else    // units are inches
+                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
             }
             else
             {
@@ -172,18 +206,11 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
                     *text = 0;
                 }
                 current_coord = atoi( line );
-                double real_scale = 1.0;
+
                 if( fmt_scale < 0 || fmt_scale > 9 )
                     fmt_scale = 4;      // select scale 1.0
 
-                double scale_list[10] =
-                {
-                    10000.0, 1000.0, 100.0, 10.0,
-                    1,
-                    0.1,     0.01,   0.001, 0.0001,0.00001
-                };
-                real_scale = scale_list[fmt_scale];
-
+                double real_scale = scale_list[fmt_scale];
                 if( m_GerbMetric )
                     real_scale = real_scale / 25.4;
                 current_coord = wxRound( current_coord * real_scale );
diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp
index 9d91924ee9..db58560e01 100644
--- a/gerbview/rs274d.cpp
+++ b/gerbview/rs274d.cpp
@@ -543,23 +543,6 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
 }
 
 
-/**
- * Function scale
- * converts a distance given in floating point to our deci-mils
- */
-int scale( double aCoord, bool isMetric )
-{
-    int ret;
-
-    if( isMetric )
-        ret = wxRound( aCoord / 0.00254 );
-    else
-        ret = wxRound( aCoord * PCB_INTERNAL_UNIT );
-
-    return ret;
-}
-
-
 bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
 {
     wxSize            size( 15, 15 );
diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp
index ce43d29a29..ab539e6ec6 100644
--- a/gerbview/rs274x.cpp
+++ b/gerbview/rs274x.cpp
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -157,7 +158,11 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
     char     line[GERBER_BUFZ];
     wxString msg;
     double   fcoord;
-    double   conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT;
+
+    // conv_scale = scaling factor from inch to Internal Unit
+    double   conv_scale = MILS_TO_IU_SCALAR*1000;
+    if( m_GerbMetric )
+        conv_scale /= 25.4;
 
 //    D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
 

From 9a6612c6ece02e37e1ce8d9d0e7f84e435e3314a Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Wed, 18 Apr 2012 07:24:40 -0500
Subject: [PATCH 13/16] use a block scope to invoke wxFFile's destructor before
 renaming temporary file

---
 pcbnew/legacy_plugin.cpp | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp
index 52476367ac..9e944698d6 100644
--- a/pcbnew/legacy_plugin.cpp
+++ b/pcbnew/legacy_plugin.cpp
@@ -3933,23 +3933,30 @@ void FPL_CACHE::Save()
 
     wxString tempFileName = wxFileName::CreateTempFileName( m_lib_name );
 
-    wxLogDebug( "tempFileName:'%s'\n", TO_UTF8( tempFileName ) );
+    // wxLogDebug( "tempFileName:'%s'\n", TO_UTF8( tempFileName ) );
 
-    FILE* fp = wxFopen( tempFileName, wxT( "w" ) );
-    if( !fp )
+    // a block {} scope to fire wxFFile wxf()'s destructor
     {
-        THROW_IO_ERROR( wxString::Format(
-            _( "Unable to open or create legacy library file '%s'" ),
-            m_lib_name.GetData() ) );
+        FILE* fp = wxFopen( tempFileName, wxT( "w" ) );
+        if( !fp )
+        {
+            THROW_IO_ERROR( wxString::Format(
+                _( "Unable to open or create legacy library file '%s'" ),
+                m_lib_name.GetData() ) );
+        }
+
+        // wxf now owns fp, will close on exception or exit from
+        // this block {} scope
+        wxFFile wxf( fp );
+
+        SaveHeader( fp );
+        SaveIndex(  fp );
+        SaveModules( fp );
+        SaveEndOfFile( fp );
     }
 
-    // wxf now owns fp, will close on exception or return
-    wxFFile wxf( fp );
-
-    SaveHeader( fp );
-    SaveIndex(  fp );
-    SaveModules( fp );
-    SaveEndOfFile( fp );
+    // fp is now closed here, and that seems proper before trying to rename
+    // the temporary file to m_lib_name.
 
     wxRemove( m_lib_name );     // it is not an error if this does not exist
 

From c24863c078a6364d15181ad73c63e4ed3fc9e019 Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Thu, 19 Apr 2012 01:55:45 -0500
Subject: [PATCH 14/16] // Dick Hollenbeck's KiROUND R&D // This provides
 better project control over rounding to int from double // than wxRound()
 did.  This scheme provides better logging in Debug builds // and it provides
 for compile time calculation of constants.

#include 
#include 
#include 

//-----------------------------------------------------------------

/**
 * KiROUND
 * rounds a floating point number to an int using
 * "round halfway cases away from zero".
 * In Debug build an assert fires if will not fit into an int.
 */

#if defined( DEBUG )

// DEBUG: a macro to capture line and file, then calls this inline

static inline int KiRound( double v, int line, const char* filename )
{
    v = v < 0 ? v - 0.5 : v + 0.5;
    if( v > INT_MAX + 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    else if( v < INT_MIN - 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    return int( v );
}

#define KiROUND( v )    KiRound( v, __LINE__, __FILE__ )

#else

// RELEASE: a macro so compile can pre-compute constants.

#define KiROUND( v )  int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )

#endif


//----------------------------------------------------------------

// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );


int main( int argc, char** argv )
{
    for( double d = double(INT_MAX)-1;  d < double(INT_MAX)+8;  d += 2.0 )
    {
        int i = KiROUND( d );

        printf( "t: %d  %.16g\n", i, d );
    }

    return 0;
}
---
 3d-viewer/3d_frame.cpp                        |  6 +--
 common/base_screen.cpp                        | 12 ++---
 common/class_bitmap_base.cpp                  |  8 ++--
 common/class_plotter.cpp                      |  2 +-
 common/common.cpp                             |  2 +-
 common/common_plotDXF_functions.cpp           |  6 +--
 common/common_plotGERBER_functions.cpp        |  6 +--
 common/common_plotHPGL_functions.cpp          | 16 +++----
 common/common_plotPS_functions.cpp            | 14 +++---
 common/dcsvg.cpp                              |  6 +--
 common/dialogs/dialog_page_settings.cpp       |  6 +--
 common/drawframe.cpp                          | 32 ++++++-------
 common/drawpanel.cpp                          | 32 ++++++-------
 common/drawtxt.cpp                            | 18 ++++----
 common/gr_basic.cpp                           |  2 +-
 common/trigo.cpp                              | 10 ++---
 cvpcb/class_DisplayFootprintsFrame.cpp        |  8 ++--
 eeschema/controle.cpp                         | 24 +++++-----
 eeschema/lib_arc.cpp                          |  4 +-
 eeschema/lib_circle.cpp                       |  4 +-
 eeschema/lib_pin.cpp                          |  4 +-
 eeschema/sch_bus_entry.cpp                    |  2 +-
 eeschema/sch_line.cpp                         |  2 +-
 eeschema/sch_sheet.cpp                        |  4 +-
 eeschema/sch_text.cpp                         |  2 +-
 eeschema/sheet.cpp                            |  4 +-
 gerbview/class_aperture_macro.cpp             | 26 +++++------
 gerbview/class_gerber_draw_item.cpp           | 14 +++---
 gerbview/controle.cpp                         |  8 ++--
 gerbview/dcode.cpp                            | 14 +++---
 gerbview/excellon_read_drill_file.cpp         |  2 +-
 gerbview/export_to_pcbnew.cpp                 |  2 +-
 gerbview/rs274_read_XY_and_IJ_coordinates.cpp | 16 +++----
 gerbview/rs274d.cpp                           |  4 +-
 gerbview/rs274x.cpp                           | 28 ++++++------
 include/common.h                              | 45 ++++++++++++++++++-
 include/plot_common.h                         |  2 +-
 pcbnew/class_board.cpp                        |  6 +--
 pcbnew/class_dimension.cpp                    |  2 +-
 pcbnew/class_drawsegment.h                    |  2 +-
 pcbnew/class_pad.cpp                          |  6 +--
 pcbnew/class_pad_draw_functions.cpp           | 16 +++----
 pcbnew/class_track.cpp                        |  2 +-
 pcbnew/class_zone.cpp                         |  4 +-
 pcbnew/controle.cpp                           |  8 ++--
 pcbnew/dialogs/dialog_orient_footprints.cpp   |  2 +-
 pcbnew/editrack.cpp                           | 10 ++---
 pcbnew/export_vrml.cpp                        | 16 +++----
 pcbnew/gendrill.cpp                           | 10 ++---
 pcbnew/gpcb_exchange.cpp                      | 22 ++++-----
 pcbnew/legacy_plugin.cpp                      |  2 +-
 pcbnew/magnetic_tracks_functions.cpp          |  8 ++--
 pcbnew/moduleframe.cpp                        |  8 ++--
 pcbnew/modview_frame.cpp                      |  8 ++--
 pcbnew/move_or_drag_track.cpp                 |  8 ++--
 pcbnew/muonde.cpp                             | 30 ++++++-------
 pcbnew/plothpgl.cpp                           |  8 ++--
 pcbnew/plotps.cpp                             |  4 +-
 pcbnew/specctra_import.cpp                    |  4 +-
 polygon/PolyLine.cpp                          |  3 +-
 60 files changed, 314 insertions(+), 272 deletions(-)

diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp
index 205ddb0d9b..f6e835f7c1 100644
--- a/3d-viewer/3d_frame.cpp
+++ b/3d-viewer/3d_frame.cpp
@@ -362,9 +362,9 @@ void EDA_3D_FRAME::Set3DBgColor()
     S3D_Color color;
     wxColour  newcolor, oldcolor;
 
-    oldcolor.Set( wxRound( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
-                  wxRound( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
-                  wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
+    oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
+                  KiROUND( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
+                  KiROUND( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
 
     newcolor = wxGetColourFromUser( this, oldcolor );
 
diff --git a/common/base_screen.cpp b/common/base_screen.cpp
index 4a6e13cd7c..7c92d64dbe 100644
--- a/common/base_screen.cpp
+++ b/common/base_screen.cpp
@@ -362,12 +362,12 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoi
     wxPoint gridOrigin = m_GridOrigin;
 
     double offset = fmod( gridOrigin.x, gridSize.x );
-    int x = wxRound( (aPosition.x - offset) / gridSize.x );
-    pt.x = wxRound( x * gridSize.x + offset );
+    int x = KiROUND( (aPosition.x - offset) / gridSize.x );
+    pt.x = KiROUND( x * gridSize.x + offset );
 
     offset = fmod( gridOrigin.y, gridSize.y );
-    int y = wxRound( (aPosition.y - offset) / gridSize.y );
-    pt.y = wxRound ( y * gridSize.y + offset );
+    int y = KiROUND( (aPosition.y - offset) / gridSize.y );
+    pt.y = KiROUND ( y * gridSize.y + offset );
 
     return pt;
 }
@@ -387,8 +387,8 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
     wxPoint pos = m_crossHairPosition - m_DrawOrg;
     double scalar = GetScalingFactor();
 
-    pos.x = wxRound( (double) pos.x * scalar );
-    pos.y = wxRound( (double) pos.y * scalar );
+    pos.x = KiROUND( (double) pos.x * scalar );
+    pos.y = KiROUND( (double) pos.y * scalar );
 
     return pos;
 }
diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp
index ebca19d945..bab646a730 100644
--- a/common/class_bitmap_base.cpp
+++ b/common/class_bitmap_base.cpp
@@ -197,8 +197,8 @@ void BITMAP_BASE::DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
     aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(),
                           logicalOriginY / GetScalingFactor() );
     aDC->DrawBitmap( *m_bitmap,
-                     wxRound( pos.x / GetScalingFactor() ),
-                     wxRound( pos.y / GetScalingFactor() ),
+                     KiROUND( pos.x / GetScalingFactor() ),
+                     KiROUND( pos.y / GetScalingFactor() ),
                      true );
     aDC->SetUserScale( scale, scale );
     aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
@@ -217,8 +217,8 @@ wxSize BITMAP_BASE::GetSize() const
         size.x = m_bitmap->GetWidth();
         size.y = m_bitmap->GetHeight();
 
-        size.x = wxRound( size.x * GetScalingFactor() );
-        size.y = wxRound( size.y * GetScalingFactor() );
+        size.x = KiROUND( size.x * GetScalingFactor() );
+        size.y = KiROUND( size.y * GetScalingFactor() );
     }
 
     return size;
diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp
index 9285340a9e..4fd290249e 100644
--- a/common/class_plotter.cpp
+++ b/common/class_plotter.cpp
@@ -98,7 +98,7 @@ double PLOTTER::user_to_device_size( double size )
 
 void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill )
 {
-    int radius     = wxRound( diametre / 2.8284 );
+    int radius     = KiROUND( diametre / 2.8284 );
     static std::vector< wxPoint > corner_list;
     corner_list.clear();
     wxPoint corner;
diff --git a/common/common.cpp b/common/common.cpp
index f23d111b09..2697a6dae8 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -371,7 +371,7 @@ double RoundTo0( double x, double precision )
 {
     assert( precision != 0 );
 
-    long long ix = wxRound( x * precision );
+    long long ix = KiROUND( x * precision );
 
     if ( x < 0.0 )
         NEGATE( ix );
diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp
index 1d7bdf1dbf..e455db7cdf 100644
--- a/common/common_plotDXF_functions.cpp
+++ b/common/common_plotDXF_functions.cpp
@@ -155,8 +155,8 @@ void DXF_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor
     size.x = aImage.GetWidth();
     size.y = aImage.GetHeight();
 
-    size.x = wxRound( size.x * aScaleFactor );
-    size.y = wxRound( size.y * aScaleFactor );
+    size.x = KiROUND( size.x * aScaleFactor );
+    size.y = KiROUND( size.y * aScaleFactor );
 
     wxPoint start = aPos;
     start.x -= size.x / 2;
@@ -241,7 +241,7 @@ void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
         return;
 
     user_to_device_coordinates( centre );
-    radius = wxRound( user_to_device_size( radius ) );
+    radius = KiROUND( user_to_device_size( radius ) );
 
     /* DXF ARC */
     wxString cname = ColorRefs[current_color].m_Name;
diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp
index cacf4476f1..051e359e57 100644
--- a/common/common_plotGERBER_functions.cpp
+++ b/common/common_plotGERBER_functions.cpp
@@ -284,7 +284,7 @@ void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int a
     double    radius = aDiameter / 2;
     const int delta  = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
 
-    start.x = aCentre.x + wxRound( radius );
+    start.x = aCentre.x + KiROUND( radius );
     start.y = aCentre.y;
     set_current_line_width( aWidth );
     move_to( start );
@@ -351,8 +351,8 @@ void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFac
     size.x = aImage.GetWidth();
     size.y = aImage.GetHeight();
 
-    size.x = wxRound( size.x * aScaleFactor );
-    size.y = wxRound( size.y * aScaleFactor );
+    size.x = KiROUND( size.x * aScaleFactor );
+    size.y = KiROUND( size.y * aScaleFactor );
 
     wxPoint start = aPos;
     start.x -= size.x / 2;
diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp
index a88c08c68e..e9c28cd988 100644
--- a/common/common_plotHPGL_functions.cpp
+++ b/common/common_plotHPGL_functions.cpp
@@ -112,8 +112,8 @@ void HPGL_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFacto
     size.x = aImage.GetWidth();
     size.y = aImage.GetHeight();
 
-    size.x = wxRound( size.x * aScaleFactor );
-    size.y = wxRound( size.y * aScaleFactor );
+    size.x = KiROUND( size.x * aScaleFactor );
+    size.y = KiROUND( size.y * aScaleFactor );
 
     wxPoint start = aPos;
     start.x -= size.x / 2;
@@ -285,7 +285,7 @@ void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
 
     if( trace_mode == FILLED )
     {
-        flash_pad_rect( pos, wxSize( size.x, deltaxy + wxRound( pen_diameter ) ),
+        flash_pad_rect( pos, wxSize( size.x, deltaxy + KiROUND( pen_diameter ) ),
                         orient, trace_mode );
         cx = 0; cy = deltaxy / 2;
         RotatePoint( &cx, &cy, orient );
@@ -298,7 +298,7 @@ void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
     }
     else    // Plot in SKETCH mode.
     {
-        sketch_oval( pos, size, orient, wxRound( pen_diameter ) );
+        sketch_oval( pos, size, orient, KiROUND( pen_diameter ) );
     }
 }
 
@@ -313,12 +313,12 @@ void HPGL_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
 
     user_to_device_coordinates( pos );
 
-    delta = wxRound( pen_diameter - pen_overlap );
+    delta = KiROUND( pen_diameter - pen_overlap );
     rayon = diametre / 2;
 
     if( trace_mode != LINE )
     {
-        rayon = ( diametre - wxRound( pen_diameter ) ) / 2;
+        rayon = ( diametre - KiROUND( pen_diameter ) ) / 2;
     }
 
     if( rayon < 0 )
@@ -483,7 +483,7 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
     wxPoint coord[4];           // absolute coordinates of corners (coordinates in plotter space)
     int     move;
 
-    move = wxRound( pen_diameter );
+    move = KiROUND( pen_diameter );
 
     for( int ii = 0; ii < 4; ii++ )
         polygone[ii] = aCorners[ii];
@@ -512,7 +512,7 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
         // TODO: replace this par the HPGL plot polygon.
         int jj;
         // Fill the shape
-        move = wxRound( pen_diameter - pen_overlap );
+        move = KiROUND( pen_diameter - pen_overlap );
         // Calculate fill height.
 
         if( polygone[0].y == polygone[3].y ) // Horizontal
diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp
index 702199d260..d0251881f8 100644
--- a/common/common_plotPS_functions.cpp
+++ b/common/common_plotPS_functions.cpp
@@ -160,7 +160,7 @@ void PS_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
 
     // Calculate start point.
     user_to_device_coordinates( centre );
-    radius = wxRound( user_to_device_size( radius ) );
+    radius = KiROUND( user_to_device_size( radius ) );
     if( plotMirror )
         fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
                  radius, (double) -EndAngle / 10, (double) -StAngle / 10,
@@ -216,8 +216,8 @@ void PS_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor
     pix_size.x = aImage.GetWidth();
     pix_size.y = aImage.GetHeight();
     wxSize drawsize;                // requested size of image
-    drawsize.x = wxRound( aScaleFactor * pix_size.x );
-    drawsize.y = wxRound( aScaleFactor * pix_size.y );
+    drawsize.x = KiROUND( aScaleFactor * pix_size.x );
+    drawsize.y = KiROUND( aScaleFactor * pix_size.y );
 
     // calculate the bottom left corner position of bitmap
     wxPoint start = aPos;
@@ -405,14 +405,14 @@ bool PS_PLOTTER::start_plot( FILE* fout )
 
     if( pageInfo.IsCustom() )
         fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
-                 wxRound( psPageSize.x * 10 * CONV_SCALE ),
-                 wxRound( psPageSize.y * 10 * CONV_SCALE ) );
+                 KiROUND( psPageSize.x * 10 * CONV_SCALE ),
+                 KiROUND( psPageSize.y * 10 * CONV_SCALE ) );
 
     else  // a standard paper size
         fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
                  TO_UTF8( pageInfo.GetType() ),
-                 wxRound( psPageSize.x * 10 * CONV_SCALE ),
-                 wxRound( psPageSize.y * 10 * CONV_SCALE ) );
+                 KiROUND( psPageSize.x * 10 * CONV_SCALE ),
+                 KiROUND( psPageSize.y * 10 * CONV_SCALE ) );
 
     if( pageInfo.IsPortrait() )
         fprintf( output_file, "%%%%Orientation: Portrait\n" );
diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp
index e6066c334d..fe7c148a19 100644
--- a/common/dcsvg.cpp
+++ b/common/dcsvg.cpp
@@ -186,15 +186,15 @@ KicadSVGFileDCImpl::~KicadSVGFileDCImpl()
 void KicadSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const
 {
     if (width)
-        *width = wxRound( (double)m_width / m_mm_to_pix_x );
+        *width = KiROUND( (double)m_width / m_mm_to_pix_x );
 
     if (height)
-        *height = wxRound( (double)m_height / m_mm_to_pix_y );
+        *height = KiROUND( (double)m_height / m_mm_to_pix_y );
 }
 
 wxSize KicadSVGFileDCImpl::GetPPI() const
 {
-    return wxSize( wxRound(m_dpi), wxRound(m_dpi) );
+    return wxSize( KiROUND(m_dpi), KiROUND(m_dpi) );
 }
 
 void KicadSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp
index 7adb5c73b0..a5cee66249 100644
--- a/common/dialogs/dialog_page_settings.cpp
+++ b/common/dialogs/dialog_page_settings.cpp
@@ -594,12 +594,12 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
     if( clamped_layout_size.x < clamped_layout_size.y )
     {
         lyHeight = MAX_PAGE_EXAMPLE_SIZE;
-        lyWidth = wxRound( (double) lyHeight / lyRatio );
+        lyWidth = KiROUND( (double) lyHeight / lyRatio );
     }
     else
     {
         lyWidth = MAX_PAGE_EXAMPLE_SIZE;
-        lyHeight = wxRound( (double) lyWidth / lyRatio );
+        lyHeight = KiROUND( (double) lyWidth / lyRatio );
     }
 
     if( m_page_bitmap )
@@ -760,5 +760,5 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog()
     // Prepare to painless double -> int conversion.
     customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );
     customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) );
-    m_layout_size = wxSize( wxRound( customSizeX ), wxRound( customSizeY ) );
+    m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) );
 }
diff --git a/common/drawframe.cpp b/common/drawframe.cpp
index a2f3979f8e..7bd1f1441b 100644
--- a/common/drawframe.cpp
+++ b/common/drawframe.cpp
@@ -515,8 +515,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
     clientSize = m_canvas->GetClientSize();
 
     // The logical size of the client window.
-    logicalClientSize.x = wxRound( (double) clientSize.x / scalar );
-    logicalClientSize.y = wxRound( (double) clientSize.y / scalar );
+    logicalClientSize.x = KiROUND( (double) clientSize.x / scalar );
+    logicalClientSize.y = KiROUND( (double) clientSize.y / scalar );
 
     // A corner of the drawing in internal units.
     wxSize corner = GetPageSizeIU();
@@ -531,14 +531,14 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
                 drawingRect.GetTop(), drawingRect.GetBottom() );
 
     // The size of the client rectangle in logical units.
-    int x = wxRound( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) );
-    int y = wxRound( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) );
+    int x = KiROUND( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) );
+    int y = KiROUND( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) );
 
     // If drawn around the center, adjust the client rectangle accordingly.
     if( screen->m_Center )
     {
-        x += wxRound( (double) drawingRect.width / 2.0 );
-        y += wxRound( (double) drawingRect.height / 2.0 );
+        x += KiROUND( (double) drawingRect.width / 2.0 );
+        y += KiROUND( (double) drawingRect.height / 2.0 );
     }
 
     wxRect logicalClientRect( wxPoint( x, y ), logicalClientSize );
@@ -622,13 +622,13 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
 
     if( screen->m_Center )
     {
-        screen->m_DrawOrg.x = -( wxRound( (double) virtualSize.x / 2.0 ) );
-        screen->m_DrawOrg.y = -( wxRound( (double) virtualSize.y / 2.0 ) );
+        screen->m_DrawOrg.x = -( KiROUND( (double) virtualSize.x / 2.0 ) );
+        screen->m_DrawOrg.y = -( KiROUND( (double) virtualSize.y / 2.0 ) );
     }
     else
     {
-        screen->m_DrawOrg.x = -( wxRound( (double) (virtualSize.x - drawingRect.width) / 2.0 ) );
-        screen->m_DrawOrg.y = -( wxRound( (double) (virtualSize.y - drawingRect.height) / 2.0 ) );
+        screen->m_DrawOrg.x = -( KiROUND( (double) (virtualSize.x - drawingRect.width) / 2.0 ) );
+        screen->m_DrawOrg.y = -( KiROUND( (double) (virtualSize.y - drawingRect.height) / 2.0 ) );
     }
 
     /* Always set scrollbar pixels per unit to 1 unless you want the zoom
@@ -640,20 +640,20 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
     screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
 
     // Calculate the number of scroll bar units for the given zoom level in device units.
-    unitsX = wxRound( (double) virtualSize.x * scalar );
-    unitsY = wxRound( (double) virtualSize.y * scalar );
+    unitsX = KiROUND( (double) virtualSize.x * scalar );
+    unitsY = KiROUND( (double) virtualSize.y * scalar );
 
     // Calculate the scroll bar position in logical units to place the center position at
     // the center of client rectangle.
     screen->SetScrollCenterPosition( aCenterPosition );
-    posX = aCenterPosition.x - wxRound( (double) logicalClientRect.width / 2.0 ) -
+    posX = aCenterPosition.x - KiROUND( (double) logicalClientRect.width / 2.0 ) -
            screen->m_DrawOrg.x;
-    posY = aCenterPosition.y - wxRound( (double) logicalClientRect.height / 2.0 ) -
+    posY = aCenterPosition.y - KiROUND( (double) logicalClientRect.height / 2.0 ) -
            screen->m_DrawOrg.y;
 
     // Convert scroll bar position to device units.
-    posX = wxRound( (double) posX * scalar );
-    posY = wxRound( (double) posY * scalar );
+    posX = KiROUND( (double) posX * scalar );
+    posY = KiROUND( (double) posY * scalar );
 
     if( posX < 0 )
     {
diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp
index c6b23f51ee..fe95da1366 100644
--- a/common/drawpanel.cpp
+++ b/common/drawpanel.cpp
@@ -405,8 +405,8 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
     double scale = GetParent()->GetScreen()->GetScalingFactor();
 
     wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
-    center.x += wxRound( (double) ( x - tmpX ) / scale );
-    center.y += wxRound( (double) ( y - tmpY ) / scale );
+    center.x += KiROUND( (double) ( x - tmpX ) / scale );
+    center.y += KiROUND( (double) ( y - tmpY ) / scale );
     GetParent()->GetScreen()->SetScrollCenterPosition( center );
 
     Scroll( x, y );
@@ -432,8 +432,8 @@ void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect )
         int scrollX, scrollY;
 
         double scalar = Screen->GetScalingFactor();
-        scrollX = wxRound( Screen->GetGridSize().x * scalar );
-        scrollY = wxRound( Screen->GetGridSize().y * scalar );
+        scrollX = KiROUND( Screen->GetGridSize().x * scalar );
+        scrollY = KiROUND( Screen->GetGridSize().y * scalar );
 
         m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
         m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
@@ -599,8 +599,8 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
     screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
     screenSize = GetClientSize();
 
-    screenGridSize.x = aDC->LogicalToDeviceXRel( wxRound( gridSize.x ) );
-    screenGridSize.y = aDC->LogicalToDeviceYRel( wxRound( gridSize.y ) );
+    screenGridSize.x = aDC->LogicalToDeviceXRel( KiROUND( gridSize.x ) );
+    screenGridSize.y = aDC->LogicalToDeviceYRel( KiROUND( gridSize.y ) );
 
     org = m_ClipBox.GetPosition();
 
@@ -621,10 +621,10 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
     // Incrementing the start point by one grid step should prevent drawing grid points
     // outside the clip box.
     if( org.x < m_ClipBox.GetX() )
-        org.x += wxRound( gridSize.x );
+        org.x += KiROUND( gridSize.x );
 
     if( org.y < m_ClipBox.GetY() )
-        org.y += wxRound( gridSize.y );
+        org.y += KiROUND( gridSize.y );
 
 #if ( defined( __WXMAC__ ) || 1 )
     // Use a pixel based draw to display grid.  There are a lot of calls, so the cost is
@@ -643,11 +643,11 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
 
     for( double x = (double) org.x; x <= right; x += gridSize.x )
     {
-        xpos = wxRound( x );
+        xpos = KiROUND( x );
 
         for( double y = (double) org.y; y <= bottom; y += gridSize.y )
         {
-            aDC->DrawPoint( xpos, wxRound( y )  );
+            aDC->DrawPoint( xpos, KiROUND( y )  );
         }
     }
 #else
@@ -684,7 +684,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
     // Draw a column of grid points.
     for( double y = (double) org.y; y <= bottom; y += gridSize.y )
     {
-        tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( wxRound( y ) ) );
+        tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( KiROUND( y ) ) );
     }
 
     // Reset the device context scale and origin and restore on exit.
@@ -700,7 +700,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
     // Blit the column for each row of the damaged region.
     for( double x = (double) org.x; x <= right; x += gridSize.x )
     {
-        aDC->Blit( scaleDC.LogicalToDeviceX( wxRound( x ) ),
+        aDC->Blit( scaleDC.LogicalToDeviceX( KiROUND( x ) ),
                    scaleDC.LogicalToDeviceY( m_ClipBox.GetY() ),
                    1, tmpBM.GetHeight(), &tmpDC, 0, 0, wxCOPY, true );
     }
@@ -1072,8 +1072,8 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
             double scale = GetParent()->GetScreen()->GetScalingFactor();
 
             wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
-            center.x += wxRound( (double) ( x - tmpX ) / scale ) / ppux;
-            center.y += wxRound( (double) ( y - tmpY ) / scale ) / ppuy;
+            center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux;
+            center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy;
             GetParent()->GetScreen()->SetScrollCenterPosition( center );
 
             Refresh();
@@ -1083,9 +1083,9 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
         {
             double scale = GetParent()->GetScreen()->GetScalingFactor();
             int x = m_PanStartCenter.x +
-                    wxRound( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
+                    KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
             int y = m_PanStartCenter.y +
-                    wxRound( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
+                    KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
 
             GetParent()->RedrawScreen( wxPoint( x, y ), false );
         }
diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp
index fed7ff29d0..590c0d69ec 100644
--- a/common/drawtxt.cpp
+++ b/common/drawtxt.cpp
@@ -35,7 +35,7 @@ double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR;
  */
 int GetPenSizeForBold( int aTextSize )
 {
-    return wxRound( aTextSize / 5.0 );
+    return KiROUND( aTextSize / 5.0 );
 }
 
 
@@ -55,7 +55,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
 {
     int    penSize  = aPenSize;
     double scale    = aBold ? 4.0 : 6.0;
-    int    maxWidth = wxRound( ABS( aSize ) / scale );
+    int    maxWidth = KiROUND( ABS( aSize ) / scale );
 
     if( penSize > maxWidth )
         penSize = maxWidth;
@@ -138,13 +138,13 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, boo
         /* Get metrics */
         int         xsta = *ptcar++ - 'R';
         int         xsto = *ptcar++ - 'R';
-        tally += wxRound( aXSize * (xsto - xsta) * s_HerscheyScaleFactor );
+        tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor );
     }
 
     /* Italic correction, 1/8em */
     if( aItalic )
     {
-        tally += wxRound( aXSize * 0.125 );
+        tally += KiROUND( aXSize * 0.125 );
     }
     return tally;
 }
@@ -196,7 +196,7 @@ static void DrawGraphicTextPline(
  */
 static int overbar_position( int size_v, int thickness )
 {
-    return wxRound( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) );
+    return KiROUND( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) );
 }
 
 
@@ -460,12 +460,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
             {
                 wxPoint currpoint;
                 hc1 -= xsta; hc2 -= 11; /* Align the midpoint */
-                hc1  = wxRound( hc1 * size_h * s_HerscheyScaleFactor );
-                hc2  = wxRound( hc2 * size_v * s_HerscheyScaleFactor );
+                hc1  = KiROUND( hc1 * size_h * s_HerscheyScaleFactor );
+                hc2  = KiROUND( hc2 * size_v * s_HerscheyScaleFactor );
 
                 // To simulate an italic font, add a x offset depending on the y offset
                 if( aItalic )
-                    hc1 -= wxRound( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 );
+                    hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 );
                 currpoint.x = hc1 + current_char_pos.x;
                 currpoint.y = hc2 + current_char_pos.y;
 
@@ -481,7 +481,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
         ptr++;
 
         // Apply the advance width
-        current_char_pos.x += wxRound( size_h * (xsto - xsta) * s_HerscheyScaleFactor );
+        current_char_pos.x += KiROUND( size_h * (xsto - xsta) * s_HerscheyScaleFactor );
     }
 
     if( overbars % 2 )
diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp
index 98126bf5cd..d5886ae113 100644
--- a/common/gr_basic.cpp
+++ b/common/gr_basic.cpp
@@ -1410,7 +1410,7 @@ void ClipAndDrawFilledPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], in
 
     for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
     {
-        clippedPolygon.push_back( wxPoint( wxRound( cit->X ), wxRound( cit->Y ) ) );
+        clippedPolygon.push_back( wxPoint( KiROUND( cit->X ), KiROUND( cit->Y ) ) );
     }
 
     if( clippedPolygon.size() )
diff --git a/common/trigo.cpp b/common/trigo.cpp
index c09a83ac99..12fb0014f2 100644
--- a/common/trigo.cpp
+++ b/common/trigo.cpp
@@ -6,7 +6,7 @@
 #include 
 #include 
 #include 
-
+#include 
 
 bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist )
 {
@@ -140,7 +140,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY )
          */
         int angle;
 
-        angle = wxRound( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) );
+        angle = KiROUND( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) );
         cXrot = pointX;
         cYrot = pointY;
 
@@ -211,7 +211,7 @@ int ArcTangente( int dy, int dx )
     }
 
     fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800;
-    return wxRound( fangle );
+    return KiROUND( fangle );
 }
 
 
@@ -253,8 +253,8 @@ void RotatePoint( int* pX, int* pY, double angle )
         double cosinus = cos( fangle );
         double fpx = (*pY * sinus ) + (*pX * cosinus );
         double fpy = (*pY * cosinus ) - (*pX * sinus );
-        *pX = wxRound( fpx );
-        *pY = wxRound( fpy );
+        *pX = KiROUND( fpx );
+        *pY = KiROUND( fpy );
     }
 }
 
diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp
index fd64a701f7..69d55be7db 100644
--- a/cvpcb/class_DisplayFootprintsFrame.cpp
+++ b/cvpcb/class_DisplayFootprintsFrame.cpp
@@ -380,25 +380,25 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
 
     case WXK_NUMPAD8:       /* cursor moved up */
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:       /* cursor moved down */
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:       /*  cursor moved left */
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:      /*  cursor moved right */
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
     }
diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp
index fb077f70a4..5552f0495e 100644
--- a/eeschema/controle.cpp
+++ b/eeschema/controle.cpp
@@ -208,25 +208,25 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
 
     case WXK_NUMPAD8:
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
@@ -293,25 +293,25 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
 
     case WXK_NUMPAD8:
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
@@ -375,25 +375,25 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
 
     case WXK_NUMPAD8:
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp
index e9567fb0cb..a13bd9a66e 100644
--- a/eeschema/lib_arc.cpp
+++ b/eeschema/lib_arc.cpp
@@ -188,7 +188,7 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran
 
     NEGATE( relativePosition.y );       // reverse Y axis
 
-    int distance = wxRound( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) );
+    int distance = KiROUND( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) );
 
     if( abs( distance - m_Radius ) > aThreshold )
         return false;
@@ -738,7 +738,7 @@ void LIB_ARC::calcRadiusAngles()
     wxPoint centerStartVector = TwoPointVector( m_Pos, m_ArcStart );
     wxPoint centerEndVector   = TwoPointVector( m_Pos, m_ArcEnd );
 
-    m_Radius = wxRound( EuclideanNorm( centerStartVector ) );
+    m_Radius = KiROUND( EuclideanNorm( centerStartVector ) );
 
     m_t1 = (int) ( atan2( (double) centerStartVector.y,
                           (double) centerStartVector.x ) * 1800 / M_PI );
diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp
index 4c5032c17e..327420a2d8 100644
--- a/eeschema/lib_circle.cpp
+++ b/eeschema/lib_circle.cpp
@@ -106,7 +106,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
 
     wxPoint relpos = aPosRef - aTransform.TransformCoordinate( m_Pos );
 
-    int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) +
+    int dist = KiROUND( sqrt( ( (double) relpos.x * relpos.x ) +
                               ( (double) relpos.y * relpos.y ) ) );
 
     if( abs( dist - m_Radius ) <= aThreshold )
@@ -346,7 +346,7 @@ void LIB_CIRCLE::calcEdit( const wxPoint& aPosition )
 
         int dx = m_Pos.x - aPosition.x;
         int dy = m_Pos.y - aPosition.y;
-        m_Radius = wxRound( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) );
+        m_Radius = KiROUND( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) );
     }
     else
     {
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index fa7c106b70..4e64347c16 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -1889,7 +1889,7 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
     int numberTextLength = showNum ? m_numTextSize * GetNumberString().Len() : 0;
 
     // Actual text height is bigger than text size
-    int numberTextHeight  = showNum ? wxRound( m_numTextSize * 1.1 ) : 0;
+    int numberTextHeight  = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
 
     if( m_shape & INVERT )
         minsizeV = MAX( TARGET_PIN_RADIUS, INVERT_PIN_RADIUS );
@@ -1914,7 +1914,7 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
         nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
 
         // Actual text height are bigger than text size
-        nameTextHeight = wxRound( m_nameTextSize * 1.1 ) + TXTMARGE;
+        nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + TXTMARGE;
     }
 
     if( nameTextOffset )        // for values > 0, pin name is inside the body
diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp
index ac9d8bd46a..a3b7b136db 100644
--- a/eeschema/sch_bus_entry.cpp
+++ b/eeschema/sch_bus_entry.cpp
@@ -169,7 +169,7 @@ int SCH_BUS_ENTRY::GetPenSize() const
 
     if( m_Layer == LAYER_BUS && m_width == 0 )
     {
-        pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
+        pensize = KiROUND( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
         pensize = MAX( pensize, 3 );
     }
 
diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp
index 6e20f18fbe..ec43fb5872 100644
--- a/eeschema/sch_line.cpp
+++ b/eeschema/sch_line.cpp
@@ -214,7 +214,7 @@ int SCH_LINE::GetPenSize() const
 
     if( m_Layer == LAYER_BUS && m_width == 0 )
     {
-        pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
+        pensize = KiROUND( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
         pensize = MAX( pensize, 3 );
     }
 
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index ab31d80788..066924b628 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -651,8 +651,8 @@ EDA_RECT SCH_SHEET::GetBoundingBox() const
     end += m_pos;
 
     // Move upper and lower limits to include texts:
-    box.SetY( box.GetY() - ( wxRound( m_sheetNameSize * 1.3 ) + 8 ) );
-    end.y += wxRound( m_fileNameSize * 1.3 ) + 8;
+    box.SetY( box.GetY() - ( KiROUND( m_sheetNameSize * 1.3 ) + 8 ) );
+    end.y += KiROUND( m_fileNameSize * 1.3 ) + 8;
 
     box.SetEnd( end );
     box.Inflate( lineWidth / 2 );
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index c6e6df09c1..08e54bb310 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -1242,7 +1242,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aPoints, const
     int x = symb_len + linewidth + 3;
 
     // 50% more for negation bar
-    int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
+    int y = KiROUND( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
 
     // Starting point(anchor)
     aPoints.push_back( wxPoint( 0, 0 ) );
diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp
index c72a7c2898..ce8e6a0601 100644
--- a/eeschema/sheet.cpp
+++ b/eeschema/sheet.cpp
@@ -231,8 +231,8 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
 
         if( sheet->HasPins() )
         {
-            int gridSizeX = wxRound( screen->GetGridSize().x );
-            int gridSizeY = wxRound( screen->GetGridSize().y );
+            int gridSizeX = KiROUND( screen->GetGridSize().x );
+            int gridSizeY = KiROUND( screen->GetGridSize().y );
 
             // If the sheet has pins, use the pin positions to clamp the minimum height.
             height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp
index 12661308d9..2e7d9ee4a3 100644
--- a/gerbview/class_aperture_macro.cpp
+++ b/gerbview/class_aperture_macro.cpp
@@ -176,7 +176,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         ConvertShapeToPolygon( aParent, polybuffer );
 
         // shape rotation:
-        rotation = wxRound( params[6].GetValue( tool ) * 10.0 );
+        rotation = KiROUND( params[6].GetValue( tool ) * 10.0 );
         if( rotation )
         {
             for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
@@ -205,7 +205,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         ConvertShapeToPolygon( aParent, polybuffer );
 
         // shape rotation:
-        rotation = wxRound( params[5].GetValue( tool ) * 10.0 );
+        rotation = KiROUND( params[5].GetValue( tool ) * 10.0 );
         if( rotation )
         {
             for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
@@ -234,7 +234,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         ConvertShapeToPolygon( aParent, polybuffer );
 
         // shape rotation:
-        rotation = wxRound( params[5].GetValue( tool ) * 10.0 );
+        rotation = KiROUND( params[5].GetValue( tool ) * 10.0 );
         if( rotation )
         {
             for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
@@ -264,7 +264,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         ConvertShapeToPolygon( aParent, polybuffer );
 
         // shape rotation:
-        rotation = wxRound( params[5].GetValue( tool ) * 10.0 );
+        rotation = KiROUND( params[5].GetValue( tool ) * 10.0 );
 
         // Because a thermal shape has 4 identical sub-shapes, only one is created in polybuffer.
         // We must draw 4 sub-shapes rotated by 90 deg
@@ -303,7 +303,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         int outerDiam    = scaletoIU( params[2].GetValue( tool ), m_GerbMetric );
         int penThickness = scaletoIU( params[3].GetValue( tool ), m_GerbMetric );
         int gap = scaletoIU( params[4].GetValue( tool ), m_GerbMetric );
-        int numCircles = wxRound( params[5].GetValue( tool ) );
+        int numCircles = KiROUND( params[5].GetValue( tool ) );
 
         // Draw circles:
         wxPoint center = aParent->GetABPosition( curPos );
@@ -329,7 +329,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         // Draw the cross:
         ConvertShapeToPolygon( aParent, polybuffer );
 
-        rotation = wxRound( params[8].GetValue( tool ) * 10.0 );
+        rotation = KiROUND( params[8].GetValue( tool ) * 10.0 );
         for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
         {
             // shape rotation:
@@ -352,7 +352,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
          * type is not stored in parameters list, so the first parameter is exposure
          */
         int numPoints = (int) params[1].GetValue( tool );
-        rotation  = wxRound( params[numPoints * 2 + 4].GetValue( tool ) * 10.0 );
+        rotation  = KiROUND( params[numPoints * 2 + 4].GetValue( tool ) * 10.0 );
         wxPoint pos;
         // Read points. numPoints does not include the starting point, so add 1.
         for( int i = 0; i 0)
@@ -537,7 +537,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM*     aParent,
         // outer arc
         startpos.x  = outerRadius;
         startpos.y  = 0;
-        angle_start = wxRound( asin( (double) halfthickness / outerRadius ) * 1800 / M_PI );
+        angle_start = KiROUND( asin( (double) halfthickness / outerRadius ) * 1800 / M_PI );
         angle_end   = 900 - angle_start;
 
         // First point, near Y axis, outer arc
@@ -593,7 +593,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM*     aParent,
 
     case AMP_POLYGON:   // Creates a regular polygon
     {
-        int vertexcount = wxRound( params[1].GetValue( tool ) );
+        int vertexcount = KiROUND( params[1].GetValue( tool ) );
         int radius    = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2;
         // rs274x said: vertex count = 3 ... 10, and the first corner is on the X axis
         if( vertexcount < 3 )
diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp
index c98ef7e78f..eb12582741 100644
--- a/gerbview/class_gerber_draw_item.cpp
+++ b/gerbview/class_gerber_draw_item.cpp
@@ -115,9 +115,9 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
         EXCHG( abPos.x, abPos.y );
 
     abPos  += m_layerOffset + m_imageParams->m_ImageOffset;
-    abPos.x = wxRound( abPos.x * m_drawScale.x );
-    abPos.y = wxRound( abPos.y * m_drawScale.y );
-    int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
+    abPos.x = KiROUND( abPos.x * m_drawScale.x );
+    abPos.y = KiROUND( abPos.y * m_drawScale.y );
+    int rotation = KiROUND(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
 
     if( rotation )
         RotatePoint( &abPos, -rotation );
@@ -144,13 +144,13 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition )
     if( !m_mirrorB )
         NEGATE( xyPos.y );
 
-    int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
+    int rotation = KiROUND(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
 
     if( rotation )
         RotatePoint( &xyPos, rotation );
 
-    xyPos.x = wxRound( xyPos.x / m_drawScale.x );
-    xyPos.y = wxRound( xyPos.y / m_drawScale.y );
+    xyPos.x = KiROUND( xyPos.x / m_drawScale.x );
+    xyPos.y = KiROUND( xyPos.y / m_drawScale.y );
     xyPos  -= m_layerOffset + m_imageParams->m_ImageOffset;
 
     if( m_swapAxis )
@@ -368,7 +368,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
         break;
 
     case GBR_CIRCLE:
-        radius = wxRound(hypot( (double) ( m_End.x - m_Start.x ),
+        radius = KiROUND(hypot( (double) ( m_End.x - m_Start.x ),
                                 (double) ( m_End.y - m_Start.y ) ));
 
         halfPenWidth = m_Size.x >> 1;
diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp
index 5ec581b7c6..f42c0e1f67 100644
--- a/gerbview/controle.cpp
+++ b/gerbview/controle.cpp
@@ -47,25 +47,25 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
     {
     case WXK_NUMPAD8:
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp
index 73d4b973eb..beb64ef5e5 100644
--- a/gerbview/dcode.cpp
+++ b/gerbview/dcode.cpp
@@ -215,9 +215,9 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
             sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
                     &dimH, &dimV, &drill, &dummy, &dummy, &type_outil );
 
-            dimH  = wxRound( dimH * dcode_scale );
-            dimV  = wxRound( dimV * dcode_scale );
-            drill = wxRound( drill * dcode_scale );
+            dimH  = KiROUND( dimH * dcode_scale );
+            dimV  = KiROUND( dimV * dcode_scale );
+            drill = KiROUND( drill * dcode_scale );
 
             if( ii < 1 )
                 ii = 1;
@@ -245,9 +245,9 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
                 }
             }
 
-            dimH  = wxRound( fdimH * dcode_scale * 1000 );
-            dimV  = wxRound( fdimV * dcode_scale * 1000 );
-            drill = wxRound( fdrill * dcode_scale * 1000 );
+            dimH  = KiROUND( fdimH * dcode_scale * 1000 );
+            dimV  = KiROUND( fdimV * dcode_scale * 1000 );
+            drill = KiROUND( fdrill * dcode_scale * 1000 );
 
             if( strchr( "CLROP", c_type_outil[0] ) )
             {
@@ -600,7 +600,7 @@ void D_CODE::ConvertShapeToPolygon()
 
         if( m_Rotation )                   // vertical oval, rotate polygon.
         {
-            int angle = wxRound( m_Rotation * 10 );
+            int angle = KiROUND( m_Rotation * 10 );
 
             for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
             {
diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp
index 4d3f01ce29..64e40a4305 100644
--- a/gerbview/excellon_read_drill_file.cpp
+++ b/gerbview/excellon_read_drill_file.cpp
@@ -436,7 +436,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
         if( m_GerbMetric )
             conv_scale /= 25.4;
 
-        dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale );
+        dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale );
         dcode->m_Shape  = APT_CIRCLE;
         break;
     }
diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index 23cefae601..2e835f909c 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -220,7 +220,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, in
                            (double)( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
 
         drawitem->SetShape( S_ARC );
-        drawitem->SetAngle( wxRound( (a - b) / M_PI * 1800.0 ) );
+        drawitem->SetAngle( KiROUND( (a - b) / M_PI * 1800.0 ) );
         drawitem->SetStart( aGbrItem->m_ArcCentre );
 
         if( drawitem->GetAngle() < 0 )
diff --git a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp
index 001cd4947e..eea3b618ca 100644
--- a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp
+++ b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp
@@ -44,9 +44,9 @@ int scaletoIU( double aCoord, bool isMetric )
     int ret;
 
     if( isMetric )
-        ret = wxRound( aCoord * MILS_TO_IU_SCALAR / 0.00254 );
+        ret = KiROUND( aCoord * MILS_TO_IU_SCALAR / 0.00254 );
     else
-        ret = wxRound( aCoord * MILS_TO_IU_SCALAR );
+        ret = KiROUND( aCoord * MILS_TO_IU_SCALAR );
 
     return ret;
 }
@@ -94,9 +94,9 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
             {
                 // When X or Y values are float numbers, they are given in mm or inches
                 if( m_GerbMetric )  // units are mm
-                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
+                    current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
                 else    // units are inches
-                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
+                    current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
             }
             else
             {
@@ -119,7 +119,7 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
                 if( m_GerbMetric )
                     real_scale = real_scale / 25.4;
 
-                current_coord = wxRound( current_coord * real_scale );
+                current_coord = KiROUND( current_coord * real_scale );
             }
 
             if( type_coord == 'X' )
@@ -185,9 +185,9 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
             {
                 // When X or Y values are float numbers, they are given in mm or inches
                 if( m_GerbMetric )  // units are mm
-                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
+                    current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
                 else    // units are inches
-                    current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
+                    current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
             }
             else
             {
@@ -213,7 +213,7 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
                 double real_scale = scale_list[fmt_scale];
                 if( m_GerbMetric )
                     real_scale = real_scale / 25.4;
-                current_coord = wxRound( current_coord * real_scale );
+                current_coord = KiROUND( current_coord * real_scale );
             }
             if( type_coord == 'I' )
                 pos.x = current_coord;
diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp
index db58560e01..e6500c0864 100644
--- a/gerbview/rs274d.cpp
+++ b/gerbview/rs274d.cpp
@@ -345,8 +345,8 @@ static void fillArcPOLY(  BOARD* aPcb, GERBER_DRAW_ITEM* aGbrItem,
      * angle is trigonometrical (counter-clockwise),
      * and axis is the X,Y gerber coordinates
      */
-    int start_angle = wxRound(atan2( (double) start.y, (double) start.x ) * 1800 / M_PI);
-    int end_angle = wxRound(atan2( (double) end.y, (double) end.x ) * 1800 / M_PI);
+    int start_angle = KiROUND(atan2( (double) start.y, (double) start.x ) * 1800 / M_PI);
+    int end_angle = KiROUND(atan2( (double) end.y, (double) end.x ) * 1800 / M_PI);
 
     // dummyTrack has right geometric parameters, but
     // fillArcGBRITEM calculates arc parameters for a draw function that expects
diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp
index ab539e6ec6..311566f0dc 100644
--- a/gerbview/rs274x.cpp
+++ b/gerbview/rs274x.cpp
@@ -306,13 +306,13 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
             case 'A':       // A axis offset in current unit (inch or mm)
                 text++;
                 fcoord     = ReadDouble( text );
-                m_Offset.x = wxRound( fcoord * conv_scale );
+                m_Offset.x = KiROUND( fcoord * conv_scale );
                 break;
 
             case 'B':       // B axis offset in current unit (inch or mm)
                 text++;
                 fcoord     = ReadDouble( text );
-                m_Offset.y = wxRound( fcoord * conv_scale );
+                m_Offset.y = KiROUND( fcoord * conv_scale );
                 break;
             }
         }
@@ -346,13 +346,13 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
             case 'A':       // A axis offset in current unit (inch or mm)
                 text++;
                 fcoord     = ReadDouble( text );
-                m_ImageOffset.x = wxRound( fcoord * conv_scale );
+                m_ImageOffset.x = KiROUND( fcoord * conv_scale );
                 break;
 
             case 'B':       // B axis offset in current unit (inch or mm)
                 text++;
                 fcoord     = ReadDouble( text );
-                m_ImageOffset.y = wxRound( fcoord * conv_scale );
+                m_ImageOffset.y = KiROUND( fcoord * conv_scale );
                 break;
             }
         }
@@ -429,7 +429,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                     m_ImageJustifyXCenter = true;
                     text++;
                 }
-                else m_ImageJustifyOffset.x = wxRound( ReadDouble( text ) * conv_scale);
+                else m_ImageJustifyOffset.x = KiROUND( ReadDouble( text ) * conv_scale);
                 break;
 
             case 'B':       // B axis justify
@@ -444,7 +444,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                     m_ImageJustifyYCenter = true;
                     text++;
                 }
-                else m_ImageJustifyOffset.y = wxRound( ReadDouble( text ) * conv_scale);
+                else m_ImageJustifyOffset.y = KiROUND( ReadDouble( text ) * conv_scale);
                 break;
             default:
                 text++;
@@ -580,7 +580,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
             text += 2;              // skip "C," for example
 
             dcode->m_Size.x = dcode->m_Size.y =
-                                  wxRound( ReadDouble( text ) * conv_scale );
+                                  KiROUND( ReadDouble( text ) * conv_scale );
 
             switch( stdAperture )   // Aperture desceiption has optional parameters. Read them
             {
@@ -593,7 +593,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Drill.x = dcode->m_Drill.y =
-                                           wxRound( ReadDouble( text ) * conv_scale );
+                                           KiROUND( ReadDouble( text ) * conv_scale );
                     dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
                 }
 
@@ -604,7 +604,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Drill.y =
-                        wxRound( ReadDouble( text ) * conv_scale );
+                        KiROUND( ReadDouble( text ) * conv_scale );
 
                     dcode->m_DrillShape = APT_DEF_RECT_HOLE;
                 }
@@ -622,7 +622,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Size.y =
-                        wxRound( ReadDouble( text ) * conv_scale );
+                        KiROUND( ReadDouble( text ) * conv_scale );
                 }
 
                 while( *text == ' ' )
@@ -632,7 +632,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Drill.x = dcode->m_Drill.y =
-                                           wxRound( ReadDouble( text ) * conv_scale );
+                                           KiROUND( ReadDouble( text ) * conv_scale );
                     dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
                 }
 
@@ -643,7 +643,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Drill.y =
-                        wxRound( ReadDouble( text ) * conv_scale );
+                        KiROUND( ReadDouble( text ) * conv_scale );
                     dcode->m_DrillShape = APT_DEF_RECT_HOLE;
                 }
                 dcode->m_Defined = true;
@@ -680,7 +680,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Drill.x = dcode->m_Drill.y =
-                                           wxRound( ReadDouble( text ) * conv_scale );
+                                           KiROUND( ReadDouble( text ) * conv_scale );
                     dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
                 }
 
@@ -691,7 +691,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int       command,
                 {
                     text++;
                     dcode->m_Drill.y =
-                        wxRound( ReadDouble( text ) * conv_scale );
+                        KiROUND( ReadDouble( text ) * conv_scale );
                     dcode->m_DrillShape = APT_DEF_RECT_HOLE;
                 }
                 dcode->m_Defined = true;
diff --git a/include/common.h b/include/common.h
index 12d8efe3f7..e9d7274255 100644
--- a/include/common.h
+++ b/include/common.h
@@ -118,11 +118,52 @@ enum pseudokeys {
 #define OFF 0
 
 
+//-----------------------------------------------------------------
+
+/**
+ * KiROUND
+ * rounds a floating point number to an int using
+ * "round halfway cases away from zero".
+ * In Debug build an assert fires if will not fit into an int.
+ */
+
+#if defined( DEBUG )
+
+// DEBUG: a macro to capture line and file, then calls this inline
+
+static inline int KiRound( double v, int line, const char* filename )
+{
+    v = v < 0 ? v - 0.5 : v + 0.5;
+    if( v > INT_MAX + 0.5 )
+    {
+        printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
+    }
+    else if( v < INT_MIN - 0.5 )
+    {
+        printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
+    }
+    return int( v );
+}
+
+#define KiROUND( v )    KiRound( v, __LINE__, __FILE__ )
+
+#else
+
+// RELEASE: a macro so compile can pre-compute constants.
+
+#define KiROUND( v )  int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
+
+#endif
+
+//----------------------------------------------------------------
+
+
+
 /// Convert mm to mils.
-inline int Mm2mils( double x ) { return wxRound( x * 1000./25.4 ); }
+inline int Mm2mils( double x ) { return KiROUND( x * 1000./25.4 ); }
 
 /// Convert mils to mm.
-inline int Mils2mm( double x ) { return wxRound( x * 25.4 / 1000. ); }
+inline int Mils2mm( double x ) { return KiROUND( x * 25.4 / 1000. ); }
 
 
 /// Return whether GOST is in play
diff --git a/include/plot_common.h b/include/plot_common.h
index f9c4c62dcc..0a5beecafb 100644
--- a/include/plot_common.h
+++ b/include/plot_common.h
@@ -257,7 +257,7 @@ public:
     virtual void set_current_line_width( int width )
     {
         // Handy override
-        current_pen_width = wxRound( pen_diameter );
+        current_pen_width = KiROUND( pen_diameter );
     }
 
     virtual void set_default_line_width( int width ) {};
diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp
index 1eec4719a9..209afd0e5b 100644
--- a/pcbnew/class_board.cpp
+++ b/pcbnew/class_board.cpp
@@ -1954,10 +1954,10 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace,
     }
 
     if( aTraceLength )
-        *aTraceLength = wxRound( full_len );
+        *aTraceLength = KiROUND( full_len );
 
     if( aDieLength )
-        *aDieLength = wxRound( lenDie );
+        *aDieLength = KiROUND( lenDie );
 
     if( aCount )
         *aCount = NbSegmBusy;
@@ -2092,7 +2092,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
     if( delta.x == 0 )
         lockPoint.x = 0;         /* horizontal segment*/
     else
-        lockPoint.y = wxRound( ( (double)lockPoint.x * delta.y ) / delta.x );
+        lockPoint.y = KiROUND( ( (double)lockPoint.x * delta.y ) / delta.x );
 
     /* Create the intermediate point (that is to say creation of a new
      * segment, beginning at the intermediate point.
diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp
index c954b630e3..f72805bad3 100644
--- a/pcbnew/class_dimension.cpp
+++ b/pcbnew/class_dimension.cpp
@@ -258,7 +258,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
     deltay = m_featureLineDOy - m_featureLineGOy;
 
     // Calculate dimension value
-    mesure = wxRound( hypot( (double) deltax, (double) deltay ) );
+    mesure = KiROUND( hypot( (double) deltax, (double) deltay ) );
 
     if( deltax || deltay )
         angle = atan2( (double) deltay, (double) deltax );
diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h
index fb32619e9c..7d9e5e5609 100644
--- a/pcbnew/class_drawsegment.h
+++ b/pcbnew/class_drawsegment.h
@@ -128,7 +128,7 @@ public:
     int GetRadius() const
     {
         double radius = hypot( (double) (m_End.x - m_Start.x), (double) (m_End.y - m_Start.y) );
-        return wxRound( radius );
+        return KiROUND( radius );
     }
 
     /**
diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp
index cd9ae27c5f..1c91dd4054 100644
--- a/pcbnew/class_pad.cpp
+++ b/pcbnew/class_pad.cpp
@@ -433,8 +433,8 @@ wxSize D_PAD::GetSolderPasteMargin()
     }
 
     wxSize pad_margin;
-    pad_margin.x = margin + wxRound( m_Size.x * mratio );
-    pad_margin.y = margin + wxRound( m_Size.y * mratio );
+    pad_margin.x = margin + KiROUND( m_Size.x * mratio );
+    pad_margin.y = margin + KiROUND( m_Size.y * mratio );
 
     // ensure mask have a size always >= 0
     if( pad_margin.x < -m_Size.x / 2 )
@@ -688,7 +688,7 @@ bool D_PAD::HitTest( const wxPoint& aPosition )
     case PAD_CIRCLE:
         dist = hypot( delta.x, delta.y );
 
-        if( wxRound( dist ) <= dx )
+        if( KiROUND( dist ) <= dx )
             return true;
 
         break;
diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp
index d314148b43..8587d71808 100644
--- a/pcbnew/class_pad_draw_functions.cpp
+++ b/pcbnew/class_pad_draw_functions.cpp
@@ -234,8 +234,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi
     }
 
     // if PAD_SMD pad and high contrast mode
-    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && 
-        ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && 
+    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
+        ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) &&
         DisplayOpt.ContrastModeDisplay )
     {
         // when routing tracks
@@ -303,7 +303,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi
     // if Contrast mode is ON and a technical layer active, show pads on this
     // layer so we can see pads on paste or solder layer and the size of the
     // mask
-    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && 
+    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
         DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER )
     {
         if( IsOnLayer( screen->m_Active_Layer ) )
@@ -376,7 +376,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi
 
     // Display net names is restricted to pads that are on the active layer
     // in hight contrast mode display
-    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && 
+    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
         !IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay )
         drawInfo.m_Display_netname = false;
 
@@ -771,8 +771,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
             // left and right sides are moved by aInflateValue.x in their perpendicular direction
             // We must calculate the corresponding displacement on the horizontal axis
             // that is delta.x +- corr.x depending on the corner
-            corr.x  = wxRound( tan( angle ) * aInflateValue.x );
-            delta.x = wxRound( aInflateValue.x / cos( angle ) );
+            corr.x  = KiROUND( tan( angle ) * aInflateValue.x );
+            delta.x = KiROUND( aInflateValue.x / cos( angle ) );
 
             // Horizontal sides are moved up and down by aInflateValue.y
             delta.y = aInflateValue.y;
@@ -787,8 +787,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
             // lower and upper sides are moved by aInflateValue.x in their perpendicular direction
             // We must calculate the corresponding displacement on the vertical axis
             // that is delta.y +- corr.y depending on the corner
-            corr.y  = wxRound( tan( angle ) * aInflateValue.y );
-            delta.y = wxRound( aInflateValue.y / cos( angle ) );
+            corr.y  = KiROUND( tan( angle ) * aInflateValue.y );
+            delta.y = KiROUND( aInflateValue.y / cos( angle ) );
 
             // Vertical sides are moved left and right by aInflateValue.x
             delta.x = aInflateValue.x;
diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp
index 1fc4ff3a5f..dc79f6181a 100644
--- a/pcbnew/class_track.cpp
+++ b/pcbnew/class_track.cpp
@@ -1173,7 +1173,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
     // Display segment length
     if( Type() != PCB_VIA_T )      // Display Diam and Drill values
     {
-        msg = frame->CoordinateToString( wxRound( GetLength() ) );
+        msg = frame->CoordinateToString( KiROUND( GetLength() ) );
         frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN );
     }
 }
diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp
index 8ee9e83b98..1732eef0e2 100644
--- a/pcbnew/class_zone.cpp
+++ b/pcbnew/class_zone.cpp
@@ -497,7 +497,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
     {
         // Use grid size because it is known
         wxRealPoint grid = GetBoard()->m_PcbFrame->GetCanvas()->GetGrid();
-        min_dist = wxRound( MIN( grid.x, grid.y ) );
+        min_dist = KiROUND( MIN( grid.x, grid.y ) );
     }
 #endif
 
@@ -543,7 +543,7 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
     {
         // Use grid size because it is known
         wxRealPoint grid = GetBoard()->m_PcbFrame->GetCanvas()->GetGrid();
-        min_dist = wxRound( MIN( grid.x, grid.y ) );
+        min_dist = KiROUND( MIN( grid.x, grid.y ) );
     }
 #endif
 
diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp
index a59abef318..5e685aba76 100644
--- a/pcbnew/controle.cpp
+++ b/pcbnew/controle.cpp
@@ -270,25 +270,25 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
     {
     case WXK_NUMPAD8:
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
diff --git a/pcbnew/dialogs/dialog_orient_footprints.cpp b/pcbnew/dialogs/dialog_orient_footprints.cpp
index 2df11a67c4..98a6294fb9 100644
--- a/pcbnew/dialogs/dialog_orient_footprints.cpp
+++ b/pcbnew/dialogs/dialog_orient_footprints.cpp
@@ -161,7 +161,7 @@ void DIALOG_ORIENT_FOOTPRINTS::OnOkClick( wxCommandEvent& event )
         return;
     }
 
-    newOrientation = wxRound(d_orient * 10);
+    newOrientation = KiROUND(d_orient * 10);
     NORMALIZE_ANGLE_180( newOrientation );
     EndModal( wxID_OK );
 }
diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp
index c731d26c42..269fe02e9b 100644
--- a/pcbnew/editrack.cpp
+++ b/pcbnew/editrack.cpp
@@ -309,7 +309,7 @@ bool PCB_EDIT_FRAME::Add45DegreeSegment( wxDC* aDC )
         return false;
     }
 
-    int segm_step_45 = wxRound( GetScreen()->GetGridSize().x / 2 );
+    int segm_step_45 = KiROUND( GetScreen()->GetGridSize().x / 2 );
 
     if( segm_step_45 < ( curTrack->m_Width * 2 ) )
         segm_step_45 = curTrack->m_Width * 2;
@@ -643,8 +643,8 @@ static void PushTrack( EDA_DRAW_PANEL* panel )
     }
 
     f   = dist / hypot( double(n.x), double(n.y) );
-    n.x = wxRound( f * n.x );
-    n.y = wxRound( f * n.y );
+    n.x = KiROUND( f * n.x );
+    n.y = KiROUND( f * n.y );
 
     Project( &track->m_End, cursor, other );
     track->m_End += n;
@@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
     for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
         trackLen += track->GetLength();
 
-    valeur_param( wxRound( trackLen ), msg );
+    valeur_param( KiROUND( trackLen ), msg );
     frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
 
     if( lenDie != 0 )      // display the track len on board and the actual track len
     {
         frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
-        valeur_param( wxRound( trackLen+lenDie ), msg );
+        valeur_param( KiROUND( trackLen+lenDie ), msg );
         frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN );
     }
 
diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp
index 27abfa0a4c..690bb13303 100644
--- a/pcbnew/export_vrml.cpp
+++ b/pcbnew/export_vrml.cpp
@@ -953,17 +953,17 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{
                 {
                     int coord[8] =
                     {
-                        wxRound(-pad_w - pad_dy), wxRound(+pad_h + pad_dx),
-                        wxRound(-pad_w + pad_dy), wxRound(-pad_h - pad_dx),
-                        wxRound(+pad_w - pad_dy), wxRound(+pad_h - pad_dx),
-                        wxRound(+pad_w + pad_dy), wxRound(-pad_h + pad_dx),
+                        KiROUND(-pad_w - pad_dy), KiROUND(+pad_h + pad_dx),
+                        KiROUND(-pad_w + pad_dy), KiROUND(-pad_h - pad_dx),
+                        KiROUND(+pad_w - pad_dy), KiROUND(+pad_h - pad_dx),
+                        KiROUND(+pad_w + pad_dy), KiROUND(-pad_h + pad_dx),
                     };
 
                     for( int i = 0; i < 4; i++ )
                     {
                         RotatePoint( &coord[i * 2], &coord[i * 2 + 1], aPad->GetOrientation() );
-                        coord[i * 2]     += wxRound( pad_x );
-                        coord[i * 2 + 1] += wxRound( pad_y );
+                        coord[i * 2]     += KiROUND( pad_x );
+                        coord[i * 2 + 1] += KiROUND( pad_y );
                     }
 
                     bag_flat_quad( layer, coord[0], coord[1],
@@ -1123,8 +1123,8 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
 
         // adjust 3D shape offset position (offset is given inch)
         #define UNITS_3D_TO_PCB_UNITS PCB_INTERNAL_UNIT
-        int offsetx = wxRound( vrmlm->m_MatPosition.x * UNITS_3D_TO_PCB_UNITS );
-        int offsety = wxRound( vrmlm->m_MatPosition.y * UNITS_3D_TO_PCB_UNITS );
+        int offsetx = KiROUND( vrmlm->m_MatPosition.x * UNITS_3D_TO_PCB_UNITS );
+        int offsety = KiROUND( vrmlm->m_MatPosition.y * UNITS_3D_TO_PCB_UNITS );
         double offsetz = vrmlm->m_MatPosition.z * UNITS_3D_TO_PCB_UNITS;
 
         if ( isFlipped )
diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp
index 0ea551856b..0aed12bb46 100644
--- a/pcbnew/gendrill.cpp
+++ b/pcbnew/gendrill.cpp
@@ -440,7 +440,7 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
             aCoordX *= 10; aCoordY *= 10;
         }
 
-        sprintf( aLine, "X%dY%d\n", wxRound( aCoordX ), wxRound( aCoordY ) );
+        sprintf( aLine, "X%dY%d\n", KiROUND( aCoordX ), KiROUND( aCoordY ) );
         break;
 
     case SUPPRESS_TRAILING:
@@ -456,8 +456,8 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
         if( aCoordY < 0 )
             ypad++;
 
-        xs.Printf( wxT( "%0*d" ), xpad, wxRound( aCoordX ) );
-        ys.Printf( wxT( "%0*d" ), ypad, wxRound( aCoordY ) );
+        xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
+        ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
 
         size_t j = xs.Len() - 1;
         while( xs[j] == '0' && j )
@@ -481,8 +481,8 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
             xpad++;
         if( aCoordY < 0 )
             ypad++;
-        xs.Printf( wxT( "%0*d" ), xpad, wxRound( aCoordX ) );
-        ys.Printf( wxT( "%0*d" ), ypad, wxRound( aCoordY ) );
+        xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
+        ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
         sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
         break;
     }
diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp
index 32e2b7790d..4649825972 100644
--- a/pcbnew/gpcb_exchange.cpp
+++ b/pcbnew/gpcb_exchange.cpp
@@ -247,8 +247,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
         }
     }
     wxPoint pos;
-    pos.x  = wxRound( ibuf[idx] * conv_unit );
-    pos.y  = wxRound( ibuf[idx+1] * conv_unit );
+    pos.x  = KiROUND( ibuf[idx] * conv_unit );
+    pos.y  = KiROUND( ibuf[idx+1] * conv_unit );
     m_Reference->SetPos( pos );
     m_Reference->SetPos0( pos );
     m_Reference->SetOrientation( ibuf[idx+2] ? 900 : 0 );
@@ -301,7 +301,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
                 if( ii < (params.GetCount() - 2) )
                 {
                     if( params[ii + 2].ToLong( &dim ) )
-                        *list[ii] = wxRound( dim * conv_unit );
+                        *list[ii] = KiROUND( dim * conv_unit );
                 }
             }
 
@@ -347,8 +347,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
             int     radius = (ibuf[2] + ibuf[3]) / 4;
 
             wxPoint centre;
-            centre.x = wxRound( ibuf[0] * conv_unit );
-            centre.y = wxRound( ibuf[1] * conv_unit );
+            centre.x = KiROUND( ibuf[0] * conv_unit );
+            centre.y = KiROUND( ibuf[1] * conv_unit );
 
             drawSeg->SetStart0( centre );
 
@@ -357,14 +357,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
 
             drawSeg->SetAngle( ibuf[5] * 10 ); // Angle value is clockwise in gpcb and Pcbnew
 
-            drawSeg->SetEnd0( wxPoint( wxRound( radius * conv_unit ), 0 ) );
+            drawSeg->SetEnd0( wxPoint( KiROUND( radius * conv_unit ), 0 ) );
 
             // Calculate start point coordinate of arc
             wxPoint arcStart( drawSeg->GetEnd0() );
             RotatePoint( &arcStart, -start_angle );
             drawSeg->SetEnd0( centre + arcStart );
 
-            drawSeg->SetWidth( wxRound( ibuf[6] * conv_unit ) );
+            drawSeg->SetWidth( KiROUND( ibuf[6] * conv_unit ) );
             drawSeg->SetDrawCoord();
             continue;
         }
@@ -389,7 +389,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
                     long dim;
 
                     if( params[ii + 2].ToLong( &dim ) )
-                        ibuf[ii] = wxRound( dim * conv_unit );
+                        ibuf[ii] = KiROUND( dim * conv_unit );
                 }
                 else
                 {
@@ -425,12 +425,12 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
 
             // Negate angle (due to Y reversed axis) and convert it to internal units
             angle = - angle * 1800.0 / M_PI;
-            pad->SetOrientation( wxRound( angle ) );
+            pad->SetOrientation( KiROUND( angle ) );
 
             wxPoint padPos( (ibuf[0] + ibuf[2]) / 2, (ibuf[1] + ibuf[3]) / 2 );
 
             pad->SetSize( wxSize(
-                    wxRound( hypot( (double)delta.x, (double)delta.y ) ) + ibuf[4],
+                    KiROUND( hypot( (double)delta.x, (double)delta.y ) ) + ibuf[4],
                     ibuf[4] ) );
 
             padPos += m_Pos;
@@ -471,7 +471,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
                 {
                     long dim;
                     if( params[ii + 2].ToLong( &dim ) )
-                        ibuf[ii] = wxRound( dim * conv_unit );
+                        ibuf[ii] = KiROUND( dim * conv_unit );
                 }
                 else
                 {
diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp
index 9e944698d6..263a9b4127 100644
--- a/pcbnew/legacy_plugin.cpp
+++ b/pcbnew/legacy_plugin.cpp
@@ -2633,7 +2633,7 @@ BIU LEGACY_PLUGIN::biuParse( const char* aValue, const char** nptrptr )
     {
         // this is the special reverse trip mm -> deci-mils testing run,
         // only available in DEBUG mode.
-        return BIU( wxRound( fval * diskToBiu ) );
+        return BIU( KiROUND( fval * diskToBiu ) );
     }
 
 #endif
diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp
index 03b2be5c98..de78eac847 100644
--- a/pcbnew/magnetic_tracks_functions.cpp
+++ b/pcbnew/magnetic_tracks_functions.cpp
@@ -61,8 +61,8 @@ static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
 
     t = min( max( t, 0.0 ), 1.0 );
 
-    res->x = wxRound( a0.x + t * a1.x );
-    res->y = wxRound( a0.y + t * a1.y );
+    res->x = KiROUND( a0.x + t * a1.x );
+    res->y = KiROUND( a0.y + t * a1.y );
 
     return true;
 }
@@ -85,8 +85,8 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track )
     t /= (double) vec.x * vec.x + (double) vec.y * vec.y;
     t = min( max( t, 0.0 ), 1.0 );
 
-    res->x = wxRound( track->m_Start.x + t * vec.x );
-    res->y = wxRound( track->m_Start.y + t * vec.y );
+    res->x = KiROUND( track->m_Start.x + t * vec.x );
+    res->y = KiROUND( track->m_Start.y + t * vec.y );
 
     return true;
 }
diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp
index aa23bb98eb..3c6261dede 100644
--- a/pcbnew/moduleframe.cpp
+++ b/pcbnew/moduleframe.cpp
@@ -435,25 +435,25 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
     {
     case WXK_NUMPAD8:
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp
index 0e6f2780d6..8c47ea7487 100644
--- a/pcbnew/modview_frame.cpp
+++ b/pcbnew/modview_frame.cpp
@@ -580,25 +580,25 @@ void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition
 
     case WXK_NUMPAD8:       /* cursor moved up */
     case WXK_UP:
-        pos.y -= wxRound( gridSize.y );
+        pos.y -= KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD2:       /* cursor moved down */
     case WXK_DOWN:
-        pos.y += wxRound( gridSize.y );
+        pos.y += KiROUND( gridSize.y );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD4:       /*  cursor moved left */
     case WXK_LEFT:
-        pos.x -= wxRound( gridSize.x );
+        pos.x -= KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
 
     case WXK_NUMPAD6:      /*  cursor moved right */
     case WXK_RIGHT:
-        pos.x += wxRound( gridSize.x );
+        pos.x += KiROUND( gridSize.x );
         m_canvas->MoveCursor( pos );
         break;
     }
diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp
index 0cdbf1f5ed..f99f26c12b 100644
--- a/pcbnew/move_or_drag_track.cpp
+++ b/pcbnew/move_or_drag_track.cpp
@@ -473,10 +473,10 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC
     if( update )
     {
         s_LastPos = Pos;
-        Track->m_Start.x = wxRound( xi1 );
-        Track->m_Start.y = wxRound( yi1 );
-        Track->m_End.x   = wxRound( xi2 );
-        Track->m_End.y   = wxRound( yi2 );
+        Track->m_Start.x = KiROUND( xi1 );
+        Track->m_Start.y = KiROUND( yi1 );
+        Track->m_End.x   = KiROUND( xi2 );
+        Track->m_End.y   = KiROUND( yi2 );
 
         if( tSegmentToEnd )
         {
diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp
index 8ae24e52fc..6f85dbe20b 100644
--- a/pcbnew/muonde.cpp
+++ b/pcbnew/muonde.cpp
@@ -103,8 +103,8 @@ static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
 
     wxPoint poly[5];
     wxPoint pt    = Mself.m_End - Mself.m_Start;
-    int     angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI );
-    int     len   = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
+    int     angle = -KiROUND( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI );
+    int     len   = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
 
     // calculate corners
     pt.x = 0; pt.y = len / 4;
@@ -124,8 +124,8 @@ static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
 
     Mself.m_End = aPanel->GetScreen()->GetCrossHairPosition();
     pt    = Mself.m_End - Mself.m_Start;
-    angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI );
-    len   = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
+    angle = -KiROUND( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI );
+    len   = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
 
     // calculate new corners
     pt.x = 0; pt.y = len / 4;
@@ -194,7 +194,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
     Mself.m_End = GetScreen()->GetCrossHairPosition();
 
     wxPoint pt = Mself.m_End - Mself.m_Start;
-    int     min_len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
+    int     min_len = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
     Mself.lng = min_len;
 
     // Enter the desired length.
@@ -330,8 +330,8 @@ static void gen_arc( std::vector & aBuffer,
         wxPoint currpt;
 
         // Rotate current point:
-        currpt.x = wxRound( ( first_point.x * fcos + first_point.y * fsin ) );
-        currpt.y = wxRound( ( first_point.y * fcos - first_point.x * fsin ) );
+        currpt.x = KiROUND( ( first_point.x * fcos + first_point.y * fsin ) );
+        currpt.y = KiROUND( ( first_point.y * fcos - first_point.x * fsin ) );
 
         wxPoint corner = aCenter + currpt;
         aBuffer.push_back( corner );
@@ -394,8 +394,8 @@ int BuildCornersList_S_Shape( std::vector & aBuffer,
     #define ADJUST_SIZE 0.988
 
     wxPoint pt       = aEndPoint - aStartPoint;
-    int     angle    = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI );
-    int     min_len  = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
+    int     angle    = -KiROUND( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI );
+    int     min_len  = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
     int     segm_len = 0;           // length of segments
     int     full_len;               // full len of shape (sum of lenght of all segments + arcs)
 
@@ -437,7 +437,7 @@ int BuildCornersList_S_Shape( std::vector & aBuffer,
         segm_len  = size.x - ( radius * 2 );
         full_len  = 2 * stubs_len;               // Length of coil connections.
         full_len += segm_len * segm_count;       // Length of full length segments.
-        full_len += wxRound( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius );    // Ard arcs len
+        full_len += KiROUND( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius );    // Ard arcs len
         full_len += segm_len - (2 * radius);     // Length of first and last segments
                                                  // (half size segments len = segm_len/2 - radius).
 
@@ -646,7 +646,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
             abort = true;
         }
 
-        angle = ABS( wxRound( fval * fcoeff ) );
+        angle = ABS( KiROUND( fval * fcoeff ) );
 
         if( angle > 1800 )
             angle = 1800;
@@ -955,8 +955,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
     if( PolyShapeType == 2 )  // mirrored
         ShapeScaleY = -ShapeScaleY;
 
-    ShapeSize.x = wxRound( ShapeScaleX );
-    ShapeSize.y = wxRound( ShapeScaleY );
+    ShapeSize.x = KiROUND( ShapeScaleX );
+    ShapeSize.y = KiROUND( ShapeScaleY );
 
     if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
     {
@@ -999,8 +999,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
 
     for( unsigned ii = 0; ii < PolyEdges.size(); ii++ )  // Copy points
     {
-        last_coordinate.x = wxRound( PolyEdges[ii] * ShapeScaleX ) + pad1->GetPos0().x;
-        last_coordinate.y = -wxRound( PolyEdges[ii] * ShapeScaleY );
+        last_coordinate.x = KiROUND( PolyEdges[ii] * ShapeScaleX ) + pad1->GetPos0().x;
+        last_coordinate.y = -KiROUND( PolyEdges[ii] * ShapeScaleY );
         polyPoints.push_back( last_coordinate );
     }
 
diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp
index da1815d98b..f5177aec7e 100644
--- a/pcbnew/plothpgl.cpp
+++ b/pcbnew/plothpgl.cpp
@@ -38,7 +38,7 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
     // Compute pen_dim (from g_m_HPGLPenDiam in mils) in pcb units,
     // with plot scale (if Scale is 2, pen diameter is always g_m_HPGLPenDiam
     // so apparent pen diam is real pen diam / Scale
-    int pen_diam = wxRound( (plot_opts.m_HPGLPenDiam * U_PCB) /
+    int pen_diam = KiROUND( (plot_opts.m_HPGLPenDiam * U_PCB) /
                             plot_opts.m_PlotScale );
 
     // compute pen_overlay (from g_m_HPGLPenOvr in mils) with plot scale
@@ -48,7 +48,7 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
     if( plot_opts.m_HPGLPenOvr >= plot_opts.m_HPGLPenDiam )
         plot_opts.m_HPGLPenOvr = plot_opts.m_HPGLPenDiam - 1;
 
-    int   pen_overlay = wxRound( plot_opts.m_HPGLPenOvr * 10.0 /
+    int   pen_overlay = KiROUND( plot_opts.m_HPGLPenOvr * 10.0 /
                                  plot_opts.m_PlotScale );
 
 
@@ -82,9 +82,9 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
     // Calculate the page size offset.
     if( center )
     {
-        offset.x = wxRound( (double) boardCenter.x -
+        offset.x = KiROUND( (double) boardCenter.x -
                             ( (double) pageSizeIU.x / 2.0 ) / scale );
-        offset.y = wxRound( (double) boardCenter.y -
+        offset.y = KiROUND( (double) boardCenter.y -
                             ( (double) pageSizeIU.y / 2.0 ) / scale );
     }
     else
diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp
index a253c0bad7..eb518d4782 100644
--- a/pcbnew/plotps.cpp
+++ b/pcbnew/plotps.cpp
@@ -92,8 +92,8 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
 
     if( center )
     {
-        offset.x = wxRound( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale );
-        offset.y = wxRound( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale );
+        offset.x = KiROUND( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale );
+        offset.y = KiROUND( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale );
     }
     else
     {
diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp
index dcb02f2b21..92f4555bc9 100644
--- a/pcbnew/specctra_import.cpp
+++ b/pcbnew/specctra_import.cpp
@@ -169,7 +169,7 @@ static int scale( double distance, UNIT_RES* aResolution )
         break;
     }
 
-    int ret = wxRound( factor * distance / resValue );
+    int ret = KiROUND( factor * distance / resValue );
 
 #else
 
@@ -197,7 +197,7 @@ static int scale( double distance, UNIT_RES* aResolution )
     // used within KiCad.
     factor *= 10.0;
 
-    int ret = wxRound( factor * distance / resValue );
+    int ret = KiROUND( factor * distance / resValue );
 
 #endif
 
diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp
index 7efda63ff0..ff4753c749 100644
--- a/polygon/PolyLine.cpp
+++ b/polygon/PolyLine.cpp
@@ -8,13 +8,14 @@
 #include 
 
 #include 
+#include      // KiROUND
 
 #include 
 #include 
 #include 
 
 
-#define to_int( x ) wxRound( (x) )
+#define to_int( x ) KiROUND( (x) )
 
 #ifndef MIN
 #define MIN( x1, x2 ) ( (x1) > (x2) ? (x2) : (x1) )

From e5947326469d06839c2686bfec185e1d6d503f38 Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Thu, 19 Apr 2012 15:07:36 -0500
Subject: [PATCH 15/16] missing include

---
 common/dcsvg.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp
index fe7c148a19..2940db5ae3 100644
--- a/common/dcsvg.cpp
+++ b/common/dcsvg.cpp
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if wxCHECK_VERSION( 2, 9, 0 )
 

From a9d1f4788b02ab0da40e25adf02726e35638eeb5 Mon Sep 17 00:00:00 2001
From: Dick Hollenbeck 
Date: Thu, 19 Apr 2012 15:28:54 -0500
Subject: [PATCH 16/16] todo

---
 TODO.txt | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/TODO.txt b/TODO.txt
index bf0d3a2f05..5c02e6f6a0 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -62,16 +62,11 @@ Dick's Peronal TODO Items  (Last Update: 5-April-2012)
    *)   a BOARD is a fully self contained document description.
    *)   plugin developers do not have to access globals, since a plugin could
         very well be a dynamically loaded DLL/DSO.
-        A problem remain with BASE_SCREEN
+   One final problem remains with BASE_SCREEN's grid origin, easy solution is to
+   move just that one field into the BOARD.
 
-2) Extend PLUGIN API to facillitate loading and saving of modules.
-
-3) Switch to PLUGIN, kill off ioascii.cpp and item_io.cpp, deleting them.
-
-4) Check back with Vladimir about finishing the nanometer work.
-
-5) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
+2) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
    This is PLUGIN::Load() and maybe PLUGIN::Save().
 
-6) Get back to the SWEET work.
+3) Get back to the SWEET work.