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

Pcbnew: fix bug Bug #1101399 (Custom page size gets reset after restarting...

Pcbnew: fix bug Bug #1101399 (Custom page size gets reset after restarting pcbnew) (bug also in eeschema)
Try to find a better fix for Bug #1100876
parent 129f93b8
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) :
    m_modified = false;
    m_page_bitmap = NULL;
    m_tb = m_Parent->GetTitleBlock();
    m_customFmt = false;

    initDialog();

@@ -111,7 +112,7 @@ void DIALOG_PAGES_SETTINGS::initDialog()
    double      customSizeY;

    // initalize page format choice box and page format list.
    // The first shows translated strings, the second contains not tralated strings
    // The first shows translated strings, the second contains not translated strings
    m_paperSizeComboBox->Clear();

    for( unsigned ii = 0; ; ii++ )
@@ -146,11 +147,22 @@ void DIALOG_PAGES_SETTINGS::initDialog()
    wxCommandEvent dummy;
    OnPaperSizeChoice( dummy );

    if( m_customFmt)    // The custom value is defined by the page size
    {
        customSizeX = m_pageInfo.GetWidthMils();
        customSizeY = m_pageInfo.GetHeightMils();
    }
    else    // The custom value is set to a default value, or the last defined value
    {
        customSizeX = m_pageInfo.GetCustomWidthMils();
        customSizeY = m_pageInfo.GetCustomHeightMils();
    }

    switch( g_UserUnit )
    {
    case MILLIMETRES:
        customSizeX = m_pageInfo.GetCustomWidthMils() * 25.4e-3;
        customSizeY = m_pageInfo.GetCustomHeightMils()* 25.4e-3;
        customSizeX *= 25.4e-3;
        customSizeY *= 25.4e-3;

        msg.Printf( wxT( "%.2f" ), customSizeX );
        m_TextUserSizeX->SetValue( msg );
@@ -161,8 +173,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()

    default:
    case INCHES:
        customSizeX = m_pageInfo.GetCustomWidthMils()  / 1000.0;
        customSizeY = m_pageInfo.GetCustomHeightMils() / 1000.0;
        customSizeX /= 1000.0;
        customSizeY /= 1000.0;

        msg.Printf( wxT( "%.3f" ), customSizeX );
        m_TextUserSizeX->SetValue( msg );
@@ -172,15 +184,6 @@ void DIALOG_PAGES_SETTINGS::initDialog()
        break;
    }

#if 0
    m_TextRevision->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Revision ) );
    m_TextTitle->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Title ) );
    m_TextCompany->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Company ) );
    m_TextComment1->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire1 ) );
    m_TextComment2->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire2 ) );
    m_TextComment3->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire3 ) );
    m_TextComment4->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire4 ) );
#else
    m_TextRevision->SetValue( m_tb.GetRevision() );
    m_TextTitle->SetValue( m_tb.GetTitle() );
    m_TextCompany->SetValue( m_tb.GetCompany() );
@@ -188,7 +191,6 @@ void DIALOG_PAGES_SETTINGS::initDialog()
    m_TextComment2->SetValue( m_tb.GetComment2() );
    m_TextComment3->SetValue( m_tb.GetComment3() );
    m_TextComment4->SetValue( m_tb.GetComment4() );
#endif

#ifndef EESCHEMA
    m_RevisionExport->Show( false );
@@ -248,6 +250,7 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
        m_orientationComboBox->Enable( false );
        m_TextUserSizeX->Enable( true );
        m_TextUserSizeY->Enable( true );
        m_customFmt = true;
    }
    else
    {
@@ -261,6 +264,7 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )

        m_TextUserSizeX->Enable( false );
        m_TextUserSizeY->Enable( false );
        m_customFmt = false;
    }

    GetPageLayoutInfoFromDialog();
+2 −2
Original line number Diff line number Diff line
/*
 * This program source code file is part of KICAD, a free EDA CAD application.
 *
 * Copyright (C) 1992-2010 <Creator>
 * Copyright (C) 1992-2010 Kicad Developers, see AUTHORS.txt for contributors.
 * Copyright (C) 1992-2013 Kicad Developers, see AUTHORS.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
@@ -45,6 +44,7 @@ private:
    wxBitmap*       m_page_bitmap;      /// Temporary bitmap for the page layout example.
    wxSize          m_layout_size;      /// Logical page layout size.
    PAGE_INFO       m_pageInfo;         /// Temporary page info.
    bool            m_customFmt;        /// true if the page selection is custom
    TITLE_BLOCK     m_tb;               /// Temporary title block (basic inscriptions).

public:
+1 −4
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event )
void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
    int id = event.GetId();
    bool state = m_optionsToolBar->GetToolToggled( id );
    bool state = event.IsChecked();

    switch( id )
    {
@@ -169,16 +169,13 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
            else
                m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
        }

        break;

    case ID_TB_OPTIONS_SHOW_RATSNEST:
        SetElementVisibility( RATSNEST_VISIBLE, state );

        if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
        {
            Compile_Ratsnest( NULL, true );
        }

        m_canvas->Refresh();
        break;
+2 −13
Original line number Diff line number Diff line
@@ -834,32 +834,21 @@ void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent )
    // inside this function (seems happen on some Linux/wxWidgets versions)
    // when the other tool is selected

    int previous_state = m_autoPlaceModeId;
    switch( aEvent.GetId() )
    {
        case ID_TOOLBARH_PCB_MODE_MODULE:
            if( aEvent.IsChecked() )
            {
                m_autoPlaceModeId = ID_TOOLBARH_PCB_MODE_MODULE;

                if( previous_state == ID_TOOLBARH_PCB_MODE_TRACKS )
                    m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, false );
            }
            else if( m_autoPlaceModeId == ID_TOOLBARH_PCB_MODE_MODULE )
                // Deselect m_autoPlaceModeId only if it was selected by this tool
                // clear m_autoPlaceModeId only if it was activated by this tool
                m_autoPlaceModeId = 0;
            break;

        case ID_TOOLBARH_PCB_MODE_TRACKS:
            if( aEvent.IsChecked() )
            {
                m_autoPlaceModeId = ID_TOOLBARH_PCB_MODE_TRACKS;

                if( previous_state == ID_TOOLBARH_PCB_MODE_MODULE )
                    m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, false );
            }
            else if( m_autoPlaceModeId == ID_TOOLBARH_PCB_MODE_TRACKS )
                // Deselect m_autoPlaceModeId only if it was selected by this tool
                // clear m_autoPlaceModeId only if it was activated by this tool
                m_autoPlaceModeId = 0;
            break;
        }
+5 −10
Original line number Diff line number Diff line
@@ -113,7 +113,8 @@ void PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle( wxUpdateUIEvent& aEvent )

void PCB_EDIT_FRAME::OnUpdateDrcEnable( wxUpdateUIEvent& aEvent )
{
    aEvent.Check( !Drc_On );
    bool state = !Drc_On;
    aEvent.Check( state );
    m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF,
                                        Drc_On ?
                                        _( "Disable design rule checking" ) :
@@ -205,15 +206,12 @@ void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )


void PCB_EDIT_FRAME::OnUpdateAutoPlaceTracksMode( wxUpdateUIEvent& aEvent )
{
{return;
    // Automatic placement of modules and tracks is a mutually exclusive operation
    // So this tool is activated only if
    // m_autoPlaceModeId == ID_TOOLBARH_PCB_MODE_TRACKS.
    // To avoid creating erroneous events (seems happen on some Linux/wxWidgets versions)
    // the tool state is changed only when it is incorrect
    bool state = m_autoPlaceModeId == ID_TOOLBARH_PCB_MODE_TRACKS;
    if( aEvent.IsChecked() != state )
        aEvent.Check( state );
    m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, state );
}


@@ -222,9 +220,6 @@ void PCB_EDIT_FRAME::OnUpdateAutoPlaceModulesMode( wxUpdateUIEvent& aEvent )
    // Automatic placement of modules and tracks is a mutually exclusive operation,
    // So this tool is activated only if
    // m_autoPlaceModeId == ID_TOOLBARH_PCB_MODE_MODULE.
    // To avoid creating erroneous events (seems happen on some Linux/wxWidgets versions)
    // the tool state is changed only when it is incorrect
    bool state = m_autoPlaceModeId == ID_TOOLBARH_PCB_MODE_MODULE;
    if( aEvent.IsChecked() != state )
        aEvent.Check( state );
    m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, state );
}