Ejemplo n.º 1
0
void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
{
    EDA_DRAW_FRAME::LoadSettings( aCfg );

    // Ensure grid id is an existent grid id:
    if( (m_LastGridSizeId <= 0) ||
        (m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
        m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;

    wxString baseCfgName = GetName();

    EDA_UNITS_T userGridUnits;
    aCfg->Read( baseCfgName + UserGridUnitsEntry, ( int* )&userGridUnits, ( int )INCHES );

    double tmp;
    aCfg->Read( baseCfgName + UserGridSizeXEntry, &tmp, 0.01 );
    m_UserGridSize.x = (int) From_User_Unit( userGridUnits, tmp );

    aCfg->Read( baseCfgName + UserGridSizeYEntry, &tmp, 0.01 );
    m_UserGridSize.y = (int) From_User_Unit( userGridUnits, tmp );

    aCfg->Read( baseCfgName + DisplayPadFillEntry, &m_DisplayOptions.m_DisplayPadFill, true );
    aCfg->Read( baseCfgName + DisplayViaFillEntry, &m_DisplayOptions.m_DisplayViaFill, true );
    aCfg->Read( baseCfgName + DisplayPadNumberEntry, &m_DisplayOptions.m_DisplayPadNum, true );
    aCfg->Read( baseCfgName + DisplayModuleEdgeEntry, &m_DisplayOptions.m_DisplayModEdgeFill, true );

    long itmp;
    aCfg->Read( baseCfgName + FastGrid1Entry, &itmp, ( long )0);
    m_FastGrid1 = itmp;
    aCfg->Read( baseCfgName + FastGrid2Entry, &itmp, ( long )0);
    m_FastGrid2 = itmp;

    aCfg->Read( baseCfgName + DisplayModuleTextEntry, &m_DisplayOptions.m_DisplayModTextFill, true );
}
Ejemplo n.º 2
0
void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id )
{
    wxRealPoint new_size;
    GRID_TYPE new_grid;

    new_size.x = From_User_Unit( aUnit, size.x );
    new_size.y = From_User_Unit( aUnit, size.y );
    new_grid.m_CmdId = id;
    new_grid.m_Size = new_size;

    AddGrid( new_grid );
}
Ejemplo n.º 3
0
const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
{
    SHAPE_LINE_CHAIN rv;
    double r = GetRadius();
    double sa = GetStartAngle();
    auto c = GetCenter();
    int n;

    if( r == 0.0 )
    {
        n = 0;
    }
    else
    {
        n = GetArcToSegmentCount( r, From_User_Unit( MILLIMETRES, aAccuracy ), m_centralAngle );
    }

    for( int i = 0; i <= n ; i++ )
    {
        double a = sa + m_centralAngle * (double) i / (double) n;
        double x = c.x + r * cos( a * M_PI / 180.0 );
        double y = c.y + r * sin( a * M_PI / 180.0 );

        rv.Append( (int) x, (int) y );
    }

    return rv;
}
Ejemplo n.º 4
0
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
    double value;
    double dtmp = 0;

    // Acquire the 'right' decimal point separator
    const struct lconv* lc = localeconv();

    wxChar      decimal_point = lc->decimal_point[0];
    wxString    buf( aTextValue.Strip( wxString::both ) );

    // Convert the period in decimal point
    buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );

    // An ugly fix needed by WxWidgets 2.9.1 that sometimes
    // back to a point as separator, although the separator is the comma
    // TODO: remove this line if WxWidgets 2.9.2 fixes this issue
    buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );

    // Find the end of the numeric part
    unsigned brk_point = 0;

    while( brk_point < buf.Len() )
    {
        wxChar ch = buf[brk_point];

        if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
        {
            break;
        }

        ++brk_point;
    }

    // Extract the numeric part
    buf.Left( brk_point );

    buf.ToDouble( &dtmp );

    // Check the optional unit designator (2 ch significant)
    wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );

    if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
    {
        aUnits = INCHES;
    }
    else if( unit == wxT( "mm" ) )
    {
        aUnits = MILLIMETRES;
    }
    else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
    {
        aUnits = INCHES;
        dtmp /= 1000;
    }

    value = From_User_Unit( aUnits, dtmp );

    return KiROUND( value );
}
void DIALOG_TRACK_VIA_SIZE::onOkClick( wxCommandEvent& aEvent )
{
    if( check() )
    {
        // Store dialog values to the router settings
        m_settings.SetTrackWidth( From_User_Unit( m_trackWidth->GetUnits(), *m_trackWidth->GetValue() ) );
        m_settings.SetViaDiameter( From_User_Unit( m_viaDiameter->GetUnits(), *m_viaDiameter->GetValue() ) );
        m_settings.SetViaDrill( From_User_Unit( m_viaDrill->GetUnits(), *m_viaDrill->GetValue() ) );
        EndModal( 1 );
    }
    else
    {
        DisplayError( GetParent(), _( "Settings are incorrect" ) );
        m_trackWidth->SetFocus();
    }
}
/**
 * Function SelectCurrentFootprint
 * Selects the current footprint name and display it
 */
