added some conditional DEBUG code for showing the pcb object tree in simple XML format
This commit is contained in:
parent
02a2268f8a
commit
5748b79107
|
@ -18,8 +18,7 @@
|
|||
|
||||
|
||||
// DrawStructureType names for error messages only:
|
||||
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1]
|
||||
= {
|
||||
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1] = {
|
||||
wxT( "Not init" ),
|
||||
|
||||
wxT( "Pcb" ),
|
||||
|
@ -168,10 +167,9 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
|
|||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*********************************************/
|
||||
wxString EDA_BaseStruct::ReturnClassName( void )
|
||||
/*********************************************/
|
||||
|
@ -191,6 +189,48 @@ wxString EDA_BaseStruct::ReturnClassName( void )
|
|||
}
|
||||
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
||||
/**
|
||||
* Function Show
|
||||
* is used to output the object tree, currently for debugging only.
|
||||
* @param nestLevel An aid to prettier tree indenting, and is the level
|
||||
* of nesting of this object within the overall tree.
|
||||
* @param os The ostream& to output to.
|
||||
*/
|
||||
void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
|
||||
{
|
||||
// for now, make it look like XML:
|
||||
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n";
|
||||
|
||||
EDA_BaseStruct* kid = m_Son;
|
||||
for( ; kid; kid = kid->Pnext )
|
||||
{
|
||||
kid->Show( nestLevel+1, os );
|
||||
}
|
||||
|
||||
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function NestedSpace
|
||||
* outputs nested space for pretty indenting.
|
||||
* @param nestLevel The nest count
|
||||
* @param os The ostream&, where to output
|
||||
* @return std::ostream& - for continuation.
|
||||
**/
|
||||
std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os )
|
||||
{
|
||||
for( int i=0; i<nestLevel; ++i )
|
||||
os << ' '; // number of spaces here controls indent per nest level
|
||||
return os;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**********************************************************************************************/
|
||||
EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) :
|
||||
EDA_BaseStruct( StructFather, idtype )
|
||||
|
@ -721,3 +761,4 @@ void DrawPickedStruct::DeleteWrapperList( void )
|
|||
delete wrapp_struct;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
#define BASE_STRUCT_H
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
#include <iostream> // needed for Show()
|
||||
#endif
|
||||
|
||||
|
||||
/* Id for class identification, at run time */
|
||||
enum DrawStructureType {
|
||||
TYPE_NOT_INIT = 0,
|
||||
|
@ -123,8 +128,30 @@ public:
|
|||
const wxPoint& offset,
|
||||
int draw_mode,
|
||||
int Color = -1 );
|
||||
|
||||
#if defined(DEBUG)
|
||||
/**
|
||||
* Function Show
|
||||
* is used to output the object tree, currently for debugging only.
|
||||
* @param nestLevel An aid to prettier tree indenting, and is the level
|
||||
* of nesting of this object within the overall tree.
|
||||
* @param os The ostream& to output to.
|
||||
*/
|
||||
virtual void Show( int nestLevel, std::ostream& os );
|
||||
|
||||
/**
|
||||
* Function NestedSpace
|
||||
* outputs nested space for pretty indenting.
|
||||
* @param nestLevel The nest count
|
||||
* @param os The ostream&, where to output
|
||||
* @return std::ostream& - for continuation.
|
||||
**/
|
||||
static std::ostream& NestedSpace( int nestLevel, std::ostream& os );
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Text justify:
|
||||
// Values -1,0,1 are used in computations, do not change them
|
||||
typedef enum {
|
||||
|
|
|
@ -176,15 +176,16 @@ public:
|
|||
EDA_BoardDesignSettings( void );
|
||||
};
|
||||
|
||||
|
||||
// Values for m_DisplayViaMode member:
|
||||
enum DisplayViaMode {
|
||||
VIA_HOLE_NOT_SHOW = 0,
|
||||
VIA_SPECIAL_HOLE_SHOW,
|
||||
ALL_VIA_HOLE_SHOW,
|
||||
OPT_VIA_HOLE_END
|
||||
|
||||
};
|
||||
|
||||
|
||||
class BOARD : public EDA_BaseStruct
|
||||
{
|
||||
public:
|
||||
|
@ -212,8 +213,8 @@ public:
|
|||
CHEVELU* m_Ratsnest; // pointeur liste des chevelus
|
||||
CHEVELU* m_LocalRatsnest; // pointeur liste des chevelus d'un module
|
||||
|
||||
EDGE_ZONE* m_CurrentLimitZone;/* pointeur sur la liste des segments
|
||||
* de delimitation de la zone en cours de trace */
|
||||
EDGE_ZONE* m_CurrentLimitZone; /* pointeur sur la liste des segments
|
||||
* de delimitation de la zone en cours de trace */
|
||||
|
||||
BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame );
|
||||
~BOARD( void );
|
||||
|
@ -230,6 +231,18 @@ public:
|
|||
|
||||
// Calcul du rectangle d'encadrement:
|
||||
bool ComputeBoundaryBox( void );
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
/**
|
||||
* Function Show
|
||||
* is used to output the object tree, currently for debugging only.
|
||||
* @param nestLevel An aid to prettier tree indenting, and is the level
|
||||
* of nesting of this object within the overall tree.
|
||||
* @param os The ostream& to output to.
|
||||
*/
|
||||
virtual void Show( int nestLevel, std::ostream& os );
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -254,3 +254,36 @@ bool BOARD::ComputeBoundaryBox( void )
|
|||
|
||||
return Has_Items;
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
/**
|
||||
* Function Show
|
||||
* is used to output the object tree, currently for debugging only.
|
||||
* @param nestLevel An aid to prettier tree indenting, and is the level
|
||||
* of nesting of this object within the overall tree.
|
||||
* @param os The ostream& to output to.
|
||||
*/
|
||||
void BOARD::Show( int nestLevel, std::ostream& os )
|
||||
{
|
||||
// for now, make it look like XML:
|
||||
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n";
|
||||
|
||||
// specialization of the output:
|
||||
EDA_BaseStruct* p = m_Modules;
|
||||
for( ; p; p = p->Pnext )
|
||||
p->Show( nestLevel+1, os );
|
||||
|
||||
p = m_Drawings;
|
||||
for( ; p; p = p->Pnext )
|
||||
p->Show( nestLevel+1, os );
|
||||
|
||||
EDA_BaseStruct* kid = m_Son;
|
||||
for( ; kid; kid = kid->Pnext )
|
||||
{
|
||||
kid->Show( nestLevel+1, os );
|
||||
}
|
||||
|
||||
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
|
||||
}
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,22 +1,22 @@
|
|||
/*******************************************************/
|
||||
/* class_module.h : module description (excepted pads) */
|
||||
/*******************************************************/
|
||||
/*******************************************************/
|
||||
/* class_module.h : module description (excepted pads) */
|
||||
/*******************************************************/
|
||||
|
||||
|
||||
class Pcb3D_GLCanvas;
|
||||
class Struct3D_Master;
|
||||
|
||||
/************************************/
|
||||
/* Modules (footprints) description */
|
||||
/* pad are in class_pad.xx */
|
||||
/************************************/
|
||||
/************************************/
|
||||
/* Modules (footprints) description */
|
||||
/* pad are in class_pad.xx */
|
||||
/************************************/
|
||||
|
||||
/* Format des modules:
|
||||
Description generale
|
||||
Description segments contour
|
||||
Description textes
|
||||
Description pastilles
|
||||
*/
|
||||
* Description generale
|
||||
* Description segments contour
|
||||
* Description textes
|
||||
* Description pastilles
|
||||
*/
|
||||
|
||||
/* Flags :*/
|
||||
|
||||
|
@ -24,9 +24,10 @@ enum Mod_Attribut /* Attributs d'un module */
|
|||
{
|
||||
MOD_DEFAULT = 0, /* Type default */
|
||||
MOD_CMS = 1, /* Pour module apparaissant dans les
|
||||
fichiers de placement automatique (principalement modules CMS */
|
||||
* fichiers de placement automatique (principalement modules CMS */
|
||||
MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit
|
||||
(connecteur, trou de percage..) */
|
||||
* (connecteur, trou de percage..) */
|
||||
|
||||
};
|
||||
|
||||
/* flags for autoplace and autoroute (.m_ModuleStatus member) */
|
||||
|
@ -34,59 +35,60 @@ enum Mod_Attribut /* Attributs d'un module */
|
|||
#define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */
|
||||
#define MODULE_to_PLACE 0x04 /* In autoplace: module waiting for autoplace */
|
||||
|
||||
class MODULE: public EDA_BaseStruct
|
||||
class MODULE : public EDA_BaseStruct
|
||||
{
|
||||
public:
|
||||
int m_Layer; // layer number
|
||||
wxPoint m_Pos; // Real coord on board
|
||||
D_PAD * m_Pads; /* Pad list (linked list) */
|
||||
EDA_BaseStruct * m_Drawings; /* Graphic items list (linked list) */
|
||||
Struct3D_Master * m_3D_Drawings; /* Pointeur sur la liste des elements de trace 3D*/
|
||||
TEXTE_MODULE * m_Reference; // texte reference du composant (U34, R18..)
|
||||
TEXTE_MODULE * m_Value; // texte valeur du composant (74LS00, 22K..)
|
||||
wxString m_LibRef; /* nom du module en librairie */
|
||||
int m_Layer; // layer number
|
||||
wxPoint m_Pos; // Real coord on board
|
||||
D_PAD* m_Pads; /* Pad list (linked list) */
|
||||
EDA_BaseStruct* m_Drawings; /* Graphic items list (linked list) */
|
||||
Struct3D_Master* m_3D_Drawings; /* Pointeur sur la liste des elements de trace 3D*/
|
||||
TEXTE_MODULE* m_Reference; // texte reference du composant (U34, R18..)
|
||||
TEXTE_MODULE* m_Value; // texte valeur du composant (74LS00, 22K..)
|
||||
wxString m_LibRef; /* nom du module en librairie */
|
||||
|
||||
int m_Attributs; /* Flags bits a bit ( voir enum Mod_Attribut ) */
|
||||
int m_Orient ; /* orientation en 1/10 degres */
|
||||
int flag ; /* flag utilise en trace rastnest et routage auto */
|
||||
int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */
|
||||
EDA_Rect m_BoundaryBox; /* position/taille du cadre de reperage (coord locales)*/
|
||||
EDA_Rect m_RealBoundaryBox ; /* position/taille du module (coord relles) */
|
||||
int m_PadNum; // Nombre total de pads
|
||||
int m_AltPadNum; // en placement auto Nombre de pads actifs pour
|
||||
// les calculs
|
||||
int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre
|
||||
int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre
|
||||
wxSize m_Ext; // marges de "garde": utilise en placement auto.
|
||||
float m_Surface; // surface du rectangle d'encadrement
|
||||
int m_Attributs; /* Flags bits a bit ( voir enum Mod_Attribut ) */
|
||||
int m_Orient; /* orientation en 1/10 degres */
|
||||
int flag; /* flag utilise en trace rastnest et routage auto */
|
||||
int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */
|
||||
EDA_Rect m_BoundaryBox; /* position/taille du cadre de reperage (coord locales)*/
|
||||
EDA_Rect m_RealBoundaryBox; /* position/taille du module (coord relles) */
|
||||
int m_PadNum; // Nombre total de pads
|
||||
int m_AltPadNum; // en placement auto Nombre de pads actifs pour
|
||||
// les calculs
|
||||
int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre
|
||||
int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre
|
||||
wxSize m_Ext; // marges de "garde": utilise en placement auto.
|
||||
float m_Surface; // surface du rectangle d'encadrement
|
||||
|
||||
unsigned long m_Link; // variable temporaire ( pour editions, ...)
|
||||
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies)
|
||||
unsigned long m_Link; // variable temporaire ( pour editions, ...)
|
||||
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies)
|
||||
|
||||
wxString m_Doc; // Texte de description du module
|
||||
wxString m_KeyWord; // Liste des mots cles relatifs au module
|
||||
wxString m_Doc; // Texte de description du module
|
||||
wxString m_KeyWord; // Liste des mots cles relatifs au module
|
||||
|
||||
public:
|
||||
MODULE(BOARD * parent);
|
||||
MODULE(MODULE * module);
|
||||
~MODULE(void);
|
||||
MODULE( BOARD* parent );
|
||||
MODULE( MODULE* module );
|
||||
~MODULE( void );
|
||||
|
||||
void Copy(MODULE * Module); // Copy structure
|
||||
MODULE * Next(void) { return (MODULE *) Pnext; }
|
||||
void Copy( MODULE* Module ); // Copy structure
|
||||
|
||||
void Set_Rectangle_Encadrement(void); /* mise a jour du rect d'encadrement
|
||||
en coord locales (orient 0 et origine = pos module) */
|
||||
MODULE* Next( void ) { return (MODULE*) Pnext; }
|
||||
|
||||
void SetRectangleExinscrit(void); /* mise a jour du rect d'encadrement
|
||||
et de la surface en coord reelles */
|
||||
void Set_Rectangle_Encadrement( void );/* mise a jour du rect d'encadrement
|
||||
* en coord locales (orient 0 et origine = pos module) */
|
||||
|
||||
void SetRectangleExinscrit( void );/* mise a jour du rect d'encadrement
|
||||
* et de la surface en coord reelles */
|
||||
|
||||
|
||||
// deplacements
|
||||
void SetPosition(const wxPoint & newpos);
|
||||
void SetOrientation(int newangle);
|
||||
void SetPosition( const wxPoint& newpos );
|
||||
void SetOrientation( int newangle );
|
||||
|
||||
/* supprime du chainage la structure Struct */
|
||||
void UnLink( void );
|
||||
void UnLink( void );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -98,11 +100,11 @@ public:
|
|||
return (m_ModuleStatus & MODULE_is_LOCKED) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function SetLocked
|
||||
* sets the MODULE_is_LOCKED bit in the m_ModuleStatus
|
||||
* @param setLocked When true means turn on locked status, else unlock
|
||||
* @param setLocked When true means turn on locked status, else unlock
|
||||
*/
|
||||
void SetLocked( bool setLocked )
|
||||
{
|
||||
|
@ -112,23 +114,34 @@ public:
|
|||
m_ModuleStatus &= ~MODULE_is_LOCKED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Readind and writing data on files */
|
||||
int WriteDescr( FILE * File );
|
||||
int Write_3D_Descr( FILE * File );
|
||||
int ReadDescr( FILE * File, int * LineNum = NULL);
|
||||
int Read_3D_Descr( FILE * File, int * LineNum = NULL);
|
||||
int WriteDescr( FILE* File );
|
||||
int Write_3D_Descr( FILE* File );
|
||||
int ReadDescr( FILE* File, int* LineNum = NULL );
|
||||
int Read_3D_Descr( FILE* File, int* LineNum = NULL );
|
||||
|
||||
/* drawing functions */
|
||||
void Draw(WinEDA_DrawPanel * panel, wxDC * DC,
|
||||
const wxPoint & offset, int draw_mode);
|
||||
void Draw3D(Pcb3D_GLCanvas * glcanvas);
|
||||
void DrawEdgesOnly(WinEDA_DrawPanel * panel, wxDC * DC,
|
||||
const wxPoint & offset,int draw_mode);
|
||||
void DrawAncre(WinEDA_DrawPanel * panel, wxDC * DC,
|
||||
const wxPoint & offset, int dim_ancre, int draw_mode);
|
||||
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||
const wxPoint& offset, int draw_mode );
|
||||
void Draw3D( Pcb3D_GLCanvas* glcanvas );
|
||||
void DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||
const wxPoint& offset, int draw_mode );
|
||||
void DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||
const wxPoint& offset, int dim_ancre, int draw_mode );
|
||||
|
||||
/* miscellaneous */
|
||||
void Display_Infos(WinEDA_BasePcbFrame * frame);
|
||||
};
|
||||
void Display_Infos( WinEDA_BasePcbFrame* frame );
|
||||
|
||||
#if defined(DEBUG)
|
||||
/**
|
||||
* Function Show
|
||||
* is used to output the object tree, currently for debugging only.
|
||||
* @param nestLevel An aid to prettier tree indenting, and is the level
|
||||
* of nesting of this object within the overall tree.
|
||||
* @param os The ostream& to output to.
|
||||
*/
|
||||
virtual void Show( int nestLevel, std::ostream& os );
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
534
pcbnew/files.cpp
534
pcbnew/files.cpp
|
@ -1,6 +1,6 @@
|
|||
/***************************************************/
|
||||
/* Files.cpp: Lecture / Sauvegarde des fichiers PCB */
|
||||
/***************************************************/
|
||||
/***************************************************/
|
||||
/* Files.cpp: Lecture / Sauvegarde des fichiers PCB */
|
||||
/***************************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
|
@ -11,321 +11,333 @@
|
|||
|
||||
|
||||
/****************************************************/
|
||||
void WinEDA_PcbFrame::Files_io(wxCommandEvent& event)
|
||||
void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
|
||||
/****************************************************/
|
||||
|
||||
/* Gestion generale des commandes de lecture de fichiers
|
||||
*/
|
||||
*/
|
||||
{
|
||||
int id = event.GetId();
|
||||
wxClientDC dc(DrawPanel);
|
||||
wxString msg;
|
||||
int id = event.GetId();
|
||||
wxClientDC dc( DrawPanel );
|
||||
wxString msg;
|
||||
|
||||
DrawPanel->PrepareGraphicContext(&dc);
|
||||
DrawPanel->PrepareGraphicContext( &dc );
|
||||
|
||||
// Arret des commandes en cours
|
||||
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
||||
{
|
||||
DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc);
|
||||
}
|
||||
SetToolID(0, wxCURSOR_ARROW,wxEmptyString);
|
||||
// Arret des commandes en cours
|
||||
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
||||
{
|
||||
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
||||
}
|
||||
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ID_MENU_LOAD_FILE:
|
||||
case ID_LOAD_FILE:
|
||||
Clear_Pcb(&dc, TRUE);
|
||||
LoadOnePcbFile(wxEmptyString, &dc, FALSE);
|
||||
ReCreateAuxiliaryToolbar();
|
||||
break;
|
||||
switch( id )
|
||||
{
|
||||
case ID_MENU_LOAD_FILE:
|
||||
case ID_LOAD_FILE:
|
||||
Clear_Pcb( &dc, TRUE );
|
||||
LoadOnePcbFile( wxEmptyString, &dc, FALSE );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
break;
|
||||
|
||||
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
|
||||
case ID_MENU_RECOVER_BOARD:
|
||||
{
|
||||
wxString filename, oldfilename = GetScreen()->m_FileName;
|
||||
if ( id == ID_MENU_RECOVER_BOARD)
|
||||
{
|
||||
filename = g_SaveFileName + PcbExtBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = oldfilename;
|
||||
ChangeFileNameExt(filename, wxT(".000"));
|
||||
}
|
||||
if ( ! wxFileExists(filename) )
|
||||
{
|
||||
msg = _("Recovery file ") + filename + _(" not found");
|
||||
DisplayInfo(this, msg);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = _("Ok to load Recovery file ") + filename;
|
||||
if ( ! IsOK (this, msg) ) break;
|
||||
}
|
||||
Clear_Pcb(&dc, TRUE);
|
||||
LoadOnePcbFile(filename, &dc, FALSE);
|
||||
GetScreen()->m_FileName = oldfilename;
|
||||
SetTitle(GetScreen()->m_FileName);
|
||||
ReCreateAuxiliaryToolbar();
|
||||
}
|
||||
break;
|
||||
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
|
||||
case ID_MENU_RECOVER_BOARD:
|
||||
{
|
||||
wxString filename, oldfilename = GetScreen()->m_FileName;
|
||||
if( id == ID_MENU_RECOVER_BOARD )
|
||||
{
|
||||
filename = g_SaveFileName + PcbExtBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = oldfilename;
|
||||
ChangeFileNameExt( filename, wxT( ".000" ) );
|
||||
}
|
||||
if( !wxFileExists( filename ) )
|
||||
{
|
||||
msg = _( "Recovery file " ) + filename + _( " not found" );
|
||||
DisplayInfo( this, msg );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = _( "Ok to load Recovery file " ) + filename;
|
||||
if( !IsOK( this, msg ) )
|
||||
break;
|
||||
}
|
||||
Clear_Pcb( &dc, TRUE );
|
||||
LoadOnePcbFile( filename, &dc, FALSE );
|
||||
GetScreen()->m_FileName = oldfilename;
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_MENU_APPEND_FILE:
|
||||
case ID_APPEND_FILE:
|
||||
LoadOnePcbFile(wxEmptyString, &dc, TRUE);
|
||||
break;
|
||||
case ID_MENU_APPEND_FILE:
|
||||
case ID_APPEND_FILE:
|
||||
LoadOnePcbFile( wxEmptyString, &dc, TRUE );
|
||||
break;
|
||||
|
||||
case ID_MENU_NEW_BOARD:
|
||||
case ID_NEW_BOARD:
|
||||
Clear_Pcb(&dc, TRUE);
|
||||
GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"),
|
||||
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData());
|
||||
SetTitle(GetScreen()->m_FileName);
|
||||
break;
|
||||
case ID_MENU_NEW_BOARD:
|
||||
case ID_NEW_BOARD:
|
||||
Clear_Pcb( &dc, TRUE );
|
||||
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
|
||||
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData() );
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
break;
|
||||
|
||||
case ID_LOAD_FILE_1:
|
||||
case ID_LOAD_FILE_2:
|
||||
case ID_LOAD_FILE_3:
|
||||
case ID_LOAD_FILE_4:
|
||||
case ID_LOAD_FILE_5:
|
||||
case ID_LOAD_FILE_6:
|
||||
case ID_LOAD_FILE_7:
|
||||
case ID_LOAD_FILE_8:
|
||||
case ID_LOAD_FILE_9:
|
||||
case ID_LOAD_FILE_10:
|
||||
Clear_Pcb(&dc, TRUE);
|
||||
wxSetWorkingDirectory(wxPathOnly(GetLastProject(id - ID_LOAD_FILE_1)));
|
||||
LoadOnePcbFile( GetLastProject(id - ID_LOAD_FILE_1).GetData(),
|
||||
&dc, FALSE);
|
||||
ReCreateAuxiliaryToolbar();
|
||||
break;
|
||||
case ID_LOAD_FILE_1:
|
||||
case ID_LOAD_FILE_2:
|
||||
case ID_LOAD_FILE_3:
|
||||
case ID_LOAD_FILE_4:
|
||||
case ID_LOAD_FILE_5:
|
||||
case ID_LOAD_FILE_6:
|
||||
case ID_LOAD_FILE_7:
|
||||
case ID_LOAD_FILE_8:
|
||||
case ID_LOAD_FILE_9:
|
||||
case ID_LOAD_FILE_10:
|
||||
Clear_Pcb( &dc, TRUE );
|
||||
wxSetWorkingDirectory( wxPathOnly( GetLastProject( id - ID_LOAD_FILE_1 ) ) );
|
||||
LoadOnePcbFile( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(),
|
||||
&dc, FALSE );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
break;
|
||||
|
||||
case ID_SAVE_BOARD:
|
||||
case ID_MENU_SAVE_BOARD:
|
||||
SavePcbFile(GetScreen()->m_FileName);
|
||||
break;
|
||||
case ID_SAVE_BOARD:
|
||||
case ID_MENU_SAVE_BOARD:
|
||||
SavePcbFile( GetScreen()->m_FileName );
|
||||
break;
|
||||
|
||||
case ID_MENU_SAVE_BOARD_AS:
|
||||
SavePcbFile(wxEmptyString);
|
||||
break;
|
||||
case ID_MENU_SAVE_BOARD_AS:
|
||||
SavePcbFile( wxEmptyString );
|
||||
break;
|
||||
|
||||
case ID_PCB_GEN_CMP_FILE:
|
||||
RecreateCmpFileFromBoard();
|
||||
break;
|
||||
case ID_PCB_GEN_CMP_FILE:
|
||||
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
|
||||
retourne:
|
||||
0 si fichier non lu ( annulation de commande ... )
|
||||
1 si OK
|
||||
*/
|
||||
* Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s
|
||||
* retourne:
|
||||
* 0 si fichier non lu ( annulation de commande ... )
|
||||
* 1 si OK
|
||||
*/
|
||||
{
|
||||
int ii;
|
||||
FILE * source;
|
||||
wxString msg;
|
||||
|
||||
ActiveScreen = GetScreen();
|
||||
int ii;
|
||||
FILE* source;
|
||||
wxString msg;
|
||||
|
||||
if( GetScreen()->IsModify() && !Append )
|
||||
{
|
||||
if( !IsOK(this, _("Board Modified: Continue ?")) )
|
||||
return(0);
|
||||
}
|
||||
ActiveScreen = GetScreen();
|
||||
|
||||
m_SelTrackWidthBox_Changed = TRUE;
|
||||
m_SelViaSizeBox_Changed = TRUE;
|
||||
if( GetScreen()->IsModify() && !Append )
|
||||
{
|
||||
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( Append )
|
||||
{
|
||||
GetScreen()->m_FileName = wxEmptyString;
|
||||
GetScreen()->SetModify();
|
||||
m_Pcb->m_Status_Pcb = 0;
|
||||
}
|
||||
m_SelTrackWidthBox_Changed = TRUE;
|
||||
m_SelViaSizeBox_Changed = TRUE;
|
||||
|
||||
if( FullFileName == wxEmptyString)
|
||||
{
|
||||
msg = wxT("*") + PcbExtBuffer;
|
||||
wxString FileName =
|
||||
EDA_FileSelector(_("Board files:"),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
GetScreen()->m_FileName, /* nom fichier par defaut */
|
||||
PcbExtBuffer, /* extension par defaut */
|
||||
msg, /* Masque d'affichage */
|
||||
this,
|
||||
wxFD_OPEN,
|
||||
FALSE
|
||||
);
|
||||
if ( FileName == wxEmptyString ) return FALSE;
|
||||
GetScreen()->m_FileName = FileName;
|
||||
}
|
||||
if( Append )
|
||||
{
|
||||
GetScreen()->m_FileName = wxEmptyString;
|
||||
GetScreen()->SetModify();
|
||||
m_Pcb->m_Status_Pcb = 0;
|
||||
}
|
||||
|
||||
else GetScreen()->m_FileName = FullFileName;
|
||||
if( FullFileName == wxEmptyString )
|
||||
{
|
||||
msg = wxT( "*" ) + PcbExtBuffer;
|
||||
wxString FileName =
|
||||
EDA_FileSelector( _( "Board files:" ),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
GetScreen()->m_FileName, /* nom fichier par defaut */
|
||||
PcbExtBuffer, /* extension par defaut */
|
||||
msg, /* Masque d'affichage */
|
||||
this,
|
||||
wxFD_OPEN,
|
||||
FALSE
|
||||
);
|
||||
if( FileName == wxEmptyString )
|
||||
return FALSE;
|
||||
GetScreen()->m_FileName = FileName;
|
||||
}
|
||||
else
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
|
||||
/////////////////////////
|
||||
/* Lecture Fichier PCB */
|
||||
/////////////////////////
|
||||
/////////////////////////
|
||||
/* Lecture Fichier PCB */
|
||||
/////////////////////////
|
||||
|
||||
source = wxFopen(GetScreen()->m_FileName,wxT("rt"));
|
||||
if (source == NULL)
|
||||
{
|
||||
msg.Printf(_("File <%s> not found"),GetScreen()->m_FileName.GetData()) ;
|
||||
DisplayError(this, msg) ;
|
||||
return(0);
|
||||
}
|
||||
source = wxFopen( GetScreen()->m_FileName, wxT( "rt" ) );
|
||||
if( source == NULL )
|
||||
{
|
||||
msg.Printf( _( "File <%s> not found" ), GetScreen()->m_FileName.GetData() );
|
||||
DisplayError( this, msg );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Lecture de l'entete et TEST si PCB format ASCII */
|
||||
GetLine(source, cbuf, &ii );
|
||||
if( strncmp( cbuf, "PCBNEW-BOARD",12) != 0)
|
||||
{
|
||||
fclose(source);
|
||||
DisplayError(this, wxT("Unknown file type"));
|
||||
return(0);
|
||||
}
|
||||
/* Lecture de l'entete et TEST si PCB format ASCII */
|
||||
GetLine( source, cbuf, &ii );
|
||||
if( strncmp( cbuf, "PCBNEW-BOARD", 12 ) != 0 )
|
||||
{
|
||||
fclose( source );
|
||||
DisplayError( this, wxT( "Unknown file type" ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetTitle(GetScreen()->m_FileName);
|
||||
SetLastProject(GetScreen()->m_FileName);
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
SetLastProject( GetScreen()->m_FileName );
|
||||
|
||||
// Rechargement de la configuration:
|
||||
wxSetWorkingDirectory( wxPathOnly(GetScreen()->m_FileName) );
|
||||
if( Append ) ReadPcbFile(DC, source, TRUE);
|
||||
else
|
||||
{
|
||||
Read_Config(GetScreen()->m_FileName);
|
||||
// Rechargement de la configuration:
|
||||
wxSetWorkingDirectory( wxPathOnly( GetScreen()->m_FileName ) );
|
||||
if( Append )
|
||||
ReadPcbFile( DC, source, TRUE );
|
||||
else
|
||||
{
|
||||
Read_Config( GetScreen()->m_FileName );
|
||||
|
||||
// Mise a jour du toolbar d'options
|
||||
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
||||
m_DisplayModText = DisplayOpt.DisplayModText ;
|
||||
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
|
||||
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
|
||||
// Mise a jour du toolbar d'options
|
||||
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
||||
m_DisplayModText = DisplayOpt.DisplayModText;
|
||||
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
|
||||
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
|
||||
|
||||
ReadPcbFile(DC, source, FALSE);
|
||||
}
|
||||
ReadPcbFile( DC, source, FALSE );
|
||||
}
|
||||
|
||||
fclose(source);
|
||||
fclose( source );
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
GetScreen()->ClrModify();
|
||||
|
||||
if( Append )
|
||||
{
|
||||
GetScreen()->SetModify();
|
||||
GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"),
|
||||
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData());
|
||||
}
|
||||
if( Append )
|
||||
{
|
||||
GetScreen()->SetModify();
|
||||
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
|
||||
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData() );
|
||||
}
|
||||
|
||||
/* liste des pads recalculee avec Affichage des messages d'erreur */
|
||||
build_liste_pads();
|
||||
|
||||
/* 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 );
|
||||
|
||||
g_SaveTime = time(NULL);
|
||||
return(1);
|
||||
|
||||
#if defined(DEBUG)
|
||||
// output the board object tree to stdout:
|
||||
m_Pcb->Show( 0, std::cout );
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
bool WinEDA_PcbFrame::SavePcbFile(const wxString & FileName)
|
||||
bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
|
||||
/************************************************************/
|
||||
|
||||
/* Sauvegarde du fichier PCB en format ASCII
|
||||
*/
|
||||
*/
|
||||
{
|
||||
wxString old_name, FullFileName, msg;
|
||||
bool saveok = TRUE;
|
||||
FILE * dest;
|
||||
wxString old_name, FullFileName, msg;
|
||||
bool saveok = TRUE;
|
||||
FILE* dest;
|
||||
|
||||
if( FileName == wxEmptyString )
|
||||
{
|
||||
msg = wxT("*") + PcbExtBuffer;
|
||||
FullFileName = EDA_FileSelector(_("Board files:"),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
GetScreen()->m_FileName, /* nom fichier par defaut */
|
||||
PcbExtBuffer, /* extension par defaut */
|
||||
msg, /* Masque d'affichage */
|
||||
this,
|
||||
wxFD_SAVE,
|
||||
FALSE
|
||||
);
|
||||
if ( FullFileName == wxEmptyString ) return FALSE;
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
}
|
||||
else GetScreen()->m_FileName = FileName;
|
||||
if( FileName == wxEmptyString )
|
||||
{
|
||||
msg = wxT( "*" ) + PcbExtBuffer;
|
||||
FullFileName = EDA_FileSelector( _( "Board files:" ),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
GetScreen()->m_FileName, /* nom fichier par defaut */
|
||||
PcbExtBuffer, /* extension par defaut */
|
||||
msg, /* Masque d'affichage */
|
||||
this,
|
||||
wxFD_SAVE,
|
||||
FALSE
|
||||
);
|
||||
if( FullFileName == wxEmptyString )
|
||||
return FALSE;
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
}
|
||||
else
|
||||
GetScreen()->m_FileName = FileName;
|
||||
|
||||
/* mise a jour date si modifications */
|
||||
if ( GetScreen()->IsModify() )
|
||||
{
|
||||
GetScreen()->m_Date = GenDate();
|
||||
}
|
||||
/* mise a jour date si modifications */
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
GetScreen()->m_Date = GenDate();
|
||||
}
|
||||
|
||||
/* Calcul du nom du fichier a creer */
|
||||
FullFileName = MakeFileName(wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer);
|
||||
/* Calcul du nom du fichier a creer */
|
||||
FullFileName = MakeFileName( wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer );
|
||||
|
||||
/* Calcul du nom du fichier de sauvegarde */
|
||||
old_name = FullFileName;
|
||||
ChangeFileNameExt(old_name,wxT(".000"));
|
||||
/* Calcul du nom du fichier de sauvegarde */
|
||||
old_name = FullFileName;
|
||||
ChangeFileNameExt( old_name, wxT( ".000" ) );
|
||||
|
||||
/* Changement du nom de l'ancien fichier s'il existe */
|
||||
if ( wxFileExists(FullFileName) )
|
||||
{
|
||||
/* conversion en *.000 de l'ancien fichier */
|
||||
wxRemoveFile(old_name); /* S'il y a une ancienne sauvegarde */
|
||||
if( ! wxRenameFile(FullFileName,old_name) )
|
||||
{
|
||||
msg = _("Warning: unable to create bakfile ") + old_name;
|
||||
DisplayError(this, msg, 15) ;
|
||||
saveok = FALSE;
|
||||
}
|
||||
}
|
||||
/* Changement du nom de l'ancien fichier s'il existe */
|
||||
if( wxFileExists( FullFileName ) )
|
||||
{
|
||||
/* conversion en *.000 de l'ancien fichier */
|
||||
wxRemoveFile( old_name ); /* S'il y a une ancienne sauvegarde */
|
||||
if( !wxRenameFile( FullFileName, old_name ) )
|
||||
{
|
||||
msg = _( "Warning: unable to create bakfile " ) + old_name;
|
||||
DisplayError( this, msg, 15 );
|
||||
saveok = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
old_name = wxEmptyString; saveok = FALSE;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
old_name = wxEmptyString; saveok = FALSE;
|
||||
}
|
||||
/* Sauvegarde de l'ancien fichier */
|
||||
dest = wxFopen( FullFileName, wxT( "wt" ) );
|
||||
if( dest == 0 )
|
||||
{
|
||||
msg = _( "Unable to create " ) + FullFileName;
|
||||
DisplayError( this, msg );
|
||||
saveok = FALSE;
|
||||
}
|
||||
|
||||
/* Sauvegarde de l'ancien fichier */
|
||||
dest = wxFopen(FullFileName, wxT("wt"));
|
||||
if (dest == 0)
|
||||
{
|
||||
msg = _("Unable to create ") + FullFileName;
|
||||
DisplayError(this, msg) ;
|
||||
saveok = FALSE;
|
||||
}
|
||||
if( dest )
|
||||
{
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
SavePcbFormatAscii( dest );
|
||||
fclose( dest );
|
||||
}
|
||||
|
||||
if( dest )
|
||||
{
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
SetTitle(GetScreen()->m_FileName);
|
||||
SavePcbFormatAscii(dest);
|
||||
fclose(dest) ;
|
||||
}
|
||||
/* Affichage des fichiers crees: */
|
||||
MsgPanel->EraseMsgBox();
|
||||
|
||||
/* Affichage des fichiers crees: */
|
||||
MsgPanel->EraseMsgBox();
|
||||
if( saveok )
|
||||
{
|
||||
msg = _( "Backup file: " ) + old_name;
|
||||
Affiche_1_Parametre( this, 1, msg, wxEmptyString, CYAN );
|
||||
}
|
||||
|
||||
if( saveok )
|
||||
{
|
||||
msg = _("Backup file: ") + old_name;
|
||||
Affiche_1_Parametre(this, 1,msg, wxEmptyString, CYAN);
|
||||
}
|
||||
if( dest )
|
||||
msg = _( "Write Board file: " );
|
||||
else
|
||||
msg = _( "Failed to create " );
|
||||
msg += FullFileName;
|
||||
|
||||
if ( dest ) msg = _("Write Board file: ");
|
||||
else msg = _("Failed to create ");
|
||||
msg += FullFileName;
|
||||
|
||||
Affiche_1_Parametre(this, 1,wxEmptyString,msg, CYAN);
|
||||
g_SaveTime = time(NULL); /* Reset delai pour sauvegarde automatique */
|
||||
GetScreen()->ClrModify();
|
||||
return TRUE;
|
||||
Affiche_1_Parametre( this, 1, wxEmptyString, msg, CYAN );
|
||||
g_SaveTime = time( NULL ); /* Reset delai pour sauvegarde automatique */
|
||||
GetScreen()->ClrModify();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
1829
pcbnew/ioascii.cpp
1829
pcbnew/ioascii.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue