Commit d814889d authored by dickelbeck's avatar dickelbeck

gerbview, pcbnew's BOARD container changes

parent ceeb27cf
...@@ -5,6 +5,27 @@ Started 2007-June-11 ...@@ -5,6 +5,27 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Dec-6 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew & gerbview
* As a final migration step, made BOARD_ITEM::SetNext() and
BOARD_ITEM::SetBack() _private_, starting at BOARD_ITEM in the class
hierarchy so that the compiler will tell us where they are used illegally.
Classes derived from BOARD_ITEM then also cannot expose SetNext() and
SetPrev(), and this forces everthing related to BOARD_ITEM through DLIST for
list manipulation. The compiler turned up a couple I had missed, two of which
were the back pointers of MODULE::m_Reference->Back(), m_Value->Back(), which I
do not think are needed since the MODULE owns these texts, not the other way around.
This should be the final nail in the coffin for undisciplined list manipulation
within pcbnew and gerbview.
* Converted BOARD::Delete() into BOARD::Remove() and then added an inline for
BOARD::Delete() which deletes what Remove() returns.
* Removed BOARD::DeleteMARKER( int ) since BOARD::Delete() works.
* Removed gerbview's undelete.cpp and made gerbview use pcbnew's,
by moving the two supporting functions into the common base class
of WinEDA_BasePcbFrame, had to add some "#if !defined(GERBVIEW)"s.
2008-Dec-5 UPDATE Dick Hollenbeck <dick@softplc.com> 2008-Dec-5 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
++pcbnew & gerbview ++pcbnew & gerbview
......
...@@ -37,8 +37,7 @@ set(GERBVIEW_SRCS ...@@ -37,8 +37,7 @@ set(GERBVIEW_SRCS
# struct.cpp <-- not used # struct.cpp <-- not used
tool_gerber.cpp tool_gerber.cpp
tracepcb.cpp tracepcb.cpp
trpiste.cpp trpiste.cpp )
undelete.cpp)
set(GERBVIEW_EXTRA_SRCS set(GERBVIEW_EXTRA_SRCS
../pcbnew/basepcbframe.cpp ../pcbnew/basepcbframe.cpp
...@@ -55,6 +54,7 @@ set(GERBVIEW_EXTRA_SRCS ...@@ -55,6 +54,7 @@ set(GERBVIEW_EXTRA_SRCS
../pcbnew/classpcb.cpp ../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp ../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp ../pcbnew/sel_layer.cpp
../pcbnew/undelete.cpp
../share/drawframe.cpp ../share/drawframe.cpp
../share/setpage.cpp ../share/setpage.cpp
......
...@@ -5,12 +5,6 @@ ...@@ -5,12 +5,6 @@
/***************************/ /***************************/
int * InstallDialogLayerPairChoice(WinEDA_GerberFrame * parent); int * InstallDialogLayerPairChoice(WinEDA_GerberFrame * parent);
/****************/
/* undelete.cpp */
/****************/
BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems );
/***********************/ /***********************/
/* gerbview_config.cpp */ /* gerbview_config.cpp */
/***********************/ /***********************/
......
...@@ -103,7 +103,7 @@ static void fillRoundFlashTRACK( TRACK* aTrack, int Dcode_index, int aLayer, ...@@ -103,7 +103,7 @@ static void fillRoundFlashTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
aTrack->SetNet( Dcode_index ); aTrack->SetNet( Dcode_index );
aTrack->m_Shape = S_SPOT_CIRCLE; aTrack->m_Shape = S_SPOT_CIRCLE;
D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );) // D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );)
if( !isDark ) if( !isDark )
{ {
...@@ -156,7 +156,7 @@ static void fillOvalOrRectFlashTRACK( TRACK* aTrack, int Dcode_index, int aLaye ...@@ -156,7 +156,7 @@ static void fillOvalOrRectFlashTRACK( TRACK* aTrack, int Dcode_index, int aLaye
aTrack->m_End.y += len; aTrack->m_End.y += len;
} }
D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );) // D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );)
if( !isDark ) if( !isDark )
{ {
aTrack->m_Flags |= DRAW_ERASED; aTrack->m_Flags |= DRAW_ERASED;
...@@ -192,7 +192,7 @@ static void fillLineTRACK( TRACK* aTrack, int Dcode_index, int aLayer, ...@@ -192,7 +192,7 @@ static void fillLineTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
aTrack->SetNet( Dcode_index ); aTrack->SetNet( Dcode_index );
D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );) //D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );)
if( !isDark ) if( !isDark )
{ {
aTrack->m_Flags |= DRAW_ERASED; aTrack->m_Flags |= DRAW_ERASED;
......
/********************************************************/
/* Effacements : Routines de sauvegarde et d'effacement */
/********************************************************/
#include "fctsys.h"
#include "common.h"
#include "gerbview.h"
#include "protos.h"
/* Routines externes : */
/* Routines Locales */
/***********************************************/
void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC )
/***********************************************/
/* Restitution d'un element (MODULE ou TRACK ) Efface
*/
{
BOARD_ITEM* item;
BOARD_ITEM* next;
int net_code;
if( !g_UnDeleteStackPtr )
return;
g_UnDeleteStackPtr--;
item = g_UnDeleteStack[g_UnDeleteStackPtr];
if( item == NULL )
return; // Ne devrait pas se produire
switch( item->Type() )
{
case TYPE_VIA:
case TYPE_TRACK:
for( ; item; item = next )
{
next = item->Next();
item->SetState( DELETED, OFF ); /* Effacement du bit DELETED */
Trace_Segment( DrawPanel, DC, (TRACK*) item, GR_OR );
}
item = g_UnDeleteStack[g_UnDeleteStackPtr];
net_code = ((TRACK*) item)->GetNet();
m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
break;
default:
DisplayError( this, wxT( "Undelete struct: type Struct inattendu" ) );
break;
}
}
/********************************************************************/
BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
/********************************************************************/
/* Sauvegarde d'un element aux fins de restitution par Undelete
* Supporte actuellement : Module et segments de piste
*/
{
BOARD_ITEM* NextS, * PtStruct = PtItem;
int ii;
if( (PtItem == NULL) || (nbitems == 0) )
return NULL;
if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE )
{
/* Delete last deleted item, and shift stack. */
g_UnDeleteStack[0]->DeleteStructure();
for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ )
{
g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1];
}
g_UnDeleteStackPtr--;;
}
g_UnDeleteStack[g_UnDeleteStackPtr++] = PtItem;
switch( PtStruct->Type() )
{
case TYPE_VIA:
case TYPE_TRACK:
{
EDA_BaseStruct* Back = NULL;
g_UnDeleteStack[g_UnDeleteStackPtr - 1] = PtStruct;
for( ; nbitems > 0; nbitems--, PtStruct = NextS )
{
NextS = PtStruct->Next();
( (TRACK*) PtStruct )->UnLink();
PtStruct->SetState( DELETED, ON );
if( nbitems <= 1 )
NextS = NULL; /* fin de chaine */
PtStruct->SetNext( NextS );
PtStruct->SetBack( Back );
Back = PtStruct;
if( NextS == NULL )
break;
}
}
break;
default:
break;
}
return g_UnDeleteStack[g_UnDeleteStackPtr - 1];
}
...@@ -32,6 +32,13 @@ enum Track_Shapes { ...@@ -32,6 +32,13 @@ enum Track_Shapes {
*/ */
class BOARD_ITEM : public EDA_BaseStruct class BOARD_ITEM : public EDA_BaseStruct
{ {
// These are made private here so they may not be used.
// Instead everything derived from BOARD_ITEM is handled via DLIST<>'s
// use of DHEAD's member functions.
void SetNext( EDA_BaseStruct* aNext ) { Pnext = aNext; }
void SetBack( EDA_BaseStruct* aBack ) { Pback = aBack; }
protected: protected:
int m_Layer; int m_Layer;
......
...@@ -128,6 +128,10 @@ public: ...@@ -128,6 +128,10 @@ public:
// PCB handling // PCB handling
bool Clear_Pcb( bool query ); bool Clear_Pcb( bool query );
void UnDeleteItem( wxDC* DC );
BOARD_ITEM* SaveItemEfface( BOARD_ITEM* aItem, int nbitems );
/** /**
* Function PcbGeneralLocateAndDisplay * Function PcbGeneralLocateAndDisplay
* searches for an item under the mouse cursor. * searches for an item under the mouse cursor.
...@@ -465,7 +469,6 @@ public: ...@@ -465,7 +469,6 @@ public:
void Erase_Modules( bool query ); void Erase_Modules( bool query );
void Erase_Textes_Pcb( bool query ); void Erase_Textes_Pcb( bool query );
void Erase_Marqueurs(); void Erase_Marqueurs();
void UnDeleteItem( wxDC* DC );
void RemoveStruct( BOARD_ITEM* Item, wxDC* DC ); void RemoveStruct( BOARD_ITEM* Item, wxDC* DC );
void Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via ); void Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via );
...@@ -704,7 +707,6 @@ public: ...@@ -704,7 +707,6 @@ public:
void Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ); void Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC );
void Ratsnest_On_Off( wxDC* DC ); void Ratsnest_On_Off( wxDC* DC );
void Clean_Pcb( wxDC* DC ); void Clean_Pcb( wxDC* DC );
BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems );
void InstallFindFrame( const wxPoint& pos, wxDC* DC ); void InstallFindFrame( const wxPoint& pos, wxDC* DC );
...@@ -841,7 +843,6 @@ public: ...@@ -841,7 +843,6 @@ public:
void Erase_Segments_Pcb( bool is_edges, bool query ); void Erase_Segments_Pcb( bool is_edges, bool query );
void Erase_Pistes( int masque_type, bool query ); void Erase_Pistes( int masque_type, bool query );
void Erase_Textes_Pcb( bool query ); void Erase_Textes_Pcb( bool query );
void UnDeleteItem( wxDC* DC );
void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ); void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number );
TRACK* Begin_Route( TRACK* track, wxDC* DC ); TRACK* Begin_Route( TRACK* track, wxDC* DC );
......
...@@ -265,19 +265,20 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) ...@@ -265,19 +265,20 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
} }
void BOARD::Delete( BOARD_ITEM* aBoardItem ) BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
{ {
if ( aBoardItem == NULL ) return; // find these calls and fix them! Don't send me no stinkin' NULL.
wxASSERT( aBoardItem );
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
case TYPE_MARKER: // this one uses a vector case TYPE_MARKER:
// find the item in the vector, then delete then erase it. // find the item in the vector, then remove it
for( unsigned i=0; i<m_markers.size(); ++i ) for( unsigned i=0; i<m_markers.size(); ++i )
{ {
if( m_markers[i] == (MARKER*) aBoardItem ) if( m_markers[i] == (MARKER*) aBoardItem )
{ {
DeleteMARKER( i ); m_markers.erase( m_markers.begin() + i );
break; break;
} }
} }
...@@ -289,24 +290,23 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem ) ...@@ -289,24 +290,23 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
{ {
if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem ) if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem )
{ {
delete m_ZoneDescriptorList[i]; m_ZoneDescriptorList.erase( m_ZoneDescriptorList.begin() + i );
m_ZoneDescriptorList.erase(m_ZoneDescriptorList.begin() + i);
break; break;
} }
} }
break; break;
case TYPE_MODULE: case TYPE_MODULE:
delete m_Modules.Remove( (MODULE*) aBoardItem ); m_Modules.Remove( (MODULE*) aBoardItem );
break; break;
case TYPE_TRACK: case TYPE_TRACK:
case TYPE_VIA: case TYPE_VIA:
delete m_Track.Remove( (TRACK*) aBoardItem ); m_Track.Remove( (TRACK*) aBoardItem );
break; break;
case TYPE_ZONE: case TYPE_ZONE:
delete m_Zone.Remove( (SEGZONE*) aBoardItem ); m_Zone.Remove( (SEGZONE*) aBoardItem );
break; break;
case TYPE_COTATION: case TYPE_COTATION:
...@@ -314,27 +314,19 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem ) ...@@ -314,27 +314,19 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
case TYPE_TEXTE: case TYPE_TEXTE:
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
case TYPE_MIRE: case TYPE_MIRE:
delete m_Drawings.Remove( aBoardItem ); m_Drawings.Remove( aBoardItem );
break; break;
case TYPE_EQUIPOT: case TYPE_EQUIPOT:
delete m_Equipots.Remove( (EQUIPOT*) aBoardItem ); m_Equipots.Remove( (EQUIPOT*) aBoardItem );
break; break;
// other types may use linked list // other types may use linked list
default: default:
wxFAIL_MSG( wxT("BOARD::Delete() needs work") ); wxFAIL_MSG( wxT("BOARD::Remove() needs more ::Type() support") );
} }
}
void BOARD::DeleteMARKER( int aIndex ) return aBoardItem;
{
if( (unsigned) aIndex < m_markers.size() )
{
delete m_markers[aIndex];
m_markers.erase( m_markers.begin() + aIndex );
}
} }
......
...@@ -128,11 +128,26 @@ public: ...@@ -128,11 +128,26 @@ public:
/** /**
* Function Delete * Function Delete
* deletes the given single item from this BOARD and deletes its memory. If you * removes the given single item from this BOARD and deletes its memory.
* need the object after deletion, first copy it.
* @param aBoardItem The item to remove from this board and delete * @param aBoardItem The item to remove from this board and delete
*/ */
void Delete( BOARD_ITEM* aBoardItem ); void Delete( BOARD_ITEM* aBoardItem )
{
wxASSERT( aBoardItem ); // developers should run DEBUG versions and fix such calls with NULL
if( aBoardItem )
delete Remove( aBoardItem );
}
/**
* Function Remove
* removes \a aBoardItem from this BOARD and returns it to caller without
* deleting it.
* @param aBoardItem The item to remove from this board.
* @return BOARD_ITEM* \a aBoardItem which was passed in.
*/
BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem );
/** /**
* Function DeleteMARKERs * Function DeleteMARKERs
...@@ -147,14 +162,6 @@ public: ...@@ -147,14 +162,6 @@ public:
void DeleteZONEOutlines(); void DeleteZONEOutlines();
/**
* Function DeleteMARKER
* deletes one MARKER from the board.
* @param aIndex The index of the marker to delete.
*/
void DeleteMARKER( int aIndex );
/** /**
* Function GetMARKER * Function GetMARKER
* returns the MARKER at a given index. * returns the MARKER at a given index.
...@@ -168,7 +175,6 @@ public: ...@@ -168,7 +175,6 @@ public:
return NULL; return NULL;
} }
/** /**
* Function GetMARKERCount * Function GetMARKERCount
* @return int - The number of MARKERS. * @return int - The number of MARKERS.
......
...@@ -68,10 +68,10 @@ MODULE::MODULE( BOARD* parent ) : ...@@ -68,10 +68,10 @@ MODULE::MODULE( BOARD* parent ) :
m_LastEdit_Time = time( NULL ); m_LastEdit_Time = time( NULL );
m_Reference = new TEXTE_MODULE( this, TEXT_is_REFERENCE ); m_Reference = new TEXTE_MODULE( this, TEXT_is_REFERENCE );
m_Reference->SetBack( this ); // m_Reference->SetBack( this );
m_Value = new TEXTE_MODULE( this, TEXT_is_VALUE ); m_Value = new TEXTE_MODULE( this, TEXT_is_VALUE );
m_Value->SetBack( this ); // m_Value->SetBack( this );
m_3D_Drawings.PushBack( new S3D_MASTER( this ) ); m_3D_Drawings.PushBack( new S3D_MASTER( this ) );
} }
...@@ -342,32 +342,31 @@ int MODULE::Write_3D_Descr( FILE* File ) const ...@@ -342,32 +342,31 @@ int MODULE::Write_3D_Descr( FILE* File ) const
*/ */
{ {
char buf[512]; char buf[512];
S3D_MASTER* Struct3D = m_3D_Drawings;
for( ; Struct3D != NULL; Struct3D = Struct3D->Next() ) for( S3D_MASTER* t3D = m_3D_Drawings; t3D; t3D = t3D->Next() )
{ {
if( !Struct3D->m_Shape3DName.IsEmpty() ) if( !t3D->m_Shape3DName.IsEmpty() )
{ {
fprintf( File, "$SHAPE3D\n" ); fprintf( File, "$SHAPE3D\n" );
fprintf( File, "Na \"%s\"\n", CONV_TO_UTF8( Struct3D->m_Shape3DName ) ); fprintf( File, "Na \"%s\"\n", CONV_TO_UTF8( t3D->m_Shape3DName ) );
sprintf( buf, "Sc %lf %lf %lf\n", sprintf( buf, "Sc %lf %lf %lf\n",
Struct3D->m_MatScale.x, t3D->m_MatScale.x,
Struct3D->m_MatScale.y, t3D->m_MatScale.y,
Struct3D->m_MatScale.z ); t3D->m_MatScale.z );
fprintf( File, to_point( buf ) ); fprintf( File, to_point( buf ) );
sprintf( buf, "Of %lf %lf %lf\n", sprintf( buf, "Of %lf %lf %lf\n",
Struct3D->m_MatPosition.x, t3D->m_MatPosition.x,
Struct3D->m_MatPosition.y, t3D->m_MatPosition.y,
Struct3D->m_MatPosition.z ); t3D->m_MatPosition.z );
fprintf( File, to_point( buf ) ); fprintf( File, to_point( buf ) );
sprintf( buf, "Ro %lf %lf %lf\n", sprintf( buf, "Ro %lf %lf %lf\n",
Struct3D->m_MatRotation.x, t3D->m_MatRotation.x,
Struct3D->m_MatRotation.y, t3D->m_MatRotation.y,
Struct3D->m_MatRotation.z ); t3D->m_MatRotation.z );
fprintf( File, to_point( buf ) ); fprintf( File, to_point( buf ) );
fprintf( File, "$EndSHAPE3D\n" ); fprintf( File, "$EndSHAPE3D\n" );
...@@ -390,15 +389,15 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum ) ...@@ -390,15 +389,15 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
char Line[1024]; char Line[1024];
char* text = Line + 3; char* text = Line + 3;
S3D_MASTER* Struct3D = m_3D_Drawings; S3D_MASTER* t3D = m_3D_Drawings;
if( !Struct3D->m_Shape3DName.IsEmpty() ) if( !t3D->m_Shape3DName.IsEmpty() )
{ {
S3D_MASTER* n3D = new S3D_MASTER( this ); S3D_MASTER* n3D = new S3D_MASTER( this );
m_3D_Drawings.PushBack( n3D ); m_3D_Drawings.PushBack( n3D );
Struct3D = n3D; t3D = n3D;
} }
while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL ) while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL )
...@@ -414,29 +413,29 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum ) ...@@ -414,29 +413,29 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
{ {
char buf[512]; char buf[512];
ReadDelimitedText( buf, text, 512 ); ReadDelimitedText( buf, text, 512 );
Struct3D->m_Shape3DName = CONV_FROM_UTF8( buf ); t3D->m_Shape3DName = CONV_FROM_UTF8( buf );
break; break;
} }
case 'S': // Scale case 'S': // Scale
sscanf( text, "%lf %lf %lf\n", sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatScale.x, &t3D->m_MatScale.x,
&Struct3D->m_MatScale.y, &t3D->m_MatScale.y,
&Struct3D->m_MatScale.z ); &t3D->m_MatScale.z );
break; break;
case 'O': // Offset case 'O': // Offset
sscanf( text, "%lf %lf %lf\n", sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatPosition.x, &t3D->m_MatPosition.x,
&Struct3D->m_MatPosition.y, &t3D->m_MatPosition.y,
&Struct3D->m_MatPosition.z ); &t3D->m_MatPosition.z );
break; break;
case 'R': // Rotation case 'R': // Rotation
sscanf( text, "%lf %lf %lf\n", sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatRotation.x, &t3D->m_MatRotation.x,
&Struct3D->m_MatRotation.y, &t3D->m_MatRotation.y,
&Struct3D->m_MatRotation.z ); &t3D->m_MatRotation.z );
break; break;
default: default:
...@@ -681,18 +680,18 @@ void MODULE::SetOrientation( int newangle ) ...@@ -681,18 +680,18 @@ void MODULE::SetOrientation( int newangle )
m_Value->SetDrawCoord(); m_Value->SetDrawCoord();
/* deplacement des contours et textes de l'empreinte : */ /* deplacement des contours et textes de l'empreinte : */
EDA_BaseStruct* PtStruct = m_Drawings; for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() == TYPE_EDGE_MODULE ) if( item->Type() == TYPE_EDGE_MODULE )
{ {
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct; EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord(); pt_edgmod->SetDrawCoord();
} }
if( PtStruct->Type() == TYPE_TEXTE_MODULE )
if( item->Type() == TYPE_TEXTE_MODULE )
{ {
/* deplacement des inscriptions : */ /* deplacement des inscriptions : */
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct; TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->SetDrawCoord(); pt_texte->SetDrawCoord();
} }
} }
......
...@@ -80,7 +80,9 @@ public: ...@@ -80,7 +80,9 @@ public:
void DeleteItem( int aIndex ) void DeleteItem( int aIndex )
{ {
m_board->DeleteMARKER( aIndex ); MARKER* marker = m_board->GetMARKER( aIndex );
if( marker )
m_board->Delete( marker );
} }
......
...@@ -407,9 +407,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -407,9 +407,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
Module->m_Drawings.Insert( newedge, PtSegm->Next() ); Module->m_Drawings.Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End = Mself.m_End; PtSegm->m_End = Mself.m_End;
PtSegm->SetNext( NULL );
/* Rotation de la self si le trace doit etre horizontal : */ /* Rotation de la self si le trace doit etre horizontal : */
LastSegm = PtSegm; LastSegm = PtSegm;
...@@ -426,8 +426,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -426,8 +426,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
} }
/* Modif position ancre */ /* Modif position ancre */
Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos = LastSegm->m_End;
Module->m_Pos.y = LastSegm->m_End.y;
/* Placement des 2 pads sur extremite */ /* Placement des 2 pads sur extremite */
PtPad = new D_PAD( Module ); PtPad = new D_PAD( Module );
...@@ -512,7 +511,8 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle ) ...@@ -512,7 +511,8 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle )
wxASSERT( list ); wxASSERT( list );
angle = -angle; angle = -angle;
y0 = PtSegm->m_Start.x - cX; x0 = PtSegm->m_Start.y - cY; y0 = PtSegm->m_Start.x - cX;
x0 = PtSegm->m_Start.y - cY;
nb_seg = ( abs( angle ) ) / 225; if( nb_seg == 0 ) nb_seg = ( abs( angle ) ) / 225; if( nb_seg == 0 )
nb_seg = 1; nb_seg = 1;
......
...@@ -8,14 +8,13 @@ ...@@ -8,14 +8,13 @@
#include "common.h" #include "common.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "protos.h"
/* Routines externes : */ /* Routines externes : */
/* Routines Locales */ /* Routines Locales */
/********************************************/ /********************************************/
void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) void WinEDA_BasePcbFrame::UnDeleteItem( wxDC* DC )
/********************************************/ /********************************************/
/* Restitution d'un element (MODULE ou TRACK ) Efface /* Restitution d'un element (MODULE ou TRACK ) Efface
...@@ -32,6 +31,12 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) ...@@ -32,6 +31,12 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
if( item == NULL ) if( item == NULL )
return; // Ne devrait pas se produire return; // Ne devrait pas se produire
// we decremented the stack pointer, so the stack no longer
// owns "item". We do here, so we have to delete item if its
// not going back into the board, see default case below.
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_VIA: case TYPE_VIA:
...@@ -48,8 +53,11 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) ...@@ -48,8 +53,11 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
m_Pcb->Add( track ); m_Pcb->Add( track );
net_code = track->GetNet(); net_code = track->GetNet();
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
#if !defined(GERBVIEW)
test_1_net_connexion( DC, net_code ); test_1_net_connexion( DC, net_code );
#endif
m_Pcb->Display_Infos( this ); m_Pcb->Display_Infos( this );
break; break;
...@@ -66,31 +74,35 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) ...@@ -66,31 +74,35 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
net_code = t->GetNet(); net_code = t->GetNet();
} }
delete list; delete list;
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
#if !defined(GERBVIEW)
test_1_net_connexion( DC, net_code ); test_1_net_connexion( DC, net_code );
#endif
m_Pcb->Display_Infos( this ); m_Pcb->Display_Infos( this );
break; break;
#if !defined(GERBVIEW)
case TYPE_MODULE: case TYPE_MODULE:
/* Erase general rastnest if needed */ // Erase general rastnest if needed
if( g_Show_Ratsnest ) if( g_Show_Ratsnest )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
m_Pcb->Add( item ); m_Pcb->Add( item );
g_UnDeleteStack[g_UnDeleteStackPtr] = NULL;
item->Draw( DrawPanel, DC, GR_OR ); item->Draw( DrawPanel, DC, GR_OR );
item->SetState( DELETED, OFF ); /* Creal DELETED flag */ item->SetState( DELETED, OFF ); /* Creal DELETED flag */
item->m_Flags = 0; item->m_Flags = 0;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
build_liste_pads(); build_liste_pads();
ReCompile_Ratsnest_After_Changes( DC ); ReCompile_Ratsnest_After_Changes( DC );
break; break;
#endif
default: default:
DisplayError( this, wxT( "WinEDA_PcbFrame::UnDeleteItem(): unexpected Struct type" ) ); DisplayError( this, wxT( "WinEDA_PcbFrame::UnDeleteItem(): unexpected Struct type" ) );
delete item;
break; break;
} }
} }
...@@ -99,7 +111,7 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) ...@@ -99,7 +111,7 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC )
/* Sauvegarde d'un element aux fins de restitution par Undelete /* Sauvegarde d'un element aux fins de restitution par Undelete
* Supporte actuellement : Module et segments de piste * Supporte actuellement : Module et segments de piste
*/ */
BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems ) BOARD_ITEM* WinEDA_BasePcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems )
{ {
if( aItem == NULL || nbitems == 0 ) if( aItem == NULL || nbitems == 0 )
return NULL; return NULL;
...@@ -135,6 +147,7 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems ) ...@@ -135,6 +147,7 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems )
BOARD_ITEM_LIST* list = new BOARD_ITEM_LIST(); BOARD_ITEM_LIST* list = new BOARD_ITEM_LIST();
g_UnDeleteStack[g_UnDeleteStackPtr++] = list; g_UnDeleteStack[g_UnDeleteStackPtr++] = list;
// copy the numerous tracks into the list, which is already on stack
int i = 0; int i = 0;
TRACK* next; TRACK* next;
for( TRACK* track = (TRACK*) aItem; track && i<nbitems; track = next, ++i ) for( TRACK* track = (TRACK*) aItem; track && i<nbitems; track = next, ++i )
...@@ -146,6 +159,7 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems ) ...@@ -146,6 +159,7 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems )
} }
break; break;
#if !defined(GERBVIEW)
case TYPE_MODULE: case TYPE_MODULE:
{ {
MODULE* module = (MODULE*) aItem; MODULE* module = (MODULE*) aItem;
...@@ -155,10 +169,12 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems ) ...@@ -155,10 +169,12 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems )
build_liste_pads(); build_liste_pads();
} }
break; break;
#endif
default: default:
break; break;
} }
// don't know why this is not simply return aItem?
return g_UnDeleteStack[g_UnDeleteStackPtr - 1]; return g_UnDeleteStack[g_UnDeleteStackPtr - 1];
} }
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