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

Cvpcb: code cleaning and minot fix

parent c5869705
...@@ -34,6 +34,14 @@ public: ...@@ -34,6 +34,14 @@ public:
void OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent ); void OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent ); void OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent );
/**
* Function InitDisplay
* Refresh the full display for this frame:
* Set the title, the status line and redraw the canvas
* Must be called after the footprint to display is modifed
*/
void InitDisplay();
/** /**
* Function IsGridVisible() , virtual * Function IsGridVisible() , virtual
* @return true if the grid must be shown * @return true if the grid must be shown
......
...@@ -30,82 +30,78 @@ ...@@ -30,82 +30,78 @@
*/ */
void CVPCB_MAINFRAME::CreateScreenCmp() void CVPCB_MAINFRAME::CreateScreenCmp()
{ {
wxString msg, FootprintName;
bool IsNew = false;
FootprintName = m_FootprintList->GetSelectedFootprint();
if( m_DisplayFootprintFrame == NULL ) if( m_DisplayFootprintFrame == NULL )
{ {
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ), m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ), wxPoint( 0, 0 ),
wxSize( 600, 400 ), wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE ); KICAD_DEFAULT_DRAWFRAME_STYLE );
IsNew = true;
m_DisplayFootprintFrame->Show( true ); m_DisplayFootprintFrame->Show( true );
} }
else else
{ {
// Raising the window does not show the window on Windows if iconized.
// This should work on any platform.
if( m_DisplayFootprintFrame->IsIconized() ) if( m_DisplayFootprintFrame->IsIconized() )
m_DisplayFootprintFrame->Iconize( false ); m_DisplayFootprintFrame->Iconize( false );
m_DisplayFootprintFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != m_DisplayFootprintFrame )
m_DisplayFootprintFrame->SetFocus();
} }
if( !FootprintName.IsEmpty() ) m_DisplayFootprintFrame->InitDisplay();
}
/* Refresh the full display for this frame:
* Set the title, the status line and redraw the canvas
* Must be called after the footprint to display is modifed
*/
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
wxString msg;
CVPCB_MAINFRAME * parentframe = (CVPCB_MAINFRAME *) GetParent();
wxString footprintName = parentframe->m_FootprintList->GetSelectedFootprint();
if( !footprintName.IsEmpty() )
{ {
msg = _( "Footprint: " ) + FootprintName; msg = _( "Footprint: " ) + footprintName;
m_DisplayFootprintFrame->SetTitle( msg ); SetTitle( msg );
FOOTPRINT_INFO* Module = m_footprints.GetModuleInfo( FootprintName ); FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
msg = _( "Lib: " ); msg = _( "Lib: " );
if( Module ) if( module_info )
msg += Module->m_LibName; msg += module_info->m_LibName;
else else
msg += wxT( "???" ); msg += wxT( "???" );
m_DisplayFootprintFrame->SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() ) if( GetBoard()->m_Modules.GetCount() )
{ {
// there is only one module in the list // there is only one module in the list
m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
} }
MODULE* mod = m_DisplayFootprintFrame->Get_Module( FootprintName ); MODULE* module = Get_Module( footprintName );
if( mod )
m_DisplayFootprintFrame->GetBoard()->m_Modules.PushBack( mod );
m_DisplayFootprintFrame->Zoom_Automatique( false ); if( module )
m_DisplayFootprintFrame->GetCanvas()->Refresh(); GetBoard()->m_Modules.PushBack( module );
// Display new cursor coordinates and zoom value: Zoom_Automatique( false );
m_DisplayFootprintFrame->UpdateStatusBar();
if( m_DisplayFootprintFrame->m_Draw3DFrame )
m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
} }
else if( !IsNew ) // No footprint to display. Erase old footprint, if any else // No footprint to display. Erase old footprint, if any
{ {
if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() ) if( GetBoard()->m_Modules.GetCount() )
{ {
m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
m_DisplayFootprintFrame->Zoom_Automatique( false ); Zoom_Automatique( false );
m_DisplayFootprintFrame->SetStatusText( wxEmptyString, 0 ); SetStatusText( wxEmptyString, 0 );
m_DisplayFootprintFrame->UpdateStatusBar(); }
} }
m_DisplayFootprintFrame->Refresh(); // Display new cursor coordinates and zoom value:
UpdateStatusBar();
if( m_DisplayFootprintFrame->m_Draw3DFrame ) GetCanvas()->Refresh();
m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
} if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
} }
/* /*
......
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