void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
{
    int page = m_pageList->GetSelection();

    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( !footprintWizard )
        return;

    if( page<0 )
        return;

    int             n = m_parameterGrid->GetNumberRows();
    wxArrayString   arr;
    wxArrayString   ptList = footprintWizard->GetParameterTypes( page );

    for( int i = 0; i<n; i++ )
    {
        wxString value = m_parameterGrid->GetCellValue( i, 1 );

        // if this parameter is expected to be an internal
        // unit convert it back from the user format
        if( ptList[i]==wxT( "IU" ) )
        {
            LOCALE_IO   toggle;
            double      dValue;

            value.ToDouble( &dValue );

            // convert from mils to inches where it's needed
            if( g_UserUnit==INCHES )
                dValue = dValue / 1000.0;

            dValue = From_User_Unit( g_UserUnit, dValue );
            value.Printf( wxT( "%f" ), dValue );
        }

        // If our locale is set to use , for decimal point, just change it
        // to be scripting compatible
        arr.Add( value );
    }

    wxString res = footprintWizard->SetParameterValues( page, arr );

    ReloadFootprint();
    DisplayWizardInfos();
}
Ejemplo n.º 7
0
void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
{
    int page = m_pageList->GetSelection();

    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( !footprintWizard )
        return;

    if( page < 0 )
        return;

    wxArrayString   prmValues = footprintWizard->GetParameterValues( page );
    wxArrayString   ptList = footprintWizard->GetParameterTypes( page );

    bool            has_changed = false;
    int             count = m_parameterGrid->GetNumberRows();

    // Skip extra event, useless
    if( event.GetString() == m_parameterGrid->GetCellValue( event.GetRow(), m_columnPrmValue ) )
        return;

    for( int prm_id = 0; prm_id < count; ++prm_id )
    {
        wxString value = m_parameterGrid->GetCellValue( prm_id, m_columnPrmValue );

        // if this parameter is expected to be an internal
        // unit convert it back from the user format
        if( ptList[prm_id]==wxT( "IU" ) )
        {
            // If our locale is set to use, for decimal point, just change it
            // to be scripting compatible
            LOCALE_IO   toggle;
            double      dValue;

            value.ToDouble( &dValue );

            // convert from mils to inches where it's needed
            if( g_UserUnit==INCHES )
                dValue = dValue / 1000.0;

            dValue = From_User_Unit( g_UserUnit, dValue );

            // Internal units are int. Print them as int.
            value.Printf( "%d", KiROUND( dValue ) );

            if(  prmValues[prm_id].EndsWith(".0") )
            {
                prmValues[prm_id].RemoveLast();
                prmValues[prm_id].RemoveLast();
            }
        }

        if( prmValues[prm_id] != value )
        {
            has_changed = true;
            prmValues[prm_id] = value;
        }
    }

    if( has_changed )
    {
        wxString res = footprintWizard->SetParameterValues( page, prmValues );

        if( !res.IsEmpty() )
            wxMessageBox( res );

        ReloadFootprint();
        DisplayWizardInfos();
    }
}