From de96452c41cbf9f1802a7531b145c2bbb898f9bb Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 24 Sep 2011 14:33:28 -0400 Subject: [PATCH] Minor common PCB library code fixes. * More common header file compiler fixes. * Translate French code naming and comments. * Remove global variable ScreenPcb. * Dead code removal. --- common/footprint_info.cpp | 2 +- common/pcbcommon.cpp | 3 -- cvpcb/class_DisplayFootprintsFrame.cpp | 6 +-- cvpcb/loadcmp.cpp | 2 +- gerbview/gerbview.cpp | 14 +++--- gerbview/gerbview_frame.cpp | 6 +-- gerbview/initpcb.cpp | 8 ++- include/pcbcommon.h | 17 ++++--- include/pcbstruct.h | 26 +++++----- pcbnew/autoplac.cpp | 1 - pcbnew/autorout.cpp | 1 - pcbnew/class_drawsegment.cpp | 2 +- pcbnew/class_edge_mod.cpp | 2 +- pcbnew/class_footprint_library.cpp | 6 +-- pcbnew/class_netclass.h | 7 ++- pcbnew/class_netinfo.h | 5 ++ pcbnew/class_text_mod.cpp | 2 +- pcbnew/class_track.cpp | 4 +- pcbnew/dialogs/dialog_display_options.cpp | 59 ++++++++++++----------- pcbnew/dist.cpp | 17 +++---- pcbnew/editrack.cpp | 8 +-- pcbnew/ioascii.cpp | 10 +++- pcbnew/librairi.cpp | 2 +- pcbnew/pcbframe.cpp | 14 +++--- pcbnew/pcbnew.cpp | 2 - pcbnew/pcbnew_config.cpp | 7 +-- pcbnew/queue.cpp | 45 +++++++++++------ pcbnew/solve.cpp | 1 - pcbnew/work.cpp | 1 + 29 files changed, 155 insertions(+), 125 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index a1778815b7..abc0d016b6 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -80,7 +80,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) char * line = reader.Line(); StrPurge( line ); - if( strnicmp( line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) + if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 ) { wxString msg; msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library." ), diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index fc9aed92cf..51bf6020a4 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -112,11 +112,8 @@ class BOARD_DESIGN_SETTINGS g_DesignSettings; */ DLIST g_CurrentTrackList; -PCB_SCREEN* ScreenPcb = NULL; BOARD* g_ModuleEditor_Pcb = NULL; -int g_GridRoutingSize = 250; - bool g_Zone_45_Only = FALSE; // Default setting used when creating a new zone diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index a65d2acbf5..d3f28e8fe0 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -74,8 +74,9 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father, // Initialize some display options DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here - DisplayOpt.ShowTrackClearanceMode = 0; /* tracks and vias clearance has - * no meaning here. */ + + // Track and via clearance has no meaning here. + DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); ReCreateHToolbar(); @@ -84,7 +85,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father, m_auimgr.SetManagedWindow( this ); - EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); diff --git a/cvpcb/loadcmp.cpp b/cvpcb/loadcmp.cpp index 3bfbda1abf..7691c044cd 100644 --- a/cvpcb/loadcmp.cpp +++ b/cvpcb/loadcmp.cpp @@ -74,7 +74,7 @@ found in the default search paths." ), Line = reader.Line(); StrPurge( Line ); - if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) + 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 ) ); diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index 05e5819a31..667231e8cb 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -1,6 +1,7 @@ -/************************************************/ -/* GERBVIEW main file */ -/************************************************/ +/** + * @file gerbview.cpp + * @brief GERBVIEW main file. + */ #include "fctsys.h" #include "appl_wxstruct.h" @@ -71,9 +72,6 @@ bool EDA_APP::OnInit() return false; } - ScreenPcb = new PCB_SCREEN(); - ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; - // read current setup and reopen last directory if no filename to open in // command line bool reopenLastUsedDirectory = argc == 1; @@ -92,7 +90,9 @@ bool EDA_APP::OnInit() // Initialize some display options DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here - DisplayOpt.ShowTrackClearanceMode = 0; // tracks and vias clearance has no meaning here + + // Track and via clearance has no meaning here. + DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; SetTopWindow( frame ); // Set GerbView mainframe on top frame->Show( true ); // Show GerbView mainframe diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index fce2957891..df42cc8dd9 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -48,7 +48,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, m_SelLayerBox = NULL; m_DCodeSelector = NULL; m_displayMode = 0; - m_drillFileHistory.SetBaseId(ID_GERBVIEW_DRILL_FILE1); + m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 ); if( DrawPanel ) DrawPanel->m_Block_Enable = true; @@ -58,7 +58,8 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) ); SetIcon( icon ); - SetScreen( ScreenPcb ); + SetScreen( new PCB_SCREEN() ); + GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER; SetBoard( new BOARD( NULL, this ) ); GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first. @@ -133,7 +134,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, GERBVIEW_FRAME::~GERBVIEW_FRAME() { - SetScreen( ScreenPcb ); wxGetApp().SaveCurrentSetupValues( m_configSettings ); } diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index 76b64bc375..6784bce279 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -44,7 +44,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) GetBoard()->m_NbNodes = 0; GetBoard()->m_NbNoconnect = 0; - SetScreen( ScreenPcb ); + SetScreen( new PCB_SCREEN() ); GetScreen()->Init(); setActiveLayer(FIRST_COPPER_LAYER); m_LayersManager->UpdateLayerIcons(); @@ -59,6 +59,7 @@ void GERBVIEW_FRAME::Erase_Current_Layer( bool query ) wxString msg; msg.Printf( _( "Clear layer %d?" ), layer + 1 ); + if( query && !IsOK( this, msg ) ) return; @@ -66,12 +67,15 @@ void GERBVIEW_FRAME::Erase_Current_Layer( bool query ) BOARD_ITEM* item = GetBoard()->m_Drawings; BOARD_ITEM * next; + for( ; item; item = next ) { next = item->Next(); GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; + if( gerb_item->GetLayer() != layer ) continue; + gerb_item->DeleteStructure(); } @@ -81,7 +85,7 @@ void GERBVIEW_FRAME::Erase_Current_Layer( bool query ) g_GERBER_List[layer]->ResetDefaultValues(); } - ScreenPcb->SetModify(); + GetScreen()->SetModify(); DrawPanel->Refresh(); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); diff --git a/include/pcbcommon.h b/include/pcbcommon.h index 500dd872a5..95a990eb44 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -1,3 +1,6 @@ +/** + * @file pcbcommon.h + */ #ifndef __PCBCOMMON_H__ #define __PCBCOMMON_H__ @@ -10,7 +13,7 @@ #include // wxArrayString class. -#define L_MIN_DESSIN 1 /* Min width segments to allow draws with thickness */ +#define MIN_DRAW_WIDTH 1 /* Minimum trace drawing width. */ class PCB_SCREEN; @@ -22,11 +25,11 @@ class DISPLAY_OPTIONS; /* Look up Table for conversion one layer number -> one bit layer mask: */ extern int g_TabOneLayerMask[LAYER_COUNT]; + /* Look up Table for conversion copper layer count -> general copper layer mask: */ extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; - extern wxArrayString g_LibName_List; // library list to load extern DISPLAY_OPTIONS DisplayOpt; @@ -46,17 +49,17 @@ extern int g_RotationAngle; extern int g_TimeOut; // Timer for automatic saving extern int g_SaveTime; // Time for next saving +/// List of segments of the trace currently being drawn. extern DLIST g_CurrentTrackList; -#define g_CurrentTrackSegment \ - g_CurrentTrackList.GetLast() ///< most recently created segment -#define g_FirstTrackSegment \ - g_CurrentTrackList.GetFirst() ///< first segment created +#define g_CurrentTrackSegment g_CurrentTrackList.GetLast() ///< most recently created segment + +#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created -extern PCB_SCREEN* ScreenPcb; extern BOARD* g_ModuleEditor_Pcb; /* Pad editing */ extern D_PAD g_Pad_Master; + #endif /* __PCBCOMMON_H__ */ diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 8a7e8bf7e1..5ffbfd10ee 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -8,12 +8,12 @@ // Definitions relatives aux libraries -#define ENTETE_LIBRAIRIE "PCBNEW-LibModule-V1" -#define L_ENTETE_LIB 18 +#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1" +#define FOOTPRINT_LIBRARY_HEADER_CNT 18 // Values for m_DisplayViaMode member: -enum DisplayViaMode { +enum VIA_DISPLAY_MODE_T { VIA_HOLE_NOT_SHOW = 0, VIA_SPECIAL_HOLE_SHOW, ALL_VIA_HOLE_SHOW, @@ -24,7 +24,7 @@ enum DisplayViaMode { /* Values for DISPLAY_OPTIONS.ShowTrackClearanceMode parameter option * This parameter controls how to show tracks and vias clearance area */ -enum ShowTrackClearanceModeList { +enum TRACE_CLEARANCE_DISPLAY_MODE_T { DO_NOT_SHOW_CLEARANCE = 0, // Do not show clearance areas SHOW_CLEARANCE_NEW_TRACKS, /* Show clearance areas only for new track * during track creation. */ @@ -50,18 +50,13 @@ public: int DisplayModEdge; int DisplayModText; bool DisplayPcbTrackFill; /* FALSE = sketch , TRUE = filled */ - int ShowTrackClearanceMode; /* = 0 , 1 or 2 - * 0 = do not show clearance - * 1 = show track clearance - * 2 = show clearance + via area - * (useful to know what clearance area is - * needed if we want to put a via on - * terminal track point) - */ - int m_DisplayViaMode; /* 0 do not show via hole, - * 1 show via hole for non default value - * 2 show all via hole */ + /// How trace clearances are displayed. @see TRACE_CLEARANCE_DISPLAY_MODE_T. + TRACE_CLEARANCE_DISPLAY_MODE_T ShowTrackClearanceMode; + + VIA_DISPLAY_MODE_T m_DisplayViaMode; /* 0 do not show via hole, + * 1 show via hole for non default value + * 2 show all via hole */ bool DisplayPolarCood; int DisplayZonesMode; @@ -78,4 +73,5 @@ public: DISPLAY_OPTIONS(); }; + #endif // PCBSTRUCT_H diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 3b4dac581b..36adbc8758 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -14,7 +14,6 @@ #include "protos.h" #include "ar_protos.h" -#include "autorout.h" #include "cell.h" #include "colors_selection.h" diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index fbcf7ea4b5..5bbb650529 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -9,7 +9,6 @@ #include "gr_basic.h" #include "pcbnew.h" -#include "autorout.h" #include "cell.h" #include "zones.h" #include "ar_protos.h" diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 6cd5318835..0fa5447285 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -260,7 +260,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx if( m_Flags & FORCE_SKETCH ) mode = SKETCH; - if( l_trace < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) ) + if( l_trace < DC->DeviceToLogicalXRel( MIN_DRAW_WIDTH ) ) mode = FILAIRE; switch( m_Shape ) diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index aeb25d57f6..8e03c1a73e 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -122,7 +122,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx typeaff = SKETCH; } - if( DC->LogicalToDeviceXRel( m_Width ) < L_MIN_DESSIN ) + if( DC->LogicalToDeviceXRel( m_Width ) < MIN_DRAW_WIDTH ) typeaff = FILAIRE; switch( type_trace ) diff --git a/pcbnew/class_footprint_library.cpp b/pcbnew/class_footprint_library.cpp index f0112913ed..ae6e14ed85 100644 --- a/pcbnew/class_footprint_library.cpp +++ b/pcbnew/class_footprint_library.cpp @@ -52,7 +52,7 @@ int FOOTPRINT_LIBRARY::IsLibrary( ) StrPurge( line ); - if( strnicmp( line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) == 0 ) + if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) == 0 ) return 1; return 0; @@ -167,8 +167,8 @@ bool FOOTPRINT_LIBRARY::ReadSectionIndex() bool FOOTPRINT_LIBRARY::WriteHeader() { char line[256]; - fprintf( m_file, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( line ) ); - fprintf( m_file, "# encoding utf-8\n"); + fprintf( m_file, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, DateAndTime( line ) ); + fprintf( m_file, "# encoding utf-8\n" ); return true; } diff --git a/pcbnew/class_netclass.h b/pcbnew/class_netclass.h index 2ad71abf3c..635bf50a48 100644 --- a/pcbnew/class_netclass.h +++ b/pcbnew/class_netclass.h @@ -1,3 +1,6 @@ +/** + * @file class_netclass.h + */ /* * This program source code file is part of KICAD, a free EDA CAD application. @@ -30,9 +33,11 @@ #include #include -#include "richio.h" + +#include +class LINE_READER; class BOARD; diff --git a/pcbnew/class_netinfo.h b/pcbnew/class_netinfo.h index 2c05f89e0f..1041932f2e 100644 --- a/pcbnew/class_netinfo.h +++ b/pcbnew/class_netinfo.h @@ -9,9 +9,14 @@ #ifndef __CLASSES_NETINFO__ #define __CLASSES_NETINFO__ + +#include + #include "class_netclass.h" +class wxDC; +class wxPoint; class LINE_READER; class EDA_DRAW_PANEL; class EDA_DRAW_FRAME; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 3ac1c6c27f..b42b4ac7ad 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -358,7 +358,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w width = m_Thickness; if( ( frame->m_DisplayModText == FILAIRE ) - || ( DC->LogicalToDeviceXRel( width ) < L_MIN_DESSIN ) ) + || ( DC->LogicalToDeviceXRel( width ) < MIN_DRAW_WIDTH ) ) width = 0; else if( frame->m_DisplayModText == SKETCH ) width = -width; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 41396ccb62..24a6787056 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -635,7 +635,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& radius = (int) hypot( (double) ( m_End.x - m_Start.x ), (double) ( m_End.y - m_Start.y ) ); - if( DC->LogicalToDeviceXRel( l_trace ) < L_MIN_DESSIN ) + if( DC->LogicalToDeviceXRel( l_trace ) < MIN_DRAW_WIDTH ) { GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, m_Start.y + aOffset.y, radius, color ); @@ -665,7 +665,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& return; } - if( DC->LogicalToDeviceXRel( l_trace ) < L_MIN_DESSIN ) + if( DC->LogicalToDeviceXRel( l_trace ) < MIN_DRAW_WIDTH ) { GRLine( &panel->m_ClipBox, DC, m_Start + aOffset, m_End + aOffset, 0, color ); return; diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index d2c610a13f..6b225200bc 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -37,29 +37,30 @@ DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) : GetSizer()->SetSizeHints( this ); } -/****************************************************************/ void DIALOG_DISPLAY_OPTIONS::init() -/****************************************************************/ { SetFocus(); if ( DisplayOpt.DisplayPcbTrackFill ) - m_OptDisplayTracks->SetSelection(1); + m_OptDisplayTracks->SetSelection( 1 ); else - m_OptDisplayTracks->SetSelection(0); + m_OptDisplayTracks->SetSelection( 0 ); switch ( DisplayOpt.ShowTrackClearanceMode ) { case DO_NOT_SHOW_CLEARANCE: - m_OptDisplayTracksClearance->SetSelection(0); + m_OptDisplayTracksClearance->SetSelection( 0 ); break; + case SHOW_CLEARANCE_NEW_TRACKS: - m_OptDisplayTracksClearance->SetSelection(1); + m_OptDisplayTracksClearance->SetSelection( 1 ); break; + default: case SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS: m_OptDisplayTracksClearance->SetSelection(2); break; + case SHOW_CLEARANCE_ALWAYS: m_OptDisplayTracksClearance->SetSelection(3); break; @@ -71,65 +72,67 @@ void DIALOG_DISPLAY_OPTIONS::init() m_OptDisplayPads->SetSelection(0); if ( DisplayOpt.DisplayViaFill ) - m_OptDisplayVias->SetSelection(1); + m_OptDisplayVias->SetSelection( 1 ); else - m_OptDisplayVias->SetSelection(0); + m_OptDisplayVias->SetSelection( 0 ); - m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1); + m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1 ); m_OptDisplayViaHole->SetSelection( DisplayOpt.m_DisplayViaMode ); m_OptDisplayModTexts->SetSelection( DisplayOpt.DisplayModText ); m_OptDisplayModEdges->SetSelection( DisplayOpt.DisplayModEdge ); m_OptDisplayPadClearence->SetValue( DisplayOpt.DisplayPadIsol ); m_OptDisplayPadNumber->SetValue( DisplayOpt.DisplayPadNum ); - m_OptDisplayPadNoConn->SetValue( m_Parent->IsElementVisible( PCB_VISIBLE(NO_CONNECTS_VISIBLE) ) ); + m_OptDisplayPadNoConn->SetValue( m_Parent->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) ) ); m_OptDisplayDrawings->SetSelection( DisplayOpt.DisplayDrawItems ); - m_ShowNetNamesOption->SetSelection( DisplayOpt.DisplayNetNamesMode); + m_ShowNetNamesOption->SetSelection( DisplayOpt.DisplayNetNamesMode ); } -/*****************************************************************/ + void DIALOG_DISPLAY_OPTIONS::OnCancelClick( wxCommandEvent& event ) -/*****************************************************************/ { - EndModal(0); + EndModal( 0 ); } -/*************************************************************************/ -void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) -/*************************************************************************/ + /* Update variables with new options */ +void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) { - if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = true; - else g_ShowPageLimits = FALSE; + if ( m_Show_Page_Limits->GetSelection() == 0 ) + g_ShowPageLimits = true; + else + g_ShowPageLimits = FALSE; - if ( m_OptDisplayTracks->GetSelection() == 1) + if ( m_OptDisplayTracks->GetSelection() == 1 ) DisplayOpt.DisplayPcbTrackFill = true; - else DisplayOpt.DisplayPcbTrackFill = FALSE; + else + DisplayOpt.DisplayPcbTrackFill = FALSE; m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - DisplayOpt.m_DisplayViaMode = m_OptDisplayViaHole->GetSelection(); + DisplayOpt.m_DisplayViaMode = (VIA_DISPLAY_MODE_T) m_OptDisplayViaHole->GetSelection(); switch ( m_OptDisplayTracksClearance->GetSelection() ) { case 0: DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; break; + case 1: DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS; break; + case 2: DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; break; + case 3: DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS; break; } - m_Parent->m_DisplayModText = DisplayOpt.DisplayModText = - m_OptDisplayModTexts->GetSelection(); - m_Parent->m_DisplayModEdge = DisplayOpt.DisplayModEdge = - m_OptDisplayModEdges->GetSelection(); + m_Parent->m_DisplayModText = DisplayOpt.DisplayModText = m_OptDisplayModTexts->GetSelection(); + m_Parent->m_DisplayModEdge = DisplayOpt.DisplayModEdge = m_OptDisplayModEdges->GetSelection(); if (m_OptDisplayPads->GetSelection() == 1 ) DisplayOpt.DisplayPadFill = true; @@ -149,12 +152,12 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) m_Parent->m_DisplayPadNum = DisplayOpt.DisplayPadNum = m_OptDisplayPadNumber->GetValue(); m_Parent->SetElementVisibility( PCB_VISIBLE(NO_CONNECTS_VISIBLE), - m_OptDisplayPadNoConn->GetValue()); + m_OptDisplayPadNoConn->GetValue() ); DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection(); DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); m_Parent->DrawPanel->Refresh(); - EndModal(1); + EndModal( 1 ); } diff --git a/pcbnew/dist.cpp b/pcbnew/dist.cpp index 9ecf8fb545..28cceeb924 100644 --- a/pcbnew/dist.cpp +++ b/pcbnew/dist.cpp @@ -1,6 +1,7 @@ -/***************************************************************/ -/* EDITEUR de PCB: AUTOROUTAGE: routine de calcul de distances */ -/***************************************************************/ +/** + * @file dist.cpp + * @brief Routines to calculate PCB editor auto routing distances. + */ #include "fctsys.h" #include "macros.h" @@ -10,10 +11,10 @@ #include "cell.h" -/* Les tables de distances et penalites sont etablies sur la base du pas -de routage de 50 unites(le pas entre les cellules est 50 unites) -La distance vraie est calculee par un facteur d'echelle -*/ +/* The tables of distances and keep out areas are established on the basis of not + * routing of 50 units (the pitch between the cells is 50 units) The true distance + * is computed by a scaling factor + */ /* calculate approximate distance */ @@ -160,5 +161,3 @@ int CalcDist(int x,int y,int z ,int side ) return ldist * 10; } - - diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index e9ec960b34..cc1bed3ee2 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -1,6 +1,6 @@ -/****************/ -/* Edit traces. */ -/****************/ +/** + * @file editrack.cpp + */ #include "fctsys.h" #include "class_drawpanel.h" @@ -639,7 +639,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo bool Track_fill_copy = DisplayOpt.DisplayPcbTrackFill; DisplayOpt.DisplayPcbTrackFill = true; - int showTrackClearanceMode = DisplayOpt.ShowTrackClearanceMode; + TRACE_CLEARANCE_DISPLAY_MODE_T showTrackClearanceMode = DisplayOpt.ShowTrackClearanceMode; if ( g_FirstTrackSegment == NULL ) return; diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index c1fb958d38..731d4eafd6 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -387,7 +387,9 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) m_Auxiliary_Axis_Position.y = gy; continue; } + #ifdef PCBNEW + if( stricmp( Line, "Layers" ) == 0 ) { int tmp; @@ -621,6 +623,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) continue; } #endif + } /* Ensure tracks and vias sizes lists are ok: @@ -653,7 +656,8 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) #ifdef PCBNEW -static int WriteSetup( FILE* aFile, PCB_BASE_FRAME* aFrame, BOARD* aBoard ) + +static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) { NETCLASS* netclass_default = aBoard->m_NetClasses.GetDefault(); char text[1024]; @@ -1017,10 +1021,12 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) if( TESTLINE( "TRACK" ) ) { + #ifdef PCBNEW TRACK* insertBeforeMe = Append ? NULL : board->m_Track.GetFirst(); ReadListeSegmentDescr( aReader, insertBeforeMe, TYPE_TRACK, NbTrack ); #endif + continue; } @@ -1074,11 +1080,13 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) if( TESTLINE( "ZONE" ) ) { + #ifdef PCBNEW SEGZONE* insertBeforeMe = Append ? NULL : board->m_Zone.GetFirst(); ReadListeSegmentDescr( aReader, insertBeforeMe, TYPE_ZONE, NbZone ); #endif + continue; } diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 1fd7464c1a..d9a7e44a63 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -88,7 +88,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() reader.ReadLine(); Line = reader.Line(); - if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) + if( strnicmp( Line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 ) { if( strnicmp( Line, "Element", 7 ) == 0 ) { diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 4656c07ba2..ee919aae3d 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -310,7 +310,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, SetIcon( icon ); m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch - SetScreen( ScreenPcb ); + SetScreen( new PCB_SCREEN() ); // LoadSettings() *after* creating m_LayersManager, because LoadSettings() // initialize parameters in m_LayersManager @@ -402,6 +402,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, PCB_EDIT_FRAME::~PCB_EDIT_FRAME() { m_RecordingMacros = -1; + for( int i = 0; i < 10; i++ ) m_Macros[i].m_Record.clear(); @@ -438,7 +439,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) { DrawPanel->m_AbortRequest = true; - if( ScreenPcb->IsModify() ) + if( GetScreen()->IsModify() ) { unsigned ii; wxMessageDialog dialog( this, _( "Board modified, Save before exit ?" ), @@ -480,6 +481,7 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event ) // This should work on any platform. if( m_Draw3DFrame->IsIconized() ) m_Draw3DFrame->Iconize( false ); + m_Draw3DFrame->Raise(); // Raising the window does not set the focus on Linux. This should work on any platform. @@ -516,9 +518,7 @@ void PCB_EDIT_FRAME::LoadSettings() if( config == NULL ) return; - /* The configuration setting that used to be mixed in with the project - * file settings. - */ + // The configuration setting that used to be mixed in with the project file settings. wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() ); PCB_BASE_FRAME::LoadSettings(); @@ -546,9 +546,7 @@ void PCB_EDIT_FRAME::SaveSettings() if( config == NULL ) return; - /* The configuration setting that used to be mixed in with the project - * file settings. - */ + // The configuration setting that used to be mixed in with the project file settings. wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() ); PCB_BASE_FRAME::SaveSettings(); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 91d456aed4..a3fda27a65 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -90,8 +90,6 @@ bool EDA_APP::OnInit() return false; } - ScreenPcb = new PCB_SCREEN(); - // read current setup and reopen last directory if no filename to open in command line bool reopenLastUsedDirectory = argc == 1; GetSettings( reopenLastUsedDirectory ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index edace62726..f1104ea9e6 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -273,13 +273,14 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() return m_configSettings; // Units used in dialogs and toolbars - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ), (int*)&g_UserUnit, MILLIMETRES ) ); + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ), + (int*)&g_UserUnit, MILLIMETRES ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayPolarCoords" ), &DisplayOpt.DisplayPolarCood, false ) ); // Display options and modes: m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ViaHoleDisplayMode" ), - &DisplayOpt.m_DisplayViaMode, + (int*) &DisplayOpt.m_DisplayViaMode, VIA_SPECIAL_HOLE_SHOW, VIA_HOLE_NOT_SHOW, OPT_VIA_HOLE_END - 1 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ), @@ -287,7 +288,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayTrackFilled" ), &DisplayOpt.DisplayPcbTrackFill, true ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ), - &DisplayOpt.ShowTrackClearanceMode, + (int*) &DisplayOpt.ShowTrackClearanceMode, SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PadFill" ), &DisplayOpt.DisplayPadFill, true ) ); diff --git a/pcbnew/queue.cpp b/pcbnew/queue.cpp index 47e8a9df79..d994f66483 100644 --- a/pcbnew/queue.cpp +++ b/pcbnew/queue.cpp @@ -1,23 +1,23 @@ -/*************/ -/* queue.cpp */ -/*************/ +/** + * @file queue.cpp + */ #include "fctsys.h" - #include "common.h" + #include "pcbnew.h" #include "autorout.h" - #include "cell.h" + struct PcbQueue /* search queue structure */ { struct PcbQueue* Next; - int Row; /* current row */ - int Col; /* current column */ - int Side; /* 0=top, 1=bottom */ - int Dist; /* path distance to this cell so far */ - int ApxDist; /* approximate distance to target from here */ + int Row; /* current row */ + int Col; /* current column */ + int Side; /* 0=top, 1=bottom */ + int Dist; /* path distance to this cell so far */ + int ApxDist; /* approximate distance to target from here */ }; static long qlen = 0; /* current queue length */ @@ -38,6 +38,7 @@ void FreeQueue() struct PcbQueue* p; InitQueue(); + while( (p = Save) != NULL ) { Save = p->Next; MyFree( p ); @@ -71,6 +72,7 @@ void GetQueue( int* r, int* c, int* s, int* d, int* a ) *r = p->Row; *c = p->Col; *s = p->Side; *d = p->Dist; *a = p->ApxDist; + if( (Head = p->Next) == NULL ) Tail = NULL; @@ -86,9 +88,9 @@ void GetQueue( int* r, int* c, int* s, int* d, int* a ) /* add a search node to the list - * Return: - * 1 - OK - * 0 - Failed to allocate memory. + * Return: + * 1 - OK + * 0 - Failed to allocate memory. */ int SetQueue( int r, int c, int side, int d, int a, int r2, int c2 ) { @@ -102,13 +104,16 @@ int SetQueue( int r, int c, int side, int d, int a, int r2, int c2 ) Save = p->Next; } else if( ( p = (struct PcbQueue*) MyMalloc( sizeof(PcbQueue) ) ) == NULL ) + { return 0; + } p->Row = r; p->Col = c; p->Side = side; i = (p->Dist = d) + (p->ApxDist = a); p->Next = NULL; + if( (q = Head) != NULL ) /* insert in proper position in list */ { if( q->Dist + q->ApxDist > i ) /* insert at head */ @@ -117,8 +122,7 @@ int SetQueue( int r, int c, int side, int d, int a, int r2, int c2 ) } else /* search for proper position */ { - for( t = q, q = q->Next; q && i > ( j = q->Dist + q->ApxDist ); - t = q, q = q->Next ) + for( t = q, q = q->Next; q && i > ( j = q->Dist + q->ApxDist ); t = q, q = q->Next ) ; if( q && i == j && q->Row == r2 && q->Col == c2 ) @@ -126,21 +130,28 @@ int SetQueue( int r, int c, int side, int d, int a, int r2, int c2 ) /* insert after q, which is a goal node */ if( ( p->Next = q->Next ) == NULL ) Tail = p; + q->Next = p; } else /* insert in front of q */ { if( ( p->Next = q ) == NULL ) Tail = p; + t->Next = p; } } } else /* empty search list */ + { Head = Tail = p; + } + OpenNodes++; + if( ++qlen > MaxNodes ) MaxNodes = qlen; + return 1; } @@ -162,7 +173,10 @@ void ReSetQueue( int r, int c, int s, int d, int a, int r2, int c2 ) Tail = q; } else if( ( Head = p->Next ) == NULL ) + { Tail = NULL; + } + p->Next = Save; Save = p; OpenNodes--; @@ -174,6 +188,7 @@ void ReSetQueue( int r, int c, int s, int d, int a, int r2, int c2 ) if( !p ) /* not found, it has already been closed once */ ClosNodes--; /* we will close it again, but just count once */ + /* if it was there, it's gone now; insert it at the proper position */ SetQueue( r, c, s, d, a, r2, c2 ); } diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index 62500f30ee..596e13610e 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -16,7 +16,6 @@ #include "pcbnew.h" #include "protos.h" #include "ar_protos.h" -#include "autorout.h" #include "cell.h" diff --git a/pcbnew/work.cpp b/pcbnew/work.cpp index 9d24b87c91..77f2d7f76f 100644 --- a/pcbnew/work.cpp +++ b/pcbnew/work.cpp @@ -90,6 +90,7 @@ int SetWork( int r1, p->Cost = GetCost( r1, c1, r2, c2 ); p->Priority = pri; p->Next = NULL; + if( Head ) /* attach at end */ Tail->Next = p;