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

Eeschema: fix bug in algorithm which select net names, in netlist...

Eeschema: fix bug in algorithm which select net names, in netlist calculations. Named nets should now keep their names. Cvpcb:minor enhancements. Gerbview: fix an issue under W7.
parents 67894dd3 9cc346ea
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "class_DisplayFootprintsFrame.h" #include "class_DisplayFootprintsFrame.h"
#include "cvpcb_id.h"
/* /*
* NOTE: There is something in 3d_viewer.h that causes a compiler error in * NOTE: There is something in 3d_viewer.h that causes a compiler error in
......
...@@ -23,7 +23,7 @@ FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( WinEDA_CvpcbFrame* parent, ...@@ -23,7 +23,7 @@ FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( WinEDA_CvpcbFrame* parent,
{ {
m_UseFootprintFullList = true; m_UseFootprintFullList = true;
m_ActiveFootprintList = NULL; m_ActiveFootprintList = NULL;
SetActiveFootprintList( TRUE ); SetActiveFootprintList( true );
} }
...@@ -61,8 +61,8 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint() ...@@ -61,8 +61,8 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint()
if( ii >= 0 ) if( ii >= 0 )
{ {
wxString msg = (*m_ActiveFootprintList)[ii]; wxString msg = (*m_ActiveFootprintList)[ii];
msg.Trim( TRUE ); msg.Trim( true );
msg.Trim( FALSE ); msg.Trim( false );
FootprintName = msg.AfterFirst( wxChar( ' ' ) ); FootprintName = msg.AfterFirst( wxChar( ' ' ) );
} }
...@@ -121,11 +121,11 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) ...@@ -121,11 +121,11 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list )
m_FullFootprintList.Add( msg ); m_FullFootprintList.Add( msg );
} }
SetActiveFootprintList( TRUE ); SetActiveFootprintList( true );
if( ( GetCount() == 0 ) if( ( GetCount() == 0 )
|| ( OldSelection < 0 ) || ( OldSelection >= GetCount() ) ) || ( OldSelection < 0 ) || ( OldSelection >= GetCount() ) )
SetSelection( 0, TRUE ); SetSelection( 0, true );
Refresh(); Refresh();
} }
...@@ -137,7 +137,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, ...@@ -137,7 +137,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component,
wxString msg; wxString msg;
unsigned jj; unsigned jj;
int OldSelection = GetSelection(); int OldSelection = GetSelection();
bool HasItem = FALSE; bool HasItem = false;
m_FilteredFootprintList.Clear(); m_FilteredFootprintList.Clear();
...@@ -150,17 +150,17 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, ...@@ -150,17 +150,17 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component,
msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1, msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1,
footprint.m_Module.GetData() ); footprint.m_Module.GetData() );
m_FilteredFootprintList.Add( msg ); m_FilteredFootprintList.Add( msg );
HasItem = TRUE; HasItem = true;
} }
} }
if( HasItem ) if( HasItem )
SetActiveFootprintList( FALSE ); SetActiveFootprintList( false );
else else
SetActiveFootprintList( TRUE ); SetActiveFootprintList( true );
if( ( GetCount() == 0 ) || ( OldSelection >= GetCount() ) ) if( ( GetCount() == 0 ) || ( OldSelection >= GetCount() ) )
SetSelection( 0, TRUE ); SetSelection( 0, true );
Refresh(); Refresh();
} }
...@@ -189,49 +189,35 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) ...@@ -189,49 +189,35 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw )
{ {
bool new_selection; bool new_selection;
if( FullList ) if( FullList )
new_selection = TRUE; new_selection = true;
else else
new_selection = FALSE; new_selection = false;
if( new_selection != old_selection ) if( new_selection != old_selection )
SetSelection( 0, TRUE ); SetSelection( 0, true );
} }
#endif #endif
if( FullList ) if( FullList )
{ {
m_UseFootprintFullList = TRUE; m_UseFootprintFullList = true;
m_ActiveFootprintList = &m_FullFootprintList; m_ActiveFootprintList = &m_FullFootprintList;
SetItemCount( m_FullFootprintList.GetCount() ); SetItemCount( m_FullFootprintList.GetCount() );
} }
else else
{ {
m_UseFootprintFullList = FALSE; m_UseFootprintFullList = false;
m_ActiveFootprintList = &m_FilteredFootprintList; m_ActiveFootprintList = &m_FilteredFootprintList;
SetItemCount( m_FilteredFootprintList.GetCount() ); SetItemCount( m_FilteredFootprintList.GetCount() );
} }
if( Redraw ) if( Redraw )
{ {
if( !m_UseFootprintFullList if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) )
|| ( m_UseFootprintFullList != old_selection ) )
{ {
Refresh(); Refresh();
} }
} }
if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) ) GetParent()->DisplayStatus();
{
GetParent()->SetStatusText( wxEmptyString, 0 );
GetParent()->SetStatusText( wxEmptyString, 1 );
}
wxString msg;
if( FullList )
msg.Printf( _( "Footprints (All): %d" ),
m_ActiveFootprintList->GetCount() );
else
msg.Printf( _( "Footprints (filtered): %d" ),
m_ActiveFootprintList->GetCount() );
GetParent()->SetStatusText( msg, 2 );
} }
...@@ -253,6 +239,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) ...@@ -253,6 +239,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
wxString FootprintName = GetSelectedFootprint(); wxString FootprintName = GetSelectedFootprint();
Module = GetModuleDescrByName( FootprintName, GetParent()->m_footprints ); Module = GetModuleDescrByName( FootprintName, GetParent()->m_footprints );
wxASSERT(Module);
if( GetParent()->DrawFrame ) if( GetParent()->DrawFrame )
{ {
GetParent()->CreateScreenCmp(); /* refresh general */ GetParent()->CreateScreenCmp(); /* refresh general */
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "cvstruct.h" #include "cvstruct.h"
#include "dialog_cvpcb_config.h" #include "dialog_cvpcb_config.h"
#include "class_DisplayFootprintsFrame.h" #include "class_DisplayFootprintsFrame.h"
#include "cvpcb_id.h"
#include "build_version.h" #include "build_version.h"
...@@ -115,7 +116,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, ...@@ -115,7 +116,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title,
m_KeepCvpcbOpen = false; m_KeepCvpcbOpen = false;
m_undefinedComponentCnt = 0; m_undefinedComponentCnt = 0;
/* Name of the document footprint list /* Name of the document footprint list
* usually located in share/modules/footprints_doc * usually located in share/modules/footprints_doc
* this is of the responsibility to users to create this file * this is of the responsibility to users to create this file
...@@ -422,9 +422,7 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event ) ...@@ -422,9 +422,7 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event )
m_undefinedComponentCnt = m_components.size(); m_undefinedComponentCnt = m_components.size();
} }
Line.Printf( _( "Components: %d (free: %d)" ), m_components.size(), DisplayStatus();
m_components.size() );
SetStatusText( Line, 1 );
} }
...@@ -557,6 +555,7 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event ) ...@@ -557,6 +555,7 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event )
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_FootprintList->SetFootprintFilteredList( &m_components[ selection ],
m_footprints ); m_footprints );
DisplayStatus();
} }
...@@ -585,3 +584,30 @@ void WinEDA_CvpcbFrame::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event ) ...@@ -585,3 +584,30 @@ void WinEDA_CvpcbFrame::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event )
{ {
event.Check( m_KeepCvpcbOpen ); event.Check( m_KeepCvpcbOpen );
} }
/** DisplayStatus()
* Displays info to the status line at bottom of the main frame
*/
void WinEDA_CvpcbFrame::DisplayStatus()
{
wxString msg;
msg.Printf( _( "Components: %d (free: %d)" ),
m_components.size(), m_undefinedComponentCnt );
SetStatusText( msg, 0 );
SetStatusText( wxEmptyString, 1 );
if( m_FootprintList )
{
if( m_FootprintList->m_UseFootprintFullList )
msg.Printf( _( "Footprints (All): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() );
else
msg.Printf( _( "Footprints (filtered): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() );
}
else
msg.Empty();
SetStatusText( msg, 2 );
}
/**
* @file cvpcb_id.h
*/
/*
* Command IDs for CvPcb.
*
* Please add IDs that are unique to the component library viewer here and
* not in the global id.h file. This will prevent the entire project from
* being rebuilt when adding new commands to the component library viewer.
*/
// Generic IDs:
#include "id.h"
// specific IDs
enum id_cvpcb_frm
{
ID_CVPCB_QUIT = ID_END_LIST,
ID_CVPCB_READ_INPUT_NETLIST,
ID_CVPCB_SAVEQUITCVPCB,
ID_CVPCB_CREATE_CONFIGWINDOW,
ID_CVPCB_CREATE_SCREENCMP,
ID_CVPCB_GOTO_FIRSTNA,
ID_CVPCB_GOTO_PREVIOUSNA,
ID_CVPCB_DEL_ASSOCIATIONS,
ID_CVPCB_AUTO_ASSOCIE,
ID_CVPCB_COMPONENT_LIST,
ID_CVPCB_FOOTPRINT_LIST,
ID_CVPCB_CREATE_STUFF_FILE,
ID_CVPCB_SHOW3D_FRAME,
ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE
};
...@@ -16,36 +16,6 @@ class COMPONENTS_LISTBOX; ...@@ -16,36 +16,6 @@ class COMPONENTS_LISTBOX;
class DISPLAY_FOOTPRINTS_FRAME; class DISPLAY_FOOTPRINTS_FRAME;
#include "id.h"
/**
* Command IDs for the component library viewer.
*
* Please add IDs that are unique to the component library viewer here and
* not in the global id.h file. This will prevent the entire project from
* being rebuilt when adding new commands to the component library viewer.
*/
enum id_cvpcb_frm
{
ID_CVPCB_QUIT = ID_END_LIST,
ID_CVPCB_READ_INPUT_NETLIST,
ID_CVPCB_SAVEQUITCVPCB,
ID_CVPCB_CREATE_CONFIGWINDOW,
ID_CVPCB_CREATE_SCREENCMP,
ID_CVPCB_GOTO_FIRSTNA,
ID_CVPCB_GOTO_PREVIOUSNA,
ID_CVPCB_DEL_ASSOCIATIONS,
ID_CVPCB_AUTO_ASSOCIE,
ID_CVPCB_COMPONENT_LIST,
ID_CVPCB_FOOTPRINT_LIST,
ID_CVPCB_CREATE_STUFF_FILE,
ID_CVPCB_SHOW3D_FRAME,
ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE
};
/** /**
* The CVPcb application main window. * The CVPcb application main window.
...@@ -120,6 +90,10 @@ public: ...@@ -120,6 +90,10 @@ public:
void SaveProjectFile( const wxString& fileName ); void SaveProjectFile( const wxString& fileName );
virtual void LoadSettings(); virtual void LoadSettings();
virtual void SaveSettings(); virtual void SaveSettings();
/** DisplayStatus()
* Displays info to the status line at bottom of the main frame
*/
void DisplayStatus();
PARAM_CFG_ARRAY& GetProjectFileParameters( void ); PARAM_CFG_ARRAY& GetProjectFileParameters( void );
......
...@@ -24,7 +24,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -24,7 +24,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
COMPONENT* Component; COMPONENT* Component;
bool isUndefined = false; bool isUndefined = false;
int NumCmp; int NumCmp;
wxString Line; wxString msg;
if( m_components.empty() ) if( m_components.empty() )
return; return;
...@@ -45,7 +45,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -45,7 +45,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
Component->m_Module = package; Component->m_Module = package;
Line.Printf( CMP_FORMAT, NumCmp + 1, msg.Printf( CMP_FORMAT, NumCmp + 1,
GetChars( Component->m_Reference ), GetChars( Component->m_Reference ),
GetChars( Component->m_Value ), GetChars( Component->m_Value ),
GetChars( Component->m_Module ) ); GetChars( Component->m_Module ) );
...@@ -54,7 +54,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -54,7 +54,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
if( isUndefined ) if( isUndefined )
m_undefinedComponentCnt -= 1; m_undefinedComponentCnt -= 1;
m_ListCmp->SetString( NumCmp, Line ); m_ListCmp->SetString( NumCmp, msg );
m_ListCmp->SetSelection( NumCmp, FALSE ); m_ListCmp->SetSelection( NumCmp, FALSE );
// We activate next component: // We activate next component:
...@@ -62,9 +62,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -62,9 +62,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
NumCmp++; NumCmp++;
m_ListCmp->SetSelection( NumCmp, TRUE ); m_ListCmp->SetSelection( NumCmp, TRUE );
Line.Printf( _( "Components: %d (free: %d)" ), DisplayStatus();
m_components.size(), m_undefinedComponentCnt );
SetStatusText( Line, 1 );
} }
...@@ -112,9 +110,7 @@ bool WinEDA_CvpcbFrame::ReadNetList() ...@@ -112,9 +110,7 @@ bool WinEDA_CvpcbFrame::ReadNetList()
if( !m_components.empty() ) if( !m_components.empty() )
m_ListCmp->SetSelection( 0, TRUE ); m_ListCmp->SetSelection( 0, TRUE );
msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(), DisplayStatus();
m_undefinedComponentCnt );
SetStatusText( msg, 1 );
/* Update the title of the main window. */ /* Update the title of the main window. */
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "cvpcb.h" #include "cvpcb.h"
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "cvpcb_id.h"
/****************************************************************************** /******************************************************************************
...@@ -122,7 +123,5 @@ void WinEDA_CvpcbFrame::BuildFOOTPRINTS_LISTBOX() ...@@ -122,7 +123,5 @@ void WinEDA_CvpcbFrame::BuildFOOTPRINTS_LISTBOX()
} }
m_FootprintList->SetFootprintFullList( m_footprints ); m_FootprintList->SetFootprintFullList( m_footprints );
DisplayStatus();
msg.Printf( _( "Footprints: %d" ), m_FootprintList->GetCount() );
SetStatusText( msg, 2 );
} }
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "cvpcb.h" #include "cvpcb.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "cvpcb_id.h"
#include "bitmaps.h" #include "bitmaps.h"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "cvpcb.h" #include "cvpcb.h"
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "cvpcb_id.h"
void WinEDA_CvpcbFrame::ReCreateHToolbar() void WinEDA_CvpcbFrame::ReCreateHToolbar()
......
...@@ -485,9 +485,8 @@ the current schematic." ), ...@@ -485,9 +485,8 @@ the current schematic." ),
{ {
versionMajor = (int) major; versionMajor = (int) major;
versionMinor = (int) minor; versionMinor = (int) minor;
// wxLogDebug( wxT( "Component library <%s> is version %d.%d." ),
wxLogDebug( wxT( "Component library <%s> is version %d.%d." ), // GetChars( GetName() ), versionMajor, versionMinor );
GetChars( GetName() ), versionMajor, versionMinor );
} }
} }
......
...@@ -104,8 +104,8 @@ void WinEDA_SchematicFrame::LoadLibraries( void ) ...@@ -104,8 +104,8 @@ void WinEDA_SchematicFrame::LoadLibraries( void )
CMP_LIBRARY::SetSortOrder( sortOrder ); CMP_LIBRARY::SetSortOrder( sortOrder );
CMP_LIBRARY::GetLibraryList().sort(); CMP_LIBRARY::GetLibraryList().sort();
#ifdef __WXDEBUG__ #if 0 // #ifdef __WXDEBUG__
wxLogDebug( wxT( "LoadLibraries () requested component library sort order:" ) ); wxLogDebug( wxT( "LoadLibraries() requested component library sort order:" ) );
for( size_t i = 0; i < sortOrder.GetCount(); i++ ) for( size_t i = 0; i < sortOrder.GetCount(); i++ )
wxLogDebug( wxT( " " ) + sortOrder[i] ); wxLogDebug( wxT( " " ) + sortOrder[i] );
......
...@@ -305,13 +305,14 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() ...@@ -305,13 +305,14 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
/* Global label */ /* Global label */
item = new wxMenuItem( placeMenu, ID_GLABEL_BUTT, _( "Global label" ), item = new wxMenuItem( placeMenu, ID_GLABEL_BUTT, _( "Global label" ),
_( "Place a global label. Warning: all global labels with the same name are connected in whole hierarchy" ), HELP_PLACE_GLOBALLABEL, wxITEM_NORMAL );
wxITEM_NORMAL );
item->SetBitmap( add_glabel_xpm ); item->SetBitmap( add_glabel_xpm );
placeMenu->Append( item ); placeMenu->Append( item );
/* Junction */ /* Junction */
item = new wxMenuItem( placeMenu, ID_JUNCTION_BUTT, _( "Junction" ), text = AddHotkeyName( _( "Junction" ), s_Schematic_Hokeys_Descr,
HK_ADD_JUNCTION, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_JUNCTION_BUTT, text,
HELP_PLACE_JUNCTION, wxITEM_NORMAL ); HELP_PLACE_JUNCTION, wxITEM_NORMAL );
item->SetBitmap( add_junction_xpm ); item->SetBitmap( add_junction_xpm );
placeMenu->Append( item ); placeMenu->Append( item );
......
...@@ -369,14 +369,19 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -369,14 +369,19 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
if( aLabelItemBuffer.size() == 0 ) if( aLabelItemBuffer.size() == 0 )
return NULL; return NULL;
int priority_order[4] = // Define a priority (from low to high) to sort labels:
{ NET_LABEL, NET_HIERLABEL, NET_PINLABEL, NET_GLOBLABEL }; // NET_PINLABEL and NET_GLOBLABEL are global labels
// and priority >= PRIO_MAX-1 is for global connections
// ( i.e. for labels that are not prefixed by a sheetpath)
#define PRIO_MAX 4
int priority_order[PRIO_MAX+1] =
{ NET_ITEM_UNSPECIFIED, NET_LABEL, NET_HIERLABEL, NET_PINLABEL, NET_GLOBLABEL };
NETLIST_OBJECT*item = aLabelItemBuffer[0]; NETLIST_OBJECT*item = aLabelItemBuffer[0];
// Calculate item priority // Calculate item priority (initial priority)
int item_priority = 0; int item_priority = 0;
for( unsigned ii = 0; ii < 4; ii++ ) for( unsigned ii = 0; ii <= PRIO_MAX; ii++ )
{ {
if ( item->m_Type == priority_order[ii] ) if ( item->m_Type == priority_order[ii] )
{ {
...@@ -388,14 +393,9 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -388,14 +393,9 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ ) for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
{ {
NETLIST_OBJECT* candidate = aLabelItemBuffer[ii]; NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
if( candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() )
{
item = candidate;
continue;
}
// Calculate candidate priority // Calculate candidate priority
int candidate_priority = 0; int candidate_priority = 0;
for( unsigned ii = 0; ii < 4; ii++ ) for( unsigned ii = 0; ii <= PRIO_MAX; ii++ )
{ {
if ( candidate->m_Type == priority_order[ii] ) if ( candidate->m_Type == priority_order[ii] )
{ {
...@@ -404,13 +404,32 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -404,13 +404,32 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
} }
} }
if( candidate_priority > item_priority ) if( candidate_priority > item_priority )
{
printf(" prio (%d %d) ", item_priority, candidate_priority );
item = candidate; item = candidate;
item_priority = candidate_priority;
}
else if( candidate_priority == item_priority ) else if( candidate_priority == item_priority )
{ {
if( candidate->m_Label.Cmp( item->m_Label ) < 0 ) // for global labels, we select the best candidate by alphabetic order
// because they have no sheetpath as prefix name
// for other labels, we select them before by sheet deep order
// because the actual name is /sheetpath/label
// and for a given path lenght, by alphabetic order
if( ( item_priority < PRIO_MAX-1 ) && // Not a global label or pin label
candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() )
{
item = candidate; item = candidate;
printf(" path (pr %d) ", item_priority);
}
else if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
{
item = candidate;
printf(" alpha ");
}
} }
} }
return item; return item;
} }
...@@ -994,25 +1013,24 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) ...@@ -994,25 +1013,24 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
/* /*
* Search if a junction is connected to segments and include the Netcode * Search if a junction is connected to segments and propagate the junction Netcode
* objects connect to the junction. * to objects connected by the junction.
* The junction must have a valid Netcode * The junction must have a valid Netcode
* The list of objects is SUPPOSED class by NumSheet ??? Croissants, * The list of objects is expected sorted by sheets.
* And research is done from the start element, 1st element * Search is done from index aIdxStart to the last element of g_NetObjectslist
* Leaf schema
* (There can be no physical connection between elements of different sheets)
*/ */
static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, static void SegmentToPointConnect( NETLIST_OBJECT* aJonction,
int IsBus, int start ) int aIsBus, int aIdxStart )
{ {
for( unsigned i = start; i < g_NetObjectslist.size(); i++ ) for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ )
{ {
NETLIST_OBJECT* Segment = g_NetObjectslist[i]; NETLIST_OBJECT* Segment = g_NetObjectslist[i];
if( Segment->m_SheetList != Jonction->m_SheetList ) // if different sheets, no physical connection between elements is possible.
if( Segment->m_SheetList != aJonction->m_SheetList )
continue; continue;
if( IsBus == 0 ) if( aIsBus == 0 )
{ {
if( Segment->m_Type != NET_SEGMENT ) if( Segment->m_Type != NET_SEGMENT )
continue; continue;
...@@ -1023,24 +1041,24 @@ static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, ...@@ -1023,24 +1041,24 @@ static void SegmentToPointConnect( NETLIST_OBJECT* Jonction,
continue; continue;
} }
if( SegmentIntersect( Segment->m_Start, Segment->m_End, Jonction->m_Start ) ) if( SegmentIntersect( Segment->m_Start, Segment->m_End, aJonction->m_Start ) )
{ {
/* Propagation Netcode has all the objects of the same Netcode. */ /* Propagation Netcode has all the objects of the same Netcode. */
if( IsBus == 0 ) if( aIsBus == 0 )
{ {
if( Segment->GetNet() ) if( Segment->GetNet() )
PropageNetCode( Segment->GetNet(), PropageNetCode( Segment->GetNet(),
Jonction->GetNet(), IsBus ); aJonction->GetNet(), aIsBus );
else else
Segment->SetNet( Jonction->GetNet() ); Segment->SetNet( aJonction->GetNet() );
} }
else else
{ {
if( Segment->m_BusNetCode ) if( Segment->m_BusNetCode )
PropageNetCode( Segment->m_BusNetCode, PropageNetCode( Segment->m_BusNetCode,
Jonction->m_BusNetCode, IsBus ); aJonction->m_BusNetCode, aIsBus );
else else
Segment->m_BusNetCode = Jonction->m_BusNetCode; Segment->m_BusNetCode = aJonction->m_BusNetCode;
} }
} }
} }
...@@ -1072,10 +1090,11 @@ void LabelConnect( NETLIST_OBJECT* LabelRef ) ...@@ -1072,10 +1090,11 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
continue; continue;
} }
//regular labels are sheet-local; // regular labels are sheet-local;
//NET_HIERLABEL are used to connect sheets. // NET_HIERLABEL are used to connect sheets.
//NET_LABEL is sheet-local (***) // NET_LABEL is sheet-local (***)
//NET_GLOBLABEL is global. // NET_GLOBLABEL is global.
// NET_PINLABEL is a kind of global label (generated by a power pin invisible)
NetObjetType ntype = g_NetObjectslist[i]->m_Type; NetObjetType ntype = g_NetObjectslist[i]->m_Type;
if( ntype == NET_LABEL if( ntype == NET_LABEL
|| ntype == NET_GLOBLABEL || ntype == NET_GLOBLABEL
......
...@@ -240,6 +240,10 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -240,6 +240,10 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event )
int WinEDA_GerberFrame::BestZoom() int WinEDA_GerberFrame::BestZoom()
{ {
// gives a minimal value to zoom, if no item in list
if( GetBoard()->m_Drawings == NULL )
return(16 * GetScreen()->m_ZoomScalar) ;
double x, y; double x, y;
EDA_Rect bbox; EDA_Rect bbox;
...@@ -249,13 +253,14 @@ int WinEDA_GerberFrame::BestZoom() ...@@ -249,13 +253,14 @@ int WinEDA_GerberFrame::BestZoom()
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
bbox.Merge( gerb_item->GetBoundingBox() ); bbox.Merge( gerb_item->GetBoundingBox() );
} }
bbox.Inflate( GetScreen()->GetGridSize().x * 2, GetScreen()->GetGridSize().y * 2);
wxSize size = DrawPanel->GetClientSize(); wxSize size = DrawPanel->GetClientSize();
x = ( bbox.GetWidth() + GetScreen()->GetGridSize().x ) / (double) size.x; x = bbox.GetWidth() / (double) size.x;
y = ( bbox.GetHeight() + GetScreen()->GetGridSize().y ) / (double) size.y; y = bbox.GetHeight() / (double) size.y;
GetScreen()->m_Curseur = bbox.Centre(); GetScreen()->m_Curseur = bbox.Centre();
return wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ); int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ) ;
return best_zoom;
} }
/**************************************/ /**************************************/
......
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