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

Pcbnew: better display of tracks/vias/grid in toolbar. All: modify the zoom...

Pcbnew: better display of tracks/vias/grid in toolbar. All: modify the zoom value shown in toolbar or status bar (roughly now zoom 1.0 is near the 1:1 scale, on a 22 inches Monitor). Fix also many other minor and very minor issues
parents f5059ec4 ad74a9a1
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -165,6 +165,51 @@ bool BASE_SCREEN::SetPreviousZoom()
    return false;
}

/* Build the list of human readable grid list.
 * The list shows the grid size both in mils or mm.
 * aMmFirst = true to have mm first and mils after
 *            false to have mils first and mm after
 */
int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst) const
{
    wxString msg;
    wxRealPoint curr_grid_size = GetGridSize();
    int idx = -1;
    int idx_usergrid = -1;

    for( size_t i = 0; i < GetGridCount(); i++ )
    {
        const GRID_TYPE& grid = m_grids[i];
        double gridValueMils = To_User_Unit( INCHES, grid.m_Size.x ) * 1000;
        double gridValue_mm = To_User_Unit( MILLIMETRES, grid.m_Size.x );

        if( grid.m_Id == ID_POPUP_GRID_USER )
        {
            msg = _( "User Grid" );
            idx_usergrid = i;
        }
        else
        {
            if( aMmFirst )
                msg.Printf( _( "Grid: %.4f mm (%.2f mils)" ),
                            gridValue_mm, gridValueMils );
            else
                msg.Printf( _( "Grid: %.2f mils (%.4f mm)" ),
                            gridValueMils, gridValue_mm );
        }

        aGridsList.Add( msg );

        if( curr_grid_size == grid.m_Size )
            idx = i;
    }

    if( idx < 0 )
        idx = idx_usergrid;

    return idx;
}


void BASE_SCREEN::SetGridList( GRIDS& gridlist )
{
+18 −10
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
    m_snapToGrid          = true;
    m_MsgFrameHeight      = EDA_MSG_PANEL::GetRequiredHeight();
    m_movingCursorWithKeyboard = false;
    m_zoomLevelCoeff      = 1.0;

    m_auimgr.SetFlags(wxAUI_MGR_DEFAULT|wxAUI_MGR_LIVE_RESIZE);

@@ -613,16 +614,7 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )

void EDA_DRAW_FRAME::UpdateStatusBar()
{
    wxString        Line;
    BASE_SCREEN*    screen = GetScreen();

    if( !screen )
        return;

    // Display Zoom level: zoom = zoom_coeff/ZoomScalar
    Line.Printf( wxT( "Z %g" ), screen->GetZoom() );

    SetStatusText( Line, 1 );
    SetStatusText( GetZoomLevelIndicator(), 1 );

    // Absolute and relative cursor positions are handled by overloading this function and
    // handling the internal to user units conversion at the appropriate level.
@@ -631,6 +623,22 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
    DisplayUnitsMsg();
}

const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
{
    BASE_SCREEN*    screen = GetScreen();
    wxString Line;

    if( screen )
    {
        // returns a human readable value which can be displayed as zoom
        // level indicator in dialogs.
        double level =  m_zoomLevelCoeff / (double)screen->GetZoom();
        Line.Printf( wxT( "Z %.2f" ), level );
    }

    return Line;
}


void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
{
+9 −36
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
    // Populate zoom submenu.
    for( int i = 0; i < maxZoomIds; i++ )
    {
        msg.Printf( wxT( "%g" ), screen->m_ZoomList[i] );
        msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );

        zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
                             wxEmptyString, wxITEM_CHECK );
@@ -266,43 +266,16 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
        AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
                     _( "Grid Select" ), KiBitmap( grid_select_xpm ) );

        GRID_TYPE   tmp;
        wxRealPoint grid = screen->GetGridSize();
        wxArrayString gridsList;
        int icurr = screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES );

        for( size_t i = 0; i < screen->GetGridCount(); i++ )
        for( unsigned i = 0; i < gridsList.GetCount(); i++ )
        {
            tmp = screen->GetGrid( i );
            double gridValueInch = To_User_Unit( INCHES, tmp.m_Size.x );
            double gridValue_mm = To_User_Unit( MILLIMETRES, tmp.m_Size.x );
            GRID_TYPE& grid = screen->GetGrid( i );
            gridMenu->Append( grid.m_Id, gridsList[i], wxEmptyString, true );

            if( tmp.m_Id == ID_POPUP_GRID_USER )
            {
                msg = _( "User Grid" );
            }
            else
            {
                switch( g_UserUnit )
                {
                case INCHES:
                    msg.Printf( wxT( "%.1f mils, (%.4f mm)" ),
                                gridValueInch * 1000, gridValue_mm );
                    break;

                case MILLIMETRES:
                    msg.Printf( wxT( "%.4f mm, (%.1f mils)" ),
                                gridValue_mm, gridValueInch * 1000 );
                    break;

                case UNSCALED_UNITS:
                    msg = wxT( "???" );
                    break;
                }
            }

            gridMenu->Append( tmp.m_Id, msg, wxEmptyString, true );

            if( grid == tmp.m_Size )
                gridMenu->Check( tmp.m_Id, true );
            if( (int)i == icurr )
                gridMenu->Check( grid.m_Id, true );
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
    EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition,
            aSize, aStyle, aFrameName )
{
    m_zoomLevelCoeff = 11.0;     // Adjusted to roughly displays zoom level = 1
                                // when the screen shows a 1:1 image
                                // obviously depends on the monitor,
                                // but this is an acceptable value
}


@@ -64,6 +68,10 @@ SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const
    return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen();
}

const wxString SCH_BASE_FRAME::GetZoomLevelIndicator() const
{
    return EDA_DRAW_FRAME::GetZoomLevelIndicator();
}

void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{
+3 −11
Original line number Diff line number Diff line
@@ -57,21 +57,13 @@

#define EESCHEMA_FILE_STAMP   "EESchema"

/* Default Eeschema zoom values. Limited to 17 values to keep a decent size
/* Default zoom values. Limited to these values to keep a decent size
 * to menus
 */
/* Please, note: wxMSW before version 2.9 seems have
 * problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
 * edit file <wxWidgets>/src/msw/dc.cpp
 * search for line static const int VIEWPORT_EXTENT = 1000;
 * and replace by static const int VIEWPORT_EXTENT = 10000;
 * see http://trac.wxwidgets.org/ticket/9554
 * This is a workaround that is not a full fix, but remaining artifacts are acceptable
 */
static double SchematicZoomList[] =
{
    0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0,
    12.0, 16.0, 23.0, 32.0, 48.0, 64.0, 80.0, 128.0
    0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 11.0,
    13.0, 16.0, 20.0, 26.0, 32.0, 48.0, 64.0, 80.0, 128.0
};

#define MM_TO_SCH_UNITS 1000.0 / 25.4       //schematic internal unites are mils
Loading