7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 09:51:43 +00:00

virtual BOARD_ITEM::Save()

This commit is contained in:
dickelbeck 2007-10-30 21:30:58 +00:00
parent a67a4f7eef
commit 64e9e16886
31 changed files with 1469 additions and 901 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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();

View File

@ -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;
};

View File

@ -287,6 +287,15 @@ public:
* @return EQUIPOT* - the net or NULL if not found.
*/
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;
/**
@ -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 */

View File

@ -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)
/**

View File

@ -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;
}
/************************************************************************/

View File

@ -29,8 +29,15 @@ 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();

View File

@ -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);
}
/****************************************************************/

View File

@ -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

View File

@ -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)
/**

View File

@ -33,8 +33,16 @@ 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
* @return int - the netcode

View File

@ -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.

View File

@ -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;
}
/**********************************************************/

View File

@ -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 */

View File

@ -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

View File

@ -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 );

View File

@ -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;
}
/******************************************************/

View File

@ -77,8 +77,16 @@ 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 );
void Draw3D( Pcb3D_GLCanvas* glcanvas );

View File

@ -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;
}
/**********************************************************************/

View File

@ -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

View File

@ -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 )

View File

@ -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 */

View File

@ -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;
}
/*********************************************************************/

View File

@ -59,9 +59,16 @@ 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
* inserts a TRACK, SEGVIA or SEGZONE into its proper list, either at the

Some files were not shown because too many files have changed in this diff Show More