Commit ff11ed0f authored by jean-pierre charras's avatar jean-pierre charras

Bug fixes, code cleaning and Cvpcb enhancements (see changelog)

parent 916f2319
......@@ -4,6 +4,18 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-apr-16, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++Cvpcb:
Fixed a bug in footprint display frame (coordinates not displayed). Windows only.
Added right toolbar to select display options
Can now read netlists using UTF8 encoding.
Convert dialog_display_option from DialogBlocks to wxFormBuilder
++Pcbnew:
Fixed a very minor bug.
Cvpcb+Pcbnew:
Code cleanup in read netlist functions: use now FILE_LINE_READER.
2010-Apr-12 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++all:
......
......@@ -6,7 +6,7 @@
#endif
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2010-04-08 SVN 25xx)"
#define KICAD_BUILD_VERSION "(2010-04-13 BZR 23xx)"
#endif
#define VERSION_STABILITY "unstable"
......
......@@ -28,6 +28,7 @@ set(CVPCB_SRCS
dialog_cvpcb_config.cpp
dialog_cvpcb_config_fbp.cpp
dialog_display_options.cpp
dialog_display_options_base.cpp
dummy_functions.cpp
genequiv.cpp
init.cpp
......
This diff is collapsed.
......@@ -21,8 +21,11 @@ public:
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void ReCreateHToolbar();
void ReCreateVToolbar();
void ReCreateOptToolbar();
void RecreateMenuBar();
void OnSelectOptionToolbar( wxCommandEvent& event );
/** Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
......
This diff is collapsed.
/////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////
// Name: dialog_display_options.h
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 17/02/2006 17:47:55
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 17/02/2006 17:47:55
// Licence: GPL
////////////////////////////////////////////
#ifndef _DIALOG_DISPLAY_OPTIONS_H_
#define _DIALOG_DISPLAY_OPTIONS_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "dialog_display_options.h"
#endif
/*!
* Includes
*/
////@begin includes
#include "wx/valgen.h"
#include "wx/statline.h"
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
class wxBoxSizer;
////@end forward declarations
/*!
* Control identifiers
*/
#include "dialog_display_options_base.h"
////@begin control identifiers
#define ID_DIALOG 10000
#define EDGE_SELECT 10001
#define TEXT_SELECT 10002
#define PADFILL_OPT 10003
#define PADNUM_OPT 10004
#define VIAFILL_OPT 10005
#define ID_STATICLINE1 10006
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_TITLE _("Display Options")
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_POSITION wxDefaultPosition
////@end control identifiers
////////////////////////////////////////////
/// Class DIALOG_FOOTPRINTS_DISPLAY_OPTIONS
// derived from DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE,
// created by wxformBuilder
////////////////////////////////////////////
/*!
* Compatibility
*/
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
/*!
* WinEDA_FootprintDisplayOptionsFrame class declaration
*/
class WinEDA_FootprintDisplayOptionsFrame: public wxDialog
{
DECLARE_DYNAMIC_CLASS( WinEDA_FootprintDisplayOptionsFrame )
DECLARE_EVENT_TABLE()
class DIALOG_FOOTPRINTS_DISPLAY_OPTIONS :
public DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE
{
private:
WinEDA_BasePcbFrame * m_Parent;
public:
/// Constructors
WinEDA_FootprintDisplayOptionsFrame( );
WinEDA_FootprintDisplayOptionsFrame( WinEDA_BasePcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_SIZE, long style = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_SIZE, long style = SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_STYLE );
/// Creates the controls and sizers
void CreateControls();
////@begin WinEDA_FootprintDisplayOptionsFrame event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
void OnApplyClick( wxCommandEvent& event );
////@end WinEDA_FootprintDisplayOptionsFrame event handler declarations
////@begin WinEDA_FootprintDisplayOptionsFrame member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end WinEDA_FootprintDisplayOptionsFrame member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
void UpdateObjectSettings(void);
////@begin WinEDA_FootprintDisplayOptionsFrame member variables
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxRadioBox* m_EdgesDisplayOption;
wxRadioBox* m_TextDisplayOption;
wxBoxSizer* ColumnBoxSizer;
wxCheckBox* m_IsShowPadFill;
wxCheckBox* m_IsShowViaFill;
wxCheckBox* m_IsShowPadNum;
wxButton* m_CancelButton;
////@end WinEDA_FootprintDisplayOptionsFrame member variables
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( WinEDA_BasePcbFrame* parent );
~DIALOG_FOOTPRINTS_DISPLAY_OPTIONS();
WinEDA_BasePcbFrame * m_Parent;
private:
void initDialog( );
void UpdateObjectSettings( void );
virtual void OnApplyClick( wxCommandEvent& event );
virtual void OnCancelClick( wxCommandEvent& event );
virtual void OnOkClick( wxCommandEvent& event );
};
#endif
// _DIALOG_DISPLAY_OPTIONS_H_
#endif // _DIALOG_DISPLAY_OPTIONS_H_
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_display_options_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_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* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
wxString m_EdgesDisplayOptionChoices[] = { _("Line"), _("Filled"), _("Sketch") };
int m_EdgesDisplayOptionNChoices = sizeof( m_EdgesDisplayOptionChoices ) / sizeof( wxString );
m_EdgesDisplayOption = new wxRadioBox( this, ID_EDGE_SELECT, _("Edges:"), wxDefaultPosition, wxDefaultSize, m_EdgesDisplayOptionNChoices, m_EdgesDisplayOptionChoices, 1, wxRA_SPECIFY_COLS );
m_EdgesDisplayOption->SetSelection( 0 );
bUpperSizer->Add( m_EdgesDisplayOption, 1, wxALL|wxEXPAND, 5 );
wxString m_TextDisplayOptionChoices[] = { _("Line"), _("Filled"), _("Sketch") };
int m_TextDisplayOptionNChoices = sizeof( m_TextDisplayOptionChoices ) / sizeof( wxString );
m_TextDisplayOption = new wxRadioBox( this, ID_TEXT_SELECT, _("Texts:"), wxDefaultPosition, wxDefaultSize, m_TextDisplayOptionNChoices, m_TextDisplayOptionChoices, 1, wxRA_SPECIFY_COLS );
m_TextDisplayOption->SetSelection( 0 );
bUpperSizer->Add( m_TextDisplayOption, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pads:") ), wxVERTICAL );
m_IsShowPadFill = new wxCheckBox( this, ID_PADFILL_OPT, _("Fill &pad"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer1->Add( m_IsShowPadFill, 0, wxALL|wxEXPAND, 5 );
m_IsShowPadNum = new wxCheckBox( this, wxID_ANY, _("Show pad &number"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer1->Add( m_IsShowPadNum, 0, wxALL|wxEXPAND, 5 );
bUpperSizer->Add( sbSizer1, 1, wxEXPAND|wxALL, 5 );
bSizerMain->Add( bUpperSizer, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY );
m_sdbSizer1->AddButton( m_sdbSizer1Apply );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
this->Layout();
// Connect Events
m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnApplyClick ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnOkClick ), NULL, this );
}
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::~DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE()
{
// Disconnect Events
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnApplyClick ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnOkClick ), NULL, this );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_display_options_base__
#define __dialog_display_options_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_EDGE_SELECT 1000
#define ID_TEXT_SELECT 1001
#define ID_PADFILL_OPT 1002
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE : public wxDialog
{
private:
protected:
wxRadioBox* m_EdgesDisplayOption;
wxRadioBox* m_TextDisplayOption;
wxCheckBox* m_IsShowPadFill;
wxCheckBox* m_IsShowPadNum;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Apply;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnApplyClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
public:
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Display Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 331,164 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE();
};
#endif //__dialog_display_options_base__
......@@ -144,6 +144,18 @@ public:
* @throw IOError only when a line is too long.
*/
int ReadLine() throw (IOError);
/**
* Function Rewind
* a wrapper to the standard function rewind.
* also clear the current line number
*/
void Rewind()
{
rewind( fp );
lineNum = 0;
}
};
......
......@@ -845,6 +845,50 @@ public:
// netlist handling:
void InstallNetlistFrame( wxDC* DC, const wxPoint& pos );
/** Function ReadPcbNetlist
* Update footprints (load missing footprints and delete on request extra
* footprints)
* Update connectivity info ( Net Name list )
* Update Reference, value and "TIME STAMP"
* @param aNetlistFullFilename = netlist file name (*.net)
* @param aCmpFullFileName = cmp/footprint list file name (*.cmp) if not found,
* only the netlist will be used
* @return true if Ok
*
* the format of the netlist is something like:
# EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22
* (
* ( 40C08647 $noname R20 4,7K {Lib=R}
* ( 1 VCC )
* ( 2 MODB_1 )
* )
* ( 40C0863F $noname R18 4,7_k {Lib=R}
* ( 1 VCC )
* ( 2 MODA_1 )
* )
* }
* #End
*/
bool ReadPcbNetlist(
const wxString& aNetlistFullFilename,
const wxString& aCmpFullFileName,
wxTextCtrl* aMessageWindow,
bool aChangeFootprint,
bool aDeleteBadTracks,
bool aDeleteExtraFootprints,
bool aSelect_By_Timestamp );
/** Function RemoveMisConnectedTracks
* finds all track segments which are mis-connected (to more than one net).
* When such a bad segment is found, mark it as needing to be removed.
* and remove all tracks having at least one flagged segment.
* @param aDC = the current device context (can be NULL)
* @param aDisplayActivity = true to display activity on the frame status bar and message panel
* @return true if any change is made
*/
bool RemoveMisConnectedTracks( wxDC* aDC, bool aDisplayActivity );
// Autoplacement:
void AutoPlace( wxCommandEvent& event );
......@@ -926,7 +970,7 @@ public:
* called on a language menu selection
*/
virtual void SetLanguage( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
......
......@@ -731,54 +731,57 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
}
/***************************************************************************/
int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
/***************************************************************************/
/**
* Function Netliste_Controle_piste
/** Function RemoveMisConnectedTracks
* finds all track segments which are mis-connected (to more than one net).
* When such a bad segment is found, mark it as needing to be removed (supression).
* When such a bad segment is found, mark it as needing to be removed.
* and remove all tracks having at least one flagged segment.
* @param aDC = the current device context (can be NULL)
* @param aDisplayActivity = true to display activity on the frame status bar and message panel
* @return true if any change is made
*/
bool WinEDA_PcbFrame::RemoveMisConnectedTracks( wxDC* aDC, bool aDisplayActivity )
{
TRACK* segment;
TRACK* other;
TRACK* next;
int net_code_s, net_code_e;
int nbpoints_modifies = 0;
int flag = 0;
bool flag = false;
wxString msg;
int percent = 0;
int oldpercent = -1;
a_color = RED;
frame->Affiche_Message( _( "DRC Control:" ) );
if( aDisplayActivity )
Affiche_Message( _( "DRC Control:" ) );
frame->DrawPanel->m_AbortRequest = FALSE;
DrawPanel->m_AbortRequest = FALSE;
if( affiche )
Affiche_1_Parametre( frame, POS_AFF_VAR, _( "NetCtr" ), wxT( "0 " ), a_color );
if( aDisplayActivity )
Affiche_1_Parametre( this, POS_AFF_VAR, _( "NetCtr" ), wxT( "0 " ), a_color );
int ii = 0;
for( segment = frame->GetBoard()->m_Track; segment; segment = (TRACK*) segment->Next() )
for( segment = GetBoard()->m_Track; segment; segment = (TRACK*) segment->Next() )
{
// display activity
ii++;
percent = (100 * ii) / frame->GetBoard()->m_Track.GetCount();
if( percent != oldpercent )
if( aDisplayActivity ) // display activity
{
frame->DisplayActivity( percent, wxT( "Drc: " ) );
oldpercent = percent;
percent = (100 * ii) / GetBoard()->m_Track.GetCount();
if( percent != oldpercent )
{
DisplayActivity( percent, wxT( "Drc: " ) );
oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->GetBoard()->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), GetBoard()->m_Track.GetCount() );
Affiche_1_Parametre( this, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), frame->GetBoard()->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
msg.Printf( wxT( "%d" ), GetBoard()->m_Track.GetCount() );
Affiche_1_Parametre( this, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
if( frame->DrawPanel->m_AbortRequest )
return flag;
if( DrawPanel->m_AbortRequest )
return flag;
}
}
segment->SetState( FLAG0, OFF );
......@@ -792,7 +795,7 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
}
else
{
other = Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track,
other = Locate_Piste_Connectee( segment, GetBoard()->m_Track,
NULL, START );
if( other )
net_code_s = other->GetNet();
......@@ -809,7 +812,7 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
}
else
{
other = Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track,
other = Locate_Piste_Connectee( segment, GetBoard()->m_Track,
NULL, END );
if( other )
net_code_e = other->GetNet();
......@@ -826,7 +829,7 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
}
// Removal of flagged segments
for( segment = frame->GetBoard()->m_Track; segment; segment = next )
for( segment = GetBoard()->m_Track; segment; segment = next )
{
next = (TRACK*) segment->Next();
......@@ -834,18 +837,18 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
{
segment->SetState( FLAG0, OFF );
flag = 1;
flag = true;
oldpercent = -1;
frame->GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_Status_Pcb = 0;
frame->Remove_One_Track( DC, segment );
Remove_One_Track( aDC, segment );
next = frame->GetBoard()->m_Track; /* NextS a peut etre ete efface */
if( affiche )
next = GetBoard()->m_Track; /* the current segment can be deleted, so restart to the beginning */
if( aDisplayActivity )
{
nbpoints_modifies++;
msg.Printf( wxT( "%d " ), nbpoints_modifies );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
Affiche_1_Parametre( this, POS_AFF_VAR, wxEmptyString, msg, a_color );
}
}
}
......
......@@ -12,15 +12,6 @@
#include "dialog_netlist.h"
extern void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
const wxString& aNetlistFullFilename,
const wxString& aCmpFullFileName,
wxTextCtrl* aMessageWindow,
bool aChangeFootprint,
bool aDeleteBadTracks,
bool aDeleteExtraFootprints,
bool aSelect_By_Timestamp );
extern void TestFor_Duplicate_Missing_And_Extra_Footprints( wxWindow* frame,
const wxString& NetlistFullFilename,
BOARD* Pcb );
......@@ -83,7 +74,7 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )
wxFileName fn = m_NetlistFilenameCtrl->GetValue();
fn.SetExt( NetCmpExtBuffer );
ReadPcbNetlist( m_Parent, m_NetlistFilenameCtrl->GetValue(),
m_Parent->ReadPcbNetlist( m_NetlistFilenameCtrl->GetValue(),
fn.GetFullPath(), m_MessageWindow,
m_ChangeExistingFootprintCtrl->GetSelection() == 1 ? TRUE : FALSE,
m_DeleteBadTracks->GetSelection() == 1 ? TRUE : FALSE,
......
......@@ -35,6 +35,7 @@
#include "gestfich.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "richio.h"
#include "dialog_netlist.h"
......@@ -75,7 +76,7 @@ static void SortListModulesToLoadByLibname( int NbModules );
static int BuildFootprintsListFromNetlistFile(
const wxString& aNetlistFullFilename,
wxArrayString& aBufName );
static bool OpenNetlistFile( const wxString& aFullFileName );
static FILE * OpenNetlistFile( const wxString& aFullFileName );
static void AddToList( const wxString& NameLibCmp,
const wxString& NameCmp,
const wxString& TimeStampPath );
......@@ -100,28 +101,27 @@ static void LoadListeModules( WinEDA_PcbFrame* aPcbFrame );
static int s_NbNewModules;
static MODULEtoLOAD* s_ModuleToLoad_List;
FILE* source;
#define BUFFER_CHAR_SIZE 2048
/** function OpenNetlistFile
* used to open a netlist file
*/
bool OpenNetlistFile( const wxString& aFullFileName )
FILE * OpenNetlistFile( const wxString& aFullFileName )
{
if( aFullFileName.IsEmpty() )
return FALSE; /* No filename: exit */
source = wxFopen( aFullFileName, wxT( "rt" ) );
if( source == 0 )
FILE * netfile = wxFopen( aFullFileName, wxT( "rt" ) );
if( netfile == NULL )
{
wxString msg;
msg.Printf( _( "Netlist file %s not found" ),
GetChars( aFullFileName ) );
DisplayError( NULL, msg );
return FALSE;
}
return true;
return netfile;
}
......@@ -132,6 +132,7 @@ bool OpenNetlistFile( const wxString& aFullFileName )
* Update Reference, value and "TIME STAMP"
* @param aNetlistFullFilename = netlist file name (*.net)
* @param aCmpFullFileName = cmp/footprint list file name (*.cmp) if not found,
* @return true if Ok
* only the netlist will be used
*
* the format of the netlist is something like:
......@@ -148,7 +149,7 @@ bool OpenNetlistFile( const wxString& aFullFileName )
* }
* #End
*/
void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
bool WinEDA_PcbFrame::ReadPcbNetlist(
const wxString& aNetlistFullFilename,
const wxString& aCmpFullFileName,
wxTextCtrl* aMessageWindow,
......@@ -157,15 +158,15 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
bool aDeleteExtraFootprints,
bool aSelect_By_Timestamp )
{
int LineNum, State, Comment;
int State, Comment;
MODULE* Module = NULL;
D_PAD* PtPad;
char Line[256];
char* Text;
int UseFichCmp = 1;
if( !OpenNetlistFile( aNetlistFullFilename ) )
return;
FILE * netfile = OpenNetlistFile( aNetlistFullFilename );
if( !netfile )
return false;
if( aMessageWindow )
{
......@@ -176,19 +177,21 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
}
// Clear undo and redo lists to avoid inconsistencies between lists
aFrame->GetScreen()->ClearUndoRedoList();
GetScreen()->ClearUndoRedoList();
aFrame->OnModify();
aFrame->GetBoard()->m_Status_Pcb = 0;
State = 0; LineNum = 0; Comment = 0;
OnModify();
GetBoard()->m_Status_Pcb = 0;
State = 0; Comment = 0;
s_NbNewModules = 0;
wxBusyCursor dummy; // Shows an hourglass while calculating
FILE_LINE_READER netlistReader( netfile, BUFFER_CHAR_SIZE );
char* Line = netlistReader;
/* First, read the netlist: Build the list of footprints to load (new
* footprints)
*/
while( GetLine( source, Line, &LineNum ) )
while( netlistReader.ReadLine( ) )
{
Text = StrPurge( Line );
......@@ -213,7 +216,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
if( State == 2 )
{
Module = ReadNetModule( aFrame,
Module = ReadNetModule( this,
aMessageWindow,
aCmpFullFileName,
Text,
......@@ -233,7 +236,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
/* Load new footprints */
if( s_NbNewModules )
{
LoadListeModules( aFrame );
LoadListeModules( this );
// Free module list:
MODULEtoLOAD* item, * next_item;
......@@ -248,8 +251,8 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
/* Second read , All footprints are on board, one must update the schematic
* info (pad netnames) */
fseek( source, 0, SEEK_SET ); LineNum = 0;
while( GetLine( source, Line, &LineNum ) )
netlistReader.Rewind( );
while( netlistReader.ReadLine( ) )
{
Text = StrPurge( Line );
......@@ -275,7 +278,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
if( State == 2 )
{
Module = ReadNetModule( aFrame,
Module = ReadNetModule( this,
aMessageWindow,
aCmpFullFileName,
Text,
......@@ -309,7 +312,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
}
}
fclose( source );
fclose( netfile );
// Delete footprints not found in netlist:
if( aDeleteExtraFootprints )
......@@ -322,7 +325,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
if( NbModulesNetListe )
{
MODULE* NextModule;
Module = aFrame->GetBoard()->m_Modules;
Module = GetBoard()->m_Modules;
bool ask_for_confirmation = true;
for( ; Module != NULL; Module = NextModule )
{
......@@ -356,19 +359,21 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
}
/* Rebuild the connectivity */
aFrame->Compile_Ratsnest( NULL, true );
Compile_Ratsnest( NULL, true );
if( aFrame->GetBoard()->m_Track )
if( GetBoard()->m_Track )
{
if( aDeleteBadTracks ) // Remove erroneous tracks
{
Netliste_Controle_piste( aFrame, NULL, true );
aFrame->Compile_Ratsnest( NULL, true );
RemoveMisConnectedTracks( NULL, true );
Compile_Ratsnest( NULL, true );
}
}
aFrame->DrawPanel->Refresh();
aFrame->GetBoard()->DisplayInfo( aFrame );
GetBoard()->DisplayInfo( this );
DrawPanel->Refresh();
return true;
}
......@@ -781,19 +786,21 @@ void TestFor_Duplicate_Missing_And_Extra_Footprints( wxWindow* aFrame,
int BuildFootprintsListFromNetlistFile( const wxString& aNetlistFullFilename,
wxArrayString& aBufName )
{
int textlen;
int nb_modules_lus;
int State, LineNum, Comment;
char Line[1024], * Text, * LibModName;
int State, Comment;
char * Text, * LibModName;
if( !OpenNetlistFile( aNetlistFullFilename ) )
FILE * netfile = OpenNetlistFile( aNetlistFullFilename );
if( !netfile )
return -1;
State = 0; LineNum = 0; Comment = 0;
FILE_LINE_READER netlistReader( netfile, BUFFER_CHAR_SIZE );
char* Line = netlistReader;
State = 0; Comment = 0;
nb_modules_lus = 0;
textlen = MAX_LEN_TXT;
while( GetLine( source, Line, &LineNum ) )
while( netlistReader.ReadLine( ) )
{
Text = StrPurge( Line );
if( Comment )
......@@ -835,7 +842,7 @@ int BuildFootprintsListFromNetlistFile( const wxString& aNetlistFullFilename,
}
}
fclose( source );
fclose( netfile );
return nb_modules_lus;
}
......@@ -876,7 +883,6 @@ int ReadListeModules( const wxString& CmpFullFileName, const wxString* RefCmp,
const wxString* TimeStamp, wxString& NameModule )
{
wxString refcurrcmp, timestamp, idmod;
char ia[1024];
char* ptcar;
FILE* FichCmp;
......@@ -893,40 +899,43 @@ int ReadListeModules( const wxString& CmpFullFileName, const wxString* RefCmp,
return 0;
}
while( fgets( ia, sizeof(ia), FichCmp ) != NULL )
FILE_LINE_READER netlistReader( FichCmp, BUFFER_CHAR_SIZE );
char* Line = netlistReader;
while( netlistReader.ReadLine() )
{
if( strnicmp( ia, "BeginCmp", 8 ) != 0 )
if( strnicmp( Line, "BeginCmp", 8 ) != 0 )
continue;
/* Begin component description. */
refcurrcmp.Empty();
idmod.Empty();
timestamp.Empty();
while( fgets( ia, sizeof(ia), FichCmp ) != NULL )
while( netlistReader.ReadLine() )
{
if( strnicmp( ia, "EndCmp", 6 ) == 0 )
if( strnicmp( Line, "EndCmp", 6 ) == 0 )
break;
if( strnicmp( ia, "Reference =", 11 ) == 0 )
if( strnicmp( Line, "Reference =", 11 ) == 0 )
{
ptcar = ia + 11;
ptcar = Line + 11;
ptcar = strtok( ptcar, " =;\t\n" );
if( ptcar )
refcurrcmp = CONV_FROM_UTF8( ptcar );
continue;
}
if( strnicmp( ia, "IdModule =", 11 ) == 0 )
if( strnicmp( Line, "IdModule =", 11 ) == 0 )
{
ptcar = ia + 11;
ptcar = Line + 11;
ptcar = strtok( ptcar, " =;\t\n" );
if( ptcar )
idmod = CONV_FROM_UTF8( ptcar );
continue;
}
if( strnicmp( ia, "TimeStamp =", 11 ) == 0 )
if( strnicmp( Line, "TimeStamp =", 11 ) == 0 )
{
ptcar = ia + 11;
ptcar = Line + 11;
ptcar = strtok( ptcar, " =;\t\n" );
if( ptcar )
timestamp = CONV_FROM_UTF8( ptcar );
......
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