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 ...@@ -6,6 +6,21 @@ Please add newer entries at the top, list the date and your name with
email address. 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> 2008-Feb-7 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+pcbnew +pcbnew
......
...@@ -20,7 +20,8 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC ) ...@@ -20,7 +20,8 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC )
/* Restitution d'un element (MODULE ou TRACK ) Efface /* Restitution d'un element (MODULE ou TRACK ) Efface
*/ */
{ {
EDA_BaseStruct* PtStruct, * PtNext; BOARD_ITEM* item;
BOARD_ITEM* next;
TRACK* pt_track; TRACK* pt_track;
int net_code; int net_code;
...@@ -28,25 +29,25 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC ) ...@@ -28,25 +29,25 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC )
return; return;
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; item = g_UnDeleteStack[g_UnDeleteStackPtr];
if( PtStruct == NULL ) if( item == NULL )
return; // Ne devrait pas se produire return; // Ne devrait pas se produire
switch( PtStruct->Type() ) switch( item->Type() )
{ {
case TYPEVIA: case TYPEVIA:
case TYPETRACK: case TYPETRACK:
for( ; PtStruct != NULL; PtStruct = PtNext ) for( ; item; item = next )
{ {
PtNext = PtStruct->Pnext; next = item->Next();
PtStruct->SetState( DELETED, OFF ); /* Effacement du bit DELETED */ item->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
Trace_Segment( DrawPanel, DC, (TRACK*) PtStruct, GR_OR ); Trace_Segment( DrawPanel, DC, (TRACK*) item, GR_OR );
} }
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; item = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ( (TRACK*) PtStruct )->GetNet(); net_code = ((TRACK*) item)->GetNet();
pt_track = ( (TRACK*) PtStruct )->GetBestInsertPoint( m_Pcb );
( (TRACK*) PtStruct )->Insert( m_Pcb, pt_track ); m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
break; break;
...@@ -97,7 +98,7 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) ...@@ -97,7 +98,7 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
{ {
NextS = PtStruct->Next(); NextS = PtStruct->Next();
( (TRACK*) PtStruct )->UnLink(); ( (TRACK*) PtStruct )->UnLink();
PtStruct->SetState( DELETED, ON ); PtStruct->SetState( DELETED, ON );
if( nbitems <= 1 ) if( nbitems <= 1 )
NextS = NULL; /* fin de chaine */ NextS = NULL; /* fin de chaine */
......
...@@ -51,30 +51,30 @@ BOARD::~BOARD() ...@@ -51,30 +51,30 @@ BOARD::~BOARD()
m_Modules->DeleteStructList(); m_Modules->DeleteStructList();
m_Modules = 0; m_Modules = 0;
m_Equipots->DeleteStructList(); m_Equipots->DeleteStructList();
m_Equipots = 0; m_Equipots = 0;
m_Track->DeleteStructList(); m_Track->DeleteStructList();
m_Track = 0; m_Track = 0;
m_Zone->DeleteStructList(); m_Zone->DeleteStructList();
m_Zone = 0; m_Zone = 0;
MyFree( m_Pads ); MyFree( m_Pads );
m_Pads = 0; m_Pads = 0;
MyFree( m_Ratsnest ); MyFree( m_Ratsnest );
m_Ratsnest = 0; m_Ratsnest = 0;
MyFree( m_LocalRatsnest ); MyFree( m_LocalRatsnest );
m_LocalRatsnest = 0; m_LocalRatsnest = 0;
DeleteMARKERs(); DeleteMARKERs();
DeleteZONEOutlines(); DeleteZONEOutlines();
delete m_CurrentZoneContour; delete m_CurrentZoneContour;
m_CurrentZoneContour = NULL; m_CurrentZoneContour = NULL;
} }
...@@ -122,12 +122,12 @@ void BOARD::UnLink() ...@@ -122,12 +122,12 @@ void BOARD::UnLink()
void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
{ {
if ( aBoardItem == NULL ) if ( aBoardItem == NULL )
{ {
wxFAIL_MSG( wxT("BOARD::Add() param error: aBoardItem NULL") ); wxFAIL_MSG( wxT("BOARD::Add() param error: aBoardItem NULL") );
return; return;
} }
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
// this one uses a vector // this one uses a vector
...@@ -135,13 +135,33 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) ...@@ -135,13 +135,33 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
aBoardItem->m_Parent = this; aBoardItem->m_Parent = this;
m_markers.push_back( (MARKER*) aBoardItem ); m_markers.push_back( (MARKER*) aBoardItem );
break; break;
// this one uses a vector // this one uses a vector
case TYPEZONE_CONTAINER: case TYPEZONE_CONTAINER:
aBoardItem->m_Parent = this; aBoardItem->m_Parent = this;
m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem ); m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem );
break; 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 // other types may use linked list
default: default:
wxFAIL_MSG( wxT("BOARD::Add() needs work") ); wxFAIL_MSG( wxT("BOARD::Add() needs work") );
...@@ -151,7 +171,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) ...@@ -151,7 +171,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
void BOARD::Delete( BOARD_ITEM* aBoardItem ) void BOARD::Delete( BOARD_ITEM* aBoardItem )
{ {
if ( aBoardItem == NULL ) return; if ( aBoardItem == NULL ) return;
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
...@@ -174,12 +194,12 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem ) ...@@ -174,12 +194,12 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem ) if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem )
{ {
delete m_ZoneDescriptorList[i]; delete m_ZoneDescriptorList[i];
m_ZoneDescriptorList.erase(m_ZoneDescriptorList.begin() + i); m_ZoneDescriptorList.erase(m_ZoneDescriptorList.begin() + i);
break; break;
} }
} }
break; break;
// other types may use linked list // other types may use linked list
default: default:
wxFAIL_MSG( wxT("BOARD::Delete() needs work") ); wxFAIL_MSG( wxT("BOARD::Delete() needs work") );
...@@ -191,7 +211,7 @@ void BOARD::DeleteMARKER( int aIndex ) ...@@ -191,7 +211,7 @@ void BOARD::DeleteMARKER( int aIndex )
{ {
if( (unsigned) aIndex < m_markers.size() ) if( (unsigned) aIndex < m_markers.size() )
{ {
delete m_markers[aIndex]; delete m_markers[aIndex];
m_markers.erase( m_markers.begin() + aIndex ); m_markers.erase( m_markers.begin() + aIndex );
} }
} }
...@@ -202,7 +222,7 @@ void BOARD::DeleteMARKERs() ...@@ -202,7 +222,7 @@ void BOARD::DeleteMARKERs()
// the vector does not know how to delete the MARKER, it holds pointers // the vector does not know how to delete the MARKER, it holds pointers
for( unsigned i=0; i<m_markers.size(); ++i ) for( unsigned i=0; i<m_markers.size(); ++i )
delete m_markers[i]; delete m_markers[i];
m_markers.clear(); m_markers.clear();
} }
...@@ -211,7 +231,7 @@ void BOARD::DeleteZONEOutlines() ...@@ -211,7 +231,7 @@ void BOARD::DeleteZONEOutlines()
// the vector does not know how to delete the ZONE Outlines, it holds pointers // the vector does not know how to delete the ZONE Outlines, it holds pointers
for( unsigned i=0; i<m_ZoneDescriptorList.size(); ++i ) for( unsigned i=0; i<m_ZoneDescriptorList.size(); ++i )
delete m_ZoneDescriptorList[i]; delete m_ZoneDescriptorList[i];
m_ZoneDescriptorList.clear(); m_ZoneDescriptorList.clear();
} }
...@@ -266,7 +286,7 @@ bool BOARD::ComputeBoundaryBox() ...@@ -266,7 +286,7 @@ bool BOARD::ComputeBoundaryBox()
* Calculate the bounding box of the board * Calculate the bounding box of the board
* This box contains pcb edges, pads , vias and tracks * This box contains pcb edges, pads , vias and tracks
* Update m_PcbBox member * Update m_PcbBox member
* *
* @return 0 for an empty board (no items), else 1 * @return 0 for an empty board (no items), else 1
*/ */
{ {
...@@ -288,7 +308,7 @@ bool BOARD::ComputeBoundaryBox() ...@@ -288,7 +308,7 @@ bool BOARD::ComputeBoundaryBox()
ptr = (DRAWSEGMENT*) PtStruct; ptr = (DRAWSEGMENT*) PtStruct;
d = (ptr->m_Width / 2) + 1; d = (ptr->m_Width / 2) + 1;
if( ptr->m_Shape == S_CIRCLE ) if( ptr->m_Shape == S_CIRCLE )
{ {
cx = ptr->m_Start.x; cy = ptr->m_Start.y; cx = ptr->m_Start.x; cy = ptr->m_Start.y;
...@@ -328,7 +348,7 @@ bool BOARD::ComputeBoundaryBox() ...@@ -328,7 +348,7 @@ bool BOARD::ComputeBoundaryBox()
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
const wxPoint& pos = pt_pad->GetPosition(); const wxPoint& pos = pt_pad->GetPosition();
d = pt_pad->m_Rayon; d = pt_pad->m_Rayon;
xmin = MIN( xmin, pos.x - d ); xmin = MIN( xmin, pos.x - d );
ymin = MIN( ymin, pos.y - d ); ymin = MIN( ymin, pos.y - d );
...@@ -440,8 +460,8 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame ) ...@@ -440,8 +460,8 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame )
} }
// virtual, see pcbstruct.h // virtual, see pcbstruct.h
SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
...@@ -451,8 +471,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -451,8 +471,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' '; std::cout << GetClass().mb_str() << ' ';
#endif #endif
while( !done ) while( !done )
{ {
stype = *p; stype = *p;
...@@ -466,11 +486,11 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -466,11 +486,11 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
/* Instances of the requested KICAD_T live in a list, either one /* Instances of the requested KICAD_T live in a list, either one
that I manage, or that my modules manage. If it's a type managed that I manage, or that my modules manage. If it's a type managed
by class MODULE, then simply pass it on to each module's by class MODULE, then simply pass it on to each module's
MODULE::Visit() function by way of the MODULE::Visit() function by way of the
IterateForward( m_Modules, ... ) call. IterateForward( m_Modules, ... ) call.
*/ */
case TYPEMODULE: case TYPEMODULE:
case TYPEPAD: case TYPEPAD:
case TYPETEXTEMODULE: case TYPETEXTEMODULE:
...@@ -515,19 +535,19 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -515,19 +535,19 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
; ;
break; break;
#if 0 // both these are on same list, so we must scan it twice in order to get VIA priority, #if 0 // both these are on same list, so we must scan it twice in order to get VIA priority,
// using new #else code below. // using new #else code below.
// But we are not using separte lists for TRACKs and SEGVIAs, because items are ordered (sortered) in the linked // But we are not using separte lists for TRACKs and SEGVIAs, because items are ordered (sortered) in the linked
// list by netcode AND by physical distance: // list by netcode AND by physical distance:
// when created, if a track or via is connected to an existing track or via, it is put in linked list // when created, if a track or via is connected to an existing track or via, it is put in linked list
// after this existing track or via // after this existing track or via
// So usually, connected tracks or vias are grouped in this list // So usually, connected tracks or vias are grouped in this list
// So the algorithm (used in rastnest computations) which computes the track connectivity is faster (more than 100 time regarding to // So the algorithm (used in rastnest computations) which computes the track connectivity is faster (more than 100 time regarding to
// a non ordered list) because when it searchs for a connexion, first it tests the near (near in term of linked list) 50 items // a non ordered list) because when it searchs for a connexion, first it tests the near (near in term of linked list) 50 items
// from the current item (track or via) in test. // from the current item (track or via) in test.
// Usually, because of this sort, a connected item (if exists) is found. // Usually, because of this sort, a connected item (if exists) is found.
// If not found (and only in this case) an exhaustive (and time consumming) search is made, // If not found (and only in this case) an exhaustive (and time consumming) search is made,
// but this case is statistically rare. // but this case is statistically rare.
case TYPEVIA: case TYPEVIA:
case TYPETRACK: case TYPETRACK:
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
...@@ -549,7 +569,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -549,7 +569,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
++p; ++p;
break; break;
case TYPETRACK: case TYPETRACK:
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
++p; ++p;
...@@ -581,31 +601,31 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -581,31 +601,31 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
case PCB_EQUIPOT_STRUCT_TYPE: case PCB_EQUIPOT_STRUCT_TYPE:
result = IterateForward( m_Equipots, inspector, testData, p ); result = IterateForward( m_Equipots, inspector, testData, p );
++p; ++p;
break; break;
case TYPEZONE: case TYPEZONE:
result = IterateForward( m_Zone, inspector, testData, p ); result = IterateForward( m_Zone, inspector, testData, p );
++p; ++p;
break; break;
case TYPEZONE_UNUSED: // Unused type case TYPEZONE_UNUSED: // Unused type
break; break;
default: // catch EOT or ANY OTHER type here and return. default: // catch EOT or ANY OTHER type here and return.
done = true; done = true;
break; break;
} }
if( result == SEARCH_QUIT ) if( result == SEARCH_QUIT )
break; break;
} }
return result; return result;
} }
/* now using PcbGeneralLocateAndDisplay() /* now using PcbGeneralLocateAndDisplay()
// see pcbstruct.h // see pcbstruct.h
BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
{ {
class PadOrModule : public INSPECTOR class PadOrModule : public INSPECTOR
...@@ -614,22 +634,22 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -614,22 +634,22 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
BOARD_ITEM* found; BOARD_ITEM* found;
int layer; int layer;
int layer_mask; int layer_mask;
PadOrModule( int alayer ) : PadOrModule( int alayer ) :
found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] ) found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] )
{} {}
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData ) SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
{ {
BOARD_ITEM* item = (BOARD_ITEM*) testItem; BOARD_ITEM* item = (BOARD_ITEM*) testItem;
const wxPoint& refPos = *(const wxPoint*) testData; const wxPoint& refPos = *(const wxPoint*) testData;
if( item->Type() == TYPEPAD ) if( item->Type() == TYPEPAD )
{ {
D_PAD* pad = (D_PAD*) item; D_PAD* pad = (D_PAD*) item;
if( pad->HitTest( refPos ) ) if( pad->HitTest( refPos ) )
{ {
if( layer_mask & pad->m_Masque_Layer ) if( layer_mask & pad->m_Masque_Layer )
{ {
found = item; found = item;
return SEARCH_QUIT; return SEARCH_QUIT;
...@@ -642,7 +662,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -642,7 +662,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
} }
} }
} }
else if( item->Type() == TYPEMODULE ) else if( item->Type() == TYPEMODULE )
{ {
MODULE* module = (MODULE*) item; MODULE* module = (MODULE*) item;
...@@ -657,7 +677,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -657,7 +677,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
found = item; found = item;
return SEARCH_QUIT; return SEARCH_QUIT;
} }
// layer mismatch, save in case we don't find a // layer mismatch, save in case we don't find a
// future layer match hit. // future layer match hit.
if( !found ) if( !found )
...@@ -668,7 +688,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -668,7 +688,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
return SEARCH_CONTINUE; return SEARCH_CONTINUE;
} }
}; };
PadOrModule inspector( layer ); PadOrModule inspector( layer );
// search only for PADs first, then MODULES, and preferably a layer match // search only for PADs first, then MODULES, and preferably a layer match
...@@ -676,7 +696,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -676,7 +696,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
// visit this BOARD with the above inspector // visit this BOARD with the above inspector
Visit( &inspector, &refPos, scanTypes ); Visit( &inspector, &refPos, scanTypes );
return inspector.found; return inspector.found;
} }
*/ */
...@@ -692,7 +712,7 @@ EQUIPOT* BOARD::FindNet( int anetcode ) const ...@@ -692,7 +712,7 @@ EQUIPOT* BOARD::FindNet( int anetcode ) const
{ {
// the first valid netcode is 1. // the first valid netcode is 1.
// zero is reserved for "no connection" and is not used. // zero is reserved for "no connection" and is not used.
if( anetcode > 0 ) if( anetcode > 0 )
{ {
for( EQUIPOT* net = m_Equipots; net; net=net->Next() ) for( EQUIPOT* net = m_Equipots; net; net=net->Next() )
{ {
...@@ -714,7 +734,7 @@ EQUIPOT* BOARD::FindNet( const wxString & aNetname ) const ...@@ -714,7 +734,7 @@ EQUIPOT* BOARD::FindNet( const wxString & aNetname ) const
{ {
// the first valid netcode is 1. // the first valid netcode is 1.
// zero is reserved for "no connection" and is not used. // zero is reserved for "no connection" and is not used.
if( ! aNetname.IsEmpty() ) if( ! aNetname.IsEmpty() )
{ {
for( EQUIPOT* net = m_Equipots; net; net=net->Next() ) for( EQUIPOT* net = m_Equipots; net; net=net->Next() )
{ {
...@@ -754,7 +774,7 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const ...@@ -754,7 +774,7 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
// visit this BOARD with the above inspector // visit this BOARD with the above inspector
BOARD* nonconstMe = (BOARD*) this; BOARD* nonconstMe = (BOARD*) this;
nonconstMe->Visit( &inspector, &aReference, scanTypes ); nonconstMe->Visit( &inspector, &aReference, scanTypes );
return inspector.found; return inspector.found;
} }
...@@ -763,19 +783,19 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const ...@@ -763,19 +783,19 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
// Sort nets by name // Sort nets by name
int s_SortByNames(const void * ptr1, const void * ptr2) int s_SortByNames(const void * ptr1, const void * ptr2)
{ {
EQUIPOT* item1 = * (EQUIPOT**) ptr1; EQUIPOT* item1 = * (EQUIPOT**) ptr1;
EQUIPOT* item2 = * (EQUIPOT**) ptr2; EQUIPOT* item2 = * (EQUIPOT**) ptr2;
return item1->m_Netname.CmpNoCase(item2->m_Netname); return item1->m_Netname.CmpNoCase(item2->m_Netname);
} }
// Sort nets by decreasing pad count // Sort nets by decreasing pad count
int s_SortByNodes(const void * ptr1, const void * ptr2) int s_SortByNodes(const void * ptr1, const void * ptr2)
{ {
EQUIPOT* item1 = * (EQUIPOT**) ptr1; EQUIPOT* item1 = * (EQUIPOT**) ptr1;
EQUIPOT* item2 = * (EQUIPOT**) ptr2; EQUIPOT* item2 = * (EQUIPOT**) ptr2;
if ( (item1->m_NbNodes - item2->m_NbNodes) != 0 ) if ( (item1->m_NbNodes - item2->m_NbNodes) != 0 )
return - (item1->m_NbNodes - item2->m_NbNodes); return - (item1->m_NbNodes - item2->m_NbNodes);
return item1->m_Netname.CmpNoCase(item2->m_Netname); return item1->m_Netname.CmpNoCase(item2->m_Netname);
} }
...@@ -788,52 +808,52 @@ int s_SortByNodes(const void * ptr1, const void * ptr2) ...@@ -788,52 +808,52 @@ int s_SortByNodes(const void * ptr1, const void * ptr2)
*/ */
int BOARD::ReturnSortedNetnamesList( wxArrayString & aNames, const int aSort_Type) int BOARD::ReturnSortedNetnamesList( wxArrayString & aNames, const int aSort_Type)
{ {
int NetCount = 0; int NetCount = 0;
int ii; int ii;
EQUIPOT* net; EQUIPOT* net;
/* count items to list and sort */ /* count items to list and sort */
for( net = m_Equipots; net; net=net->Next() ) for( net = m_Equipots; net; net=net->Next() )
{ {
if ( net->m_Netname.IsEmpty() ) continue; if ( net->m_Netname.IsEmpty() ) continue;
NetCount++; NetCount++;
} }
if ( NetCount == 0 ) return 0; if ( NetCount == 0 ) return 0;
/* Build the list */ /* Build the list */
EQUIPOT* * net_ptr_list = (EQUIPOT* *) MyMalloc( NetCount * sizeof(* net_ptr_list) ); EQUIPOT* * net_ptr_list = (EQUIPOT* *) MyMalloc( NetCount * sizeof(* net_ptr_list) );
for( ii = 0, net = m_Equipots; net; net=net->Next() ) for( ii = 0, net = m_Equipots; net; net=net->Next() )
{ {
if ( net->m_Netname.IsEmpty() ) continue; if ( net->m_Netname.IsEmpty() ) continue;
net_ptr_list[ii] = net; net_ptr_list[ii] = net;
ii++; ii++;
} }
/* sort the list */ /* sort the list */
switch ( aSort_Type ) switch ( aSort_Type )
{ {
case NO_SORT : break; case NO_SORT : break;
case ALPHA_SORT : case ALPHA_SORT :
qsort (net_ptr_list, NetCount, sizeof(EQUIPOT*), s_SortByNames); qsort (net_ptr_list, NetCount, sizeof(EQUIPOT*), s_SortByNames);
break; break;
case PAD_CNT_SORT: case PAD_CNT_SORT:
qsort (net_ptr_list, NetCount, sizeof(EQUIPOT*), s_SortByNodes); qsort (net_ptr_list, NetCount, sizeof(EQUIPOT*), s_SortByNodes);
break; break;
} }
/* fill the given list */ /* fill the given list */
for( ii = 0; ii < NetCount; ii++ ) for( ii = 0; ii < NetCount; ii++ )
{ {
net = net_ptr_list[ii]; net = net_ptr_list[ii];
aNames.Add(net->m_Netname); aNames.Add(net->m_Netname);
} }
MyFree(net_ptr_list); MyFree(net_ptr_list);
return NetCount; return NetCount;
} }
/************************************/ /************************************/
...@@ -847,12 +867,12 @@ bool BOARD::Save( FILE* aFile ) const ...@@ -847,12 +867,12 @@ bool BOARD::Save( FILE* aFile ) const
for( item = m_Equipots; item; item=item->Next() ) for( item = m_Equipots; item; item=item->Next() )
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
// save the modules // save the modules
for( item = m_Modules; item; item=item->Next() ) for( item = m_Modules; item; item=item->Next() )
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
for( item = m_Drawings; item; item=item->Next() ) for( item = m_Drawings; item; item=item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
...@@ -867,15 +887,15 @@ bool BOARD::Save( FILE* aFile ) const ...@@ -867,15 +887,15 @@ bool BOARD::Save( FILE* aFile ) const
default: default:
// future: throw exception here // future: throw exception here
#if defined(DEBUG) #if defined(DEBUG)
printf( "BOARD::Save() ignoring m_Drawings type %d\n", item->Type() ); printf( "BOARD::Save() ignoring m_Drawings type %d\n", item->Type() );
#endif #endif
break; break;
} }
} }
// do not save MARKERs, they can be regenerated easily // do not save MARKERs, they can be regenerated easily
// save the tracks & vias // save the tracks & vias
fprintf( aFile, "$TRACK\n" ); fprintf( aFile, "$TRACK\n" );
for( item = m_Track; item; item=item->Next() ) for( item = m_Track; item; item=item->Next() )
...@@ -889,22 +909,22 @@ bool BOARD::Save( FILE* aFile ) const ...@@ -889,22 +909,22 @@ bool BOARD::Save( FILE* aFile ) const
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
fprintf( aFile, "$EndZONE\n" ); fprintf( aFile, "$EndZONE\n" );
// save the zone edges // save the zone edges
for( unsigned ii = 0; ii < m_ZoneDescriptorList.size(); ii++ ) for( unsigned ii = 0; ii < m_ZoneDescriptorList.size(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_ZoneDescriptorList[ii]; ZONE_CONTAINER* edge_zone = m_ZoneDescriptorList[ii];
edge_zone->Save( aFile ); edge_zone->Save( aFile );
} }
if( fprintf( aFile, "$EndBOARD\n" ) != sizeof("$EndBOARD\n")-1 ) if( fprintf( aFile, "$EndBOARD\n" ) != sizeof("$EndBOARD\n")-1 )
goto out; goto out;
rc = true; // wrote all OK rc = true; // wrote all OK
out: out:
return rc; return rc;
} }
/***********************************************************************************************/ /***********************************************************************************************/
...@@ -917,12 +937,12 @@ void BOARD::RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMo ...@@ -917,12 +937,12 @@ void BOARD::RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMo
{ {
if ( ! aDC ) return; if ( ! aDC ) return;
for( int ii = 0; ii < GetAreaCount(); ii++ ) for( int ii = 0; ii < GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = GetArea(ii); ZONE_CONTAINER* edge_zone = GetArea(ii);
if( (aLayer < 0) || (aLayer == edge_zone->GetLayer()) ) if( (aLayer < 0) || (aLayer == edge_zone->GetLayer()) )
edge_zone->Draw( panel, aDC, wxPoint( 0, 0 ), aDrawMode ); edge_zone->Draw( panel, aDC, wxPoint( 0, 0 ), aDrawMode );
} }
} }
...@@ -932,14 +952,14 @@ void BOARD::RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMo ...@@ -932,14 +952,14 @@ void BOARD::RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMo
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level * @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree. * of nesting of this object within the overall tree.
* @param os The ostream& to output to. * @param os The ostream& to output to.
*/ */
void BOARD::Show( int nestLevel, std::ostream& os ) void BOARD::Show( int nestLevel, std::ostream& os )
{ {
BOARD_ITEM* p; BOARD_ITEM* p;
// for now, make it look like XML: // for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
...@@ -955,7 +975,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) ...@@ -955,7 +975,7 @@ void BOARD::Show( int nestLevel, std::ostream& os )
for( ; p; p = p->Next() ) for( ; p; p = p->Next() )
p->Show( nestLevel+2, os ); p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</pdrawings>\n"; NestedSpace( nestLevel+1, os ) << "</pdrawings>\n";
NestedSpace( nestLevel+1, os ) << "<nets>\n"; NestedSpace( nestLevel+1, os ) << "<nets>\n";
p = m_Equipots; p = m_Equipots;
for( ; p; p = p->Next() ) for( ; p; p = p->Next() )
...@@ -963,13 +983,13 @@ void BOARD::Show( int nestLevel, std::ostream& os ) ...@@ -963,13 +983,13 @@ void BOARD::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel+1, os ) << "</nets>\n"; NestedSpace( nestLevel+1, os ) << "</nets>\n";
NestedSpace( nestLevel+1, os ) << "<tracks>\n"; NestedSpace( nestLevel+1, os ) << "<tracks>\n";
p = m_Track; p = m_Track;
for( ; p; p = p->Next() ) for( ; p; p = p->Next() )
p->Show( nestLevel+2, os ); p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</tracks>\n"; NestedSpace( nestLevel+1, os ) << "</tracks>\n";
NestedSpace( nestLevel+1, os ) << "<zones>\n"; NestedSpace( nestLevel+1, os ) << "<zones>\n";
p = m_Zone; p = m_Zone;
for( ; p; p = p->Next() ) for( ; p; p = p->Next() )
p->Show( nestLevel+2, os ); p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</zones>\n"; NestedSpace( nestLevel+1, os ) << "</zones>\n";
...@@ -978,13 +998,13 @@ void BOARD::Show( int nestLevel, std::ostream& os ) ...@@ -978,13 +998,13 @@ void BOARD::Show( int nestLevel, std::ostream& os )
for( ZONE_CONTAINERS::iterator i=m_ZoneDescriptorList.begin(); i!=m_ZoneDescriptorList.end(); ++i ) for( ZONE_CONTAINERS::iterator i=m_ZoneDescriptorList.begin(); i!=m_ZoneDescriptorList.end(); ++i )
(*i)->Show( nestLevel+2, os ); (*i)->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</zone_container>\n"; NestedSpace( nestLevel+1, os ) << "</zone_container>\n";
p = (BOARD_ITEM*) m_Son; p = (BOARD_ITEM*) m_Son;
for( ; p; p = p->Next() ) for( ; p; p = p->Next() )
{ {
p->Show( nestLevel+1, os ); p->Show( nestLevel+1, os );
} }
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
......
...@@ -16,11 +16,11 @@ class EDA_BoardDesignSettings; ...@@ -16,11 +16,11 @@ class EDA_BoardDesignSettings;
class BOARD : public BOARD_ITEM class BOARD : public BOARD_ITEM
{ {
friend class WinEDA_PcbFrame; friend class WinEDA_PcbFrame;
private: private:
typedef std::vector<MARKER*> MARKERS; // @todo: switch to boost:ptr_vector, and change ~BOARD() typedef std::vector<MARKER*> MARKERS; // @todo: switch to boost:ptr_vector, and change ~BOARD()
MARKERS m_markers; ///< MARKERs for clearance problems, owned by pointer MARKERS m_markers; ///< MARKERs for clearance problems, owned by pointer
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD() typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD()
ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
* @return const wxPoint& of (0,0) * @return const wxPoint& of (0,0)
*/ */
wxPoint& GetPosition(); wxPoint& GetPosition();
/* supprime du chainage la structure Struct */ /* supprime du chainage la structure Struct */
void UnLink(); void UnLink();
...@@ -68,9 +68,11 @@ public: ...@@ -68,9 +68,11 @@ public:
* Function Add * Function Add
* adds the given item to this BOARD and takes ownership of its memory. * adds the given item to this BOARD and takes ownership of its memory.
* @param aBoardItem The item to add to this board. * @param aBoardItem The item to add to this board.
* @param aControl An int which can vary how the item is added. * @param aControl An int which can vary how the item is added.
*/ */
void Add( BOARD_ITEM* aBoardItem, int aControl = 0 ); void Add( BOARD_ITEM* aBoardItem, int aControl = 0 );
#define ADD_APPEND 1 ///< aControl flag for Add( aControl ), appends not inserts
/** /**
* Function Delete * Function Delete
...@@ -90,17 +92,17 @@ public: ...@@ -90,17 +92,17 @@ public:
* Function DeleteZONEOutlines * Function DeleteZONEOutlines
* deletes ALL zone outlines from the board. * deletes ALL zone outlines from the board.
*/ */
void DeleteZONEOutlines(); void DeleteZONEOutlines();
/** /**
* Function DeleteMARKER * Function DeleteMARKER
* deletes one MARKER from the board. * deletes one MARKER from the board.
* @param aIndex The index of the marker to delete. * @param aIndex The index of the marker to delete.
*/ */
void DeleteMARKER( int aIndex ); void DeleteMARKER( int aIndex );
/** /**
* Function GetMARKER * Function GetMARKER
* returns the MARKER at a given index. * returns the MARKER at a given index.
...@@ -114,7 +116,7 @@ public: ...@@ -114,7 +116,7 @@ public:
return NULL; return NULL;
} }
/** /**
* Function GetMARKERCount * Function GetMARKERCount
* @return int - The number of MARKERS. * @return int - The number of MARKERS.
...@@ -129,7 +131,7 @@ public: ...@@ -129,7 +131,7 @@ public:
* @return int - The number of copper layers in the BOARD. * @return int - The number of copper layers in the BOARD.
*/ */
int GetCopperLayerCount() const; int GetCopperLayerCount() const;
/** /**
* Function GetLayerName * Function GetLayerName
* returns the name of the requested layer. Hopefully layer names will * returns the name of the requested layer. Hopefully layer names will
...@@ -138,13 +140,13 @@ public: ...@@ -138,13 +140,13 @@ public:
* @param aLayerIndex A layer index, like COPPER_LAYER_N, etc. * @param aLayerIndex A layer index, like COPPER_LAYER_N, etc.
* @return wxString - the layer name. * @return wxString - the layer name.
*/ */
wxString GetLayerName( int aLayerIndex ) const; wxString GetLayerName( int aLayerIndex ) const;
/* Routines de calcul des nombres de segments pistes et zones */ /* Routines de calcul des nombres de segments pistes et zones */
int GetNumSegmTrack(); int GetNumSegmTrack();
int GetNumSegmZone(); int GetNumSegmZone();
int GetNumNoconnect(); // retourne le nombre de connexions manquantes int GetNumNoconnect(); // retourne le nombre de connexions manquantes
/** /**
* Function GetNumRatsnests * Function GetNumRatsnests
* @return int - The number of rats * @return int - The number of rats
...@@ -153,23 +155,23 @@ public: ...@@ -153,23 +155,23 @@ public:
{ {
return m_NbLinks; return m_NbLinks;
} }
int GetNumNodes(); // retourne le nombre de pads a netcode > 0 int GetNumNodes(); // retourne le nombre de pads a netcode > 0
// Calcul du rectangle d'encadrement: // Calcul du rectangle d'encadrement:
bool ComputeBoundaryBox(); bool ComputeBoundaryBox();
/** /**
* Function Display_Infos * Function Display_Infos
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_DrawFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
/** /**
* Function Visit * Function Visit
* may be re-implemented for each derived class in order to handle * may be re-implemented for each derived class in order to handle
...@@ -178,12 +180,12 @@ public: ...@@ -178,12 +180,12 @@ public:
* to do so on lists of such data. * to do so on lists of such data.
* @param inspector An INSPECTOR instance to use in the inspection. * @param inspector An INSPECTOR instance to use in the inspection.
* @param testData Arbitrary data used by the inspector. * @param testData Arbitrary data used by the inspector.
* @param scanTypes Which KICAD_T types are of interest and the order * @param scanTypes Which KICAD_T types are of interest and the order
* is significant too, terminated by EOT. * is significant too, terminated by EOT.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE, and determined by the inspector. * else SCAN_CONTINUE, and determined by the inspector.
*/ */
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
...@@ -213,7 +215,7 @@ public: ...@@ -213,7 +215,7 @@ public:
* designator, else NULL. * designator, else NULL.
*/ */
MODULE* FindModuleByReference( const wxString& aReference ) const; MODULE* FindModuleByReference( const wxString& aReference ) const;
/** /**
* Function ReturnSortedNetnamesList * Function ReturnSortedNetnamesList
* searches for a net with the given netcode. * searches for a net with the given netcode.
...@@ -221,11 +223,11 @@ public: ...@@ -221,11 +223,11 @@ public:
* @param aSort_Type : NO_SORT = no sort, ALPHA_SORT = sort by alphabetic order, PAD_CNT_SORT = sort by active pads count. * @param aSort_Type : NO_SORT = no sort, ALPHA_SORT = sort by alphabetic order, PAD_CNT_SORT = sort by active pads count.
* @return int - net names count. * @return int - net names count.
*/ */
enum netname_sort_type { enum netname_sort_type {
NO_SORT, NO_SORT,
ALPHA_SORT, ALPHA_SORT,
PAD_CNT_SORT PAD_CNT_SORT
}; };
int ReturnSortedNetnamesList( wxArrayString & aNames, const int aSort_Type); int ReturnSortedNetnamesList( wxArrayString & aNames, const int aSort_Type);
...@@ -234,10 +236,10 @@ public: ...@@ -234,10 +236,10 @@ public:
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** /**
* Function GetClass * Function GetClass
* returns the class name. * returns the class name.
...@@ -252,41 +254,41 @@ public: ...@@ -252,41 +254,41 @@ public:
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level * @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree. * of nesting of this object within the overall tree.
* @param os The ostream& to output to. * @param os The ostream& to output to.
*/ */
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
/**************************/ /**************************/
/* footprint operations : */ /* footprint operations : */
/**************************/ /**************************/
void Change_Side_Module( MODULE* Module, wxDC* DC ); void Change_Side_Module( MODULE* Module, wxDC* DC );
/*************************/ /*************************/
/* Copper Areas handling */ /* Copper Areas handling */
/*************************/ /*************************/
/** /**
* Function RedrawAreasOutlines * Function RedrawAreasOutlines
* Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 ) * Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
*/ */
void RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMode, int aLayer); void RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMode, int aLayer);
/** /**
* Function SetAreasNetCodesFromNetNames * Function SetAreasNetCodesFromNetNames
* Set the .m_NetCode member of all copper areas, according to the area Net Name * Set the .m_NetCode member of all copper areas, according to the area Net Name
* The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons. * The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons.
* However the Netcode is an arbitrary equyivalence, it must be set after each netlist read * However the Netcode is an arbitrary equyivalence, it must be set after each netlist read
* or net change * or net change
* Must be called after pad netcodes are calculated * Must be called after pad netcodes are calculated
* @return : error count * @return : error count
*/ */
int SetAreasNetCodesFromNetNames(void); int SetAreasNetCodesFromNetNames(void);
/** /**
* Function GetArea * Function GetArea
* returns the Area (Zone Container) at a given index. * returns the Area (Zone Container) at a given index.
* @param index The array type index into a collection of ZONE_CONTAINER *. * @param index The array type index into a collection of ZONE_CONTAINER *.
...@@ -299,7 +301,7 @@ public: ...@@ -299,7 +301,7 @@ public:
return NULL; return NULL;
} }
/** /**
* Function GetAreaIndex * Function GetAreaIndex
* returns the Area Index for the given Zone Container. * returns the Area Index for the given Zone Container.
* @param aArea :The ZONE_CONTAINER to find. * @param aArea :The ZONE_CONTAINER to find.
...@@ -308,13 +310,13 @@ public: ...@@ -308,13 +310,13 @@ public:
int GetAreaIndex( const ZONE_CONTAINER* aArea) const int GetAreaIndex( const ZONE_CONTAINER* aArea) const
{ {
for( int ii = 0; ii < GetAreaCount(); ii++ ) // Search for aArea in list for( int ii = 0; ii < GetAreaCount(); ii++ ) // Search for aArea in list
{ {
if ( aArea == GetArea( ii ) ) // Found ! if ( aArea == GetArea( ii ) ) // Found !
return ii; return ii;
} }
return -1; return -1;
} }
/** /**
* Function GetAreaCount * Function GetAreaCount
* @return int - The number of Areas or ZONE_CONTAINER. * @return int - The number of Areas or ZONE_CONTAINER.
...@@ -324,132 +326,132 @@ public: ...@@ -324,132 +326,132 @@ public:
return (int) m_ZoneDescriptorList.size(); return (int) m_ZoneDescriptorList.size();
} }
/* Functions used in test, merge and cut outlines */ /* Functions used in test, merge and cut outlines */
/** /**
* Function AddArea * Function AddArea
* add empty copper area to net * add empty copper area to net
* @return pointer to the new area * @return pointer to the new area
*/ */
ZONE_CONTAINER* AddArea( int netcode, int layer, int x, int y, int hatch ); ZONE_CONTAINER* AddArea( int netcode, int layer, int x, int y, int hatch );
/** /**
* remove copper area from net * remove copper area from net
* @param area = area to remove * @param area = area to remove
* @return 0 * @return 0
*/ */
int RemoveArea( ZONE_CONTAINER* area_to_remove ); int RemoveArea( ZONE_CONTAINER* area_to_remove );
/** /**
* Function InsertArea * Function InsertArea
* add empty copper area to net, inserting after m_ZoneDescriptorList[iarea] * add empty copper area to net, inserting after m_ZoneDescriptorList[iarea]
* @return pointer to the new area * @return pointer to the new area
*/ */
ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch ); ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch );
/** /**
Function CompleteArea Function CompleteArea
* complete copper area contour by adding a line from last to first corner * complete copper area contour by adding a line from last to first corner
* if there is only 1 or 2 corners, remove (delete) the area * if there is only 1 or 2 corners, remove (delete) the area
* @param area_to_complete = area to complete or remove * @param area_to_complete = area to complete or remove
* @param style = style of last corner * @param style = style of last corner
* @return 1 if Ok, 0 if area removed * @return 1 if Ok, 0 if area removed
*/ */
int CompleteArea( ZONE_CONTAINER* area_to_complete, int style ); int CompleteArea( ZONE_CONTAINER* area_to_complete, int style );
/** /**
* Function TestAreaPolygon * Function TestAreaPolygon
* Test an area for self-intersection. * Test an area for self-intersection.
* *
* @param CurrArea = copper area to test * @param CurrArea = copper area to test
* @return : * @return :
* -1 if arcs intersect other sides * -1 if arcs intersect other sides
* 0 if no intersecting sides * 0 if no intersecting sides
* 1 if intersecting sides, but no intersecting arcs * 1 if intersecting sides, but no intersecting arcs
* Also sets utility2 flag of area with return value * Also sets utility2 flag of area with return value
*/ */
int TestAreaPolygon( ZONE_CONTAINER* CurrArea ); int TestAreaPolygon( ZONE_CONTAINER* CurrArea );
/** /**
* Function ClipAreaPolygon * Function ClipAreaPolygon
* Process an area that has been modified, by clipping its polygon against itself. * Process an area that has been modified, by clipping its polygon against itself.
* This may change the number and order of copper areas in the net. * This may change the number and order of copper areas in the net.
* @param bMessageBoxInt == TRUE, shows message when clipping occurs. * @param bMessageBoxInt == TRUE, shows message when clipping occurs.
* @param bMessageBoxArc == TRUE, shows message when clipping can't be done due to arcs. * @param bMessageBoxArc == TRUE, shows message when clipping can't be done due to arcs.
* @return: * @return:
* -1 if arcs intersect other sides, so polygon can't be clipped * -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides * 0 if no intersecting sides
* 1 if intersecting sides * 1 if intersecting sides
* Also sets areas->utility1 flags if areas are modified * Also sets areas->utility1 flags if areas are modified
*/ */
int ClipAreaPolygon( ZONE_CONTAINER* CurrArea, int ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs = TRUE ); bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs = TRUE );
/** /**
* Process an area that has been modified, by clipping its polygon against * Process an area that has been modified, by clipping its polygon against
* itself and the polygons for any other areas on the same net. * itself and the polygons for any other areas on the same net.
* This may change the number and order of copper areas in the net. * This may change the number and order of copper areas in the net.
* @param modified_area = area to test * @param modified_area = area to test
* @param bMessageBox : if TRUE, shows message boxes when clipping occurs. * @param bMessageBox : if TRUE, shows message boxes when clipping occurs.
* @return : * @return :
* -1 if arcs intersect other sides, so polygon can't be clipped * -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides * 0 if no intersecting sides
* 1 if intersecting sides, polygon clipped * 1 if intersecting sides, polygon clipped
*/ */
int AreaPolygonModified( ZONE_CONTAINER* modified_area, int AreaPolygonModified( ZONE_CONTAINER* modified_area,
bool bMessageBoxArc, bool bMessageBoxArc,
bool bMessageBoxInt ); bool bMessageBoxInt );
/** /**
* Function CombineAllAreasInNet * Function CombineAllAreasInNet
* Checks all copper areas in net for intersections, combining them if found * Checks all copper areas in net for intersections, combining them if found
* @param aNetCode = net to consider * @param aNetCode = net to consider
* @param bMessageBox : if true display warning message box * @param bMessageBox : if true display warning message box
* @param bUseUtility : if true, don't check areas if both utility flags are 0 * @param bUseUtility : if true, don't check areas if both utility flags are 0
* Sets utility flag = 1 for any areas modified * Sets utility flag = 1 for any areas modified
* If an area has self-intersecting arcs, doesn't try to combine it * If an area has self-intersecting arcs, doesn't try to combine it
*/ */
int CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtility ); int CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtility );
/** /**
* Function TestAreaIntersections * Function TestAreaIntersections
* Check for intersection of a given copper area with other areas in same net * Check for intersection of a given copper area with other areas in same net
* @param area_to_test = area to compare to all other areas in the same net * @param area_to_test = area to compare to all other areas in the same net
*/ */
bool TestAreaIntersections( ZONE_CONTAINER* area_to_test ); bool TestAreaIntersections( ZONE_CONTAINER* area_to_test );
/** /**
* Function TestAreaIntersection * Function TestAreaIntersection
* Test for intersection of 2 copper areas * Test for intersection of 2 copper areas
* area_to_test must be after area_ref in m_ZoneDescriptorList * area_to_test must be after area_ref in m_ZoneDescriptorList
* @param area_ref = area reference * @param area_ref = area reference
* @param area_to_test = area to compare for intersection calculations * @param area_to_test = area to compare for intersection calculations
* @return : 0 if no intersection * @return : 0 if no intersection
* 1 if intersection * 1 if intersection
* 2 if arcs intersect * 2 if arcs intersect
*/ */
int TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test ); int TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test );
/** /**
* Function CombineAreas * Function CombineAreas
* If possible, combine 2 copper areas * If possible, combine 2 copper areas
* area_ref must be BEFORE area_to_combine * area_ref must be BEFORE area_to_combine
* area_to_combine will be deleted, if areas are combined * area_to_combine will be deleted, if areas are combined
* @return : 0 if no intersection * @return : 0 if no intersection
* 1 if intersection * 1 if intersection
* 2 if arcs intersect * 2 if arcs intersect
*/ */
int CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combine ); int CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combine );
/** /**
* Function Test_Drc_Areas_Outlines_To_Areas_Outlines * Function Test_Drc_Areas_Outlines_To_Areas_Outlines
* Test Areas outlines for DRC: * Test Areas outlines for DRC:
* Test areas inside other areas * Test areas inside other areas
* Test areas too close * Test areas too close
* @param aArea_To_Examine: area to compare with other areas. if NULL: all areas are compared tp all others * @param aArea_To_Examine: area to compare with other areas. if NULL: all areas are compared tp all others
* @param aCreate_Markers: if true create DRC markers. False: do not creates anything * @param aCreate_Markers: if true create DRC markers. False: do not creates anything
* @return errors count * @return errors count
*/ */
int Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_Examine,bool aCreate_Markers ); int Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_Examine,bool aCreate_Markers );
}; };
#endif // #ifndef CLASS_BOARD_H #endif // #ifndef CLASS_BOARD_H
...@@ -150,9 +150,9 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings() ...@@ -150,9 +150,9 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_ViaDrill = 250; // defualt via drill (for the entire board) 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_ViaDrillCustomValue = 250; // via drill for vias which must have a defined drill value
m_CurrentViaSize = 450; // Current via size 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_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_MicroViaDrill = 50; // micro via drill (for the entire board)
m_CurrentMicroViaSize = 150; // Current micro via size m_CurrentMicroViaSize = 150; // Current micro via size
m_MicroViasAllowed = false; // true to allow micro vias m_MicroViasAllowed = false; // true to allow micro vias
......
...@@ -387,7 +387,6 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) ...@@ -387,7 +387,6 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
* Routine de fin de trace d'une piste (succession de segments) * Routine de fin de trace d'une piste (succession de segments)
*/ */
{ {
TRACK* pt_track;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
wxPoint pos; wxPoint pos;
EDA_BaseStruct* LockPoint; EDA_BaseStruct* LockPoint;
...@@ -453,11 +452,8 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) ...@@ -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 */ /* Test if no segment left. Can happend on a double click on the start point */
if( g_FirstTrackSegment != NULL ) if( g_FirstTrackSegment != NULL )
{ {
/* Put new track in buffer: search the best insertion poinr */ // Put new track in board
pt_track = g_FirstTrackSegment->GetBestInsertPoint( m_Pcb ); m_Pcb->Add( g_FirstTrackSegment );
/* Uut track in linked list */
g_FirstTrackSegment->Insert( m_Pcb, pt_track );
trace_ratsnest_pad( DC ); trace_ratsnest_pad( DC );
Trace_Une_Piste( DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); Trace_Une_Piste( DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR );
...@@ -466,7 +462,8 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) ...@@ -466,7 +462,8 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
TRACK* ptr = g_FirstTrackSegment; int ii; TRACK* ptr = g_FirstTrackSegment; int ii;
for( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount); 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 */ /* Delete the old track, if exists */
...@@ -527,16 +524,16 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -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 */ /* dessin de la nouvelle piste : mise a jour du point d'arrivee */
g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer ); g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
if( ! g_DesignSettings.m_UseConnectedTrackWidth ) if( ! g_DesignSettings.m_UseConnectedTrackWidth )
g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
TRACK* previous_track = (TRACK*) g_CurrentTrackSegment->Pback; TRACK* previous_track = (TRACK*) g_CurrentTrackSegment->Pback;
if( previous_track && (previous_track->Type() == TYPETRACK) ) if( previous_track && (previous_track->Type() == TYPETRACK) )
{ {
previous_track->SetLayer( screen->m_Active_Layer ); previous_track->SetLayer( screen->m_Active_Layer );
if( ! g_DesignSettings.m_UseConnectedTrackWidth ) if( ! g_DesignSettings.m_UseConnectedTrackWidth )
previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
} }
} }
if( Track_45_Only ) if( Track_45_Only )
......
...@@ -30,313 +30,315 @@ void WinEDA_PcbFrame::ReCreateMenuBar() ...@@ -30,313 +30,315 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
int ii; int ii;
wxMenuBar * menuBar = GetMenuBar(); wxMenuBar * menuBar = GetMenuBar();
if( menuBar == NULL ) if( menuBar == NULL )
{ {
menuBar = new wxMenuBar(); menuBar = new wxMenuBar();
////////////////// //////////////////
// Menu "Files" // // Menu "Files" //
////////////////// //////////////////
m_FilesMenu = new wxMenu; m_FilesMenu = new wxMenu;
wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_MENU_LOAD_FILE, wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_MENU_LOAD_FILE,
_("Load Board Ctrl-O"), _("Load Board Ctrl-O"),
_("Delete old Board and Load new Board")); _("Delete old Board and Load new Board"));
item->SetBitmap(open_xpm); item->SetBitmap(open_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
item = new wxMenuItem(m_FilesMenu, ID_MENU_APPEND_FILE, item = new wxMenuItem(m_FilesMenu, ID_MENU_APPEND_FILE,
_("Append Board"), _("Append Board"),
_("Add Board to old Board")); _("Add Board to old Board"));
item->SetBitmap(import_xpm); item->SetBitmap(import_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
item = new wxMenuItem(m_FilesMenu, ID_MENU_NEW_BOARD, item = new wxMenuItem(m_FilesMenu, ID_MENU_NEW_BOARD,
_("&New board"), _("&New board"),
_("Clear old PCB and init a new one")); _("Clear old PCB and init a new one"));
item->SetBitmap(new_xpm); item->SetBitmap(new_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
item = new wxMenuItem(m_FilesMenu, ID_MENU_RECOVER_BOARD, item = new wxMenuItem(m_FilesMenu, ID_MENU_RECOVER_BOARD,
_("&Rescue"), _("&Rescue"),
_("Clear old board and get last rescue file")); _("Clear old board and get last rescue file"));
item->SetBitmap(hammer_xpm); item->SetBitmap(hammer_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
item = new wxMenuItem(m_FilesMenu, ID_MENU_READ_LAST_SAVED_VERSION_BOARD, item = new wxMenuItem(m_FilesMenu, ID_MENU_READ_LAST_SAVED_VERSION_BOARD,
_("&Previous version"), _("&Previous version"),
_("Clear old board and get old version of board") ); _("Clear old board and get old version of board") );
item->SetBitmap(jigsaw_xpm); item->SetBitmap(jigsaw_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
// Add save menu // Add save menu
m_FilesMenu->AppendSeparator(); m_FilesMenu->AppendSeparator();
item = new wxMenuItem(m_FilesMenu, ID_MENU_SAVE_BOARD, item = new wxMenuItem(m_FilesMenu, ID_MENU_SAVE_BOARD,
_("&Save board Ctrl-S"), _("&Save board Ctrl-S"),
_("Save current board") ); _("Save current board") );
item->SetBitmap(save_xpm); item->SetBitmap(save_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
item = new wxMenuItem(m_FilesMenu, ID_MENU_SAVE_BOARD_AS, item = new wxMenuItem(m_FilesMenu, ID_MENU_SAVE_BOARD_AS,
_("Save Board as.."), _("Save Board as.."),
_("Save current board as..") ); _("Save current board as..") );
item->SetBitmap(save_as_xpm); item->SetBitmap(save_as_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
// Add print menu // Add print menu
m_FilesMenu->AppendSeparator(); m_FilesMenu->AppendSeparator();
item = new wxMenuItem(m_FilesMenu, ID_GEN_PRINT, item = new wxMenuItem(m_FilesMenu, ID_GEN_PRINT,
_("P&rint"), _("Print on current printer")); _("P&rint"), _("Print on current printer"));
item->SetBitmap(print_button); item->SetBitmap(print_button);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
// Add plot menu // Add plot menu
item = new wxMenuItem(m_FilesMenu, ID_GEN_PLOT, _("&Plot"), item = new wxMenuItem(m_FilesMenu, ID_GEN_PLOT, _("&Plot"),
_("Plot (HPGL, PostScript, or Gerber format)")); _("Plot (HPGL, PostScript, or Gerber format)"));
item->SetBitmap(plot_xpm); item->SetBitmap(plot_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
// Add Export menu // Add Export menu
m_FilesMenu->AppendSeparator(); m_FilesMenu->AppendSeparator();
wxMenu * submenuexport = new wxMenu(); wxMenu * submenuexport = new wxMenu();
item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_SPECCTRA, item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_SPECCTRA,
_("&Specctra DSN"), _("Export the current board to a \"Specctra DSN\" file") ); _("&Specctra DSN"), _("Export the current board to a \"Specctra DSN\" file") );
item->SetBitmap(export_xpm); item->SetBitmap(export_xpm);
submenuexport->Append(item); submenuexport->Append(item);
item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_FILE_GENCADFORMAT, item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_FILE_GENCADFORMAT,
_("&GenCAD"), _("Export GenCAD Format") ); _("&GenCAD"), _("Export GenCAD Format") );
item->SetBitmap(export_xpm); item->SetBitmap(export_xpm);
submenuexport->Append(item); submenuexport->Append(item);
item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_FILE_MODULE_REPORT, item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_FILE_MODULE_REPORT,
_("&Module report"), _("Create a pcb report (footprint report)") ); _("&Module report"), _("Create a pcb report (footprint report)") );
item->SetBitmap(tools_xpm); item->SetBitmap(tools_xpm);
submenuexport->Append(item); submenuexport->Append(item);
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuexport, ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuexport,
ID_GEN_EXPORT_FILE, _("E&xport"), _("Export board"), export_xpm); ID_GEN_EXPORT_FILE, _("E&xport"), _("Export board"), export_xpm);
//-----<Add import menu>----------------------------------------------- //-----<Add import menu>-----------------------------------------------
// no separator, keep it next to Import // no separator, keep it next to Import
wxMenu * submenuImport = new wxMenu(); wxMenu * submenuImport = new wxMenu();
item = new wxMenuItem(submenuImport, ID_GEN_IMPORT_SPECCTRA_SESSION, item = new wxMenuItem(submenuImport, ID_GEN_IMPORT_SPECCTRA_SESSION,
_("&Specctra Session"), _("Import a routed \"Specctra Session\" (*.ses) file") ); _("&Specctra Session"), _("Import a routed \"Specctra Session\" (*.ses) file") );
item->SetBitmap(export_xpm); // @todo need better bitmap item->SetBitmap(export_xpm); // @todo need better bitmap
submenuImport->Append(item); submenuImport->Append(item);
item = new wxMenuItem(submenuImport, ID_GEN_IMPORT_SPECCTRA_DESIGN, /* would be implemented in WinEDA_PcbFrame::ImportSpecctraDesign() in specctra_import.cpp
_("&Specctra Design"), _("Import a \"Specctra Design\" (*.dsn) file") ); item = new wxMenuItem(submenuImport, ID_GEN_IMPORT_SPECCTRA_DESIGN,
item->SetBitmap(export_xpm); // @todo need better bitmap _("&Specctra Design"), _("Import a \"Specctra Design\" (*.dsn) file") );
submenuImport->Append(item); 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);
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuImport,
ID_GEN_IMPORT_FILE, _("Import"), _("Import files"), export_xpm);
//-----</Add import menu>---------------------------------------------- //-----</Add import menu>----------------------------------------------
// Add archive footprints menu // Add archive footprints menu
m_FilesMenu->AppendSeparator(); m_FilesMenu->AppendSeparator();
wxMenu * submenuarchive = new wxMenu(); wxMenu * submenuarchive = new wxMenu();
item = new wxMenuItem(submenuarchive, ID_MENU_ARCHIVE_NEW_MODULES, item = new wxMenuItem(submenuarchive, ID_MENU_ARCHIVE_NEW_MODULES,
_("Add new footprints"), _("Add new footprints"),
_("Archive new footprints only in a library (keep other footprints in this lib)") ); _("Archive new footprints only in a library (keep other footprints in this lib)") );
item->SetBitmap(library_update_xpm); item->SetBitmap(library_update_xpm);
submenuarchive->Append(item); submenuarchive->Append(item);
item = new wxMenuItem(submenuarchive, ID_MENU_ARCHIVE_ALL_MODULES, item = new wxMenuItem(submenuarchive, ID_MENU_ARCHIVE_ALL_MODULES,
_("Create footprint archive"), _("Create footprint archive"),
_("Archive all footprints in a library(old lib will be deleted)") ); _("Archive all footprints in a library(old lib will be deleted)") );
item->SetBitmap(library_xpm); item->SetBitmap(library_xpm);
submenuarchive->Append(item); submenuarchive->Append(item);
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuarchive, ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuarchive,
ID_MENU_ARCHIVE_MODULES, ID_MENU_ARCHIVE_MODULES,
_("Archive footprints"), _("Archive footprints"),
_("Archive or Add footprints in a library file"), library_xpm); _("Archive or Add footprints in a library file"), library_xpm);
// Add exit menu // Add exit menu
m_FilesMenu->AppendSeparator(); m_FilesMenu->AppendSeparator();
item = new wxMenuItem(m_FilesMenu, ID_EXIT, _("E&xit"), _("Quit pcbnew") ); item = new wxMenuItem(m_FilesMenu, ID_EXIT, _("E&xit"), _("Quit pcbnew") );
item->SetBitmap(exit_xpm); item->SetBitmap(exit_xpm);
m_FilesMenu->Append(item); m_FilesMenu->Append(item);
// Creation des selections des anciens fichiers // Creation des selections des anciens fichiers
m_FilesMenu->AppendSeparator(); m_FilesMenu->AppendSeparator();
int max_file = m_Parent->m_LastProjectMaxCount; int max_file = m_Parent->m_LastProjectMaxCount;
for ( ii = 0; ii < max_file; ii++ ) for ( ii = 0; ii < max_file; ii++ )
{ {
if ( GetLastProject(ii).IsEmpty() ) break; if ( GetLastProject(ii).IsEmpty() ) break;
m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) );
} }
/////////////////////////////////// ///////////////////////////////////
// Configuration et preferences: // // Configuration et preferences: //
/////////////////////////////////// ///////////////////////////////////
wxMenu * configmenu = new wxMenu; wxMenu * configmenu = new wxMenu;
item = new wxMenuItem(configmenu, ID_CONFIG_REQ, _("&Libs and Dir"), item = new wxMenuItem(configmenu, ID_CONFIG_REQ, _("&Libs and Dir"),
_("Setting Libraries, Directories and others...")); _("Setting Libraries, Directories and others..."));
item->SetBitmap(library_xpm); item->SetBitmap(library_xpm);
configmenu->Append(item); configmenu->Append(item);
item = new wxMenuItem(configmenu, ID_COLORS_SETUP, _("&Colors"), item = new wxMenuItem(configmenu, ID_COLORS_SETUP, _("&Colors"),
_("Select Colors and Display for PCB items")); _("Select Colors and Display for PCB items"));
item->SetBitmap(palette_xpm); item->SetBitmap(palette_xpm);
configmenu->Append(item); configmenu->Append(item);
item = new wxMenuItem(configmenu, ID_OPTIONS_SETUP, _("&General Options"), item = new wxMenuItem(configmenu, ID_OPTIONS_SETUP, _("&General Options"),
_("Select general options for pcbnew")); _("Select general options for pcbnew"));
item->SetBitmap(preference_xpm); item->SetBitmap(preference_xpm);
configmenu->Append(item); configmenu->Append(item);
item = new wxMenuItem(configmenu, ID_PCB_LOOK_SETUP, _("&Display Options"), item = new wxMenuItem(configmenu, ID_PCB_LOOK_SETUP, _("&Display Options"),
_("Select what items are displayed")); _("Select what items are displayed"));
item->SetBitmap(display_options_xpm); item->SetBitmap(display_options_xpm);
configmenu->Append(item); configmenu->Append(item);
// Font selection and setup // Font selection and setup
AddFontSelectionMenu(configmenu); AddFontSelectionMenu(configmenu);
m_Parent->SetLanguageList(configmenu); m_Parent->SetLanguageList(configmenu);
configmenu->AppendSeparator(); configmenu->AppendSeparator();
item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, _("&Save preferences"), item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, _("&Save preferences"),
_("Save application preferences")); _("Save application preferences"));
item->SetBitmap(save_setup_xpm); item->SetBitmap(save_setup_xpm);
configmenu->Append(item); configmenu->Append(item);
item = new wxMenuItem(configmenu, ID_CONFIG_READ, _("&Read preferences"), item = new wxMenuItem(configmenu, ID_CONFIG_READ, _("&Read preferences"),
_("Read application preferences")); _("Read application preferences"));
item->SetBitmap(read_setup_xpm); item->SetBitmap(read_setup_xpm);
configmenu->Append(item); configmenu->Append(item);
configmenu->AppendSeparator(); configmenu->AppendSeparator();
AddHotkeyConfigMenu( configmenu ); AddHotkeyConfigMenu( configmenu );
///////////////////////////// /////////////////////////////
// Ajustage de dimensions: // // Ajustage de dimensions: //
///////////////////////////// /////////////////////////////
wxMenu * sizes_menu = new wxMenu; wxMenu * sizes_menu = new wxMenu;
item = new wxMenuItem(sizes_menu, ID_PCB_TRACK_SIZE_SETUP, _("Tracks and Vias"), item = new wxMenuItem(sizes_menu, ID_PCB_TRACK_SIZE_SETUP, _("Tracks and Vias"),
_("Adjust size and width for tracks, vias")); _("Adjust size and width for tracks, vias"));
item->SetBitmap(showtrack_xpm); item->SetBitmap(showtrack_xpm);
sizes_menu->Append(item); sizes_menu->Append(item);
item = new wxMenuItem(sizes_menu, ID_PCB_USER_GRID_SETUP, _("User Grid Size"), item = new wxMenuItem(sizes_menu, ID_PCB_USER_GRID_SETUP, _("User Grid Size"),
_("Adjust User Grid")); _("Adjust User Grid"));
item->SetBitmap(grid_xpm); item->SetBitmap(grid_xpm);
sizes_menu->Append(item); sizes_menu->Append(item);
item = new wxMenuItem(sizes_menu, ID_PCB_DRAWINGS_WIDTHS_SETUP, _("Texts and Drawings"), item = new wxMenuItem(sizes_menu, ID_PCB_DRAWINGS_WIDTHS_SETUP, _("Texts and Drawings"),
_("Adjust width for texts and drawings")); _("Adjust width for texts and drawings"));
item->SetBitmap(options_text_xpm); item->SetBitmap(options_text_xpm);
sizes_menu->Append(item); sizes_menu->Append(item);
item = new wxMenuItem(sizes_menu, ID_PCB_PAD_SETUP, _("Pad Settings"), item = new wxMenuItem(sizes_menu, ID_PCB_PAD_SETUP, _("Pad Settings"),
_("Adjust size,shape,layers... for Pads")); _("Adjust size,shape,layers... for Pads"));
item->SetBitmap(pad_xpm); item->SetBitmap(pad_xpm);
sizes_menu->Append(item); sizes_menu->Append(item);
sizes_menu->AppendSeparator(); sizes_menu->AppendSeparator();
item = new wxMenuItem(sizes_menu, ID_CONFIG_SAVE, _("&Save Setup"), item = new wxMenuItem(sizes_menu, ID_CONFIG_SAVE, _("&Save Setup"),
_("Save options in current directory")); _("Save options in current directory"));
item->SetBitmap(save_xpm); item->SetBitmap(save_xpm);
sizes_menu->Append(item); sizes_menu->Append(item);
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// Menu postprocess ( generation fichiers percage, placement... // // Menu postprocess ( generation fichiers percage, placement... //
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
wxMenu *postprocess_menu = new wxMenu; wxMenu *postprocess_menu = new wxMenu;
item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_POS_MODULES_FILE, item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_POS_MODULES_FILE,
_("Create &Modules Pos"), _("Create &Modules Pos"),
_("Gen Position modules file")); _("Gen Position modules file"));
item->SetBitmap(post_compo_xpm); item->SetBitmap(post_compo_xpm);
postprocess_menu->Append(item); postprocess_menu->Append(item);
item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_DRILL_FILE, _("Create &Drill file"), item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_DRILL_FILE, _("Create &Drill file"),
_("Gen Drill (EXCELLON] file and/or Drill sheet")); _("Gen Drill (EXCELLON] file and/or Drill sheet"));
item->SetBitmap(post_drill_xpm); item->SetBitmap(post_drill_xpm);
postprocess_menu->Append(item); postprocess_menu->Append(item);
item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_CMP_FILE, _("Create &Cmp file"), item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_CMP_FILE, _("Create &Cmp file"),
_("Recreate .cmp file for CvPcb")); _("Recreate .cmp file for CvPcb"));
item->SetBitmap(save_cmpstuff_xpm); item->SetBitmap(save_cmpstuff_xpm);
postprocess_menu->Append(item); postprocess_menu->Append(item);
////////////////////////// //////////////////////////
// Menu d'outils divers // // Menu d'outils divers //
////////////////////////// //////////////////////////
wxMenu *miscellaneous_menu = new wxMenu; wxMenu *miscellaneous_menu = new wxMenu;
item = new wxMenuItem(miscellaneous_menu, ID_PCB_GLOBAL_DELETE, _("Global &Deletions"), item = new wxMenuItem(miscellaneous_menu, ID_PCB_GLOBAL_DELETE, _("Global &Deletions"),
_("Delete Tracks, Modules, Texts... on Board")); _("Delete Tracks, Modules, Texts... on Board"));
item->SetBitmap(general_deletions_xpm); item->SetBitmap(general_deletions_xpm);
miscellaneous_menu->Append(item); miscellaneous_menu->Append(item);
item = new wxMenuItem(miscellaneous_menu, ID_MENU_LIST_NETS, _("&List nets"), item = new wxMenuItem(miscellaneous_menu, ID_MENU_LIST_NETS, _("&List nets"),
_("List nets (names and id)")); _("List nets (names and id)"));
item->SetBitmap(tools_xpm); item->SetBitmap(tools_xpm);
miscellaneous_menu->Append(item); miscellaneous_menu->Append(item);
item = new wxMenuItem(miscellaneous_menu, ID_MENU_PCB_CLEAN, _("&Track operations"), item = new wxMenuItem(miscellaneous_menu, ID_MENU_PCB_CLEAN, _("&Track operations"),
_("Clean stubs, vias, delete break points, or connect dangling tracks to pads and vias")); _("Clean stubs, vias, delete break points, or connect dangling tracks to pads and vias"));
item->SetBitmap(delete_body_xpm); item->SetBitmap(delete_body_xpm);
miscellaneous_menu->Append(item); miscellaneous_menu->Append(item);
item = new wxMenuItem(miscellaneous_menu, ID_MENU_PCB_SWAP_LAYERS, _("&Swap layers"), item = new wxMenuItem(miscellaneous_menu, ID_MENU_PCB_SWAP_LAYERS, _("&Swap layers"),
_("Swap tracks on copper layers or drawings on others layers")); _("Swap tracks on copper layers or drawings on others layers"));
item->SetBitmap(swap_layer_xpm); item->SetBitmap(swap_layer_xpm);
miscellaneous_menu->Append(item); miscellaneous_menu->Append(item);
//////////////// ////////////////
// Menu Help: // // Menu Help: //
//////////////// ////////////////
wxMenu *helpMenu = new wxMenu; wxMenu *helpMenu = new wxMenu;
item = new wxMenuItem(helpMenu , ID_GENERAL_HELP, _("&Contents"), _("Open the pcbnew manual")); item = new wxMenuItem(helpMenu , ID_GENERAL_HELP, _("&Contents"), _("Open the pcbnew manual"));
item->SetBitmap(help_xpm); item->SetBitmap(help_xpm);
helpMenu->Append(item); helpMenu->Append(item);
item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT, _("&About"), _("About this application")); item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT, _("&About"), _("About this application"));
item->SetBitmap(info_xpm); item->SetBitmap(info_xpm);
helpMenu->Append(item); helpMenu->Append(item);
////////////////////// //////////////////////
// Menu Display 3D: // // Menu Display 3D: //
////////////////////// //////////////////////
wxMenu *Display3DMenu = new wxMenu; wxMenu *Display3DMenu = new wxMenu;
item = new wxMenuItem(Display3DMenu , ID_MENU_PCB_SHOW_3D_FRAME, _("3D Display"), _("Show Board in 3D Mode")); item = new wxMenuItem(Display3DMenu , ID_MENU_PCB_SHOW_3D_FRAME, _("3D Display"), _("Show Board in 3D Mode"));
item->SetBitmap(show_3d_xpm); item->SetBitmap(show_3d_xpm);
Display3DMenu->Append(item); Display3DMenu->Append(item);
menuBar->Append(m_FilesMenu, _("&File")); menuBar->Append(m_FilesMenu, _("&File"));
menuBar->Append(configmenu, _("&Preferences")); menuBar->Append(configmenu, _("&Preferences"));
menuBar->Append(sizes_menu, _("&Dimensions")); menuBar->Append(sizes_menu, _("&Dimensions"));
menuBar->Append(miscellaneous_menu, _("&Miscellaneous")); menuBar->Append(miscellaneous_menu, _("&Miscellaneous"));
menuBar->Append(postprocess_menu, _("P&ostprocess")); menuBar->Append(postprocess_menu, _("P&ostprocess"));
menuBar->Append(Display3DMenu, _("&3D Display")); menuBar->Append(Display3DMenu, _("&3D Display"));
menuBar->Append(helpMenu, _("&Help")); menuBar->Append(helpMenu, _("&Help"));
// Associate the menu bar with the frame // Associate the menu bar with the frame
SetMenuBar(menuBar); SetMenuBar(menuBar);
} }
else // simple mise a jour de la liste des fichiers anciens else // simple mise a jour de la liste des fichiers anciens
{ {
wxMenuItem * item; wxMenuItem * item;
int max_file = m_Parent->m_LastProjectMaxCount; int max_file = m_Parent->m_LastProjectMaxCount;
for ( ii = max_file-1; ii >=0 ; ii-- ) for ( ii = max_file-1; ii >=0 ; ii-- )
{ {
if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) )
{ {
item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii);
if ( item ) delete item; if ( item ) delete item;
} }
} }
for ( ii = 0; ii < max_file; ii++ ) for ( ii = 0; ii < max_file; ii++ )
{ {
if ( GetLastProject(ii).IsEmpty() ) break; if ( GetLastProject(ii).IsEmpty() ) break;
m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) );
} }
} }
} }
...@@ -312,7 +312,7 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides ) ...@@ -312,7 +312,7 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
* coord destination (row,col) * coord destination (row,col)
* net_code * net_code
* pointeur sur le chevelu de reference * pointeur sur le chevelu de reference
* *
* Retourne : * Retourne :
* SUCCESS si route trouvee * SUCCESS si route trouvee
* TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer) * TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer)
...@@ -722,10 +722,10 @@ static long bit[8][9] = { /* OT=Otherside */ ...@@ -722,10 +722,10 @@ static long bit[8][9] = { /* OT=Otherside */
* La recherche se fait en sens inverse du routage, * La recherche se fait en sens inverse du routage,
* c.a.d du point d'arrivee (target) vers le point de depart (source) * c.a.d du point d'arrivee (target) vers le point de depart (source)
* du routeur. * du routeur.
* *
* target_side = cote (TOP / BOTTOM) de depart * target_side = cote (TOP / BOTTOM) de depart
* mask_layer_source = masque des couches d'arrivee * mask_layer_source = masque des couches d'arrivee
* *
* Retourne: * Retourne:
* 0 si erreur * 0 si erreur
* > 0 si Ok * > 0 si Ok
...@@ -983,7 +983,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -983,7 +983,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
NewTrack->Insert( pcb, g_CurrentTrackSegment ); NewTrack->Insert( pcb, g_CurrentTrackSegment );
g_CurrentTrackSegment->m_Start = pt_cur_ch->pad_end->GetPosition(); g_CurrentTrackSegment->m_Start = pt_cur_ch->pad_end->GetPosition();
NewTrack->m_Start = g_CurrentTrackSegment->m_End; NewTrack->m_Start = g_CurrentTrackSegment->m_End;
g_CurrentTrackSegment = NewTrack; g_CurrentTrackSegment = NewTrack;
...@@ -1065,10 +1065,10 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1065,10 +1065,10 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
NewTrack->Insert( pcbframe->m_Pcb, g_CurrentTrackSegment ); NewTrack->Insert( pcbframe->m_Pcb, g_CurrentTrackSegment );
NewTrack->m_End = pt_cur_ch->pad_start->GetPosition(); NewTrack->m_End = pt_cur_ch->pad_start->GetPosition();
NewTrack->m_Start = g_CurrentTrackSegment->m_End; NewTrack->m_Start = g_CurrentTrackSegment->m_End;
g_CurrentTrackSegment = NewTrack; g_CurrentTrackSegment = NewTrack;
g_TrackSegmentCount++; g_TrackSegmentCount++;
} }
...@@ -1082,8 +1082,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1082,8 +1082,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
g_CurrentTrackSegment->SetState( END_ONPAD, ON ); g_CurrentTrackSegment->SetState( END_ONPAD, ON );
/* recherche de la zone de rangement et insertion de la nouvelle piste */ /* recherche de la zone de rangement et insertion de la nouvelle piste */
pt_track = g_FirstTrackSegment->GetBestInsertPoint( pcbframe->m_Pcb ); pcbframe->m_Pcb->Add( g_FirstTrackSegment );
g_FirstTrackSegment->Insert( pcbframe->m_Pcb, pt_track );
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR );
......
...@@ -3760,7 +3760,12 @@ class SPECCTRA_DB : public OUTPUTFORMATTER ...@@ -3760,7 +3760,12 @@ class SPECCTRA_DB : public OUTPUTFORMATTER
TRACK* makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IOError ); 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>---------------------------------------------------- //-----</FromSESSION>----------------------------------------------------
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "wxPcbStruct.h" // Change_Side_Module() #include "wxPcbStruct.h" // Change_Side_Module()
#include "pcbstruct.h" // HISTORY_NUMBER #include "pcbstruct.h" // HISTORY_NUMBER
#include "autorout.h" // NET_CODES_OK #include "autorout.h" // NET_CODES_OK
#include "trigo.h" // RotatePoint()
#include <set> // std::set #include <set> // std::set
...@@ -351,8 +353,38 @@ IMAGE* SPECCTRA_DB::makeIMAGE( MODULE* aModule ) ...@@ -351,8 +353,38 @@ IMAGE* SPECCTRA_DB::makeIMAGE( MODULE* aModule )
pin->padstack_id = padstack->padstack_id; pin->padstack_id = padstack->padstack_id;
pin->pin_id = CONV_TO_UTF8( pad->ReturnStringPadName() ); pin->pin_id = CONV_TO_UTF8( pad->ReturnStringPadName() );
// copper shape's position is hole position + offset #if 0
wxPoint pos = pad->m_Pos0 + pad->m_Offset; 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 ) ); pin->SetVertex( mapPt( pos ) );
} }
...@@ -385,8 +417,8 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia ) ...@@ -385,8 +417,8 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia )
circle->SetLayerId( "signal" ); circle->SetLayerId( "signal" );
snprintf( name, sizeof(name), "Via_%.6g:%.6g_mil", dsnDiameter, snprintf( name, sizeof(name), "Via[A]%.6g:%.6g_mil", dsnDiameter,
// encode the drill value in the name for later import // encode the drill value into the name for later import
scale( aVia->GetDrillValue() ) ); scale( aVia->GetDrillValue() ) );
name[ sizeof(name)-1 ] = 0; name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name ); padstack->SetPadstackId( name );
...@@ -418,7 +450,7 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia ) ...@@ -418,7 +450,7 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia )
snprintf( name, sizeof(name), "Via[%d-%d]_%.6g:%.6g_mil", snprintf( name, sizeof(name), "Via[%d-%d]_%.6g:%.6g_mil",
topLayer, botLayer, dsnDiameter, 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() ) scale( aVia->GetDrillValue() )
); );
name[ sizeof(name)-1 ] = 0; name[ sizeof(name)-1 ] = 0;
...@@ -446,8 +478,8 @@ PADSTACK* SPECCTRA_DB::makeVia( int aCopperDiameter, int aDrillDiameter ) ...@@ -446,8 +478,8 @@ PADSTACK* SPECCTRA_DB::makeVia( int aCopperDiameter, int aDrillDiameter )
circle->SetLayerId( "signal" ); circle->SetLayerId( "signal" );
snprintf( name, sizeof(name), "Via_%.6g:%.6g_mil", dsnDiameter, snprintf( name, sizeof(name), "Via[A]%.6g:%.6g_mil", dsnDiameter,
// encode the drill value in the name for later import // encode the drill value into the name for later import
scale( aDrillDiameter ) ); scale( aDrillDiameter ) );
name[ sizeof(name)-1 ] = 0; name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name ); padstack->SetPadstackId( name );
......
...@@ -150,6 +150,14 @@ static int scale( double distance, UNIT_RES* aResolution ) ...@@ -150,6 +150,14 @@ static int scale( double distance, UNIT_RES* aResolution )
return ret; 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 ) static wxPoint mapPt( const POINT& aPoint, UNIT_RES* aResolution )
{ {
wxPoint ret( scale( aPoint.x, aResolution ), wxPoint ret( scale( aPoint.x, aResolution ),
...@@ -182,16 +190,14 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro ...@@ -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; SEGVIA* via = 0;
SHAPE* shape; SHAPE* shape;
int shapeCount = aPadstack->Length(); int shapeCount = aPadstack->Length();
int drillDiam = -1; int drillDiam = -1;
int viaDiam = 400; int copperLayerCount = sessionBoard->GetCopperLayerCount();
// @todo this needs a lot of work yet, it is not complete yet.
// The drill diameter is encoded in the padstack name if PCBNEW did the DSN export. // 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 ...@@ -200,15 +206,16 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
if( drillStartNdx != -1 ) if( drillStartNdx != -1 )
{ {
++drillStartNdx; // skip over the ':'
int drillEndNdx = aPadstack->padstack_id.rfind( '_' ); int drillEndNdx = aPadstack->padstack_id.rfind( '_' );
if( drillEndNdx != -1 ) 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(); const char* sdiamTxt = diamTxt.c_str();
double drillMils = strtod( sdiamTxt, 0 ); double drillMils = strtod( sdiamTxt, 0 );
// drillMils is not in the session units, but actual mils so we don't use scale() // 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 if( drillDiam == g_DesignSettings.m_ViaDrill ) // default
drillDiam = -1; // import as default drillDiam = -1; // import as default
...@@ -217,38 +224,94 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet ...@@ -217,38 +224,94 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
if( shapeCount == 0 ) if( shapeCount == 0 )
{ {
ThrowIOError( _( "Session via padstack has no shapes") );
} }
else if( shapeCount == 1 ) else if( shapeCount == 1 )
{ {
shape = (SHAPE*) (*aPadstack)[0]; shape = (SHAPE*) (*aPadstack)[0];
if( shape->shape->Type() == T_circle ) DSN_T type = shape->shape->Type();
{ if( type != T_circle )
CIRCLE* circle = (CIRCLE*) shape->shape; ThrowIOError( _( "Unsupported via shape: \"%s\""),
viaDiam = scale( circle->diameter, routeResolution ); LEXER::GetTokenString( type ).GetData() );
via = new SEGVIA( sessionBoard ); CIRCLE* circle = (CIRCLE*) shape->shape;
via->SetPosition( mapPt( aPoint, routeResolution ) ); int viaDiam = scale( circle->diameter, routeResolution );
via->SetDrillValue( drillDiam );
via->m_Shape = VIA_THROUGH; via = new SEGVIA( sessionBoard );
via->m_Width = viaDiam; via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetLayerPair( CMP_N, COPPER_LAYER_N ); 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]; 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; CIRCLE* circle = (CIRCLE*) shape->shape;
viaDiam = scale( circle->diameter, routeResolution );
int layerNdx = findLayerName( circle->layer_id );
via = new SEGVIA( sessionBoard ); if( layerNdx == -1 )
via->SetPosition( mapPt( aPoint, routeResolution ) ); {
via->SetDrillValue( drillDiam ); wxString layerName = CONV_FROM_UTF8( circle->layer_id.c_str() );
via->m_Shape = VIA_THROUGH; ThrowIOError( _("Session file uses invalid layer id \"%s\""),
via->m_Width = viaDiam; layerName.GetData() );
via->SetLayerPair( CMP_N, COPPER_LAYER_N ); }
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 ) if( via )
...@@ -365,7 +428,6 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) ...@@ -365,7 +428,6 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
// else netCode remains 0 // else netCode remains 0
} }
WIRES& wires = net->wires; WIRES& wires = net->wires;
for( unsigned i=0; i<wires.size(); ++i ) for( unsigned i=0; i<wires.size(); ++i )
{ {
...@@ -386,9 +448,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) ...@@ -386,9 +448,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
for( unsigned pt=0; pt<path->points.size()-1; ++pt ) for( unsigned pt=0; pt<path->points.size()-1; ++pt )
{ {
TRACK* track = makeTRACK( path, pt, netCode ); TRACK* track = makeTRACK( path, pt, netCode );
aBoard->Add( track );
TRACK* insertAid = track->GetBestInsertPoint( aBoard );
track->Insert( aBoard, insertAid );
} }
} }
...@@ -428,12 +488,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) ...@@ -428,12 +488,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
for( unsigned v=0; v<wire_via->vertexes.size(); ++v ) for( unsigned v=0; v<wire_via->vertexes.size(); ++v )
{ {
SEGVIA* via = makeVIA( padstack, wire_via->vertexes[v], netCode ); SEGVIA* via = makeVIA( padstack, wire_via->vertexes[v], netCode );
aBoard->Add( via );
if( !via )
ThrowIOError( _("Unable to make a via") );
TRACK* insertAid = via->GetBestInsertPoint( aBoard );
via->Insert( aBoard, insertAid );
} }
} }
} }
......
...@@ -21,33 +21,33 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) ...@@ -21,33 +21,33 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
/* Restitution d'un element (MODULE ou TRACK ) Efface /* Restitution d'un element (MODULE ou TRACK ) Efface
*/ */
{ {
BOARD_ITEM* PtStruct, * PtNext; BOARD_ITEM* item;
TRACK* pt_track; BOARD_ITEM* next;
int net_code; int net_code;
if( !g_UnDeleteStackPtr ) if( !g_UnDeleteStackPtr )
return; return;
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; item = g_UnDeleteStack[g_UnDeleteStackPtr];
if( PtStruct == NULL ) if( item == NULL )
return; // Ne devrait pas se produire return; // Ne devrait pas se produire
switch( PtStruct->Type() ) switch( item->Type() )
{ {
case TYPEVIA: case TYPEVIA:
case TYPETRACK: case TYPETRACK:
for( ; PtStruct != NULL; PtStruct = PtNext ) for( ; item; item = next )
{ {
PtNext = PtStruct->Next(); next = item->Next();
PtStruct->SetState( DELETED, OFF ); /* Effacement du bit DELETED */ item->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
( (TRACK*) PtStruct )->Draw( DrawPanel, DC, GR_OR ); ((TRACK*) item)->Draw( DrawPanel, DC, GR_OR );
} }
PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; item = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ( (TRACK*) PtStruct )->GetNet(); net_code = ((TRACK*) item)->GetNet();
pt_track = ( (TRACK*) PtStruct )->GetBestInsertPoint( m_Pcb );
( (TRACK*) PtStruct )->Insert( m_Pcb, pt_track ); m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
test_1_net_connexion( DC, net_code ); test_1_net_connexion( DC, net_code );
...@@ -61,18 +61,14 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) ...@@ -61,18 +61,14 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
/* Reinsertion du module dans la liste chainee des modules, /* Reinsertion du module dans la liste chainee des modules,
* en debut de chaine */ * en debut de chaine */
PtStruct->Pback = m_Pcb; m_Pcb->Add( item );
PtNext = m_Pcb->m_Modules;
PtStruct->Pnext = PtNext;
if( PtNext )
PtNext->Pback = PtStruct;
m_Pcb->m_Modules = (MODULE*) PtStruct;
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; 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 */ item->SetState( DELETED, OFF ); /* Creal DELETED flag */
PtStruct->m_Flags = 0; item->m_Flags = 0;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
build_liste_pads(); build_liste_pads();
ReCompile_Ratsnest_After_Changes( DC ); ReCompile_Ratsnest_After_Changes( DC );
...@@ -124,11 +120,11 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) ...@@ -124,11 +120,11 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
{ {
NextS = PtStruct->Next(); NextS = PtStruct->Next();
( (TRACK*) PtStruct )->UnLink(); ( (TRACK*) PtStruct )->UnLink();
PtStruct->SetState( DELETED, ON ); PtStruct->SetState( DELETED, ON );
if( nbitems <= 1 ) if( nbitems <= 1 )
NextS = NULL; /* fin de chaine */ NextS = NULL; /* fin de chaine */
PtStruct->Pnext = NextS; PtStruct->Pnext = NextS;
PtStruct->Pback = Back; Back = PtStruct; PtStruct->Pback = Back; Back = PtStruct;
if( NextS == NULL ) 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