Exemplo n.º 1
0
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
{
    if( m_pageList == NULL )
        return;

    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( !footprintWizard )
        return;

    m_pageList->Clear();
    int max_page = footprintWizard->GetNumParameterPages();

    for( int i = 0; i<max_page; i++ )
    {
        wxString name = footprintWizard->GetParameterPageName( i );
        m_pageList->Append( name );
    }

    m_pageList->SetSelection( 0, true );

    ReCreateParameterList();
    ReCreateHToolbar();
    DisplayWizardInfos();
    m_canvas->Refresh();
}
void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
{
    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( !footprintWizard )
        return;

    SetCurItem( NULL );
    // Delete the current footprint
    GetBoard()->m_Modules.DeleteAll();

    // Creates the module
    MODULE* module = footprintWizard->GetModule();

    if( module )
    {
        //  Add the object to board
        module->SetParent( (EDA_ITEM*) GetBoard() );
        GetBoard()->m_Modules.Append( module );
        module->SetPosition( wxPoint( 0, 0 ) );
    }
    else
    {
        DBG(printf( "footprintWizard->GetModule() returns NULL\n" );)
    }

    m_canvas->Refresh();
}
void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
{
    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( !footprintWizard )
        return;

    SetCurItem( NULL );
    // Delete the current footprint
    GetBoard()->m_Modules.DeleteAll();

    // Creates the module
    wxString msg;
    MODULE* module = footprintWizard->GetFootprint( &msg );
    DisplayBuildMessage( msg );

    if( module )
    {
        //  Add the object to board
        GetBoard()->Add( module, ADD_APPEND );
        module->SetPosition( wxPoint( 0, 0 ) );
    }
    else
    {
        DBG(printf( "footprintWizard->GetFootprint() returns NULL\n" );)
    }

    m_canvas->Refresh();
}
/**
 * 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();
}
Exemplo n.º 5
0
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{
    if( m_parameterGrid == NULL )
        return;

    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( footprintWizard == NULL )
        return;

    int page = m_pageList->GetSelection();

    if( page<0 )
        return;

    m_parameterGrid->ClearGrid();


    // Rows
    m_parameterGrid->AutoSizeRows();
    m_parameterGrid->EnableDragRowSize( true );
    m_parameterGrid->SetRowLabelSize( 1 );
    m_parameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );

    // Get the list of names, values, and types
    wxArrayString   fpList  = footprintWizard->GetParameterNames( page );
    wxArrayString   fvList  = footprintWizard->GetParameterValues( page );
    wxArrayString   ptList  = footprintWizard->GetParameterTypes( page );

    // Dimension the wxGrid
    m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
    m_parameterGrid->AppendRows( fpList.size() );

    wxString name, value, units;
    for( unsigned int i = 0; i<fpList.size(); i++ )
    {
        name    = fpList[i];
        value   = fvList[i];

        m_parameterGrid->SetCellValue( i, 0, name );
        m_parameterGrid->SetReadOnly( i, 0 );

        if( ptList[i]==wxT( "IU" ) )
        {
            LOCALE_IO toggle;

            // We are handling internal units, so convert them to the current
            // system selected units and store into value.
            double dValue;

            value.ToDouble( &dValue );

            dValue = To_User_Unit( g_UserUnit, dValue );

            if( g_UserUnit==INCHES )    // we convert inches into mils for more detail
            {
                dValue  = dValue * 1000.0;
                units   = wxT( "mils" );
            }
            else if( g_UserUnit==MILLIMETRES )
            {
                units = wxT( "mm" );
            }

            std::string s = Double2Str( dValue );
            value = FROM_UTF8( s.c_str() );
        }
        else if( ptList[i]==wxT( "UNITS" ) )    // 1,2,3,4,5 ... N
        {
            units = wxT( "" );
        }

        m_parameterGrid->SetCellValue( i, 1, value );
        m_parameterGrid->SetCellValue( i, 2, units );
        m_parameterGrid->SetReadOnly( i, 2 );
    }

    m_parameterGrid->AutoSizeColumns();
}
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();
    }
}
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{
    if( m_parameterGrid == NULL )
        return;

    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();

    if( footprintWizard == NULL )
        return;

    int page = m_pageList->GetSelection();

    if( page<0 )
        return;

    m_parameterGrid->ClearGrid();

    // Get the list of names, values, and types
    wxArrayString   fpList  = footprintWizard->GetParameterNames( page );
    wxArrayString   fvList  = footprintWizard->GetParameterValues( page );
    wxArrayString   ptList  = footprintWizard->GetParameterTypes( page );

    // Dimension the wxGrid
    if( m_parameterGrid->GetNumberRows() > 0 )
        m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );

    m_parameterGrid->AppendRows( fpList.size() );

    wxString value, units;
    for( unsigned int i = 0; i< fpList.size(); i++ )
    {
        value   = fvList[i];

        m_parameterGrid->SetCellValue( i, m_columnPrmName, fpList[i] );
        m_parameterGrid->SetReadOnly( i, m_columnPrmName );

        if( ptList[i]==wxT( "IU" ) )
        {
            LOCALE_IO toggle;

            // We are handling internal units, so convert them to the current
            // system selected units and store into value.
            double dValue;

            value.ToDouble( &dValue );

            dValue = To_User_Unit( g_UserUnit, dValue );

            if( g_UserUnit==INCHES )    // we convert inches into mils for more detail
            {
                dValue  = dValue * 1000.0;
                units   = wxT( "mils" );
            }
            else if( g_UserUnit==MILLIMETRES )
            {
                units = wxT( "mm" );
            }

            // Use Double2Str to build the string, because useless trailing 0
            // are removed. The %f format does not remove them
            std::string s = Double2Str( dValue );
            value = FROM_UTF8( s.c_str() );
        }
        else if( ptList[i]==wxT( "UNITS" ) )    // 1,2,3,4,5 ... N
        {
            units = wxT( "" );
        }

        m_parameterGrid->SetCellValue( i, m_columnPrmValue, value );
        m_parameterGrid->SetCellValue( i, m_columnPrmUnit, units );
        m_parameterGrid->SetReadOnly( i, m_columnPrmUnit );
    }

    m_parameterGrid->AutoSizeColumns();
}