Commit f0ba106e authored by dickelbeck's avatar dickelbeck

more amazing free software

parent 70fde0fd
......@@ -5,6 +5,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
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>
================================================================================
+pcbnew
......
......@@ -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 )
{
out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) );
......@@ -3624,6 +3633,10 @@ int ELEM_HOLDER::FindElem( DSN_T aType, int instanceNum )
return -1;
}
//-----<UNIT_RES>---------------------------------------------------------
UNIT_RES UNIT_RES::Default( NULL, T_resolution );
//-----<PADSTACK>---------------------------------------------------------
......
......@@ -276,6 +276,8 @@ struct PROPERTY
typedef std::vector<PROPERTY> PROPERTIES;
class UNIT_RES;
/**
* Class ELEM
* is a base class for any DSN element class.
......@@ -285,8 +287,6 @@ class ELEM
{
friend class SPECCTRA_DB;
protected:
DSN_T type;
ELEM* parent;
......@@ -325,16 +325,9 @@ public:
* Function GetUnits
* returns the units for this section. Derived classes may override this
* 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
{
if( parent )
return parent->GetUnits();
return T_inch;
}
virtual UNIT_RES* GetUnits() const;
/**
* Function Format
......@@ -501,6 +494,14 @@ class UNIT_RES : public ELEM
int value;
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 ) :
ELEM( aType, aParent )
{
......@@ -508,6 +509,9 @@ public:
value = 2540000;
}
DSN_T GetEngUnits() const { return units; }
int GetValue() const { return value; }
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{
if( type == T_unit )
......@@ -518,11 +522,6 @@ public:
out->Print( nestLevel, "(%s %s %d)\n", LEXER::GetTokenText( Type() ),
LEXER::GetTokenText(units), value );
}
DSN_T GetUnits() const
{
return units;
}
};
......@@ -1644,10 +1643,10 @@ public:
i->Format( out, nestLevel );
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
return ELEM::GetUnits();
}
......@@ -1844,10 +1843,10 @@ public:
i->Format( out, nestLevel );
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
return ELEM::GetUnits();
}
......@@ -2071,10 +2070,10 @@ public:
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
return ELEM::GetUnits();
}
......@@ -2182,10 +2181,10 @@ public:
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
return ELEM::GetUnits();
}
......@@ -2354,10 +2353,10 @@ public:
i->Format( out, nestLevel );
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
return ELEM::GetUnits();
}
......@@ -3027,10 +3026,10 @@ public:
i->Format( out, nestLevel );
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
return ELEM::GetUnits();
}
......@@ -3112,10 +3111,10 @@ public:
out->Print( nestLevel, ")\n" );
}
DSN_T GetUnits() const
UNIT_RES* GetUnits() const
{
if( unit )
return unit->GetUnits();
return unit;
if( resolution )
return resolution->GetUnits();
......
......@@ -42,18 +42,23 @@ using namespace DSN;
void WinEDA_PcbFrame::ImportSpecctraDesign( wxCommandEvent& event )
{
/* @todo write this someday
if( !Clear_Pcb( true ) )
return;
*/
}
void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
{
/*
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
return;
}
*/
wxString sessionExt( wxT( ".ses" ) );
wxString fileName = GetScreen()->m_FileName;
......@@ -84,12 +89,12 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
}
catch( IOError ioe )
{
setlocale( LC_NUMERIC, "" ); // Switch the locale to standard C
setlocale( LC_NUMERIC, "" ); // revert to the current locale
DisplayError( this, ioe.errorText );
return;
}
setlocale( LC_NUMERIC, "" ); // Switch the locale to standard C
setlocale( LC_NUMERIC, "" ); // revert to the current locale
m_SelTrackWidthBox_Changed = TRUE;
m_SelViaSizeBox_Changed = TRUE;
......@@ -103,18 +108,43 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
}
namespace DSN {
static wxPoint mapPt( const POINT& aPoint, double aResolution )
static wxPoint mapPt( const POINT& aPoint, UNIT_RES* aResolution )
{
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
// used within Kicad.
ret.x = (int) (10.0 * aPoint.x / aResolution);
ret.y = (int) -(10.0 * aPoint.y / aResolution);
factor *= 10.0;
ret.x = (int) (factor * aPoint.x / resValue);
ret.y = (int) -(factor * aPoint.y / resValue); // negate y coord
return ret;
}
......@@ -161,17 +191,16 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
MODULE* module = aBoard->FindModuleByReference( reference );
if( !module )
{
wxString errorMsg;
errorMsg.Printf(
_("Session file has reference to non-existing component \"%s\""),
ThrowIOError(
_("Session file has 'reference' to non-existent component \"%s\""),
reference.GetData() );
ThrowIOError( errorMsg );
}
if( !place->hasVertex )
continue;
double resolution = 100; //place->GetResolution();
UNIT_RES* resolution = place->GetUnits();
wxASSERT( resolution );
wxPoint newPos = mapPt( place->vertex, resolution );
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.
int orientation = (int) (place->rotation * 10.0);
module->SetOrientation( orientation );
if( module->GetLayer() != CMP_N )
{
// module is on copper layer (back)
aBoard->Change_Side_Module( module, 0 );
}
module->SetOrientation( orientation );
}
else if( place->side == T_back )
{
int orientation = (int) (-place->rotation * 10.0 - 1800);
module->SetOrientation( orientation );
int orientation = (place->rotation + 180.0) * 10.0;
if( module->GetLayer() != COPPER_LAYER_N )
{
// module is on component layer (front)
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 )
{
// create a track or via and position it.
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment