From ee9e9b84c4e10b0d18d97e21eb96575fdfd2c290 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 7 Nov 2010 21:06:07 +0100 Subject: [PATCH 1/2] minors enhancements and minor code cleanup --- cvpcb/class_DisplayFootprintsFrame.cpp | 1 + cvpcb/class_footprints_listbox.cpp | 49 ++++++++++---------------- cvpcb/cvframe.cpp | 34 +++++++++++++++--- cvpcb/cvstruct.h | 34 +++--------------- cvpcb/init.cpp | 14 +++----- cvpcb/listboxes.cpp | 5 ++- cvpcb/menucfg.cpp | 1 + cvpcb/tool_cvpcb.cpp | 1 + eeschema/class_library.cpp | 5 ++- eeschema/eelibs_read_libraryfiles.cpp | 4 +-- eeschema/menubar.cpp | 7 ++-- eeschema/netlist.cpp | 33 +++++++++-------- 12 files changed, 86 insertions(+), 102 deletions(-) diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 9bfda9872e..707a442fe3 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -14,6 +14,7 @@ #include "protos.h" #include "cvstruct.h" #include "class_DisplayFootprintsFrame.h" +#include "cvpcb_id.h" /* * NOTE: There is something in 3d_viewer.h that causes a compiler error in diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 98f051dd3d..fe2318e89f 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -23,7 +23,7 @@ FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( WinEDA_CvpcbFrame* parent, { m_UseFootprintFullList = true; m_ActiveFootprintList = NULL; - SetActiveFootprintList( TRUE ); + SetActiveFootprintList( true ); } @@ -61,8 +61,8 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint() if( ii >= 0 ) { wxString msg = (*m_ActiveFootprintList)[ii]; - msg.Trim( TRUE ); - msg.Trim( FALSE ); + msg.Trim( true ); + msg.Trim( false ); FootprintName = msg.AfterFirst( wxChar( ' ' ) ); } @@ -121,11 +121,11 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) m_FullFootprintList.Add( msg ); } - SetActiveFootprintList( TRUE ); + SetActiveFootprintList( true ); if( ( GetCount() == 0 ) || ( OldSelection < 0 ) || ( OldSelection >= GetCount() ) ) - SetSelection( 0, TRUE ); + SetSelection( 0, true ); Refresh(); } @@ -137,7 +137,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, wxString msg; unsigned jj; int OldSelection = GetSelection(); - bool HasItem = FALSE; + bool HasItem = false; m_FilteredFootprintList.Clear(); @@ -150,17 +150,17 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1, footprint.m_Module.GetData() ); m_FilteredFootprintList.Add( msg ); - HasItem = TRUE; + HasItem = true; } } if( HasItem ) - SetActiveFootprintList( FALSE ); + SetActiveFootprintList( false ); else - SetActiveFootprintList( TRUE ); + SetActiveFootprintList( true ); if( ( GetCount() == 0 ) || ( OldSelection >= GetCount() ) ) - SetSelection( 0, TRUE ); + SetSelection( 0, true ); Refresh(); } @@ -189,49 +189,35 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) { bool new_selection; if( FullList ) - new_selection = TRUE; + new_selection = true; else - new_selection = FALSE; + new_selection = false; if( new_selection != old_selection ) - SetSelection( 0, TRUE ); + SetSelection( 0, true ); } #endif if( FullList ) { - m_UseFootprintFullList = TRUE; + m_UseFootprintFullList = true; m_ActiveFootprintList = &m_FullFootprintList; SetItemCount( m_FullFootprintList.GetCount() ); } else { - m_UseFootprintFullList = FALSE; + m_UseFootprintFullList = false; m_ActiveFootprintList = &m_FilteredFootprintList; SetItemCount( m_FilteredFootprintList.GetCount() ); } if( Redraw ) { - if( !m_UseFootprintFullList - || ( m_UseFootprintFullList != old_selection ) ) + if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) ) { Refresh(); } } - if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) ) - { - 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 ); + GetParent()->DisplayStatus(); } @@ -253,6 +239,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) wxString FootprintName = GetSelectedFootprint(); Module = GetModuleDescrByName( FootprintName, GetParent()->m_footprints ); + wxASSERT(Module); if( GetParent()->DrawFrame ) { GetParent()->CreateScreenCmp(); /* refresh general */ diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index f9906ad871..1f00830749 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -16,6 +16,7 @@ #include "cvstruct.h" #include "dialog_cvpcb_config.h" #include "class_DisplayFootprintsFrame.h" +#include "cvpcb_id.h" #include "build_version.h" @@ -115,7 +116,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, m_KeepCvpcbOpen = false; m_undefinedComponentCnt = 0; - /* Name of the document footprint list * usually located in share/modules/footprints_doc * this is of the responsibility to users to create this file @@ -422,9 +422,7 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event ) m_undefinedComponentCnt = m_components.size(); } - Line.Printf( _( "Components: %d (free: %d)" ), m_components.size(), - m_components.size() ); - SetStatusText( Line, 1 ); + DisplayStatus(); } @@ -557,6 +555,7 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event ) m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_footprints ); + DisplayStatus(); } @@ -585,3 +584,30 @@ void WinEDA_CvpcbFrame::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event ) { 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 ); +} diff --git a/cvpcb/cvstruct.h b/cvpcb/cvstruct.h index fce18885fd..b38b1ba87d 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/cvstruct.h @@ -16,36 +16,6 @@ class COMPONENTS_LISTBOX; 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. @@ -120,6 +90,10 @@ public: void SaveProjectFile( const wxString& fileName ); virtual void LoadSettings(); virtual void SaveSettings(); + /** DisplayStatus() + * Displays info to the status line at bottom of the main frame + */ + void DisplayStatus(); PARAM_CFG_ARRAY& GetProjectFileParameters( void ); diff --git a/cvpcb/init.cpp b/cvpcb/init.cpp index b07aa561b9..ec5392ab51 100644 --- a/cvpcb/init.cpp +++ b/cvpcb/init.cpp @@ -24,7 +24,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) COMPONENT* Component; bool isUndefined = false; int NumCmp; - wxString Line; + wxString msg; if( m_components.empty() ) return; @@ -45,7 +45,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) Component->m_Module = package; - Line.Printf( CMP_FORMAT, NumCmp + 1, + msg.Printf( CMP_FORMAT, NumCmp + 1, GetChars( Component->m_Reference ), GetChars( Component->m_Value ), GetChars( Component->m_Module ) ); @@ -54,7 +54,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) if( isUndefined ) m_undefinedComponentCnt -= 1; - m_ListCmp->SetString( NumCmp, Line ); + m_ListCmp->SetString( NumCmp, msg ); m_ListCmp->SetSelection( NumCmp, FALSE ); // We activate next component: @@ -62,9 +62,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) NumCmp++; m_ListCmp->SetSelection( NumCmp, TRUE ); - Line.Printf( _( "Components: %d (free: %d)" ), - m_components.size(), m_undefinedComponentCnt ); - SetStatusText( Line, 1 ); + DisplayStatus(); } @@ -112,9 +110,7 @@ bool WinEDA_CvpcbFrame::ReadNetList() if( !m_components.empty() ) m_ListCmp->SetSelection( 0, TRUE ); - msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(), - m_undefinedComponentCnt ); - SetStatusText( msg, 1 ); + DisplayStatus(); /* Update the title of the main window. */ SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index ba5722955f..fb1c6a652a 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -9,6 +9,7 @@ #include "cvpcb.h" #include "protos.h" #include "cvstruct.h" +#include "cvpcb_id.h" /****************************************************************************** @@ -122,7 +123,5 @@ void WinEDA_CvpcbFrame::BuildFOOTPRINTS_LISTBOX() } m_FootprintList->SetFootprintFullList( m_footprints ); - - msg.Printf( _( "Footprints: %d" ), m_FootprintList->GetCount() ); - SetStatusText( msg, 2 ); + DisplayStatus(); } diff --git a/cvpcb/menucfg.cpp b/cvpcb/menucfg.cpp index f1b0b913a3..12335eeaf3 100644 --- a/cvpcb/menucfg.cpp +++ b/cvpcb/menucfg.cpp @@ -10,6 +10,7 @@ #include "cvpcb.h" #include "cvstruct.h" +#include "cvpcb_id.h" #include "bitmaps.h" diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp index 70a7172e66..de32cbb684 100644 --- a/cvpcb/tool_cvpcb.cpp +++ b/cvpcb/tool_cvpcb.cpp @@ -11,6 +11,7 @@ #include "cvpcb.h" #include "protos.h" #include "cvstruct.h" +#include "cvpcb_id.h" void WinEDA_CvpcbFrame::ReCreateHToolbar() diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 711269c3b6..c6d0093ae7 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -485,9 +485,8 @@ the current schematic." ), { versionMajor = (int) major; versionMinor = (int) minor; - - wxLogDebug( wxT( "Component library <%s> is version %d.%d." ), - GetChars( GetName() ), versionMajor, versionMinor ); +// wxLogDebug( wxT( "Component library <%s> is version %d.%d." ), +// GetChars( GetName() ), versionMajor, versionMinor ); } } diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index b1de95346c..3c0f9c367a 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -104,8 +104,8 @@ void WinEDA_SchematicFrame::LoadLibraries( void ) CMP_LIBRARY::SetSortOrder( sortOrder ); CMP_LIBRARY::GetLibraryList().sort(); -#ifdef __WXDEBUG__ - wxLogDebug( wxT( "LoadLibraries () requested component library sort order:" ) ); +#if 0 // #ifdef __WXDEBUG__ + wxLogDebug( wxT( "LoadLibraries() requested component library sort order:" ) ); for( size_t i = 0; i < sortOrder.GetCount(); i++ ) wxLogDebug( wxT( " " ) + sortOrder[i] ); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index ed7ec136be..a499cb7156 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -305,13 +305,14 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* 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" ), - wxITEM_NORMAL ); + HELP_PLACE_GLOBALLABEL, wxITEM_NORMAL ); item->SetBitmap( add_glabel_xpm ); placeMenu->Append( item ); /* 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 ); item->SetBitmap( add_junction_xpm ); placeMenu->Append( item ); diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index a5bc380a6c..26c7805266 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -994,25 +994,24 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) /* - * Search if a junction is connected to segments and include the Netcode - * objects connect to the junction. + * Search if a junction is connected to segments and propagate the junction Netcode + * to objects connected by the junction. * The junction must have a valid Netcode - * The list of objects is SUPPOSED class by NumSheet ??? Croissants, - * And research is done from the start element, 1st element - * Leaf schema - * (There can be no physical connection between elements of different sheets) + * The list of objects is expected sorted by sheets. + * Search is done from index aIdxStart to the last element of g_NetObjectslist */ -static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, - int IsBus, int start ) +static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, + 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]; - 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; - if( IsBus == 0 ) + if( aIsBus == 0 ) { if( Segment->m_Type != NET_SEGMENT ) continue; @@ -1023,24 +1022,24 @@ static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, 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. */ - if( IsBus == 0 ) + if( aIsBus == 0 ) { if( Segment->GetNet() ) PropageNetCode( Segment->GetNet(), - Jonction->GetNet(), IsBus ); + aJonction->GetNet(), aIsBus ); else - Segment->SetNet( Jonction->GetNet() ); + Segment->SetNet( aJonction->GetNet() ); } else { if( Segment->m_BusNetCode ) PropageNetCode( Segment->m_BusNetCode, - Jonction->m_BusNetCode, IsBus ); + aJonction->m_BusNetCode, aIsBus ); else - Segment->m_BusNetCode = Jonction->m_BusNetCode; + Segment->m_BusNetCode = aJonction->m_BusNetCode; } } } From 9cc346ea6128c62757ea3583f7be0b1978b4ce5d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 7 Nov 2010 21:40:19 +0100 Subject: [PATCH 2/2] add forgotten file --- cvpcb/cvpcb_id.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cvpcb/cvpcb_id.h diff --git a/cvpcb/cvpcb_id.h b/cvpcb/cvpcb_id.h new file mode 100644 index 0000000000..c7e0301582 --- /dev/null +++ b/cvpcb/cvpcb_id.h @@ -0,0 +1,34 @@ +/** + * @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 +};