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
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>
================================================================================
+ all
......
......@@ -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 )
/*********************************************************/
......
This diff is collapsed.
......@@ -34,10 +34,6 @@ void Set_Rectangle_Encadrement(MODULE * PtModule);
/* Mise a jour du rectangle d'encadrement du 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 */
/**************/
......
......@@ -16,51 +16,60 @@
/*******************************************/
void WinEDA_CvpcbFrame::CreateScreenCmp()
/*******************************************/
/* Creation de la fenetre d'affichage du composant
*/
*/
{
wxString msg, FootprintName;
bool IsNew = FALSE;
wxString msg, FootprintName;
bool IsNew = FALSE;
FootprintName = m_FootprintList->GetSelectedFootprint();
FootprintName = m_FootprintList->GetSelectedFootprint();
if ( DrawFrame == NULL)
{
DrawFrame = new WinEDA_DisplayFrame(this, m_Parent, _("Module"),
wxPoint(0,0) , wxSize(600,400) );
IsNew = TRUE;
}
else DrawFrame->Maximize(FALSE);
if( DrawFrame == NULL )
{
DrawFrame = new WinEDA_DisplayFrame( this, m_Parent, _( "Module" ),
wxPoint( 0, 0 ), wxSize( 600, 400 ) );
DrawFrame->SetFocus(); /* Active entree clavier */
DrawFrame->Show(TRUE);
IsNew = TRUE;
}
else
DrawFrame->Maximize( FALSE );
if( ! FootprintName.IsEmpty() )
{
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();
}
DrawFrame->SetFocus(); /* Active entree clavier */
DrawFrame->Show( TRUE );
else if ( !IsNew )
{
DrawFrame->ReDrawPanel();
if ( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay();
}
}
if( !FootprintName.IsEmpty() )
{
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 )
{
// 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"
......@@ -17,160 +17,28 @@
/*******************************************************************/
void WinEDA_DisplayFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg)
void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/
/* Affiche le module courant */
{
if (! m_Pcb ) return;
MODULE * Module= m_Pcb->m_Modules;
if( !m_Pcb )
return;
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 )
{
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_COPY);
Module->Display_Infos(this);
}
DrawPanel->DrawBackGround( DC );
Affiche_Status_Box();
DrawPanel->Trace_Curseur(DC);
}
/***********************************************/
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;
if( Module )
{
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_COPY );
Module->Display_Infos( this );
}
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:
msg.Printf( wxT(" DeleteStructure: Type %d Inattendu"),
PtStruct->Type());
DisplayError(NULL, msg);
break;
}
Affiche_Status_Box();
DrawPanel->Trace_Curseur( DC );
}
......@@ -277,9 +277,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{
NextS = pt_segm->Next();
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 );
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
}
}
......@@ -288,9 +289,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{
NextS = pt_segm->Next();
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 );
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
}
}
......
......@@ -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;
DeleteStructList( m_Pcb->m_Track );
m_Pcb->m_Track->DeleteStructList();
m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0;
DeleteStructList( m_Pcb->m_Zone );
m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
for( ; g_UnDeleteStackPtr != 0; )
{
g_UnDeleteStackPtr--;
DeleteStructList( g_UnDeleteStack[ g_UnDeleteStackPtr] );
g_UnDeleteStack[ g_UnDeleteStackPtr]->DeleteStructList();
}
/* init pointeurs et variables */
......@@ -90,7 +90,7 @@ void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query )
if( m_Pcb->m_Zone )
{
DeleteStructList( m_Pcb->m_Zone );
m_Pcb->m_Zone->DeleteStructList( );
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
}
......@@ -122,7 +122,7 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC,
case TYPECOTATION:
case TYPEMIRE:
if( PtStruct->GetLayer() == layer || layer < 0 )
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
break;
default:
......@@ -158,7 +158,7 @@ void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type,
PtNext = pt_segm->Next();
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
continue;
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
}
ScreenPcb->SetModify();
......@@ -180,7 +180,7 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPETEXTE )
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
}
ScreenPcb->SetModify();
......@@ -206,7 +206,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( wxDC* DC, bool query )
PtNext = pt_segm->Next();
if( pt_segm->GetLayer() != layer )
continue;
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
}
ScreenPcb->SetModify();
......
......@@ -41,7 +41,6 @@ OBJECTS= \
dcode.o\
undelete.o\
infospgm.o \
struct.o \
files.o\
block.o\
controle.o\
......@@ -173,8 +172,6 @@ ioascii.o: ioascii.cpp $(COMMON)
chrono.o: chrono.cpp pcbnew.h
struct.o: struct.cpp $(COMMON)
coordbox.o: coordbox.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,
void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC,
BOARD * Pcb, int drawmode);
/**************/
/* struct.cpp */
/**************/
void DeleteStructure(EDA_BaseStruct * Struct);
void DeleteStructList( EDA_BaseStruct * Struct);
/*************/
/* dcode.cpp */
/*************/
......
......@@ -10,6 +10,8 @@
/* Variables locales */
#if 0
/***************************************************/
void DeleteStructure( EDA_BaseStruct * PtStruct )
/***************************************************/
......@@ -91,3 +93,5 @@ EDA_BaseStruct *PtNext;
}
}
#endif
......@@ -75,7 +75,7 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
{
/* Delete last deleted item, and shift stack. */
DeleteStructure( g_UnDeleteStack[0] );
g_UnDeleteStack[0]->DeleteStructure();
for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
{
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
......
......@@ -185,7 +185,10 @@ public:
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..) */
int GetState( int type );
......@@ -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)
/**
......@@ -403,7 +414,6 @@ public:
BOARD_ITEM* Next() const { return (BOARD_ITEM*) Pnext; }
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
/**
......@@ -443,6 +453,24 @@ public:
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
......
......@@ -465,7 +465,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
/* le module est ici bon a etre efface */
module->m_Flags = 0;
module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( module );
module->DeleteStructure();
m_Pcb->m_Status_Pcb = 0;
}
}
......@@ -483,7 +483,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{
/* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR );
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
}
}
}
......@@ -512,7 +512,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break;
/* l'element est ici bon a etre efface */
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR );
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
break;
case TYPETEXTE:
......@@ -523,7 +523,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
/* le texte est ici bon a etre efface */
( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Suppression du texte en Memoire*/
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
break;
case TYPEMIRE:
......@@ -535,7 +535,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break;
/* l'element est ici bon a etre efface */
( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
break;
case TYPECOTATION:
......@@ -547,7 +547,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break;
/* l'element est ici bon a etre efface */
( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
break;
default:
......@@ -565,9 +565,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
{
NextS = pt_segm->Next();
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 );
DeleteStructure( pt_segm );
PtStruct->DeleteStructure();
}
}
}
......
......@@ -533,7 +533,7 @@ void DeleteMarkedItems( MODULE* module )
next_pad = pad->Next();
if( pad->m_Selected == 0 )
continue;
DeleteStructure( pad );
pad->DeleteStructure();
}
item = module->m_Drawings;
......@@ -542,7 +542,7 @@ void DeleteMarkedItems( MODULE* module )
next_item = item->Next();
if( item->m_Selected == 0 )
continue;
DeleteStructure( item );
item->DeleteStructure();
}
}
......
......@@ -48,6 +48,32 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
/***************/
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
return (const char**) xpm;
}
......@@ -300,7 +300,7 @@ static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
/* Suppression du segment */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure( PtSegm );
PtSegm->DeleteStructure();
if( NextS == NULL )
break;
}
......@@ -340,7 +340,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/* Lenght segment = 0; delete it */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure( PtSegm );
PtSegm->DeleteStructure();
nbpoints_supprimes++;
msg.Printf( wxT( " %d" ), nbpoints_supprimes );
......@@ -402,7 +402,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
{
ii--;
pt_aux->Draw( frame->DrawPanel, DC, GR_OR );
DeleteStructure( pt_aux );
pt_aux->DeleteStructure();
nbpoints_supprimes++;
msg.Printf( wxT( " %d" ), nbpoints_supprimes );
......@@ -482,7 +482,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
if( pt_segm_delete )
{
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 )
if( pt_segm_delete )
{
nbpoints_supprimes++; no_inc = 1;
DeleteStructure( pt_segm_delete );
pt_segm_delete->DeleteStructure();
}
}
......
......@@ -128,7 +128,7 @@ wxDC * DC = Cmd->DC;
for ( ; ii > 0; ii --, pt_track = NextS)
{
NextS = (TRACK*) pt_track->Pnext;
DeleteStructure(pt_track);
pt_track->DeleteStructure();
}
test_1_net_connexion(DC, old_net_code );
}
......
......@@ -208,7 +208,7 @@ static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC )
if( Cotation->m_Flags & IS_NEW )
{
Cotation->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Cotation );
Cotation ->DeleteStructure();
}
else
{
......@@ -378,7 +378,7 @@ void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC )
if( DC )
Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Cotation );
Cotation ->DeleteStructure();
m_CurrentScreen->SetModify();
}
......
......@@ -128,7 +128,7 @@ void WinEDA_DrcFrame::CreateControls()
SetFont(*g_DialogFont);
////@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;
......@@ -215,7 +215,7 @@ void WinEDA_DrcFrame::CreateControls()
wxStaticText* itemStaticText25 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
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);
// Set validators
......@@ -228,6 +228,9 @@ void WinEDA_DrcFrame::CreateControls()
AddUnitSymbol(*m_ClearenceTitle);
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"));
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;
#define ID_BUTTON_BROWSE_RPT_FILE 10011
#define ID_TEXTCTRL_GET_RPT_FILENAME 10010
#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_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_DRCFRAME_SIZE wxSize(400, 300)
......@@ -88,6 +88,9 @@ public:
/// Creates the controls and sizers
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
/// 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 )
Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* suppression d'un segment */
DeleteStructure( Edge );
Edge ->DeleteStructure();
Module->m_LastEdit_Time = time( NULL );
Module->Set_Rectangle_Encadrement();
GetScreen()->SetModify();
......@@ -307,7 +307,7 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
{
MODULE* Module = (MODULE*) Edge->m_Parent;
Edge->Draw( Panel, DC, MoveVector, GR_XOR );
DeleteStructure( Edge );
Edge ->DeleteStructure();
Module->Set_Rectangle_Encadrement();
}
else
......@@ -435,7 +435,7 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
if( (Edge->m_Start.x == Edge->m_End.x)
&& (Edge->m_Start.y == Edge->m_End.y) )
{
DeleteStructure( Edge );
Edge ->DeleteStructure();
}
}
Edge->m_Flags = 0;
......
......@@ -109,7 +109,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
DisplayOpt.DisplayDrawItems = SKETCH;
Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_XOR );
PtStruct = Segment->Pback;
DeleteStructure( Segment );
Segment ->DeleteStructure();
if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) )
Segment = (DRAWSEGMENT*) PtStruct;
DisplayOpt.DisplayDrawItems = track_fill_copy;
......@@ -119,7 +119,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
{
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_XOR );
Segment->m_Flags = 0;
DeleteStructure( Segment );
Segment ->DeleteStructure();
SetCurItem( NULL );
GetScreen()->SetModify();
}
......@@ -191,7 +191,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( pt_segm->GetLayer() == layer )
{
Trace_DrawSegmentPcb( DrawPanel, DC, pt_segm, GR_XOR );
DeleteStructure( PtStruct );
PtStruct ->DeleteStructure();
}
break;
......@@ -200,7 +200,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( pt_txt->GetLayer() == layer )
{
pt_txt->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct );
PtStruct ->DeleteStructure();
}
break;
......@@ -210,7 +210,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
if( Cotation->GetLayer() == layer )
{
Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( PtStruct );
PtStruct ->DeleteStructure();
}
break;
......@@ -234,7 +234,7 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
if( Segment->m_Flags & IS_NEW )
{
Panel->ManageCurseur( Panel, DC, FALSE );
DeleteStructure( Segment );
Segment ->DeleteStructure();
Segment = NULL;
}
else
......@@ -338,7 +338,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
/* Effacement si Longueur nulle */
if( (Segment->m_Start.x == Segment->m_End.x)
&& (Segment->m_Start.y == Segment->m_End.y) )
DeleteStructure( Segment );
Segment ->DeleteStructure();
else
{
......
......@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text, wxDC* DC )
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* liberation de la memoire : */
DeleteStructure( Text );
Text ->DeleteStructure();
GetScreen()->SetModify();
Module->m_LastEdit_Time = time( NULL );
}
......
......@@ -129,28 +129,29 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
}
/* Suppression des listes chainees */
DeleteStructList( m_Pcb->m_Equipots );
m_Pcb->m_Equipots->DeleteStructList();
m_Pcb->m_Equipots = NULL;
DeleteStructList( m_Pcb->m_Drawings );
m_Pcb->m_Drawings->DeleteStructList();
m_Pcb->m_Drawings = NULL;
DeleteStructList( m_Pcb->m_Modules );
m_Pcb->m_Modules->DeleteStructList();
m_Pcb->m_Modules = NULL;
DeleteStructList( m_Pcb->m_Track );
m_Pcb->m_Track->DeleteStructList();
m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0;
DeleteStructList( m_Pcb->m_Zone );
m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
DelLimitesZone( DC, FALSE );
for( ; g_UnDeleteStackPtr != 0; )
{
g_UnDeleteStackPtr--;
DeleteStructList( g_UnDeleteStack[g_UnDeleteStackPtr] );
g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList();
}
/* init pointeurs et variables */
......@@ -214,11 +215,11 @@ void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query )
if( m_Pcb->m_Zone )
{
while( m_Pcb->m_Zone )
DeleteStructure( m_Pcb->m_Zone );
m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
}
DelLimitesZone( DC, FALSE );
GetScreen()->SetModify();
......@@ -257,7 +258,7 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query )
case TYPECOTATION:
case TYPEMIRE:
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
DeleteStructure( PtStruct );
PtStruct->DeleteStructure();
break;
default:
......@@ -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
*/
{
TRACK* pt_segm;
EDA_BaseStruct* PtNext;
TRACK* pt_segm;
TRACK* PtNext;
if( query && !IsOK( this, _( "Delete Tracks?" ) ) )
return;
......@@ -289,10 +290,12 @@ void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query )
/* Marquage des pistes a effacer */
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 )
continue;
DeleteStructure( pt_segm );
pt_segm->DeleteStructure();
}
GetScreen()->SetModify();
......@@ -307,8 +310,8 @@ void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query )
if( query && !IsOK( this, _( "Delete Modules?" ) ) )
return;
while( m_Pcb->m_Modules )
DeleteStructure( m_Pcb->m_Modules );
m_Pcb->m_Modules->DeleteStructList();
m_Pcb->m_Modules = 0;
m_Pcb->m_Status_Pcb = 0;
m_Pcb->m_NbNets = 0;
......@@ -335,7 +338,7 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPETEXTE )
DeleteStructure( PtStruct );
PtStruct ->DeleteStructure();
}
GetScreen()->SetModify();
......@@ -353,7 +356,7 @@ void WinEDA_PcbFrame::Erase_Marqueurs()
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPEMARQUEUR )
DeleteStructure( PtStruct );
PtStruct ->DeleteStructure();
}
GetScreen()->SetModify();
......
......@@ -86,7 +86,7 @@ OBJECTS= $(TARGET).o classpcb.o\
zones.o undelete.o \
copy_track.o\
move_or_drag_track.o\
ioascii.o struct.o \
ioascii.o \
mirepcb.o xchgmod.o\
plotps.o\
dragsegm.o\
......@@ -282,8 +282,6 @@ copy_track.o: copy_track.cpp $(COMMON)
ioascii.o: ioascii.cpp $(COMMON)
struct.o: struct.cpp $(COMMON)
coordbox.o: coordbox.cpp $(COMMON)
mirepcb.o: mirepcb.cpp $(COMMON)
......
......@@ -168,7 +168,7 @@ void WinEDA_PcbFrame::Delete_Mire( MIREPCB* MirePcb, wxDC* DC )
return;
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 )
if( MirePcb->m_Flags & IS_NEW )
{
MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( MirePcb );
MirePcb ->DeleteStructure();
MirePcb = NULL;
}
else /* Ancienne mire en deplacement: Remise en ancienne position */
......
......@@ -180,7 +180,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
if( module->m_Flags & IS_NEW )
{
DeleteStructure( module );
module ->DeleteStructure();
module = NULL;
pcbframe->m_Pcb->m_Status_Pcb = 0;
pcbframe->build_liste_pads();
......
......@@ -256,7 +256,7 @@ wxString line;
if ( DC ) Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR);
DeleteStructure(Pad);
Pad->DeleteStructure();
/* Redessin du module */
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 )
for( ; ii > 0; ii--, pt_track = NextS )
{
NextS = (TRACK*) pt_track->Pnext;
DeleteStructure( pt_track );
pt_track ->DeleteStructure();
}
test_1_net_connexion( DC, old_net_code );
......
......@@ -103,7 +103,7 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
if( Module->m_Flags & IS_NEW )
{
Module->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Module );
Module ->DeleteStructure();
}
else
{
......
......@@ -329,7 +329,7 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Suppression du texte en Memoire*/
DeleteStructure( TextePcb );
TextePcb ->DeleteStructure();
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL );
......@@ -365,7 +365,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC )
InstallTextPCBOptionsFrame( TextePcb, DC, TextePcb->m_Pos );
if( TextePcb->m_Text.IsEmpty() )
{
DeleteStructure( TextePcb );
TextePcb ->DeleteStructure();
TextePcb = NULL;
}
else
......
......@@ -372,12 +372,6 @@ TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm);
/****************/
void RemoteCommand( const char* cmdline );
/*************/
/* STRUCT.CPP */
/*************/
void DeleteStructure( BOARD_ITEM* Struct );
void DeleteStructList( BOARD_ITEM* Struct );
/***************/
/* AUTOPLACE.CPP */
......
......@@ -801,7 +801,7 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code()
while( pt_equipot )
{
PtStruct = pt_equipot->Pnext;
DeleteStructure( pt_equipot );
pt_equipot ->DeleteStructure();
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
for ( jj = 0; jj < nb_segm; jj++, pt_del = NextS)
{
NextS = (TRACK*) pt_del->Pnext;
DeleteStructure(pt_del);
pt_del->DeleteStructure();
}
/* nettoyage des flags */
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 )
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
{
/* Delete last deleted item, and shift stack. */
DeleteStructList( g_UnDeleteStack[0] );
g_UnDeleteStack[0]->DeleteStructList();
for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
{
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
......
......@@ -573,7 +573,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff,
}
/* Effacement de l'ancien module */
DeleteStructure( OldModule );
OldModule ->DeleteStructure();
m_Pcb->m_Status_Pcb = 0;
NewModule->m_Flags = 0;
......
......@@ -461,7 +461,7 @@ void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* Zone )
modify = TRUE;
/* effacement des segments a l'ecran */
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