Commit d985f2d6 authored by dickelbeck's avatar dickelbeck

DeleteStructure() & DeleteStructList() consolidation

parent e9921a71
...@@ -5,6 +5,16 @@ Please add newer entries at the top, list the date and your name with ...@@ -5,6 +5,16 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Oct-3 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
made BOARD_ITEM::UnLink() virtual
added BOARD_ITEM::DeleteStructure().
added EDA_BaseStruct::DeleteStructList()
deleted gerbview/struct.cpp, pcbnew/struct.cpp,
BOARD::~BOARD() now deletes objects that it owns.
2007-Oct-2 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Oct-2 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+ all + all
......
...@@ -73,6 +73,23 @@ void EDA_BaseStruct::SetState( int type, int state ) ...@@ -73,6 +73,23 @@ void EDA_BaseStruct::SetState( int type, int state )
} }
/***********************************************************/
void EDA_BaseStruct::DeleteStructList()
/***********************************************************/
{
EDA_BaseStruct* item = this;
EDA_BaseStruct* next;
while( item )
{
next = item->Next();
delete item;
item = next;
}
}
/*********************************************************/ /*********************************************************/
void EDA_BaseStruct::AddToChain( EDA_BaseStruct* laststruct ) void EDA_BaseStruct::AddToChain( EDA_BaseStruct* laststruct )
/*********************************************************/ /*********************************************************/
......
This diff is collapsed.
...@@ -34,10 +34,6 @@ void Set_Rectangle_Encadrement(MODULE * PtModule); ...@@ -34,10 +34,6 @@ void Set_Rectangle_Encadrement(MODULE * PtModule);
/* 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 */
void DeleteStructure( void * GenericStructure );
/* Supprime de la liste chainee la stucture pointee par GenericStructure
et libere la memoire correspondante */
/**************/ /**************/
/* MEMOIRE.CC */ /* MEMOIRE.CC */
/**************/ /**************/
......
...@@ -16,51 +16,60 @@ ...@@ -16,51 +16,60 @@
/*******************************************/ /*******************************************/
void WinEDA_CvpcbFrame::CreateScreenCmp() void WinEDA_CvpcbFrame::CreateScreenCmp()
/*******************************************/ /*******************************************/
/* Creation de la fenetre d'affichage du composant /* Creation de la fenetre d'affichage du composant
*/ */
{ {
wxString msg, FootprintName; wxString msg, FootprintName;
bool IsNew = FALSE; bool IsNew = FALSE;
FootprintName = m_FootprintList->GetSelectedFootprint(); FootprintName = m_FootprintList->GetSelectedFootprint();
if ( DrawFrame == NULL) if( DrawFrame == NULL )
{ {
DrawFrame = new WinEDA_DisplayFrame(this, m_Parent, _("Module"), DrawFrame = new WinEDA_DisplayFrame( this, m_Parent, _( "Module" ),
wxPoint(0,0) , wxSize(600,400) ); wxPoint( 0, 0 ), wxSize( 600, 400 ) );
IsNew = TRUE;
}
else DrawFrame->Maximize(FALSE);
DrawFrame->SetFocus(); /* Active entree clavier */ IsNew = TRUE;
DrawFrame->Show(TRUE); }
else
DrawFrame->Maximize( FALSE );
if( ! FootprintName.IsEmpty() ) DrawFrame->SetFocus(); /* Active entree clavier */
{ DrawFrame->Show( TRUE );
msg = _("Footprint: ") + FootprintName;
DrawFrame->SetTitle(msg);
STOREMOD * Module = GetModuleDescrByName(FootprintName);
msg = _("Lib: ");
if ( Module ) msg += Module->m_LibName;
else msg += wxT("???");
DrawFrame->SetStatusText(msg, 0);
if ( DrawFrame->m_Pcb->m_Modules )
{
DeleteStructure( DrawFrame->m_Pcb->m_Modules );
DrawFrame->m_Pcb->m_Modules = NULL;
}
DrawFrame->m_Pcb->m_Modules = DrawFrame->Get_Module(FootprintName);
DrawFrame->Zoom_Automatique(FALSE);
if ( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay();
}
else if ( !IsNew ) if( !FootprintName.IsEmpty() )
{ {
DrawFrame->ReDrawPanel(); msg = _( "Footprint: " ) + FootprintName;
if ( DrawFrame->m_Draw3DFrame ) DrawFrame->SetTitle( msg );
DrawFrame->m_Draw3DFrame->NewDisplay(); STOREMOD* Module = GetModuleDescrByName( FootprintName );
} msg = _( "Lib: " );
}
if( Module )
msg += Module->m_LibName;
else
msg += wxT( "???" );
DrawFrame->SetStatusText( msg, 0 );
if( DrawFrame->m_Pcb->m_Modules )
{
// there is only one module in the list
DrawFrame->m_Pcb->m_Modules->DeleteStructure();
DrawFrame->m_Pcb->m_Modules = NULL;
}
DrawFrame->m_Pcb->m_Modules = DrawFrame->Get_Module( FootprintName );
DrawFrame->Zoom_Automatique( FALSE );
if( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay();
}
else if( !IsNew )
{
DrawFrame->ReDrawPanel();
if( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay();
}
}
/************************************************/ /************************************************/
/* Routines de visualisation du module courant */ /* Routines de visualisation du module courant */
/************************************************/ /************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -17,160 +17,28 @@ ...@@ -17,160 +17,28 @@
/*******************************************************************/ /*******************************************************************/
void WinEDA_DisplayFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/ /*******************************************************************/
/* Affiche le module courant */ /* Affiche le module courant */
{ {
if (! m_Pcb ) return; if( !m_Pcb )
return;
MODULE * Module= m_Pcb->m_Modules;
ActiveScreen = (PCB_SCREEN *) GetScreen(); MODULE* Module = m_Pcb->m_Modules;
if ( EraseBg ) DrawPanel->EraseScreen(DC); ActiveScreen = (PCB_SCREEN*) GetScreen();
DrawPanel->DrawBackGround(DC); if( EraseBg )
DrawPanel->EraseScreen( DC );
if( Module ) DrawPanel->DrawBackGround( DC );
{
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_COPY);
Module->Display_Infos(this);
}
Affiche_Status_Box(); if( Module )
DrawPanel->Trace_Curseur(DC); {
} Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_COPY );
Module->Display_Infos( this );
}
/***********************************************/
void DeleteStructure( void * GenericStructure )
/***********************************************/
/* Supprime de la liste chainee la stucture pointee par GenericStructure
et libere la memoire correspondante
*/
{
EDA_BaseStruct * PtStruct, *PtNext, *PtBack;
int IsDeleted;
int typestruct;
wxString msg;
PtStruct = (EDA_BaseStruct *) GenericStructure;
if( PtStruct == NULL) return ;
typestruct = (int)PtStruct->Type();
IsDeleted = PtStruct->GetState(DELETED);
PtNext = PtStruct->Pnext;
PtBack = PtStruct->Pback;
switch( typestruct )
{
case TYPE_NOT_INIT:
DisplayError(NULL, wxT("DeleteStruct: Type Structure Non Initialise"));
break;
case PCB_EQUIPOT_STRUCT_TYPE:
#undef Struct
#define Struct ((EQUIPOT*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEMODULE:
#undef Struct
#define Struct ((MODULE*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEPAD:
#undef Struct
#define Struct ((D_PAD*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPECOTATION:
#undef Struct
#define Struct ((COTATION*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEMIRE: Affiche_Status_Box();
#undef Struct DrawPanel->Trace_Curseur( DC );
#define Struct ((MIREPCB*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEDRAWSEGMENT:
#undef Struct
#define Struct ((DRAWSEGMENT*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPETEXTE:
#undef Struct
#define Struct ((TEXTE_PCB*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPETEXTEMODULE:
#undef Struct
#define Struct ((TEXTE_MODULE*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEEDGEMODULE:
#undef Struct
#define Struct ((EDGE_MODULE*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPETRACK:
#undef Struct
#define Struct ((TRACK*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEVIA:
#undef Struct
#define Struct ((SEGVIA*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEZONE:
#undef Struct
#define Struct ((SEGZONE*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEMARQUEUR:
#undef Struct
#define Struct ((MARQUEUR*)PtStruct)
Struct->UnLink();
delete Struct;
break;
case TYPEPCB:
default:
msg.Printf( wxT(" DeleteStructure: Type %d Inattendu"),
PtStruct->Type());
DisplayError(NULL, msg);
break;
}
} }
...@@ -277,9 +277,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -277,9 +277,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) )
{ /* la piste est ici bonne a etre efface */ {
/* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->Draw( DrawPanel, DC, GR_XOR );
DeleteStructure( pt_segm ); pt_segm->DeleteStructure();
} }
} }
...@@ -288,9 +289,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -288,9 +289,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) )
{ /* la piste est ici bonne a etre efface */ {
/* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->Draw( DrawPanel, DC, GR_XOR );
DeleteStructure( pt_segm ); pt_segm->DeleteStructure();
} }
} }
......
...@@ -36,21 +36,21 @@ bool WinEDA_GerberFrame::Clear_Pcb( wxDC* DC, bool query ) ...@@ -36,21 +36,21 @@ bool WinEDA_GerberFrame::Clear_Pcb( wxDC* DC, bool query )
} }
} }
DeleteStructList( m_Pcb->m_Drawings ); m_Pcb->m_Drawings->DeleteStructList();
m_Pcb->m_Drawings = NULL; m_Pcb->m_Drawings = NULL;
DeleteStructList( m_Pcb->m_Track ); m_Pcb->m_Track->DeleteStructList();
m_Pcb->m_Track = NULL; m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0; m_Pcb->m_NbSegmTrack = 0;
DeleteStructList( m_Pcb->m_Zone ); m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL; m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0; m_Pcb->m_NbSegmZone = 0;
for( ; g_UnDeleteStackPtr != 0; ) for( ; g_UnDeleteStackPtr != 0; )
{ {
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
DeleteStructList( g_UnDeleteStack[ g_UnDeleteStackPtr] ); g_UnDeleteStack[ g_UnDeleteStackPtr]->DeleteStructList();
} }
/* init pointeurs et variables */ /* init pointeurs et variables */
...@@ -90,7 +90,7 @@ void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query ) ...@@ -90,7 +90,7 @@ void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query )
if( m_Pcb->m_Zone ) if( m_Pcb->m_Zone )
{ {
DeleteStructList( m_Pcb->m_Zone ); m_Pcb->m_Zone->DeleteStructList( );
m_Pcb->m_Zone = NULL; m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0; m_Pcb->m_NbSegmZone = 0;
} }
...@@ -122,7 +122,7 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC, ...@@ -122,7 +122,7 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC,
case TYPECOTATION: case TYPECOTATION:
case TYPEMIRE: case TYPEMIRE:
if( PtStruct->GetLayer() == layer || layer < 0 ) if( PtStruct->GetLayer() == layer || layer < 0 )
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
break; break;
default: default:
...@@ -158,7 +158,7 @@ void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type, ...@@ -158,7 +158,7 @@ void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type,
PtNext = pt_segm->Next(); PtNext = pt_segm->Next();
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type ) if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
continue; continue;
DeleteStructure( pt_segm ); pt_segm->DeleteStructure();
} }
ScreenPcb->SetModify(); ScreenPcb->SetModify();
...@@ -180,7 +180,7 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query ) ...@@ -180,7 +180,7 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
{ {
PtNext = PtStruct->Next(); PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPETEXTE ) if( PtStruct->Type() == TYPETEXTE )
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
} }
ScreenPcb->SetModify(); ScreenPcb->SetModify();
...@@ -206,7 +206,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( wxDC* DC, bool query ) ...@@ -206,7 +206,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( wxDC* DC, bool query )
PtNext = pt_segm->Next(); PtNext = pt_segm->Next();
if( pt_segm->GetLayer() != layer ) if( pt_segm->GetLayer() != layer )
continue; continue;
DeleteStructure( pt_segm ); pt_segm->DeleteStructure();
} }
ScreenPcb->SetModify(); ScreenPcb->SetModify();
......
...@@ -41,7 +41,6 @@ OBJECTS= \ ...@@ -41,7 +41,6 @@ OBJECTS= \
dcode.o\ dcode.o\
undelete.o\ undelete.o\
infospgm.o \ infospgm.o \
struct.o \
files.o\ files.o\
block.o\ block.o\
controle.o\ controle.o\
...@@ -173,8 +172,6 @@ ioascii.o: ioascii.cpp $(COMMON) ...@@ -173,8 +172,6 @@ ioascii.o: ioascii.cpp $(COMMON)
chrono.o: chrono.cpp pcbnew.h chrono.o: chrono.cpp pcbnew.h
struct.o: struct.cpp $(COMMON)
coordbox.o: coordbox.cpp $(COMMON) coordbox.o: coordbox.cpp $(COMMON)
mirepcb.o: mirepcb.cpp $(COMMON) mirepcb.o: mirepcb.cpp $(COMMON)
......
This diff is collapsed.
...@@ -126,12 +126,6 @@ void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC, ...@@ -126,12 +126,6 @@ void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC,
void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC,
BOARD * Pcb, int drawmode); BOARD * Pcb, int drawmode);
/**************/
/* struct.cpp */
/**************/
void DeleteStructure(EDA_BaseStruct * Struct);
void DeleteStructList( EDA_BaseStruct * Struct);
/*************/ /*************/
/* dcode.cpp */ /* dcode.cpp */
/*************/ /*************/
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
/* Variables locales */ /* Variables locales */
#if 0
/***************************************************/ /***************************************************/
void DeleteStructure( EDA_BaseStruct * PtStruct ) void DeleteStructure( EDA_BaseStruct * PtStruct )
/***************************************************/ /***************************************************/
...@@ -91,3 +93,5 @@ EDA_BaseStruct *PtNext; ...@@ -91,3 +93,5 @@ EDA_BaseStruct *PtNext;
} }
} }
#endif
...@@ -75,7 +75,7 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) ...@@ -75,7 +75,7 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE ) if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
{ {
/* Delete last deleted item, and shift stack. */ /* Delete last deleted item, and shift stack. */
DeleteStructure( g_UnDeleteStack[0] ); g_UnDeleteStack[0]->DeleteStructure();
for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ ) for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
{ {
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1]; g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
......
...@@ -185,7 +185,10 @@ public: ...@@ -185,7 +185,10 @@ public:
KICAD_T Type() const { return m_StructType; } KICAD_T Type() const { return m_StructType; }
EDA_BaseStruct* Next() const { return Pnext; } EDA_BaseStruct* Next() const { return (EDA_BaseStruct*) Pnext; }
EDA_BaseStruct* Back() const { return (EDA_BaseStruct*) Pback; }
EDA_BaseStruct* GetParent() const { return (EDA_BaseStruct*) m_Parent; }
/* Gestion de l'etat (status) de la structure (active, deleted..) */ /* Gestion de l'etat (status) de la structure (active, deleted..) */
int GetState( int type ); int GetState( int type );
...@@ -284,6 +287,14 @@ public: ...@@ -284,6 +287,14 @@ public:
} }
/**
* Function DeleteStructList
* deletes each item in a linked list of EDA_BaseStructs, starting with
* "this" object.
*/
void DeleteStructList();
#if defined(DEBUG) #if defined(DEBUG)
/** /**
...@@ -403,7 +414,6 @@ public: ...@@ -403,7 +414,6 @@ public:
BOARD_ITEM* Next() const { return (BOARD_ITEM*) Pnext; } BOARD_ITEM* Next() const { return (BOARD_ITEM*) Pnext; }
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; } BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; } BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
/** /**
...@@ -443,6 +453,24 @@ public: ...@@ -443,6 +453,24 @@ public:
return false; // only MODULEs can be locked at this time. return false; // only MODULEs can be locked at this time.
} }
/**
* Function UnLink
* detaches this object from its owner.
*/
virtual void UnLink() = 0;
/**
* Function DeleteStructure
* deletes this object after UnLink()ing it from its owner.
*/
void DeleteStructure()
{
UnLink();
delete this;
}
/** /**
* Function MenuText * Function MenuText
......
...@@ -465,7 +465,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -465,7 +465,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
/* le module est ici bon a etre efface */ /* le module est ici bon a etre efface */
module->m_Flags = 0; module->m_Flags = 0;
module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( module ); module->DeleteStructure();
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
} }
} }
...@@ -483,7 +483,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -483,7 +483,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{ {
/* la piste est ici bonne a etre efface */ /* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->Draw( DrawPanel, DC, GR_XOR );
DeleteStructure( pt_segm ); pt_segm->DeleteStructure();
} }
} }
} }
...@@ -512,7 +512,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -512,7 +512,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR ); Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR );
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
break; break;
case TYPETEXTE: case TYPETEXTE:
...@@ -523,7 +523,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -523,7 +523,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
/* le texte est ici bon a etre efface */ /* le texte est ici bon a etre efface */
( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Suppression du texte en Memoire*/ /* Suppression du texte en Memoire*/
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
break; break;
case TYPEMIRE: case TYPEMIRE:
...@@ -535,7 +535,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -535,7 +535,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
break; break;
case TYPECOTATION: case TYPECOTATION:
...@@ -547,7 +547,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -547,7 +547,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
break; break;
default: default:
...@@ -565,9 +565,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -565,9 +565,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) )
{ /* la piste est ici bonne a etre efface */ {
/* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->Draw( DrawPanel, DC, GR_XOR );
DeleteStructure( pt_segm ); PtStruct->DeleteStructure();
} }
} }
} }
......
...@@ -533,7 +533,7 @@ void DeleteMarkedItems( MODULE* module ) ...@@ -533,7 +533,7 @@ void DeleteMarkedItems( MODULE* module )
next_pad = pad->Next(); next_pad = pad->Next();
if( pad->m_Selected == 0 ) if( pad->m_Selected == 0 )
continue; continue;
DeleteStructure( pad ); pad->DeleteStructure();
} }
item = module->m_Drawings; item = module->m_Drawings;
...@@ -542,7 +542,7 @@ void DeleteMarkedItems( MODULE* module ) ...@@ -542,7 +542,7 @@ void DeleteMarkedItems( MODULE* module )
next_item = item->Next(); next_item = item->Next();
if( item->m_Selected == 0 ) if( item->m_Selected == 0 )
continue; continue;
DeleteStructure( item ); item->DeleteStructure();
} }
} }
......
...@@ -48,6 +48,32 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) : ...@@ -48,6 +48,32 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
/***************/ /***************/
BOARD::~BOARD() BOARD::~BOARD()
{ {
m_Drawings->DeleteStructList();
m_Drawings = 0;
m_Modules->DeleteStructList();
m_Modules = 0;
m_Equipots->DeleteStructList();
m_Equipots = 0;
m_Track->DeleteStructList();
m_Track = 0;
m_Zone->DeleteStructList();
m_Zone = 0;
m_CurrentLimitZone->DeleteStructList();
m_CurrentLimitZone = 0;
MyFree( m_Pads );
m_Pads = 0;
MyFree( m_Ratsnest );
m_Ratsnest = 0;
MyFree( m_LocalRatsnest );
m_LocalRatsnest = 0;
} }
......
...@@ -279,3 +279,4 @@ const char** BOARD_ITEM::MenuIcon() const ...@@ -279,3 +279,4 @@ const char** BOARD_ITEM::MenuIcon() const
return (const char**) xpm; return (const char**) xpm;
} }
...@@ -300,7 +300,7 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC ) ...@@ -300,7 +300,7 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
/* Suppression du segment */ /* Suppression du segment */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR ); PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure( PtSegm ); PtSegm->DeleteStructure();
if( NextS == NULL ) if( NextS == NULL )
break; break;
} }
...@@ -340,7 +340,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) ...@@ -340,7 +340,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/* Lenght segment = 0; delete it */ /* Lenght segment = 0; delete it */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR ); PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure( PtSegm ); PtSegm->DeleteStructure();
nbpoints_supprimes++; nbpoints_supprimes++;
msg.Printf( wxT( " %d" ), nbpoints_supprimes ); msg.Printf( wxT( " %d" ), nbpoints_supprimes );
...@@ -402,7 +402,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) ...@@ -402,7 +402,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
{ {
ii--; ii--;
pt_aux->Draw( frame->DrawPanel, DC, GR_OR ); pt_aux->Draw( frame->DrawPanel, DC, GR_OR );
DeleteStructure( pt_aux ); pt_aux->DeleteStructure();
nbpoints_supprimes++; nbpoints_supprimes++;
msg.Printf( wxT( " %d" ), nbpoints_supprimes ); msg.Printf( wxT( " %d" ), nbpoints_supprimes );
...@@ -482,7 +482,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) ...@@ -482,7 +482,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
if( pt_segm_delete ) if( pt_segm_delete )
{ {
nbpoints_supprimes++; no_inc = 1; nbpoints_supprimes++; no_inc = 1;
DeleteStructure( pt_segm_delete ); pt_segm_delete->DeleteStructure();
} }
} }
...@@ -519,7 +519,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) ...@@ -519,7 +519,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
if( pt_segm_delete ) if( pt_segm_delete )
{ {
nbpoints_supprimes++; no_inc = 1; nbpoints_supprimes++; no_inc = 1;
DeleteStructure( pt_segm_delete ); pt_segm_delete->DeleteStructure();
} }
} }
......
...@@ -128,7 +128,7 @@ wxDC * DC = Cmd->DC; ...@@ -128,7 +128,7 @@ wxDC * DC = Cmd->DC;
for ( ; ii > 0; ii --, pt_track = NextS) for ( ; ii > 0; ii --, pt_track = NextS)
{ {
NextS = (TRACK*) pt_track->Pnext; NextS = (TRACK*) pt_track->Pnext;
DeleteStructure(pt_track); pt_track->DeleteStructure();
} }
test_1_net_connexion(DC, old_net_code ); test_1_net_connexion(DC, old_net_code );
} }
......
...@@ -208,7 +208,7 @@ static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -208,7 +208,7 @@ static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC )
if( Cotation->m_Flags & IS_NEW ) if( Cotation->m_Flags & IS_NEW )
{ {
Cotation->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); Cotation->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Cotation ); Cotation ->DeleteStructure();
} }
else else
{ {
...@@ -378,7 +378,7 @@ void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC ) ...@@ -378,7 +378,7 @@ void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC )
if( DC ) if( DC )
Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Cotation ); Cotation ->DeleteStructure();
m_CurrentScreen->SetModify(); m_CurrentScreen->SetModify();
} }
......
...@@ -128,7 +128,7 @@ void WinEDA_DrcFrame::CreateControls() ...@@ -128,7 +128,7 @@ void WinEDA_DrcFrame::CreateControls()
SetFont(*g_DialogFont); SetFont(*g_DialogFont);
////@begin WinEDA_DrcFrame content construction ////@begin WinEDA_DrcFrame content construction
// Generated by DialogBlocks, 20/08/2007 08:58:05 (unregistered) // Generated by DialogBlocks, Tue 02 Oct 2007 16:31:47 CDT (unregistered)
WinEDA_DrcFrame* itemDialog1 = this; WinEDA_DrcFrame* itemDialog1 = this;
...@@ -215,7 +215,7 @@ void WinEDA_DrcFrame::CreateControls() ...@@ -215,7 +215,7 @@ void WinEDA_DrcFrame::CreateControls()
wxStaticText* itemStaticText25 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* itemStaticText25 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
m_MainSizer->Add(itemStaticText25, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); m_MainSizer->Add(itemStaticText25, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_logWindow = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE|wxTE_READONLY ); m_logWindow = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 300), wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxFULL_REPAINT_ON_RESIZE );
m_MainSizer->Add(m_logWindow, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); m_MainSizer->Add(m_logWindow, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
// Set validators // Set validators
...@@ -228,6 +228,9 @@ void WinEDA_DrcFrame::CreateControls() ...@@ -228,6 +228,9 @@ void WinEDA_DrcFrame::CreateControls()
AddUnitSymbol(*m_ClearenceTitle); AddUnitSymbol(*m_ClearenceTitle);
m_RptFilenameCtrl->SetValue(s_RptFilename); m_RptFilenameCtrl->SetValue(s_RptFilename);
// capture the text control's events, all of them.
// m_logWindow->PushEventHandler( this );
} }
/*! /*!
...@@ -359,3 +362,52 @@ wxString FileName, Mask(wxT("*")), Ext(wxT(".rpt")); ...@@ -359,3 +362,52 @@ wxString FileName, Mask(wxT("*")), Ext(wxT(".rpt"));
s_RptFilename = FileName; s_RptFilename = FileName;
} }
/*!
* Override the event handler so we can direct the m_lowWindows events here initially
*/
bool WinEDA_DrcFrame::ProcessEvent( wxEvent& event )
{
int id = event.GetId();
if( id == ID_TEXTCTRL )
{
//printf("ID_TEXTCTRL\n");
// this does not work yet
if( event.GetEventType() == wxMOUSE_BTN_LEFT )
{
wxMouseEvent& mouseEvent = (wxMouseEvent&) event;
if( mouseEvent.LeftUp() )
{
wxTextCoord col;
wxTextCoord row;
wxPoint pos = mouseEvent.GetPosition();
if( wxTE_HT_UNKNOWN != m_logWindow->HitTest( pos, &col, &row ) )
{
wxString text = m_logWindow->GetLineText( row );
int debug = 1;
}
}
}
return false;
}
else
{
bool ret;
// printf("ProcessEvent(%d)\n", id);
ret = static_cast<wxDialog*>(this)->wxDialog::ProcessEvent( event );
// printf("~ProcessEvent\n");
return ret;
}
}
...@@ -52,7 +52,7 @@ class wxBoxSizer; ...@@ -52,7 +52,7 @@ class wxBoxSizer;
#define ID_BUTTON_BROWSE_RPT_FILE 10011 #define ID_BUTTON_BROWSE_RPT_FILE 10011
#define ID_TEXTCTRL_GET_RPT_FILENAME 10010 #define ID_TEXTCTRL_GET_RPT_FILENAME 10010
#define ID_TEXTCTRL 10001 #define ID_TEXTCTRL 10001
#define SYMBOL_WINEDA_DRCFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER #define SYMBOL_WINEDA_DRCFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WINEDA_DRCFRAME_TITLE _("DRC Control") #define SYMBOL_WINEDA_DRCFRAME_TITLE _("DRC Control")
#define SYMBOL_WINEDA_DRCFRAME_IDNAME ID_DIALOG #define SYMBOL_WINEDA_DRCFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_DRCFRAME_SIZE wxSize(400, 300) #define SYMBOL_WINEDA_DRCFRAME_SIZE wxSize(400, 300)
...@@ -88,6 +88,9 @@ public: ...@@ -88,6 +88,9 @@ public:
/// Creates the controls and sizers /// Creates the controls and sizers
void CreateControls(); void CreateControls();
/// Override the event handler so we can direct the m_lowWindows events here initially
virtual bool ProcessEvent( wxEvent& event );
////@begin WinEDA_DrcFrame event handler declarations ////@begin WinEDA_DrcFrame event handler declarations
/// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG
......
This diff is collapsed.
...@@ -286,7 +286,7 @@ void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -286,7 +286,7 @@ void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* suppression d'un segment */ /* suppression d'un segment */
DeleteStructure( Edge ); Edge ->DeleteStructure();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -307,7 +307,7 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -307,7 +307,7 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
MODULE* Module = (MODULE*) Edge->m_Parent; MODULE* Module = (MODULE*) Edge->m_Parent;
Edge->Draw( Panel, DC, MoveVector, GR_XOR ); Edge->Draw( Panel, DC, MoveVector, GR_XOR );
DeleteStructure( Edge ); Edge ->DeleteStructure();
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
} }
else else
...@@ -435,7 +435,7 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -435,7 +435,7 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
if( (Edge->m_Start.x == Edge->m_End.x) if( (Edge->m_Start.x == Edge->m_End.x)
&& (Edge->m_Start.y == Edge->m_End.y) ) && (Edge->m_Start.y == Edge->m_End.y) )
{ {
DeleteStructure( Edge ); Edge ->DeleteStructure();
} }
} }
Edge->m_Flags = 0; Edge->m_Flags = 0;
......
...@@ -109,7 +109,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -109,7 +109,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
DisplayOpt.DisplayDrawItems = SKETCH; DisplayOpt.DisplayDrawItems = SKETCH;
Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_XOR ); Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_XOR );
PtStruct = Segment->Pback; PtStruct = Segment->Pback;
DeleteStructure( Segment ); Segment ->DeleteStructure();
if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) ) if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) )
Segment = (DRAWSEGMENT*) PtStruct; Segment = (DRAWSEGMENT*) PtStruct;
DisplayOpt.DisplayDrawItems = track_fill_copy; DisplayOpt.DisplayDrawItems = track_fill_copy;
...@@ -119,7 +119,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -119,7 +119,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
{ {
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_XOR ); Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_XOR );
Segment->m_Flags = 0; Segment->m_Flags = 0;
DeleteStructure( Segment ); Segment ->DeleteStructure();
SetCurItem( NULL ); SetCurItem( NULL );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
...@@ -191,7 +191,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -191,7 +191,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( pt_segm->GetLayer() == layer ) if( pt_segm->GetLayer() == layer )
{ {
Trace_DrawSegmentPcb( DrawPanel, DC, pt_segm, GR_XOR ); Trace_DrawSegmentPcb( DrawPanel, DC, pt_segm, GR_XOR );
DeleteStructure( PtStruct ); PtStruct ->DeleteStructure();
} }
break; break;
...@@ -200,7 +200,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -200,7 +200,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( pt_txt->GetLayer() == layer ) if( pt_txt->GetLayer() == layer )
{ {
pt_txt->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); pt_txt->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct ); PtStruct ->DeleteStructure();
} }
break; break;
...@@ -210,7 +210,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -210,7 +210,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( Cotation->GetLayer() == layer ) if( Cotation->GetLayer() == layer )
{ {
Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct ); PtStruct ->DeleteStructure();
} }
break; break;
...@@ -234,7 +234,7 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -234,7 +234,7 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
if( Segment->m_Flags & IS_NEW ) if( Segment->m_Flags & IS_NEW )
{ {
Panel->ManageCurseur( Panel, DC, FALSE ); Panel->ManageCurseur( Panel, DC, FALSE );
DeleteStructure( Segment ); Segment ->DeleteStructure();
Segment = NULL; Segment = NULL;
} }
else else
...@@ -338,7 +338,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -338,7 +338,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
/* Effacement si Longueur nulle */ /* Effacement si Longueur nulle */
if( (Segment->m_Start.x == Segment->m_End.x) if( (Segment->m_Start.x == Segment->m_End.x)
&& (Segment->m_Start.y == Segment->m_End.y) ) && (Segment->m_Start.y == Segment->m_End.y) )
DeleteStructure( Segment ); Segment ->DeleteStructure();
else else
{ {
......
...@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text, wxDC* DC )
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* liberation de la memoire : */ /* liberation de la memoire : */
DeleteStructure( Text ); Text ->DeleteStructure();
GetScreen()->SetModify(); GetScreen()->SetModify();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
} }
......
...@@ -129,28 +129,29 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query ) ...@@ -129,28 +129,29 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
} }
/* Suppression des listes chainees */ /* Suppression des listes chainees */
DeleteStructList( m_Pcb->m_Equipots ); m_Pcb->m_Equipots->DeleteStructList();
m_Pcb->m_Equipots = NULL; m_Pcb->m_Equipots = NULL;
DeleteStructList( m_Pcb->m_Drawings ); m_Pcb->m_Drawings->DeleteStructList();
m_Pcb->m_Drawings = NULL; m_Pcb->m_Drawings = NULL;
DeleteStructList( m_Pcb->m_Modules ); m_Pcb->m_Modules->DeleteStructList();
m_Pcb->m_Modules = NULL; m_Pcb->m_Modules = NULL;
DeleteStructList( m_Pcb->m_Track ); m_Pcb->m_Track->DeleteStructList();
m_Pcb->m_Track = NULL; m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0; m_Pcb->m_NbSegmTrack = 0;
DeleteStructList( m_Pcb->m_Zone ); m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL; m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0; m_Pcb->m_NbSegmZone = 0;
DelLimitesZone( DC, FALSE ); DelLimitesZone( DC, FALSE );
for( ; g_UnDeleteStackPtr != 0; ) for( ; g_UnDeleteStackPtr != 0; )
{ {
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
DeleteStructList( g_UnDeleteStack[g_UnDeleteStackPtr] ); g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList();
} }
/* init pointeurs et variables */ /* init pointeurs et variables */
...@@ -214,11 +215,11 @@ void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query ) ...@@ -214,11 +215,11 @@ void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query )
if( m_Pcb->m_Zone ) if( m_Pcb->m_Zone )
{ {
while( m_Pcb->m_Zone ) m_Pcb->m_Zone->DeleteStructList();
DeleteStructure( m_Pcb->m_Zone ); m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0; m_Pcb->m_NbSegmZone = 0;
} }
DelLimitesZone( DC, FALSE ); DelLimitesZone( DC, FALSE );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -257,7 +258,7 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query ) ...@@ -257,7 +258,7 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query )
case TYPECOTATION: case TYPECOTATION:
case TYPEMIRE: case TYPEMIRE:
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer ) if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
DeleteStructure( PtStruct ); PtStruct->DeleteStructure();
break; break;
default: default:
...@@ -280,8 +281,8 @@ void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query ) ...@@ -280,8 +281,8 @@ void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query )
* Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 * Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1
*/ */
{ {
TRACK* pt_segm; TRACK* pt_segm;
EDA_BaseStruct* PtNext; TRACK* PtNext;
if( query && !IsOK( this, _( "Delete Tracks?" ) ) ) if( query && !IsOK( this, _( "Delete Tracks?" ) ) )
return; return;
...@@ -289,10 +290,12 @@ void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query ) ...@@ -289,10 +290,12 @@ void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query )
/* Marquage des pistes a effacer */ /* Marquage des pistes a effacer */
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext ) for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext )
{ {
PtNext = pt_segm->Pnext; PtNext = (TRACK*) pt_segm->Pnext;
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type ) if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
continue; continue;
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -307,8 +310,8 @@ void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query ) ...@@ -307,8 +310,8 @@ void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query )
if( query && !IsOK( this, _( "Delete Modules?" ) ) ) if( query && !IsOK( this, _( "Delete Modules?" ) ) )
return; return;
while( m_Pcb->m_Modules ) m_Pcb->m_Modules->DeleteStructList();
DeleteStructure( m_Pcb->m_Modules ); m_Pcb->m_Modules = 0;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
m_Pcb->m_NbNets = 0; m_Pcb->m_NbNets = 0;
...@@ -335,7 +338,7 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query ) ...@@ -335,7 +338,7 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
{ {
PtNext = PtStruct->Next(); PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPETEXTE ) if( PtStruct->Type() == TYPETEXTE )
DeleteStructure( PtStruct ); PtStruct ->DeleteStructure();
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -353,7 +356,7 @@ void WinEDA_PcbFrame::Erase_Marqueurs() ...@@ -353,7 +356,7 @@ void WinEDA_PcbFrame::Erase_Marqueurs()
{ {
PtNext = PtStruct->Next(); PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPEMARQUEUR ) if( PtStruct->Type() == TYPEMARQUEUR )
DeleteStructure( PtStruct ); PtStruct ->DeleteStructure();
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
......
...@@ -86,7 +86,7 @@ OBJECTS= $(TARGET).o classpcb.o\ ...@@ -86,7 +86,7 @@ OBJECTS= $(TARGET).o classpcb.o\
zones.o undelete.o \ zones.o undelete.o \
copy_track.o\ copy_track.o\
move_or_drag_track.o\ move_or_drag_track.o\
ioascii.o struct.o \ ioascii.o \
mirepcb.o xchgmod.o\ mirepcb.o xchgmod.o\
plotps.o\ plotps.o\
dragsegm.o\ dragsegm.o\
...@@ -282,8 +282,6 @@ copy_track.o: copy_track.cpp $(COMMON) ...@@ -282,8 +282,6 @@ copy_track.o: copy_track.cpp $(COMMON)
ioascii.o: ioascii.cpp $(COMMON) ioascii.o: ioascii.cpp $(COMMON)
struct.o: struct.cpp $(COMMON)
coordbox.o: coordbox.cpp $(COMMON) coordbox.o: coordbox.cpp $(COMMON)
mirepcb.o: mirepcb.cpp $(COMMON) mirepcb.o: mirepcb.cpp $(COMMON)
......
...@@ -168,7 +168,7 @@ void WinEDA_PcbFrame::Delete_Mire( MIREPCB* MirePcb, wxDC* DC ) ...@@ -168,7 +168,7 @@ void WinEDA_PcbFrame::Delete_Mire( MIREPCB* MirePcb, wxDC* DC )
return; return;
MirePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); MirePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( MirePcb ); MirePcb ->DeleteStructure();
} }
...@@ -190,7 +190,7 @@ static void Exit_EditMire( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -190,7 +190,7 @@ static void Exit_EditMire( WinEDA_DrawPanel* Panel, wxDC* DC )
if( MirePcb->m_Flags & IS_NEW ) if( MirePcb->m_Flags & IS_NEW )
{ {
MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( MirePcb ); MirePcb ->DeleteStructure();
MirePcb = NULL; MirePcb = NULL;
} }
else /* Ancienne mire en deplacement: Remise en ancienne position */ else /* Ancienne mire en deplacement: Remise en ancienne position */
......
...@@ -180,7 +180,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -180,7 +180,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
if( module->m_Flags & IS_NEW ) if( module->m_Flags & IS_NEW )
{ {
DeleteStructure( module ); module ->DeleteStructure();
module = NULL; module = NULL;
pcbframe->m_Pcb->m_Status_Pcb = 0; pcbframe->m_Pcb->m_Status_Pcb = 0;
pcbframe->build_liste_pads(); pcbframe->build_liste_pads();
......
...@@ -256,7 +256,7 @@ wxString line; ...@@ -256,7 +256,7 @@ wxString line;
if ( DC ) Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR); if ( DC ) Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR);
DeleteStructure(Pad); Pad->DeleteStructure();
/* Redessin du module */ /* Redessin du module */
if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR); if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR);
......
...@@ -390,7 +390,7 @@ void WinEDA_PcbFrame::Place_Dupl_Route( Track* Track, wxDC* DC ) ...@@ -390,7 +390,7 @@ void WinEDA_PcbFrame::Place_Dupl_Route( Track* Track, wxDC* DC )
for( ; ii > 0; ii--, pt_track = NextS ) for( ; ii > 0; ii--, pt_track = NextS )
{ {
NextS = (TRACK*) pt_track->Pnext; NextS = (TRACK*) pt_track->Pnext;
DeleteStructure( pt_track ); pt_track ->DeleteStructure();
} }
test_1_net_connexion( DC, old_net_code ); test_1_net_connexion( DC, old_net_code );
......
...@@ -103,7 +103,7 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC ) ...@@ -103,7 +103,7 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
if( Module->m_Flags & IS_NEW ) if( Module->m_Flags & IS_NEW )
{ {
Module->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); Module->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Module ); Module ->DeleteStructure();
} }
else else
{ {
......
...@@ -329,7 +329,7 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -329,7 +329,7 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Suppression du texte en Memoire*/ /* Suppression du texte en Memoire*/
DeleteStructure( TextePcb ); TextePcb ->DeleteStructure();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL ); SetCurItem( NULL );
...@@ -365,7 +365,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) ...@@ -365,7 +365,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC )
InstallTextPCBOptionsFrame( TextePcb, DC, TextePcb->m_Pos ); InstallTextPCBOptionsFrame( TextePcb, DC, TextePcb->m_Pos );
if( TextePcb->m_Text.IsEmpty() ) if( TextePcb->m_Text.IsEmpty() )
{ {
DeleteStructure( TextePcb ); TextePcb ->DeleteStructure();
TextePcb = NULL; TextePcb = NULL;
} }
else else
......
...@@ -372,12 +372,6 @@ TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm); ...@@ -372,12 +372,6 @@ TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm);
/****************/ /****************/
void RemoteCommand( const char* cmdline ); void RemoteCommand( const char* cmdline );
/*************/
/* STRUCT.CPP */
/*************/
void DeleteStructure( BOARD_ITEM* Struct );
void DeleteStructList( BOARD_ITEM* Struct );
/***************/ /***************/
/* AUTOPLACE.CPP */ /* AUTOPLACE.CPP */
......
...@@ -801,7 +801,7 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() ...@@ -801,7 +801,7 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code()
while( pt_equipot ) while( pt_equipot )
{ {
PtStruct = pt_equipot->Pnext; PtStruct = pt_equipot->Pnext;
DeleteStructure( pt_equipot ); pt_equipot ->DeleteStructure();
pt_equipot = (EQUIPOT*) PtStruct; pt_equipot = (EQUIPOT*) PtStruct;
} }
......
/***********************************************/
/* Routines d'effacement et copie de structures*/
/***********************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
/* Routines Locales */
/* Variables locales */
/**************************************************/
void DeleteStructure( BOARD_ITEM* PtStruct )
/**************************************************/
/* Supprime de la liste chainee la stucture pointee par GenericStructure
* et libere la memoire correspondante
*/
{
BOARD_ITEM* PtNext;
BOARD_ITEM* PtBack;
int IsDeleted;
wxString Line;
if( PtStruct == NULL )
return;
IsDeleted = PtStruct->GetState( DELETED );
PtNext = PtStruct->Next();
PtBack = PtStruct->Back();
KICAD_T typestruct = PtStruct->Type();
switch( typestruct )
{
case TYPE_NOT_INIT:
DisplayError( NULL, wxT( "DeleteStruct: Type Not Init" ) );
break;
case PCB_EQUIPOT_STRUCT_TYPE:
#undef Struct
#define Struct ( (EQUIPOT*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEMODULE:
#undef Struct
#define Struct ( (MODULE*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEPAD:
#undef Struct
#define Struct ( (D_PAD*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPECOTATION:
#undef Struct
#define Struct ( (COTATION*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEMIRE:
#undef Struct
#define Struct ( (MIREPCB*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEDRAWSEGMENT:
#undef Struct
#define Struct ( (DRAWSEGMENT*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPETEXTE:
#undef Struct
#define Struct ( (TEXTE_PCB*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPETEXTEMODULE:
#undef Struct
#define Struct ( (TEXTE_MODULE*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEEDGEMODULE:
#undef Struct
#define Struct ( (EDGE_MODULE*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPETRACK:
#undef Struct
#define Struct ( (TRACK*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEVIA:
#undef Struct
#define Struct ( (SEGVIA*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEZONE:
#undef Struct
#define Struct ( (SEGZONE*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEMARQUEUR:
#undef Struct
#define Struct ( (MARQUEUR*) PtStruct )
Struct->UnLink();
delete Struct;
break;
case TYPEPCB:
default:
Line.Printf( wxT( " DeleteStructure: unexpected Type %d" ),
PtStruct->Type() );
DisplayError( NULL, Line );
break;
}
}
/**************************************************/
void DeleteStructList( BOARD_ITEM* PtStruct )
/**************************************************/
/* Supprime la liste chainee pointee par PtStruct
* et libere la memoire correspondante
*/
{
BOARD_ITEM* PtNext;
while( PtStruct )
{
PtNext = PtStruct->Next();
delete PtStruct;
PtStruct = PtNext;
}
}
/***********************************************/
/* Routines d'effacement et copie de structures*/
/***********************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#if 0
/* Routines Locales */
/* Variables locales */
/***********************************************/
void DeleteStructure( BOARD_ITEM* item )
/***********************************************/
/* Supprime de la liste chainee la stucture pointee par GenericStructure
et libere la memoire correspondante
*/
{
if( !item )
return;
switch( item->Type() )
{
case TYPE_NOT_INIT:
DisplayError(NULL, wxT("DeleteStruct: Type Structure Non Initialise"));
break;
case PCB_EQUIPOT_STRUCT_TYPE:
case TYPEMODULE:
case TYPEPAD:
case TYPECOTATION:
case TYPEMIRE:
case TYPEDRAWSEGMENT:
case TYPETEXTE:
case TYPETEXTEMODULE:
case TYPEEDGEMODULE:
case TYPETRACK:
case TYPEVIA:
case TYPEZONE:
case TYPEMARQUEUR:
item->UnLink();
delete item;
break;
default:
{
wxString msg;
msg.Printf( wxT(" DeleteStructure: Type %d Inattendu"), item->Type() );
DisplayError(NULL, msg);
}
}
}
#endif
...@@ -180,7 +180,7 @@ TRACK * BufDeb, *BufEnd; /* Pointeurs de debut et de fin de la zone ...@@ -180,7 +180,7 @@ TRACK * BufDeb, *BufEnd; /* Pointeurs de debut et de fin de la zone
for ( jj = 0; jj < nb_segm; jj++, pt_del = NextS) for ( jj = 0; jj < nb_segm; jj++, pt_del = NextS)
{ {
NextS = (TRACK*) pt_del->Pnext; NextS = (TRACK*) pt_del->Pnext;
DeleteStructure(pt_del); pt_del->DeleteStructure();
} }
/* nettoyage des flags */ /* nettoyage des flags */
for(pt_del = Pcb->m_Track; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext) for(pt_del = Pcb->m_Track; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext)
......
...@@ -103,7 +103,7 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) ...@@ -103,7 +103,7 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE ) if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
{ {
/* Delete last deleted item, and shift stack. */ /* Delete last deleted item, and shift stack. */
DeleteStructList( g_UnDeleteStack[0] ); g_UnDeleteStack[0]->DeleteStructList();
for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ ) for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
{ {
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1]; g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
......
...@@ -573,7 +573,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, ...@@ -573,7 +573,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff,
} }
/* Effacement de l'ancien module */ /* Effacement de l'ancien module */
DeleteStructure( OldModule ); OldModule ->DeleteStructure();
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
NewModule->m_Flags = 0; NewModule->m_Flags = 0;
......
...@@ -461,7 +461,7 @@ void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* Zone ) ...@@ -461,7 +461,7 @@ void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* Zone )
modify = TRUE; modify = TRUE;
/* effacement des segments a l'ecran */ /* effacement des segments a l'ecran */
Trace_Une_Piste( DrawPanel, DC, pt_segm, nb_segm, GR_XOR ); Trace_Une_Piste( DrawPanel, DC, pt_segm, nb_segm, GR_XOR );
DeleteStructure( pt_segm ); pt_segm ->DeleteStructure();
} }
} }
......
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