virtual BOARD_ITEM::Save()
This commit is contained in:
parent
a67a4f7eef
commit
64e9e16886
|
@ -4,17 +4,33 @@ Started 2007-June-11
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2007-Oct-30 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||
================================================================================
|
||||
+ pcbnew
|
||||
added BOARD_ITEM::Save() and to all derived classes as well. Made virtual
|
||||
and removed all UI code from these utility functions.
|
||||
removed WriteDesc() functions from all BOARD_ITEM derived classes, although
|
||||
Keeping old ones in commented out form for a while for reference.
|
||||
@todo: delete these from *.cpp files eventually.
|
||||
zones.cpp, clean up in prep for enhancements.
|
||||
+ gerbview
|
||||
fixed bug which came about when BOARD::~BOARD() started deleting the objects
|
||||
that a BOARD owns. export_to_pcbnew.cpp was not consistent with this
|
||||
design and was crashing. Also, export_to_pcbnew.cpp now uses the simple
|
||||
BOARD::Save() function. It was another place to maintain the PCB file format,
|
||||
rather than simply putting that knowledge into one place like BOARD::Save().
|
||||
|
||||
|
||||
2007-Oct-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||
================================================================================
|
||||
+cvpcb: listboxes.cpp problem solved: exists only under windows
|
||||
now apply to windows only, because this Workaround creates a problem undex linux
|
||||
|
||||
+others:
|
||||
some very minor problems solved
|
||||
|
||||
+eeschema:
|
||||
in B.O.M.: the footprint field can be added to the field list
|
||||
|
||||
|
||||
2007-Oct-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||
================================================================================
|
||||
+cvpcb: listboxes.cpp problem solved: Workaround for a curious bug in wxWidgets:
|
||||
|
@ -33,12 +49,10 @@ email address.
|
|||
+ all:
|
||||
remove unused files.
|
||||
some translations
|
||||
|
||||
+cvpcb:
|
||||
set flag wxFRAME_FLOAT_ON_PARENT when create the footprint 3D frame and the
|
||||
display frame
|
||||
minor other changes
|
||||
|
||||
+ pcbnew:
|
||||
Use collector class to locate items in modedit.
|
||||
This is a big enhancement,
|
||||
|
|
|
@ -58,7 +58,7 @@ void EDA_BaseStruct::InitVars()
|
|||
|
||||
|
||||
/* Gestion de l'etat (status) de la structure (active, deleted..) */
|
||||
int EDA_BaseStruct::GetState( int type )
|
||||
int EDA_BaseStruct::GetState( int type ) const
|
||||
{
|
||||
return m_Status & type;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File )
|
|||
|
||||
|
||||
/*******************************************************************/
|
||||
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
|
||||
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
|
||||
int* LayerLookUpTable )
|
||||
/*******************************************************************/
|
||||
|
||||
|
@ -136,20 +136,17 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
|
|||
* @return 1 if OK, 0 if fail
|
||||
*/
|
||||
{
|
||||
char Line[256];
|
||||
char line[256];
|
||||
TRACK* track;
|
||||
TRACK* next_track;
|
||||
BOARD_ITEM* PtStruct;
|
||||
BOARD_ITEM* NextStruct;
|
||||
BOARD* GerberPcb = frame->m_Pcb;
|
||||
BOARD* Pcb;
|
||||
BOARD* gerberPcb = frame->m_Pcb;
|
||||
BOARD* pcb;
|
||||
|
||||
wxBeginBusyCursor();
|
||||
|
||||
/* Create an image of gerber data */
|
||||
Pcb = new BOARD( NULL, frame );
|
||||
// create an image of gerber data
|
||||
pcb = new BOARD( NULL, frame );
|
||||
|
||||
for( track = GerberPcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
|
||||
for( track = gerberPcb->m_Track; track; track = track->Next() )
|
||||
{
|
||||
int layer = track->GetLayer();
|
||||
int pcb_layer_number = LayerLookUpTable[layer];
|
||||
|
@ -158,23 +155,23 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
|
|||
|
||||
if( pcb_layer_number > CMP_N )
|
||||
{
|
||||
DRAWSEGMENT* drawitem = new DRAWSEGMENT( NULL, TYPEDRAWSEGMENT );
|
||||
DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPEDRAWSEGMENT );
|
||||
|
||||
drawitem->SetLayer( pcb_layer_number );
|
||||
drawitem->m_Start = track->m_Start;
|
||||
drawitem->m_End = track->m_End;
|
||||
drawitem->m_Width = track->m_Width;
|
||||
drawitem->Pnext = Pcb->m_Drawings;
|
||||
Pcb->m_Drawings = drawitem;
|
||||
drawitem->Pnext = pcb->m_Drawings;
|
||||
pcb->m_Drawings = drawitem;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACK* newtrack;
|
||||
|
||||
// replace spots with vias when possible
|
||||
if( (track->m_Shape == S_SPOT_CIRCLE)
|
||||
|| (track->m_Shape == S_SPOT_RECT)
|
||||
|| (track->m_Shape == S_SPOT_OVALE) )
|
||||
if( track->m_Shape == S_SPOT_CIRCLE
|
||||
|| track->m_Shape == S_SPOT_RECT
|
||||
|| track->m_Shape == S_SPOT_OVALE )
|
||||
{
|
||||
newtrack = new SEGVIA( (const SEGVIA&) *track );
|
||||
|
||||
|
@ -198,19 +195,20 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
|
|||
newtrack->SetLayer( pcb_layer_number );
|
||||
}
|
||||
|
||||
newtrack->Insert( Pcb, NULL );
|
||||
newtrack->Insert( pcb, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
// delete redundant vias
|
||||
for( track = Pcb->m_Track; track != NULL; track = track->Next() )
|
||||
for( track = pcb->m_Track; track; track = track->Next() )
|
||||
{
|
||||
if( track->m_Shape != VIA_THROUGH )
|
||||
continue;
|
||||
|
||||
// Search and delete others vias
|
||||
TRACK* next_track;
|
||||
TRACK* alt_track = track->Next();
|
||||
for( ; alt_track != NULL; alt_track = next_track )
|
||||
for( ; alt_track; alt_track = next_track )
|
||||
{
|
||||
next_track = alt_track->Next();
|
||||
if( alt_track->m_Shape != VIA_THROUGH )
|
||||
|
@ -229,54 +227,16 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
|
|||
setlocale( LC_NUMERIC, "C" );
|
||||
|
||||
// write the PCB heading
|
||||
fprintf( File, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
|
||||
DateAndTime( Line ) );
|
||||
WriteGeneralDescrPcb( Pcb, File );
|
||||
WriteSetup( File, Pcb );
|
||||
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
|
||||
DateAndTime( line ) );
|
||||
WriteGeneralDescrPcb( pcb, aFile );
|
||||
WriteSetup( aFile, pcb );
|
||||
|
||||
// write the useful part of the pcb
|
||||
PtStruct = Pcb->m_Drawings;
|
||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
||||
{
|
||||
switch( PtStruct->Type() )
|
||||
{
|
||||
case TYPETEXTE:
|
||||
( (TEXTE_PCB*) PtStruct )->WriteTextePcbDescr( File );
|
||||
break;
|
||||
pcb->Save( aFile );
|
||||
|
||||
case TYPEDRAWSEGMENT:
|
||||
( (DRAWSEGMENT*) PtStruct )->WriteDrawSegmentDescr( File );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( File, "$TRACK\n" );
|
||||
for( track = Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
|
||||
{
|
||||
track->WriteTrackDescr( File );
|
||||
}
|
||||
|
||||
fprintf( File, "$EndTRACK\n" );
|
||||
|
||||
fprintf( File, "$EndBOARD\n" );
|
||||
|
||||
// Delete the copy
|
||||
for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = NextStruct )
|
||||
{
|
||||
NextStruct = PtStruct->Next();
|
||||
delete PtStruct;
|
||||
}
|
||||
|
||||
for( track = Pcb->m_Track; track != NULL; track = next_track )
|
||||
{
|
||||
next_track = (TRACK*) track->Pnext;
|
||||
delete track;
|
||||
}
|
||||
|
||||
delete Pcb;
|
||||
// the destructor should destroy all owned sub-objects
|
||||
delete pcb;
|
||||
|
||||
setlocale( LC_NUMERIC, "" ); // revert to the current locale
|
||||
wxEndBusyCursor();
|
||||
|
|
|
@ -191,7 +191,7 @@ public:
|
|||
|
||||
|
||||
/* Gestion de l'etat (status) de la structure (active, deleted..) */
|
||||
int GetState( int type );
|
||||
int GetState( int type ) const;
|
||||
void SetState( int type, int state );
|
||||
|
||||
int ReturnStatus() const { return m_Status; }
|
||||
|
@ -490,6 +490,17 @@ public:
|
|||
* @todo: make this virtual and split into each derived class
|
||||
*/
|
||||
const char** MenuIcon() const;
|
||||
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
virtual bool Save( FILE* aFile ) const = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -289,6 +289,15 @@ public:
|
|||
EQUIPOT* FindNet( int aNetcode ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Function GetClass
|
||||
* returns the class name.
|
||||
|
@ -370,7 +379,15 @@ public:
|
|||
~DRAWSEGMENT();
|
||||
|
||||
// Read/write data
|
||||
bool WriteDrawSegmentDescr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
|
||||
|
||||
/* remove this from the linked list */
|
||||
|
|
|
@ -576,6 +576,73 @@ EQUIPOT* BOARD::FindNet( int anetcode ) const
|
|||
}
|
||||
|
||||
|
||||
|
||||
bool BOARD::Save( FILE* aFile ) const
|
||||
{
|
||||
bool rc = false;
|
||||
BOARD_ITEM* item;
|
||||
|
||||
// save the nets
|
||||
for( item = m_Equipots; item; item=item->Next() )
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
|
||||
// save the modules
|
||||
for( item = m_Modules; item; item=item->Next() )
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
|
||||
for( item = m_Drawings; item; item=item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case TYPETEXTE:
|
||||
case TYPEDRAWSEGMENT:
|
||||
case TYPEMIRE:
|
||||
case TYPECOTATION:
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
break;
|
||||
|
||||
case TYPEMARQUEUR: // do not save MARKERs, they can be regenerated easily
|
||||
break;
|
||||
|
||||
default:
|
||||
// future: throw exception here
|
||||
#if defined(DEBUG)
|
||||
printf( "BOARD::Save() ignoring draw type %d\n", item->Type() );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// save the tracks & vias
|
||||
fprintf( aFile, "$TRACK\n" );
|
||||
for( item = m_Track; item; item=item->Next() )
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
fprintf( aFile, "$EndTRACK\n" );
|
||||
|
||||
|
||||
// save the zones
|
||||
fprintf( aFile, "$ZONE\n" );
|
||||
for( item = m_Zone; item; item=item->Next() )
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
fprintf( aFile, "$EndZONE\n" );
|
||||
|
||||
|
||||
if( fprintf( aFile, "$EndBOARD\n" ) != sizeof("$EndBOARD\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true; // wrote all OK
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
||||
/**
|
||||
|
|
|
@ -227,6 +227,7 @@ bool COTATION::ReadCotationDescr( FILE* File, int* LineNum )
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/**************************************************/
|
||||
bool COTATION::WriteCotationDescr( FILE* File )
|
||||
/**************************************************/
|
||||
|
@ -285,6 +286,73 @@ bool COTATION::WriteCotationDescr( FILE* File )
|
|||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool COTATION::Save( FILE* aFile ) const
|
||||
{
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
if( fprintf( aFile, "$COTATION\n" ) != sizeof("$COTATION\n")-1 )
|
||||
goto out;
|
||||
|
||||
fprintf( aFile, "Ge %d %d %lX\n", m_Shape, m_Layer, m_TimeStamp );
|
||||
|
||||
fprintf( aFile, "Va %d\n", m_Value );
|
||||
|
||||
if( !m_Text->m_Text.IsEmpty() )
|
||||
fprintf( aFile, "Te \"%s\"\n", CONV_TO_UTF8( m_Text->m_Text ) );
|
||||
else
|
||||
fprintf( aFile, "Te \"?\"\n" );
|
||||
|
||||
fprintf( aFile, "Po %d %d %d %d %d %d %d\n",
|
||||
m_Text->m_Pos.x, m_Text->m_Pos.y,
|
||||
m_Text->m_Size.x, m_Text->m_Size.y,
|
||||
m_Text->m_Width, m_Text->m_Orient,
|
||||
m_Text->m_Miroir );
|
||||
|
||||
fprintf( aFile, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
Barre_ox, Barre_oy,
|
||||
Barre_fx, Barre_fy, m_Width );
|
||||
|
||||
fprintf( aFile, "Sd %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
TraitD_ox, TraitD_oy,
|
||||
TraitD_fx, TraitD_fy, m_Width );
|
||||
|
||||
fprintf( aFile, "Sg %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
TraitG_ox, TraitG_oy,
|
||||
TraitG_fx, TraitG_fy, m_Width );
|
||||
|
||||
fprintf( aFile, "S1 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
FlecheD1_ox, FlecheD1_oy,
|
||||
FlecheD1_fx, FlecheD1_fy, m_Width );
|
||||
|
||||
fprintf( aFile, "S2 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
FlecheD2_ox, FlecheD2_oy,
|
||||
FlecheD2_fx, FlecheD2_fy, m_Width );
|
||||
|
||||
|
||||
fprintf( aFile, "S3 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
FlecheG1_ox, FlecheG1_oy,
|
||||
FlecheG1_fx, FlecheG1_fy, m_Width );
|
||||
|
||||
fprintf( aFile, "S4 %d %d %d %d %d %d\n", S_SEGMENT,
|
||||
FlecheG2_ox, FlecheG2_oy,
|
||||
FlecheG2_fx, FlecheG2_fy, m_Width );
|
||||
|
||||
if( fprintf( aFile, "$EndCOTATION\n" ) != sizeof("$EndCOTATION\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
|
|
@ -29,7 +29,14 @@ public:
|
|||
~COTATION();
|
||||
|
||||
bool ReadCotationDescr( FILE* File, int* LineNum );
|
||||
bool WriteCotationDescr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
/* supprime du chainage la structure Struct */
|
||||
void UnLink();
|
||||
|
|
|
@ -298,6 +298,7 @@ void EDGE_MODULE::Display_Infos( WinEDA_DrawFrame* frame )
|
|||
}
|
||||
|
||||
|
||||
#if 0 // replaced by Save()
|
||||
/*****************************************/
|
||||
int EDGE_MODULE::WriteDescr( FILE* File )
|
||||
/*****************************************/
|
||||
|
@ -358,6 +359,59 @@ int EDGE_MODULE::WriteDescr( FILE* File )
|
|||
|
||||
return NbLigne;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool EDGE_MODULE::Save( FILE* aFile ) const
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
switch( m_Shape )
|
||||
{
|
||||
case S_SEGMENT:
|
||||
ret = fprintf( aFile, "DS %d %d %d %d %d %d\n",
|
||||
m_Start0.x, m_Start0.y,
|
||||
m_End0.x, m_End0.y,
|
||||
m_Width, m_Layer );
|
||||
break;
|
||||
|
||||
case S_CIRCLE:
|
||||
ret = fprintf( aFile, "DC %d %d %d %d %d %d\n",
|
||||
m_Start0.x, m_Start0.y,
|
||||
m_End0.x, m_End0.y,
|
||||
m_Width, m_Layer );
|
||||
break;
|
||||
|
||||
case S_ARC:
|
||||
ret = fprintf( aFile, "DA %d %d %d %d %d %d %d\n",
|
||||
m_Start0.x, m_Start0.y,
|
||||
m_End0.x, m_End0.y,
|
||||
m_Angle,
|
||||
m_Width, m_Layer );
|
||||
break;
|
||||
|
||||
case S_POLYGON:
|
||||
ret = fprintf( aFile, "DP %d %d %d %d %d %d %d\n",
|
||||
m_Start0.x, m_Start0.y,
|
||||
m_End0.x, m_End0.y,
|
||||
m_PolyCount,
|
||||
m_Width, m_Layer );
|
||||
|
||||
int* pInt;
|
||||
pInt = m_PolyList;
|
||||
for( int i=0; i<m_PolyCount; ++i, pInt+=2 )
|
||||
fprintf( aFile, "Dl %d %d\n", pInt[0], pInt[1] );
|
||||
break;
|
||||
|
||||
default:
|
||||
// future: throw an exception here
|
||||
printf( "%s unexpected EDGE_MODULE::m_Shape: %d\n", __func__, m_Shape );
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret > 5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
|
|
@ -34,8 +34,14 @@ public:
|
|||
|
||||
void Copy( EDGE_MODULE* source ); // copy structure
|
||||
|
||||
/* Reading and writing data on files */
|
||||
int WriteDescr( FILE* File );
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
int ReadDescr( char* Line, FILE* File, int* LineNum = NULL );
|
||||
|
||||
// Mise a jour des coordon<6F>s pour l'affichage
|
||||
|
|
|
@ -106,6 +106,7 @@ int EQUIPOT:: ReadEquipotDescr( FILE* File, int* LineNum )
|
|||
}
|
||||
|
||||
|
||||
#if 0 // replaced by Save()
|
||||
/********************************************/
|
||||
int EQUIPOT:: WriteEquipotDescr( FILE* File )
|
||||
/********************************************/
|
||||
|
@ -121,6 +122,32 @@ int EQUIPOT:: WriteEquipotDescr( FILE* File )
|
|||
fprintf( File, "$EndEQUIPOT\n" );
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool EQUIPOT::Save( FILE* aFile ) const
|
||||
{
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
fprintf( aFile, "$EQUIPOT\n" );
|
||||
fprintf( aFile, "Na %d \"%.16s\"\n", GetNet(), CONV_TO_UTF8( m_Netname ) );
|
||||
fprintf( aFile, "St %s\n", "~" );
|
||||
|
||||
if( m_ForceWidth )
|
||||
fprintf( aFile, "Lw %d\n", m_ForceWidth );
|
||||
|
||||
if( fprintf( aFile, "$EndEQUIPOT\n" ) != sizeof("$EndEQUIPOT\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,15 @@ public:
|
|||
|
||||
/* Readind and writing data on files */
|
||||
int ReadEquipotDescr( FILE* File, int* LineNum );
|
||||
int WriteEquipotDescr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Function GetNet
|
||||
|
|
|
@ -33,6 +33,20 @@ public:
|
|||
void Display_Infos( WinEDA_DrawFrame* frame );
|
||||
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const
|
||||
{
|
||||
// not implemented, this is here to satisfy BOARD_ITEM::Save()
|
||||
// "pure" virtual-ness
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
|
|
|
@ -94,6 +94,7 @@ bool MIREPCB::ReadMirePcbDescr( FILE* File, int* LineNum )
|
|||
}
|
||||
|
||||
|
||||
#if 0 // replaced by Save()
|
||||
/************************************************/
|
||||
bool MIREPCB::WriteMirePcbDescr( FILE* File )
|
||||
/************************************************/
|
||||
|
@ -109,6 +110,34 @@ bool MIREPCB::WriteMirePcbDescr( FILE* File )
|
|||
fprintf( File, "$EndMIREPCB\n" );
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool MIREPCB::Save( FILE* aFile ) const
|
||||
{
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
if( fprintf( aFile, "$MIREPCB\n" ) != sizeof("$MIREPCB\n")-1 )
|
||||
goto out;
|
||||
|
||||
fprintf( aFile, "Po %X %d %d %d %d %d %8.8lX\n",
|
||||
m_Shape, m_Layer,
|
||||
m_Pos.x, m_Pos.y,
|
||||
m_Size, m_Width, m_TimeStamp );
|
||||
|
||||
if( fprintf( aFile, "$EndMIREPCB\n" ) != sizeof("$EndMIREPCB\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
|
|
|
@ -19,7 +19,14 @@ public:
|
|||
MIREPCB( BOARD_ITEM* StructFather );
|
||||
~MIREPCB();
|
||||
|
||||
bool WriteMirePcbDescr( FILE* File );
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
bool ReadMirePcbDescr( FILE* File, int* LineNum );
|
||||
|
||||
/* supprime du chainage la structure Struct */
|
||||
|
|
|
@ -345,6 +345,7 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/*************************************/
|
||||
int MODULE::WriteDescr( FILE* File )
|
||||
/*************************************/
|
||||
|
@ -489,10 +490,110 @@ int MODULE::WriteDescr( FILE* File )
|
|||
NbLigne++;
|
||||
return NbLigne;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool MODULE::Save( FILE* aFile ) const
|
||||
{
|
||||
char statusTxt[8];
|
||||
BOARD_ITEM* item;
|
||||
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
fprintf( aFile, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
|
||||
|
||||
// Generation des coord et caracteristiques
|
||||
memset( statusTxt, 0, sizeof(statusTxt) );
|
||||
if( IsLocked() )
|
||||
statusTxt[0] = 'F';
|
||||
else
|
||||
statusTxt[0] = '~';
|
||||
|
||||
if( m_ModuleStatus & MODULE_is_PLACED )
|
||||
statusTxt[1] = 'P';
|
||||
else
|
||||
statusTxt[1] = '~';
|
||||
|
||||
fprintf( aFile, "Po %d %d %d %d %8.8lX %8.8lX %s\n",
|
||||
m_Pos.x, m_Pos.y,
|
||||
m_Orient, m_Layer, m_LastEdit_Time,
|
||||
m_TimeStamp, statusTxt );
|
||||
|
||||
fprintf( aFile, "Li %s\n", CONV_TO_UTF8( m_LibRef ) );
|
||||
|
||||
if( !m_Doc.IsEmpty() )
|
||||
{
|
||||
fprintf( aFile, "Cd %s\n", CONV_TO_UTF8( m_Doc ) );
|
||||
}
|
||||
|
||||
if( !m_KeyWord.IsEmpty() )
|
||||
{
|
||||
fprintf( aFile, "Kw %s\n", CONV_TO_UTF8( m_KeyWord ) );
|
||||
}
|
||||
|
||||
fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp );
|
||||
|
||||
fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 );
|
||||
|
||||
// attributes
|
||||
if( m_Attributs != MOD_DEFAULT )
|
||||
{
|
||||
fprintf( aFile, "At " );
|
||||
if( m_Attributs & MOD_CMS )
|
||||
fprintf( aFile, "SMD " );
|
||||
if( m_Attributs & MOD_VIRTUAL )
|
||||
fprintf( aFile, "VIRTUAL " );
|
||||
fprintf( aFile, "\n" );
|
||||
}
|
||||
|
||||
// save reference
|
||||
if( !m_Reference->Save( aFile ) )
|
||||
goto out;
|
||||
|
||||
// save value
|
||||
if( !m_Value->Save( aFile ) )
|
||||
goto out;
|
||||
|
||||
// save drawing elements
|
||||
for( item=m_Drawings; item; item=item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case TYPETEXTEMODULE:
|
||||
case TYPEEDGEMODULE:
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
break;
|
||||
|
||||
default:
|
||||
#if defined(DEBUG)
|
||||
printf( "MODULE::Save() ignoring type %d\n", item->Type() );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// save the pads
|
||||
for( item=m_Pads; item; item=item->Next() )
|
||||
if( !item->Save( aFile ) )
|
||||
goto out;
|
||||
|
||||
// Generation des informations de trac<61>3D
|
||||
Write_3D_Descr( aFile );
|
||||
|
||||
fprintf( aFile, "$EndMODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
|
||||
|
||||
rc = true;
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/***************************************/
|
||||
int MODULE::Write_3D_Descr( FILE* File )
|
||||
int MODULE::Write_3D_Descr( FILE* File ) const
|
||||
/***************************************/
|
||||
|
||||
/* Sauvegarde de la description 3D du MODULE
|
||||
|
|
|
@ -116,8 +116,16 @@ public:
|
|||
|
||||
|
||||
/* Reading and writing data on files */
|
||||
int WriteDescr( FILE* File );
|
||||
int Write_3D_Descr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
int Write_3D_Descr( FILE* File ) const;
|
||||
int ReadDescr( FILE* File, int* LineNum = NULL );
|
||||
int Read_3D_Descr( FILE* File, int* LineNum = NULL );
|
||||
|
||||
|
|
|
@ -763,6 +763,8 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
|
|||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/***********************************/
|
||||
int D_PAD::WriteDescr( FILE* File )
|
||||
/***********************************/
|
||||
|
@ -849,6 +851,92 @@ int D_PAD::WriteDescr( FILE* File )
|
|||
NbLigne++;
|
||||
return NbLigne;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool D_PAD::Save( FILE* aFile ) const
|
||||
{
|
||||
int cshape;
|
||||
const char* texttype;
|
||||
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
// check the return values for first and last fprints() in this function
|
||||
if( fprintf( aFile, "$PAD\n" ) != sizeof("$PAD\n")-1 )
|
||||
goto out;
|
||||
|
||||
switch( m_PadShape )
|
||||
{
|
||||
case CIRCLE:
|
||||
cshape = 'C'; break;
|
||||
|
||||
case RECT:
|
||||
cshape = 'R'; break;
|
||||
|
||||
case OVALE:
|
||||
cshape = 'O'; break;
|
||||
|
||||
case TRAPEZE:
|
||||
cshape = 'T'; break;
|
||||
|
||||
default:
|
||||
cshape = 'C';
|
||||
DisplayError( NULL, _( "Unknown Pad shape" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf( aFile, "Sh \"%.4s\" %c %d %d %d %d %d\n",
|
||||
m_Padname, cshape, m_Size.x, m_Size.y,
|
||||
m_DeltaSize.x, m_DeltaSize.y, m_Orient );
|
||||
|
||||
fprintf( aFile, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y );
|
||||
if( m_DrillShape == OVALE )
|
||||
{
|
||||
fprintf( aFile, " %c %d %d", 'O', m_Drill.x, m_Drill.y );
|
||||
}
|
||||
fprintf( aFile, "\n" );
|
||||
|
||||
switch( m_Attribut )
|
||||
{
|
||||
case STANDARD:
|
||||
texttype = "STD"; break;
|
||||
|
||||
case SMD:
|
||||
texttype = "SMD"; break;
|
||||
|
||||
case CONN:
|
||||
texttype = "CONN"; break;
|
||||
|
||||
case P_HOLE:
|
||||
texttype = "HOLE"; break;
|
||||
|
||||
case MECA:
|
||||
texttype = "MECA"; break;
|
||||
|
||||
default:
|
||||
texttype = "STD";
|
||||
DisplayError( NULL, wxT( "Invalid Pad attribute" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf( aFile, "At %s N %8.8X\n", texttype, m_Masque_Layer );
|
||||
|
||||
fprintf( aFile, "Ne %d \"%s\"\n", GetNet(), CONV_TO_UTF8( m_Netname ) );
|
||||
|
||||
fprintf( aFile, "Po %d %d\n", m_Pos0.x, m_Pos0.y );
|
||||
|
||||
if( fprintf( aFile, "$EndPAD\n" ) != sizeof("$EndPAD\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************/
|
||||
|
|
|
@ -77,7 +77,15 @@ public:
|
|||
|
||||
/* Reading and writing data on files */
|
||||
int ReadDescr( FILE* File, int* LineNum = NULL );
|
||||
int WriteDescr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
|
||||
/* drawing functions */
|
||||
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode );
|
||||
|
|
|
@ -112,6 +112,7 @@ int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
|
|||
}
|
||||
|
||||
|
||||
#if 0 // replaced by Save()
|
||||
/**************************************************/
|
||||
int TEXTE_PCB::WriteTextePcbDescr( FILE* File )
|
||||
/**************************************************/
|
||||
|
@ -129,6 +130,36 @@ int TEXTE_PCB::WriteTextePcbDescr( FILE* File )
|
|||
fprintf( File, "$EndTEXTPCB\n" );
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool TEXTE_PCB::Save( FILE* aFile ) const
|
||||
{
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
if( m_Text.IsEmpty() )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
if( fprintf( aFile, "$TEXTPCB\n" ) != sizeof("$TEXTPCB\n")-1 )
|
||||
goto out;
|
||||
|
||||
fprintf( aFile, "Te \"%s\"\n", CONV_TO_UTF8( m_Text ) );
|
||||
fprintf( aFile, "Po %d %d %d %d %d %d\n",
|
||||
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient );
|
||||
fprintf( aFile, "De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0 );
|
||||
|
||||
if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true;
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
|
@ -24,8 +24,14 @@ public:
|
|||
|
||||
// File Operations:
|
||||
int ReadTextePcbDescr( FILE* File, int* LineNum );
|
||||
int WriteTextePcbDescr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
/**
|
||||
* Function Display_Infos
|
||||
|
|
|
@ -71,6 +71,28 @@ TEXTE_MODULE::~TEXTE_MODULE()
|
|||
}
|
||||
|
||||
|
||||
bool TEXTE_MODULE::Save( FILE* aFile ) const
|
||||
{
|
||||
MODULE* parent = (MODULE*) GetParent();
|
||||
int orient = m_Orient;
|
||||
|
||||
if( parent )
|
||||
orient += parent->m_Orient;
|
||||
|
||||
int ret = fprintf( aFile, "T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n",
|
||||
m_Type,
|
||||
m_Pos0.x, m_Pos0.y,
|
||||
m_Size.y, m_Size.x,
|
||||
orient,
|
||||
m_Width,
|
||||
m_Miroir ? 'N' : 'M', m_NoShow ? 'I' : 'V',
|
||||
GetLayer(),
|
||||
CONV_TO_UTF8( m_Text ) );
|
||||
|
||||
return (ret > 20);
|
||||
}
|
||||
|
||||
|
||||
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure
|
||||
{
|
||||
if( source == NULL )
|
||||
|
|
|
@ -47,9 +47,15 @@ public:
|
|||
|
||||
void SetLocalCoord(); // mise a jour des coordonn<6E>s relatives
|
||||
|
||||
// a partir des coord absolues de trac<61>
|
||||
/* Reading and writing data on files */
|
||||
int WriteDescr( FILE* File );
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
|
||||
int ReadDescr( FILE* File, int* LineNum = NULL );
|
||||
|
||||
/* drawing functions */
|
||||
|
|
|
@ -535,6 +535,7 @@ TRACK* TRACK::GetEndNetCode( int NetCode )
|
|||
}
|
||||
|
||||
|
||||
#if 0 // replaced by Save()
|
||||
/********************************************/
|
||||
bool TRACK::WriteTrackDescr( FILE* File )
|
||||
/********************************************/
|
||||
|
@ -558,6 +559,29 @@ bool TRACK::WriteTrackDescr( FILE* File )
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool TRACK::Save( FILE* aFile ) const
|
||||
{
|
||||
int type = 0;
|
||||
|
||||
if( Type() == TYPEVIA )
|
||||
type = 1;
|
||||
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
fprintf( aFile, "Po %d %d %d %d %d %d %d\n", m_Shape,
|
||||
m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width, m_Drill );
|
||||
|
||||
fprintf( aFile, "De %d %d %d %lX %X\n",
|
||||
m_Layer, type, GetNet(),
|
||||
m_TimeStamp, ReturnStatus() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
|
|
@ -59,8 +59,15 @@ public:
|
|||
/* supprime du chainage la structure Struct */
|
||||
void UnLink();
|
||||
|
||||
// Read/write data
|
||||
bool WriteTrackDescr( FILE* File );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures for this object out to a FILE in "*.pcb" format.
|
||||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Function Insert
|
||||
|
|
|
@ -102,7 +102,7 @@ void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
|
|||
m_TimeStamp = source->m_TimeStamp;
|
||||
}
|
||||
|
||||
|
||||
#if 0 // replaced by Save()
|
||||
/********************************************************/
|
||||
bool DRAWSEGMENT::WriteDrawSegmentDescr( FILE* File )
|
||||
/********************************************************/
|
||||
|
@ -121,6 +121,36 @@ bool DRAWSEGMENT::WriteDrawSegmentDescr( FILE* File )
|
|||
fprintf( File, "$EndDRAWSEGMENT\n" );
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool DRAWSEGMENT::Save( FILE* aFile ) const
|
||||
{
|
||||
if( GetState( DELETED ) )
|
||||
return true;
|
||||
|
||||
bool rc = false;
|
||||
|
||||
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("%DRAWSEGMENT\n")-1 )
|
||||
goto out;
|
||||
|
||||
fprintf( aFile, "Po %d %d %d %d %d %d\n",
|
||||
m_Shape,
|
||||
m_Start.x, m_Start.y,
|
||||
m_End.x, m_End.y, m_Width );
|
||||
|
||||
fprintf( aFile, "De %d %d %d %lX %X\n",
|
||||
m_Layer, m_Type, m_Angle,
|
||||
m_TimeStamp, ReturnStatus() );
|
||||
|
||||
if( fprintf( aFile, "$EndDRAWSEGMENT\n" ) != sizeof("$EndDRAWSEGMENT\n")-1 )
|
||||
goto out;
|
||||
|
||||
rc = true;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
|
|
@ -234,7 +234,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC * DC, bo
|
|||
g_SaveTime = time( NULL );
|
||||
|
||||
|
||||
#if 0 && defined(DEBUG)
|
||||
#if 1 && defined(DEBUG)
|
||||
// note this seems to freeze up pcbnew when run under the kicad project
|
||||
// manager. runs fine from command prompt.
|
||||
// output the board object tree to stdout:
|
||||
|
|
|
@ -1070,7 +1070,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
|
|||
|
||||
#ifdef PCBNEW
|
||||
/***************************************************/
|
||||
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* File )
|
||||
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
|
||||
/****************************************************/
|
||||
|
||||
/* Routine de sauvegarde du PCB courant sous format ASCII
|
||||
|
@ -1079,139 +1079,35 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* File )
|
|||
* 0 si sauvegarde non faite
|
||||
*/
|
||||
{
|
||||
int ii, NbModules, nseg;
|
||||
float Pas;
|
||||
char Line[256];
|
||||
EQUIPOT* Equipot;
|
||||
TRACK* PtSegm;
|
||||
EDA_BaseStruct* PtStruct;
|
||||
MODULE* Module;
|
||||
|
||||
wxBeginBusyCursor();
|
||||
bool rc;
|
||||
char line[256];
|
||||
|
||||
m_Pcb->m_Status_Pcb &= ~CONNEXION_OK;
|
||||
|
||||
/* Calcul du nombre des modules */
|
||||
PtStruct = (EDA_BaseStruct*) m_Pcb->m_Modules;
|
||||
NbModules = 0;
|
||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||
NbModules++;
|
||||
wxBeginBusyCursor();
|
||||
|
||||
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
||||
setlocale( LC_NUMERIC, "C" );
|
||||
|
||||
/* Ecriture de l'entete PCB : */
|
||||
fprintf( File, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
|
||||
DateAndTime( Line ) );
|
||||
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
|
||||
DateAndTime( line ) );
|
||||
|
||||
WriteGeneralDescrPcb( File );
|
||||
WriteSheetDescr( m_CurrentScreen, File );
|
||||
WriteSetup( File, this );
|
||||
WriteGeneralDescrPcb( aFile );
|
||||
WriteSheetDescr( m_CurrentScreen, aFile );
|
||||
WriteSetup( aFile, this );
|
||||
|
||||
/* Ecriture des donnes utiles du pcb */
|
||||
rc = m_Pcb->Save( aFile );
|
||||
|
||||
Equipot = m_Pcb->m_Equipots;
|
||||
|
||||
Pas = 100.0;
|
||||
if( m_Pcb->m_NbNets )
|
||||
Pas /= m_Pcb->m_NbNets;
|
||||
|
||||
for( ii = 0; Equipot != NULL; ii++, Equipot = (EQUIPOT*) Equipot->Pnext )
|
||||
{
|
||||
Equipot->WriteEquipotDescr( File );
|
||||
DisplayActivity( (int) ( Pas * ii ), wxT( "Equipot:" ) );
|
||||
}
|
||||
|
||||
Pas = 100.0;
|
||||
if( NbModules )
|
||||
Pas /= NbModules;
|
||||
|
||||
Module = m_Pcb->m_Modules;
|
||||
for( ii = 1; Module != NULL; Module = Module->Next(), ii++ )
|
||||
{
|
||||
Module->WriteDescr( File );
|
||||
DisplayActivity( (int) (ii * Pas), wxT( "Modules:" ) );
|
||||
}
|
||||
|
||||
/* sortie des inscriptions du PCB: */
|
||||
PtStruct = m_Pcb->m_Drawings;
|
||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||
{
|
||||
switch( PtStruct->Type() )
|
||||
{
|
||||
case TYPETEXTE:
|
||||
( (TEXTE_PCB*) PtStruct )->WriteTextePcbDescr( File );
|
||||
break;
|
||||
|
||||
case TYPEDRAWSEGMENT:
|
||||
( (DRAWSEGMENT*) PtStruct )->WriteDrawSegmentDescr( File );
|
||||
break;
|
||||
|
||||
case TYPEMIRE:
|
||||
( (MIREPCB*) PtStruct )->WriteMirePcbDescr( File );
|
||||
break;
|
||||
|
||||
case TYPECOTATION:
|
||||
( (COTATION*) PtStruct )->WriteCotationDescr( File );
|
||||
break;
|
||||
|
||||
case TYPEMARQUEUR: /* sauvegarde inutile */
|
||||
break;
|
||||
|
||||
default:
|
||||
DisplayError( this, wxT( "Unknown Draw Type" ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Pas = 100.0;
|
||||
if( m_Pcb->m_NbSegmTrack )
|
||||
Pas /= (m_Pcb->m_NbSegmTrack);
|
||||
|
||||
fprintf( File, "$TRACK\n" );
|
||||
PtSegm = m_Pcb->m_Track;
|
||||
|
||||
DisplayActivity( 0, wxT( "Tracks:" ) );
|
||||
for( nseg = 0, ii = 0; PtSegm != NULL; ii++, PtSegm = (TRACK*) PtSegm->Pnext )
|
||||
{
|
||||
( (TRACK*) PtSegm )->WriteTrackDescr( File );
|
||||
if( nseg != (int) ( ii * Pas) )
|
||||
{
|
||||
nseg = (int) ( ii * Pas);
|
||||
DisplayActivity( nseg, wxT( "Tracks:" ) );
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( File, "$EndTRACK\n" );
|
||||
|
||||
fprintf( File, "$ZONE\n" );
|
||||
PtSegm = (TRACK*) m_Pcb->m_Zone;
|
||||
ii = m_Pcb->m_NbSegmZone;
|
||||
|
||||
Pas = 100.0;
|
||||
if( ii )
|
||||
Pas /= ii;
|
||||
|
||||
PtSegm = m_Pcb->m_Zone;
|
||||
|
||||
DisplayActivity( 0, wxT( "Zones:" ) );
|
||||
for( nseg = 0, ii = 0; PtSegm != NULL; ii++, PtSegm = (TRACK*) PtSegm->Pnext )
|
||||
{
|
||||
( (TRACK*) PtSegm )->WriteTrackDescr( File );
|
||||
if( nseg != (int) ( ii * Pas) )
|
||||
{
|
||||
nseg = (int) ( ii * Pas);
|
||||
DisplayActivity( nseg, wxT( "Zones:" ) );
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( File, "$EndZONE\n" );
|
||||
fprintf( File, "$EndBOARD\n" );
|
||||
|
||||
setlocale( LC_NUMERIC, "" ); // revert to the current locale
|
||||
setlocale( LC_NUMERIC, "" ); // revert to the current locale
|
||||
wxEndBusyCursor();
|
||||
|
||||
Affiche_Message( wxEmptyString );
|
||||
return 1;
|
||||
if( !rc )
|
||||
DisplayError( this, wxT( "Unable to save PCB file" ) );
|
||||
else
|
||||
Affiche_Message( wxEmptyString );
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
1338
pcbnew/librairi.cpp
1338
pcbnew/librairi.cpp
File diff suppressed because it is too large
Load Diff
|
@ -17,17 +17,17 @@
|
|||
void Trace_Pistes( WinEDA_DrawPanel* panel, BOARD* Pcb, wxDC* DC, int drawmode )
|
||||
/********************************************************************************/
|
||||
|
||||
/* Draw all tracks and zones.
|
||||
/* Draw all tracks and zones. As long as dark colors are used for the tracks,
|
||||
* Then the OR draw mode should show tracks underneath other tracks. But a white
|
||||
* track will cover any other color since it has more bits to OR in.
|
||||
*/
|
||||
{
|
||||
TRACK * track = Pcb->m_Track;
|
||||
for( ; track != NULL; track = track->Next() )
|
||||
for( TRACK* track = Pcb->m_Track; track; track = track->Next() )
|
||||
{
|
||||
track->Draw( panel, DC, drawmode );
|
||||
}
|
||||
|
||||
SEGZONE * zone = Pcb->m_Zone;
|
||||
for( ; zone != NULL; zone = zone->Next() )
|
||||
for( SEGZONE* zone = Pcb->m_Zone; zone; zone = zone->Next() )
|
||||
{
|
||||
zone->Draw( panel, DC, drawmode );
|
||||
}
|
||||
|
@ -51,12 +51,8 @@ void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track,
|
|||
* donc mis a 0 avant appel a la routine si la piste a tracer est la derniere
|
||||
*/
|
||||
{
|
||||
if( Track == NULL )
|
||||
return;
|
||||
for( ; nbsegment > 0; nbsegment--, Track = (TRACK*) Track->Pnext )
|
||||
for( ; nbsegment > 0 && Track; nbsegment--, Track = Track->Next() )
|
||||
{
|
||||
if( Track == NULL )
|
||||
break;
|
||||
Track->Draw( panel, DC, draw_mode );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -384,25 +384,23 @@ void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent& event )
|
|||
|
||||
|
||||
/**************************************************************/
|
||||
void WinEDA_PcbFrame::Edit_Zone_Width( wxDC* DC, SEGZONE* Zone )
|
||||
void WinEDA_PcbFrame::Edit_Zone_Width( wxDC* DC, SEGZONE* aZone )
|
||||
/**************************************************************/
|
||||
|
||||
/* Edite (change la largeur des segments) la zone Zone.
|
||||
* La zone est constituee des segments zones de meme TimeStamp
|
||||
*/
|
||||
{
|
||||
SEGZONE* pt_segm, * NextS;
|
||||
unsigned long TimeStamp;
|
||||
bool modify = FALSE;
|
||||
double f_new_width;
|
||||
int w_tmp;
|
||||
wxString Line;
|
||||
wxString Msg( _( "New zone segment width: " ) );
|
||||
|
||||
if( Zone == NULL )
|
||||
if( aZone == NULL )
|
||||
return;
|
||||
|
||||
f_new_width = To_User_Unit( g_UnitMetric, Zone->m_Width, GetScreen()->GetInternalUnits() );
|
||||
f_new_width = To_User_Unit( g_UnitMetric, aZone->m_Width, GetScreen()->GetInternalUnits() );
|
||||
|
||||
Line.Printf( wxT( "%.4f" ), f_new_width );
|
||||
|
||||
|
@ -417,15 +415,12 @@ void WinEDA_PcbFrame::Edit_Zone_Width( wxDC* DC, SEGZONE* Zone )
|
|||
f_new_width, GetScreen(
|
||||
)->GetInternalUnits() );
|
||||
|
||||
TimeStamp = Zone->m_TimeStamp;
|
||||
|
||||
for( pt_segm = (SEGZONE*) m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
|
||||
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() )
|
||||
{
|
||||
NextS = (SEGZONE*) pt_segm->Pnext;
|
||||
if( pt_segm->m_TimeStamp == TimeStamp )
|
||||
if( zone->m_TimeStamp == aZone->m_TimeStamp )
|
||||
{
|
||||
modify = TRUE;
|
||||
Edit_TrackSegm_Width( DC, pt_segm );
|
||||
Edit_TrackSegm_Width( DC, zone );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,22 +441,23 @@ void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* Zone )
|
|||
* La zone est constituee des segments zones de meme TimeStamp
|
||||
*/
|
||||
{
|
||||
SEGZONE* pt_segm, * NextS;
|
||||
unsigned long TimeStamp;
|
||||
int nb_segm = 0;
|
||||
bool modify = FALSE;
|
||||
|
||||
TimeStamp = Zone->m_TimeStamp;
|
||||
|
||||
for( pt_segm = (SEGZONE*) m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
|
||||
SEGZONE* next;
|
||||
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = next )
|
||||
{
|
||||
NextS = (SEGZONE*) pt_segm->Pnext;
|
||||
if( pt_segm->m_TimeStamp == TimeStamp )
|
||||
next = zone->Next();
|
||||
if( zone->m_TimeStamp == TimeStamp )
|
||||
{
|
||||
modify = TRUE;
|
||||
|
||||
/* effacement des segments a l'ecran */
|
||||
Trace_Une_Piste( DrawPanel, DC, pt_segm, nb_segm, GR_XOR );
|
||||
pt_segm ->DeleteStructure();
|
||||
Trace_Une_Piste( DrawPanel, DC, zone, nb_segm, GR_XOR );
|
||||
zone->DeleteStructure();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,7 +671,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone()
|
|||
oldedge = m_Pcb->m_CurrentLimitZone;
|
||||
|
||||
if( (m_Pcb->m_CurrentLimitZone == NULL ) /* debut reel du trace */
|
||||
|| (DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */
|
||||
|| (DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */
|
||||
{
|
||||
m_Pcb->m_CurrentLimitZone = newedge = new EDGE_ZONE( m_Pcb );
|
||||
|
||||
|
@ -694,8 +690,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone()
|
|||
else /* piste en cours : les coord du point d'arrivee ont ete mises
|
||||
* a jour par la routine Show_Zone_Edge_While_MoveMouse*/
|
||||
{
|
||||
if( (oldedge->m_Start.x != oldedge->m_End.x)
|
||||
|| (oldedge->m_Start.y != oldedge->m_End.y) )
|
||||
if( oldedge->m_Start != oldedge->m_End )
|
||||
{
|
||||
newedge = new EDGE_ZONE( oldedge );
|
||||
newedge->Pback = oldedge;
|
||||
|
@ -834,11 +829,15 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC )
|
|||
DisplayError( this, wxT( "Board is empty!" ), 10 );
|
||||
return;
|
||||
}
|
||||
|
||||
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
||||
WinEDA_ZoneFrame* frame = new WinEDA_ZoneFrame( this );
|
||||
ii = frame->ShowModal(); frame->Destroy();
|
||||
|
||||
ii = frame->ShowModal();
|
||||
frame->Destroy();
|
||||
DrawPanel->MouseToCursorSchema();
|
||||
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
||||
|
||||
if( ii )
|
||||
return;
|
||||
|
||||
|
@ -856,7 +855,9 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC )
|
|||
s_TimeStamp = time( NULL );
|
||||
|
||||
/* Calcul du pas de routage fixe a 5 mils et plus */
|
||||
E_scale = g_GridRoutingSize / 50; if( g_GridRoutingSize < 1 )
|
||||
E_scale = g_GridRoutingSize / 50;
|
||||
|
||||
if( g_GridRoutingSize < 1 )
|
||||
g_GridRoutingSize = 1;
|
||||
|
||||
/* calcule de Ncols et Nrow, taille de la matrice de routage */
|
||||
|
@ -865,8 +866,10 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC )
|
|||
/* Determination de la cellule pointee par la souris */
|
||||
ZoneStartFill.x = ( GetScreen()->m_Curseur.x - m_Pcb->m_BoundaryBox.m_Pos.x +
|
||||
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
|
||||
|
||||
ZoneStartFill.y = ( GetScreen()->m_Curseur.y - m_Pcb->m_BoundaryBox.m_Pos.y +
|
||||
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
|
||||
|
||||
if( ZoneStartFill.x < 0 )
|
||||
ZoneStartFill.x = 0;
|
||||
if( ZoneStartFill.x >= Ncols )
|
||||
|
@ -886,8 +889,10 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC )
|
|||
|
||||
msg.Printf( wxT( "%d" ), Ncols );
|
||||
Affiche_1_Parametre( this, 1, wxT( "Cols" ), msg, GREEN );
|
||||
|
||||
msg.Printf( wxT( "%d" ), Nrows );
|
||||
Affiche_1_Parametre( this, 7, wxT( "Lines" ), msg, GREEN );
|
||||
|
||||
msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
|
||||
Affiche_1_Parametre( this, 14, wxT( "Mem(Ko)" ), msg, CYAN );
|
||||
|
||||
|
@ -922,10 +927,13 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC )
|
|||
{
|
||||
if( g_HightLigth_NetCode != pt_segm->GetNet() )
|
||||
continue;
|
||||
|
||||
if( pt_segm->GetLayer() != GetScreen()->m_Active_Layer )
|
||||
continue;
|
||||
|
||||
if( pt_segm->Type() != TYPETRACK )
|
||||
continue;
|
||||
|
||||
TraceSegmentPcb( m_Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue