Commit 7559e134 authored by dickelbeck's avatar dickelbeck

specctra_export: add support for dsn outline

parent 923ece9c
......@@ -5,6 +5,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Feb-22 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
specctra_export.cpp: added DSN 'outline' support from EDGE_MODULEs.
lines and circles, not arcs.
factored out EDGE_MODULE::ShowShape() from EDGE_MODULE::Show().
2008-Feb-21 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
......@@ -18,7 +27,6 @@ email address.
- incorrect annotation in complex hierarchy with multi parts per package (duplicates created).
2008-Feb-20 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
......
......@@ -540,18 +540,13 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos )
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void EDGE_MODULE::Show( int nestLevel, std::ostream& os )
const char* EDGE_MODULE::ShowShape( int aShape )
{
const char* cp;
switch( m_Shape )
switch( aShape )
{
case S_SEGMENT: cp = "line"; break;
case S_RECT: cp = "rect"; break;
......@@ -565,6 +560,21 @@ void EDGE_MODULE::Show( int nestLevel, std::ostream& os )
default: cp = "??EDGE??"; break;
}
return cp;
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void EDGE_MODULE::Show( int nestLevel, std::ostream& os )
{
const char* cp = ShowShape( m_Shape );
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" type=\"" << cp << "\">";
......
......@@ -103,5 +103,13 @@ public:
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
/**
* Function ShowShape
* converts the enum Track_Shapes integer value to a C string.
*/
static const char* ShowShape( int aShape );
#endif
};
......@@ -693,6 +693,11 @@ public:
layer_id = aLayerId;
}
void SetAperture( double aWidth )
{
aperture_width = aWidth;
}
void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{
const char* newline = nestLevel ? "\n" : "";
......@@ -1883,6 +1888,11 @@ class SHAPE : public WINDOW
WINDOWS windows;
public:
/**
* Constructor SHAPE
* alternatively takes a DSN_T aType of T_outline
*/
SHAPE( ELEM* aParent, DSN_T aType = T_shape ) :
WINDOW( aParent, aType )
{
......
......@@ -545,21 +545,21 @@ typedef std::map<wxString, int, wxString_less_than> PINMAP;
IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
{
PINMAP pinmap;
TYPE_COLLECTOR pads;
TYPE_COLLECTOR moduleItems;
wxString padName;
// get all the MODULE's pads.
pads.Collect( aModule, scanPADs );
moduleItems.Collect( aModule, scanPADs );
IMAGE* image = new IMAGE(0);
image->image_id = CONV_TO_UTF8( aModule->m_LibRef );
// from the pads, and make an IMAGE using collated padstacks.
for( int p=0; p<pads.GetCount(); ++p )
for( int p=0; p<moduleItems.GetCount(); ++p )
{
D_PAD* pad = (D_PAD*) pads[p];
D_PAD* pad = (D_PAD*) moduleItems[p];
// see if this pad is a through hole with no copper on its perimeter
if( isKeepout( pad ) )
......@@ -636,6 +636,67 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
}
}
static const KICAD_T scanEDGEs[] = { TYPEEDGEMODULE, EOT };
// get all the MODULE's EDGE_MODULEs and convert those to DSN outlines.
moduleItems.Collect( aModule, scanEDGEs );
for( int i=0; i<moduleItems.GetCount(); ++i )
{
EDGE_MODULE* graphic = (EDGE_MODULE*) moduleItems[i];
SHAPE* outline;
PATH* path;
switch( graphic->m_Shape )
{
case S_SEGMENT:
outline = new SHAPE( image, T_outline );
image->Append( outline );
path = new PATH( outline );
outline->SetShape( path );
path->SetAperture( scale( graphic->m_Width ) );
path->SetLayerId( "signal" );
path->AppendPoint( mapPt( graphic->m_Start0 ) );
path->AppendPoint( mapPt( graphic->m_End0 ) );
break;
case S_CIRCLE:
{
// this is best done by 4 QARC's but freerouter does not yet support QARCs.
// for now, support by using line segments.
outline = new SHAPE( image, T_outline );
image->Append( outline );
path = new PATH( outline );
outline->SetShape( path );
path->SetAperture( scale( graphic->m_Width ) );
path->SetLayerId( "signal" );
double radius = hypot( scale( graphic->m_Start.x - graphic->m_End.x ),
scale( graphic->m_Start.y - graphic->m_End.y ) );
POINT offset = mapPt( graphic->m_Start0 );
// better if evenly divisible into 360
const int DEGREE_INTERVAL = 18; // 18 means 20 line segments
for( double radians = 0.0; radians < 2*M_PI; radians += DEGREE_INTERVAL * M_PI / 180.0 )
{
POINT point( radius*cos( radians ), radius*sin( radians ) );
point += offset;
path->AppendPoint( point );
}
}
break;
case S_RECT:
case S_ARC:
default:
D( printf("makeIMAGE(): unsupported shape %s\n", EDGE_MODULE::ShowShape(graphic->m_Shape) );)
continue;
}
}
return image;
}
......
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