From 3ef380f936b01fcbd519391f9a685b22fa020801 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Mon, 24 Nov 2008 06:53:43 +0000 Subject: [PATCH] dlist cleanups, start of edit component in schematic rework --- 3d-viewer/3d_class.cpp | 98 +-- 3d-viewer/3d_draw.cpp | 10 +- 3d-viewer/3d_read_mesh.cpp | 9 +- 3d-viewer/3d_struct.h | 143 ++-- change_log.txt | 24 + common/CMakeLists.txt | 1 + common/base_screen.cpp | 35 +- common/base_struct.cpp | 27 +- common/block_commande.cpp | 2 +- common/dlist.cpp | 2 +- common/makefile.include | 63 +- eeschema/CMakeLists.txt | 3 +- eeschema/annotate.cpp | 6 +- eeschema/block.cpp | 64 +- eeschema/block_libedit.cpp | 2 +- eeschema/build_BOM.cpp | 38 +- eeschema/bus-wire-junction.cpp | 54 +- eeschema/class_drawsheet.cpp | 30 +- eeschema/class_library.cpp | 9 +- eeschema/class_screen.cpp | 12 +- eeschema/classes_body_items.h | 9 +- eeschema/cleanup.cpp | 10 +- eeschema/component_class.cpp | 8 +- eeschema/component_class.h | 35 +- eeschema/controle.cpp | 4 +- eeschema/dangling_ends.cpp | 2 +- eeschema/delete.cpp | 44 +- eeschema/delsheet.cpp | 164 ++-- .../dialog_edit_component_in_schematic.cpp | 722 +++++++++++------- eeschema/dialog_edit_component_in_schematic.h | 191 ++--- eeschema/edit_component_in_lib.cpp | 14 +- eeschema/edit_component_in_schematic.cpp | 605 ++------------- eeschema/edit_label.cpp | 2 +- eeschema/eelibs_draw_components.cpp | 6 +- eeschema/eelibs_read_libraryfiles.cpp | 21 +- eeschema/erc.cpp | 6 +- eeschema/files-io.cpp | 2 +- eeschema/getpart.cpp | 2 +- eeschema/hierarch.cpp | 2 +- eeschema/libedit_undo_redo.cpp | 113 +-- eeschema/libfield.cpp | 372 ++++----- eeschema/load_one_schematic_file.cpp | 28 +- eeschema/locate.cpp | 6 +- eeschema/netform.cpp | 12 +- eeschema/netlist.cpp | 4 +- eeschema/pinedit.cpp | 55 +- eeschema/plot.cpp | 13 +- eeschema/plothpgl.cpp | 4 +- eeschema/plotps.cpp | 2 +- eeschema/program.h | 3 + eeschema/savelib.cpp | 10 +- eeschema/schematic_undo_redo.cpp | 62 +- eeschema/schframe.cpp | 4 + eeschema/sheet.cpp | 6 +- eeschema/sheetlab.cpp | 18 +- eeschema/symbdraw.cpp | 2 +- eeschema/symbedit.cpp | 6 +- gerbview/deltrack.cpp | 14 +- gerbview/export_to_pcbnew.cpp | 2 +- gerbview/lay2plot.cpp | 42 +- gerbview/locate.cpp | 8 +- gerbview/rs274d.cpp | 4 +- gerbview/trpiste.cpp | 4 +- gerbview/undelete.cpp | 7 +- include/base_struct.h | 32 +- include/board_item_struct.h | 14 +- include/dlist.h | 3 +- include/drawpanel_wxstruct.h | 4 + include/wxEeschemaStruct.h | 30 +- pcbnew/affiche.cpp | 10 +- pcbnew/attribut.cpp | 4 +- pcbnew/automove.cpp | 8 +- pcbnew/autoplac.cpp | 22 +- pcbnew/autorout.cpp | 16 +- pcbnew/block.cpp | 54 +- pcbnew/block_module_editor.cpp | 12 +- pcbnew/board.cpp | 12 +- pcbnew/class_board.cpp | 82 +- pcbnew/class_cotation.cpp | 17 +- pcbnew/class_cotation.h | 3 + pcbnew/class_drawsegment.cpp | 21 +- pcbnew/class_drawsegment.h | 7 +- pcbnew/class_edge_mod.cpp | 17 +- pcbnew/class_edge_mod.h | 8 + pcbnew/class_equipot.cpp | 29 +- pcbnew/class_equipot.h | 3 +- pcbnew/class_mire.cpp | 21 +- pcbnew/class_mire.h | 3 + pcbnew/class_module.cpp | 207 +++-- pcbnew/class_module.h | 26 +- pcbnew/class_pad.cpp | 25 +- pcbnew/class_pad.h | 2 +- pcbnew/class_pcb_text.cpp | 17 +- pcbnew/class_text_mod.cpp | 17 +- pcbnew/class_text_mod.h | 3 + pcbnew/class_track.cpp | 259 ++++--- pcbnew/class_track.h | 7 +- pcbnew/connect.cpp | 28 +- pcbnew/cotation.cpp | 7 +- pcbnew/cross-probing.cpp | 4 +- pcbnew/deltrack.cpp | 12 +- pcbnew/dialog_edit_mod_text.cpp | 4 +- pcbnew/dialog_edit_module.cpp | 22 +- pcbnew/dialog_orient_footprints.cpp | 22 +- pcbnew/dialog_pad_properties.cpp | 4 +- pcbnew/dragsegm.cpp | 42 +- pcbnew/drc.cpp | 2 +- pcbnew/edgemod.cpp | 20 +- pcbnew/edit_track_width.cpp | 10 +- pcbnew/editedge.cpp | 14 +- pcbnew/editmod.cpp | 7 +- pcbnew/editrack-part2.cpp | 30 +- pcbnew/editrack.cpp | 24 +- pcbnew/edtxtmod.cpp | 18 +- pcbnew/export_gencad.cpp | 32 +- pcbnew/gen_drill_report_files.cpp | 2 +- pcbnew/gen_modules_placefile.cpp | 2 +- pcbnew/gen_self.h | 25 +- pcbnew/globaleditpad.cpp | 24 +- pcbnew/gpcb_exchange.cpp | 24 +- pcbnew/initpcb.cpp | 2 +- pcbnew/ioascii.cpp | 54 +- pcbnew/lay2plot.cpp | 32 +- pcbnew/librairi.cpp | 16 +- pcbnew/loadcmp.cpp | 20 +- pcbnew/locate.cpp | 16 +- pcbnew/mirepcb.cpp | 7 +- pcbnew/modedit.cpp | 20 +- pcbnew/modedit_undo_redo.cpp | 10 +- pcbnew/moduleframe.cpp | 2 +- pcbnew/modules.cpp | 18 +- pcbnew/move-drag_pads.cpp | 40 +- pcbnew/move_or_drag_track.cpp | 136 ++-- pcbnew/muonde.cpp | 18 +- pcbnew/netlist.cpp | 18 +- pcbnew/pcbtexte.cpp | 6 +- pcbnew/plot_rtn.cpp | 24 +- pcbnew/plotgerb.cpp | 16 +- pcbnew/plothpgl.cpp | 12 +- pcbnew/plotps.cpp | 12 +- pcbnew/ratsnest.cpp | 46 +- pcbnew/router.cpp | 6 +- pcbnew/solve.cpp | 23 +- pcbnew/surbrill.cpp | 6 +- pcbnew/swap_layers.cpp | 9 +- pcbnew/tr_modif.cpp | 20 +- pcbnew/tracemod.cpp | 9 +- pcbnew/tracepcb.cpp | 6 +- pcbnew/track.cpp | 24 +- pcbnew/undelete.cpp | 5 +- pcbnew/via_edit.cpp | 2 +- pcbnew/xchgmod.cpp | 26 +- 152 files changed, 2605 insertions(+), 2712 deletions(-) diff --git a/3d-viewer/3d_class.cpp b/3d-viewer/3d_class.cpp index 1ea95d3f08..192e1fd78e 100644 --- a/3d-viewer/3d_class.cpp +++ b/3d-viewer/3d_class.cpp @@ -1,4 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// + // Name: 3d_class.cpp ///////////////////////////////////////////////////////////////////////////// @@ -20,59 +21,62 @@ S3D_Vertex::S3D_Vertex() /****************************/ { - x = y = z = 0.0; + x = y = z = 0.0; } /**************************************************************************/ -S3D_Material::S3D_Material( Struct3D_Master * father, const wxString & name ): - EDA_BaseStruct( father, NOT_USED ) +S3D_Material::S3D_Material( Struct3D_Master* father, const wxString& name ) : + EDA_BaseStruct( father, NOT_USED ) /**************************************************************************/ { - m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0; - m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0; + m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0; + m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0; m_AmbientIntensity = 1.0; m_Transparency = 0.0; - m_Shininess = 1.0; - m_Name = name; + m_Shininess = 1.0; + m_Name = name; } + /***********************************/ void S3D_Material::SetMaterial() /***********************************/ { - glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); - glColor4f(m_DiffuseColor.x * m_AmbientIntensity, - m_DiffuseColor.y * m_AmbientIntensity, - m_DiffuseColor.z * m_AmbientIntensity, - 1.0 - m_Transparency ); + glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); + glColor4f( m_DiffuseColor.x * m_AmbientIntensity, + m_DiffuseColor.y * m_AmbientIntensity, + m_DiffuseColor.z * m_AmbientIntensity, + 1.0 - m_Transparency ); #if 0 - glColorMaterial(GL_FRONT_AND_BACK,GL_SPECULAR); - glColor3f(m_SpecularColor.x, m_SpecularColor.y,m_SpecularColor.z); + glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR ); + glColor3f( m_SpecularColor.x, m_SpecularColor.y, m_SpecularColor.z ); #endif - glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); + glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); } + /****************************************************/ -void Struct3D_Master::Copy(Struct3D_Master * pattern) +void Struct3D_Master::Copy( Struct3D_Master* pattern ) /****************************************************/ { - m_Shape3DName = pattern->m_Shape3DName; - m_MatScale = pattern->m_MatScale; - m_MatRotation = pattern->m_MatRotation; - m_MatPosition = pattern->m_MatPosition; - m_3D_Drawings = NULL; - m_Materials = NULL; + m_Shape3DName = pattern->m_Shape3DName; + m_MatScale = pattern->m_MatScale; + m_MatRotation = pattern->m_MatRotation; + m_MatPosition = pattern->m_MatPosition; + m_3D_Drawings = NULL; + m_Materials = NULL; } + /***************************************************************/ -Struct3D_Master::Struct3D_Master(EDA_BaseStruct * StructFather): - EDA_BaseStruct( StructFather, NOT_USED ) +Struct3D_Master::Struct3D_Master( EDA_BaseStruct* StructFather ) : + EDA_BaseStruct( StructFather, NOT_USED ) /***************************************************************/ { - m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0; - m_3D_Drawings = NULL; - m_Materials = NULL; + m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0; + m_3D_Drawings = NULL; + m_Materials = NULL; } @@ -80,32 +84,31 @@ Struct3D_Master::Struct3D_Master(EDA_BaseStruct * StructFather): Struct3D_Master:: ~Struct3D_Master() /***************************************/ { -Struct3D_Shape * next; -S3D_Material * nextmat; + Struct3D_Shape* next; + S3D_Material* nextmat; - for( ; m_3D_Drawings != NULL; m_3D_Drawings = next ) - { - next = (Struct3D_Shape *) m_3D_Drawings->Pnext; - delete m_3D_Drawings; - } + for( ; m_3D_Drawings != NULL; m_3D_Drawings = next ) + { + next = m_3D_Drawings->Next(); + delete m_3D_Drawings; + } - for( ; m_Materials != NULL; m_Materials = nextmat ) - { - nextmat = (S3D_Material *) m_Materials->Pnext; - delete m_Materials; - } + for( ; m_Materials != NULL; m_Materials = nextmat ) + { + nextmat = m_Materials->Next(); + delete m_Materials; + } } - /***************************************************************/ -Struct3D_Shape::Struct3D_Shape(EDA_BaseStruct * StructFather): - EDA_BaseStruct( StructFather, NOT_USED ) +Struct3D_Shape::Struct3D_Shape( EDA_BaseStruct* StructFather ) : + EDA_BaseStruct( StructFather, NOT_USED ) /***************************************************************/ { - m_3D_Coord = NULL; - m_3D_CoordIndex = NULL; - m_3D_Points = 0; + m_3D_Coord = NULL; + m_3D_CoordIndex = NULL; + m_3D_Points = 0; } @@ -113,7 +116,6 @@ Struct3D_Shape::Struct3D_Shape(EDA_BaseStruct * StructFather): Struct3D_Shape:: ~Struct3D_Shape() /***************************************/ { - delete m_3D_Coord; - delete m_3D_CoordIndex; + delete m_3D_Coord; + delete m_3D_CoordIndex; } - diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 2cc94de9b7..93498c4b7d 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -214,7 +214,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() /* draw graphic items */ EDA_BaseStruct* PtStruct; - for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -466,7 +466,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) /* Draw pads */ glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( ; pad != NULL; pad = pad->Next() ) { pad->Draw3D( glcanvas ); } @@ -477,9 +477,11 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) if( g_Parm_3D_Visu.m_Draw3DModule ) { glPushMatrix(); + glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BoardScale, -m_Pos.y * g_Parm_3D_Visu.m_BoardScale, g_Parm_3D_Visu.m_LayerZcoord[m_Layer] ); + if( m_Orient ) { glRotatef( (double) m_Orient / 10, 0.0, 0.0, 1.0 ); @@ -491,7 +493,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) } DataScale3D = g_Parm_3D_Visu.m_BoardScale * UNITS3D_TO_UNITSPCB; - for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext ) + for( ; Struct3D != NULL; Struct3D = Struct3D->Next() ) { if( !Struct3D->m_Shape3DName.IsEmpty() ) { @@ -507,7 +509,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) { EDA_BaseStruct* Struct = m_Drawings; glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis - for( ; Struct != NULL; Struct = Struct->Pnext ) + for( ; Struct != NULL; Struct = Struct->Next() ) { switch( Struct->Type() ) { diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp index 71b0bd3daa..c2bc4327c7 100644 --- a/3d-viewer/3d_read_mesh.cpp +++ b/3d-viewer/3d_read_mesh.cpp @@ -108,8 +108,7 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum ) mat_name = CONV_FROM_UTF8( text ); if( stricmp( command, "USE" ) == 0 ) { - for( material = m_Materials; material != NULL; - material = (S3D_Material*) material->Pnext ) + for( material = m_Materials; material; material = material->Next() ) { if( material->m_Name == mat_name ) { @@ -126,8 +125,8 @@ int Struct3D_Master:: ReadMaterial( FILE* file, int* LineNum ) { material = new S3D_Material( this, mat_name ); - material->Pnext = m_Materials; - m_Materials = material; + Insert( material ); + while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); @@ -297,7 +296,7 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNu * 0.923880 -4.09802e-6 0.382683, * 0.707107 -9.38186e-7 0.707107] * } - * + * * Return the coordinate list * text_buffer contains the first line of this node : * "coord Coordinate { point [" diff --git a/3d-viewer/3d_struct.h b/3d-viewer/3d_struct.h index db5431f512..e19085d829 100644 --- a/3d-viewer/3d_struct.h +++ b/3d-viewer/3d_struct.h @@ -1,7 +1,7 @@ - /********************************************************/ - /* 3d_struct.h : definition des structures de donnees */ - /* pour la representation 3D des modules */ - /********************************************************/ +/********************************************************/ +/* 3d_struct.h : definition des structures de donnees */ +/* pour la representation 3D des modules */ +/********************************************************/ #ifndef STRUCT_3D_H #define STRUCT_3D_H @@ -9,128 +9,143 @@ #include "base_struct.h" /* 3D modeler units -> PCB units conversion scale: - 1 "3D unit modeler" = 1 unit wings3d = 2,54 mm = 0.1 inch */ + * 1 "3D unit modeler" = 1 unit wings3d = 2,54 mm = 0.1 inch */ #define UNITS3D_TO_UNITSPCB 1000 class Struct3D_Master; 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*/ { public: - double m_Red, m_Green, m_Blue; + double m_Red, m_Green, m_Blue; public: - S3D_Color() - { - m_Red = m_Green = m_Blue = 0; - } + S3D_Color() { + m_Red = m_Green = m_Blue = 0; + } }; -class S3D_Vertex /* This is a 3D coordinate (3 float numbers: x,y,z coordinates)*/ +class S3D_Vertex /* This is a 3D coordinate (3 float numbers: x,y,z coordinates)*/ { public: - double x, y, z; + double x, y, z; public: - S3D_Vertex(); + S3D_Vertex(); }; -class S3D_Material: public EDA_BaseStruct /* openGL "material" data*/ +class S3D_Material : public EDA_BaseStruct /* openGL "material" data*/ { public: - wxString m_Name; - S3D_Vertex m_DiffuseColor; + wxString m_Name; + S3D_Vertex m_DiffuseColor; S3D_Vertex m_EmissiveColor; S3D_Vertex m_SpecularColor; - float m_AmbientIntensity; - float m_Transparency; - float m_Shininess; + float m_AmbientIntensity; + float m_Transparency; + float m_Shininess; public: - S3D_Material(Struct3D_Master * father, const wxString & name); - void SetMaterial(); + S3D_Material( Struct3D_Master * father, const wxString &name ); + + S3D_Material* Next() const { return (S3D_Material*) Pnext; } + S3D_Material* Back() const { return (S3D_Material*) Pback; } + + void SetMaterial(); }; + /*******************************************/ -class Struct3D_Master: public EDA_BaseStruct +class Struct3D_Master : public EDA_BaseStruct /*******************************************/ /* Master structure for a 3D item description */ { public: - wxString m_Shape3DName; /* 3D shape name in 3D library */ - S3D_Vertex m_MatScale; - S3D_Vertex m_MatRotation; - S3D_Vertex m_MatPosition; - Struct3D_Shape * m_3D_Drawings; - S3D_Material *m_Materials; + wxString m_Shape3DName; /* 3D shape name in 3D library */ + S3D_Vertex m_MatScale; + S3D_Vertex m_MatRotation; + S3D_Vertex m_MatPosition; + Struct3D_Shape* m_3D_Drawings; + S3D_Material* m_Materials; public: - Struct3D_Master(EDA_BaseStruct * StructFather); - ~Struct3D_Master(); + Struct3D_Master( EDA_BaseStruct * StructFather ); + ~Struct3D_Master(); - void Copy(Struct3D_Master * pattern); - int ReadData(); - int ReadMaterial(FILE * file, int *LineNum); - int ReadChildren(FILE * file, int *LineNum); - int ReadShape(FILE * file, int *LineNum); - int ReadAppearance(FILE * file, int *LineNum); - int ReadGeometry(FILE * file, int *LineNum); - void Set_Object_Coords(S3D_Vertex * coord, int nbcoord ); + Struct3D_Master* Next() const { return (Struct3D_Master*) Pnext; } + Struct3D_Master* Back() const { return (Struct3D_Master*) Pback; } + void Insert( S3D_Material* aMaterial ) + { + aMaterial->SetNext( m_Materials ); + m_Materials = aMaterial; + } + + void Copy( Struct3D_Master* pattern ); + int ReadData(); + int ReadMaterial( FILE* file, int* LineNum ); + int ReadChildren( FILE* file, int* LineNum ); + int ReadShape( FILE* file, int* LineNum ); + int ReadAppearance( FILE* file, int* LineNum ); + int ReadGeometry( FILE* file, int* LineNum ); + void Set_Object_Coords( S3D_Vertex* coord, int nbcoord ); }; /*********************************************/ -class Struct3D_Shape: public EDA_BaseStruct +class Struct3D_Shape : public EDA_BaseStruct /*********************************************/ /* decrit une forme complexe 3D */ { public: - S3D_Vertex * m_3D_Coord; - int * m_3D_CoordIndex; - int m_3D_Points; + S3D_Vertex* m_3D_Coord; + int* m_3D_CoordIndex; + int m_3D_Points; public: - Struct3D_Shape(EDA_BaseStruct * StructFather); - ~Struct3D_Shape(); + Struct3D_Shape( EDA_BaseStruct * StructFather ); + ~Struct3D_Shape(); - int ReadData(FILE * file, int *LineNum); + Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; } + Struct3D_Shape* Back() const { return (Struct3D_Shape*) Pback; } + + int ReadData( FILE* file, int* LineNum ); }; - /*****************************************************************/ /* Classe pour afficher et editer un Vertex (triplet de valeurs),*/ /* en INCHES ou MM ou sans unites */ /*****************************************************************/ + /* internal_unit is the internal unit number by inch: - - 1000 for EESchema - - 10000 for PcbNew -*/ + * - 1000 for EESchema + * - 10000 for PcbNew + */ class WinEDA_VertexCtrl { private: - int m_Units; - int m_Internal_Unit; - wxTextCtrl * m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl; - wxStaticText * m_Text; + int m_Units; + int m_Internal_Unit; + wxTextCtrl* m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl; + wxStaticText* m_Text; public: - // Constructor and destructor - WinEDA_VertexCtrl(wxWindow *parent, const wxString & title, - wxBoxSizer * BoxSizer, - int units, int internal_unit); - ~WinEDA_VertexCtrl(); + // Constructor and destructor + WinEDA_VertexCtrl( wxWindow * parent, const wxString &title, + wxBoxSizer * BoxSizer, + int units, int internal_unit ); - S3D_Vertex GetValue(); - void SetValue(S3D_Vertex vertex); - void Enable(bool enbl); - void SetToolTip(const wxString & text); + ~WinEDA_VertexCtrl(); + + S3D_Vertex GetValue(); + void SetValue( S3D_Vertex vertex ); + void Enable( bool enbl ); + void SetToolTip( const wxString& text ); }; - #endif /* STRUCT_3D_H */ diff --git a/change_log.txt b/change_log.txt index adc6e3ac15..3dffb68a06 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,30 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2008-Nov-23 UPDATE Dick Hollenbeck +================================================================================ ++all + + Made _protected_ EDA_BaseStruct's: + EDA_BaseStruct* Pnext; /* Linked list: Link (next struct) */ + EDA_BaseStruct* Pback; /* Linked list: Link (previous struct) */ + EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ + EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */ + + Split TRACK::Draw() out for SEGVIA + + Added dlist.h & dlist.cpp for DLIST<> template. All the _inline_ list manipulation + code throughout the package is rediculous. I don't mind list traversal, only + list manipulation. DLIST<> templates can be used to consolidate reliable + list manipulation operations and get this code out of the mainline. + These functions are shared/inherited for any derivation, so only one copy exists + in the final program image. To use, simply declare e.g. DLIST or similar. + See dlist.h, template class DLIST for function comments. + + added EDA_BaseStruct::m_List to assist in debugging list manipulation functions. ++eeschema + Started on the edit component in schematic editor. It is not complete and + breaks the usefulness of the editor at this moment. Do not build this version + if you want to fully use eeschema. I will get something working in another day, + even if it is the old editor. + + 2008-Nov-22 UPDATE Jean-Pierre Charras ================================================================================ ++pcbnew diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index c4985834ab..9e897281fe 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -16,6 +16,7 @@ set(COMMON_SRCS copy_to_clipboard.cpp dcsvg.cpp displlst.cpp + dlist.cpp drawtxt.cpp edaappl.cpp eda_dde.cpp diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 27680c5e09..dda3c052e6 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -446,14 +446,14 @@ void BASE_SCREEN::ClearUndoRedoList() while( m_UndoList ) { - nextitem = m_UndoList->Pnext; + nextitem = m_UndoList->Next(); delete m_UndoList; m_UndoList = nextitem; } while( m_RedoList ) { - nextitem = m_RedoList->Pnext; + nextitem = m_RedoList->Next(); delete m_RedoList; m_RedoList = nextitem; } @@ -469,32 +469,33 @@ void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem ) */ { int ii; - EDA_BaseStruct* item, * nextitem; + EDA_BaseStruct* item; + EDA_BaseStruct* nextitem; if( newitem == NULL ) return; - newitem->Pnext = m_UndoList; + newitem->SetNext( m_UndoList ); m_UndoList = newitem; /* Free first items, if count max reached */ for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) { - if( item->Pnext == NULL ) + if( item->Next() == NULL ) return; - item = item->Pnext; + item = item->Next(); } if( item == NULL ) return; - nextitem = item->Pnext; - item->Pnext = NULL; // Set end of chain + nextitem = item->Next(); + item->SetNext( NULL ); // Set end of chain // Delete the extra items for( item = nextitem; item != NULL; item = nextitem ) { - nextitem = item->Pnext; + nextitem = item->Next(); delete item; } } @@ -510,26 +511,26 @@ void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem ) if( newitem == NULL ) return; - newitem->Pnext = m_RedoList; + newitem->SetNext( m_RedoList ); m_RedoList = newitem; /* Free first items, if count max reached */ for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) { - if( item->Pnext == NULL ) + if( item->Next() == NULL ) break; - item = item->Pnext; + item = item->Next(); } if( item == NULL ) return; - nextitem = item->Pnext; - item->Pnext = NULL; // Set end of chain + nextitem = item->Next(); + item->SetNext( NULL ); // Set end of chain // Delete the extra items for( item = nextitem; item != NULL; item = nextitem ) { - nextitem = item->Pnext; + nextitem = item->Next(); delete item; } } @@ -542,7 +543,7 @@ EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList() EDA_BaseStruct* item = m_UndoList; if( item ) - m_UndoList = item->Pnext; + m_UndoList = item->Next(); return item; } @@ -554,7 +555,7 @@ EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList() EDA_BaseStruct* item = m_RedoList; if( item ) - m_RedoList = item->Pnext; + m_RedoList = item->Next(); return item; } diff --git a/common/base_struct.cpp b/common/base_struct.cpp index d98ca994b7..48fb47677f 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -43,15 +43,16 @@ void EDA_BaseStruct::InitVars() /********************************************/ { m_StructType = TYPE_NOT_INIT; - Pnext = NULL; /* Linked list: Link (next struct) */ - Pback = NULL; /* Linked list: Link (previous struct) */ - m_Parent = NULL; /* Linked list: Link (parent struct) */ - m_Son = NULL; /* Linked list: Link (son struct) */ - m_Image = NULL; /* Link to an image copy for undelete or abort command */ - m_Flags = 0; /* flags for editions and other */ - m_TimeStamp = 0; // Time stamp used for logical links + Pnext = NULL; // Linked list: Link (next struct) + Pback = NULL; // Linked list: Link (previous struct) + m_Parent = NULL; // Linked list: Link (parent struct) + m_Son = NULL; // Linked list: Link (son struct) + m_List = NULL; // I am not on any list yet + m_Image = NULL; // Link to an image copy for undelete or abort command + m_Flags = 0; // flags for editions and other + m_TimeStamp = 0; // Time stamp used for logical links m_Status = 0; - m_Selected = 0; /* Used by block commands, and selective editing */ + m_Selected = 0; // Used by block commands, and selective editing } @@ -536,11 +537,11 @@ void EDA_TextStruct::CreateDrawData() { x0 = 0; y0 = 0; #if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC) - AsciiCode = (*ptr) & 0x7FF; - if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr - AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF; - else - AsciiCode = AsciiCode & 0xFF; + AsciiCode = (*ptr) & 0x7FF; + if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr + AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF; + else + AsciiCode = AsciiCode & 0xFF; #else AsciiCode = (*ptr) & 255; #endif diff --git a/common/block_commande.cpp b/common/block_commande.cpp index 48a66d8927..81343334c8 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -254,7 +254,7 @@ void InitBlockLocateDatas( WinEDA_DrawPanel* Panel, const wxPoint& startpos ) screen->BlockLocate.m_State = STATE_BLOCK_INIT; screen->BlockLocate.SetOrigin( startpos ); screen->BlockLocate.SetSize( wxSize( 0, 0 ) ); - screen->BlockLocate.Pnext = NULL; + screen->BlockLocate.SetNext( NULL ); screen->BlockLocate.m_BlockDrawStruct = NULL; Panel->ManageCurseur = DrawAndSizingBlockOutlines; Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand; diff --git a/common/dlist.cpp b/common/dlist.cpp index 930088457f..4620054781 100644 --- a/common/dlist.cpp +++ b/common/dlist.cpp @@ -128,7 +128,7 @@ void DHEAD::Insert( EDA_BaseStruct* aNewElement, EDA_BaseStruct* aAfterMe ) void DHEAD::Remove( EDA_BaseStruct* aElement ) { - wxASSERT( aElement ) + wxASSERT( aElement ); wxASSERT( aElement->GetList() == this ); if( aElement->Next() ) diff --git a/common/makefile.include b/common/makefile.include index 2d6c26ad43..27646434cb 100644 --- a/common/makefile.include +++ b/common/makefile.include @@ -5,36 +5,37 @@ COMMON = ../include/colors.h OBJECTS= \ - confirm.o \ - base_struct.o\ - copy_to_clipboard.o\ - basicframe.o\ + confirm.o \ + base_struct.o\ + copy_to_clipboard.o\ + basicframe.o\ class_drawpickedstruct.o\ - common_plot_functions.o\ - common_plotPS_functions.o\ - common_plotHPGL_functions.o\ - hotkeys_basic.o\ - drawtxt.o \ - about_kicad.o\ - wxwineda.o \ - string.o \ - gr_basic.o\ - gestfich.o\ - trigo.o\ - selcolor.o\ - common.o\ - eda_doc.o\ - toolbars.o\ - displlst.o \ - edaappl.o\ - block_commande.o\ - msgpanel.o\ - projet_config.o\ - get_component_dialog.o\ - eda_dde.o\ - worksheet.o\ - base_screen.o\ - dcsvg.o + common_plot_functions.o\ + common_plotPS_functions.o\ + common_plotHPGL_functions.o\ + dlist.o \ + hotkeys_basic.o\ + drawtxt.o \ + about_kicad.o\ + wxwineda.o \ + string.o \ + gr_basic.o\ + gestfich.o\ + trigo.o\ + selcolor.o\ + common.o\ + eda_doc.o\ + toolbars.o\ + displlst.o \ + edaappl.o\ + block_commande.o\ + msgpanel.o\ + projet_config.o\ + get_component_dialog.o\ + eda_dde.o\ + worksheet.o\ + base_screen.o\ + dcsvg.o ifdef KICAD_PYTHON OBJECTS += pyhandler.o @@ -86,8 +87,8 @@ trigo.o: trigo.cpp ../include/trigo.h bitmaps.o: bitmaps.cpp ../include/bitmaps.h edaappl.o: edaappl.cpp $(COMMON) ../include/worksheet.h\ - ../include/common.h ../include/gr_basic.h\ - ../include/build_version.h + ../include/common.h ../include/gr_basic.h\ + ../include/build_version.h eda_dde.o: eda_dde.cpp $(COMMON) ../include/eda_dde.h diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index e2face971e..de1e78c7f9 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -36,7 +36,8 @@ set(EESCHEMA_SRCS # dialog_cmp_graphic_properties.cpp dialog_create_component.cpp # dialog_edit_component_in_lib.cpp -# dialog_edit_component_in_schematic.cpp + dialog_edit_component_in_schematic_fbp.cpp + dialog_edit_component_in_schematic.cpp # dialog_edit_label.cpp dialog_eeschema_config.cpp dialog_erc.cpp diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 930792d463..b680dfc07a 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -64,7 +64,7 @@ void ReAnnotatePowerSymbolsOnly( void ) sheet = SheetList.GetNext() ) { EDA_BaseStruct* DrawList = sheet->LastDrawList(); - for( ; DrawList != NULL; DrawList = DrawList->Pnext ) + for( ; DrawList != NULL; DrawList = DrawList->Next() ) { if( DrawList->Type() != TYPE_SCH_COMPONENT ) continue; @@ -207,7 +207,7 @@ void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly, bool aRedr while( screen ) { strct = screen->EEDrawList; - for( ; strct; strct = strct->Pnext ) + for( ; strct; strct = strct->Next() ) { if( strct->Type() == TYPE_SCH_COMPONENT ) { @@ -348,7 +348,7 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet ) SCH_COMPONENT* DrawLibItem; EDA_LibComponentStruct* Entry; - for( ; DrawList; DrawList = DrawList->Pnext ) + for( ; DrawList; DrawList = DrawList->Next() ) { if( DrawList->Type() == TYPE_SCH_COMPONENT ) { diff --git a/eeschema/block.cpp b/eeschema/block.cpp index c1edb709f7..9b9cea836d 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -316,7 +316,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) if( block->m_Command == BLOCK_ABORT ) { /* clear struct.m_Flags */ EDA_BaseStruct* Struct; - for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Pnext ) + for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() ) Struct->m_Flags = 0; } @@ -502,7 +502,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, (SCH_ITEM*)PickedList->m_PickedStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y ); - PickedList = (DrawPickedStruct*) PickedList->Pnext; + PickedList = (DrawPickedStruct*) PickedList->Next(); } } else @@ -535,7 +535,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, (SCH_ITEM*)PickedList->m_PickedStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y ); - PickedList = (DrawPickedStruct*) PickedList->Pnext; + PickedList = (DrawPickedStruct*) PickedList->Next(); } } else @@ -729,7 +729,7 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center ) { MirrorYPoint( DrawSheetLabel->m_Pos, Center ); DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1; - DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Pnext; + DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Next(); } break; @@ -852,7 +852,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc } SetStructFather( Struct, screen ); - PickedList = (DrawPickedStruct*) PickedList->Pnext; + PickedList = (DrawPickedStruct*) PickedList->Next(); } RedrawStructList( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); @@ -860,7 +860,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc PickedList = (DrawPickedStruct*) NewDrawStruct; while( PickedList ) { - PickedList->m_PickedStruct->Pnext = screen->EEDrawList; + PickedList->m_PickedStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = PickedList->m_PickedStruct; PickedList = PickedList->Next(); } @@ -888,7 +888,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc { DrawSheetStruct* sheet = (DrawSheetStruct*) NewDrawStruct; sheet->m_TimeStamp = GetTimeStamp(); - sheet->m_Son = NULL; + sheet->SetSon( NULL ); break; } @@ -901,7 +901,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); SetStructFather( NewDrawStruct, screen ); - NewDrawStruct->Pnext = screen->EEDrawList; + NewDrawStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = NewDrawStruct; } @@ -934,7 +934,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct ) { /* Cette stucture est rattachee a une feuille, et n'est pas * accessible par la liste globale directement */ - frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct*) DrawStruct )->m_Parent, IS_CHANGED ); + frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct*) DrawStruct )->GetParent(), IS_CHANGED ); frame->DeleteSheetLabel( DC ? true : false , (Hierarchical_PIN_Sheet_Struct*) DrawStruct ); return; } @@ -948,7 +948,8 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct ) SCH_ITEM * item = cur->m_PickedStruct; screen->RemoveFromDrawList( item ); panel->PostDirtyRect( item->GetBoundingBox() ); - item->Pnext = item->Pback = NULL; + item->SetNext( 0 ); + item->SetBack( 0 ); item->m_Flags = IS_DELETED; } @@ -962,7 +963,9 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct ) panel->PostDirtyRect( DrawStruct->GetBoundingBox() ); /* Unlink the structure */ - DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link + DrawStruct->SetNext( 0 ); + DrawStruct->SetBack( 0 ); // Only one struct -> no link + if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) { frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); // Currently In TEST @@ -1005,14 +1008,14 @@ SCH_ITEM * SaveStructListForPaste( SCH_ITEM * DrawStruct ) EDA_BaseStruct* item = g_BlockSaveDataList, * next_item; while( item ) { - next_item = item->Pnext; + next_item = item->Next(); delete item; item = next_item; } } - g_BlockSaveDataList = DrawStructCopy; - DrawStructCopy->m_Parent = NULL; + g_BlockSaveDataList = DrawStructCopy; + DrawStructCopy->SetParent( NULL ); return DrawStructCopy; } @@ -1051,14 +1054,14 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) ( (SCH_COMPONENT*) Struct )->ClearAnnotation(NULL); SetStructFather( Struct, GetScreen() ); } - PickedList = (DrawPickedStruct*) PickedList->Pnext; + PickedList = (DrawPickedStruct*) PickedList->Next(); } RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; ) { SCH_ITEM * Struct = PickedList->m_PickedStruct; - Struct->Pnext = GetScreen()->EEDrawList; + Struct->SetNext( GetScreen()->EEDrawList ); SetStructFather( Struct, GetScreen() ); GetScreen()->EEDrawList = Struct; PickedList = PickedList->Next(); @@ -1076,7 +1079,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) } SetStructFather( DrawStruct, GetScreen() ); RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); - DrawStruct->Pnext = GetScreen()->EEDrawList; + DrawStruct->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = DrawStruct; SaveCopyInUndoList( DrawStruct, IS_NEW ); } @@ -1343,7 +1346,7 @@ SCH_ITEM * DuplicateStruct( SCH_ITEM * DrawStruct ) if( NewDrawStruct == NULL ) NewDrawStruct = NewPickedItem; if( LastPickedItem ) - LastPickedItem->Pnext = NewPickedItem; + LastPickedItem->SetNext( NewPickedItem ); LastPickedItem = NewPickedItem; NewPickedItem->m_PickedStruct = DuplicateStruct( PickedList->m_PickedStruct ); @@ -1469,7 +1472,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) { if( SLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ) AddPickedItem( screen, SLabel->m_Pos ); - SLabel = (Hierarchical_PIN_Sheet_Struct*) SLabel->Pnext; + SLabel = (Hierarchical_PIN_Sheet_Struct*) SLabel->Next(); } } @@ -1495,7 +1498,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) while( DrawStructs ) { Struct = DrawStructs->m_PickedStruct; - DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; + DrawStructs = (DrawPickedStruct*) DrawStructs->Next(); switch( Struct->Type() ) { @@ -1537,8 +1540,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; break; @@ -1550,8 +1552,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) if( STRUCT->m_Start == position ) { DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags &= ~STARTPOINT; @@ -1559,8 +1560,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) else if( STRUCT->m_End == position ) { DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags &= ~ENDPOINT; @@ -1581,8 +1581,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; Struct->m_Flags |= SELECTED; break; @@ -1596,8 +1595,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; Struct->m_Flags |= SELECTED; break; @@ -1622,8 +1620,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; Struct->m_Flags |= SELECTED; break; @@ -1636,8 +1633,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; Struct->m_Flags |= SELECTED; break; diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 59fd9193fb..e729983b93 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -517,7 +517,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) item->m_Selected = 0; LibEDA_BaseStruct* newitem = CopyDrawEntryStruct( NULL, item ); newitem->m_Selected = IS_SELECTED; - newitem->Pnext = LibEntry->m_Drawings; + newitem->SetNext( LibEntry->m_Drawings ); LibEntry->m_Drawings = newitem; } diff --git a/eeschema/build_BOM.cpp b/eeschema/build_BOM.cpp index e658b7c7d7..5455902008 100644 --- a/eeschema/build_BOM.cpp +++ b/eeschema/build_BOM.cpp @@ -301,7 +301,7 @@ int BuildComponentsListFromSchematic( ListComponent* aList ) itemCount++; DrawLibItem = (SCH_COMPONENT*) SchItem; - DrawLibItem->m_Parent = sheet->LastScreen(); + DrawLibItem->SetParent( sheet->LastScreen() ); if( aList ) { aList->m_Comp = DrawLibItem; @@ -362,29 +362,29 @@ static int GenListeGLabels( ListLabel* list ) break; case DRAW_SHEET_STRUCT_TYPE: - { - #define Sheet ( (DrawSheetStruct*) DrawList ) - SheetLabel = Sheet->m_Label; - while( SheetLabel != NULL ) { - if( list ) + #define Sheet ( (DrawSheetStruct*) DrawList ) + SheetLabel = Sheet->m_Label; + while( SheetLabel != NULL ) { - list->m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE; - snprintf( list->m_SheetPath, sizeof(list->m_SheetPath), - "%s", CONV_TO_UTF8( path ) ); - list->m_Label = SheetLabel; - list++; + if( list ) + { + list->m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE; + snprintf( list->m_SheetPath, sizeof(list->m_SheetPath), + "%s", CONV_TO_UTF8( path ) ); + list->m_Label = SheetLabel; + list++; + } + itemCount++; + SheetLabel = SheetLabel->Next(); } - itemCount++; - SheetLabel = (Hierarchical_PIN_Sheet_Struct*) (SheetLabel->Pnext); } - } break; default: break; } - DrawList = DrawList->Pnext; + DrawList = DrawList->Next(); } } @@ -750,13 +750,13 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, if( CompactForm ) { fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*)DrawLibItem->m_Parent, DrawLibItem->m_Pos ); + msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*)DrawLibItem->GetParent(), DrawLibItem->m_Pos ); fprintf( f, "%c%s)", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) ); } else { fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*)DrawLibItem->m_Parent, DrawLibItem->m_Pos ); + msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*)DrawLibItem->GetParent(), DrawLibItem->m_Pos ); fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) ); } } @@ -819,7 +819,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, if( ( Multi > 1 ) && aIncludeSubComponents ) { -#if defined(KICAD_GOST) +#if defined(KICAD_GOST) Unit = aList[ii].m_Unit + '1' - 1; } @@ -837,7 +837,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, { msg = aList[ii].m_SheetList.PathHumanReadable(); fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*)DrawLibItem->m_Parent, DrawLibItem->m_Pos ); + msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*)DrawLibItem->GetParent(), DrawLibItem->m_Pos ); fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) ); } diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 5cd2c24790..94d0c15f84 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -50,7 +50,7 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE: RemoveFromDrawList( item ); - item->Pnext = List; + item->SetNext( List ); List = item; if( CreateCopy ) { @@ -58,7 +58,7 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) new_item = ( (DrawJunctionStruct*) item )->GenCopy(); else new_item = ( (EDA_DrawLineStruct*) item )->GenCopy(); - new_item->Pnext = EEDrawList; + new_item->SetNext( EEDrawList ); EEDrawList = new_item; } break; @@ -79,7 +79,8 @@ static void RestoreOldWires( SCH_SCREEN* screen ) /* Replace the wires in screen->EEDrawList by s_OldWiresList wires. */ { - SCH_ITEM* item, * next_item; + SCH_ITEM* item; + SCH_ITEM* next_item; for( item = screen->EEDrawList; item != NULL; item = next_item ) { @@ -101,7 +102,8 @@ static void RestoreOldWires( SCH_SCREEN* screen ) while( s_OldWiresList ) { next_item = s_OldWiresList->Next(); - s_OldWiresList->Pnext = screen->EEDrawList, + + s_OldWiresList->SetNext( screen->EEDrawList ); screen->EEDrawList = s_OldWiresList; s_OldWiresList = next_item; } @@ -166,8 +168,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) { nextsegment = newsegment->GenCopy(); nextsegment->m_Flags = IS_NEW; - newsegment->Pnext = nextsegment; - nextsegment->Pback = newsegment; + newsegment->SetNext( nextsegment ); + nextsegment->SetBack( newsegment ); } GetScreen()->SetCurItem( newsegment ); DrawPanel->ManageCurseur = Segment_in_Ghost; @@ -176,7 +178,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) } else /* Trace en cours: Placement d'un point supplementaire */ { - nextsegment = (EDA_DrawLineStruct*) oldsegment->Pnext; + nextsegment = oldsegment->Next(); if( !g_HVLines ) { /* if only one segment is needed and the current is has len = 0, do not create a new one*/ if( oldsegment->IsNull() ) @@ -198,7 +200,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) } /* Placement en liste generale */ - oldsegment->Pnext = GetScreen()->EEDrawList; + oldsegment->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = oldsegment; DrawPanel->CursorOff( DC ); // Erase schematic cursor RedrawOneStruct( DrawPanel, DC, oldsegment, GR_DEFAULT_DRAWMODE ); @@ -209,10 +211,10 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) { newsegment = nextsegment->GenCopy(); nextsegment->m_Start = newsegment->m_End; - nextsegment->Pnext = NULL; - nextsegment->Pback = newsegment; - newsegment->Pnext = nextsegment; - newsegment->Pback = NULL; + nextsegment->SetNext( NULL ); + nextsegment->SetBack( newsegment ); + newsegment->SetNext( nextsegment ); + newsegment->SetBack( NULL ); } else { @@ -256,16 +258,16 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) lastsegment = firstsegment; while( lastsegment ) { - EDA_DrawLineStruct* nextsegment = (EDA_DrawLineStruct*) lastsegment->Pnext; + EDA_DrawLineStruct* nextsegment = lastsegment->Next(); if( lastsegment->IsNull() ) { - EDA_DrawLineStruct* previous_segment = (EDA_DrawLineStruct*) lastsegment->Pback; + EDA_DrawLineStruct* previous_segment = lastsegment->Back(); if( firstsegment == lastsegment ) firstsegment = nextsegment; if( nextsegment ) - nextsegment->Pback = NULL; + nextsegment->SetBack( NULL ); if( previous_segment ) - previous_segment->Pnext = nextsegment; + previous_segment->SetNext( nextsegment ); delete lastsegment; } lastsegment = nextsegment; @@ -276,8 +278,8 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) while( segment ) { lastsegment = segment; - segment = (EDA_DrawLineStruct*) segment->Pnext; - lastsegment->Pnext = GetScreen()->EEDrawList; + segment = segment->Next(); + lastsegment->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = lastsegment; } @@ -311,7 +313,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) g_ItemToRepeat = segment; } segment->m_Flags = 0; - segment = (EDA_DrawLineStruct*) segment->Pnext; + segment = segment->Next(); } // Automatic place of a junction on the end point, if needed @@ -348,7 +350,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) break; } - item = item->Pnext; + item = item->Next(); } @@ -386,7 +388,7 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { if( !segment->IsNull() ) // Redraw if segment lengtht != 0 RedrawOneStruct( panel, DC, segment, g_XorMode, color ); - segment = (EDA_DrawLineStruct*) segment->Pnext; + segment = segment->Next(); } } @@ -403,7 +405,7 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { if( !segment->IsNull() ) // Redraw if segment lengtht != 0 RedrawOneStruct( panel, DC, segment, g_XorMode, color ); - segment = (EDA_DrawLineStruct*) segment->Pnext; + segment = segment->Next(); } } @@ -416,7 +418,7 @@ static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_p * with the 2 segments kept H or V only */ { - EDA_DrawLineStruct* nextsegment = (EDA_DrawLineStruct*) segment->Pnext; + EDA_DrawLineStruct* nextsegment = segment->Next(); wxPoint middle_position = new_pos; if( nextsegment == NULL ) @@ -543,7 +545,7 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( RedrawOneStruct( DrawPanel, DC, NewJunction, GR_DEFAULT_DRAWMODE ); DrawPanel->CursorOn( DC ); // Display schematic cursor - NewJunction->Pnext = GetScreen()->EEDrawList; + NewJunction->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = NewJunction; GetScreen()->SetModify(); if( PutInUndoList ) @@ -568,7 +570,7 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC ) RedrawOneStruct( DrawPanel, DC, NewNoConnect, GR_DEFAULT_DRAWMODE ); DrawPanel->CursorOn( DC ); // Display schematic cursor - NewNoConnect->Pnext = GetScreen()->EEDrawList; + NewNoConnect->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = NewNoConnect; GetScreen()->SetModify(); SaveCopyInUndoList( NewNoConnect, IS_NEW ); @@ -729,7 +731,7 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) if( g_ItemToRepeat ) { - g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; + g_ItemToRepeat->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = g_ItemToRepeat; TestDanglingEnds( GetScreen()->EEDrawList, NULL ); RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE ); diff --git a/eeschema/class_drawsheet.cpp b/eeschema/class_drawsheet.cpp index b0477cd46e..b19e2a02af 100644 --- a/eeschema/class_drawsheet.cpp +++ b/eeschema/class_drawsheet.cpp @@ -146,7 +146,7 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() newitem->m_Size = m_Size; - newitem->m_Parent = m_Parent; + newitem->SetParent( m_Parent ); newitem->m_TimeStamp = GetTimeStamp(); newitem->m_FileName = m_FileName; @@ -161,15 +161,15 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() if( label ) { Slabel = newitem->m_Label = label->GenCopy(); - Slabel->m_Parent = newitem; + Slabel->SetParent( newitem ); label = label->Next(); } while( label ) { - Slabel->Pnext = label->GenCopy(); - Slabel = (Hierarchical_PIN_Sheet_Struct*) Slabel->Pnext; - Slabel->m_Parent = newitem; + Slabel->SetNext( label->GenCopy() ); + Slabel = Slabel->Next(); + Slabel->SetParent( newitem ); label = label->Next(); } @@ -202,14 +202,14 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) Hierarchical_PIN_Sheet_Struct* label = m_Label; while( label ) { - label->m_Parent = this; + label->SetParent( this ); label = label->Next(); } label = copyitem->m_Label; while( label ) { - label->m_Parent = copyitem; + label->SetParent( copyitem ); label = label->Next(); } } @@ -257,13 +257,15 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList; SCH_HIERLABEL* HLabel = NULL; - for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) { if( DrawStruct->Type() != TYPE_SCH_HIERLABEL ) continue; + HLabel = (SCH_HIERLABEL*) DrawStruct; if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 ) break; // Found! + HLabel = NULL; } @@ -375,7 +377,7 @@ int DrawSheetStruct::ComponentCount() if( m_AssociatedScreen ) { EDA_BaseStruct* bs; - for( bs = m_AssociatedScreen->EEDrawList; bs != NULL; bs = bs->Pnext ) + for( bs = m_AssociatedScreen->EEDrawList; bs != NULL; bs = bs->Next() ) { if( bs->Type() == TYPE_SCH_COMPONENT ) { @@ -416,7 +418,7 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen ) if( ss->SearchHierarchy( filename, screen ) ) return true; } - strct = strct->Pnext; + strct = strct->Next(); } } return false; @@ -446,7 +448,7 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* lis if( ss->LocatePathOfScreen( screen, list ) ) return true; } - strct = strct->Pnext; + strct = strct->Next(); } list->Pop(); @@ -488,7 +490,7 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* frame ) if( !sheetstruct->Load( frame ) ) success = false; } - bs = bs->Pnext; + bs = bs->Next(); } } } @@ -506,7 +508,7 @@ int DrawSheetStruct::CountSheets() if( m_AssociatedScreen ) { EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; - for( ; strct; strct = strct->Pnext ) + for( ; strct; strct = strct->Next() ) { if( strct->Type() == DRAW_SHEET_STRUCT_TYPE ) { @@ -787,7 +789,7 @@ void DrawSheetPath::UpdateAllScreenReferences() component->GetField(REFERENCE)->m_Text = component->GetRef( this ); component->m_Multi = component->GetUnitSelection( this ); } - t = t->Pnext; + t = t->Next(); } } diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 0549a7cb66..aef4e902b2 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -41,7 +41,7 @@ void FreeLibraryEntry( LibCmpEntry* Entry ) /* Used by PQFreeFunc() to delete all entries */ { - SAFE_DELETE( Entry ); + SAFE_DELETE( Entry ); } @@ -196,8 +196,9 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() field = Fields; Fields = NULL; while( field ) { - TempField = field; field = (LibDrawField*) field->Pnext; - SAFE_DELETE( TempField ); + TempField = field; + field = field->Next(); + SAFE_DELETE( TempField ); } /* suppression des elements dependants */ @@ -205,7 +206,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() while( DrawItem ) { NextDrawItem = DrawItem->Next(); - SAFE_DELETE( DrawItem ); + SAFE_DELETE( DrawItem ); DrawItem = NextDrawItem; } } diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp index 1ebbea6e3b..879929af9d 100644 --- a/eeschema/class_screen.cpp +++ b/eeschema/class_screen.cpp @@ -28,7 +28,7 @@ void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) case DRAW_SHEET_STRUCT_TYPE: case DRAW_MARKER_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE: - Struct->m_Parent = Screen; + Struct->SetParent( Screen ); break; case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: @@ -138,9 +138,9 @@ void SCH_SCREEN::RemoveFromDrawList( SCH_ITEM * DrawStruct ) EDA_BaseStruct* DrawList = EEDrawList; while( DrawList && DrawList->Next() ) { - if( DrawList->Pnext == DrawStruct ) + if( DrawList->Next() == DrawStruct ) { - DrawList->Pnext = DrawList->Pnext->Pnext; + DrawList->SetNext( DrawList->Next()->Next() ); break; } DrawList = DrawList->Next(); @@ -170,7 +170,7 @@ bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* st ) void SCH_SCREEN::AddToDrawList( SCH_ITEM* st ) /**************************************************************/ { //simple function to add to the head of the drawlist. - st->Pnext = EEDrawList; + st->SetNext( EEDrawList ); EEDrawList = st; } @@ -262,7 +262,7 @@ void EDA_ScreenList::BuildScreenList( EDA_BaseStruct* s ) { BuildScreenList( strct ); } - strct = strct->Pnext; + strct = strct->Next(); } } } @@ -335,7 +335,7 @@ void EDA_SheetList::BuildSheetList( DrawSheetStruct* sheet ) DrawSheetStruct* sht = (DrawSheetStruct*) strct; BuildSheetList( sht ); } - strct = strct->Pnext; + strct = strct->Next(); } } m_currList.Pop(); diff --git a/eeschema/classes_body_items.h b/eeschema/classes_body_items.h index dbd9096ff2..4f82fef17f 100644 --- a/eeschema/classes_body_items.h +++ b/eeschema/classes_body_items.h @@ -193,10 +193,15 @@ public: public: LibDrawPin(); ~LibDrawPin() { } + + LibDrawPin* Next() const { return (LibDrawPin*) Pnext; } + LibDrawPin* Back() const { return (LibDrawPin*) Pback; } + virtual wxString GetClass() const { return wxT( "LibDrawPin" ); } + /** * Function Save * writes the data structures for this object out to a FILE in "*.brd" format. @@ -451,8 +456,8 @@ public: public: - LibDrawField* Next() { return (LibDrawField*) Pnext; } - LibDrawField* Prev() { return (LibDrawField*) Pback; } + LibDrawField* Next() const { return (LibDrawField*) Pnext; } + LibDrawField* Back() const { return (LibDrawField*) Pback; } LibDrawField( int idfield = 2 ); diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp index da4ed9665c..020a7327e8 100644 --- a/eeschema/cleanup.cpp +++ b/eeschema/cleanup.cpp @@ -167,14 +167,14 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen, wrapper->m_PickedStruct = segment->GenCopy(); wrapper->m_Image = segment; wrapper->m_PickedStruct->m_Image = segment; - wrapper->Pnext = List; + wrapper->SetNext( List ); List = wrapper; } NewSegment = segment->GenCopy(); NewSegment->m_Start = breakpoint; segment->m_End = NewSegment->m_Start; - NewSegment->Pnext = segment->Pnext; - segment->Pnext = NewSegment; + NewSegment->SetNext( segment->Next() ); + segment->SetNext( NewSegment ); DrawList = NewSegment; if( PutInUndoList ) { @@ -182,7 +182,7 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen, wrapper->m_Flags = IS_NEW; wrapper->m_Image = NewSegment; - wrapper->Pnext = List; + wrapper->SetNext( List ); List = wrapper; } break; @@ -196,7 +196,7 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen, break; } - DrawList = DrawList->Pnext; + DrawList = DrawList->Next(); } return List; diff --git a/eeschema/component_class.cpp b/eeschema/component_class.cpp index d5f22557d4..040c30348a 100644 --- a/eeschema/component_class.cpp +++ b/eeschema/component_class.cpp @@ -72,10 +72,10 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : Pnext = NULL; m_Son = NULL; - // Re-parent the fields, which before this were aTemplate's parent + // Re-parent the fields, which before this had aTemplate as parent for( int i=0; im_Parent = this; + GetField( i )->SetParent( this ); } } @@ -424,11 +424,11 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem ) // (after swap(), m_Parent member does not point to the right parent): for( int ii = 0; ii < copyitem->GetFieldCount(); ++ii ) { - copyitem->GetField(ii)->m_Parent = copyitem; + copyitem->GetField(ii)->SetParent( copyitem ); } for( int ii = 0; ii < GetFieldCount(); ++ii ) { - GetField(ii)->m_Parent = this; + GetField(ii)->SetParent( this ); } } diff --git a/eeschema/component_class.h b/eeschema/component_class.h index bbe274dddd..0a5fb7737f 100644 --- a/eeschema/component_class.h +++ b/eeschema/component_class.h @@ -39,7 +39,11 @@ struct Error } }; -/* Fields identifiers */ + +/** + * Enum NumFieldType + * is the numbered set of all fields a SCH_COMPONENT can hold + */ enum NumFieldType { REFERENCE = 0, ///< Field Reference of part, i.e. "IC21" VALUE, ///< Field Value of part, i.e. "3.3K" @@ -59,31 +63,36 @@ enum NumFieldType { }; +/// A container for several SCH_CMP_FIELD items +typedef std::vector SCH_CMP_FIELDS; + + /** * Class SCH_COMPONENT * describes a real schematic component */ class SCH_COMPONENT : public SCH_ITEM { + friend class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC; + public: - int m_Multi; /* In multi unit chip - which unit to draw. */ + int m_Multi; ///< In multi unit chip - which unit to draw. wxPoint m_Pos; - wxString m_ChipName; /* Key to look for in the library, i.e. "74LS00". */ + wxString m_ChipName; ///< Key to look for in the library, i.e. "74LS00". + wxString m_PrefixString; /* C, R, U, Q etc - the first character which typically indicates what the component is. * determined, upon placement, from the library component. - * determined, upon file load, by the first non-digits in the reference fields. */ + * determined, upon file load, by the first non-digits in the reference fields. + */ int m_Convert; /* Handle mutiple shape (for instance De Morgan conversion) */ int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */ private: -/** how many fields are fixed, or automatic and pre-made in the SCH_COMPONENT class */ - - typedef std::vector SCH_CMP_FIELDS; - SCH_CMP_FIELDS m_Fields; + SCH_CMP_FIELDS m_Fields; ///< variable length list of fields /* Hierarchical references. @@ -200,14 +209,16 @@ public: void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); - - //returns a unique ID, in the form of a path. + // returns a unique ID, in the form of a path. wxString GetPath( DrawSheetPath* sheet ); - //returns the reference, for the given sheet path. + /** + * Function GetRef + * returns the reference, for the given sheet path. + */ const wxString GetRef( DrawSheetPath* sheet ); - //Set the reference, for the given sheet path. + // Set the reference, for the given sheet path. void SetRef( DrawSheetPath* sheet, const wxString& ref ); /** diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index b3e7545b15..cb42cf781d 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -54,7 +54,7 @@ SCH_ITEM * WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Includ { case DRAW_PART_TEXT_STRUCT_TYPE: case COMPONENT_FIELD_DRAW_TYPE: - LibItem = (SCH_COMPONENT*) DrawStruct->m_Parent; + LibItem = (SCH_COMPONENT*) DrawStruct->GetParent(); SendMessageToPCBNEW( DrawStruct,LibItem ); break; @@ -168,7 +168,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin if( DrawStruct ) { SCH_CMP_FIELD* Field = (SCH_CMP_FIELD*) DrawStruct; - LibItem = (SCH_COMPONENT*) Field->m_Parent; + LibItem = (SCH_COMPONENT*) Field->GetParent(); LibItem->Display_Infos( this ); return DrawStruct; diff --git a/eeschema/dangling_ends.cpp b/eeschema/dangling_ends.cpp index da51a26d12..eb3359702e 100644 --- a/eeschema/dangling_ends.cpp +++ b/eeschema/dangling_ends.cpp @@ -314,7 +314,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) DanglingEndHandle* StartList = NULL, * item, * lastitem = NULL; EDA_BaseStruct* DrawItem; - for( DrawItem = DrawList; DrawItem != NULL; DrawItem = DrawItem->Pnext ) + for( DrawItem = DrawList; DrawItem != NULL; DrawItem = DrawItem->Next() ) { switch( DrawItem->Type() ) { diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index 16c1a7033f..6f6e779af5 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -147,7 +147,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio /* Put this structure in the picked list: */ PickedItem = new DrawPickedStruct( DelStruct ); - PickedItem->Pnext = PickedList; + PickedItem->SetNext( PickedList ); PickedList = PickedItem; DelStruct = DelStruct->Next(); screen->EEDrawList = DelStruct; @@ -194,7 +194,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio EDA_BaseStruct* removed_struct; for( removed_struct = GetScreen()->EEDrawList; removed_struct != NULL; - removed_struct = removed_struct->Pnext ) + removed_struct = removed_struct->Next() ) { if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 ) continue; @@ -214,7 +214,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio * and now is not connected, the wire can be deleted */ for( removed_struct = GetScreen()->EEDrawList; removed_struct != NULL; - removed_struct = removed_struct->Pnext ) + removed_struct = removed_struct->Next() ) { if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 ) continue; @@ -236,7 +236,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio /* Put this structure in the picked list: */ PickedItem = new DrawPickedStruct( DelStruct ); - PickedItem->Pnext = PickedList; + PickedItem->SetNext( PickedList ); PickedList = PickedItem; DelStruct = GetScreen()->EEDrawList; } @@ -264,7 +264,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio /* Put this structure in the picked list: */ PickedItem = new DrawPickedStruct( DelStruct ); - PickedItem->Pnext = PickedList; + PickedItem->SetNext( PickedList ); PickedList = PickedItem; } #undef JUNCTION @@ -292,7 +292,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio /* Put this structure in the picked list: */ PickedItem = new DrawPickedStruct( DelStruct ); - PickedItem->Pnext = PickedList; + PickedItem->SetNext( PickedList ); PickedList = PickedItem; } } @@ -398,7 +398,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) * accessible par la liste globale directement */ //this structure has a sheet attached, which we must find. DrawList = Screen->EEDrawList; - for( ; DrawList != NULL; DrawList = DrawList->Pnext ) + for( ; DrawList != NULL; DrawList = DrawList->Next() ) { if( DrawList->Type() != DRAW_SHEET_STRUCT_TYPE ) continue; @@ -411,19 +411,19 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) if( SheetLabel == (Hierarchical_PIN_Sheet_Struct*) DrawStruct ) { ( (DrawSheetStruct*) DrawList )->m_Label = - (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext; + (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Next(); SAFE_DELETE( DrawStruct ); return; } else { - while( SheetLabel->Pnext ) /* Examen de la liste dependante */ + while( SheetLabel->Next() ) /* Examen de la liste dependante */ { - NextLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext; + NextLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Next(); if( NextLabel == (Hierarchical_PIN_Sheet_Struct*) DrawStruct ) { - SheetLabel->Pnext = (EDA_BaseStruct*) NextLabel->Pnext; + SheetLabel->SetNext( (EDA_BaseStruct*) NextLabel->Next() ); SAFE_DELETE( DrawStruct ); return; } @@ -448,18 +448,18 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) else { DrawList = Screen->EEDrawList; - while( DrawList && DrawList->Pnext ) + while( DrawList && DrawList->Next() ) { - if( DrawList->Pnext == PickedList->m_PickedStruct ) + if( DrawList->Next() == PickedList->m_PickedStruct ) { - DrawList->Pnext = DrawList->Pnext->Pnext; + DrawList->SetNext( DrawList->Next()->Next() ); SAFE_DELETE( DrawStruct ); return; } - DrawList = DrawList->Pnext; + DrawList = DrawList->Next(); } } - PickedList = (DrawPickedStruct*) PickedList->Pnext; + PickedList = (DrawPickedStruct*) PickedList->Next(); } } else // structure usuelle */ @@ -472,15 +472,15 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) else { DrawList = Screen->EEDrawList; - while( DrawList && DrawList->Pnext ) + while( DrawList && DrawList->Next() ) { - if( DrawList->Pnext == DrawStruct ) + if( DrawList->Next() == DrawStruct ) { - DrawList->Pnext = DrawStruct->Pnext; + DrawList->SetNext( DrawStruct->Next() ); SAFE_DELETE( DrawStruct ); return; } - DrawList = DrawList->Pnext; + DrawList = DrawList->Next(); } } } @@ -557,9 +557,9 @@ void DeleteOneLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC, { while( PreviousDrawItem ) { - if( PreviousDrawItem->Pnext == DrawItem ) + if( PreviousDrawItem->Next() == DrawItem ) { - PreviousDrawItem->Pnext = DrawItem->Pnext; + PreviousDrawItem->SetNext( DrawItem->Next() ); SAFE_DELETE( DrawItem ); break; } diff --git a/eeschema/delsheet.cpp b/eeschema/delsheet.cpp index bfe079e2cb..5eaf2ce7b1 100644 --- a/eeschema/delsheet.cpp +++ b/eeschema/delsheet.cpp @@ -1,6 +1,6 @@ - /*******************************************************/ - /* delsheet.cpp Routine d'effacement d'une hierarchie */ - /*******************************************************/ +/*******************************************************/ +/* delsheet.cpp Routine d'effacement d'une hierarchie */ +/*******************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -14,102 +14,110 @@ /**************************************************************************/ -void DeleteSubHierarchy(DrawSheetStruct * FirstSheet, bool confirm_deletion) +void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion ) /**************************************************************************/ /* Free (delete) all schematic data (include the sub hierarchy sheets ) - for the hierarchical sheet FirstSheet - FirstSheet is not deleted. -*/ + * for the hierarchical sheet FirstSheet + * FirstSheet is not deleted. + */ { -EDA_BaseStruct *DrawStruct; -EDA_BaseStruct *EEDrawList; -WinEDA_SchematicFrame * frame = g_EDA_Appl->m_SchematicFrame; -wxString msg; + EDA_BaseStruct* DrawStruct; + EDA_BaseStruct* EEDrawList; + WinEDA_SchematicFrame* frame = g_EDA_Appl->m_SchematicFrame; + wxString msg; - if( FirstSheet == NULL ) return; + if( FirstSheet == NULL ) + return; - if( FirstSheet->Type() != DRAW_SHEET_STRUCT_TYPE) - { - DisplayError(NULL, - wxT("DeleteSubHierarchy error(): NOT a Sheet")); - return; - } + if( FirstSheet->Type() != DRAW_SHEET_STRUCT_TYPE ) + { + DisplayError( NULL, + wxT( "DeleteSubHierarchy error(): NOT a Sheet" ) ); + return; + } - /* effacement du sous schema correspondant */ - if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion ) - { - msg.Printf( _("Sheet %s (file %s) modified. Save it?"), - FirstSheet->m_SheetName.GetData(), - FirstSheet->GetFileName().GetData()); - if( IsOK(NULL, msg) ) - { - frame->SaveEEFile(FirstSheet->m_AssociatedScreen, FILE_SAVE_AS); - } - } + /* effacement du sous schema correspondant */ + if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion ) + { + msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ), + FirstSheet->m_SheetName.GetData(), + FirstSheet->GetFileName().GetData() ); + if( IsOK( NULL, msg ) ) + { + frame->SaveEEFile( FirstSheet->m_AssociatedScreen, FILE_SAVE_AS ); + } + } - /* free the sub hierarchy */ - if(FirstSheet->m_AssociatedScreen){ - EEDrawList = FirstSheet->m_AssociatedScreen->EEDrawList; - while (EEDrawList != NULL) - { - DrawStruct = EEDrawList; - EEDrawList = EEDrawList->Pnext; - if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) - { - DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion); - } - } - /* Effacement des elements de la feuille courante */ - FirstSheet->m_AssociatedScreen->FreeDrawList(); - } + /* free the sub hierarchy */ + if( FirstSheet->m_AssociatedScreen ) + { + EEDrawList = FirstSheet->m_AssociatedScreen->EEDrawList; + while( EEDrawList != NULL ) + { + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Next(); + if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) + { + DeleteSubHierarchy( (DrawSheetStruct*) DrawStruct, confirm_deletion ); + } + } + + /* Effacement des elements de la feuille courante */ + FirstSheet->m_AssociatedScreen->FreeDrawList(); + } } + /*********************************************************************/ + //void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion) /********************************************************************/ /* free the draw list DrawList and the subhierarchies */ + //this is redundant -- use FreeDrawList, a member of SCH_SCREEN + /* -{ -EDA_BaseStruct *DrawStruct; - - while (DrawList != NULL) - { - DrawStruct = DrawList; - DrawList = DrawList->Pnext; - - if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) - { - DeleteSubHierarchy((DrawSheetStruct*) DrawStruct, confirm_deletion); - } - - delete DrawStruct; - } -} -*/ + * { + * EDA_BaseStruct *DrawStruct; + * + * while (DrawList != NULL) + * { + * DrawStruct = DrawList; + * DrawList = DrawList->Pnext; + * + * if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) + * { + * DeleteSubHierarchy((DrawSheetStruct*) DrawStruct, confirm_deletion); + * } + * + * delete DrawStruct; + * } + * } + */ /********************************************************************/ -bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion) +bool ClearProjectDrawList( SCH_SCREEN* screen, bool confirm_deletion ) /********************************************************************/ + /* free the draw list screen->EEDrawList and the subhierarchies - clear the screen datas (filenames ..) -*/ + * clear the screen datas (filenames ..) + */ { - if ( screen == NULL ) return(TRUE); + if( screen == NULL ) + return TRUE; - screen->FreeDrawList(); + screen->FreeDrawList(); - /* Clear the screen datas */ - screen->m_ScreenNumber = screen->m_NumberOfScreen = 1; - screen->m_Title.Empty(); - screen->m_Revision.Empty(); - screen->m_Company.Empty(); - screen->m_Commentaire1.Empty(); - screen->m_Commentaire2.Empty(); - screen->m_Commentaire3.Empty(); - screen->m_Commentaire4.Empty(); - screen->m_Date = GenDate(); + /* Clear the screen datas */ + screen->m_ScreenNumber = screen->m_NumberOfScreen = 1; + screen->m_Title.Empty(); + screen->m_Revision.Empty(); + screen->m_Company.Empty(); + screen->m_Commentaire1.Empty(); + screen->m_Commentaire2.Empty(); + screen->m_Commentaire3.Empty(); + screen->m_Commentaire4.Empty(); + screen->m_Date = GenDate(); - return TRUE; + return TRUE; } - diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp index 06f0d974c6..68bdd54466 100644 --- a/eeschema/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -1,310 +1,504 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_edit_component_in_schematic.cpp -// Purpose: -// Author: jean-pierre Charras -// Modified by: -// Created: 03/03/2006 15:02:54 -// RCS-ID: -// Copyright: License GNU -// Licence: -///////////////////////////////////////////////////////////////////////////// -// Generated by DialogBlocks (unregistered), 03/03/2006 15:02:54 +#include +#include +#include "fctsys.h" +#include "gr_basic.h" -////@begin includes -////@end includes +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" #include "dialog_edit_component_in_schematic.h" -////@begin XPM images -////@end XPM images -/*! - * WinEDA_ComponentPropertiesFrame type definition - */ +#define ID_ON_SELECT_FIELD 3000 -IMPLEMENT_DYNAMIC_CLASS( WinEDA_ComponentPropertiesFrame, wxDialog ) -/*! - * WinEDA_ComponentPropertiesFrame event table definition - */ -BEGIN_EVENT_TABLE( WinEDA_ComponentPropertiesFrame, wxDialog ) - -////@begin WinEDA_ComponentPropertiesFrame event table entries - EVT_BUTTON( wxID_CANCEL, WinEDA_ComponentPropertiesFrame::OnCancelClick ) - - EVT_BUTTON( ID_RESTORE_CMP_DEFAULTS, WinEDA_ComponentPropertiesFrame::OnRestoreCmpDefaultsClick ) - - EVT_BUTTON( wxID_OK, WinEDA_ComponentPropertiesFrame::OnOkClick ) - -////@end WinEDA_ComponentPropertiesFrame event table entries - - EVT_RADIOBOX(ID_ON_SELECT_FIELD, WinEDA_ComponentPropertiesFrame::SelectNewField) - -END_EVENT_TABLE() - -/*! - * WinEDA_ComponentPropertiesFrame constructors - */ - -WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( ) +/**********************************************************************/ +void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, + SCH_COMPONENT* aComponent ) +/*********************************************************************/ { + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + if( aComponent->Type() != TYPE_SCH_COMPONENT ) + { + DisplayError( parent, + wxT( "InstallCmpeditFrame() error: This struct is not a component" ) ); + } + else + { + wxASSERT( aComponent ); // this is no longer callable with NULL + + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* frame = + new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent ); + + frame->InitBuffers( aComponent ); + frame->ShowModal(); + frame->Destroy(); + } + + parent->DrawPanel->MouseToCursorSchema(); + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; } -WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( WinEDA_SchematicFrame* parent, - SCH_COMPONENT * cmp, - wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) + +#if 0 +/*********************************************************************/ +void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) +/*********************************************************************/ { - m_Parent = parent; - m_Cmp = cmp; - m_LibEntry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; - InitBuffers(); + SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; - Create(parent, id, caption, pos, size, style); - - if ( m_LibEntry == NULL ) + // save old component in undo list + if( g_ItemToUndoCopy && g_ItemToUndoCopy->Type() == component->Type() ) { - SetTitle(_("Component properties (Not found in lib)")); + component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); + + frame->SaveCopyInUndoList( component, IS_CHANGED ); + + component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); + } + + m_AddExtraText = 0; + if( m_FieldId == REFERENCE ) + { + EDA_LibComponentStruct* part; + + part = FindLibPart( component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( part ) + { + if( part->m_UnitCount > 1 ) + m_AddExtraText = 1; + } + } + + Draw( frame->DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE ); + m_Flags = 0; + frame->GetScreen()->SetCurItem( NULL ); + frame->GetScreen()->SetModify(); +} +#endif + + +DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ) : + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( parent ) +{ + m_Parent = (WinEDA_SchematicFrame*) parent; + +// fieldGrid->SetDefaultColSize( 160, true ); +// fieldGrid->SetColLabelValue( 0, _("Field Text") ); + + // set grid as read only. + fieldGrid->EnableEditing( false ); + + // @todo make this conditional on 2.8.8 wxWidgets + fieldGrid->SetRowLabelSize( wxGRID_AUTOSIZE ); + + // else fieldGrid->SetRowLabelSize( 140 ) or so + + // select only a single row, and since table is only a single column wide + // this means only one cell. + fieldGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); + + wxToolTip::Enable( true ); +} + + +/* +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellLeftClick( wxGridEvent& event ) +{ + // TODO: Implement OnGridCellLeftClick +} +*/ + +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx ) +{ + fieldGrid->SelectCol( 0 ); + fieldGrid->SelectRow( aFieldNdx ); +} + + +int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx() +{ + wxArrayInt array = fieldGrid->GetSelectedRows(); + if( !array.IsEmpty() ) + return array.Item(0); + else + return -1; +} + + +#if 0 +/*****************************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) +/*****************************************************************************/ + +/* Replace le composant en position normale, dimensions et positions + * fields comme definies en librairie + */ +{ + EDA_LibComponentStruct* Entry; + + if( m_Cmp == NULL ) + return; + + Entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + + if( Entry == NULL ) + return; + + wxClientDC dc( m_Parent->DrawPanel ); + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); + + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); + + /* Mise aux valeurs par defaut des champs et orientation */ + m_Cmp->GetField( REFERENCE )->m_Pos.x = + Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; + + m_Cmp->GetField( REFERENCE )->m_Pos.y = + Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; + + m_Cmp->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient; + m_Cmp->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size; + m_Cmp->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify; + m_Cmp->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify; + + m_Cmp->GetField( VALUE )->m_Pos.x = + Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; + + m_Cmp->GetField( VALUE )->m_Pos.y = + Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; + + m_Cmp->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient; + m_Cmp->GetField( VALUE )->m_Size = Entry->m_Name.m_Size; + m_Cmp->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify; + m_Cmp->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify; + + m_Cmp->SetRotationMiroir( CMP_NORMAL ); + + m_Parent->GetScreen()->SetModify(); + + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); + EndModal( 1 ); +} +#endif + + +/********************************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ) +/********************************************************************************/ +{ + m_Cmp = aComponent; + + setSelectedFieldNdx( REFERENCE ); + + m_FieldBuf = aComponent->m_Fields; + + m_FieldBuf[REFERENCE].m_Text = m_Cmp->GetRef( m_Parent->GetSheet() ); + + for( int ii = 0; ii < aComponent->GetFieldCount(); ++ii ) + { + // make the editable field position relative to the component + m_FieldBuf[ii].m_Pos -= m_Cmp->m_Pos; } } -/*! - * WinEDA_ComponentPropertiesFrame creator - */ -bool WinEDA_ComponentPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +#if 0 + +/****************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyDataToPanel() +/****************************************************************/ { - m_FieldNameCtrl = NULL; -////@begin WinEDA_ComponentPropertiesFrame member initialisation - m_GeneralBoxSizer = NULL; - m_NoteBook = NULL; - m_PanelBasic = NULL; - m_SelectUnit = NULL; - m_OrientUnit = NULL; - m_MirrorUnit = NULL; - m_MsgPartLocked = NULL; - m_ConvertButt = NULL; - m_RefInLib = NULL; - m_PanelField = NULL; - m_ShowFieldTextCtrl = NULL; - m_VorientFieldText = NULL; - m_FieldDatasBoxSizer = NULL; - m_FieldSelectionBoxSizer = NULL; - m_btClose = NULL; -////@end WinEDA_ComponentPropertiesFrame member initialisation + int fieldNdx = GetSelectedFieldNdx(); -////@begin WinEDA_ComponentPropertiesFrame creation - SetExtraStyle(wxWS_EX_BLOCK_EVENTS); - wxDialog::Create( parent, id, caption, pos, size, style ); + if( fieldNdx == -1 ) + return; - CreateControls(); - if (GetSizer()) + for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) { - GetSizer()->SetSizeHints(this); + m_FieldSelection->SetString( ii, m_FieldName[ii] ); } - Centre(); -////@end WinEDA_ComponentPropertiesFrame creation - return true; + + if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) + m_FieldTextCtrl->Enable( FALSE ); + + if( m_FieldFlags[fieldNdx] ) + m_ShowFieldTextCtrl->SetValue( TRUE ); + else + m_ShowFieldTextCtrl->SetValue( FALSE ); + + // If the field value is empty and the position is zero, we set the + // initial position as a small offset from the ref field, and orient + // it the same as the ref field. That is likely to put it at least + // close to the desired position. + if( m_FieldBuf[fieldNdx].m_Pos == wxPoint( 0, 0 ) + && m_FieldBuf[fieldNdx].m_Text.IsEmpty() ) + { + m_VorientFieldText->SetValue( m_FieldOrient[REFERENCE] != 0 ); + m_FieldPositionCtrl->SetValue( m_FieldPosition[REFERENCE].x + 100, + m_FieldPosition[REFERENCE].y + 100 ); + } + else + { + m_FieldPositionCtrl->SetValue( m_FieldPosition[fieldNdx].x, m_FieldPosition[fieldNdx].y ); + m_VorientFieldText->SetValue( m_FieldOrient[fieldNdx] != 0 ); + } + + m_FieldNameCtrl->SetValue( m_FieldName[fieldNdx] ); + + if( fieldNdx < FIELD1 ) + m_FieldNameCtrl->Enable( FALSE ); + else + m_FieldNameCtrl->Enable( TRUE ); + + m_FieldTextCtrl->SetValue( m_FieldText[fieldNdx] ); + m_FieldTextCtrl->SetValue( m_FieldSize[fieldNdx] ); } -/*! - * Control creation for WinEDA_ComponentPropertiesFrame + + +/****************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelFieldToData() +/****************************************************************/ + +/* Copy the values displayed on the panel field to the buffers according to + * the current field number */ - -void WinEDA_ComponentPropertiesFrame::CreateControls() { - SetFont(*g_DialogFont); + int id = m_CurrentFieldId; -////@begin WinEDA_ComponentPropertiesFrame content construction - // Generated by DialogBlocks, 29/04/2008 21:04:31 (unregistered) - - WinEDA_ComponentPropertiesFrame* itemDialog1 = this; - - m_GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); - itemDialog1->SetSizer(m_GeneralBoxSizer); - - m_NoteBook = new wxNotebook( itemDialog1, ID_SCHEDIT_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT|wxNB_TOP ); - - m_PanelBasic = new wxPanel( m_NoteBook, ID_PANEL_BASIC, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); - wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); - m_PanelBasic->SetSizer(itemBoxSizer5); - - wxArrayString m_SelectUnitStrings; - m_SelectUnitStrings.Add(_("Unit 1")); - m_SelectUnitStrings.Add(_("Unit 2")); - m_SelectUnitStrings.Add(_("Unit 3")); - m_SelectUnitStrings.Add(_("Unit 4")); - m_SelectUnitStrings.Add(_("Unit 5")); - m_SelectUnitStrings.Add(_("Unit 6")); - m_SelectUnitStrings.Add(_("Unit 7")); - m_SelectUnitStrings.Add(_("Unit 8")); - m_SelectUnitStrings.Add(_("Unit 9")); - m_SelectUnitStrings.Add(_("Unit 10")); - m_SelectUnitStrings.Add(_("Unit 11")); - m_SelectUnitStrings.Add(_("Unit 12")); - m_SelectUnitStrings.Add(_("Unit 13")); - m_SelectUnitStrings.Add(_("Unit 14")); - m_SelectUnitStrings.Add(_("Unit 15")); - m_SelectUnitStrings.Add(_("Unit 16")); - m_SelectUnitStrings.Add(_("Unit 16")); - m_SelectUnitStrings.Add(_("Unit 17")); - m_SelectUnitStrings.Add(_("Unit 18")); - m_SelectUnitStrings.Add(_("Unit 19")); - m_SelectUnitStrings.Add(_("Unit 20")); - m_SelectUnitStrings.Add(_("Unit 21")); - m_SelectUnitStrings.Add(_("Unit 22")); - m_SelectUnitStrings.Add(_("Unit 23")); - m_SelectUnitStrings.Add(_("Unit 24")); - m_SelectUnitStrings.Add(_("Unit 25")); - m_SelectUnitStrings.Add(_("Unit 26")); - m_SelectUnit = new wxRadioBox( m_PanelBasic, ID_RADIOBOX_UNIT, _("Unit:"), wxDefaultPosition, wxDefaultSize, m_SelectUnitStrings, 9, wxRA_SPECIFY_ROWS ); - m_SelectUnit->SetSelection(0); - itemBoxSizer5->Add(m_SelectUnit, 0, wxGROW|wxALL, 5); - - wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer5->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer7->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - wxArrayString m_OrientUnitStrings; - m_OrientUnitStrings.Add(_("0")); - m_OrientUnitStrings.Add(_("+90")); - m_OrientUnitStrings.Add(_("180")); - m_OrientUnitStrings.Add(_("-90")); - m_OrientUnit = new wxRadioBox( m_PanelBasic, ID_RADIOBOX_ORIENT, _("Orient:"), wxDefaultPosition, wxDefaultSize, m_OrientUnitStrings, 1, wxRA_SPECIFY_COLS ); - m_OrientUnit->SetSelection(0); - itemBoxSizer8->Add(m_OrientUnit, 0, wxGROW|wxLEFT|wxRIGHT, 5); - - wxArrayString m_MirrorUnitStrings; - m_MirrorUnitStrings.Add(_("Normal")); - m_MirrorUnitStrings.Add(_("Mirror --")); - m_MirrorUnitStrings.Add(_("Mirror !")); - m_MirrorUnit = new wxRadioBox( m_PanelBasic, ID_RADIOBOX_MIRROR, _("Mirror:"), wxDefaultPosition, wxDefaultSize, m_MirrorUnitStrings, 1, wxRA_SPECIFY_COLS ); - m_MirrorUnit->SetSelection(0); - itemBoxSizer8->Add(m_MirrorUnit, 0, wxGROW|wxLEFT|wxRIGHT, 5); - - m_MsgPartLocked = new wxStaticText( m_PanelBasic, wxID_STATIC, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer7->Add(m_MsgPartLocked, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); - - m_ConvertButt = new wxCheckBox( m_PanelBasic, ID_CHECKBOX, _("Convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - m_ConvertButt->SetValue(false); - itemBoxSizer7->Add(m_ConvertButt, 0, wxALIGN_LEFT|wxALL, 5); - - wxStaticText* itemStaticText13 = new wxStaticText( m_PanelBasic, wxID_STATIC, _("Chip Name:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemStaticText13->SetForegroundColour(wxColour(202, 0, 0)); - itemBoxSizer7->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - m_RefInLib = new wxTextCtrl( m_PanelBasic, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer7->Add(m_RefInLib, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); - - m_NoteBook->AddPage(m_PanelBasic, _("Options")); - - m_PanelField = new wxPanel( m_NoteBook, ID_PANEL_FIELD, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); - wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL); - m_PanelField->SetSizer(itemBoxSizer16); - - wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer16->Add(itemBoxSizer17, 0, wxALIGN_TOP|wxALL, 5); - wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer17->Add(itemBoxSizer18, 0, wxGROW|wxALL, 5); - m_ShowFieldTextCtrl = new wxCheckBox( m_PanelField, ID_CHECKBOX_SHOW_FILED, _("Show Text"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - m_ShowFieldTextCtrl->SetValue(false); - itemBoxSizer18->Add(m_ShowFieldTextCtrl, 0, wxGROW|wxALL, 5); - - m_VorientFieldText = new wxCheckBox( m_PanelField, ID_CHECKBOX_FILED_ORIENT, _("Vertical"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - m_VorientFieldText->SetValue(false); - itemBoxSizer18->Add(m_VorientFieldText, 0, wxGROW|wxALL, 5); - - m_FieldDatasBoxSizer = new wxBoxSizer(wxVERTICAL); - itemBoxSizer17->Add(m_FieldDatasBoxSizer, 0, wxGROW|wxALL, 5); - - m_FieldSelectionBoxSizer = new wxBoxSizer(wxVERTICAL); - itemBoxSizer16->Add(m_FieldSelectionBoxSizer, 0, wxGROW|wxALL, 5); - - m_NoteBook->AddPage(m_PanelField, _("Fields")); - - m_GeneralBoxSizer->Add(m_NoteBook, 0, wxGROW|wxALL, 5); - - wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxHORIZONTAL); - m_GeneralBoxSizer->Add(itemBoxSizer23, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - - m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - m_btClose->SetForegroundColour(wxColour(0, 0, 255)); - itemBoxSizer23->Add(m_btClose, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton25 = new wxButton( itemDialog1, ID_RESTORE_CMP_DEFAULTS, _("Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton25->SetForegroundColour(wxColour(206, 0, 0)); - itemBoxSizer23->Add(itemButton25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton26->SetForegroundColour(wxColour(0, 128, 0)); - itemBoxSizer23->Add(itemButton26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - -////@end WinEDA_ComponentPropertiesFrame content construction - m_btClose->SetFocus(); - BuildPanelBasic(); - BuildPanelFields(); + m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); + m_FieldOrient[id] = m_VorientFieldText->GetValue(); + m_FieldText[id] = m_FieldTextCtrl->GetText(); + m_FieldName[id] = m_FieldNameCtrl->GetValue(); + m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); + m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); } -/*! - * Should we show tooltips? + +/*************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::fillTableModel() +/*************************************************************/ +{ +} + + +/**********************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::buildPanelBasic() +/**********************************************************/ + +/* create the basic panel for component properties editing */ - -bool WinEDA_ComponentPropertiesFrame::ShowToolTips() { - return true; + int Nb_Max_Unit = m_SelectUnit->GetCount(); + int ii; + + int nb_units = m_LibEntry ? MAX( m_LibEntry->m_UnitCount, 1 ) : 0; + + // Disable non existant units selection buttons + for( ii = nb_units; ii < Nb_Max_Unit; ii++ ) + { + m_SelectUnit->Enable( ii, FALSE ); + } + + if( m_Cmp->m_Multi <= Nb_Max_Unit ) + m_SelectUnit->SetSelection( m_Cmp->m_Multi - 1 ); + + ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y); + + if( ii == CMP_ORIENT_90 ) + m_OrientUnit->SetSelection( 1 ); + else if( ii == CMP_ORIENT_180 ) + m_OrientUnit->SetSelection( 2 ); + else if( ii == CMP_ORIENT_270 ) + m_OrientUnit->SetSelection( 3 ); + + ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y); + if( ii == CMP_MIROIR_X ) + m_MirrorUnit->SetSelection( 1 ); + else if( ii == CMP_MIROIR_Y ) + m_MirrorUnit->SetSelection( 2 ); + + // Positionnement de la selection normal/convert + if( m_Cmp->m_Convert > 1 ) + m_ConvertButt->SetValue( TRUE ); + + if( (m_LibEntry == NULL) || LookForConvertPart( m_LibEntry ) <= 1 ) + { + m_ConvertButt->Enable( FALSE ); + } + + // Show the "Parts Locked" option: + if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked ) + { + m_MsgPartLocked->Show( false ); + } + + // Positionnement de la reference en librairie + m_RefInLib->SetValue( m_Cmp->m_ChipName ); } -/*! - * Get bitmap resources + +/*************************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::selectNewField( wxCommandEvent& event ) +/*************************************************************************/ + +/* called when changing the current field selected + * Save the current field settings in buffer and display the new one */ - -wxBitmap WinEDA_ComponentPropertiesFrame::GetBitmapResource( const wxString& name ) { - // Bitmap retrieval -////@begin WinEDA_ComponentPropertiesFrame bitmap retrieval - wxUnusedVar(name); - return wxNullBitmap; -////@end WinEDA_ComponentPropertiesFrame bitmap retrieval + CopyPanelFieldToData(); + m_CurrentFieldId = m_FieldSelection->GetSelection(); + CopyDataToPanelField(); } -/*! - * Get icon resources + +/***********************************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::ComponentPropertiesAccept( wxCommandEvent& event ) +/***********************************************************************************/ + +/* Update the new parameters for the current edited component */ - -wxIcon WinEDA_ComponentPropertiesFrame::GetIconResource( const wxString& name ) { - // Icon retrieval -////@begin WinEDA_ComponentPropertiesFrame icon retrieval - wxUnusedVar(name); - return wxNullIcon; -////@end WinEDA_ComponentPropertiesFrame icon retrieval -} -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ + wxPoint cmp_pos = m_Cmp->m_Pos; + wxClientDC dc( m_Parent->DrawPanel ); + wxString newname; -void WinEDA_ComponentPropertiesFrame::OnCancelClick( wxCommandEvent& event ) -{ - EndModal( -1 ); + /* save old cmp in undo list if not already in edit, or moving ... */ + if( m_Cmp->m_Flags == 0 ) + m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED ); + + CopyPanelFieldToData(); + + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); + + + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); + + newname = m_RefInLib->GetValue(); + newname.MakeUpper(); + newname.Replace( wxT( " " ), wxT( "_" ) ); + + if( newname.IsEmpty() ) + DisplayError( this, _( "No Component Name!" ) ); + + else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) + { + if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL ) + { + wxString message; + message.Printf( _( "Component [%s] not found!" ), newname.GetData() ); + DisplayError( this, message ); + } + else // Changement de composant! + { + m_Cmp->m_ChipName = newname; + } + } + + // Mise a jour de la representation: + if( m_ConvertButt->IsEnabled() ) + (m_ConvertButt->GetValue() == TRUE) ? + m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; + + //Set the part selection in multiple part per pakcage + if( m_Cmp->m_Multi ) + { + int unit_selection = m_SelectUnit->GetSelection() + 1; + m_Cmp->SetUnitSelection( m_Parent->GetSheet(), unit_selection ); + m_Cmp->m_Multi = unit_selection; + } + + //Mise a jour de l'orientation: + switch( m_OrientUnit->GetSelection() ) + { + case 0: + m_Cmp->SetRotationMiroir( CMP_ORIENT_0 ); + break; + + case 1: + m_Cmp->SetRotationMiroir( CMP_ORIENT_90 ); + break; + + case 2: + m_Cmp->SetRotationMiroir( CMP_ORIENT_180 ); + break; + + case 3: + m_Cmp->SetRotationMiroir( CMP_ORIENT_270 ); + break; + } + + switch( m_MirrorUnit->GetSelection() ) + { + case 0: + break; + + case 1: + m_Cmp->SetRotationMiroir( CMP_MIROIR_X ); + break; + + case 2: + m_Cmp->SetRotationMiroir( CMP_MIROIR_Y ); + break; + } + + + // Mise a jour des textes (update the texts) + for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + if( ii == REFERENCE ) // la reference ne peut etre vide + { + if( !m_FieldText[ii].IsEmpty() ) + m_Cmp->SetRef(m_Parent->GetSheet(), m_FieldText[ii]); + } + else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER + { + EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData( + ), wxEmptyString, FIND_ROOT ); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + m_Cmp->GetField( ii )->m_Text = m_Cmp->m_ChipName; + else if( !m_FieldText[ii].IsEmpty() ) + { + m_Cmp->GetField( ii )->m_Text = m_FieldText[ii]; + } + } + else + m_Cmp->GetField( ii )->m_Text = m_FieldText[ii]; + + if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) ) + m_Cmp->GetField( ii )->m_Name = m_FieldName[ii]; + else + m_Cmp->GetField( ii )->m_Name.Empty(); + + m_Cmp->GetField( ii )->m_Size.x = + m_Cmp->GetField( ii )->m_Size.y = m_FieldSize[ii]; + if( m_FieldFlags[ii] ) + m_Cmp->GetField( ii )->m_Attributs &= ~TEXT_NO_VISIBLE; + else + m_Cmp->GetField( ii )->m_Attributs |= TEXT_NO_VISIBLE; + m_Cmp->GetField( ii )->m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + m_Cmp->GetField( ii )->m_Pos = m_FieldPosition[ii]; + m_Cmp->GetField( ii )->m_Pos.x += cmp_pos.x; + m_Cmp->GetField( ii )->m_Pos.y += cmp_pos.y; + } + + m_Parent->GetScreen()->SetModify(); + + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); + m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, &dc ); + + EndModal( 0 ); } -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESTORE_CMP_DEFAULTS - */ - -void WinEDA_ComponentPropertiesFrame::OnRestoreCmpDefaultsClick( wxCommandEvent& event ) -{ - SetInitCmp(event); -} - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - */ - -void WinEDA_ComponentPropertiesFrame::OnOkClick( wxCommandEvent& event ) -{ - ComponentPropertiesAccept(event); -} +#endif diff --git a/eeschema/dialog_edit_component_in_schematic.h b/eeschema/dialog_edit_component_in_schematic.h index c6f0a8485f..42cbc41c34 100644 --- a/eeschema/dialog_edit_component_in_schematic.h +++ b/eeschema/dialog_edit_component_in_schematic.h @@ -1,158 +1,55 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_edit_component_in_schematic.h -// Purpose: -// Author: jean-pierre Charras -// Modified by: -// Created: 03/03/2006 15:02:54 -// RCS-ID: -// Copyright: License GNU -// Licence: -///////////////////////////////////////////////////////////////////////////// -// Generated by DialogBlocks (unregistered), 03/03/2006 15:02:54 +#ifndef __dialog_edit_component_in_schematic__ +#define __dialog_edit_component_in_schematic__ -#ifndef _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ -#define _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ -/*! - * Includes +#include "dialog_edit_component_in_schematic_fbp.h" + +/** + * class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC + * is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which is maintained by + * wxFormBuilder. Do not auto-generate this class or file, it is hand coded. */ - -////@begin includes -#include "wx/notebook.h" -////@end includes - -/*! - * Forward declarations - */ - -////@begin forward declarations -class wxBoxSizer; -class wxNotebook; -////@end forward declarations - -/*! - * Control identifiers - */ - -////@begin control identifiers -#define ID_DIALOG 10000 -#define ID_SCHEDIT_NOTEBOOK 10001 -#define ID_PANEL_BASIC 10002 -#define ID_RADIOBOX_UNIT 10004 -#define ID_RADIOBOX_ORIENT 10005 -#define ID_RADIOBOX_MIRROR 10007 -#define ID_CHECKBOX 10008 -#define ID_TEXTCTRL 10009 -#define ID_PANEL_FIELD 10003 -#define ID_CHECKBOX_SHOW_FILED 10010 -#define ID_CHECKBOX_FILED_ORIENT 10011 -#define ID_RESTORE_CMP_DEFAULTS 10006 -#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER -#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_TITLE _("Component Properties") -#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_IDNAME ID_DIALOG -#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_SIZE wxSize(400, 300) -#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_POSITION wxDefaultPosition -////@end control identifiers - -/*! - * Compatibility - */ - -#ifndef wxCLOSE_BOX -#define wxCLOSE_BOX 0x1000 -#endif - -/*! - * WinEDA_ComponentPropertiesFrame class declaration - */ - -class WinEDA_ComponentPropertiesFrame: public wxDialog +class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP { - DECLARE_DYNAMIC_CLASS( WinEDA_ComponentPropertiesFrame ) - DECLARE_EVENT_TABLE() + WinEDA_SchematicFrame* m_Parent; + SCH_COMPONENT* m_Cmp; + EDA_LibComponentStruct* m_LibEntry; + + /// a copy of the edited component's SCH_CMP_FIELDs + SCH_CMP_FIELDS m_FieldBuf; + + void setSelectedFieldNdx( int aFieldNdx ); + + int getSelectedFieldNdx(); + + + /** + * Function CopyDataToPanel + * sets the values displayed on the panel according to + * the current field number + */ + void copyDataToPanel(); + + + void fillTableModel(); + +protected: + + // Handlers for DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP events. +// void OnGridCellLeftClick( wxGridEvent& event ); public: - /// Constructors - WinEDA_ComponentPropertiesFrame( ); - WinEDA_ComponentPropertiesFrame( WinEDA_SchematicFrame* parent, - SCH_COMPONENT * cmp, - wxWindowID id = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_STYLE ); + /** Constructor */ + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ); - /// Creation - bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_STYLE ); + /** + * Function InitBuffers + * sets up to edit the given component. + * @param aComponent The component to edit. + */ + void InitBuffers( SCH_COMPONENT* aComponent ); - /// Creates the controls and sizers - void CreateControls(); - -////@begin WinEDA_ComponentPropertiesFrame event handler declarations - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - void OnCancelClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESTORE_CMP_DEFAULTS - void OnRestoreCmpDefaultsClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - void OnOkClick( wxCommandEvent& event ); - -////@end WinEDA_ComponentPropertiesFrame event handler declarations - -////@begin WinEDA_ComponentPropertiesFrame member function declarations - - /// Retrieves bitmap resources - wxBitmap GetBitmapResource( const wxString& name ); - - /// Retrieves icon resources - wxIcon GetIconResource( const wxString& name ); -////@end WinEDA_ComponentPropertiesFrame member function declarations - - /// Should we show tooltips? - static bool ShowToolTips(); - - void InitBuffers(); - void BuildPanelBasic(); - void BuildPanelFields(); - void ComponentPropertiesAccept(wxCommandEvent& event); - void SetInitCmp( wxCommandEvent& event ); - void CopyDataToPanelField(); - void CopyPanelFieldToData(); - void SelectNewField(wxCommandEvent& event); - -////@begin WinEDA_ComponentPropertiesFrame member variables - wxBoxSizer* m_GeneralBoxSizer; - wxNotebook* m_NoteBook; - wxPanel* m_PanelBasic; - wxRadioBox* m_SelectUnit; - wxRadioBox* m_OrientUnit; - wxRadioBox* m_MirrorUnit; - wxStaticText* m_MsgPartLocked; - wxCheckBox* m_ConvertButt; - wxTextCtrl* m_RefInLib; - wxPanel* m_PanelField; - wxCheckBox* m_ShowFieldTextCtrl; - wxCheckBox* m_VorientFieldText; - wxBoxSizer* m_FieldDatasBoxSizer; - wxBoxSizer* m_FieldSelectionBoxSizer; - wxButton* m_btClose; -////@end WinEDA_ComponentPropertiesFrame member variables - - WinEDA_SchematicFrame * m_Parent; - SCH_COMPONENT * m_Cmp; - EDA_LibComponentStruct * m_LibEntry; - int m_CurrentFieldId; - - wxRadioBox * m_FieldSelection; - WinEDA_GraphicTextCtrl * m_FieldTextCtrl; - WinEDA_EnterText * m_FieldNameCtrl; - WinEDA_PositionCtrl * m_FieldPositionCtrl; - wxString m_FieldText[NUMBER_OF_FIELDS]; - wxString m_FieldName[NUMBER_OF_FIELDS]; - wxPoint m_FieldPosition[NUMBER_OF_FIELDS]; - int m_FieldSize[NUMBER_OF_FIELDS]; - int m_FieldFlags[NUMBER_OF_FIELDS]; - int m_FieldOrient[NUMBER_OF_FIELDS]; }; -#endif - // _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ +#endif // __dialog_edit_component_in_schematic__ diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index af1c5bc5d8..98b5839491 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -191,7 +191,7 @@ void WinEDA_PartPropertiesFrame::InitBuffers() while( Field ) { CopyFieldDataToBuffer( Field ); - Field = (LibDrawField*) Field->Pnext; + Field = Field->Next(); } } @@ -753,7 +753,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) LibDrawField* NextField, * previousField = NULL; while( Field ) { - NextField = (LibDrawField*) Field->Pnext; + NextField = Field->Next(); if( Field->m_FieldId == ii ) { CopyBufferToFieldData( Field ); @@ -765,7 +765,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) { SAFE_DELETE( Field ); if( previousField ) - previousField->Pnext = NextField; + previousField->SetNext( NextField ); else CurrentLibEntry->Fields = NextField; } @@ -789,7 +789,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) Field = new LibDrawField( ii ); CopyBufferToFieldData( Field ); - Field->Pnext = CurrentLibEntry->Fields; + Field->SetNext( CurrentLibEntry->Fields ); CurrentLibEntry->Fields = Field; } } @@ -805,7 +805,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) if( Field->m_FieldId >= FIELD1 ) if( Field->m_Text.IsEmpty() ) Field->m_Text = wxT( "~" ); - Field = (LibDrawField*) Field->Pnext; + Field = Field->Next(); } } @@ -1043,7 +1043,7 @@ bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage( int MaxUnit ) for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ ) { NextDrawItem = CopyDrawEntryStruct( this, DrawItem ); - NextDrawItem->Pnext = CurrentLibEntry->m_Drawings; + NextDrawItem->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = NextDrawItem; NextDrawItem->m_Unit = ii; } @@ -1090,7 +1090,7 @@ bool WinEDA_PartPropertiesFrame::SetUnsetConvert() } } NextDrawItem = CopyDrawEntryStruct( this, DrawItem ); - NextDrawItem->Pnext = CurrentLibEntry->m_Drawings; + NextDrawItem->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = NextDrawItem; NextDrawItem->m_Convert = 2; } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index a9b96ac8a7..4ef3e3227e 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -15,432 +15,13 @@ #include "protos.h" -/* Fonctions exportees */ - /* Fonctions locales */ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ); static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); -/* variables locales */ -static SCH_CMP_FIELD* CurrentField; -static int Multiflag; -static int TextFieldSize = DEFAULT_SIZE_TEXT; -static wxPoint OldPos; - - -/************************************/ -/* class WinEDA_PartPropertiesFrame */ -/************************************/ -#define ID_ON_SELECT_FIELD 3000 - -#include "dialog_edit_component_in_schematic.cpp" - -/**********************************************************************/ -void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, - SCH_COMPONENT* cmp ) -/*********************************************************************/ - -/* Create the dialog box for the current component edition - */ -{ - parent->DrawPanel->m_IgnoreMouseEvents = TRUE; - if( cmp->Type() != TYPE_SCH_COMPONENT ) - { - DisplayError( parent, - wxT( "InstallCmpeditFrame() error: This struct is not a component" ) ); - } - else - { - WinEDA_ComponentPropertiesFrame* frame = - new WinEDA_ComponentPropertiesFrame( parent, cmp ); - frame->ShowModal(); - frame->Destroy(); - } - - parent->DrawPanel->MouseToCursorSchema(); - parent->DrawPanel->m_IgnoreMouseEvents = FALSE; -} - - -/*****************************************************/ -void WinEDA_ComponentPropertiesFrame::InitBuffers() -/*****************************************************/ - -/* Init the buffers to a default value, - * or to values from Component!= NULL - */ -{ - int ii; - - m_CurrentFieldId = REFERENCE; - - /* Init default values */ - for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) - { - m_FieldSize[ii] = DEFAULT_SIZE_TEXT; - m_FieldFlags[ii] = 1; - m_FieldOrient[ii] = 0; - } - - if( m_Cmp == NULL ) - return; - - for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) - { - m_FieldName[ii] = m_Cmp->ReturnFieldName( ii ); - - if(ii == REFERENCE) - m_FieldText[ii] = m_Cmp->GetRef( m_Parent->GetSheet() ); - else - m_FieldText[ii] = m_Cmp->GetField( ii )->m_Text; - - m_FieldSize[ii] = m_Cmp->GetField( ii )->m_Size.x; - m_FieldFlags[ii] = (m_Cmp->GetField( ii )->m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; - m_FieldOrient[ii] = m_Cmp->GetField( ii )->m_Orient == TEXT_ORIENT_VERT ? 1 : 0; - - if( m_Cmp->GetField( ii )->m_Text.IsEmpty() ) - continue; - - // These values have meaning only if this field is not void: - m_FieldPosition[ii] = m_Cmp->GetField( ii )->m_Pos; - m_FieldPosition[ii].x -= m_Cmp->m_Pos.x; - m_FieldPosition[ii].y -= m_Cmp->m_Pos.y; - } -} - - -/****************************************************************/ -void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField() -/****************************************************************/ - -/* Set the values displayed on the panel field according to - * the current field number - */ -{ - int fieldId = m_CurrentFieldId; - - for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ){ - m_FieldSelection->SetString( ii, m_FieldName[ii] ); - } - - if( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) - m_FieldTextCtrl->Enable( FALSE ); - - if( m_FieldFlags[fieldId] ) - m_ShowFieldTextCtrl->SetValue( TRUE ); - else - m_ShowFieldTextCtrl->SetValue( FALSE ); - - // If the field value is empty and the position is zero, we set the - // initial position as a small offset from the ref field, and orient - // it the same as the ref field. That is likely to put it at least - // close to the desired position. - if( ( m_FieldPosition[fieldId] == wxPoint( 0, 0 ) ) - && m_FieldText[fieldId].IsEmpty() ) - { - m_VorientFieldText->SetValue( m_FieldOrient[REFERENCE] != 0 ); - m_FieldPositionCtrl->SetValue( m_FieldPosition[REFERENCE].x + 100, - m_FieldPosition[REFERENCE].y + 100 ); - } - else - { - m_FieldPositionCtrl->SetValue( m_FieldPosition[fieldId].x, m_FieldPosition[fieldId].y ); - m_VorientFieldText->SetValue( m_FieldOrient[fieldId] != 0 ); - } - - m_FieldNameCtrl->SetValue( m_FieldName[fieldId] ); - if( fieldId < FIELD1 ) - m_FieldNameCtrl->Enable( FALSE ); - else - m_FieldNameCtrl->Enable( TRUE ); - m_FieldTextCtrl->SetValue( m_FieldText[fieldId] ); - m_FieldTextCtrl->SetValue( m_FieldSize[fieldId] ); -} - - -/****************************************************************/ -void WinEDA_ComponentPropertiesFrame::CopyPanelFieldToData() -/****************************************************************/ - -/* Copy the values displayed on the panel field to the buffers according to - * the current field number - */ -{ - int id = m_CurrentFieldId; - - m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); - m_FieldOrient[id] = m_VorientFieldText->GetValue(); - m_FieldText[id] = m_FieldTextCtrl->GetText(); - m_FieldName[id] = m_FieldNameCtrl->GetValue(); - m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); - m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); -} - - -/*************************************************************/ -void WinEDA_ComponentPropertiesFrame::BuildPanelFields() -/*************************************************************/ -{ - int ii, FieldId; - wxPoint field_pos; - - m_CurrentFieldId = FieldId = REFERENCE; - - // Create the box field selection: - wxString fieldnamelist[NUMBER_OF_FIELDS]; - for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) - { - if( m_FieldName[ii].IsEmpty() ) - fieldnamelist[ii] = ReturnDefaultFieldName( ii ); - else - fieldnamelist[ii] = m_FieldName[ii]; - } - - m_FieldSelection = new wxRadioBox( m_PanelField, ID_ON_SELECT_FIELD, - _( "Field to edit" ), wxDefaultPosition, wxDefaultSize, - NUMBER_OF_FIELDS, fieldnamelist, 2, wxRA_SPECIFY_COLS ); - m_FieldSelectionBoxSizer->Add( m_FieldSelection, 0, wxGROW | wxALL, 5 ); - - // Create the box for field name display - m_FieldNameCtrl = new WinEDA_EnterText( m_PanelField, - _( "Field Name:" ), m_FieldName[FieldId], - m_FieldDatasBoxSizer, wxSize( 200, -1 ) ); - if( FieldId < FIELD1 ) - m_FieldNameCtrl->Enable( FALSE ); - else - m_FieldNameCtrl->Enable( TRUE ); - - // Create the box for text editing (text, size) - m_FieldTextCtrl = new WinEDA_GraphicTextCtrl( m_PanelField, - _( - "Field Text:" ), - m_FieldText[FieldId], - m_FieldSize[FieldId], - g_UnitMetric, - m_FieldDatasBoxSizer, 200, - m_Parent->m_InternalUnits ); - - // Create the box for text editing (position) - m_FieldPositionCtrl = new WinEDA_PositionCtrl( m_PanelField, _( "Pos" ), - m_FieldPosition[FieldId], - g_UnitMetric, - m_FieldDatasBoxSizer, - m_Parent->m_InternalUnits ); - - CopyDataToPanelField(); -} - - -/**********************************************************/ -void WinEDA_ComponentPropertiesFrame::BuildPanelBasic() -/**********************************************************/ - -/* create the basic panel for component properties editing - */ -{ - int Nb_Max_Unit = m_SelectUnit->GetCount(); - int ii; - - int nb_units = m_LibEntry ? MAX( m_LibEntry->m_UnitCount, 1 ) : 0; - - // Disable non existant units selection buttons - for( ii = nb_units; ii < Nb_Max_Unit; ii++ ) - { - m_SelectUnit->Enable( ii, FALSE ); - } - - if( m_Cmp->m_Multi <= Nb_Max_Unit ) - m_SelectUnit->SetSelection( m_Cmp->m_Multi - 1 ); - - ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y); - - if( ii == CMP_ORIENT_90 ) - m_OrientUnit->SetSelection( 1 ); - else if( ii == CMP_ORIENT_180 ) - m_OrientUnit->SetSelection( 2 ); - else if( ii == CMP_ORIENT_270 ) - m_OrientUnit->SetSelection( 3 ); - - ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y); - if( ii == CMP_MIROIR_X ) - m_MirrorUnit->SetSelection( 1 ); - else if( ii == CMP_MIROIR_Y ) - m_MirrorUnit->SetSelection( 2 ); - - // Positionnement de la selection normal/convert - if( m_Cmp->m_Convert > 1 ) - m_ConvertButt->SetValue( TRUE ); - - if( (m_LibEntry == NULL) || LookForConvertPart( m_LibEntry ) <= 1 ) - { - m_ConvertButt->Enable( FALSE ); - } - - // Show the "Parts Locked" option: - if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked ) - { - m_MsgPartLocked->Show( false ); - } - - // Positionnement de la reference en librairie - m_RefInLib->SetValue( m_Cmp->m_ChipName ); -} - - -/*************************************************************************/ -void WinEDA_ComponentPropertiesFrame::SelectNewField( wxCommandEvent& event ) -/*************************************************************************/ - -/* called when changing the current field selected - * Save the current field settings in buffer and display the new one - */ -{ - CopyPanelFieldToData(); - m_CurrentFieldId = m_FieldSelection->GetSelection(); - CopyDataToPanelField(); -} - - -/***********************************************************************************/ -void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& event ) -/***********************************************************************************/ - -/* Update the new parameters for the current edited component - */ -{ - wxPoint cmp_pos = m_Cmp->m_Pos; - wxClientDC dc( m_Parent->DrawPanel ); - wxString newname; - - /* save old cmp in undo list if not already in edit, or moving ... */ - if( m_Cmp->m_Flags == 0 ) - m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED ); - - CopyPanelFieldToData(); - - m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - - - RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); - - newname = m_RefInLib->GetValue(); - newname.MakeUpper(); - newname.Replace( wxT( " " ), wxT( "_" ) ); - - if( newname.IsEmpty() ) - DisplayError( this, _( "No Component Name!" ) ); - else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) - { - if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL ) - { - wxString message; - message.Printf( _( "Component [%s] not found!" ), newname.GetData() ); - DisplayError( this, message ); - } - else // Changement de composant! - { - m_Cmp->m_ChipName = newname; - } - } - - // Mise a jour de la representation: - if( m_ConvertButt->IsEnabled() ) - (m_ConvertButt->GetValue() == TRUE) ? - m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; - - //Set the part selection in multiple part per pakcage - if( m_Cmp->m_Multi ) - { - int unit_selection = m_SelectUnit->GetSelection() + 1; - m_Cmp->SetUnitSelection( m_Parent->GetSheet(), unit_selection ); - m_Cmp->m_Multi = unit_selection; - } - - //Mise a jour de l'orientation: - switch( m_OrientUnit->GetSelection() ) - { - case 0: - m_Cmp->SetRotationMiroir( CMP_ORIENT_0 ); - break; - - case 1: - m_Cmp->SetRotationMiroir( CMP_ORIENT_90 ); - break; - - case 2: - m_Cmp->SetRotationMiroir( CMP_ORIENT_180 ); - break; - - case 3: - m_Cmp->SetRotationMiroir( CMP_ORIENT_270 ); - break; - } - - switch( m_MirrorUnit->GetSelection() ) - { - case 0: - break; - - case 1: - m_Cmp->SetRotationMiroir( CMP_MIROIR_X ); - break; - - case 2: - m_Cmp->SetRotationMiroir( CMP_MIROIR_Y ); - break; - } - - - // Mise a jour des textes (update the texts) - for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) - { - if( ii == REFERENCE ) // la reference ne peut etre vide - { - if( !m_FieldText[ii].IsEmpty() ) - m_Cmp->SetRef(m_Parent->GetSheet(), m_FieldText[ii]); - } - else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER - { - EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData( - ), wxEmptyString, FIND_ROOT ); - if( Entry && (Entry->m_Options == ENTRY_POWER) ) - m_Cmp->GetField( ii )->m_Text = m_Cmp->m_ChipName; - else if( !m_FieldText[ii].IsEmpty() ) - { - m_Cmp->GetField( ii )->m_Text = m_FieldText[ii]; - } - } - else - m_Cmp->GetField( ii )->m_Text = m_FieldText[ii]; - - if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) ) - m_Cmp->GetField( ii )->m_Name = m_FieldName[ii]; - else - m_Cmp->GetField( ii )->m_Name.Empty(); - - m_Cmp->GetField( ii )->m_Size.x = - m_Cmp->GetField( ii )->m_Size.y = m_FieldSize[ii]; - if( m_FieldFlags[ii] ) - m_Cmp->GetField( ii )->m_Attributs &= ~TEXT_NO_VISIBLE; - else - m_Cmp->GetField( ii )->m_Attributs |= TEXT_NO_VISIBLE; - m_Cmp->GetField( ii )->m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; - m_Cmp->GetField( ii )->m_Pos = m_FieldPosition[ii]; - m_Cmp->GetField( ii )->m_Pos.x += cmp_pos.x; - m_Cmp->GetField( ii )->m_Pos.y += cmp_pos.y; - } - - m_Parent->GetScreen()->SetModify(); - - RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); - m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, &dc ); - - EndModal( 0 ); -} - /************************************************************************************/ -void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) +void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) /************************************************************************************/ /* Prepare le deplacement du texte en cours d'edition @@ -448,12 +29,11 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) { EDA_LibComponentStruct* Entry; - - CurrentField = Field; - if( Field == NULL ) + SetCurrentField( aField ); + if( aField == NULL ) return; - if( Field->m_Text == wxEmptyString ) + if( aField->m_Text == wxEmptyString ) { DisplayError( this, _( "No Field to move" ), 10 ); return; @@ -461,48 +41,48 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) wxPoint pos, newpos; int x1, y1; - SCH_COMPONENT* Cmp = (SCH_COMPONENT*) CurrentField->m_Parent; + SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent(); SAFE_DELETE( g_ItemToUndoCopy ); - g_ItemToUndoCopy = Cmp->GenCopy(); + g_ItemToUndoCopy = comp->GenCopy(); - pos = Cmp->m_Pos; + pos = comp->m_Pos; /* Les positions sont calculees par la matrice TRANSPOSEE de la matrice * de rotation-miroir */ - x1 = Field->m_Pos.x - pos.x; - y1 = Field->m_Pos.y - pos.y; + x1 = aField->m_Pos.x - pos.x; + y1 = aField->m_Pos.y - pos.y; // Empirically this is necessary. The Y coordinate appears to be inverted // under some circumstances, but that inversion is not preserved by all // combinations of mirroring and rotation. The following clause is true // when the number of rotations and the number of mirrorings are both odd. - if( Cmp->m_Transform[1][0] * Cmp->m_Transform[0][1] < 0 ) + if( comp->m_Transform[1][0] * comp->m_Transform[0][1] < 0 ) { y1 = -y1; } - newpos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; - newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; + newpos.x = pos.x + comp->m_Transform[0][0] * x1 + comp->m_Transform[1][0] * y1; + newpos.y = pos.y + comp->m_Transform[0][1] * x1 + comp->m_Transform[1][1] * y1; DrawPanel->CursorOff( DC ); GetScreen()->m_Curseur = newpos; DrawPanel->MouseToCursorSchema(); - OldPos = Field->m_Pos; - Multiflag = 0; - if( Field->m_FieldId == REFERENCE ) + m_OldPos = aField->m_Pos; + m_Multiflag = 0; + if( aField->m_FieldId == REFERENCE ) { - Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + Entry = FindLibPart( comp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry != NULL ) { if( Entry->m_UnitCount > 1 ) - Multiflag = 1; + m_Multiflag = 1; } } DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; DrawPanel->ManageCurseur = MoveCmpField; - Field->m_Flags = IS_MOVED; + aField->m_Flags = IS_MOVED; DrawPanel->CursorOn( DC ); } @@ -513,7 +93,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) /**********************************************************************************/ /* Edit the field Field (text, size) */ { - int FieldNumber, flag; + int fieldNdx, flag; EDA_LibComponentStruct* Entry; if( Field == NULL ) @@ -522,10 +102,10 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) return; } - SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->m_Parent; + SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent(); - FieldNumber = Field->m_FieldId; - if( FieldNumber == VALUE ) + fieldNdx = Field->m_FieldId; + if( fieldNdx == VALUE ) { Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry && (Entry->m_Options == ENTRY_POWER) ) @@ -539,7 +119,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) } flag = 0; - if( FieldNumber == REFERENCE ) + if( fieldNdx == REFERENCE ) { Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry != NULL ) @@ -568,20 +148,20 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) if( Field->m_Text.IsEmpty() ) { Field->m_Pos = Cmp->m_Pos; - Field->m_Size.x = Field->m_Size.y = TextFieldSize; + Field->m_Size.x = Field->m_Size.y = m_TextFieldSize; } Field->m_Text = newtext; - if( FieldNumber == REFERENCE ){ + if( fieldNdx == REFERENCE ){ Cmp->SetRef(GetSheet(), newtext); } } else /* Nouveau texte NULL */ { - if( FieldNumber == REFERENCE ) + if( fieldNdx == REFERENCE ) { DisplayError( this, _( "Reference needed !, No change" ) ); } - else if( FieldNumber == VALUE ) + else if( fieldNdx == VALUE ) { DisplayError( this, _( "Value needed !, No change" ) ); } @@ -607,31 +187,36 @@ static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { wxPoint pos; int x1, y1; - int FieldNumber; + int fieldNdx; - if( CurrentField == NULL ) + WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent(); + SCH_CMP_FIELD* currentField = frame->GetCurrentField(); + + if( currentField == NULL ) return; - SCH_COMPONENT* Cmp = (SCH_COMPONENT*) CurrentField->m_Parent; - FieldNumber = CurrentField->m_FieldId; + SCH_COMPONENT* component = (SCH_COMPONENT*) currentField->GetParent(); + fieldNdx = currentField->m_FieldId; - /* Effacement: */ - CurrentField->m_AddExtraText = Multiflag; + // Effacement: + currentField->m_AddExtraText = frame->m_Multiflag; if( erase ) { - CurrentField->Draw( panel, DC, wxPoint(0,0), g_XorMode ); + currentField->Draw( panel, DC, wxPoint(0,0), g_XorMode ); } - pos = ( (SCH_COMPONENT*) CurrentField->m_Parent )->m_Pos; + pos = ( (SCH_COMPONENT*) currentField->GetParent() )->m_Pos; /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice - * de rotation-miroir */ + * de rotation-miroir + */ x1 = panel->GetScreen()->m_Curseur.x - pos.x; y1 = panel->GetScreen()->m_Curseur.y - pos.y; - CurrentField->m_Pos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; - CurrentField->m_Pos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; - CurrentField->Draw( panel, DC, wxPoint(0,0), g_XorMode ); + currentField->m_Pos.x = pos.x + component->m_Transform[0][0] * x1 + component->m_Transform[1][0] * y1; + currentField->m_Pos.y = pos.y + component->m_Transform[0][1] * x1 + component->m_Transform[1][1] * y1; + + currentField->Draw( panel, DC, wxPoint(0,0), g_XorMode ); } @@ -641,15 +226,21 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ) { Panel->ForceCloseManageCurseur = NULL; Panel->ManageCurseur = NULL; - if( CurrentField ) + + WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent(); + SCH_CMP_FIELD* currentField = frame->GetCurrentField(); + + if( currentField ) { - CurrentField->m_AddExtraText = Multiflag; - CurrentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode ); - CurrentField->m_Flags = 0; - CurrentField->m_Pos = OldPos; - CurrentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode ); + currentField->m_AddExtraText = frame->m_Multiflag; + currentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode ); + currentField->m_Flags = 0; + currentField->m_Pos = frame->m_OldPos; + currentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode ); } - CurrentField = NULL; + + frame->SetCurrentField( NULL ); + SAFE_DELETE( g_ItemToUndoCopy ); } @@ -658,7 +249,7 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ) void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) /*********************************************************************************/ { - int FieldNumber, flag; + int fieldNdx, flag; EDA_LibComponentStruct* Entry; if( Field == NULL ) @@ -666,13 +257,13 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) if( Field->m_Text == wxEmptyString ) return; - SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->m_Parent; + SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent(); - FieldNumber = Field->m_FieldId; + fieldNdx = Field->m_FieldId; flag = 0; - if( FieldNumber == REFERENCE ) + if( fieldNdx == REFERENCE ) { - Entry = FindLibPart( ( (SCH_COMPONENT*) Field->m_Parent )->m_ChipName.GetData(), + Entry = FindLibPart( ( (SCH_COMPONENT*) Field->GetParent() )->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry != NULL ) { @@ -702,26 +293,27 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) /*********************************************************************/ { - int FieldNumber; + int fieldNdx; EDA_LibComponentStruct* Entry; frame->DrawPanel->ManageCurseur = NULL; frame->DrawPanel->ForceCloseManageCurseur = NULL; - SCH_COMPONENT* Cmp = (SCH_COMPONENT*) m_Parent; - /* save old cmp in undo list */ - if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == Cmp->Type()) ) + SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); + + // save old cmp in undo list + if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == component->Type()) ) { - Cmp->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); - ( (WinEDA_SchematicFrame*) frame )->SaveCopyInUndoList( Cmp, IS_CHANGED ); - Cmp->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); + component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); + frame->SaveCopyInUndoList( component, IS_CHANGED ); + component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); } - FieldNumber = m_FieldId; + fieldNdx = m_FieldId; m_AddExtraText = 0; - if( FieldNumber == REFERENCE ) + if( fieldNdx == REFERENCE ) { - Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + Entry = FindLibPart( component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); if( Entry != NULL ) { if( Entry->m_UnitCount > 1 ) @@ -733,7 +325,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) m_Flags = 0; frame->GetScreen()->SetCurItem( NULL ); frame->GetScreen()->SetModify(); - CurrentField = NULL; + frame->SetCurrentField( NULL ); } @@ -813,6 +405,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) Cmp->Display_Infos( this ); } + /*****************************************************************************************/ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ) /*****************************************************************************************/ @@ -866,52 +459,4 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC Cmp->Display_Infos( this ); } -/*****************************************************************************/ -void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) -/*****************************************************************************/ -/* Replace le composant en position normale, dimensions et positions - * fields comme definies en librairie - */ -{ - EDA_LibComponentStruct* Entry; - - if( m_Cmp == NULL ) - return; - - Entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - - if( Entry == NULL ) - return; - - wxClientDC dc( m_Parent->DrawPanel ); - m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - - RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); - - /* Mise aux valeurs par defaut des champs et orientation */ - m_Cmp->GetField( REFERENCE )->m_Pos.x = - Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; - m_Cmp->GetField( REFERENCE )->m_Pos.y = - Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; - m_Cmp->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient; - m_Cmp->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size; - m_Cmp->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify; - m_Cmp->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify; - - m_Cmp->GetField( VALUE )->m_Pos.x = - Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; - m_Cmp->GetField( VALUE )->m_Pos.y = - Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; - m_Cmp->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient; - m_Cmp->GetField( VALUE )->m_Size = Entry->m_Name.m_Size; - m_Cmp->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify; - m_Cmp->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify; - - m_Cmp->SetRotationMiroir( CMP_NORMAL ); - - m_Parent->GetScreen()->SetModify(); - - RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); - EndModal( 1 ); -} diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 8ffb8cf9ac..785006b700 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -378,7 +378,7 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, /* add the new text in linked list if old text is in list */ if( (flags & IS_NEW) == 0 ) { - newtext->Pnext = GetScreen()->EEDrawList; + newtext->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = newtext; GetScreen()->SetModify(); } diff --git a/eeschema/eelibs_draw_components.cpp b/eeschema/eelibs_draw_components.cpp index ab166aee83..704c54e8bd 100644 --- a/eeschema/eelibs_draw_components.cpp +++ b/eeschema/eelibs_draw_components.cpp @@ -64,7 +64,7 @@ wxPoint TransformCoordinate( int aTransformMatrix[2][2], wxPoint& aPosition ) void CreateDummyCmp() /******************************/ { - DummyCmp = new EDA_LibComponentStruct( NULL ); + DummyCmp = new EDA_LibComponentStruct( NULL ); LibDrawSquare* Square = new LibDrawSquare(); @@ -78,7 +78,7 @@ void CreateDummyCmp() Text->m_Text = wxT( "??" ); DummyCmp->m_Drawings = Square; - Square->Pnext = Text; + Square->SetNext( Text ); } @@ -153,7 +153,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 ) LibEntry->m_Name.Draw( panel, DC, aOffset, color, DrawMode, NULL, TransMat ); - for( Field = LibEntry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext ) + for( Field = LibEntry->Fields; Field != NULL; Field = Field->Next() ) { if( Field->m_Text.IsEmpty() ) return; diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index ad4e67b751..b55b5357b5 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -92,8 +92,8 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, LoadDocLib( frame, FullFileName, NewLib->m_Name ); } else{ - SAFE_DELETE( NewLib ); - } + SAFE_DELETE( NewLib ); + } fclose( f ); return NewLib; } @@ -138,7 +138,7 @@ void LoadLibraries( WinEDA_DrawFrame* frame ) if( LibName.IsEmpty() ) continue; - FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer ); + FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer ); // Loaded library statusbar message msg = _( "Library " ) + FullLibName; @@ -238,7 +238,7 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName ) TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext; } - SAFE_DELETE( Lib ); + SAFE_DELETE( Lib ); /* The removed librairy can be the current library in libedit. * If so, clear the current library in libedit */ @@ -285,7 +285,7 @@ int LibraryEntryCompare( EDA_LibComponentStruct* LE1, EDA_LibComponentStruct* LE /**************************************************/ /* Routine to load a library from given open file */ /**************************************************/ -PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, +PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, LibraryStruct* Library, FILE* libfile, int* NumOfParts ) @@ -487,7 +487,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ), *LineNum, currentLibraryName.GetData() ); DisplayError( frame, Msg ); - SAFE_DELETE( LibEntry ); + SAFE_DELETE( LibEntry ); return NULL; } } @@ -784,7 +784,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char* MsgLine.Printf( wxT( "Error in %c DRAW command in line %d, aborted." ), Line[0], *LineNum ); DisplayError( frame, MsgLine ); - SAFE_DELETE( New ); + SAFE_DELETE( New ); /* FLush till end of draw: */ do { @@ -803,7 +803,8 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char* Head = Tail = New; else { - Tail->Pnext = New; Tail = New; + Tail->SetNext( New ); + Tail = New; } } } @@ -935,7 +936,7 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line ) Field = new LibDrawField( NumOfField ); - Field->Pnext = LibEntry->Fields; + Field->SetNext( LibEntry->Fields ); LibEntry->Fields = Field; break; } @@ -1154,7 +1155,7 @@ void EDA_LibComponentStruct::SortDrawItems() Bufentry = BufentryBase; for( ii = 0; ii < nbitems; ii++ ) { - (*Bufentry)->Pnext = *(Bufentry + 1); + (*Bufentry)->SetNext( *(Bufentry + 1) ); Bufentry++; } diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index b4c8c57bf3..0cc2172b84 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -428,7 +428,7 @@ void WinEDA_ErcFrame::DelERCMarkers( wxCommandEvent& event ) // Delete markers for the current screen DrawStruct = m_Parent->GetScreen()->EEDrawList; - for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) { if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE ) continue; @@ -533,7 +533,7 @@ static void Diagnose( WinEDA_DrawPanel* panel, wxDC* DC, Marker->m_Type = MARQ_ERC; Marker->m_MarkFlags = WAR; screen = NetItemRef->m_SheetList.LastScreen(); - Marker->Pnext = screen->EEDrawList; + Marker->SetNext( screen->EEDrawList ); screen->EEDrawList = Marker; g_EESchemaVar.NbErrorErc++; g_EESchemaVar.NbWarningErc++; @@ -741,7 +741,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) ); DrawStruct = Sheet->LastDrawList(); - for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) { if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE ) continue; diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 99b2931c76..98c3a4b2a2 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -216,7 +216,7 @@ SCH_SCREEN* WinEDA_SchematicFrame::CreateNewScreen( NewScreen->m_Company = OldScreen->m_Company; NewScreen->m_TimeStamp = TimeStamp; - NewScreen->Pback = OldScreen; + NewScreen->SetBack( OldScreen ); return NewScreen; } diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index ea3a1f2914..2a92fb5f23 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -218,7 +218,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, DrawLibItem->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify; /* Init des autres champs si predefinis dans la librairie */ - for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext ) + for( Field = Entry->Fields; Field != NULL; Field = Field->Next() ) { if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) continue; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index c060eead56..100c31317a 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -233,7 +233,7 @@ void WinEDA_HierFrame::BuildSheetList( DrawSheetPath* list, m_Tree->Expand( menu ); list->Pop(); } - bs = bs->Pnext; + bs = bs->Next(); } maxposx -= m_Tree->GetIndent(); diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index e7b311d617..a1f9018e16 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -1,6 +1,6 @@ - /********************************************/ - /* library editor: undo and redo functions */ - /********************************************/ +/********************************************/ +/* library editor: undo and redo functions */ +/********************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -15,72 +15,79 @@ /*************************************************************************/ -void WinEDA_LibeditFrame::SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, - int unused_flag) +void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, + int unused_flag ) /*************************************************************************/ { -EDA_BaseStruct * item; -EDA_LibComponentStruct * CopyItem; + EDA_BaseStruct* item; + EDA_LibComponentStruct* CopyItem; - CopyItem = CopyLibEntryStruct ( this, (EDA_LibComponentStruct *) ItemToCopy); - GetScreen()->AddItemToUndoList((EDA_BaseStruct *)CopyItem); - /* Clear current flags (which can be temporary set by a current edit command) */ - for ( item = CopyItem->m_Drawings; item != NULL; item = item->Pnext ) - item->m_Flags = 0; - + CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy ); + GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CopyItem ); + /* Clear current flags (which can be temporary set by a current edit command) */ + for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) + item->m_Flags = 0; - /* Clear redo list, because after new save there is no redo to do */ - while ( GetScreen()->m_RedoList ) - { - item = GetScreen()->m_RedoList->Pnext; - delete (GetScreen()->m_RedoList); - GetScreen()->m_RedoList = item; - } + /* Clear redo list, because after new save there is no redo to do */ + while( GetScreen()->m_RedoList ) + { + item = GetScreen()->m_RedoList->Next(); + delete( GetScreen()->m_RedoList ); + GetScreen()->m_RedoList = item; + } } + /******************************************************/ bool WinEDA_LibeditFrame::GetComponentFromRedoList() /******************************************************/ + /* Redo the last edition: - - Place the current edited library component in undo list - - Get old version of the current edited library component + * - Place the current edited library component in undo list + * - Get old version of the current edited library component * @return FALSE if nothing done, else TRUE -*/ + */ { - if ( GetScreen()->m_RedoList == NULL ) return FALSE; - - GetScreen()->AddItemToUndoList((EDA_BaseStruct *)CurrentLibEntry); - CurrentLibEntry = - (EDA_LibComponentStruct *) GetScreen()->GetItemFromRedoList(); - if ( CurrentLibEntry ) CurrentLibEntry->Pnext = NULL; - CurrentDrawItem = NULL; - GetScreen()->SetModify(); - ReCreateHToolbar(); - SetToolbars(); - - return TRUE; + if( GetScreen()->m_RedoList == NULL ) + return FALSE; + + GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CurrentLibEntry ); + CurrentLibEntry = + (EDA_LibComponentStruct*) GetScreen()->GetItemFromRedoList(); + if( CurrentLibEntry ) + CurrentLibEntry->SetNext( NULL ); + CurrentDrawItem = NULL; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); + + return TRUE; } + /******************************************************/ bool WinEDA_LibeditFrame::GetComponentFromUndoList() /******************************************************/ -/* Undo the last edition: - - Place the current edited library component in Redo list - - Get old version of the current edited library component - * @return FALSE if nothing done, else TRUE -*/ -{ - if ( GetScreen()->m_UndoList == NULL ) return FALSE; - - GetScreen()->AddItemToRedoList((EDA_BaseStruct *)CurrentLibEntry); - CurrentLibEntry = - (EDA_LibComponentStruct *) GetScreen()->GetItemFromUndoList(); - if ( CurrentLibEntry ) CurrentLibEntry->Pnext = NULL; - CurrentDrawItem = NULL; - GetScreen()->SetModify(); - ReCreateHToolbar(); - SetToolbars(); - - return TRUE; +/* Undo the last edition: + * - Place the current edited library component in Redo list + * - Get old version of the current edited library component + * @return FALSE if nothing done, else TRUE + */ +{ + if( GetScreen()->m_UndoList == NULL ) + return FALSE; + + GetScreen()->AddItemToRedoList( (EDA_BaseStruct*) CurrentLibEntry ); + CurrentLibEntry = + (EDA_LibComponentStruct*) GetScreen()->GetItemFromUndoList(); + + if( CurrentLibEntry ) + CurrentLibEntry->SetNext( NULL ); + CurrentDrawItem = NULL; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); + + return TRUE; } diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index 004c471c56..63611dfb16 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -2,7 +2,7 @@ /* EESchema - edition des librairies: Edition des champs ( Fields ) */ /*********************************************************************/ - /* Fichier libfield.cpp */ +/* Fichier libfield.cpp */ #include "fctsys.h" #include "gr_basic.h" @@ -17,27 +17,27 @@ #include "wx/spinctrl.h" /* Routines locales */ -static void ShowMoveField(WinEDA_DrawPanel * panel, wxDC *DC, bool erase); +static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* Variables locales */ -extern int CurrentUnit; +extern int CurrentUnit; static wxPoint StartCursor, LastTextPosition; /***********************************************************/ -static void ExitMoveField(WinEDA_DrawPanel * Panel, wxDC * DC) +static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC ) /***********************************************************/ { - Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - if(CurrentDrawItem == NULL) return; + if( CurrentDrawItem == NULL ) + return; - wxPoint curpos; + wxPoint curpos; curpos = Panel->GetScreen()->m_Curseur; Panel->GetScreen()->m_Curseur = StartCursor; - ShowMoveField(Panel, DC, TRUE); + ShowMoveField( Panel, DC, TRUE ); Panel->GetScreen()->m_Curseur = curpos; CurrentDrawItem->m_Flags = 0; @@ -45,124 +45,130 @@ static void ExitMoveField(WinEDA_DrawPanel * Panel, wxDC * DC) } - /****************************************************************************/ -void WinEDA_LibeditFrame::StartMoveField(wxDC * DC, LibDrawField *field) +void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field ) /****************************************************************************/ /* Initialise le deplacement d'un champ ( ref ou Name) */ { -wxPoint startPos; + wxPoint startPos; - if( (CurrentLibEntry == NULL) || ( field == NULL ) ) return; - CurrentDrawItem = field; + if( (CurrentLibEntry == NULL) || ( field == NULL ) ) + return; + CurrentDrawItem = field; LastTextPosition = field->m_Pos; CurrentDrawItem->m_Flags |= IS_MOVED; startPos.x = LastTextPosition.x; startPos.y = -LastTextPosition.y; - DrawPanel->CursorOff(DC); + DrawPanel->CursorOff( DC ); GetScreen()->m_Curseur = startPos; DrawPanel->MouseToCursorSchema(); DrawPanel->ManageCurseur = ShowMoveField; DrawPanel->ForceCloseManageCurseur = ExitMoveField; - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); StartCursor = GetScreen()->m_Curseur; - DrawPanel->CursorOn(DC); + DrawPanel->CursorOn( DC ); } + /*****************************************************************/ /* Routine d'affichage du texte 'Field' en cours de deplacement. */ /* Routine normalement attachee au curseur */ /*****************************************************************/ -static void ShowMoveField(WinEDA_DrawPanel * panel, wxDC *DC, bool erase) +static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { -int color; -LibDrawField *Field = (LibDrawField *)CurrentDrawItem; + int color; + LibDrawField* Field = (LibDrawField*) CurrentDrawItem; - if( (CurrentLibEntry == NULL) || (Field == NULL) ) return; + if( (CurrentLibEntry == NULL) || (Field == NULL) ) + return; - switch (Field->m_FieldId) - { - case VALUE: - color = ReturnLayerColor(LAYER_VALUEPART); - break; + switch( Field->m_FieldId ) + { + case VALUE: + color = ReturnLayerColor( LAYER_VALUEPART ); + break; - case REFERENCE: - color = ReturnLayerColor(LAYER_REFERENCEPART); - break; + case REFERENCE: + color = ReturnLayerColor( LAYER_REFERENCEPART ); + break; - default: - color = ReturnLayerColor(LAYER_FIELDS); - break; - } + default: + color = ReturnLayerColor( LAYER_FIELDS ); + break; + } wxString text = Field->m_Text; - if ( Field->m_FieldId == REFERENCE ) - text << wxT("?"); + if( Field->m_FieldId == REFERENCE ) + text << wxT( "?" ); - int TransMat[2][2]; + int TransMat[2][2]; TransMat[0][0] = 1; TransMat[1][1] = -1; TransMat[1][0] = TransMat[0][1] = 0; - if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + if( Field->m_Attributs & TEXT_NO_VISIBLE ) + color = DARKGRAY; if( erase ) - Field->Draw( panel, DC, wxPoint(0,0), - color, - g_XorMode, &text, TransMat ); + Field->Draw( panel, DC, wxPoint( 0, 0 ), + color, + g_XorMode, &text, TransMat ); LastTextPosition.x = panel->GetScreen()->m_Curseur.x; - LastTextPosition.y = - panel->GetScreen()->m_Curseur.y; + LastTextPosition.y = -panel->GetScreen()->m_Curseur.y; Field->m_Pos = LastTextPosition; - Field->Draw( panel, DC, wxPoint(0,0), - color, - g_XorMode, &text, TransMat ); + Field->Draw( panel, DC, wxPoint( 0, 0 ), + color, + g_XorMode, &text, TransMat ); } + /*******************************************************************/ -void WinEDA_LibeditFrame::PlaceField(wxDC * DC, LibDrawField *Field) +void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field ) /*******************************************************************/ { -int color; + int color; - if(Field == NULL ) return; + if( Field == NULL ) + return; - switch (Field->m_FieldId) + switch( Field->m_FieldId ) { - case REFERENCE: - color = ReturnLayerColor(LAYER_REFERENCEPART); - break; + case REFERENCE: + color = ReturnLayerColor( LAYER_REFERENCEPART ); + break; - case VALUE: - color = ReturnLayerColor(LAYER_VALUEPART); - break; + case VALUE: + color = ReturnLayerColor( LAYER_VALUEPART ); + break; - default: - color = ReturnLayerColor(LAYER_FIELDS); - break; + default: + color = ReturnLayerColor( LAYER_FIELDS ); + break; } Field->m_Flags = 0; - if( (Field->m_Attributs & TEXT_NO_VISIBLE) != 0 ) color = DARKGRAY; + if( (Field->m_Attributs & TEXT_NO_VISIBLE) != 0 ) + color = DARKGRAY; Field->m_Pos.x = GetScreen()->m_Curseur.x; - Field->m_Pos.y = - GetScreen()->m_Curseur.y; -int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth); - DrawPanel->CursorOff(DC); + Field->m_Pos.y = -GetScreen()->m_Curseur.y; + int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth ); + DrawPanel->CursorOff( DC ); - GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); - DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), - color, Field->m_Text, - Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - Field->m_Size, - Field->m_HJustify, Field->m_VJustify, LineWidth); + GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE ); + DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify, LineWidth ); - DrawPanel->CursorOn(DC); + DrawPanel->CursorOn( DC ); GetScreen()->SetModify(); DrawPanel->ManageCurseur = NULL; @@ -172,177 +178,197 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth); /******************************************************************/ -void WinEDA_LibeditFrame::EditField(wxDC * DC, LibDrawField *Field) +void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field ) /******************************************************************/ { - wxString Text; - wxString title; - int color; - int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth); + wxString Text; + wxString title; + int color; + int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth ); - if( Field == NULL) return; + if( Field == NULL ) + return; - switch (Field->m_FieldId) - { - case REFERENCE: - title = wxT("Reference:"); - color = ReturnLayerColor(LAYER_REFERENCEPART); - break; + switch( Field->m_FieldId ) + { + case REFERENCE: + title = wxT( "Reference:" ); + color = ReturnLayerColor( LAYER_REFERENCEPART ); + break; - case VALUE: - title = wxT("Value:"); - color = ReturnLayerColor(LAYER_VALUEPART); - break; + case VALUE: + title = wxT( "Value:" ); + color = ReturnLayerColor( LAYER_VALUEPART ); + break; - default: - color = ReturnLayerColor(LAYER_FIELDS); - break; - } + default: + color = ReturnLayerColor( LAYER_FIELDS ); + break; + } - if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + if( Field->m_Attributs & TEXT_NO_VISIBLE ) + color = DARKGRAY; Text = Field->m_Text; - Get_Message(title, _("Edit field"), Text, this); - Text.Replace( wxT(" ") , wxT("_") ); + Get_Message( title, _( "Edit field" ), Text, this ); + Text.Replace( wxT( " " ), wxT( "_" ) ); - GRSetDrawMode(DC, g_XorMode); - DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), - color, Field->m_Text, - Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - Field->m_Size, - Field->m_HJustify, Field->m_VJustify, LineWidth); + GRSetDrawMode( DC, g_XorMode ); + DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify, LineWidth ); - if( ! Text.IsEmpty() ) + if( !Text.IsEmpty() ) { - SaveCopyInUndoList(CurrentLibEntry); + SaveCopyInUndoList( CurrentLibEntry ); Field->m_Text = Text; } - else DisplayError(this, _("No new text: no change") ); + else + DisplayError( this, _( "No new text: no change" ) ); - if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + if( Field->m_Flags == 0 ) + GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE ); - DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), - color, Field->m_Text, - Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - Field->m_Size, - Field->m_HJustify, Field->m_VJustify, LineWidth); + DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify, LineWidth ); GetScreen()->SetModify(); - if ( Field->m_FieldId == VALUE ) ReCreateHToolbar(); + if( Field->m_FieldId == VALUE ) + ReCreateHToolbar(); } + /********************************************************************/ -void WinEDA_LibeditFrame::RotateField(wxDC * DC, LibDrawField *Field) +void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field ) /********************************************************************/ + /* Routine de modification de l'orientation ( Horiz ou Vert. ) du champ. - si un champ est en cours d'edition, modif de celui ci. - sinon Modif du champ pointe par la souris -*/ + * si un champ est en cours d'edition, modif de celui ci. + * sinon Modif du champ pointe par la souris + */ { -int color; + int color; - if( Field == NULL) return; + if( Field == NULL ) + return; GetScreen()->SetModify(); - switch (Field->m_FieldId) - { - case REFERENCE: - color = ReturnLayerColor(LAYER_REFERENCEPART); - break; - case VALUE: - color = ReturnLayerColor(LAYER_VALUEPART); - break; + switch( Field->m_FieldId ) + { + case REFERENCE: + color = ReturnLayerColor( LAYER_REFERENCEPART ); + break; - default: - color = ReturnLayerColor(LAYER_FIELDS); - break; - } + case VALUE: + color = ReturnLayerColor( LAYER_VALUEPART ); + break; - if( (Field->m_Attributs & TEXT_NO_VISIBLE) != 0 ) color = DARKGRAY; + default: + color = ReturnLayerColor( LAYER_FIELDS ); + break; + } - DrawPanel->CursorOff(DC); + if( (Field->m_Attributs & TEXT_NO_VISIBLE) != 0 ) + color = DARKGRAY; - GRSetDrawMode(DC, g_XorMode); -int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth); - DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), - color, Field->m_Text, - Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - Field->m_Size, - Field->m_HJustify, Field->m_VJustify, LineWidth); + DrawPanel->CursorOff( DC ); - if( Field->m_Orient) Field->m_Orient = 0; - else Field->m_Orient = 1; + GRSetDrawMode( DC, g_XorMode ); + int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth ); + DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify, LineWidth ); - if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + if( Field->m_Orient ) + Field->m_Orient = 0; + else + Field->m_Orient = 1; - DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), - color, Field->m_Text, - Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - Field->m_Size, - Field->m_HJustify, Field->m_VJustify, LineWidth); - DrawPanel->CursorOn(DC); + if( Field->m_Flags == 0 ) + GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE ); + + DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify, LineWidth ); + DrawPanel->CursorOn( DC ); } -/****************************************************************************/ -LibDrawField * WinEDA_LibeditFrame::LocateField(EDA_LibComponentStruct *LibEntry) -/****************************************************************************/ -/* Locate the component fiels (ref, name or auxiliary fields) under the mouse cursor - return: - pointer on the field (or NULL ) -*/ -{ +/****************************************************************************/ +LibDrawField* WinEDA_LibeditFrame::LocateField( EDA_LibComponentStruct* LibEntry ) +/****************************************************************************/ + +/* Locate the component fiels (ref, name or auxiliary fields) under the mouse cursor + * return: + * pointer on the field (or NULL ) + */ +{ wxPoint refpos; + refpos.x = GetScreen()->m_Curseur.x; - refpos.y = - GetScreen()->m_Curseur.y; // Y axis is from bottom to top in library + refpos.y = -GetScreen()->m_Curseur.y; // Y axis is from bottom to top in library /* Test reference */ - if ( LibEntry->m_Name.HitTest(refpos) ) + if( LibEntry->m_Name.HitTest( refpos ) ) return &LibEntry->m_Name; /* Test Prefix */ - if( LibEntry->m_Prefix.HitTest(refpos) ) + if( LibEntry->m_Prefix.HitTest( refpos ) ) return &LibEntry->m_Prefix; /* Localisation des autres fields */ - for (LibDrawField * Field = LibEntry->Fields; Field != NULL; - Field = (LibDrawField*)Field->Pnext) - { - if ( Field->m_Text.IsEmpty() ) continue; - if (Field->HitTest(refpos) ) - return(Field); - } + for( LibDrawField* field = LibEntry->Fields; field; field = field->Next() ) + { + if( field->m_Text.IsEmpty() ) + continue; + + if( field->HitTest( refpos ) ) + return field; + } return NULL; } + /********************************************************************************/ LibEDA_BaseStruct* WinEDA_LibeditFrame::LocateItemUsingCursor() /********************************************************************************/ { LibEDA_BaseStruct* DrawEntry = CurrentDrawItem; - if ( CurrentLibEntry == NULL ) return NULL; + if( CurrentLibEntry == NULL ) + return NULL; - if ( (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) - { // Simple localisation des elements - DrawEntry = LocatePin(GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert); - if ( DrawEntry == NULL ) + if( (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) + { // Simple localisation des elements + DrawEntry = LocatePin( + GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert ); + if( DrawEntry == NULL ) { - DrawEntry = CurrentDrawItem = LocateDrawItem((SCH_SCREEN*)GetScreen(), - GetScreen()->m_MousePosition,CurrentLibEntry,CurrentUnit, - CurrentConvert,LOCATE_ALL_DRAW_ITEM); + DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) GetScreen(), + GetScreen()->m_MousePosition, CurrentLibEntry, CurrentUnit, + CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } - if ( DrawEntry == NULL ) + if( DrawEntry == NULL ) { - DrawEntry = CurrentDrawItem = LocateDrawItem((SCH_SCREEN*)GetScreen(), GetScreen()->m_Curseur, CurrentLibEntry,CurrentUnit, - CurrentConvert,LOCATE_ALL_DRAW_ITEM); + DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) GetScreen(), + GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, + CurrentConvert, LOCATE_ALL_DRAW_ITEM ); } - if ( DrawEntry == NULL ) + if( DrawEntry == NULL ) { DrawEntry = CurrentDrawItem = (LibEDA_BaseStruct*) - LocateField(CurrentLibEntry); + LocateField( CurrentLibEntry ); } } return DrawEntry; diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 55eef9f548..d09296c274 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -212,7 +212,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F if( !Failed ) { - SegmentStruct->Pnext = screen->EEDrawList; + SegmentStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = SegmentStruct; } break; @@ -251,7 +251,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F { RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; - RaccordStruct->Pnext = screen->EEDrawList; + RaccordStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = RaccordStruct; } break; @@ -294,7 +294,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F if( !Failed ) { - PolylineStruct->Pnext = screen->EEDrawList; + PolylineStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = PolylineStruct; } break; @@ -314,7 +314,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F } else { - ConnectionStruct->Pnext = screen->EEDrawList; + ConnectionStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = ConnectionStruct; } break; @@ -331,7 +331,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F { NoConnectStruct = new DrawNoConnectStruct( pos ); - NoConnectStruct->Pnext = screen->EEDrawList; + NoConnectStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = NoConnectStruct; } break; @@ -362,7 +362,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F sscanf( text + 3, "%X", &ii ); MarkerStruct->m_MarkFlags = ii; } - MarkerStruct->Pnext = screen->EEDrawList; + MarkerStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = MarkerStruct; } break; @@ -452,7 +452,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F } if( Struct ) { - Struct->Pnext = screen->EEDrawList; + Struct->SetNext( screen->EEDrawList ); screen->EEDrawList = Struct; } } @@ -480,7 +480,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F { Pnext = screen->EEDrawList; screen->EEDrawList = screen->EEDrawList->Next(); - Pnext->Pnext = Phead; + Pnext->SetNext( Phead ); Phead = Pnext; } @@ -825,9 +825,9 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, if( !Failed ) { - component->Pnext = Window->EEDrawList; - Window->EEDrawList = component; - component->m_Parent = Window; + component->SetNext( Window->EEDrawList ); + Window->EEDrawList = component; + component->SetParent( Window ); } return Failed; /* Fin lecture 1 composant */ @@ -965,7 +965,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi if( SheetStruct->m_Label == NULL ) OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; else - OldSheetLabel->Pnext = (EDA_BaseStruct*) SheetLabelStruct; + OldSheetLabel->SetNext( (EDA_BaseStruct*) SheetLabelStruct ); OldSheetLabel = SheetLabelStruct; /* Lecture des coordonnees */ @@ -1017,9 +1017,9 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi } if( !Failed ) { - SheetStruct->Pnext = Window->EEDrawList; + SheetStruct->SetNext( Window->EEDrawList ); Window->EEDrawList = SheetStruct; - SheetStruct->m_Parent = Window; + SheetStruct->SetParent( Window ); } return Failed; /* Fin lecture 1 composant */ } diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp index 15dcc2a121..7e392be1bf 100644 --- a/eeschema/locate.cpp +++ b/eeschema/locate.cpp @@ -165,12 +165,12 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask ) /* Put this structure in the picked list: */ PickedItem = new DrawPickedStruct( DrawStruct ); - PickedItem->Pnext = PickedList; + PickedItem->SetNext( PickedList ); PickedList = PickedItem; } } - if( PickedList && PickedList->Pnext == NULL ) + if( PickedList && PickedList->Next() == NULL ) { /* Only one item was picked - convert to scalar form (no list): */ PickedItem = PickedList; @@ -1192,7 +1192,7 @@ Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet, const w && (pos.x <= maxx) && (pos.x >= minx) ) return SheetLabel; - SheetLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext; + SheetLabel = SheetLabel->Next(); } return NULL; diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 7e47952298..510d6c33a3 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -289,7 +289,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( SchItem = sheet->LastDrawList(); SchItem != NULL; SchItem = SchItem->Pnext ) + for( SchItem = sheet->LastDrawList(); SchItem != NULL; SchItem = SchItem->Next() ) { SchItem = Component = FindNextComponentAndCreatPinList( SchItem, sheet ); @@ -413,7 +413,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() ) { wxChar ident; if( DrawList->Type() != TYPE_SCH_TEXT ) @@ -467,7 +467,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, ClearUsedFlags(); /* Reset the flags FlagControlMulti in all schematic files*/ for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() ) { DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet ); if( Component == NULL ) @@ -556,7 +556,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() ) { DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet ); if( Component == NULL ) @@ -771,7 +771,7 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in, for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( SchItem = sheet->LastDrawList(); SchItem; SchItem = SchItem->Pnext ) + for( SchItem = sheet->LastDrawList(); SchItem; SchItem = SchItem->Next() ) { if( SchItem->Type() != TYPE_SCH_COMPONENT ) continue; @@ -960,7 +960,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) { - for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext ) + for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() ) { DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet ); if( Component == NULL ) diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 9777387d41..3f59ffc7d7 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -489,7 +489,7 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O DrawSheetPath list; DrawList = sheetlist->LastScreen()->EEDrawList; - for( ; DrawList; DrawList = DrawList->Pnext ) + for( ; DrawList; DrawList = DrawList->Next() ) { switch( DrawList->Type() ) { @@ -678,7 +678,7 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O list.Push( STRUCT ); SheetLabel = STRUCT->m_Label; for( ; SheetLabel != NULL; - SheetLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext ) + SheetLabel = SheetLabel->Next() ) { ii = IsBusLabel( SheetLabel->m_Text ); if( ObjNet ) diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 8cf52b902a..9c2801becf 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -135,7 +135,7 @@ void WinEDA_LibeditFrame::InitEditOnePin() /* Marquage des pins a traiter,Si edition d'une pin non deja selectionnee */ Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -200,7 +200,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; // Tst for an other pin in same new position: - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -239,7 +239,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) /* Put linked pins in new position, and clear flags */ Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -276,7 +276,7 @@ void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient ) RefPin->m_Orient = neworient; Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->m_Flags == 0 ) continue; @@ -302,7 +302,7 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC ) /* Marquage des pins a traiter */ Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { Pin->m_Flags = 0; if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) @@ -381,7 +381,7 @@ void WinEDA_PinPropertiesFrame::SetPinShape( int newshape ) CurrentPin->Display_Infos_DrawEntry( m_Parent ); Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -414,7 +414,7 @@ void WinEDA_PinPropertiesFrame::SetPinType( int newtype ) m_Parent->GetScreen()->SetModify(); Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -450,7 +450,7 @@ void WinEDA_PinPropertiesFrame::SetPinName( const wxString& newname, int newsize /* Traitement des autres pins */ Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -492,7 +492,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize ) m_Parent->GetScreen()->SetModify(); Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -539,7 +539,8 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC, { if( DrawItem->Type() != COMPONENT_PIN_DRAW_TYPE ) { - DrawItem = DrawItem->Next(); continue; + DrawItem = DrawItem->Next(); + continue; } Pin = (LibDrawPin*) DrawItem; DrawItem = DrawItem->Next(); @@ -602,7 +603,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) else CurrentPin->m_Attributs &= ~PINNOTDRAW; - CurrentPin->Pnext = CurrentLibEntry->m_Drawings; + CurrentPin->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = CurrentPin; CurrentLibEntry->SortDrawItems(); @@ -725,7 +726,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw, CurrentPin->m_Attributs &= ~PINNOTDRAW; Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->m_Flags == 0 ) continue; @@ -765,7 +766,7 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize ) if( g_EditPinByPinIsOn == FALSE ) { Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -805,7 +806,7 @@ static void CreateImagePins( LibDrawPin* Pin ) NewPin->m_Convert = 1; else NewPin->m_Convert = 2; - NewPin->Pnext = CurrentLibEntry->m_Drawings; + NewPin->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = NewPin; } @@ -821,7 +822,7 @@ static void CreateImagePins( LibDrawPin* Pin ) if( CurrentConvert != 0 ) NewPin->m_Convert = 1; NewPin->m_Unit = ii; - NewPin->Pnext = CurrentLibEntry->m_Drawings; + NewPin->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = NewPin; /* Creation pour la representation "Convert" */ @@ -832,7 +833,7 @@ static void CreateImagePins( LibDrawPin* Pin ) NewPin->m_Convert = 2; if( Pin->m_Unit != 0 ) NewPin->m_Unit = ii; - NewPin->Pnext = CurrentLibEntry->m_Drawings; + NewPin->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = NewPin; } } @@ -861,7 +862,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, GetScreen()->SetModify(); Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) continue; @@ -911,7 +912,7 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin ) return; Pin = SourcePin->GenCopy(); - Pin->Pnext = CurrentLibEntry->m_Drawings; + Pin->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = Pin; Pin->m_Flags = IS_NEW; @@ -960,16 +961,17 @@ bool WinEDA_LibeditFrame::TestPins( EDA_LibComponentStruct* LibEntry ) // Test des pins ( duplicates...) { - int nb_pins, ii, error; - LibDrawPin* Pin, ** PinList; - wxString msg; + int nb_pins, ii, error; + LibDrawPin* Pin; + LibDrawPin** PinList; + wxString msg; if( CurrentLibEntry == NULL ) return FALSE; // Construction de la liste des pins: Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( nb_pins = 0; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( nb_pins = 0; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ) nb_pins++; @@ -977,7 +979,7 @@ bool WinEDA_LibeditFrame::TestPins( EDA_LibComponentStruct* LibEntry ) PinList = (LibDrawPin**) MyZMalloc( (nb_pins + 1) * sizeof(LibDrawPin*) ); Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; - for( ii = 0; Pin != NULL; Pin = (LibDrawPin*) Pin->Pnext ) + for( ii = 0; Pin != NULL; Pin = Pin->Next() ) { if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ) PinList[ii++] = Pin; @@ -993,23 +995,29 @@ bool WinEDA_LibeditFrame::TestPins( EDA_LibComponentStruct* LibEntry ) wxString aux_msg, StringPinNum; LibDrawPin* curr_pin = PinList[ii]; Pin = PinList[ii - 1]; + if( Pin->m_PinNum != curr_pin->m_PinNum ) continue; + if( Pin->m_Convert != curr_pin->m_Convert ) continue; + if( Pin->m_Unit != curr_pin->m_Unit ) continue; + error++; curr_pin->ReturnPinStringNum( StringPinNum ); msg.Printf( _( "Duplicate Pin %4.4s (Pin %s loc %d, %d, and Pin %s loc %d, %d)" ), StringPinNum.GetData(), curr_pin->m_PinName.GetData(), curr_pin->m_Pos.x, -curr_pin->m_Pos.y, Pin->m_PinName.GetData(), Pin->m_Pos.x, -Pin->m_Pos.y ); + if( CurrentLibEntry->m_UnitCount > 1 ) { aux_msg.Printf( _( " Part %d" ), curr_pin->m_Unit ); msg += aux_msg; } + if( g_AsDeMorgan ) { if( curr_pin->m_Convert ) @@ -1017,6 +1025,7 @@ bool WinEDA_LibeditFrame::TestPins( EDA_LibComponentStruct* LibEntry ) else msg += _( " Normal" ); } + DisplayError( this, msg ); } diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp index b13bacddb3..963df88747 100644 --- a/eeschema/plot.cpp +++ b/eeschema/plot.cpp @@ -434,7 +434,7 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, wxString Text; Text = field->m_Text; #if defined(KICAD_GOST) - Text.Append( '.' ); + Text.Append( '.' ); Text.Append( '1' - 1 + DrawLibItem->m_Multi ); #else Text.Append( 'A' - 1 + DrawLibItem->m_Multi ); @@ -772,20 +772,26 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) Move_Plume( Struct->m_Pos, 'U' ); pos = Struct->m_Pos; pos.x += Struct->m_Size.x; + Move_Plume( pos, 'D' ); pos.y += Struct->m_Size.y; + Move_Plume( pos, 'D' ); pos = Struct->m_Pos; pos.y += Struct->m_Size.y; + Move_Plume( pos, 'D' ); Move_Plume( Struct->m_Pos, 'D' ); + Plume( 'U' ); /* Trace des textes : SheetName */ Text = Struct->m_SheetName; size = wxSize( Struct->m_SheetNameSize, Struct->m_SheetNameSize ); pos = Struct->m_Pos; pos.y -= 4; + if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) SetColorMapPS( ReturnLayerColor( LAYER_SHEETNAME ) ); + PlotGraphicText( g_PlotFormat, pos, txtcolor, Text, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM ); @@ -793,8 +799,10 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) /* Trace des textes : FileName */ Text = Struct->GetFileName(); size = wxSize( Struct->m_FileNameSize, Struct->m_FileNameSize ); + if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) SetColorMapPS( ReturnLayerColor( LAYER_SHEETFILENAME ) ); + PlotGraphicText( g_PlotFormat, wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ), txtcolor, @@ -805,9 +813,10 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) SheetLabelStruct = Struct->m_Label; if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) ); + while( SheetLabelStruct != NULL ) { PlotSheetLabelStruct( SheetLabelStruct ); - SheetLabelStruct = (Hierarchical_PIN_Sheet_Struct*) (SheetLabelStruct->Pnext); + SheetLabelStruct = SheetLabelStruct->Next(); } } diff --git a/eeschema/plothpgl.cpp b/eeschema/plothpgl.cpp index 54aad6f840..92e4cf42e7 100644 --- a/eeschema/plothpgl.cpp +++ b/eeschema/plothpgl.cpp @@ -572,7 +572,7 @@ void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL( int Select_PlotAll, int HPGL_She InitPlotParametresHPGL( PlotOffset, g_PlotScaleX, g_PlotScaleY ); Plot_1_Page_HPGL( PlotFileName, screen ); SetLocaleTo_Default( ); - screen = (BASE_SCREEN*) screen->Pnext; + screen = screen->Next(); if( Select_PlotAll == FALSE ) break; } @@ -721,7 +721,7 @@ void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL( const wxString& FullFileName, } Plume( 'U' ); - DrawList = DrawList->Pnext; + DrawList = DrawList->Next(); } /* fin */ diff --git a/eeschema/plotps.cpp b/eeschema/plotps.cpp index d3f200d42b..180eba5e66 100644 --- a/eeschema/plotps.cpp +++ b/eeschema/plotps.cpp @@ -401,7 +401,7 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize ) PlotOneSheetPS( PlotFileName, screen, RealSheet, BBox, plot_offset ); - screen = (BASE_SCREEN*) screen->Pnext; + screen = screen->Next(); if( AllPages == FALSE ) break; diff --git a/eeschema/program.h b/eeschema/program.h index 1f8aceccd9..75697a195b 100644 --- a/eeschema/program.h +++ b/eeschema/program.h @@ -80,6 +80,9 @@ public: EDA_DrawLineStruct( const wxPoint& pos, int layer ); ~EDA_DrawLineStruct() { } + EDA_DrawLineStruct* Next() const { return (EDA_DrawLineStruct*) Pnext; } + EDA_DrawLineStruct* Back() const { return (EDA_DrawLineStruct*) Pback; } + virtual wxString GetClass() const { return wxT( "EDA_DrawLine" ); diff --git a/eeschema/savelib.cpp b/eeschema/savelib.cpp index fbb2b905ea..90bfa76897 100644 --- a/eeschema/savelib.cpp +++ b/eeschema/savelib.cpp @@ -310,10 +310,10 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr /* Copie des champs */ for( OldField = OldEntry->Fields; OldField != NULL; - OldField = (LibDrawField*) OldField->Pnext ) + OldField = (LibDrawField*) OldField->Next() ) { NewField = OldField->GenCopy(); - NewField->Pnext = NewStruct->Fields; + NewField->SetNext( NewStruct->Fields ); NewStruct->Fields = NewField; } @@ -330,10 +330,10 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr if( LastItem == NULL ) NewStruct->m_Drawings = NewDrawings; else - LastItem->Pnext = NewDrawings; + LastItem->SetNext( NewDrawings ); LastItem = NewDrawings; - NewDrawings->Pnext = NULL; + NewDrawings->SetNext( NULL ); } else // Should nevers occurs, just in case... { // CopyDrawEntryStruct() was not able to duplicate the type of OldDrawings @@ -395,7 +395,7 @@ bool EDA_LibComponentStruct::Save( FILE* aFile ) m_Name.Save( aFile ); for( Field = Fields; Field!= NULL; - Field = (LibDrawField*) Field->Pnext ) + Field = (LibDrawField*) Field->Next() ) { if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) continue; diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 139753a83d..c8433d5e46 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -217,7 +217,9 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM * ItemToCopy, break; case IS_CHANGED: /* Create a copy of schematic */ - NewList->m_Son = CopyItem = DuplicateStruct( ItemToCopy ); + CopyItem = DuplicateStruct( ItemToCopy ); + NewList->SetSon( CopyItem ); + if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) { DrawPickedStruct* PickedList = (DrawPickedStruct*) CopyItem; @@ -239,7 +241,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM * ItemToCopy, case IS_NEW: if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) { - NewList->m_Son = ItemToCopy; + NewList->SetSon( ItemToCopy ); DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy; while( PickedList ) { @@ -258,11 +260,11 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM * ItemToCopy, case IS_NEW | IS_CHANGED: case IS_WIRE_IMAGE: - NewList->m_Son = ItemToCopy; + NewList->SetSon( ItemToCopy ); break; case IS_DELETED: - NewList->m_Son = ItemToCopy; + NewList->SetSon( ItemToCopy ); ItemToCopy->m_Flags = flag_type_command; if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) { @@ -327,7 +329,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) * Put data pointed by List in the previous state, i.e. the state memorised by List */ { - SCH_ITEM* FirstItem = (SCH_ITEM*) List->m_Son; + SCH_ITEM* FirstItem = (SCH_ITEM*) List->GetSon(); SCH_ITEM* item; DrawPickedStruct* PickedList; @@ -374,7 +376,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) FirstItem = (SCH_ITEM*)List->m_Image; ( (SCH_SCREEN*) GetScreen() )->RemoveFromDrawList( FirstItem ); FirstItem->m_Flags = IS_DELETED; - List->m_Son = FirstItem; + List->SetSon( FirstItem ); } break; @@ -386,7 +388,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) while( PickedList ) { item = PickedList->m_PickedStruct; - item->Pnext = GetScreen()->EEDrawList; + item->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = item; item->m_Flags = 0; PickedList->m_PickedStruct = NULL; @@ -397,21 +399,21 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) } else { - FirstItem->Pnext = GetScreen()->EEDrawList; + FirstItem->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = FirstItem; FirstItem->m_Flags = 0; - List->m_Image = List->m_Son; - List->m_Son = NULL; + List->m_Image = List->GetSon(); + List->SetSon( NULL ); } break; case IS_WIRE_IMAGE: /* Exchange the current wires and the oild wires */ - List->m_Son = ( (SCH_SCREEN*) GetScreen() )->ExtractWires( FALSE ); + List->SetSon( ( (SCH_SCREEN*) GetScreen() )->ExtractWires( FALSE ) ); while( FirstItem ) { SCH_ITEM* nextitem = FirstItem->Next(); - FirstItem->Pnext = GetScreen()->EEDrawList; + FirstItem->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = FirstItem; FirstItem->m_Flags = 0; FirstItem = nextitem; @@ -445,7 +447,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) case IS_DELETED: item = PickedList->m_PickedStruct; - item->Pnext = GetScreen()->EEDrawList; + item->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = item; item->m_Flags = 0; PickedList->m_PickedStruct = NULL; @@ -513,8 +515,8 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List ) for( ; List != NULL; List = nextitem ) { - nextitem = List->Pnext; - FirstItem = List->m_Son; + nextitem = List->Next(); + FirstItem = List->GetSon(); CmdType = List->m_Flags; SAFE_DELETE( List ); @@ -571,7 +573,7 @@ void SCH_SCREEN::ClearUndoORRedoList( EDA_BaseStruct* List ) { while( FirstItem ) { - EDA_BaseStruct* nextitem = FirstItem->Pnext; + EDA_BaseStruct* nextitem = FirstItem->Next(); delete FirstItem; FirstItem = nextitem; } @@ -638,24 +640,25 @@ void SCH_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem ) return; if( m_UndoList ) - m_UndoList->Pback = newitem; - newitem->Pnext = m_UndoList; - newitem->Pback = NULL; + m_UndoList->SetBack( newitem ); + + newitem->SetNext( m_UndoList ); + newitem->SetBack( NULL ); m_UndoList = newitem; /* Free oldest items, if count max reached */ for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) { - if( item->Pnext == NULL ) + if( item->Next() == NULL ) return; - item = item->Pnext; + item = item->Next(); } if( item == NULL ) return; - nextitem = item->Pnext; - item->Pnext = NULL; // Set end of chain + nextitem = item->Next(); + item->SetNext( NULL ); // Set end of chain // Delete the extra items ClearUndoORRedoList( nextitem ); @@ -672,22 +675,23 @@ void SCH_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem ) if( newitem == NULL ) return; - newitem->Pback = NULL; - newitem->Pnext = m_RedoList; + newitem->SetBack( NULL ); + newitem->SetNext( m_RedoList ); m_RedoList = newitem; + /* Free first items, if count max reached */ for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) { - if( item->Pnext == NULL ) + if( item->Next() == NULL ) break; - item = item->Pnext; + item = item->Next(); } if( item == NULL ) return; - nextitem = item->Pnext; - item->Pnext = NULL; // Set end of chain + nextitem = item->Next(); + item->SetNext( NULL ); // Set end of chain // Delete the extra items ClearUndoORRedoList( nextitem ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index da0d5fd992..c22a5e5e1c 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -140,6 +140,10 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, m_Draw_Grid = g_ShowGrid; // TRUE to show a grid m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references m_CurrentSheet = new DrawSheetPath(); + m_CurrentField = NULL; + m_Multiflag = 0; + m_TextFieldSize = DEFAULT_SIZE_TEXT; + CreateScreens(); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index b2b6cfa83f..357fe2ac7c 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -348,7 +348,7 @@ DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC ) Sheet->m_Flags = IS_NEW | IS_RESIZED; Sheet->m_TimeStamp = GetTimeStamp(); - Sheet->m_Parent = GetScreen(); + Sheet->SetParent( GetScreen() ); Sheet->m_AssociatedScreen = NULL; s_SheetMindx = SHEET_MIN_WIDTH; s_SheetMindy = SHEET_MIN_HEIGHT; @@ -401,7 +401,7 @@ void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC ) (int) ( (sheetlabel->GetLength() + 1) * sheetlabel->m_Size.x ) ); s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y ); - sheetlabel = (Hierarchical_PIN_Sheet_Struct*) sheetlabel->Pnext; + sheetlabel = sheetlabel->Next(); } DrawPanel->ManageCurseur = DeplaceSheet; @@ -457,7 +457,7 @@ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { if( SheetLabel->m_Edge ) SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; - SheetLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext; + SheetLabel = SheetLabel->Next(); } } else /* Move Sheet */ diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 3a983dd9b5..3ebdcd3e74 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -171,7 +171,7 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) */ void Hierarchical_PIN_Sheet_Struct::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) { - DrawSheetStruct* Sheet = (DrawSheetStruct*) m_Parent; + DrawSheetStruct* Sheet = (DrawSheetStruct*) GetParent(); if( m_Flags & IS_NEW ) /* ajout a la liste des structures */ { @@ -182,12 +182,12 @@ void Hierarchical_PIN_Sheet_Struct::Place( WinEDA_SchematicFrame* frame, wxDC* D Hierarchical_PIN_Sheet_Struct* pinsheet = Sheet->m_Label; while( pinsheet ) { - if( pinsheet->Pnext == NULL ) + if( pinsheet->Next() == NULL ) { - pinsheet->Pnext = this; + pinsheet->SetNext( this ); break; } - pinsheet = (Hierarchical_PIN_Sheet_Struct*) pinsheet->Pnext; + pinsheet = pinsheet->Next(); } } } @@ -242,7 +242,7 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) if( SheetLabel == NULL ) return; - DrawSheetStruct* Sheet = (DrawSheetStruct*) SheetLabel->m_Parent; + DrawSheetStruct* Sheet = (DrawSheetStruct*) SheetLabel->GetParent(); if( Sheet == NULL ) return; @@ -362,7 +362,7 @@ Hierarchical_PIN_Sheet_Struct* WinEDA_SchematicFrame::Import_PinSheet( DrawSheet if(!Sheet->m_AssociatedScreen) return NULL; DrawStruct = Sheet->m_AssociatedScreen->EEDrawList; HLabel = NULL; - for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) { if( DrawStruct->Type() != TYPE_SCH_HIERLABEL ) continue; @@ -370,7 +370,7 @@ Hierarchical_PIN_Sheet_Struct* WinEDA_SchematicFrame::Import_PinSheet( DrawSheet /* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */ SheetLabel = Sheet->m_Label; - for( ; SheetLabel != NULL; SheetLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext ) + for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() ) { if( SheetLabel->m_Text.CmpNoCase( HLabel->m_Text ) == 0 ) { @@ -419,7 +419,7 @@ void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw, * si aRedraw == true, effacement a l'ecran du dessin */ { - DrawSheetStruct* parent = (DrawSheetStruct*) aSheetLabelToDel->m_Parent; + DrawSheetStruct* parent = (DrawSheetStruct*) aSheetLabelToDel->GetParent(); wxASSERT( parent ); wxASSERT( parent->Type() == DRAW_SHEET_STRUCT_TYPE ); @@ -438,7 +438,7 @@ void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw, if( label == aSheetLabelToDel ) { if( prev ) - prev->Pnext = label->Next(); + prev->SetNext( label->Next() ); else parent->m_Label = label->Next(); diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 6a9cb86b25..5e0cf1fb5b 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -664,7 +664,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) if( CurrentDrawItem->m_Flags & IS_NEW ) { SaveCopyInUndoList( CurrentLibEntry ); - CurrentDrawItem->Pnext = CurrentLibEntry->m_Drawings; + CurrentDrawItem->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = CurrentDrawItem; switch( CurrentDrawItem->Type() ) diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 74ecf96fe6..058b4194cd 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -103,9 +103,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( wxDC* DC ) DrawEntry->m_Flags = IS_NEW; DrawEntry->m_Selected = IS_SELECTED; - if( DrawEntry->Pnext == NULL ) + if( DrawEntry->Next() == NULL ) { /* Fin de liste trouvee */ - DrawEntry->Pnext = CurrentLibEntry->m_Drawings; + DrawEntry->SetNext( CurrentLibEntry->m_Drawings ); CurrentLibEntry->m_Drawings = LibEntry->m_Drawings; LibEntry->m_Drawings = NULL; break; @@ -235,7 +235,7 @@ void SuppressDuplicateDrawItem( EDA_LibComponentStruct* LibEntry ) DEntryRef = LibEntry->m_Drawings; while( DEntryRef ) { - if( DEntryRef->Pnext == NULL ) + if( DEntryRef->Next() == NULL ) return; DEntryCompare = DEntryRef->Next(); if( DEntryCompare == NULL ) diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp index 432c9691b6..edad130d86 100644 --- a/gerbview/deltrack.cpp +++ b/gerbview/deltrack.cpp @@ -59,21 +59,21 @@ TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track ) { // modification du trace Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; - - delete Track; - + g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); + + delete Track; + g_TrackSegmentCount--; if( g_TrackSegmentCount && (g_CurrentTrackSegment->Type() == TYPEVIA) ) { Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); delete Track; g_TrackSegmentCount--; } if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->Pnext = NULL; + g_CurrentTrackSegment->SetNext( NULL ); Affiche_Status_Box(); @@ -90,7 +90,7 @@ TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track ) return g_CurrentTrackSegment; } } - + return NULL; } // Fin traitement si trace en cours diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index ce3a9d35da..86f0d4028a 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -161,7 +161,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, drawitem->m_Start = track->m_Start; drawitem->m_End = track->m_End; drawitem->m_Width = track->m_Width; - drawitem->Pnext = pcb->m_Drawings; + drawitem->SetNext( pcb->m_Drawings ); pcb->m_Drawings = drawitem; } else diff --git a/gerbview/lay2plot.cpp b/gerbview/lay2plot.cpp index c1829b33d2..2c19f51978 100644 --- a/gerbview/lay2plot.cpp +++ b/gerbview/lay2plot.cpp @@ -1,6 +1,6 @@ - /**********************************************/ - /* Routine de selection de couches pour trace */ - /**********************************************/ + /**********************************************/ + /* Routine de selection de couches pour trace */ + /**********************************************/ #include "fctsys.h" @@ -19,28 +19,28 @@ void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer) /*******************************************************************************/ /* routine de trace du pcb, avec selection des couches */ { -DISPLAY_OPTIONS save_opt; -TRACK * pt_piste; + DISPLAY_OPTIONS save_opt; + TRACK * pt_piste; - save_opt = DisplayOpt; - DisplayOpt.DisplayPadFill = FILLED; - DisplayOpt.DisplayPadNum = 0; - DisplayOpt.DisplayPadNoConn = 0; - DisplayOpt.DisplayPadIsol = 0; - DisplayOpt.DisplayPcbTrackFill = FILLED; - DisplayOpt.DisplayTrackIsol = 0; - DisplayOpt.DisplayDrawItems = FILLED; - DisplayOpt.DisplayZones = 1; + save_opt = DisplayOpt; + DisplayOpt.DisplayPadFill = FILLED; + DisplayOpt.DisplayPadNum = 0; + DisplayOpt.DisplayPadNoConn = 0; + DisplayOpt.DisplayPadIsol = 0; + DisplayOpt.DisplayPcbTrackFill = FILLED; + DisplayOpt.DisplayTrackIsol = 0; + DisplayOpt.DisplayDrawItems = FILLED; + DisplayOpt.DisplayZones = 1; - /* trace des pistes */ - pt_piste = Pcb->m_Track; - for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) - { + /* trace des pistes */ + pt_piste = Pcb->m_Track; + for( ; pt_piste != NULL ; pt_piste = pt_piste->Next() ) + { // if( (printmasklayer & ReturnMaskLayer(pt_piste) ) == 0 ) continue; - Trace_Segment(NULL, DC, pt_piste, drawmode); - } + Trace_Segment(NULL, DC, pt_piste, drawmode); + } - DisplayOpt = save_opt; + DisplayOpt = save_opt; } diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 488f4adbb7..97541530f0 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -59,7 +59,7 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) Track = TrackLocate; if( TrackLocate->Type() == TYPEVIA ) break; - TrackLocate = (TRACK*) TrackLocate->Pnext; + TrackLocate = TrackLocate->Next(); } Track->Display_Infos( this ); @@ -185,7 +185,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer ) TRACK* Track; /* pointeur sur les pistes */ int l_piste; /* demi-largeur de la piste */ - for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( Track = start_adresse; Track != NULL; Track = Track->Next() ) { if( Track->GetState( BUSY | DELETED ) ) continue; @@ -249,7 +249,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ) TRACK* Zone; /* pointeur sur les pistes */ int l_segm; /* demi-largeur de la piste */ - for( Zone = start_adresse; Zone != NULL; Zone = (TRACK*) Zone->Pnext ) + for( Zone = start_adresse; Zone != NULL; Zone = Zone->Next() ) { /* calcul des coordonnees du segment teste */ l_segm = Zone->m_Width >> 1; /* l_piste = demi largeur piste */ @@ -287,7 +287,7 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) SET_REF_POS( ref ); PtStruct = (EDA_BaseStruct*) pt_txt_pcb; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() != TYPETEXTE ) continue; diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 642aa19673..34b1287bba 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -817,8 +817,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, last = (SEGZONE*) frame->m_Pcb->m_Zone; if( last ) - while( last->Pnext ) - last = (SEGZONE*) last->Pnext; + while( last->Next() ) + last = (SEGZONE*) last->Next(); edge_poly->Insert( frame->m_Pcb, last ); diff --git a/gerbview/trpiste.cpp b/gerbview/trpiste.cpp index 1ff7f05ab5..72104f1096 100644 --- a/gerbview/trpiste.cpp +++ b/gerbview/trpiste.cpp @@ -38,7 +38,7 @@ void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_ dcode_hightlight = gerber->m_Selected_Tool; Track = Pcb->m_Track; - for( ; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( ; Track != NULL; Track = Track->Next() ) { if( printmasklayer != -1 ) if( (Track->ReturnMaskLayer() & printmasklayer) == 0 ) @@ -226,7 +226,7 @@ void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int d GRSetDrawMode( DC, drawmode ); track = Pcb->m_Track; - for( ; track != NULL; track = (TRACK*) track->Pnext ) + for( ; track != NULL; track = track->Next() ) { if( (track->m_Shape == S_ARC) || (track->m_Shape == S_CIRCLE) diff --git a/gerbview/undelete.cpp b/gerbview/undelete.cpp index 08283dd957..05716dcfca 100644 --- a/gerbview/undelete.cpp +++ b/gerbview/undelete.cpp @@ -101,8 +101,11 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) PtStruct->SetState( DELETED, ON ); if( nbitems <= 1 ) NextS = NULL; /* fin de chaine */ - PtStruct->Pnext = NextS; - PtStruct->Pback = Back; Back = PtStruct; + + PtStruct->SetNext( NextS ); + PtStruct->SetBack( Back ); + Back = PtStruct; + if( NextS == NULL ) break; } diff --git a/include/base_struct.h b/include/base_struct.h index f62a82b8a9..c7ff88705d 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -92,6 +92,7 @@ class WinEDA_DrawFrame; class BOARD; class EDA_Rect; + /** * Class INSPECTOR * is an abstract class that is used to inspect and possibly collect the @@ -209,9 +210,11 @@ public: /* Basic Classes : used classes are derived from them */ /******************************************************/ -/** class EDA_BaseStruct - * Basic class, not directly used. - * All the kicad classes used to describe a shematic or a board item are derived from. +class DHEAD; + +/** + * Class EDA_BaseStruct + * is a base class for most all the kicad significant classes, used in schematics and boards. */ class EDA_BaseStruct { @@ -223,13 +226,15 @@ private: */ KICAD_T m_StructType; -public: +protected: EDA_BaseStruct* Pnext; /* Linked list: Link (next struct) */ EDA_BaseStruct* Pback; /* Linked list: Link (previous struct) */ EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */ - EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */ + DHEAD* m_List; ///< which DLIST I am on. + +public: int m_Flags; // flags for editing and other misc. uses #define IS_CHANGED (1 << 0) #define IS_LINKED (1 << 1) @@ -248,6 +253,10 @@ public: #define CANDIDATE (1 << 14) ///< flag indiquant que la structure est connectee #define SKIP_STRUCT (1 << 15) ///< flag indiquant que la structure ne doit pas etre traitee #define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function +#define DRAW_ERASED (1 << 17) ///< draw in background color, used by classs TRACK in gerbview + + + EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */ unsigned long m_TimeStamp; // Time stamp used for logical links int m_Selected; /* Used by block commands, and selective editing */ @@ -274,10 +283,17 @@ public: KICAD_T Type() const { return m_StructType; } - 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; } + EDA_BaseStruct* Next() const { return (EDA_BaseStruct*) Pnext; } + EDA_BaseStruct* Back() const { return (EDA_BaseStruct*) Pback; } + EDA_BaseStruct* GetParent() const { return m_Parent; } + EDA_BaseStruct* GetSon() const { return m_Son; } + DHEAD* GetList() const { return m_List; } + void SetNext( EDA_BaseStruct* aNext ) { Pnext = aNext; } + void SetBack( EDA_BaseStruct* aBack ) { Pback = aBack; } + void SetParent( EDA_BaseStruct* aParent ) { m_Parent = aParent; } + void SetSon( EDA_BaseStruct* aSon ) { m_Son = aSon; } + void SetList( DHEAD* aList ) { m_List = aList; } /* Gestion de l'etat (status) de la structure (active, deleted..) */ diff --git a/include/board_item_struct.h b/include/board_item_struct.h index d3d3d26cb3..0f2f8bee84 100644 --- a/include/board_item_struct.h +++ b/include/board_item_struct.h @@ -18,8 +18,8 @@ * Class BOARD_CONNECTED_ITEM * This is a base class derived from BOARD_ITEM for items that can be connected * mainly: tracks and pads - * Handle connection info - * + * Handle connection info + * */ @@ -183,14 +183,18 @@ public: }; -class BOARD_CONNECTED_ITEM: public BOARD_ITEM +class BOARD_CONNECTED_ITEM : public BOARD_ITEM { protected: int m_NetCode; // Net number + int m_Subnet; /* In rastnest routines : for the current net, - * block number (number common to the current connected items found) */ - int m_ZoneSubnet; // variable used in rastnest computations : for the current net, + * block number (number common to the current connected items found) + */ + + int m_ZoneSubnet; // variable used in rastnest computations : for the current net, // handle block number in zone connection + public: BOARD_CONNECTED_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ); BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src ); diff --git a/include/dlist.h b/include/dlist.h index 59b1af167f..d68d19e34f 100644 --- a/include/dlist.h +++ b/include/dlist.h @@ -40,7 +40,7 @@ protected: EDA_BaseStruct* first; ///< first element in list, or NULL if list empty EDA_BaseStruct* last; ///< last elment in list, or NULL if empty unsigned count; ///< how many elements are in the list - bool meOwner; ///< I must delete the objects in my destructor + bool meOwner; ///< I must delete the objects I hold in my destructor /** * Constructor DHEAD @@ -113,6 +113,7 @@ public: * is the head of a doubly linked list. It contains pointers to the first * and last elements in a doubly linked list. The elements in the list must * be of class T or derived from T, and T must be derived from EDA_BaseStruct. + * @see DHEAD for additional public functions. */ template class DLIST : public DHEAD diff --git a/include/drawpanel_wxstruct.h b/include/drawpanel_wxstruct.h index aecab6b365..c3a802eade 100644 --- a/include/drawpanel_wxstruct.h +++ b/include/drawpanel_wxstruct.h @@ -269,6 +269,10 @@ public: BASE_SCREEN( int idscreen, KICAD_T aType = SCREEN_STRUCT_TYPE ); ~BASE_SCREEN(); + BASE_SCREEN* Next() const { return (BASE_SCREEN*) Pnext; } + BASE_SCREEN* Back() const { return (BASE_SCREEN*) Pback; } + + /** * Function setCurItem * sets the currently selected object, m_CurrentItem. diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 725d062953..237901a442 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -49,10 +49,18 @@ class WinEDA_SchematicFrame : public WinEDA_DrawFrame { public: WinEDAChoiceBox* m_SelPartBox; - DrawSheetPath* m_CurrentSheet; //which sheet we are presently working on. + DrawSheetPath* m_CurrentSheet; ///< which sheet we are presently working on. + int m_Multiflag; + wxPoint m_OldPos; + + private: wxMenu* m_FilesMenu; + SCH_CMP_FIELD* m_CurrentField; + int m_TextFieldSize; + + public: WinEDA_SchematicFrame( wxWindow* father, WinEDA_App* parent, const wxString& title, @@ -81,6 +89,13 @@ public: int hotkey, EDA_BaseStruct* DrawStruct ); + SCH_CMP_FIELD* GetCurrentField() { return m_CurrentField; } + + void SetCurrentField( SCH_CMP_FIELD* aCurrentField ) + { + m_CurrentField = aCurrentField; + } + DrawSheetPath* GetSheet(); SCH_SCREEN* GetScreen() const; @@ -105,8 +120,9 @@ public: bool IncludePin ); - /** function FillFootprintFieldForAllInstancesofComponent - * Search for component "aReference", and place a Footprint in Footprint field + /** + * Function FillFootprintFieldForAllInstancesofComponent + * searches for component "aReference", and places a Footprint in Footprint field * @param aReference = reference of the component to initialise * @param aFootPrint = new value for the filed Fottprint component * @param aSetVisible = true to have the field visible, false to set the invisible flag @@ -119,6 +135,7 @@ public: bool FillFootprintFieldForAllInstancesofComponent( const wxString& aReference, const wxString& aFootPrint, bool aSetVisible ); + SCH_ITEM* FindComponentAndItem( const wxString& component_reference, bool Find_in_hierarchy, int SearchType, @@ -131,7 +148,9 @@ public: /* netlist generation */ void* BuildNetListBase(); - /** Function DeleteAnnotation + + /** + * Function DeleteAnnotation * Remove current component annotations * @param aCurrentSheetOnly : if false: remove all annotations, else remove annotation relative to the current sheet only * @param aRedraw : true to refresh display @@ -142,7 +161,8 @@ public: void InstallPreviousSheet(); void InstallNextScreen( DrawSheetStruct* Sheet ); - /** Function SetSheetNumberAndCount + /** + * Function SetSheetNumberAndCount * Set the m_ScreenNumber and m_NumberOfScreen members for screens * must be called after a delete or add sheet command, and when entering a sheet */ diff --git a/pcbnew/affiche.cpp b/pcbnew/affiche.cpp index 70d865c853..a727054fe7 100644 --- a/pcbnew/affiche.cpp +++ b/pcbnew/affiche.cpp @@ -40,9 +40,9 @@ void Affiche_Infos_Equipot( int netcode, WinEDA_BasePcbFrame* frame ) Affiche_1_Parametre( frame, 30, _( "Net Code" ), txt, RED ); for( ii = 0, module = frame->m_Pcb->m_Modules; module != 0; - module = (MODULE*) module->Pnext ) + module = module->Next() ) { - for( pad = module->m_Pads; pad != 0; pad = (D_PAD*) pad->Pnext ) + for( pad = module->m_Pads; pad != 0; pad = pad->Next() ) { if( pad->GetNet() == netcode ) ii++; @@ -52,15 +52,15 @@ void Affiche_Infos_Equipot( int netcode, WinEDA_BasePcbFrame* frame ) txt.Printf( wxT( "%d" ), ii ); Affiche_1_Parametre( frame, 40, _( "Pads" ), txt, DARKGREEN ); - for( ii = 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext ) + for( ii = 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Next() ) { ii++; if( Struct->Type() == TYPEVIA ) if( ( (SEGVIA*) Struct )->GetNet() == netcode ) nb_vias++; - if( Struct->Type() == TYPETRACK ) + if( Struct->Type() == TYPETRACK ) if( ( (TRACK*) Struct )->GetNet() == netcode ) - lengthnet += ( (TRACK*) Struct )->GetLength(); + lengthnet += ( (TRACK*) Struct )->GetLength(); } txt.Printf( wxT( "%d" ), nb_vias ); diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index f3ed8d7824..726a10a046 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -51,7 +51,7 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) { Track->SetState( SEGM_FIXE, Flag_On ); Track->SetState( BUSY, OFF ); - Track = (TRACK*) Track->Pnext; + Track = Track->Next(); } DrawPanel->CursorOn( DC ); // Display cursor shape @@ -74,7 +74,7 @@ void WinEDA_PcbFrame::Attribut_net( wxDC* DC, int net_code, bool Flag_On ) /* search the first segment for the selected net_code */ if( net_code >= 0 ) { - for( ; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( ; Track != NULL; Track = Track->Next() ) { if( net_code == Track->GetNet() ) break; diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index 32b7008f65..6c4705baaf 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -223,7 +223,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( wxDC* DC, bool PlaceModulesHorsPcb ) } Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) // remise a jour du rect d'encadrement + for( ; Module != NULL; Module = Module->Next() ) // remise a jour du rect d'encadrement { Module->Set_Rectangle_Encadrement(); Module->SetRectangleExinscrit(); @@ -315,7 +315,7 @@ void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe ) else { Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { if( WildCompareString( ModulesMaskSelection, Module->m_Reference->m_Text ) ) { @@ -346,7 +346,7 @@ MODULE** GenListeModules( BOARD* Pcb, int* NbModules ) * peut deplacer */ Module = Pcb->m_Modules; NbMod = 0; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) NbMod++; ListeMod = (MODULE**) MyZMalloc( (NbMod + 1) * sizeof(MODULE *) ); @@ -359,7 +359,7 @@ MODULE** GenListeModules( BOARD* Pcb, int* NbModules ) PtList = ListeMod; Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { *PtList = Module; PtList++; Module->SetRectangleExinscrit(); diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 7eb82f2fa8..b5e90ca76b 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -127,7 +127,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC /* Compute module parmeters used in auto place */ Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) // remise a jour du rect d'encadrement + for( ; Module != NULL; Module = Module->Next() ) // remise a jour du rect d'encadrement { Module->Set_Rectangle_Encadrement(); Module->SetRectangleExinscrit(); @@ -143,7 +143,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC /* Placement des modules fixes sur le plan de placement */ Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { Module->m_ModuleStatus &= ~MODULE_to_PLACE; @@ -306,7 +306,7 @@ end_of_tst: g_GridRoutingSize = OldPasRoute; Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { Module->Set_Rectangle_Encadrement(); } @@ -452,7 +452,7 @@ int WinEDA_PcbFrame::GenPlaceBoard() TmpSegm.SetLayer( -1 ); TmpSegm.SetNet( -1 ); TmpSegm.m_Width = g_GridRoutingSize / 2; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { DRAWSEGMENT* DrawSegm; @@ -548,7 +548,7 @@ void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module ) /* Trace des pads et leur surface de securite */ marge = g_DesignSettings.m_TrackClearence + g_DesignSettings.m_CurrentTrackWidth; - for( Pad = Module->m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext ) + for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() ) { Place_1_Pad_Board( m_Pcb, Pad, CELL_is_MODULE, marge, WRITE_OR_CELL ); } @@ -619,7 +619,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC ) if( Module->GetLayer() == COPPER_LAYER_N ) masque_otherlayer = CMP_LAYER; - for( Pad = Module->m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext ) + for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() ) { if( (Pad->m_Masque_Layer & masque_otherlayer) == 0 ) continue; @@ -949,12 +949,12 @@ void Build_PlacedPads_List( BOARD* Pcb ) /* Calcul du nombre de pads utiles */ Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + for( ; PtPad != NULL; PtPad = PtPad->Next() ) { Pcb->m_NbPads++; } @@ -969,17 +969,17 @@ void Build_PlacedPads_List( BOARD* Pcb ) /* Initialisation du buffer et des variables de travail */ Module = Pcb->m_Modules; - for( ; (Module != NULL) && (pt_liste_pad != NULL); Module = (MODULE*) Module->Pnext ) + for( ; (Module != NULL) && (pt_liste_pad != NULL); Module = Module->Next() ) { if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + for( ; PtPad != NULL; PtPad = PtPad->Next() ) { *pt_liste_pad = PtPad; PtPad->SetSubNet( 0 ); PtPad->SetSubRatsnest( 0 ); - PtPad->m_Parent = Module; + PtPad->SetParent( Module ); if( PtPad->GetNet() ) Pcb->m_NbNodes++; pt_liste_pad++; diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 8411b33ffa..8817fac7b3 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -100,7 +100,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) case ROUTE_MODULE: { D_PAD* pt_pad = (D_PAD*) Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { if( ptmp->pad_start == pt_pad ) ptmp->status |= CH_ROUTE_REQ; @@ -216,7 +216,7 @@ void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC ) { color = 0; dcell0 = GetCell( row, col, BOTTOM ); - if( dcell0 & HOLE ) + if( dcell0 & HOLE ) color = GREEN; // if( Nb_Sides ) // dcell1 = GetCell( row, col, TOP ); @@ -225,20 +225,20 @@ void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC ) // dcell0 |= dcell1; if( !color && (dcell0 & VIA_IMPOSSIBLE) ) color = BLUE; - if( dcell0 & CELL_is_EDGE ) + if( dcell0 & CELL_is_EDGE ) color = YELLOW; - else if( dcell0 & CELL_is_ZONE ) + else if( dcell0 & CELL_is_ZONE ) color = YELLOW; - - #define DRAW_OFFSET_X -20 - #define DRAW_OFFSET_Y 20 + + #define DRAW_OFFSET_X -20 + #define DRAW_OFFSET_Y 20 // if( color ) { for( i = 0; i < maxi; i++ ) for( j = 0; j < maxi; j++ ) GRSPutPixel( &panel->m_ClipBox, DC, (col * maxi) + i + DRAW_OFFSET_X, - (row * maxi) + j + DRAW_OFFSET_Y, color ); + (row * maxi) + j + DRAW_OFFSET_Y, color ); } } diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 4b751b88e2..de5a1d4f82 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -615,7 +615,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; int Angle_Rot_Module = 900; module = m_Pcb->m_Modules; - for( ; module != NULL; module = (MODULE*) module->Pnext ) + for( ; module != NULL; module = module->Next() ) { if( ! module->HitTest( GetScreen()->BlockLocate ) ) continue; @@ -684,7 +684,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) /* Move and rotate the graphic items */ PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -780,7 +780,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) { bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; module = m_Pcb->m_Modules; - for( ; module != NULL; module = (MODULE*) module->Pnext ) + for( ; module != NULL; module = module->Next() ) { if( ! module->HitTest( GetScreen()->BlockLocate ) ) continue; @@ -823,7 +823,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); } } - track = (TRACK*) track->Pnext; + track = track->Next(); } } @@ -841,7 +841,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) INVERT( track->m_End.y ); track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); } - track = (TRACK*) track->Pnext; + track = track->Next(); } for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) { @@ -860,7 +860,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) masque_layer &= ~EDGE_LAYER; PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -967,7 +967,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) module = m_Pcb->m_Modules; oldpos = GetScreen()->m_Curseur; - for( ; module != NULL; module = (MODULE*) module->Pnext ) + for( ; module != NULL; module = module->Next() ) { if( ! module->HitTest( GetScreen()->BlockLocate ) ) continue; @@ -995,7 +995,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) track->m_Start += MoveVector; track->m_End += MoveVector; } - track = (TRACK*) track->Pnext; + track = track->Next(); } } @@ -1011,7 +1011,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) track->m_Start += MoveVector; track->m_End += MoveVector; } - track = (TRACK*) track->Pnext; + track = track->Next(); } for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) { @@ -1029,7 +1029,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) masque_layer &= ~EDGE_LAYER; PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -1123,7 +1123,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) module = m_Pcb->m_Modules; oldpos = GetScreen()->m_Curseur; - for( ; module != NULL; module = (MODULE*) module->Pnext ) + for( ; module != NULL; module = module->Next() ) { MODULE* new_module; if( ! module->HitTest( GetScreen()->BlockLocate ) ) @@ -1134,9 +1134,9 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) new_module = new MODULE( m_Pcb ); new_module->Copy( module ); new_module->m_TimeStamp = GetTimeStamp(); - new_module->Pnext = m_Pcb->m_Modules; - new_module->Pback = m_Pcb; - m_Pcb->m_Modules->Pback = new_module; + new_module->SetNext( m_Pcb->m_Modules ); + new_module->SetBack( m_Pcb ); + m_Pcb->m_Modules->SetBack( new_module ); m_Pcb->m_Modules = new_module; GetScreen()->m_Curseur = module->m_Pos + MoveVector; Place_Module( new_module, DC ); @@ -1208,7 +1208,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) masque_layer &= ~EDGE_LAYER; PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -1225,9 +1225,9 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb ); new_drawsegment->Copy( STRUCT ); - new_drawsegment->Pnext = m_Pcb->m_Drawings; - new_drawsegment->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_drawsegment; + new_drawsegment->SetNext( m_Pcb->m_Drawings ); + new_drawsegment->SetBack( m_Pcb ); + m_Pcb->m_Drawings->SetBack( new_drawsegment ); m_Pcb->m_Drawings = new_drawsegment; new_drawsegment->m_Start += MoveVector; new_drawsegment->m_End += MoveVector; @@ -1246,9 +1246,9 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /* le texte est ici bon a etre deplace */ TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb ); new_pcbtext->Copy( STRUCT ); - new_pcbtext->Pnext = m_Pcb->m_Drawings; - new_pcbtext->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_pcbtext; + new_pcbtext->SetNext( m_Pcb->m_Drawings ); + new_pcbtext->SetBack( m_Pcb ); + m_Pcb->m_Drawings->SetBack( new_pcbtext ); m_Pcb->m_Drawings = new_pcbtext; /* Redessin du Texte */ new_pcbtext->m_Pos += MoveVector; @@ -1267,9 +1267,9 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /* l'element est ici bon a etre efface */ MIREPCB* new_mire = new MIREPCB( m_Pcb ); new_mire->Copy( STRUCT ); - new_mire->Pnext = m_Pcb->m_Drawings; - new_mire->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_mire; + new_mire->SetNext( m_Pcb->m_Drawings ); + new_mire->SetBack( m_Pcb ); + m_Pcb->m_Drawings->SetBack( new_mire ); m_Pcb->m_Drawings = new_mire; new_mire->m_Pos += MoveVector; new_mire->Draw( DrawPanel, DC, GR_OR ); @@ -1287,9 +1287,9 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /* l'element est ici bon a etre copie */ COTATION* new_cotation = new COTATION( m_Pcb ); new_cotation->Copy( STRUCT ); - new_cotation->Pnext = m_Pcb->m_Drawings; - new_cotation->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_cotation; + new_cotation->SetNext( m_Pcb->m_Drawings ); + new_cotation->SetBack( m_Pcb ); + m_Pcb->m_Drawings->SetBack( new_cotation ); m_Pcb->m_Drawings = new_cotation; new_cotation->Move( MoveVector ); new_cotation->Draw( DrawPanel, DC, GR_OR ); diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 827fdd6a87..ec058bf4c4 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -404,9 +404,9 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) D_PAD* NewPad = new D_PAD( module ); NewPad->Copy( pad ); NewPad->m_Selected = IS_SELECTED; - NewPad->Pnext = module->m_Pads; - NewPad->Pback = module; - module->m_Pads->Pback = NewPad; + NewPad->SetNext( module->m_Pads ); + NewPad->SetBack( module ); + module->m_Pads->SetBack( NewPad ); module->m_Pads = NewPad; } @@ -438,9 +438,9 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) if( NewStruct == NULL ) break; NewStruct->m_Selected = IS_SELECTED; - NewStruct->Pnext = module->m_Drawings; - NewStruct->Pback = module; - module->m_Drawings->Pback = module; + NewStruct->SetNext( module->m_Drawings ); + NewStruct->SetBack( module ); + module->m_Drawings->SetBack( module ); module->m_Drawings = NewStruct; } diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 16ee42255c..0f99f4a42b 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -177,7 +177,7 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) * Pour Routage 1 seule face: * le plan BOTTOM est utilise * et Route_Layer_BOTTOM = Route_Layer_TOP - * + * * Selon les bits = 1 du parametre flag: * si FORCE_PADS : tous les pads seront places meme ceux de meme net_code */ @@ -312,18 +312,18 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) /* Put tracks and vias on matrix */ pt_segm = Pcb->m_Track; - for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( net_code == pt_segm->GetNet() ) continue; - - TraceSegmentPcb( Pcb, pt_segm, HOLE, marge, WRITE_CELL ); - TraceSegmentPcb( Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); + + TraceSegmentPcb( Pcb, pt_segm, HOLE, marge, WRITE_CELL ); + TraceSegmentPcb( Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); } /* Put zone filling on matrix */ pt_segm = (TRACK*) Pcb->m_Zone; - for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( net_code == pt_segm->GetNet() ) continue; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 69a27281a6..5005954691 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -217,11 +217,11 @@ wxPoint& BOARD::GetPosition() void BOARD::UnLink() { /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() == TYPEPCB ) + if( Back()->Type() == TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { @@ -230,10 +230,11 @@ void BOARD::UnLink() } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } @@ -249,13 +250,13 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) { // this one uses a vector case TYPEMARKER: - aBoardItem->m_Parent = this; + aBoardItem->SetParent( this ); m_markers.push_back( (MARKER*) aBoardItem ); break; // this one uses a vector case TYPEZONE_CONTAINER: - aBoardItem->m_Parent = this; + aBoardItem->SetParent( this ); m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem ); break; @@ -270,11 +271,11 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) case TYPEMODULE: // this is an insert, not an append which may also be needed. { - aBoardItem->Pback = this; + aBoardItem->SetBack( this ); BOARD_ITEM* next = m_Modules; - aBoardItem->Pnext = next; + aBoardItem->SetNext( next ); if( next ) - next->Pback = aBoardItem; + next->SetBack( aBoardItem ); m_Modules = (MODULE*) aBoardItem; } break; @@ -408,17 +409,16 @@ bool BOARD::ComputeBoundaryBox() */ { int rayon, cx, cy, d, xmin, ymin, xmax, ymax; - bool Has_Items = FALSE; + bool hasItems = FALSE; EDA_BaseStruct* PtStruct; DRAWSEGMENT* ptr; - TRACK* Track; xmin = ymin = 0x7FFFFFFFl; xmax = ymax = -0x7FFFFFFFl; /* Analyse PCB edges*/ PtStruct = m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() != TYPEDRAWSEGMENT ) continue; @@ -435,7 +435,7 @@ bool BOARD::ComputeBoundaryBox() ymin = MIN( ymin, cy - rayon ); xmax = MAX( xmax, cx + rayon ); ymax = MAX( ymax, cy + rayon ); - Has_Items = TRUE; + hasItems = TRUE; } else { @@ -447,22 +447,22 @@ bool BOARD::ComputeBoundaryBox() cy = MAX( ptr->m_Start.y, ptr->m_End.y ); xmax = MAX( xmax, cx + d ); ymax = MAX( ymax, cy + d ); - Has_Items = TRUE; + hasItems = TRUE; } } /* Analyse footprints */ - MODULE* module = m_Modules; - for( ; module != NULL; module = (MODULE*) module->Pnext ) + + for( MODULE* module = m_Modules; module; module = module->Next() ) { - Has_Items = TRUE; + hasItems = TRUE; xmin = MIN( xmin, ( module->m_Pos.x + module->m_BoundaryBox.GetX() ) ); ymin = MIN( ymin, ( module->m_Pos.y + module->m_BoundaryBox.GetY() ) ); xmax = MAX( xmax, module->m_Pos.x + module->m_BoundaryBox.GetRight() ); ymax = MAX( ymax, module->m_Pos.y + module->m_BoundaryBox.GetBottom() ); - D_PAD* pt_pad = module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + + for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() ) { const wxPoint& pos = pt_pad->GetPosition(); @@ -475,35 +475,35 @@ bool BOARD::ComputeBoundaryBox() } /* Analyse track and zones */ - for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( TRACK* track = m_Track; track; track = track->Next() ) { - d = (Track->m_Width / 2) + 1; - cx = MIN( Track->m_Start.x, Track->m_End.x ); - cy = MIN( Track->m_Start.y, Track->m_End.y ); + d = (track->m_Width / 2) + 1; + cx = MIN( track->m_Start.x, track->m_End.x ); + cy = MIN( track->m_Start.y, track->m_End.y ); xmin = MIN( xmin, cx - d ); ymin = MIN( ymin, cy - d ); - cx = MAX( Track->m_Start.x, Track->m_End.x ); - cy = MAX( Track->m_Start.y, Track->m_End.y ); + cx = MAX( track->m_Start.x, track->m_End.x ); + cy = MAX( track->m_Start.y, track->m_End.y ); xmax = MAX( xmax, cx + d ); ymax = MAX( ymax, cy + d ); - Has_Items = TRUE; + hasItems = TRUE; } - for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( TRACK* track = m_Zone; track; track = track->Next() ) { - d = (Track->m_Width / 2) + 1; - cx = MIN( Track->m_Start.x, Track->m_End.x ); - cy = MIN( Track->m_Start.y, Track->m_End.y ); + d = (track->m_Width / 2) + 1; + cx = MIN( track->m_Start.x, track->m_End.x ); + cy = MIN( track->m_Start.y, track->m_End.y ); xmin = MIN( xmin, cx - d ); ymin = MIN( ymin, cy - d ); - cx = MAX( Track->m_Start.x, Track->m_End.x ); - cy = MAX( Track->m_Start.y, Track->m_End.y ); + cx = MAX( track->m_Start.x, track->m_End.x ); + cy = MAX( track->m_Start.y, track->m_End.y ); xmax = MAX( xmax, cx + d ); ymax = MAX( ymax, cy + d ); - Has_Items = TRUE; + hasItems = TRUE; } - if( !Has_Items && m_PcbFrame ) + if( !hasItems && m_PcbFrame ) { if( m_PcbFrame->m_Draw_Sheet_Ref ) { @@ -525,7 +525,7 @@ bool BOARD::ComputeBoundaryBox() m_BoundaryBox.SetWidth( xmax - xmin ); m_BoundaryBox.SetHeight( ymax - ymin ); - return Has_Items; + return hasItems; } @@ -541,8 +541,6 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame ) #define POS_AFF_NBCONNECT 40 #define POS_AFF_NBNOCONNECT 48 - int nb_vias = 0, ii; - EDA_BaseStruct* Struct; wxString txt; frame->MsgPanel->EraseMsgBox(); @@ -550,10 +548,10 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame ) txt.Printf( wxT( "%d" ), m_NbPads ); Affiche_1_Parametre( frame, POS_AFF_NBPADS, _( "Pads" ), txt, DARKGREEN ); - for( ii = 0, Struct = m_Track; Struct != NULL; Struct = Struct->Pnext ) + int nb_vias = 0; + for( BOARD_ITEM* item = m_Track; item; item = item->Next() ) { - ii++; - if( Struct->Type() == TYPEVIA ) + if( item->Type() == TYPEVIA ) nb_vias++; } diff --git a/pcbnew/class_cotation.cpp b/pcbnew/class_cotation.cpp index 8cb4775f85..5fab9d1daf 100644 --- a/pcbnew/class_cotation.cpp +++ b/pcbnew/class_cotation.cpp @@ -35,24 +35,23 @@ COTATION::~COTATION() */ void COTATION::UnLink() { - /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; + ((BOARD*) Back() )->m_Drawings = Next(); } } - /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } diff --git a/pcbnew/class_cotation.h b/pcbnew/class_cotation.h index c0e9f6cc95..825ea25e68 100644 --- a/pcbnew/class_cotation.h +++ b/pcbnew/class_cotation.h @@ -28,6 +28,9 @@ public: COTATION( BOARD_ITEM* StructFather ); ~COTATION(); + COTATION* Next() const { return (COTATION*) Pnext; } + COTATION* Back() const { return (COTATION*) Pback; } + wxPoint& GetPosition() { return m_Pos; diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index fbecdaafd2..6173a27339 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -31,30 +31,25 @@ DRAWSEGMENT:: ~DRAWSEGMENT() void DRAWSEGMENT::UnLink() - -/** - * Function UnLink - * remove item from linked list. - */ { - /* ereas back link */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; + ( (BOARD*) Back() )->m_Drawings = Next(); } } /* erase forward link */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index dc94db3504..ca95d8727e 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -20,6 +20,8 @@ public: DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT ); ~DRAWSEGMENT(); + DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; } + DRAWSEGMENT* Back() const { return (DRAWSEGMENT*) Pback; } /** * Function GetPosition @@ -55,7 +57,10 @@ public: bool ReadDrawSegmentDescr( FILE* File, int* LineNum ); - /* remove this from the linked list */ + /** + * Function UnLink + * remove item from linked list. + */ void UnLink(); void Copy( DRAWSEGMENT* source ); diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 9f7add10c0..7d369580c0 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -84,23 +84,24 @@ void EDGE_MODULE::UnLink() /********************************/ { /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEMODULE ) + if( Back()->Type() != TYPEMODULE ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (MODULE*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; + ( (MODULE*) Back() )->m_Drawings = Next(); } } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } @@ -275,7 +276,7 @@ void EDGE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) if( !module ) return; - BOARD* board = (BOARD*) module->m_Parent; + BOARD* board = (BOARD*) module->GetParent(); if( !board ) return; diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index ed5453b162..0705a4a933 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -29,6 +29,14 @@ public: EDGE_MODULE( EDGE_MODULE* edge ); ~EDGE_MODULE(); + EDGE_MODULE* Next() const { return (EDGE_MODULE*) Pnext; } + EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; } + + +/** + * Function UnLink + * remove item from linked list. + */ /** * Function GetPosition diff --git a/pcbnew/class_equipot.cpp b/pcbnew/class_equipot.cpp index d7c56d4bd3..3a22060d85 100644 --- a/pcbnew/class_equipot.cpp +++ b/pcbnew/class_equipot.cpp @@ -55,23 +55,24 @@ wxPoint& EQUIPOT::GetPosition() void EQUIPOT::UnLink() { /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Equipots = (EQUIPOT*) Pnext; + ( (BOARD*) Back() )->m_Equipots = Next(); } } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } @@ -120,20 +121,20 @@ bool EQUIPOT::Save( FILE* aFile ) const return true; bool rc = false; - + fprintf( aFile, "$EQUIPOT\n" ); fprintf( aFile, "Na %d \"%.16s\"\n", GetNet(), CONV_TO_UTF8( m_Netname ) ); fprintf( aFile, "St %s\n", "~" ); - + if( m_ForceWidth ) fprintf( aFile, "Lw %d\n", m_ForceWidth ); - + if( fprintf( aFile, "$EndEQUIPOT\n" ) != sizeof("$EndEQUIPOT\n")-1 ) goto out; rc = true; - -out: + +out: return rc; } @@ -142,14 +143,14 @@ out: /** * Function Show * is used to output the object tree, currently for debugging only. - * @param nestLevel An aid to prettier tree indenting, and is the level + * @param nestLevel An aid to prettier tree indenting, and is the level * of nesting of this object within the overall tree. * @param os The ostream& to output to. */ void EQUIPOT::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: - NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << " name=\"" << m_Netname.mb_str() << '"' << " netcode=\"" << GetNet() << "\"/>\n"; } diff --git a/pcbnew/class_equipot.h b/pcbnew/class_equipot.h index 65ffb6a000..20f79e3a6d 100644 --- a/pcbnew/class_equipot.h +++ b/pcbnew/class_equipot.h @@ -28,7 +28,8 @@ public: EQUIPOT( BOARD_ITEM* StructFather ); ~EQUIPOT(); - EQUIPOT* Next() { return (EQUIPOT*) Pnext; } + EQUIPOT* Next() const { return (EQUIPOT*) Pnext; } + EQUIPOT* Back() const { return (EQUIPOT*) Pback; } /** * Function GetPosition diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index 81804f8b8b..cd187fa692 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -25,29 +25,24 @@ MIREPCB::~MIREPCB() /***************************/ void MIREPCB::UnLink() /***************************/ - -/* supprime du chainage la structure Struct - * les structures arrieres et avant sont chainees directement - */ { - /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; + ( (BOARD*) Back() )->m_Drawings = Next(); } } - /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index b8977c984c..948b4b983d 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -19,6 +19,9 @@ public: MIREPCB( BOARD_ITEM* StructFather ); ~MIREPCB(); + MIREPCB* Next() const { return (MIREPCB*) Pnext; } + MIREPCB* Back() const { return (MIREPCB*) Pnext; } + wxPoint& GetPosition() { return m_Pos; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 3d40d7c477..ae7a18ec7e 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -54,8 +54,6 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset /*************************************************/ /* Class MODULE : description d'un composant pcb */ /*************************************************/ - -/* Constructeur de la classe MODULE */ MODULE::MODULE( BOARD* parent ) : BOARD_ITEM( parent, TYPEMODULE ) { @@ -71,53 +69,51 @@ MODULE::MODULE( BOARD* parent ) : m_Surface = 0; m_Link = 0; m_LastEdit_Time = time( NULL ); + m_Reference = new TEXTE_MODULE( this, TEXT_is_REFERENCE ); - m_Reference->Pback = this; + m_Reference->SetBack( this ); + m_Value = new TEXTE_MODULE( this, TEXT_is_VALUE ); - m_Value->Pback = this; + m_Value->SetBack( this ); + m_3D_Drawings = new Struct3D_Master( this ); } -/* Destructeur */ MODULE::~MODULE() { - D_PAD* Pad; - EDA_BaseStruct* Struct, * NextStruct; + EDA_BaseStruct* item; + EDA_BaseStruct* next; delete m_Reference; delete m_Value; - for( Struct = m_3D_Drawings; Struct != NULL; Struct = NextStruct ) + for( item = m_3D_Drawings; item; item = next ) { - NextStruct = Struct->Pnext; - delete Struct; + next = item->Next(); + delete item; } - /* effacement des pads */ - for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*) NextStruct ) + for( item = m_Pads; item; item = next ) { - NextStruct = Pad->Pnext; - delete Pad; + next = item->Next(); + delete item; } /* effacement des elements de trace */ - for( Struct = m_Drawings; Struct != NULL; Struct = NextStruct ) + for( item = m_Drawings; item; item = next ) { - NextStruct = Struct->Pnext; + next = item->Next(); - switch( ( Struct->Type() ) ) + switch( item->Type() ) { case TYPEEDGEMODULE: - delete (EDGE_MODULE*) Struct; - break; - case TYPETEXTEMODULE: - delete (TEXTE_MODULE*) Struct; + delete item; break; default: - DisplayError( NULL, wxT( "Warn: ItemType not handled in delete MODULE" ) ); - NextStruct = NULL; + DisplayError( NULL, wxT( "Warning: Item Type not handled in delete MODULE" ) ); + next = NULL; break; } } @@ -128,7 +124,7 @@ MODULE::~MODULE() void MODULE::Copy( MODULE* Module ) /*********************************/ { - D_PAD* pad, * lastpad; + D_PAD* lastpad; m_Pos = Module->m_Pos; m_Layer = Module->m_Layer; @@ -148,28 +144,30 @@ void MODULE::Copy( MODULE* Module ) m_Value->Copy( Module->m_Value ); /* Copie des structures auxiliaires: Pads */ - lastpad = NULL; pad = Module->m_Pads; - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + lastpad = NULL; + + for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) { D_PAD* newpad = new D_PAD( this ); newpad->Copy( pad ); if( m_Pads == NULL ) { - newpad->Pback = this; - m_Pads = (D_PAD*) newpad; + newpad->SetBack( this ); + m_Pads = newpad; } else { - newpad->Pback = lastpad; - lastpad->Pnext = newpad; + newpad->SetBack( lastpad ); + lastpad->SetNext( newpad ); } lastpad = newpad; } /* Copy des structures auxiliaires: Drawings */ - BOARD_ITEM* OldStruct = Module->m_Drawings; BOARD_ITEM* NewStruct, * LastStruct = NULL; + + BOARD_ITEM* OldStruct = Module->m_Drawings; for( ; OldStruct; OldStruct = OldStruct->Next() ) { NewStruct = NULL; @@ -193,15 +191,16 @@ void MODULE::Copy( MODULE* Module ) if( NewStruct == NULL ) break; + if( m_Drawings == NULL ) { - NewStruct->Pback = this; + NewStruct->SetBack( this ); m_Drawings = NewStruct; } else { - NewStruct->Pback = LastStruct; - LastStruct->Pnext = NewStruct; + NewStruct->SetBack( LastStruct ); + LastStruct->SetNext( NewStruct ); } LastStruct = NewStruct; } @@ -211,14 +210,14 @@ void MODULE::Copy( MODULE* Module ) Struct3D_Master* Struct3D, * NewStruct3D, * CurrStruct3D; - Struct3D = (Struct3D_Master*) Module->m_3D_Drawings->Pnext; + Struct3D = Module->m_3D_Drawings->Next(); CurrStruct3D = m_3D_Drawings; - for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext ) + for( ; Struct3D != NULL; Struct3D = Struct3D->Next() ) { NewStruct3D = new Struct3D_Master( this ); NewStruct3D->Copy( Struct3D ); - CurrStruct3D->Pnext = NewStruct3D; - NewStruct3D->Pback = CurrStruct3D; + CurrStruct3D->SetNext( NewStruct3D ); + NewStruct3D->SetBack( CurrStruct3D ); CurrStruct3D = NewStruct3D; } @@ -233,12 +232,11 @@ void MODULE::Copy( MODULE* Module ) */ void MODULE::UnLink() { - /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { @@ -248,18 +246,20 @@ void MODULE::UnLink() g_UnDeleteStack[g_UnDeleteStackPtr - 1] = Next(); } else - ( (BOARD*) Pback )->m_Modules = (MODULE*) Pnext; + ( (BOARD*) Back() )->m_Modules = Next(); } } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } + /**********************************************************/ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& offset ) @@ -276,13 +276,12 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, if( (m_Flags & DO_NOT_DRAW) ) return; - /* Draw pads */ - D_PAD* pt_pad = m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { - if( pt_pad->m_Flags & IS_MOVED ) + if( pad->m_Flags & IS_MOVED ) continue; - pt_pad->Draw( panel, DC, draw_mode, offset ); + + pad->Draw( panel, DC, draw_mode, offset ); } // Draws foootprint anchor @@ -453,7 +452,7 @@ int MODULE::Write_3D_Descr( FILE* File ) const char buf[512]; Struct3D_Master* Struct3D = m_3D_Drawings; - for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext ) + for( ; Struct3D != NULL; Struct3D = Struct3D->Next() ) { if( !Struct3D->m_Shape3DName.IsEmpty() ) { @@ -503,11 +502,12 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum ) if( !Struct3D->m_Shape3DName.IsEmpty() ) { Struct3D_Master* NewStruct3D; - while( Struct3D->Pnext ) - Struct3D = (Struct3D_Master*) Struct3D->Pnext; + while( Struct3D->Next() ) + Struct3D = Struct3D->Next(); - Struct3D->Pnext = NewStruct3D = new Struct3D_Master( this ); - NewStruct3D->Pback = Struct3D; + NewStruct3D = new Struct3D_Master( this ); + Struct3D->SetNext( NewStruct3D ); + NewStruct3D->SetBack( Struct3D ); Struct3D = NewStruct3D; } @@ -590,13 +590,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) if( LastPad == NULL ) { - ptpad->Pback = (EDA_BaseStruct*) this; + ptpad->SetBack( this ); m_Pads = ptpad; } else { - ptpad->Pback = (EDA_BaseStruct*) LastPad; - LastPad->Pnext = (EDA_BaseStruct*) ptpad; + ptpad->SetBack( LastPad ); + LastPad->SetNext( ptpad ); } LastPad = ptpad; continue; @@ -683,13 +683,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) DrawText = new TEXTE_MODULE( this ); if( LastModStruct == NULL ) { - DrawText->Pback = this; + DrawText->SetBack( this ); m_Drawings = DrawText; } else { - DrawText->Pback = LastModStruct; - LastModStruct->Pnext = DrawText; + DrawText->SetBack( LastModStruct ); + LastModStruct->SetNext( DrawText ); } LastModStruct = DrawText; } @@ -702,13 +702,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) if( LastModStruct == NULL ) { - DrawSegm->Pback = this; + DrawSegm->SetBack( this ); m_Drawings = DrawSegm; } else { - DrawSegm->Pback = LastModStruct; - LastModStruct->Pnext = DrawSegm; + DrawSegm->SetBack( LastModStruct ); + LastModStruct->SetNext( DrawSegm ); } LastModStruct = DrawSegm; @@ -757,8 +757,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) m_Value->m_Pos.y += deltaY; /* deplacement des pastilles */ - D_PAD* pad = m_Pads; - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { pad->m_Pos.x += deltaX; pad->m_Pos.y += deltaY; @@ -766,7 +765,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) /* deplacement des dessins de l'empreinte : */ EDA_BaseStruct* PtStruct = m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -809,8 +808,7 @@ void MODULE::SetOrientation( int newangle ) NORMALIZE_ANGLE_POS( m_Orient ); /* deplacement et rotation des pastilles */ - D_PAD* pad = m_Pads; - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { px = pad->m_Pos0.x; py = pad->m_Pos0.y; @@ -829,7 +827,7 @@ void MODULE::SetOrientation( int newangle ) /* deplacement des contours et textes de l'empreinte : */ EDA_BaseStruct* PtStruct = m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() == TYPEEDGEMODULE ) { @@ -862,25 +860,23 @@ void MODULE::Set_Rectangle_Encadrement() * en coord relatives / position ancre */ { - EDGE_MODULE* pt_edge_mod; - D_PAD* pad; int width; int cx, cy, uxf, uyf, rayon; int xmax, ymax; /* Init des pointeurs */ - pt_edge_mod = (EDGE_MODULE*) m_Drawings; - /* Init des coord du cadre a une valeur limite non nulle */ m_BoundaryBox.m_Pos.x = -500; xmax = 500; m_BoundaryBox.m_Pos.y = -500; ymax = 500; /* Contours: Recherche des coord min et max et mise a jour du cadre */ - for( ; pt_edge_mod != NULL; pt_edge_mod = (EDGE_MODULE*) pt_edge_mod->Pnext ) + for( EDGE_MODULE* pt_edge_mod = (EDGE_MODULE*) m_Drawings; + pt_edge_mod; pt_edge_mod = pt_edge_mod->Next() ) { if( pt_edge_mod->Type() != TYPEEDGEMODULE ) continue; + width = pt_edge_mod->m_Width / 2; switch( pt_edge_mod->m_Shape ) @@ -913,7 +909,7 @@ void MODULE::Set_Rectangle_Encadrement() } /* Pads: Recherche des coord min et max et mise a jour du cadre */ - for( pad = m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { rayon = pad->m_Rayon; cx = pad->m_Pos0.x; cy = pad->m_Pos0.y; @@ -940,8 +936,6 @@ void MODULE::SetRectangleExinscrit() * Met egalement a jour la surface (.m_Surface) du module. */ { - EDGE_MODULE* EdgeMod; - D_PAD* Pad; int width; int cx, cy, uxf, uyf, rayon; int xmax, ymax; @@ -950,20 +944,20 @@ void MODULE::SetRectangleExinscrit() m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y; /* Contours: Recherche des coord min et max et mise a jour du cadre */ - EdgeMod = (EDGE_MODULE*) m_Drawings; - for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext ) + for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings; edge; edge = edge->Next() ) { - if( EdgeMod->Type() != TYPEEDGEMODULE ) + if( edge->Type() != TYPEEDGEMODULE ) continue; - width = EdgeMod->m_Width / 2; - switch( EdgeMod->m_Shape ) + width = edge->m_Width / 2; + + switch( edge->m_Shape ) { case S_ARC: case S_CIRCLE: { - cx = EdgeMod->m_Start.x; cy = EdgeMod->m_Start.y; // centre - uxf = EdgeMod->m_End.x; uyf = EdgeMod->m_End.y; + cx = edge->m_Start.x; cy = edge->m_Start.y; // centre + uxf = edge->m_End.x; uyf = edge->m_End.y; rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) ); rayon += width; m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, cx - rayon ); @@ -974,25 +968,29 @@ void MODULE::SetRectangleExinscrit() } default: - m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, EdgeMod->m_Start.x - width ); - m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, EdgeMod->m_End.x - width ); - m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, EdgeMod->m_Start.y - width ); - m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, EdgeMod->m_End.y - width ); - xmax = MAX( xmax, EdgeMod->m_Start.x + width ); - xmax = MAX( xmax, EdgeMod->m_End.x + width ); - ymax = MAX( ymax, EdgeMod->m_Start.y + width ); - ymax = MAX( ymax, EdgeMod->m_End.y + width ); + m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, edge->m_Start.x - width ); + m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, edge->m_End.x - width ); + m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, edge->m_Start.y - width ); + m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, edge->m_End.y - width ); + xmax = MAX( xmax, edge->m_Start.x + width ); + xmax = MAX( xmax, edge->m_End.x + width ); + ymax = MAX( ymax, edge->m_Start.y + width ); + ymax = MAX( ymax, edge->m_End.y + width ); break; } } /* Pads: Recherche des coord min et max et mise a jour du cadre */ - for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext ) + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { - rayon = Pad->m_Rayon; - cx = Pad->m_Pos.x; cy = Pad->m_Pos.y; + rayon = pad->m_Rayon; + + cx = pad->m_Pos.x; + cy = pad->m_Pos.y; + m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, cx - rayon ); m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, cy - rayon ); + xmax = MAX( xmax, cx + rayon ); ymax = MAX( ymax, cy + rayon ); } @@ -1022,12 +1020,11 @@ EDA_Rect MODULE::GetBoundingBox() text_area = m_Value->GetBoundingBox(); area.Merge( text_area ); - EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings; - for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext ) + for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings; edge; edge = edge->Next() ) { - if( EdgeMod->Type() != TYPETEXTEMODULE ) + if( edge->Type() != TYPETEXTEMODULE ) continue; - text_area = ((TEXTE_MODULE*)EdgeMod)->GetBoundingBox(); + text_area = ((TEXTE_MODULE*)edge)->GetBoundingBox(); area.Merge( text_area ); } @@ -1086,7 +1083,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) while( PtStruct ) { nbpad++; - PtStruct = PtStruct->Pnext; + PtStruct = PtStruct->Next(); } msg.Printf( wxT( "%d" ), nbpad ); @@ -1288,20 +1285,20 @@ void MODULE::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Pads; - for( ; p; p = p->Pnext ) + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); NestedSpace( nestLevel + 1, os ) << "\n"; NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Drawings; - for( ; p; p = p->Pnext ) + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Son; - for( ; p; p = p->Pnext ) + for( ; p; p = p->Next() ) { p->Show( nestLevel + 1, os ); } diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index b3aaea8d08..3577b66af4 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -74,14 +74,25 @@ public: MODULE( MODULE* module ); ~MODULE(); + MODULE* Next() const { return (MODULE*) Pnext; } + MODULE* Back() const { return (MODULE*) Pback; } + void Copy( MODULE* Module ); // Copy structure - MODULE* Next() { return (MODULE*) Pnext; } - /** Function Set_Rectangle_Encadrement() - * Calculates the bounding box - * for orient 0 et origin = module anchor) - */ + /** + * Function Add + * adds the given item to this MODULE and takes ownership of its memory. + * @param aBoardItem The item to add to this board. + * @param doInsert If true, then insert, else append + void Add( BOARD_ITEM* aBoardItem, bool doInsert = true ); + */ + + + /** + * Function Set_Rectangle_Encadrement() + * calculates the bounding box for orient 0 et origin = module anchor) + */ void Set_Rectangle_Encadrement(); /** function SetRectangleExinscrit() @@ -89,6 +100,7 @@ public: * and also calculates the area value (used in automatic placement) */ void SetRectangleExinscrit(); + /** * Function GetBoundingBox * returns the bounding box of this Footprint @@ -156,12 +168,12 @@ public: /** * Function Read_GPCB_Descr - * Read a footprint description in GPCB format (newlib version) + * reads a footprint description in GPCB format (newlib version) * @param CmpFullFileName = Full file name (there is one footprint per file. * this is also the footprint name * @return bool - true if success reading else false. */ - bool Read_GPCB_Descr(const wxString & CmpFullFileName); + bool Read_GPCB_Descr(const wxString & CmpFullFileName); int Read_3D_Descr( FILE* File, int* LineNum = NULL ); /* drawing functions */ diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index b55fe2607c..ae80183286 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -89,10 +89,10 @@ EDA_Rect D_PAD::GetBoundingBox() // Calculate area: ComputeRayon(); // calculate the radius of the area, considered as a circle EDA_Rect area; - area.SetOrigin(m_Pos); - area.Inflate(m_Rayon, m_Rayon); + area.SetOrigin(m_Pos); + area.Inflate(m_Rayon, m_Rayon); - return area; + return area; } @@ -211,23 +211,24 @@ void D_PAD::UnLink() */ { /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEMODULE ) + if( Back()->Type() != TYPEMODULE ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (MODULE*) Pback )->m_Pads = (D_PAD*) Pnext; + ( (MODULE*) Back() )->m_Pads = Next(); } } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } @@ -254,8 +255,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin int fillpad = 0; wxPoint shape_pos; - if ( m_Flags & DO_NOT_DRAW ) - return; + if ( m_Flags & DO_NOT_DRAW ) + return; wxASSERT( panel ); diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index b6c8ef3cb1..1e2e0a2840 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -37,7 +37,7 @@ public: wxSize m_Drill; // Drill diam (drill shape = PAD_CIRCLE) or drill size(shape = OVAL) // for drill shape = PAD_CIRCLE, drill diam = m_Drill.x - wxSize m_Offset; /*This parameter is usefull only for oblong pads (it can be used for other + wxSize m_Offset; /* This parameter is usefull only for oblong pads (it can be used for other * shapes, but without any interest). * this is the offset between the pad hole and the pad shape (you must * understand here pad shape = copper area around the hole) diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 2f395b28c1..8abea9fc97 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -51,23 +51,24 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source ) void TEXTE_PCB::UnLink() { /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; + ( (BOARD*) Back() )->m_Drawings = Next(); } } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } @@ -175,7 +176,7 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame ) wxASSERT( parent ); if( parent->Type() == TYPECOTATION ) - board = (BOARD*) parent->m_Parent; + board = (BOARD*) parent->GetParent(); else board = (BOARD*) parent; wxASSERT( board ); diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index fb0029f327..69b78c28ff 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -211,23 +211,24 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) void TEXTE_MODULE::UnLink() { /* Modification du chainage arriere */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEMODULE ) + if( Back()->Type() != TYPEMODULE ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (MODULE*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; + ( (MODULE*) Back() )->m_Drawings = Next(); } } /* Modification du chainage avant */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } @@ -481,7 +482,7 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) if( !module ) return; - BOARD* board = (BOARD*) module->m_Parent; + BOARD* board = (BOARD*) module->GetParent(); wxASSERT( board ); static const wxString text_type_msg[3] = { diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 2b3620c967..87a9fc7413 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -33,6 +33,9 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS ); ~TEXTE_MODULE(); + TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; } + TEXTE_MODULE* Back() const { return (TEXTE_MODULE*) Pback; } + /** * Function GetPosition * returns the position of this object. diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index a51e3a6a01..bb6f802d94 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -409,11 +409,11 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const void TRACK::UnLink() { /* Remove the back link */ - if( Pback ) + if( Back() ) { - if( Pback->Type() != TYPEPCB ) + if( Back()->Type() != TYPEPCB ) { - Pback->Pnext = Pnext; + Back()->SetNext( Next() ); } else /* Le chainage arriere pointe sur la structure "Pere" */ { @@ -426,26 +426,27 @@ void TRACK::UnLink() { if( Type() == TYPEZONE ) { - ( (BOARD*) Pback )->m_Zone = (SEGZONE*) Pnext; + ( (BOARD*) Back() )->m_Zone = (SEGZONE*) Next(); } else { - ( (BOARD*) Pback )->m_Track = (TRACK*) Pnext; + ( (BOARD*) Back() )->m_Track = Next(); } } } } /* Remove the forward link */ - if( Pnext ) - Pnext->Pback = Pback; + if( Next() ) + Next()->SetBack( Back() ); - Pnext = Pback = NULL; + SetNext( 0 ); + SetBack( 0 ); } /************************************************************/ -void TRACK::Insert( BOARD* Pcb, BOARD_ITEM* InsertPoint ) +void TRACK::Insert( BOARD* Pcb, TRACK* InsertPoint ) /************************************************************/ /* insert this (and its linked segments is exists) @@ -474,20 +475,20 @@ void TRACK::Insert( BOARD* Pcb, BOARD_ITEM* InsertPoint ) } else { - NextS = (TRACK*) InsertPoint->Pnext; + NextS = InsertPoint->Next(); Pback = InsertPoint; - InsertPoint->Pnext = this; + InsertPoint->SetNext( this ); } /* Set the forward link */ track = this; - while( track->Pnext ) // Search the end of added chain - track = (TRACK*) track->Pnext; + while( track->Next() ) // Search the end of added chain + track = track->Next(); /* Link the end of chain */ - track->Pnext = NextS; + track->SetNext( NextS ); if( NextS ) - NextS->Pback = track; + NextS->SetBack( track ); } @@ -626,12 +627,6 @@ bool TRACK::Save( FILE* aFile ) const /*********************************************************************/ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& notUsed ) /*********************************************************************/ - -/** Draws the segment. - * @param panel = current panel - * @param DC = current device context - * @param draw_mode = GR_XOR, GR_OR.. - */ { int l_piste; int color; @@ -644,10 +639,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin GRSetDrawMode( DC, draw_mode ); - if( Type() == TYPEVIA ) - color = g_DesignSettings.m_ViaColor[m_Shape]; - else - color = g_DesignSettings.m_LayerColor[m_Layer]; + color = g_DesignSettings.m_LayerColor[m_Layer]; if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW ) return; @@ -678,88 +670,6 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin l_piste = m_Width >> 1; - if( Type() == TYPEVIA ) /* The via is drawn as a circle */ - { - rayon = l_piste; - if( rayon < zoom ) - rayon = zoom; - - GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color ); - if( rayon > (4 * zoom) ) - { - int drill_rayon = GetDrillValue() / 2; - int inner_rayon = rayon - (2 * zoom); - GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, - inner_rayon, color ); - - // Draw the via hole if the display option allows it - if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) - { - if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) || // Display all drill holes requested - ( (drill_rayon > 0 ) && ! IsDrillDefault() ) ) // Or Display non default holes requested - { - if( drill_rayon < inner_rayon ) // We can show the via hole - { - GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, - drill_rayon, color ); - } - } - } - - if( DisplayOpt.DisplayTrackIsol ) - GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, - rayon + g_DesignSettings.m_TrackClearence, color ); - // for Micro Vias, draw a partial cross : - // X on component layer, or + on copper layer - // (so we can see 2 superimposed microvias ): - if ( Shape() == VIA_MICROVIA ) - { - int ax, ay, bx, by; - if ( IsOnLayer(COPPER_LAYER_N) ) - { - ax = rayon; ay = 0; - bx = drill_rayon; by = 0; - } - else - { - ax = ay = (rayon * 707) / 1000; - bx = by = (drill_rayon * 707) / 1000; - } - /* lines | or \ */ - GRLine( &panel->m_ClipBox, DC, m_Start.x - ax , m_Start.y - ay, - m_Start.x - bx , m_Start.y - by, 0, color ); - GRLine( &panel->m_ClipBox, DC, m_Start.x + bx , m_Start.y + by, - m_Start.x + ax , m_Start.y + ay, 0, color ); - /* lines - or / */ - GRLine( &panel->m_ClipBox, DC, m_Start.x + ay, m_Start.y - ax , - m_Start.x + by, m_Start.y - bx, 0, color ); - GRLine( &panel->m_ClipBox, DC, m_Start.x - by, m_Start.y + bx , - m_Start.x - ay, m_Start.y + ax, 0, color ); - } - // for Buried Vias, draw a partial line : - // orient depending on layer pair - // (so we can see superimposed buried vias ): - if ( Shape() == VIA_BLIND_BURIED ) - { - int ax = 0, ay = rayon, bx = 0, by = drill_rayon; - int layer_top, layer_bottom ; - ((SEGVIA*)this)->ReturnLayerPair(&layer_top, &layer_bottom); - /* lines for the top layer */ - RotatePoint( &ax, &ay, layer_top * 3600 / g_DesignSettings.m_CopperLayerCount); - RotatePoint( &bx, &by, layer_top * 3600 / g_DesignSettings.m_CopperLayerCount); - GRLine( &panel->m_ClipBox, DC, m_Start.x - ax , m_Start.y - ay, - m_Start.x - bx , m_Start.y - by, 0, color ); - /* lines for the bottom layer */ - ax = 0; ay = rayon; bx = 0; by = drill_rayon; - RotatePoint( &ax, &ay, layer_bottom * 3600 / g_DesignSettings.m_CopperLayerCount); - RotatePoint( &bx, &by, layer_bottom * 3600 / g_DesignSettings.m_CopperLayerCount); - GRLine( &panel->m_ClipBox, DC, m_Start.x - ax , m_Start.y - ay, - m_Start.x - bx , m_Start.y - by, 0, color ); - } - } - return; - } - if( m_Shape == S_CIRCLE ) { rayon = (int) hypot( (double) (m_End.x - m_Start.x), @@ -806,7 +716,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin m_End.x, m_End.y, m_Width, color ); } - /* Shows clearance (for tracks and vias, not for zone segments */ + // Show clearance for tracks, not for zone segments if( ShowClearance( this ) ) { GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, @@ -816,6 +726,139 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin } +/*******************************************************************************************/ +void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& notUsed ) +/*******************************************************************************************/ +{ + int color; + int zoom; + int rayon; + int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; + + if( Type() == TYPEZONE && !DisplayOpt.DisplayZones ) + return; + + GRSetDrawMode( DC, draw_mode ); + + color = g_DesignSettings.m_ViaColor[m_Shape]; + + if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW ) + return; + + if( DisplayOpt.ContrastModeDisplay ) + { + if( !IsOnLayer( curr_layer ) ) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + + if( draw_mode & GR_SURBRILL ) + { + if( draw_mode & GR_AND ) + color &= ~HIGHT_LIGHT_FLAG; + else + color |= HIGHT_LIGHT_FLAG; + } + + if( color & HIGHT_LIGHT_FLAG ) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + + SetAlpha( &color, 150 ); + + zoom = panel->GetZoom(); + + rayon = m_Width >> 1; + if( rayon < zoom ) + rayon = zoom; + + GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color ); + if( rayon > (4 * zoom) ) + { + int drill_rayon = GetDrillValue() / 2; + int inner_rayon = rayon - (2 * zoom); + + GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, + inner_rayon, color ); + + // Draw the via hole if the display option allows it + if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) + { + if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) || // Display all drill holes requested + ( (drill_rayon > 0 ) && ! IsDrillDefault() ) ) // Or Display non default holes requested + { + if( drill_rayon < inner_rayon ) // We can show the via hole + { + GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, + drill_rayon, color ); + } + } + } + + if( DisplayOpt.DisplayTrackIsol ) + GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, + rayon + g_DesignSettings.m_TrackClearence, color ); + + // for Micro Vias, draw a partial cross : + // X on component layer, or + on copper layer + // (so we can see 2 superimposed microvias ): + if( Shape() == VIA_MICROVIA ) + { + int ax, ay, bx, by; + + if( IsOnLayer(COPPER_LAYER_N) ) + { + ax = rayon; ay = 0; + bx = drill_rayon; by = 0; + } + else + { + ax = ay = (rayon * 707) / 1000; + bx = by = (drill_rayon * 707) / 1000; + } + + /* lines | or \ */ + GRLine( &panel->m_ClipBox, DC, m_Start.x - ax , m_Start.y - ay, + m_Start.x - bx , m_Start.y - by, 0, color ); + GRLine( &panel->m_ClipBox, DC, m_Start.x + bx , m_Start.y + by, + m_Start.x + ax , m_Start.y + ay, 0, color ); + + /* lines - or / */ + GRLine( &panel->m_ClipBox, DC, m_Start.x + ay, m_Start.y - ax , + m_Start.x + by, m_Start.y - bx, 0, color ); + GRLine( &panel->m_ClipBox, DC, m_Start.x - by, m_Start.y + bx , + m_Start.x - ay, m_Start.y + ax, 0, color ); + } + + // for Buried Vias, draw a partial line : + // orient depending on layer pair + // (so we can see superimposed buried vias ): + if( Shape() == VIA_BLIND_BURIED ) + { + int ax = 0, ay = rayon, bx = 0, by = drill_rayon; + int layer_top, layer_bottom; + + ((SEGVIA*)this)->ReturnLayerPair(&layer_top, &layer_bottom); + + /* lines for the top layer */ + RotatePoint( &ax, &ay, layer_top * 3600 / g_DesignSettings.m_CopperLayerCount); + RotatePoint( &bx, &by, layer_top * 3600 / g_DesignSettings.m_CopperLayerCount); + GRLine( &panel->m_ClipBox, DC, m_Start.x - ax , m_Start.y - ay, + m_Start.x - bx , m_Start.y - by, 0, color ); + + /* lines for the bottom layer */ + ax = 0; ay = rayon; bx = 0; by = drill_rayon; + RotatePoint( &ax, &ay, layer_bottom * 3600 / g_DesignSettings.m_CopperLayerCount); + RotatePoint( &bx, &by, layer_bottom * 3600 / g_DesignSettings.m_CopperLayerCount); + GRLine( &panel->m_ClipBox, DC, m_Start.x - ax , m_Start.y - ay, + m_Start.x - bx , m_Start.y - by, 0, color ); + } + } +} + + + // see class_track.h void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) { diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index f3c2ae0f17..09ff92fce0 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -50,9 +50,9 @@ public: TRACK* Copy() const; TRACK* Next() const { return (TRACK*) Pnext; } - TRACK* Back() const { return (TRACK*) Pback; } + /** * Function GetPosition * returns the position of this object. @@ -89,7 +89,7 @@ public: * @param aPcb The BOARD to insert into. * @param InsertPoint See above */ - void Insert( BOARD* aPcb, BOARD_ITEM* InsertPoint ); + void Insert( BOARD* aPcb, TRACK* InsertPoint ); /** * Function GetBestInsertPoint @@ -277,6 +277,9 @@ public: } + void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset ); + + /** * Function IsOnLayer * tests to see if this object is on the given layer. Is virtual diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index 4b614406ca..00d238da2c 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -53,7 +53,7 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_ EXCHG( old_val, new_val ); pt_conn = pt_start_conn; - for( ; pt_conn != NULL; pt_conn = (TRACK*) pt_conn->Pnext ) + for( ; pt_conn != NULL; pt_conn = pt_conn->Next() ) { if( pt_conn->GetSubNet() != old_val ) { @@ -110,7 +110,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) /* Clear variables used in computations */ pt_conn = pt_start_conn; - for( ; pt_conn != NULL; pt_conn = (TRACK*) pt_conn->Pnext ) + for( ; pt_conn != NULL; pt_conn = pt_conn->Next() ) { pt_conn->SetSubNet( 0 ); PtStruct = pt_conn->start; @@ -130,7 +130,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) /* Start of calculation */ pt_conn = pt_start_conn; - for( ; pt_conn != NULL; pt_conn = (TRACK*) pt_conn->Pnext ) + for( ; pt_conn != NULL; pt_conn = pt_conn->Next() ) { /* First: handling connections to pads */ PtStruct = pt_conn->start; @@ -300,7 +300,7 @@ void WinEDA_BasePcbFrame::test_connexions( wxDC* DC ) Build_Pads_Info_Connections_By_Tracks( pt_start_conn, pt_end_conn ); - pt_start_conn = (TRACK*) pt_end_conn->Pnext; // this is now the first segment of the next net + pt_start_conn = pt_end_conn->Next(); // this is now the first segment of the next net } Merge_SubNets_Connected_By_CopperAreas( m_Pcb ); @@ -391,7 +391,7 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* TRACK* Track; /* Reset the old connections type track to track */ - for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( Track = pt_start_conn; Track != NULL; Track = Track->Next() ) { Track->SetSubNet( 0 ); @@ -406,13 +406,13 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* } /* Update connections type track to track */ - for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext ) + for( Track = pt_start_conn; Track != NULL; Track = Track->Next() ) { if( Track->Type() == TYPEVIA ) // A via can connect many tracks, we must search for all track segments in this net { TRACK* pt_segm; int layermask = Track->ReturnMaskLayer(); - for( pt_segm = pt_start_conn; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + for( pt_segm = pt_start_conn; pt_segm != NULL; pt_segm = pt_segm->Next() ) { int curlayermask = pt_segm->ReturnMaskLayer(); @@ -607,7 +607,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) /* Reset variables and flags used in computation */ pt_piste = m_Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) { pt_piste->SetState( BUSY | EDIT | BEGIN_ONPAD | END_ONPAD, OFF ); pt_piste->SetZoneSubNet( 0 ); @@ -618,7 +618,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) * if found, set the track net code to the pad netcode */ pt_piste = m_Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) { flag = 0; masque_layer = g_TabOneLayerMask[pt_piste->GetLayer()]; @@ -821,7 +821,7 @@ static void RebuildTrackChain( BOARD* pcb ) Liste = (TRACK**) MyZMalloc( (nbsegm + 1) * sizeof(TRACK*) ); ii = 0; Track = pcb->m_Track; - for( ; Track != NULL; ii++, Track = (TRACK*) Track->Pnext ) + for( ; Track != NULL; ii++, Track = Track->Next() ) { Liste[ii] = Track; } @@ -832,13 +832,15 @@ static void RebuildTrackChain( BOARD* pcb ) /* Update the linked list pointers */ Track = Liste[0]; - Track->Pback = pcb; Track->Pnext = Liste[1]; + Track->SetBack( pcb ); + Track->SetNext( Liste[1] ); + pcb->m_Track = Track; for( ii = 1; ii < nbsegm; ii++ ) { Track = Liste[ii]; - Track->Pback = Liste[ii - 1]; - Track->Pnext = Liste[ii + 1]; + Track->SetBack( Liste[ii - 1] ); + Track->SetNext( Liste[ii + 1] ); } MyFree( Liste ); diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index 83ce8ceab5..a751b5ea63 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -280,10 +280,11 @@ COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, wxDC* DC ) Cotation->m_Flags = 0; /* Insertion de la structure dans le Chainage .Drawings du PCB */ - Cotation->Pback = m_Pcb; - Cotation->Pnext = m_Pcb->m_Drawings; + Cotation->SetBack( m_Pcb ); + Cotation->SetNext( m_Pcb->m_Drawings ); + if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = Cotation; + m_Pcb->m_Drawings->SetBack( Cotation ); m_Pcb->m_Drawings = Cotation; GetScreen()->SetModify(); diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 7f3b9c6793..ebee5d99fe 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -155,7 +155,7 @@ void WinEDA_PcbFrame::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) break; case TYPEPAD: - module = (MODULE*) objectToSync->m_Parent; + module = (MODULE*) objectToSync->GetParent(); pad = (D_PAD*) objectToSync; msg = pad->ReturnStringPadName(); sprintf( cmd, "$PART: \"%s\" $PAD: \"%s\"", @@ -166,7 +166,7 @@ void WinEDA_PcbFrame::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) case TYPETEXTEMODULE: #define REFERENCE 0 #define VALUE 1 - module = (MODULE*) objectToSync->m_Parent; + module = (MODULE*) objectToSync->GetParent(); text_mod = (TEXTE_MODULE*) objectToSync; if( text_mod->m_Type == REFERENCE ) text_key = "$REF:"; diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 1f699fa9cd..da458d726e 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -49,19 +49,19 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) // modification du trace Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); delete Track; g_TrackSegmentCount--; if( g_TwoSegmentTrackBuild ) { - // g_CurrentTrackSegment->Pback must not be a via, or we want delete also the via + // g_CurrentTrackSegment->Back() must not be a via, or we want delete also the via if( (g_TrackSegmentCount >= 2) && (g_CurrentTrackSegment->Type() != TYPEVIA) - && (g_CurrentTrackSegment->Pback->Type() == TYPEVIA) ) + && (g_CurrentTrackSegment->Back()->Type() == TYPEVIA) ) { Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); delete Track; g_TrackSegmentCount--; } @@ -71,7 +71,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) && (g_CurrentTrackSegment->Type() == TYPEVIA) ) { Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); delete Track; g_TrackSegmentCount--; if( g_CurrentTrackSegment && (g_CurrentTrackSegment->Type() != TYPEVIA) ) @@ -79,7 +79,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) } if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->Pnext = NULL; + g_CurrentTrackSegment->SetNext( NULL ); // Rectification couche active qui a pu changer si une via // a ete effacee diff --git a/pcbnew/dialog_edit_mod_text.cpp b/pcbnew/dialog_edit_mod_text.cpp index 4bf485cac5..ffda1eb75b 100644 --- a/pcbnew/dialog_edit_mod_text.cpp +++ b/pcbnew/dialog_edit_mod_text.cpp @@ -102,7 +102,7 @@ WinEDA_TextModPropertiesFrame::WinEDA_TextModPropertiesFrame( WinEDA_BasePcbFram m_CurrentTextMod = TextMod; if( m_CurrentTextMod ) { - m_Module = (MODULE*) m_CurrentTextMod->m_Parent; + m_Module = (MODULE*) m_CurrentTextMod->GetParent(); } Create( parent, id, caption, pos, size, style ); @@ -469,6 +469,6 @@ void WinEDA_TextModPropertiesFrame::TextModPropertiesAccept( wxCommandEvent& eve (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) ); } m_Parent->GetScreen()->SetModify(); - ( (MODULE*) m_CurrentTextMod->m_Parent )->m_LastEdit_Time = time( NULL ); + ( (MODULE*) m_CurrentTextMod->GetParent() )->m_LastEdit_Time = time( NULL ); Close( TRUE ); } diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index e97dcefc17..bd4e10e7ae 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -101,8 +101,8 @@ void WinEDA_ModulePropertiesFrame::CreateControls() /* creation des autres formes 3D */ Panel3D_Ctrl* panel3D = m_Panel3D, * nextpanel3D; Struct3D_Master* draw3D = m_CurrentModule->m_3D_Drawings; - draw3D = (Struct3D_Master*) draw3D->Pnext; - for( ; draw3D != NULL; draw3D = (Struct3D_Master*) draw3D->Pnext ) + draw3D = (Struct3D_Master*) draw3D->Next(); + for( ; draw3D != NULL; draw3D = (Struct3D_Master*) draw3D->Next() ) { nextpanel3D = new Panel3D_Ctrl( this, m_NoteBook, -1, draw3D ); m_NoteBook->AddPage( nextpanel3D, _( "3D settings" ), FALSE ); @@ -427,7 +427,7 @@ Panel3D_Ctrl::Panel3D_Ctrl( WinEDA_ModulePropertiesFrame* parentframe, button->SetForegroundColour( *wxRED ); PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); - if( (struct3D == NULL) || (struct3D->Pback != NULL) ) + if( (struct3D == NULL) || (struct3D->Back() != NULL) ) { button = new wxButton( this, ID_REMOVE_3D_SHAPE, _( "Remove 3D Shape" ) ); button->SetForegroundColour( *wxRED ); @@ -605,19 +605,19 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event ) if( ( draw3D->m_Shape3DName.IsEmpty() ) && (draw3D != m_CurrentModule->m_3D_Drawings) ) continue; - if( (draw3D->Pnext == NULL) && panel3D->m_Pnext ) + if( (draw3D->Next() == NULL) && panel3D->m_Pnext ) { nextdraw3D = new Struct3D_Master( draw3D ); - nextdraw3D->Pback = draw3D; - draw3D->Pnext = nextdraw3D; + nextdraw3D->SetBack( draw3D ); + draw3D->SetNext( nextdraw3D ); } - draw3D = (Struct3D_Master*) draw3D->Pnext; + draw3D = (Struct3D_Master*) draw3D->Next(); } for( ; draw3D != NULL; draw3D = nextdraw3D ) { - nextdraw3D = (Struct3D_Master*) draw3D->Pnext; - (draw3D->Pback)->Pnext = NULL; + nextdraw3D = (Struct3D_Master*) draw3D->Next(); + (draw3D->Back())->SetNext( NULL ); delete draw3D; } @@ -737,7 +737,7 @@ void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox() { if( item->Type() == TYPETEXTEMODULE ) m_TextListBox->Append( ( (TEXTE_MODULE*) item )->m_Text ); - item = item->Pnext; + item = item->Next(); } SetTextListButtons(); @@ -797,7 +797,7 @@ void WinEDA_ModulePropertiesFrame::EditOrDelTextModule( wxCommandEvent& event ) break; } } - item = item->Pnext; jj++; + item = item->Next(); jj++; } } diff --git a/pcbnew/dialog_orient_footprints.cpp b/pcbnew/dialog_orient_footprints.cpp index 13d41e5933..4c84c9b5ef 100644 --- a/pcbnew/dialog_orient_footprints.cpp +++ b/pcbnew/dialog_orient_footprints.cpp @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// // Name: dialog_orient_footprints.cpp -// Purpose: +// Purpose: // Author: j-p Charras -// Modified by: +// Modified by: // Created: 11/07/2008 13:32:12 -// RCS-ID: -// Copyright: j-p Charras +// RCS-ID: +// Copyright: j-p Charras // Licence: GPL ///////////////////////////////////////////////////////////////////////////// @@ -132,7 +132,7 @@ void dialog_orient_footprints::Init() */ void dialog_orient_footprints::CreateControls() -{ +{ ////@begin dialog_orient_footprints content construction // Generated by DialogBlocks, 11/07/2008 16:49:18 (unregistered) @@ -179,11 +179,11 @@ void dialog_orient_footprints::CreateControls() itemBoxSizer10->Add(m_CloseButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); ////@end dialog_orient_footprints content construction - + wxString txt; txt.Printf(wxT("%g"), (double) s_NewOrientation/10); m_OrientationCtrl->SetValue(txt); - + m_CloseButton->SetFocus( ); } @@ -257,7 +257,7 @@ void WinEDA_PcbFrame::ReOrientModules( const wxString& ModuleMask, return; Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { if( Module->IsLocked() && !include_fixe ) continue; @@ -269,7 +269,7 @@ void WinEDA_PcbFrame::ReOrientModules( const wxString& ModuleMask, Rotate_Module( NULL, Module, Orient, FALSE ); } } - + if ( redraw ) DrawPanel->Refresh(); } @@ -283,7 +283,7 @@ void dialog_orient_footprints::OnOkClick( wxCommandEvent& event ) { double d_orient; wxString text = m_OrientationCtrl->GetValue(); - + if ( ! text.ToDouble(&d_orient) ) { DisplayError(this, _("Bad value for footprints orientation")); @@ -318,6 +318,6 @@ void dialog_orient_footprints::OnCancelClick( wxCommandEvent& event ) void dialog_orient_footprints::OnCloseWindow( wxCloseEvent& event ) { - EndModal(1); + EndModal(1); } diff --git a/pcbnew/dialog_pad_properties.cpp b/pcbnew/dialog_pad_properties.cpp index 9078ec0a05..874472b879 100644 --- a/pcbnew/dialog_pad_properties.cpp +++ b/pcbnew/dialog_pad_properties.cpp @@ -145,7 +145,7 @@ void DialogPadProperties::InitDialog( wxInitDialogEvent& event ) if( m_CurrentPad ) { - MODULE* Module = (MODULE*) m_CurrentPad->m_Parent; + MODULE* Module = (MODULE*) m_CurrentPad->GetParent(); tmp = m_CurrentPad->m_Orient - Module->m_Orient; } else @@ -475,7 +475,7 @@ void DialogPadProperties::PadPropertiesAccept( wxCommandEvent& event ) if( m_CurrentPad ) // Set Pad Name & Num { m_Parent->SaveCopyInUndoList( m_Parent->m_Pcb->m_Modules ); - MODULE* Module = (MODULE*) m_CurrentPad->m_Parent; + MODULE* Module = (MODULE*) m_CurrentPad->GetParent(); Module->m_LastEdit_Time = time( NULL ); if( m_DC ) // redraw the area where the pad was, without pad (delete pad on screen) diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index dc0e317fb6..101245e6e9 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -67,8 +67,8 @@ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ) { px = pt_pad->m_Pos.x - g_Offset_Module.x; py = pt_pad->m_Pos.y - g_Offset_Module.y; - - Track->m_Start.x = px; + + Track->m_Start.x = px; Track->m_Start.y = py; } @@ -77,11 +77,11 @@ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ) { px = pt_pad->m_Pos.x - g_Offset_Module.x; py = pt_pad->m_Pos.y - g_Offset_Module.y; - - Track->m_End.x = px; + + Track->m_End.x = px; Track->m_End.y = py; } - + Track->Draw( panel, DC, GR_XOR ); } } @@ -102,7 +102,7 @@ void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module ) D_PAD* pt_pad; pt_pad = Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() ) { Build_1_Pad_SegmentsToDrag( panel, DC, pt_pad ); } @@ -133,16 +133,16 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad { if( Track->GetNet() != net_code ) break; /* hors zone */ - + if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ - + if( pos == Track->m_Start ) { AddSegmentToDragList( panel, DC, STARTPOINT, Track ); g_DragSegmentList->m_Pad_Start = PtPad; } - + if( pos == Track->m_End ) { AddSegmentToDragList( panel, DC, ENDPOINT, Track ); @@ -165,24 +165,24 @@ void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, pt_drag = new DRAG_SEGM( Track ); - pt_drag->Pnext = g_DragSegmentList; + pt_drag->Pnext = g_DragSegmentList; g_DragSegmentList = pt_drag; - + if( (flag & STARTPOINT) ) pt_drag->m_Flag |= 1; - + if( (flag & ENDPOINT) ) pt_drag->m_Flag |= 2; - + Track->Draw( panel, DC, GR_XOR ); Track->SetState( EDIT, ON ); - + if( (flag & STARTPOINT) ) Track->m_Flags |= STARTPOINT; - + if( (flag & ENDPOINT) ) Track->m_Flags |= ENDPOINT; - + Track->Draw( panel, DC, GR_XOR ); } @@ -203,18 +203,18 @@ void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, { if( Track->GetNet() != net_code ) break; /* hors zone */ - + if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ - + if( Track->m_Flags & IS_DRAGGED ) continue; // already in list - + if( Track->m_Start == point ) { AddSegmentToDragList( panel, DC, STARTPOINT, Track ); } - + if( Track->m_End == point ) { AddSegmentToDragList( panel, DC, ENDPOINT, Track ); @@ -241,7 +241,7 @@ void EraseDragListe() for( ; pt_drag != NULL; pt_drag = NextStruct ) { NextStruct = pt_drag->Pnext; - pt_drag->m_Segm->m_Flags = 0; + pt_drag->m_Segm->m_Flags = 0; delete pt_drag; } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 61fb6e15aa..435faa04e6 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -911,7 +911,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, /* No problem if pads are from the same footprint * and have the same pad number ( equivalent pads ) */ - if( (pad->m_Parent == aRefPad->m_Parent) && (pad->m_NumPadName == aRefPad->m_NumPadName) ) + if( (pad->GetParent() == aRefPad->GetParent()) && (pad->m_NumPadName == aRefPad->m_NumPadName) ) continue; if( !checkClearancePadToPad( aRefPad, pad, g_DesignSettings.m_TrackClearence ) ) diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index d79f8dbe51..033a1ecfe3 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -76,7 +76,7 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) DrawPanel->ForceCloseManageCurseur = NULL; SetCurItem( NULL ); GetScreen()->SetModify(); - MODULE* Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->GetParent(); Module->Set_Rectangle_Encadrement(); } @@ -92,7 +92,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) if( Edge == NULL ) return; - MODULE* Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->GetParent(); if( erase ) { @@ -121,7 +121,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) if( Edge == NULL ) return; - MODULE* Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->GetParent(); // if( erase ) { @@ -160,7 +160,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) if( Edge == NULL ) { Edge = (EDGE_MODULE*) Module->m_Drawings; - for( ; Edge != NULL; Edge = (EDGE_MODULE*) Edge->Pnext ) + for( ; Edge != NULL; Edge = Edge->Next() ) { if( Edge->Type() != TYPEEDGEMODULE ) continue; @@ -210,7 +210,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC ) if( Edge == NULL ) { Edge = (EDGE_MODULE*) Module->m_Drawings; - for( ; Edge != NULL; Edge = (EDGE_MODULE*) Edge->Pnext ) + for( ; Edge != NULL; Edge = Edge->Next() ) { if( Edge->Type() != TYPEEDGEMODULE ) continue; @@ -282,7 +282,7 @@ void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) return; } - MODULE* Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->GetParent(); Edge->Draw( DrawPanel, DC, GR_XOR ); /* suppression d'un segment */ @@ -305,7 +305,7 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) { if( Edge->m_Flags & IS_NEW ) /* effacement du nouveau contour */ { - MODULE* Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->GetParent(); Edge->Draw( Panel, DC, GR_XOR, MoveVector ); Edge ->DeleteStructure(); Module->Set_Rectangle_Encadrement(); @@ -348,10 +348,10 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, MoveVector.x = MoveVector.y = 0; /* Add the new item to the Drawings list head*/ - Edge->Pback = Module; - Edge->Pnext = Module->m_Drawings; + Edge->SetBack( Module ); + Edge->SetNext( Module->m_Drawings ); if( Module->m_Drawings ) - Module->m_Drawings->Pback = Edge; + Module->m_Drawings->SetBack( Edge ); Module->m_Drawings = Edge; /* Mise a jour des caracteristiques du segment ou de l'arc */ diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index a8e056b6b7..b57bbc96c1 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -34,8 +34,8 @@ int WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* DC, TRACK* pt_segm ) if( pt_segm->Type() == TYPEVIA ) { consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentViaSize; - if ( pt_segm->m_Shape == VIA_MICROVIA ) - consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentMicroViaSize; + if ( pt_segm->m_Shape == VIA_MICROVIA ) + consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentMicroViaSize; } if( old_w < consigne ) /* DRC utile puisque augm de dimension */ @@ -69,7 +69,7 @@ void WinEDA_PcbFrame::Edit_Track_Width( wxDC* DC, TRACK* pt_segm ) return; pt_track = Marque_Une_Piste( this, DC, pt_segm, &nb_segm, 0 ); - for( ii = 0; ii < nb_segm; ii++, pt_track = (TRACK*) pt_track->Pnext ) + for( ii = 0; ii < nb_segm; ii++, pt_track = pt_track->Next() ) { pt_track->SetState( BUSY, OFF ); errdrc = Edit_TrackSegm_Width( DC, pt_track ); @@ -97,7 +97,7 @@ void WinEDA_PcbFrame::Edit_Net_Width( wxDC* DC, int Netcode ) return; /* balayage des segments */ - for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( Netcode != pt_segm->GetNet() ) /* mauvaise piste */ continue; @@ -142,7 +142,7 @@ bool WinEDA_PcbFrame::Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via ) } pt_segm = m_Pcb->m_Track; - for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( pt_segm->Type() == TYPEVIA ) /* mise a jour du diametre de la via */ { diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 8d8b780147..07133b94dc 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -108,7 +108,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) /* effacement du segment en cours de trace */ DisplayOpt.DisplayDrawItems = SKETCH; Segment->Draw( DrawPanel, DC, GR_XOR ); - PtStruct = Segment->Pback; + PtStruct = Segment->Back(); Segment ->DeleteStructure(); if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) ) Segment = (DRAWSEGMENT*) PtStruct; @@ -270,10 +270,10 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, { if( Segment->m_Shape == S_SEGMENT ) { - Segment->Pnext = m_Pcb->m_Drawings; - Segment->Pback = m_Pcb; + Segment->SetNext( m_Pcb->m_Drawings ); + Segment->SetBack( m_Pcb ); if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = Segment; + m_Pcb->m_Drawings->SetBack( Segment ); m_Pcb->m_Drawings = Segment; GetScreen()->SetModify(); Segment->m_Flags = 0; @@ -320,10 +320,10 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) else { Segment->m_Flags = 0; - Segment->Pnext = m_Pcb->m_Drawings; - Segment->Pback = m_Pcb; + Segment->SetNext( m_Pcb->m_Drawings ); + Segment->SetBack( m_Pcb ); if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = Segment; + m_Pcb->m_Drawings->SetBack( Segment ); m_Pcb->m_Drawings = Segment; GetScreen()->SetModify(); } diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 853c2a53a3..8944d40651 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -89,14 +89,15 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod, wxDC* DC ) /* Mise a jour des coord relatives des pads */ pt_pad = (D_PAD*) pt_mod->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { - pt_pad->m_Pos0.x += deltaX; pt_pad->m_Pos0.y += deltaY; + pt_pad->m_Pos0.x += deltaX; + pt_pad->m_Pos0.y += deltaY; } /* Mise a jour des coord relatives contours .. */ PtStruct = pt_mod->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 4a12501244..9d40a25d76 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -105,14 +105,14 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) /* effacement du flag BUSY et sauvegarde en membre .param de la couche * initiale */ ii = nb_segm; pt_segm = pt_track; - for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Pnext ) + for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Next() ) { pt_segm->SetState( BUSY, OFF ); pt_segm->m_Param = pt_segm->GetLayer(); /* pour sauvegarde */ } ii = 0; pt_segm = pt_track; - for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) + for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() ) { if( pt_segm->Type() == TYPEVIA ) continue; @@ -127,7 +127,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) { /* Annulation du changement */ ii = 0; pt_segm = pt_track; - for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) + for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() ) { pt_segm->SetLayer( pt_segm->m_Param ); } @@ -141,7 +141,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL ); /* controle des extremites de segments: sont-ils sur un pad */ ii = 0; pt_segm = pt_track; - for( ; ii < nb_segm; pt_segm = (TRACK*) pt_segm->Pnext, ii++ ) + for( ; ii < nb_segm; pt_segm = (TRACK*) pt_segm->Next(), ii++ ) { pt_segm->start = Locate_Pad_Connecte( m_Pcb, pt_segm, START ); pt_segm->end = Locate_Pad_Connecte( m_Pcb, pt_segm, END ); @@ -179,7 +179,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) return false; pt_segm = g_FirstTrackSegment; - for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) + for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Next() ) { if( (pt_segm->Type() == TYPEVIA) && (g_CurrentTrackSegment->m_End == pt_segm->m_Start) ) @@ -274,8 +274,8 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) /* A new via was created. It was Ok. * Put it in linked list, after the g_CurrentTrackSegment */ - Via->Pback = g_CurrentTrackSegment; - g_CurrentTrackSegment->Pnext = Via; + Via->SetBack( g_CurrentTrackSegment ); + g_CurrentTrackSegment->SetNext( Via ); g_TrackSegmentCount++; /* The g_CurrentTrackSegment is now in linked list and we need a new track segment @@ -295,9 +295,9 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) g_TrackSegmentCount++; - g_CurrentTrackSegment->Pback = Via; + g_CurrentTrackSegment->SetBack( Via ); - Via->Pnext = g_CurrentTrackSegment; + Via->SetNext( g_CurrentTrackSegment ); if( g_TwoSegmentTrackBuild ) { @@ -307,8 +307,8 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) g_CurrentTrackSegment = track->Copy(); g_TrackSegmentCount++; - g_CurrentTrackSegment->Pback = track; - track->Pnext = g_CurrentTrackSegment; + g_CurrentTrackSegment->SetBack( track ); + track->SetNext( g_CurrentTrackSegment ); } DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); @@ -371,7 +371,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) if( item->Type() == TYPEPAD ) { pt_pad = (D_PAD*) item; - Module = (MODULE*) pt_pad->m_Parent; + Module = (MODULE*) pt_pad->GetParent(); } if( pt_pad ) /* Affichage du chevelu du net correspondant */ @@ -402,8 +402,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) { if( item->Type() == TYPETEXTEMODULE ) { - if( item->m_Parent && (item->m_Parent->Type() == TYPEMODULE) ) - Module = (MODULE*) item->m_Parent; + if( item->GetParent() && (item->GetParent()->Type() == TYPEMODULE) ) + Module = (MODULE*) item->GetParent(); } else if( item->Type() == TYPEMODULE ) { @@ -414,7 +414,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) { Module->Display_Infos( this ); pt_pad = Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() ) { pt_chevelu = (CHEVELU*) m_Pcb->m_Ratsnest; for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- ) diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index df0e37bab3..389c912899 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -57,7 +57,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) TRACK* previoustrack; for( ; track; track = previoustrack ) { - previoustrack = (TRACK*) track->Pback; + previoustrack = track->Back(); delete track; } } @@ -163,8 +163,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) // Create 2 segments g_CurrentTrackSegment = g_CurrentTrackSegment->Copy(); g_TrackSegmentCount++; - g_CurrentTrackSegment->Pback = g_FirstTrackSegment; - g_FirstTrackSegment->Pnext = g_CurrentTrackSegment; + g_CurrentTrackSegment->SetBack( g_FirstTrackSegment ); + g_FirstTrackSegment->SetNext( g_CurrentTrackSegment ); g_CurrentTrackSegment->start = g_FirstTrackSegment; g_FirstTrackSegment->end = g_CurrentTrackSegment; g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); @@ -271,7 +271,7 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ) if( g_TrackSegmentCount < 2 ) return 0; /* il faut au moins 2 segments */ - Previous = (TRACK*) pt_segm->Pback; // pointe le segment precedent + Previous = pt_segm->Back(); // pointe le segment precedent // Test s'il y a 2 segments consecutifs a raccorder if( (pt_segm->Type() != TYPETRACK ) @@ -413,10 +413,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) // cleanup - if( g_CurrentTrackSegment->Pnext != NULL ) + if( g_CurrentTrackSegment->Next() != NULL ) { - delete g_CurrentTrackSegment->Pnext; - g_CurrentTrackSegment->Pnext = NULL; + delete g_CurrentTrackSegment->Next(); + g_CurrentTrackSegment->SetNext( NULL ); } @@ -647,7 +647,7 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; if( g_TwoSegmentTrackBuild ) { - TRACK* previous_track = (TRACK*) g_CurrentTrackSegment->Pback; + TRACK* previous_track = g_CurrentTrackSegment->Back(); if( previous_track && (previous_track->Type() == TYPETRACK) ) { previous_track->SetLayer( screen->m_Active_Layer ); @@ -767,7 +767,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) return; TRACK* NewTrack = track; - track = (TRACK*) track->Pback; + track = track->Back(); SegmentCount--; if( track ) { @@ -778,7 +778,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) iDy = abs( iDy ); } - TRACK* LastTrack = track ? (TRACK*) track->Pback : NULL; + TRACK* LastTrack = track ? track->Back() : NULL; if( LastTrack ) { if( (LastTrack->m_End.x == LastTrack->m_Start.x) @@ -944,8 +944,8 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) /* Must create a new segment, from track end to pad center */ g_CurrentTrackSegment = lasttrack->Copy(); g_TrackSegmentCount++; - lasttrack->Pnext = g_CurrentTrackSegment; - g_CurrentTrackSegment->Pback = lasttrack; + lasttrack->SetNext( g_CurrentTrackSegment ); + g_CurrentTrackSegment->SetBack( lasttrack ); lasttrack->end = g_CurrentTrackSegment; } diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index c5063eea11..ae0c82ff7d 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -38,11 +38,11 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) Text = new TEXTE_MODULE( Module ); /* Chainage de la nouvelle structure en tete de liste drawings */ - Text->Pnext = Module->m_Drawings; - Text->Pback = Module; + Text->SetNext( Module->m_Drawings ); + Text->SetBack( Module ); if( Module->m_Drawings ) - Module->m_Drawings->Pback = Text; + Module->m_Drawings->SetBack( Text ); Module->m_Drawings = Text; Text->m_Flags = IS_NEW; @@ -72,7 +72,7 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) if( Text == NULL ) return; - MODULE* module = (MODULE*) Text->m_Parent; + MODULE* module = (MODULE*) Text->GetParent(); // we expect MoveVector to be (0,0) if there is no move in progress Text->Draw( DrawPanel, DC, GR_XOR, MoveVector ); @@ -104,7 +104,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text, wxDC* DC ) if( Text == NULL ) return; - Module = (MODULE*) Text->m_Parent; + Module = (MODULE*) Text->GetParent(); if( Text->m_Type == TEXT_is_DIVERS ) { @@ -138,7 +138,7 @@ static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ) if( Text == NULL ) return; - Module = (MODULE*) Text->m_Parent; + Module = (MODULE*) Text->GetParent(); Text->Draw( Panel, DC, GR_XOR, MoveVector ); @@ -168,7 +168,7 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) if( Text == NULL ) return; - Module = (MODULE*) Text->m_Parent; + Module = (MODULE*) Text->GetParent(); Text->m_Flags |= IS_MOVED; Module->m_Flags |= IN_EDIT; @@ -201,7 +201,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) Text->m_Pos = GetScreen()->m_Curseur; /* mise a jour des coordonnées relatives a l'ancre */ - MODULE* Module = (MODULE*) Text->m_Parent; + MODULE* Module = (MODULE*) Text->GetParent(); if( Module ) { int px = Text->m_Pos.x - Module->m_Pos.x; @@ -239,7 +239,7 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase if( Text == NULL ) return; - Module = (MODULE*) Text->m_Parent; + Module = (MODULE*) Text->GetParent(); /* effacement du texte : */ if( erase ) diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index ed386c2e0e..8bde0438e6 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -308,10 +308,10 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) fputs( "$SHAPES\n", file ); - for( module = pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext ) + for( module = pcb->m_Modules; module != NULL; module = module->Next() ) { ModuleWriteShape( file, module ); - for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { layer = "ALL"; if( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) @@ -368,7 +368,7 @@ void CreateComponentsSection( FILE* file, BOARD* pcb ) fputs( "$COMPONENTS\n", file ); - for( ; module != NULL; module = (MODULE*) module->Pnext ) + for( ; module != NULL; module = module->Next() ) { int orient = module->m_Orient; if( module->flag ) @@ -448,7 +448,7 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) fputs( "$SIGNALS\n", file ); - for( equipot = pcb->m_Equipots; equipot != NULL; equipot = (EQUIPOT*) equipot->Pnext ) + for( equipot = pcb->m_Equipots; equipot != NULL; equipot = equipot->Next() ) { if( equipot->m_Netname == wxEmptyString ) // dummy equipot (non connexion) { @@ -463,9 +463,9 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); - for( module = pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext ) + for( module = pcb->m_Modules; module != NULL; module = module->Next() ) { - for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { wxString padname; if( pad->GetNet() != equipot->GetNet() ) @@ -493,7 +493,7 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ) */ { wxString msg; - PCB_SCREEN* screen = (PCB_SCREEN*)(frame->GetScreen()); + PCB_SCREEN* screen = (PCB_SCREEN*)(frame->GetScreen()); fputs( "$HEADER\n", file ); fputs( "GENCAD 1.4\n", file ); @@ -559,10 +559,10 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) // Calcul du nombre de segments a ecrire nbitems = 0; - for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + for( track = pcb->m_Track; track != NULL; track = track->Next() ) nbitems++; - for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + for( track = pcb->m_Zone; track != NULL; track = track->Next() ) { if( track->Type() == TYPEZONE ) nbitems++; @@ -571,10 +571,10 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) tracklist = (TRACK**) MyMalloc( (nbitems + 1) * sizeof(TRACK *) ); nbitems = 0; - for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + for( track = pcb->m_Track; track != NULL; track = track->Next() ) tracklist[nbitems++] = track; - for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + for( track = pcb->m_Zone; track != NULL; track = track->Next() ) { if( track->Type() == TYPEZONE ) tracklist[nbitems++] = track; @@ -649,12 +649,12 @@ void CreateDevicesSection( FILE* file, BOARD* pcb ) fputs( "$DEVICES\n", file ); - for( module = pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext ) + for( module = pcb->m_Modules; module != NULL; module = module->Next() ) { fprintf( file, "DEVICE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); fprintf( file, "PART %s\n", CONV_TO_UTF8( module->m_LibRef ) ); fprintf( file, "TYPE %s\n", "UNKNOWN" ); - for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { fprintf( file, "PINDESCR %.4s", pad->m_Padname ); if( pad->m_Netname == wxEmptyString ) @@ -719,7 +719,7 @@ int* CreateTracksInfoData( FILE* file, BOARD* pcb ) trackinfo = (int*) adr_lowmem; *trackinfo = -1; - for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + for( track = pcb->m_Track; track != NULL; track = track->Next() ) { if( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee { @@ -741,7 +741,7 @@ int* CreateTracksInfoData( FILE* file, BOARD* pcb ) } } - for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + for( track = pcb->m_Zone; track != NULL; track = track->Next() ) { if( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee { @@ -812,7 +812,7 @@ void ModuleWriteShape( FILE* file, MODULE* module ) /* Generation des elements Drawing modules */ PtStruct = module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index fa407755c5..73c7c6464a 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -127,7 +127,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w /* Draw items on edge layer */ PtStruct = aPcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index fb99c2df5e..4ab6daafdd 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -447,7 +447,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) /* Write board Edges */ EDA_BaseStruct* PtStruct; - for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() != TYPEDRAWSEGMENT ) continue; diff --git a/pcbnew/gen_self.h b/pcbnew/gen_self.h index 7493536ca7..28725b9c70 100644 --- a/pcbnew/gen_self.h +++ b/pcbnew/gen_self.h @@ -290,18 +290,18 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) /* Generation des elements speciaux: drawsegments */ LastSegm = (EDGE_MODULE*) Module->m_Drawings; if( LastSegm ) - while( LastSegm->Pnext ) - LastSegm = (EDGE_MODULE*) LastSegm->Pnext; + while( LastSegm->Next() ) + LastSegm = (EDGE_MODULE*) LastSegm->Next(); FirstSegm = PtSegm = new EDGE_MODULE( Module ); if( LastSegm ) { - LastSegm->Pnext = PtSegm; - PtSegm->Pback = LastSegm; + LastSegm->SetNext( PtSegm ); + PtSegm->SetBack( LastSegm ); } else { - Module->m_Drawings = PtSegm; PtSegm->Pback = Module; + Module->m_Drawings = PtSegm; PtSegm->SetBack( Module ); } PtSegm->m_Start = Mself.m_Start; PtSegm->m_End.x = Mself.m_Start.x; @@ -404,13 +404,13 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) PtSegm = newedge; PtSegm->m_Start = PtSegm->m_End; PtSegm->m_End = Mself.m_End; - PtSegm->Pnext = NULL; + PtSegm->SetNext( NULL ); /* Rotation de la self si le trace doit etre horizontal : */ LastSegm = PtSegm; if( Mself.orient == 0 ) { - for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) + for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Next() ) { RotatePoint( &PtSegm->m_Start.x, &PtSegm->m_Start.y, FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); @@ -421,12 +421,15 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) } /* Modif position ancre */ - Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y; + Module->m_Pos.x = LastSegm->m_End.x; + Module->m_Pos.y = LastSegm->m_End.y; /* Placement des 2 pads sur extremite */ PtPad = new D_PAD( Module ); - Module->m_Pads = PtPad; PtPad->Pback = Module; + Module->m_Pads = PtPad; + PtPad->SetBack( Module ); + 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; @@ -462,7 +465,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) Module->m_Value->m_Pos0.y = Module->m_Value->m_Pos.y - Module->m_Pos.y; /* Init des Coord locales des segments */ - for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) + for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Next() ) { PtSegm->m_Start0.x = PtSegm->m_Start.x - Module->m_Pos.x; PtSegm->m_Start0.y = PtSegm->m_Start.y - Module->m_Pos.y; @@ -508,7 +511,7 @@ static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle ) { newedge = new EDGE_MODULE( (MODULE*) NULL ); newedge->Copy( PtSegm ); - newedge->m_Parent = PtSegm->m_Parent; + newedge->SetParent( PtSegm->GetParent() ); newedge->AddToChain( PtSegm ); PtSegm = newedge; PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y; diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 32449321ac..99a99d04ef 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -218,7 +218,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( aPad == NULL ) return; - Module = (MODULE*) aPad->m_Parent; + Module = (MODULE*) aPad->GetParent(); if( Module == NULL ) { @@ -246,7 +246,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) /* Mise a jour des modules ou du module */ Module = (MODULE*) m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { if( !Edit_Same_Modules ) if( Module != Module_Ref ) @@ -258,15 +258,15 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) Module->Display_Infos( this ); /* Effacement du module */ - if ( aDraw ) - { - Module->m_Flags |= DO_NOT_DRAW; - DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); - Module->m_Flags &= ~DO_NOT_DRAW; - } + if ( aDraw ) + { + Module->m_Flags |= DO_NOT_DRAW; + DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); + Module->m_Flags &= ~DO_NOT_DRAW; + } - D_PAD* pt_pad = (D_PAD*) Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + D_PAD* pt_pad = (D_PAD*) Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { /* Filtrage des modifications interdites */ if( Pad_Shape_Filter ) @@ -342,8 +342,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) } Module->Set_Rectangle_Encadrement(); - if ( aDraw ) - DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); + if ( aDraw ) + DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); } GetScreen()->SetModify(); diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 656830f2aa..4ab0556a2c 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -253,13 +253,13 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( LastModStruct == NULL ) { - DrawSegm->Pback = this; + DrawSegm->SetBack( this ); m_Drawings = DrawSegm; } else { - DrawSegm->Pback = LastModStruct; - LastModStruct->Pnext = DrawSegm; + DrawSegm->SetBack( LastModStruct ); + LastModStruct->SetNext( DrawSegm ); } int* list[5] = { &DrawSegm->m_Start0.x, &DrawSegm->m_Start0.y, @@ -290,13 +290,13 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( LastModStruct == NULL ) { - DrawSegm->Pback = this; + DrawSegm->SetBack( this ); m_Drawings = DrawSegm; } else { - DrawSegm->Pback = LastModStruct; - LastModStruct->Pnext = DrawSegm; + DrawSegm->SetBack( LastModStruct ); + LastModStruct->SetNext( DrawSegm ); } for( unsigned ii = 0; ii < 7; ii++ ) { @@ -379,13 +379,13 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( LastPad == NULL ) { - Pad->Pback = (EDA_BaseStruct*) this; + Pad->SetBack( (EDA_BaseStruct*) this ); m_Pads = Pad; } else { - Pad->Pback = (EDA_BaseStruct*) LastPad; - LastPad->Pnext = (EDA_BaseStruct*) Pad; + Pad->SetBack( (EDA_BaseStruct*) LastPad ); + LastPad->SetNext( (EDA_BaseStruct*) Pad ); } LastPad = Pad; continue; @@ -433,13 +433,13 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( LastPad == NULL ) { - Pad->Pback = (EDA_BaseStruct*) this; + Pad->SetBack( (EDA_BaseStruct*) this ); m_Pads = Pad; } else { - Pad->Pback = (EDA_BaseStruct*) LastPad; - LastPad->Pnext = (EDA_BaseStruct*) Pad; + Pad->SetBack( (EDA_BaseStruct*) LastPad ); + LastPad->SetNext( (EDA_BaseStruct*) Pad ); } LastPad = Pad; continue; diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index bfea5cff95..2b670b5193 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -252,7 +252,7 @@ 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 = (TRACK*) pt_segm->Pnext; + PtNext = pt_segm->Next(); if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type ) continue; diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 3e1a0edfa3..442bfc616b 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -607,11 +607,11 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) /* Write segment count for footprints, drawings, track and zones */ /* Calculate the footprint count */ - for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Next() ) NbModules++; PtStruct = m_Pcb->m_Drawings; NbDrawItem = 0; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) NbDrawItem++; fprintf( File, "Ndraw %d\n", NbDrawItem ); @@ -783,23 +783,23 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( Append ) { LastModule = m_Pcb->m_Modules; - for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Pnext ) + for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Next() ) { - if( LastModule->Pnext == NULL ) + if( LastModule->Next() == NULL ) break; } LastStructPcb = m_Pcb->m_Drawings; for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Next() ) { - if( LastStructPcb->Pnext == NULL ) + if( LastStructPcb->Next() == NULL ) break; } LastEquipot = m_Pcb->m_Equipots; - for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*) LastEquipot->Pnext ) + for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*) LastEquipot->Next() ) { - if( LastEquipot->Pnext == NULL ) + if( LastEquipot->Next() == NULL ) break; } } @@ -843,12 +843,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( LastEquipot == NULL ) { m_Pcb->m_Equipots = Equipot; - Equipot->Pback = m_Pcb; + Equipot->SetBack( m_Pcb ); } else { - Equipot->Pback = LastEquipot; - LastEquipot->Pnext = Equipot; + Equipot->SetBack( LastEquipot ); + LastEquipot->SetNext( Equipot ); } LastEquipot = Equipot; m_Pcb->m_NbNets++; @@ -873,12 +873,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( LastModule == NULL ) { m_Pcb->m_Modules = Module; - Module->Pback = m_Pcb; + Module->SetBack( m_Pcb ); } else { - Module->Pback = LastModule; - LastModule->Pnext = Module; + Module->SetBack( LastModule ); + LastModule->SetNext( Module ); } LastModule = Module; nbmod++; @@ -893,12 +893,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( LastStructPcb == NULL ) { m_Pcb->m_Drawings = StructPcb; - StructPcb->Pback = m_Pcb; + StructPcb->SetBack( m_Pcb ); } else { - StructPcb->Pback = LastStructPcb; - LastStructPcb->Pnext = StructPcb; + StructPcb->SetBack( LastStructPcb ); + LastStructPcb->SetNext( StructPcb ); } LastStructPcb = StructPcb; continue; @@ -911,12 +911,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( LastStructPcb == NULL ) { m_Pcb->m_Drawings = DrawSegm; - DrawSegm->Pback = m_Pcb; + DrawSegm->SetBack( m_Pcb ); } else { - DrawSegm->Pback = LastStructPcb; - LastStructPcb->Pnext = DrawSegm; + DrawSegm->SetBack( LastStructPcb ); + LastStructPcb->SetNext( DrawSegm ); } LastStructPcb = DrawSegm; continue; @@ -930,12 +930,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( LastStructPcb == NULL ) { m_Pcb->m_Drawings = Cotation; - Cotation->Pback = m_Pcb; + Cotation->SetBack( m_Pcb ); } else { - Cotation->Pback = LastStructPcb; - LastStructPcb->Pnext = Cotation; + Cotation->SetBack( LastStructPcb ); + LastStructPcb->SetNext( Cotation ); } LastStructPcb = Cotation; continue; @@ -949,12 +949,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( LastStructPcb == NULL ) { m_Pcb->m_Drawings = Mire; - Mire->Pback = m_Pcb; + Mire->SetBack( m_Pcb ); } else { - Mire->Pback = LastStructPcb; - LastStructPcb->Pnext = Mire; + Mire->SetBack( LastStructPcb ); + LastStructPcb->SetNext( Mire ); } LastStructPcb = Mire; continue; @@ -969,7 +969,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) { for( ; StartTrack != NULL; StartTrack = StartTrack->Next() ) { - if( StartTrack->Pnext == NULL ) + if( StartTrack->Next() == NULL ) break; } } @@ -990,7 +990,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) { for( ; StartZone != NULL; StartZone = StartZone->Next() ) { - if( StartZone->Pnext == NULL ) + if( StartZone->Next() == NULL ) break; } } diff --git a/pcbnew/lay2plot.cpp b/pcbnew/lay2plot.cpp index bc9081f6b0..472b27080e 100644 --- a/pcbnew/lay2plot.cpp +++ b/pcbnew/lay2plot.cpp @@ -76,7 +76,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl /* Draw the tracks */ pt_piste = Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) { if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; @@ -93,7 +93,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl } pt_piste = Pcb->m_Zone; - for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) { if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; @@ -103,7 +103,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl // Draw footprints, this is done at last in order to print the pad holes in while // after the tracks Module = (MODULE*) Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { Plot_Module( this, DC, Module, drawmode, printmasklayer ); } @@ -114,7 +114,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl int color = WHITE; bool blackpenstate = GetGRForceBlackPenState( ); GRForceBlackPen( FALSE ); - for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) { if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; @@ -161,21 +161,21 @@ static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC, /* Draw pads */ pt_pad = Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { if( (pt_pad->m_Masque_Layer & masklayer ) == 0 ) continue; - // Usually we draw pads in sketch mode on non copper layers: - if ( (masklayer & ALL_CU_LAYERS) == 0 ) - { - int tmp_fill = ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill; - // Switch in sketch mode - ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = 0; - pt_pad->Draw( panel, DC, draw_mode ); - ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = tmp_fill; - } - else // on copper layer, draw pads according to current options - pt_pad->Draw( panel, DC, draw_mode ); + // Usually we draw pads in sketch mode on non copper layers: + if ( (masklayer & ALL_CU_LAYERS) == 0 ) + { + int tmp_fill = ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill; + // Switch in sketch mode + ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = 0; + pt_pad->Draw( panel, DC, draw_mode ); + ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = tmp_fill; + } + else // on copper layer, draw pads according to current options + pt_pad->Draw( panel, DC, draw_mode ); } /* draw footprint graphic shapes */ diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 440f0caa45..ae315cec14 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -125,10 +125,10 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) /* Insert footprint in list*/ if( m_Pcb->m_Modules ) { - m_Pcb->m_Modules->Pback = module; + m_Pcb->m_Modules->SetBack( module ); } - module->Pnext = m_Pcb->m_Modules; - module->Pback = m_Pcb; + module->SetNext( m_Pcb->m_Modules ); + module->SetBack( m_Pcb ); m_Pcb->m_Modules = module; /* Display info : */ @@ -465,14 +465,14 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, /* Calcul du nombre de modules */ Module = (MODULE*) m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) NbModules++; Pas = (float) 100 / NbModules; DisplayActivity( 0, wxEmptyString ); Module = (MODULE*) m_Pcb->m_Modules; - for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Pnext ) + for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() ) { if( Save_1_Module( FullFileName, Module, NewModulesOnly ? FALSE : TRUE, FALSE ) == 0 ) @@ -734,11 +734,11 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n // Creates the new module and add it to the head of the linked list of modules Module = new MODULE( m_Pcb ); - Module->Pnext = m_Pcb->m_Modules; - Module->Pback = m_Pcb; + Module->SetNext( m_Pcb->m_Modules ); + Module->SetBack( m_Pcb ); if( m_Pcb->m_Modules ) { - m_Pcb->m_Modules->Pback = Module; + m_Pcb->m_Modules->SetBack( Module ); } m_Pcb->m_Modules = Module; diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 93afdf50c7..014a0af865 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -69,8 +69,10 @@ void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module ) NewModule->m_Link = Module->m_TimeStamp; Module = NewModule; - Module->m_Parent = m_Pcb; - Module->Pback = m_Pcb->m_Modules; Module->Pnext = NULL; + Module->SetParent( m_Pcb ); + Module->SetBack( m_Pcb->m_Modules ); + Module->SetNext( NULL ); + m_Pcb->m_Modules = Module; Module->m_Flags = 0; @@ -200,8 +202,8 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, /* Calcul de l'adresse du dernier module: */ Module = m_Pcb->m_Modules; if( Module ) - while( Module->Pnext ) - Module = (MODULE*) Module->Pnext; + while( Module->Next() ) + Module = (MODULE*) Module->Next(); for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) { @@ -274,12 +276,12 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, if( Module == NULL ) /* 1er Module */ { m_Pcb->m_Modules = NewModule; - NewModule->Pback = m_Pcb; + NewModule->SetBack( m_Pcb ); } else { - Module->Pnext = NewModule; - NewModule->Pback = Module; + Module->SetNext( NewModule ); + NewModule->SetBack( Module ); } fclose( lib_module ); Affiche_Message( wxEmptyString ); @@ -576,7 +578,7 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) /* Recherche des composants en BOARD */ ii = 0; Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) { ii++; ListBox->Append( Module->m_Reference->m_Text ); @@ -602,7 +604,7 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) // Recherche du pointeur sur le module Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) { if( CmpName.CmpNoCase( Module->m_Reference->m_Text ) == 0 ) break; diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index 1a2bccfa35..0bd5698c7b 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -239,7 +239,7 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) ref_pos = RefPos( typeloc ); pt_module = Pcb->m_Modules; - for( ; pt_module; pt_module = (MODULE*) pt_module->Pnext ) + for( ; pt_module; pt_module = (MODULE*) pt_module->Next() ) { // is the ref point within the module's bounds? if( !pt_module->HitTest( ref_pos ) ) @@ -400,7 +400,7 @@ suite: if( PtSegmN == pt_lim ) PtSegmN = NULL; else - PtSegmN = (TRACK*) PtSegmN->Pnext; + PtSegmN = PtSegmN->Next(); } if( PtSegmB ) @@ -427,14 +427,14 @@ suite1: if( PtSegmB == pt_base ) PtSegmB = NULL; else if( PtSegmB->Type() != TYPEPCB ) - PtSegmB = (TRACK*) PtSegmB->Pback; + PtSegmB = PtSegmB->Back(); else PtSegmB = NULL; } } /* Recherche generale */ - for( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = (TRACK*) PtSegmN->Pnext ) + for( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = PtSegmN->Next() ) { if( PtSegmN->GetState( DELETED | BUSY ) ) { @@ -495,7 +495,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc ) TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer ) { - for( TRACK* Track = start_adresse; Track; Track = (TRACK*) Track->Pnext ) + for( TRACK* Track = start_adresse; Track; Track = Track->Next() ) { if( Track->GetState( BUSY | DELETED ) ) continue; @@ -549,7 +549,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ) { - for( TRACK* Zone = start_adresse; Zone; Zone = (TRACK*) Zone->Pnext ) + for( TRACK* Zone = start_adresse; Zone; Zone = Zone->Next() ) { if( (layer != -1) && (Zone->GetLayer() != layer) ) continue; @@ -615,7 +615,7 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, if( start_adr == NULL ) return NULL; - for( PtSegm = start_adr; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext ) + for( PtSegm = start_adr; PtSegm != NULL; PtSegm = PtSegm->Next() ) { if( PtSegm->GetState( DELETED | BUSY ) == 0 ) { @@ -655,7 +655,7 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, { TRACK* PtSegm; - for( PtSegm = start_adr; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext ) + for( PtSegm = start_adr; PtSegm != NULL; PtSegm = PtSegm->Next() ) { if( PtSegm->Type() == TYPEVIA ) { diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 0693eb81fe..9c42e7ba3e 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -208,10 +208,11 @@ MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC ) { MIREPCB* MirePcb = new MIREPCB( m_Pcb ); - MirePcb->Pnext = m_Pcb->m_Drawings; - MirePcb->Pback = m_Pcb; + MirePcb->SetNext( m_Pcb->m_Drawings ); + MirePcb->SetBack( m_Pcb ); + if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = MirePcb; + m_Pcb->m_Drawings->SetBack( MirePcb ); m_Pcb->m_Drawings = MirePcb; MirePcb->SetLayer( EDGE_N ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 196937e762..53e1171acb 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -257,7 +257,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) if( module_in_edit->m_Link ) // this is not a new module ... { source_module = mainpcb->m_Modules; - for( ; source_module != NULL; source_module = (MODULE*) source_module->Pnext ) + for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() ) { if( module_in_edit->m_Link == source_module->m_TimeStamp ) break; @@ -284,15 +284,15 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) // Create the "new" module MODULE* newmodule = new MODULE( mainpcb ); newmodule->Copy( module_in_edit ); - newmodule->m_Parent = mainpcb; // modifie par la copie + newmodule->SetParent( mainpcb ); // modifie par la copie newmodule->m_Link = 0; // Put the footprint in the main pcb linked list. - newmodule->Pnext = mainpcb->m_Modules; + newmodule->SetNext( mainpcb->m_Modules ); mainpcb->m_Modules = newmodule; - newmodule->Pback = mainpcb; - if( newmodule->Pnext ) - newmodule->Pnext->Pback = newmodule; + newmodule->SetBack( mainpcb ); + if( newmodule->Next() ) + newmodule->Next()->SetBack( newmodule ); if( source_module ) // this is an update command { @@ -672,7 +672,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform case ID_MODEDIT_MODULE_ROTATE: module->SetOrientation( angle ); - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( ; pad != NULL; pad = (D_PAD*) pad->Next() ) { pad->m_Pos0 = pad->m_Pos; pad->m_Orient -= angle; @@ -691,7 +691,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform module->m_Value->m_Orient -= 1800; /* Rectification des contours et textes de l'empreinte : */ - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() == TYPEEDGEMODULE ) { @@ -711,7 +711,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform break; case ID_MODEDIT_MODULE_MIRROR: - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( ; pad != NULL; pad = (D_PAD*) pad->Next() ) { pad->m_Pos.y = -pad->m_Pos.y; pad->m_Pos0.y = -pad->m_Pos0.y; @@ -737,7 +737,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform /* Inversion miroir des dessins de l'empreinte : */ PtStruct = module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index ef46980e6e..835b7dbcfe 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -22,17 +22,17 @@ void WinEDA_ModuleEditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, CopyItem = new MODULE( m_Pcb ); CopyItem->Copy( (MODULE*) ItemToCopy ); - CopyItem->m_Parent = m_Pcb; + CopyItem->SetParent( m_Pcb ); GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CopyItem ); /* Clear current flags (which can be temporary set by a current edit command) */ - for( item = CopyItem->m_Drawings; item != NULL; item = item->Pnext ) + for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) item->m_Flags = 0; /* Clear redo list, because after new save there is no redo to do */ while( GetScreen()->m_RedoList ) { - item = GetScreen()->m_RedoList->Pnext; + item = GetScreen()->m_RedoList->Next(); delete GetScreen()->m_RedoList; GetScreen()->m_RedoList = item; } @@ -55,7 +55,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList() m_Pcb->m_Modules = (MODULE*) GetScreen()->GetItemFromRedoList(); if( m_Pcb->m_Modules ) - m_Pcb->m_Modules->Pnext = NULL; + m_Pcb->m_Modules->SetNext( NULL ); SetCurItem( NULL );; GetScreen()->SetModify(); ReCreateHToolbar(); @@ -80,7 +80,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList() (MODULE*) GetScreen()->GetItemFromUndoList(); if( m_Pcb->m_Modules ) - m_Pcb->m_Modules->Pnext = NULL; + m_Pcb->m_Modules->SetNext( NULL ); GetScreen()->SetModify(); SetCurItem( NULL );; ReCreateHToolbar(); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index e236c0c3e8..a0ec6fa8c7 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -228,7 +228,7 @@ void WinEDA_ModuleEditFrame::SetToolbars() MODULE* source_module = mainpcb->m_Modules; // search if the source module was not deleted: - for( ; source_module != NULL; source_module = (MODULE*) source_module->Pnext ) + for( ; source_module != NULL; source_module = source_module->Next() ) { if( module_in_edit->m_Link == source_module->m_TimeStamp ) break; diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 2cab7fd8d8..2d3ec648d4 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -45,7 +45,7 @@ void Show_Pads_On_Off( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module ) pad_fill_tmp = DisplayOpt.DisplayPadFill; DisplayOpt.DisplayPadFill = FALSE; /* Trace en SKETCH */ pt_pad = module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { pt_pad->Draw( panel, DC, GR_XOR, g_Offset_Module ); } @@ -239,7 +239,7 @@ MODULE* WinEDA_BasePcbFrame::Copie_Module( MODULE* module ) m_Pcb->m_Status_Pcb = 0; newmodule = new MODULE( m_Pcb ); newmodule->Copy( module ); - newmodule->m_Parent = m_Pcb; + newmodule->SetParent( m_Pcb ); newmodule->AddToChain( module ); newmodule->m_Flags = IS_NEW; @@ -320,18 +320,18 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDe DrawGeneralRatsnest( DC ); /* Suppression du chainage */ - PtBack = module->Pback; - PtNext = module->Pnext; + PtBack = module->Back(); + PtNext = module->Next(); if( PtBack == (EDA_BaseStruct*) m_Pcb ) { m_Pcb->m_Modules = (MODULE*) PtNext; } else { - PtBack->Pnext = PtNext; + PtBack->SetNext( PtNext ); } if( PtNext ) - PtNext->Pback = PtBack; + PtNext->SetBack( PtBack ); /* Sauvegarde en buffer des undelete */ SaveItemEfface( module, 1 ); @@ -411,7 +411,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) /* Inversion miroir + layers des pastilles */ pt_pad = Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { pt_pad->m_Pos.y -= Module->m_Pos.y; pt_pad->m_Pos.y = -pt_pad->m_Pos.y; @@ -469,7 +469,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) /* Inversion miroir des dessins de l'empreinte : */ PtStruct = Module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -805,7 +805,7 @@ void DrawModuleOutlines( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module ) DisplayOpt.DisplayPadFill = SKETCH; /* Trace en SKETCH en deplacement */ pt_pad = module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { pt_pad->Draw( panel, DC, GR_XOR, g_Offset_Module ); } diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index 668a27ea78..fc4c0abccb 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -112,7 +112,7 @@ void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD* pt_pad ) if( pt_pad == NULL ) return; - Module = (MODULE*) pt_pad->m_Parent; + Module = (MODULE*) pt_pad->GetParent(); pt_pad->Display_Infos( this ); @@ -120,7 +120,7 @@ void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD* pt_pad ) g_Pad_Master.m_Attribut = pt_pad->m_Attribut; g_Pad_Master.m_Masque_Layer = pt_pad->m_Masque_Layer; g_Pad_Master.m_Orient = pt_pad->m_Orient - - ( (MODULE*) pt_pad->m_Parent )->m_Orient; + ( (MODULE*) pt_pad->GetParent() )->m_Orient; g_Pad_Master.m_Size = pt_pad->m_Size; g_Pad_Master.m_DeltaSize = pt_pad->m_DeltaSize; pt_pad->ComputeRayon(); @@ -142,17 +142,17 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) */ { if( aDraw ) - { - aPad->m_Flags |= DO_NOT_DRAW; - DrawPanel->PostDirtyRect( aPad->GetBoundingBox() ); - aPad->m_Flags &= ~DO_NOT_DRAW; - } + { + aPad->m_Flags |= DO_NOT_DRAW; + DrawPanel->PostDirtyRect( aPad->GetBoundingBox() ); + aPad->m_Flags &= ~DO_NOT_DRAW; + } aPad->m_PadShape = g_Pad_Master.m_PadShape; aPad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer; aPad->m_Attribut = g_Pad_Master.m_Attribut; aPad->m_Orient = g_Pad_Master.m_Orient + - ( (MODULE*) aPad->m_Parent )->m_Orient; + ( (MODULE*) aPad->GetParent() )->m_Orient; aPad->m_Size = g_Pad_Master.m_Size; aPad->m_DeltaSize = wxSize( 0, 0 ); aPad->m_Offset = g_Pad_Master.m_Offset; @@ -183,8 +183,8 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) aPad->ComputeRayon(); if( aDraw ) - DrawPanel->PostDirtyRect( aPad->GetBoundingBox() ); - ( (MODULE*) aPad->m_Parent )->m_LastEdit_Time = time( NULL ); + DrawPanel->PostDirtyRect( aPad->GetBoundingBox() ); + ( (MODULE*) aPad->GetParent() )->m_LastEdit_Time = time( NULL ); } @@ -206,19 +206,19 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) if( ptliste == NULL ) /* 1er pad */ { Module->m_Pads = Pad; - Pad->Pback = (EDA_BaseStruct*) Module; + Pad->SetBack( Module ); } else { while( ptliste ) { - if( ptliste->Pnext == NULL ) + if( ptliste->Next() == NULL ) break; - ptliste = (D_PAD*) ptliste->Pnext; + ptliste = (D_PAD*) ptliste->Next(); } - Pad->Pback = (EDA_BaseStruct*) ptliste; - ptliste->Pnext = (EDA_BaseStruct*) Pad; + Pad->SetBack( ptliste ); + ptliste->SetNext( Pad ); } /* Mise a jour des caract de la pastille : */ @@ -253,7 +253,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) Module->Set_Rectangle_Encadrement(); Pad->Display_Infos( this ); if ( draw ) - DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); + DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); } @@ -268,7 +268,7 @@ void WinEDA_BasePcbFrame::DeletePad( D_PAD* Pad, wxDC* DC ) if( Pad == NULL ) return; - Module = (MODULE*) Pad->m_Parent; + Module = (MODULE*) Pad->GetParent(); Module->m_LastEdit_Time = time( NULL ); line.Printf( _( "Delete Pad (module %s %s) " ), @@ -298,7 +298,7 @@ void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC ) if( Pad == NULL ) return; - Module = (MODULE*) Pad->m_Parent; + Module = (MODULE*) Pad->GetParent(); s_CurrentSelectedPad = Pad; Pad_OldPos = Pad->m_Pos; @@ -332,7 +332,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) if( Pad == NULL ) return; - Module = (MODULE*) Pad->m_Parent; + Module = (MODULE*) Pad->GetParent(); /* Placement du pad */ Pad->Draw( DrawPanel, DC, GR_XOR ); @@ -387,7 +387,7 @@ void WinEDA_BasePcbFrame::RotatePad( D_PAD* Pad, wxDC* DC ) if( Pad == NULL ) return; - Module = (MODULE*) Pad->m_Parent; + Module = (MODULE*) Pad->GetParent(); Module->m_LastEdit_Time = time( NULL ); GetScreen()->SetModify(); diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index b9abef6a32..5114474f85 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -67,7 +67,7 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) { if( NewTrack == NULL ) break; - NextS = (TRACK*) NewTrack->Pnext; + NextS = (TRACK*) NewTrack->Next(); delete NewTrack; } } @@ -76,7 +76,7 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) TRACK* Track = NewTrack; int dx = s_LastPos.x - PosInit.x; int dy = s_LastPos.y - PosInit.y; - for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext ) + for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Next() ) { if( Track == NULL ) break; @@ -95,7 +95,7 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - ((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem(NULL); + ((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem(NULL); /* Annulation deplacement et Redessin des segments dragges */ DRAG_SEGM* pt_drag = g_DragSegmentList; @@ -234,8 +234,8 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, if( TrackSegWrapper == NULL ) return; - - Track = TrackSegWrapper->m_Segm; + + Track = TrackSegWrapper->m_Segm; if( Track == NULL ) return; @@ -262,7 +262,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, Track->Draw( panel, DC, draw_mode ); if( tSegmentToStart ) tSegmentToStart->Draw( panel, DC, draw_mode ); - + if( tSegmentToEnd ) tSegmentToEnd->Draw( panel, DC, draw_mode ); } @@ -389,12 +389,12 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, // update the segment coordinates (if possible) if( tSegmentToStart == NULL ) { - xi1 = tx1; + xi1 = tx1; yi1 = ty1; } if( tSegmentToEnd == NULL ) { - xi2 = tx2; + xi2 = tx2; yi2 = ty2; } @@ -464,8 +464,8 @@ bool InitialiseDragParameters() tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point } } - //would be nice to eliminate collinear segments here, so we don't - //have to deal with that annoying "Unable to drag this segment: two collinear segments" + //would be nice to eliminate collinear segments here, so we don't + //have to deal with that annoying "Unable to drag this segment: two collinear segments" s_StartPointVertical = false; s_EndPointVertical = false; @@ -674,64 +674,64 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co } void SortTrackEndPoints(TRACK* track) { - //sort the track endpoints -- should not matter in terms of drawing - //or producing the pcb -- but makes doing comparisons easier. - wxPoint tmp; - int dx = track->m_End.x - track->m_Start.x; - if(dx){ - if( track->m_Start.x > track->m_End.x ){ - tmp = track->m_Start; - track->m_Start = track->m_End; - track->m_End = tmp; - } - }else{ - if( track->m_Start.y > track->m_End.y ){ - tmp = track->m_Start; - track->m_Start = track->m_End; - track->m_End = tmp; - } - } + //sort the track endpoints -- should not matter in terms of drawing + //or producing the pcb -- but makes doing comparisons easier. + wxPoint tmp; + int dx = track->m_End.x - track->m_Start.x; + if(dx){ + if( track->m_Start.x > track->m_End.x ){ + tmp = track->m_Start; + track->m_Start = track->m_End; + track->m_End = tmp; + } + }else{ + if( track->m_Start.y > track->m_End.y ){ + tmp = track->m_Start; + track->m_Start = track->m_End; + track->m_End = tmp; + } + } } /***********************************************************************************/ bool WinEDA_PcbFrame::MergeCollinearTracks( TRACK* track, wxDC* DC, int end ) /***********************************************************************************/ { - TRACK* testtrack = NULL; - - testtrack = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, end ); - if( testtrack ) - { - SortTrackEndPoints(track); - SortTrackEndPoints(testtrack); - int dx = track->m_End.x - track->m_Start.x; - int dy = track->m_End.y - track->m_Start.y; - int tdx = testtrack->m_End.x - testtrack->m_Start.x; - int tdy = testtrack->m_End.y - testtrack->m_Start.y; - - if( (dy * tdx == dx * tdy && dy != 0 && dx != 0 && tdy != 0 && tdx != 0) /*angle, same slope*/ - || (dy == 0 && tdy == 0 && dx*tdx )/*horizontal*/ - || (dx == 0 && tdx == 0 && dy*tdy )/*vertical*/ ) { - if(track->m_Start == testtrack->m_Start || track->m_End == testtrack->m_Start){ - if( ( dx*tdx && testtrack->m_End.x > track->m_End.x ) - ||( dy*tdy && testtrack->m_End.y > track->m_End.y )){ - track->m_End = testtrack->m_End; - - Delete_Segment( DC, testtrack ); - return true; - } - } - if(track->m_Start == testtrack->m_End || track->m_End == testtrack->m_End){ - if( ( dx*tdx && testtrack->m_Start.x < track->m_Start.x ) - ||( dy*tdy && testtrack->m_Start.y < track->m_Start.y )){ - track->m_Start = testtrack->m_Start; - - Delete_Segment( DC, testtrack ); - return true; - } - } - } - } - return false; + TRACK* testtrack = NULL; + + testtrack = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, end ); + if( testtrack ) + { + SortTrackEndPoints(track); + SortTrackEndPoints(testtrack); + int dx = track->m_End.x - track->m_Start.x; + int dy = track->m_End.y - track->m_Start.y; + int tdx = testtrack->m_End.x - testtrack->m_Start.x; + int tdy = testtrack->m_End.y - testtrack->m_Start.y; + + if( (dy * tdx == dx * tdy && dy != 0 && dx != 0 && tdy != 0 && tdx != 0) /*angle, same slope*/ + || (dy == 0 && tdy == 0 && dx*tdx )/*horizontal*/ + || (dx == 0 && tdx == 0 && dy*tdy )/*vertical*/ ) { + if(track->m_Start == testtrack->m_Start || track->m_End == testtrack->m_Start){ + if( ( dx*tdx && testtrack->m_End.x > track->m_End.x ) + ||( dy*tdy && testtrack->m_End.y > track->m_End.y )){ + track->m_End = testtrack->m_End; + + Delete_Segment( DC, testtrack ); + return true; + } + } + if(track->m_Start == testtrack->m_End || track->m_End == testtrack->m_End){ + if( ( dx*tdx && testtrack->m_Start.x < track->m_Start.x ) + ||( dy*tdy && testtrack->m_Start.y < track->m_Start.y )){ + track->m_Start = testtrack->m_Start; + + Delete_Segment( DC, testtrack ); + return true; + } + } + } + } + return false; } /***********************************************************************************/ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ) @@ -743,9 +743,9 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC if( !track ) return; - - while(MergeCollinearTracks(track, DC, START)){}; - while(MergeCollinearTracks(track, DC, END)){}; + + while(MergeCollinearTracks(track, DC, START)){}; + while(MergeCollinearTracks(track, DC, END)){}; s_StartSegmentPresent = s_EndSegmentPresent = TRUE; @@ -805,7 +805,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint ); track->m_Flags |= STARTPOINT; } - + if( TrackToEndPoint ) { int flag = STARTPOINT; @@ -924,7 +924,7 @@ EDA_BaseStruct* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask ) /* detection du point type PAD */ pt_pad = NULL; Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) { pt_pad = Locate_Pads( Module, pos, LayerMask ); if( pt_pad ) diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index e5b0a23347..b3e95de1cf 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -64,15 +64,15 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( wxDC* DC, { D_PAD* pad; pad = new D_PAD( Module ); - pad->Pback = Module; + pad->SetBack( Module ); if( Module->m_Pads == NULL ) { Module->m_Pads = pad; } else { - Module->m_Pads->Pback = pad; - pad->Pnext = Module->m_Pads; + Module->m_Pads->SetBack( pad ); + pad->SetNext( Module->m_Pads ); Module->m_Pads = pad; } pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; @@ -222,14 +222,14 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( wxDC* DC, int shape_type ) oX = pt_pad->m_Pos0.x = -(gap_size + pt_pad->m_Size.x) / 2; pt_pad->m_Pos.x += pt_pad->m_Pos0.x; - pt_pad = (D_PAD*) pt_pad->Pnext; + pt_pad = (D_PAD*) pt_pad->Next(); pt_pad->m_Pos0.x = oX + gap_size + pt_pad->m_Size.x; pt_pad->m_Pos.x += pt_pad->m_Pos0.x; break; case 1: //Stub : pt_pad->SetPadName( wxT( "1" ) ); - pt_pad = (D_PAD*) pt_pad->Pnext; + pt_pad = (D_PAD*) pt_pad->Next(); pt_pad->m_Pos0.y = -(gap_size + pt_pad->m_Size.y) / 2; pt_pad->m_Size.y = gap_size; pt_pad->m_Pos.y += pt_pad->m_Pos0.y; @@ -241,7 +241,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( wxDC* DC, int shape_type ) ii = angle / 50; edge = new EDGE_MODULE( Module ); Module->m_Drawings = edge; - edge->Pback = Module; + edge->SetBack( Module ); edge->m_Shape = S_POLYGON; edge->SetLayer( LAYER_CMP_N ); edge->m_PolyCount = ii + 3; @@ -562,13 +562,13 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( wxDC* DC ) pad1->m_Pos0.x = -ShapeSize.x / 2; pad1->m_Pos.x += pad1->m_Pos0.x; - pad2 = (D_PAD*) pad1->Pnext; + pad2 = (D_PAD*) pad1->Next(); pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x; pad2->m_Pos.x += pad2->m_Pos0.x; edge = new EDGE_MODULE( Module ); Module->m_Drawings = edge; - edge->Pback = Module; + edge->SetBack( Module ); edge->m_Shape = S_POLYGON; edge->SetLayer( LAYER_CMP_N ); npoints = PolyEdgesCount; @@ -678,7 +678,7 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module ) { DisplayError( this, _( "No pad for this module" ) ); return; } - next_pad = (D_PAD*) pad->Pnext; + next_pad = (D_PAD*) pad->Next(); if( next_pad == NULL ) { DisplayError( this, _( "Only one pad for this module" ) ); return; diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index d05b0502fe..e135faa344 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -45,7 +45,7 @@ public: int timestamp, const wxString& path ); ~MODULEtoLOAD() { }; - MODULEtoLOAD* Next() { return (MODULEtoLOAD*) Pnext; } + MODULEtoLOAD* Next() const { return (MODULEtoLOAD*) Pnext; } }; /* Fonctions locales : */ @@ -293,7 +293,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame, else /* Raz netnames sur pads */ { PtPad = Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Next() ) { PtPad->m_Netname = wxEmptyString; } @@ -590,7 +590,7 @@ int SetPadNetName( wxWindow* frame, char* Text, MODULE* Module ) /* recherche du pad */ pad = Module->m_Pads; trouve = FALSE; - for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + for( ; pad != NULL; pad = (D_PAD*) pad->Next() ) { if( strnicmp( TextPinName, pad->m_Padname, 4 ) == 0 ) { /* trouve */ @@ -637,12 +637,12 @@ MODULE* WinEDA_PcbFrame::ListAndSelectModuleName( void ) /* Calcul du nombre des modules */ nb_empr = 0; Module = (MODULE*) m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) nb_empr++; ListNames = (const wxChar**) MyZMalloc( (nb_empr + 1) * sizeof(wxChar*) ); Module = (MODULE*) m_Pcb->m_Modules; - for( ii = 0; Module != NULL; Module = (MODULE*) Module->Pnext, ii++ ) + for( ii = 0; Module != NULL; Module = (MODULE*) Module->Next(), ii++ ) { ListNames[ii] = Module->m_Reference->m_Text.GetData(); } @@ -659,7 +659,7 @@ MODULE* WinEDA_PcbFrame::ListAndSelectModuleName( void ) else /* Recherche du module selectionne */ { Module = (MODULE*) m_Pcb->m_Modules; - for( jj = 0; Module != NULL; Module = (MODULE*) Module->Pnext, jj++ ) + for( jj = 0; Module != NULL; Module = (MODULE*) Module->Next(), jj++ ) { if( Module->m_Reference->m_Text.Cmp( ListNames[ii] ) == 0 ) break; @@ -984,7 +984,7 @@ void AddToList( const wxString& NameLibCmp, const wxString& CmpName, MODULEtoLOAD* NewMod; NewMod = new MODULEtoLOAD( NameLibCmp, CmpName, TimeStamp, path ); - NewMod->Pnext = s_ModuleToLoad_List; + NewMod->SetNext( s_ModuleToLoad_List ); s_ModuleToLoad_List = NewMod; s_NbNewModules++; } @@ -1101,12 +1101,12 @@ void SortListModulesToLoadByLibname( int NbModules ) for( ii = 0; ii < NbModules - 1; ii++ ) { item = base_list[ii]; - item->Pnext = base_list[ii + 1]; + item->SetNext( base_list[ii + 1] ); } // Dernier item: Pnext = NULL: item = base_list[ii]; - item->Pnext = NULL; + item->SetNext( NULL ); free( base_list ); } diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp index 1a19078b55..3824493b8b 100644 --- a/pcbnew/pcbtexte.cpp +++ b/pcbnew/pcbtexte.cpp @@ -361,10 +361,10 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) TextePcb = new TEXTE_PCB( m_Pcb ); /* Chainage de la nouvelle structure en debut de liste */ - TextePcb->Pnext = m_Pcb->m_Drawings; - TextePcb->Pback = (EDA_BaseStruct*) m_Pcb; + TextePcb->SetNext( m_Pcb->m_Drawings ); + TextePcb->SetBack( m_Pcb ); if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; + m_Pcb->m_Drawings->SetBack( TextePcb ); m_Pcb->m_Drawings = TextePcb; /* Mise a jour des caracteristiques */ diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 805a2eae36..d60d244492 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -40,7 +40,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, /* Trace du contour du PCB et des Elements du type Drawings Pcb */ PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -81,7 +81,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, for( MODULE* Module = m_Pcb->m_Modules; Module; Module = Module->Next() ) { pt_pad = (D_PAD*) Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { /* Tst si layer OK */ if( (pt_pad->m_Masque_Layer & masque_layer) == 0 ) @@ -262,7 +262,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, } pt_texte = (TEXTE_MODULE*) Module->m_Drawings; - for( ; pt_texte != NULL; pt_texte = (TEXTE_MODULE*) pt_texte->Pnext ) + for( ; pt_texte != NULL; pt_texte = pt_texte->Next() ) { if( pt_texte->Type() != TYPETEXTEMODULE ) continue; @@ -445,10 +445,10 @@ void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer ) nb_items = 0; Module = pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { PtEdge = (EDGE_MODULE*) Module->m_Drawings; - for( ; PtEdge != NULL; PtEdge = (EDGE_MODULE*) PtEdge->Pnext ) + for( ; PtEdge != NULL; PtEdge = PtEdge->Next() ) { if( PtEdge->Type() != TYPEEDGEMODULE ) continue; @@ -527,8 +527,8 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) // which are relative to module position, orientation 0 int ii, * source, * ptr, * ptr_base; MODULE* Module = NULL; - if( PtEdge->m_Parent && (PtEdge->m_Parent->Type() == TYPEMODULE) ) - Module = (MODULE*) PtEdge->m_Parent; + if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPEMODULE) ) + Module = (MODULE*) PtEdge->GetParent(); ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) ); source = PtEdge->m_PolyList; for( ii = 0; ii < PtEdge->m_PolyCount; ii++ ) @@ -625,13 +625,13 @@ void Plot_1_texte( int format_plot, const wxString& Text, int angle, for( ; kk < nbcodes; kk++ ) { #if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC) - int code = Text.GetChar(kk) & 0x7FF; - if ( code > 0x40F && code < 0x450 ) // big small Cyr - code = utf8_to_ascii[code - 0x410] & 0xFF; + int code = Text.GetChar(kk) & 0x7FF; + if ( code > 0x40F && code < 0x450 ) // big small Cyr + code = utf8_to_ascii[code - 0x410] & 0xFF; else - code = code & 0xFF; + code = code & 0xFF; #else - int code = Text.GetChar( kk ) & 0xFF; + int code = Text.GetChar( kk ) & 0xFF; #endif ptcar = graphic_fonte_shape[code]; /* ptcar pointe la description * du caractere a dessiner */ diff --git a/pcbnew/plotgerb.cpp b/pcbnew/plotgerb.cpp index a082d1a919..b5f1166f74 100644 --- a/pcbnew/plotgerb.cpp +++ b/pcbnew/plotgerb.cpp @@ -162,7 +162,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, /* Draw items type Drawings Pcb : */ PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -199,10 +199,10 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 38, wxT( "DrawMod" ), wxEmptyString, GREEN ); Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) { PtStruct = Module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { @@ -221,10 +221,10 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 48, wxT( "Pads" ), wxEmptyString, GREEN ); Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = (MODULE*) Module->Next() ) { PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Next() ) { wxPoint shape_pos; if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) @@ -280,7 +280,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, { nb_items = 0; Affiche_1_Parametre( this, 56, wxT( "Vias" ), wxEmptyString, RED ); - for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Next() ) { if( track->Type() != TYPEVIA ) continue; @@ -312,7 +312,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "Tracks" ), wxEmptyString, YELLOW ); - for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Next() ) { wxPoint end; @@ -337,7 +337,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, if( m_Pcb->m_Zone ) Affiche_1_Parametre( this, 72, wxT( "Zones " ), wxEmptyString, YELLOW ); - for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Next() ) { wxPoint end; diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index f5d1f0d8c3..1dc6f2772c 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -248,7 +248,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 48, wxT( "DrawMod" ), wxEmptyString, GREEN ); Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { PtStruct = Module->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) @@ -271,10 +271,10 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 48, wxT( "Pads " ), wxEmptyString, GREEN ); Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Next() ) { wxPoint shape_pos; if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) @@ -328,7 +328,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 56, wxT( "Vias" ), wxEmptyString, RED ); - for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) + for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { if( pts->Type() != TYPEVIA ) continue; @@ -360,7 +360,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, /* trace des segments pistes */ nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "Tracks " ), wxEmptyString, YELLOW ); - for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) + for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { if( pts->Type() == TYPEVIA ) continue; @@ -397,7 +397,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, /* trace des segments pistes et zones */ nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "Zones " ), wxEmptyString, YELLOW ); - for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext ) + for( pts = m_Pcb->m_Zone; pts != NULL; pts = pts->Next() ) { if( g_TabOneLayerMask[pts->GetLayer()] & masque_layer ) { diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index c5161bbebc..debd6b62e1 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -289,7 +289,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 48, wxT( "DrawMod" ), wxEmptyString, GREEN ); Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { PtStruct = Module->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) @@ -311,10 +311,10 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 48, wxT( "Pads " ), wxEmptyString, GREEN ); Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Next() ) { if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) continue; @@ -391,7 +391,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 64, _( "Tracks" ), wxEmptyString, YELLOW ); - for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) + for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { if( pts->Type() == TYPEVIA ) continue; @@ -412,7 +412,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "Zones " ), wxEmptyString, YELLOW ); - for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext ) + for( pts = m_Pcb->m_Zone; pts != NULL; pts = pts->Next() ) { if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) continue; @@ -481,7 +481,7 @@ static void PrintDrillMark( BOARD* Pcb ) } Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { PtPad = Module->m_Pads; for( ; PtPad != NULL; PtPad = PtPad->Next() ) diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 0bcae7428f..1bf05e9b15 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -919,14 +919,14 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() if( ii == 0 ) { m_Pcb->m_Equipots = pt_equipot; - pt_equipot->Pback = m_Pcb; + pt_equipot->SetBack( m_Pcb ); } else { - PtStruct->Pnext = pt_equipot; - pt_equipot->Pback = PtStruct; + PtStruct->SetNext( pt_equipot ); + pt_equipot->SetBack( PtStruct ); } - pt_equipot->Pnext = NULL; + pt_equipot->SetNext( NULL ); } // Set the net_code for this equipot and reset other values @@ -936,14 +936,14 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() BufPtEquipot[ii] = pt_equipot; PtStruct = (EDA_BaseStruct*) pt_equipot; - pt_equipot = (EQUIPOT*) pt_equipot->Pnext; + pt_equipot = pt_equipot->Next(); } /* Delete the unused equipots in the old list */ while( pt_equipot ) { - PtStruct = pt_equipot->Pnext; + PtStruct = pt_equipot->Next(); pt_equipot->DeleteStructure(); pt_equipot = (EQUIPOT*) PtStruct; } @@ -966,7 +966,7 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() MyFree( BufPtEquipot ); m_Pcb->m_Status_Pcb |= NET_CODES_OK; - m_Pcb->SetAreasNetCodesFromNetNames(); + m_Pcb->SetAreasNetCodesFromNetNames(); } @@ -1002,10 +1002,10 @@ void WinEDA_BasePcbFrame::build_liste_pads() /* Set the pad count */ m_Pcb->m_NbPads = 0; Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { - PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + PtPad = Module->m_Pads; + for( ; PtPad != NULL; PtPad = PtPad->Next() ) m_Pcb->m_NbPads++; } @@ -1019,14 +1019,14 @@ void WinEDA_BasePcbFrame::build_liste_pads() /* Clear variables used in rastnest computation */ Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { - PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + PtPad = Module->m_Pads; + for( ; PtPad != NULL; PtPad = PtPad->Next() ) { *pt_liste_pad = PtPad; PtPad->SetSubRatsnest( 0 ); - PtPad->m_Parent = Module; // Just in case + PtPad->SetParent( Module ); if( PtPad->GetNet() ) m_Pcb->m_NbNodes++; @@ -1089,9 +1089,9 @@ char* WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) build_liste_pads(); /* Compute the "local" ratsnest if needed (when this footprint starts move) - and the list of external pads to consider, i.e pads in others footprints which are "connected" to - a pad in the current footprint - */ + and the list of external pads to consider, i.e pads in others footprints which are "connected" to + a pad in the current footprint + */ if( (m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) != 0 ) goto calcul_chevelu_ext; @@ -1100,7 +1100,7 @@ char* WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) nb_pads_ref = 0; pad_ref = Module->m_Pads; - for( ; pad_ref != NULL; pad_ref = (D_PAD*) pad_ref->Pnext ) + for( ; pad_ref != NULL; pad_ref = pad_ref->Next() ) { if( pad_ref->GetNet() == 0 ) continue; @@ -1137,7 +1137,7 @@ char* WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) if( pad_externe->GetNet() != current_net_code ) continue; - if( pad_externe->m_Parent == Module ) + if( pad_externe->GetParent() == Module ) continue; pad_externe->SetSubRatsnest(0); @@ -1156,8 +1156,8 @@ char* WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) /* Compute the internal rats nest: * this is the same as general ratsnest, but considers only the current footprint pads - * it is therefore not time consuming, and it is made only once - */ + * it is therefore not time consuming, and it is made only once + */ local_liste_chevelu = (CHEVELU*) pt_liste_pad; // buffer chevelu a la suite de la liste des pads nb_local_chevelu = 0; pt_liste_ref = (LISTE_PAD*) adr_lowmem; @@ -1286,8 +1286,8 @@ calcul_chevelu_ext: adr_max = MAX( adr_max, (char*) (local_chevelu + 1) ); return (char*) (local_chevelu + 1); /* the struct pointed by local_chevelu is used - in temporary computations, so we skip it - */ + in temporary computations, so we skip it + */ } diff --git a/pcbnew/router.cpp b/pcbnew/router.cpp index 22b62d4315..22dc547f55 100644 --- a/pcbnew/router.cpp +++ b/pcbnew/router.cpp @@ -330,7 +330,7 @@ void ReturnNbViasAndTracks( BOARD* Pcb, int netcode, int* nb_vias, if( track == NULL ) return; - for( ; track != NULL; track = (TRACK*) track->Pnext ) + for( ; track != NULL; track = track->Next() ) { if( track->GetNet() > netcode ) return; @@ -360,7 +360,7 @@ void GenExistantTracks( BOARD* Pcb, FILE* outfile, return; - for( ; track != NULL; track = (TRACK*) track->Pnext ) + for( ; track != NULL; track = track->Next() ) { netcode = track->GetNet(); if( netcode > current_net_code ) @@ -447,7 +447,7 @@ int GenEdges( BOARD* Pcb, FILE* outfile ) int NbItems = 0; /* impression des contours */ - for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() != TYPEDRAWSEGMENT ) continue; diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index 3cbfcf5357..836f60cd58 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -915,9 +915,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, NewTrack = new SEGVIA( pcb ); g_TrackSegmentCount++; - NewTrack->Pback = g_CurrentTrackSegment; + NewTrack->SetBack( g_CurrentTrackSegment ); if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->Pnext = NewTrack; + g_CurrentTrackSegment->SetNext( NewTrack ); else g_FirstTrackSegment = NewTrack; @@ -940,9 +940,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, NewTrack = new TRACK( pcb ); g_TrackSegmentCount++; - NewTrack->Pback = g_CurrentTrackSegment; + NewTrack->SetBack( g_CurrentTrackSegment ); if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->Pnext = NewTrack; + g_CurrentTrackSegment->SetNext( NewTrack ); else g_FirstTrackSegment = NewTrack; @@ -957,7 +957,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); g_CurrentTrackSegment->SetNet( current_net_code ); - if( g_CurrentTrackSegment->Pback == NULL ) /* Start Piste */ + if( g_CurrentTrackSegment->Back() == NULL ) /* Start Piste */ { g_CurrentTrackSegment->m_Start.x = segm_fX; g_CurrentTrackSegment->m_Start.y = segm_fY; @@ -988,12 +988,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, } else { - if( g_CurrentTrackSegment->Pback ) + if( g_CurrentTrackSegment->Back() ) { - g_CurrentTrackSegment->m_Start.x = ( (TRACK*) g_CurrentTrackSegment->Pback )-> - m_End.x; - g_CurrentTrackSegment->m_Start.y = ( (TRACK*) g_CurrentTrackSegment->Pback )-> - m_End.y; + g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->Back()->m_End; } } g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; @@ -1002,7 +999,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, || (g_CurrentTrackSegment->m_Start.y != g_CurrentTrackSegment->m_End.y) ) { /* Reduction des segments alignes a 1 seul */ - OldTrack = (TRACK*) g_CurrentTrackSegment->Pback; + OldTrack = g_CurrentTrackSegment->Back(); if( OldTrack && (OldTrack->Type() != TYPEVIA) ) { dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; @@ -1015,7 +1012,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, OldTrack->m_End.y = g_CurrentTrackSegment->m_End.y; delete g_CurrentTrackSegment; g_CurrentTrackSegment = OldTrack; - g_CurrentTrackSegment->Pnext = NULL; + g_CurrentTrackSegment->SetNext( NULL ); g_TrackSegmentCount--; } } @@ -1086,7 +1083,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) pcbframe->test_1_net_connexion( DC, g_FirstTrackSegment->GetNet() ); /* Trace de la forme exacte de la piste en BOARD */ - for( pt_track = g_FirstTrackSegment; ; pt_track = (TRACK*) pt_track->Pnext ) + for( pt_track = g_FirstTrackSegment; ; pt_track = (TRACK*) pt_track->Next() ) { TraceSegmentPcb( pcbframe->m_Pcb, pt_track, HOLE, marge, WRITE_CELL ); TraceSegmentPcb( pcbframe->m_Pcb, pt_track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); diff --git a/pcbnew/surbrill.cpp b/pcbnew/surbrill.cpp index 0abfe8c14d..4d14eaad7f 100644 --- a/pcbnew/surbrill.cpp +++ b/pcbnew/surbrill.cpp @@ -41,7 +41,7 @@ void WinEDA_PcbFrame::Liste_Equipot( wxCommandEvent& event ) List = new WinEDA_TextFrame( this, _( "List Nets" ) ); Equipot = (EQUIPOT*) m_Pcb->m_Equipots; - for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext ) + for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Next() ) { wxString Line; /* calcul adr relative du nom de la pastille reference de la piste */ @@ -62,7 +62,7 @@ void WinEDA_PcbFrame::Liste_Equipot( wxCommandEvent& event ) /* Recherche du numero de net rellement selectionn�*/ Equipot = (EQUIPOT*) m_Pcb->m_Equipots; - for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext ) + for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Next() ) { /* calcul adr relative du nom de la pastille reference de la piste */ if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) ) @@ -220,7 +220,7 @@ static void Pad_Surbrillance( WinEDA_DrawPanel* panel, D_PAD* pt_pad; /* trace des pastilles */ - for( pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( pt_pad = Module->m_Pads; pt_pad; pt_pad = pt_pad->Next() ) { if( pt_pad->GetNet() == NetCode ) { diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index 81dfaead29..fd32f1b93d 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -332,8 +332,8 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) return; // (Cancelled dialog box returns -1 instead) /* Modifications des pistes */ - pt_segm = (TRACK*) m_Pcb->m_Track; - for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + pt_segm = m_Pcb->m_Track; + for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) { GetScreen()->SetModify(); if( pt_segm->Type() == TYPEVIA ) @@ -358,8 +358,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) } /* Modifications des zones */ - pt_segm = (TRACK*) m_Pcb->m_Zone; - for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + for( pt_segm = m_Pcb->m_Zone; pt_segm; pt_segm = pt_segm->Next() ) { GetScreen()->SetModify(); jj = pt_segm->GetLayer(); @@ -369,7 +368,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) /* Modifications des autres segments */ PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() == TYPEDRAWSEGMENT ) { diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index ef7a8a5185..088d8e104d 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -46,13 +46,13 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, * une via est souvent sur un carrefour de segments, et ne caracterise pas * une piste */ if( pt_new_track->Type() == TYPEVIA && (nbptnewpiste > 1 ) ) - pt_new_track = (TRACK*) pt_new_track->Pnext; + pt_new_track = pt_new_track->Next(); pt_new_track = Marque_Une_Piste( frame, DC, pt_new_track, &nbptnewpiste, 0 ); EndNewTrack = pt_new_track; for( ii = 1; ii < nbptnewpiste; ii++ ) { - EndNewTrack = (TRACK*) EndNewTrack->Pnext; + EndNewTrack = EndNewTrack->Next(); } /* Calcul des limites de recherche des segments de piste */ @@ -63,7 +63,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, BufEnd = BufDeb->GetEndNetCode( pt_new_track->GetNet() ); /* nettoyage des flags pour tout le net */ - for( pt_del = BufDeb; pt_del != NULL; pt_del = (TRACK*) pt_del->Pnext ) + for( pt_del = BufDeb; pt_del != NULL; pt_del = pt_del->Next() ) { pt_del->SetState( BUSY | EDIT | CHAIN, OFF ); if( pt_del == BufEnd ) @@ -143,13 +143,13 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, } if( pt_del == BufEnd ) break; - pt_del = (TRACK*) pt_segm->Pnext; + pt_del = pt_segm->Next(); } if( nbconnect == 0 ) { /* nettoyage des flags */ - for( pt_del = BufDeb; pt_del != NULL; pt_del = (TRACK*) pt_del->Pnext ) + for( pt_del = BufDeb; pt_del != NULL; pt_del = pt_del->Next() ) { pt_del->SetState( DELETED | EDIT | CHAIN, OFF ); if( pt_del == BufEnd ) @@ -168,7 +168,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, /* Examen de tous les segments marques */ while( nbconnect ) { - for( pt_del = BufDeb; pt_del != NULL; pt_del = (TRACK*) pt_del->Pnext ) + for( pt_del = BufDeb; pt_del != NULL; pt_del = pt_del->Next() ) { if( pt_del->GetState( CHAIN ) ) break; @@ -183,7 +183,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, * segments marques est connecte au point de depart de la piste nouvelle */ ii = 0; pt_segm = pt_del; - for( ; pt_segm && (ii < nb_segm); pt_segm = (TRACK*) pt_segm->Pnext, ii++ ) + for( ; pt_segm && (ii < nb_segm); pt_segm = pt_segm->Next(), ii++ ) { if( ( pt_segm->GetState( BUSY ) ) == 0 ) break; @@ -194,12 +194,12 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, Trace_Une_Piste( frame->DrawPanel, DC, pt_del, nb_segm, GR_XOR | GR_SURBRILL ); for( jj = 0; jj < nb_segm; jj++, pt_del = NextS ) { - NextS = (TRACK*) pt_del->Pnext; + NextS = pt_del->Next(); pt_del->DeleteStructure(); } /* nettoyage des flags */ - for( pt_del = Pcb->m_Track; pt_del != NULL; pt_del = (TRACK*) pt_del->Pnext ) + for( pt_del = Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() ) { if( pt_del->GetState( EDIT ) ) { @@ -219,7 +219,7 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, } /* nettoyage des flags */ - for( pt_del = Pcb->m_Track; pt_del != NULL; pt_del = (TRACK*) pt_del->Pnext ) + for( pt_del = Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() ) { pt_del->SetState( DELETED | EDIT | CHAIN, OFF ); if( pt_del == BufEnd ) diff --git a/pcbnew/tracemod.cpp b/pcbnew/tracemod.cpp index 1b444d96ec..ae48a63a41 100644 --- a/pcbnew/tracemod.cpp +++ b/pcbnew/tracemod.cpp @@ -42,7 +42,6 @@ void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, */ { int tmp; - D_PAD* pt_pad; PCB_SCREEN* screen; WinEDA_BasePcbFrame* frame; @@ -53,12 +52,12 @@ void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, frame->m_DisplayPadFill = FALSE; /* trace des pastilles */ - pt_pad = Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) { - if( (pt_pad->m_Masque_Layer & MasqueLayer) == 0 ) + if( (pad->m_Masque_Layer & MasqueLayer) == 0 ) continue; - pt_pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) ); + + pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) ); } frame->m_DisplayPadFill = tmp; diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 42e7e9df90..eeacdcdab3 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -29,7 +29,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) */ { - MODULE* Module; PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); if( !m_Pcb || !screen ) @@ -45,10 +44,9 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) TraceWorkSheet( DC, screen, 0 ); /* Redraw the footprint */ - Module = (MODULE*) m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) { - Module->Draw( DrawPanel, DC, GR_OR ); + module->Draw( DrawPanel, DC, GR_OR ); } Affiche_Status_Box(); diff --git a/pcbnew/track.cpp b/pcbnew/track.cpp index bc3f0e06c5..d6dcf33d76 100644 --- a/pcbnew/track.cpp +++ b/pcbnew/track.cpp @@ -75,12 +75,12 @@ TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, pt_segm->m_Start, masque_layer ); if( Segm1 ) { - Segm2 = Fast_Locate_Piste( (TRACK*) Segm1->Pnext, NULL, + Segm2 = Fast_Locate_Piste( Segm1->Next(), NULL, pt_segm->m_Start, masque_layer ); } if( Segm2 ) { - Segm3 = Fast_Locate_Piste( (TRACK*) Segm2->Pnext, NULL, + Segm3 = Fast_Locate_Piste( Segm2->Next(), NULL, pt_segm->m_Start, masque_layer ); } if( Segm3 ) @@ -127,7 +127,7 @@ TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, /* Test des connexions: si via utile: suppression marquage */ layer = Track->GetLayer(); - while( ( Track = Fast_Locate_Piste( (TRACK*) Track->Pnext, NULL, + while( ( Track = Fast_Locate_Piste( (TRACK*) Track->Next(), NULL, Segm->RefTrack->m_Start, masque_layer ) ) != NULL ) { @@ -150,7 +150,7 @@ TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, /* Reclassement des segments marques en une chaine */ FirstTrack = frame->m_Pcb->m_Track; NbSegmBusy = 0; - for( ; FirstTrack != NULL; FirstTrack = (TRACK*) FirstTrack->Pnext ) + for( ; FirstTrack != NULL; FirstTrack = (TRACK*) FirstTrack->Next() ) { /* recherche du debut de la liste des segments marques a BUSY */ if( FirstTrack->GetState( BUSY ) ) @@ -162,10 +162,10 @@ TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, /* Reclassement de la chaine debutant a FirstTrack et finissant * au dernier segment marque. FirstTrack n'est pas modifie */ - Track = (TRACK*) FirstTrack->Pnext; + Track = (TRACK*) FirstTrack->Next(); for( ; Track != NULL; Track = NextTrack ) { - NextTrack = (TRACK*) Track->Pnext; + NextTrack = (TRACK*) Track->Next(); if( Track->GetState( BUSY ) ) { NbSegmBusy++; @@ -240,13 +240,13 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye if( pt_segm->GetState( BUSY ) ) { - pt_segm = (TRACK*) pt_segm->Pnext; + pt_segm = (TRACK*) pt_segm->Next(); continue; } if( pt_segm == pt_via ) /* deja traite */ { - pt_segm = (TRACK*) pt_segm->Pnext; + pt_segm = (TRACK*) pt_segm->Next(); continue; } @@ -254,7 +254,7 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye if( NbSegm == 1 ) /* 1ere detection de segment de piste */ { MarqSegm = pt_segm; - pt_segm = (TRACK*) pt_segm->Pnext; + pt_segm = (TRACK*) pt_segm->Next(); } else /* 2eme detection de segment -> fin de piste */ { @@ -316,7 +316,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, /* calcul de la limite d'analyse */ *StartTrack = *EndTrack = NULL; TrackListEnd = Track = RefTrack; ii = 0; - for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Pnext ) + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Next() ) { TrackListEnd = Track; Track->m_Param = 0; @@ -324,7 +324,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, /* Calcul des extremites */ NbEnds = 0; Track = RefTrack; ii = 0; - for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Pnext ) + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Next() ) { if( Track->Type() == TYPEVIA ) continue; @@ -424,7 +424,7 @@ void ListSetState( EDA_BaseStruct* Start, int NbItem, int State, int onoff ) { if( Start == NULL ) return; - for( ; (Start != NULL) && (NbItem > 0); NbItem--, Start = Start->Pnext ) + for( ; (Start != NULL) && (NbItem > 0); NbItem--, Start = Start->Next() ) { Start->SetState( State, onoff ); } diff --git a/pcbnew/undelete.cpp b/pcbnew/undelete.cpp index abe5a058ef..80b96b852c 100644 --- a/pcbnew/undelete.cpp +++ b/pcbnew/undelete.cpp @@ -125,8 +125,9 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) if( nbitems <= 1 ) NextS = NULL; /* fin de chaine */ - PtStruct->Pnext = NextS; - PtStruct->Pback = Back; Back = PtStruct; + PtStruct->SetNext( NextS ); + PtStruct->SetBack( Back ); + Back = PtStruct; if( NextS == NULL ) break; } diff --git a/pcbnew/via_edit.cpp b/pcbnew/via_edit.cpp index 58a791d01a..3207d77b8f 100644 --- a/pcbnew/via_edit.cpp +++ b/pcbnew/via_edit.cpp @@ -64,7 +64,7 @@ void WinEDA_PcbFrame::Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via if( via->GetDrillValue() > 0 ) g_DesignSettings.m_ViaDrillCustomValue = via->GetDrillValue(); via_struct = m_Pcb->m_Track; - for( ; via_struct != NULL; via_struct = (TRACK*) via_struct->Pnext ) + for( ; via_struct != NULL; via_struct = via_struct->Next() ) { if( via_struct->Type() == TYPEVIA ) /* mise a jour du diametre de la via */ { diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 66c730138e..d92e375dd3 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -360,17 +360,17 @@ void WinEDA_ExchangeModuleFrame::Change_ModuleId( wxCommandEvent& event ) */ PtModule = m_Parent->m_Pcb->m_Modules; - for( ; PtModule != NULL; PtModule = (MODULE*) PtModule->Pnext ) + for( ; PtModule != NULL; PtModule = PtModule->Next() ) { - if( PtModule->Pnext == NULL ) + if( PtModule->Next() == NULL ) break; } /* Ici PtModule pointe le dernier module de la liste */ - for( ; PtModule != (MODULE*) m_Parent->m_Pcb; PtModule = PtBack ) + for( ; (BOARD*) PtModule != m_Parent->m_Pcb; PtModule = PtBack ) { MODULE* module; - PtBack = (MODULE*) PtModule->Pback; + PtBack = PtModule->Back(); if( lib_reference.CmpNoCase( PtModule->m_LibRef ) != 0 ) continue; if( check_module_value ) @@ -419,17 +419,17 @@ void WinEDA_ExchangeModuleFrame::Change_ModuleAll( wxCommandEvent& event ) * Change_1_Module() modifie le dernier module de la liste */ - PtModule = (MODULE*) m_Parent->m_Pcb->m_Modules; - for( ; PtModule != NULL; PtModule = (MODULE*) PtModule->Pnext ) + PtModule = m_Parent->m_Pcb->m_Modules; + for( ; PtModule != NULL; PtModule = PtModule->Next() ) { - if( PtModule->Pnext == NULL ) + if( PtModule->Next() == NULL ) break; } /* Ici PtModule pointe le dernier module de la liste */ - for( ; PtModule != (MODULE*) (m_Parent->m_Pcb); PtModule = PtBack ) + for( ; (BOARD*) PtModule != m_Parent->m_Pcb; PtModule = PtBack ) { - PtBack = (MODULE*) PtModule->Pback; + PtBack = PtModule->Back(); if( Change_1_Module( PtModule, PtModule->m_LibRef.GetData(), ShowErr ) ) change = TRUE; else if( ShowErr ) @@ -524,7 +524,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, DisplayError( winaff, wxT( "WinEDA_BasePcbFrame::Exchange_Module() StuctType error" ) ); } - NewModule->m_Parent = m_Pcb; + NewModule->SetParent( m_Pcb ); m_Pcb->m_Status_Pcb = 0; oldpos = GetScreen()->m_Curseur; @@ -554,12 +554,12 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, /* mise a jour des netnames ( lorsque c'est possible) */ pt_pad = NewModule->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { pt_pad->m_Netname = wxEmptyString; pt_pad->SetNet( 0 ); pt_old_pad = OldModule->m_Pads; - for( ; pt_old_pad != NULL; pt_old_pad = (D_PAD*) pt_old_pad->Pnext ) + for( ; pt_old_pad != NULL; pt_old_pad = pt_old_pad->Next() ) { if( strnicmp( pt_pad->m_Padname, pt_old_pad->m_Padname, sizeof(pt_pad->m_Padname) ) == 0 ) @@ -642,7 +642,7 @@ bool WinEDA_PcbFrame::RecreateCmpFileFromBoard() fgets( Line, sizeof(Line), FichCmp ); fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) ); - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( ; Module != NULL; Module = Module->Next() ) { fprintf( FichCmp, "\nBeginCmp\n" ); fprintf( FichCmp, "TimeStamp = %8.8lX\n", Module->m_TimeStamp );