Commit e574a1b0 authored by dickelbeck's avatar dickelbeck

more DLIST<> work

parent f966097d
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "trackball.h" #include "trackball.h"
/**************************************************************************/ /**************************************************************************/
void Struct3D_Master::Set_Object_Coords( S3D_Vertex* coord, int nbcoord ) void S3D_MASTER::Set_Object_Coords( S3D_Vertex* coord, int nbcoord )
/**************************************************************************/ /**************************************************************************/
{ {
int ii; int ii;
......
...@@ -26,7 +26,7 @@ S3D_Vertex::S3D_Vertex() ...@@ -26,7 +26,7 @@ S3D_Vertex::S3D_Vertex()
/**************************************************************************/ /**************************************************************************/
S3D_Material::S3D_Material( Struct3D_Master* father, const wxString& name ) : S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
EDA_BaseStruct( father, NOT_USED ) EDA_BaseStruct( father, NOT_USED )
/**************************************************************************/ /**************************************************************************/
{ {
...@@ -40,7 +40,7 @@ S3D_Material::S3D_Material( Struct3D_Master* father, const wxString& name ) : ...@@ -40,7 +40,7 @@ S3D_Material::S3D_Material( Struct3D_Master* father, const wxString& name ) :
/***********************************/ /***********************************/
void S3D_Material::SetMaterial() void S3D_MATERIAL::SetMaterial()
/***********************************/ /***********************************/
{ {
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
...@@ -57,7 +57,7 @@ void S3D_Material::SetMaterial() ...@@ -57,7 +57,7 @@ void S3D_Material::SetMaterial()
/****************************************************/ /****************************************************/
void Struct3D_Master::Copy( Struct3D_Master* pattern ) void S3D_MASTER::Copy( S3D_MASTER* pattern )
/****************************************************/ /****************************************************/
{ {
m_Shape3DName = pattern->m_Shape3DName; m_Shape3DName = pattern->m_Shape3DName;
...@@ -70,7 +70,7 @@ void Struct3D_Master::Copy( Struct3D_Master* pattern ) ...@@ -70,7 +70,7 @@ void Struct3D_Master::Copy( Struct3D_Master* pattern )
/***************************************************************/ /***************************************************************/
Struct3D_Master::Struct3D_Master( EDA_BaseStruct* aParent ) : S3D_MASTER::S3D_MASTER( EDA_BaseStruct* aParent ) :
EDA_BaseStruct( aParent, NOT_USED ) EDA_BaseStruct( aParent, NOT_USED )
/***************************************************************/ /***************************************************************/
{ {
...@@ -81,11 +81,11 @@ Struct3D_Master::Struct3D_Master( EDA_BaseStruct* aParent ) : ...@@ -81,11 +81,11 @@ Struct3D_Master::Struct3D_Master( EDA_BaseStruct* aParent ) :
/***************************************/ /***************************************/
Struct3D_Master:: ~Struct3D_Master() S3D_MASTER:: ~S3D_MASTER()
/***************************************/ /***************************************/
{ {
Struct3D_Shape* next; Struct3D_Shape* next;
S3D_Material* nextmat; S3D_MATERIAL* nextmat;
for( ; m_3D_Drawings != NULL; m_3D_Drawings = next ) for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
{ {
......
...@@ -472,7 +472,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) ...@@ -472,7 +472,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
} }
/* Draw module shape: 3D shape if exists (or module edge if not exists) */ /* Draw module shape: 3D shape if exists (or module edge if not exists) */
Struct3D_Master* Struct3D = m_3D_Drawings; S3D_MASTER* Struct3D = m_3D_Drawings;
bool As3dShape = FALSE; bool As3dShape = FALSE;
if( g_Parm_3D_Visu.m_Draw3DModule ) if( g_Parm_3D_Visu.m_Draw3DModule )
{ {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
/***********************************/ /***********************************/
int Struct3D_Master:: ReadData() int S3D_MASTER:: ReadData()
/************************************/ /************************************/
{ {
char line[1024], * text; char line[1024], * text;
...@@ -81,7 +81,7 @@ int Struct3D_Master:: ReadData() ...@@ -81,7 +81,7 @@ int Struct3D_Master:: ReadData()
/*********************************************************/ /*********************************************************/
int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum ) int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum )
/*********************************************************/ /*********************************************************/
/* /*
...@@ -100,7 +100,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum ) ...@@ -100,7 +100,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum )
{ {
char line[512], * text, * command; char line[512], * text, * command;
wxString mat_name; wxString mat_name;
S3D_Material* material = NULL; S3D_MATERIAL* material = NULL;
// Lecture de la commande: // Lecture de la commande:
command = strtok( NULL, " \t\n\r" ); command = strtok( NULL, " \t\n\r" );
...@@ -123,7 +123,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum ) ...@@ -123,7 +123,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum )
if( stricmp( command, "DEF" ) == 0 ) if( stricmp( command, "DEF" ) == 0 )
{ {
material = new S3D_Material( this, mat_name ); material = new S3D_MATERIAL( this, mat_name );
Insert( material ); Insert( material );
...@@ -186,7 +186,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum ) ...@@ -186,7 +186,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum )
/**********************************************************/ /**********************************************************/
int Struct3D_Master::ReadChildren( FILE* file, int* LineNum ) int S3D_MASTER::ReadChildren( FILE* file, int* LineNum )
/***********************************************************/ /***********************************************************/
{ {
char line[1024], * text; char line[1024], * text;
...@@ -215,7 +215,7 @@ int Struct3D_Master::ReadChildren( FILE* file, int* LineNum ) ...@@ -215,7 +215,7 @@ int Struct3D_Master::ReadChildren( FILE* file, int* LineNum )
/********************************************************/ /********************************************************/
int Struct3D_Master::ReadShape( FILE* file, int* LineNum ) int S3D_MASTER::ReadShape( FILE* file, int* LineNum )
/********************************************************/ /********************************************************/
{ {
char line[1024], * text; char line[1024], * text;
...@@ -250,7 +250,7 @@ int Struct3D_Master::ReadShape( FILE* file, int* LineNum ) ...@@ -250,7 +250,7 @@ int Struct3D_Master::ReadShape( FILE* file, int* LineNum )
/*************************************************************/ /*************************************************************/
int Struct3D_Master::ReadAppearance( FILE* file, int* LineNum ) int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum )
/*************************************************************/ /*************************************************************/
{ {
char line[1024], * text; char line[1024], * text;
...@@ -381,7 +381,7 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNu ...@@ -381,7 +381,7 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNu
/***********************************************************/ /***********************************************************/
int Struct3D_Master::ReadGeometry( FILE* file, int* LineNum ) int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
/***********************************************************/ /***********************************************************/
{ {
char line[1024], buffer[1024], * text; char line[1024], buffer[1024], * text;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define UNITS3D_TO_UNITSPCB 1000 #define UNITS3D_TO_UNITSPCB 1000
class Struct3D_Master; class S3D_MASTER;
class Struct3D_Shape; class Struct3D_Shape;
class S3D_Color /* This is a 3D color (R, G, G) 3 floats range 0 to 1.0*/ class S3D_Color /* This is a 3D color (R, G, G) 3 floats range 0 to 1.0*/
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
S3D_Vertex(); S3D_Vertex();
}; };
class S3D_Material : public EDA_BaseStruct /* openGL "material" data*/ class S3D_MATERIAL : public EDA_BaseStruct /* openGL "material" data*/
{ {
public: public:
wxString m_Name; wxString m_Name;
...@@ -46,17 +46,17 @@ public: ...@@ -46,17 +46,17 @@ public:
float m_Shininess; float m_Shininess;
public: public:
S3D_Material( Struct3D_Master * father, const wxString &name ); S3D_MATERIAL( S3D_MASTER * father, const wxString &name );
S3D_Material* Next() const { return (S3D_Material*) Pnext; } S3D_MATERIAL* Next() const { return (S3D_MATERIAL*) Pnext; }
S3D_Material* Back() const { return (S3D_Material*) Pback; } S3D_MATERIAL* Back() const { return (S3D_MATERIAL*) Pback; }
void SetMaterial(); void SetMaterial();
}; };
/*******************************************/ /*******************************************/
class Struct3D_Master : public EDA_BaseStruct class S3D_MASTER : public EDA_BaseStruct
/*******************************************/ /*******************************************/
/* Master structure for a 3D item description */ /* Master structure for a 3D item description */
{ {
...@@ -66,23 +66,23 @@ public: ...@@ -66,23 +66,23 @@ public:
S3D_Vertex m_MatRotation; S3D_Vertex m_MatRotation;
S3D_Vertex m_MatPosition; S3D_Vertex m_MatPosition;
Struct3D_Shape* m_3D_Drawings; Struct3D_Shape* m_3D_Drawings;
S3D_Material* m_Materials; S3D_MATERIAL* m_Materials;
public: public:
Struct3D_Master( EDA_BaseStruct * aParent ); S3D_MASTER( EDA_BaseStruct * aParent );
~Struct3D_Master(); ~S3D_MASTER();
Struct3D_Master* Next() const { return (Struct3D_Master*) Pnext; } S3D_MASTER* Next() const { return (S3D_MASTER*) Pnext; }
Struct3D_Master* Back() const { return (Struct3D_Master*) Pback; } S3D_MASTER* Back() const { return (S3D_MASTER*) Pback; }
void Insert( S3D_Material* aMaterial ) void Insert( S3D_MATERIAL* aMaterial )
{ {
aMaterial->SetNext( m_Materials ); aMaterial->SetNext( m_Materials );
m_Materials = aMaterial; m_Materials = aMaterial;
} }
void Copy( Struct3D_Master* pattern ); void Copy( S3D_MASTER* pattern );
int ReadData(); int ReadData();
int ReadMaterial( FILE* file, int* LineNum ); int ReadMaterial( FILE* file, int* LineNum );
int ReadChildren( FILE* file, int* LineNum ); int ReadChildren( FILE* file, int* LineNum );
......
...@@ -5,6 +5,15 @@ Started 2007-June-11 ...@@ -5,6 +5,15 @@ 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-5 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew & gerbview
* Renamed Struct3D_Master to S3D_MASTER.
* MODULE::m_3D_Drawings is now a DLIST<>
* Removed AddToChain(), DeleteStructList() and replaced with calls to DLIST<>
members so that list item counting stays accurate.
2008-Dec-05 UPDATE Wayne Stambaugh <stambaughw@verizon.net> 2008-Dec-05 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================ ================================================================================
++all ++all
......
...@@ -56,37 +56,6 @@ void EDA_BaseStruct::InitVars() ...@@ -56,37 +56,6 @@ void EDA_BaseStruct::InitVars()
} }
/***********************************************************/
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 )
/*********************************************************/
/*
* Add "this" to the linked list, after laststruct
*/
{
Pnext = laststruct->Pnext;
Pback = laststruct;
laststruct->Pnext = this;
}
// see base_struct.h // see base_struct.h
SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
INSPECTOR* inspector, INSPECTOR* inspector,
......
...@@ -45,7 +45,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -45,7 +45,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
for( ; g_UnDeleteStackPtr != 0; ) for( ; g_UnDeleteStackPtr != 0; )
{ {
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
g_UnDeleteStack[ g_UnDeleteStackPtr]->DeleteStructList(); delete g_UnDeleteStack[ g_UnDeleteStackPtr];
} }
/* init pointeurs et variables */ /* init pointeurs et variables */
...@@ -89,26 +89,24 @@ void WinEDA_GerberFrame::Erase_Zones( bool query ) ...@@ -89,26 +89,24 @@ void WinEDA_GerberFrame::Erase_Zones( bool query )
void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query ) void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
/************************************************************************/ /************************************************************************/
{ {
BOARD_ITEM* PtStruct; int layer = GetScreen()->m_Active_Layer;
BOARD_ITEM* PtNext;
int layer = GetScreen()->m_Active_Layer;
if( all_layers ) if( all_layers )
layer = -1; layer = -1;
PtStruct = m_Pcb->m_Drawings; BOARD_ITEM* next;
for( ; PtStruct != NULL; PtStruct = PtNext ) for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = next )
{ {
PtNext = PtStruct->Next(); next = item->Next();
switch( PtStruct->Type() ) switch( item->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPE_TEXTE: case TYPE_TEXTE:
case TYPE_COTATION: case TYPE_COTATION:
case TYPE_MIRE: case TYPE_MIRE:
if( PtStruct->GetLayer() == layer || layer < 0 ) if( item->GetLayer() == layer || layer < 0 )
PtStruct->DeleteStructure(); m_Pcb->Delete( item );
break; break;
default: default:
......
...@@ -424,24 +424,6 @@ public: ...@@ -424,24 +424,6 @@ public:
} }
/**
* Function DeleteStructList
* deletes each item in a linked list of EDA_BaseStructs, starting with
* "this" object.
*/
void DeleteStructList();
/**
* Function AddToChain
* adds this item just after laststruct in a linked list established
* by the Prev and Back pointers of my base EDA_BaseStruct.
* @deprecated
* @param laststruct The item to add after
*/
void AddToChain( EDA_BaseStruct* laststruct );
#if defined (DEBUG) #if defined (DEBUG)
/** /**
......
...@@ -192,26 +192,6 @@ wxPoint& BOARD::GetPosition() ...@@ -192,26 +192,6 @@ wxPoint& BOARD::GetPosition()
} }
void BOARD::UnLink()
{
/* Update back link */
if( Back() )
{
if( Back()->Type() == TYPE_PCB )
{
Back()->SetNext( Next() );
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
{ {
if ( aBoardItem == NULL ) if ( aBoardItem == NULL )
...@@ -316,6 +296,31 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem ) ...@@ -316,6 +296,31 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
} }
break; break;
case TYPE_MODULE:
delete m_Modules.Remove( (MODULE*) aBoardItem );
break;
case TYPE_TRACK:
case TYPE_VIA:
delete m_Track.Remove( (TRACK*) aBoardItem );
break;
case TYPE_ZONE:
delete m_Zone.Remove( (SEGZONE*) aBoardItem );
break;
case TYPE_COTATION:
case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
case TYPE_EDGE_MODULE:
case TYPE_MIRE:
delete m_Drawings.Remove( aBoardItem );
break;
case TYPE_EQUIPOT:
delete m_Equipots.Remove( (EQUIPOT*) aBoardItem );
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::Delete() needs work") );
......
...@@ -115,8 +115,6 @@ public: ...@@ -115,8 +115,6 @@ public:
*/ */
wxPoint& GetPosition(); wxPoint& GetPosition();
/* supprime du chainage la structure Struct */
void UnLink();
/** /**
* Function Add * Function Add
......
...@@ -57,7 +57,6 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset ...@@ -57,7 +57,6 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset
MODULE::MODULE( BOARD* parent ) : MODULE::MODULE( BOARD* parent ) :
BOARD_ITEM( parent, TYPE_MODULE ) BOARD_ITEM( parent, TYPE_MODULE )
{ {
m_3D_Drawings = NULL;
m_Attributs = MOD_DEFAULT; m_Attributs = MOD_DEFAULT;
m_Layer = CMP_N; m_Layer = CMP_N;
m_Orient = 0; m_Orient = 0;
...@@ -74,48 +73,40 @@ MODULE::MODULE( BOARD* parent ) : ...@@ -74,48 +73,40 @@ MODULE::MODULE( BOARD* parent ) :
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 = new Struct3D_Master( this ); m_3D_Drawings.PushBack( new S3D_MASTER( this ) );
} }
MODULE::~MODULE() MODULE::~MODULE()
{ {
EDA_BaseStruct* item;
EDA_BaseStruct* next;
delete m_Reference; delete m_Reference;
delete m_Value; delete m_Value;
for( item = m_3D_Drawings; item; item = next )
{
next = item->Next();
delete item;
}
} }
/*********************************/ /*********************************/
void MODULE::Copy( MODULE* Module ) void MODULE::Copy( MODULE* aModule )
/*********************************/ /*********************************/
{ {
m_Pos = Module->m_Pos; m_Pos = aModule->m_Pos;
m_Layer = Module->m_Layer; m_Layer = aModule->m_Layer;
m_LibRef = Module->m_LibRef; m_LibRef = aModule->m_LibRef;
m_Attributs = Module->m_Attributs; m_Attributs = aModule->m_Attributs;
m_Orient = Module->m_Orient; m_Orient = aModule->m_Orient;
m_BoundaryBox = Module->m_BoundaryBox; m_BoundaryBox = aModule->m_BoundaryBox;
m_PadNum = Module->m_PadNum; m_PadNum = aModule->m_PadNum;
m_CntRot90 = Module->m_CntRot90; m_CntRot90 = aModule->m_CntRot90;
m_CntRot180 = Module->m_CntRot180; m_CntRot180 = aModule->m_CntRot180;
m_LastEdit_Time = Module->m_LastEdit_Time; m_LastEdit_Time = aModule->m_LastEdit_Time;
m_Path = Module->m_Path; //is this correct behavior? m_Path = aModule->m_Path; //is this correct behavior?
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
/* Copy des structures auxiliaires: Reference et value */ /* Copy des structures auxiliaires: Reference et value */
m_Reference->Copy( Module->m_Reference ); m_Reference->Copy( aModule->m_Reference );
m_Value->Copy( Module->m_Value ); m_Value->Copy( aModule->m_Value );
/* Copie des structures auxiliaires: Pads */ /* Copie des structures auxiliaires: Pads */
for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() )
{ {
D_PAD* newpad = new D_PAD( this ); D_PAD* newpad = new D_PAD( this );
newpad->Copy( pad ); newpad->Copy( pad );
...@@ -124,7 +115,7 @@ void MODULE::Copy( MODULE* Module ) ...@@ -124,7 +115,7 @@ void MODULE::Copy( MODULE* Module )
} }
/* Copy des structures auxiliaires: Drawings */ /* Copy des structures auxiliaires: Drawings */
for( BOARD_ITEM* item = Module->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aModule->m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -148,25 +139,16 @@ void MODULE::Copy( MODULE* Module ) ...@@ -148,25 +139,16 @@ void MODULE::Copy( MODULE* Module )
} }
} }
/* Copy des elements complementaires Drawings 3D */ for( S3D_MASTER* item = aModule->m_3D_Drawings; item; item = item->Next() )
m_3D_Drawings->Copy( Module->m_3D_Drawings );
Struct3D_Master* Struct3D, * NewStruct3D, * CurrStruct3D;
Struct3D = Module->m_3D_Drawings->Next();
CurrStruct3D = m_3D_Drawings;
for( ; Struct3D != NULL; Struct3D = Struct3D->Next() )
{ {
NewStruct3D = new Struct3D_Master( this ); S3D_MASTER* t3d = new S3D_MASTER( this );
NewStruct3D->Copy( Struct3D ); t3d->Copy( item );
CurrStruct3D->SetNext( NewStruct3D ); m_3D_Drawings.PushBack( t3d );
NewStruct3D->SetBack( CurrStruct3D );
CurrStruct3D = NewStruct3D;
} }
/* Copie des elements complementaires */ /* Copie des elements complementaires */
m_Doc = Module->m_Doc; m_Doc = aModule->m_Doc;
m_KeyWord = Module->m_KeyWord; m_KeyWord = aModule->m_KeyWord;
} }
...@@ -360,7 +342,7 @@ int MODULE::Write_3D_Descr( FILE* File ) const ...@@ -360,7 +342,7 @@ int MODULE::Write_3D_Descr( FILE* File ) const
*/ */
{ {
char buf[512]; char buf[512];
Struct3D_Master* Struct3D = m_3D_Drawings; S3D_MASTER* Struct3D = m_3D_Drawings;
for( ; Struct3D != NULL; Struct3D = Struct3D->Next() ) for( ; Struct3D != NULL; Struct3D = Struct3D->Next() )
{ {
...@@ -406,19 +388,17 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum ) ...@@ -406,19 +388,17 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
*/ */
{ {
char Line[1024]; char Line[1024];
char* text = Line + 3; char* text = Line + 3;
Struct3D_Master* Struct3D = m_3D_Drawings;
S3D_MASTER* Struct3D = m_3D_Drawings;
if( !Struct3D->m_Shape3DName.IsEmpty() ) if( !Struct3D->m_Shape3DName.IsEmpty() )
{ {
Struct3D_Master* NewStruct3D; S3D_MASTER* n3D = new S3D_MASTER( this );
while( Struct3D->Next() )
Struct3D = Struct3D->Next(); m_3D_Drawings.PushBack( n3D );
NewStruct3D = new Struct3D_Master( this ); Struct3D = n3D;
Struct3D->SetNext( NewStruct3D );
NewStruct3D->SetBack( Struct3D );
Struct3D = NewStruct3D;
} }
while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL ) while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL )
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
class Pcb3D_GLCanvas; class Pcb3D_GLCanvas;
class Struct3D_Master; class S3D_MASTER;
/************************************/ /************************************/
/* Modules (footprints) description */ /* Modules (footprints) description */
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
wxPoint m_Pos; // Real coord on board wxPoint m_Pos; // Real coord on board
DLIST<D_PAD> m_Pads; /* Pad list (linked list) */ DLIST<D_PAD> m_Pads; /* Pad list (linked list) */
DLIST<BOARD_ITEM> m_Drawings; /* Graphic items list (linked list) */ DLIST<BOARD_ITEM> m_Drawings; /* Graphic items list (linked list) */
Struct3D_Master* m_3D_Drawings; /* First item of the 3D shapes (linked list)*/ DLIST<S3D_MASTER> m_3D_Drawings; /* First item of the 3D shapes (linked list)*/
TEXTE_MODULE* m_Reference; // Component reference (U34, R18..) TEXTE_MODULE* m_Reference; // Component reference (U34, R18..)
TEXTE_MODULE* m_Value; // Component value (74LS00, 22K..) TEXTE_MODULE* m_Value; // Component value (74LS00, 22K..)
wxString m_LibRef; /* Name of the module in library (and the default value when loading amodule from the library) */ wxString m_LibRef; /* Name of the module in library (and the default value when loading amodule from the library) */
......
...@@ -100,9 +100,9 @@ void WinEDA_ModulePropertiesFrame::CreateControls() ...@@ -100,9 +100,9 @@ void WinEDA_ModulePropertiesFrame::CreateControls()
/* creation des autres formes 3D */ /* creation des autres formes 3D */
Panel3D_Ctrl* panel3D = m_Panel3D, * nextpanel3D; Panel3D_Ctrl* panel3D = m_Panel3D, * nextpanel3D;
Struct3D_Master* draw3D = m_CurrentModule->m_3D_Drawings; S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
draw3D = (Struct3D_Master*) draw3D->Next(); draw3D = (S3D_MASTER*) draw3D->Next();
for( ; draw3D != NULL; draw3D = (Struct3D_Master*) draw3D->Next() ) for( ; draw3D != NULL; draw3D = (S3D_MASTER*) draw3D->Next() )
{ {
nextpanel3D = new Panel3D_Ctrl( this, m_NoteBook, -1, draw3D ); nextpanel3D = new Panel3D_Ctrl( this, m_NoteBook, -1, draw3D );
m_NoteBook->AddPage( nextpanel3D, _( "3D settings" ), FALSE ); m_NoteBook->AddPage( nextpanel3D, _( "3D settings" ), FALSE );
...@@ -382,7 +382,7 @@ void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties( bool FullOptions ...@@ -382,7 +382,7 @@ void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties( bool FullOptions
/**************************************************************/ /**************************************************************/
Panel3D_Ctrl::Panel3D_Ctrl( WinEDA_ModulePropertiesFrame* parentframe, Panel3D_Ctrl::Panel3D_Ctrl( WinEDA_ModulePropertiesFrame* parentframe,
wxNotebook* parent, wxNotebook* parent,
int id, Struct3D_Master* struct3D ) : int id, S3D_MASTER* struct3D ) :
wxPanel( parent, id ) wxPanel( parent, id )
/**************************************************************/ /**************************************************************/
...@@ -594,31 +594,34 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event ) ...@@ -594,31 +594,34 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event )
/* Mise a jour des parametres 3D */ /* Mise a jour des parametres 3D */
Panel3D_Ctrl* panel3D = m_Panel3D; Panel3D_Ctrl* panel3D = m_Panel3D;
Struct3D_Master* draw3D = m_CurrentModule->m_3D_Drawings, S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
* nextdraw3D; S3D_MASTER* nextdraw3D;
for( ; panel3D != NULL; panel3D = panel3D->m_Pnext ) for( ; panel3D != NULL; panel3D = panel3D->m_Pnext )
{ {
draw3D->m_Shape3DName = panel3D->m_3D_ShapeName->GetValue(); draw3D->m_Shape3DName = panel3D->m_3D_ShapeName->GetValue();
draw3D->m_MatScale = panel3D->m_3D_Scale->GetValue(); draw3D->m_MatScale = panel3D->m_3D_Scale->GetValue();
draw3D->m_MatRotation = panel3D->m_3D_Rotation->GetValue(); draw3D->m_MatRotation = panel3D->m_3D_Rotation->GetValue();
draw3D->m_MatPosition = panel3D->m_3D_Offset->GetValue(); draw3D->m_MatPosition = panel3D->m_3D_Offset->GetValue();
if( ( draw3D->m_Shape3DName.IsEmpty() ) if( ( draw3D->m_Shape3DName.IsEmpty() )
&& (draw3D != m_CurrentModule->m_3D_Drawings) ) && (draw3D != m_CurrentModule->m_3D_Drawings) )
continue; continue;
if( (draw3D->Next() == NULL) && panel3D->m_Pnext ) if( (draw3D->Next() == NULL) && panel3D->m_Pnext )
{ {
nextdraw3D = new Struct3D_Master( draw3D ); nextdraw3D = new S3D_MASTER( draw3D );
nextdraw3D->SetBack( draw3D );
draw3D->SetNext( nextdraw3D ); // insert after draw3D, therefore pass ->Next() to insert before the next.
m_CurrentModule->m_3D_Drawings.Insert( nextdraw3D, draw3D->Next() );
} }
draw3D = (Struct3D_Master*) draw3D->Next(); draw3D = (S3D_MASTER*) draw3D->Next();
} }
for( ; draw3D != NULL; draw3D = nextdraw3D ) for( ; draw3D != NULL; draw3D = nextdraw3D )
{ {
nextdraw3D = (Struct3D_Master*) draw3D->Next(); nextdraw3D = (S3D_MASTER*) draw3D->Next();
(draw3D->Back())->SetNext( NULL );
delete draw3D; delete m_CurrentModule->m_3D_Drawings.Remove( draw3D );
} }
m_CurrentModule->Set_Rectangle_Encadrement(); m_CurrentModule->Set_Rectangle_Encadrement();
......
/************************************************/ /************************************************/
/* Module editor: Dialog box for editing module */ /* Module editor: Dialog box for editing module */
/* properties and carateristics */ /* properties and carateristics */
/************************************************/ /************************************************/
enum id_Module_properties enum id_Module_properties
{ {
ID_GOTO_MODULE_EDITOR =1900, ID_GOTO_MODULE_EDITOR =1900,
ID_MODULE_PROPERTIES_EXCHANGE, ID_MODULE_PROPERTIES_EXCHANGE,
ID_MODULE_EDIT_ADD_TEXT, ID_MODULE_EDIT_ADD_TEXT,
ID_MODULE_EDIT_EDIT_TEXT, ID_MODULE_EDIT_EDIT_TEXT,
ID_MODULE_EDIT_DELETE_TEXT, ID_MODULE_EDIT_DELETE_TEXT,
ID_MODULE_LISTBOX_SELECT, ID_MODULE_LISTBOX_SELECT,
ID_LISTBOX_ORIENT_SELECT, ID_LISTBOX_ORIENT_SELECT,
ID_BROWSE_3D_LIB, ID_BROWSE_3D_LIB,
ID_ADD_3D_SHAPE, ID_ADD_3D_SHAPE,
ID_REMOVE_3D_SHAPE, ID_REMOVE_3D_SHAPE,
ID_NOTEBOOK, ID_NOTEBOOK,
ID_MODULE_EDIT_X_POSITION, ID_MODULE_EDIT_X_POSITION,
ID_MODULE_EDIT_Y_POSITION ID_MODULE_EDIT_Y_POSITION
}; };
class Panel3D_Ctrl; class Panel3D_Ctrl;
/**************************************/ /**************************************/
/* class WinEDA_ModulePropertiesFrame */ /* class WinEDA_ModulePropertiesFrame */
/**************************************/ /**************************************/
class WinEDA_ModulePropertiesFrame: public wxDialog class WinEDA_ModulePropertiesFrame: public wxDialog
{ {
private: private:
WinEDA_BasePcbFrame * m_Parent; WinEDA_BasePcbFrame * m_Parent;
wxDC * m_DC; wxDC * m_DC;
MODULE * m_CurrentModule; MODULE * m_CurrentModule;
wxNotebook* m_NoteBook; wxNotebook* m_NoteBook;
wxPanel * m_PanelProperties; wxPanel * m_PanelProperties;
Panel3D_Ctrl * m_Panel3D; Panel3D_Ctrl * m_Panel3D;
WinEDAChoiceBox * m_TextListBox; WinEDAChoiceBox * m_TextListBox;
wxRadioBox * m_LayerCtrl; wxRadioBox * m_LayerCtrl;
wxRadioBox * m_OrientCtrl; wxRadioBox * m_OrientCtrl;
wxTextCtrl * m_OrientValue; wxTextCtrl * m_OrientValue;
wxRadioBox * m_AttributsCtrl; wxRadioBox * m_AttributsCtrl;
wxRadioBox * m_AutoPlaceCtrl; wxRadioBox * m_AutoPlaceCtrl;
wxSlider * m_CostRot90Ctrl, * m_CostRot180Ctrl; wxSlider * m_CostRot90Ctrl, * m_CostRot180Ctrl;
wxButton * m_DeleteFieddButton; wxButton * m_DeleteFieddButton;
wxTextCtrl *m_Doc, *m_Keyword; wxTextCtrl *m_Doc, *m_Keyword;
wxBoxSizer * m_GeneralBoxSizer; wxBoxSizer * m_GeneralBoxSizer;
wxBoxSizer* m_PanelPropertiesBoxSizer; wxBoxSizer* m_PanelPropertiesBoxSizer;
wxTextCtrl *m_ModPositionX, *m_ModPositionY; wxTextCtrl *m_ModPositionX, *m_ModPositionY;
wxString *m_ModPosXStr, *m_ModPosYStr; wxString *m_ModPosXStr, *m_ModPosYStr;
public: public:
// Constructor and destructor // Constructor and destructor
WinEDA_ModulePropertiesFrame(WinEDA_BasePcbFrame *parent, WinEDA_ModulePropertiesFrame(WinEDA_BasePcbFrame *parent,
MODULE * Module, wxDC * DC, const wxPoint & pos); MODULE * Module, wxDC * DC, const wxPoint & pos);
~WinEDA_ModulePropertiesFrame() ~WinEDA_ModulePropertiesFrame()
{ {
} }
private: private:
void CreateControls(); void CreateControls();
void OnCancelClick(wxCommandEvent& event); void OnCancelClick(wxCommandEvent& event);
void OnOkClick(wxCommandEvent& event); void OnOkClick(wxCommandEvent& event);
void CreateTextModule(wxCommandEvent& event); void CreateTextModule(wxCommandEvent& event);
void EditOrDelTextModule(wxCommandEvent& event); void EditOrDelTextModule(wxCommandEvent& event);
void SelectTextListBox(wxCommandEvent& event); void SelectTextListBox(wxCommandEvent& event);
void ReCreateFieldListBox(); void ReCreateFieldListBox();
void SetTextListButtons(); void SetTextListButtons();
void BuildPanelModuleProperties(bool FullOptions); void BuildPanelModuleProperties(bool FullOptions);
void ModuleOrientEvent(wxCommandEvent& event); void ModuleOrientEvent(wxCommandEvent& event);
void ExchangeModule(wxCommandEvent& event); void ExchangeModule(wxCommandEvent& event);
void GotoModuleEditor(wxCommandEvent& event); void GotoModuleEditor(wxCommandEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -82,18 +82,18 @@ class Panel3D_Ctrl: public wxPanel ...@@ -82,18 +82,18 @@ class Panel3D_Ctrl: public wxPanel
/* panel d'entree des caract 3D */ /* panel d'entree des caract 3D */
{ {
public: public:
Panel3D_Ctrl * m_Pnext, * m_Pback; // Chainage Panel3D_Ctrl * m_Pnext, * m_Pback; // Chainage
wxNotebook * m_Parent; wxNotebook * m_Parent;
WinEDA_ModulePropertiesFrame * m_ParentFrame; WinEDA_ModulePropertiesFrame * m_ParentFrame;
wxBoxSizer* m_Panel3DBoxSizer; wxBoxSizer* m_Panel3DBoxSizer;
wxTextCtrl * m_3D_ShapeName; wxTextCtrl * m_3D_ShapeName;
WinEDA_VertexCtrl *m_3D_Scale, *m_3D_Offset, *m_3D_Rotation; WinEDA_VertexCtrl *m_3D_Scale, *m_3D_Offset, *m_3D_Rotation;
public: public:
Panel3D_Ctrl(WinEDA_ModulePropertiesFrame * parentframe, Panel3D_Ctrl(WinEDA_ModulePropertiesFrame * parentframe,
wxNotebook * parent, int id, Struct3D_Master * struct3D); wxNotebook * parent, int id, S3D_MASTER * struct3D);
~Panel3D_Ctrl(); ~Panel3D_Ctrl();
void Browse3DLib(wxCommandEvent& event); void Browse3DLib(wxCommandEvent& event);
void AddOrRemove3DShape(wxCommandEvent& event); void AddOrRemove3DShape(wxCommandEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -335,61 +335,75 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -335,61 +335,75 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
* @return the new created edge. * @return the new created edge.
*/ */
{ {
MODULE* Module = m_Pcb->m_Modules; MODULE* module = m_Pcb->m_Modules;
int angle = 0; int angle = 0;
if( Module == NULL ) if( module == NULL )
return NULL; return NULL;
if( Edge == NULL ) /* Start a new edge item */ if( Edge == NULL ) /* Start a new edge item */
{ {
SaveCopyInUndoList( Module ); SaveCopyInUndoList( module );
Edge = new EDGE_MODULE( Module );
Edge = new EDGE_MODULE( module );
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
/* Add the new item to the Drawings list head*/ /* Add the new item to the Drawings list head*/
Module->m_Drawings.PushFront( Edge ); module->m_Drawings.PushFront( Edge );
/* Mise a jour des caracteristiques du segment ou de l'arc */ /* Mise a jour des caracteristiques du segment ou de l'arc */
Edge->m_Flags = IS_NEW; Edge->m_Flags = IS_NEW;
Edge->m_Angle = angle; Edge->m_Angle = angle;
Edge->m_Shape = type_edge; Edge->m_Shape = type_edge;
if( Edge->m_Shape == S_ARC ) if( Edge->m_Shape == S_ARC )
Edge->m_Angle = ArcValue; Edge->m_Angle = ArcValue;
Edge->m_Width = ModuleSegmentWidth; Edge->m_Width = ModuleSegmentWidth;
Edge->SetLayer( Module->GetLayer() ); Edge->SetLayer( module->GetLayer() );
if( Module->GetLayer() == CMP_N )
if( module->GetLayer() == CMP_N )
Edge->SetLayer( SILKSCREEN_N_CMP ); Edge->SetLayer( SILKSCREEN_N_CMP );
if( Module->GetLayer() == COPPER_LAYER_N ) if( module->GetLayer() == COPPER_LAYER_N )
Edge->SetLayer( SILKSCREEN_N_CU ); Edge->SetLayer( SILKSCREEN_N_CU );
/* Initialise the starting point of the new segment or arc */ /* Initialise the starting point of the new segment or arc */
Edge->m_Start = GetScreen()->m_Curseur; Edge->m_Start = GetScreen()->m_Curseur;
/* Initialise the ending point of the new segment or arc */ /* Initialise the ending point of the new segment or arc */
Edge->m_End = Edge->m_Start; Edge->m_End = Edge->m_Start;
/* Initialise the relative coordinates */ /* Initialise the relative coordinates */
Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; Edge->m_Start0.x = Edge->m_Start.x - module->m_Pos.x;
Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; Edge->m_Start0.y = Edge->m_Start.y - module->m_Pos.y;
RotatePoint( (int*) &(Edge->m_Start0.x),
(int*) &(Edge->m_Start0.y), -Module->m_Orient ); RotatePoint( (int*) &Edge->m_Start0.x,
(int*) &Edge->m_Start0.y, -module->m_Orient );
Edge->m_End0 = Edge->m_Start0; Edge->m_End0 = Edge->m_Start0;
Module->Set_Rectangle_Encadrement(); module->Set_Rectangle_Encadrement();
DrawPanel->ManageCurseur = ShowEdgeModule; DrawPanel->ManageCurseur = ShowEdgeModule;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module;
} }
else /* trace en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Montre_Position_New_Edge_Module*/ /* trace en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Montre_Position_New_Edge_Module
*/
else
{ {
if( type_edge == S_SEGMENT ) if( type_edge == S_SEGMENT )
{ {
if( (Edge->m_Start0.x) != (Edge->m_End0.x) if( Edge->m_Start0 != Edge->m_End0 )
|| (Edge->m_Start0.y) != (Edge->m_End0.y) )
{ {
Edge->Draw( DrawPanel, DC, GR_OR ); Edge->Draw( DrawPanel, DC, GR_OR );
EDGE_MODULE* newedge = new EDGE_MODULE( Module );
EDGE_MODULE* newedge = new EDGE_MODULE( module );
newedge->Copy( Edge ); newedge->Copy( Edge );
newedge->AddToChain( Edge );
// insert _after_ Edge, which is the same as inserting _before_ Edge->Next()
module->m_Drawings.Insert( newedge, Edge->Next() );
Edge->m_Flags = 0; Edge->m_Flags = 0;
Edge = newedge; Edge = newedge;
...@@ -399,14 +413,16 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -399,14 +413,16 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge->m_End = Edge->m_Start; Edge->m_End = Edge->m_Start;
/* Mise a jour des coord relatives */ /* Mise a jour des coord relatives */
Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; Edge->m_Start0.x = Edge->m_Start.x - module->m_Pos.x;
Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; Edge->m_Start0.y = Edge->m_Start.y - module->m_Pos.y;
RotatePoint( (int*) &(Edge->m_Start0.x),
(int*) &(Edge->m_Start0.y), -Module->m_Orient ); RotatePoint( (int*) &Edge->m_Start0.x,
(int*) &Edge->m_Start0.y, -module->m_Orient );
Edge->m_End0 = Edge->m_Start0; Edge->m_End0 = Edge->m_Start0;
Module->Set_Rectangle_Encadrement(); module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); module->m_LastEdit_Time = time( NULL );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
} }
......
...@@ -301,16 +301,21 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -301,16 +301,21 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc( PtSegm, PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900 ); PtSegm = gen_arc( PtSegm, PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900 );
if( lextbrin ) if( lextbrin )
{ {
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
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.x -= lextbrin; PtSegm->m_End.x -= lextbrin;
...@@ -322,7 +327,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -322,7 +327,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
int arc_angle; int arc_angle;
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
...@@ -338,7 +345,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -338,7 +345,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
{ {
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
if( ii & 1 ) if( ii & 1 )
...@@ -356,7 +365,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -356,7 +365,9 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
{ {
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
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.x -= lextbrin; PtSegm->m_End.x -= lextbrin;
...@@ -364,7 +375,8 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -364,7 +375,8 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm ); Module->m_Drawings.Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y; PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900 ); PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900 );
...@@ -375,14 +387,17 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -375,14 +387,17 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
{ {
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
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.x += lextbrin; PtSegm->m_End.x += lextbrin;
} }
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm );
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900 ); PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900 );
...@@ -390,7 +405,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -390,7 +405,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
newedge = new EDGE_MODULE( Module ); newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->AddToChain( PtSegm ); 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;
...@@ -420,9 +435,11 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -420,9 +435,11 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
Module->m_Pads.PushFront( PtPad ); Module->m_Pads.PushFront( PtPad );
PtPad->SetPadName( wxT( "1" ) ); PtPad->SetPadName( wxT( "1" ) );
PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y;
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x; PtPad->m_Pos = LastSegm->m_End;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width; PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width;
PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->GetLayer()]; PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->GetLayer()];
PtPad->m_Attribut = PAD_SMD; PtPad->m_Attribut = PAD_SMD;
...@@ -431,12 +448,15 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -431,12 +448,15 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
D_PAD* newpad = new D_PAD( Module ); D_PAD* newpad = new D_PAD( Module );
newpad->Copy( PtPad ); newpad->Copy( PtPad );
newpad->AddToChain( PtPad );
Module->m_Pads.Insert( newpad, PtPad->Next() );
PtPad = newpad; PtPad = newpad;
PtPad->SetPadName( wxT( "2" ) ); PtPad->SetPadName( wxT( "2" ) );
PtPad->m_Pos.x = FirstSegm->m_Start.x; PtPad->m_Pos.y = FirstSegm->m_Start.y;
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x; PtPad->m_Pos = FirstSegm->m_Start;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
/* Modif des positions textes */ /* Modif des positions textes */
Module->Display_Infos( this ); Module->Display_Infos( this );
...@@ -446,20 +466,19 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -446,20 +466,19 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
LastSegm->m_End.y ) / 2; LastSegm->m_End.y ) / 2;
Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y; Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y;
Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y; Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y;
Module->m_Reference->m_Pos0.x = Module->m_Reference->m_Pos.x - Module->m_Pos.x; Module->m_Reference->m_Pos0 = Module->m_Reference->m_Pos - Module->m_Pos;
Module->m_Reference->m_Pos0.y = Module->m_Reference->m_Pos.y - Module->m_Pos.y;
Module->m_Value->m_Pos0.x = Module->m_Value->m_Pos.x - Module->m_Pos.x; Module->m_Value->m_Pos0 = Module->m_Value->m_Pos - Module->m_Pos;
Module->m_Value->m_Pos0.y = Module->m_Value->m_Pos.y - Module->m_Pos.y;
/* Init des Coord locales des segments */ /* Init des Coord locales des segments */
for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Next() ) for( PtSegm = FirstSegm; PtSegm; PtSegm = PtSegm->Next() )
{ {
PtSegm->m_Start0.x = PtSegm->m_Start.x - Module->m_Pos.x; PtSegm->m_Start0 = PtSegm->m_Start - Module->m_Pos;
PtSegm->m_Start0.y = PtSegm->m_Start.y - Module->m_Pos.y;
PtSegm->m_End0.x = PtSegm->m_End.x - Module->m_Pos.x; PtSegm->m_End0 = PtSegm->m_End - Module->m_Pos;
PtSegm->m_End0.y = PtSegm->m_End.y - Module->m_Pos.y;
} }
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
...@@ -487,11 +506,17 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle ) ...@@ -487,11 +506,17 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle )
int x0, xr0, y0, yr0; int x0, xr0, y0, yr0;
EDGE_MODULE* newedge; EDGE_MODULE* newedge;
// m_Drawings in the board
DLIST<BOARD_ITEM>* list = (DLIST<BOARD_ITEM>*) PtSegm->GetList();
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;
alpha = ( (float) angle * 3.14159 / 1800 ) / nb_seg; alpha = ( (float) angle * 3.14159 / 1800 ) / nb_seg;
for( ii = 1; ii <= nb_seg; ii++ ) for( ii = 1; ii <= nb_seg; ii++ )
...@@ -501,9 +526,12 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle ) ...@@ -501,9 +526,12 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle )
newedge = new EDGE_MODULE( (MODULE*) NULL ); newedge = new EDGE_MODULE( (MODULE*) NULL );
newedge->Copy( PtSegm ); newedge->Copy( PtSegm );
newedge->SetParent( PtSegm->GetParent() ); newedge->SetParent( PtSegm->GetParent() );
newedge->AddToChain( PtSegm );
list->Insert( newedge, PtSegm->Next() );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
PtSegm->m_Start = PtSegm->m_End;
} }
beta = (alpha * ii); beta = (alpha * ii);
...@@ -511,7 +539,9 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle ) ...@@ -511,7 +539,9 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle )
xr0 = (int) (x0 * fcos + y0 * fsin); xr0 = (int) (x0 * fcos + y0 * fsin);
yr0 = (int) (y0 * fcos - x0 * fsin); yr0 = (int) (y0 * fcos - x0 * fsin);
PtSegm->m_End.x = cX + yr0; PtSegm->m_End.y = cY + xr0;
PtSegm->m_End.x = cX + yr0;
PtSegm->m_End.y = cY + xr0;
} }
return PtSegm; return PtSegm;
......
...@@ -134,7 +134,8 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query ) ...@@ -134,7 +134,8 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
while( g_UnDeleteStackPtr > 0 ) while( g_UnDeleteStackPtr > 0 )
{ {
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList();
delete g_UnDeleteStack[g_UnDeleteStackPtr];
} }
/* init pointeurs et variables */ /* init pointeurs et variables */
...@@ -214,7 +215,7 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( bool is_edges, bool query ) ...@@ -214,7 +215,7 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( bool is_edges, bool query )
case TYPE_COTATION: case TYPE_COTATION:
case TYPE_MIRE: case TYPE_MIRE:
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer ) if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
PtStruct->DeleteStructure(); m_Pcb->Delete( PtStruct );
break; break;
default: default:
......
...@@ -76,10 +76,15 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList() ...@@ -76,10 +76,15 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList()
GetScreen()->AddItemToRedoList( m_Pcb->m_Modules.PopFront() ); GetScreen()->AddItemToRedoList( m_Pcb->m_Modules.PopFront() );
m_Pcb->Add( (MODULE*) GetScreen()->GetItemFromUndoList() ); MODULE* module = (MODULE*) GetScreen()->GetItemFromUndoList();
if( module )
m_Pcb->Add( module, ADD_APPEND );
/* Add() calls PushBack(), no need for this
if( m_Pcb->m_Modules ) if( m_Pcb->m_Modules )
m_Pcb->m_Modules->SetNext( NULL ); m_Pcb->m_Modules->SetNext( NULL );
*/
GetScreen()->SetModify(); GetScreen()->SetModify();
SetCurItem( NULL );; SetCurItem( NULL );;
ReCreateHToolbar(); ReCreateHToolbar();
......
...@@ -239,8 +239,13 @@ MODULE* WinEDA_BasePcbFrame::Copie_Module( MODULE* module ) ...@@ -239,8 +239,13 @@ MODULE* WinEDA_BasePcbFrame::Copie_Module( MODULE* module )
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
newmodule = new MODULE( m_Pcb ); newmodule = new MODULE( m_Pcb );
newmodule->Copy( module ); newmodule->Copy( module );
/* no, Add() below does this
newmodule->SetParent( m_Pcb ); newmodule->SetParent( m_Pcb );
newmodule->AddToChain( module ); */
m_Pcb->Add( newmodule, ADD_APPEND );
newmodule->m_Flags = IS_NEW; newmodule->m_Flags = IS_NEW;
build_liste_pads(); build_liste_pads();
......
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
int timestamp, int timestamp,
const wxString& path ); const wxString& path );
~MODULEtoLOAD() { }; ~MODULEtoLOAD() { };
MODULEtoLOAD* Next() const { return (MODULEtoLOAD*) Pnext; } MODULEtoLOAD* Next() const { return (MODULEtoLOAD*) Pnext; }
}; };
...@@ -1027,7 +1028,8 @@ void LoadListeModules( WinEDA_PcbFrame* aPcbFrame, wxDC* DC ) ...@@ -1027,7 +1028,8 @@ void LoadListeModules( WinEDA_PcbFrame* aPcbFrame, wxDC* DC )
for( ii = 0; ii < s_NbNewModules; ii++, cmp = cmp->Next() ) for( ii = 0; ii < s_NbNewModules; ii++, cmp = cmp->Next() )
{ {
if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) ) if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) )
{ /* New footprint : must be loaded from a library */ {
/* New footprint : must be loaded from a library */
Module = aPcbFrame->Get_Librairie_Module( NULL, wxEmptyString, cmp->m_LibName, FALSE ); Module = aPcbFrame->Get_Librairie_Module( NULL, wxEmptyString, cmp->m_LibName, FALSE );
ref = cmp; ref = cmp;
if( Module == NULL ) if( Module == NULL )
...@@ -1051,9 +1053,12 @@ void LoadListeModules( WinEDA_PcbFrame* aPcbFrame, wxDC* DC ) ...@@ -1051,9 +1053,12 @@ void LoadListeModules( WinEDA_PcbFrame* aPcbFrame, wxDC* DC )
MODULE* newmodule; MODULE* newmodule;
if( Module == NULL ) if( Module == NULL )
continue; /* module non existant en libr */ continue; /* module non existant en libr */
newmodule = new MODULE( aPcbFrame->m_Pcb ); newmodule = new MODULE( aPcbFrame->m_Pcb );
newmodule->Copy( Module ); newmodule->Copy( Module );
newmodule->AddToChain( Module );
aPcbFrame->m_Pcb->Add( newmodule, ADD_APPEND );
Module = newmodule; Module = newmodule;
Module->m_Reference->m_Text = cmp->m_CmpName; Module->m_Reference->m_Text = cmp->m_CmpName;
Module->m_TimeStamp = cmp->m_TimeStamp; Module->m_TimeStamp = cmp->m_TimeStamp;
......
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