Commit de96452c authored by Wayne Stambaugh's avatar Wayne Stambaugh

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