Commit edb48d46 authored by charras's avatar charras

Fixed minor bugs. Code cleaning

parent 483359b3
......@@ -26,11 +26,6 @@ static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
/* class WinEDA_PinSheetPropertiesFrame */
/****************************************/
#define NBSHAPES 5
static wxString shape_list[NBSHAPES] =
{
wxT( "Input" ), wxT( "Output" ), wxT( "Bidi" ), wxT( "TriState" ), wxT( "Passive" )
};
/*****************************************************/
......@@ -91,7 +86,7 @@ WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame(
m_CurrentPinSheet = curr_pinsheet;
/* Creation des boutons de commande */
/* Create buttons: */
Button = new wxButton( this, wxID_OK, _( "OK" ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
......@@ -103,7 +98,12 @@ WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame(
m_CurrentPinSheet->m_Size.x,
g_UnitMetric, LeftBoxSizer, 200 );
// Selection de la forme :
// Display shape selection :
#define NBSHAPES 5
wxString shape_list[NBSHAPES] =
{
_( "Input" ), _( "Output" ), _( "Bidi" ), _( "TriState" ), _( "Passive" )
};
m_PinSheetShape = new wxRadioBox( this, -1, _( "PinSheet Shape:" ),
wxDefaultPosition, wxSize( -1, -1 ),
NBSHAPES, shape_list, 1 );
......@@ -138,9 +138,6 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
/*****************************************************************/
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
/*****************************************************************/
/* Routine de sortie du Menu d'Edition Des NETS (Labels) SHEET
*/
{
Hierarchical_PIN_Sheet_Struct* SheetLabel = (Hierarchical_PIN_Sheet_Struct*)
Panel->GetScreen()->GetCurItem();
......
......@@ -189,7 +189,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
// Placement des PADS sur le board //
/////////////////////////////////////
for( unsigned i=0; i<aPcb->m_Pads.size(); ++i )
for( unsigned i=0; i<aPcb->GetPadsCount(); ++i )
{
D_PAD* pad = aPcb->m_Pads[i];
......@@ -281,7 +281,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
if( PtText->GetLength() == 0 )
break;
EDA_Rect textbox = PtText->GetTextBox(-1);
ux0 = textbox.GetX(); uy0 = textbox.GetY();
dx = textbox.GetWidth();
......
......@@ -522,7 +522,7 @@ void BOARD::DisplayInfo( WinEDA_DrawFrame* frame )
viasCount++;
}
txt.Printf( wxT( "%d" ), m_Pads.size() );
txt.Printf( wxT( "%d" ), GetPadsCount() );
Affiche_1_Parametre( frame, POS_AFF_NBPADS, _( "Pads" ), txt, DARKGREEN );
txt.Printf( wxT( "%d" ), viasCount );
......@@ -531,7 +531,7 @@ void BOARD::DisplayInfo( WinEDA_DrawFrame* frame )
txt.Printf( wxT( "%d" ), GetNodesCount() );
Affiche_1_Parametre( frame, POS_AFF_NBNODES, _( "Nodes" ), txt, DARKCYAN );
txt.Printf( wxT( "%d" ), m_NetInfo->GetCount() );
txt.Printf( wxT( "%d" ), m_NetInfo->GetNetsCount() );
Affiche_1_Parametre( frame, POS_AFF_NBNETS, _( "Nets" ), txt, RED );
/* These parameters are known only if the full ratsnest is available,
......@@ -822,8 +822,8 @@ NETINFO_ITEM* BOARD::FindNet( int anetcode ) const
// zero is reserved for "no connection" and is not used.
if( anetcode > 0 )
{
wxASSERT( anetcode == m_NetInfo->GetItem( anetcode )->GetNet() );
return m_NetInfo->GetItem( anetcode );
wxASSERT( anetcode == m_NetInfo->GetNetItem( anetcode )->GetNet() );
return m_NetInfo->GetNetItem( anetcode );
}
return NULL;
}
......@@ -841,10 +841,10 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
// zero is reserved for "no connection" and is not used.
if( !aNetname.IsEmpty() )
{
for( unsigned ii = 1; ii < m_NetInfo->GetCount(); ii++ )
for( unsigned ii = 1; ii < m_NetInfo->GetNetsCount(); ii++ )
{
if( m_NetInfo->GetItem( ii )->GetNetname() == aNetname )
return m_NetInfo->GetItem( ii );
if( m_NetInfo->GetNetItem( ii )->GetNetname() == aNetname )
return m_NetInfo->GetNetItem( ii );
}
}
return NULL;
......@@ -899,16 +899,16 @@ static bool s_SortByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
*/
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
{
if( m_NetInfo->GetCount() == 0 )
if( m_NetInfo->GetNetsCount() == 0 )
return 0;
/* Build the list */
std::vector <NETINFO_ITEM*> netBuffer;
netBuffer.reserve( m_NetInfo->GetCount() );
for( unsigned ii = 1; ii < m_NetInfo->GetCount(); ii++ )
netBuffer.reserve( m_NetInfo->GetNetsCount() );
for( unsigned ii = 1; ii < m_NetInfo->GetNetsCount(); ii++ )
{
if( m_NetInfo->GetItem( ii )->GetNet() > 0 )
netBuffer.push_back( m_NetInfo->GetItem( ii ) );
if( m_NetInfo->GetNetItem( ii )->GetNet() > 0 )
netBuffer.push_back( m_NetInfo->GetNetItem( ii ) );
}
/* sort the list */
......@@ -930,8 +930,8 @@ bool BOARD::Save( FILE* aFile ) const
BOARD_ITEM* item;
// save the nets
for( unsigned ii = 0; ii < m_NetInfo->GetCount(); ii++ )
if( !m_NetInfo->GetItem( ii )->Save( aFile ) )
for( unsigned ii = 0; ii < m_NetInfo->GetNetsCount(); ii++ )
if( !m_NetInfo->GetNetItem( ii )->Save( aFile ) )
goto out;
// save the modules
......
......@@ -242,7 +242,18 @@ public:
return m_FullRatsnest.size();
}
unsigned GetNodesCount(); // retourne le nombre de pads a netcode > 0
/** Function GetNodesCount
* @return the number of pads members of nets (i.e. with netcode > 0)
*/
unsigned GetNodesCount();
/** Function GetPadsCount
* @return the number of pads in board
*/
unsigned GetPadsCount()
{
return m_Pads.size();
}
/** Function Build_Pads_Full_List
* Create the pad list
......
......@@ -79,19 +79,19 @@ public:
* @param aNetcode = netcode to identify a given NETINFO_ITEM
* @return a NETINFO_ITEM pointer to the selected NETINFO_ITEM by its netcode, or NULL if not found
*/
NETINFO_ITEM* GetItem( int aNetcode );
NETINFO_ITEM* GetNetItem( int aNetcode );
/** Function GetCount()
* @return the number of nets ( always >= 1 )
* the first net is the "not connected" net
* becuse the first net is the "not connected" net and always exists
*/
unsigned GetCount() { return m_NetBuffer.size(); }
unsigned GetNetsCount() { return m_NetBuffer.size(); }
/**
* Function Append
* adds \a aNewElement to the end of the list.
*/
void Append( NETINFO_ITEM* aNewElement );
void AppendNet( NETINFO_ITEM* aNewElement );
/** Function DeleteData
* delete the list of nets (and free memory)
......@@ -99,7 +99,7 @@ public:
void DeleteData();
/** Function BuildListOfNets
* initialize the list of NETINFO_ITEM m_NetBuffer
* Build or rebuild the list of NETINFO_ITEM m_NetBuffer
* The list is sorted by names.
*/
void BuildListOfNets();
......
......@@ -27,9 +27,9 @@ NETINFO_LIST::~NETINFO_LIST()
* @param aNetcode = netcode to identify a given NETINFO_ITEM
* @return a NETINFO_ITEM pointer to the selected NETINFO_ITEM by its netcode, or NULL if not found
*/
NETINFO_ITEM* NETINFO_LIST::GetItem( int aNetcode )
NETINFO_ITEM* NETINFO_LIST::GetNetItem( int aNetcode )
{
if( aNetcode < 0 || ( aNetcode > (int) ( GetCount() - 1 ) ) )
if( aNetcode < 0 || ( aNetcode > (int) ( GetNetsCount() - 1 ) ) )
return NULL;
return m_NetBuffer[aNetcode];
}
......@@ -40,7 +40,7 @@ NETINFO_ITEM* NETINFO_LIST::GetItem( int aNetcode )
*/
void NETINFO_LIST::DeleteData()
{
for( unsigned ii = 0; ii < GetCount(); ii++ )
for( unsigned ii = 0; ii < GetNetsCount(); ii++ )
delete m_NetBuffer[ii];
m_NetBuffer.clear();
......@@ -51,7 +51,7 @@ void NETINFO_LIST::DeleteData()
* Function Append
* adds \a aNewElement to the end of the list.
*/
void NETINFO_LIST::Append( NETINFO_ITEM* aNewElement )
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
{
m_NetBuffer.push_back( aNewElement );
}
......@@ -87,7 +87,7 @@ void NETINFO_LIST::BuildListOfNets()
// Create and add the "unconnected net"
net_item = new NETINFO_ITEM( m_Parent );
Append( net_item );
AppendNet( net_item );
/* Build the PAD list, sorted by net */
m_Parent->Build_Pads_Full_List();
......@@ -113,7 +113,7 @@ void NETINFO_LIST::BuildListOfNets()
net_item = new NETINFO_ITEM( m_Parent );
net_item->SetNet( netcode );
net_item->SetNetname( pad->GetNetname() );
Append( net_item );
AppendNet( net_item );
}
pad->SetNet( netcode );
......
......@@ -276,7 +276,7 @@ void WinEDA_BasePcbFrame::test_connexions( wxDC* DC )
*/
{
// Clear the cluster identifier for all pads
for( unsigned i = 0; i< m_Pcb->m_Pads.size(); ++i )
for( unsigned i = 0; i< m_Pcb->GetPadsCount(); ++i )
{
D_PAD* pad = m_Pcb->m_Pads[i];
......@@ -324,7 +324,7 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code )
if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
Compile_Ratsnest( DC, TRUE );
for( unsigned i = 0; i<m_Pcb->m_Pads.size(); ++i )
for( unsigned i = 0; i<m_Pcb->GetPadsCount(); ++i )
{
D_PAD* pad = m_Pcb->m_Pads[i];
......@@ -472,7 +472,7 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste,
D_PAD* pad;
int ii;
int nb_pad = aPcb->m_Pads.size();
int nb_pad = aPcb->GetPadsCount();
LISTE_PAD* ptr_pad = pt_liste;
LISTE_PAD* lim = pt_liste + nb_pad - 1;
......@@ -557,7 +557,7 @@ void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector )
{
aVector->insert( aVector->end(), aBoard->m_Pads.begin(), aBoard->m_Pads.end() );
qsort( &(*aVector)[0], aBoard->m_Pads.size(), sizeof( D_PAD*), SortPadsByXCoord );
qsort( &(*aVector)[0], aBoard->GetPadsCount(), sizeof( D_PAD*), SortPadsByXCoord );
}
......@@ -584,7 +584,7 @@ void WinEDA_BasePcbFrame::RecalculateAllTracksNetcode( )
// Build the net info list
GetBoard()->m_NetInfo->BuildListOfNets();
if( m_Pcb->m_Pads.size() == 0 ) // If no pad, reset pointers and netcode, and do nothing else
if( m_Pcb->GetPadsCount() == 0 ) // If no pad, reset pointers and netcode, and do nothing else
{
pt_piste = m_Pcb->m_Track;
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
......
......@@ -581,7 +581,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
if( testPads )
{
for( unsigned ii = 0; ii<m_pcb->m_Pads.size(); ++ii )
for( unsigned ii = 0; ii<m_pcb->GetPadsCount(); ++ii )
{
D_PAD* pad = m_pcb->m_Pads[ii];
......
......@@ -168,10 +168,10 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
fputs( "$PADS\n", file );
if( pcb->m_Pads.size() > 0 )
if( pcb->GetPadsCount() > 0 )
{
pads.insert( pads.end(), pcb->m_Pads.begin(), pcb->m_Pads.end() );
qsort( &pads[0], pcb->m_Pads.size(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes );
qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes );
}
D_PAD* old_pad = NULL;
......@@ -440,9 +440,9 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
fputs( "$SIGNALS\n", file );
for( unsigned ii = 0; ii < pcb->m_NetInfo->GetCount() ; ii++ )
for( unsigned ii = 0; ii < pcb->m_NetInfo->GetNetsCount() ; ii++ )
{
net = pcb->m_NetInfo->GetItem(ii);
net = pcb->m_NetInfo->GetNetItem(ii);
if( net->GetNetname() == wxEmptyString ) // dummy equipot (non connexion)
{
wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++;
......
......@@ -594,7 +594,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() );
fprintf( File, "Nmodule %d\n", NbModules );
fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() );
fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetNetsCount() );
fprintf( File, "$EndGENERAL\n\n" );
return TRUE;
......@@ -784,7 +784,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
if( strnicmp( Line, "$EQUIPOT", 7 ) == 0 )
{
NETINFO_ITEM* net = new NETINFO_ITEM( GetBoard() );
GetBoard()->m_NetInfo->Append( net );
GetBoard()->m_NetInfo->AppendNet( net );
net->ReadDescr( File, &LineNum );
continue;
}
......
......@@ -583,7 +583,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_
* (bonne position ET bonne couche).
*/
{
for( unsigned i=0; i<Pcb->m_Pads.size(); ++i )
for( unsigned i=0; i<Pcb->GetPadsCount(); ++i )
{
D_PAD* pad = Pcb->m_Pads[i];
......
......@@ -332,15 +332,26 @@ void WinEDA_ModuleEditFrame::SetToolbars()
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood ?
_( "Polar Coords not show" ) :
_( "Display Polar Coords" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
m_CursorShape );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
!m_DisplayPadFill );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
m_DisplayPadFill ?
_( "Show Pads Sketch mode" ) :
_( "Show pads filled mode" ) );
}
if( m_AuxiliaryToolBar )
......
......@@ -115,13 +115,13 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
if( display_status_pcb )
{
msg.Printf( wxT( " %d" ), m_Pcb->m_Pads.size() );
msg.Printf( wxT( " %d" ), m_Pcb->GetPadsCount() );
Affiche_1_Parametre( this, 1, wxT( "pads" ), msg, RED );
}
if( display_status_pcb )
{
msg.Printf( wxT( " %d" ), m_Pcb->m_NetInfo->GetCount() );
msg.Printf( wxT( " %d" ), m_Pcb->m_NetInfo->GetNetsCount() );
Affiche_1_Parametre( this, 8, wxT( "Nets" ), msg, CYAN );
}
......@@ -419,14 +419,14 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
m_Pcb->m_FullRatsnest.clear();
if( m_Pcb->m_Pads.size() == 0 )
if( m_Pcb->GetPadsCount() == 0 )
return;
/* Created pad list and the net_codes if needed */
if( (m_Pcb->m_Status_Pcb & NET_CODES_OK) == 0 )
m_Pcb->m_NetInfo->BuildListOfNets();
for( unsigned ii = 0; ii<m_Pcb->m_Pads.size(); ++ii )
for( unsigned ii = 0; ii<m_Pcb->GetPadsCount(); ++ii )
{
pad = m_Pcb->m_Pads[ii];
pad->SetSubRatsnest( 0 );
......@@ -441,7 +441,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
unsigned current_net_code = 1; // 1er net_code a analyser (net_code = 0 -> no connect)
noconn = 0;
for( ; current_net_code < m_Pcb->m_NetInfo->GetCount(); current_net_code++ )
for( ; current_net_code < m_Pcb->m_NetInfo->GetNetsCount(); current_net_code++ )
{
NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code );
if ( net == NULL ) //Should not occur
......@@ -676,12 +676,12 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
D_PAD* pad;
NETINFO_ITEM* net;
if( m_Pcb->m_Pads.size() == 0 )
if( m_Pcb->GetPadsCount() == 0 )
return;
if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
Build_Board_Ratsnest( DC );
for( int net_code = 1; net_code < (int) m_Pcb->m_NetInfo->GetCount(); net_code++ )
for( int net_code = 1; net_code < (int) m_Pcb->m_NetInfo->GetNetsCount(); net_code++ )
{
net = m_Pcb->FindNet( net_code );
if ( net == NULL ) //Should not occur
......
......@@ -158,11 +158,11 @@ void Out_Pads( BOARD* Pcb, FILE* outfile )
LISTE_PAD* pt_liste_pad, * pt_start_liste,
* pt_end_liste, * pt_liste_pad_limite;
int pin_min_layer, pin_max_layer;
int no_conn = Pcb->m_Pads.size() + 1;/* valeur incrementee pour indiquer
int no_conn = Pcb->GetPadsCount() + 1;/* valeur incrementee pour indiquer
* que le pad n'est pas deja connecte a une piste*/
pt_liste_pad = pt_start_liste = &Pcb->m_Pads[0];
pt_liste_pad_limite = pt_start_liste + Pcb->m_Pads.size();
pt_liste_pad_limite = pt_start_liste + Pcb->GetPadsCount();
if( pt_liste_pad == NULL )
return;
......
......@@ -433,7 +433,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
/* Regenere les barrieres restantes (qui peuvent empieter sur le placement
* des bits precedents) */
ptr = (LISTE_PAD*) &pcbframe->GetBoard()->m_Pads[0];
i = pcbframe->GetBoard()->m_Pads.size();
i = pcbframe->GetBoard()->GetPadsCount();
for( ; i > 0; i--, ptr++ )
{
if( (pt_cur_ch->m_PadStart != *ptr) && (pt_cur_ch->m_PadEnd != *ptr) )
......
......@@ -1114,7 +1114,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
int highestNetCode = -1;
// for( EQUIPOT* equipot = aBoard->m_Equipots; equipot; equipot = equipot->Next() )
// highestNetCode = MAX( highestNetCode, equipot->GetNet() );
highestNetCode = aBoard->m_NetInfo->GetCount() - 1;
highestNetCode = aBoard->m_NetInfo->GetNetsCount() - 1;
deleteNETs();
// expand the net vector to highestNetCode+1, setting empty to NULL
......@@ -1124,9 +1124,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
for( unsigned i=1; i<nets.size(); ++i )
nets[i] = new NET( pcb->network );
for( unsigned ii = 0; ii < aBoard->m_NetInfo->GetCount(); ii++ )
for( unsigned ii = 0; ii < aBoard->m_NetInfo->GetNetsCount(); ii++ )
{
NETINFO_ITEM* net = aBoard->m_NetInfo->GetItem(ii);
NETINFO_ITEM* net = aBoard->m_NetInfo->GetNetItem(ii);
int netcode = net->GetNet();
if( netcode > 0 )
nets[ netcode ]->net_id = CONV_TO_UTF8( net->GetNetname() );
......
......@@ -37,9 +37,9 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
WinEDA_TextFrame List( this, _( "List Nets" ) );
for( unsigned ii = 0; ii < GetBoard()->m_NetInfo->GetCount(); ii++ )
for( unsigned ii = 0; ii < GetBoard()->m_NetInfo->GetNetsCount(); ii++ )
{
net = GetBoard()->m_NetInfo->GetItem( ii );
net = GetBoard()->m_NetInfo->GetNetItem( ii );
wxString Line;
if( !WildCompareString( netFilter, net->GetNetname(), false ) )
continue;
......@@ -58,9 +58,9 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
unsigned netcode = (unsigned) selection;
// Search for the net selected.
for( unsigned ii = 0; ii < GetBoard()->m_NetInfo->GetCount(); ii++ )
for( unsigned ii = 0; ii < GetBoard()->m_NetInfo->GetNetsCount(); ii++ )
{
net = GetBoard()->m_NetInfo->GetItem( ii );
net = GetBoard()->m_NetInfo->GetNetItem( ii );
if( !WildCompareString( netFilter, net->GetNetname(), false ) )
continue;
......
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