Commit 5748b791 authored by dickelbeck's avatar dickelbeck

added some conditional DEBUG code for showing the pcb object tree in simple XML format

parent 02a2268f
......@@ -18,8 +18,7 @@
// DrawStructureType names for error messages only:
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1]
= {
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1] = {
wxT( "Not init" ),
wxT( "Pcb" ),
......@@ -168,10 +167,9 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
*/
{
}
#endif
/*********************************************/
wxString EDA_BaseStruct::ReturnClassName( void )
/*********************************************/
......@@ -191,6 +189,48 @@ wxString EDA_BaseStruct::ReturnClassName( void )
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n";
EDA_BaseStruct* kid = m_Son;
for( ; kid; kid = kid->Pnext )
{
kid->Show( nestLevel+1, os );
}
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
}
/**
* Function NestedSpace
* outputs nested space for pretty indenting.
* @param nestLevel The nest count
* @param os The ostream&, where to output
* @return std::ostream& - for continuation.
**/
std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os )
{
for( int i=0; i<nestLevel; ++i )
os << ' '; // number of spaces here controls indent per nest level
return os;
}
#endif
/**********************************************************************************************/
EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) :
EDA_BaseStruct( StructFather, idtype )
......@@ -721,3 +761,4 @@ void DrawPickedStruct::DeleteWrapperList( void )
delete wrapp_struct;
}
}
......@@ -6,6 +6,11 @@
#define BASE_STRUCT_H
#if defined(DEBUG)
#include <iostream> // needed for Show()
#endif
/* Id for class identification, at run time */
enum DrawStructureType {
TYPE_NOT_INIT = 0,
......@@ -123,8 +128,30 @@ public:
const wxPoint& offset,
int draw_mode,
int Color = -1 );
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
/**
* Function NestedSpace
* outputs nested space for pretty indenting.
* @param nestLevel The nest count
* @param os The ostream&, where to output
* @return std::ostream& - for continuation.
**/
static std::ostream& NestedSpace( int nestLevel, std::ostream& os );
#endif
};
// Text justify:
// Values -1,0,1 are used in computations, do not change them
typedef enum {
......
......@@ -176,15 +176,16 @@ public:
EDA_BoardDesignSettings( void );
};
// Values for m_DisplayViaMode member:
enum DisplayViaMode {
VIA_HOLE_NOT_SHOW = 0,
VIA_SPECIAL_HOLE_SHOW,
ALL_VIA_HOLE_SHOW,
OPT_VIA_HOLE_END
};
class BOARD : public EDA_BaseStruct
{
public:
......@@ -212,8 +213,8 @@ public:
CHEVELU* m_Ratsnest; // pointeur liste des chevelus
CHEVELU* m_LocalRatsnest; // pointeur liste des chevelus d'un module
EDGE_ZONE* m_CurrentLimitZone;/* pointeur sur la liste des segments
* de delimitation de la zone en cours de trace */
EDGE_ZONE* m_CurrentLimitZone; /* pointeur sur la liste des segments
* de delimitation de la zone en cours de trace */
BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame );
~BOARD( void );
......@@ -230,6 +231,18 @@ public:
// Calcul du rectangle d'encadrement:
bool ComputeBoundaryBox( void );
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
#endif
};
......
......@@ -254,3 +254,36 @@ bool BOARD::ComputeBoundaryBox( void )
return Has_Items;
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void BOARD::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n";
// specialization of the output:
EDA_BaseStruct* p = m_Modules;
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
p = m_Drawings;
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
EDA_BaseStruct* kid = m_Son;
for( ; kid; kid = kid->Pnext )
{
kid->Show( nestLevel+1, os );
}
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
}
#endif
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/****************************************************/
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -23,1050 +23,1152 @@
#include "3d_struct.h"
#include "protos.h"
#define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes...
#define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes...
/*********************************************************************************/
void MODULE::DrawAncre(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset,
int dim_ancre, int draw_mode)
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode )
/*********************************************************************************/
/* trace de l'ancre (croix verticale)
(doit etre fait apres les pads,
car le trace du trou efface tout donc peut etre l'ancre */
* (doit etre fait apres les pads,
* car le trace du trou efface tout donc peut etre l'ancre */
{
int zoom = panel->GetZoom();
int anchor_size = dim_ancre * zoom;
GRSetDrawMode(DC, draw_mode);
if((g_AnchorColor & ITEM_NOT_SHOW) == 0 )
{
GRLine(&panel->m_ClipBox, DC,
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
m_Pos.x -offset.x + anchor_size,m_Pos.y - offset.y,
0, g_AnchorColor);
GRLine(&panel->m_ClipBox, DC,
m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size ,
m_Pos.x - offset.x, m_Pos.y - offset.y + anchor_size ,
0, g_AnchorColor);
}
int zoom = panel->GetZoom();
int anchor_size = dim_ancre * zoom;
GRSetDrawMode( DC, draw_mode );
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
{
GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y,
0, g_AnchorColor );
GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size,
m_Pos.x - offset.x, m_Pos.y - offset.y + anchor_size,
0, g_AnchorColor );
}
}
/*************************************************/
/* Class MODULE : description d'un composant pcb */
/*************************************************/
/*************************************************/
/* Class MODULE : description d'un composant pcb */
/*************************************************/
/* Constructeur de la classe MODULE */
MODULE::MODULE(BOARD * parent): EDA_BaseStruct( parent, TYPEMODULE)
MODULE::MODULE( BOARD* parent ) : EDA_BaseStruct( parent, TYPEMODULE )
{
m_Pads = NULL;
m_Drawings = NULL;
m_3D_Drawings = NULL;
m_Attributs = MOD_DEFAULT;
m_Layer = CMP_N;
m_Orient = 0;
m_ModuleStatus = 0;
flag = 0;
m_CntRot90 = m_CntRot180 = 0;
m_Surface = 0;
m_Link = 0;
m_LastEdit_Time = time(NULL);
m_Reference = new TEXTE_MODULE(this, TEXT_is_REFERENCE);
m_Reference->Pback = this;
m_Value = new TEXTE_MODULE(this, TEXT_is_VALUE);
m_Value->Pback = this;
m_3D_Drawings = new Struct3D_Master(this);
m_Pads = NULL;
m_Drawings = NULL;
m_3D_Drawings = NULL;
m_Attributs = MOD_DEFAULT;
m_Layer = CMP_N;
m_Orient = 0;
m_ModuleStatus = 0;
flag = 0;
m_CntRot90 = m_CntRot180 = 0;
m_Surface = 0;
m_Link = 0;
m_LastEdit_Time = time( NULL );
m_Reference = new TEXTE_MODULE( this, TEXT_is_REFERENCE );
m_Reference->Pback = this;
m_Value = new TEXTE_MODULE( this, TEXT_is_VALUE );
m_Value->Pback = this;
m_3D_Drawings = new Struct3D_Master( this );
}
/* Destructeur */
MODULE::~MODULE(void)
/* Destructeur */
MODULE::~MODULE( void )
{
D_PAD * Pad;
EDA_BaseStruct * Struct, * NextStruct;
delete m_Reference;
delete m_Value;
for ( Struct = m_3D_Drawings; Struct != NULL; Struct = NextStruct)
{
NextStruct = Struct->Pnext;
delete Struct;
}
/* effacement des pads */
for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*)NextStruct )
{
NextStruct = Pad->Pnext;
delete Pad;
}
/* effacement des elements de trace */
for ( Struct = m_Drawings; Struct != NULL; Struct = NextStruct )
{
NextStruct = Struct->Pnext;
switch( (Struct->m_StructType) )
{
case TYPEEDGEMODULE:
delete (EDGE_MODULE*)Struct;
break;
case TYPETEXTEMODULE:
delete (TEXTE_MODULE*)Struct;
break;
default:
DisplayError(NULL, wxT("Warn: ItemType not handled in delete MODULE"));
NextStruct = NULL;
break;
}
}
D_PAD* Pad;
EDA_BaseStruct* Struct, * NextStruct;
delete m_Reference;
delete m_Value;
for( Struct = m_3D_Drawings; Struct != NULL; Struct = NextStruct )
{
NextStruct = Struct->Pnext;
delete Struct;
}
/* effacement des pads */
for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*) NextStruct )
{
NextStruct = Pad->Pnext;
delete Pad;
}
/* effacement des elements de trace */
for( Struct = m_Drawings; Struct != NULL; Struct = NextStruct )
{
NextStruct = Struct->Pnext;
switch( (Struct->m_StructType) )
{
case TYPEEDGEMODULE:
delete (EDGE_MODULE*) Struct;
break;
case TYPETEXTEMODULE:
delete (TEXTE_MODULE*) Struct;
break;
default:
DisplayError( NULL, wxT( "Warn: ItemType not handled in delete MODULE" ) );
NextStruct = NULL;
break;
}
}
}
/*********************************/
void MODULE::Copy(MODULE * Module)
void MODULE::Copy( MODULE* Module )
/*********************************/
{
D_PAD * pad,* lastpad;
m_Pos = Module->m_Pos;
m_Layer = Module->m_Layer;
m_LibRef = Module->m_LibRef;
m_Attributs = Module->m_Attributs;
m_Orient = Module->m_Orient;
m_BoundaryBox = Module->m_BoundaryBox;
m_PadNum = Module->m_PadNum;
m_CntRot90 = Module->m_CntRot90;
m_CntRot180 = Module->m_CntRot180;
m_LastEdit_Time = Module->m_LastEdit_Time;
m_TimeStamp = GetTimeStamp();
/* Copy des structures auxiliaires: Reference et value */
m_Reference->Copy(Module->m_Reference);
m_Value->Copy(Module->m_Value);
/* Copie des structures auxiliaires: Pads */
lastpad = NULL; pad = Module->m_Pads;
for( ;pad != NULL ; pad = (D_PAD*)pad->Pnext)
{
D_PAD * newpad = new D_PAD (this);
newpad->Copy(pad);
if(m_Pads == NULL)
{
newpad->Pback = this;
m_Pads = (D_PAD*)newpad;
}
else
{
newpad->Pback = lastpad;
lastpad->Pnext = newpad;
}
lastpad = newpad;
}
/* Copy des structures auxiliaires: Drawings */
EDA_BaseStruct* OldStruct = (EDA_BaseStruct*) Module->m_Drawings;
EDA_BaseStruct* NewStruct, *LastStruct = NULL;
for( ;OldStruct ; OldStruct = OldStruct->Pnext)
{
NewStruct = NULL;
switch(OldStruct->m_StructType)
{
case TYPETEXTEMODULE:
NewStruct = new TEXTE_MODULE( this );
((TEXTE_MODULE*)NewStruct)->Copy((TEXTE_MODULE*)OldStruct);
break;
case TYPEEDGEMODULE:
NewStruct = new EDGE_MODULE( this );
((EDGE_MODULE*)NewStruct)->Copy((EDGE_MODULE*)OldStruct);
break;
default:
DisplayError(NULL, wxT("Internal Err: CopyModule: type indefini"));
break;
}
if( NewStruct == NULL) break;
if(m_Drawings == NULL)
{
NewStruct->Pback = this;
m_Drawings = NewStruct;
}
else
{
NewStruct->Pback = LastStruct;
LastStruct->Pnext = NewStruct;
}
LastStruct = NewStruct;
}
/* Copy des elements complementaires Drawings 3D */
m_3D_Drawings->Copy(Module->m_3D_Drawings);
Struct3D_Master * Struct3D, *NewStruct3D, *CurrStruct3D;
Struct3D = (Struct3D_Master *) Module->m_3D_Drawings->Pnext;
CurrStruct3D = m_3D_Drawings;
for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext)
{
NewStruct3D = new Struct3D_Master(this);
NewStruct3D->Copy(Struct3D);
CurrStruct3D->Pnext = NewStruct3D;
NewStruct3D->Pback = CurrStruct3D;
CurrStruct3D = NewStruct3D;
}
/* Copie des elements complementaires */
m_Doc = Module->m_Doc;
m_KeyWord = Module->m_KeyWord;
D_PAD* pad, * lastpad;
m_Pos = Module->m_Pos;
m_Layer = Module->m_Layer;
m_LibRef = Module->m_LibRef;
m_Attributs = Module->m_Attributs;
m_Orient = Module->m_Orient;
m_BoundaryBox = Module->m_BoundaryBox;
m_PadNum = Module->m_PadNum;
m_CntRot90 = Module->m_CntRot90;
m_CntRot180 = Module->m_CntRot180;
m_LastEdit_Time = Module->m_LastEdit_Time;
m_TimeStamp = GetTimeStamp();
/* Copy des structures auxiliaires: Reference et value */
m_Reference->Copy( Module->m_Reference );
m_Value->Copy( Module->m_Value );
/* Copie des structures auxiliaires: Pads */
lastpad = NULL; pad = Module->m_Pads;
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
{
D_PAD* newpad = new D_PAD( this );
newpad->Copy( pad );
if( m_Pads == NULL )
{
newpad->Pback = this;
m_Pads = (D_PAD*) newpad;
}
else
{
newpad->Pback = lastpad;
lastpad->Pnext = newpad;
}
lastpad = newpad;
}
/* Copy des structures auxiliaires: Drawings */
EDA_BaseStruct* OldStruct = (EDA_BaseStruct*) Module->m_Drawings;
EDA_BaseStruct* NewStruct, * LastStruct = NULL;
for( ; OldStruct; OldStruct = OldStruct->Pnext )
{
NewStruct = NULL;
switch( OldStruct->m_StructType )
{
case TYPETEXTEMODULE:
NewStruct = new TEXTE_MODULE( this );
( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) OldStruct );
break;
case TYPEEDGEMODULE:
NewStruct = new EDGE_MODULE( this );
( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) OldStruct );
break;
default:
DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) );
break;
}
if( NewStruct == NULL )
break;
if( m_Drawings == NULL )
{
NewStruct->Pback = this;
m_Drawings = NewStruct;
}
else
{
NewStruct->Pback = LastStruct;
LastStruct->Pnext = NewStruct;
}
LastStruct = NewStruct;
}
/* Copy des elements complementaires Drawings 3D */
m_3D_Drawings->Copy( Module->m_3D_Drawings );
Struct3D_Master* Struct3D, * NewStruct3D, * CurrStruct3D;
Struct3D = (Struct3D_Master*) Module->m_3D_Drawings->Pnext;
CurrStruct3D = m_3D_Drawings;
for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext )
{
NewStruct3D = new Struct3D_Master( this );
NewStruct3D->Copy( Struct3D );
CurrStruct3D->Pnext = NewStruct3D;
NewStruct3D->Pback = CurrStruct3D;
CurrStruct3D = NewStruct3D;
}
/* Copie des elements complementaires */
m_Doc = Module->m_Doc;
m_KeyWord = Module->m_KeyWord;
}
/* supprime du chainage la structure Struct
les structures arrieres et avant sont chainees directement
* les structures arrieres et avant sont chainees directement
*/
void MODULE::UnLink( void )
{
/* Modification du chainage arriere */
if( Pback )
{
if( Pback->m_StructType != TYPEPCB)
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
if ( GetState(DELETED) ) // A REVOIR car Pback = NULL si place en undelete
{
if( g_UnDeleteStack ) g_UnDeleteStack[g_UnDeleteStackPtr-1] = Pnext;
}
else ((BOARD*)Pback)->m_Modules = (MODULE *) Pnext;
}
}
/* Modification du chainage avant */
if( Pnext) Pnext->Pback = Pback;
Pnext = Pback = NULL;
/* Modification du chainage arriere */
if( Pback )
{
if( Pback->m_StructType != TYPEPCB )
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
if( GetState( DELETED ) ) // A REVOIR car Pback = NULL si place en undelete
{
if( g_UnDeleteStack )
g_UnDeleteStack[g_UnDeleteStackPtr - 1] = Pnext;
}
else
( (BOARD*) Pback )->m_Modules = (MODULE*) Pnext;
}
}
/* Modification du chainage avant */
if( Pnext )
Pnext->Pback = Pback;
Pnext = Pback = NULL;
}
/**********************************************************/
void MODULE::Draw(WinEDA_DrawPanel * panel, wxDC * DC,
const wxPoint & offset, int draw_mode)
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode )
/**********************************************************/
/* Dessin d'une empreinte sur l'ecran actif:
Entree :
Module: pointeur sur le module
ox, oy = offset de trace
draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
Utilise par ailleur:
Description des parametres de l'empreinte calcules par caract() ;
*/
* Entree :
* Module: pointeur sur le module
* ox, oy = offset de trace
* draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
* Utilise par ailleur:
* Description des parametres de l'empreinte calcules par caract() ;
*/
{
D_PAD * pt_pad ;
EDA_BaseStruct * PtStruct;
TEXTE_MODULE * PtTexte;
/* trace des pastilles */
pt_pad = m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
if ( pt_pad->m_Flags & IS_MOVED ) continue;
pt_pad->Draw(panel, DC, offset,draw_mode);
}
/* Impression de l'ancre du module */
DrawAncre(panel, DC, offset, DIM_ANCRE_MODULE, draw_mode) ;
/* impression des graphismes */
if ( ! (m_Reference->m_Flags & IS_MOVED) )
m_Reference->Draw(panel, DC, offset, draw_mode);
if ( ! (m_Value->m_Flags & IS_MOVED) )
m_Value->Draw(panel, DC, offset, draw_mode);
PtStruct = m_Drawings;
for( ;PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
if ( PtStruct->m_Flags & IS_MOVED ) continue;
switch( PtStruct->m_StructType )
{
case TYPETEXTEMODULE:
PtTexte = (TEXTE_MODULE *) PtStruct;
PtTexte->Draw(panel, DC, offset, draw_mode);
break;
case TYPEEDGEMODULE:
((EDGE_MODULE *) PtStruct)->Draw(panel, DC, offset, draw_mode);
break;
default: break;
}
}
D_PAD* pt_pad;
EDA_BaseStruct* PtStruct;
TEXTE_MODULE* PtTexte;
/* trace des pastilles */
pt_pad = m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
if( pt_pad->m_Flags & IS_MOVED )
continue;
pt_pad->Draw( panel, DC, offset, draw_mode );
}
/* Impression de l'ancre du module */
DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode );
/* impression des graphismes */
if( !(m_Reference->m_Flags & IS_MOVED) )
m_Reference->Draw( panel, DC, offset, draw_mode );
if( !(m_Value->m_Flags & IS_MOVED) )
m_Value->Draw( panel, DC, offset, draw_mode );
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
if( PtStruct->m_Flags & IS_MOVED )
continue;
switch( PtStruct->m_StructType )
{
case TYPETEXTEMODULE:
PtTexte = (TEXTE_MODULE*) PtStruct;
PtTexte->Draw( panel, DC, offset, draw_mode );
break;
case TYPEEDGEMODULE:
( (EDGE_MODULE*) PtStruct )->Draw( panel, DC, offset, draw_mode );
break;
default:
break;
}
}
}
/**************************************************************/
void MODULE::DrawEdgesOnly(WinEDA_DrawPanel * panel, wxDC * DC,
const wxPoint & offset, int draw_mode)
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode )
/**************************************************************/
{
EDA_BaseStruct * PtStruct;
/* impression des graphismes */
PtStruct = m_Drawings;
for( ;PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
switch( PtStruct->m_StructType )
{
case TYPEEDGEMODULE:
((EDGE_MODULE *) PtStruct)->Draw(panel, DC, offset, draw_mode);
break;
default: break;
}
}
EDA_BaseStruct* PtStruct;
/* impression des graphismes */
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
switch( PtStruct->m_StructType )
{
case TYPEEDGEMODULE:
( (EDGE_MODULE*) PtStruct )->Draw( panel, DC, offset, draw_mode );
break;
default:
break;
}
}
}
/*************************************/
int MODULE::WriteDescr( FILE * File )
int MODULE::WriteDescr( FILE* File )
/*************************************/
/* Sauvegarde de la description d'un MODULE
*/
*/
{
char StringStat[20];
TEXTE_MODULE * PtText;
EDGE_MODULE * PtEdge;
D_PAD * ptpad;
EDA_BaseStruct * PtStruct;
int ii, NbLigne = 0;
wxString msg;
if( GetState(DELETED) ) return(NbLigne);
/* Generation du fichier module: */
fprintf( File,"$MODULE %s\n", CONV_TO_UTF8(m_LibRef));
NbLigne++;
/* Generation des coord et caracteristiques */
memset(StringStat, 0, sizeof(StringStat) );
if( m_ModuleStatus & MODULE_is_LOCKED)
StringStat[0] = 'F';
else StringStat[0] = '~';
if( m_ModuleStatus & MODULE_is_PLACED)
StringStat[1] = 'P';
else StringStat[1] = '~';
fprintf( File,"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, StringStat);
NbLigne++;
fprintf(File,"Li %s\n", CONV_TO_UTF8(m_LibRef));
NbLigne++;
if ( ! m_Doc.IsEmpty())
{
fprintf(File,"Cd %s\n", CONV_TO_UTF8(m_Doc));
NbLigne++;
}
if ( ! m_KeyWord.IsEmpty())
{
fprintf(File,"Kw %s\n", CONV_TO_UTF8(m_KeyWord));
NbLigne++;
}
fprintf(File,"Sc %8.8lX\n", m_TimeStamp);
NbLigne++;
fprintf(File,"Op %X %X 0\n", m_CntRot90, m_CntRot180);
NbLigne++;
/* Attributs du module */
if( m_Attributs != MOD_DEFAULT )
{
fprintf(File,"At ");
if( m_Attributs & MOD_CMS ) fprintf(File,"SMD ");
if( m_Attributs & MOD_VIRTUAL ) fprintf(File,"VIRTUAL ");
fprintf(File,"\n");
}
/* Texte Reference du module */
fprintf(File,"T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n",
m_Reference->m_Type,
m_Reference->m_Pos0.x, m_Reference->m_Pos0.y,
m_Reference->m_Size.y,m_Reference->m_Size.x,
m_Reference->m_Orient + m_Orient, m_Reference->m_Width,
m_Reference->m_Miroir ? 'N' : 'M', m_Reference->m_NoShow ? 'I' : 'V',
m_Reference->m_Layer,
CONV_TO_UTF8(m_Reference->m_Text) );
NbLigne++;
/* Texte Value du module */
fprintf(File,"T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n",
m_Value->m_Type,
m_Value->m_Pos0.x, m_Value->m_Pos0.y,
m_Value->m_Size.y,m_Value->m_Size.x,
m_Value->m_Orient + m_Orient, m_Value->m_Width,
m_Value->m_Miroir ? 'N' : 'M', m_Value->m_NoShow ? 'I' : 'V',
m_Value->m_Layer,
CONV_TO_UTF8(m_Value->m_Text) );
NbLigne++;
/* Generation des elements Drawing modules */
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext)
{
switch(PtStruct->m_StructType )
{
case TYPETEXTEMODULE:
PtText = ((TEXTE_MODULE *) PtStruct);
fprintf(File,"T%d %d %d %d %d %d %d %c %c %d \"%s\"\n",
PtText->m_Type,
PtText->m_Pos0.x, PtText->m_Pos0.y,
PtText->m_Size.y,PtText->m_Size.x,
PtText->m_Orient + m_Orient, PtText->m_Width,
PtText->m_Miroir ? 'N' : 'M',
PtText->m_NoShow ? 'I' : 'V',
PtText->m_Layer, CONV_TO_UTF8(PtText->m_Text) );
NbLigne++;
break;
case TYPEEDGEMODULE:
PtEdge = (EDGE_MODULE*) PtStruct;
PtEdge->WriteDescr( File );
break;
default:
msg.Printf( wxT("Type (%d) Draw Module inconnu"),
PtStruct->m_StructType);
DisplayError(NULL, msg);
break;
} /* Fin switch gestion des Items draw */
}
/* Generation de la liste des pads */
ptpad = m_Pads;
for( ; ptpad != NULL; ptpad = (D_PAD*)ptpad->Pnext)
{
ii = ptpad->WriteDescr(File);
NbLigne += ii;
}
/* Generation des informations de trac 3D */
Write_3D_Descr( File );
/* Fin de description: */
fprintf( File,"$EndMODULE %s\n", CONV_TO_UTF8(m_LibRef));
NbLigne++;
return(NbLigne);
char StringStat[20];
TEXTE_MODULE* PtText;
EDGE_MODULE* PtEdge;
D_PAD* ptpad;
EDA_BaseStruct* PtStruct;
int ii, NbLigne = 0;
wxString msg;
if( GetState( DELETED ) )
return NbLigne;
/* Generation du fichier module: */
fprintf( File, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
NbLigne++;
/* Generation des coord et caracteristiques */
memset( StringStat, 0, sizeof(StringStat) );
if( m_ModuleStatus & MODULE_is_LOCKED )
StringStat[0] = 'F';
else
StringStat[0] = '~';
if( m_ModuleStatus & MODULE_is_PLACED )
StringStat[1] = 'P';
else
StringStat[1] = '~';
fprintf( File, "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, StringStat );
NbLigne++;
fprintf( File, "Li %s\n", CONV_TO_UTF8( m_LibRef ) );
NbLigne++;
if( !m_Doc.IsEmpty() )
{
fprintf( File, "Cd %s\n", CONV_TO_UTF8( m_Doc ) );
NbLigne++;
}
if( !m_KeyWord.IsEmpty() )
{
fprintf( File, "Kw %s\n", CONV_TO_UTF8( m_KeyWord ) );
NbLigne++;
}
fprintf( File, "Sc %8.8lX\n", m_TimeStamp );
NbLigne++;
fprintf( File, "Op %X %X 0\n", m_CntRot90, m_CntRot180 );
NbLigne++;
/* Attributs du module */
if( m_Attributs != MOD_DEFAULT )
{
fprintf( File, "At " );
if( m_Attributs & MOD_CMS )
fprintf( File, "SMD " );
if( m_Attributs & MOD_VIRTUAL )
fprintf( File, "VIRTUAL " );
fprintf( File, "\n" );
}
/* Texte Reference du module */
fprintf( File, "T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n",
m_Reference->m_Type,
m_Reference->m_Pos0.x, m_Reference->m_Pos0.y,
m_Reference->m_Size.y, m_Reference->m_Size.x,
m_Reference->m_Orient + m_Orient, m_Reference->m_Width,
m_Reference->m_Miroir ? 'N' : 'M', m_Reference->m_NoShow ? 'I' : 'V',
m_Reference->m_Layer,
CONV_TO_UTF8( m_Reference->m_Text ) );
NbLigne++;
/* Texte Value du module */
fprintf( File, "T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n",
m_Value->m_Type,
m_Value->m_Pos0.x, m_Value->m_Pos0.y,
m_Value->m_Size.y, m_Value->m_Size.x,
m_Value->m_Orient + m_Orient, m_Value->m_Width,
m_Value->m_Miroir ? 'N' : 'M', m_Value->m_NoShow ? 'I' : 'V',
m_Value->m_Layer,
CONV_TO_UTF8( m_Value->m_Text ) );
NbLigne++;
/* Generation des elements Drawing modules */
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
switch( PtStruct->m_StructType )
{
case TYPETEXTEMODULE:
PtText = ( (TEXTE_MODULE*) PtStruct );
fprintf( File, "T%d %d %d %d %d %d %d %c %c %d \"%s\"\n",
PtText->m_Type,
PtText->m_Pos0.x, PtText->m_Pos0.y,
PtText->m_Size.y, PtText->m_Size.x,
PtText->m_Orient + m_Orient, PtText->m_Width,
PtText->m_Miroir ? 'N' : 'M',
PtText->m_NoShow ? 'I' : 'V',
PtText->m_Layer, CONV_TO_UTF8( PtText->m_Text ) );
NbLigne++;
break;
case TYPEEDGEMODULE:
PtEdge = (EDGE_MODULE*) PtStruct;
PtEdge->WriteDescr( File );
break;
default:
msg.Printf( wxT( "Type (%d) Draw Module inconnu" ),
PtStruct->m_StructType );
DisplayError( NULL, msg );
break;
}
/* Fin switch gestion des Items draw */
}
/* Generation de la liste des pads */
ptpad = m_Pads;
for( ; ptpad != NULL; ptpad = (D_PAD*) ptpad->Pnext )
{
ii = ptpad->WriteDescr( File );
NbLigne += ii;
}
/* Generation des informations de trac�3D */
Write_3D_Descr( File );
/* Fin de description: */
fprintf( File, "$EndMODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
NbLigne++;
return NbLigne;
}
/***************************************/
int MODULE::Write_3D_Descr( FILE * File )
int MODULE::Write_3D_Descr( FILE* File )
/***************************************/
/* Sauvegarde de la description 3D du MODULE
*/
*/
{
char buf[512];
Struct3D_Master * Struct3D = m_3D_Drawings;
for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master *) Struct3D->Pnext)
{
if ( ! Struct3D->m_Shape3DName.IsEmpty() )
{
fprintf( File,"$SHAPE3D\n");
fprintf( File,"Na \"%s\"\n", CONV_TO_UTF8(Struct3D->m_Shape3DName));
sprintf( buf,"Sc %lf %lf %lf\n",
Struct3D->m_MatScale.x,
Struct3D->m_MatScale.y,
Struct3D->m_MatScale.z);
fprintf( File, to_point(buf) );
sprintf( buf,"Of %lf %lf %lf\n",
Struct3D->m_MatPosition.x,
Struct3D->m_MatPosition.y,
Struct3D->m_MatPosition.z);
fprintf( File, to_point(buf) );
sprintf( buf,"Ro %lf %lf %lf\n",
Struct3D->m_MatRotation.x,
Struct3D->m_MatRotation.y,
Struct3D->m_MatRotation.z);
fprintf( File, to_point(buf) );
fprintf( File,"$EndSHAPE3D\n");
}
}
return 0;
char buf[512];
Struct3D_Master* Struct3D = m_3D_Drawings;
for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext )
{
if( !Struct3D->m_Shape3DName.IsEmpty() )
{
fprintf( File, "$SHAPE3D\n" );
fprintf( File, "Na \"%s\"\n", CONV_TO_UTF8( Struct3D->m_Shape3DName ) );
sprintf( buf, "Sc %lf %lf %lf\n",
Struct3D->m_MatScale.x,
Struct3D->m_MatScale.y,
Struct3D->m_MatScale.z );
fprintf( File, to_point( buf ) );
sprintf( buf, "Of %lf %lf %lf\n",
Struct3D->m_MatPosition.x,
Struct3D->m_MatPosition.y,
Struct3D->m_MatPosition.z );
fprintf( File, to_point( buf ) );
sprintf( buf, "Ro %lf %lf %lf\n",
Struct3D->m_MatRotation.x,
Struct3D->m_MatRotation.y,
Struct3D->m_MatRotation.z );
fprintf( File, to_point( buf ) );
fprintf( File, "$EndSHAPE3D\n" );
}
}
return 0;
}
/****************************************************/
int MODULE::Read_3D_Descr( FILE * File, int * LineNum)
int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
/****************************************************/
/* Lecture de la description d'un MODULE (format Ascii)
la 1ere ligne de descr ($MODULE) est supposee etre deja lue
retourne 0 si OK
*/
* la 1ere ligne de descr ($MODULE) est supposee etre deja lue
* retourne 0 si OK
*/
{
char Line[1024];
char * text = Line + 3;
Struct3D_Master * Struct3D = m_3D_Drawings;
if ( ! Struct3D->m_Shape3DName.IsEmpty() )
{
Struct3D_Master * NewStruct3D;
while ( Struct3D->Pnext )
Struct3D = (Struct3D_Master *)Struct3D->Pnext;
Struct3D->Pnext = NewStruct3D = new Struct3D_Master(this);
NewStruct3D->Pback = Struct3D;
Struct3D = NewStruct3D;
}
while( GetLine(File, Line, LineNum , sizeof(Line) -1) != NULL )
{
switch( Line[0] )
{
case '$': // Fin de description
if( Line[1] == 'E' ) return 0;
return 1;
case 'N': // Shape File Name
{
char buf[512];
ReadDelimitedText( buf, text, 512);
Struct3D->m_Shape3DName = CONV_FROM_UTF8(buf);
break;
}
case 'S': // Scale
sscanf( text,"%lf %lf %lf\n",
&Struct3D->m_MatScale.x,
&Struct3D->m_MatScale.y,
&Struct3D->m_MatScale.z);
break;
case 'O': // Offset
sscanf( text,"%lf %lf %lf\n",
&Struct3D->m_MatPosition.x,
&Struct3D->m_MatPosition.y,
&Struct3D->m_MatPosition.z);
break;
case 'R': // Rotation
sscanf( text,"%lf %lf %lf\n",
&Struct3D->m_MatRotation.x,
&Struct3D->m_MatRotation.y,
&Struct3D->m_MatRotation.z);
break;
default:
break;
}
}
return 1;
char Line[1024];
char* text = Line + 3;
Struct3D_Master* Struct3D = m_3D_Drawings;
if( !Struct3D->m_Shape3DName.IsEmpty() )
{
Struct3D_Master* NewStruct3D;
while( Struct3D->Pnext )
Struct3D = (Struct3D_Master*) Struct3D->Pnext;
Struct3D->Pnext = NewStruct3D = new Struct3D_Master( this );
NewStruct3D->Pback = Struct3D;
Struct3D = NewStruct3D;
}
while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL )
{
switch( Line[0] )
{
case '$': // Fin de description
if( Line[1] == 'E' )
return 0;
return 1;
case 'N': // Shape File Name
{
char buf[512];
ReadDelimitedText( buf, text, 512 );
Struct3D->m_Shape3DName = CONV_FROM_UTF8( buf );
break;
}
case 'S': // Scale
sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatScale.x,
&Struct3D->m_MatScale.y,
&Struct3D->m_MatScale.z );
break;
case 'O': // Offset
sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatPosition.x,
&Struct3D->m_MatPosition.y,
&Struct3D->m_MatPosition.z );
break;
case 'R': // Rotation
sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatRotation.x,
&Struct3D->m_MatRotation.y,
&Struct3D->m_MatRotation.z );
break;
default:
break;
}
}
return 1;
}
/**************************************************/
int MODULE::ReadDescr( FILE * File, int * LineNum)
int MODULE::ReadDescr( FILE* File, int* LineNum )
/**************************************************/
/* Lecture de la description d'un MODULE (format Ascii)
la 1ere ligne de descr ($MODULE) est supposee etre deja lue
retourne 0 si OK
*/
* la 1ere ligne de descr ($MODULE) est supposee etre deja lue
* retourne 0 si OK
*/
{
D_PAD * LastPad = NULL, * ptpad;
EDA_BaseStruct * LastModStruct = NULL;
EDGE_MODULE * DrawSegm;
TEXTE_MODULE * DrawText;
char Line[256], BufLine[256], BufCar1[128], BufCar2[128], *PtLine;
int itmp1, itmp2;
while( GetLine(File, Line, LineNum , sizeof(Line) -1) != NULL )
{
if( Line[0] == '$' )
{
if( Line[1] == 'E' ) break;
if( Line[1] == 'P' )
{
ptpad = new D_PAD(this);
ptpad->ReadDescr(File, LineNum );
RotatePoint( &ptpad->m_Pos.x, &ptpad->m_Pos.y, m_Orient );
ptpad->m_Pos.x += m_Pos.x;
ptpad->m_Pos.y += m_Pos.y;
if(LastPad == NULL )
{
ptpad->Pback = (EDA_BaseStruct *) this;
m_Pads = ptpad;
}
else
{
ptpad->Pback = (EDA_BaseStruct *) LastPad;
LastPad->Pnext = (EDA_BaseStruct *)ptpad;
}
LastPad = ptpad;
continue;
}
if( Line[1] == 'S' ) Read_3D_Descr(File, LineNum );
}
if ( strlen(Line) < 4 ) continue;
PtLine = Line + 3; /* Pointe 1er code utile de la ligne */
switch( Line[0] )
{
case 'P':
memset(BufCar1, 0, sizeof(BufCar1) );
sscanf( PtLine,"%d %d %d %d %lX %lX %s",
&m_Pos.x, &m_Pos.y,
&m_Orient, &m_Layer ,
&m_LastEdit_Time, &m_TimeStamp,BufCar1);
m_ModuleStatus = 0;
if(BufCar1[0] == 'F') m_ModuleStatus |= MODULE_is_LOCKED;
if(BufCar1[1] == 'P') m_ModuleStatus |= MODULE_is_PLACED;
break;
case 'L': /* Li = Lecture du nom librairie du module */
*BufLine = 0;
sscanf(PtLine," %s",BufLine);
m_LibRef = CONV_FROM_UTF8(BufLine);
break;
case 'S':
sscanf(PtLine," %lX", &m_TimeStamp);
break;
case 'O': /* (Op)tions de placement auto */
itmp1 = itmp2 = 0;
sscanf(PtLine," %X %X", &itmp1, &itmp2);
m_CntRot180 = itmp2 & 0x0F;
if( m_CntRot180 > 10 ) m_CntRot180 = 10;
m_CntRot90 = itmp1 & 0x0F;
if( m_CntRot90 > 10 ) m_CntRot90 = 0;
itmp1 = (itmp1 >> 4) & 0x0F;
if( itmp1 > 10 ) itmp1 = 0;
m_CntRot90 |= itmp1 << 4;
break;
case 'A': /* At = (At)tributs du module */
if ( strstr(PtLine, "SMD") ) m_Attributs |= MOD_CMS;
if ( strstr(PtLine, "VIRTUAL") ) m_Attributs |= MOD_VIRTUAL;
break;
case 'T': /* lecture des textes modules */
sscanf(Line+1,"%d", &itmp1);
if ( itmp1 == TEXT_is_REFERENCE )
DrawText = m_Reference;
else if ( itmp1 == TEXT_is_VALUE )
DrawText = m_Value;
else /* text is a drawing */
{DrawText = new TEXTE_MODULE(this);
if(LastModStruct == NULL )
{
DrawText->Pback = this;
m_Drawings = (EDA_BaseStruct*) DrawText;
}
else
{
DrawText->Pback = LastModStruct;
LastModStruct->Pnext = DrawText;
}
LastModStruct = (EDA_BaseStruct*) DrawText;
}
sscanf(Line+1,"%d %d %d %d %d %d %d %s %s %d",
&itmp1,
&DrawText->m_Pos0.x, &DrawText->m_Pos0.y,
&DrawText->m_Size.y, &DrawText->m_Size.x,
&DrawText->m_Orient, &DrawText->m_Width,
BufCar1, BufCar2, &DrawText->m_Layer);
DrawText->m_Type = itmp1;
DrawText->m_Orient -= m_Orient; // m_Orient texte relative au module
if( BufCar1[0] == 'M') DrawText->m_Miroir = 0;
else DrawText->m_Miroir = 1;
if( BufCar2[0] == 'I') DrawText->m_NoShow = 1;
else DrawText->m_NoShow = 0;
if(m_Layer == CUIVRE_N) DrawText->m_Layer = SILKSCREEN_N_CU;
if(m_Layer == CMP_N) DrawText->m_Layer = SILKSCREEN_N_CMP;
/* calcul de la position vraie */
DrawText->SetDrawCoord();
/* Lecture de la chaine "text" */
ReadDelimitedText(BufLine, Line , sizeof(BufLine) );
DrawText->m_Text = CONV_FROM_UTF8(BufLine);
// Controle d'epaisseur raisonnable:
if( DrawText->m_Width <= 1 ) DrawText->m_Width = 1;
if( DrawText->m_Width > MAX_WIDTH ) DrawText->m_Width = MAX_WIDTH;
break;
case 'D': /* lecture du contour */
DrawSegm = new EDGE_MODULE(this);
if(LastModStruct == NULL )
{
DrawSegm->Pback = this;
m_Drawings = DrawSegm;
}
else
{
DrawSegm->Pback = LastModStruct;
LastModStruct->Pnext = DrawSegm;
}
LastModStruct = DrawSegm;
DrawSegm->ReadDescr( Line, File, LineNum);
DrawSegm->SetDrawCoord();
break;
case 'C': /* Lecture de la doc */
m_Doc = CONV_FROM_UTF8(StrPurge(PtLine));
break;
case 'K': /* Lecture de la liste des mots cle */
m_KeyWord = CONV_FROM_UTF8(StrPurge(PtLine));
break;
default:
break;
}
}
/* Recalcul de l'encadrement */
Set_Rectangle_Encadrement();
return(0);
D_PAD* LastPad = NULL, * ptpad;
EDA_BaseStruct* LastModStruct = NULL;
EDGE_MODULE* DrawSegm;
TEXTE_MODULE* DrawText;
char Line[256], BufLine[256], BufCar1[128], BufCar2[128], * PtLine;
int itmp1, itmp2;
while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL )
{
if( Line[0] == '$' )
{
if( Line[1] == 'E' )
break;
if( Line[1] == 'P' )
{
ptpad = new D_PAD( this );
ptpad->ReadDescr( File, LineNum );
RotatePoint( &ptpad->m_Pos.x, &ptpad->m_Pos.y, m_Orient );
ptpad->m_Pos.x += m_Pos.x;
ptpad->m_Pos.y += m_Pos.y;
if( LastPad == NULL )
{
ptpad->Pback = (EDA_BaseStruct*) this;
m_Pads = ptpad;
}
else
{
ptpad->Pback = (EDA_BaseStruct*) LastPad;
LastPad->Pnext = (EDA_BaseStruct*) ptpad;
}
LastPad = ptpad;
continue;
}
if( Line[1] == 'S' )
Read_3D_Descr( File, LineNum );
}
if( strlen( Line ) < 4 )
continue;
PtLine = Line + 3;
/* Pointe 1er code utile de la ligne */
switch( Line[0] )
{
case 'P':
memset( BufCar1, 0, sizeof(BufCar1) );
sscanf( PtLine, "%d %d %d %d %lX %lX %s",
&m_Pos.x, &m_Pos.y,
&m_Orient, &m_Layer,
&m_LastEdit_Time, &m_TimeStamp, BufCar1 );
m_ModuleStatus = 0;
if( BufCar1[0] == 'F' )
m_ModuleStatus |= MODULE_is_LOCKED;
if( BufCar1[1] == 'P' )
m_ModuleStatus |= MODULE_is_PLACED;
break;
case 'L': /* Li = Lecture du nom librairie du module */
*BufLine = 0;
sscanf( PtLine, " %s", BufLine );
m_LibRef = CONV_FROM_UTF8( BufLine );
break;
case 'S':
sscanf( PtLine, " %lX", &m_TimeStamp );
break;
case 'O': /* (Op)tions de placement auto */
itmp1 = itmp2 = 0;
sscanf( PtLine, " %X %X", &itmp1, &itmp2 );
m_CntRot180 = itmp2 & 0x0F;
if( m_CntRot180 > 10 )
m_CntRot180 = 10;
m_CntRot90 = itmp1 & 0x0F;
if( m_CntRot90 > 10 )
m_CntRot90 = 0;
itmp1 = (itmp1 >> 4) & 0x0F;
if( itmp1 > 10 )
itmp1 = 0;
m_CntRot90 |= itmp1 << 4;
break;
case 'A': /* At = (At)tributs du module */
if( strstr( PtLine, "SMD" ) )
m_Attributs |= MOD_CMS;
if( strstr( PtLine, "VIRTUAL" ) )
m_Attributs |= MOD_VIRTUAL;
break;
case 'T': /* lecture des textes modules */
sscanf( Line + 1, "%d", &itmp1 );
if( itmp1 == TEXT_is_REFERENCE )
DrawText = m_Reference;
else if( itmp1 == TEXT_is_VALUE )
DrawText = m_Value;
else /* text is a drawing */
{
DrawText = new TEXTE_MODULE( this );
if( LastModStruct == NULL )
{
DrawText->Pback = this;
m_Drawings = (EDA_BaseStruct*) DrawText;
}
else
{
DrawText->Pback = LastModStruct;
LastModStruct->Pnext = DrawText;
}
LastModStruct = (EDA_BaseStruct*) DrawText;
}
sscanf( Line + 1, "%d %d %d %d %d %d %d %s %s %d",
&itmp1,
&DrawText->m_Pos0.x, &DrawText->m_Pos0.y,
&DrawText->m_Size.y, &DrawText->m_Size.x,
&DrawText->m_Orient, &DrawText->m_Width,
BufCar1, BufCar2, &DrawText->m_Layer );
DrawText->m_Type = itmp1;
DrawText->m_Orient -= m_Orient; // m_Orient texte relative au module
if( BufCar1[0] == 'M' )
DrawText->m_Miroir = 0;
else
DrawText->m_Miroir = 1;
if( BufCar2[0] == 'I' )
DrawText->m_NoShow = 1;
else
DrawText->m_NoShow = 0;
if( m_Layer == CUIVRE_N )
DrawText->m_Layer = SILKSCREEN_N_CU;
if( m_Layer == CMP_N )
DrawText->m_Layer = SILKSCREEN_N_CMP;
/* calcul de la position vraie */
DrawText->SetDrawCoord();
/* Lecture de la chaine "text" */
ReadDelimitedText( BufLine, Line, sizeof(BufLine) );
DrawText->m_Text = CONV_FROM_UTF8( BufLine );
// Controle d'epaisseur raisonnable:
if( DrawText->m_Width <= 1 )
DrawText->m_Width = 1;
if( DrawText->m_Width > MAX_WIDTH )
DrawText->m_Width = MAX_WIDTH;
break;
case 'D': /* lecture du contour */
DrawSegm = new EDGE_MODULE( this );
if( LastModStruct == NULL )
{
DrawSegm->Pback = this;
m_Drawings = DrawSegm;
}
else
{
DrawSegm->Pback = LastModStruct;
LastModStruct->Pnext = DrawSegm;
}
LastModStruct = DrawSegm;
DrawSegm->ReadDescr( Line, File, LineNum );
DrawSegm->SetDrawCoord();
break;
case 'C': /* Lecture de la doc */
m_Doc = CONV_FROM_UTF8( StrPurge( PtLine ) );
break;
case 'K': /* Lecture de la liste des mots cle */
m_KeyWord = CONV_FROM_UTF8( StrPurge( PtLine ) );
break;
default:
break;
}
}
/* Recalcul de l'encadrement */
Set_Rectangle_Encadrement();
return 0;
}
/****************************************************/
void MODULE::SetPosition(const wxPoint & newpos)
void MODULE::SetPosition( const wxPoint& newpos )
/****************************************************/
// replace le module en position newpos
{
int deltaX = newpos.x - m_Pos.x;
int deltaY = newpos.y - m_Pos.y;
/* deplacement de l'ancre */
m_Pos.x += deltaX ; m_Pos.y += deltaY ;
/* deplacement de la reference */
m_Reference->m_Pos.x += deltaX ; m_Reference->m_Pos.y += deltaY;
/* deplacement de la Valeur */
m_Value->m_Pos.x += deltaX ; m_Value->m_Pos.y += deltaY;
/* deplacement des pastilles */
D_PAD * pad = m_Pads;
for ( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
{
pad->m_Pos.x += deltaX ; pad->m_Pos.y += deltaY ;
}
/* deplacement des dessins de l'empreinte : */
EDA_BaseStruct * PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext)
{
switch( PtStruct->m_StructType)
{
case TYPEEDGEMODULE:
{
EDGE_MODULE * pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord();
break;
}
case TYPETEXTEMODULE:
{
TEXTE_MODULE * pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.x += deltaX ; pt_texte->m_Pos.y += deltaY;
break;
}
default: DisplayError(NULL, wxT("Type Draw Indefini")); break;
}
}
Set_Rectangle_Encadrement();
int deltaX = newpos.x - m_Pos.x;
int deltaY = newpos.y - m_Pos.y;
/* deplacement de l'ancre */
m_Pos.x += deltaX; m_Pos.y += deltaY;
/* deplacement de la reference */
m_Reference->m_Pos.x += deltaX; m_Reference->m_Pos.y += deltaY;
/* deplacement de la Valeur */
m_Value->m_Pos.x += deltaX; m_Value->m_Pos.y += deltaY;
/* deplacement des pastilles */
D_PAD* pad = m_Pads;
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
{
pad->m_Pos.x += deltaX; pad->m_Pos.y += deltaY;
}
/* deplacement des dessins de l'empreinte : */
EDA_BaseStruct* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
switch( PtStruct->m_StructType )
{
case TYPEEDGEMODULE:
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord();
break;
}
case TYPETEXTEMODULE:
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.x += deltaX; pt_texte->m_Pos.y += deltaY;
break;
}
default:
DisplayError( NULL, wxT( "Type Draw Indefini" ) ); break;
}
}
Set_Rectangle_Encadrement();
}
/*********************************************/
void MODULE::SetOrientation(int newangle)
void MODULE::SetOrientation( int newangle )
/*********************************************/
/* Tourne de newangle (en 0.1 degres) le module
*/
*/
{
int px ,py;
newangle -= m_Orient; // = delta de rotation
m_Orient += newangle;
NORMALIZE_ANGLE_POS(m_Orient);
/* deplacement et rotation des pastilles */
D_PAD * pad = m_Pads;
for (; pad != NULL; pad = (D_PAD*) pad->Pnext )
{
px = pad->m_Pos0.x;
py = pad->m_Pos0.y;
pad->m_Orient += newangle ; /* change m_Orientation */
NORMALIZE_ANGLE_POS(pad->m_Orient);
RotatePoint( &px, &py, (int) m_Orient );
pad->m_Pos.x = m_Pos.x + px;
pad->m_Pos.y = m_Pos.y + py;
}
/* mise a jour de la reference et de la valeur*/
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
/* deplacement des contours et textes de l'empreinte : */
EDA_BaseStruct * PtStruct = m_Drawings;
for(; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
if( PtStruct->m_StructType == TYPEEDGEMODULE )
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct ;
pt_edgmod->SetDrawCoord();
}
if( PtStruct->m_StructType == TYPETEXTEMODULE )
{
/* deplacement des inscriptions : */
TEXTE_MODULE * pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->SetDrawCoord();
}
}
/* Recalcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
int px, py;
newangle -= m_Orient; // = delta de rotation
m_Orient += newangle;
NORMALIZE_ANGLE_POS( m_Orient );
/* deplacement et rotation des pastilles */
D_PAD* pad = m_Pads;
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
{
px = pad->m_Pos0.x;
py = pad->m_Pos0.y;
pad->m_Orient += newangle; /* change m_Orientation */
NORMALIZE_ANGLE_POS( pad->m_Orient );
RotatePoint( &px, &py, (int) m_Orient );
pad->m_Pos.x = m_Pos.x + px;
pad->m_Pos.y = m_Pos.y + py;
}
/* mise a jour de la reference et de la valeur*/
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
/* deplacement des contours et textes de l'empreinte : */
EDA_BaseStruct* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
if( PtStruct->m_StructType == TYPEEDGEMODULE )
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord();
}
if( PtStruct->m_StructType == TYPETEXTEMODULE )
{
/* deplacement des inscriptions : */
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->SetDrawCoord();
}
}
/* Recalcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
}
/************************************************/
void MODULE::Set_Rectangle_Encadrement(void)
void MODULE::Set_Rectangle_Encadrement( void )
/************************************************/
/* Mise a jour du rectangle d'encadrement du module
Entree : pointeur sur module
Le rectangle d'encadrement est le rectangle comprenant les contours et les
pads.
Le rectangle est calcule:
pour orient 0
en coord relatives / position ancre
*/
* Entree : pointeur sur module
* Le rectangle d'encadrement est le rectangle comprenant les contours et les
* pads.
* Le rectangle est calcule:
* pour orient 0
* en coord relatives / position ancre
*/
{
EDGE_MODULE* pt_edge_mod;
D_PAD * pad;
int width;
int cx, cy, uxf, uyf, rayon;
int xmax, ymax;
/* Init des pointeurs */
pt_edge_mod = (EDGE_MODULE*) m_Drawings;
/* Init des coord du cadre a une valeur limite non nulle */
m_BoundaryBox.m_Pos.x = -500; xmax = 500;
m_BoundaryBox.m_Pos.y = -500; ymax = 500;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
for( ;pt_edge_mod != NULL; pt_edge_mod = (EDGE_MODULE*)pt_edge_mod->Pnext )
{
if( pt_edge_mod->m_StructType != TYPEEDGEMODULE) continue;
width = pt_edge_mod->m_Width / 2;
switch(pt_edge_mod->m_Shape)
{
case S_ARC:
case S_CIRCLE:
{
cx = pt_edge_mod->m_Start0.x; cy = pt_edge_mod->m_Start0.y ; // centre
uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y ;
rayon = (int)hypot((double)(cx-uxf),(double)(cy - uyf) );
rayon += width;
m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,cx - rayon);
m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,cy - rayon);
xmax = max(xmax, cx + rayon);
ymax = max(ymax, cy + rayon);
break;
}
default:
m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,pt_edge_mod->m_Start0.x - width);
m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,pt_edge_mod->m_End0.x - width);
m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,pt_edge_mod->m_Start0.y - width);
m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,pt_edge_mod->m_End0.y - width);
xmax = max(xmax, pt_edge_mod->m_Start0.x + width);
xmax = max(xmax, pt_edge_mod->m_End0.x + width);
ymax = max(ymax, pt_edge_mod->m_Start0.y + width);
ymax = max(ymax, pt_edge_mod->m_End0.y + width);
break;
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for( pad = m_Pads; pad != NULL; pad = (D_PAD*)pad->Pnext )
{
rayon = pad->m_Rayon;
cx = pad->m_Pos0.x; cy = pad->m_Pos0.y;
m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,cx - rayon);
m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,cy - rayon);
xmax = max(xmax, cx + rayon);
ymax = max(ymax, cy + rayon);
}
m_BoundaryBox.SetWidth(xmax - m_BoundaryBox.m_Pos.x);
m_BoundaryBox.SetHeight(ymax - m_BoundaryBox.m_Pos.y);
EDGE_MODULE* pt_edge_mod;
D_PAD* pad;
int width;
int cx, cy, uxf, uyf, rayon;
int xmax, ymax;
/* Init des pointeurs */
pt_edge_mod = (EDGE_MODULE*) m_Drawings;
/* Init des coord du cadre a une valeur limite non nulle */
m_BoundaryBox.m_Pos.x = -500; xmax = 500;
m_BoundaryBox.m_Pos.y = -500; ymax = 500;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
for( ; pt_edge_mod != NULL; pt_edge_mod = (EDGE_MODULE*) pt_edge_mod->Pnext )
{
if( pt_edge_mod->m_StructType != TYPEEDGEMODULE )
continue;
width = pt_edge_mod->m_Width / 2;
switch( pt_edge_mod->m_Shape )
{
case S_ARC:
case S_CIRCLE:
{
cx = pt_edge_mod->m_Start0.x; cy = pt_edge_mod->m_Start0.y; // centre
uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y;
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) );
rayon += width;
m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, cx - rayon );
m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, cy - rayon );
xmax = max( xmax, cx + rayon );
ymax = max( ymax, cy + rayon );
break;
}
default:
m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_Start0.x - width );
m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_End0.x - width );
m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_Start0.y - width );
m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_End0.y - width );
xmax = max( xmax, pt_edge_mod->m_Start0.x + width );
xmax = max( xmax, pt_edge_mod->m_End0.x + width );
ymax = max( ymax, pt_edge_mod->m_Start0.y + width );
ymax = max( ymax, pt_edge_mod->m_End0.y + width );
break;
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for( pad = m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext )
{
rayon = pad->m_Rayon;
cx = pad->m_Pos0.x; cy = pad->m_Pos0.y;
m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, cx - rayon );
m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, cy - rayon );
xmax = max( xmax, cx + rayon );
ymax = max( ymax, cy + rayon );
}
m_BoundaryBox.SetWidth( xmax - m_BoundaryBox.m_Pos.x );
m_BoundaryBox.SetHeight( ymax - m_BoundaryBox.m_Pos.y );
}
/****************************************/
void MODULE::SetRectangleExinscrit(void)
void MODULE::SetRectangleExinscrit( void )
/****************************************/
/* Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles:
Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
Entree : pointeur sur module
Le rectangle d'encadrement est le rectangle comprenant les contours et les
pads.
Met egalement a jour la surface (.m_Surface) du module.
*/
* Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
* Entree : pointeur sur module
* Le rectangle d'encadrement est le rectangle comprenant les contours et les
* pads.
* Met egalement a jour la surface (.m_Surface) du module.
*/
{
EDGE_MODULE* EdgeMod;
D_PAD * Pad;
int width;
int cx, cy, uxf, uyf, rayon;
int xmax, ymax;
m_RealBoundaryBox.m_Pos.x = xmax = m_Pos.x;
m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
EdgeMod = (EDGE_MODULE*)m_Drawings;
for( ;EdgeMod != NULL; EdgeMod = (EDGE_MODULE*)EdgeMod->Pnext )
{
if( EdgeMod->m_StructType != TYPEEDGEMODULE) continue;
width = EdgeMod->m_Width / 2;
switch(EdgeMod->m_Shape)
{
case S_ARC:
case S_CIRCLE:
{
cx = EdgeMod->m_Start.x; cy = EdgeMod->m_Start.y ; // centre
uxf = EdgeMod->m_End.x; uyf = EdgeMod->m_End.y ;
rayon = (int)hypot((double)(cx-uxf),(double)(cy - uyf) );
rayon += width;
m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,cx - rayon);
m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,cy - rayon);
xmax = max(xmax,cx + rayon);
ymax = max(ymax,cy + rayon);
break;
}
default:
m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,EdgeMod->m_Start.x - width);
m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,EdgeMod->m_End.x - width);
m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,EdgeMod->m_Start.y - width);
m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,EdgeMod->m_End.y - width);
xmax = max(xmax,EdgeMod->m_Start.x + width);
xmax = max(xmax,EdgeMod->m_End.x + width);
ymax = max(ymax,EdgeMod->m_Start.y + width);
ymax = max(ymax,EdgeMod->m_End.y + width);
break;
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*)Pad->Pnext )
{
rayon = Pad->m_Rayon;
cx = Pad->m_Pos.x; cy = Pad->m_Pos.y;
m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,cx - rayon);
m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,cy - rayon);
xmax = max(xmax,cx + rayon);
ymax = max(ymax,cy + rayon);
}
m_RealBoundaryBox.SetWidth(xmax - m_RealBoundaryBox.m_Pos.x);
m_RealBoundaryBox.SetHeight(ymax - m_RealBoundaryBox.m_Pos.y);
m_Surface = ABS((float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight());
EDGE_MODULE* EdgeMod;
D_PAD* Pad;
int width;
int cx, cy, uxf, uyf, rayon;
int xmax, ymax;
m_RealBoundaryBox.m_Pos.x = xmax = m_Pos.x;
m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
EdgeMod = (EDGE_MODULE*) m_Drawings;
for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
{
if( EdgeMod->m_StructType != TYPEEDGEMODULE )
continue;
width = EdgeMod->m_Width / 2;
switch( EdgeMod->m_Shape )
{
case S_ARC:
case S_CIRCLE:
{
cx = EdgeMod->m_Start.x; cy = EdgeMod->m_Start.y; // centre
uxf = EdgeMod->m_End.x; uyf = EdgeMod->m_End.y;
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) );
rayon += width;
m_RealBoundaryBox.m_Pos.x = min( m_RealBoundaryBox.m_Pos.x, cx - rayon );
m_RealBoundaryBox.m_Pos.y = min( m_RealBoundaryBox.m_Pos.y, cy - rayon );
xmax = max( xmax, cx + rayon );
ymax = max( ymax, cy + rayon );
break;
}
default:
m_RealBoundaryBox.m_Pos.x = min( m_RealBoundaryBox.m_Pos.x, EdgeMod->m_Start.x - width );
m_RealBoundaryBox.m_Pos.x = min( m_RealBoundaryBox.m_Pos.x, EdgeMod->m_End.x - width );
m_RealBoundaryBox.m_Pos.y = min( m_RealBoundaryBox.m_Pos.y, EdgeMod->m_Start.y - width );
m_RealBoundaryBox.m_Pos.y = min( m_RealBoundaryBox.m_Pos.y, EdgeMod->m_End.y - width );
xmax = max( xmax, EdgeMod->m_Start.x + width );
xmax = max( xmax, EdgeMod->m_End.x + width );
ymax = max( ymax, EdgeMod->m_Start.y + width );
ymax = max( ymax, EdgeMod->m_End.y + width );
break;
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext )
{
rayon = Pad->m_Rayon;
cx = Pad->m_Pos.x; cy = Pad->m_Pos.y;
m_RealBoundaryBox.m_Pos.x = min( m_RealBoundaryBox.m_Pos.x, cx - rayon );
m_RealBoundaryBox.m_Pos.y = min( m_RealBoundaryBox.m_Pos.y, cy - rayon );
xmax = max( xmax, cx + rayon );
ymax = max( ymax, cy + rayon );
}
m_RealBoundaryBox.SetWidth( xmax - m_RealBoundaryBox.m_Pos.x );
m_RealBoundaryBox.SetHeight( ymax - m_RealBoundaryBox.m_Pos.y );
m_Surface = ABS( (float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
}
/*******************************************************/
void MODULE::Display_Infos(WinEDA_BasePcbFrame * frame)
void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame )
/*******************************************************/
{
int nbpad;
char bufcar[512], Line[512];
int pos;
bool flag = FALSE;
wxString msg;
frame->MsgPanel->EraseMsgBox() ; /* Effacement de la zone message */
if ( frame->m_Ident != PCB_FRAME ) flag = TRUE;
pos = 1;
Affiche_1_Parametre(frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN);
/* Affiche signature temporelle ou date de modif (en edition de modules) */
pos += 14;
if ( flag ) // Affichage date de modification (utile en Module Editor)
{
strcpy(Line, ctime(&m_LastEdit_Time));
strtok(Line," \n\r");
strcpy( bufcar, strtok(NULL," \n\r") ); strcat(bufcar," ");
strcat( bufcar, strtok(NULL," \n\r") ); strcat(bufcar,", ");
strtok(NULL," \n\r");
strcat( bufcar, strtok(NULL," \n\r") );
msg = CONV_FROM_UTF8(bufcar);
Affiche_1_Parametre(frame, pos, _("Last Change"), msg, BROWN);
pos += 4;
}
else
{
msg.Printf( wxT("%8.8lX"), m_TimeStamp);
Affiche_1_Parametre(frame, pos, _("TimeStamp"), msg,BROWN);
}
pos += 6;
Affiche_1_Parametre(frame, pos,_("Layer"),ReturnPcbLayerName(m_Layer),RED) ;
pos += 6;
EDA_BaseStruct * PtStruct = m_Pads;
nbpad = 0;
while( PtStruct ) { nbpad ++; PtStruct = PtStruct->Pnext; }
msg.Printf( wxT("%d"),nbpad);
Affiche_1_Parametre(frame, pos,_("Pads"), msg,BLUE);
pos += 4;
msg = wxT("..");
if( m_ModuleStatus & MODULE_is_LOCKED ) msg[0] = 'F';
if( m_ModuleStatus & MODULE_is_PLACED ) msg[1] = 'P';
Affiche_1_Parametre(frame, pos,_("Stat"), msg, MAGENTA);
pos += 4;
msg.Printf( wxT("%.1f"),(float)m_Orient / 10 );
Affiche_1_Parametre(frame, pos,_("Orient"), msg, BROWN);
pos += 5;
Affiche_1_Parametre(frame, pos,_("Module"), m_LibRef, BLUE);
pos += 9;
Affiche_1_Parametre(frame, pos, _("3D-Shape"),
m_3D_Drawings->m_Shape3DName, RED);
pos += 14;
wxString doc = _("Doc: ") + m_Doc;
wxString keyword = _("KeyW: ") + m_KeyWord;
Affiche_1_Parametre(frame, pos, doc, keyword, BLACK);
int nbpad;
char bufcar[512], Line[512];
int pos;
bool flag = FALSE;
wxString msg;
frame->MsgPanel->EraseMsgBox(); /* Effacement de la zone message */
if( frame->m_Ident != PCB_FRAME )
flag = TRUE;
pos = 1;
Affiche_1_Parametre( frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN );
/* Affiche signature temporelle ou date de modif (en edition de modules) */
pos += 14;
if( flag ) // Affichage date de modification (utile en Module Editor)
{
strcpy( Line, ctime( &m_LastEdit_Time ) );
strtok( Line, " \n\r" );
strcpy( bufcar, strtok( NULL, " \n\r" ) ); strcat( bufcar, " " );
strcat( bufcar, strtok( NULL, " \n\r" ) ); strcat( bufcar, ", " );
strtok( NULL, " \n\r" );
strcat( bufcar, strtok( NULL, " \n\r" ) );
msg = CONV_FROM_UTF8( bufcar );
Affiche_1_Parametre( frame, pos, _( "Last Change" ), msg, BROWN );
pos += 4;
}
else
{
msg.Printf( wxT( "%8.8lX" ), m_TimeStamp );
Affiche_1_Parametre( frame, pos, _( "TimeStamp" ), msg, BROWN );
}
pos += 6;
Affiche_1_Parametre( frame, pos, _( "Layer" ), ReturnPcbLayerName( m_Layer ), RED );
pos += 6;
EDA_BaseStruct* PtStruct = m_Pads;
nbpad = 0;
while( PtStruct )
{
nbpad++; PtStruct = PtStruct->Pnext;
}
msg.Printf( wxT( "%d" ), nbpad );
Affiche_1_Parametre( frame, pos, _( "Pads" ), msg, BLUE );
pos += 4;
msg = wxT( ".." );
if( m_ModuleStatus & MODULE_is_LOCKED )
msg[0] = 'F';
if( m_ModuleStatus & MODULE_is_PLACED )
msg[1] = 'P';
Affiche_1_Parametre( frame, pos, _( "Stat" ), msg, MAGENTA );
pos += 4;
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 );
Affiche_1_Parametre( frame, pos, _( "Orient" ), msg, BROWN );
pos += 5;
Affiche_1_Parametre( frame, pos, _( "Module" ), m_LibRef, BLUE );
pos += 9;
Affiche_1_Parametre( frame, pos, _( "3D-Shape" ),
m_3D_Drawings->m_Shape3DName, RED );
pos += 14;
wxString doc = _( "Doc: " ) + m_Doc;
wxString keyword = _( "KeyW: " ) + m_KeyWord;
Affiche_1_Parametre( frame, pos, doc, keyword, BLACK );
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void MODULE::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() <<
" ref=\"" << m_Reference->m_Text.mb_str() <<
"\" value=\"" << m_Value->m_Text.mb_str() <<
"\">\n";
EDA_BaseStruct* p = m_Drawings;
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
EDA_BaseStruct* kid = m_Son;
for( ; kid; kid = kid->Pnext )
{
kid->Show( nestLevel+1, os );
}
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
}
#endif
/*******************************************************/
/* class_module.h : module description (excepted pads) */
/*******************************************************/
/*******************************************************/
/* class_module.h : module description (excepted pads) */
/*******************************************************/
class Pcb3D_GLCanvas;
class Struct3D_Master;
/************************************/
/* Modules (footprints) description */
/* pad are in class_pad.xx */
/************************************/
/************************************/
/* Modules (footprints) description */
/* pad are in class_pad.xx */
/************************************/
/* Format des modules:
Description generale
Description segments contour
Description textes
Description pastilles
*/
* Description generale
* Description segments contour
* Description textes
* Description pastilles
*/
/* Flags :*/
......@@ -24,9 +24,10 @@ enum Mod_Attribut /* Attributs d'un module */
{
MOD_DEFAULT = 0, /* Type default */
MOD_CMS = 1, /* Pour module apparaissant dans les
fichiers de placement automatique (principalement modules CMS */
* fichiers de placement automatique (principalement modules CMS */
MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit
(connecteur, trou de percage..) */
* (connecteur, trou de percage..) */
};
/* flags for autoplace and autoroute (.m_ModuleStatus member) */
......@@ -34,59 +35,60 @@ enum Mod_Attribut /* Attributs d'un module */
#define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */
#define MODULE_to_PLACE 0x04 /* In autoplace: module waiting for autoplace */
class MODULE: public EDA_BaseStruct
class MODULE : public EDA_BaseStruct
{
public:
int m_Layer; // layer number
wxPoint m_Pos; // Real coord on board
D_PAD * m_Pads; /* Pad list (linked list) */
EDA_BaseStruct * m_Drawings; /* Graphic items list (linked list) */
Struct3D_Master * m_3D_Drawings; /* Pointeur sur la liste des elements de trace 3D*/
TEXTE_MODULE * m_Reference; // texte reference du composant (U34, R18..)
TEXTE_MODULE * m_Value; // texte valeur du composant (74LS00, 22K..)
wxString m_LibRef; /* nom du module en librairie */
int m_Attributs; /* Flags bits a bit ( voir enum Mod_Attribut ) */
int m_Orient ; /* orientation en 1/10 degres */
int flag ; /* flag utilise en trace rastnest et routage auto */
int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */
EDA_Rect m_BoundaryBox; /* position/taille du cadre de reperage (coord locales)*/
EDA_Rect m_RealBoundaryBox ; /* position/taille du module (coord relles) */
int m_PadNum; // Nombre total de pads
int m_AltPadNum; // en placement auto Nombre de pads actifs pour
// les calculs
int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre
int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre
wxSize m_Ext; // marges de "garde": utilise en placement auto.
float m_Surface; // surface du rectangle d'encadrement
unsigned long m_Link; // variable temporaire ( pour editions, ...)
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies)
wxString m_Doc; // Texte de description du module
wxString m_KeyWord; // Liste des mots cles relatifs au module
int m_Layer; // layer number
wxPoint m_Pos; // Real coord on board
D_PAD* m_Pads; /* Pad list (linked list) */
EDA_BaseStruct* m_Drawings; /* Graphic items list (linked list) */
Struct3D_Master* m_3D_Drawings; /* Pointeur sur la liste des elements de trace 3D*/
TEXTE_MODULE* m_Reference; // texte reference du composant (U34, R18..)
TEXTE_MODULE* m_Value; // texte valeur du composant (74LS00, 22K..)
wxString m_LibRef; /* nom du module en librairie */
int m_Attributs; /* Flags bits a bit ( voir enum Mod_Attribut ) */
int m_Orient; /* orientation en 1/10 degres */
int flag; /* flag utilise en trace rastnest et routage auto */
int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */
EDA_Rect m_BoundaryBox; /* position/taille du cadre de reperage (coord locales)*/
EDA_Rect m_RealBoundaryBox; /* position/taille du module (coord relles) */
int m_PadNum; // Nombre total de pads
int m_AltPadNum; // en placement auto Nombre de pads actifs pour
// les calculs
int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre
int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre
wxSize m_Ext; // marges de "garde": utilise en placement auto.
float m_Surface; // surface du rectangle d'encadrement
unsigned long m_Link; // variable temporaire ( pour editions, ...)
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies)
wxString m_Doc; // Texte de description du module
wxString m_KeyWord; // Liste des mots cles relatifs au module
public:
MODULE(BOARD * parent);
MODULE(MODULE * module);
~MODULE(void);
MODULE( BOARD* parent );
MODULE( MODULE* module );
~MODULE( void );
void Copy( MODULE* Module ); // Copy structure
void Copy(MODULE * Module); // Copy structure
MODULE * Next(void) { return (MODULE *) Pnext; }
MODULE* Next( void ) { return (MODULE*) Pnext; }
void Set_Rectangle_Encadrement(void); /* mise a jour du rect d'encadrement
en coord locales (orient 0 et origine = pos module) */
void Set_Rectangle_Encadrement( void );/* mise a jour du rect d'encadrement
* en coord locales (orient 0 et origine = pos module) */
void SetRectangleExinscrit(void); /* mise a jour du rect d'encadrement
et de la surface en coord reelles */
void SetRectangleExinscrit( void );/* mise a jour du rect d'encadrement
* et de la surface en coord reelles */
// deplacements
void SetPosition(const wxPoint & newpos);
void SetOrientation(int newangle);
void SetPosition( const wxPoint& newpos );
void SetOrientation( int newangle );
/* supprime du chainage la structure Struct */
void UnLink( void );
void UnLink( void );
/**
......@@ -98,11 +100,11 @@ public:
return (m_ModuleStatus & MODULE_is_LOCKED) != 0;
}
/**
* Function SetLocked
* sets the MODULE_is_LOCKED bit in the m_ModuleStatus
* @param setLocked When true means turn on locked status, else unlock
* @param setLocked When true means turn on locked status, else unlock
*/
void SetLocked( bool setLocked )
{
......@@ -112,23 +114,34 @@ public:
m_ModuleStatus &= ~MODULE_is_LOCKED;
}
/* Readind and writing data on files */
int WriteDescr( FILE * File );
int Write_3D_Descr( FILE * File );
int ReadDescr( FILE * File, int * LineNum = NULL);
int Read_3D_Descr( FILE * File, int * LineNum = NULL);
int WriteDescr( FILE* File );
int Write_3D_Descr( FILE* File );
int ReadDescr( FILE* File, int* LineNum = NULL );
int Read_3D_Descr( FILE* File, int* LineNum = NULL );
/* drawing functions */
void Draw(WinEDA_DrawPanel * panel, wxDC * DC,
const wxPoint & offset, int draw_mode);
void Draw3D(Pcb3D_GLCanvas * glcanvas);
void DrawEdgesOnly(WinEDA_DrawPanel * panel, wxDC * DC,
const wxPoint & offset,int draw_mode);
void DrawAncre(WinEDA_DrawPanel * panel, wxDC * DC,
const wxPoint & offset, int dim_ancre, int draw_mode);
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode );
void Draw3D( Pcb3D_GLCanvas* glcanvas );
void DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode );
void DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int dim_ancre, int draw_mode );
/* miscellaneous */
void Display_Infos(WinEDA_BasePcbFrame * frame);
};
void Display_Infos( WinEDA_BasePcbFrame* frame );
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
#endif
};
/***************************************************/
/* Files.cpp: Lecture / Sauvegarde des fichiers PCB */
/***************************************************/
/***************************************************/
/* Files.cpp: Lecture / Sauvegarde des fichiers PCB */
/***************************************************/
#include "fctsys.h"
......@@ -11,321 +11,333 @@
/****************************************************/
void WinEDA_PcbFrame::Files_io(wxCommandEvent& event)
void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
/****************************************************/
/* Gestion generale des commandes de lecture de fichiers
*/
*/
{
int id = event.GetId();
wxClientDC dc(DrawPanel);
wxString msg;
DrawPanel->PrepareGraphicContext(&dc);
// Arret des commandes en cours
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc);
}
SetToolID(0, wxCURSOR_ARROW,wxEmptyString);
switch (id)
{
case ID_MENU_LOAD_FILE:
case ID_LOAD_FILE:
Clear_Pcb(&dc, TRUE);
LoadOnePcbFile(wxEmptyString, &dc, FALSE);
ReCreateAuxiliaryToolbar();
break;
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
case ID_MENU_RECOVER_BOARD:
{
wxString filename, oldfilename = GetScreen()->m_FileName;
if ( id == ID_MENU_RECOVER_BOARD)
{
filename = g_SaveFileName + PcbExtBuffer;
}
else
{
filename = oldfilename;
ChangeFileNameExt(filename, wxT(".000"));
}
if ( ! wxFileExists(filename) )
{
msg = _("Recovery file ") + filename + _(" not found");
DisplayInfo(this, msg);
break;
}
else
{
msg = _("Ok to load Recovery file ") + filename;
if ( ! IsOK (this, msg) ) break;
}
Clear_Pcb(&dc, TRUE);
LoadOnePcbFile(filename, &dc, FALSE);
GetScreen()->m_FileName = oldfilename;
SetTitle(GetScreen()->m_FileName);
ReCreateAuxiliaryToolbar();
}
break;
case ID_MENU_APPEND_FILE:
case ID_APPEND_FILE:
LoadOnePcbFile(wxEmptyString, &dc, TRUE);
break;
case ID_MENU_NEW_BOARD:
case ID_NEW_BOARD:
Clear_Pcb(&dc, TRUE);
GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"),
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData());
SetTitle(GetScreen()->m_FileName);
break;
case ID_LOAD_FILE_1:
case ID_LOAD_FILE_2:
case ID_LOAD_FILE_3:
case ID_LOAD_FILE_4:
case ID_LOAD_FILE_5:
case ID_LOAD_FILE_6:
case ID_LOAD_FILE_7:
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
Clear_Pcb(&dc, TRUE);
wxSetWorkingDirectory(wxPathOnly(GetLastProject(id - ID_LOAD_FILE_1)));
LoadOnePcbFile( GetLastProject(id - ID_LOAD_FILE_1).GetData(),
&dc, FALSE);
ReCreateAuxiliaryToolbar();
break;
case ID_SAVE_BOARD:
case ID_MENU_SAVE_BOARD:
SavePcbFile(GetScreen()->m_FileName);
break;
case ID_MENU_SAVE_BOARD_AS:
SavePcbFile(wxEmptyString);
break;
case ID_PCB_GEN_CMP_FILE:
RecreateCmpFileFromBoard();
break;
default: DisplayError(this, wxT("File_io Internal Error") ); break;
}
int id = event.GetId();
wxClientDC dc( DrawPanel );
wxString msg;
DrawPanel->PrepareGraphicContext( &dc );
// Arret des commandes en cours
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
switch( id )
{
case ID_MENU_LOAD_FILE:
case ID_LOAD_FILE:
Clear_Pcb( &dc, TRUE );
LoadOnePcbFile( wxEmptyString, &dc, FALSE );
ReCreateAuxiliaryToolbar();
break;
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
case ID_MENU_RECOVER_BOARD:
{
wxString filename, oldfilename = GetScreen()->m_FileName;
if( id == ID_MENU_RECOVER_BOARD )
{
filename = g_SaveFileName + PcbExtBuffer;
}
else
{
filename = oldfilename;
ChangeFileNameExt( filename, wxT( ".000" ) );
}
if( !wxFileExists( filename ) )
{
msg = _( "Recovery file " ) + filename + _( " not found" );
DisplayInfo( this, msg );
break;
}
else
{
msg = _( "Ok to load Recovery file " ) + filename;
if( !IsOK( this, msg ) )
break;
}
Clear_Pcb( &dc, TRUE );
LoadOnePcbFile( filename, &dc, FALSE );
GetScreen()->m_FileName = oldfilename;
SetTitle( GetScreen()->m_FileName );
ReCreateAuxiliaryToolbar();
}
break;
case ID_MENU_APPEND_FILE:
case ID_APPEND_FILE:
LoadOnePcbFile( wxEmptyString, &dc, TRUE );
break;
case ID_MENU_NEW_BOARD:
case ID_NEW_BOARD:
Clear_Pcb( &dc, TRUE );
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData() );
SetTitle( GetScreen()->m_FileName );
break;
case ID_LOAD_FILE_1:
case ID_LOAD_FILE_2:
case ID_LOAD_FILE_3:
case ID_LOAD_FILE_4:
case ID_LOAD_FILE_5:
case ID_LOAD_FILE_6:
case ID_LOAD_FILE_7:
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
Clear_Pcb( &dc, TRUE );
wxSetWorkingDirectory( wxPathOnly( GetLastProject( id - ID_LOAD_FILE_1 ) ) );
LoadOnePcbFile( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(),
&dc, FALSE );
ReCreateAuxiliaryToolbar();
break;
case ID_SAVE_BOARD:
case ID_MENU_SAVE_BOARD:
SavePcbFile( GetScreen()->m_FileName );
break;
case ID_MENU_SAVE_BOARD_AS:
SavePcbFile( wxEmptyString );
break;
case ID_PCB_GEN_CMP_FILE:
RecreateCmpFileFromBoard();
break;
default:
DisplayError( this, wxT( "File_io Internal Error" ) ); break;
}
}
/*****************************************************************************************/
int WinEDA_PcbFrame::LoadOnePcbFile(const wxString & FullFileName, wxDC * DC, bool Append)
int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, bool Append )
/******************************************************************************************/
/*
Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s
retourne:
0 si fichier non lu ( annulation de commande ... )
1 si OK
*/
* Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s
* retourne:
* 0 si fichier non lu ( annulation de commande ... )
* 1 si OK
*/
{
int ii;
FILE * source;
wxString msg;
ActiveScreen = GetScreen();
if( GetScreen()->IsModify() && !Append )
{
if( !IsOK(this, _("Board Modified: Continue ?")) )
return(0);
}
m_SelTrackWidthBox_Changed = TRUE;
m_SelViaSizeBox_Changed = TRUE;
if( Append )
{
GetScreen()->m_FileName = wxEmptyString;
GetScreen()->SetModify();
m_Pcb->m_Status_Pcb = 0;
}
if( FullFileName == wxEmptyString)
{
msg = wxT("*") + PcbExtBuffer;
wxString FileName =
EDA_FileSelector(_("Board files:"),
wxEmptyString, /* Chemin par defaut */
GetScreen()->m_FileName, /* nom fichier par defaut */
PcbExtBuffer, /* extension par defaut */
msg, /* Masque d'affichage */
this,
wxFD_OPEN,
FALSE
);
if ( FileName == wxEmptyString ) return FALSE;
GetScreen()->m_FileName = FileName;
}
else GetScreen()->m_FileName = FullFileName;
/////////////////////////
/* Lecture Fichier PCB */
/////////////////////////
source = wxFopen(GetScreen()->m_FileName,wxT("rt"));
if (source == NULL)
{
msg.Printf(_("File <%s> not found"),GetScreen()->m_FileName.GetData()) ;
DisplayError(this, msg) ;
return(0);
}
/* Lecture de l'entete et TEST si PCB format ASCII */
GetLine(source, cbuf, &ii );
if( strncmp( cbuf, "PCBNEW-BOARD",12) != 0)
{
fclose(source);
DisplayError(this, wxT("Unknown file type"));
return(0);
}
SetTitle(GetScreen()->m_FileName);
SetLastProject(GetScreen()->m_FileName);
// Rechargement de la configuration:
wxSetWorkingDirectory( wxPathOnly(GetScreen()->m_FileName) );
if( Append ) ReadPcbFile(DC, source, TRUE);
else
{
Read_Config(GetScreen()->m_FileName);
// Mise a jour du toolbar d'options
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayModText = DisplayOpt.DisplayModText ;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
ReadPcbFile(DC, source, FALSE);
}
fclose(source);
GetScreen()->ClrModify();
if( Append )
{
GetScreen()->SetModify();
GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"),
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData());
}
/* liste des pads recalculee avec Affichage des messages d'erreur */
build_liste_pads();
Affiche_Infos_Status_Pcb(this);
g_SaveTime = time(NULL);
return(1);
int ii;
FILE* source;
wxString msg;
ActiveScreen = GetScreen();
if( GetScreen()->IsModify() && !Append )
{
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
return 0;
}
m_SelTrackWidthBox_Changed = TRUE;
m_SelViaSizeBox_Changed = TRUE;
if( Append )
{
GetScreen()->m_FileName = wxEmptyString;
GetScreen()->SetModify();
m_Pcb->m_Status_Pcb = 0;
}
if( FullFileName == wxEmptyString )
{
msg = wxT( "*" ) + PcbExtBuffer;
wxString FileName =
EDA_FileSelector( _( "Board files:" ),
wxEmptyString, /* Chemin par defaut */
GetScreen()->m_FileName, /* nom fichier par defaut */
PcbExtBuffer, /* extension par defaut */
msg, /* Masque d'affichage */
this,
wxFD_OPEN,
FALSE
);
if( FileName == wxEmptyString )
return FALSE;
GetScreen()->m_FileName = FileName;
}
else
GetScreen()->m_FileName = FullFileName;
/////////////////////////
/* Lecture Fichier PCB */
/////////////////////////
source = wxFopen( GetScreen()->m_FileName, wxT( "rt" ) );
if( source == NULL )
{
msg.Printf( _( "File <%s> not found" ), GetScreen()->m_FileName.GetData() );
DisplayError( this, msg );
return 0;
}
/* Lecture de l'entete et TEST si PCB format ASCII */
GetLine( source, cbuf, &ii );
if( strncmp( cbuf, "PCBNEW-BOARD", 12 ) != 0 )
{
fclose( source );
DisplayError( this, wxT( "Unknown file type" ) );
return 0;
}
SetTitle( GetScreen()->m_FileName );
SetLastProject( GetScreen()->m_FileName );
// Rechargement de la configuration:
wxSetWorkingDirectory( wxPathOnly( GetScreen()->m_FileName ) );
if( Append )
ReadPcbFile( DC, source, TRUE );
else
{
Read_Config( GetScreen()->m_FileName );
// Mise a jour du toolbar d'options
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayModText = DisplayOpt.DisplayModText;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
ReadPcbFile( DC, source, FALSE );
}
fclose( source );
GetScreen()->ClrModify();
if( Append )
{
GetScreen()->SetModify();
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData() );
}
/* liste des pads recalculee avec Affichage des messages d'erreur */
build_liste_pads();
Affiche_Infos_Status_Pcb( this );
g_SaveTime = time( NULL );
#if defined(DEBUG)
// output the board object tree to stdout:
m_Pcb->Show( 0, std::cout );
#endif
return 1;
}
/***********************************************************/
bool WinEDA_PcbFrame::SavePcbFile(const wxString & FileName)
bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
/************************************************************/
/* Sauvegarde du fichier PCB en format ASCII
*/
*/
{
wxString old_name, FullFileName, msg;
bool saveok = TRUE;
FILE * dest;
if( FileName == wxEmptyString )
{
msg = wxT("*") + PcbExtBuffer;
FullFileName = EDA_FileSelector(_("Board files:"),
wxEmptyString, /* Chemin par defaut */
GetScreen()->m_FileName, /* nom fichier par defaut */
PcbExtBuffer, /* extension par defaut */
msg, /* Masque d'affichage */
this,
wxFD_SAVE,
FALSE
);
if ( FullFileName == wxEmptyString ) return FALSE;
GetScreen()->m_FileName = FullFileName;
}
else GetScreen()->m_FileName = FileName;
/* mise a jour date si modifications */
if ( GetScreen()->IsModify() )
{
GetScreen()->m_Date = GenDate();
}
/* Calcul du nom du fichier a creer */
FullFileName = MakeFileName(wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer);
/* Calcul du nom du fichier de sauvegarde */
old_name = FullFileName;
ChangeFileNameExt(old_name,wxT(".000"));
/* Changement du nom de l'ancien fichier s'il existe */
if ( wxFileExists(FullFileName) )
{
/* conversion en *.000 de l'ancien fichier */
wxRemoveFile(old_name); /* S'il y a une ancienne sauvegarde */
if( ! wxRenameFile(FullFileName,old_name) )
{
msg = _("Warning: unable to create bakfile ") + old_name;
DisplayError(this, msg, 15) ;
saveok = FALSE;
}
}
else
{
old_name = wxEmptyString; saveok = FALSE;
}
/* Sauvegarde de l'ancien fichier */
dest = wxFopen(FullFileName, wxT("wt"));
if (dest == 0)
{
msg = _("Unable to create ") + FullFileName;
DisplayError(this, msg) ;
saveok = FALSE;
}
if( dest )
{
GetScreen()->m_FileName = FullFileName;
SetTitle(GetScreen()->m_FileName);
SavePcbFormatAscii(dest);
fclose(dest) ;
}
/* Affichage des fichiers crees: */
MsgPanel->EraseMsgBox();
if( saveok )
{
msg = _("Backup file: ") + old_name;
Affiche_1_Parametre(this, 1,msg, wxEmptyString, CYAN);
}
if ( dest ) msg = _("Write Board file: ");
else msg = _("Failed to create ");
msg += FullFileName;
Affiche_1_Parametre(this, 1,wxEmptyString,msg, CYAN);
g_SaveTime = time(NULL); /* Reset delai pour sauvegarde automatique */
GetScreen()->ClrModify();
return TRUE;
wxString old_name, FullFileName, msg;
bool saveok = TRUE;
FILE* dest;
if( FileName == wxEmptyString )
{
msg = wxT( "*" ) + PcbExtBuffer;
FullFileName = EDA_FileSelector( _( "Board files:" ),
wxEmptyString, /* Chemin par defaut */
GetScreen()->m_FileName, /* nom fichier par defaut */
PcbExtBuffer, /* extension par defaut */
msg, /* Masque d'affichage */
this,
wxFD_SAVE,
FALSE
);
if( FullFileName == wxEmptyString )
return FALSE;
GetScreen()->m_FileName = FullFileName;
}
else
GetScreen()->m_FileName = FileName;
/* mise a jour date si modifications */
if( GetScreen()->IsModify() )
{
GetScreen()->m_Date = GenDate();
}
/* Calcul du nom du fichier a creer */
FullFileName = MakeFileName( wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer );
/* Calcul du nom du fichier de sauvegarde */
old_name = FullFileName;
ChangeFileNameExt( old_name, wxT( ".000" ) );
/* Changement du nom de l'ancien fichier s'il existe */
if( wxFileExists( FullFileName ) )
{
/* conversion en *.000 de l'ancien fichier */
wxRemoveFile( old_name ); /* S'il y a une ancienne sauvegarde */
if( !wxRenameFile( FullFileName, old_name ) )
{
msg = _( "Warning: unable to create bakfile " ) + old_name;
DisplayError( this, msg, 15 );
saveok = FALSE;
}
}
else
{
old_name = wxEmptyString; saveok = FALSE;
}
/* Sauvegarde de l'ancien fichier */
dest = wxFopen( FullFileName, wxT( "wt" ) );
if( dest == 0 )
{
msg = _( "Unable to create " ) + FullFileName;
DisplayError( this, msg );
saveok = FALSE;
}
if( dest )
{
GetScreen()->m_FileName = FullFileName;
SetTitle( GetScreen()->m_FileName );
SavePcbFormatAscii( dest );
fclose( dest );
}
/* Affichage des fichiers crees: */
MsgPanel->EraseMsgBox();
if( saveok )
{
msg = _( "Backup file: " ) + old_name;
Affiche_1_Parametre( this, 1, msg, wxEmptyString, CYAN );
}
if( dest )
msg = _( "Write Board file: " );
else
msg = _( "Failed to create " );
msg += FullFileName;
Affiche_1_Parametre( this, 1, wxEmptyString, msg, CYAN );
g_SaveTime = time( NULL ); /* Reset delai pour sauvegarde automatique */
GetScreen()->ClrModify();
return TRUE;
}
......@@ -3,7 +3,7 @@
/* Fichier common a PCBNEW et CVPCB */
/********************************************************************/
/* ioascii.cpp */
/* ioascii.cpp */
#include "fctsys.h"
#include "gr_basic.h"
......@@ -24,1094 +24,1163 @@
/* Format des structures de sauvegarde type ASCII :
Structure PAD:
$PAD
Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions
Dr diam, dV dH :drill : diametre offsets de percage
At type S/N layers : type standard,cms,conn,hole,meca.,
Stack/Normal,
Hexadecimal 32 bits: occupation des couches
Nm net_code netname
Po posrefX posrefy : position refX,Y (= position orient 0 / ancre)
$EndPAD
******** Structure module ***********
$MODULE namelib
Po ax ay orient layer masquelayer m_TimeCode
ax ay = coord ancre (position module)
orient = orient en 0.1 degre
layer = numero de couche
masquelayer = couche pour serigraphie
m_TimeCode a usage interne (groupements)
Li <namelib>
Cd <text> Description du composant (Composant Doc)
Kw <text> Liste des mots cle
Sc schematimestamp de reference schematique
Op rot90 rot180 Options de placement auto (cout rot 90, 180 )
rot90 est sur 2x4 bits:
lsb = cout rot 90, msb = cout rot -90;
Tn px py dimv dimh orient epaisseur miroir visible "texte"
n = type (0 = ref, 1 = val, > 1 =qcq
Textes POS x,y / ancre et orient module 0
dimv dimh orient
epaisseur miroir (Normal/miroir)
visible V/I
DS ox oy fx fy w
edge: segment coord ox,oy a fx,fy, relatives
a l'ancre et orient 0
epaisseur w
DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur)
$PAD
$EndPAD section pads s'il y en a
$EndMODULE
Structure PAD:
$PAD
Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions
Dr diam, dV dH :drill : diametre offsets de percage
At type S/N layers : type standard,cms,conn,hole,meca.,
Stack/Normal,
Hexadecimal 32 bits: occupation des couches
Nm net_code netname
Po posrefX posrefy : position refX,Y (= position orient 0 / ancre)
$EndPAD
****** Structure module ***********
$MODULE namelib
Po ax ay orient layer masquelayer m_TimeCode
ax ay = coord ancre (position module)
orient = orient en 0.1 degre
layer = numero de couche
masquelayer = couche pour serigraphie
m_TimeCode a usage interne (groupements)
Li <namelib>
Cd <text> Description du composant (Composant Doc)
Kw <text> Liste des mots cle
Sc schematimestamp de reference schematique
Op rot90 rot180 Options de placement auto (cout rot 90, 180 )
rot90 est sur 2x4 bits:
lsb = cout rot 90, msb = cout rot -90;
Tn px py dimv dimh orient epaisseur miroir visible "texte"
n = type (0 = ref, 1 = val, > 1 =qcq
Textes POS x,y / ancre et orient module 0
dimv dimh orient
epaisseur miroir (Normal/miroir)
visible V/I
DS ox oy fx fy w
edge: segment coord ox,oy a fx,fy, relatives
a l'ancre et orient 0
epaisseur w
DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur)
$PAD
$EndPAD section pads s'il y en a
$EndMODULE
*/
extern Ki_PageDescr * SheetList[];
extern Ki_PageDescr* SheetList[];
/* Variables locales, utilisees pour la lecture des fichiers PCB */
int NbDraw,NbTrack,NbZone, NbMod, NbNets;
int NbDraw, NbTrack, NbZone, NbMod, NbNets;
/**********************************************************************/
int WinEDA_BasePcbFrame::ReadListeSegmentDescr(wxDC * DC, FILE * File,
TRACK * PtSegm,int StructType,
int * LineNum, int NumSegm)
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
TRACK* PtSegm, int StructType,
int* LineNum, int NumSegm )
/**********************************************************************/
/* Lecture de la description d'une liste de segments (Tracks, zones)
Retourne:
si ok nombre d'items lus.
si pas de fin de block ($..) - nombre.
*/
* Retourne:
* si ok nombre d'items lus.
* si pas de fin de block ($..) - nombre.
*/
{
int shape, width, layer, type, flags, net_code;
int ii = 0, PerCent, Pas;
char Line[256];
TRACK * NewTrack;
int shape, width, layer, type, flags, net_code;
int ii = 0, PerCent, Pas;
char Line[256];
TRACK* NewTrack;
PerCent = 0; Pas = NumSegm / 99;
PerCent = 0; Pas = NumSegm / 99;
#ifdef PCBNEW
switch ( StructType )
{
case TYPETRACK:
case TYPEVIA:
DisplayActivity(PerCent, wxT("Tracks:") );
break;
case TYPEZONE:
DisplayActivity(PerCent, wxT("Zones:") );
break;
}
switch( StructType )
{
case TYPETRACK:
case TYPEVIA:
DisplayActivity( PerCent, wxT( "Tracks:" ) );
break;
case TYPEZONE:
DisplayActivity( PerCent, wxT( "Zones:" ) );
break;
}
#endif
while( GetLine(File, Line, LineNum ) )
{
if(Line[0] == '$')
{
return(ii); /* fin de liste OK */
}
switch ( StructType )
{
default:
case TYPETRACK: NewTrack = new TRACK( m_Pcb );
break;
case TYPEVIA: NewTrack = new SEGVIA( m_Pcb );
break;
case TYPEZONE: NewTrack = new SEGZONE( m_Pcb );
break;
}
NewTrack->Insert(m_Pcb, PtSegm); PtSegm = NewTrack;
int arg_count = sscanf( Line+2," %d %d %d %d %d %d %d",&shape,
&PtSegm->m_Start.x, &PtSegm->m_Start.y,
&PtSegm->m_End.x, &PtSegm->m_End.y, &width,
& PtSegm->m_Drill);
PtSegm->m_Width = width; PtSegm->m_Shape = shape;
if ( arg_count < 7 ) PtSegm->m_Drill = -1;
if( GetLine(File, Line, LineNum ) == NULL ) break;
if(Line[0] == '$') break;
sscanf( Line+2," %d %d %d %lX %X", &layer, &type,&net_code,
&PtSegm->m_TimeStamp, &flags);
if ( type == 1 ) PtSegm->m_StructType = TYPEVIA;
PtSegm->m_Layer = layer;
PtSegm->m_NetCode = net_code; PtSegm->SetState(flags, ON);
while( GetLine( File, Line, LineNum ) )
{
if( Line[0] == '$' )
{
return ii; /* fin de liste OK */
}
switch( StructType )
{
default:
case TYPETRACK:
NewTrack = new TRACK( m_Pcb );
break;
case TYPEVIA:
NewTrack = new SEGVIA( m_Pcb );
break;
case TYPEZONE:
NewTrack = new SEGZONE( m_Pcb );
break;
}
NewTrack->Insert( m_Pcb, PtSegm ); PtSegm = NewTrack;
int arg_count = sscanf( Line + 2, " %d %d %d %d %d %d %d", &shape,
&PtSegm->m_Start.x, &PtSegm->m_Start.y,
&PtSegm->m_End.x, &PtSegm->m_End.y, &width,
&PtSegm->m_Drill );
PtSegm->m_Width = width; PtSegm->m_Shape = shape;
if( arg_count < 7 )
PtSegm->m_Drill = -1;
if( GetLine( File, Line, LineNum ) == NULL )
break;
if( Line[0] == '$' )
break;
sscanf( Line + 2, " %d %d %d %lX %X", &layer, &type, &net_code,
&PtSegm->m_TimeStamp, &flags );
if( type == 1 )
PtSegm->m_StructType = TYPEVIA;
PtSegm->m_Layer = layer;
PtSegm->m_NetCode = net_code; PtSegm->SetState( flags, ON );
#ifdef PCBNEW
PtSegm->Draw(DrawPanel, DC, GR_OR);
PtSegm->Draw( DrawPanel, DC, GR_OR );
#endif
ii++;
if( ( Pas && (ii % Pas ) == 0) )
{
PerCent ++;
ii++;
if( ( Pas && (ii % Pas ) == 0) )
{
PerCent++;
#ifdef PCBNEW
switch ( StructType )
{
case TYPETRACK:
case TYPEVIA:
DisplayActivity(PerCent, wxT("Tracks:") );
break;
case TYPEZONE:
DisplayActivity(PerCent, wxT("Zones:") );
break;
}
switch( StructType )
{
case TYPETRACK:
case TYPEVIA:
DisplayActivity( PerCent, wxT( "Tracks:" ) );
break;
case TYPEZONE:
DisplayActivity( PerCent, wxT( "Zones:" ) );
break;
}
#endif
}
}
DisplayError(this, _("Error: Unexpected end of file !") );
return(-ii);
}
}
}
DisplayError( this, _( "Error: Unexpected end of file !" ) );
return -ii;
}
/**********************************************************************************/
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb(wxDC * DC, FILE * File, int * LineNum)
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( wxDC* DC, FILE* File, int* LineNum )
/**********************************************************************************/
{
char Line[1024], *data;
BASE_SCREEN * screen = m_CurrentScreen;
while( GetLine(File, Line, LineNum ) != NULL )
{
data = strtok(Line," =\n\r");
if(strnicmp(data,"$EndGENERAL",10) == 0) break;
if( strncmp(data, "Ly", 2) == 0 ) // Old format for Layer count
{
int Masque_Layer = 1, ii;
data = strtok(NULL," =\n\r");
sscanf(data,"%X",&Masque_Layer);
// Setup layer count
m_Pcb->m_BoardSettings->m_CopperLayerCount = 0;
for ( ii = 0; ii < NB_COPPER_LAYERS; ii++ )
{
if ( Masque_Layer & 1 ) m_Pcb->m_BoardSettings->m_CopperLayerCount++;
Masque_Layer >>= 1;
}
continue;
}
if(strnicmp(data, "Links", 5) == 0)
{
data = strtok(NULL," =\n\r");
m_Pcb->m_NbLinks = atoi(data);
continue;
}
if(strnicmp(data, "NoConn", 6) == 0)
{
data = strtok(NULL," =\n\r");
m_Pcb->m_NbNoconnect = atoi(data);
continue;
}
if(strnicmp(data, "Di", 2) == 0)
{
int ii, jj, bestzoom;
wxSize pcbsize, screensize;
data = strtok(NULL," =\n\r");
m_Pcb->m_BoundaryBox.SetX(atoi(data));
data = strtok(NULL," =\n\r");
m_Pcb->m_BoundaryBox.SetY(atoi(data));
data = strtok(NULL," =\n\r");
m_Pcb->m_BoundaryBox.SetWidth(atoi(data) - m_Pcb->m_BoundaryBox.GetX());
data = strtok(NULL," =\n\r");
m_Pcb->m_BoundaryBox.SetHeight(atoi(data) - m_Pcb->m_BoundaryBox.GetY());
/* calcul du zoom optimal */
pcbsize = m_Pcb->m_BoundaryBox.GetSize();
screensize = DrawPanel->GetClientSize();
ii = pcbsize.x/screensize.x;
jj = pcbsize.y/screensize.y;
bestzoom = max(ii, jj);
screen->m_Curseur = m_Pcb->m_BoundaryBox.Centre();
screen->SetZoom(bestzoom);
// la position des tracs a chang: mise a jour dans le DC courant
wxPoint org;
DrawPanel->GetViewStart(&org.x, &org.y);
DrawPanel->GetScrollPixelsPerUnit(&ii, &jj);
org.x *= ii; org.y *= jj;
char Line[1024], * data;
BASE_SCREEN* screen = m_CurrentScreen;
while( GetLine( File, Line, LineNum ) != NULL )
{
data = strtok( Line, " =\n\r" );
if( strnicmp( data, "$EndGENERAL", 10 ) == 0 )
break;
if( strncmp( data, "Ly", 2 ) == 0 ) // Old format for Layer count
{
int Masque_Layer = 1, ii;
data = strtok( NULL, " =\n\r" );
sscanf( data, "%X", &Masque_Layer );
// Setup layer count
m_Pcb->m_BoardSettings->m_CopperLayerCount = 0;
for( ii = 0; ii < NB_COPPER_LAYERS; ii++ )
{
if( Masque_Layer & 1 )
m_Pcb->m_BoardSettings->m_CopperLayerCount++;
Masque_Layer >>= 1;
}
continue;
}
if( strnicmp( data, "Links", 5 ) == 0 )
{
data = strtok( NULL, " =\n\r" );
m_Pcb->m_NbLinks = atoi( data );
continue;
}
if( strnicmp( data, "NoConn", 6 ) == 0 )
{
data = strtok( NULL, " =\n\r" );
m_Pcb->m_NbNoconnect = atoi( data );
continue;
}
if( strnicmp( data, "Di", 2 ) == 0 )
{
int ii, jj, bestzoom;
wxSize pcbsize, screensize;
data = strtok( NULL, " =\n\r" );
m_Pcb->m_BoundaryBox.SetX( atoi( data ) );
data = strtok( NULL, " =\n\r" );
m_Pcb->m_BoundaryBox.SetY( atoi( data ) );
data = strtok( NULL, " =\n\r" );
m_Pcb->m_BoundaryBox.SetWidth( atoi( data ) - m_Pcb->m_BoundaryBox.GetX() );
data = strtok( NULL, " =\n\r" );
m_Pcb->m_BoundaryBox.SetHeight( atoi( data ) - m_Pcb->m_BoundaryBox.GetY() );
/* calcul du zoom optimal */
pcbsize = m_Pcb->m_BoundaryBox.GetSize();
screensize = DrawPanel->GetClientSize();
ii = pcbsize.x / screensize.x;
jj = pcbsize.y / screensize.y;
bestzoom = max( ii, jj );
screen->m_Curseur = m_Pcb->m_BoundaryBox.Centre();
screen->SetZoom( bestzoom );
// la position des trac� a chang� mise a jour dans le DC courant
wxPoint org;
DrawPanel->GetViewStart( &org.x, &org.y );
DrawPanel->GetScrollPixelsPerUnit( &ii, &jj );
org.x *= ii; org.y *= jj;
#ifdef WX_ZOOM
DC->SetUserScale(1.0/(double)screen->GetZoom(), 1.0/screen->GetZoom());
org.x *= screen->GetZoom(); org.y *= screen->GetZoom();
DC->SetDeviceOrigin(-org.x, -org.y);
DC->SetUserScale( 1.0 / (double) screen->GetZoom(), 1.0 / screen->GetZoom() );
org.x *= screen->GetZoom(); org.y *= screen->GetZoom();
DC->SetDeviceOrigin( -org.x, -org.y );
#endif
DrawPanel->SetBoundaryBox();
Recadre_Trace(TRUE);
continue;
}
/* Lecture du nombre de segments type DRAW , TRACT, ZONE */
if(stricmp(data, "Ndraw") == 0)
{
data = strtok(NULL," =\n\r");
NbDraw = atoi(data);;
continue;
}
if(stricmp(data, "Ntrack") == 0)
{
data = strtok(NULL," =\n\r");
NbTrack = atoi(data);
continue;
}
if(stricmp(data, "Nzone") == 0)
{
data = strtok(NULL," =\n\r");
NbZone = atoi(data);
continue;
}
if(stricmp(data, "Nmodule") == 0)
{
data = strtok(NULL," =\n\r");
NbMod = atoi(data);
continue;
}
if(stricmp(data, "Nnets") == 0)
{
data = strtok(NULL," =\n\r");
NbNets = atoi(data);
continue;
}
}
return(1);
DrawPanel->SetBoundaryBox();
Recadre_Trace( TRUE );
continue;
}
/* Lecture du nombre de segments type DRAW , TRACT, ZONE */
if( stricmp( data, "Ndraw" ) == 0 )
{
data = strtok( NULL, " =\n\r" );
NbDraw = atoi( data );;
continue;
}
if( stricmp( data, "Ntrack" ) == 0 )
{
data = strtok( NULL, " =\n\r" );
NbTrack = atoi( data );
continue;
}
if( stricmp( data, "Nzone" ) == 0 )
{
data = strtok( NULL, " =\n\r" );
NbZone = atoi( data );
continue;
}
if( stricmp( data, "Nmodule" ) == 0 )
{
data = strtok( NULL, " =\n\r" );
NbMod = atoi( data );
continue;
}
if( stricmp( data, "Nnets" ) == 0 )
{
data = strtok( NULL, " =\n\r" );
NbNets = atoi( data );
continue;
}
}
return 1;
}
/*************************************************************/
int WinEDA_BasePcbFrame::ReadSetup(FILE * File, int * LineNum)
int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
/*************************************************************/
{
char Line[1024], *data;
while( GetLine(File, Line, LineNum ) != NULL )
{
strtok(Line," =\n\r");
data = strtok(NULL," =\n\r");
if(stricmp(Line,"$EndSETUP") == 0)
{
return 0;
}
if(stricmp(Line, "AuxiliaryAxisOrg") == 0)
{
int gx = 0, gy =0;
gx = atoi(data);
data = strtok(NULL," =\n\r");
if ( data ) gy = atoi(data);
m_Auxiliary_Axis_Position.x = gx; m_Auxiliary_Axis_Position.y = gy;
continue;
}
char Line[1024], * data;
while( GetLine( File, Line, LineNum ) != NULL )
{
strtok( Line, " =\n\r" );
data = strtok( NULL, " =\n\r" );
if( stricmp( Line, "$EndSETUP" ) == 0 )
{
return 0;
}
if( stricmp( Line, "AuxiliaryAxisOrg" ) == 0 )
{
int gx = 0, gy = 0;
gx = atoi( data );
data = strtok( NULL, " =\n\r" );
if( data )
gy = atoi( data );
m_Auxiliary_Axis_Position.x = gx; m_Auxiliary_Axis_Position.y = gy;
continue;
}
#ifdef PCBNEW
if(stricmp(Line, "Layers") == 0)
{
int tmp;
sscanf(data,"%d",&tmp);
m_Pcb->m_BoardSettings->m_CopperLayerCount = tmp;
continue;
}
if(stricmp(Line, "TrackWidth") == 0)
{
g_DesignSettings.m_CurrentTrackWidth = atoi(data);
AddHistory(g_DesignSettings.m_CurrentTrackWidth, TYPETRACK);
continue;
}
if(stricmp(Line, "TrackWidthHistory") == 0)
{
int tmp = atoi(data);
AddHistory(tmp, TYPETRACK);
continue;
}
if(stricmp(Line, "TrackClearence") == 0)
{
g_DesignSettings.m_TrackClearence = atoi(data);
continue;
}
if(stricmp(Line, "ZoneClearence") == 0)
{
g_DesignSettings.m_ZoneClearence = atoi(data);
continue;
}
if(stricmp(Line, "GridSize") == 0)
{
wxSize Grid;
Grid.x = atoi(data);
data = strtok(NULL," =\n\r");
if ( data ) Grid.y = atoi(data);
else Grid.y = Grid.x;
GetScreen()->SetGrid(Grid);
continue;
}
if(stricmp(Line, "ZoneGridSize") == 0)
{
g_GridRoutingSize = atoi(data);
continue;
}
if(stricmp(Line, "UserGridSize") == 0)
{
wxString msg;
if ( data )
{
msg = CONV_FROM_UTF8(data);
msg.ToDouble(&g_UserGrid.x);
}
else continue;
data = strtok(NULL," =\n\r");
if ( data )
{
msg = CONV_FROM_UTF8(data);
msg.ToDouble(&g_UserGrid.y);
}
else g_UserGrid.y = g_UserGrid.x;
GetScreen()->m_UserGrid = g_UserGrid;
data = strtok(NULL," =\n\r");
if ( data )
{
if ( stricmp(data, "mm") == 0 )
g_UserGrid_Unit = MILLIMETRE;
else g_UserGrid_Unit = INCHES;
GetScreen()->m_UserGridUnit = g_UserGrid_Unit;
}
continue;
}
if(stricmp(Line, "DrawSegmWidth") == 0)
{
g_DesignSettings.m_DrawSegmentWidth = atoi(data);
continue;
}
if(stricmp(Line, "EdgeSegmWidth") == 0)
{
g_DesignSettings.m_EdgeSegmentWidth = atoi(data);
continue;
}
if(stricmp(Line, "ViaSize") == 0)
{
g_DesignSettings.m_CurrentViaSize = atoi(data);
AddHistory(g_DesignSettings.m_CurrentViaSize, TYPEVIA);
continue;
}
if(stricmp(Line, "ViaSizeHistory") == 0)
{
int tmp = atoi(data);
AddHistory(tmp, TYPEVIA);
continue;
}
if(stricmp(Line, "ViaDrill") == 0)
{
g_DesignSettings.m_ViaDrill = atoi(data);
continue;
}
if(stricmp(Line, "TextPcbWidth") == 0)
{
g_DesignSettings.m_PcbTextWidth = atoi(data);
continue;
}
if(stricmp(Line, "TextPcbSize") == 0)
{
g_DesignSettings.m_PcbTextSize.x = atoi(data);
data = strtok(NULL," =\n\r");
g_DesignSettings.m_PcbTextSize.y = atoi(data);
continue;
}
if(stricmp(Line, "EdgeModWidth") == 0)
{
ModuleSegmentWidth = atoi(data);
continue;
}
if(stricmp(Line, "TextModWidth") == 0)
{
ModuleTextWidth = atoi(data);
continue;
}
if(stricmp(Line, "TextModSize") == 0)
{
ModuleTextSize.x = atoi(data);
data = strtok(NULL," =\n\r");
ModuleTextSize.y = atoi(data);
continue;
}
if(stricmp(Line, "PadSize") == 0)
{
g_Pad_Master.m_Size.x = atoi(data);
data = strtok(NULL," =\n\r");
g_Pad_Master.m_Size.y = atoi(data);
continue;
}
if(stricmp(Line, "PadDrill") == 0)
{
g_Pad_Master.m_Drill.x = atoi(data);
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x;
continue;
}
if(stricmp(Line, "PadDeltaSize") == 0)
{
g_Pad_Master.m_DeltaSize.x = atoi(data);
data = strtok(NULL," =\n\r");
g_Pad_Master.m_DeltaSize.y = atoi(data);
continue;
}
if(stricmp(Line, "PadShapeOffset") == 0)
{
g_Pad_Master.m_Offset.x = atoi(data);
data = strtok(NULL," =\n\r");
g_Pad_Master.m_Offset.y = atoi(data);
continue;
}
if( stricmp( Line, "Layers" ) == 0 )
{
int tmp;
sscanf( data, "%d", &tmp );
m_Pcb->m_BoardSettings->m_CopperLayerCount = tmp;
continue;
}
if( stricmp( Line, "TrackWidth" ) == 0 )
{
g_DesignSettings.m_CurrentTrackWidth = atoi( data );
AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPETRACK );
continue;
}
if( stricmp( Line, "TrackWidthHistory" ) == 0 )
{
int tmp = atoi( data );
AddHistory( tmp, TYPETRACK );
continue;
}
if( stricmp( Line, "TrackClearence" ) == 0 )
{
g_DesignSettings.m_TrackClearence = atoi( data );
continue;
}
if( stricmp( Line, "ZoneClearence" ) == 0 )
{
g_DesignSettings.m_ZoneClearence = atoi( data );
continue;
}
if( stricmp( Line, "GridSize" ) == 0 )
{
wxSize Grid;
Grid.x = atoi( data );
data = strtok( NULL, " =\n\r" );
if( data )
Grid.y = atoi( data );
else
Grid.y = Grid.x;
GetScreen()->SetGrid( Grid );
continue;
}
if( stricmp( Line, "ZoneGridSize" ) == 0 )
{
g_GridRoutingSize = atoi( data );
continue;
}
if( stricmp( Line, "UserGridSize" ) == 0 )
{
wxString msg;
if( data )
{
msg = CONV_FROM_UTF8( data );
msg.ToDouble( &g_UserGrid.x );
}
else
continue;
data = strtok( NULL, " =\n\r" );
if( data )
{
msg = CONV_FROM_UTF8( data );
msg.ToDouble( &g_UserGrid.y );
}
else
g_UserGrid.y = g_UserGrid.x;
GetScreen()->m_UserGrid = g_UserGrid;
data = strtok( NULL, " =\n\r" );
if( data )
{
if( stricmp( data, "mm" ) == 0 )
g_UserGrid_Unit = MILLIMETRE;
else
g_UserGrid_Unit = INCHES;
GetScreen()->m_UserGridUnit = g_UserGrid_Unit;
}
continue;
}
if( stricmp( Line, "DrawSegmWidth" ) == 0 )
{
g_DesignSettings.m_DrawSegmentWidth = atoi( data );
continue;
}
if( stricmp( Line, "EdgeSegmWidth" ) == 0 )
{
g_DesignSettings.m_EdgeSegmentWidth = atoi( data );
continue;
}
if( stricmp( Line, "ViaSize" ) == 0 )
{
g_DesignSettings.m_CurrentViaSize = atoi( data );
AddHistory( g_DesignSettings.m_CurrentViaSize, TYPEVIA );
continue;
}
if( stricmp( Line, "ViaSizeHistory" ) == 0 )
{
int tmp = atoi( data );
AddHistory( tmp, TYPEVIA );
continue;
}
if( stricmp( Line, "ViaDrill" ) == 0 )
{
g_DesignSettings.m_ViaDrill = atoi( data );
continue;
}
if( stricmp( Line, "TextPcbWidth" ) == 0 )
{
g_DesignSettings.m_PcbTextWidth = atoi( data );
continue;
}
if( stricmp( Line, "TextPcbSize" ) == 0 )
{
g_DesignSettings.m_PcbTextSize.x = atoi( data );
data = strtok( NULL, " =\n\r" );
g_DesignSettings.m_PcbTextSize.y = atoi( data );
continue;
}
if( stricmp( Line, "EdgeModWidth" ) == 0 )
{
ModuleSegmentWidth = atoi( data );
continue;
}
if( stricmp( Line, "TextModWidth" ) == 0 )
{
ModuleTextWidth = atoi( data );
continue;
}
if( stricmp( Line, "TextModSize" ) == 0 )
{
ModuleTextSize.x = atoi( data );
data = strtok( NULL, " =\n\r" );
ModuleTextSize.y = atoi( data );
continue;
}
if( stricmp( Line, "PadSize" ) == 0 )
{
g_Pad_Master.m_Size.x = atoi( data );
data = strtok( NULL, " =\n\r" );
g_Pad_Master.m_Size.y = atoi( data );
continue;
}
if( stricmp( Line, "PadDrill" ) == 0 )
{
g_Pad_Master.m_Drill.x = atoi( data );
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x;
continue;
}
if( stricmp( Line, "PadDeltaSize" ) == 0 )
{
g_Pad_Master.m_DeltaSize.x = atoi( data );
data = strtok( NULL, " =\n\r" );
g_Pad_Master.m_DeltaSize.y = atoi( data );
continue;
}
if( stricmp( Line, "PadShapeOffset" ) == 0 )
{
g_Pad_Master.m_Offset.x = atoi( data );
data = strtok( NULL, " =\n\r" );
g_Pad_Master.m_Offset.y = atoi( data );
continue;
}
#endif
}
return(1);
}
return 1;
}
#ifdef PCBNEW
/***************************************************************/
static int WriteSetup(FILE * File, WinEDA_BasePcbFrame * frame)
static int WriteSetup( FILE* File, WinEDA_BasePcbFrame* frame )
/***************************************************************/
{
char text[1024];
int ii, jj;
fprintf(File,"$SETUP\n");
sprintf(text, "InternalUnit %f INCH\n", 1.0/PCB_INTERNAL_UNIT);
fprintf(File, text);
if ( frame->GetScreen()->m_UserGridIsON ) ii = jj = -1;
else
{
ii = frame->GetScreen()->GetGrid().x;
jj = frame->GetScreen()->GetGrid().y;
}
sprintf(text, "GridSize %d %d\n", ii, jj);
fprintf(File, text);
sprintf(text, "UserGridSize %lf %lf %s\n",
frame->GetScreen()->m_UserGrid.x, frame->GetScreen()->m_UserGrid.y,
( g_UserGrid_Unit == 0 )? "INCH" : "mm");
fprintf(File, text);
fprintf(File, "ZoneGridSize %d\n", g_GridRoutingSize);
fprintf(File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount);
fprintf(File, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth);
for ( ii = 0; ii < HIST0RY_NUMBER; ii++)
{
if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break;
fprintf(File, "TrackWidthHistory %d\n",
g_DesignSettings.m_TrackWidhtHistory[ii]);
}
fprintf(File, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence);
fprintf(File, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence);
fprintf(File, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth);
fprintf(File, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth);
fprintf(File, "ViaSize %d\n", g_DesignSettings.m_CurrentViaSize);
fprintf(File, "ViaDrill %d\n", g_DesignSettings.m_ViaDrill);
for ( ii = 0; ii < HIST0RY_NUMBER; ii++)
{
if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break;
fprintf(File, "ViaSizeHistory %d\n", g_DesignSettings.m_ViaSizeHistory[ii]);
}
fprintf(File, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth);
fprintf(File, "TextPcbSize %d %d\n",
g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y);
fprintf(File, "EdgeModWidth %d\n", ModuleSegmentWidth);
fprintf(File, "TextModSize %d %d\n", ModuleTextSize.x , ModuleTextSize.y);
fprintf(File, "TextModWidth %d\n", ModuleTextWidth);
fprintf(File, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y);
fprintf(File, "PadDrill %d\n", g_Pad_Master.m_Drill.x);
char text[1024];
int ii, jj;
fprintf( File, "$SETUP\n" );
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( File, text );
if( frame->GetScreen()->m_UserGridIsON )
ii = jj = -1;
else
{
ii = frame->GetScreen()->GetGrid().x;
jj = frame->GetScreen()->GetGrid().y;
}
sprintf( text, "GridSize %d %d\n", ii, jj );
fprintf( File, text );
sprintf( text, "UserGridSize %lf %lf %s\n",
frame->GetScreen()->m_UserGrid.x, frame->GetScreen()->m_UserGrid.y,
( g_UserGrid_Unit == 0 ) ? "INCH" : "mm" );
fprintf( File, text );
fprintf( File, "ZoneGridSize %d\n", g_GridRoutingSize );
fprintf( File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount );
fprintf( File, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth );
for( ii = 0; ii < HIST0RY_NUMBER; ii++ )
{
if( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 )
break;
fprintf( File, "TrackWidthHistory %d\n",
g_DesignSettings.m_TrackWidhtHistory[ii] );
}
fprintf( File, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence );
fprintf( File, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence );
fprintf( File, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth );
fprintf( File, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth );
fprintf( File, "ViaSize %d\n", g_DesignSettings.m_CurrentViaSize );
fprintf( File, "ViaDrill %d\n", g_DesignSettings.m_ViaDrill );
for( ii = 0; ii < HIST0RY_NUMBER; ii++ )
{
if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 )
break;
fprintf( File, "ViaSizeHistory %d\n", g_DesignSettings.m_ViaSizeHistory[ii] );
}
fprintf( File, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth );
fprintf( File, "TextPcbSize %d %d\n",
g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y );
fprintf( File, "EdgeModWidth %d\n", ModuleSegmentWidth );
fprintf( File, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y );
fprintf( File, "TextModWidth %d\n", ModuleTextWidth );
fprintf( File, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y );
fprintf( File, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
// fprintf(File, "PadDeltaSize %d %d\n", Pad_DeltaSize.x, Pad_DeltaSize.y);
// fprintf(File, "PadDrillOffset %d %d\n", Pad_OffsetSize.x, Pad_OffsetSize.y);
fprintf(File, "AuxiliaryAxisOrg %d %d\n",
frame->m_Auxiliary_Axis_Position.x, frame->m_Auxiliary_Axis_Position.y);
fprintf(File,"$EndSETUP\n\n");
return(1);
fprintf( File, "AuxiliaryAxisOrg %d %d\n",
frame->m_Auxiliary_Axis_Position.x, frame->m_Auxiliary_Axis_Position.y );
fprintf( File, "$EndSETUP\n\n" );
return 1;
}
#endif
/******************************************************/
bool WinEDA_PcbFrame::WriteGeneralDescrPcb(FILE * File)
bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
/******************************************************/
{
EDA_BaseStruct * PtStruct = m_Pcb->m_Modules;
int NbModules, NbDrawItem, NbLayers;
/* Calcul du nombre des modules */
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext) NbModules++;
/* generation du masque des couches autorisees */
NbLayers = m_Pcb->m_BoardSettings->m_CopperLayerCount;
fprintf(File,"$GENERAL\n");
fprintf(File,"LayerCount %d\n",NbLayers);
// Write old format for Layer count (for compatibility with old versions of pcbnew
fprintf(File,"Ly %8X\n", g_TabAllCopperLayerMask[NbLayers-1] | ALL_NO_CU_LAYERS); // For compatibility with old version of pcbnew
fprintf(File,"Links %d\n",m_Pcb->m_NbLinks);
fprintf(File,"NoConn %d\n",m_Pcb->m_NbNoconnect);
/* Generation des coord du rectangle d'encadrement */
m_Pcb->ComputeBoundaryBox();
fprintf(File,"Di %d %d %d %d\n",
m_Pcb->m_BoundaryBox.GetX(), m_Pcb->m_BoundaryBox.GetY(),
m_Pcb->m_BoundaryBox.GetRight(),
m_Pcb->m_BoundaryBox.GetBottom());
/* Generation du nombre de segments type DRAW , TRACT ZONE */
PtStruct = m_Pcb->m_Drawings; NbDrawItem = 0;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) NbDrawItem++;
fprintf(File,"Ndraw %d\n", NbDrawItem);
fprintf(File,"Ntrack %d\n", m_Pcb->GetNumSegmTrack() );
fprintf(File,"Nzone %d\n", m_Pcb->GetNumSegmZone() );
fprintf(File,"Nmodule %d\n",NbModules );
fprintf(File,"Nnets %d\n",m_Pcb->m_NbNets );
fprintf(File,"$EndGENERAL\n\n");
return TRUE;
EDA_BaseStruct* PtStruct = m_Pcb->m_Modules;
int NbModules, NbDrawItem, NbLayers;
/* Calcul du nombre des modules */
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext )
NbModules++;
/* generation du masque des couches autorisees */
NbLayers = m_Pcb->m_BoardSettings->m_CopperLayerCount;
fprintf( File, "$GENERAL\n" );
fprintf( File, "LayerCount %d\n", NbLayers );
// Write old format for Layer count (for compatibility with old versions of pcbnew
fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew
fprintf( File, "Links %d\n", m_Pcb->m_NbLinks );
fprintf( File, "NoConn %d\n", m_Pcb->m_NbNoconnect );
/* Generation des coord du rectangle d'encadrement */
m_Pcb->ComputeBoundaryBox();
fprintf( File, "Di %d %d %d %d\n",
m_Pcb->m_BoundaryBox.GetX(), m_Pcb->m_BoundaryBox.GetY(),
m_Pcb->m_BoundaryBox.GetRight(),
m_Pcb->m_BoundaryBox.GetBottom() );
/* Generation du nombre de segments type DRAW , TRACT ZONE */
PtStruct = m_Pcb->m_Drawings; NbDrawItem = 0;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
NbDrawItem++;
fprintf( File, "Ndraw %d\n", NbDrawItem );
fprintf( File, "Ntrack %d\n", m_Pcb->GetNumSegmTrack() );
fprintf( File, "Nzone %d\n", m_Pcb->GetNumSegmZone() );
fprintf( File, "Nmodule %d\n", NbModules );
fprintf( File, "Nnets %d\n", m_Pcb->m_NbNets );
fprintf( File, "$EndGENERAL\n\n" );
return TRUE;
}
/******************************************************/
bool WriteSheetDescr(BASE_SCREEN * screen, FILE * File)
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
/******************************************************/
{
/* Sauvegarde des dimensions de la feuille de dessin, des textes du cartouche.. */
Ki_PageDescr * sheet = screen->m_CurrentSheet;
fprintf(File,"$SHEETDESCR\n");
fprintf(File,"Sheet %s %d %d\n",
CONV_TO_UTF8(sheet->m_Name), sheet->m_Size.x,sheet->m_Size.y);
fprintf(File,"Title \"%s\"\n", CONV_TO_UTF8(screen->m_Title));
fprintf(File,"Date \"%s\"\n", CONV_TO_UTF8(screen->m_Date));
fprintf(File,"Rev \"%s\"\n", CONV_TO_UTF8(screen->m_Revision));
fprintf(File,"Comp \"%s\"\n", CONV_TO_UTF8(screen->m_Company));
fprintf(File,"Comment1 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire1));
fprintf(File,"Comment2 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire2));
fprintf(File,"Comment3 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire3));
fprintf(File,"Comment4 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire4));
fprintf(File,"$EndSHEETDESCR\n\n");
return TRUE;
/* Sauvegarde des dimensions de la feuille de dessin, des textes du cartouche.. */
Ki_PageDescr* sheet = screen->m_CurrentSheet;
fprintf( File, "$SHEETDESCR\n" );
fprintf( File, "Sheet %s %d %d\n",
CONV_TO_UTF8( sheet->m_Name ), sheet->m_Size.x, sheet->m_Size.y );
fprintf( File, "Title \"%s\"\n", CONV_TO_UTF8( screen->m_Title ) );
fprintf( File, "Date \"%s\"\n", CONV_TO_UTF8( screen->m_Date ) );
fprintf( File, "Rev \"%s\"\n", CONV_TO_UTF8( screen->m_Revision ) );
fprintf( File, "Comp \"%s\"\n", CONV_TO_UTF8( screen->m_Company ) );
fprintf( File, "Comment1 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire1 ) );
fprintf( File, "Comment2 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire2 ) );
fprintf( File, "Comment3 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire3 ) );
fprintf( File, "Comment4 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire4 ) );
fprintf( File, "$EndSHEETDESCR\n\n" );
return TRUE;
}
/***************************************************************************/
static bool ReadSheetDescr(BASE_SCREEN * screen, FILE * File, int * LineNum)
static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
/***************************************************************************/
{
char Line[1024], buf[1024], * text;
/* Recheche suite et fin de descr */
while( GetLine(File, Line, LineNum ) != NULL )
{
if( strnicmp(Line,"$End",4) == 0 ) return TRUE;
if(strnicmp(Line, "Sheet", 4) == 0)
{
text = strtok(Line, " \t\n\r");
text = strtok(NULL, " \t\n\r");
Ki_PageDescr * sheet = SheetList[0];
int ii;
for( ii = 0; sheet != NULL; ii++, sheet = SheetList[ii])
{
if( stricmp( CONV_TO_UTF8(sheet->m_Name), text) == 0 )
{
screen->m_CurrentSheet = sheet;
if ( sheet == &g_Sheet_user )
{
text = strtok(NULL, " \t\n\r");
if ( text ) sheet->m_Size.x = atoi(text);
text = strtok(NULL, " \t\n\r");
if ( text ) sheet->m_Size.y = atoi(text);
}
break;
}
}
continue;
}
if( strnicmp(Line,"Title",2) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Title = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Date",2) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Date = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Rev",2) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Revision = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Comp",4) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Company = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Comment1",8) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Commentaire1 = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Comment2",8) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Commentaire2 = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Comment3",8) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Commentaire3 = CONV_FROM_UTF8(buf);
continue;
}
if( strnicmp(Line,"Comment4",8) == 0 )
{
ReadDelimitedText( buf, Line, 256);
screen->m_Commentaire4 = CONV_FROM_UTF8(buf);
continue;
}
}
return(FALSE);
char Line[1024], buf[1024], * text;
/* Recheche suite et fin de descr */
while( GetLine( File, Line, LineNum ) != NULL )
{
if( strnicmp( Line, "$End", 4 ) == 0 )
return TRUE;
if( strnicmp( Line, "Sheet", 4 ) == 0 )
{
text = strtok( Line, " \t\n\r" );
text = strtok( NULL, " \t\n\r" );
Ki_PageDescr* sheet = SheetList[0];
int ii;
for( ii = 0; sheet != NULL; ii++, sheet = SheetList[ii] )
{
if( stricmp( CONV_TO_UTF8( sheet->m_Name ), text ) == 0 )
{
screen->m_CurrentSheet = sheet;
if( sheet == &g_Sheet_user )
{
text = strtok( NULL, " \t\n\r" );
if( text )
sheet->m_Size.x = atoi( text );
text = strtok( NULL, " \t\n\r" );
if( text )
sheet->m_Size.y = atoi( text );
}
break;
}
}
continue;
}
if( strnicmp( Line, "Title", 2 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Title = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Date", 2 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Date = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Rev", 2 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Revision = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Comp", 4 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Company = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Comment1", 8 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Commentaire1 = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Comment2", 8 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Commentaire2 = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Comment3", 8 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Commentaire3 = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( Line, "Comment4", 8 ) == 0 )
{
ReadDelimitedText( buf, Line, 256 );
screen->m_Commentaire4 = CONV_FROM_UTF8( buf );
continue;
}
}
return FALSE;
}
/********************************************************************/
int WinEDA_PcbFrame::ReadPcbFile(wxDC * DC, FILE * File, bool Append)
int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
/********************************************************************/
/* Lit un fichier PCB .brd
Si Append == 0: l'ancien pcb en memoire est supprime
Sinon il y a ajout des elements
*/
* Si Append == 0: l'ancien pcb en memoire est supprime
* Sinon il y a ajout des elements
*/
{
char Line[1024];
int LineNum = 0;
int nbsegm, nbmod;
EDA_BaseStruct * LastStructPcb = NULL, * StructPcb;
MODULE * LastModule = NULL, * Module;
EQUIPOT * LastEquipot = NULL, * Equipot;
wxBusyCursor dummy;
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale(LC_NUMERIC, "C");
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
m_Pcb->m_NbNets = 0;
m_Pcb->m_Status_Pcb = 0;
nbmod = 0;
if ( Append )
{
LastModule = m_Pcb->m_Modules;
for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Pnext )
{
if ( LastModule->Pnext == NULL ) break;
}
LastStructPcb = m_Pcb->m_Drawings;
for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Pnext )
{
if ( LastStructPcb->Pnext == NULL ) break;
}
LastEquipot = m_Pcb->m_Equipots;
for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*)LastEquipot->Pnext )
{
if ( LastEquipot->Pnext == NULL ) break;
}
}
while( GetLine(File, Line, &LineNum ) != NULL )
{
if(strnicmp(Line,"$EndPCB",6) == 0) break;
if( strnicmp(Line,"$GENERAL",8) == 0 )
{
ReadGeneralDescrPcb(DC, File, &LineNum);
continue;
}
if( strnicmp(Line,"$SHEETDESCR",11) == 0 )
{
ReadSheetDescr(m_CurrentScreen, File, &LineNum);
continue;
}
if( strnicmp(Line,"$SETUP",6) == 0 )
{
if( ! Append)
{
ReadSetup(File, &LineNum);
}
else
{
while( GetLine(File, Line, &LineNum ) != NULL )
if( strnicmp(Line,"$EndSETUP",6) == 0 ) break;
}
continue;
}
if(strnicmp(Line,"$EQUIPOT",7) == 0)
{
Equipot = new EQUIPOT(m_Pcb);
Equipot->ReadEquipotDescr(File, &LineNum);
if( LastEquipot == NULL )
{
m_Pcb->m_Equipots = Equipot;
Equipot->Pback = m_Pcb;
}
else
{
Equipot->Pback = LastEquipot;
LastEquipot->Pnext = Equipot;
}
LastEquipot = Equipot;
m_Pcb->m_NbNets++;
continue;
}
if(strnicmp(Line,"$MODULE",7) == 0)
{
float Pas;
Pas = 100.0; if( NbMod > 1) Pas /= NbMod;
Module = new MODULE(m_Pcb);
if( Module == NULL ) continue;
Module->ReadDescr(File, &LineNum);
if( LastModule == NULL )
{
m_Pcb->m_Modules = Module;
Module->Pback = m_Pcb;
}
else
{
Module->Pback = LastModule;
LastModule->Pnext = Module;
}
LastModule = Module;
nbmod++;
char Line[1024];
int LineNum = 0;
int nbsegm, nbmod;
EDA_BaseStruct* LastStructPcb = NULL, * StructPcb;
MODULE* LastModule = NULL, * Module;
EQUIPOT* LastEquipot = NULL, * Equipot;
wxBusyCursor dummy;
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
m_Pcb->m_NbNets = 0;
m_Pcb->m_Status_Pcb = 0;
nbmod = 0;
if( Append )
{
LastModule = m_Pcb->m_Modules;
for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Pnext )
{
if( LastModule->Pnext == NULL )
break;
}
LastStructPcb = m_Pcb->m_Drawings;
for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Pnext )
{
if( LastStructPcb->Pnext == NULL )
break;
}
LastEquipot = m_Pcb->m_Equipots;
for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*) LastEquipot->Pnext )
{
if( LastEquipot->Pnext == NULL )
break;
}
}
while( GetLine( File, Line, &LineNum ) != NULL )
{
if( strnicmp( Line, "$EndPCB", 6 ) == 0 )
break;
if( strnicmp( Line, "$GENERAL", 8 ) == 0 )
{
ReadGeneralDescrPcb( DC, File, &LineNum );
continue;
}
if( strnicmp( Line, "$SHEETDESCR", 11 ) == 0 )
{
ReadSheetDescr( m_CurrentScreen, File, &LineNum );
continue;
}
if( strnicmp( Line, "$SETUP", 6 ) == 0 )
{
if( !Append )
{
ReadSetup( File, &LineNum );
}
else
{
while( GetLine( File, Line, &LineNum ) != NULL )
if( strnicmp( Line, "$EndSETUP", 6 ) == 0 )
break;
}
continue;
}
if( strnicmp( Line, "$EQUIPOT", 7 ) == 0 )
{
Equipot = new EQUIPOT( m_Pcb );
Equipot->ReadEquipotDescr( File, &LineNum );
if( LastEquipot == NULL )
{
m_Pcb->m_Equipots = Equipot;
Equipot->Pback = m_Pcb;
}
else
{
Equipot->Pback = LastEquipot;
LastEquipot->Pnext = Equipot;
}
LastEquipot = Equipot;
m_Pcb->m_NbNets++;
continue;
}
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{
float Pas;
Pas = 100.0; if( NbMod > 1 )
Pas /= NbMod;
Module = new MODULE( m_Pcb );
if( Module == NULL )
continue;
Module->ReadDescr( File, &LineNum );
if( LastModule == NULL )
{
m_Pcb->m_Modules = Module;
Module->Pback = m_Pcb;
}
else
{
Module->Pback = LastModule;
LastModule->Pnext = Module;
}
LastModule = Module;
nbmod++;
#ifdef PCBNEW
DisplayActivity((int)( Pas * nbmod), wxT("Modules:"));
DisplayActivity( (int) ( Pas * nbmod), wxT( "Modules:" ) );
#endif
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
continue;
}
if(strnicmp(Line,"$TEXTPCB",8) == 0)
{
TEXTE_PCB * pcbtxt = new TEXTE_PCB(m_Pcb);
StructPcb = (EDA_BaseStruct*) pcbtxt;
pcbtxt->ReadTextePcbDescr(File, &LineNum);
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = StructPcb;
StructPcb->Pback = m_Pcb;
}
else
{
StructPcb->Pback = LastStructPcb;
LastStructPcb->Pnext = StructPcb;
}
LastStructPcb = StructPcb;
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
continue;
}
if( strnicmp( Line, "$TEXTPCB", 8 ) == 0 )
{
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_Pcb );
StructPcb = (EDA_BaseStruct*) pcbtxt;
pcbtxt->ReadTextePcbDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = StructPcb;
StructPcb->Pback = m_Pcb;
}
else
{
StructPcb->Pback = LastStructPcb;
LastStructPcb->Pnext = StructPcb;
}
LastStructPcb = StructPcb;
#ifdef PCBNEW
((TEXTE_PCB*)StructPcb)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR);
( (TEXTE_PCB*) StructPcb )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
#endif
continue;
}
if( strnicmp(Line,"$DRAWSEGMENT",10) == 0)
{
DRAWSEGMENT * DrawSegm = new DRAWSEGMENT(m_Pcb);
DrawSegm->ReadDrawSegmentDescr(File, &LineNum);
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = DrawSegm;
DrawSegm->Pback = m_Pcb;
}
else
{
DrawSegm->Pback = LastStructPcb;
LastStructPcb->Pnext = DrawSegm;
}
LastStructPcb = DrawSegm;
continue;
}
if( strnicmp( Line, "$DRAWSEGMENT", 10 ) == 0 )
{
DRAWSEGMENT* DrawSegm = new DRAWSEGMENT( m_Pcb );
DrawSegm->ReadDrawSegmentDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = DrawSegm;
DrawSegm->Pback = m_Pcb;
}
else
{
DrawSegm->Pback = LastStructPcb;
LastStructPcb->Pnext = DrawSegm;
}
LastStructPcb = DrawSegm;
#ifdef PCBNEW
Trace_DrawSegmentPcb(DrawPanel, DC, DrawSegm, GR_OR);
Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_OR );
#endif
continue;
}
if( strnicmp(Line,"$COTATION",9) == 0)
{
COTATION * Cotation = new COTATION(m_Pcb);
Cotation->ReadCotationDescr(File, &LineNum);
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = Cotation;
Cotation->Pback = m_Pcb;
}
else
{
Cotation->Pback = LastStructPcb;
LastStructPcb->Pnext = Cotation;
}
LastStructPcb = Cotation;
continue;
}
if( strnicmp( Line, "$COTATION", 9 ) == 0 )
{
COTATION* Cotation = new COTATION( m_Pcb );
Cotation->ReadCotationDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = Cotation;
Cotation->Pback = m_Pcb;
}
else
{
Cotation->Pback = LastStructPcb;
LastStructPcb->Pnext = Cotation;
}
LastStructPcb = Cotation;
#ifdef PCBNEW
Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
#endif
continue;
}
if( strnicmp(Line,"$MIREPCB",8) == 0)
{
MIREPCB * Mire = new MIREPCB(m_Pcb);
Mire->ReadMirePcbDescr(File, &LineNum);
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = Mire;
Mire->Pback = m_Pcb;
}
else
{
Mire->Pback = LastStructPcb;
LastStructPcb->Pnext = Mire;
}
LastStructPcb = Mire;
continue;
}
if( strnicmp( Line, "$MIREPCB", 8 ) == 0 )
{
MIREPCB* Mire = new MIREPCB( m_Pcb );
Mire->ReadMirePcbDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = Mire;
Mire->Pback = m_Pcb;
}
else
{
Mire->Pback = LastStructPcb;
LastStructPcb->Pnext = Mire;
}
LastStructPcb = Mire;
#ifdef PCBNEW
Mire->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
Mire->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
#endif
continue;
}
if(strnicmp(Line,"$TRACK",6) == 0)
{
TRACK * StartTrack = m_Pcb->m_Track;
nbsegm = 0;
if( Append )
{
for( ;StartTrack != NULL; StartTrack = (TRACK*)StartTrack->Pnext)
{
if( StartTrack->Pnext == NULL ) break;
}
}
continue;
}
if( strnicmp( Line, "$TRACK", 6 ) == 0 )
{
TRACK* StartTrack = m_Pcb->m_Track;
nbsegm = 0;
if( Append )
{
for( ; StartTrack != NULL; StartTrack = (TRACK*) StartTrack->Pnext )
{
if( StartTrack->Pnext == NULL )
break;
}
}
#ifdef PCBNEW
int ii = ReadListeSegmentDescr(DC, File, StartTrack, TYPETRACK,
&LineNum, NbTrack);
m_Pcb->m_NbSegmTrack += ii;
int ii = ReadListeSegmentDescr( DC, File, StartTrack, TYPETRACK,
&LineNum, NbTrack );
m_Pcb->m_NbSegmTrack += ii;
#endif
continue;
}
if(strnicmp(Line,"$ZONE",5) == 0)
{
TRACK * StartZone = m_Pcb->m_Zone;
if( Append )
{
for( ;StartZone != NULL; StartZone = (TRACK*)StartZone->Pnext)
{
if( StartZone->Pnext == NULL ) break;
}
}
continue;
}
if( strnicmp( Line, "$ZONE", 5 ) == 0 )
{
TRACK* StartZone = m_Pcb->m_Zone;
if( Append )
{
for( ; StartZone != NULL; StartZone = (TRACK*) StartZone->Pnext )
{
if( StartZone->Pnext == NULL )
break;
}
}
#ifdef PCBNEW
int ii = ReadListeSegmentDescr(DC, File, StartZone,TYPEZONE,
&LineNum, NbZone);
m_Pcb->m_NbSegmZone += ii;
int ii = ReadListeSegmentDescr( DC, File, StartZone, TYPEZONE,
&LineNum, NbZone );
m_Pcb->m_NbSegmZone += ii;
#endif
continue;
}
}
continue;
}
}
setlocale(LC_NUMERIC, ""); // revert to the current locale
setlocale( LC_NUMERIC, "" ); // revert to the current locale
Affiche_Message(wxEmptyString);
Affiche_Message( wxEmptyString );
#ifdef PCBNEW
Compile_Ratsnest(DC, TRUE);
Compile_Ratsnest( DC, TRUE );
#endif
return(1);
return 1;
}
#ifdef PCBNEW
/***************************************************/
int WinEDA_PcbFrame::SavePcbFormatAscii(FILE * File)
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* File )
/****************************************************/
/* Routine de sauvegarde du PCB courant sous format ASCII
retourne
1 si OK
0 si sauvegarde non faite
*/
* retourne
* 1 si OK
* 0 si sauvegarde non faite
*/
{
int ii, NbModules, nseg;
float Pas;
char Line[256];
EQUIPOT * Equipot;
TRACK * PtSegm;
EDA_BaseStruct * PtStruct;
MODULE * Module;
wxBeginBusyCursor();
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++;
// 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) );
WriteGeneralDescrPcb(File);
WriteSheetDescr(m_CurrentScreen, File);
WriteSetup(File, this);
/* Ecriture des donnes utiles du pcb */
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->m_StructType )
{
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
wxEndBusyCursor();
Affiche_Message(wxEmptyString);
return 1;
int ii, NbModules, nseg;
float Pas;
char Line[256];
EQUIPOT* Equipot;
TRACK* PtSegm;
EDA_BaseStruct* PtStruct;
MODULE* Module;
wxBeginBusyCursor();
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++;
// 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 ) );
WriteGeneralDescrPcb( File );
WriteSheetDescr( m_CurrentScreen, File );
WriteSetup( File, this );
/* Ecriture des donnes utiles du pcb */
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->m_StructType )
{
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
wxEndBusyCursor();
Affiche_Message( wxEmptyString );
return 1;
}
#endif
#endif
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