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

Pcbnew: fix 2 minor issues, noticeable only in debug mode.

When reading board files, the net 0 was stored twice.
It creates only log messges in debug mode, because the list of nets is rebuild after reading files.
parent 20f0a5f8
......@@ -1381,13 +1381,10 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
NETINFO_ITEM* net = m_NetInfo.GetNetItem( aNetcode );
#if defined(DEBUG)
if( net ) // item can be NULL if anetcode is not valid
if( net && aNetcode != net->GetNet()) // item can be NULL if anetcode is not valid
{
if( aNetcode != net->GetNet() )
{
printf( "FindNet() anetcode %d != GetNet() %d (net: %s)\n",
aNetcode, net->GetNet(), TO_UTF8( net->GetNetname() ) );
}
wxLogError( wxT( "FindNet() anetcode %d != GetNet() %d (net: %s)\n" ),
aNetcode, net->GetNet(), TO_UTF8( net->GetNetname() ) );
}
#endif
......@@ -1440,7 +1437,7 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
if( item == NULL )
return NULL;
int icmp = item->GetNetname().Cmp( aNetname );
int icmp = item->GetNetname().Cmp( aNetname );
if( icmp == 0 ) // found !
{
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 24 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_MODULE_FOR_BOARDEDITOR_BASE_H__
#define __DIALOG_EDIT_MODULE_FOR_BOARDEDITOR_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/slider.h>
#include <wx/choice.h>
#include <wx/statline.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/listbox.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_NOTEBOOK 1000
#define ID_LISTBOX_ORIENT_SELECT 1001
#define ID_MODULE_PROPERTIES_EXCHANGE 1002
#define ID_GOTO_MODULE_EDITOR 1003
#define ID_BROWSE_3D_LIB 1004
#define ID_ADD_3D_SHAPE 1005
#define ID_REMOVE_3D_SHAPE 1006
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MODULE_BOARD_EDITOR_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MODULE_BOARD_EDITOR_BASE : public wxDialog
{
private:
wxBoxSizer* m_GeneralBoxSizer;
wxBoxSizer* m_PropRightSizer;
protected:
wxNotebook* m_NoteBook;
wxPanel* m_PanelProperties;
wxTextCtrl* m_ReferenceCtrl;
wxButton* m_button4;
wxTextCtrl* m_ValueCtrl;
wxButton* m_button5;
wxRadioBox* m_LayerCtrl;
wxRadioBox* m_OrientCtrl;
wxStaticText* m_staticText4;
wxTextCtrl* m_OrientValue;
wxStaticText* XPositionStatic;
wxTextCtrl* m_ModPositionX;
wxStaticText* YPositionStatic;
wxTextCtrl* m_ModPositionY;
wxButton* m_buttonExchange;
wxButton* m_buttonModuleEditor;
wxRadioBox* m_AttributsCtrl;
wxRadioBox* m_AutoPlaceCtrl;
wxStaticText* m_staticText11;
wxSlider* m_CostRot90Ctrl;
wxStaticText* m_staticText12;
wxSlider* m_CostRot180Ctrl;
wxStaticText* m_staticText16;
wxChoice* m_ZoneConnectionChoice;
wxStaticText* m_staticTextInfo;
wxStaticText* m_staticTextNetClearance;
wxTextCtrl* m_NetClearanceValueCtrl;
wxStaticText* m_NetClearanceUnits;
wxStaticLine* m_staticline1;
wxStaticLine* m_staticline2;
wxStaticLine* m_staticline3;
wxStaticText* m_MaskClearanceTitle;
wxTextCtrl* m_SolderMaskMarginCtrl;
wxStaticText* m_SolderMaskMarginUnits;
wxStaticText* m_staticTextSolderPaste;
wxTextCtrl* m_SolderPasteMarginCtrl;
wxStaticText* m_SolderPasteMarginUnits;
wxStaticText* m_staticTextRatio;
wxTextCtrl* m_SolderPasteMarginRatioCtrl;
wxStaticText* m_SolderPasteRatioMarginUnits;
wxPanel* m_Panel3D;
wxStaticText* m_staticText3Dname;
wxListBox* m_3D_ShapeNameListBox;
wxButton* m_buttonBrowse;
wxButton* m_buttonAdd;
wxButton* m_buttonRemove;
wxStdDialogButtonSizer* m_sdbSizerStdButtons;
wxButton* m_sdbSizerStdButtonsOK;
wxButton* m_sdbSizerStdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnEditReference( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditValue( wxCommandEvent& event ) { event.Skip(); }
virtual void ModuleOrientEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void ExchangeModule( wxCommandEvent& event ) { event.Skip(); }
virtual void GotoModuleEditor( wxCommandEvent& event ) { event.Skip(); }
virtual void On3DShapeNameSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void Browse3DLib( wxCommandEvent& event ) { event.Skip(); }
virtual void Add3DShape( wxCommandEvent& event ) { event.Skip(); }
virtual void Remove3DShape( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
wxStaticBoxSizer* m_Sizer3DValues;
DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,800 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_MODULE_BOARD_EDITOR_BASE();
};
#endif //__DIALOG_EDIT_MODULE_FOR_BOARDEDITOR_BASE_H__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_MODULE_FOR_BOARDEDITOR_BASE_H__
#define __DIALOG_EDIT_MODULE_FOR_BOARDEDITOR_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/slider.h>
#include <wx/choice.h>
#include <wx/statline.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/listbox.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_NOTEBOOK 1000
#define ID_LISTBOX_ORIENT_SELECT 1001
#define ID_MODULE_PROPERTIES_EXCHANGE 1002
#define ID_GOTO_MODULE_EDITOR 1003
#define ID_BROWSE_3D_LIB 1004
#define ID_ADD_3D_SHAPE 1005
#define ID_REMOVE_3D_SHAPE 1006
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MODULE_BOARD_EDITOR_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MODULE_BOARD_EDITOR_BASE : public wxDialog
{
private:
wxBoxSizer* m_GeneralBoxSizer;
wxBoxSizer* m_PropRightSizer;
protected:
wxNotebook* m_NoteBook;
wxPanel* m_PanelProperties;
wxTextCtrl* m_ReferenceCtrl;
wxButton* m_button4;
wxTextCtrl* m_ValueCtrl;
wxButton* m_button5;
wxRadioBox* m_LayerCtrl;
wxRadioBox* m_OrientCtrl;
wxStaticText* m_staticText4;
wxTextCtrl* m_OrientValue;
wxStaticText* XPositionStatic;
wxTextCtrl* m_ModPositionX;
wxStaticText* YPositionStatic;
wxTextCtrl* m_ModPositionY;
wxButton* m_buttonExchange;
wxButton* m_buttonModuleEditor;
wxRadioBox* m_AttributsCtrl;
wxRadioBox* m_AutoPlaceCtrl;
wxStaticText* m_staticText11;
wxSlider* m_CostRot90Ctrl;
wxStaticText* m_staticText12;
wxSlider* m_CostRot180Ctrl;
wxStaticText* m_staticText16;
wxChoice* m_ZoneConnectionChoice;
wxStaticText* m_staticTextInfo;
wxStaticText* m_staticTextNetClearance;
wxTextCtrl* m_NetClearanceValueCtrl;
wxStaticText* m_NetClearanceUnits;
wxStaticLine* m_staticline1;
wxStaticLine* m_staticline2;
wxStaticLine* m_staticline3;
wxStaticText* m_MaskClearanceTitle;
wxTextCtrl* m_SolderMaskMarginCtrl;
wxStaticText* m_SolderMaskMarginUnits;
wxStaticText* m_staticTextSolderPaste;
wxTextCtrl* m_SolderPasteMarginCtrl;
wxStaticText* m_SolderPasteMarginUnits;
wxStaticText* m_staticTextRatio;
wxTextCtrl* m_SolderPasteMarginRatioCtrl;
wxStaticText* m_SolderPasteRatioMarginUnits;
wxPanel* m_Panel3D;
wxStaticText* m_staticText3Dname;
wxListBox* m_3D_ShapeNameListBox;
wxButton* m_buttonBrowse;
wxButton* m_buttonAdd;
wxButton* m_buttonRemove;
wxStdDialogButtonSizer* m_sdbSizerStdButtons;
wxButton* m_sdbSizerStdButtonsOK;
wxButton* m_sdbSizerStdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnEditReference( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditValue( wxCommandEvent& event ) { event.Skip(); }
virtual void ModuleOrientEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void ExchangeModule( wxCommandEvent& event ) { event.Skip(); }
virtual void GotoModuleEditor( wxCommandEvent& event ) { event.Skip(); }
virtual void On3DShapeNameSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void Browse3DLib( wxCommandEvent& event ) { event.Skip(); }
virtual void Add3DShape( wxCommandEvent& event ) { event.Skip(); }
virtual void Remove3DShape( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
wxStaticBoxSizer* m_Sizer3DValues;
DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 544,599 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_MODULE_BOARD_EDITOR_BASE();
};
#endif //__DIALOG_EDIT_MODULE_FOR_BOARDEDITOR_BASE_H__
......@@ -1713,13 +1713,11 @@ void LEGACY_PLUGIN::loadPCB_LINE()
THROW_IO_ERROR( "Missing '$EndDRAWSEGMENT'" );
}
void LEGACY_PLUGIN::loadNETINFO_ITEM()
{
char buf[1024];
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
m_board->AppendNet( net );
while( READLINE( m_reader ) )
{
......@@ -1738,7 +1736,15 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
}
else if( TESTLINE( "$EndEQUIPOT" ) )
{
// net 0 should be already in list, so store this net
// if it is not the net 0, or if the net 0 does not exists.
if( net->GetNet() > 0 || m_board->FindNet( 0 ) == NULL )
m_board->AppendNet( net );
else
delete net;
return; // preferred exit
}
}
THROW_IO_ERROR( "Missing '$EndEQUIPOT'" );
......@@ -2135,8 +2141,11 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
}
zc->SetTimeStamp( timestamp );
zc->SetNet( netcode );
zc->SetNetName( FROM_UTF8( buf ) );
// Init the net code only, not the netname, to be sure
// the zone net name is the name read in file.
// (When mismatch, the user will be prompted in DRC, to fix the actual name)
zc->BOARD_CONNECTED_ITEM::SetNet( netcode );
zc->SetNetName( FROM_UTF8( buf ) ); // init the net name here
}
else if( TESTLINE( "ZLayer" ) ) // layer found
......
......@@ -605,7 +605,7 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR )
default:
wxString err;
err.Printf( _( "%d is not a valid title block comment number" ), commentNumber );
err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber );
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
......@@ -705,7 +705,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
if( it == m_layerMap.end() )
{
wxString error;
error.Printf( _( "Layer '%s' in file <%s> at line %d, position %d was not defined in the layers section" ),
error.Printf( wxT( "Layer '%s' in file <%s> at line %d, position %d was not defined in the layers section" ),
GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
}
......@@ -720,7 +720,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
if( !m_board->IsLayerEnabled( layerIndex ) )
{
wxString error;
error.Printf( _( "Layer index %d in file <%s> at line %d, offset %d was not defined in the layers section" ),
error.Printf( wxT( "Layer index %d in file <%s> at line %d, offset %d was not defined in the layers section" ),
layerIndex, GetChars( CurSource() ), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
}
......@@ -1003,10 +1003,16 @@ void PCB_PARSER::parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR )
wxString name = FromUTF8();
NeedRIGHT();
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
net->SetNet( number );
net->SetNetname( name );
m_board->AppendNet( net );
// net 0 should be already in list, so store this net
// if it is not the net 0, or if the net 0 does not exists.
// (TODO: a better test.)
if( number > 0 || m_board->FindNet( 0 ) == NULL )
{
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
net->SetNet( number );
net->SetNetname( name );
m_board->AppendNet( net );
}
}
......@@ -2322,7 +2328,10 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
switch( token )
{
case T_net:
zone->SetNet( parseInt( "net number" ) );
// Init the net code only, not the netname, to be sure
// the zone net name is the name read in file.
// (When mismatch, the user will be prompted in DRC, to fix the actual name)
zone->BOARD_CONNECTED_ITEM::SetNet( parseInt( "net number" ) );
NeedRIGHT();
break;
......
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