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