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;
......@@ -97,7 +98,7 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
{
NextS = PtStruct->Next();
( (TRACK*) PtStruct )->UnLink();
PtStruct->SetState( DELETED, ON );
if( nbitems <= 1 )
NextS = NULL; /* fin de chaine */
......
This diff is collapsed.
This diff is collapsed.
......@@ -150,9 +150,9 @@ 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_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)
m_CurrentMicroViaSize = 150; // Current micro via size
m_MicroViasAllowed = false; // true to allow micro vias
......
......@@ -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 */
......@@ -527,16 +524,16 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
/* dessin de la nouvelle piste : mise a jour du point d'arrivee */
g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
if( ! g_DesignSettings.m_UseConnectedTrackWidth )
g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth;
g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( g_TwoSegmentTrackBuild )
{
TRACK* previous_track = (TRACK*) g_CurrentTrackSegment->Pback;
if( previous_track && (previous_track->Type() == TYPETRACK) )
{
previous_track->SetLayer( screen->m_Active_Layer );
if( ! g_DesignSettings.m_UseConnectedTrackWidth )
previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
}
if( ! g_DesignSettings.m_UseConnectedTrackWidth )
previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
}
}
if( Track_45_Only )
......
This diff is collapsed.
......@@ -312,7 +312,7 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
* coord destination (row,col)
* net_code
* pointeur sur le chevelu de reference
*
*
* Retourne :
* SUCCESS si route trouvee
* TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer)
......@@ -722,10 +722,10 @@ static long bit[8][9] = { /* OT=Otherside */
* La recherche se fait en sens inverse du routage,
* c.a.d du point d'arrivee (target) vers le point de depart (source)
* du routeur.
*
*
* target_side = cote (TOP / BOTTOM) de depart
* mask_layer_source = masque des couches d'arrivee
*
*
* Retourne:
* 0 si erreur
* > 0 si Ok
......@@ -983,7 +983,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
NewTrack->Insert( pcb, g_CurrentTrackSegment );
g_CurrentTrackSegment->m_Start = pt_cur_ch->pad_end->GetPosition();
NewTrack->m_Start = g_CurrentTrackSegment->m_End;
g_CurrentTrackSegment = NewTrack;
......@@ -1065,10 +1065,10 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
NewTrack->Insert( pcbframe->m_Pcb, g_CurrentTrackSegment );
NewTrack->m_End = pt_cur_ch->pad_start->GetPosition();
NewTrack->m_Start = g_CurrentTrackSegment->m_End;
g_CurrentTrackSegment = NewTrack;
g_CurrentTrackSegment = NewTrack;
g_TrackSegmentCount++;
}
......@@ -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() );
// copper shape's position is hole position + offset
wxPoint pos = pad->m_Pos0 + pad->m_Offset;
#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
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,38 +224,94 @@ 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 )
{
CIRCLE* circle = (CIRCLE*) shape->shape;
viaDiam = scale( circle->diameter, routeResolution );
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->m_Shape = VIA_THROUGH;
via->m_Width = viaDiam;
via->SetLayerPair( CMP_N, COPPER_LAYER_N );
}
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 viaDiam = scale( circle->diameter, routeResolution );
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->m_Shape = VIA_THROUGH;
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;
int viaDiam = scale( circle->diameter, routeResolution );
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->m_Shape = VIA_THROUGH;
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;
viaDiam = scale( circle->diameter, routeResolution );
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->m_Shape = VIA_THROUGH;
via->m_Width = viaDiam;
via->SetLayerPair( CMP_N, COPPER_LAYER_N );
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 );
......@@ -124,11 +120,11 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
{
NextS = PtStruct->Next();
( (TRACK*) PtStruct )->UnLink();
PtStruct->SetState( DELETED, ON );
if( nbitems <= 1 )
NextS = NULL; /* fin de chaine */
PtStruct->Pnext = NextS;
PtStruct->Pback = Back; Back = PtStruct;
if( NextS == NULL )
......
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