Commit 2b215d81 authored by dickelbeck's avatar dickelbeck

amazing free specctra software

parent dd141c17
......@@ -6,6 +6,21 @@ Please add newer entries at the top, list the date and your name with
email address.
2008-Feb-11 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
* Added case TYPETRACK, TYPEVIA, and TYPEMODULE support to Board::Add() so
that we can over time hide more of the storage architecture of a BOARD and
isolate those dependencies in fewer places.
* Fixed some pad orientation issues in specctra_export.
* Added VIA_MICROVIA & VIA_BLIND_BURIED support to SPECCTRA::makeVIA().
* Commented out the specctra design import menu choice for now, don't have
time or need for this import.
* Specctra export adds 1/2 mil to clearance rules for freerouter so that
the routed board clears our DRC checker OK.
* Session import seems done now.
2008-Feb-7 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
......
......@@ -20,7 +20,8 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC )
/* Restitution d'un element (MODULE ou TRACK ) Efface
*/
{
EDA_BaseStruct* PtStruct, * PtNext;
BOARD_ITEM* item;
BOARD_ITEM* next;
TRACK* pt_track;
int net_code;
......@@ -28,25 +29,25 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC )
return;
g_UnDeleteStackPtr--;
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr];
if( PtStruct == NULL )
item = g_UnDeleteStack[g_UnDeleteStackPtr];
if( item == NULL )
return; // Ne devrait pas se produire
switch( PtStruct->Type() )
switch( item->Type() )
{
case TYPEVIA:
case TYPETRACK:
for( ; PtStruct != NULL; PtStruct = PtNext )
for( ; item; item = next )
{
PtNext = PtStruct->Pnext;
PtStruct->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
Trace_Segment( DrawPanel, DC, (TRACK*) PtStruct, GR_OR );
next = item->Next();
item->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
Trace_Segment( DrawPanel, DC, (TRACK*) item, GR_OR );
}
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ( (TRACK*) PtStruct )->GetNet();
pt_track = ( (TRACK*) PtStruct )->GetBestInsertPoint( m_Pcb );
( (TRACK*) PtStruct )->Insert( m_Pcb, pt_track );
item = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ((TRACK*) item)->GetNet();
m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
break;
......
......@@ -142,6 +142,26 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem );
break;
case TYPETRACK:
case TYPEVIA:
{
TRACK* insertAid = ((TRACK*)aBoardItem)->GetBestInsertPoint( this );
((TRACK*)aBoardItem)->Insert( this, insertAid );
}
break;
case TYPEMODULE:
// this is an insert, not an append which may also be needed.
{
aBoardItem->Pback = this;
BOARD_ITEM* next = m_Modules;
aBoardItem->Pnext = next;
if( next )
next->Pback = aBoardItem;
m_Modules = (MODULE*) aBoardItem;
}
break;
// other types may use linked list
default:
wxFAIL_MSG( wxT("BOARD::Add() needs work") );
......
......@@ -71,6 +71,8 @@ public:
* @param aControl An int which can vary how the item is added.
*/
void Add( BOARD_ITEM* aBoardItem, int aControl = 0 );
#define ADD_APPEND 1 ///< aControl flag for Add( aControl ), appends not inserts
/**
* Function Delete
......
......@@ -150,7 +150,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_ViaDrill = 250; // defualt via drill (for the entire board)
m_ViaDrillCustomValue = 250; // via drill for vias which must have a defined drill value
m_CurrentViaSize = 450; // Current via size
m_CurrentViaType = VIA_THROUGH; // via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA)
m_CurrentViaType = VIA_THROUGH; // via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA)
m_CurrentTrackWidth = 170; // current track width
m_UseConnectedTrackWidth = false; // if true, when creating a new track starting on an existing track, use this track width
m_MicroViaDrill = 50; // micro via drill (for the entire board)
......
......@@ -387,7 +387,6 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
* Routine de fin de trace d'une piste (succession de segments)
*/
{
TRACK* pt_track;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
wxPoint pos;
EDA_BaseStruct* LockPoint;
......@@ -453,11 +452,8 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
/* Test if no segment left. Can happend on a double click on the start point */
if( g_FirstTrackSegment != NULL )
{
/* Put new track in buffer: search the best insertion poinr */
pt_track = g_FirstTrackSegment->GetBestInsertPoint( m_Pcb );
/* Uut track in linked list */
g_FirstTrackSegment->Insert( m_Pcb, pt_track );
// Put new track in board
m_Pcb->Add( g_FirstTrackSegment );
trace_ratsnest_pad( DC );
Trace_Une_Piste( DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR );
......@@ -466,7 +462,8 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
TRACK* ptr = g_FirstTrackSegment; int ii;
for( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount); ii++ )
{
ptr->m_Flags = 0; ptr = ptr->Next();
ptr->m_Flags = 0;
ptr = ptr->Next();
}
/* Delete the old track, if exists */
......
......@@ -126,10 +126,12 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
item->SetBitmap(export_xpm); // @todo need better bitmap
submenuImport->Append(item);
/* would be implemented in WinEDA_PcbFrame::ImportSpecctraDesign() in specctra_import.cpp
item = new wxMenuItem(submenuImport, ID_GEN_IMPORT_SPECCTRA_DESIGN,
_("&Specctra Design"), _("Import a \"Specctra Design\" (*.dsn) file") );
item->SetBitmap(export_xpm); // @todo need better bitmap
submenuImport->Append(item);
*/
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuImport,
ID_GEN_IMPORT_FILE, _("Import"), _("Import files"), export_xpm);
......
......@@ -1082,8 +1082,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
/* recherche de la zone de rangement et insertion de la nouvelle piste */
pt_track = g_FirstTrackSegment->GetBestInsertPoint( pcbframe->m_Pcb );
g_FirstTrackSegment->Insert( pcbframe->m_Pcb, pt_track );
pcbframe->m_Pcb->Add( g_FirstTrackSegment );
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR );
......
......@@ -3760,7 +3760,12 @@ class SPECCTRA_DB : public OUTPUTFORMATTER
TRACK* makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IOError );
SEGVIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode );
/**
* Function makeVIA
* instantiates a Kicad SEGVIA on the heap and initializes it with internal
* values consistent with the given PADSTACK, POINT, and netcode.
*/
SEGVIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IOError );
//-----</FromSESSION>----------------------------------------------------
......
......@@ -37,6 +37,8 @@
#include "wxPcbStruct.h" // Change_Side_Module()
#include "pcbstruct.h" // HISTORY_NUMBER
#include "autorout.h" // NET_CODES_OK
#include "trigo.h" // RotatePoint()
#include <set> // std::set
......@@ -351,8 +353,38 @@ IMAGE* SPECCTRA_DB::makeIMAGE( MODULE* aModule )
pin->padstack_id = padstack->padstack_id;
pin->pin_id = CONV_TO_UTF8( pad->ReturnStringPadName() );
#if 0
if( pad->m_Orient )
{
int angle = pad->m_Orient - aModule->m_Orient; // tenths of degrees
NORMALIZE_ANGLE_POS(angle);
pin->SetRotation( angle / 10.0 );
}
#else
{
int angle = pad->m_Orient - aModule->m_Orient; // tenths of degrees
if( angle )
{
NORMALIZE_ANGLE_POS(angle);
pin->SetRotation( angle / 10.0 );
}
}
#endif
wxPoint pos;
int angle = pad->m_Orient - aModule->m_Orient; // tenths of degrees
if( angle && (pad->m_Offset.x || pad->m_Offset.y) )
{
wxPoint offset( pad->m_Offset.x, pad->m_Offset.y );
RotatePoint( &offset, angle );
pos = pad->m_Pos0 + offset;
}
else
{
// copper shape's position is hole position + offset
wxPoint pos = pad->m_Pos0 + pad->m_Offset;
pos = pad->m_Pos0 + pad->m_Offset;
}
pin->SetVertex( mapPt( pos ) );
}
......@@ -385,8 +417,8 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia )
circle->SetLayerId( "signal" );
snprintf( name, sizeof(name), "Via_%.6g:%.6g_mil", dsnDiameter,
// encode the drill value in the name for later import
snprintf( name, sizeof(name), "Via[A]%.6g:%.6g_mil", dsnDiameter,
// encode the drill value into the name for later import
scale( aVia->GetDrillValue() ) );
name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name );
......@@ -418,7 +450,7 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia )
snprintf( name, sizeof(name), "Via[%d-%d]_%.6g:%.6g_mil",
topLayer, botLayer, dsnDiameter,
// encode the drill value in the name for later import
// encode the drill value into the name for later import
scale( aVia->GetDrillValue() )
);
name[ sizeof(name)-1 ] = 0;
......@@ -446,8 +478,8 @@ PADSTACK* SPECCTRA_DB::makeVia( int aCopperDiameter, int aDrillDiameter )
circle->SetLayerId( "signal" );
snprintf( name, sizeof(name), "Via_%.6g:%.6g_mil", dsnDiameter,
// encode the drill value in the name for later import
snprintf( name, sizeof(name), "Via[A]%.6g:%.6g_mil", dsnDiameter,
// encode the drill value into the name for later import
scale( aDrillDiameter ) );
name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name );
......
......@@ -150,6 +150,14 @@ static int scale( double distance, UNIT_RES* aResolution )
return ret;
}
/**
* Function mapPt
* translates a point from the Specctra Session format coordinate system
* to the Kicad coordinate system.
* @param aPoint The session point to translate
* @return wxPoint - The Kicad coordinate system point.
*/
static wxPoint mapPt( const POINT& aPoint, UNIT_RES* aResolution )
{
wxPoint ret( scale( aPoint.x, aResolution ),
......@@ -182,16 +190,14 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro
}
SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode )
SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IOError )
{
SEGVIA* via = 0;
SHAPE* shape;
int shapeCount = aPadstack->Length();
int drillDiam = -1;
int viaDiam = 400;
// @todo this needs a lot of work yet, it is not complete yet.
int copperLayerCount = sessionBoard->GetCopperLayerCount();
// The drill diameter is encoded in the padstack name if PCBNEW did the DSN export.
......@@ -200,15 +206,16 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
if( drillStartNdx != -1 )
{
++drillStartNdx; // skip over the ':'
int drillEndNdx = aPadstack->padstack_id.rfind( '_' );
if( drillEndNdx != -1 )
{
std::string diamTxt( aPadstack->padstack_id, drillStartNdx+1, drillEndNdx-drillStartNdx-1 );
std::string diamTxt( aPadstack->padstack_id, drillStartNdx, drillEndNdx-drillStartNdx );
const char* sdiamTxt = diamTxt.c_str();
double drillMils = strtod( sdiamTxt, 0 );
// drillMils is not in the session units, but actual mils so we don't use scale()
drillDiam = drillMils * 10;
drillDiam = (int) (drillMils * 10);
if( drillDiam == g_DesignSettings.m_ViaDrill ) // default
drillDiam = -1; // import as default
......@@ -217,14 +224,18 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
if( shapeCount == 0 )
{
ThrowIOError( _( "Session via padstack has no shapes") );
}
else if( shapeCount == 1 )
{
shape = (SHAPE*) (*aPadstack)[0];
if( shape->shape->Type() == T_circle )
{
DSN_T type = shape->shape->Type();
if( type != T_circle )
ThrowIOError( _( "Unsupported via shape: \"%s\""),
LEXER::GetTokenString( type ).GetData() );
CIRCLE* circle = (CIRCLE*) shape->shape;
viaDiam = scale( circle->diameter, routeResolution );
int viaDiam = scale( circle->diameter, routeResolution );
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
......@@ -233,14 +244,16 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
via->m_Width = viaDiam;
via->SetLayerPair( CMP_N, COPPER_LAYER_N );
}
}
else if( shapeCount == sessionBoard->GetCopperLayerCount() )
else if( shapeCount == copperLayerCount )
{
shape = (SHAPE*) (*aPadstack)[0];
if( shape->shape->Type() == T_circle )
{
DSN_T type = shape->shape->Type();
if( type != T_circle )
ThrowIOError( _( "Unsupported via shape: \"%s\""),
LEXER::GetTokenString( type ).GetData() );
CIRCLE* circle = (CIRCLE*) shape->shape;
viaDiam = scale( circle->diameter, routeResolution );
int viaDiam = scale( circle->diameter, routeResolution );
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
......@@ -249,6 +262,56 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
via->m_Width = viaDiam;
via->SetLayerPair( CMP_N, COPPER_LAYER_N );
}
else // VIA_MICROVIA or VIA_BLIND_BURIED
{
int topLayerNdx = -1;
int botLayerNdx = 7000;
int viaDiam = -1;
for( int i=0; i<shapeCount; ++i )
{
shape = (SHAPE*) (*aPadstack)[i];
DSN_T type = shape->shape->Type();
if( type != T_circle )
ThrowIOError( _( "Unsupported via shape: \"%s\""),
LEXER::GetTokenString( type ).GetData() );
CIRCLE* circle = (CIRCLE*) shape->shape;
int layerNdx = findLayerName( circle->layer_id );
if( layerNdx == -1 )
{
wxString layerName = CONV_FROM_UTF8( circle->layer_id.c_str() );
ThrowIOError( _("Session file uses invalid layer id \"%s\""),
layerName.GetData() );
}
if( layerNdx > topLayerNdx )
topLayerNdx = layerNdx;
if( layerNdx < botLayerNdx )
botLayerNdx = layerNdx;
if( viaDiam == -1 )
viaDiam = scale( circle->diameter, routeResolution );
}
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
if( (topLayerNdx==0 && botLayerNdx==1)
|| (topLayerNdx==copperLayerCount-2 && botLayerNdx==copperLayerCount-1))
via->m_Shape = VIA_MICROVIA;
else
via->m_Shape = VIA_BLIND_BURIED;
via->m_Width = viaDiam;
topLayerNdx = pcbLayer2kicad[topLayerNdx];
botLayerNdx = pcbLayer2kicad[botLayerNdx];
via->SetLayerPair( topLayerNdx, botLayerNdx );
}
if( via )
......@@ -365,7 +428,6 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
// else netCode remains 0
}
WIRES& wires = net->wires;
for( unsigned i=0; i<wires.size(); ++i )
{
......@@ -386,9 +448,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
for( unsigned pt=0; pt<path->points.size()-1; ++pt )
{
TRACK* track = makeTRACK( path, pt, netCode );
TRACK* insertAid = track->GetBestInsertPoint( aBoard );
track->Insert( aBoard, insertAid );
aBoard->Add( track );
}
}
......@@ -428,12 +488,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
for( unsigned v=0; v<wire_via->vertexes.size(); ++v )
{
SEGVIA* via = makeVIA( padstack, wire_via->vertexes[v], netCode );
if( !via )
ThrowIOError( _("Unable to make a via") );
TRACK* insertAid = via->GetBestInsertPoint( aBoard );
via->Insert( aBoard, insertAid );
aBoard->Add( via );
}
}
}
......
......@@ -21,33 +21,33 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
/* Restitution d'un element (MODULE ou TRACK ) Efface
*/
{
BOARD_ITEM* PtStruct, * PtNext;
TRACK* pt_track;
BOARD_ITEM* item;
BOARD_ITEM* next;
int net_code;
if( !g_UnDeleteStackPtr )
return;
g_UnDeleteStackPtr--;
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr];
if( PtStruct == NULL )
item = g_UnDeleteStack[g_UnDeleteStackPtr];
if( item == NULL )
return; // Ne devrait pas se produire
switch( PtStruct->Type() )
switch( item->Type() )
{
case TYPEVIA:
case TYPETRACK:
for( ; PtStruct != NULL; PtStruct = PtNext )
for( ; item; item = next )
{
PtNext = PtStruct->Next();
PtStruct->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
( (TRACK*) PtStruct )->Draw( DrawPanel, DC, GR_OR );
next = item->Next();
item->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
((TRACK*) item)->Draw( DrawPanel, DC, GR_OR );
}
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ( (TRACK*) PtStruct )->GetNet();
pt_track = ( (TRACK*) PtStruct )->GetBestInsertPoint( m_Pcb );
( (TRACK*) PtStruct )->Insert( m_Pcb, pt_track );
item = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ((TRACK*) item)->GetNet();
m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
test_1_net_connexion( DC, net_code );
......@@ -61,18 +61,14 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
/* Reinsertion du module dans la liste chainee des modules,
* en debut de chaine */
PtStruct->Pback = m_Pcb;
PtNext = m_Pcb->m_Modules;
PtStruct->Pnext = PtNext;
if( PtNext )
PtNext->Pback = PtStruct;
m_Pcb->m_Modules = (MODULE*) PtStruct;
m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
( (MODULE*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
((MODULE*) item)->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
PtStruct->SetState( DELETED, OFF ); /* Creal DELETED flag */
PtStruct->m_Flags = 0;
item->SetState( DELETED, OFF ); /* Creal DELETED flag */
item->m_Flags = 0;
m_Pcb->m_Status_Pcb = 0;
build_liste_pads();
ReCompile_Ratsnest_After_Changes( DC );
......
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