Commit f0ba106e authored by dickelbeck's avatar dickelbeck
Browse files

more amazing free software

parent 70fde0fd
Loading
Loading
Loading
Loading
+42 −36
Original line number Original line Diff line number Diff line
@@ -5,6 +5,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
Please add newer entries at the top, list the date and your name with
email address.
email address.


2008-Feb-7 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
    specctra import of *.ses, done by end of today probably.


2008-Feb-6 UPDATE   Dick Hollenbeck <dick@softplc.com>
2008-Feb-6 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
+pcbnew
+pcbnew
+497 −484
Original line number Original line Diff line number Diff line
@@ -3590,6 +3590,15 @@ ELEM::~ELEM()
}
}




UNIT_RES* ELEM::GetUnits() const
{
    if( parent )
        return parent->GetUnits();

    return &UNIT_RES::Default;
}


void ELEM::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
void ELEM::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{
{
    out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) );
    out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) );
@@ -3624,6 +3633,10 @@ int ELEM_HOLDER::FindElem( DSN_T aType, int instanceNum )
    return -1;
    return -1;
}
}


//-----<UNIT_RES>---------------------------------------------------------

UNIT_RES UNIT_RES::Default( NULL, T_resolution );



//-----<PADSTACK>---------------------------------------------------------
//-----<PADSTACK>---------------------------------------------------------


+611 −612
Original line number Original line Diff line number Diff line
@@ -276,6 +276,8 @@ struct PROPERTY
typedef std::vector<PROPERTY>       PROPERTIES;
typedef std::vector<PROPERTY>       PROPERTIES;




class UNIT_RES;

/**
/**
 * Class ELEM
 * Class ELEM
 * is a base class for any DSN element class.
 * is a base class for any DSN element class.
@@ -285,8 +287,6 @@ class ELEM
{
{
    friend class SPECCTRA_DB;
    friend class SPECCTRA_DB;



    
protected:
protected:
    DSN_T           type;
    DSN_T           type;
    ELEM*           parent;
    ELEM*           parent;
@@ -325,16 +325,9 @@ public:
     * Function GetUnits
     * Function GetUnits
     * returns the units for this section.  Derived classes may override this
     * returns the units for this section.  Derived classes may override this
     * to check for section specific overrides.
     * to check for section specific overrides.
     * @return DSN_T - one of the allowed values to &lt;unit_descriptor&gt;
     * @return UNIT_RES* - from a local or parent scope
     */
     */
    virtual DSN_T   GetUnits() const
    virtual UNIT_RES* GetUnits() const;
    {
        if( parent )
            return parent->GetUnits();
        
        return T_inch;
    }



    /**
    /**
     * Function Format
     * Function Format
@@ -501,6 +494,14 @@ class UNIT_RES : public ELEM
    int         value;
    int         value;


public:
public:

    /**
     * A static instance which holds the default units of T_inch and 2540000.
     * See page 108 of the specctra spec, May 2000.
     */
    static UNIT_RES Default;


    UNIT_RES( ELEM* aParent, DSN_T aType ) :
    UNIT_RES( ELEM* aParent, DSN_T aType ) :
        ELEM( aType, aParent )
        ELEM( aType, aParent )
    {
    {
@@ -508,6 +509,9 @@ public:
        value = 2540000;
        value = 2540000;
    }
    }


    DSN_T   GetEngUnits() const  { return units; }
    int     GetValue() const  { return value; }

    void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
    void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
    {
    {
        if( type == T_unit )
        if( type == T_unit )
@@ -518,11 +522,6 @@ public:
            out->Print( nestLevel, "(%s %s %d)\n", LEXER::GetTokenText( Type() ),
            out->Print( nestLevel, "(%s %s %d)\n", LEXER::GetTokenText( Type() ),
                       LEXER::GetTokenText(units), value );
                       LEXER::GetTokenText(units), value );
    }
    }
    
    DSN_T   GetUnits() const
    {
        return units;
    }
};
};




@@ -1644,10 +1643,10 @@ public:
            i->Format( out, nestLevel );
            i->Format( out, nestLevel );
    }
    }


    DSN_T   GetUnits() const
    UNIT_RES* GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        return ELEM::GetUnits();
        return ELEM::GetUnits();
    }
    }
@@ -1844,10 +1843,10 @@ public:
            i->Format( out, nestLevel );
            i->Format( out, nestLevel );
    }
    }


    DSN_T   GetUnits() const
    UNIT_RES* GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        return ELEM::GetUnits();
        return ELEM::GetUnits();
    }
    }
@@ -2071,10 +2070,10 @@ public:
    }
    }




    DSN_T   GetUnits() const
    UNIT_RES* GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        return ELEM::GetUnits();
        return ELEM::GetUnits();
    }
    }
@@ -2182,10 +2181,10 @@ public:
    }
    }




    DSN_T   GetUnits() const
    UNIT_RES* GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        return ELEM::GetUnits();
        return ELEM::GetUnits();
    }
    }
@@ -2354,10 +2353,10 @@ public:
            i->Format( out, nestLevel );
            i->Format( out, nestLevel );
    }
    }


    DSN_T   GetUnits() const
    UNIT_RES* GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        return ELEM::GetUnits();
        return ELEM::GetUnits();
    }
    }
@@ -3027,10 +3026,10 @@ public:
            i->Format( out, nestLevel );
            i->Format( out, nestLevel );
    }
    }


    DSN_T   GetUnits() const
    UNIT_RES*  GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        return ELEM::GetUnits();
        return ELEM::GetUnits();
    }
    }
@@ -3112,10 +3111,10 @@ public:
        out->Print( nestLevel, ")\n" );
        out->Print( nestLevel, ")\n" );
    }
    }


    DSN_T   GetUnits() const
    UNIT_RES*  GetUnits() const
    {
    {
        if( unit )
        if( unit )
            return unit->GetUnits();
            return unit;


        if( resolution )
        if( resolution )
            return resolution->GetUnits();
            return resolution->GetUnits();
+92 −51
Original line number Original line Diff line number Diff line
@@ -42,18 +42,23 @@ using namespace DSN;


void WinEDA_PcbFrame::ImportSpecctraDesign( wxCommandEvent& event )
void WinEDA_PcbFrame::ImportSpecctraDesign( wxCommandEvent& event )
{
{
    /* @todo write this someday

    if( !Clear_Pcb( true ) )
    if( !Clear_Pcb( true ) )
        return;
        return;
    */
}
}




void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
{
{
/*
    if( GetScreen()->IsModify() )
    if( GetScreen()->IsModify() )
    {
    {
        if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
        if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
            return;
            return;
    }
    }
*/


    wxString sessionExt( wxT( ".ses" ) );
    wxString sessionExt( wxT( ".ses" ) );
    wxString fileName = GetScreen()->m_FileName;
    wxString fileName = GetScreen()->m_FileName;
@@ -84,12 +89,12 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
    }
    }
    catch( IOError ioe )
    catch( IOError ioe )
    {
    {
        setlocale( LC_NUMERIC, "" );    // Switch the locale to standard C 
        setlocale( LC_NUMERIC, "" );    // revert to the current locale
        DisplayError( this, ioe.errorText );
        DisplayError( this, ioe.errorText );
        return;
        return;
    }
    }


    setlocale( LC_NUMERIC, "" );    // Switch the locale to standard C 
    setlocale( LC_NUMERIC, "" );    // revert to the current locale


    m_SelTrackWidthBox_Changed = TRUE;
    m_SelTrackWidthBox_Changed = TRUE;
    m_SelViaSizeBox_Changed    = TRUE;
    m_SelViaSizeBox_Changed    = TRUE;
@@ -103,18 +108,43 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
}
}





