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

Cvpcb: code cleaning and minot fix

parent c5869705
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,14 @@ public:
    void OnUpdateTextDrawMode( 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
     * @return true if the grid must be shown
+38 −42
Original line number Diff line number Diff line
@@ -30,82 +30,78 @@
 */
void CVPCB_MAINFRAME::CreateScreenCmp()
{
    wxString msg, FootprintName;
    bool     IsNew = false;

    FootprintName = m_FootprintList->GetSelectedFootprint();

    if( m_DisplayFootprintFrame == NULL )
    {
        m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
                                                  wxPoint( 0, 0 ),
                                                  wxSize( 600, 400 ),
                                                  KICAD_DEFAULT_DRAWFRAME_STYLE );
        IsNew = true;
        m_DisplayFootprintFrame->Show( true );
    }
    else
    {
        // Raising the window does not show the window on Windows if iconized.
        // This should work on any platform.
        if( m_DisplayFootprintFrame->IsIconized() )
             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();
    m_DisplayFootprintFrame->InitDisplay();
}

    if( !FootprintName.IsEmpty() )
/* 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()
{
        msg = _( "Footprint: " ) + FootprintName;
        m_DisplayFootprintFrame->SetTitle( msg );
        FOOTPRINT_INFO* Module = m_footprints.GetModuleInfo( FootprintName );
    wxString msg;
    CVPCB_MAINFRAME * parentframe = (CVPCB_MAINFRAME *) GetParent();
    wxString footprintName = parentframe->m_FootprintList->GetSelectedFootprint();

    if( !footprintName.IsEmpty() )
    {
        msg = _( "Footprint: " ) + footprintName;
        SetTitle( msg );
        FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
        msg = _( "Lib: " );

        if( Module )
            msg += Module->m_LibName;
        if( module_info )
            msg += module_info->m_LibName;
        else
            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
            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 );
        if( module )
            GetBoard()->m_Modules.PushBack( module );

        m_DisplayFootprintFrame->Zoom_Automatique( false );
        m_DisplayFootprintFrame->GetCanvas()->Refresh();
        Zoom_Automatique( false );

        // Display new cursor coordinates and zoom value:
        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();
            m_DisplayFootprintFrame->Zoom_Automatique( false );
            m_DisplayFootprintFrame->SetStatusText( wxEmptyString, 0 );
            m_DisplayFootprintFrame->UpdateStatusBar();
            GetBoard()->m_Modules.DeleteAll();
            Zoom_Automatique( false );
            SetStatusText( wxEmptyString, 0 );
        }
    }

        m_DisplayFootprintFrame->Refresh();
    // Display new cursor coordinates and zoom value:
    UpdateStatusBar();

        if( m_DisplayFootprintFrame->m_Draw3DFrame )
            m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
    }
    GetCanvas()->Refresh();

    if( m_Draw3DFrame )
        m_Draw3DFrame->NewDisplay();
}

/*