From e23512d8158875964f53f2d846aaf2e477fdf169 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 18 Dec 2011 21:22:16 +0100 Subject: [PATCH] Cvpcb: fix incorrect behavior when clicking on a component --- cvpcb/cvframe.cpp | 56 +++++++++++++++++++++++++++++------------ cvpcb/cvpcb_mainframe.h | 8 ++++++ cvpcb/setvisu.cpp | 33 ++++++++---------------- 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index fe9c178614..05cda00dd4 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -500,36 +500,47 @@ void CVPCB_MAINFRAME::OnLeftDClick( wxListEvent& event ) } +/* Called when clicking on a component in component list window + * * Updates the filtered foorprint list, if the filtered list option is selected + * * Updates the current selected footprint in footprint list + * * Updates the footprint shown in footprint display window (if opened) + */ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) { - int selection; + #define REDRAW_LIST true + #define SELECT_FULL_LIST true + int selection = -1; if( !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) + m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); + + else { - m_FootprintList->SetActiveFootprintList( true, true ); - return; + selection = m_ListCmp->GetSelection(); + + if( selection < 0 ) + m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); + + else + { + if( &m_components[ selection ] == NULL ) + m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); + else + m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], + m_footprints ); + } } selection = m_ListCmp->GetSelection(); if( selection < 0 ) - { - m_FootprintList->SetActiveFootprintList( true, true ); return; - } - - if( &m_components[ selection ] == NULL ) - { - m_FootprintList->SetActiveFootprintList( true, true ); - return; - } - - m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_footprints ); // Preview of the already assigned footprint. // Find the footprint that was already choosen for this component and select it. wxString module = *(&m_components[ selection ].m_Module); + bool found = false; for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ ) { wxString footprintName; @@ -539,10 +550,23 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) footprintName = msg.AfterFirst( wxChar( ' ' ) ); if( module.Cmp( footprintName ) == 0 ) + { m_FootprintList->SetSelection( ii, true ); - else - m_FootprintList->SetSelection( ii, false ); + found = true; + break; + } } + if( ! found ) + { + int ii = m_FootprintList->GetSelection(); + if ( ii >= 0 ) + m_FootprintList->SetSelection( ii, false ); + if( m_DisplayFootprintFrame ) + { + CreateScreenCmp(); + } + } + SendMessageToEESCHEMA(); DisplayStatus(); diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index bbe2125631..06ad0246b0 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -54,6 +54,14 @@ public: void OnLeftClick( wxListEvent& event ); void OnLeftDClick( wxListEvent& event ); + + /** + * Function OnSelectComponent + * Called when clicking on a component in component list window + * * Updates the filtered foorprint list, if the filtered list option is selected + * * Updates the current selected footprint in footprint list + * * Updates the footprint shown in footprint display window (if opened) + */ void OnSelectComponent( wxListEvent& event ); void OnQuit( wxCommandEvent& event ); diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index 795fd6218b..ae7d7d28e3 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -84,13 +84,22 @@ void CVPCB_MAINFRAME::CreateScreenCmp() m_DisplayFootprintFrame->Zoom_Automatique( false ); m_DisplayFootprintFrame->DrawPanel->Refresh(); - m_DisplayFootprintFrame->UpdateStatusBar(); /* Display new cursor coordinates and zoom value */ + // Display new cursor coordinates and zoom value: + m_DisplayFootprintFrame->UpdateStatusBar(); if( m_DisplayFootprintFrame->m_Draw3DFrame ) m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay(); } - else if( !IsNew ) + else if( !IsNew ) // No footprint to display. Erase old footprint, if any { + if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() ) + { + m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll(); + m_DisplayFootprintFrame->Zoom_Automatique( false ); + m_DisplayFootprintFrame->SetStatusText( wxEmptyString, 0 ); + m_DisplayFootprintFrame->UpdateStatusBar(); + } + m_DisplayFootprintFrame->Refresh(); if( m_DisplayFootprintFrame->m_Draw3DFrame ) @@ -98,8 +107,6 @@ void CVPCB_MAINFRAME::CreateScreenCmp() } } - - /* * Draws the current highlighted footprint. */ @@ -131,21 +138,3 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin m_Modules->Draw( aPanel, aDC, GR_COPY ); } } - -/* dummy_functions: - * - * These functions are used in some classes. - * they are useful in Pcbnew, but have no meaning or are never used - * in CvPcb or GerbView. - * but they must exist because they appear in some classes. - * Do nothing in CvPcb. - */ -TRACK* MarkTrace( BOARD* aPcb, - TRACK* aStartSegm, - int* aSegmCount, - int* aTrackLen, - int* aLenDie, - bool aReorder ) -{ - return NULL; -}