namespace DSN {
namespace DSN {




static wxPoint mapPt( const POINT& aPoint, double aResolution )
static wxPoint mapPt( const POINT& aPoint, UNIT_RES* aResolution )
{
{
    wxPoint ret;
    wxPoint ret;


    double  resValue = aResolution->GetValue();

    double  factor;     // multiply this times units to get mils for Kicad.

    switch( aResolution->GetEngUnits() )
    {
    default:
    case T_inch:
        factor = 0.001;
        break;
    case T_mil:
        factor = 1.0;
        break;
    case T_cm:
        factor = 2.54/1000.0;
        break;
    case T_mm:
        factor = 25.4/1000.0;
        break;
    case T_um:
        factor = 25.4;
        break;
    }

    // the factor of 10.0 is used to convert mils to deci-mils, the units
    // the factor of 10.0 is used to convert mils to deci-mils, the units
    // used within Kicad.
    // used within Kicad.
    ret.x = (int)  (10.0 * aPoint.x / aResolution);
    factor *= 10.0;
    ret.y = (int) -(10.0 * aPoint.y / aResolution);

    ret.x = (int)  (factor * aPoint.x / resValue);
    ret.y = (int) -(factor * aPoint.y / resValue);  // negate y coord


    return ret;
    return ret;
}
}
@@ -161,17 +191,16 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
            MODULE* module = aBoard->FindModuleByReference( reference );
            MODULE* module = aBoard->FindModuleByReference( reference );
            if( !module )
            if( !module )
            {
            {
                wxString errorMsg;
                ThrowIOError(
                errorMsg.Printf( 
                   _("Session file has 'reference' to non-existent component \"%s\""),
                   _("Session file has reference to non-existing component \"%s\""), 
                   reference.GetData() );
                   reference.GetData() );
                ThrowIOError( errorMsg );
            }
            }


            if( !place->hasVertex )
            if( !place->hasVertex )
                continue;
                continue;


            double resolution = 100; //place->GetResolution();
            UNIT_RES* resolution = place->GetUnits();
            wxASSERT( resolution );


            wxPoint newPos = mapPt( place->vertex, resolution );
            wxPoint newPos = mapPt( place->vertex, resolution );
            module->SetPosition( newPos );
            module->SetPosition( newPos );
@@ -180,19 +209,29 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
            {
            {
                // convert from degrees to tenths of degrees used in Kicad.
                // convert from degrees to tenths of degrees used in Kicad.
                int orientation = (int) (place->rotation * 10.0);
                int orientation = (int) (place->rotation * 10.0);
                module->SetOrientation( orientation ); 


                if( module->GetLayer() != CMP_N )
                if( module->GetLayer() != CMP_N )
                {
                    // module is on copper layer (back)
                    aBoard->Change_Side_Module( module, 0 );
                    aBoard->Change_Side_Module( module, 0 );
                }
                }
                module->SetOrientation( orientation );
            }
            else if( place->side == T_back )
            else if( place->side == T_back )
            {
            {
                int orientation = (int) (-place->rotation * 10.0 - 1800);
                int orientation = (place->rotation + 180.0) * 10.0;
                module->SetOrientation( orientation );
                
                if( module->GetLayer() != COPPER_LAYER_N )
                if( module->GetLayer() != COPPER_LAYER_N )
                {
                    // module is on component layer (front)
                    aBoard->Change_Side_Module( module, 0 );
                    aBoard->Change_Side_Module( module, 0 );
                }
                }
                module->SetOrientation( orientation );
            }
            else
            {
                // as I write this, the LEXER *is* catching this, so we should never see below:
                wxFAIL_MSG( wxT("DSN::LEXER did not catch an illegal side := 'back|front'") );
            }
        }
        }
    }
    }


@@ -201,6 +240,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
    for( NET_OUTS::iterator i=net_outs.begin();  i!=net_outs.end();  ++i )
    for( NET_OUTS::iterator i=net_outs.begin();  i!=net_outs.end();  ++i )
    {
    {
        // create a track or via and position it.
        // create a track or via and position it.


    }
    }
}
}


+246 −246

File changed.

Contains only whitespace changes.