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,7 +213,7 @@ 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
|
||||
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 );
|
||||
|
@ -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,24 +35,24 @@ 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..)
|
||||
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_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) */
|
||||
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
|
||||
|
@ -67,23 +68,24 @@ public:
|
|||
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 );
|
||||
|
@ -114,21 +116,32 @@ public:
|
|||
|
||||
|
||||
/* 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
|
||||
|
||||
};
|
||||
|
|
240
pcbnew/files.cpp
240
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,30 +11,31 @@
|
|||
|
||||
|
||||
/****************************************************/
|
||||
void WinEDA_PcbFrame::Files_io(wxCommandEvent& event)
|
||||
void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
|
||||
/****************************************************/
|
||||
/* Gestion generale des commandes de lecture de fichiers
|
||||
*/
|
||||
{
|
||||
int id = event.GetId();
|
||||
wxClientDC dc(DrawPanel);
|
||||
wxString msg;
|
||||
|
||||
DrawPanel->PrepareGraphicContext(&dc);
|
||||
/* Gestion generale des commandes de lecture de fichiers
|
||||
*/
|
||||
{
|
||||
int id = event.GetId();
|
||||
wxClientDC dc( DrawPanel );
|
||||
wxString msg;
|
||||
|
||||
DrawPanel->PrepareGraphicContext( &dc );
|
||||
|
||||
// Arret des commandes en cours
|
||||
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
||||
{
|
||||
DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc);
|
||||
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_LOAD_FILE:
|
||||
Clear_Pcb(&dc, TRUE);
|
||||
LoadOnePcbFile(wxEmptyString, &dc, FALSE);
|
||||
Clear_Pcb( &dc, TRUE );
|
||||
LoadOnePcbFile( wxEmptyString, &dc, FALSE );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
break;
|
||||
|
||||
|
@ -42,45 +43,46 @@ wxString msg;
|
|||
case ID_MENU_RECOVER_BOARD:
|
||||
{
|
||||
wxString filename, oldfilename = GetScreen()->m_FileName;
|
||||
if ( id == ID_MENU_RECOVER_BOARD)
|
||||
if( id == ID_MENU_RECOVER_BOARD )
|
||||
{
|
||||
filename = g_SaveFileName + PcbExtBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = oldfilename;
|
||||
ChangeFileNameExt(filename, wxT(".000"));
|
||||
ChangeFileNameExt( filename, wxT( ".000" ) );
|
||||
}
|
||||
if ( ! wxFileExists(filename) )
|
||||
if( !wxFileExists( filename ) )
|
||||
{
|
||||
msg = _("Recovery file ") + filename + _(" not found");
|
||||
DisplayInfo(this, msg);
|
||||
msg = _( "Recovery file " ) + filename + _( " not found" );
|
||||
DisplayInfo( this, msg );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = _("Ok to load Recovery file ") + filename;
|
||||
if ( ! IsOK (this, msg) ) break;
|
||||
msg = _( "Ok to load Recovery file " ) + filename;
|
||||
if( !IsOK( this, msg ) )
|
||||
break;
|
||||
}
|
||||
Clear_Pcb(&dc, TRUE);
|
||||
LoadOnePcbFile(filename, &dc, FALSE);
|
||||
Clear_Pcb( &dc, TRUE );
|
||||
LoadOnePcbFile( filename, &dc, FALSE );
|
||||
GetScreen()->m_FileName = oldfilename;
|
||||
SetTitle(GetScreen()->m_FileName);
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_MENU_APPEND_FILE:
|
||||
case ID_APPEND_FILE:
|
||||
LoadOnePcbFile(wxEmptyString, &dc, TRUE);
|
||||
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);
|
||||
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:
|
||||
|
@ -93,53 +95,53 @@ wxString msg;
|
|||
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);
|
||||
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);
|
||||
SavePcbFile( GetScreen()->m_FileName );
|
||||
break;
|
||||
|
||||
case ID_MENU_SAVE_BOARD_AS:
|
||||
SavePcbFile(wxEmptyString);
|
||||
SavePcbFile( wxEmptyString );
|
||||
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;
|
||||
int ii;
|
||||
FILE* source;
|
||||
wxString msg;
|
||||
|
||||
ActiveScreen = GetScreen();
|
||||
|
||||
if( GetScreen()->IsModify() && !Append )
|
||||
{
|
||||
if( !IsOK(this, _("Board Modified: Continue ?")) )
|
||||
return(0);
|
||||
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_SelTrackWidthBox_Changed = TRUE;
|
||||
|
@ -152,11 +154,11 @@ wxString msg;
|
|||
m_Pcb->m_Status_Pcb = 0;
|
||||
}
|
||||
|
||||
if( FullFileName == wxEmptyString)
|
||||
if( FullFileName == wxEmptyString )
|
||||
{
|
||||
msg = wxT("*") + PcbExtBuffer;
|
||||
msg = wxT( "*" ) + PcbExtBuffer;
|
||||
wxString FileName =
|
||||
EDA_FileSelector(_("Board files:"),
|
||||
EDA_FileSelector( _( "Board files:" ),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
GetScreen()->m_FileName, /* nom fichier par defaut */
|
||||
PcbExtBuffer, /* extension par defaut */
|
||||
|
@ -165,90 +167,98 @@ wxString msg;
|
|||
wxFD_OPEN,
|
||||
FALSE
|
||||
);
|
||||
if ( FileName == wxEmptyString ) return FALSE;
|
||||
if( FileName == wxEmptyString )
|
||||
return FALSE;
|
||||
GetScreen()->m_FileName = FileName;
|
||||
}
|
||||
|
||||
else GetScreen()->m_FileName = FullFileName;
|
||||
else
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
|
||||
/////////////////////////
|
||||
/* 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) ;
|
||||
return(0);
|
||||
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)
|
||||
GetLine( source, cbuf, &ii );
|
||||
if( strncmp( cbuf, "PCBNEW-BOARD", 12 ) != 0 )
|
||||
{
|
||||
fclose(source);
|
||||
DisplayError(this, wxT("Unknown file type"));
|
||||
return(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);
|
||||
wxSetWorkingDirectory( wxPathOnly( GetScreen()->m_FileName ) );
|
||||
if( Append )
|
||||
ReadPcbFile( DC, source, TRUE );
|
||||
else
|
||||
{
|
||||
Read_Config(GetScreen()->m_FileName);
|
||||
Read_Config( GetScreen()->m_FileName );
|
||||
|
||||
// Mise a jour du toolbar d'options
|
||||
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
||||
m_DisplayModText = DisplayOpt.DisplayModText ;
|
||||
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();
|
||||
|
||||
if( Append )
|
||||
{
|
||||
GetScreen()->SetModify();
|
||||
GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"),
|
||||
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData());
|
||||
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
|
||||
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData() );
|
||||
}
|
||||
|
||||
|
||||
/* liste des pads recalculee avec Affichage des messages d'erreur */
|
||||
build_liste_pads();
|
||||
|
||||
Affiche_Infos_Status_Pcb(this);
|
||||
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
|
||||
*/
|
||||
*/
|
||||
{
|
||||
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:"),
|
||||
msg = wxT( "*" ) + PcbExtBuffer;
|
||||
FullFileName = EDA_FileSelector( _( "Board files:" ),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
GetScreen()->m_FileName, /* nom fichier par defaut */
|
||||
PcbExtBuffer, /* extension par defaut */
|
||||
|
@ -257,57 +267,58 @@ FILE * dest;
|
|||
wxFD_SAVE,
|
||||
FALSE
|
||||
);
|
||||
if ( FullFileName == wxEmptyString ) return FALSE;
|
||||
if( FullFileName == wxEmptyString )
|
||||
return FALSE;
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
}
|
||||
else GetScreen()->m_FileName = FileName;
|
||||
else
|
||||
GetScreen()->m_FileName = FileName;
|
||||
|
||||
/* mise a jour date si modifications */
|
||||
if ( GetScreen()->IsModify() )
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
GetScreen()->m_Date = GenDate();
|
||||
}
|
||||
|
||||
/* Calcul du nom du fichier a creer */
|
||||
FullFileName = MakeFileName(wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer);
|
||||
FullFileName = MakeFileName( wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer );
|
||||
|
||||
/* Calcul du nom du fichier de sauvegarde */
|
||||
old_name = FullFileName;
|
||||
ChangeFileNameExt(old_name,wxT(".000"));
|
||||
ChangeFileNameExt( old_name, wxT( ".000" ) );
|
||||
|
||||
/* Changement du nom de l'ancien fichier s'il existe */
|
||||
if ( wxFileExists(FullFileName) )
|
||||
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) )
|
||||
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) ;
|
||||
msg = _( "Warning: unable to create bakfile " ) + old_name;
|
||||
DisplayError( this, msg, 15 );
|
||||
saveok = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
old_name = wxEmptyString; saveok = FALSE;
|
||||
}
|
||||
|
||||
/* Sauvegarde de l'ancien fichier */
|
||||
dest = wxFopen(FullFileName, wxT("wt"));
|
||||
if (dest == 0)
|
||||
dest = wxFopen( FullFileName, wxT( "wt" ) );
|
||||
if( dest == 0 )
|
||||
{
|
||||
msg = _("Unable to create ") + FullFileName;
|
||||
DisplayError(this, msg) ;
|
||||
msg = _( "Unable to create " ) + FullFileName;
|
||||
DisplayError( this, msg );
|
||||
saveok = FALSE;
|
||||
}
|
||||
|
||||
if( dest )
|
||||
{
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
SetTitle(GetScreen()->m_FileName);
|
||||
SavePcbFormatAscii(dest);
|
||||
fclose(dest) ;
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
SavePcbFormatAscii( dest );
|
||||
fclose( dest );
|
||||
}
|
||||
|
||||
/* Affichage des fichiers crees: */
|
||||
|
@ -315,17 +326,18 @@ FILE * dest;
|
|||
|
||||
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 = _( "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 */
|
||||
Affiche_1_Parametre( this, 1, wxEmptyString, msg, CYAN );
|
||||
g_SaveTime = time( NULL ); /* Reset delai pour sauvegarde automatique */
|
||||
GetScreen()->ClrModify();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue