diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 72c7196728..fb0977924e 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -202,13 +202,14 @@ void Pcb3D_GLCanvas::Draw3D_Track(TRACK * track) /************************************************/ { double zpos; -int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[track->m_Layer]; -int layer = track->m_Layer; +int layer = track->GetLayer(); +int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; double ox, oy, fx, fy; double w; if ( color & ITEM_NOT_SHOW ) return; - if ( track->m_Layer == CMP_N ) layer = g_Parm_3D_Visu.m_Layers -1; + if ( layer == CMP_N ) + layer = g_Parm_3D_Visu.m_Layers -1; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; SetGLColor(color); @@ -268,7 +269,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment(DRAWSEGMENT * segment) int layer; double x, y, xf, yf; double zpos, w; -int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->m_Layer]; +int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->GetLayer()]; if ( color & ITEM_NOT_SHOW ) return; @@ -279,7 +280,7 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->m_Layer]; xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale; yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale; - if ( segment->m_Layer == EDGE_N) + if ( segment->GetLayer() == EDGE_N) { for ( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ ) { @@ -291,7 +292,7 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->m_Layer]; else { - zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->m_Layer]; + zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->GetLayer()]; Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos); } } diff --git a/change_log.txt b/change_log.txt index 4cf32ffe16..6316022548 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,16 +5,36 @@ Please add newer entries at the top, list the date and your name with email address. +2007-Aug-23 UPDATE Dick Hollenbeck +================================================================================ + @todo add constructor initializers for classes that were derived from + EDA_BaseLineStruct but are now not. Its late, will do tomorrow. + @todo test yesterday's changes, it builds, may not run right yet. + + 2007-Aug-22 UPDATE Dick Hollenbeck ================================================================================ + eeschema & pcbnew + Things are still pretty transient, should be stable a day or two: * Fixed a filename case sensitivity problem that would show up on Linux but probably not on Windows: bitmap/Reload.xpm needed uppercase R. - * Since so many classes introduced m_Layer, I moved m_Layer into - EDA_BaseStruct so all classes can inherit it and that way we can test - layer using a general, polymorphic test, i.e. don't have to cast a - EDA_BaseStruct* to a class specific pointer to test layer. Could also have - used a virtual function but too many places use m_Layer directly. + * Wedged a new class BOARD_ITEM underneath all PCB drawable classes, this is + a big change and may introduce a bug or two, but it is worth it for the + future, because we can introduce virtual functions there that do not impact + the entire project (since everything is derived from EDA_BaseStruct). + The corresponding class in EESCHEMA seems to be DrawPartStruct, so we had + nothing in PCBNEW like that. + BOARD_ITEM::GetLayer() and SetLayer() introduced, more functions to come. + Much of this work is geared towards making collectors.cpp's ARROWCOLLECTOR::Inspect() + very very simple, and that can be model for future work. + * Changed min() and max() macros to MIN() and MAX() because min() and max() + are actually reserved according to the C++ standard! (and their usage prevented + the use of #include ). + * Added files class_collector.h, collectors.h, and collectors.cpp. + File collectors.cpp is still unfinished. + * Started using a function and class comment style that will make sense to the + Doxygen source code documenter program. + * Beautified more un-beautified files. 2007-aug-21 UPDATE Jean-Pierre Charras diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 21b9e48472..d9445aa3d7 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -106,7 +106,6 @@ void EDA_BaseStruct::InitVars( void ) m_TimeStamp = 0; // Time stamp used for logical links m_Status = 0; m_Selected = 0; /* Used by block commands, and selective editing */ - m_Layer = 0; } @@ -283,6 +282,7 @@ std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os ) #endif + /**********************************************************************************************/ EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : EDA_BaseStruct( StructFather, idtype ) diff --git a/eeschema/class_hierarchy_sheet.cpp b/eeschema/class_hierarchy_sheet.cpp index 45e7a24ccd..545fa88d65 100644 --- a/eeschema/class_hierarchy_sheet.cpp +++ b/eeschema/class_hierarchy_sheet.cpp @@ -1,12 +1,13 @@ ///////////////////////////////////////////////////////////////////////////// + // Name: sheet.cpp -// Purpose: +// Purpose: // Author: jean-pierre Charras -// Modified by: +// Modified by: // Created: 08/02/2006 18:37:02 -// RCS-ID: +// RCS-ID: // Copyright: License GNU -// Licence: +// Licence: ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". @@ -32,285 +33,298 @@ /***********************************************************/ -DrawSheetStruct::DrawSheetStruct(const wxPoint & pos) : - SCH_SCREEN( SCHEMATIC_FRAME ) +DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : + SCH_SCREEN( SCHEMATIC_FRAME ) /***********************************************************/ { - m_Label = NULL; - m_NbLabel = 0; - m_Layer = LAYER_SHEET; - m_Pos = pos; - m_SheetNameSize = m_FileNameSize = 60; - /* change the struct type: SCREEN_STRUCT_TYPE to DRAW_SHEET_STRUCT_TYPE */ - m_StructType = DRAW_SHEET_STRUCT_TYPE; + m_Label = NULL; + m_NbLabel = 0; + m_Layer = LAYER_SHEET; + m_Pos = pos; + m_SheetNameSize = m_FileNameSize = 60; + /* change the struct type: SCREEN_STRUCT_TYPE to DRAW_SHEET_STRUCT_TYPE */ + m_StructType = DRAW_SHEET_STRUCT_TYPE; } + /**************************************/ -DrawSheetStruct::~DrawSheetStruct(void) +DrawSheetStruct::~DrawSheetStruct() /**************************************/ { -DrawSheetLabelStruct * label = m_Label, * next_label; + DrawSheetLabelStruct* label = m_Label, * next_label; - while (label) - { - next_label = (DrawSheetLabelStruct *)label->Pnext; - delete label; - label = next_label; - } + while( label ) + { + next_label = (DrawSheetLabelStruct*) label->Pnext; + delete label; + label = next_label; + } } /***********************************************/ -DrawSheetStruct * DrawSheetStruct::GenCopy(void) +DrawSheetStruct* DrawSheetStruct::GenCopy( void ) /***********************************************/ + /* creates a copy of a sheet - The linked data itself (EEDrawList) is not duplicated -*/ + * The linked data itself (EEDrawList) is not duplicated + */ { -DrawSheetStruct * newitem = new DrawSheetStruct(m_Pos); -DrawSheetLabelStruct * Slabel = NULL, * label = m_Label; + DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos ); - newitem->m_Size = m_Size; - newitem->m_Parent = m_Parent; - newitem->m_TimeStamp = GetTimeStamp(); + DrawSheetLabelStruct* Slabel = NULL, * label = m_Label; - newitem->m_FileName = m_FileName; - newitem->m_FileNameSize = m_FileNameSize; - newitem->m_SheetName = m_SheetName; - newitem->m_SheetNameSize = m_SheetNameSize; + newitem->m_Size = m_Size; + newitem->m_Parent = m_Parent; + newitem->m_TimeStamp = GetTimeStamp(); - if( label ) - { - Slabel = newitem->m_Label = label->GenCopy(); - Slabel->m_Parent = newitem; - label = (DrawSheetLabelStruct*)label->Pnext; - } + newitem->m_FileName = m_FileName; + newitem->m_FileNameSize = m_FileNameSize; + newitem->m_SheetName = m_SheetName; + newitem->m_SheetNameSize = m_SheetNameSize; - while( label ) - { - Slabel->Pnext = label->GenCopy(); - Slabel = (DrawSheetLabelStruct*)Slabel->Pnext; - Slabel->m_Parent = newitem; - label = (DrawSheetLabelStruct*)label->Pnext; - } + if( label ) + { + Slabel = newitem->m_Label = label->GenCopy(); + Slabel->m_Parent = newitem; + label = (DrawSheetLabelStruct*) label->Pnext; + } - /* copy screen data */ - newitem->m_DrawOrg = m_DrawOrg; - newitem->m_Curseur = m_Curseur; - newitem->m_MousePosition = m_MousePosition; - newitem->m_MousePositionInPixels = m_MousePositionInPixels; - newitem->m_O_Curseur = m_O_Curseur; - newitem->m_ScrollbarPos = m_ScrollbarPos; - newitem->m_ScrollbarNumber = m_ScrollbarNumber; - newitem->m_StartVisu = m_StartVisu; - newitem->m_FirstRedraw = m_FirstRedraw; + while( label ) + { + Slabel->Pnext = label->GenCopy(); + Slabel = (DrawSheetLabelStruct*) Slabel->Pnext; + Slabel->m_Parent = newitem; + label = (DrawSheetLabelStruct*) label->Pnext; + } - newitem->EEDrawList = EEDrawList; /* Object list (main data) for schematic */ - newitem->m_UndoList = m_UndoList; /* Object list for the undo command (old data) */ - newitem->m_RedoList = m_RedoList; /* Object list for the redo command (old data) */ + /* copy screen data */ + newitem->m_DrawOrg = m_DrawOrg; + newitem->m_Curseur = m_Curseur; + newitem->m_MousePosition = m_MousePosition; + newitem->m_MousePositionInPixels = m_MousePositionInPixels; + newitem->m_O_Curseur = m_O_Curseur; + newitem->m_ScrollbarPos = m_ScrollbarPos; + newitem->m_ScrollbarNumber = m_ScrollbarNumber; + newitem->m_StartVisu = m_StartVisu; + newitem->m_FirstRedraw = m_FirstRedraw; - newitem->m_CurrentSheet = m_CurrentSheet; - newitem->m_SheetNumber = m_SheetNumber; - newitem->m_NumberOfSheet = m_NumberOfSheet; - newitem->m_FileName = m_FileName; - newitem->m_Title = m_Title; - newitem->m_Date = m_Date; - newitem->m_Revision = m_Revision; - newitem->m_Company = m_Company; - newitem->m_Commentaire1 = m_Commentaire1; - newitem->m_Commentaire2 = m_Commentaire2; - newitem->m_Commentaire3 = m_Commentaire3; - newitem->m_Commentaire4 = m_Commentaire4; + newitem->EEDrawList = EEDrawList; /* Object list (main data) for schematic */ + newitem->m_UndoList = m_UndoList; /* Object list for the undo command (old data) */ + newitem->m_RedoList = m_RedoList; /* Object list for the redo command (old data) */ - return newitem; + newitem->m_CurrentSheet = m_CurrentSheet; + newitem->m_SheetNumber = m_SheetNumber; + newitem->m_NumberOfSheet = m_NumberOfSheet; + newitem->m_FileName = m_FileName; + newitem->m_Title = m_Title; + newitem->m_Date = m_Date; + newitem->m_Revision = m_Revision; + newitem->m_Company = m_Company; + newitem->m_Commentaire1 = m_Commentaire1; + newitem->m_Commentaire2 = m_Commentaire2; + newitem->m_Commentaire3 = m_Commentaire3; + newitem->m_Commentaire4 = m_Commentaire4; + + return newitem; } /**********************************************************/ -void DrawSheetStruct::SwapData(DrawSheetStruct * copyitem) +void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) /**********************************************************/ + /* Used if undo / redo command: - swap data between this and copyitem -*/ + * swap data between this and copyitem + */ { - EXCHG(m_Pos, copyitem->m_Pos); - EXCHG(m_Size, copyitem->m_Size); - EXCHG(m_SheetName, copyitem->m_SheetName); - EXCHG(m_SheetNameSize, copyitem->m_SheetNameSize); - EXCHG(m_FileNameSize, copyitem->m_FileNameSize); - EXCHG(m_Label, copyitem->m_Label); - EXCHG(m_NbLabel, copyitem->m_NbLabel); + EXCHG( m_Pos, copyitem->m_Pos ); + EXCHG( m_Size, copyitem->m_Size ); + EXCHG( m_SheetName, copyitem->m_SheetName ); + EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize ); + EXCHG( m_FileNameSize, copyitem->m_FileNameSize ); + EXCHG( m_Label, copyitem->m_Label ); + EXCHG( m_NbLabel, copyitem->m_NbLabel ); } + /**************************************************************************************/ -void DrawSheetStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, - int DrawMode, int Color) +void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) /**************************************************************************************/ /* Draw the hierarchical sheet shape */ { -DrawSheetLabelStruct * SheetLabelStruct; -int txtcolor; -wxString Text; -int color; -wxPoint pos = m_Pos + offset; -int LineWidth = g_DrawMinimunLineWidth; - - if( Color >= 0 ) color = Color; - else color = ReturnLayerColor(m_Layer); - GRSetDrawMode(DC, DrawMode); + DrawSheetLabelStruct* SheetLabelStruct; + int txtcolor; + wxString Text; + int color; + wxPoint pos = m_Pos + offset; + int LineWidth = g_DrawMinimunLineWidth; - GRRect(&panel->m_ClipBox, DC, pos.x, pos.y, - pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color); + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); - /* Draw text : SheetName */ - if( Color > 0 ) txtcolor = Color; - else txtcolor = ReturnLayerColor(LAYER_SHEETNAME); + GRRect( &panel->m_ClipBox, DC, pos.x, pos.y, + pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); - Text = wxT("Sheet: ") + m_SheetName; - DrawGraphicText(panel, DC, - wxPoint(pos.x, pos.y - 8), txtcolor, - Text, TEXT_ORIENT_HORIZ, wxSize(m_SheetNameSize,m_SheetNameSize), - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth); + /* Draw text : SheetName */ + if( Color > 0 ) + txtcolor = Color; + else + txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); - /* Draw text : FileName */ - if( Color >= 0 ) txtcolor = Color; - else txtcolor = ReturnLayerColor(LAYER_SHEETFILENAME); - Text = wxT("File: ") + m_FileName; - DrawGraphicText(panel, DC, - wxPoint(pos.x, pos.y + m_Size.y + 4), - txtcolor, - Text, TEXT_ORIENT_HORIZ, wxSize(m_FileNameSize,m_FileNameSize), - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth); + Text = wxT( "Sheet: " ) + m_SheetName; + DrawGraphicText( panel, DC, + wxPoint( pos.x, pos.y - 8 ), txtcolor, + Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ), + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); + + /* Draw text : FileName */ + if( Color >= 0 ) + txtcolor = Color; + else + txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); + Text = wxT( "File: " ) + m_FileName; + DrawGraphicText( panel, DC, + wxPoint( pos.x, pos.y + m_Size.y + 4 ), + txtcolor, + Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth ); - /* Draw text : SheetLabel */ - SheetLabelStruct = m_Label; - while( SheetLabelStruct != NULL ) - { - SheetLabelStruct->Draw(panel, DC, offset,DrawMode, Color); - SheetLabelStruct = (DrawSheetLabelStruct*)(SheetLabelStruct->Pnext); - } + /* Draw text : SheetLabel */ + SheetLabelStruct = m_Label; + while( SheetLabelStruct != NULL ) + { + SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color ); + SheetLabelStruct = (DrawSheetLabelStruct*) (SheetLabelStruct->Pnext); + } } - /************************/ - /* DrawSheetLabelStruct */ - /************************/ +/************************/ +/* DrawSheetLabelStruct */ +/************************/ /*******************************************************************/ -DrawSheetLabelStruct::DrawSheetLabelStruct(DrawSheetStruct * parent, - const wxPoint & pos, const wxString & text) : - EDA_BaseStruct(DRAW_SHEETLABEL_STRUCT_TYPE), - EDA_TextStruct(text) +DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent, + const wxPoint& pos, const wxString& text ) : + EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ), + EDA_TextStruct( text ) /*******************************************************************/ { - m_Layer = LAYER_SHEETLABEL; - m_Parent = parent; - m_Pos = pos; - m_Edge = 0; - m_Shape = NET_INPUT; - m_IsDangling = TRUE; + m_Layer = LAYER_SHEETLABEL; + m_Parent = parent; + m_Pos = pos; + m_Edge = 0; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; } + /***********************************************************/ -DrawSheetLabelStruct * DrawSheetLabelStruct::GenCopy(void) +DrawSheetLabelStruct* DrawSheetLabelStruct::GenCopy( void ) /***********************************************************/ { -DrawSheetLabelStruct * newitem = - new DrawSheetLabelStruct( (DrawSheetStruct *)m_Parent, m_Pos, m_Text); + DrawSheetLabelStruct* newitem = + new DrawSheetLabelStruct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text ); - newitem->m_Edge = m_Edge; - newitem->m_Shape = m_Shape; + newitem->m_Edge = m_Edge; + newitem->m_Shape = m_Shape; - return newitem; + return newitem; } - /********************************************************************************************/ -void DrawSheetLabelStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, - int DrawMode, int Color) +void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) /********************************************************************************************/ /* Routine de dessin des Labels type hierarchie */ { -int side, txtcolor; -int posx , tposx, posy, size2; -wxSize size; -int NbSegm, coord[20]; -int LineWidth = g_DrawMinimunLineWidth; + int side, txtcolor; + int posx, tposx, posy, size2; + wxSize size; + int NbSegm, coord[20]; + int LineWidth = g_DrawMinimunLineWidth; - if( Color >= 0 ) txtcolor = Color; - else txtcolor = ReturnLayerColor(m_Layer); - GRSetDrawMode(DC, DrawMode); + if( Color >= 0 ) + txtcolor = Color; + else + txtcolor = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); - posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size; - if( !m_Text.IsEmpty() ) - { - if( m_Edge ) - { - tposx = posx - size.x; - side = GR_TEXT_HJUSTIFY_RIGHT; - } - else - { - tposx = posx + size.x + (size.x /8) ; - side = GR_TEXT_HJUSTIFY_LEFT; - } - DrawGraphicText(panel, DC, wxPoint(tposx, posy), txtcolor, - m_Text, TEXT_ORIENT_HORIZ,size , - side, GR_TEXT_VJUSTIFY_CENTER, LineWidth); - } - /* dessin du symbole de connexion */ + posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size; + if( !m_Text.IsEmpty() ) + { + if( m_Edge ) + { + tposx = posx - size.x; + side = GR_TEXT_HJUSTIFY_RIGHT; + } + else + { + tposx = posx + size.x + (size.x / 8); + side = GR_TEXT_HJUSTIFY_LEFT; + } + DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor, + m_Text, TEXT_ORIENT_HORIZ, size, + side, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); + } + /* dessin du symbole de connexion */ - if(m_Edge) - { - size.x = -size.x; - size.y = -size.y; - } - - coord[0] = posx; coord[1] = posy; size2 = size.x /2; - NbSegm = 0; - switch(m_Shape) - { - case 0: /* input |> */ - coord[2] = posx ; coord[3] = posy - size2; - coord[4] = posx + size2; coord[5] = posy - size2; - coord[6] = posx + size.x; coord[7] = posy; - coord[8] = posx + size2; coord[9] = posy + size2; - coord[10] = posx ; coord[11] = posy + size2; - coord[12] = coord[0] ; coord[13] = coord[1]; - NbSegm = 7; - break; + if( m_Edge ) + { + size.x = -size.x; + size.y = -size.y; + } - case 1: /* output <| */ - coord[2] = posx + size2; coord[3] = posy - size2; - coord[4] = posx + size.x; coord[5] = posy - size2; - coord[6] = posx + size.x; coord[7] = posy + size2; - coord[8] = posx + size2; coord[9] = posy + size2; - coord[10] = coord[0] ; coord[11] = coord[1]; - NbSegm = 6; - break; + coord[0] = posx; coord[1] = posy; size2 = size.x / 2; + NbSegm = 0; - case 2: /* bidi <> */ - case 3: /* TriSt <> */ - coord[2] = posx + size2; coord[3] = posy - size2; - coord[4] = posx + size.x; coord[5] = posy; - coord[6] = posx + size2; coord[7] = posy +size2; - coord[8] = coord[0]; coord[9] = coord[1]; - NbSegm = 5; - break; + switch( m_Shape ) + { + case 0: /* input |> */ + coord[2] = posx; coord[3] = posy - size2; + coord[4] = posx + size2; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = posx; coord[11] = posy + size2; + coord[12] = coord[0]; coord[13] = coord[1]; + NbSegm = 7; + break; - default: /* unsp []*/ - coord[2] = posx ; coord[3] = posy - size2; - coord[4] = posx + size.x; coord[5] = posy - size2; - coord[6] = posx + size.x; coord[7] = posy + size2; - coord[8] = posx ; coord[9] = posy + size2; - coord[10] = coord[0] ; coord[11] = coord[1]; - NbSegm = 6; - break; - } -int FillShape = FALSE; - GRPoly(&panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor); /* Poly Non rempli */ + case 1: /* output <| */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy + size2; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = coord[0]; coord[11] = coord[1]; + NbSegm = 6; + break; + + case 2: /* bidi <> */ + case 3: /* TriSt <> */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy; + coord[6] = posx + size2; coord[7] = posy + size2; + coord[8] = coord[0]; coord[9] = coord[1]; + NbSegm = 5; + break; + + default: /* unsp []*/ + coord[2] = posx; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy + size2; + coord[8] = posx; coord[9] = posy + size2; + coord[10] = coord[0]; coord[11] = coord[1]; + NbSegm = 6; + break; + } + + int FillShape = FALSE; + GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ } - - diff --git a/eeschema/class_screen.h b/eeschema/class_screen.h index 6c75d28ccd..73878b6a01 100644 --- a/eeschema/class_screen.h +++ b/eeschema/class_screen.h @@ -107,10 +107,10 @@ public: }; -class DrawSheetLabelStruct : public EDA_BaseStruct - , public EDA_TextStruct +class DrawSheetLabelStruct : public EDA_BaseStruct, public EDA_TextStruct { public: + int m_Layer; int m_Edge, m_Shape; bool m_IsDangling; // TRUE si non connecté @@ -141,6 +141,7 @@ public: int m_FileNameSize; wxPoint m_Pos; wxSize m_Size; /* Position and Size of sheet symbol */ + int m_Layer; DrawSheetLabelStruct* m_Label; /* Points de connection */ int m_NbLabel; /* Nombre de points de connexion */ diff --git a/eeschema/cmpclass.cpp b/eeschema/cmpclass.cpp index 7bbd6178fe..8b06880594 100644 --- a/eeschema/cmpclass.cpp +++ b/eeschema/cmpclass.cpp @@ -14,236 +14,247 @@ #include "protos.h" - /*******************************************************************/ -DrawBusEntryStruct::DrawBusEntryStruct(const wxPoint & pos, int shape, int id) : - EDA_BaseStruct(DRAW_BUSENTRY_STRUCT_TYPE) +DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) : + EDA_BaseStruct( DRAW_BUSENTRY_STRUCT_TYPE ) /*******************************************************************/ { + m_Pos = pos; + m_Size.x = 100; + m_Size.y = 100; + m_Layer = LAYER_WIRE; + m_Width = 0; - m_Pos = pos; - m_Size.x = 100; - m_Size.y = 100; - m_Layer = LAYER_WIRE; - m_Width = 0; - - if( id == BUS_TO_BUS ) - { - m_Layer = LAYER_BUS; - m_Width = 1; - } - - if(shape == '/' ) m_Size.y = - 100; + if( id == BUS_TO_BUS ) + { + m_Layer = LAYER_BUS; + m_Width = 1; + } + if( shape == '/' ) + m_Size.y = -100; } /*************************************/ -wxPoint DrawBusEntryStruct::m_End(void) +wxPoint DrawBusEntryStruct::m_End( void ) /*************************************/ + // retourne la coord de fin du raccord { - return ( wxPoint(m_Pos.x + m_Size.x, m_Pos.y + m_Size.y) ); + return wxPoint( m_Pos.x + m_Size.x, m_Pos.y + m_Size.y ); } + /***************************************************/ -DrawBusEntryStruct * DrawBusEntryStruct::GenCopy(void) +DrawBusEntryStruct* DrawBusEntryStruct::GenCopy( void ) /***************************************************/ { -DrawBusEntryStruct * newitem = new DrawBusEntryStruct(m_Pos,0,0); + DrawBusEntryStruct* newitem = new DrawBusEntryStruct( m_Pos, 0, 0 ); - newitem->m_Layer = m_Layer; - newitem->m_Width = m_Width; - newitem->m_Size = m_Size; - newitem->m_Flags = m_Flags; + newitem->m_Layer = m_Layer; + newitem->m_Width = m_Width; + newitem->m_Size = m_Size; + newitem->m_Flags = m_Flags; - return newitem; + return newitem; } - /****************************/ - /* class DrawJunctionStruct */ - /***************************/ +/****************************/ +/* class DrawJunctionStruct */ +/***************************/ /************************************************************/ -DrawJunctionStruct::DrawJunctionStruct(const wxPoint & pos) : - EDA_BaseStruct(DRAW_JUNCTION_STRUCT_TYPE) +DrawJunctionStruct::DrawJunctionStruct( const wxPoint& pos ) : + EDA_BaseStruct( DRAW_JUNCTION_STRUCT_TYPE ) /************************************************************/ { - m_Pos = pos; - m_Layer = LAYER_JUNCTION; + m_Pos = pos; + m_Layer = LAYER_JUNCTION; } -DrawJunctionStruct * DrawJunctionStruct::GenCopy(void) + +DrawJunctionStruct* DrawJunctionStruct::GenCopy( void ) { -DrawJunctionStruct * newitem = new DrawJunctionStruct(m_Pos); + DrawJunctionStruct* newitem = new DrawJunctionStruct( m_Pos ); - newitem->m_Layer = m_Layer; - newitem->m_Flags = m_Flags; + newitem->m_Layer = m_Layer; + newitem->m_Flags = m_Flags; - return newitem; + return newitem; } - /*****************************/ - /* class DrawNoConnectStruct */ - /*****************************/ +/*****************************/ +/* class DrawNoConnectStruct */ +/*****************************/ -DrawNoConnectStruct::DrawNoConnectStruct(const wxPoint & pos) : - EDA_BaseStruct(DRAW_NOCONNECT_STRUCT_TYPE) +DrawNoConnectStruct::DrawNoConnectStruct( const wxPoint& pos ) : + EDA_BaseStruct( DRAW_NOCONNECT_STRUCT_TYPE ) { - m_Pos = pos; + m_Pos = pos; } -DrawNoConnectStruct * DrawNoConnectStruct::GenCopy(void) + +DrawNoConnectStruct* DrawNoConnectStruct::GenCopy( void ) { -DrawNoConnectStruct * newitem = new DrawNoConnectStruct(m_Pos); + DrawNoConnectStruct* newitem = new DrawNoConnectStruct( m_Pos ); - newitem->m_Flags = m_Flags; + newitem->m_Flags = m_Flags; - return newitem; + return newitem; } - /**************************/ - /* class DrawMarkerStruct */ - /**************************/ +/**************************/ +/* class DrawMarkerStruct */ +/**************************/ -DrawMarkerStruct::DrawMarkerStruct( const wxPoint & pos, const wxString & text): - EDA_BaseStruct(DRAW_MARKER_STRUCT_TYPE) +DrawMarkerStruct::DrawMarkerStruct( const wxPoint& pos, const wxString& text ) : + EDA_BaseStruct( DRAW_MARKER_STRUCT_TYPE ) { - m_Pos = pos; /* XY coordinates of marker. */ - m_Type = MARQ_UNSPEC; - m_MarkFlags = 0; // complements d'information - m_Comment = text; + m_Pos = pos; /* XY coordinates of marker. */ + m_Type = MARQ_UNSPEC; + m_MarkFlags = 0; // complements d'information + m_Comment = text; } -DrawMarkerStruct::~DrawMarkerStruct(void) + +DrawMarkerStruct::~DrawMarkerStruct( void ) { } -DrawMarkerStruct * DrawMarkerStruct::GenCopy(void) -{ -DrawMarkerStruct * newitem = new DrawMarkerStruct( m_Pos, m_Comment); - newitem->m_Type = m_Type; - newitem->m_MarkFlags = m_MarkFlags; - return newitem; +DrawMarkerStruct* DrawMarkerStruct::GenCopy( void ) +{ + DrawMarkerStruct* newitem = new DrawMarkerStruct( m_Pos, m_Comment ); + + newitem->m_Type = m_Type; + newitem->m_MarkFlags = m_MarkFlags; + + return newitem; } -wxString DrawMarkerStruct::GetComment(void) +wxString DrawMarkerStruct::GetComment( void ) { - return m_Comment; + return m_Comment; } - /***************************/ - /* Class EDA_DrawLineStruct */ - /***************************/ +/***************************/ +/* Class EDA_DrawLineStruct */ +/***************************/ -EDA_DrawLineStruct::EDA_DrawLineStruct(const wxPoint & pos, int layer ): - EDA_BaseLineStruct(NULL, DRAW_SEGMENT_STRUCT_TYPE) +EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) : + EDA_BaseLineStruct( NULL, DRAW_SEGMENT_STRUCT_TYPE ) { - m_Start = pos; - m_End = pos; - m_StartIsDangling = m_EndIsDangling = FALSE; + m_Start = pos; + m_End = pos; + m_StartIsDangling = m_EndIsDangling = FALSE; - switch(layer) - { - default: - m_Layer = LAYER_NOTES; /* Mettre ds Notes */ - m_Width = GR_NORM_WIDTH; - break; + switch( layer ) + { + default: + m_Layer = LAYER_NOTES; /* Mettre ds Notes */ + m_Width = GR_NORM_WIDTH; + break; - case LAYER_WIRE: - m_Layer = LAYER_WIRE; - m_Width = GR_NORM_WIDTH; - break; - case LAYER_BUS: - m_Layer = LAYER_BUS; - m_Width = GR_THICK_WIDTH; - break; - } + case LAYER_WIRE: + m_Layer = LAYER_WIRE; + m_Width = GR_NORM_WIDTH; + break; + + case LAYER_BUS: + m_Layer = LAYER_BUS; + m_Width = GR_THICK_WIDTH; + break; + } } + /***************************************************/ -EDA_DrawLineStruct * EDA_DrawLineStruct::GenCopy(void) +EDA_DrawLineStruct* EDA_DrawLineStruct::GenCopy( void ) /***************************************************/ { -EDA_DrawLineStruct * newitem = new EDA_DrawLineStruct(m_Start, m_Layer); + EDA_DrawLineStruct* newitem = new EDA_DrawLineStruct( m_Start, m_Layer ); - newitem->m_End = m_End; + newitem->m_End = m_End; - return newitem; + return newitem; } + /************************************************************/ -bool EDA_DrawLineStruct::IsOneEndPointAt(const wxPoint & pos) +bool EDA_DrawLineStruct::IsOneEndPointAt( const wxPoint& pos ) /************************************************************/ + /* Return TRUE if the start or the end point is in position pos -*/ + */ { - if ( (pos.x == m_Start.x) && (pos.y == m_Start.y) ) return TRUE; - if ( (pos.x == m_End.x) && (pos.y == m_End.y) ) return TRUE; - return FALSE; + if( (pos.x == m_Start.x) && (pos.y == m_Start.y) ) + return TRUE; + if( (pos.x == m_End.x) && (pos.y == m_End.y) ) + return TRUE; + return FALSE; } - /****************************/ - /* Class DrawPolylineStruct */ - /****************************/ + +/****************************/ +/* Class DrawPolylineStruct */ +/****************************/ /***********************************************************/ -DrawPolylineStruct::DrawPolylineStruct(int layer): - EDA_BaseStruct(DRAW_POLYLINE_STRUCT_TYPE) +DrawPolylineStruct::DrawPolylineStruct( int layer ) : + EDA_BaseStruct( DRAW_POLYLINE_STRUCT_TYPE ) /***********************************************************/ { - m_NumOfPoints = 0; /* Number of XY pairs in Points array. */ - m_Points = NULL; /* XY pairs that forms the polyline. */ - m_Width = GR_NORM_WIDTH; + m_NumOfPoints = 0; /* Number of XY pairs in Points array. */ + m_Points = NULL; /* XY pairs that forms the polyline. */ + m_Width = GR_NORM_WIDTH; - switch ( layer ) - { - default: - m_Layer = LAYER_NOTES; - break; + switch( layer ) + { + default: + m_Layer = LAYER_NOTES; + break; - case LAYER_WIRE: - case LAYER_NOTES: - m_Layer = layer; - break; + case LAYER_WIRE: + case LAYER_NOTES: + m_Layer = layer; + break; - case LAYER_BUS: - m_Layer = layer; - m_Width = GR_THICK_WIDTH; - break; - } + case LAYER_BUS: + m_Layer = layer; + m_Width = GR_THICK_WIDTH; + break; + } } /********************************************/ -DrawPolylineStruct::~DrawPolylineStruct(void) +DrawPolylineStruct::~DrawPolylineStruct( void ) /*********************************************/ { - if ( m_Points ) free ( m_Points ); + if( m_Points ) + free( m_Points ); } + /*****************************************************/ -DrawPolylineStruct * DrawPolylineStruct::GenCopy(void) +DrawPolylineStruct* DrawPolylineStruct::GenCopy( void ) /*****************************************************/ { -int memsize; + int memsize; -DrawPolylineStruct * newitem = - new DrawPolylineStruct( m_Layer ); + DrawPolylineStruct* newitem = + new DrawPolylineStruct( m_Layer ); - memsize = sizeof(int) * 2 * m_NumOfPoints; - newitem->m_NumOfPoints = m_NumOfPoints; - newitem->m_Points = (int *) MyZMalloc(memsize); - memcpy ( newitem->m_Points, m_Points, memsize); + memsize = sizeof(int) * 2 * m_NumOfPoints; + newitem->m_NumOfPoints = m_NumOfPoints; + newitem->m_Points = (int*) MyZMalloc( memsize ); + memcpy( newitem->m_Points, m_Points, memsize ); - return newitem; + return newitem; } - - - diff --git a/eeschema/component_class.h b/eeschema/component_class.h index fe78e5ffc1..9939d0244b 100644 --- a/eeschema/component_class.h +++ b/eeschema/component_class.h @@ -39,7 +39,8 @@ typedef enum class PartTextStruct: public EDA_BaseStruct, public EDA_TextStruct { public: - int m_FieldId; + int m_Layer; + int m_FieldId; wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1.. and for fields 1 to 8 the name is editable */ @@ -54,6 +55,7 @@ public: void SwapData(PartTextStruct * copyitem); }; + /* the class DrawPartStruct describes a basic virtual component Not used directly: used classes are EDA_SchComponentStruct (the "classic" schematic component @@ -62,6 +64,7 @@ public: class DrawPartStruct: public EDA_BaseStruct { public: + int m_Layer; wxString m_ChipName; /* Key to look for in the library, i.e. "74LS00". */ PartTextStruct m_Field[NUMBER_OF_FIELDS]; wxPoint m_Pos; /* Exact position of part. */ diff --git a/eeschema/program.h b/eeschema/program.h index 9d1e1f467a..d5c5c5cae7 100644 --- a/eeschema/program.h +++ b/eeschema/program.h @@ -106,6 +106,7 @@ class DrawBusEntryStruct: public EDA_BaseStruct /* Struct de descr 1 raccord a 45 degres de BUS ou WIRE */ { public: + int m_Layer; int m_Width; wxPoint m_Pos; wxSize m_Size; @@ -121,6 +122,7 @@ public: class DrawPolylineStruct: public EDA_BaseStruct /* Polyligne (serie de segments) */ { public: + int m_Layer; int m_Width; int m_NumOfPoints; /* Number of XY pairs in Points array. */ int *m_Points; /* XY pairs that forms the polyline. */ @@ -135,6 +137,7 @@ public: class DrawJunctionStruct: public EDA_BaseStruct { public: + int m_Layer; wxPoint m_Pos; /* XY coordinates of connection. */ public: @@ -147,6 +150,7 @@ public: class DrawTextStruct: public EDA_BaseStruct, public EDA_TextStruct { public: + int m_Layer; int m_Shape; bool m_IsDangling; // TRUE si non connecté @@ -163,6 +167,7 @@ private: void DrawAsGlobalLabel(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); }; + class DrawLabelStruct: public DrawTextStruct { public: @@ -170,6 +175,7 @@ public: ~DrawLabelStruct(void) {} }; + class DrawGlobalLabelStruct: public DrawTextStruct { public: diff --git a/gerbview/affiche.cpp b/gerbview/affiche.cpp index c6b52cf849..6c0f05a998 100644 --- a/gerbview/affiche.cpp +++ b/gerbview/affiche.cpp @@ -1,6 +1,6 @@ - /**********************************************************/ - /* Routines d'affichage de parametres et caracteristiques */ - /**********************************************************/ +/**********************************************************/ +/* Routines d'affichage de parametres et caracteristiques */ +/**********************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -13,96 +13,102 @@ /* Routines locales */ /****************************************************************************/ -void Affiche_Infos_PCB_Texte(WinEDA_BasePcbFrame * frame, TEXTE_PCB* pt_texte) +void Affiche_Infos_PCB_Texte( WinEDA_BasePcbFrame* frame, TEXTE_PCB* pt_texte ) /****************************************************************************/ + /* Affiche en bas d'ecran les caract du texte sur PCB - Entree : - pointeur de la description du texte -*/ + * Entree : + * pointeur de la description du texte + */ { -wxString Line; + wxString Line; - frame->MsgPanel->EraseMsgBox(); + frame->MsgPanel->EraseMsgBox(); - if( pt_texte->m_StructType == TYPECOTATION ) - Affiche_1_Parametre(frame, 1,_("COTATION"),pt_texte->m_Text, DARKGREEN); + if( pt_texte->m_StructType == TYPECOTATION ) + Affiche_1_Parametre( frame, 1, _( "COTATION" ), pt_texte->m_Text, DARKGREEN ); - else - Affiche_1_Parametre(frame, 1,_("PCB Text"),pt_texte->m_Text, DARKGREEN); + else + Affiche_1_Parametre( frame, 1, _( "PCB Text" ), pt_texte->m_Text, DARKGREEN ); - Line = _("Layer "); Line << pt_texte->m_Layer + 1; - Affiche_1_Parametre(frame, 28, _("Layer:"), Line, g_DesignSettings.m_LayerColor[pt_texte->m_Layer] ); + Line = _( "Layer " ); + Line << pt_texte->GetLayer() + 1; + + Affiche_1_Parametre( frame, 28, _( "Layer:" ), Line, + g_DesignSettings.m_LayerColor[pt_texte->GetLayer()] ); - Affiche_1_Parametre(frame, 36, _("Mirror"),wxEmptyString,GREEN) ; - if( (pt_texte->m_Miroir & 1) ) - Affiche_1_Parametre(frame, -1,wxEmptyString, _("No"), DARKGREEN) ; - else Affiche_1_Parametre(frame, -1,wxEmptyString, _("Yes"), DARKGREEN) ; - + Affiche_1_Parametre( frame, 36, _( "Mirror" ), wxEmptyString, GREEN ); + + if( (pt_texte->m_Miroir & 1) ) + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "No" ), DARKGREEN ); + else + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Yes" ), DARKGREEN ); - Line.Printf( wxT("%.1f"),(float)pt_texte->m_Orient/10 ); - Affiche_1_Parametre(frame, 43,_("Orient"), Line, DARKGREEN) ; - valeur_param(pt_texte->m_Width,Line) ; - Affiche_1_Parametre(frame, 50,_("Width"), Line,MAGENTA) ; + Line.Printf( wxT( "%.1f" ), (float) pt_texte->m_Orient / 10 ); + Affiche_1_Parametre( frame, 43, _( "Orient" ), Line, DARKGREEN ); - valeur_param(pt_texte->m_Size.x,Line) ; - Affiche_1_Parametre(frame, 60,_("H Size"), Line,RED) ; + valeur_param( pt_texte->m_Width, Line ); + Affiche_1_Parametre( frame, 50, _( "Width" ), Line, MAGENTA ); - valeur_param(pt_texte->m_Size.y,Line); - Affiche_1_Parametre(frame, 70,_("V Size"), Line,RED) ; + valeur_param( pt_texte->m_Size.x, Line ); + Affiche_1_Parametre( frame, 60, _( "H Size" ), Line, RED ); + valeur_param( pt_texte->m_Size.y, Line ); + Affiche_1_Parametre( frame, 70, _( "V Size" ), Line, RED ); } - /*********************************************************************/ -void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK * pt_piste) +void Affiche_Infos_Piste( WinEDA_BasePcbFrame* frame, TRACK* pt_piste ) /*********************************************************************/ /* Affiche les caract principales d'un segment de piste en bas d'ecran */ { -int d_index, ii = -1; -D_CODE * pt_D_code; -int layer = frame->GetScreen()->m_Active_Layer; -wxString msg; - - frame->MsgPanel->EraseMsgBox(); + int d_index, ii = -1; + D_CODE* pt_D_code; + int layer = frame->GetScreen()->m_Active_Layer; + wxString msg; - d_index = pt_piste->m_NetCode; - pt_D_code = ReturnToolDescr(layer, d_index, &ii); + frame->MsgPanel->EraseMsgBox(); - switch(pt_piste->m_StructType) - { - case TYPETRACK: - if ( pt_piste->m_Shape < S_SPOT_CIRCLE ) msg = wxT("LINE"); - else msg = wxT("FLASH"); - break; + d_index = pt_piste->m_NetCode; + pt_D_code = ReturnToolDescr( layer, d_index, &ii ); - case TYPEZONE: - msg = wxT("ZONE"); break; + switch( pt_piste->m_StructType ) + { + case TYPETRACK: + if( pt_piste->m_Shape < S_SPOT_CIRCLE ) + msg = wxT( "LINE" ); + else + msg = wxT( "FLASH" ); + break; - default: - msg = wxT("????"); break; - } - Affiche_1_Parametre(frame, 1, _("Type"), msg, DARKCYAN); + case TYPEZONE: + msg = wxT( "ZONE" ); break; - msg.Printf( wxT("%d"), ii+1); - Affiche_1_Parametre(frame, 10, _("Tool"), msg, RED); + default: + msg = wxT( "????" ); break; + } - if ( pt_D_code ) - { - msg.Printf( wxT("D%d"), d_index); - Affiche_1_Parametre(frame, 20, _("D CODE"),msg, BLUE); + Affiche_1_Parametre( frame, 1, _( "Type" ), msg, DARKCYAN ); - Affiche_1_Parametre(frame, 30, _("D type"), - pt_D_code ? g_GERBER_Tool_Type[pt_D_code->m_Shape] : _("????"), - BLUE); - } + msg.Printf( wxT( "%d" ), ii + 1 ); + Affiche_1_Parametre( frame, 10, _( "Tool" ), msg, RED ); - msg.Printf( wxT("%d"),pt_piste->m_Layer + 1); - Affiche_1_Parametre(frame, 40, _("Layer"), msg, BROWN) ; + if( pt_D_code ) + { + msg.Printf( wxT( "D%d" ), d_index ); + Affiche_1_Parametre( frame, 20, _( "D CODE" ), msg, BLUE ); - /* Affiche Epaisseur */ - valeur_param((unsigned)(pt_piste->m_Width), msg) ; - Affiche_1_Parametre(frame, 50, _("Width"), msg, DARKCYAN) ; + Affiche_1_Parametre( frame, 30, _( "D type" ), + pt_D_code ? g_GERBER_Tool_Type[pt_D_code->m_Shape] : _( "????" ), + BLUE ); + } + + msg.Printf( wxT( "%d" ), pt_piste->GetLayer() + 1 ); + Affiche_1_Parametre( frame, 40, _( "Layer" ), msg, BROWN ); + + /* Affiche Epaisseur */ + valeur_param( (unsigned) (pt_piste->m_Width), msg ); + Affiche_1_Parametre( frame, 50, _( "Width" ), msg, DARKCYAN ); } - diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 00c5af6ac3..a48f20a146 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -340,7 +340,7 @@ D_CODE * pt_Dcode; /* Pointeur sur le D code*/ track = m_Pcb->m_Track; for ( ; track != NULL ; track = (TRACK*) track->Pnext ) { - pt_Dcode = ReturnToolDescr(track->m_Layer, track->m_NetCode); + pt_Dcode = ReturnToolDescr(track->GetLayer(), track->m_NetCode); pt_Dcode->m_InUse = TRUE; if ( // Line Item @@ -359,8 +359,8 @@ D_CODE * pt_Dcode; /* Pointeur sur le D code*/ int width, len; wxSize size = pt_Dcode->m_Size; - width = min( size.x, size.y ); - len = max( size.x, size.y ) - width; + width = MIN( size.x, size.y ); + len = MAX( size.x, size.y ) - width; track->m_Width = width; diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp index 671a655205..9721117c89 100644 --- a/gerbview/deltrack.cpp +++ b/gerbview/deltrack.cpp @@ -30,7 +30,7 @@ void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, int dcode_value, int laye next_track = track->Next(); if( dcode_value != track->m_NetCode ) continue; - if( layer_number >= 0 && layer_number != track->m_Layer ) + if( layer_number >= 0 && layer_number != track->GetLayer() ) continue; Delete_Segment( DC, track ); } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 438007115e..57fb344117 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -1,7 +1,8 @@ /* export_to_pcbnew.cpp */ + /* -Export des couches vers pcbnew -*/ + * Export des couches vers pcbnew + */ #include "fctsys.h" @@ -11,224 +12,242 @@ Export des couches vers pcbnew #include "protos.h" /* Routines Locales : */ -static int SavePcbFormatAscii(WinEDA_GerberFrame * frame, - FILE * File, int * LayerLookUpTable); +static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, + FILE* File, int* LayerLookUpTable ); /* Variables Locales */ /************************************************************************/ -void WinEDA_GerberFrame::ExportDataInPcbnewFormat(wxCommandEvent& event) +void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) /************************************************************************/ + /* Export data in pcbnew format -*/ + */ { -wxString FullFileName, msg; -wxString PcbExt(wxT(".brd")); -FILE * dest; + wxString FullFileName, msg; - msg = wxT("*") + PcbExt; - FullFileName = EDA_FileSelector(_("Board file name:"), - wxEmptyString, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - PcbExt, /* extension par defaut */ - msg, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if ( FullFileName == wxEmptyString ) return; + wxString PcbExt( wxT( ".brd" ) ); - int * LayerLookUpTable; - if ( ( LayerLookUpTable = InstallDialogLayerPairChoice(this) ) != NULL ) - { - if ( wxFileExists(FullFileName) ) - { - if ( ! IsOK(this, _("Ok to change the existing file ?")) ) - return; - } - dest = wxFopen(FullFileName, wxT("wt")); - if (dest == 0) - { - msg = _("Unable to create ") + FullFileName; - DisplayError(this, msg) ; - return; - } - GetScreen()->m_FileName = FullFileName; - SavePcbFormatAscii(this, dest, LayerLookUpTable); - fclose(dest) ; - } + FILE* dest; + + msg = wxT( "*" ) + PcbExt; + FullFileName = EDA_FileSelector( _( "Board file name:" ), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + PcbExt, /* extension par defaut */ + msg, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if( FullFileName == wxEmptyString ) + return; + + int* LayerLookUpTable; + if( ( LayerLookUpTable = InstallDialogLayerPairChoice( this ) ) != NULL ) + { + if( wxFileExists( FullFileName ) ) + { + if( !IsOK( this, _( "Ok to change the existing file ?" ) ) ) + return; + } + dest = wxFopen( FullFileName, wxT( "wt" ) ); + if( dest == 0 ) + { + msg = _( "Unable to create " ) + FullFileName; + DisplayError( this, msg ); + return; + } + GetScreen()->m_FileName = FullFileName; + SavePcbFormatAscii( this, dest, LayerLookUpTable ); + fclose( dest ); + } } /***************************************************************/ -static int WriteSetup(FILE * File, BOARD * Pcb) +static int WriteSetup( FILE* File, BOARD* Pcb ) /***************************************************************/ { -char text[1024]; + char text[1024]; - fprintf(File,"$SETUP\n"); - sprintf(text, "InternalUnit %f INCH\n", 1.0/PCB_INTERNAL_UNIT); - fprintf(File, text); - - Pcb->m_BoardSettings->m_CopperLayerCount = g_DesignSettings.m_CopperLayerCount; - fprintf(File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount); + fprintf( File, "$SETUP\n" ); + sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT ); + fprintf( File, text ); - fprintf(File,"$EndSETUP\n\n"); - return(1); + Pcb->m_BoardSettings->m_CopperLayerCount = g_DesignSettings.m_CopperLayerCount; + fprintf( File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount ); + + fprintf( File, "$EndSETUP\n\n" ); + return 1; } + /******************************************************/ -static bool WriteGeneralDescrPcb(BOARD * Pcb, FILE * File) +static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File ) /******************************************************/ { -int NbLayers; + int NbLayers; - /* generation du masque des couches autorisees */ - NbLayers = Pcb->m_BoardSettings->m_CopperLayerCount; - fprintf(File,"$GENERAL\n"); - fprintf(File,"LayerCount %d\n",NbLayers); + /* generation du masque des couches autorisees */ + NbLayers = Pcb->m_BoardSettings->m_CopperLayerCount; + fprintf( File, "$GENERAL\n" ); + fprintf( File, "LayerCount %d\n", NbLayers ); - /* Generation des coord du rectangle d'encadrement */ - Pcb->ComputeBoundaryBox(); - fprintf(File,"Di %d %d %d %d\n", - Pcb->m_BoundaryBox.GetX(), Pcb->m_BoundaryBox.GetY(), - Pcb->m_BoundaryBox.GetRight(), - Pcb->m_BoundaryBox.GetBottom()); + /* Generation des coord du rectangle d'encadrement */ + Pcb->ComputeBoundaryBox(); + fprintf( File, "Di %d %d %d %d\n", + Pcb->m_BoundaryBox.GetX(), Pcb->m_BoundaryBox.GetY(), + Pcb->m_BoundaryBox.GetRight(), + Pcb->m_BoundaryBox.GetBottom() ); - fprintf(File,"$EndGENERAL\n\n"); - return TRUE; + fprintf( File, "$EndGENERAL\n\n" ); + return TRUE; } /*******************************************************************/ -static int SavePcbFormatAscii(WinEDA_GerberFrame * frame,FILE * File, - int * LayerLookUpTable) +static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File, + int* LayerLookUpTable ) /*******************************************************************/ + /* Routine de sauvegarde du PCB courant sous format ASCII - retourne - 1 si OK - 0 si sauvegarde non faite -*/ + * retourne + * 1 si OK + * 0 si sauvegarde non faite + */ { -char Line[256]; -TRACK * track, *next_track; -EDA_BaseStruct * PtStruct, *NextStruct; -BOARD * GerberPcb = frame->m_Pcb; -BOARD * Pcb; - - wxBeginBusyCursor(); - - /* Create an image of gerber data */ - Pcb = new BOARD(NULL, frame); - for(track = GerberPcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) - { - int layer = track->m_Layer; - int pcb_layer_number = LayerLookUpTable[layer]; - if ( pcb_layer_number < 0 ) continue; - if ( pcb_layer_number > CMP_N ) - { - DRAWSEGMENT * drawitem = new DRAWSEGMENT(NULL, TYPEDRAWSEGMENT); - drawitem->m_Layer = pcb_layer_number; - drawitem->m_Start = track->m_Start; - drawitem->m_End = track->m_End; - drawitem->m_Width = track->m_Width; - drawitem->Pnext = Pcb->m_Drawings; - Pcb->m_Drawings = drawitem; - } - else - { - TRACK * newtrack = new TRACK(*track); - newtrack->m_Layer = pcb_layer_number; - newtrack->Insert(Pcb, NULL); - } - } + char Line[256]; + TRACK* track, * next_track; + BOARD_ITEM* PtStruct; + BOARD_ITEM* NextStruct; + BOARD* GerberPcb = frame->m_Pcb; + BOARD* Pcb; - /* replace spots by vias when possible */ - for(track = Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) - { - if( (track->m_Shape != S_SPOT_CIRCLE) && (track->m_Shape != S_SPOT_RECT) && (track->m_Shape != S_SPOT_OVALE) ) - continue; - /* A spot is found, and can be a via: change it for via, and delete others - spots at same location */ - track->m_Shape = VIA_NORMALE; - track->m_StructType = TYPEVIA; - track->m_Layer = 0x0F; // Layers are 0 to 15 (Cu/Cmp) - track->m_Drill = -1; - /* Compute the via position from track position ( Via position is the position of the middle of the track segment */ - track->m_Start.x = (track->m_Start.x +track->m_End.x)/2; - track->m_Start.y = (track->m_Start.y +track->m_End.y)/2; - track->m_End = track->m_Start; - } - /* delete redundant vias */ - for(track = Pcb->m_Track; track != NULL; track = track->Next()) - { - if( track->m_Shape != VIA_NORMALE ) continue; - /* Search and delete others vias*/ - TRACK * alt_track = track->Next(); - for( ; alt_track != NULL; alt_track = next_track) - { - next_track = (TRACK*) alt_track->Pnext; - if( alt_track->m_Shape != VIA_NORMALE ) continue; - if ( alt_track->m_Start != track->m_Start ) continue; - /* delete track */ - alt_track->UnLink(); - delete alt_track; - } - } + wxBeginBusyCursor(); - - // Switch the locale to standard C (needed to print floating point numbers like 1.3) - setlocale(LC_NUMERIC, "C"); - /* Ecriture de l'entete PCB : */ - fprintf(File,"PCBNEW-BOARD Version %d date %s\n\n",g_CurrentVersionPCB, - DateAndTime(Line) ); - WriteGeneralDescrPcb(Pcb, File); - WriteSetup(File, Pcb); + /* Create an image of gerber data */ + Pcb = new BOARD( NULL, frame ); - /* Ecriture des donnes utiles du pcb */ - PtStruct = Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch ( PtStruct->m_StructType ) - { - case TYPETEXTE: - ((TEXTE_PCB*)PtStruct)->WriteTextePcbDescr(File) ; - break; + for( track = GerberPcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + { + int layer = track->GetLayer(); + int pcb_layer_number = LayerLookUpTable[layer]; + if( pcb_layer_number < 0 ) + continue; + if( pcb_layer_number > CMP_N ) + { + DRAWSEGMENT* drawitem = new DRAWSEGMENT( NULL, TYPEDRAWSEGMENT ); - case TYPEDRAWSEGMENT: - ((DRAWSEGMENT *)PtStruct)->WriteDrawSegmentDescr(File); - break; + drawitem->SetLayer( pcb_layer_number ); + drawitem->m_Start = track->m_Start; + drawitem->m_End = track->m_End; + drawitem->m_Width = track->m_Width; + drawitem->Pnext = Pcb->m_Drawings; + Pcb->m_Drawings = drawitem; + } + else + { + TRACK* newtrack = new TRACK( * track ); - default: - break; - } - } + newtrack->SetLayer( pcb_layer_number ); + newtrack->Insert( Pcb, NULL ); + } + } - fprintf(File,"$TRACK\n"); - for(track = Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) - { - track->WriteTrackDescr(File); - } + /* replace spots by vias when possible */ + for( track = Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + { + if( (track->m_Shape != S_SPOT_CIRCLE) && (track->m_Shape != S_SPOT_RECT) && + (track->m_Shape != S_SPOT_OVALE) ) + continue; - fprintf(File,"$EndTRACK\n"); + /* A spot is found, and can be a via: change it for via, and delete others + * spots at same location */ + track->m_Shape = VIA_NORMALE; + track->m_StructType = TYPEVIA; + track->SetLayer( 0x0F ); // Layers are 0 to 15 (Cu/Cmp) + track->m_Drill = -1; + /* Compute the via position from track position ( Via position is the position of the middle of the track segment */ + track->m_Start.x = (track->m_Start.x + track->m_End.x) / 2; + track->m_Start.y = (track->m_Start.y + track->m_End.y) / 2; + track->m_End = track->m_Start; + } - fprintf(File,"$EndBOARD\n"); + /* delete redundant vias */ + for( track = Pcb->m_Track; track != NULL; track = track->Next() ) + { + if( track->m_Shape != VIA_NORMALE ) + continue; + /* Search and delete others vias*/ + TRACK* alt_track = track->Next(); + for( ; alt_track != NULL; alt_track = next_track ) + { + next_track = (TRACK*) alt_track->Pnext; + if( alt_track->m_Shape != VIA_NORMALE ) + continue; + if( alt_track->m_Start != track->m_Start ) + continue; + /* delete track */ + alt_track->UnLink(); + delete alt_track; + } + } - /* Delete the copy */ - for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = NextStruct ) - { - NextStruct = PtStruct->Pnext; - delete PtStruct; - } - for(track = Pcb->m_Track; track != NULL; track = next_track) - { - next_track = (TRACK*) track->Pnext; - delete track; - } - delete Pcb; + // Switch the locale to standard C (needed to print floating point numbers like 1.3) + setlocale( LC_NUMERIC, "C" ); + /* Ecriture de l'entete PCB : */ + fprintf( File, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, + DateAndTime( Line ) ); + WriteGeneralDescrPcb( Pcb, File ); + WriteSetup( File, Pcb ); - setlocale(LC_NUMERIC, ""); // revert to the current locale - wxEndBusyCursor(); - return 1; + /* Ecriture des donnes utiles du pcb */ + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPETEXTE: + ( (TEXTE_PCB*) PtStruct )->WriteTextePcbDescr( File ); + break; + + case TYPEDRAWSEGMENT: + ( (DRAWSEGMENT*) PtStruct )->WriteDrawSegmentDescr( File ); + break; + + default: + break; + } + } + + fprintf( File, "$TRACK\n" ); + for( track = Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + { + track->WriteTrackDescr( File ); + } + + fprintf( File, "$EndTRACK\n" ); + + fprintf( File, "$EndBOARD\n" ); + + /* Delete the copy */ + for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = NextStruct ) + { + NextStruct = PtStruct->Next(); + delete PtStruct; + } + + for( track = Pcb->m_Track; track != NULL; track = next_track ) + { + next_track = (TRACK*) track->Pnext; + delete track; + } + + delete Pcb; + + setlocale( LC_NUMERIC, "" ); // revert to the current locale + wxEndBusyCursor(); + return 1; } diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index b707c811d5..43449824c9 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -1,7 +1,7 @@ - /**********************************************/ - /* GERBVIEW : Routines d'initialisation globale */ - /******* Fichier INITPCB.C ********************/ - /**********************************************/ +/**********************************************/ +/* GERBVIEW : Routines d'initialisation globale */ +/******* Fichier INITPCB.C ********************/ +/**********************************************/ #include "fctsys.h" @@ -14,205 +14,201 @@ /* Routines Locales */ +/********************************************************/ +bool WinEDA_GerberFrame::Clear_Pcb( wxDC* DC, bool query ) +/********************************************************/ -/********************************************************/ -bool WinEDA_GerberFrame::Clear_Pcb(wxDC * DC, bool query) -/********************************************************/ /* Realise les init des pointeurs et variables - Si Item == NULL, il n'y aura pas de confirmation -*/ + * Si Item == NULL, il n'y aura pas de confirmation + */ { -int layer; + int layer; - if( m_Pcb == NULL ) return FALSE; + if( m_Pcb == NULL ) + return FALSE; - if ( query ) - { - if (m_Pcb->m_Drawings || m_Pcb->m_Track || m_Pcb->m_Zone ) - { - if( ! IsOK(this, _("Current Data will be lost ?")) ) return FALSE; - } - } + if( query ) + { + if( m_Pcb->m_Drawings || m_Pcb->m_Track || m_Pcb->m_Zone ) + { + if( !IsOK( this, _( "Current Data will be lost ?" ) ) ) + return FALSE; + } + } - DeleteStructList(m_Pcb->m_Drawings); - m_Pcb->m_Drawings = NULL; + DeleteStructList( m_Pcb->m_Drawings ); + m_Pcb->m_Drawings = NULL; - DeleteStructList(m_Pcb->m_Track); - m_Pcb->m_Track = NULL; - m_Pcb->m_NbSegmTrack = 0; + DeleteStructList( m_Pcb->m_Track ); + m_Pcb->m_Track = NULL; + m_Pcb->m_NbSegmTrack = 0; - DeleteStructList(m_Pcb->m_Zone); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; + DeleteStructList( m_Pcb->m_Zone ); + m_Pcb->m_Zone = NULL; + m_Pcb->m_NbSegmZone = 0; - for ( ; g_UnDeleteStackPtr != 0; ) - { - g_UnDeleteStackPtr--; - DeleteStructList(g_UnDeleteStack[ g_UnDeleteStackPtr]); - } + for( ; g_UnDeleteStackPtr != 0; ) + { + g_UnDeleteStackPtr--; + DeleteStructList( g_UnDeleteStack[ g_UnDeleteStackPtr] ); + } - /* init pointeurs et variables */ - for ( layer = 0; layer < 32; layer++ ) - { - if ( g_GERBER_Descr_List[layer] ) - g_GERBER_Descr_List[layer]->InitToolTable(); - } + /* init pointeurs et variables */ + for( layer = 0; layer < 32; layer++ ) + { + if( g_GERBER_Descr_List[layer] ) + g_GERBER_Descr_List[layer]->InitToolTable(); + } - /* remise a 0 ou a une valeur initiale des variables de la structure */ - m_Pcb->m_BoundaryBox.SetOrigin(0,0); - m_Pcb->m_BoundaryBox.SetSize(0,0); - m_Pcb->m_Status_Pcb = 0; - m_Pcb->m_NbLoclinks = 0; - m_Pcb->m_NbLinks = 0; - m_Pcb->m_NbPads = 0; - m_Pcb->m_NbNets = 0; - m_Pcb->m_NbNodes = 0; - m_Pcb->m_NbNoconnect = 0; - m_Pcb->m_NbSegmTrack = 0; - m_Pcb->m_NbSegmZone = 0; + /* remise a 0 ou a une valeur initiale des variables de la structure */ + m_Pcb->m_BoundaryBox.SetOrigin( 0, 0 ); + m_Pcb->m_BoundaryBox.SetSize( 0, 0 ); + m_Pcb->m_Status_Pcb = 0; + m_Pcb->m_NbLoclinks = 0; + m_Pcb->m_NbLinks = 0; + m_Pcb->m_NbPads = 0; + m_Pcb->m_NbNets = 0; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbNoconnect = 0; + m_Pcb->m_NbSegmTrack = 0; + m_Pcb->m_NbSegmZone = 0; - /* Init parametres de gestion des ecrans PAD et PCB */ - m_CurrentScreen = ActiveScreen = ScreenPcb; - GetScreen()->Init(); + /* Init parametres de gestion des ecrans PAD et PCB */ + m_CurrentScreen = ActiveScreen = ScreenPcb; + GetScreen()->Init(); - return TRUE; + return TRUE; } + /*********************************************************/ -void WinEDA_GerberFrame::Erase_Zones(wxDC * DC, bool query) +void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query ) /*********************************************************/ { + if( query && !IsOK( this, _( "Delete zones ?" ) ) ) + return; - if( query && !IsOK(this, _("Delete zones ?") ) ) return ; - - if( m_Pcb->m_Zone ) - { - DeleteStructList(m_Pcb->m_Zone); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; - } - ScreenPcb->SetModify(); + if( m_Pcb->m_Zone ) + { + DeleteStructList( m_Pcb->m_Zone ); + m_Pcb->m_Zone = NULL; + m_Pcb->m_NbSegmZone = 0; + } + ScreenPcb->SetModify(); } /*****************************************************/ -void WinEDA_GerberFrame::Erase_Segments_Pcb(wxDC * DC, - bool all_layers, bool query) +void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC, + bool all_layers, bool query ) /*****************************************************/ { -EDA_BaseStruct * PtStruct, *PtNext; -int layer = GetScreen()->m_Active_Layer; + BOARD_ITEM* PtStruct; + BOARD_ITEM* PtNext; + int layer = GetScreen()->m_Active_Layer; - if ( all_layers ) layer = -1; + if( all_layers ) + layer = -1; - PtStruct = (EDA_BaseStruct *) m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtNext) - { - PtNext = PtStruct->Pnext; - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - if( (((DRAWSEGMENT*)PtStruct)->m_Layer == layer) - || layer < 0) - DeleteStructure(PtStruct); - break; + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + PtNext = PtStruct->Next(); - case TYPETEXTE: - if( (((TEXTE_PCB*)PtStruct)->m_Layer == layer) - || layer < 0) - DeleteStructure(PtStruct); - break; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + case TYPETEXTE: + case TYPECOTATION: + case TYPEMIRE: + if( PtStruct->GetLayer() == layer || layer < 0 ) + DeleteStructure( PtStruct ); + break; - case TYPECOTATION: - if( (((COTATION*)PtStruct)->m_Layer == layer) - || layer < 0) - DeleteStructure(PtStruct); - break; + default: + DisplayError( this, wxT( "Type Draw inconnu/inattendu" ) ); + break; + } + } - case TYPEMIRE: - if( (((MIREPCB*)PtStruct)->m_Layer == layer) - || layer < 0) - DeleteStructure(PtStruct); - break; - - default: - DisplayError(this, wxT("Type Draw inconnu/inattendu")); - break; - } - } - - ScreenPcb->SetModify(); + ScreenPcb->SetModify(); } /****************************************************************/ -void WinEDA_GerberFrame::Erase_Pistes(wxDC * DC, int masque_type, - bool query) +void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type, + bool query ) /****************************************************************/ + /* Efface les segments de piste, selon les autorisations affichees -masque_type = masque des options de selection: -SEGM_FIXE, SEGM_AR - Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 -*/ + * masque_type = masque des options de selection: + * SEGM_FIXE, SEGM_AR + * Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 + */ { -TRACK * pt_segm; -EDA_BaseStruct * PtNext; + TRACK* pt_segm; + BOARD_ITEM* PtNext; - if( query && ! IsOK(this, _("Delete Tracks?")) ) return; + if( query && !IsOK( this, _( "Delete Tracks?" ) ) ) + return; - /* Marquage des pistes a effacer */ - for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext) - { - PtNext = pt_segm->Pnext; - if( pt_segm->GetState(SEGM_FIXE|SEGM_AR) & masque_type) continue; - DeleteStructure(pt_segm); - } + /* Marquage des pistes a effacer */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext ) + { + PtNext = pt_segm->Next(); + if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type ) + continue; + DeleteStructure( pt_segm ); + } - ScreenPcb->SetModify(); + ScreenPcb->SetModify(); } /*****************************************************************/ -void WinEDA_GerberFrame::Erase_Textes_Pcb(wxDC * DC, bool query) +void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query ) /*****************************************************************/ { -EDA_BaseStruct * PtStruct, *PtNext; + BOARD_ITEM* PtStruct; + BOARD_ITEM* PtNext; - if( query && ! IsOK(this, _("Delete Pcb Texts") ) ) return; + if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) ) + return; - PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtNext) - { - PtNext = PtStruct->Pnext; - if(PtStruct->m_StructType == TYPETEXTE ) DeleteStructure(PtStruct); - } + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + PtNext = PtStruct->Next(); + if( PtStruct->m_StructType == TYPETEXTE ) + DeleteStructure( PtStruct ); + } - ScreenPcb->SetModify(); + ScreenPcb->SetModify(); } + /*******************************************************************/ -void WinEDA_GerberFrame::Erase_Current_Layer(wxDC * DC, bool query) +void WinEDA_GerberFrame::Erase_Current_Layer( wxDC* DC, bool query ) /*******************************************************************/ { -TRACK * pt_segm; -EDA_BaseStruct * PtNext; -int layer = GetScreen()->m_Active_Layer; -wxString msg; + TRACK* pt_segm; + BOARD_ITEM* PtNext; + int layer = GetScreen()->m_Active_Layer; + wxString msg; - msg.Printf( _("Delete Layer %d"), layer+1); - if( query && ! IsOK(this, msg) ) return; + msg.Printf( _( "Delete Layer %d" ), layer + 1 ); + if( query && !IsOK( this, msg ) ) + return; - /* Marquage des pistes a effacer */ - for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext) - { - PtNext = pt_segm->Pnext; - if( pt_segm->m_Layer != layer) continue; - DeleteStructure(pt_segm); - } + /* Marquage des pistes a effacer */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext ) + { + PtNext = pt_segm->Next(); + if( pt_segm->GetLayer() != layer ) + continue; + DeleteStructure( pt_segm ); + } - ScreenPcb->SetModify(); - ScreenPcb->SetRefreshReq(); + ScreenPcb->SetModify(); + ScreenPcb->SetRefreshReq(); } - - - diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index a55aa2c27d..aedc66708c 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -102,7 +102,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) * NULL si rien trouve */ { - EDA_BaseStruct* PtStruct; + BOARD_ITEM* PtStruct; DRAWSEGMENT* pts; wxPoint ref; PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen; @@ -110,7 +110,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) SET_REF_POS( ref ); PtStruct = Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; @@ -121,7 +121,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; /* detection : */ - if( pts->m_Layer != screen->m_Active_Layer ) + if( pts->GetLayer() != screen->m_Active_Layer ) continue; if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) ) @@ -208,7 +208,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer ) } if( Layer >= 0 ) - if( Track->m_Layer != Layer ) + if( Track->GetLayer() != Layer ) continue;/* Segments sur couches differentes */ if( distance( l_piste ) ) return Track; @@ -260,7 +260,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ) dx -= ux0; dy -= uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; - if( (layer != -1) && (Zone->m_Layer != layer) ) + if( (layer != -1) && (Zone->GetLayer() != layer) ) continue; if( distance( l_segm ) ) return Zone; diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index a772ba81b9..99a4db3b8d 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -105,7 +105,7 @@ TRACK * track; track = new TRACK(frame->m_Pcb); track->Insert(frame->m_Pcb, NULL); - track->m_Layer = frame->GetScreen()->m_Active_Layer; + track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->m_Width = diametre ; track->m_Start = track->m_End = pos; NEGATE(track->m_Start.y); @@ -129,13 +129,13 @@ static void Append_1_Flash_GERBER(int Dcode_index, TRACK * track; int width, len; - width = min( size.x, size.y ); - len = max( size.x, size.y ) - width; + width = MIN( size.x, size.y ); + len = MAX( size.x, size.y ) - width; track = new TRACK(frame->m_Pcb); track->Insert(frame->m_Pcb, NULL); - track->m_Layer = frame->GetScreen()->m_Active_Layer; + track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->m_Width = width; track->m_Start = track->m_End = pos; NEGATE(track->m_Start.y); @@ -176,7 +176,7 @@ TRACK * track; track = new TRACK( frame->m_Pcb ); track->Insert(frame->m_Pcb, NULL); - track->m_Layer = frame->GetScreen()->m_Active_Layer ; + track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->m_Width = largeur ; track->m_Start = startpoint; NEGATE(track->m_Start.y); @@ -213,7 +213,7 @@ wxPoint center, delta; track->Insert(frame->m_Pcb, NULL); track->m_Shape = S_ARC; - track->m_Layer = frame->GetScreen()->m_Active_Layer ; + track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->m_Width = largeur ; if ( multiquadrant ) @@ -555,7 +555,7 @@ bool GERBER_Descr::Execute_G_Command(char * &text, int G_commande) if ( D_commande < FIRST_DCODE) return FALSE; if (D_commande > (MAX_TOOLS-1)) D_commande = MAX_TOOLS-1; m_Current_Tool = D_commande; - D_CODE * pt_Dcode = ReturnToolDescr(m_Layer, D_commande); + D_CODE * pt_Dcode = ReturnToolDescr( m_Layer, D_commande ); if ( pt_Dcode ) pt_Dcode->m_InUse = TRUE; break; } @@ -643,7 +643,7 @@ wxString msg; if ( last ) while (last->Pnext ) last = (SEGZONE*)last->Pnext; edge_poly->Insert(frame->m_Pcb, last); - edge_poly->m_Layer = frame->GetScreen()->m_Active_Layer ; + edge_poly->SetLayer( frame->GetScreen()->m_Active_Layer ); edge_poly->m_Width = 1; edge_poly->m_Start = m_PreviousPos; NEGATE(edge_poly->m_Start.y); diff --git a/gerbview/tracepcb.cpp b/gerbview/tracepcb.cpp index 11d04e9baf..fa7fc243fc 100644 --- a/gerbview/tracepcb.cpp +++ b/gerbview/tracepcb.cpp @@ -116,7 +116,7 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay { if( nbpoints ) { - int Color = g_DesignSettings.m_LayerColor[track->m_Layer]; + int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, 1, Color, Color ); } @@ -141,7 +141,7 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay } if( track->Next() == NULL ) // Last point { - int Color = g_DesignSettings.m_LayerColor[track->m_Layer]; + int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, 1, Color, Color ); } diff --git a/gerbview/trpiste.cpp b/gerbview/trpiste.cpp index 3bf495e3e7..90782c1df2 100644 --- a/gerbview/trpiste.cpp +++ b/gerbview/trpiste.cpp @@ -1,6 +1,6 @@ - /*****************************************************************/ - /* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */ - /*****************************************************************/ +/*****************************************************************/ +/* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */ +/*****************************************************************/ #include "fctsys.h" @@ -17,342 +17,353 @@ /* variables locales : */ /***************************************************************************************************/ -void Draw_Track_Buffer(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int draw_mode, int printmasklayer) +void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_mode, + int printmasklayer ) /***************************************************************************************************/ + /* Function to draw the tracks (i.e Sports or lines) in gerbview - Polygons are not handled here (there are in Pcb->m_Zone) + * Polygons are not handled here (there are in Pcb->m_Zone) * @param DC = device context to draw * @param Pcb = Board to draw (only Pcb->m_Track is used) * @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..) * @param printmasklayer = mask for allowed layer (=-1 to draw all layers) -*/ + */ { -TRACK * Track; -int layer = ((PCB_SCREEN*)panel->GetScreen())->m_Active_Layer; -GERBER_Descr * gerber_layer = g_GERBER_Descr_List[layer]; -int dcode_hightlight = 0; + TRACK* Track; + int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; + GERBER_Descr* gerber_layer = g_GERBER_Descr_List[layer]; + int dcode_hightlight = 0; - if ( gerber_layer ) - dcode_hightlight = gerber_layer->m_Selected_Tool; + if( gerber_layer ) + dcode_hightlight = gerber_layer->m_Selected_Tool; - Track = Pcb->m_Track; - for ( ; Track != NULL ; Track = (TRACK*) Track->Pnext ) - { - if ( printmasklayer != -1 ) - if ( (Track->ReturnMaskLayer() & printmasklayer) == 0 ) continue; + Track = Pcb->m_Track; + for( ; Track != NULL; Track = (TRACK*) Track->Pnext ) + { + if( printmasklayer != -1 ) + if( (Track->ReturnMaskLayer() & printmasklayer) == 0 ) + continue; - if ( (dcode_hightlight == Track->m_NetCode) && - (Track->m_Layer == layer) ) - Trace_Segment(panel, DC, Track, draw_mode | GR_SURBRILL); - else Trace_Segment(panel, DC, Track, draw_mode ); - } + if( (dcode_hightlight == Track->m_NetCode) + && (Track->GetLayer() == layer) ) + Trace_Segment( panel, DC, Track, draw_mode | GR_SURBRILL ); + else + Trace_Segment( panel, DC, Track, draw_mode ); + } } /***********************************************************************************/ -void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* track, int draw_mode) +void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mode ) /***********************************************************************************/ + /* routine de trace de 1 segment de piste. -Parametres : - track = adresse de la description de la piste en buflib - draw_mode = mode ( GR_XOR, GR_OR..) -*/ + * Parametres : + * track = adresse de la description de la piste en buflib + * draw_mode = mode ( GR_XOR, GR_OR..) + */ { -int l_piste; -int color; -int zoom; -int rayon; -int fillopt; -static bool show_err; + int l_piste; + int color; + int zoom; + int rayon; + int fillopt; + static bool show_err; - color = g_DesignSettings.m_LayerColor[track->m_Layer]; - if(color & ITEM_NOT_SHOW ) return ; + color = g_DesignSettings.m_LayerColor[track->GetLayer()]; + if( color & ITEM_NOT_SHOW ) + return; - zoom = panel->GetZoom(); + zoom = panel->GetZoom(); - GRSetDrawMode(DC, draw_mode); - 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; + GRSetDrawMode( DC, draw_mode ); + 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; - rayon = l_piste = track->m_Width >> 1; + rayon = l_piste = track->m_Width >> 1; - fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; + fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; - switch (track->m_Shape) - { - case S_CIRCLE: - rayon = (int)hypot((double)(track->m_End.x-track->m_Start.x), - (double)(track->m_End.y-track->m_Start.y) ); - if ( (l_piste/zoom) < L_MIN_DESSIN) - { - GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon , 0, color) ; - } + switch( track->m_Shape ) + { + case S_CIRCLE: + rayon = (int) hypot( (double) (track->m_End.x - track->m_Start.x), + (double) (track->m_End.y - track->m_Start.y) ); + if( (l_piste / zoom) < L_MIN_DESSIN ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, 0, color ); + } - if( fillopt == SKETCH) - { - GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon-l_piste, 0, color); - GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon+l_piste, 0, color); - } - else - { - GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon, track->m_Width,color); - } - break; + if( fillopt == SKETCH ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon - l_piste, 0, color ); + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon + l_piste, 0, color ); + } + else + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, track->m_Width, color ); + } + break; - case S_ARC: - { - if( fillopt == SKETCH) - { - GRArc1(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, - track->m_Param, track->m_Sous_Netcode, 0, color); - } - else - { - GRArc1(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, - track->m_Param,track->m_Sous_Netcode, - track->m_Width, color); - } - } - break; + case S_ARC: + { + if( fillopt == SKETCH ) + { + GRArc1( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Param, track->m_Sous_Netcode, 0, color ); + } + else + { + GRArc1( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Param, track->m_Sous_Netcode, + track->m_Width, color ); + } + } + break; - case S_SPOT_CIRCLE: - fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - if ( (rayon/zoom) < L_MIN_DESSIN) - { - GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon , 0, color) ; - } + case S_SPOT_CIRCLE: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + if( (rayon / zoom) < L_MIN_DESSIN ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, 0, color ); + } + else if( fillopt == SKETCH ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, 0, color ); + } + else + { + GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, 0, color, color ); + } + break; - else if( fillopt == SKETCH ) - { - GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon, 0, color); - } - else - { - GRFilledCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - rayon, 0, color, color); - } - break; + case S_SPOT_RECT: + case S_RECT: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + if( (l_piste / zoom) < L_MIN_DESSIN ) + { + GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, 0, color ); + } + else if( fillopt == SKETCH ) + { + GRRect( &panel->m_ClipBox, DC, + track->m_Start.x - l_piste, + track->m_Start.y - l_piste, + track->m_End.x + l_piste, + track->m_End.y + l_piste, + 0, color ); + } + else + { + GRFilledRect( &panel->m_ClipBox, DC, + track->m_Start.x - l_piste, + track->m_Start.y - l_piste, + track->m_End.x + l_piste, + track->m_End.y + l_piste, + 0, color, color ); + } + break; - case S_SPOT_RECT: - case S_RECT: - fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - if ( (l_piste/zoom) < L_MIN_DESSIN) - { - GRLine(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, 0, color); - } - else if( fillopt == SKETCH ) - { - GRRect(&panel->m_ClipBox, DC, - track->m_Start.x - l_piste, - track->m_Start.y - l_piste, - track->m_End.x + l_piste, - track->m_End.y + l_piste, - 0, color) ; - } - else - { - GRFilledRect(&panel->m_ClipBox, DC, - track->m_Start.x - l_piste, - track->m_Start.y - l_piste, - track->m_End.x + l_piste, - track->m_End.y + l_piste, - 0, color, color) ; - } - break; + case S_SPOT_OVALE: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - case S_SPOT_OVALE: - fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - case S_SEGMENT: - if ( (l_piste/zoom) < L_MIN_DESSIN) - { - GRLine(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, 0, color); - break; - } + case S_SEGMENT: + if( (l_piste / zoom) < L_MIN_DESSIN ) + { + GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, 0, color ); + break; + } - if( fillopt == SKETCH ) - { - GRCSegm(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, - track->m_Width, color) ; - } - else - { - GRFillCSegm(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, - track->m_Width, color) ; - } - break; + if( fillopt == SKETCH ) + { + GRCSegm( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Width, color ); + } + else + { + GRFillCSegm( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Width, color ); + } + break; - default: - if ( ! show_err ) - { - DisplayError(panel, wxT("Trace_Segment() type error")); - show_err = TRUE; - } - break; - } + default: + if( !show_err ) + { + DisplayError( panel, wxT( "Trace_Segment() type error" ) ); + show_err = TRUE; + } + break; + } } + /**************************************************************************/ -void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC, - DRAWSEGMENT * PtDrawSegment, int draw_mode) +void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC, + DRAWSEGMENT* PtDrawSegment, int draw_mode ) /**************************************************************************/ + /* Affichage d'un segment type drawing PCB: - Entree : ox, oy = offset de trace - draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND) - Les contours sont de differents type: - segment - cercle - arc -*/ + * Entree : ox, oy = offset de trace + * draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND) + * Les contours sont de differents type: + * segment + * cercle + * arc + */ { -int ux0, uy0, dx, dy; -int l_piste; -int color, mode; -int zoom = panel->GetZoom(); -int rayon; + int ux0, uy0, dx, dy; + int l_piste; + int color, mode; + int zoom = panel->GetZoom(); + int rayon; - color = g_DesignSettings.m_LayerColor[PtDrawSegment->m_Layer]; - if(color & ITEM_NOT_SHOW ) return ; + color = g_DesignSettings.m_LayerColor[PtDrawSegment->GetLayer()]; + if( color & ITEM_NOT_SHOW ) + return; - GRSetDrawMode(DC, draw_mode); - l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */ + GRSetDrawMode( DC, draw_mode ); + l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */ - /* coord de depart */ - ux0 = PtDrawSegment->m_Start.x; - uy0 = PtDrawSegment->m_Start.y; - /* coord d'arrivee */ - dx = PtDrawSegment->m_End.x; - dy = PtDrawSegment->m_End.y; + /* coord de depart */ + ux0 = PtDrawSegment->m_Start.x; + uy0 = PtDrawSegment->m_Start.y; + /* coord d'arrivee */ + dx = PtDrawSegment->m_End.x; + dy = PtDrawSegment->m_End.y; - mode = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; - if(PtDrawSegment->m_Flags & FORCE_SKETCH) mode = SKETCH; - if ( l_piste < (L_MIN_DESSIN * zoom) ) mode = FILAIRE; + mode = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; + if( PtDrawSegment->m_Flags & FORCE_SKETCH ) + mode = SKETCH; + if( l_piste < (L_MIN_DESSIN * zoom) ) + mode = FILAIRE; - switch (PtDrawSegment->m_Shape) - { - case S_CIRCLE: - rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); - if ( mode == FILAIRE) - { - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, 0, color) ; - } - else if( mode == SKETCH) - { - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon-l_piste, 0, color); - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon+l_piste, 0, color); - } - else - { - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width,color); - } - break; + switch( PtDrawSegment->m_Shape ) + { + case S_CIRCLE: + rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + if( mode == FILAIRE ) + { + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, 0, color ); + } + else if( mode == SKETCH ) + { + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, 0, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, 0, color ); + } + else + { + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width, color ); + } + break; - case S_ARC: - { - int StAngle, EndAngle; - rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); - StAngle = (int) ArcTangente(dy-uy0, dx-ux0); - EndAngle = StAngle + PtDrawSegment->m_Angle; - if ( mode == FILAIRE) - GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, 0, color); - else if( mode == SKETCH) - { - GRArc(&panel->m_ClipBox, DC, ux0, uy0, 0, StAngle, EndAngle, - rayon - l_piste, color); - GRArc(&panel->m_ClipBox, DC, ux0, uy0, 0, StAngle, EndAngle, - rayon + l_piste, color); - } - else - { - GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon, PtDrawSegment->m_Width,color); - } - } - break; + case S_ARC: + { + int StAngle, EndAngle; + rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + StAngle = (int) ArcTangente( dy - uy0, dx - ux0 ); + EndAngle = StAngle + PtDrawSegment->m_Angle; + if( mode == FILAIRE ) + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, 0, color ); + else if( mode == SKETCH ) + { + GRArc( &panel->m_ClipBox, DC, ux0, uy0, 0, StAngle, EndAngle, + rayon - l_piste, color ); + GRArc( &panel->m_ClipBox, DC, ux0, uy0, 0, StAngle, EndAngle, + rayon + l_piste, color ); + } + else + { + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon, PtDrawSegment->m_Width, color ); + } + } + break; - default: - if( mode == FILAIRE) - GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color) ; - else if( mode == SKETCH) - { - GRCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, - PtDrawSegment->m_Width, color) ; - } - else - { - GRFillCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, - PtDrawSegment->m_Width, color) ; - } - break; - } + default: + if( mode == FILAIRE ) + GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color ); + else if( mode == SKETCH ) + { + GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color ); + } + else + { + GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color ); + } + break; + } } /*****************************************************************************************/ -void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode) +void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode ) /*****************************************************************************************/ { -TRACK * track; -wxPoint pos; -int width, orient; -wxString Line; + TRACK* track; + wxPoint pos; + int width, orient; + wxString Line; - GRSetDrawMode(DC, drawmode); - track = Pcb->m_Track; - for ( ; track != NULL ; track = (TRACK*) track->Pnext ) - { - if ( (track->m_Shape == S_ARC) || - (track->m_Shape == S_CIRCLE) || - (track->m_Shape == S_ARC_RECT) ) - { - pos.x = track->m_Start.x; - pos.y = track->m_Start.y; - } + GRSetDrawMode( DC, drawmode ); + track = Pcb->m_Track; + for( ; track != NULL; track = (TRACK*) track->Pnext ) + { + if( (track->m_Shape == S_ARC) + || (track->m_Shape == S_CIRCLE) + || (track->m_Shape == S_ARC_RECT) ) + { + pos.x = track->m_Start.x; + pos.y = track->m_Start.y; + } + else + { + pos.x = (track->m_Start.x + track->m_End.x) / 2; + pos.y = (track->m_Start.y + track->m_End.y) / 2; + } + Line.Printf( wxT( "D%d" ), track->m_NetCode ); + width = track->m_Width; + orient = TEXT_ORIENT_HORIZ; + if( track->m_Shape >= S_SPOT_CIRCLE ) // forme flash + { + width /= 3; + } + else // lines + { + int dx, dy; + dx = track->m_Start.x - track->m_End.x; + dy = track->m_Start.y - track->m_End.y; + if( abs( dx ) < abs( dy ) ) + orient = TEXT_ORIENT_VERT; + width /= 2; + } - else - { - pos.x = (track->m_Start.x + track->m_End.x) / 2; - pos.y = (track->m_Start.y + track->m_End.y) / 2; - } - Line.Printf( wxT("D%d"), track->m_NetCode); - width = track->m_Width; - orient = TEXT_ORIENT_HORIZ; - if ( track->m_Shape >= S_SPOT_CIRCLE) // forme flash - { - width /= 3; - } - - else // lines - { - int dx, dy; - dx = track->m_Start.x - track->m_End.x; - dy = track->m_Start.y - track->m_End.y; - if ( abs(dx) < abs(dy) ) orient = TEXT_ORIENT_VERT; - width /= 2; - } - - DrawGraphicText(panel, DC, - pos, g_DCodesColor, Line, - orient, wxSize(width, width), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); - } + DrawGraphicText( panel, DC, + pos, g_DCodesColor, Line, + orient, wxSize( width, width ), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + } } - diff --git a/include/base_struct.h b/include/base_struct.h index e8cbc01a42..fdfd389151 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -110,7 +110,7 @@ public: * * @param testItem An EDA_BaseStruct to examine. * @param testData is arbitrary data needed by the inspector to determine - * if the EDA_BaseStruct under test meets its match criteria. + * if the BOARD_ITEM under test meets its match criteria. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * else SCAN_CONTINUE; */ @@ -154,7 +154,7 @@ public: unsigned long m_TimeStamp; // Time stamp used for logical links int m_Selected; /* Used by block commands, and selective editing */ - int m_Layer; ///< used by many derived classes, so make common +// int m_Layer; ///< used by many derived classes, so make common private: int m_Status; @@ -298,21 +298,6 @@ public: **/ static std::ostream& NestedSpace( int nestLevel, std::ostream& os ); - - /** - * Function ListHas - * scans the given array and detects if the given type t is present. - * @param list An array of KICAD_T, terminated with EOT. - * @param t A KICAD_T to check for. - * @return bool - true if present, else false. - */ - static bool ListHas( const KICAD_T list[], KICAD_T t ) - { - for( const KICAD_T* p = list; *p != EOT; ++p ) - if( *p == t ) - return true; - return false; - } #endif }; @@ -383,12 +368,59 @@ public: }; -/* Basic class for build items like lines, which have 1 start point and 1 end point. - * Arc and circles can use this class. +/** + * Class BOARD_ITEM + * is an abstract base class for any item which can be embedded within the BOARD + * container class, and therefore instances of derived classes should only be + * found in PCBNEW or other programs that use class BOARD and its contents. + * The corresponding class in EESCHEMA seems to be DrawPartStruct. + */ +class BOARD_ITEM : public EDA_BaseStruct +{ +protected: + int m_Layer; + +public: + + BOARD_ITEM( BOARD_ITEM* StructFather, DrawStructureType idtype ) : + EDA_BaseStruct( StructFather, idtype ), + m_Layer(0) + { + } + + BOARD_ITEM( const BOARD_ITEM& src ) : + EDA_BaseStruct( src.m_Parent, src.m_StructType ), + m_Layer( src.m_Layer ) + { + } + + BOARD_ITEM* Next() { return (BOARD_ITEM*) Pnext; } + + + /** + * Function GetLayer + * returns the layer this item is on. + */ + int GetLayer() const { return m_Layer; } + + /** + * Function SetLayer + * sets the layer this item is on. + * @param aLayer The layer number. + */ + void SetLayer( int aLayer ) { m_Layer = aLayer; } + + +}; + + +/* Base class for building items like lines, which have 1 start point and 1 end point. + * Arc and circles can use this class. */ class EDA_BaseLineStruct : public EDA_BaseStruct { public: + int m_Layer; // Layer number int m_Width; // 0 = line, > 0 = tracks, bus ... wxPoint m_Start; // Line start point wxPoint m_End; // Line end point diff --git a/include/class_collector.h b/include/class_collector.h new file mode 100644 index 0000000000..0585d26c95 --- /dev/null +++ b/include/class_collector.h @@ -0,0 +1,242 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com + * Copyright (C) 2004-2007 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef COLLECTOR_H +#define COLLECTOR_H + +#include +//#include // abs() + +#include "fctsys.h" +#include "base_struct.h" // SEARCH_RESULT +#include "common.h" // GetTimeStamp() + + +class EDA_BaseStruct; +class BOARD; + + +/** + * Class COLLECTOR + * is an abstract class that will find and hold all the objects according to + * an inspection done by the Inspect() function which must be implemented by + * any derived class. When Inspect() finds an object that it wants to collect, + * i.e. one that it "likes", then it only has to do an Append( testItem ) + * on it to add it to its collection, but in all cases for the scan to continue, + * Inspect() must return SEARCH_CONTINUE. + * + * Later, after collection, the user can iterate through all the objects + * in the remembered collection using GetCount() and the [int] operator. + * + * Philosophy: this class knows nothing of the context in which as BOARD is used + * and that means it knows nothing about which layers are visible or current, + * but can handle those concerns by the SetPreferredLayer() function. + */ +class COLLECTOR : public INSPECTOR +{ +protected: +// int m_Type; + + /// Which object types to scan + const KICAD_T* m_ScanTypes; + + /// The layer that is desired as a primary search criterion + int m_PreferredLayer; + + /// A place to hold collected objects without taking ownership of their memory. + std::vector list; + + /// The point at which the snapshot was taken. + wxPoint m_RefPos; + + /// The time at which the collection was made. + int m_TimeAtCollection; + + +public: + + COLLECTOR() + { + m_PreferredLayer = 0; + m_ScanTypes = 0; + } + + virtual ~COLLECTOR() + { + // empty the list so that ~list() does not try and delete all + // the objects that it holds. list is not the owner of such objects + // and this prevents a double free()ing. + Empty(); + } + + + /** + * Function Type + * returns the type of the collector. + int Type() const { return m_Type; } + */ + + + void SetPreferredLayer( int aPreferredLayer ) + { + m_PreferredLayer = aPreferredLayer; + } + + + /** + * Function GetCount + * returns the number of objects in the list + */ + int GetCount() const + { + return list.size(); + } + + + /** + * Function Empty + * sets the list to empty + */ + void Empty() + { + list.clear(); + } + + + /** + * Function Append + * adds an item to the end of the list. + * @param item An EDA_BaseStruct* to add. + */ + void Append( EDA_BaseStruct* item ) + { + list.push_back( item ); + } + + + /** + * Function operator[int] + * is used for read only access and returns the object at index ndx. + * @param ndx The index into the list. + * @return EDA_BaseStruct* - or something derived from it, or NULL. + */ + EDA_BaseStruct* operator[]( int ndx ) const + { + if( (unsigned)ndx < (unsigned)GetCount() ) + return list[ ndx ]; + return NULL; + } + + void SetScanTypes( const KICAD_T* scanTypes ) + { + m_ScanTypes = scanTypes; + } + + wxPoint GetRefPos() const { return m_RefPos; } + + void SetRefPos( const wxPoint& arefPos ) + { + m_RefPos = arefPos; + } + + void SetTimeNow() + { + m_TimeAtCollection = GetTimeStamp(); + } + int GetTime() + { + return m_TimeAtCollection; + } + + + /** + * Function IsSimilarPointAndTime + * returns true if the given reference point is "similar" (defined here) + * to the internal reference point and the current time is within a few + * seconds of the internal m_TimeAtCollection. + * + * @param aRefPos A wxPoint to compare to. + * @return bool - true if the point and time are similar, else false. + */ + bool IsSimilarPointAndTime( const wxPoint& aRefPos ) + { + const int distMax = 2; // adjust these here + const int timeMax = 3; // seconds, I think + + int dx = abs( aRefPos.x - m_RefPos.x ); + int dy = abs( aRefPos.y - m_RefPos.y ); + + if( dx <= distMax && dy <= distMax + && GetTimeStamp()-m_TimeAtCollection <= timeMax ) + return true; + else + return false; + } + + + /** + * Function Inspect + * is the examining function within the INSPECTOR which is passed to the + * Iterate function. It is used primarily for searching, but not limited to + * that. It can also collect or modify the scanned objects. + * + * @param testItem An EDA_BaseStruct to examine. + * @param testData is arbitrary data needed by the inspector to determine + * if the EDA_BaseStruct under test meets its match criteria. + * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, + * else SCAN_CONTINUE; + * + * implement in derived class: + SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem, + const void* testData ) = 0; + */ + + + /** + * Function Scan + * scans a BOARD using this class's Inspector method, which does the collection. + * @param board A BOARD to scan. + * @param refPos A wxPoint to use in hit-testing. + * + * example implementation, in derived class: + * + virtual void Scan( BOARD* board, const wxPoint& refPos ) + { + example implementation: + + SetRefPos( refPos ); // remember where the snapshot was taken from + + Empty(); // empty the collection + + // visit the board with the INSPECTOR (me). + board->Visit( this, // INSPECTOR* inspector + NULL, // const void* testData, + m_ScanTypes); + SetTimeNow(); // when it was taken + } + */ +}; + +#endif // COLLECTOR_H + diff --git a/include/macros.h b/include/macros.h index 5932be2def..a6018b1ee7 100644 --- a/include/macros.h +++ b/include/macros.h @@ -11,12 +11,14 @@ #define CONV_FROM_UTF8(utf8string) (utf8string) #endif +/* violation of C++ standard, cannot use MIN() and MAX() #ifndef min -#define min(x, y) ((x) > (y) ? (y) : (x)) +#define MIN(x, y) ((x) > (y) ? (y) : (x)) #endif #ifndef max -#define max(x, y) ((x) > (y) ? (x) : (y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif +*/ #ifndef MIN #define MIN(x, y) ((x) > (y) ? (y) : (x)) diff --git a/include/pcbstruct.h b/include/pcbstruct.h index da6868165c..2e4b042289 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -187,7 +187,7 @@ enum DisplayViaMode { }; -class BOARD : public EDA_BaseStruct +class BOARD : public BOARD_ITEM { public: WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation @@ -204,7 +204,7 @@ public: int m_NbSegmTrack; // nombre d'elements de type segments de piste int m_NbSegmZone; // nombre d'elements de type segments de zone - EDA_BaseStruct* m_Drawings; // pointeur sur liste drawings + BOARD_ITEM* m_Drawings; // pointeur sur liste drawings MODULE* m_Modules; // pointeur sur liste zone modules EQUIPOT* m_Equipots; // pointeur liste zone equipot TRACK* m_Track; // pointeur relatif zone piste @@ -339,15 +339,19 @@ public: /* Description des elements du PCB */ /***********************************/ -class DRAWSEGMENT : public EDA_BaseLineStruct +class DRAWSEGMENT : public BOARD_ITEM { public: + int m_Width; // 0 = line, > 0 = tracks, bus ... + wxPoint m_Start; // Line start point + wxPoint m_End; // Line end point + int m_Shape; // forme: Segment , Cercle.. int m_Type; // numero de sous type ( cotation.. ) int m_Angle; // pour les arcs: "longueur" de l'arc en 1/10 deg public: - DRAWSEGMENT( EDA_BaseStruct* StructFather, DrawStructureType idtype = TYPEDRAWSEGMENT ); + DRAWSEGMENT( BOARD_ITEM* StructFather, DrawStructureType idtype = TYPEDRAWSEGMENT ); ~DRAWSEGMENT( void ); // Read/write data @@ -405,7 +409,7 @@ public: class EDGE_ZONE : public DRAWSEGMENT { public: - EDGE_ZONE( EDA_BaseStruct* StructFather ); + EDGE_ZONE( BOARD_ITEM* StructFather ); EDGE_ZONE( const EDGE_ZONE& edgezone ); ~EDGE_ZONE( void ); }; @@ -415,7 +419,7 @@ public: /* Gestion des marqueurs sur le PCB */ /************************************/ -class MARQUEUR : public EDA_BaseStruct +class MARQUEUR : public BOARD_ITEM { /* Description d'un marqueur */ public: @@ -426,7 +430,7 @@ public: wxString m_Diag; /* Associated text (comment) */ public: - MARQUEUR( EDA_BaseStruct* StructFather ); + MARQUEUR( BOARD_ITEM* StructFather ); ~MARQUEUR( void ); void UnLink( void ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 5e202723a4..6d17af0059 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -11,8 +11,6 @@ #define eda_global extern #endif -#include - #include #include "wx/log.h" #include "wx/config.h" @@ -98,6 +96,7 @@ class WinEDA3D_DrawFrame; class PARAM_CFG_BASE; class Ki_PageDescr; class Ki_HotkeyInfo; +class ARROWCOLLECTOR; enum id_librarytype { @@ -519,9 +518,7 @@ private: wxMenu* m_FilesMenu; #if defined(DEBUG) - class COLLECTOR; - COLLECTOR* m_GeneralCollector; ///< while arrow icon tool - COLLECTOR* m_RatsModuleCollector; ///< while find1rats icon tool + ARROWCOLLECTOR* m_ArrowCollector; ///< while arrow icon tool #endif diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 9a0330f52d..1aad6a4b4a 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -448,7 +448,7 @@ int WinEDA_PcbFrame::GenPlaceBoard( void ) PtStruct = m_Pcb->m_Drawings; TRACK TmpSegm( NULL ); - TmpSegm.m_Layer = -1; + TmpSegm.SetLayer( -1 ); TmpSegm.m_NetCode = -1; TmpSegm.m_Width = g_GridRoutingSize / 2; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) @@ -459,7 +459,7 @@ int WinEDA_PcbFrame::GenPlaceBoard( void ) { case TYPEDRAWSEGMENT: DrawSegm = (DRAWSEGMENT*) PtStruct; - if( DrawSegm->m_Layer != EDGE_N ) + if( DrawSegm->GetLayer() != EDGE_N ) break; TmpSegm.m_Start = DrawSegm->m_Start; @@ -536,9 +536,9 @@ void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module ) fy = m_Pcb->m_BoundaryBox.GetBottom(); masque_layer = 0; - if( Module->m_Layer == CMP_N ) + if( Module->GetLayer() == CMP_N ) masque_layer = CMP_LAYER; - if( Module->m_Layer == CUIVRE_N ) + if( Module->GetLayer() == CUIVRE_N ) masque_layer = CUIVRE_LAYER; TraceFilledRectangle( m_Pcb, ox, oy, fx, fy, masque_layer, @@ -615,7 +615,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC ) { D_PAD* Pad; int masque_otherlayer; masque_otherlayer = CUIVRE_LAYER; - if( Module->m_Layer == CUIVRE_N ) + if( Module->GetLayer() == CUIVRE_N ) masque_otherlayer = CMP_LAYER; for( Pad = Module->m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext ) @@ -823,7 +823,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide ) int error, Penalite, marge, side, otherside; side = TOP; otherside = BOTTOM; - if( Module->m_Layer == CUIVRE_N ) + if( Module->GetLayer() == CUIVRE_N ) { side = BOTTOM; otherside = TOP; } @@ -1064,7 +1064,7 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int u if( trace & 2 ) { data = GetDist( row, col, TOP ); - data = max( data, LocalPenalite ); + data = MAX( data, LocalPenalite ); SetDist( row, col, TOP, data ); } } @@ -1193,7 +1193,7 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly( void ) { int rayon, cx, cy, d; int xmax, ymax; - EDA_BaseStruct* PtStruct; + BOARD_ITEM* PtStruct; DRAWSEGMENT* ptr; bool succes = FALSE; @@ -1205,7 +1205,7 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly( void ) /* Analyse des Contours PCB */ PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; @@ -1217,21 +1217,21 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly( void ) cx = ptr->m_Start.x; cy = ptr->m_Start.y; rayon = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) ); rayon += d; - m_Pcb->m_BoundaryBox.m_Pos.x = min( m_Pcb->m_BoundaryBox.m_Pos.x, cx - rayon ); - m_Pcb->m_BoundaryBox.m_Pos.y = min( m_Pcb->m_BoundaryBox.m_Pos.y, cy - rayon ); - xmax = max( xmax, cx + rayon ); - ymax = max( ymax, cy + rayon ); + m_Pcb->m_BoundaryBox.m_Pos.x = MIN( m_Pcb->m_BoundaryBox.m_Pos.x, cx - rayon ); + m_Pcb->m_BoundaryBox.m_Pos.y = MIN( m_Pcb->m_BoundaryBox.m_Pos.y, cy - rayon ); + xmax = MAX( xmax, cx + rayon ); + ymax = MAX( ymax, cy + rayon ); } else { - cx = min( ptr->m_Start.x, ptr->m_End.x ); - cy = min( ptr->m_Start.y, ptr->m_End.y ); - m_Pcb->m_BoundaryBox.m_Pos.x = min( m_Pcb->m_BoundaryBox.m_Pos.x, cx - d ); - m_Pcb->m_BoundaryBox.m_Pos.y = min( m_Pcb->m_BoundaryBox.m_Pos.y, cy - d ); - cx = max( ptr->m_Start.x, ptr->m_End.x ); - cy = max( ptr->m_Start.y, ptr->m_End.y ); - xmax = max( xmax, cx + d ); - ymax = max( ymax, cy + d ); + cx = MIN( ptr->m_Start.x, ptr->m_End.x ); + cy = MIN( ptr->m_Start.y, ptr->m_End.y ); + m_Pcb->m_BoundaryBox.m_Pos.x = MIN( m_Pcb->m_BoundaryBox.m_Pos.x, cx - d ); + m_Pcb->m_BoundaryBox.m_Pos.y = MIN( m_Pcb->m_BoundaryBox.m_Pos.y, cy - d ); + cx = MAX( ptr->m_Start.x, ptr->m_End.x ); + cy = MAX( ptr->m_Start.y, ptr->m_End.y ); + xmax = MAX( xmax, cx + d ); + ymax = MAX( ymax, cy + d ); } } diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 5f7d021bb7..e140578ea7 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -430,7 +430,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) * routine d'effacement du block deja selectionne */ { - EDA_BaseStruct* PtStruct, * NextS; + BOARD_ITEM* PtStruct, * NextS; int masque_layer; if( !InstallBlockCmdFrame( this, _( "Delete Block" ) ) ) @@ -448,7 +448,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) module = m_Pcb->m_Modules; for( ; module != NULL; module = (MODULE*) NextS ) { - NextS = module->Pnext; + NextS = module->Next(); if( IsModuleInBox( GetScreen()->BlockLocate, module ) == NULL ) continue; /* le module est ici bon a etre efface */ @@ -467,9 +467,10 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) Affiche_Message( _( "Delete tracks" ) ); for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS ) { - NextS = pt_segm->Pnext; + NextS = pt_segm->Next(); if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) - { /* la piste est ici bonne a etre efface */ + { + /* la piste est ici bonne a etre efface */ pt_segm->Draw( DrawPanel, DC, GR_XOR ); DeleteStructure( pt_segm ); } @@ -487,14 +488,14 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) PtStruct = m_Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = NextS ) { - NextS = PtStruct->Pnext; + NextS = PtStruct->Next(); switch( PtStruct->m_StructType ) { case TYPEDRAWSEGMENT: #undef STRUCT #define STRUCT ( (DRAWSEGMENT*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -517,7 +518,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) case TYPEMIRE: #undef STRUCT #define STRUCT ( (MIREPCB*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -529,7 +530,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) case TYPECOTATION: #undef STRUCT #define STRUCT ( (COTATION*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -551,7 +552,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) Affiche_Message( _( "Delete zones" ) ); for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = (TRACK*) NextS ) { - NextS = pt_segm->Pnext; + NextS = pt_segm->Next(); if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) { /* la piste est ici bonne a etre efface */ pt_segm->Draw( DrawPanel, DC, GR_XOR ); @@ -682,7 +683,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) case TYPEDRAWSEGMENT: #undef STRUCT #define STRUCT ( (DRAWSEGMENT*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -715,7 +716,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) case TYPEMIRE: #undef STRUCT #define STRUCT ( (MIREPCB*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -728,7 +729,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) case TYPECOTATION: #undef STRUCT #define STRUCT ( (COTATION*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -852,7 +853,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) INVERT( track->m_End.y ); if( track->m_StructType != TYPEVIA ) { - track->m_Layer = ChangeSideNumLayer( track->m_Layer ); + track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); } track->Draw( DrawPanel, DC, GR_OR ); // reaffichage @@ -875,7 +876,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) track->Draw( DrawPanel, DC, GR_XOR ); // effacement INVERT( track->m_Start.y ); INVERT( track->m_End.y ); - track->m_Layer = ChangeSideNumLayer( track->m_Layer ); + track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); track->Draw( DrawPanel, DC, GR_OR ); // reaffichage } track = (TRACK*) track->Pnext; @@ -897,7 +898,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) case TYPEDRAWSEGMENT: #undef STRUCT #define STRUCT ( (DRAWSEGMENT*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -909,7 +910,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) } INVERT( STRUCT->m_Start.y ); INVERT( STRUCT->m_End.y ); - STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_OR ); break; @@ -925,11 +926,11 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) /* Redessin du Texte */ INVERT( STRUCT->m_Pos.y ); INVERT_ANGLE( STRUCT->m_Orient ); - if( (STRUCT->m_Layer == CUIVRE_N) || (STRUCT->m_Layer == CMP_N) ) + if( (STRUCT->GetLayer() == CUIVRE_N) || (STRUCT->GetLayer() == CMP_N) ) { STRUCT->m_Miroir ^= 1; /* inverse miroir */ } - STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); STRUCT->CreateDrawData(); ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); break; @@ -937,21 +938,21 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) case TYPEMIRE: #undef STRUCT #define STRUCT ( (MIREPCB*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; /* l'element est ici bon a etre modifie */ ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); INVERT( STRUCT->m_Pos.y ); - STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); break; case TYPECOTATION: #undef STRUCT #define STRUCT ( (COTATION*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -982,7 +983,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) INVERT( STRUCT->FlecheD2_oy ); INVERT( STRUCT->FlecheD2_fy ); - STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); break; @@ -1111,7 +1112,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) case TYPEDRAWSEGMENT: #undef STRUCT #define STRUCT ( (DRAWSEGMENT*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -1139,7 +1140,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) case TYPEMIRE: #undef STRUCT #define STRUCT ( (MIREPCB*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -1152,7 +1153,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) case TYPECOTATION: #undef STRUCT #define STRUCT ( (COTATION*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -1315,7 +1316,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { #undef STRUCT #define STRUCT ( (DRAWSEGMENT*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -1357,7 +1358,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { #undef STRUCT #define STRUCT ( (MIREPCB*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; @@ -1377,7 +1378,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { #undef STRUCT #define STRUCT ( (COTATION*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) break; diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index df63574a24..fb8fb35937 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -395,8 +395,8 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) /* Copy marked items, at new position = old position + offset */ { - EDA_BaseStruct* item; - EDA_BaseStruct* NewStruct; + BOARD_ITEM* item; + BOARD_ITEM* NewStruct; if( module == NULL ) return; diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index fae07f84e2..451a2398a7 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -186,7 +186,7 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) TRACK* pt_segm; TEXTE_PCB* PtText; DRAWSEGMENT* DrawSegm; - EDA_BaseStruct* PtStruct; + BOARD_ITEM* PtStruct; int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy; int marge, via_marge; int masque_layer; @@ -211,19 +211,19 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) // Placement des elements de modules sur PCB // /////////////////////////////////////////////// PtStruct = Pcb->m_Modules; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - EDA_BaseStruct* PtModStruct = ( (MODULE*) PtStruct )->m_Drawings; - for( ; PtModStruct != NULL; PtModStruct = PtModStruct->Pnext ) + BOARD_ITEM* PtModStruct = ( (MODULE*) PtStruct )->m_Drawings; + for( ; PtModStruct != NULL; PtModStruct = PtModStruct->Next() ) { switch( PtModStruct->m_StructType ) { case TYPEEDGEMODULE: { TRACK* TmpSegm = new TRACK( NULL ); - TmpSegm->m_Layer = ( (EDGE_MODULE*) PtModStruct )->m_Layer; - if( TmpSegm->m_Layer == EDGE_N ) - TmpSegm->m_Layer = -1; + TmpSegm->SetLayer( ( (EDGE_MODULE*) PtModStruct )->GetLayer() ); + if( TmpSegm->GetLayer() == EDGE_N ) + TmpSegm->SetLayer( -1 ); TmpSegm->m_Start = ( (EDGE_MODULE*) PtModStruct )->m_Start; TmpSegm->m_End = ( (EDGE_MODULE*) PtModStruct )->m_End; @@ -249,7 +249,7 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) // Placement des contours et segments PCB // //////////////////////////////////////////// PtStruct = Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->m_StructType ) { @@ -258,10 +258,10 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) int type_cell = HOLE; TRACK* TmpSegm = new TRACK( NULL ); DrawSegm = (DRAWSEGMENT*) PtStruct; - TmpSegm->m_Layer = DrawSegm->m_Layer; - if( DrawSegm->m_Layer == EDGE_N ) + TmpSegm->SetLayer( DrawSegm->GetLayer() ); + if( DrawSegm->GetLayer() == EDGE_N ) { - TmpSegm->m_Layer = -1; + TmpSegm->SetLayer( -1 ); type_cell |= CELL_is_EDGE; } @@ -293,7 +293,7 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) ux1 = ux0 + dx; uy1 = uy0 + dy; ux0 -= dx; uy0 -= dy; - masque_layer = g_TabOneLayerMask[PtText->m_Layer]; + masque_layer = g_TabOneLayerMask[PtText->GetLayer()]; TraceFilledRectangle( Pcb, ux0 - marge, uy0 - marge, ux1 + marge, uy1 + marge, (int) (PtText->m_Orient), diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 7857420679..394e1e044f 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -15,7 +15,7 @@ /* Constructor */ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) : - EDA_BaseStruct( parent, TYPEPCB ) + BOARD_ITEM( (BOARD_ITEM*) parent, TYPEPCB ) { m_PcbFrame = frame; m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule @@ -24,7 +24,7 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) : m_NbPads = 0; // nombre total de pads m_NbNodes = 0; // nombre de pads connectes m_NbLinks = 0; // nombre de chevelus (donc aussi nombre - // minimal de pistes a tracer + // minimal de pistes a tracer m_NbSegmTrack = 0; // nombre d'elements de type segments de piste m_NbSegmZone = 0; // nombre d'elements de type segments de zone m_NbNoconnect = 0; // nombre de chevelus actifs @@ -39,7 +39,7 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) : m_Ratsnest = NULL; // pointeur liste rats m_LocalRatsnest = NULL; // pointeur liste rats local m_CurrentLimitZone = NULL; // pointeur liste des EDEGE_ZONES - // de determination des contours de zone + // de determination des contours de zone } @@ -160,22 +160,22 @@ bool BOARD::ComputeBoundaryBox( void ) cx = ptr->m_Start.x; cy = ptr->m_Start.y; rayon = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) ); rayon += d; - xmin = min( xmin, cx - rayon ); - ymin = min( ymin, cy - rayon ); - xmax = max( xmax, cx + rayon ); - ymax = max( ymax, cy + rayon ); + xmin = MIN( xmin, cx - rayon ); + ymin = MIN( ymin, cy - rayon ); + xmax = MAX( xmax, cx + rayon ); + ymax = MAX( ymax, cy + rayon ); Has_Items = TRUE; } else { - cx = min( ptr->m_Start.x, ptr->m_End.x ); - cy = min( ptr->m_Start.y, ptr->m_End.y ); - xmin = min( xmin, cx - d ); - ymin = min( ymin, cy - d ); - cx = max( ptr->m_Start.x, ptr->m_End.x ); - cy = max( ptr->m_Start.y, ptr->m_End.y ); - xmax = max( xmax, cx + d ); - ymax = max( ymax, cy + d ); + cx = MIN( ptr->m_Start.x, ptr->m_End.x ); + cy = MIN( ptr->m_Start.y, ptr->m_End.y ); + xmin = MIN( xmin, cx - d ); + ymin = MIN( ymin, cy - d ); + cx = MAX( ptr->m_Start.x, ptr->m_End.x ); + cy = MAX( ptr->m_Start.y, ptr->m_End.y ); + xmax = MAX( xmax, cx + d ); + ymax = MAX( ymax, cy + d ); Has_Items = TRUE; } } @@ -185,19 +185,19 @@ bool BOARD::ComputeBoundaryBox( void ) for( ; module != NULL; module = (MODULE*) module->Pnext ) { Has_Items = 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() ); + 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 ) { d = pt_pad->m_Rayon; - xmin = min( xmin, pt_pad->m_Pos.x - d ); - ymin = min( ymin, pt_pad->m_Pos.y - d ); - xmax = max( xmax, pt_pad->m_Pos.x + d ); - ymax = max( ymax, pt_pad->m_Pos.y + d ); + xmin = MIN( xmin, pt_pad->m_Pos.x - d ); + ymin = MIN( ymin, pt_pad->m_Pos.y - d ); + xmax = MAX( xmax, pt_pad->m_Pos.x + d ); + ymax = MAX( ymax, pt_pad->m_Pos.y + d ); } } @@ -205,28 +205,28 @@ bool BOARD::ComputeBoundaryBox( void ) for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext ) { 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 ); - xmax = max( xmax, cx + d ); - ymax = max( ymax, cy + d ); + 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 ); + xmax = MAX( xmax, cx + d ); + ymax = MAX( ymax, cy + d ); Has_Items = TRUE; } for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext ) { 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 ); - xmax = max( xmax, cx + d ); - ymax = max( ymax, cy + d ); + 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 ); + xmax = MAX( xmax, cx + d ); + ymax = MAX( ymax, cy + d ); Has_Items = TRUE; } @@ -378,7 +378,7 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) class PadOrModule : public INSPECTOR { public: - EDA_BaseStruct* found; + BOARD_ITEM* found; int layer; int layer_mask; @@ -388,46 +388,47 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData ) { - const wxPoint& refPos = *(const wxPoint*) testData; + BOARD_ITEM* item = (BOARD_ITEM*) testItem; + const wxPoint& refPos = *(const wxPoint*) testData; - if( testItem->m_StructType == TYPEPAD ) + if( item->m_StructType == TYPEPAD ) { - D_PAD* pad = (D_PAD*) testItem; + D_PAD* pad = (D_PAD*) item; if( pad->HitTest( refPos ) ) { if( layer_mask & pad->m_Masque_Layer ) { - found = testItem; + found = item; return SEARCH_QUIT; } else if( !found ) { MODULE* parent = (MODULE*) pad->m_Parent; - if( IsModuleLayerVisible( parent->m_Layer ) ) - found = testItem; + if( IsModuleLayerVisible( parent->GetLayer() ) ) + found = item; } } } - else if( testItem->m_StructType == TYPEMODULE ) + else if( item->m_StructType == TYPEMODULE ) { - MODULE* module = (MODULE*) testItem; + MODULE* module = (MODULE*) item; // consider only visible modules - if( IsModuleLayerVisible( module->m_Layer ) ) + if( IsModuleLayerVisible( module->GetLayer() ) ) { if( module->HitTest( refPos ) ) { - if( layer == module->m_Layer ) + if( layer == module->GetLayer() ) { - found = testItem; + found = item; return SEARCH_QUIT; } // layer mismatch, save in case we don't find a // future layer match hit. if( !found ) - found = testItem; + found = item; } } } diff --git a/pcbnew/class_cotation.cpp b/pcbnew/class_cotation.cpp index 14d6f81e73..4ed652acc0 100644 --- a/pcbnew/class_cotation.cpp +++ b/pcbnew/class_cotation.cpp @@ -11,8 +11,8 @@ #include "wxstruct.h" -COTATION::COTATION( EDA_BaseStruct* StructFather ) : - EDA_BaseStruct( StructFather, TYPECOTATION ) +COTATION::COTATION( BOARD_ITEM* StructFather ) : + BOARD_ITEM( StructFather, TYPECOTATION ) { m_Layer = DRAW_LAYER; m_Width = 50; @@ -24,7 +24,7 @@ COTATION::COTATION( EDA_BaseStruct* StructFather ) : /* Effacement memoire de la structure */ -COTATION::~COTATION( void ) +COTATION::~COTATION() { delete m_Text; } @@ -44,7 +44,7 @@ void COTATION::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = Pnext; + ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } @@ -68,7 +68,7 @@ void COTATION::Copy( COTATION* source ) /*************************************/ { m_Value = source->m_Value; - m_Layer = source->m_Layer; + SetLayer( source->GetLayer() ); m_Width = source->m_Width; m_Pos = source->m_Pos; m_Shape = source->m_Shape; @@ -112,15 +112,18 @@ bool COTATION::ReadCotationDescr( FILE* File, int* LineNum ) if( Line[0] == 'G' ) { - sscanf( Line + 2, " %d %d %lX", &m_Shape, &m_Layer, &m_TimeStamp ); + int layer; + + sscanf( Line + 2, " %d %d %lX", &m_Shape, &layer, &m_TimeStamp ); /* Mise a jour des param .layer des sous structures */ - if( m_Layer < FIRST_NO_COPPER_LAYER ) - m_Layer = FIRST_NO_COPPER_LAYER; - if( m_Layer > LAST_NO_COPPER_LAYER ) - m_Layer = LAST_NO_COPPER_LAYER; + if( layer < FIRST_NO_COPPER_LAYER ) + layer = FIRST_NO_COPPER_LAYER; + if( layer > LAST_NO_COPPER_LAYER ) + layer = LAST_NO_COPPER_LAYER; - m_Text->m_Layer = m_Layer; + SetLayer( layer ); + m_Text->SetLayer( layer ); continue; } diff --git a/pcbnew/class_cotation.h b/pcbnew/class_cotation.h index 601fa69e46..a6605001cd 100644 --- a/pcbnew/class_cotation.h +++ b/pcbnew/class_cotation.h @@ -6,7 +6,7 @@ #include "base_struct.h" -class COTATION : public EDA_BaseStruct +class COTATION : public BOARD_ITEM { public: int m_Width; @@ -25,8 +25,8 @@ public: int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy; public: - COTATION( EDA_BaseStruct* StructFather ); - ~COTATION( void ); + COTATION( BOARD_ITEM* StructFather ); + ~COTATION(); bool ReadCotationDescr( FILE* File, int* LineNum ); bool WriteCotationDescr( FILE* File ); diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 729b830757..3ba303a47d 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -29,7 +29,7 @@ /******************************************/ EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : - EDA_BaseLineStruct( parent, TYPEEDGEMODULE ) + BOARD_ITEM( parent, TYPEEDGEMODULE ) { m_Shape = S_SEGMENT; m_Angle = 0; @@ -91,7 +91,7 @@ void EDGE_MODULE::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (MODULE*) Pback )->m_Drawings = Pnext; + ( (MODULE*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } @@ -287,10 +287,10 @@ void EDGE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) Affiche_1_Parametre( frame, 24, _( "TimeStamp" ), bufcar, BROWN ); - Affiche_1_Parametre( frame, 34, _( "Mod Layer" ), ReturnPcbLayerName( module->m_Layer ), RED ); + Affiche_1_Parametre( frame, 34, _( "Mod Layer" ), ReturnPcbLayerName( module->GetLayer() ), RED ); Affiche_1_Parametre( frame, 44, _( "Seg Layer" ), - ReturnPcbLayerName( module->m_Layer ), RED ); + ReturnPcbLayerName( module->GetLayer() ), RED ); valeur_param( m_Width, bufcar ); Affiche_1_Parametre( frame, 54, _( "Width" ), bufcar, BLUE ); diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 08301da59d..a8db4863d4 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -7,9 +7,13 @@ class Pcb3D_GLCanvas; /* description des contours (empreintes ) et TYPES des CONTOURS : */ -class EDGE_MODULE : public EDA_BaseLineStruct +class EDGE_MODULE : public BOARD_ITEM { public: + int m_Width; // 0 = line, > 0 = tracks, bus ... + wxPoint m_Start; // Line start point + wxPoint m_End; // Line end point + int m_Shape; // voir "enum Track_Shapes" wxPoint m_Start0; // coord relatives a l'ancre du point de depart(Orient 0) wxPoint m_End0; // coord relatives a l'ancre du point de fin (Orient 0) diff --git a/pcbnew/class_equipot.cpp b/pcbnew/class_equipot.cpp index 7e60fed38c..4733c2c01d 100644 --- a/pcbnew/class_equipot.cpp +++ b/pcbnew/class_equipot.cpp @@ -22,8 +22,8 @@ /*********************************************************/ /* Constructeur de la classe EQUIPOT */ -EQUIPOT::EQUIPOT( EDA_BaseStruct* StructFather ) : - EDA_BaseStruct( StructFather, PCB_EQUIPOT_STRUCT_TYPE ) +EQUIPOT::EQUIPOT( BOARD_ITEM* StructFather ) : + BOARD_ITEM( StructFather, PCB_EQUIPOT_STRUCT_TYPE ) { m_NetCode = 0; m_NbNodes = m_NbLink = m_NbNoconn = 0; @@ -39,7 +39,7 @@ EQUIPOT::EQUIPOT( EDA_BaseStruct* StructFather ) : /* destructeut */ -EQUIPOT::~EQUIPOT( void ) +EQUIPOT::~EQUIPOT() { } diff --git a/pcbnew/class_equipot.h b/pcbnew/class_equipot.h index da4b3b940d..dd9b054a75 100644 --- a/pcbnew/class_equipot.h +++ b/pcbnew/class_equipot.h @@ -5,7 +5,7 @@ /* Representation des descriptions des equipotentielles */ -class EQUIPOT : public EDA_BaseStruct +class EQUIPOT : public BOARD_ITEM { public: wxString m_Netname; // nom du net @@ -22,8 +22,8 @@ public: CHEVELU* m_RatsnestStart; // pointeur sur debut de liste ratsnests du net CHEVELU* m_RatsnestEnd; // pointeur sur fin de liste ratsnests du net - EQUIPOT( EDA_BaseStruct* StructFather ); - ~EQUIPOT( void ); + EQUIPOT( BOARD_ITEM* StructFather ); + ~EQUIPOT(); /* Effacement memoire de la structure */ void UnLink( void ); diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index e4b81732fa..588cbdb75d 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -9,15 +9,15 @@ #include "pcbnew.h" -MIREPCB::MIREPCB( EDA_BaseStruct* StructFather ) : - EDA_BaseStruct( StructFather, TYPEMIRE ) +MIREPCB::MIREPCB( BOARD_ITEM* StructFather ) : + BOARD_ITEM( StructFather, TYPEMIRE ) { m_Shape = 0; m_Size = 5000; } -MIREPCB::~MIREPCB( void ) +MIREPCB::~MIREPCB() { } @@ -39,7 +39,7 @@ void MIREPCB::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = Pnext; + ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index 248159737e..fa193b6214 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -7,7 +7,7 @@ #include "base_struct.h" -class MIREPCB : public EDA_BaseStruct +class MIREPCB : public BOARD_ITEM { public: int m_Width; @@ -16,8 +16,8 @@ public: int m_Size; public: - MIREPCB( EDA_BaseStruct* StructFather ); - ~MIREPCB( void ); + MIREPCB( BOARD_ITEM* StructFather ); + ~MIREPCB(); bool WriteMirePcbDescr( FILE* File ); bool ReadMirePcbDescr( FILE* File, int* LineNum ); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index c64fafdef6..5d4c306a94 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -58,7 +58,8 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset /*************************************************/ /* Constructeur de la classe MODULE */ -MODULE::MODULE( BOARD* parent ) : EDA_BaseStruct( parent, TYPEMODULE ) +MODULE::MODULE( BOARD* parent ) : + BOARD_ITEM( parent, TYPEMODULE ) { m_Pads = NULL; m_Drawings = NULL; @@ -168,9 +169,9 @@ void MODULE::Copy( MODULE* Module ) } /* Copy des structures auxiliaires: Drawings */ - EDA_BaseStruct* OldStruct = (EDA_BaseStruct*) Module->m_Drawings; - EDA_BaseStruct* NewStruct, * LastStruct = NULL; - for( ; OldStruct; OldStruct = OldStruct->Pnext ) + BOARD_ITEM* OldStruct = Module->m_Drawings; + BOARD_ITEM* NewStruct, * LastStruct = NULL; + for( ; OldStruct; OldStruct = OldStruct->Next() ) { NewStruct = NULL; @@ -423,7 +424,7 @@ int MODULE::WriteDescr( FILE* File ) m_Reference->m_Size.y, m_Reference->m_Size.x, m_Reference->m_Orient + m_Orient, m_Reference->m_Width, m_Reference->m_Miroir ? 'N' : 'M', m_Reference->m_NoShow ? 'I' : 'V', - m_Reference->m_Layer, + m_Reference->GetLayer(), CONV_TO_UTF8( m_Reference->m_Text ) ); NbLigne++; @@ -434,7 +435,7 @@ int MODULE::WriteDescr( FILE* File ) m_Value->m_Size.y, m_Value->m_Size.x, m_Value->m_Orient + m_Orient, m_Value->m_Width, m_Value->m_Miroir ? 'N' : 'M', m_Value->m_NoShow ? 'I' : 'V', - m_Value->m_Layer, + m_Value->GetLayer(), CONV_TO_UTF8( m_Value->m_Text ) ); NbLigne++; @@ -453,7 +454,7 @@ int MODULE::WriteDescr( FILE* File ) PtText->m_Orient + m_Orient, PtText->m_Width, PtText->m_Miroir ? 'N' : 'M', PtText->m_NoShow ? 'I' : 'V', - PtText->m_Layer, CONV_TO_UTF8( PtText->m_Text ) ); + PtText->GetLayer(), CONV_TO_UTF8( PtText->m_Text ) ); NbLigne++; break; @@ -720,22 +721,23 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) if( LastModStruct == NULL ) { DrawText->Pback = this; - m_Drawings = (EDA_BaseStruct*) DrawText; + m_Drawings = DrawText; } else { DrawText->Pback = LastModStruct; LastModStruct->Pnext = DrawText; } - LastModStruct = (EDA_BaseStruct*) DrawText; + LastModStruct = DrawText; } + int layer; sscanf( Line + 1, "%d %d %d %d %d %d %d %s %s %d", &itmp1, &DrawText->m_Pos0.x, &DrawText->m_Pos0.y, &DrawText->m_Size.y, &DrawText->m_Size.x, &DrawText->m_Orient, &DrawText->m_Width, - BufCar1, BufCar2, &DrawText->m_Layer ); + BufCar1, BufCar2, &layer ); DrawText->m_Type = itmp1; DrawText->m_Orient -= m_Orient; // m_Orient texte relative au module @@ -748,11 +750,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) else DrawText->m_NoShow = 0; - if( m_Layer == CUIVRE_N ) - DrawText->m_Layer = SILKSCREEN_N_CU; - if( m_Layer == CMP_N ) - DrawText->m_Layer = SILKSCREEN_N_CMP; + if( layer == CUIVRE_N ) + layer = SILKSCREEN_N_CU; + else if( layer == CMP_N ) + layer = SILKSCREEN_N_CMP; + DrawText->SetLayer( layer ); + /* calcul de la position vraie */ DrawText->SetDrawCoord(); /* Lecture de la chaine "text" */ @@ -961,22 +965,22 @@ void MODULE::Set_Rectangle_Encadrement( void ) uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y; rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) ); rayon += width; - m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, cx - rayon ); - m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, cy - rayon ); - xmax = max( xmax, cx + rayon ); - ymax = max( ymax, cy + rayon ); + m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, cx - rayon ); + m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, cy - rayon ); + xmax = MAX( xmax, cx + rayon ); + ymax = MAX( ymax, cy + rayon ); break; } default: - m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_Start0.x - width ); - m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_End0.x - width ); - m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_Start0.y - width ); - m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_End0.y - width ); - xmax = max( xmax, pt_edge_mod->m_Start0.x + width ); - xmax = max( xmax, pt_edge_mod->m_End0.x + width ); - ymax = max( ymax, pt_edge_mod->m_Start0.y + width ); - ymax = max( ymax, pt_edge_mod->m_End0.y + width ); + m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_Start0.x - width ); + m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_End0.x - width ); + m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_Start0.y - width ); + m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_End0.y - width ); + xmax = MAX( xmax, pt_edge_mod->m_Start0.x + width ); + xmax = MAX( xmax, pt_edge_mod->m_End0.x + width ); + ymax = MAX( ymax, pt_edge_mod->m_Start0.y + width ); + ymax = MAX( ymax, pt_edge_mod->m_End0.y + width ); break; } } @@ -986,10 +990,10 @@ void MODULE::Set_Rectangle_Encadrement( void ) { rayon = pad->m_Rayon; cx = pad->m_Pos0.x; cy = pad->m_Pos0.y; - m_BoundaryBox.m_Pos.x = min( m_BoundaryBox.m_Pos.x, cx - rayon ); - m_BoundaryBox.m_Pos.y = min( m_BoundaryBox.m_Pos.y, cy - rayon ); - xmax = max( xmax, cx + rayon ); - ymax = max( ymax, cy + rayon ); + m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, cx - rayon ); + m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, cy - rayon ); + xmax = MAX( xmax, cx + rayon ); + ymax = MAX( ymax, cy + rayon ); } m_BoundaryBox.SetWidth( xmax - m_BoundaryBox.m_Pos.x ); @@ -1035,22 +1039,22 @@ void MODULE::SetRectangleExinscrit( void ) uxf = EdgeMod->m_End.x; uyf = EdgeMod->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 ); - m_RealBoundaryBox.m_Pos.y = min( m_RealBoundaryBox.m_Pos.y, cy - rayon ); - xmax = max( xmax, cx + rayon ); - ymax = max( ymax, cy + rayon ); + 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 ); break; } 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, 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 ); break; } } @@ -1060,10 +1064,10 @@ void MODULE::SetRectangleExinscrit( void ) { 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 ); + 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 ); } m_RealBoundaryBox.SetWidth( xmax - m_RealBoundaryBox.m_Pos.x ); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index c6016b3e0e..fb4c7c57e5 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -35,12 +35,12 @@ enum Mod_Attribut /* Attributs d'un module */ #define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */ #define MODULE_to_PLACE 0x04 /* In autoplace: module waiting for autoplace */ -class MODULE : public EDA_BaseStruct +class MODULE : public BOARD_ITEM { public: wxPoint m_Pos; // Real coord on board D_PAD* m_Pads; /* Pad list (linked list) */ - EDA_BaseStruct* m_Drawings; /* Graphic items list (linked list) */ + BOARD_ITEM* m_Drawings; /* Graphic items list (linked list) */ Struct3D_Master* m_3D_Drawings; /* Pointeur sur la liste des elements de trace 3D*/ TEXTE_MODULE* m_Reference; // texte reference du composant (U34, R18..) TEXTE_MODULE* m_Value; // texte valeur du composant (74LS00, 22K..) @@ -72,9 +72,9 @@ public: MODULE( MODULE* module ); ~MODULE( void ); - void Copy( MODULE* Module ); // Copy structure + void Copy( MODULE* Module ); // Copy structure - MODULE* Next( void ) { return (MODULE*) Pnext; } + MODULE* Next() { return (MODULE*) Pnext; } void Set_Rectangle_Encadrement( void );/* mise a jour du rect d'encadrement * en coord locales (orient 0 et origine = pos module) */ diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index b43009ad71..2865af2903 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -25,7 +25,8 @@ /* classe D_PAD : constructeur */ /*******************************/ -D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD ) +D_PAD::D_PAD( MODULE* parent ) : + BOARD_ITEM( parent, TYPEPAD ) { m_NumPadName = 0; m_Masque_Layer = CUIVRE_LAYER; @@ -520,7 +521,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int /* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */ if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn ) { - dx0 = min( dx0, dy0 ); + dx0 = MIN( dx0, dy0 ); int nc_color = BLUE; if( m_Masque_Layer & CMP_LAYER ) /* Trace forme \ */ GRLine( &panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0, @@ -535,7 +536,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int if( !frame->m_DisplayPadNum ) return; - dx = min( m_Size.x, m_Size.y ); /* dx = text size */ + dx = MIN( m_Size.x, m_Size.y ); /* dx = text size */ if( (dx / zoom) > 12 ) /* size must be enought to draw 2 chars */ { wxString buffer; diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 348e89b5d0..1c5f45c3ed 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -20,7 +20,7 @@ class Pcb3D_GLCanvas; #define PAD_STACK 0x80 // bit 7 de .attrib (flag) /* Definition type Structure d'un pad */ -class D_PAD : public EDA_BaseStruct +class D_PAD : public BOARD_ITEM { public: union diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 9d69ae256d..63f746a553 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -15,15 +15,15 @@ /* class TEXTE_PCB */ /*******************/ -TEXTE_PCB::TEXTE_PCB( EDA_BaseStruct* parent ) : - EDA_BaseStruct( parent, TYPETEXTE ), +TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) : + BOARD_ITEM( parent, TYPETEXTE ), EDA_TextStruct() { } /* Destructeur */ -TEXTE_PCB:: ~TEXTE_PCB( void ) +TEXTE_PCB:: ~TEXTE_PCB() { } @@ -59,7 +59,7 @@ void TEXTE_PCB::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = Pnext; + ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index e06173f774..fece05a079 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -6,25 +6,25 @@ #include "base_struct.h" -class TEXTE_PCB : public EDA_BaseStruct, public EDA_TextStruct +class TEXTE_PCB : public BOARD_ITEM, public EDA_TextStruct { public: - TEXTE_PCB(EDA_BaseStruct * parent); - TEXTE_PCB(TEXTE_PCB * textepcb); - ~TEXTE_PCB(void); + TEXTE_PCB( BOARD_ITEM* parent ); + TEXTE_PCB( TEXTE_PCB* textepcb ); + ~TEXTE_PCB(); /* supprime du chainage la structure Struct */ void UnLink( void ); /* duplicate structure */ - void Copy(TEXTE_PCB * source); + void Copy( TEXTE_PCB* source ); - void Draw(WinEDA_DrawPanel * panel, wxDC * DC, - const wxPoint & offset, int DrawMode); + void Draw( WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int DrawMode ); // File Operations: - int ReadTextePcbDescr(FILE * File, int * LineNum); - int WriteTextePcbDescr(FILE * File); + int ReadTextePcbDescr( FILE* File, int* LineNum ); + int WriteTextePcbDescr( FILE* File ); /** diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 6ab7368ea7..5be4cf7d9c 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -28,7 +28,7 @@ /* Constructeur de TEXTE_MODULE */ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : - EDA_BaseStruct( parent, TYPETEXTEMODULE ) + BOARD_ITEM( parent, TYPETEXTEMODULE ) { MODULE* Module = (MODULE*) m_Parent; @@ -41,18 +41,27 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : m_Orient = 0; /* en 1/10 degre */ m_Miroir = 1; // Mode normal (pas de miroir) m_Unused = 0; - m_Layer = SILKSCREEN_N_CMP; + + SetLayer( SILKSCREEN_N_CMP ); if( Module && (Module->m_StructType == TYPEMODULE) ) { m_Pos = Module->m_Pos; - m_Layer = Module->m_Layer; - if( Module->m_Layer == CUIVRE_N ) - m_Layer = SILKSCREEN_N_CU; - if( Module->m_Layer == CMP_N ) - m_Layer = SILKSCREEN_N_CMP; - if( (Module->m_Layer == SILKSCREEN_N_CU) - || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + + int moduleLayer = Module->GetLayer(); + + if( moduleLayer == CUIVRE_N ) + SetLayer( SILKSCREEN_N_CU ); + else if( moduleLayer == CMP_N ) + SetLayer( SILKSCREEN_N_CMP ); + else + SetLayer( moduleLayer ); + + if( moduleLayer == SILKSCREEN_N_CU + || moduleLayer == ADHESIVE_N_CU + || moduleLayer == CUIVRE_N ) + { m_Miroir = 0; + } } } @@ -68,7 +77,7 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure return; m_Pos = source->m_Pos; - m_Layer = source->m_Layer; + SetLayer( source->GetLayer() ); m_Miroir = source->m_Miroir; // vue normale / miroir m_NoShow = source->m_NoShow; // 0: visible 1: invisible @@ -97,7 +106,7 @@ void TEXTE_MODULE::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (MODULE*) Pback )->m_Drawings = Pnext; + ( (MODULE*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } @@ -245,11 +254,12 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint offset, int pos.x, pos.y + anchor_size, 0, g_AnchorColor ); } - color = g_DesignSettings.m_LayerColor[Module->m_Layer]; + color = g_DesignSettings.m_LayerColor[Module->GetLayer()]; - if( Module && Module->m_Layer == CUIVRE_N ) + if( Module && Module->GetLayer() == CUIVRE_N ) color = g_ModuleTextCUColor; - if( Module && Module->m_Layer == CMP_N ) + + else if( Module && Module->GetLayer() == CMP_N ) color = g_ModuleTextCMPColor; if( (color & ITEM_NOT_SHOW) != 0 ) diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 829b934cc4..def913a6f4 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -13,7 +13,7 @@ #define TEXT_is_DIVERS 2 -class TEXTE_MODULE : public EDA_BaseStruct +class TEXTE_MODULE : public BOARD_ITEM { public: int m_Width; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 94dd25ef31..3f7bde08b6 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -22,8 +22,8 @@ /* Constructeur des classes type pistes, vias et zones */ -TRACK::TRACK( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : - EDA_BaseLineStruct( StructFather, idtype ) +TRACK::TRACK( BOARD_ITEM* StructFather, DrawStructureType idtype ) : + BOARD_ITEM( StructFather, idtype ) { m_Shape = S_SEGMENT; start = end = NULL; @@ -35,13 +35,13 @@ TRACK::TRACK( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : -SEGZONE::SEGZONE( EDA_BaseStruct* StructFather ) : +SEGZONE::SEGZONE( BOARD_ITEM* StructFather ) : TRACK( StructFather, TYPEZONE ) { } -SEGVIA::SEGVIA( EDA_BaseStruct* StructFather ) : +SEGVIA::SEGVIA( BOARD_ITEM* StructFather ) : TRACK( StructFather, TYPEVIA ) { } @@ -50,7 +50,7 @@ SEGVIA::SEGVIA( EDA_BaseStruct* StructFather ) : /* Copy constructor */ TRACK::TRACK( const TRACK& Source ) : - EDA_BaseLineStruct( Source.m_Parent, (DrawStructureType)Source.m_StructType ) + BOARD_ITEM( (const BOARD_ITEM&) Source ) { m_StructType = Source.m_StructType; m_Shape = Source.m_Shape; @@ -235,14 +235,6 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) } -/************************/ -TRACK* TRACK::Next( void ) -/************************/ -{ - return (TRACK*) Pnext; -} - - /* supprime du chainage la structure Struct * les structures arrieres et avant sont chainees directement */ diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index edbd66d243..20b499c4b4 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -19,12 +19,19 @@ /***/ -class TRACK : public EDA_BaseLineStruct +class TRACK : public BOARD_ITEM { public: + int m_Width; // 0 = line, > 0 = tracks, bus ... + wxPoint m_Start; // Line start point + wxPoint m_End; // Line end point + int m_Shape; // vias: shape and type, Track = shape.. int m_Drill; // for vias: via drill (- 1 for default value) - EDA_BaseStruct* start, * end; // pointers on a connected item (pad or track) + + BOARD_ITEM* start; // pointers on a connected item (pad or track) + BOARD_ITEM* end; + int m_NetCode; // Net number int m_Sous_Netcode; /* In rastnest routines : for the current net, * block number (number common to the current connected items found) */ @@ -33,15 +40,12 @@ public: int m_Param; // Auxiliary variable ( used in some computations ) public: - TRACK( EDA_BaseStruct* StructFather, DrawStructureType idtype = TYPETRACK ); + TRACK( BOARD_ITEM* StructFather, DrawStructureType idtype = TYPETRACK ); TRACK( const TRACK& track ); - TRACK* Next( void ); // Retourne le chainage avant + TRACK* Next() { return (TRACK*) Pnext; } - TRACK* Back( void ) // Retourne le chainage avant - { - return (TRACK*) Pback; - } + TRACK* Back() { return (TRACK*) Pback; } /* supprime du chainage la structure Struct */ @@ -122,7 +126,7 @@ public: class SEGZONE : public TRACK { public: - SEGZONE( EDA_BaseStruct* StructFather ); + SEGZONE( BOARD_ITEM* StructFather ); #if defined(DEBUG) /** @@ -141,7 +145,7 @@ public: class SEGVIA : public TRACK { public: - SEGVIA( EDA_BaseStruct* StructFather ); + SEGVIA( BOARD_ITEM* StructFather ); bool IsViaOnLayer( int layer ); void SetLayerPair( int top_layer, int bottom_layer ); void ReturnLayerPair( int* top_layer, int* bottom_layer ); diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 875c98ed54..8802062aef 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -35,7 +35,7 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /**********************/ /* Classe EDGE_ZONE: constructeur */ -EDGE_ZONE::EDGE_ZONE( EDA_BaseStruct* parent ) : +EDGE_ZONE::EDGE_ZONE( BOARD_ITEM* parent ) : DRAWSEGMENT( parent, TYPEEDGEZONE ) { } @@ -52,8 +52,8 @@ EDGE_ZONE:: ~EDGE_ZONE( void ) /**********************/ /* Classe DRAWSEGMENT: constructeur */ -DRAWSEGMENT::DRAWSEGMENT( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : - EDA_BaseLineStruct( StructFather, idtype ) +DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, DrawStructureType idtype ) : + BOARD_ITEM( StructFather, idtype ) { m_Flags = m_Shape = m_Type = m_Angle = 0; } @@ -76,7 +76,7 @@ void DRAWSEGMENT::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = Pnext; + ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } @@ -262,8 +262,8 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos ) /* Classe MARQUEUR */ /*******************/ -MARQUEUR::MARQUEUR( EDA_BaseStruct* StructFather ) : - EDA_BaseStruct( StructFather, TYPEMARQUEUR ) +MARQUEUR::MARQUEUR( BOARD_ITEM* StructFather ) : + BOARD_ITEM( StructFather, TYPEMARQUEUR ) { m_Bitmap = NULL; m_Type = 0; @@ -291,7 +291,7 @@ void MARQUEUR::UnLink( void ) } else /* Le chainage arriere pointe sur la structure "Pere" */ { - ( (BOARD*) Pback )->m_Drawings = Pnext; + ( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext; } } diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index e3fcdd58ab..d815aa29b7 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -379,7 +379,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) if( PtSegm->m_StructType != pt_aux->m_StructType ) continue; - if( PtSegm->m_Layer != pt_aux->m_Layer ) + if( PtSegm->GetLayer() != pt_aux->GetLayer() ) continue; if( PtSegm->m_NetCode != pt_aux->m_NetCode ) break; @@ -587,7 +587,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre { /* Ce ne doit pas etre sur un pad */ if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_Start, - g_TabOneLayerMask[pt_ref->m_Layer] ) ) + g_TabOneLayerMask[pt_ref->GetLayer()] ) ) return NULL; if( (pt_ref->m_Start.x == pt_segm->m_Start.x) @@ -605,7 +605,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre else /* extremite == END */ { /* Ce ne doit pas etre sur un pad */ - if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->m_Layer] ) ) + if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->GetLayer()] ) ) return NULL; if( pt_ref->m_End == pt_segm->m_Start ) diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp new file mode 100644 index 0000000000..f00dc5339a --- /dev/null +++ b/pcbnew/collectors.cpp @@ -0,0 +1,134 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com + * Copyright (C) 2004-2007 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if defined(DEBUG) + +#include "collectors.h" +#include "pcbnew.h" // class BOARD + + +/* This module contains out of line member functions for classes given in + collectors.h. Those classes augment the functionality of class WinEDA_PcbFrame. +*/ + + +// see collectors.h +const KICAD_T ARROWCOLLECTOR::AllBoardItems[] = { + TYPETEXTE, + TYPEDRAWSEGMENT, + TYPECOTATION, + TYPEVIA, + TYPETRACK, + TYPEPAD, + TYPETEXTEMODULE, + TYPEMODULE, + EOT +}; + + +/** + * Function Inspect + * is the examining function within the INSPECTOR which is passed to the + * Iterate function. Searches and collects all the objects that the old + * function PcbGeneralLocateAndDisplay() would find, except that it keeps all + * that it finds and does not do any displaying. + * + * @param testItem An EDA_BaseStruct to examine. + * @param notUsed The const void* testData. + * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, + * else SCAN_CONTINUE; + */ +SEARCH_RESULT ARROWCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* notUsed ) +{ + BOARD_ITEM* item = (BOARD_ITEM*) testItem; + + switch( item->m_StructType ) + { + case TYPEPAD: + case TYPEVIA: + /* + if( item->IsOnOneOfTheseLayers( m_LayerMask ) ) + { + if( item->HitTest( refPos ) ) + Append2nd( testItem ); + } + */ + break; + + case TYPETRACK: + case TYPETEXTE: + case TYPEDRAWSEGMENT: + case TYPECOTATION: + case TYPETEXTEMODULE: + case TYPEMODULE: + if( item->GetLayer() == m_PreferredLayer ) + { + if( item->HitTest( m_RefPos ) ) + Append( item ); + } + /* + else if( item->IsOnOneOfTheseLayers( m_LayerMask ) ) + { + if( item->HitTest( m_RefPos ) ) + Append2nd( item ); + } + */ + break; + + default: + ; // nothing + } + + return SEARCH_CONTINUE; +} + + +// see collectors.h +void ARROWCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, + int aPreferredLayer, int aLayerMask ) +{ + Empty(); // empty the collection, primary criteria list + Empty2nd(); // empty the collection, secondary criteria list + + /* remember where the snapshot was taken from and pass refPos to + the Inspect() function. + */ + SetRefPos( refPos ); + + // visit the board with the INSPECTOR (me). + board->Visit( this, // INSPECTOR* inspector + NULL, // const void* testData, not used here + m_ScanTypes); + + SetTimeNow(); // when snapshot was taken + + // @todo: append 2nd list onto end of the first "list" + + Empty2nd(); +} + + +#endif // DEBUG + +//EOF diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h new file mode 100644 index 0000000000..5a52ae3bef --- /dev/null +++ b/pcbnew/collectors.h @@ -0,0 +1,141 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com + * Copyright (C) 2004-2007 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef COLLECTORS_H +#define COLLECTORS_H + + +/* This module contains a number of COLLECTOR implementations which are used + to augment the functionality of class WinEDA_PcbFrame. +*/ + + +#include "class_collector.h" + + + +class RAT1COLLECTOR : public COLLECTOR +{ + ; +}; + + +/** + * Class ARROWCOLLECTOR + * is intended for use when the right click button is pressed, or when the + * plain "arrow" tool is in effect. This class can be used by window classes + * such as WinEDA_PcbFrame. + * + * Philosophy: this class knows nothing of the context in which as BOARD is used + * and that means it knows nothing about which layers are visible or current, + * but can handle those concerns by the SetPreferredLayer() function and the + * SetLayerMask() fuction. + */ +class ARROWCOLLECTOR : public COLLECTOR +{ + /** + * A place to hold collected objects which don't match precisely the search + * criteria, but would be acceptable if nothing else is found. + * "2nd" choice, which will be appended to the end of COLLECTOR's prime + * "list" at the end of the search. + */ + std::vector list2nd; + + + /** + * A bit-mapped layer mask that defines any layers which are acceptable + * on a secondary search criterion basis. + */ + int m_LayerMask; + + +public: + + /// A scan list for all editable board items, like PcbGeneralLocateAndDisplay() + static const KICAD_T AllBoardItems[]; + + + /** + * Constructor ARROWCOLLECTOR + */ + ARROWCOLLECTOR() + { + m_LayerMask = 0; + SetScanTypes( AllBoardItems ); + } + + void Empty2nd() + { + list2nd.clear(); + } + + void Append2nd( EDA_BaseStruct* item ) + { + list2nd.push_back( item ); + } + + + /** + * Function SetLayerMask + * takes a bit-mapped layer mask and records it. During the scan/search, + * this is used as a secondary criterion. That is, if there is no direct + * layer match with COLLECTOR::m_PreferredLayer (the primary criterion), + * then an object on any layer given in this bit-map is recorded as a + * second choice object if it also HitTest()s true. + * + * @param aLayerMask A layer mask which has bits in it indicating which + * layers are acceptable. Caller must pay attention to which layers are + * visible, selected, etc. All those concerns are handled outside this + * class, as stated in the class Philosophy above. + */ + void SetLayerMask( int aLayerMask ) + { + m_LayerMask = aLayerMask; + } + + + /** + * Function Inspect + * is the examining function within the INSPECTOR which is passed to the + * Iterate function. + * + * @param testItem An EDA_BaseStruct to examine. + * @param testData is not used in this class. + * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, + * else SCAN_CONTINUE; + */ + SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData ); + + + /** + * Function Scan + * scans a BOARD using this class's Inspector method, which does the collection. + * @param board A BOARD to scan. + * @param refPos A wxPoint to use in hit-testing. + */ + void Scan( BOARD* board, const wxPoint& refPos, int aPreferredLayer, int aLayerMask ); +}; + + +#endif // COLLECTORS_H diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index 19f0244f8d..9db61a1ca0 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -1,7 +1,7 @@ - /*************************************************************/ - /******************* editeur de PCB **************************/ - /* traitement du Chevelu: routines de calcul des connexions */ - /*************************************************************/ +/*************************************************************/ +/******************* editeur de PCB **************************/ +/* traitement du Chevelu: routines de calcul des connexions */ +/*************************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -16,766 +16,833 @@ /* variables locales */ /* routines exportees */ -void Recalcule_all_net_connexion(wxDC * DC); +void Recalcule_all_net_connexion( wxDC* DC ); /* Routines locales */ -static void propage_equipot(TRACK* pt_start_conn,TRACK* pt_end_conn) ; -static void calcule_connexite_1_net(TRACK* pt_start_conn,TRACK* pt_end_conn); -static void RebuildTrackChain(BOARD * pcb); -static int tri_par_netcode(TRACK ** pt_ref, TRACK ** pt_compare); +static void propage_equipot( TRACK* pt_start_conn, TRACK* pt_end_conn ); +static void calcule_connexite_1_net( TRACK* pt_start_conn, TRACK* pt_end_conn ); +static void RebuildTrackChain( BOARD* pcb ); +static int tri_par_netcode( TRACK** pt_ref, TRACK** pt_compare ); /*..*/ /*****************************************************************/ -static int change_equipot(TRACK* pt_start_conn,TRACK* pt_end_conn, - int old_val, int new_val) +static int change_equipot( TRACK* pt_start_conn, TRACK* pt_end_conn, + int old_val, int new_val ) /*****************************************************************/ + /* - Change les num locaux d'equipot old valeur en new valeur - retourne le nombre de changements - si pt_end_conn = NULL: recherche jusqu'a fin de chaine -*/ + * Change les num locaux d'equipot old valeur en new valeur + * retourne le nombre de changements + * si pt_end_conn = NULL: recherche jusqu'a fin de chaine + */ { -TRACK * pt_conn; -int nb_change = 0 ; -D_PAD * pt_pad; + TRACK* pt_conn; + int nb_change = 0; + D_PAD* pt_pad; - if( old_val == new_val) return(0) ; + if( old_val == new_val ) + return 0; - if( (old_val > 0) && (old_val < new_val) ) EXCHG(old_val,new_val) ; + if( (old_val > 0) && (old_val < new_val) ) + EXCHG( old_val, new_val ); - pt_conn = pt_start_conn; - for ( ; pt_conn != NULL; pt_conn= (TRACK*) pt_conn->Pnext) - { - if( pt_conn->m_Sous_Netcode != old_val) - { - if(pt_conn == pt_end_conn) break; - continue; - } + pt_conn = pt_start_conn; + for( ; pt_conn != NULL; pt_conn = (TRACK*) pt_conn->Pnext ) + { + if( pt_conn->m_Sous_Netcode != old_val ) + { + if( pt_conn == pt_end_conn ) + break; + continue; + } - nb_change++; - pt_conn->m_Sous_Netcode = new_val ; + nb_change++; + pt_conn->m_Sous_Netcode = new_val; - if( pt_conn->start && ( pt_conn->start->m_StructType == TYPEPAD) ) - { - pt_pad = (D_PAD*)(pt_conn->start); - if(pt_pad->m_physical_connexion == old_val) - pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; - } + if( pt_conn->start && ( pt_conn->start->m_StructType == TYPEPAD) ) + { + pt_pad = (D_PAD*) (pt_conn->start); + if( pt_pad->m_physical_connexion == old_val ) + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } - if( pt_conn->end && (pt_conn->end->m_StructType == TYPEPAD) ) - { - pt_pad = (D_PAD*)(pt_conn->end); - if(pt_pad->m_physical_connexion == old_val) - pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; - } - if(pt_conn == pt_end_conn) break; - } - return(nb_change); + if( pt_conn->end && (pt_conn->end->m_StructType == TYPEPAD) ) + { + pt_pad = (D_PAD*) (pt_conn->end); + if( pt_pad->m_physical_connexion == old_val ) + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + if( pt_conn == pt_end_conn ) + break; + } + + return nb_change; } + /******************************************************************/ -static void propage_equipot(TRACK* pt_start_conn,TRACK* pt_end_conn) +static void propage_equipot( TRACK* pt_start_conn, TRACK* pt_end_conn ) /******************************************************************/ + /* balaye la liste des SEGMENTS de PISTE - - debut = pt_start_conn - - fin = pt_end_conn (pointe le dernier segment a analyser) - pour attribuer ou propager un numero d'equipotentielle par - blocs de connexions existantes - la zone balayee est supposee appartenir au meme net, c'est a dire que - les segments de pistes sont tries par net_code -*/ + * - debut = pt_start_conn + * - fin = pt_end_conn (pointe le dernier segment a analyser) + * pour attribuer ou propager un numero d'equipotentielle par + * blocs de connexions existantes + * la zone balayee est supposee appartenir au meme net, c'est a dire que + * les segments de pistes sont tries par net_code + */ { -TRACK * pt_conn; -int sous_net_code ; -D_PAD * pt_pad; -TRACK * pt_autre_piste; -EDA_BaseStruct * PtStruct; + TRACK* pt_conn; + int sous_net_code; + D_PAD* pt_pad; + TRACK* pt_autre_piste; + BOARD_ITEM* PtStruct; - /* Initialisations prealables */ - pt_conn = pt_start_conn; - for ( ; pt_conn != NULL; pt_conn= (TRACK*) pt_conn->Pnext) - { - pt_conn->m_Sous_Netcode = 0; - PtStruct = pt_conn->start; - if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) - ((D_PAD*)PtStruct)->m_physical_connexion = 0; + /* Initialisations prealables */ + pt_conn = pt_start_conn; + for( ; pt_conn != NULL; pt_conn = (TRACK*) pt_conn->Pnext ) + { + pt_conn->m_Sous_Netcode = 0; + PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + ( (D_PAD*) PtStruct )->m_physical_connexion = 0; - PtStruct = pt_conn->end; - if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) - ((D_PAD*)PtStruct)->m_physical_connexion = 0; + PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + ( (D_PAD*) PtStruct )->m_physical_connexion = 0; - if (pt_conn == pt_end_conn) break; - } - sous_net_code = 1 ; pt_start_conn->m_Sous_Netcode = sous_net_code; + if( pt_conn == pt_end_conn ) + break; + } - /* debut du calcul de propagation */ - pt_conn = pt_start_conn; - for ( ; pt_conn != NULL; pt_conn= (TRACK*) pt_conn->Pnext) - { - /* Traitement des connexions a pads */ - PtStruct = pt_conn->start; - if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) - /* la connexion debute sur 1 pad */ - { - pt_pad = (D_PAD*) PtStruct; - if( pt_conn->m_Sous_Netcode) /* la connexion fait deja partie d'une chaine */ - { - if(pt_pad->m_physical_connexion > 0) /* le pad fait aussi partie d'une chaine */ - { - change_equipot(pt_start_conn,pt_end_conn, - pt_pad->m_physical_connexion,pt_conn->m_Sous_Netcode); - } - else pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; - } - else /* la connexion ne fait pas partie encore d'une chaine */ - { - if(pt_pad->m_physical_connexion > 0) - { - pt_conn->m_Sous_Netcode = pt_pad->m_physical_connexion; - } - else - { - sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; - pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; - } - } - } + sous_net_code = 1; + pt_start_conn->m_Sous_Netcode = sous_net_code; - PtStruct = pt_conn->end; - if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) - /* la connexion finit sur 1 pad */ - { - pt_pad = (D_PAD*)PtStruct; - if( pt_conn->m_Sous_Netcode) - { - if(pt_pad->m_physical_connexion > 0) - { - change_equipot(pt_start_conn,pt_end_conn, - pt_pad->m_physical_connexion,pt_conn->m_Sous_Netcode); - } - else pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; - } - else - { - if(pt_pad->m_physical_connexion > 0) - { - pt_conn->m_Sous_Netcode = pt_pad->m_physical_connexion; - } - else - { - sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; - pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; - } - } - } + /* debut du calcul de propagation */ + pt_conn = pt_start_conn; + for( ; pt_conn != NULL; pt_conn = (TRACK*) pt_conn->Pnext ) + { + /* Traitement des connexions a pads */ + PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + /* la connexion debute sur 1 pad */ + { + pt_pad = (D_PAD*) PtStruct; + if( pt_conn->m_Sous_Netcode ) /* la connexion fait deja partie d'une chaine */ + { + if( pt_pad->m_physical_connexion > 0 ) /* le pad fait aussi partie d'une chaine */ + { + change_equipot( pt_start_conn, pt_end_conn, + pt_pad->m_physical_connexion, pt_conn->m_Sous_Netcode ); + } + else + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + else /* la connexion ne fait pas partie encore d'une chaine */ + { + if( pt_pad->m_physical_connexion > 0 ) + { + pt_conn->m_Sous_Netcode = pt_pad->m_physical_connexion; + } + else + { + sous_net_code++; + pt_conn->m_Sous_Netcode = sous_net_code; + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + } + } + + PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + /* la connexion finit sur 1 pad */ + { + pt_pad = (D_PAD*) PtStruct; + if( pt_conn->m_Sous_Netcode ) + { + if( pt_pad->m_physical_connexion > 0 ) + { + change_equipot( pt_start_conn, pt_end_conn, + pt_pad->m_physical_connexion, pt_conn->m_Sous_Netcode ); + } + else + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + else + { + if( pt_pad->m_physical_connexion > 0 ) + { + pt_conn->m_Sous_Netcode = pt_pad->m_physical_connexion; + } + else + { + sous_net_code++; pt_conn->m_Sous_Netcode = sous_net_code; + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + } + } - /* traitement des connexions entre segments */ - PtStruct = pt_conn->start; - if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) - { /* debut sur une autre piste */ - pt_autre_piste = (TRACK*)PtStruct; + /* traitement des connexions entre segments */ + PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) + { + /* debut sur une autre piste */ + pt_autre_piste = (TRACK*) PtStruct; - if(pt_conn->m_Sous_Netcode) /* La connexion fait deja partie d'un block */ - { - if(pt_autre_piste->m_Sous_Netcode) - { - change_equipot(pt_start_conn,pt_end_conn, - pt_autre_piste->m_Sous_Netcode,pt_conn->m_Sous_Netcode); - } - else - { - pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; - } - } + if( pt_conn->m_Sous_Netcode ) /* La connexion fait deja partie d'un block */ + { + if( pt_autre_piste->m_Sous_Netcode ) + { + change_equipot( pt_start_conn, pt_end_conn, + pt_autre_piste->m_Sous_Netcode, pt_conn->m_Sous_Netcode ); + } + else + { + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + } + else /* La connexion ne fait partie d'aucun block */ + { + if( pt_autre_piste->m_Sous_Netcode ) + { + pt_conn->m_Sous_Netcode = pt_autre_piste->m_Sous_Netcode; + } + else + { + sous_net_code++; pt_conn->m_Sous_Netcode = sous_net_code; + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + } + } - else /* La connexion ne fait partie d'aucun block */ - { - if(pt_autre_piste->m_Sous_Netcode) - { - pt_conn->m_Sous_Netcode = pt_autre_piste->m_Sous_Netcode; - } - else - { - sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; - pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; - } - } - } - - PtStruct = pt_conn->end; - if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) - { /* fin connectee a une autre piste */ - pt_autre_piste = (TRACK*) PtStruct; - if(pt_conn->m_Sous_Netcode) /* La connexion fait deja partie d'un block */ - { - if(pt_autre_piste->m_Sous_Netcode) - { - change_equipot(pt_start_conn,pt_end_conn, - pt_autre_piste->m_Sous_Netcode,pt_conn->m_Sous_Netcode); - } - else pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; - } - else /* La connexion ne fait partie d'aucun block */ - { - if(pt_autre_piste->m_Sous_Netcode) - { - pt_conn->m_Sous_Netcode = pt_autre_piste->m_Sous_Netcode; - } - else - { - sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; - pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; - } - } - } - if (pt_conn == pt_end_conn) break; - } + PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) + { + /* fin connectee a une autre piste */ + pt_autre_piste = (TRACK*) PtStruct; + + if( pt_conn->m_Sous_Netcode ) /* La connexion fait deja partie d'un block */ + { + if( pt_autre_piste->m_Sous_Netcode ) + { + change_equipot( pt_start_conn, pt_end_conn, + pt_autre_piste->m_Sous_Netcode, pt_conn->m_Sous_Netcode ); + } + else + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + else /* La connexion ne fait partie d'aucun block */ + { + if( pt_autre_piste->m_Sous_Netcode ) + { + pt_conn->m_Sous_Netcode = pt_autre_piste->m_Sous_Netcode; + } + else + { + sous_net_code++; pt_conn->m_Sous_Netcode = sous_net_code; + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + } + } + if( pt_conn == pt_end_conn ) + break; + } } + /***************************************************/ -void WinEDA_BasePcbFrame::test_connexions(wxDC * DC ) +void WinEDA_BasePcbFrame::test_connexions( wxDC* DC ) /***************************************************/ + /* -Routine recherchant les connexions deja faites et mettant a jour -le status du chevelu ( Bit CH_ACTIF mis a 0 si connexion trouvee -Les pistes sont supposees etre triees par ordre de net_code croissant -*/ + * Routine recherchant les connexions deja faites et mettant a jour + * le status du chevelu ( Bit CH_ACTIF mis a 0 si connexion trouvee + * Les pistes sont supposees etre triees par ordre de net_code croissant + */ { -TRACK * pt_start_conn, * pt_end_conn; -int ii ; -LISTE_PAD * pt_pad; -int current_net_code; + TRACK* pt_start_conn, * pt_end_conn; + int ii; + LISTE_PAD* pt_pad; + int current_net_code; - /* Etablissement des equipotentielles vraies */ - pt_pad = m_Pcb->m_Pads; - for( ii = 0; ii < m_Pcb->m_NbPads; ii++ , pt_pad++) - { - (*pt_pad)->m_physical_connexion = 0 ; - } + /* Etablissement des equipotentielles vraies */ + pt_pad = m_Pcb->m_Pads; + for( ii = 0; ii < m_Pcb->m_NbPads; ii++, pt_pad++ ) + { + (*pt_pad)->m_physical_connexion = 0; + } - //////////////////////////// - // Calcul de la connexite // - //////////////////////////// + //////////////////////////// + // Calcul de la connexite // + //////////////////////////// - /* Les pointeurs .start et .end sont mis a jour, si la - connexion est du type segment a segment - */ + /* Les pointeurs .start et .end sont mis a jour, si la + * connexion est du type segment a segment + */ - pt_start_conn = m_Pcb->m_Track; - while(pt_start_conn != NULL) - { - current_net_code = pt_start_conn->m_NetCode; - pt_end_conn = pt_start_conn->GetEndNetCode(current_net_code); + pt_start_conn = m_Pcb->m_Track; + while( pt_start_conn != NULL ) + { + current_net_code = pt_start_conn->m_NetCode; + pt_end_conn = pt_start_conn->GetEndNetCode( current_net_code ); - /* Calcul des connexions type segment du net courant */ - calcule_connexite_1_net(pt_start_conn, pt_end_conn); + /* Calcul des connexions type segment du net courant */ + calcule_connexite_1_net( pt_start_conn, pt_end_conn ); - pt_start_conn = (TRACK*)pt_end_conn->Pnext; - } + pt_start_conn = (TRACK*) pt_end_conn->Pnext; + } - return; + return; } + /**************************************************************/ -void WinEDA_BasePcbFrame::Recalcule_all_net_connexion(wxDC * DC) +void WinEDA_BasePcbFrame::Recalcule_all_net_connexion( wxDC* DC ) /**************************************************************/ + /* - Routine Recalculant les pointeurs sur connexions types piste a piste - relatives a tous les nets. - Cette routine est utilisee apres reclassement des segments de piste par - ordre de net_code, puisque des pointeurs sur connexions deviennent faux - ( les pointeurs type pad restent bons ) -*/ + * Routine Recalculant les pointeurs sur connexions types piste a piste + * relatives a tous les nets. + * Cette routine est utilisee apres reclassement des segments de piste par + * ordre de net_code, puisque des pointeurs sur connexions deviennent faux + * ( les pointeurs type pad restent bons ) + */ { -TRACK * EndConn; -int net_code, net_code_max; + TRACK* EndConn; + int net_code, net_code_max; - if(m_Pcb->m_Track == NULL ) return; + if( m_Pcb->m_Track == NULL ) + return; - /* calcul du net_code max */ - EndConn = m_Pcb->m_Track; - while( EndConn->Pnext) EndConn = (TRACK*)EndConn->Pnext; - net_code_max = EndConn->m_NetCode; + /* calcul du net_code max */ + EndConn = m_Pcb->m_Track; + while( EndConn->Pnext ) + EndConn = (TRACK*) EndConn->Pnext; - for ( net_code = 0; net_code <= net_code_max; net_code++ ) - { - test_1_net_connexion(DC, net_code); - } + net_code_max = EndConn->m_NetCode; + + for( net_code = 0; net_code <= net_code_max; net_code++ ) + { + test_1_net_connexion( DC, net_code ); + } } + /*************************************************************************/ -void WinEDA_BasePcbFrame::test_1_net_connexion(wxDC * DC, int net_code) +void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code ) /*************************************************************************/ + /* -Routine recherchant les connexions deja faites relatives a 1 net -*/ + * Routine recherchant les connexions deja faites relatives a 1 net + */ { -TRACK * pt_start_conn, * pt_end_conn; -int ii, nb_net_noconnect = 0; -LISTE_PAD * pt_pad; -wxString msg; - - if(net_code == 0) return; + TRACK* pt_start_conn, * pt_end_conn; + int ii, nb_net_noconnect = 0; + LISTE_PAD* pt_pad; + wxString msg; - if ( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) - Compile_Ratsnest( DC, TRUE ); + if( net_code == 0 ) + return; - pt_pad = (LISTE_PAD*)m_Pcb->m_Pads; - for( ii = 0; ii < m_Pcb->m_NbPads; ii++ , pt_pad++) - { - int pad_net_code = (*pt_pad)->m_NetCode; - if(pad_net_code < net_code) continue; - if(pad_net_code > net_code) break; - (*pt_pad)->m_physical_connexion = 0 ; - } + if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + Compile_Ratsnest( DC, TRUE ); - /* Determination des limites du net */ - if( m_Pcb->m_Track ) - { - pt_end_conn = NULL; - pt_start_conn = m_Pcb->m_Track->GetStartNetCode(net_code); + pt_pad = (LISTE_PAD*) m_Pcb->m_Pads; + for( ii = 0; ii < m_Pcb->m_NbPads; ii++, pt_pad++ ) + { + int pad_net_code = (*pt_pad)->m_NetCode; + if( pad_net_code < net_code ) + continue; + if( pad_net_code > net_code ) + break; + (*pt_pad)->m_physical_connexion = 0; + } - if( pt_start_conn ) - pt_end_conn = pt_start_conn->GetEndNetCode(net_code); + /* Determination des limites du net */ + if( m_Pcb->m_Track ) + { + pt_end_conn = NULL; + pt_start_conn = m_Pcb->m_Track->GetStartNetCode( net_code ); - if( pt_start_conn && pt_end_conn ) // c.a.d. s'il y a des segments - { - calcule_connexite_1_net(pt_start_conn, pt_end_conn); - } - } + if( pt_start_conn ) + pt_end_conn = pt_start_conn->GetEndNetCode( net_code ); - /* Test des chevelus */ - nb_net_noconnect = Test_1_Net_Ratsnest(DC, net_code); + if( pt_start_conn && pt_end_conn ) // c.a.d. s'il y a des segments + { + calcule_connexite_1_net( pt_start_conn, pt_end_conn ); + } + } - /* Affichage des resultats */ - msg.Printf( wxT("links %d nc %d net:nc %d"), - m_Pcb->m_NbLinks, m_Pcb->GetNumNoconnect(), - nb_net_noconnect); + /* Test des chevelus */ + nb_net_noconnect = Test_1_Net_Ratsnest( DC, net_code ); - Affiche_Message(msg); - return; + /* Affichage des resultats */ + msg.Printf( wxT( "links %d nc %d net:nc %d" ), + m_Pcb->m_NbLinks, m_Pcb->GetNumNoconnect(), + nb_net_noconnect ); + + Affiche_Message( msg ); + return; } - /***************************************************************************/ -static void calcule_connexite_1_net(TRACK* pt_start_conn,TRACK* pt_end_conn) +static void calcule_connexite_1_net( TRACK* pt_start_conn, TRACK* pt_end_conn ) /***************************************************************************/ + /* calcule la connexite d'un net constitue de segments de piste consecutifs. - Entree: - pt_start_conn = adresse du 1er segment ( debut du net ) - pt_end_conn = adr de fin (dernier segment) - Les connexions relatives aux pads doivent etre deja calculees, car elles - ne sont pas ici recalculees ( pour des raisons de temps de calcul, et - du fait que lors des modif de pistes, les pads ne sont pas touches -*/ + * Entree: + * pt_start_conn = adresse du 1er segment ( debut du net ) + * pt_end_conn = adr de fin (dernier segment) + * Les connexions relatives aux pads doivent etre deja calculees, car elles + * ne sont pas ici recalculees ( pour des raisons de temps de calcul, et + * du fait que lors des modif de pistes, les pads ne sont pas touches + */ { -TRACK * Track; + TRACK* Track; - /* Les pointeurs .start et .end sont mis a jour, si la - connexion est du type segment a segment. - la connexion sur pads est supposee etre deja calculee */ + /* Les pointeurs .start et .end sont mis a jour, si la + * connexion est du type segment a segment. + * la connexion sur pads est supposee etre deja calculee */ - /* Raz des pointeurs sur pistes */ - for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext) - { - Track->m_Sous_Netcode = 0; + /* Raz des pointeurs sur pistes */ + for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext ) + { + Track->m_Sous_Netcode = 0; - if( Track->GetState(BEGIN_ONPAD) == 0 ) Track->start = NULL; - if( Track->GetState(END_ONPAD) == 0 ) Track->end = NULL; + if( Track->GetState( BEGIN_ONPAD ) == 0 ) + Track->start = NULL; + if( Track->GetState( END_ONPAD ) == 0 ) + Track->end = NULL; - if (Track == pt_end_conn) break; - } + if( Track == pt_end_conn ) + break; + } - /* calcul des connexions */ - for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext) - { - if(Track->m_StructType == TYPEVIA) - { - TRACK* pt_segm; - int layermask = Track->ReturnMaskLayer(); - for( pt_segm = pt_start_conn; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) - { - int curlayermask = pt_segm->ReturnMaskLayer(); - if( !pt_segm->start && (pt_segm->m_Start == Track->m_Start) && - ( layermask & curlayermask ) ) - { - pt_segm->start = Track; - } - if( !pt_segm->end && (pt_segm->m_End == Track->m_Start) && - (layermask & curlayermask) ) - { - pt_segm->end = Track; - } - if( pt_segm == pt_end_conn ) break; - } - } + /* calcul des connexions */ + for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext ) + { + if( Track->m_StructType == TYPEVIA ) + { + TRACK* pt_segm; + int layermask = Track->ReturnMaskLayer(); + for( pt_segm = pt_start_conn; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + int curlayermask = pt_segm->ReturnMaskLayer(); + if( !pt_segm->start && (pt_segm->m_Start == Track->m_Start) + && ( layermask & curlayermask ) ) + { + pt_segm->start = Track; + } + if( !pt_segm->end && (pt_segm->m_End == Track->m_Start) + && (layermask & curlayermask) ) + { + pt_segm->end = Track; + } + if( pt_segm == pt_end_conn ) + break; + } + } - if( Track->start == NULL ) - { - Track->start = Locate_Piste_Connectee(Track, Track,pt_end_conn,START); - } + if( Track->start == NULL ) + { + Track->start = Locate_Piste_Connectee( Track, Track, pt_end_conn, START ); + } - if( Track->end == NULL ) - { - Track->end = Locate_Piste_Connectee(Track, Track,pt_end_conn,END); - } - if (Track == pt_end_conn) break; - } - - /* Generation des sous equipots du net */ - propage_equipot(pt_start_conn,pt_end_conn); + if( Track->end == NULL ) + { + Track->end = Locate_Piste_Connectee( Track, Track, pt_end_conn, END ); + } + if( Track == pt_end_conn ) + break; + } + /* Generation des sous equipots du net */ + propage_equipot( pt_start_conn, pt_end_conn ); } +/********************************************/ +/* Reattribution des net_codes de reference */ +/********************************************/ - /********************************************/ - /* Reattribution des net_codes de reference */ - /********************************************/ /* - reattribution des net_codes aux segments de pistes. - Routine utilisee apres modification generale des noms de nets (apres - lecrure netliste ou edition de nets sur pads, effacement /ajout de - modules...) - - Elle se fait en 2 passes: - 1 - reattribution des segments commencant ( et/ou finissant ) sur 1 pad - les autres segments sont mis a reference NULLE - 2 - reattribution des segments restantes a ref NULLE -*/ + * reattribution des net_codes aux segments de pistes. + * Routine utilisee apres modification generale des noms de nets (apres + * lecrure netliste ou edition de nets sur pads, effacement /ajout de + * modules...) + * + * Elle se fait en 2 passes: + * 1 - reattribution des segments commencant ( et/ou finissant ) sur 1 pad + * les autres segments sont mis a reference NULLE + * 2 - reattribution des segments restantes a ref NULLE + */ #define POS_AFF_CHREF 62 + /* recherche le pad connecte a l'extremite de la piste de coord px, py - parametres d'appel: - px, py = coord du point tst - masque_layer = couche(s) de connexion - pt_liste = adresse de la liste des pointeurs de pads, tels que - apparaissant apres build_liste_pad, mais classee par position X - de pads croissantes. - retourne : pointeur sur le pad connecte - la routine travaille par dichotomie sur la liste des pads tries par pos X -croissante, elle est donc beaucoup plus rapide que Fast_Locate_Pad_connecte, -mais implique le calcul de cette liste. + * parametres d'appel: + * px, py = coord du point tst + * masque_layer = couche(s) de connexion + * pt_liste = adresse de la liste des pointeurs de pads, tels que + * apparaissant apres build_liste_pad, mais classee par position X + * de pads croissantes. + * retourne : pointeur sur le pad connecte + * la routine travaille par dichotomie sur la liste des pads tries par pos X + * croissante, elle est donc beaucoup plus rapide que Fast_Locate_Pad_connecte, + * mais implique le calcul de cette liste. + * + * (la liste placee en m_Pcb->m_Pads et elle triee par netcodes croissants) + */ -(la liste placee en m_Pcb->m_Pads et elle triee par netcodes croissants) -*/ - -static D_PAD * SuperFast_Locate_Pad_Connecte( BOARD * pcb, LISTE_PAD * pt_liste, - int px, int py, int masque_layer) +static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* pcb, LISTE_PAD* pt_liste, + int px, int py, int masque_layer ) { -D_PAD * pad ; -LISTE_PAD * ptr_pad , * lim; -int nb_pad = pcb->m_NbPads; -int ii; - lim = pt_liste + (pcb->m_NbPads - 1 ); - ptr_pad = pt_liste; - while(nb_pad) - { - pad = * ptr_pad; - ii = nb_pad; - nb_pad >>= 1; if( (ii & 1) && ( ii > 1 ) ) nb_pad++; - if( pad->m_Pos.x < px ) /* on doit chercher plus loin */ - { - ptr_pad += nb_pad; if(ptr_pad > lim) ptr_pad = lim; - continue; - } - if( pad->m_Pos.x > px ) /* on doit chercher moins loin */ - { - ptr_pad -= nb_pad; - if(ptr_pad < pt_liste) ptr_pad = pt_liste; - continue; - } + D_PAD* pad; + LISTE_PAD* ptr_pad, * lim; + int nb_pad = pcb->m_NbPads; + int ii; - if( pad->m_Pos.x == px ) /* zone de classement trouvee */ - { - /* recherche du debut de la zone */ - while( ptr_pad >= pt_liste) - { - pad = * ptr_pad; - if(pad->m_Pos.x == px) ptr_pad--; - else break; - } - ptr_pad++; /* pointe depart de zone a pad->m_Pos.x = px */ + lim = pt_liste + (pcb->m_NbPads - 1 ); + ptr_pad = pt_liste; + while( nb_pad ) + { + pad = *ptr_pad; + ii = nb_pad; + nb_pad >>= 1; if( (ii & 1) && ( ii > 1 ) ) + nb_pad++; + if( pad->m_Pos.x < px ) /* on doit chercher plus loin */ + { + ptr_pad += nb_pad; if( ptr_pad > lim ) + ptr_pad = lim; + continue; + } + if( pad->m_Pos.x > px ) /* on doit chercher moins loin */ + { + ptr_pad -= nb_pad; + if( ptr_pad < pt_liste ) + ptr_pad = pt_liste; + continue; + } - for( ; ; ptr_pad++ ) - { - if(ptr_pad > lim) return(NULL); /* hors zone */ - pad = *ptr_pad; - if( pad->m_Pos.x != px ) return(NULL); /* hors zone */ - if( pad->m_Pos.y != py ) continue ; - /* Pad peut-etre trouve ici: il doit etre sur la bonne couche */ - if (pad->m_Masque_Layer & masque_layer) return(pad) ; - } - } - } - return(NULL); + if( pad->m_Pos.x == px ) /* zone de classement trouvee */ + { + /* recherche du debut de la zone */ + while( ptr_pad >= pt_liste ) + { + pad = *ptr_pad; + if( pad->m_Pos.x == px ) + ptr_pad--; + else + break; + } + + ptr_pad++; /* pointe depart de zone a pad->m_Pos.x = px */ + + for( ; ; ptr_pad++ ) + { + if( ptr_pad > lim ) + return NULL; /* hors zone */ + pad = *ptr_pad; + if( pad->m_Pos.x != px ) + return NULL; /* hors zone */ + if( pad->m_Pos.y != py ) + continue; + /* Pad peut-etre trouve ici: il doit etre sur la bonne couche */ + if( pad->m_Masque_Layer & masque_layer ) + return pad; + } + } + } + + return NULL; } -static int SortPadsByXCoord( void * pt_ref, void * pt_comp) +static int SortPadsByXCoord( void* pt_ref, void* pt_comp ) + /* used to Sort a pad list by x coordinate value -*/ + */ { -D_PAD * ref = *(LISTE_PAD*) pt_ref; -D_PAD * comp = *(LISTE_PAD*) pt_comp; - return( ref->m_Pos.x - comp->m_Pos.x ); + D_PAD* ref = *(LISTE_PAD*) pt_ref; + D_PAD* comp = *(LISTE_PAD*) pt_comp; + + return ref->m_Pos.x - comp->m_Pos.x; } + /****************************************************/ -LISTE_PAD* CreateSortedPadListByXCoord(BOARD * pcb ) +LISTE_PAD* CreateSortedPadListByXCoord( BOARD* pcb ) /****************************************************/ + /* Create a sorted list of pointers to pads. - This list is sorted by X ccordinate value. - The list must be freed bu user -*/ + * This list is sorted by X ccordinate value. + * The list must be freed bu user + */ { -LISTE_PAD* pad_list = (LISTE_PAD*) MyMalloc( pcb->m_NbPads * sizeof( D_PAD *) ); - memcpy(pad_list, pcb->m_Pads, pcb->m_NbPads* sizeof( D_PAD *) ); - qsort(pad_list, pcb->m_NbPads, sizeof( D_PAD *), - (int(*)(const void *, const void *)) SortPadsByXCoord); - return pad_list; + LISTE_PAD* pad_list = (LISTE_PAD*) MyMalloc( pcb->m_NbPads * sizeof( D_PAD *) ); + + memcpy( pad_list, pcb->m_Pads, pcb->m_NbPads * sizeof( D_PAD *) ); + qsort( pad_list, pcb->m_NbPads, sizeof( D_PAD *), + ( int( * ) ( const void*, const void* ) )SortPadsByXCoord ); + return pad_list; } + /******************************************************************/ -void WinEDA_BasePcbFrame::reattribution_reference_piste(int affiche) +void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) /******************************************************************/ { -TRACK * pt_piste, - * pt_next; -int a_color; -char new_passe_request = 1, flag; -LISTE_PAD * pt_mem; -EDA_BaseStruct * PtStruct; -int masque_layer; -wxString msg; + TRACK* pt_piste, + * pt_next; + int a_color; + char new_passe_request = 1, flag; + LISTE_PAD* pt_mem; + BOARD_ITEM* PtStruct; + int masque_layer; + wxString msg; - if( m_Pcb->m_NbPads == 0 ) return; - a_color = CYAN; - if(affiche) - Affiche_1_Parametre(this, POS_AFF_CHREF, wxT("DataBase"), wxT("Netcodes"),a_color); + if( m_Pcb->m_NbPads == 0 ) + return; + a_color = CYAN; + if( affiche ) + Affiche_1_Parametre( this, POS_AFF_CHREF, wxT( "DataBase" ), wxT( "Netcodes" ), a_color ); - recalcule_pad_net_code(); + recalcule_pad_net_code(); - if(affiche) Affiche_1_Parametre(this, -1,wxEmptyString, wxT("Gen Pads "),a_color); + if( affiche ) + Affiche_1_Parametre( this, -1, wxEmptyString, wxT( "Gen Pads " ), a_color ); - ////////////////////////////////////////////////////// - // Connexion des pistes accrochees a 1 pad au moins // - ////////////////////////////////////////////////////// - pt_mem = CreateSortedPadListByXCoord(m_Pcb); + ////////////////////////////////////////////////////// + // Connexion des pistes accrochees a 1 pad au moins // + ////////////////////////////////////////////////////// + pt_mem = CreateSortedPadListByXCoord( m_Pcb ); - if(affiche) - Affiche_1_Parametre(this, -1,wxEmptyString, wxT("Conn Pads"),a_color); + if( affiche ) + Affiche_1_Parametre( this, -1, wxEmptyString, wxT( "Conn Pads" ), a_color ); - /* Raz des flags particuliers des segments de piste */ - pt_piste = m_Pcb->m_Track; - for ( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) - { - pt_piste->SetState(BUSY|EDIT|BEGIN_ONPAD|END_ONPAD, OFF); - pt_piste->m_NetCode = 0; - } + /* Raz des flags particuliers des segments de piste */ + pt_piste = m_Pcb->m_Track; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + { + pt_piste->SetState( BUSY | EDIT | BEGIN_ONPAD | END_ONPAD, OFF ); + pt_piste->m_NetCode = 0; + } - pt_piste = m_Pcb->m_Track; - for ( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) - { - flag = 0; - masque_layer = g_TabOneLayerMask[pt_piste->m_Layer]; + pt_piste = m_Pcb->m_Track; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + { + flag = 0; + masque_layer = g_TabOneLayerMask[pt_piste->GetLayer()]; - /* y a t-il une pastille sur une extremite */ - pt_piste->start = SuperFast_Locate_Pad_Connecte(m_Pcb, pt_mem, - pt_piste->m_Start.x, pt_piste->m_Start.y, masque_layer); - if( pt_piste->start != NULL) - { - pt_piste->SetState( BEGIN_ONPAD, ON); - pt_piste->m_NetCode = ((D_PAD*)(pt_piste->start))->m_NetCode; - } + /* y a t-il une pastille sur une extremite */ + pt_piste->start = SuperFast_Locate_Pad_Connecte( m_Pcb, + pt_mem, + pt_piste->m_Start.x, + pt_piste->m_Start.y, + masque_layer ); + if( pt_piste->start != NULL ) + { + pt_piste->SetState( BEGIN_ONPAD, ON ); + pt_piste->m_NetCode = ( (D_PAD*) (pt_piste->start) )->m_NetCode; + } - pt_piste->end = SuperFast_Locate_Pad_Connecte(m_Pcb, pt_mem, - pt_piste->m_End.x, pt_piste->m_End.y, masque_layer); + pt_piste->end = SuperFast_Locate_Pad_Connecte( m_Pcb, + pt_mem, + pt_piste->m_End.x, + pt_piste->m_End.y, + masque_layer ); - if( pt_piste->end != NULL) - { - pt_piste->SetState(END_ONPAD, ON); - pt_piste->m_NetCode = ((D_PAD*)(pt_piste->end))->m_NetCode; - } + if( pt_piste->end != NULL ) + { + pt_piste->SetState( END_ONPAD, ON ); + pt_piste->m_NetCode = ( (D_PAD*) (pt_piste->end) )->m_NetCode; + } + } - } - MyFree(pt_mem); + MyFree( pt_mem ); - //////////////////////////////////////////////////// - // Calcul de la connexite entre segments de piste // - //////////////////////////////////////////////////// + //////////////////////////////////////////////////// + // Calcul de la connexite entre segments de piste // + //////////////////////////////////////////////////// - /* Les pointeurs .start et .end sont mis a jour, s'ils etaient NULLs. - La connexion est alors du type segment a segment - */ - if(affiche) - Affiche_1_Parametre(this, POS_AFF_CHREF,wxEmptyString, wxT("Conn Segm"), a_color); + /* Les pointeurs .start et .end sont mis a jour, s'ils etaient NULLs. + * La connexion est alors du type segment a segment + */ + if( affiche ) + Affiche_1_Parametre( this, POS_AFF_CHREF, wxEmptyString, wxT( "Conn Segm" ), a_color ); - for ( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next()) - { - if ( pt_piste->start == NULL ) - { - pt_piste->start = Locate_Piste_Connectee(pt_piste, m_Pcb->m_Track,NULL,START); - } + for( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next() ) + { + if( pt_piste->start == NULL ) + { + pt_piste->start = Locate_Piste_Connectee( pt_piste, m_Pcb->m_Track, NULL, START ); + } - if ( pt_piste->end == NULL ) - { - pt_piste->end = Locate_Piste_Connectee(pt_piste, m_Pcb->m_Track,NULL,END); - } - } + if( pt_piste->end == NULL ) + { + pt_piste->end = Locate_Piste_Connectee( pt_piste, m_Pcb->m_Track, NULL, END ); + } + } - //////////////////////////////// - // Reattribution des net_code // - //////////////////////////////// + //////////////////////////////// + // Reattribution des net_code // + //////////////////////////////// - a_color = YELLOW; + a_color = YELLOW; - while(new_passe_request) - { - bool reset_flag = FALSE; - new_passe_request = 0; - if(affiche) - { - msg.Printf( wxT("Net->Segm pass %d "), new_passe_request+1); - Affiche_1_Parametre(this, POS_AFF_CHREF,wxEmptyString, msg, a_color); - } + while( new_passe_request ) + { + bool reset_flag = FALSE; + new_passe_request = 0; + if( affiche ) + { + msg.Printf( wxT( "Net->Segm pass %d " ), new_passe_request + 1 ); + Affiche_1_Parametre( this, POS_AFF_CHREF, wxEmptyString, msg, a_color ); + } - /* look for vias which could be connect many tracks */ - for ( TRACK * via = m_Pcb->m_Track; via != NULL; via = via->Next() ) - { - if ( via->m_StructType != TYPEVIA ) continue; - if ( via->m_NetCode > 0 ) continue; // Netcode already known - // Lock for a connection to a track with a known netcode - pt_next = m_Pcb->m_Track; - while ( (pt_next = Locate_Piste_Connectee(via, pt_next, NULL,START)) != NULL ) - { - if (pt_next->m_NetCode ) - { - via->m_NetCode = pt_next->m_NetCode; - break; - } - pt_next->SetState(BUSY, ON); - reset_flag = TRUE; - } - } + /* look for vias which could be connect many tracks */ + for( TRACK* via = m_Pcb->m_Track; via != NULL; via = via->Next() ) + { + if( via->m_StructType != TYPEVIA ) + continue; + if( via->m_NetCode > 0 ) + continue; // Netcode already known + // Lock for a connection to a track with a known netcode + pt_next = m_Pcb->m_Track; + while( ( pt_next = Locate_Piste_Connectee( via, pt_next, NULL, START ) ) != NULL ) + { + if( pt_next->m_NetCode ) + { + via->m_NetCode = pt_next->m_NetCode; + break; + } + pt_next->SetState( BUSY, ON ); + reset_flag = TRUE; + } + } - if ( reset_flag ) for ( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next()) - { - pt_piste->SetState(BUSY, OFF); - } + if( reset_flag ) + for( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next() ) + { + pt_piste->SetState( BUSY, OFF ); + } - for ( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next()) - { - /* Traitement du point de debut */ - PtStruct = (EDA_BaseStruct*)pt_piste->start; - if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) - { // Begin on an other track segment - pt_next = (TRACK*)PtStruct; - if(pt_piste->m_NetCode) - { - if(pt_next->m_NetCode == 0) - { - new_passe_request = 1; - pt_next->m_NetCode = pt_piste->m_NetCode; - } - } + for( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next() ) + { + /* Traitement du point de debut */ + PtStruct = (BOARD_ITEM*) pt_piste->start; + if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) + { // Begin on an other track segment + pt_next = (TRACK*) PtStruct; + if( pt_piste->m_NetCode ) + { + if( pt_next->m_NetCode == 0 ) + { + new_passe_request = 1; + pt_next->m_NetCode = pt_piste->m_NetCode; + } + } + else + { + if( pt_next->m_NetCode != 0 ) + { + pt_piste->m_NetCode = pt_next->m_NetCode; + new_passe_request = 1; + } + } + } - else - { - if(pt_next->m_NetCode != 0) - { - pt_piste->m_NetCode = pt_next->m_NetCode; - new_passe_request = 1; - } - } - } + /* Localisation du point de fin */ + PtStruct = pt_piste->end; + if( PtStruct &&(PtStruct->m_StructType != TYPEPAD) ) + { // End sur piste + pt_next = (TRACK*) PtStruct; + if( pt_piste->m_NetCode ) + { + if( pt_next->m_NetCode == 0 ) + { + new_passe_request = 1; + pt_next->m_NetCode = pt_piste->m_NetCode; + } + } + else + { + if( pt_next->m_NetCode != 0 ) + { + pt_piste->m_NetCode = pt_next->m_NetCode; + new_passe_request = 1; + } + } + } + } + } - /* Localisation du point de fin */ - PtStruct = pt_piste->end; - if( PtStruct &&(PtStruct->m_StructType != TYPEPAD) ) - { // End sur piste - pt_next = (TRACK*)PtStruct; - if(pt_piste->m_NetCode) - { - if(pt_next->m_NetCode == 0) - { - new_passe_request = 1; - pt_next->m_NetCode = pt_piste->m_NetCode; - } - } - else - { - if(pt_next->m_NetCode != 0) - { - pt_piste->m_NetCode = pt_next->m_NetCode; - new_passe_request = 1; - } - } - } - } - } + /* Reclassemment des pistes par numero de net: */ + if( affiche ) + Affiche_1_Parametre( this, -1, wxEmptyString, wxT( "Reorder " ), a_color ); + RebuildTrackChain( m_Pcb ); - /* Reclassemment des pistes par numero de net: */ - if( affiche ) Affiche_1_Parametre(this, -1,wxEmptyString, wxT("Reorder "),a_color); - RebuildTrackChain(m_Pcb); - - if( affiche ) Affiche_1_Parametre(this, -1,wxEmptyString, wxT(" "),a_color); + if( affiche ) + Affiche_1_Parametre( this, -1, wxEmptyString, wxT( " " ), a_color ); } + /* - routine de tri de connexion utilisee par la fonction QSORT - le tri est fait par numero de net -*/ -int tri_par_netcode(TRACK ** pt_ref, TRACK ** pt_compare) + * routine de tri de connexion utilisee par la fonction QSORT + * le tri est fait par numero de net + */ +int tri_par_netcode( TRACK** pt_ref, TRACK** pt_compare ) { -int ii ; - ii = (*pt_ref)->m_NetCode -(* pt_compare)->m_NetCode ; - return(ii) ; + int ii; + + ii = (*pt_ref)->m_NetCode - (*pt_compare)->m_NetCode; + return ii; } +/*****************************************/ +static void RebuildTrackChain( BOARD* pcb ) +/*****************************************/ -/*****************************************/ -static void RebuildTrackChain(BOARD * pcb) -/*****************************************/ /* Recalcule le chainage des pistes pour que le chainage soit fait par - netcodes croissants -*/ + * netcodes croissants + */ { -TRACK * Track, ** Liste; -int ii, nbsegm; + TRACK* Track, ** Liste; + int ii, nbsegm; - /* Count segments */ - nbsegm = pcb->GetNumSegmTrack(); - if( pcb->m_Track == NULL ) return; + /* Count segments */ + nbsegm = pcb->GetNumSegmTrack(); + if( pcb->m_Track == NULL ) + return; - Liste = (TRACK ** ) MyZMalloc( (nbsegm+1) * sizeof(TRACK*) ); + Liste = (TRACK**) MyZMalloc( (nbsegm + 1) * sizeof(TRACK *) ); - ii = 0; Track = pcb->m_Track; - for( ; Track != NULL; ii++, Track = (TRACK*) Track->Pnext) - { - Liste[ii] = Track; - } + ii = 0; Track = pcb->m_Track; + for( ; Track != NULL; ii++, Track = (TRACK*) Track->Pnext ) + { + Liste[ii] = Track; + } - qsort(Liste, nbsegm, sizeof(TRACK*), - (int(*)(const void *, const void *)) tri_par_netcode); + qsort( Liste, nbsegm, sizeof(TRACK *), + ( int( * ) ( const void*, const void* ) )tri_par_netcode ); - /* Update the linked list pointers */ + /* Update the linked list pointers */ - Track = Liste[0]; - Track->Pback = pcb; Track->Pnext = 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 = Liste[0]; + Track->Pback = pcb; Track->Pnext = 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]; + } - MyFree(Liste); + MyFree( Liste ); } - diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index a2a26fd949..81d8b69dca 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -147,7 +147,7 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); } - m_SelLayerBox->SetSelection( Cotation->m_Layer - (CMP_N + 1) ); + m_SelLayerBox->SetSelection( Cotation->GetLayer() - (CMP_N + 1) ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); @@ -180,8 +180,9 @@ void WinEDA_CotationPropertiesFrame::CotationPropertiesAccept( wxCommandEvent& e CurrentCotation->m_Text->m_Width = CurrentCotation->m_Width = m_TxtWidthCtrl->GetValue(); CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; - CurrentCotation->m_Layer = CurrentCotation->m_Text->m_Layer = - m_SelLayerBox->GetChoice() + CMP_N + 1; + + CurrentCotation->SetLayer( m_SelLayerBox->GetChoice() + CMP_N + 1 ); + CurrentCotation->m_Text->SetLayer( m_SelLayerBox->GetChoice() + CMP_N + 1 ); CurrentCotation->m_Text->CreateDrawData(); @@ -236,7 +237,7 @@ COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, wxDC* DC ) Cotation = new COTATION( m_Pcb ); Cotation->m_Flags = IS_NEW; - Cotation->m_Layer = GetScreen()->m_Active_Layer; + Cotation->SetLayer( GetScreen()->m_Active_Layer ); Cotation->m_Width = g_DesignSettings.m_DrawSegmentWidth; Cotation->m_Text->m_Width = Cotation->m_Width; @@ -317,7 +318,7 @@ static void Montre_Position_New_Cotation( WinEDA_DrawPanel* panel, wxDC* DC, boo Cotation->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); } - Cotation->m_Layer = screen->m_Active_Layer; + Cotation->SetLayer( screen->m_Active_Layer ); if( status_cotation == 1 ) { Cotation->TraitD_ox = pos.x; @@ -399,7 +400,7 @@ static void Ajuste_Details_Cotation( COTATION* Cotation ) wxString msg; /* Init des couches : */ - Cotation->m_Text->m_Layer = Cotation->m_Layer; + Cotation->m_Text->SetLayer( Cotation->GetLayer() ); /* calcul de la hauteur du texte + trait de cotation */ ii = Cotation->m_Text->m_Size.y + diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index e085c7736a..db15c27785 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -68,7 +68,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) delete Track; g_TrackSegmentCount--; if( g_CurrentTrackSegment && (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) - previous_layer = g_CurrentTrackSegment->m_Layer; + previous_layer = g_CurrentTrackSegment->GetLayer(); } if( g_CurrentTrackSegment ) diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index f284a3ffd3..b9dff9e033 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -236,7 +236,7 @@ void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties( bool FullOptions wxString layer_list[2] = { _( "Component" ), _( "Copper" ) }; m_LayerCtrl = new wxRadioBox( m_PanelProperties, -1, _( "Layer" ), wxDefaultPosition, wxSize( -1, -1 ), 2, layer_list, 1 ); - m_LayerCtrl->SetSelection( (m_CurrentModule->m_Layer == CUIVRE_N) ? 1 : 0 ); + m_LayerCtrl->SetSelection( (m_CurrentModule->GetLayer() == CUIVRE_N) ? 1 : 0 ); PropLeftSizer->Add( m_LayerCtrl, 0, wxGROW | wxALL, 5 ); bool select = FALSE; @@ -518,10 +518,10 @@ void WinEDA_ModulePropertiesFrame::ModulePropertiesAccept( wxCommandEvent& event { if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT { - if( m_CurrentModule->m_Layer == CUIVRE_N ) + if( m_CurrentModule->GetLayer() == CUIVRE_N ) change_layer = TRUE; } - else if( m_CurrentModule->m_Layer == CMP_N ) + else if( m_CurrentModule->GetLayer() == CMP_N ) change_layer = TRUE; } diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index a0add3f0d7..55bc07b75f 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -200,11 +200,11 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC ) { if( Edge->m_StructType != TYPEEDGEMODULE ) continue; - Edge->m_Layer = new_layer; + Edge->SetLayer( new_layer ); } } else - Edge->m_Layer = new_layer; + Edge->SetLayer( new_layer ); GetScreen()->SetModify(); Module->Set_Rectangle_Encadrement(); @@ -336,11 +336,11 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, if( Edge->m_Shape == S_ARC ) Edge->m_Angle = ArcValue; Edge->m_Width = ModuleSegmentWidth; - Edge->m_Layer = Module->m_Layer; - if( Module->m_Layer == CMP_N ) - Edge->m_Layer = SILKSCREEN_N_CMP; - if( Module->m_Layer == CUIVRE_N ) - Edge->m_Layer = SILKSCREEN_N_CU; + Edge->SetLayer( Module->GetLayer() ); + if( Module->GetLayer() == CMP_N ) + Edge->SetLayer( SILKSCREEN_N_CMP ); + if( Module->GetLayer() == CUIVRE_N ) + Edge->SetLayer( SILKSCREEN_N_CU ); /* Mise a jour du point de depart du segment ou de l'arc */ Edge->m_Start = GetScreen()->m_Curseur; /* Mise a jour de la fin du segment , rectangle ou de l'arc*/ diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 69e261b00c..7c836819fe 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -138,7 +138,7 @@ void WinEDA_PcbFrame::Drawing_SetNewWidth( DRAWSEGMENT* DrawSegm, wxDC* DC ) Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_XOR ); - if( DrawSegm->m_Layer == EDGE_N ) + if( DrawSegm->GetLayer() == EDGE_N ) DrawSegm->m_Width = g_DesignSettings.m_EdgeSegmentWidth; else DrawSegm->m_Width = g_DesignSettings.m_DrawSegmentWidth; @@ -159,7 +159,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC TEXTE_PCB* pt_txt; EDA_BaseStruct* PtStruct, * PtNext; COTATION* Cotation; - int layer = Segment->m_Layer; + int layer = Segment->GetLayer(); if( layer <= CMP_N ) { @@ -187,7 +187,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC { case TYPEDRAWSEGMENT: pt_segm = (DRAWSEGMENT*) PtStruct; - if( pt_segm->m_Layer == layer ) + if( pt_segm->GetLayer() == layer ) { Trace_DrawSegmentPcb( DrawPanel, DC, pt_segm, GR_XOR ); DeleteStructure( PtStruct ); @@ -196,7 +196,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC case TYPETEXTE: pt_txt = (TEXTE_PCB*) PtStruct; - if( pt_txt->m_Layer == layer ) + if( pt_txt->GetLayer() == layer ) { pt_txt->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); DeleteStructure( PtStruct ); @@ -206,7 +206,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC case TYPECOTATION: Cotation = (COTATION*) PtStruct; - if( Cotation->m_Layer == layer ) + if( Cotation->GetLayer() == layer ) { Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); DeleteStructure( PtStruct ); @@ -276,7 +276,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, { GetScreen()->SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) ); Segment->m_Flags = IS_NEW; - Segment->m_Layer = GetScreen()->m_Active_Layer; + Segment->SetLayer( GetScreen()->m_Active_Layer ); Segment->m_Width = s_large; Segment->m_Shape = shape; Segment->m_Angle = 900; @@ -307,7 +307,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, GetScreen()->SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) ); Segment->m_Flags = IS_NEW; - Segment->m_Layer = DrawItem->m_Layer; + Segment->SetLayer( DrawItem->GetLayer() ); Segment->m_Width = s_large; Segment->m_Shape = DrawItem->m_Shape; Segment->m_Type = DrawItem->m_Type; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 8299b63ab5..3d190623ca 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -108,7 +108,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Pnext ) { pt_segm->SetState( BUSY, OFF ); - pt_segm->m_Param = pt_segm->m_Layer; /* pour sauvegarde */ + pt_segm->m_Param = pt_segm->GetLayer(); /* pour sauvegarde */ } ii = 0; pt_segm = pt_track; @@ -118,17 +118,17 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) continue; /* inversion des couches */ - if( pt_segm->m_Layer == l1 ) - pt_segm->m_Layer = l2; - else if( pt_segm->m_Layer == l2 ) - pt_segm->m_Layer = l1; + if( pt_segm->GetLayer() == l1 ) + pt_segm->SetLayer( l2 ); + else if( pt_segm->GetLayer() == l2 ) + pt_segm->SetLayer( l1 ); if( (Drc_On) && ( Drc( this, DC, pt_segm, m_Pcb->m_Track, 1 ) == BAD_DRC ) ) { /* Annulation du changement */ ii = 0; pt_segm = pt_track; for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) { - pt_segm->m_Layer = pt_segm->m_Param; + pt_segm->SetLayer( pt_segm->m_Param ); } Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR ); @@ -178,7 +178,7 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) } /* Les vias ne doivent pas etre inutilement empilees: */ - if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->m_Layer ) ) + if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) return; pt_segm = g_FirstTrackSegment; for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) @@ -206,7 +206,7 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) Via->m_NetCode = g_HightLigth_NetCode; Via->m_Start = Via->m_End = g_CurrentTrackSegment->m_End; - Via->m_Layer = GetScreen()->m_Active_Layer; + Via->SetLayer( GetScreen()->m_Active_Layer ); // Provisoirement. indicate the first layer (?) @@ -218,19 +218,19 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) if( (Via->m_Shape & 15) == VIA_ENTERREE ) { - Via->m_Layer |= GetScreen()->m_Active_Layer << 4; + Via->SetLayer( Via->GetLayer() | GetScreen()->m_Active_Layer << 4 ); } else if( (Via->m_Shape & 15) == VIA_BORGNE ) //blind via { // A revoir! ( la via devrait deboucher sur 1 cote ) - Via->m_Layer |= GetScreen()->m_Active_Layer << 4; + Via->SetLayer( Via->GetLayer() | GetScreen()->m_Active_Layer << 4 ); } else - Via->m_Layer = 0x0F; + Via->SetLayer( 0x0F ); if( Drc_On &&( Drc( this, DC, Via, m_Pcb->m_Track, 1 ) == BAD_DRC ) ) { /* Via impossible a placer ici */ delete Via; - GetScreen()->m_Active_Layer = g_CurrentTrackSegment->m_Layer; + GetScreen()->m_Active_Layer = g_CurrentTrackSegment->GetLayer(); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); return; } @@ -240,7 +240,7 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) g_CurrentTrackSegment->Pnext = Via; g_TrackSegmentCount++; g_CurrentTrackSegment = new TRACK( *g_CurrentTrackSegment ); - g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End = Via->m_Start; g_TrackSegmentCount++; g_CurrentTrackSegment->Pback = Via; diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index cd402ece36..291da721ea 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -130,7 +130,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) Hight_Light( DC ); g_CurrentTrackSegment->m_Flags = IS_NEW; - g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; g_CurrentTrackSegment->m_Start = pos; g_CurrentTrackSegment->m_End = g_CurrentTrackSegment->m_Start; @@ -211,7 +211,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) g_CurrentTrackSegment->m_Flags = IS_NEW; g_TrackSegmentCount++; g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End; - g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; /* Show the new position */ ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); @@ -269,9 +269,9 @@ int Add_45_degrees_Segment( WinEDA_BasePcbFrame* frame, wxDC* DC, TRACK* pt_segm dy1 = pt_segm->m_End.y - pt_segm->m_Start.y; // les segments doivent etre de longueur suffisante: - if( max( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) ) + if( MAX( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) ) return 0; - if( max( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) ) + if( MAX( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) ) return 0; /* creation du nouveau segment, raccordant des 2 segm: */ @@ -502,14 +502,14 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase } /* dessin de la nouvelle piste : mise a jour du point d'arrivee */ - g_CurrentTrackSegment->m_Layer = screen->m_Active_Layer; + g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer ); g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; if( g_TwoSegmentTrackBuild ) { TRACK* previous_track = (TRACK*) g_CurrentTrackSegment->Pback; if( previous_track && (previous_track->m_StructType == TYPETRACK) ) { - previous_track->m_Layer = screen->m_Active_Layer; + previous_track->SetLayer( screen->m_Active_Layer ); previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; } } @@ -584,7 +584,7 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) break; case 45: - deltax = min( deltax, deltay ); deltay = deltax; + deltax = MIN( deltax, deltay ); deltay = deltax; /* recalcul des signes de deltax et deltay */ if( (ActiveScreen->m_Curseur.x - ox) < 0 ) deltax = -deltax; @@ -666,7 +666,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount ) break; case 45: - iDx = min( iDx, iDy ); + iDx = MIN( iDx, iDy ); iDy = iDx; /* recalcul des signes de deltax et deltay */ if( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) @@ -707,7 +707,7 @@ TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ) TRACK* firsttrack = track; TRACK* oldtrack; int nn = 0; - EDA_BaseStruct* LockPoint; + BOARD_ITEM* LockPoint; if( track == 0 ) return NULL; diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index a1bee28005..0bfc03f9bc 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -12,809 +12,876 @@ #include "protos.h" #include "id.h" -bool CreateHeaderInfoData(FILE * file, WinEDA_PcbFrame * frame); -static int * CreateTracksInfoData(FILE * file, BOARD * pcb); -static void CreateBoardSection(FILE * file, BOARD * pcb); -static void CreateComponentsSection(FILE * file, BOARD * pcb); -static void CreateDevicesSection(FILE * file, BOARD * pcb); -static void CreateRoutesSection(FILE * file, BOARD * pcb); -static void CreateSignalsSection(FILE * file, BOARD * pcb); -static void CreateShapesSection(FILE * file, BOARD * pcb); -static void CreatePadsShapesSection(FILE * file, BOARD * pcb); -static void ModuleWriteShape( FILE * File, MODULE * module ); +bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ); +static int* CreateTracksInfoData( FILE* file, BOARD* pcb ); +static void CreateBoardSection( FILE* file, BOARD* pcb ); +static void CreateComponentsSection( FILE* file, BOARD* pcb ); +static void CreateDevicesSection( FILE* file, BOARD* pcb ); +static void CreateRoutesSection( FILE* file, BOARD* pcb ); +static void CreateSignalsSection( FILE* file, BOARD* pcb ); +static void CreateShapesSection( FILE* file, BOARD* pcb ); +static void CreatePadsShapesSection( FILE* file, BOARD* pcb ); +static void ModuleWriteShape( FILE* File, MODULE* module ); -wxString GenCAD_Layer_Name[32] // layer name pour extensions fichiers de trace - = { - wxT("BOTTOM"), wxT("INNER1"), wxT("INNER2"), wxT("INNER3"), - wxT("INNER4"), wxT("INNER5"), wxT("INNER6"), wxT("INNER7"), - wxT("INNER8"), wxT("INNER9"), wxT("INNER10"), wxT("INNER11"), - wxT("INNER12"), wxT("INNER13"), wxT("INNER14"), wxT("TOP"), - wxT("adhecu"), wxT("adhecmp"), wxT("SOLDERPASTE_BOTTOM"), wxT("SOLDERPASTE_TOP"), - wxT("SILKSCREEN_BOTTOM"), wxT("SILKSCREEN_TOP"), wxT("SOLDERMASK_BOTTOM"), wxT("SOLDERMASK_TOP"), - wxT("drawings"), wxT("comments"), wxT("eco1"), wxT("eco2"), - wxT("edges"), wxT("--"), wxT("--"), wxT("--") - }; +// layer name pour extensions fichiers de tracewxString +static const wxString GenCAD_Layer_Name[32] = { + wxT( "BOTTOM" ), wxT( "INNER1" ), wxT( "INNER2" ), wxT("INNER3" ), + wxT( "INNER4" ), wxT( "INNER5" ), wxT( "INNER6" ), wxT("INNER7" ), + wxT( "INNER8" ), wxT( "INNER9" ), wxT( "INNER10" ), wxT("INNER11" ), + wxT( "INNER12" ), wxT( "INNER13" ), wxT( "INNER14" ), wxT( "TOP" ), + wxT( "adhecu" ), wxT( "adhecmp" ), wxT( "SOLDERPASTE_BOTTOM" ), wxT("SOLDERPASTE_TOP" ), + wxT( "SILKSCREEN_BOTTOM" ), wxT( "SILKSCREEN_TOP" ), wxT( "SOLDERMASK_BOTTOM" ), wxT("SOLDERMASK_TOP" ), + wxT( "drawings" ), wxT( "comments" ), wxT( "eco1" ), wxT( "eco2" ), + wxT( "edges" ), wxT( "--" ), wxT( "--" ), wxT( "--" ) +}; -int offsetX, offsetY; -D_PAD * PadList; +int offsetX, offsetY; +D_PAD* PadList; /* routines de conversion des coord ( sous GenCAD axe Y vers le haut) */ -static int mapXto(int x) +static int mapXto( int x ) { - return x - offsetX; + return x - offsetX; } -static int mapYto(int y) + + +static int mapYto( int y ) { - return offsetY - y; + return offsetY - y; } /***********************************************************/ -void WinEDA_PcbFrame::ExportToGenCAD(wxCommandEvent& event) +void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) /***********************************************************/ + /* -Exporte le board au format GenCAD 1.4 -*/ + * Exporte le board au format GenCAD 1.4 + */ { -wxString FullFileName = GetScreen()->m_FileName; -wxString msg, std_ext, mask; -FILE * file; - - std_ext = wxT(".gcd"); - mask = wxT("*") + std_ext; - ChangeFileNameExt(FullFileName,std_ext); - FullFileName = EDA_FileSelector(_("GenCAD file:"), - wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - std_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if ( FullFileName == wxEmptyString ) return; - - if ( (file = wxFopen(FullFileName, wxT("wt") )) == NULL ) - { - msg = _("Unable to create ") + FullFileName; - DisplayError(this, msg); return; - } + wxString FullFileName = GetScreen()->m_FileName; + wxString msg, std_ext, mask; + FILE* file; - /* Mise a jour des infos PCB: */ - m_Pcb->ComputeBoundaryBox(); + std_ext = wxT( ".gcd" ); + mask = wxT( "*" ) + std_ext; + ChangeFileNameExt( FullFileName, std_ext ); + FullFileName = EDA_FileSelector( _( "GenCAD file:" ), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + std_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if( FullFileName == wxEmptyString ) + return; - offsetX = m_Auxiliary_Axis_Position.x; - offsetY = m_Auxiliary_Axis_Position.y; -wxClientDC dc(DrawPanel); - DrawPanel->PrepareGraphicContext(&dc); - Compile_Ratsnest( &dc, TRUE ); - - /* Mise des modules vus en miroir en position "normale" - (necessaire pour decrire les formes sous GenCAD, - qui sont decrites en vue normale, orientation 0)) */ -MODULE * module; - for(module = m_Pcb->m_Modules; module != NULL; module = module->Next()) - { - module->flag = 0; - if ( module->m_Layer == CUIVRE_N ) - { - Change_Side_Module(module, NULL); - module->flag = 1; - } - } - // Creation de l'entete: - CreateHeaderInfoData(file, this); - CreateBoardSection(file, m_Pcb); + if( ( file = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) + { + msg = _( "Unable to create " ) + FullFileName; + DisplayError( this, msg ); return; + } - /* Creation liste des TRACKS - (section $TRACK) id liste des outils de tracage de pistes */ - CreateTracksInfoData(file, m_Pcb); + /* Mise a jour des infos PCB: */ + m_Pcb->ComputeBoundaryBox(); - /* Creation de la liste des formes utilisees - (formes des composants principalement */ - CreatePadsShapesSection(file, m_Pcb); // doit etre appele avant CreateShapesSection() - CreateShapesSection( file, m_Pcb); - - /* Creation de la liste des equipotentielles: */ - CreateSignalsSection(file, m_Pcb); - - CreateDevicesSection(file, m_Pcb); - CreateComponentsSection(file, m_Pcb); - CreateRoutesSection(file, m_Pcb); + offsetX = m_Auxiliary_Axis_Position.x; + offsetY = m_Auxiliary_Axis_Position.y; + wxClientDC dc( DrawPanel ); - fclose(file); + DrawPanel->PrepareGraphicContext( &dc ); + Compile_Ratsnest( &dc, TRUE ); - /* Remise en place des modules vus en miroir */ - for(module = m_Pcb->m_Modules; module != NULL; module = module->Next()) - { - if ( module->flag ) - { - Change_Side_Module(module, NULL); - module->flag = 0; - } - } + /* Mise des modules vus en miroir en position "normale" + * (necessaire pour decrire les formes sous GenCAD, + * qui sont decrites en vue normale, orientation 0)) */ + MODULE* module; + for( module = m_Pcb->m_Modules; module != NULL; module = module->Next() ) + { + module->flag = 0; + if( module->GetLayer() == CUIVRE_N ) + { + Change_Side_Module( module, NULL ); + module->flag = 1; + } + } + + // Creation de l'entete: + CreateHeaderInfoData( file, this ); + CreateBoardSection( file, m_Pcb ); + + /* Creation liste des TRACKS + * (section $TRACK) id liste des outils de tracage de pistes */ + CreateTracksInfoData( file, m_Pcb ); + + /* Creation de la liste des formes utilisees + * (formes des composants principalement */ + CreatePadsShapesSection( file, m_Pcb ); // doit etre appele avant CreateShapesSection() + CreateShapesSection( file, m_Pcb ); + + /* Creation de la liste des equipotentielles: */ + CreateSignalsSection( file, m_Pcb ); + + CreateDevicesSection( file, m_Pcb ); + CreateComponentsSection( file, m_Pcb ); + CreateRoutesSection( file, m_Pcb ); + + fclose( file ); + + /* Remise en place des modules vus en miroir */ + for( module = m_Pcb->m_Modules; module != NULL; module = module->Next() ) + { + if( module->flag ) + { + Change_Side_Module( module, NULL ); + module->flag = 0; + } + } } /**************************************************************************/ -static int Pad_list_Sort_by_Shapes(const void * refptr, const void * objptr) +static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr ) /**************************************************************************/ -/* -Routine de tri de la liste des pads par type, puis pa taille -*/ -{ -const D_PAD * padref, *padcmp; -int diff; - - padref = *((D_PAD**) refptr); - padcmp = *((D_PAD**) objptr); - if( (diff = padref->m_PadShape - padcmp->m_PadShape) ) return diff; - if( (diff = padref->m_Size.x - padcmp->m_Size.x) ) return diff; - if( (diff = padref->m_Size.y - padcmp->m_Size.y) ) return diff; - if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) ) return diff; - if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) ) return diff; - if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) ) return diff; - if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) return diff; - return 0; +/* + * Routine de tri de la liste des pads par type, puis pa taille + */ +{ + const D_PAD* padref, * padcmp; + int diff; + + padref = *( (D_PAD**) refptr ); + padcmp = *( (D_PAD**) objptr ); + if( (diff = padref->m_PadShape - padcmp->m_PadShape) ) + return diff; + if( (diff = padref->m_Size.x - padcmp->m_Size.x) ) + return diff; + if( (diff = padref->m_Size.y - padcmp->m_Size.y) ) + return diff; + if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) ) + return diff; + if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) ) + return diff; + if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) ) + return diff; + if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) + return diff; + + return 0; } + /*****************************************************/ -void CreatePadsShapesSection(FILE * file, BOARD * pcb) +void CreatePadsShapesSection( FILE* file, BOARD* pcb ) /*****************************************************/ + /* Cree la liste des formes des pads ( 1 forme par pad ) -initialise le membre .m_logical_connexion de la struct pad, la valeur 1 ..n -pour les formes de pad PAD1 a PADn -*/ + * initialise le membre .m_logical_connexion de la struct pad, la valeur 1 ..n + * pour les formes de pad PAD1 a PADn + */ { -D_PAD * pad, **padlist, **pad_list_base; -char * pad_type; -int memsize, ii, dx, dy; -D_PAD * old_pad = NULL; -int pad_name_number; - - fputs("$PADS\n", file); + D_PAD* pad, ** padlist, ** pad_list_base; + char* pad_type; + int memsize, ii, dx, dy; + D_PAD* old_pad = NULL; + int pad_name_number; - // Generation de la liste des pads tries par forme et dimensions: - memsize = (pcb->m_NbPads + 1) * sizeof(D_PAD*); - pad_list_base = (D_PAD**) MyZMalloc(memsize); - memcpy(pad_list_base, pcb->m_Pads, memsize); - qsort(pad_list_base, pcb->m_NbPads, sizeof(D_PAD*), Pad_list_Sort_by_Shapes); - - pad_name_number = 0; - for( padlist = pad_list_base, ii = 0; ii < pcb->m_NbPads; padlist++, ii++) - { - pad = *padlist; - pad->m_logical_connexion = pad_name_number; + fputs( "$PADS\n", file ); - if ( old_pad && - (old_pad->m_PadShape == pad->m_PadShape) && - (old_pad->m_Size.x == pad->m_Size.x) && - (old_pad->m_Size.y == pad->m_Size.y) && - (old_pad->m_Offset.x == pad->m_Offset.x) && - (old_pad->m_Offset.y == pad->m_Offset.y) && - (old_pad->m_DeltaSize.x == pad->m_DeltaSize.x) && - (old_pad->m_DeltaSize.y == pad->m_DeltaSize.y) - ) - continue; // Forme deja generee + // Generation de la liste des pads tries par forme et dimensions: + memsize = (pcb->m_NbPads + 1) * sizeof(D_PAD *); + pad_list_base = (D_PAD**) MyZMalloc( memsize ); + memcpy( pad_list_base, pcb->m_Pads, memsize ); + qsort( pad_list_base, pcb->m_NbPads, sizeof(D_PAD *), Pad_list_Sort_by_Shapes ); - old_pad = pad; + pad_name_number = 0; + for( padlist = pad_list_base, ii = 0; ii < pcb->m_NbPads; padlist++, ii++ ) + { + pad = *padlist; + pad->m_logical_connexion = pad_name_number; - pad_name_number ++; - pad->m_logical_connexion = pad_name_number; + if( old_pad + && (old_pad->m_PadShape == pad->m_PadShape) + && (old_pad->m_Size.x == pad->m_Size.x) + && (old_pad->m_Size.y == pad->m_Size.y) + && (old_pad->m_Offset.x == pad->m_Offset.x) + && (old_pad->m_Offset.y == pad->m_Offset.y) + && (old_pad->m_DeltaSize.x == pad->m_DeltaSize.x) + && (old_pad->m_DeltaSize.y == pad->m_DeltaSize.y) + ) + continue; // Forme deja generee - fprintf(file, "PAD PAD%d", pad->m_logical_connexion); + old_pad = pad; - dx = pad->m_Size.x / 2; dy = pad->m_Size.y / 2; + pad_name_number++; + pad->m_logical_connexion = pad_name_number; - switch( pad->m_PadShape ) - { - default: - case CIRCLE: - pad_type = "ROUND"; - fprintf(file, " %s %d\n", pad_type, pad->m_Drill.x); - fprintf(file, "CIRCLE %d %d %d\n", - pad->m_Offset.x, - pad->m_Offset.y, pad->m_Size.x/2); - break; - - case RECT: - pad_type = "RECTANGULAR"; - fprintf(file, " %s %d\n", pad_type, pad->m_Drill.x); - fprintf(file, "RECTANGLE %d %d %d %d\n", - -dx + pad->m_Offset.x, - dy - pad->m_Offset.y, - dx + pad->m_Offset.x, - pad->m_Offset.y + dy ); - break; - - case OVALE: /* description du contour par 2 linges et 2 arcs */ - { - pad_type = "FINGER"; - fprintf(file, " %s %d\n", pad_type, pad->m_Drill.x); - int dr = dx - dy; - if ( dr >= 0 ) // ovale horizontal - { - int rayon = dy; - fprintf(file, "LINE %d %d %d %d\n", - -dr + pad->m_Offset.x, - pad->m_Offset.y - rayon, - dr + pad->m_Offset.x, - pad->m_Offset.y - rayon ); - fprintf(file, "ARC %d %d %d %d %d %d\n", - dr + pad->m_Offset.x, - pad->m_Offset.y - rayon, - dr + pad->m_Offset.x, - pad->m_Offset.y + rayon, - dr + pad->m_Offset.x, - pad->m_Offset.y); + fprintf( file, "PAD PAD%d", pad->m_logical_connexion ); - fprintf(file, "LINE %d %d %d %d\n", - dr + pad->m_Offset.x, - pad->m_Offset.y + rayon, - -dr + pad->m_Offset.x, - pad->m_Offset.y + rayon ); - fprintf(file, "ARC %d %d %d %d %d %d\n", - -dr + pad->m_Offset.x, - pad->m_Offset.y + rayon, - -dr + pad->m_Offset.x, - pad->m_Offset.y - rayon, - -dr + pad->m_Offset.x, - pad->m_Offset.y); - } - else // ovale vertical - { - dr = -dr; - int rayon = dx; - fprintf(file, "LINE %d %d %d %d\n", - -rayon + pad->m_Offset.x, - pad->m_Offset.y - dr, - -rayon + pad->m_Offset.x, - pad->m_Offset.y + dr ); - fprintf(file, "ARC %d %d %d %d %d %d\n", - -rayon + pad->m_Offset.x, - pad->m_Offset.y + dr, - rayon + pad->m_Offset.x, - pad->m_Offset.y + dr, - pad->m_Offset.x, - pad->m_Offset.y + dr); + dx = pad->m_Size.x / 2; dy = pad->m_Size.y / 2; - fprintf(file, "LINE %d %d %d %d\n", - rayon + pad->m_Offset.x, - pad->m_Offset.y + dr, - rayon + pad->m_Offset.x, - pad->m_Offset.y - dr ); - fprintf(file, "ARC %d %d %d %d %d %d\n", - rayon + pad->m_Offset.x, - pad->m_Offset.y - dr, - - rayon + pad->m_Offset.x, - pad->m_Offset.y - dr, - pad->m_Offset.x, - pad->m_Offset.y - dr); - } - break; - } - - case TRAPEZE: - pad_type = "POLYGON"; - break; - } - } - - fputs("$ENDPADS\n\n", file); - MyFree(pad_list_base); + switch( pad->m_PadShape ) + { + default: + case CIRCLE: + pad_type = "ROUND"; + fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); + fprintf( file, "CIRCLE %d %d %d\n", + pad->m_Offset.x, -pad->m_Offset.y, pad->m_Size.x / 2 ); + break; + + case RECT: + pad_type = "RECTANGULAR"; + fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); + fprintf( file, "RECTANGLE %d %d %d %d\n", + -dx + pad->m_Offset.x, -dy - pad->m_Offset.y, + dx + pad->m_Offset.x, -pad->m_Offset.y + dy ); + break; + + case OVALE: /* description du contour par 2 linges et 2 arcs */ + { + pad_type = "FINGER"; + fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); + int dr = dx - dy; + if( dr >= 0 ) // ovale horizontal + { + int rayon = dy; + fprintf( file, "LINE %d %d %d %d\n", + -dr + pad->m_Offset.x, -pad->m_Offset.y - rayon, + dr + pad->m_Offset.x, -pad->m_Offset.y - rayon ); + fprintf( file, "ARC %d %d %d %d %d %d\n", + dr + pad->m_Offset.x, -pad->m_Offset.y - rayon, + dr + pad->m_Offset.x, -pad->m_Offset.y + rayon, + dr + pad->m_Offset.x, -pad->m_Offset.y ); + + fprintf( file, "LINE %d %d %d %d\n", + dr + pad->m_Offset.x, -pad->m_Offset.y + rayon, + -dr + pad->m_Offset.x, -pad->m_Offset.y + rayon ); + fprintf( file, "ARC %d %d %d %d %d %d\n", + -dr + pad->m_Offset.x, -pad->m_Offset.y + rayon, + -dr + pad->m_Offset.x, -pad->m_Offset.y - rayon, + -dr + pad->m_Offset.x, -pad->m_Offset.y ); + } + else // ovale vertical + { + dr = -dr; + int rayon = dx; + fprintf( file, "LINE %d %d %d %d\n", + -rayon + pad->m_Offset.x, -pad->m_Offset.y - dr, + -rayon + pad->m_Offset.x, -pad->m_Offset.y + dr ); + fprintf( file, "ARC %d %d %d %d %d %d\n", + -rayon + pad->m_Offset.x, -pad->m_Offset.y + dr, + rayon + pad->m_Offset.x, -pad->m_Offset.y + dr, + pad->m_Offset.x, -pad->m_Offset.y + dr ); + + fprintf( file, "LINE %d %d %d %d\n", + rayon + pad->m_Offset.x, -pad->m_Offset.y + dr, + rayon + pad->m_Offset.x, -pad->m_Offset.y - dr ); + fprintf( file, "ARC %d %d %d %d %d %d\n", + rayon + pad->m_Offset.x, -pad->m_Offset.y - dr, + -rayon + pad->m_Offset.x, -pad->m_Offset.y - dr, + pad->m_Offset.x, -pad->m_Offset.y - dr ); + } + break; + } + + case TRAPEZE: + pad_type = "POLYGON"; + break; + } + } + + fputs( "$ENDPADS\n\n", file ); + MyFree( pad_list_base ); } /**************************************************/ -void CreateShapesSection(FILE * file, BOARD * pcb) +void CreateShapesSection( FILE* file, BOARD* pcb ) /**************************************************/ + /* Creation de la liste des formes des composants. -Comme la forme de base (module de librairie peut etre modifiee, -une forme est creee par composant -La forme est donnee normalisee, c'est a dire orientation 0, position 0 non miroir -Il y aura donc des formes indentiques redondantes - - Syntaxe: -$SHAPES -SHAPE -shape_descr (line, arc ..) -PIN - -SHAPE -.. -$ENDSHAPES -*/ + * Comme la forme de base (module de librairie peut etre modifiee, + * une forme est creee par composant + * La forme est donnee normalisee, c'est a dire orientation 0, position 0 non miroir + * Il y aura donc des formes indentiques redondantes + * + * Syntaxe: + * $SHAPES + * SHAPE + * shape_descr (line, arc ..) + * PIN + * + * SHAPE + * .. + * $ENDSHAPES + */ { -MODULE * module; -D_PAD * pad; -char * layer; -int orient; -wxString pinname; -char * mirror = "0"; - - fputs("$SHAPES\n", file); + MODULE* module; + D_PAD* pad; + char* layer; + int orient; + wxString pinname; + char* mirror = "0"; - for(module = pcb->m_Modules; module != NULL; module = (MODULE *) module->Pnext) - { - ModuleWriteShape( file, module ); - for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext) - { - layer = "ALL"; - if ( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) - { - if ( module->m_Layer == CMP_N ) layer = "BOTTOM"; - else layer = "TOP"; - } - else if ( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) - { - if ( module->m_Layer == CMP_N ) layer = "TOP"; - else layer = "BOTTOM"; - } - - pad->ReturnStringPadName(pinname); - if( pinname.IsEmpty() ) pinname = wxT("noname"); - - orient = pad->m_Orient - module->m_Orient; - NORMALIZE_ANGLE_POS(orient); - fprintf(file, "PIN %s PAD%d %d %d %s %d %s", - CONV_TO_UTF8(pinname), pad->m_logical_connexion, - pad->m_Pos0.x, - pad->m_Pos0.y, - layer, orient/10, mirror ); - if ( orient % 10 ) fprintf(file, " .%d", orient % 10 ); - fprintf(file, "\n"); - } - } - - fputs("$ENDSHAPES\n\n", file); + fputs( "$SHAPES\n", file ); + + for( module = pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext ) + { + ModuleWriteShape( file, module ); + for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + layer = "ALL"; + if( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) + { + if( module->GetLayer() == CMP_N ) + layer = "BOTTOM"; + else + layer = "TOP"; + } + else if( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) + { + if( module->GetLayer() == CMP_N ) + layer = "TOP"; + else + layer = "BOTTOM"; + } + + pad->ReturnStringPadName( pinname ); + if( pinname.IsEmpty() ) + pinname = wxT( "noname" ); + + orient = pad->m_Orient - module->m_Orient; + NORMALIZE_ANGLE_POS( orient ); + fprintf( file, "PIN %s PAD%d %d %d %s %d %s", + CONV_TO_UTF8( pinname ), pad->m_logical_connexion, + pad->m_Pos0.x, -pad->m_Pos0.y, + layer, orient / 10, mirror ); + if( orient % 10 ) + fprintf( file, " .%d", orient % 10 ); + fprintf( file, "\n" ); + } + } + + fputs( "$ENDSHAPES\n\n", file ); } + /******************************************************/ -void CreateComponentsSection(FILE * file, BOARD * pcb) +void CreateComponentsSection( FILE* file, BOARD* pcb ) /******************************************************/ + /* Creation de la section $COMPONENTS (Placement des composants - Composants cote CUIVRE: - Les formes sont donnees avec l'option "FLIP", c.a.d.: - - ils sont decrits en vue normale (comme s'ils etaient sur cote COMPOSANT) - - leur orientation est donnée comme s'ils etaient cote composant. -*/ + * Composants cote CUIVRE: + * Les formes sont donnees avec l'option "FLIP", c.a.d.: + * - ils sont decrits en vue normale (comme s'ils etaient sur cote COMPOSANT) + * - leur orientation est donnée comme s'ils etaient cote composant. + */ { -MODULE * module = pcb->m_Modules; -TEXTE_MODULE * PtTexte; -char * mirror; -char * flip; -int ii; - - fputs("$COMPONENTS\n", file); + MODULE* module = pcb->m_Modules; + TEXTE_MODULE* PtTexte; + char* mirror; + char* flip; + int ii; - for(; module != NULL; module = (MODULE *) module->Pnext) - { - int orient = module->m_Orient; - if (module->flag) - { - mirror = "MIRRORX"; // Miroir selon axe X - flip = "FLIP"; // Description normale ( formes a afficher en miroir X) - NEGATE_AND_NORMALIZE_ANGLE_POS(orient); - } - else - { - mirror ="0"; - flip = "0"; - } - - fprintf(file, "COMPONENT %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); - fprintf(file, "DEVICE %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); - fprintf(file, "PLACE %d %d\n", mapXto(module->m_Pos.x), mapYto(module->m_Pos.y)); - fprintf(file, "LAYER %s\n", (module->flag)? "BOTTOM" : "TOP"); + fputs( "$COMPONENTS\n", file ); - fprintf(file, "ROTATION %d", orient/10 ); - if (orient%10 ) fprintf(file, ".%d", orient%10 ); - fputs("\n",file); + for( ; module != NULL; module = (MODULE*) module->Pnext ) + { + int orient = module->m_Orient; + if( module->flag ) + { + mirror = "MIRRORX"; // Miroir selon axe X + flip = "FLIP"; // Description normale ( formes a afficher en miroir X) + NEGATE_AND_NORMALIZE_ANGLE_POS( orient ); + } + else + { + mirror = "0"; + flip = "0"; + } - fprintf(file, "SHAPE %s %s %s\n", - CONV_TO_UTF8(module->m_Reference->m_Text), mirror, flip); - - /* Generation des elements textes (ref et valeur seulement) */ - PtTexte = module->m_Reference; - for ( ii = 0; ii < 2; ii++ ) - { - int orient = PtTexte->m_Orient; - wxString layer = GenCAD_Layer_Name[SILKSCREEN_N_CMP]; - fprintf(file, "TEXT %d %d %d %d.%d %s %s \"%s\"", - PtTexte->m_Pos0.x, - PtTexte->m_Pos0.y, - PtTexte->m_Size.x, - orient /10, orient %10, - mirror, - CONV_TO_UTF8(layer), - CONV_TO_UTF8(PtTexte->m_Text) - ); - - fprintf(file, " 0 0 %d %d\n", - (int) (PtTexte->m_Size.x * PtTexte->m_Text.Len() ), - (int) PtTexte->m_Size.y ); - - PtTexte = module->m_Value; - } - - // commentaire: - fprintf(file, "SHEET Part %s %s\n", CONV_TO_UTF8(module->m_Reference->m_Text), - CONV_TO_UTF8(module->m_Value->m_Text)); - - } - - fputs("$ENDCOMPONENTS\n\n", file); + fprintf( file, "COMPONENT %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); + fprintf( file, "DEVICE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); + fprintf( file, "PLACE %d %d\n", mapXto( module->m_Pos.x ), mapYto( module->m_Pos.y ) ); + fprintf( file, "LAYER %s\n", (module->flag) ? "BOTTOM" : "TOP" ); + + fprintf( file, "ROTATION %d", orient / 10 ); + if( orient % 10 ) + fprintf( file, ".%d", orient % 10 ); + fputs( "\n", file ); + + fprintf( file, "SHAPE %s %s %s\n", + CONV_TO_UTF8( module->m_Reference->m_Text ), mirror, flip ); + + /* Generation des elements textes (ref et valeur seulement) */ + PtTexte = module->m_Reference; + for( ii = 0; ii < 2; ii++ ) + { + int orient = PtTexte->m_Orient; + wxString layer = GenCAD_Layer_Name[SILKSCREEN_N_CMP]; + fprintf( file, "TEXT %d %d %d %d.%d %s %s \"%s\"", + PtTexte->m_Pos0.x, -PtTexte->m_Pos0.y, + PtTexte->m_Size.x, + orient / 10, orient % 10, + mirror, + CONV_TO_UTF8( layer ), + CONV_TO_UTF8( PtTexte->m_Text ) + ); + + fprintf( file, " 0 0 %d %d\n", + (int) ( PtTexte->m_Size.x * PtTexte->m_Text.Len() ), + (int) PtTexte->m_Size.y ); + + PtTexte = module->m_Value; + } + + // commentaire: + fprintf( file, "SHEET Part %s %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ), + CONV_TO_UTF8( module->m_Value->m_Text ) ); + } + + fputs( "$ENDCOMPONENTS\n\n", file ); } + /***************************************************/ -void CreateSignalsSection(FILE * file, BOARD * pcb) +void CreateSignalsSection( FILE* file, BOARD* pcb ) /***************************************************/ + /* Creation de la liste des equipotentielles: - $SIGNALS - SIGNAL - NODE - ... - NODE - $ENDSIGNALS -*/ + * $SIGNALS + * SIGNAL + * NODE + * ... + * NODE + * $ENDSIGNALS + */ { -wxString msg; -EQUIPOT * equipot; -D_PAD * pad; -MODULE * module; -int NbNoConn = 1; - - fputs("$SIGNALS\n", file); - - for( equipot = pcb->m_Equipots; equipot != NULL; equipot = (EQUIPOT *) equipot->Pnext ) - { - if ( equipot->m_Netname == wxEmptyString ) // dummy equipot (non connexion) - { - equipot->m_Netname << wxT("NoConnection") << NbNoConn++; - } - - if ( equipot->m_NetCode <= 0 ) // dummy equipot (non connexion) - continue; - - msg = wxT("\nSIGNAL ") + equipot->m_Netname; - fputs( CONV_TO_UTF8(msg), file); fputs("\n", file); - - for ( module = pcb->m_Modules; module != NULL; module = (MODULE *) module->Pnext ) - { - for( pad = module->m_Pads; pad != NULL; pad = (D_PAD *) pad->Pnext ) - { - wxString padname; - if ( pad->m_NetCode != equipot->m_NetCode ) continue; - pad->ReturnStringPadName(padname); - msg.Printf(wxT("NODE %s %.4s"), - module->m_Reference->m_Text.GetData(), padname.GetData()); - fputs( CONV_TO_UTF8(msg), file); fputs("\n", file); - } - } - } - - fputs("$ENDSIGNALS\n\n", file); + wxString msg; + EQUIPOT* equipot; + D_PAD* pad; + MODULE* module; + int NbNoConn = 1; + fputs( "$SIGNALS\n", file ); + + for( equipot = pcb->m_Equipots; equipot != NULL; equipot = (EQUIPOT*) equipot->Pnext ) + { + if( equipot->m_Netname == wxEmptyString ) // dummy equipot (non connexion) + { + equipot->m_Netname << wxT( "NoConnection" ) << NbNoConn++; + } + + if( equipot->m_NetCode <= 0 ) // dummy equipot (non connexion) + continue; + + msg = wxT( "\nSIGNAL " ) + equipot->m_Netname; + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + + for( module = pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext ) + { + for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + wxString padname; + if( pad->m_NetCode != equipot->m_NetCode ) + continue; + pad->ReturnStringPadName( padname ); + msg.Printf( wxT( "NODE %s %.4s" ), + module->m_Reference->m_Text.GetData(), padname.GetData() ); + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + } + } + } + + fputs( "$ENDSIGNALS\n\n", file ); } + /*************************************************************/ -bool CreateHeaderInfoData(FILE * file, WinEDA_PcbFrame * frame) +bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ) /*************************************************************/ + /* Creation de la section $HEADER ... $ENDHEADER -*/ + */ { -wxString msg; -PCB_SCREEN * screen = frame->GetScreen(); - - fputs("$HEADER\n", file); - fputs("GENCAD 1.4\n", file); - msg = wxT("USER ") + g_Main_Title + wxT(" ") + GetBuildVersion(); - fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); - msg = wxT("DRAWING ") + screen->m_FileName; - fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); - msg = wxT("REVISION ") + screen->m_Revision + wxT(" ") + screen->m_Date; - fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); - msg.Printf(wxT("UNITS USER %d"), PCB_INTERNAL_UNIT); - fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); - msg.Printf( wxT("ORIGIN %d %d"), mapXto(frame->m_Auxiliary_Axis_Position.x), - mapYto(frame->m_Auxiliary_Axis_Position.y)) ; - fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); - fputs("INTERTRACK 0\n", file); - fputs("$ENDHEADER\n\n", file); - - return TRUE; + wxString msg; + PCB_SCREEN* screen = frame->GetScreen(); + + fputs( "$HEADER\n", file ); + fputs( "GENCAD 1.4\n", file ); + msg = wxT( "USER " ) + g_Main_Title + wxT( " " ) + GetBuildVersion(); + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + msg = wxT( "DRAWING " ) + screen->m_FileName; + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) + screen->m_Date; + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + msg.Printf( wxT( "UNITS USER %d" ), PCB_INTERNAL_UNIT ); + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + msg.Printf( wxT( "ORIGIN %d %d" ), mapXto( frame->m_Auxiliary_Axis_Position.x ), + mapYto( frame->m_Auxiliary_Axis_Position.y ) ); + fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); + fputs( "INTERTRACK 0\n", file ); + fputs( "$ENDHEADER\n\n", file ); + + return TRUE; } /**************************************************************************/ -static int Track_list_Sort_by_Netcode(const void * refptr, const void * objptr) +static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr ) /**************************************************************************/ + /* -Routine de tri de la liste des piste par netcode, - puis par largeur puis par layer -*/ + * Routine de tri de la liste des piste par netcode, + * puis par largeur puis par layer + */ { -const TRACK * ref, *cmp; -int diff; - - ref = *((TRACK**) refptr); - cmp = *((TRACK**) objptr); - if( (diff = ref->m_NetCode - cmp->m_NetCode) ) return diff; - if( (diff = ref->m_Width - cmp->m_Width) ) return diff; - if( (diff = ref->m_Layer - cmp->m_Layer) ) return diff; + const TRACK* ref, * cmp; + int diff; - return 0; + ref = *( (TRACK**) refptr ); + cmp = *( (TRACK**) objptr ); + if( (diff = ref->m_NetCode - cmp->m_NetCode) ) + return diff; + if( (diff = ref->m_Width - cmp->m_Width) ) + return diff; + if( (diff = ref->GetLayer() - cmp->GetLayer()) ) + return diff; + + return 0; } + + /*************************************************/ -void CreateRoutesSection(FILE * file, BOARD * pcb) +void CreateRoutesSection( FILE* file, BOARD* pcb ) /*************************************************/ + /* Creation de la liste des pistes, vias et zones -section: -$ROUTE -... -$ENROUTE -Les segments de piste doivent etre regroupes par nets -*/ + * section: + * $ROUTE + * ... + * $ENROUTE + * Les segments de piste doivent etre regroupes par nets + */ { -TRACK * track, ** tracklist; -int vianum = 1; -int old_netcode, old_width, old_layer; -int nbitems, ii; - - // Calcul du nombre de segments a ecrire - nbitems = 0; - for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) nbitems++; - for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) - { - if ( track->m_StructType == TYPEZONE ) nbitems++; - } - tracklist = (TRACK **) MyMalloc( (nbitems+1) * sizeof(TRACK *) ); - - nbitems = 0; - for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) - tracklist[nbitems++] = track; - for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) - { - if ( track->m_StructType == TYPEZONE ) tracklist[nbitems++] = track; - } - tracklist[nbitems] = NULL; + TRACK* track, ** tracklist; + int vianum = 1; + int old_netcode, old_width, old_layer; + int nbitems, ii; - qsort(tracklist, nbitems, sizeof(TRACK *), Track_list_Sort_by_Netcode); - - fputs("$ROUTES\n", file); + // Calcul du nombre de segments a ecrire + nbitems = 0; + for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + nbitems++; - old_netcode = -1; old_width = -1; old_layer = -1; - for( ii = 0; ii < nbitems; ii++ ) - { - track = tracklist[ii]; - if ( old_netcode != track->m_NetCode ) - { - old_netcode = track->m_NetCode; - EQUIPOT * equipot = pcb->FindNet( track->m_NetCode); - wxString netname; - if (equipot && (equipot->m_Netname != wxEmptyString) ) - netname = equipot->m_Netname; - else netname = wxT("_noname_" ); - fprintf(file,"\nROUTE %s\n",CONV_TO_UTF8(netname)); - } + for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + { + if( track->m_StructType == TYPEZONE ) + nbitems++; + } - if ( old_width != track->m_Width ) - { - old_width = track->m_Width; - fprintf(file,"TRACK TRACK%d\n", track->m_Width); - } - - if ( (track->m_StructType == TYPETRACK) || (track->m_StructType == TYPEZONE) ) - { - if ( old_layer != track->m_Layer ) - { - old_layer = track->m_Layer; - fprintf(file,"LAYER %s\n", - CONV_TO_UTF8(GenCAD_Layer_Name[track->m_Layer & 0x1F])); - } - - fprintf(file, "LINE %d %d %d %d\n", - mapXto(track->m_Start.x), mapYto(track->m_Start.y), - mapXto(track->m_End.x), mapYto(track->m_End.y) ); - } - if ( track->m_StructType == TYPEVIA ) - { - fprintf(file, "VIA viapad%d %d %d ALL %d via%d\n", - track->m_Width, - mapXto(track->m_Start.x), mapYto(track->m_Start.y), - g_DesignSettings.m_ViaDrill, vianum++ ); - } - } + tracklist = (TRACK**) MyMalloc( (nbitems + 1) * sizeof(TRACK *) ); - fputs("$ENDROUTES\n\n", file); + nbitems = 0; + for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + tracklist[nbitems++] = track; - free(tracklist); + for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + { + if( track->m_StructType == TYPEZONE ) + tracklist[nbitems++] = track; + } + + tracklist[nbitems] = NULL; + + qsort( tracklist, nbitems, sizeof(TRACK *), Track_list_Sort_by_Netcode ); + + fputs( "$ROUTES\n", file ); + + old_netcode = -1; old_width = -1; old_layer = -1; + for( ii = 0; ii < nbitems; ii++ ) + { + track = tracklist[ii]; + if( old_netcode != track->m_NetCode ) + { + old_netcode = track->m_NetCode; + EQUIPOT* equipot = pcb->FindNet( track->m_NetCode ); + wxString netname; + if( equipot && (equipot->m_Netname != wxEmptyString) ) + netname = equipot->m_Netname; + else + netname = wxT( "_noname_" ); + fprintf( file, "\nROUTE %s\n", CONV_TO_UTF8( netname ) ); + } + + if( old_width != track->m_Width ) + { + old_width = track->m_Width; + fprintf( file, "TRACK TRACK%d\n", track->m_Width ); + } + + if( (track->m_StructType == TYPETRACK) || (track->m_StructType == TYPEZONE) ) + { + if( old_layer != track->GetLayer() ) + { + old_layer = track->GetLayer(); + fprintf( file, "LAYER %s\n", + CONV_TO_UTF8( GenCAD_Layer_Name[track->GetLayer() & 0x1F] ) ); + } + + fprintf( file, "LINE %d %d %d %d\n", + mapXto( track->m_Start.x ), mapYto( track->m_Start.y ), + mapXto( track->m_End.x ), mapYto( track->m_End.y ) ); + } + if( track->m_StructType == TYPEVIA ) + { + fprintf( file, "VIA viapad%d %d %d ALL %d via%d\n", + track->m_Width, + mapXto( track->m_Start.x ), mapYto( track->m_Start.y ), + g_DesignSettings.m_ViaDrill, vianum++ ); + } + } + + fputs( "$ENDROUTES\n\n", file ); + + free( tracklist ); } /***************************************************/ -void CreateDevicesSection(FILE * file, BOARD * pcb) +void CreateDevicesSection( FILE* file, BOARD* pcb ) /***************************************************/ + /* Creation de la section de description des proprietes des composants - ( la forme des composants est dans la section shape ) -*/ + * ( la forme des composants est dans la section shape ) + */ { -MODULE * module; -D_PAD * pad; - - fputs("$DEVICES\n", file); + MODULE* module; + D_PAD* pad; - for(module = pcb->m_Modules; module != NULL; module = (MODULE *) module->Pnext) - { - 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) - { - fprintf(file, "PINDESCR %.4s", pad->m_Padname); - if ( pad->m_Netname == wxEmptyString ) fputs(" NoConn\n", file); - else fprintf(file, " %.4s\n", pad->m_Padname); - } - fprintf(file, "ATTRIBUTE %s\n", CONV_TO_UTF8(module->m_Value->m_Text)); - } - - fputs("$ENDDEVICES\n\n", file); + fputs( "$DEVICES\n", file ); + + for( module = pcb->m_Modules; module != NULL; module = (MODULE*) module->Pnext ) + { + 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 ) + { + fprintf( file, "PINDESCR %.4s", pad->m_Padname ); + if( pad->m_Netname == wxEmptyString ) + fputs( " NoConn\n", file ); + else + fprintf( file, " %.4s\n", pad->m_Padname ); + } + + fprintf( file, "ATTRIBUTE %s\n", CONV_TO_UTF8( module->m_Value->m_Text ) ); + } + + fputs( "$ENDDEVICES\n\n", file ); } /*************************************************/ -void CreateBoardSection(FILE * file, BOARD * pcb) +void CreateBoardSection( FILE* file, BOARD* pcb ) /*************************************************/ + /* Creation de la section $BOARD. -On ne cree ici que le rectangle d'encadrement du Board -*/ + * On ne cree ici que le rectangle d'encadrement du Board + */ { - fputs("$BOARD\n", file); - fprintf(file, "LINE %d %d %d %d\n", - mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.m_Pos.y), - mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.m_Pos.y) ); - fprintf(file, "LINE %d %d %d %d\n", - mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.m_Pos.y), - mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.GetBottom()) ); - fprintf(file, "LINE %d %d %d %d\n", - mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.GetBottom()), - mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.GetBottom()) ); - fprintf(file, "LINE %d %d %d %d\n", - mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.GetBottom()), - mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.m_Pos.y) ); + fputs( "$BOARD\n", file ); + fprintf( file, "LINE %d %d %d %d\n", + mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.m_Pos.y ), + mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.m_Pos.y ) ); + fprintf( file, "LINE %d %d %d %d\n", + mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.m_Pos.y ), + mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.GetBottom() ) ); + fprintf( file, "LINE %d %d %d %d\n", + mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.GetBottom() ), + mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.GetBottom() ) ); + fprintf( file, "LINE %d %d %d %d\n", + mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.GetBottom() ), + mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.m_Pos.y ) ); - fputs("$ENDBOARD\n\n", file); + fputs( "$ENDBOARD\n\n", file ); } /****************************************************/ -int * CreateTracksInfoData(FILE * file, BOARD * pcb) +int* CreateTracksInfoData( FILE* file, BOARD* pcb ) /****************************************************/ + /* Creation de la section "$TRACKS" -Cette section definit les largeurs de pistes utilsees -format: -$TRACK -TRACK -$ENDTRACK - -on attribut ici comme nom l'epaisseur des traits precede de "TRACK": ex -pour une largeur de 120 : nom = "TRACK120". -*/ + * Cette section definit les largeurs de pistes utilsees + * format: + * $TRACK + * TRACK + * $ENDTRACK + * + * on attribut ici comme nom l'epaisseur des traits precede de "TRACK": ex + * pour une largeur de 120 : nom = "TRACK120". + */ { -TRACK * track; -int * trackinfo, * ptinfo; - - /* recherche des epaisseurs utilisees pour les traces: */ - - trackinfo = (int*) adr_lowmem; - *trackinfo = -1; + TRACK* track; + int* trackinfo, * ptinfo; - for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) - { - if ( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee - { - ptinfo = (int*) adr_lowmem; - while (*ptinfo >= 0 ) - { - if ( *ptinfo != track->m_Width ) ptinfo ++; - else break; - } - trackinfo = ptinfo; - if ( *ptinfo < 0 ) - { - *ptinfo = track->m_Width; - ptinfo++; *ptinfo = -1; - } - } - } - for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) - { - if ( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee - { - ptinfo = (int*) adr_lowmem; - while (*ptinfo >= 0 ) - { - if ( *ptinfo != track->m_Width ) ptinfo ++; - else break; - } - trackinfo = ptinfo; - if ( *ptinfo < 0 ) - { - *ptinfo = track->m_Width; - ptinfo++; *ptinfo = -1; - } - } - } + /* recherche des epaisseurs utilisees pour les traces: */ - // Write data - fputs("$TRACKS\n", file); - for( trackinfo = (int*) adr_lowmem; * trackinfo >= 0; trackinfo++ ) - { - fprintf(file,"TRACK TRACK%d %d\n", * trackinfo, * trackinfo); - } - fputs("$ENDTRACKS\n\n", file); - - return (int*) adr_lowmem; + trackinfo = (int*) adr_lowmem; + *trackinfo = -1; + + for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + { + if( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee + { + ptinfo = (int*) adr_lowmem; + while( *ptinfo >= 0 ) + { + if( *ptinfo != track->m_Width ) + ptinfo++; + else + break; + } + + trackinfo = ptinfo; + if( *ptinfo < 0 ) + { + *ptinfo = track->m_Width; + ptinfo++; *ptinfo = -1; + } + } + } + + for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + { + if( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee + { + ptinfo = (int*) adr_lowmem; + while( *ptinfo >= 0 ) + { + if( *ptinfo != track->m_Width ) + ptinfo++; + else + break; + } + + trackinfo = ptinfo; + if( *ptinfo < 0 ) + { + *ptinfo = track->m_Width; + ptinfo++; *ptinfo = -1; + } + } + } + + // Write data + fputs( "$TRACKS\n", file ); + for( trackinfo = (int*) adr_lowmem; *trackinfo >= 0; trackinfo++ ) + { + fprintf( file, "TRACK TRACK%d %d\n", *trackinfo, *trackinfo ); + } + + fputs( "$ENDTRACKS\n\n", file ); + + return (int*) adr_lowmem; } /***************************************************/ -void ModuleWriteShape( FILE * file, MODULE * module ) +void ModuleWriteShape( FILE* file, MODULE* module ) /***************************************************/ + /* Sauvegarde de la forme d'un MODULE (section SHAPE) - La forme est donnee "normalisee" (Orient 0, vue normale ( non miroir) - Syntaxe: -SHAPE - shape_descr (line, arc ..): -LINE startX startY endX endY -ARC startX startY endX endY centreX scentreY -CIRCLE centreX scentreY radius -*/ + * La forme est donnee "normalisee" (Orient 0, vue normale ( non miroir) + * Syntaxe: + * SHAPE + * shape_descr (line, arc ..): + * LINE startX startY endX endY + * ARC startX startY endX endY centreX scentreY + * CIRCLE centreX scentreY radius + */ { -EDGE_MODULE * PtEdge; -EDA_BaseStruct * PtStruct; -int Yaxis_sign = -1; // Controle changement signe axe Y (selon module normal/miroir et conevtions d'axe) - - - /* Generation du fichier module: */ - fprintf(file, "\nSHAPE %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); - - /* Attributs du module */ - if( module->m_Attributs != MOD_DEFAULT ) - { - fprintf(file,"ATTRIBUTE"); - if( module->m_Attributs & MOD_CMS ) fprintf(file," SMD"); - if( module->m_Attributs & MOD_VIRTUAL ) fprintf(file," VIRTUAL"); - fprintf(file,"\n"); - } + EDGE_MODULE* PtEdge; + EDA_BaseStruct* PtStruct; + int Yaxis_sign = -1; // Controle changement signe axe Y (selon module normal/miroir et conevtions d'axe) - /* Generation des elements Drawing modules */ - PtStruct = module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) - { - switch(PtStruct->m_StructType ) - { - case TYPETEXTEMODULE: - break; + /* Generation du fichier module: */ + fprintf( file, "\nSHAPE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); - case TYPEEDGEMODULE: - PtEdge = (EDGE_MODULE*) PtStruct; - switch(PtEdge->m_Shape ) - { - case S_SEGMENT: - fprintf(file,"LINE %d %d %d %d\n", - PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y, - PtEdge->m_End0.x, Yaxis_sign * PtEdge->m_End0.y); - break; - case S_CIRCLE: - { - int rayon = (int)hypot( - (double)(PtEdge->m_End0.x - PtEdge->m_Start0.x), - (double)(PtEdge->m_End0.y - PtEdge->m_Start0.y) ); - fprintf(file,"CIRCLE %d %d %d\n", - PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y, - rayon); - break; - } + /* Attributs du module */ + if( module->m_Attributs != MOD_DEFAULT ) + { + fprintf( file, "ATTRIBUTE" ); + if( module->m_Attributs & MOD_CMS ) + fprintf( file, " SMD" ); + if( module->m_Attributs & MOD_VIRTUAL ) + fprintf( file, " VIRTUAL" ); + fprintf( file, "\n" ); + } - case S_ARC: /* print ARC x,y start x,y end x,y centre */ - { - int arcendx, arcendy; - arcendx = PtEdge->m_Start0.x; - arcendy = PtEdge->m_Start0.y; - RotatePoint(& arcendx, &arcendy, PtEdge->m_Angle); - fprintf(file,"ARC %d %d %d %d %d %d\n", - PtEdge->m_End0.x, Yaxis_sign * PtEdge->m_End0.y, - arcendx, Yaxis_sign * arcendy, - PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y); - break; - } - default: - DisplayError(NULL, wxT("Type Edge Module inconnu")); - break; - } /* Fin switch type edge */ - break; - default: - break; - } /* Fin switch gestion des Items draw */ - } + /* Generation des elements Drawing modules */ + PtStruct = module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPETEXTEMODULE: + break; + + case TYPEEDGEMODULE: + PtEdge = (EDGE_MODULE*) PtStruct; + + switch( PtEdge->m_Shape ) + { + case S_SEGMENT: + fprintf( file, "LINE %d %d %d %d\n", + PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y, + PtEdge->m_End0.x, Yaxis_sign * PtEdge->m_End0.y ); + break; + + case S_CIRCLE: + { + int rayon = (int) hypot( + (double) (PtEdge->m_End0.x - PtEdge->m_Start0.x), + (double) (PtEdge->m_End0.y - PtEdge->m_Start0.y) ); + fprintf( file, "CIRCLE %d %d %d\n", + PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y, + rayon ); + break; + } + + case S_ARC: /* print ARC x,y start x,y end x,y centre */ + { + int arcendx, arcendy; + arcendx = PtEdge->m_Start0.x; + arcendy = PtEdge->m_Start0.y; + RotatePoint( &arcendx, &arcendy, PtEdge->m_Angle ); + fprintf( file, "ARC %d %d %d %d %d %d\n", + PtEdge->m_End0.x, Yaxis_sign * PtEdge->m_End0.y, + arcendx, Yaxis_sign * arcendy, + PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y ); + break; + } + + default: + DisplayError( NULL, wxT( "Type Edge Module inconnu" ) ); + break; + } + + /* Fin switch type edge */ + break; + + default: + break; + } + + /* Fin switch gestion des Items draw */ + } } - diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 276e41f1e9..1de92407d3 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -1,427 +1,453 @@ - /*************************************/ - /* fichier gen_modules_placefile.cpp */ - /*************************************/ +/*************************************/ +/* fichier gen_modules_placefile.cpp */ +/*************************************/ /* - 1 - create ascii files for automatic placement of smd components - 2 - create a module report (pos and module descr) (ascii file) -*/ + * 1 - create ascii files for automatic placement of smd components + * 2 - create a module report (pos and module descr) (ascii file) + */ #include "fctsys.h" #include "common.h" #include "pcbnew.h" #include "trigo.h" -class LIST_MOD /* Permet de lister les elements utiles des modules */ +class LIST_MOD /* Permet de lister les elements utiles des modules */ { public: - MODULE * m_Module; - const wxChar * m_Reference; - const wxChar * m_Value; + MODULE* m_Module; + const wxChar* m_Reference; + const wxChar* m_Value; }; /* variables locale : */ -static wxPoint File_Place_Offset; /* Offset des coord de placement pour le fichier généré */ +static wxPoint File_Place_Offset; /* Offset des coord de placement pour le fichier généré */ /* Routines Locales */ -static void WriteDrawSegmentPcb(DRAWSEGMENT * PtDrawSegment, FILE * rptfile); +static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ); /* Routine de tri utilisee par GenereModulesPosition() */ -static int ListeModCmp(LIST_MOD * Ref, LIST_MOD * Cmp) +static int ListeModCmp( LIST_MOD* Ref, LIST_MOD* Cmp ) { - return ( StrLenNumCmp(Ref->m_Reference, Cmp->m_Reference, 16) ); + return StrLenNumCmp( Ref->m_Reference, Cmp->m_Reference, 16 ); } +/**************************************************************/ +void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) +/**************************************************************/ -/**************************************************************/ -void WinEDA_PcbFrame::GenModulesPosition(wxCommandEvent& event) -/**************************************************************/ /* Routine de generation du fichier de positionnement des modules, - utilisé pour les machines de placement de composants -*/ + * utilisé pour les machines de placement de composants + */ { -float conv_unit; -int NbMod, ii; -bool GenCu = FALSE; -MODULE * Module; -LIST_MOD * Liste; -char Line[1024], Buff[80]; -wxString NameLayerCu, NameLayerCmp, msg; -FILE * LayerCu = NULL, *LayerCmp = NULL; + float conv_unit; + int NbMod, ii; + bool GenCu = FALSE; + MODULE* Module; + LIST_MOD* Liste; + char Line[1024], Buff[80]; + wxString NameLayerCu, NameLayerCmp, msg; + FILE* LayerCu = NULL, * LayerCmp = NULL; + + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ - /* Calcul des echelles de conversion */ - conv_unit = 0.0001; /* unites = INCHES */ // if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */ - File_Place_Offset = m_Auxiliary_Axis_Position; + File_Place_Offset = m_Auxiliary_Axis_Position; - /* Calcul du nombre de modules utiles ( Attribut CMS, non VIRTUAL ) ) */ - NbMod = 0; Module = m_Pcb->m_Modules; - for ( ; Module != NULL; Module = (MODULE*) Module->Pnext) - { - if( Module->m_Attributs & MOD_VIRTUAL ) continue; - if( (Module->m_Attributs & MOD_CMS) == 0 ) continue; - if( Module->m_Layer == CUIVRE_N) GenCu = TRUE; - NbMod++; - } - if ( NbMod == 0 ) - { - DisplayError(this, _("No Modules for Automated Placement"), 20); return; - } + /* Calcul du nombre de modules utiles ( Attribut CMS, non VIRTUAL ) ) */ + NbMod = 0; Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + if( Module->m_Attributs & MOD_VIRTUAL ) + continue; + if( (Module->m_Attributs & MOD_CMS) == 0 ) + continue; + if( Module->GetLayer() == CUIVRE_N ) + GenCu = TRUE; + NbMod++; + } + + if( NbMod == 0 ) + { + DisplayError( this, _( "No Modules for Automated Placement" ), 20 ); return; + } - /* Init nom fichier */ - NameLayerCmp = m_CurrentScreen->m_FileName; - ChangeFileNameExt(NameLayerCmp, wxT("-cmp.pos")); + /* Init nom fichier */ + NameLayerCmp = m_CurrentScreen->m_FileName; + ChangeFileNameExt( NameLayerCmp, wxT( "-cmp.pos" ) ); - LayerCmp = wxFopen(NameLayerCmp, wxT("wt")); - if (LayerCmp == 0) - { - msg = _("Unable to create ") + NameLayerCu; - DisplayError(this, msg); return ; - } + LayerCmp = wxFopen( NameLayerCmp, wxT( "wt" ) ); + if( LayerCmp == 0 ) + { + msg = _( "Unable to create " ) + NameLayerCu; + DisplayError( this, msg ); return; + } - if( GenCu ) - { - NameLayerCu = m_CurrentScreen->m_FileName; - ChangeFileNameExt(NameLayerCu, wxT("-copper.pos")); - LayerCu = wxFopen(NameLayerCu, wxT("wt")); - if (LayerCu == 0) - { - msg = _("Unable to create ") + NameLayerCu; - DisplayError(this, msg); - fclose(LayerCmp); - return ; - } - } + if( GenCu ) + { + NameLayerCu = m_CurrentScreen->m_FileName; + ChangeFileNameExt( NameLayerCu, wxT( "-copper.pos" ) ); + LayerCu = wxFopen( NameLayerCu, wxT( "wt" ) ); + if( LayerCu == 0 ) + { + msg = _( "Unable to create " ) + NameLayerCu; + DisplayError( this, msg ); + fclose( LayerCmp ); + return; + } + } - // Switch the locale to standard C (needed to print floating point numbers like 1.3) - setlocale(LC_NUMERIC, "C"); + // Switch the locale to standard C (needed to print floating point numbers like 1.3) + setlocale( LC_NUMERIC, "C" ); - /* Affichage du bilan : */ - MsgPanel->EraseMsgBox(); - Affiche_1_Parametre(this,0,_("Component side place file:"),NameLayerCmp,BLUE); + /* Affichage du bilan : */ + MsgPanel->EraseMsgBox(); + Affiche_1_Parametre( this, 0, _( "Component side place file:" ), NameLayerCmp, BLUE ); - if( GenCu ) - Affiche_1_Parametre(this,32,_("Copper side place file:"),NameLayerCu,BLUE); + if( GenCu ) + Affiche_1_Parametre( this, 32, _( "Copper side place file:" ), NameLayerCu, BLUE ); - msg.Empty(); msg << NbMod; - Affiche_1_Parametre(this,65, _("Module count"), msg, RED); + msg.Empty(); msg << NbMod; + Affiche_1_Parametre( this, 65, _( "Module count" ), msg, RED ); - /* Etablissement de la liste des modules par ordre alphabetique */ - Liste = (LIST_MOD*) MyZMalloc( NbMod * sizeof(LIST_MOD) ); + /* Etablissement de la liste des modules par ordre alphabetique */ + Liste = (LIST_MOD*) MyZMalloc( NbMod * sizeof(LIST_MOD) ); - Module = (MODULE*)m_Pcb->m_Modules; - for( ii = 0; Module != NULL; Module = Module->Next() ) - { - if( Module->m_Attributs & MOD_VIRTUAL ) continue; - if( (Module->m_Attributs & MOD_CMS) == 0 ) continue; + Module = (MODULE*) m_Pcb->m_Modules; + for( ii = 0; Module != NULL; Module = Module->Next() ) + { + if( Module->m_Attributs & MOD_VIRTUAL ) + continue; + if( (Module->m_Attributs & MOD_CMS) == 0 ) + continue; - Liste[ii].m_Module = Module; - Liste[ii].m_Reference = Module->m_Reference->m_Text; - Liste[ii].m_Value = Module->m_Value->m_Text; - ii++; - } + Liste[ii].m_Module = Module; + Liste[ii].m_Reference = Module->m_Reference->m_Text; + Liste[ii].m_Value = Module->m_Value->m_Text; + ii++; + } - qsort(Liste, NbMod , sizeof(LIST_MOD), - (int(*)(const void *, const void*))ListeModCmp); + qsort( Liste, NbMod, sizeof(LIST_MOD), + ( int( * ) ( const void*, const void* ) )ListeModCmp ); - /* Generation entete du fichier 'commentaires) */ - sprintf(Line,"### Module positions - created on %s ###\n", - DateAndTime(Buff) ); - fputs(Line,LayerCmp); - if( GenCu ) fputs(Line,LayerCu); + /* Generation entete du fichier 'commentaires) */ + sprintf( Line, "### Module positions - created on %s ###\n", + DateAndTime( Buff ) ); + fputs( Line, LayerCmp ); + if( GenCu ) + fputs( Line, LayerCu ); - wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); - sprintf(Line,"### Printed by PcbNew version %s\n", CONV_TO_UTF8(Title) ); - fputs(Line,LayerCmp); - if( GenCu ) fputs(Line,LayerCu); + wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + sprintf( Line, "### Printed by PcbNew version %s\n", CONV_TO_UTF8( Title ) ); + fputs( Line, LayerCmp ); + if( GenCu ) + fputs( Line, LayerCu ); - sprintf(Line,"## Unit = inches, Angle = deg.\n"); - fputs(Line,LayerCmp); - if( GenCu ) fputs(Line,LayerCu); + sprintf( Line, "## Unit = inches, Angle = deg.\n" ); + fputs( Line, LayerCmp ); + if( GenCu ) + fputs( Line, LayerCu ); - sprintf(Line,"## Side : Components\n"); - fputs(Line,LayerCmp); + sprintf( Line, "## Side : Components\n" ); + fputs( Line, LayerCmp ); - if( GenCu ) - { - sprintf(Line,"## Side : Copper\n"); - fputs(Line,LayerCu); - } + if( GenCu ) + { + sprintf( Line, "## Side : Copper\n" ); + fputs( Line, LayerCu ); + } - sprintf(Line, - "# Ref Val PosX PosY Rot Side\n"); - fputs(Line,LayerCmp); - if( GenCu ) fputs(Line,LayerCu); + sprintf( Line, + "# Ref Val PosX PosY Rot Side\n" ); + fputs( Line, LayerCmp ); + if( GenCu ) + fputs( Line, LayerCu ); - /* Generation lignes utiles du fichier */ - for ( ii = 0 ; ii < NbMod; ii++) - { - wxPoint module_pos; - wxString ref = Liste[ii].m_Reference; - wxString val = Liste[ii].m_Value; - sprintf(Line,"%-8.8s %-16.16s ", CONV_TO_UTF8(ref), CONV_TO_UTF8(val) ); + /* Generation lignes utiles du fichier */ + for( ii = 0; ii < NbMod; ii++ ) + { + wxPoint module_pos; + wxString ref = Liste[ii].m_Reference; + wxString val = Liste[ii].m_Value; + sprintf( Line, "%-8.8s %-16.16s ", CONV_TO_UTF8( ref ), CONV_TO_UTF8( val ) ); - module_pos = Liste[ii].m_Module->m_Pos; - module_pos.x -= File_Place_Offset.x; - module_pos.y -= File_Place_Offset.y; - - char * text = Line + strlen(Line); - sprintf( text, " %9.4f %9.4f %8.1f ", - (float) module_pos.x * conv_unit, - (float) module_pos.y * conv_unit, - (float) Liste[ii].m_Module->m_Orient / 10); + module_pos = Liste[ii].m_Module->m_Pos; + module_pos.x -= File_Place_Offset.x; + module_pos.y -= File_Place_Offset.y; - if (Liste[ii].m_Module->m_Layer == CMP_N) - { - strcat(Line,"Cmp.\n"); - fputs(Line, LayerCmp); - } + char* text = Line + strlen( Line ); + sprintf( text, " %9.4f %9.4f %8.1f ", + (float) module_pos.x * conv_unit, + (float) module_pos.y * conv_unit, + (float) Liste[ii].m_Module->m_Orient / 10 ); - else if (Liste[ii].m_Module->m_Layer == CUIVRE_N) - { - strcat(Line,"Cu\n"); - fputs(Line, LayerCu); - } - } + if( Liste[ii].m_Module->GetLayer() == CMP_N ) + { + strcat( Line, "Cmp.\n" ); + fputs( Line, LayerCmp ); + } + else if( Liste[ii].m_Module->GetLayer() == CUIVRE_N ) + { + strcat( Line, "Cu\n" ); + fputs( Line, LayerCu ); + } + } - /* Generation fin du fichier */ - fputs("## End\n", LayerCmp); - fclose(LayerCmp); - if( GenCu ) - { - fputs("## End\n", LayerCu); - fclose(LayerCu); - } - MyFree(Liste); - setlocale(LC_NUMERIC, ""); // revert to the current locale + /* Generation fin du fichier */ + fputs( "## End\n", LayerCmp ); + fclose( LayerCmp ); + if( GenCu ) + { + fputs( "## End\n", LayerCu ); + fclose( LayerCu ); + } + MyFree( Liste ); + setlocale( LC_NUMERIC, "" ); // revert to the current locale - msg = wxT("Cmp File: ") + NameLayerCmp; - if( GenCu ) msg += wxT("\nCu File: ") + NameLayerCu; + msg = wxT( "Cmp File: " ) + NameLayerCmp; + if( GenCu ) + msg += wxT( "\nCu File: " ) + NameLayerCu; - DisplayInfo(this, msg); + DisplayInfo( this, msg ); } +/**************************************************************/ +void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) +/**************************************************************/ -/**************************************************************/ -void WinEDA_PcbFrame::GenModuleReport(wxCommandEvent& event) -/**************************************************************/ /* Print a module report. -*/ + */ { -float conv_unit; -MODULE * Module; -D_PAD * pad; -char Line[1024], Buff[80]; -wxString FullFileName, NameLayerCmp, msg; -FILE * rptfile; -wxPoint module_pos; - - /* Calcul des echelles de conversion */ - conv_unit = 0.0001; /* unites = INCHES */ + float conv_unit; + MODULE* Module; + D_PAD* pad; + char Line[1024], Buff[80]; + wxString FullFileName, NameLayerCmp, msg; + FILE* rptfile; + wxPoint module_pos; + + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ + // if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */ - File_Place_Offset = wxPoint(0,0); + File_Place_Offset = wxPoint( 0, 0 ); - /* Init nom fichier */ - FullFileName = m_CurrentScreen->m_FileName; - ChangeFileNameExt(FullFileName, wxT(".rpt")); + /* Init nom fichier */ + FullFileName = m_CurrentScreen->m_FileName; + ChangeFileNameExt( FullFileName, wxT( ".rpt" ) ); - rptfile = wxFopen(FullFileName, wxT("wt")); - if (rptfile == NULL) - { - msg = _("Unable to create ") + FullFileName; - DisplayError(this, msg); return ; - } + rptfile = wxFopen( FullFileName, wxT( "wt" ) ); + if( rptfile == NULL ) + { + msg = _( "Unable to create " ) + FullFileName; + DisplayError( this, msg ); return; + } - // Switch the locale to standard C (needed to print floating point numbers like 1.3) - setlocale(LC_NUMERIC, "C"); + // Switch the locale to standard C (needed to print floating point numbers like 1.3) + setlocale( LC_NUMERIC, "C" ); - /* Generation entete du fichier 'commentaires) */ - sprintf(Line,"## Module report - date %s\n", DateAndTime(Buff) ); - fputs(Line,rptfile); + /* Generation entete du fichier 'commentaires) */ + sprintf( Line, "## Module report - date %s\n", DateAndTime( Buff ) ); + fputs( Line, rptfile ); - wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); - sprintf(Line,"## Created by PcbNew version %s\n", CONV_TO_UTF8(Title) ); - fputs(Line,rptfile); - fputs("## Unit = inches, Angle = deg.\n",rptfile); + wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + sprintf( Line, "## Created by PcbNew version %s\n", CONV_TO_UTF8( Title ) ); + fputs( Line, rptfile ); + fputs( "## Unit = inches, Angle = deg.\n", rptfile ); - /* Generation lignes utiles du fichier */ - fputs("##\n", rptfile); - fputs("\n$BeginDESCRIPTION\n", rptfile); - - m_Pcb->ComputeBoundaryBox(); - fputs("\n$BOARD\n", rptfile); - fputs("unit INCH\n", rptfile); - sprintf(Line,"upper_left_corner %9.6f %9.6f\n", - (float) m_Pcb->m_BoundaryBox.GetX() * conv_unit, - (float) m_Pcb->m_BoundaryBox.GetY() * conv_unit); - fputs(Line, rptfile); - - sprintf(Line,"lower_right_corner %9.6f %9.6f\n", - (float) (m_Pcb->m_BoundaryBox.GetRight() ) * conv_unit, - (float) (m_Pcb->m_BoundaryBox.GetBottom() ) * conv_unit); - fputs(Line, rptfile); - - fputs("$EndBOARD\n\n", rptfile); + /* Generation lignes utiles du fichier */ + fputs( "##\n", rptfile ); + fputs( "\n$BeginDESCRIPTION\n", rptfile ); - Module = (MODULE*)m_Pcb->m_Modules; - for( ; Module != NULL; Module = Module->Next() ) - { - sprintf(Line,"$MODULE \"%s\"\n", CONV_TO_UTF8(Module->m_Reference->m_Text)); - fputs(Line, rptfile); - - sprintf(Line,"reference \"%s\"\n", CONV_TO_UTF8(Module->m_Reference->m_Text)); - fputs(Line, rptfile); - sprintf(Line,"value \"%s\"\n", CONV_TO_UTF8(Module->m_Value->m_Text)); - fputs(Line, rptfile); - sprintf(Line,"footprint \"%s\"\n", CONV_TO_UTF8(Module->m_LibRef)); - fputs(Line, rptfile); + m_Pcb->ComputeBoundaryBox(); + fputs( "\n$BOARD\n", rptfile ); + fputs( "unit INCH\n", rptfile ); + sprintf( Line, "upper_left_corner %9.6f %9.6f\n", + (float) m_Pcb->m_BoundaryBox.GetX() * conv_unit, + (float) m_Pcb->m_BoundaryBox.GetY() * conv_unit ); + fputs( Line, rptfile ); - msg = wxT("attribut"); - if ( Module->m_Attributs & MOD_VIRTUAL ) msg += wxT(" virtual"); - if ( Module->m_Attributs & MOD_CMS ) msg += wxT(" smd"); - if ( (Module->m_Attributs & (MOD_VIRTUAL|MOD_CMS)) == 0 ) - msg += wxT(" none"); - msg += wxT("\n"); - fputs(CONV_TO_UTF8(msg), rptfile); - - module_pos = Module->m_Pos; - module_pos.x -= File_Place_Offset.x; - module_pos.y -= File_Place_Offset.y; - sprintf( Line, "position %9.6f %9.6f\n", - (float) module_pos.x * conv_unit, - (float) module_pos.y * conv_unit); - fputs(Line, rptfile); + sprintf( Line, "lower_right_corner %9.6f %9.6f\n", + (float) ( m_Pcb->m_BoundaryBox.GetRight() ) * conv_unit, + (float) ( m_Pcb->m_BoundaryBox.GetBottom() ) * conv_unit ); + fputs( Line, rptfile ); - sprintf( Line, "orientation %.2f\n", (float) Module->m_Orient / 10); - if (Module->m_Layer == CMP_N) strcat(Line,"layer component\n"); - else if (Module->m_Layer == CUIVRE_N) strcat(Line,"layer copper\n"); - else strcat(Line,"layer other\n"); - fputs(Line, rptfile); + fputs( "$EndBOARD\n\n", rptfile ); - Module->Write_3D_Descr( rptfile ); - - for ( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) - { - fprintf( rptfile,"$PAD \"%.4s\"\n", pad->m_Padname); - sprintf( Line, "position %9.6f %9.6f\n", - (float) pad->m_Pos0.x * conv_unit, - (float) pad->m_Pos0.y * conv_unit); - fputs(Line, rptfile); + Module = (MODULE*) m_Pcb->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) + { + sprintf( Line, "$MODULE \"%s\"\n", CONV_TO_UTF8( Module->m_Reference->m_Text ) ); + fputs( Line, rptfile ); - sprintf( Line, "size %9.6f %9.6f\n", - (float) pad->m_Size.x * conv_unit, - (float) pad->m_Size.y * conv_unit); - fputs(Line, rptfile); - sprintf( Line, "drill %9.6f\n", (float) pad->m_Drill.x * conv_unit); - fputs(Line, rptfile); - sprintf( Line, "shape_offset %9.6f %9.6f\n", - (float) pad->m_Offset.x * conv_unit, - (float) pad->m_Offset.y * conv_unit); - fputs(Line, rptfile); + sprintf( Line, "reference \"%s\"\n", CONV_TO_UTF8( Module->m_Reference->m_Text ) ); + fputs( Line, rptfile ); + sprintf( Line, "value \"%s\"\n", CONV_TO_UTF8( Module->m_Value->m_Text ) ); + fputs( Line, rptfile ); + sprintf( Line, "footprint \"%s\"\n", CONV_TO_UTF8( Module->m_LibRef ) ); + fputs( Line, rptfile ); - sprintf( Line, "orientation %.2f\n", (float) (pad->m_Orient - Module->m_Orient) / 10); - fputs(Line, rptfile); -char *shape_name[6] = {"??? ","Circ","Rect","Oval","trap","spec"} ; - sprintf( Line, "Shape %s\n", shape_name[pad->m_PadShape]); - fputs(Line, rptfile); + msg = wxT( "attribut" ); + if( Module->m_Attributs & MOD_VIRTUAL ) + msg += wxT( " virtual" ); + if( Module->m_Attributs & MOD_CMS ) + msg += wxT( " smd" ); + if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 ) + msg += wxT( " none" ); + msg += wxT( "\n" ); + fputs( CONV_TO_UTF8( msg ), rptfile ); - int layer = 0; - if(pad->m_Masque_Layer & CUIVRE_LAYER) layer = 1; - if(pad->m_Masque_Layer & CMP_LAYER) layer |= 2; -char *layer_name[4] = {"??? ","copper","component","all"} ; - sprintf( Line, "Layer %s\n", layer_name[layer]); - fputs(Line, rptfile); - fprintf( rptfile,"$EndPAD\n"); - } - - fprintf( rptfile,"$EndMODULE %s\n\n", (const char*) Module->m_Reference->m_Text.GetData() ); - } + module_pos = Module->m_Pos; + module_pos.x -= File_Place_Offset.x; + module_pos.y -= File_Place_Offset.y; + sprintf( Line, "position %9.6f %9.6f\n", + (float) module_pos.x * conv_unit, + (float) module_pos.y * conv_unit ); + fputs( Line, rptfile ); - /* Write board Edges */ -EDA_BaseStruct * PtStruct; - for ( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) - { - if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; - if( ((DRAWSEGMENT *) PtStruct)->m_Layer != EDGE_N ) continue; - WriteDrawSegmentPcb( (DRAWSEGMENT *) PtStruct, rptfile); - } - - /* Generation fin du fichier */ - fputs("$EndDESCRIPTION\n", rptfile); - fclose(rptfile); - setlocale(LC_NUMERIC, ""); // revert to the current locale + sprintf( Line, "orientation %.2f\n", (float) Module->m_Orient / 10 ); + if( Module->GetLayer() == CMP_N ) + strcat( Line, "layer component\n" ); + else if( Module->GetLayer() == CUIVRE_N ) + strcat( Line, "layer copper\n" ); + else + strcat( Line, "layer other\n" ); + fputs( Line, rptfile ); + + Module->Write_3D_Descr( rptfile ); + + for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) + { + fprintf( rptfile, "$PAD \"%.4s\"\n", pad->m_Padname ); + sprintf( Line, "position %9.6f %9.6f\n", + (float) pad->m_Pos0.x * conv_unit, + (float) pad->m_Pos0.y * conv_unit ); + fputs( Line, rptfile ); + + sprintf( Line, "size %9.6f %9.6f\n", + (float) pad->m_Size.x * conv_unit, + (float) pad->m_Size.y * conv_unit ); + fputs( Line, rptfile ); + sprintf( Line, "drill %9.6f\n", (float) pad->m_Drill.x * conv_unit ); + fputs( Line, rptfile ); + sprintf( Line, "shape_offset %9.6f %9.6f\n", + (float) pad->m_Offset.x * conv_unit, + (float) pad->m_Offset.y * conv_unit ); + fputs( Line, rptfile ); + + sprintf( Line, "orientation %.2f\n", (float) (pad->m_Orient - Module->m_Orient) / 10 ); + fputs( Line, rptfile ); + char* shape_name[6] = { "??? ", "Circ", "Rect", "Oval", "trap", "spec" }; + sprintf( Line, "Shape %s\n", shape_name[pad->m_PadShape] ); + fputs( Line, rptfile ); + + int layer = 0; + if( pad->m_Masque_Layer & CUIVRE_LAYER ) + layer = 1; + if( pad->m_Masque_Layer & CMP_LAYER ) + layer |= 2; + char* layer_name[4] = { "??? ", "copper", "component", "all" }; + sprintf( Line, "Layer %s\n", layer_name[layer] ); + fputs( Line, rptfile ); + fprintf( rptfile, "$EndPAD\n" ); + } + + fprintf( rptfile, "$EndMODULE %s\n\n", + (const char*) Module->m_Reference->m_Text.GetData() ); + } + + /* Write board Edges */ + EDA_BaseStruct* PtStruct; + for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) + continue; + if( ( (DRAWSEGMENT*) PtStruct )->GetLayer() != EDGE_N ) + continue; + WriteDrawSegmentPcb( (DRAWSEGMENT*) PtStruct, rptfile ); + } + + /* Generation fin du fichier */ + fputs( "$EndDESCRIPTION\n", rptfile ); + fclose( rptfile ); + setlocale( LC_NUMERIC, "" ); // revert to the current locale } /*******************************************************************/ -void WriteDrawSegmentPcb(DRAWSEGMENT * PtDrawSegment, FILE * rptfile) +void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) /*******************************************************************/ + /* Sortie dsur rptfile d'un segment type drawing PCB: - Les contours sont de differents type: - segment - cercle - arc -*/ + * Les contours sont de differents type: + * segment + * cercle + * arc + */ { -double conv_unit, ux0, uy0, dx, dy; -double rayon, width; -char Line[1024]; - - /* Calcul des echelles de conversion */ - conv_unit = 0.0001; /* unites = INCHES */ - /* coord de depart */ - ux0 = PtDrawSegment->m_Start.x * conv_unit; - uy0 = PtDrawSegment->m_Start.y * conv_unit; - /* coord d'arrivee */ - dx = PtDrawSegment->m_End.x * conv_unit; - dy = PtDrawSegment->m_End.y * conv_unit; + double conv_unit, ux0, uy0, dx, dy; + double rayon, width; + char Line[1024]; - width = PtDrawSegment->m_Width * conv_unit; + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ + /* coord de depart */ + ux0 = PtDrawSegment->m_Start.x * conv_unit; + uy0 = PtDrawSegment->m_Start.y * conv_unit; + /* coord d'arrivee */ + dx = PtDrawSegment->m_End.x * conv_unit; + dy = PtDrawSegment->m_End.y * conv_unit; - switch (PtDrawSegment->m_Shape) - { - case S_CIRCLE: - rayon = hypot(dx-ux0,dy-uy0); - sprintf(Line,"$CIRCLE \n"); fputs(Line, rptfile); - sprintf( Line, "centre %.6lf %.6lf\n", ux0, uy0); - sprintf( Line, "radius %.6lf\n", rayon); - sprintf( Line, "width %.6lf\n", width); - sprintf(Line,"$EndCIRCLE \n"); - fputs(Line, rptfile); - break; + width = PtDrawSegment->m_Width * conv_unit; - case S_ARC: - { - int endx = PtDrawSegment->m_End.x, endy = PtDrawSegment->m_End.y; - rayon = hypot(dx-ux0,dy-uy0); - RotatePoint(&endx, &endy, PtDrawSegment->m_Start.x, PtDrawSegment->m_Start.y,PtDrawSegment->m_Angle); - sprintf(Line,"$ARC \n"); fputs(Line, rptfile); - sprintf( Line, "centre %.6lf %.6lf\n", ux0, uy0); - sprintf( Line, "start %.6lf %.6lf\n", endx * conv_unit, endy * conv_unit); - sprintf( Line, "end %.6lf %.6lf\n", dx, dy); - sprintf( Line, "width %.6lf\n", width); - sprintf(Line,"$EndARC \n"); - fputs(Line, rptfile); - } - break; + switch( PtDrawSegment->m_Shape ) + { + case S_CIRCLE: + rayon = hypot( dx - ux0, dy - uy0 ); + sprintf( Line, "$CIRCLE \n" ); fputs( Line, rptfile ); + sprintf( Line, "centre %.6lf %.6lf\n", ux0, uy0 ); + sprintf( Line, "radius %.6lf\n", rayon ); + sprintf( Line, "width %.6lf\n", width ); + sprintf( Line, "$EndCIRCLE \n" ); + fputs( Line, rptfile ); + break; - default: - sprintf(Line,"$LINE \n"); - fputs(Line, rptfile); - sprintf( Line, "start %.6lf %.6lf\n", ux0, uy0); - sprintf( Line, "end %.6lf %.6lf\n", dx, dy); - sprintf( Line, "width %.6lf\n", width); - sprintf(Line,"$EndLINE \n"); - fputs(Line, rptfile); - break; - } + case S_ARC: + { + int endx = PtDrawSegment->m_End.x, endy = PtDrawSegment->m_End.y; + rayon = hypot( dx - ux0, dy - uy0 ); + RotatePoint( &endx, + &endy, + PtDrawSegment->m_Start.x, + PtDrawSegment->m_Start.y, + PtDrawSegment->m_Angle ); + sprintf( Line, "$ARC \n" ); fputs( Line, rptfile ); + sprintf( Line, "centre %.6lf %.6lf\n", ux0, uy0 ); + sprintf( Line, "start %.6lf %.6lf\n", endx * conv_unit, endy * conv_unit ); + sprintf( Line, "end %.6lf %.6lf\n", dx, dy ); + sprintf( Line, "width %.6lf\n", width ); + sprintf( Line, "$EndARC \n" ); + fputs( Line, rptfile ); + } + break; + + default: + sprintf( Line, "$LINE \n" ); + fputs( Line, rptfile ); + sprintf( Line, "start %.6lf %.6lf\n", ux0, uy0 ); + sprintf( Line, "end %.6lf %.6lf\n", dx, dy ); + sprintf( Line, "width %.6lf\n", width ); + sprintf( Line, "$EndLINE \n" ); + fputs( Line, rptfile ); + break; + } } - diff --git a/pcbnew/gen_self.h b/pcbnew/gen_self.h index e809bdfef2..246878e4e6 100644 --- a/pcbnew/gen_self.h +++ b/pcbnew/gen_self.h @@ -245,7 +245,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) Mself.m_Size.x = Mself.m_Size.y / 2; // Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle - Mself.rayon = min( Mself.m_Width * 5, Mself.m_Size.x / 4 ); + Mself.rayon = MIN( Mself.m_Width * 5, Mself.m_Size.x / 4 ); /* Calcul des parametres */ for( Mself.nbrin = 2; ; Mself.nbrin++ ) @@ -307,7 +307,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) PtSegm->m_End.x = Mself.m_Start.x; PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta; PtSegm->m_Width = Mself.m_Width; - PtSegm->m_Layer = Module->m_Layer; + PtSegm->SetLayer( Module->GetLayer() ); PtSegm->m_Shape = S_SEGMENT; newedge = new EDGE_MODULE( Module ); @@ -432,7 +432,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x; PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width; - PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->m_Layer]; + PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->GetLayer()]; PtPad->m_Attribut = SMD; PtPad->m_PadShape = CIRCLE; PtPad->m_Rayon = PtPad->m_Size.x / 2; diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index cd4e18dc21..f6150ab260 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -915,7 +915,7 @@ wxString msg; float Xscale = (float) (SheetSize.x - (marge*2)) / dX; float Yscale = (float) (SheetSize.y * 0.6 - (marge*2)) / dY; - scale_x = scale_y = min(Xscale, Yscale); + scale_x = scale_y = MIN(Xscale, Yscale); g_PlotOffset.x = - (SheetSize.x/2) + (int)(BoardCentre.x * scale_x) + marge; diff --git a/pcbnew/graphpcb.cpp b/pcbnew/graphpcb.cpp index d1de395656..bbfe3a1431 100644 --- a/pcbnew/graphpcb.cpp +++ b/pcbnew/graphpcb.cpp @@ -1,8 +1,8 @@ - /* EDITEUR de PCB: AUTOROUTAGE: routines "graphiques" */ - /******************************************************/ +/* EDITEUR de PCB: AUTOROUTAGE: routines "graphiques" */ +/******************************************************/ - /* Fichier BOARD.CC */ +/* Fichier BOARD.CC */ #include "fctsys.h" #include "gr_basic.h" @@ -17,738 +17,899 @@ /* Routines externes */ /* routines internes */ -void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color ); -void DrawSegmentQcq(int ux0,int uy0,int ux1,int uy1,int lg,int layer, - int color, int op_logique); -void DrawHVSegment(int ux0,int uy0,int ux1,int uy1,int demi_largeur,int layer, - int color, int op_logique); +void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color ); +void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, + int color, int op_logique ); +void DrawHVSegment( int ux0, int uy0, int ux1, int uy1, int demi_largeur, int layer, + int color, int op_logique ); -void TraceFilledCercle(BOARD * Pcb, int cx, int cy, int rayon,int masque_layer, - int color, int op_logique); -void TraceCercle(int ux0,int uy0,int ux1,int uy1,int lg,int layer, - int color, int op_logique); +void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, + int color, int op_logique ); +void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, + int color, int op_logique ); -void TraceArc(int ux0,int uy0,int ux1,int uy1,int ArcAngle, int lg,int layer, - int color, int op_logique); +void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer, + int color, int op_logique ); /* Macro d'appel de mise a jour de cellules */ -#define OP_CELL(layer,dy,dx) {if(layer < 0) \ - { \ - WriteCell(dy,dx,BOTTOM,color); \ - if(Nb_Sides) WriteCell(dy,dx,TOP,color);\ - } \ - else { \ - if(layer == Route_Layer_BOTTOM) WriteCell(dy,dx,BOTTOM,color);\ - if(Nb_Sides) \ - if(layer == Route_Layer_TOP) WriteCell(dy,dx,TOP,color);\ - } } +#define OP_CELL( layer, dy, dx ) { if( layer < 0 ) \ + { \ + WriteCell( dy, dx, BOTTOM, color ); \ + if( Nb_Sides ) \ + WriteCell( dy, dx, TOP, color );\ + } \ + else { \ + if( layer == Route_Layer_BOTTOM ) \ + WriteCell( dy, dx, BOTTOM, color );\ + if( Nb_Sides ) \ + if( layer == Route_Layer_TOP ) \ + WriteCell( dy, dx, TOP, color );\ + } } /******************************************************************************/ -void Place_1_Pad_Board(BOARD * Pcb, D_PAD * pt_pad, int color, int marge, int op_logique) +void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logique ) /******************************************************************************/ + /* Initialise a la valeur color, les cellules du Board comprises dans la - surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement - et la demi largeur de la piste - Parametres: - pt_pad : pointeur sur la description du pad - color : masque a ecrire dans les cellules - marge : valeur a ajouter au rayon ou demi cote du pad - op_logique: type d'ecriture dans la cellule ( WRITE, OR ) -*/ + * surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement + * et la demi largeur de la piste + * Parametres: + * pt_pad : pointeur sur la description du pad + * color : masque a ecrire dans les cellules + * marge : valeur a ajouter au rayon ou demi cote du pad + * op_logique: type d'ecriture dans la cellule ( WRITE, OR ) + */ { -int dx , dy; -wxPoint shape_pos = pt_pad->ReturnShapePos();; + int dx, dy; + wxPoint shape_pos = pt_pad->ReturnShapePos();; - dx = pt_pad->m_Size.x / 2 ; dx += marge; + dx = pt_pad->m_Size.x / 2; dx += marge; - if(pt_pad->m_PadShape == CIRCLE) - { - TraceFilledCercle(Pcb, shape_pos.x, shape_pos.y, dx, - pt_pad->m_Masque_Layer, color, op_logique); - return; - } + if( pt_pad->m_PadShape == CIRCLE ) + { + TraceFilledCercle( Pcb, shape_pos.x, shape_pos.y, dx, + pt_pad->m_Masque_Layer, color, op_logique ); + return; + } - dy = pt_pad->m_Size.y / 2; dy += marge; + dy = pt_pad->m_Size.y / 2; dy += marge; - if(pt_pad->m_PadShape == TRAPEZE) - { - dx += abs(pt_pad->m_DeltaSize.y) / 2; - dy += abs(pt_pad->m_DeltaSize.x) / 2; - } + if( pt_pad->m_PadShape == TRAPEZE ) + { + dx += abs( pt_pad->m_DeltaSize.y ) / 2; + dy += abs( pt_pad->m_DeltaSize.x ) / 2; + } - if( (pt_pad->m_Orient % 900) == 0 ) - { /* Le pad est un rectangle horizontal ou vertical */ + if( (pt_pad->m_Orient % 900) == 0 ) + { /* Le pad est un rectangle horizontal ou vertical */ + if( (pt_pad->m_Orient == 900 ) || (pt_pad->m_Orient == 2700) ) + { /* orient tournee de 90 deg */ + EXCHG( dx, dy ); + } - if ( (pt_pad->m_Orient == 900 ) || (pt_pad->m_Orient == 2700) ) - { /* orient tournee de 90 deg */ - EXCHG(dx, dy) ; - } - - TraceFilledRectangle(Pcb, shape_pos.x - dx, shape_pos.y - dy, - shape_pos.x + dx, shape_pos.y + dy, - pt_pad->m_Masque_Layer, color, op_logique); - } - - else - { - TraceFilledRectangle(Pcb, shape_pos.x - dx, shape_pos.y - dy, - shape_pos.x + dx, shape_pos.y + dy, - (int) pt_pad->m_Orient, - pt_pad->m_Masque_Layer, color, op_logique); - } + TraceFilledRectangle( Pcb, shape_pos.x - dx, shape_pos.y - dy, + shape_pos.x + dx, shape_pos.y + dy, + pt_pad->m_Masque_Layer, color, op_logique ); + } + else + { + TraceFilledRectangle( Pcb, shape_pos.x - dx, shape_pos.y - dy, + shape_pos.x + dx, shape_pos.y + dy, + (int) pt_pad->m_Orient, + pt_pad->m_Masque_Layer, color, op_logique ); + } } /************************************************************************/ -void TraceFilledCercle(BOARD * Pcb, int cx, int cy, int rayon,int masque_layer, - int color, int op_logique) +void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, + int color, int op_logique ) /************************************************************************/ + /* Initialise a la valeur color, les cellules du Board comprises dans la - surface du cercle de centre cx,cy. - Parametres: - rayon : valeur a ajouter au rayon ou demi cote du pad - masque_layer = couches occupees - color : masque a ecrire dans les cellules - op_logique: type d'ecriture dans la cellule ( WRITE, OR ) -*/ + * surface du cercle de centre cx,cy. + * Parametres: + * rayon : valeur a ajouter au rayon ou demi cote du pad + * masque_layer = couches occupees + * color : masque a ecrire dans les cellules + * op_logique: type d'ecriture dans la cellule ( WRITE, OR ) + */ { -int row, col; -int ux0 , uy0 , ux1, uy1; -int row_max, col_max, row_min, col_min; -int trace = 0; -float fdistmin, fdistx, fdisty; -void (*WriteCell)(int,int,int,BoardCell); -int tstwrite = 0; -int distmin; + int row, col; + int ux0, uy0, ux1, uy1; + int row_max, col_max, row_min, col_min; + int trace = 0; + float fdistmin, fdistx, fdisty; - /* Determination des couches occupees : */ + void (*WriteCell)( int, int, int, BoardCell ); + int tstwrite = 0; + int distmin; - /* routage sur 1 seule couche: - sur bitmap BOTTOM et Route_Layer_B = Route_Layer_A*/ + /* Determination des couches occupees : */ - if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) - trace = 1; /* Trace sur BOTTOM */ + /* routage sur 1 seule couche: + * sur bitmap BOTTOM et Route_Layer_B = Route_Layer_A*/ - if(masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) - if(Nb_Sides) - trace |= 2; /* Trace sur TOP */ + if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + trace = 1; /* Trace sur BOTTOM */ - if( trace == 0) return; + if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) + if( Nb_Sides ) + trace |= 2;/* Trace sur TOP */ - switch(op_logique) - { - default: - case WRITE_CELL: WriteCell = SetCell; break; - case WRITE_OR_CELL: WriteCell = OrCell; break; - case WRITE_XOR_CELL: WriteCell = XorCell; break; - case WRITE_AND_CELL: WriteCell = AndCell; break; - case WRITE_ADD_CELL: WriteCell = AddCell; break; - } + if( trace == 0 ) + return; - cx -= Pcb->m_BoundaryBox.m_Pos.x; cy -= Pcb->m_BoundaryBox.m_Pos.y; + switch( op_logique ) + { + default: + case WRITE_CELL: + WriteCell = SetCell; break; - distmin = rayon ; + case WRITE_OR_CELL: + WriteCell = OrCell; break; - /* Calcul du rectangle d'encadrement du cercle*/ - ux0 = cx - rayon; uy0 = cy - rayon; - ux1 = cx + rayon; uy1 = cy + rayon; + case WRITE_XOR_CELL: + WriteCell = XorCell; break; - /* Calcul des coord limites des cellules appartenant au rectangle */ - row_max = uy1 / g_GridRoutingSize; - col_max = ux1 / g_GridRoutingSize; - row_min = uy0 / g_GridRoutingSize;// if (uy0 > row_min*g_GridRoutingSize ) row_min++; - col_min = ux0 / g_GridRoutingSize;// if (ux0 > col_min*g_GridRoutingSize ) col_min++; + case WRITE_AND_CELL: + WriteCell = AndCell; break; - if( row_min < 0 ) row_min = 0; - if( row_max >= (Nrows-1)) row_max = Nrows-1; - if( col_min < 0 ) col_min = 0; - if( col_max >= (Ncols-1)) col_max = Ncols-1; + case WRITE_ADD_CELL: + WriteCell = AddCell; break; + } - /* On s'assure que l'on place toujours au moins une cellule */ - if( row_min > row_max ) row_max = row_min; - if( col_min > col_max ) col_max = col_min; + cx -= Pcb->m_BoundaryBox.m_Pos.x; cy -= Pcb->m_BoundaryBox.m_Pos.y; - fdistmin = (float)distmin*distmin; + distmin = rayon; - for( row = row_min ;row <= row_max ; row++) - { - fdisty = (float)(cy - (row * g_GridRoutingSize)); - fdisty *= fdisty; - for(col = col_min; col <= col_max; col++) - { - fdistx = (float)(cx - (col * g_GridRoutingSize) ); - fdistx *= fdistx; + /* Calcul du rectangle d'encadrement du cercle*/ + ux0 = cx - rayon; uy0 = cy - rayon; + ux1 = cx + rayon; uy1 = cy + rayon; - if( fdistmin <= (fdistx + fdisty) ) continue; + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize; // if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = ux0 / g_GridRoutingSize; // if (ux0 > col_min*g_GridRoutingSize ) col_min++; - if(trace & 1) WriteCell(row,col,BOTTOM,color); - if(trace & 2) WriteCell(row,col,TOP,color); - tstwrite = 1; - } - } + if( row_min < 0 ) + row_min = 0; + if( row_max >= (Nrows - 1) ) + row_max = Nrows - 1; + if( col_min < 0 ) + col_min = 0; + if( col_max >= (Ncols - 1) ) + col_max = Ncols - 1; -if (tstwrite) return; + /* On s'assure que l'on place toujours au moins une cellule */ + if( row_min > row_max ) + row_max = row_min; + if( col_min > col_max ) + col_max = col_min; - /* Si aucune cellule n'a ete ecrite, on touche les 4 voisins diagonaux - (cas defavorable: pad hors grille, au centre des 4 voisins diagonaux) */ + fdistmin = (float) distmin * distmin; - distmin = g_GridRoutingSize/2 +1; - fdistmin = ((float)distmin*distmin) * 2; /* = dist centre au point diagonal*/ + for( row = row_min; row <= row_max; row++ ) + { + fdisty = (float) ( cy - (row * g_GridRoutingSize) ); + fdisty *= fdisty; + for( col = col_min; col <= col_max; col++ ) + { + fdistx = (float) ( cx - (col * g_GridRoutingSize) ); + fdistx *= fdistx; - for( row = row_min ;row <= row_max ; row++) - { - fdisty = (float)(cy - (row * g_GridRoutingSize)); - fdisty *= fdisty; - for(col = col_min; col <= col_max; col++) - { - fdistx = (float)(cx - (col * g_GridRoutingSize) ); - fdistx *= fdistx; + if( fdistmin <= (fdistx + fdisty) ) + continue; - if( fdistmin <= (fdistx + fdisty) ) continue; + if( trace & 1 ) + WriteCell( row, col, BOTTOM, color ); + if( trace & 2 ) + WriteCell( row, col, TOP, color ); + tstwrite = 1; + } + } - if(trace & 1) WriteCell(row,col,BOTTOM,color); - if(trace & 2) WriteCell(row,col,TOP,color); - } - } + if( tstwrite ) + return; + + /* Si aucune cellule n'a ete ecrite, on touche les 4 voisins diagonaux + * (cas defavorable: pad hors grille, au centre des 4 voisins diagonaux) */ + + distmin = g_GridRoutingSize / 2 + 1; + fdistmin = ( (float) distmin * distmin ) * 2; /* = dist centre au point diagonal*/ + + for( row = row_min; row <= row_max; row++ ) + { + fdisty = (float) ( cy - (row * g_GridRoutingSize) ); + fdisty *= fdisty; + for( col = col_min; col <= col_max; col++ ) + { + fdistx = (float) ( cx - (col * g_GridRoutingSize) ); + fdistx *= fdistx; + + if( fdistmin <= (fdistx + fdisty) ) + continue; + + if( trace & 1 ) + WriteCell( row, col, BOTTOM, color ); + if( trace & 2 ) + WriteCell( row, col, TOP, color ); + } + } } +/******************************************************************************/ +void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_logique ) +/******************************************************************************/ -/******************************************************************************/ -void TraceSegmentPcb(BOARD * Pcb, TRACK* pt_segm, int color, int marge, int op_logique ) -/******************************************************************************/ /* trace un Segment de piste sur le BOARD de routage -*/ + */ { -int demi_pas, demi_largeur; -int ux0 , uy0 , ux1, uy1; -int layer = pt_segm->m_Layer; + int demi_pas, demi_largeur; + int ux0, uy0, ux1, uy1; + int layer = pt_segm->GetLayer(); - demi_pas = g_GridRoutingSize / 2; - demi_largeur = (pt_segm->m_Width / 2) + marge; - /* Calcul du rectangle d'encadrement du segment ( si H,V ou Via) */ - ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x; - uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y; - ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x; - uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y; + demi_pas = g_GridRoutingSize / 2; + demi_largeur = (pt_segm->m_Width / 2) + marge; + /* Calcul du rectangle d'encadrement du segment ( si H,V ou Via) */ + ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x; + uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y; + ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x; + uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y; - if ( color == VIA_IMPOSSIBLE ) layer = -1; + if( color == VIA_IMPOSSIBLE ) + layer = -1; - /* Test si VIA (cercle plein a tracer) */ - if(pt_segm->m_StructType == TYPEVIA ) - { - TraceFilledCercle(Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, - 0x0000FFFF, color, op_logique); - return; - } + /* Test si VIA (cercle plein a tracer) */ + if( pt_segm->m_StructType == TYPEVIA ) + { + TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, + 0x0000FFFF, color, op_logique ); + return; + } - /* Le segment est ici un segment de droite ou un cercle ou un arc: */ - if( pt_segm->m_Shape == S_CIRCLE ) - { - TraceCercle(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); - return; - } + /* Le segment est ici un segment de droite ou un cercle ou un arc: */ + if( pt_segm->m_Shape == S_CIRCLE ) + { + TraceCercle( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); + return; + } - if( pt_segm->m_Shape == S_ARC ) - { - TraceArc(ux0,uy0,ux1,uy1,pt_segm->m_Param,demi_largeur,layer,color,op_logique); - return; - } + if( pt_segm->m_Shape == S_ARC ) + { + TraceArc( ux0, uy0, ux1, uy1, pt_segm->m_Param, demi_largeur, layer, color, op_logique ); + return; + } - /* Le segment est ici un segment de droite */ - if( (ux0 != ux1) && (uy0 != uy1) ) // segment incline - { - DrawSegmentQcq(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); - return; - } - - // Ici le segment est HORIZONTAL ou VERTICAL + /* Le segment est ici un segment de droite */ + if( (ux0 != ux1) && (uy0 != uy1) ) // segment incline + { + DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); + return; + } + + // Ici le segment est HORIZONTAL ou VERTICAL // DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); //F4EXB 051018-01 - DrawSegmentQcq(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); //F4EXB 051018-01 - return; //F4EXB 051018-01 - + DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); //F4EXB 051018-01 + return; //F4EXB 051018-01 } /******************************************************************************************/ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op_logique ) /******************************************************************************************/ + /* trace une ligne; si layer = -1 sur toutes les couches -*/ + */ { -int dx, dy , lim; -int cumul, inc, il, delta; -void (*WriteCell)(int,int,int,BoardCell); + int dx, dy, lim; + int cumul, inc, il, delta; - switch(op_logique) - { - default: - case WRITE_CELL: WriteCell = SetCell; break; - case WRITE_OR_CELL: WriteCell = OrCell; break; - case WRITE_XOR_CELL: WriteCell = XorCell; break; - case WRITE_AND_CELL: WriteCell = AndCell; break; - case WRITE_ADD_CELL: WriteCell = AddCell; break; - } + void (*WriteCell)( int, int, int, BoardCell ); - if( x0 == x1 ) // ligne verticale - { - if(y1 < y0 ) EXCHG (y0,y1); - dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize ; - dx = x0 / g_GridRoutingSize; - /* Clipping aux limites du board */ - if( (dx < 0) || (dx >= Ncols) ) return; - if( dy < 0 ) dy = 0; - if( lim >= Nrows ) lim = Nrows-1; - for( ; dy <= lim ; dy ++ ) - { - OP_CELL(layer,dy,dx); - } - return; - } + switch( op_logique ) + { + default: + case WRITE_CELL: + WriteCell = SetCell; break; - if( y0 == y1 ) // ligne horizontale - { - if(x1 < x0 ) EXCHG (x0,x1); - dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize ; - dy = y0 / g_GridRoutingSize; - /* Clipping aux limites du board */ - if( (dy < 0) || (dy >= Nrows) ) return; - if( dx < 0 ) dx = 0; - if( lim >= Ncols ) lim = Ncols-1; - for( ; dx <= lim ; dx ++ ) - { - OP_CELL(layer,dy,dx); - } - return; - } + case WRITE_OR_CELL: + WriteCell = OrCell; break; - /* Ici l'angle est quelconque: on utilise l'algorithme de LUCAS */ - if ( abs(x1-x0) >= abs(y1-y0) ) /* segment peu incline */ - { - if(x1 < x0) {EXCHG(x1,x0); EXCHG(y1,y0) ;} + case WRITE_XOR_CELL: + WriteCell = XorCell; break; - dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize ; - dy = y0 / g_GridRoutingSize; - inc = 1; if( y1 < y0) inc = -1; - il = lim - dx; cumul = il / 2; delta = abs(y1 - y0)/g_GridRoutingSize; - for( ; dx <= lim ; ) - { - if( (dx >= 0) && (dy >= 0) && - (dx < Ncols) && (dy < Nrows) ) - { - OP_CELL(layer,dy,dx); - } - dx++; cumul += delta ; - if(cumul > il ) - { - cumul -= il; dy += inc; - } - } - } - else - { - if(y1 < y0) {EXCHG(x1,x0); EXCHG(y1,y0) ;} + case WRITE_AND_CELL: + WriteCell = AndCell; break; - dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize ; - dx = x0 / g_GridRoutingSize; - inc = 1; if( x1 < x0) inc = -1; - il = lim - dy; cumul = il /2; delta = abs(x1 - x0)/g_GridRoutingSize; - for( ; dy <= lim ; ) - { - if( (dx >= 0) && (dy >= 0) && - (dx < Ncols) && (dy < Nrows) ) - { - OP_CELL(layer,dy,dx); - } - dy++; cumul += delta ; - if(cumul > il ) - { - cumul -= il; dx += inc; - } - } - } + case WRITE_ADD_CELL: + WriteCell = AddCell; break; + } + + if( x0 == x1 ) // ligne verticale + { + if( y1 < y0 ) + EXCHG( y0, y1 ); + dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize; + dx = x0 / g_GridRoutingSize; + /* Clipping aux limites du board */ + if( (dx < 0) || (dx >= Ncols) ) + return; + if( dy < 0 ) + dy = 0; + if( lim >= Nrows ) + lim = Nrows - 1; + for( ; dy <= lim; dy++ ) + { + OP_CELL( layer, dy, dx ); + } + + return; + } + + if( y0 == y1 ) // ligne horizontale + { + if( x1 < x0 ) + EXCHG( x0, x1 ); + dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize; + dy = y0 / g_GridRoutingSize; + /* Clipping aux limites du board */ + if( (dy < 0) || (dy >= Nrows) ) + return; + if( dx < 0 ) + dx = 0; + if( lim >= Ncols ) + lim = Ncols - 1; + for( ; dx <= lim; dx++ ) + { + OP_CELL( layer, dy, dx ); + } + + return; + } + + /* Ici l'angle est quelconque: on utilise l'algorithme de LUCAS */ + if( abs( x1 - x0 ) >= abs( y1 - y0 ) ) /* segment peu incline */ + { + if( x1 < x0 ) + { + EXCHG( x1, x0 ); EXCHG( y1, y0 ); + } + + dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize; + dy = y0 / g_GridRoutingSize; + inc = 1; if( y1 < y0 ) + inc = -1; + il = lim - dx; cumul = il / 2; delta = abs( y1 - y0 ) / g_GridRoutingSize; + for( ; dx <= lim; ) + { + if( (dx >= 0) && (dy >= 0) + && (dx < Ncols) && (dy < Nrows) ) + { + OP_CELL( layer, dy, dx ); + } + dx++; cumul += delta; + if( cumul > il ) + { + cumul -= il; dy += inc; + } + } + } + else + { + if( y1 < y0 ) + { + EXCHG( x1, x0 ); EXCHG( y1, y0 ); + } + + dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize; + dx = x0 / g_GridRoutingSize; + inc = 1; if( x1 < x0 ) + inc = -1; + il = lim - dy; cumul = il / 2; delta = abs( x1 - x0 ) / g_GridRoutingSize; + for( ; dy <= lim; ) + { + if( (dx >= 0) && (dy >= 0) + && (dx < Ncols) && (dy < Nrows) ) + { + OP_CELL( layer, dy, dx ); + } + dy++; cumul += delta; + if( cumul > il ) + { + cumul -= il; dx += inc; + } + } + } } + /*****************************************************************/ -void TraceFilledRectangle(BOARD * Pcb, - int ux0, int uy0, int ux1, int uy1, - int masque_layer, int color, int op_logique) +void TraceFilledRectangle( BOARD* Pcb, + int ux0, int uy0, int ux1, int uy1, + int masque_layer, int color, int op_logique ) /*****************************************************************/ + /* Fonction Surchargee. - - Met a la valeur color l'ensemble des cellules du board inscrites dans - le rectangle de coord ux0,uy0 ( angle haut a gauche ) - a ux1,uy1 ( angle bas a droite ) - Le rectangle est horizontal ( ou vertical ) - Coordonnees PCB. -*/ + * + * Met a la valeur color l'ensemble des cellules du board inscrites dans + * le rectangle de coord ux0,uy0 ( angle haut a gauche ) + * a ux1,uy1 ( angle bas a droite ) + * Le rectangle est horizontal ( ou vertical ) + * Coordonnees PCB. + */ { -int row, col; -int row_min, row_max, col_min, col_max; -int trace = 0; -void (*WriteCell)(int,int,int,BoardCell); + int row, col; + int row_min, row_max, col_min, col_max; + int trace = 0; - if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) - trace = 1; /* Trace sur BOTTOM */ + void (*WriteCell)( int, int, int, BoardCell ); - if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides) - trace |= 2; /* Trace sur TOP */ + if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + trace = 1; /* Trace sur BOTTOM */ - if(trace == 0) return; + if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides ) + trace |= 2; /* Trace sur TOP */ - switch(op_logique) - { - default: - case WRITE_CELL: WriteCell = SetCell; break; - case WRITE_OR_CELL: WriteCell = OrCell; break; - case WRITE_XOR_CELL: WriteCell = XorCell; break; - case WRITE_AND_CELL: WriteCell = AndCell; break; - case WRITE_ADD_CELL: WriteCell = AddCell; break; - } + if( trace == 0 ) + return; - ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; - ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + switch( op_logique ) + { + default: + case WRITE_CELL: + WriteCell = SetCell; break; - /* Calcul des coord limites des cellules appartenant au rectangle */ - row_max = uy1 / g_GridRoutingSize; - col_max = ux1 / g_GridRoutingSize; - row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; - col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + case WRITE_OR_CELL: + WriteCell = OrCell; break; - if( row_min < 0 ) row_min = 0; - if( row_max >= (Nrows-1)) row_max = Nrows-1; - if( col_min < 0 ) col_min = 0; - if( col_max >= (Ncols-1)) col_max = Ncols-1; + case WRITE_XOR_CELL: + WriteCell = XorCell; break; - for( row = row_min ;row <= row_max ; row++) - { - for(col = col_min;col <= col_max; col++) - { - if(trace & 1) WriteCell(row,col,BOTTOM,color); - if(trace & 2) WriteCell(row,col,TOP,color); - } - } + case WRITE_AND_CELL: + WriteCell = AndCell; break; + + case WRITE_ADD_CELL: + WriteCell = AddCell; break; + } + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize ) + row_min++; + col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize ) + col_min++; + + if( row_min < 0 ) + row_min = 0; + if( row_max >= (Nrows - 1) ) + row_max = Nrows - 1; + if( col_min < 0 ) + col_min = 0; + if( col_max >= (Ncols - 1) ) + col_max = Ncols - 1; + + for( row = row_min; row <= row_max; row++ ) + { + for( col = col_min; col <= col_max; col++ ) + { + if( trace & 1 ) + WriteCell( row, col, BOTTOM, color ); + if( trace & 2 ) + WriteCell( row, col, TOP, color ); + } + } } /***********************************************************************************/ -void TraceFilledRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, int angle, - int masque_layer, int color, int op_logique) +void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int angle, + int masque_layer, int color, int op_logique ) /***********************************************************************************/ /* Fonction Surchargee. - - Met a la valeur color l'ensemble des cellules du board inscrites dans - le rectangle de coord ux0,uy0 ( angle haut a droite ) - a ux1,uy1 ( angle bas a gauche ) - Le rectangle est tourne de la valeur angle (en 0,1 degres) - Coordonnees PCB. -*/ + * + * Met a la valeur color l'ensemble des cellules du board inscrites dans + * le rectangle de coord ux0,uy0 ( angle haut a droite ) + * a ux1,uy1 ( angle bas a gauche ) + * Le rectangle est tourne de la valeur angle (en 0,1 degres) + * Coordonnees PCB. + */ { -int row, col; -int cx, cy; /* Centre du rectangle */ -int rayon; /* rayon du cercle exinscrit */ -int row_min, row_max, col_min, col_max; -int rotrow, rotcol; -int trace = 0; -void (*WriteCell)(int,int,int,BoardCell); + int row, col; + int cx, cy; /* Centre du rectangle */ + int rayon; /* rayon du cercle exinscrit */ + int row_min, row_max, col_min, col_max; + int rotrow, rotcol; + int trace = 0; - if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) - trace = 1; /* Trace sur BOTTOM */ + void (*WriteCell)( int, int, int, BoardCell ); - if(masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) - if(Nb_Sides) - trace |= 2; /* Trace sur TOP */ + if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + trace = 1; /* Trace sur BOTTOM */ - if(trace == 0) return; + if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) + if( Nb_Sides ) + trace |= 2;/* Trace sur TOP */ - switch(op_logique) - { - default: - case WRITE_CELL: WriteCell = SetCell; break; - case WRITE_OR_CELL: WriteCell = OrCell; break; - case WRITE_XOR_CELL: WriteCell = XorCell; break; - case WRITE_AND_CELL: WriteCell = AndCell; break; - case WRITE_ADD_CELL: WriteCell = AddCell; break; - } + if( trace == 0 ) + return; - ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; - ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + switch( op_logique ) + { + default: + case WRITE_CELL: + WriteCell = SetCell; break; - cx = (ux0 + ux1) / 2; cy = (uy0 + uy1) / 2; - rayon = (int) sqrt( (float)(cx - ux0) * (cx - ux0) - + (float)(cy - uy0) * (cy - uy0) ); + case WRITE_OR_CELL: + WriteCell = OrCell; break; - /* Calcul des coord limites des cellules appartenant au rectangle */ - row_max = (cy + rayon) / g_GridRoutingSize; - col_max = (cx + rayon) / g_GridRoutingSize; - row_min = (cy - rayon) / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; - col_min = (cx - rayon) / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + case WRITE_XOR_CELL: + WriteCell = XorCell; break; - if( row_min < 0 ) row_min = 0; - if( row_max >= (Nrows-1)) row_max = Nrows-1; - if( col_min < 0 ) col_min = 0; - if( col_max >= (Ncols-1)) col_max = Ncols-1; + case WRITE_AND_CELL: + WriteCell = AndCell; break; - for( row = row_min ;row <= row_max ; row++) - { - for(col = col_min;col <= col_max; col++) - { - rotrow = row * g_GridRoutingSize; rotcol = col * g_GridRoutingSize; - RotatePoint(&rotcol, &rotrow, cx, cy, - angle); - if( rotrow <= uy0 ) continue; - if( rotrow >= uy1 ) continue; - if( rotcol <= ux0 ) continue; - if( rotcol >= ux1 ) continue; - if(trace & 1) WriteCell(row,col,BOTTOM,color); - if(trace & 2) WriteCell(row,col,TOP,color); - } - } + case WRITE_ADD_CELL: + WriteCell = AddCell; break; + } + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + cx = (ux0 + ux1) / 2; cy = (uy0 + uy1) / 2; + rayon = (int) sqrt( (float) (cx - ux0) * (cx - ux0) + + (float) (cy - uy0) * (cy - uy0) ); + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = (cy + rayon) / g_GridRoutingSize; + col_max = (cx + rayon) / g_GridRoutingSize; + row_min = (cy - rayon) / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize ) + row_min++; + col_min = (cx - rayon) / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize ) + col_min++; + + if( row_min < 0 ) + row_min = 0; + if( row_max >= (Nrows - 1) ) + row_max = Nrows - 1; + if( col_min < 0 ) + col_min = 0; + if( col_max >= (Ncols - 1) ) + col_max = Ncols - 1; + + for( row = row_min; row <= row_max; row++ ) + { + for( col = col_min; col <= col_max; col++ ) + { + rotrow = row * g_GridRoutingSize; rotcol = col * g_GridRoutingSize; + RotatePoint( &rotcol, &rotrow, cx, cy, -angle ); + if( rotrow <= uy0 ) + continue; + if( rotrow >= uy1 ) + continue; + if( rotcol <= ux0 ) + continue; + if( rotcol >= ux1 ) + continue; + if( trace & 1 ) + WriteCell( row, col, BOTTOM, color ); + if( trace & 2 ) + WriteCell( row, col, TOP, color ); + } + } } +/*****************************************************************/ +void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, + int color, int op_logique ) +/*****************************************************************/ -/*****************************************************************/ -void DrawSegmentQcq(int ux0,int uy0,int ux1,int uy1,int lg,int layer, - int color, int op_logique) -/*****************************************************************/ /* Remplit toutes les cellules du BOARD contenues dans le segment - de demi-largeur lg, org ux,y0 fin ux,y1 a la valeur color . - coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. -*/ + * de demi-largeur lg, org ux,y0 fin ux,y1 a la valeur color . + * coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. + */ { -int row, col; -int inc; -int row_max, col_max, row_min, col_min; -int demi_pas; -void (*WriteCell)(int,int,int,BoardCell); -int angle; -int cx, cy, dx, dy; + int row, col; + int inc; + int row_max, col_max, row_min, col_min; + int demi_pas; - switch(op_logique) - { - default: - case WRITE_CELL: WriteCell = SetCell; break; - case WRITE_OR_CELL: WriteCell = OrCell; break; - case WRITE_XOR_CELL: WriteCell = XorCell; break; - case WRITE_AND_CELL: WriteCell = AndCell; break; - case WRITE_ADD_CELL: WriteCell = AddCell; break; - } + void (*WriteCell)( int, int, int, BoardCell ); + int angle; + int cx, cy, dx, dy; - /* on rend la coordonnee ux1 tj > ux0 , pour simplifier les calculs */ - if( ux1 < ux0 ) { EXCHG(ux1,ux0); EXCHG(uy1,uy0);} + switch( op_logique ) + { + default: + case WRITE_CELL: + WriteCell = SetCell; break; - /* calcul de l'increment selon axe Y */ - inc = 1; if(uy1 < uy0) inc = -1; + case WRITE_OR_CELL: + WriteCell = OrCell; break; - /* Calcul de l'encadrement : */ - demi_pas = g_GridRoutingSize/2; + case WRITE_XOR_CELL: + WriteCell = XorCell; break; - col_min = (ux0 - lg) / g_GridRoutingSize; - if (col_min < 0 ) col_min = 0; - col_max = (ux1 + lg + demi_pas) / g_GridRoutingSize; - if (col_max > (Ncols-1) ) col_max = Ncols-1; + case WRITE_AND_CELL: + WriteCell = AndCell; break; - if(inc > 0) - { - row_min = (uy0 - lg) / g_GridRoutingSize; - row_max = (uy1 + lg + demi_pas) / g_GridRoutingSize; - } - else{ - row_min = (uy1 - lg) / g_GridRoutingSize; - row_max = (uy0 + lg + demi_pas) / g_GridRoutingSize; - } + case WRITE_ADD_CELL: + WriteCell = AddCell; break; + } - if (row_min < 0 ) row_min = 0; - if (row_min > (Nrows-1) ) row_min = Nrows-1; - if (row_max < 0 ) row_max = 0; - if (row_max > (Nrows-1) ) row_max = Nrows-1; + /* on rend la coordonnee ux1 tj > ux0 , pour simplifier les calculs */ + if( ux1 < ux0 ) + { + EXCHG( ux1, ux0 ); EXCHG( uy1, uy0 ); + } + + /* calcul de l'increment selon axe Y */ + inc = 1; if( uy1 < uy0 ) + inc = -1; + + /* Calcul de l'encadrement : */ + demi_pas = g_GridRoutingSize / 2; + + col_min = (ux0 - lg) / g_GridRoutingSize; + if( col_min < 0 ) + col_min = 0; + col_max = (ux1 + lg + demi_pas) / g_GridRoutingSize; + if( col_max > (Ncols - 1) ) + col_max = Ncols - 1; + + if( inc > 0 ) + { + row_min = (uy0 - lg) / g_GridRoutingSize; + row_max = (uy1 + lg + demi_pas) / g_GridRoutingSize; + } + else + { + row_min = (uy1 - lg) / g_GridRoutingSize; + row_max = (uy0 + lg + demi_pas) / g_GridRoutingSize; + } + + if( row_min < 0 ) + row_min = 0; + if( row_min > (Nrows - 1) ) + row_min = Nrows - 1; + if( row_max < 0 ) + row_max = 0; + if( row_max > (Nrows - 1) ) + row_max = Nrows - 1; - dx = ux1 - ux0; dy = uy1 - uy0; - if (dx) angle = (int)(atan2(dy,dx) * 1800 / M_PI); - else { angle = 900; if (dy < 0) angle = -900; } + dx = ux1 - ux0; dy = uy1 - uy0; + if( dx ) + angle = (int) (atan2( dy, dx ) * 1800 / M_PI); + else + { + angle = 900; if( dy < 0 ) + angle = -900; + } - RotatePoint(&dx, &dy, angle); /* dx = longueur, dy = 0 */ - for( col = col_min; col <= col_max ; col++ ) - { - int cxr; - cxr = (col * g_GridRoutingSize) - ux0; - for(row = row_min; row <= row_max ; row ++ ) - { - cy = (row * g_GridRoutingSize) - uy0; - cx = cxr; - RotatePoint(&cx, &cy, angle); - if( abs(cy) > lg) continue; /* Le point est trop loin sur l'axe Y */ + RotatePoint( &dx, &dy, angle ); /* dx = longueur, dy = 0 */ + for( col = col_min; col <= col_max; col++ ) + { + int cxr; + cxr = (col * g_GridRoutingSize) - ux0; + for( row = row_min; row <= row_max; row++ ) + { + cy = (row * g_GridRoutingSize) - uy0; + cx = cxr; + RotatePoint( &cx, &cy, angle ); + if( abs( cy ) > lg ) + continue; /* Le point est trop loin sur l'axe Y */ - /* ici le point a tester est proche du segment: la position - selon l'axe X doit etre testee */ - if( (cx >= 0) && (cx <= dx) ) - { - OP_CELL(layer,row,col); - continue; - } - /* examen des extremites qui sont arrondies */ - if( (cx < 0) && (cx >= -lg) ) - { - if( ((cx * cx) + (cy*cy)) <= (lg*lg) ) - OP_CELL(layer,row,col); - continue; - } - if( (cx > dx) && (cx <= (dx+lg)) ) - { - if( (((cx-dx) * (cx-dx)) + (cy*cy)) <= (lg*lg) ) - OP_CELL(layer,row,col); - continue; - } - } - } + /* ici le point a tester est proche du segment: la position + * selon l'axe X doit etre testee */ + if( (cx >= 0) && (cx <= dx) ) + { + OP_CELL( layer, row, col ); + continue; + } + /* examen des extremites qui sont arrondies */ + if( (cx < 0) && (cx >= -lg) ) + { + if( ( (cx * cx) + (cy * cy) ) <= (lg * lg) ) + OP_CELL( layer, row, col ); + continue; + } + if( (cx > dx) && ( cx <= (dx + lg) ) ) + { + if( ( ( (cx - dx) * (cx - dx) ) + (cy * cy) ) <= (lg * lg) ) + OP_CELL( layer, row, col ); + continue; + } + } + } } + /********************************************************************/ -void DrawHVSegment(int ux0,int uy0,int ux1,int uy1,int demi_largeur,int layer, - int color, int op_logique) +void DrawHVSegment( int ux0, int uy0, int ux1, int uy1, int demi_largeur, int layer, + int color, int op_logique ) /********************************************************************/ + /* Draw a horizontal or vertical segment. -same as DrawSegmentQcq, but faster -*/ + * same as DrawSegmentQcq, but faster + */ { -int row, col; -int row_max, col_max, row_min, col_min; -void (*WriteCell)(int,int,int,BoardCell); + int row, col; + int row_max, col_max, row_min, col_min; - switch(op_logique) - { - default: - case WRITE_CELL: WriteCell = SetCell; break; - case WRITE_OR_CELL: WriteCell = OrCell; break; - case WRITE_XOR_CELL: WriteCell = XorCell; break; - case WRITE_AND_CELL: WriteCell = AndCell; break; - case WRITE_ADD_CELL: WriteCell = AddCell; break; - } + void (*WriteCell)( int, int, int, BoardCell ); - // Modif des coord pour que les coord de fin soient > coord de debut - if( uy1 < uy0 ) EXCHG(uy0,uy1) ; // ceci n'est vrai que parce que - if( ux1 < ux0 ) EXCHG(ux0,ux1) ; // dx ou dy ou les 2 sonts nuls + switch( op_logique ) + { + default: + case WRITE_CELL: + WriteCell = SetCell; break; - // Le segment est assimile a un rectangle. - // TODO: traiter correctement les extremites arrondies + case WRITE_OR_CELL: + WriteCell = OrCell; break; + + case WRITE_XOR_CELL: + WriteCell = XorCell; break; + + case WRITE_AND_CELL: + WriteCell = AndCell; break; + + case WRITE_ADD_CELL: + WriteCell = AddCell; break; + } + + // Modif des coord pour que les coord de fin soient > coord de debut + if( uy1 < uy0 ) + EXCHG( uy0, uy1 ); // ceci n'est vrai que parce que + if( ux1 < ux0 ) + EXCHG( ux0, ux1 ); // dx ou dy ou les 2 sonts nuls + + // Le segment est assimile a un rectangle. + // TODO: traiter correctement les extremites arrondies // if ( ux0 == ux1 ) // Vertical Segment - { - ux0 -= demi_largeur; ux1 += demi_largeur; - } + { + ux0 -= demi_largeur; ux1 += demi_largeur; + } + // else // Horizontal segment - { - uy0 -= demi_largeur ;uy1 += demi_largeur; - } + { + uy0 -= demi_largeur; uy1 += demi_largeur; + } - // Calcul des coord limites des cellules appartenant au rectangle - row_max = uy1 / g_GridRoutingSize; - col_max = ux1 / g_GridRoutingSize; + // Calcul des coord limites des cellules appartenant au rectangle + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; - row_min = uy0 / g_GridRoutingSize; - if (uy0 > row_min*g_GridRoutingSize ) row_min++; // Traitement de l'arrondi par defaut + row_min = uy0 / g_GridRoutingSize; + if( uy0 > row_min * g_GridRoutingSize ) + row_min++; // Traitement de l'arrondi par defaut - col_min = ux0 / g_GridRoutingSize; - if (ux0 > col_min*g_GridRoutingSize ) col_min++; + col_min = ux0 / g_GridRoutingSize; + if( ux0 > col_min * g_GridRoutingSize ) + col_min++; - if( row_min < 0 ) row_min = 0; - if( row_max >= (Nrows-1)) row_max = Nrows-1; - if( col_min < 0 ) col_min = 0; - if( col_max >= (Ncols-1)) col_max = Ncols-1; + if( row_min < 0 ) + row_min = 0; + if( row_max >= (Nrows - 1) ) + row_max = Nrows - 1; + if( col_min < 0 ) + col_min = 0; + if( col_max >= (Ncols - 1) ) + col_max = Ncols - 1; - if( row_min > row_max ) row_max = row_min; - if( col_min > col_max ) col_max = col_min; + if( row_min > row_max ) + row_max = row_min; + if( col_min > col_max ) + col_max = col_min; - for( row = row_min ;row <= row_max ; row++) - { - for(col = col_min;col <= col_max; col++) - { - OP_CELL(layer,row,col); - } - } + for( row = row_min; row <= row_max; row++ ) + { + for( col = col_min; col <= col_max; col++ ) + { + OP_CELL( layer, row, col ); + } + } } + /*****************************************************************/ -void TraceCercle(int ux0,int uy0,int ux1,int uy1,int lg,int layer, - int color, int op_logique) +void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, + int color, int op_logique ) /*****************************************************************/ + /* Remplit toutes les cellules du BOARD contenues dans le cercle - de demi-largeur lg, centre ux,y0 passant par ux,y1 a la valeur color . - coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. -*/ + * de demi-largeur lg, centre ux,y0 passant par ux,y1 a la valeur color . + * coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. + */ { -int rayon, nb_segm; -int x0,y0, // Point de depart du segment en cours de trace - x1,y1; // point d'arrivee -int ii; -int angle; + int rayon, nb_segm; + int x0, y0, // Point de depart du segment en cours de trace + x1, y1; // point d'arrivee + int ii; + int angle; - rayon = (int)hypot((double)(ux1-ux0),(double)(uy1-uy0) ); + rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) ); - x0 = x1 = rayon; y0 = y1 = 0; - if( lg < 1 ) lg = 1; - nb_segm = (2 * rayon) / lg; - if(nb_segm < 5) nb_segm = 5; - if(nb_segm > 100) nb_segm = 100; - for( ii = 1 ; ii < nb_segm ; ii++) - { - angle = (3600 * ii) / nb_segm; - x1 = (int)(rayon * fcosinus[angle]); - y1 = (int)(rayon * fsinus[angle]); - DrawSegmentQcq(x0+ux0,y0+uy0, x1+ux0,y1+uy0,lg,layer, color, op_logique); - x0 = x1; y0 = y1; - } + x0 = x1 = rayon; y0 = y1 = 0; + if( lg < 1 ) + lg = 1; + nb_segm = (2 * rayon) / lg; + if( nb_segm < 5 ) + nb_segm = 5; + if( nb_segm > 100 ) + nb_segm = 100; + for( ii = 1; ii < nb_segm; ii++ ) + { + angle = (3600 * ii) / nb_segm; + x1 = (int) (rayon * fcosinus[angle]); + y1 = (int) (rayon * fsinus[angle]); + DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logique ); + x0 = x1; y0 = y1; + } - DrawSegmentQcq(x1+ux0,y1+uy0, ux0+rayon, uy0,lg,layer, color, op_logique); + DrawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + rayon, uy0, lg, layer, color, op_logique ); } + /****************************************************************************/ -void TraceArc(int ux0,int uy0,int ux1,int uy1, int ArcAngle, int lg,int layer, - int color, int op_logique) +void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer, + int color, int op_logique ) /****************************************************************************/ /* Remplit toutes les cellules du BOARD contenues dans l'arc de "longueur" angle - de demi-largeur lg, centre ux,y0 commencant en ux,y1 a la valeur color . - coord en unites PCB (0.1 mil) relatives a l'origine - pt_pcb->m_PcbBox.m_Xmin,Y du board. -*/ + * de demi-largeur lg, centre ux,y0 commencant en ux,y1 a la valeur color . + * coord en unites PCB (0.1 mil) relatives a l'origine + * pt_pcb->m_PcbBox.m_Xmin,Y du board. + */ { -int rayon, nb_segm; -int x0,y0, // Point de depart du segment en cours de trace - x1,y1; // point d'arrivee -int ii; -int angle, StAngle; + int rayon, nb_segm; + int x0, y0, // Point de depart du segment en cours de trace + x1, y1; // point d'arrivee + int ii; + int angle, StAngle; - rayon = (int)hypot((double)(ux1-ux0),(double)(uy1-uy0) ); + rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) ); - x0 = ux1 - ux0; - y0 = uy1 - uy0; - StAngle = ArcTangente(uy1 - uy0, ux1 - ux0); - if( lg < 1 ) lg = 1; - nb_segm = (2 * rayon) / lg; - nb_segm = (nb_segm * abs(ArcAngle)) / 3600; - if(nb_segm < 5) nb_segm = 5; - if(nb_segm > 100) nb_segm = 100; + x0 = ux1 - ux0; + y0 = uy1 - uy0; + StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 ); + if( lg < 1 ) + lg = 1; + nb_segm = (2 * rayon) / lg; + nb_segm = ( nb_segm * abs( ArcAngle ) ) / 3600; + if( nb_segm < 5 ) + nb_segm = 5; + if( nb_segm > 100 ) + nb_segm = 100; - for( ii = 1 ; ii <= nb_segm ; ii++) - { - angle = (ArcAngle * ii) / nb_segm; - angle += StAngle; + for( ii = 1; ii <= nb_segm; ii++ ) + { + angle = (ArcAngle * ii) / nb_segm; + angle += StAngle; - while ( angle >= 3600 ) angle -= 3600; - while ( angle < 0 ) angle += 3600; + while( angle >= 3600 ) + angle -= 3600; - x1 = (int)(rayon * fcosinus[angle]); - y1 = (int)(rayon * fsinus[angle]); - DrawSegmentQcq(x0+ux0,y0+uy0, x1+ux0,y1+uy0,lg,layer, color, op_logique); - x0 = x1; y0 = y1; - } + while( angle < 0 ) + angle += 3600; + + x1 = (int) (rayon * fcosinus[angle]); + y1 = (int) (rayon * fsinus[angle]); + DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logique ); + x0 = x1; y0 = y1; + } // DrawSegmentQcq(x1+ux0,y1+uy0, ux0+rayon, uy0,lg,layer, color, op_logique); } - diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 8aeede0771..64e21d8384 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -229,7 +229,8 @@ void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query ) void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query ) /*****************************************************************************/ { - EDA_BaseStruct* PtStruct, * PtNext; + BOARD_ITEM* PtStruct; + BOARD_ITEM* PtNext; int masque_layer = (~EDGE_LAYER) & 0x1FFF0000; if( is_edges ) @@ -244,30 +245,18 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query ) return; } - PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; + PtStruct = m_Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtNext ) { - PtNext = PtStruct->Pnext; + PtNext = PtStruct->Next(); switch( PtStruct->m_StructType ) { case TYPEDRAWSEGMENT: - if( g_TabOneLayerMask[( (DRAWSEGMENT*) PtStruct )->m_Layer] & masque_layer ) - DeleteStructure( PtStruct ); - break; - case TYPETEXTE: - if( g_TabOneLayerMask[( (TEXTE_PCB*) PtStruct )->m_Layer] & masque_layer ) - DeleteStructure( PtStruct ); - break; - case TYPECOTATION: - if( g_TabOneLayerMask[( (COTATION*) PtStruct )->m_Layer] & masque_layer ) - DeleteStructure( PtStruct ); - break; - case TYPEMIRE: - if( g_TabOneLayerMask[( (MIREPCB*) PtStruct )->m_Layer] & masque_layer ) + if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer ) DeleteStructure( PtStruct ); break; diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 66a0dcfd69..d4f4096128 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -154,7 +154,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, &PtSegm->m_TimeStamp, &flags ); if( type == 1 ) PtSegm->m_StructType = TYPEVIA; - PtSegm->m_Layer = layer; + + PtSegm->SetLayer( layer ); PtSegm->m_NetCode = net_code; PtSegm->SetState( flags, ON ); #ifdef PCBNEW PtSegm->Draw( DrawPanel, DC, GR_OR ); @@ -249,7 +250,7 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( wxDC* DC, FILE* File, int* LineNum screensize = DrawPanel->GetClientSize(); ii = pcbsize.x / screensize.x; jj = pcbsize.y / screensize.y; - bestzoom = max( ii, jj ); + bestzoom = MAX( ii, jj ); screen->m_Curseur = m_Pcb->m_BoundaryBox.Centre(); screen->SetZoom( bestzoom ); @@ -779,7 +780,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append ) char Line[1024]; int LineNum = 0; int nbsegm, nbmod; - EDA_BaseStruct* LastStructPcb = NULL, * StructPcb; + BOARD_ITEM* LastStructPcb = NULL, * StructPcb; MODULE* LastModule = NULL, * Module; EQUIPOT* LastEquipot = NULL, * Equipot; @@ -803,7 +804,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append ) } LastStructPcb = m_Pcb->m_Drawings; - for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Pnext ) + for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Next() ) { if( LastStructPcb->Pnext == NULL ) break; @@ -901,7 +902,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append ) if( strnicmp( Line, "$TEXTPCB", 8 ) == 0 ) { TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_Pcb ); - StructPcb = (EDA_BaseStruct*) pcbtxt; + StructPcb = pcbtxt; pcbtxt->ReadTextePcbDescr( File, &LineNum ); if( LastStructPcb == NULL ) { diff --git a/pcbnew/lay2plot.cpp b/pcbnew/lay2plot.cpp index 6ce820a0a4..af0ddcadbf 100644 --- a/pcbnew/lay2plot.cpp +++ b/pcbnew/lay2plot.cpp @@ -1,6 +1,6 @@ - /**********************************************/ - /* Routine de selection de couches pour trace */ - /**********************************************/ +/**********************************************/ +/* Routine de selection de couches pour trace */ +/**********************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -15,194 +15,211 @@ /* Variables locales : */ /* Routines Locales */ -static void Plot_Module(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, - int draw_mode, int masklayer); +static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, + int draw_mode, int masklayer ); /**********************************************************************************/ -void WinEDA_DrawPanel::PrintPage(wxDC *DC, bool Print_Sheet_Ref, int printmasklayer) +void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmasklayer ) /**********************************************************************************/ + /* Used to print the board. - Draw the board, but only layers allowed by printmasklayer - ( printmasklayer is a 32 bits mask: bit n = 1 -> layer n is printed) -*/ + * Draw the board, but only layers allowed by printmasklayer + * ( printmasklayer is a 32 bits mask: bit n = 1 -> layer n is printed) + */ { -MODULE * Module; -EDA_BaseStruct * PtStruct; -int drawmode = GR_COPY; -DISPLAY_OPTIONS save_opt; -TRACK * pt_piste; -WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame *) m_Parent; -BOARD * Pcb = frame->m_Pcb; + MODULE* Module; + BOARD_ITEM* PtStruct; + int drawmode = GR_COPY; + DISPLAY_OPTIONS save_opt; + TRACK* pt_piste; + WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) m_Parent; + BOARD* Pcb = frame->m_Pcb; - save_opt = DisplayOpt; - if( printmasklayer & ALL_CU_LAYERS ) DisplayOpt.DisplayPadFill = FILLED; - else DisplayOpt.DisplayPadFill = SKETCH; - frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; - frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum = FALSE; - DisplayOpt.DisplayPadNoConn = FALSE; - DisplayOpt.DisplayPadIsol = FALSE; - DisplayOpt.DisplayModEdge = FILLED; - DisplayOpt.DisplayModText = FILLED; - frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = FILLED; - DisplayOpt.DisplayTrackIsol = FALSE; - DisplayOpt.DisplayDrawItems = FILLED; - DisplayOpt.DisplayZones = TRUE; + save_opt = DisplayOpt; + if( printmasklayer & ALL_CU_LAYERS ) + DisplayOpt.DisplayPadFill = FILLED; + else + DisplayOpt.DisplayPadFill = SKETCH; + frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; + frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum = FALSE; + DisplayOpt.DisplayPadNoConn = FALSE; + DisplayOpt.DisplayPadIsol = FALSE; + DisplayOpt.DisplayModEdge = FILLED; + DisplayOpt.DisplayModText = FILLED; + frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = FILLED; + DisplayOpt.DisplayTrackIsol = FALSE; + DisplayOpt.DisplayDrawItems = FILLED; + DisplayOpt.DisplayZones = TRUE; - printmasklayer |= EDGE_LAYER; + printmasklayer |= EDGE_LAYER; - /* Draw the pcb graphic items (texts, ...) */ - PtStruct = Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch(PtStruct->m_StructType) - { - case TYPEDRAWSEGMENT: - if( (g_TabOneLayerMask[((DRAWSEGMENT*)PtStruct)->m_Layer] & printmasklayer) == 0 ) - break; - Trace_DrawSegmentPcb(this, DC, (DRAWSEGMENT*) PtStruct, drawmode); - break; + /* Draw the pcb graphic items (texts, ...) */ + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 ) + break; + Trace_DrawSegmentPcb( this, DC, (DRAWSEGMENT*) PtStruct, drawmode ); + break; - case TYPECOTATION: - if( (g_TabOneLayerMask[((COTATION*)PtStruct)->m_Layer] & printmasklayer) == 0 ) - break; - ((COTATION*) PtStruct)->Draw(this, DC, wxPoint(0,0), drawmode); - break; + case TYPECOTATION: + if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 ) + break; + ( (COTATION*) PtStruct )->Draw( this, DC, wxPoint( 0, 0 ), drawmode ); + break; - case TYPETEXTE: - { - if( (g_TabOneLayerMask[((TEXTE_PCB *)PtStruct)->m_Layer] & printmasklayer) == 0 ) - break; - ((TEXTE_PCB *) PtStruct)->Draw(this, DC, wxPoint(0,0), drawmode); - break; - } + case TYPETEXTE: + { + if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 ) + break; + ( (TEXTE_PCB*) PtStruct )->Draw( this, DC, wxPoint( 0, 0 ), drawmode ); + break; + } - case TYPEMIRE: - if( (g_TabOneLayerMask[((MIREPCB*)PtStruct)->m_Layer] & printmasklayer) == 0 ) break; - ((MIREPCB*) PtStruct)->Draw(this, DC, wxPoint(0,0), drawmode); - break; + case TYPEMIRE: + if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 ) + break; + ( (MIREPCB*) PtStruct )->Draw( this, DC, wxPoint( 0, 0 ), drawmode ); + break; - case TYPEMARQUEUR: /* Trace des marqueurs */ - break; + case TYPEMARQUEUR: /* Trace des marqueurs */ + break; - default: break; - } - } + default: + break; + } + } - /* Draw the tracks */ - pt_piste = Pcb->m_Track; - for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) - { - if( (printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; - if ( pt_piste->m_StructType == TYPEVIA ) /* VIA rencontree */ - { - int rayon = pt_piste->m_Width >> 1; - int color = g_DesignSettings.m_ViaColor[pt_piste->m_Shape]; - GRSetDrawMode(DC, drawmode); - GRFilledCircle(&m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, - rayon, 0, color, color) ; - } - else pt_piste->Draw(this, DC, drawmode); - } + /* Draw the tracks */ + pt_piste = Pcb->m_Track; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) + continue; + if( pt_piste->m_StructType == TYPEVIA ) /* VIA rencontree */ + { + int rayon = pt_piste->m_Width >> 1; + int color = g_DesignSettings.m_ViaColor[pt_piste->m_Shape]; + GRSetDrawMode( DC, drawmode ); + GRFilledCircle( &m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, + rayon, 0, color, color ); + } + else + pt_piste->Draw( this, DC, drawmode ); + } - pt_piste = Pcb->m_Zone; - for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) - { - if( (printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue ; - pt_piste->Draw(this, DC, drawmode); - } + pt_piste = Pcb->m_Zone; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) + continue; + pt_piste->Draw( this, DC, drawmode ); + } - // 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 ) - { - Plot_Module(this, DC, Module, drawmode, printmasklayer); - } + // 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 ) + { + Plot_Module( this, DC, Module, drawmode, printmasklayer ); + } - /* draw the via holes */ - pt_piste = Pcb->m_Track; - int rayon = g_DesignSettings.m_ViaDrill / 2; - int color = WHITE; - for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) - { - if( (printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; - if ( pt_piste->m_StructType == TYPEVIA ) /* VIA rencontree */ - { - GRSetDrawMode(DC, drawmode); - GRFilledCircle(&m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, - rayon, 0, color, color) ; - } - } + /* draw the via holes */ + pt_piste = Pcb->m_Track; + int rayon = g_DesignSettings.m_ViaDrill / 2; + int color = WHITE; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) + continue; + if( pt_piste->m_StructType == TYPEVIA ) /* VIA rencontree */ + { + GRSetDrawMode( DC, drawmode ); + GRFilledCircle( &m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, + rayon, 0, color, color ); + } + } - if ( Print_Sheet_Ref ) - m_Parent->TraceWorkSheet( DC, ActiveScreen, 0); + if( Print_Sheet_Ref ) + m_Parent->TraceWorkSheet( DC, ActiveScreen, 0 ); - DisplayOpt = save_opt; - frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; - frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum; + DisplayOpt = save_opt; + frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; + frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum; } /***********************************************************/ -static void Plot_Module(WinEDA_DrawPanel * panel, wxDC * DC, - MODULE * Module, int draw_mode, int masklayer) +static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC, + MODULE* Module, int draw_mode, int masklayer ) /***********************************************************/ { -D_PAD * pt_pad ; -EDA_BaseStruct * PtStruct; -TEXTE_MODULE * TextMod; -int mlayer; + D_PAD* pt_pad; + EDA_BaseStruct* PtStruct; + TEXTE_MODULE* TextMod; + int mlayer; - /* Draw pads */ - pt_pad = Module->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) - { - if( (pt_pad->m_Masque_Layer & masklayer ) == 0 ) continue; - pt_pad->Draw(panel, DC, wxPoint(0,0), draw_mode); - } + /* Draw pads */ + pt_pad = Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + if( (pt_pad->m_Masque_Layer & masklayer ) == 0 ) + continue; + pt_pad->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode ); + } - /* draw footprint graphic shapes */ - PtStruct = Module->m_Drawings; - mlayer = g_TabOneLayerMask[Module->m_Layer]; - if( Module->m_Layer == CUIVRE_N) mlayer = SILKSCREEN_LAYER_CU; - if( Module->m_Layer == CMP_N) mlayer = SILKSCREEN_LAYER_CMP; - if( mlayer & masklayer ) - { - /* Analyse des autorisations de trace pour les textes VALEUR et REF */ - bool trace_val, trace_ref; - trace_val = trace_ref = TRUE; // les 2 autorisations de tracer sont donnees - if(Module->m_Reference->m_NoShow) trace_ref = FALSE; - if(Module->m_Value->m_NoShow) trace_val = FALSE; + /* draw footprint graphic shapes */ + PtStruct = Module->m_Drawings; + mlayer = g_TabOneLayerMask[Module->GetLayer()]; + if( Module->GetLayer() == CUIVRE_N ) + mlayer = SILKSCREEN_LAYER_CU; + else if( Module->GetLayer() == CMP_N ) + mlayer = SILKSCREEN_LAYER_CMP; + + if( mlayer & masklayer ) + { + /* Analyse des autorisations de trace pour les textes VALEUR et REF */ + bool trace_val, trace_ref; + trace_val = trace_ref = TRUE; // les 2 autorisations de tracer sont donnees + if( Module->m_Reference->m_NoShow ) + trace_ref = FALSE; + if( Module->m_Value->m_NoShow ) + trace_val = FALSE; - if(trace_ref) - Module->m_Reference->Draw(panel, DC, wxPoint(0,0), draw_mode ); - if(trace_val) - Module->m_Value->Draw(panel, DC, wxPoint(0,0), draw_mode ); - } + if( trace_ref ) + Module->m_Reference->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode ); + if( trace_val ) + Module->m_Value->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode ); + } - for( ;PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPETEXTEMODULE: - if( (mlayer & masklayer ) == 0) break; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPETEXTEMODULE: + if( (mlayer & masklayer ) == 0 ) + break; - TextMod = (TEXTE_MODULE *) PtStruct; - TextMod->Draw(panel, DC, wxPoint(0,0), draw_mode ); - break; + TextMod = (TEXTE_MODULE*) PtStruct; + TextMod->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode ); + break; - case TYPEEDGEMODULE: - { - EDGE_MODULE * edge = (EDGE_MODULE *) PtStruct; - if( (g_TabOneLayerMask[edge->m_Layer] & masklayer ) == 0) break; - edge->Draw(panel, DC, wxPoint(0,0), draw_mode); - break; - } - default: break; - } - } + case TYPEEDGEMODULE: + { + EDGE_MODULE* edge = (EDGE_MODULE*) PtStruct; + if( (g_TabOneLayerMask[edge->GetLayer()] & masklayer ) == 0 ) + break; + edge->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode ); + break; + } + + default: + break; + } + } } - - diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index cce0d1f4b0..6aee99a6cd 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -79,7 +79,7 @@ void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module ) m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; Place_Module( Module, NULL ); - if( Module->m_Layer != CMP_N ) + if( Module->GetLayer() != CMP_N ) Change_Side_Module( Module, NULL ); Rotate_Module( NULL, Module, 0, FALSE ); m_CurrentScreen->ClrModify(); diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index a8ed428ec6..6c9ebe82b7 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -169,7 +169,7 @@ EDA_BaseStruct* WinEDA_BasePcbFrame::Locate( int typeloc, int LayerSearch ) MODULE* module = m_Pcb->m_Modules; for( ; module != NULL; module = (MODULE*) module->Pnext ) { - if( module->m_Layer != LayerSearch ) + if( module->GetLayer() != LayerSearch ) continue; item = LocateTexteModule( m_Pcb, &module, typeloc | VISIBLE_ONLY ); @@ -266,7 +266,7 @@ D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr ) MODULE* module; wxPoint ref_pos; - masque_layer = g_TabOneLayerMask[ptr_piste->m_Layer]; + masque_layer = g_TabOneLayerMask[ptr_piste->GetLayer()]; if( extr == START ) { ref_pos = ptr_piste->m_Start; @@ -374,14 +374,14 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ) DRAWSEGMENT* pts = (DRAWSEGMENT*) PtStruct; - if( (pts->m_Layer != LayerSearch) && (LayerSearch != -1) ) + if( (pts->GetLayer() != LayerSearch) && (LayerSearch != -1) ) continue; if( pts->HitTest( ref_pos ) ) { // return this hit if layer matches, else remember in // case no layer match is found. - if( pts->m_Layer == screen->m_Active_Layer ) + if( pts->GetLayer() == screen->m_Active_Layer ) return pts; else if( !locate_segm ) @@ -394,8 +394,8 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ) /************************************************* - * D_PAD * Locate_Any_Pad(int typeloc, bool OnlyCurrentLayer) - * D_PAD* Locate_Any_Pad(int ref_pos, bool OnlyCurrentLayer) + * D_PAD * Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer) + * D_PAD* Locate_Any_Pad( BOARD* Pcb, int ref_pos, bool OnlyCurrentLayer) *************************************************/ /* @@ -522,7 +522,7 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) * d'appartenance du module et a la couche cuivre si le module * est sur couche serigr,adhesive cuivre, a la couche cmp si le module * est sur couche serigr,adhesive composant */ - layer = pt_module->m_Layer; + layer = pt_module->GetLayer(); if( layer==ADHESIVE_N_CU || layer==SILKSCREEN_N_CU ) layer = CUIVRE_N; @@ -538,21 +538,21 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer ) { - if( min( lx, ly ) <= min_dim ) + if( MIN( lx, ly ) <= min_dim ) { /* meilleure empreinte localisee sur couche active */ module = pt_module; - min_dim = min( lx, ly ); + min_dim = MIN( lx, ly ); } } else if( !(typeloc & MATCH_LAYER) && ( !(typeloc & VISIBLE_ONLY) || IsModuleLayerVisible( layer ) ) ) { - if( min( lx, ly ) <= alt_min_dim ) + if( MIN( lx, ly ) <= alt_min_dim ) { /* meilleure empreinte localisee sur autres couches */ Altmodule = pt_module; - alt_min_dim = min( lx, ly ); + alt_min_dim = MIN( lx, ly ); } } } @@ -603,7 +603,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc ) for( ; module != NULL; module = (MODULE*) module->Pnext ) { - int layer = module->m_Layer; + int layer = module->GetLayer(); if( layer==ADHESIVE_N_CU || layer==SILKSCREEN_N_CU ) layer = CUIVRE_N; else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP ) @@ -817,7 +817,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa if( Track->GetState( BUSY | DELETED ) ) continue; - if( (g_DesignSettings.m_LayerColor[Track->m_Layer] & ITEM_NOT_SHOW) ) + if( (g_DesignSettings.m_LayerColor[Track->GetLayer()] & ITEM_NOT_SHOW) ) continue; if( Track->m_StructType == TYPEVIA ) /* VIA rencontree */ @@ -828,7 +828,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa else { if( MasqueLayer != -1 ) - if( (g_TabOneLayerMask[Track->m_Layer] & MasqueLayer) == 0 ) + if( (g_TabOneLayerMask[Track->GetLayer()] & MasqueLayer) == 0 ) continue; /* Segments sur couches differentes */ if( Track->HitTest( ref_pos ) ) @@ -869,7 +869,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ) { for( TRACK* Zone = start_adresse; Zone; Zone = (TRACK*) Zone->Pnext ) { - if( (layer != -1) && (Zone->m_Layer != layer) ) + if( (layer != -1) && (Zone->GetLayer() != layer) ) continue; if( Zone->HitTest( ref_pos ) ) @@ -898,7 +898,7 @@ TEXTE_PCB* Locate_Texte_Pcb( EDA_BaseStruct* PtStruct, int LayerSearch, int type TEXTE_PCB* pt_txt_pcb = (TEXTE_PCB*) PtStruct; - if( pt_txt_pcb->m_Layer == LayerSearch ) + if( pt_txt_pcb->GetLayer() == LayerSearch ) { if( pt_txt_pcb->HitTest( ref ) ) { @@ -1048,7 +1048,7 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, continue; item = (MIREPCB*) PtStruct; - if( LayerSearch != -1 && item->m_Layer != LayerSearch ) + if( LayerSearch != -1 && item->GetLayer() != LayerSearch ) continue; if( item->HitTest( ref_pos ) ) diff --git a/pcbnew/makefile.include b/pcbnew/makefile.include index 7df3a2ef96..20145d66a9 100644 --- a/pcbnew/makefile.include +++ b/pcbnew/makefile.include @@ -101,7 +101,8 @@ OBJECTS= $(TARGET).o classpcb.o\ gen_modules_placefile.o\ modedit.o\ export_gencad.o\ - hotkeys.o + hotkeys.o \ + collectors.o setpage.o: ../share/setpage.cpp $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp @@ -289,3 +290,4 @@ dragsegm.o: dragsegm.cpp drag.h $(COMMON) router.o: router.cpp $(COMMON) +collectors.o: collectors.cpp collectors.h $(COMMON) diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 177dd35688..0b093bf671 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -218,7 +218,7 @@ MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC ) m_Pcb->m_Drawings->Pback = MirePcb; m_Pcb->m_Drawings = MirePcb; - MirePcb->m_Layer = EDGE_N; + MirePcb->SetLayer( EDGE_N ); MirePcb->m_Width = g_DesignSettings.m_EdgeSegmentWidth; MirePcb->m_Size = MireDefaultSize; MirePcb->m_Pos = GetScreen()->m_Curseur; diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index faeb8478f8..59b12381f2 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -104,7 +104,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; module->m_Flags |= IS_MOVED; ModuleInitOrient = module->m_Orient; - ModuleInitLayer = module->m_Layer; + ModuleInitLayer = module->GetLayer(); /* Effacement chevelu general si necessaire */ if( g_Show_Ratsnest ) @@ -192,7 +192,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) { if( ModuleInitOrient != module->m_Orient ) pcbframe->Rotate_Module( NULL, module, ModuleInitOrient, FALSE ); - if( ModuleInitLayer != module->m_Layer ) + if( ModuleInitLayer != module->GetLayer() ) pcbframe->Change_Side_Module( module, NULL ); module->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); } @@ -337,7 +337,7 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) if( Module == NULL ) return; - if( (Module->m_Layer != CMP_N) && (Module->m_Layer != CUIVRE_N) ) + if( (Module->GetLayer() != CMP_N) && (Module->GetLayer() != CUIVRE_N) ) return; m_CurrentScreen->SetModify(); @@ -367,7 +367,7 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) } /* mise a jour du Flag de l'empreinte et des couches des contours et textes */ - Module->m_Layer = ChangeSideNumLayer( Module->m_Layer ); + Module->SetLayer( ChangeSideNumLayer( Module->GetLayer() ) ); /* Inversion miroir de l'orientation */ Module->m_Orient = -Module->m_Orient; @@ -397,17 +397,17 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Miroir = 1; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); - pt_texte->m_Layer = Module->m_Layer; - pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer ); + pt_texte->SetLayer( Module->GetLayer() ); + pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); - if( Module->m_Layer == CUIVRE_N ) - pt_texte->m_Layer = SILKSCREEN_N_CU; + if( Module->GetLayer() == CUIVRE_N ) + pt_texte->SetLayer( SILKSCREEN_N_CU ); - if( Module->m_Layer == CMP_N ) - pt_texte->m_Layer = SILKSCREEN_N_CMP; + if( Module->GetLayer() == CMP_N ) + pt_texte->SetLayer( SILKSCREEN_N_CMP ); - if( (Module->m_Layer == SILKSCREEN_N_CU) - || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + if( (Module->GetLayer() == SILKSCREEN_N_CU) + || (Module->GetLayer() == ADHESIVE_N_CU) || (Module->GetLayer() == CUIVRE_N) ) pt_texte->m_Miroir = 0; /* Inversion miroir de la Valeur et mise en miroir : */ @@ -418,17 +418,17 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Miroir = 1; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); - pt_texte->m_Layer = Module->m_Layer; - pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer ); + pt_texte->SetLayer( Module->GetLayer() ); + pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); - if( Module->m_Layer == CUIVRE_N ) - pt_texte->m_Layer = SILKSCREEN_N_CU; + if( Module->GetLayer() == CUIVRE_N ) + pt_texte->SetLayer( SILKSCREEN_N_CU ); - if( Module->m_Layer == CMP_N ) - pt_texte->m_Layer = SILKSCREEN_N_CMP; + if( Module->GetLayer() == CMP_N ) + pt_texte->SetLayer( SILKSCREEN_N_CMP ); - if( (Module->m_Layer == SILKSCREEN_N_CU) - || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + if( (Module->GetLayer() == SILKSCREEN_N_CU) + || (Module->GetLayer() == ADHESIVE_N_CU) || (Module->GetLayer() == CUIVRE_N) ) pt_texte->m_Miroir = 0; /* Inversion miroir des dessins de l'empreinte : */ @@ -453,7 +453,7 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_edgmod->m_Angle = -pt_edgmod->m_Angle; } - pt_edgmod->m_Layer = ChangeSideNumLayer( pt_edgmod->m_Layer ); + pt_edgmod->SetLayer( ChangeSideNumLayer( pt_edgmod->GetLayer() ) ); break; case TYPETEXTEMODULE: @@ -466,18 +466,21 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_texte->m_Miroir = 1; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); - pt_texte->m_Layer = Module->m_Layer; - pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer ); + pt_texte->SetLayer( Module->GetLayer() ); + pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); - if( Module->m_Layer == CUIVRE_N ) - pt_texte->m_Layer = SILKSCREEN_N_CU; + if( Module->GetLayer() == CUIVRE_N ) + pt_texte->SetLayer( SILKSCREEN_N_CU ); - if( Module->m_Layer == CMP_N ) - pt_texte->m_Layer = SILKSCREEN_N_CMP; + if( Module->GetLayer() == CMP_N ) + pt_texte->SetLayer( SILKSCREEN_N_CMP ); - if( (Module->m_Layer == SILKSCREEN_N_CU) - || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + if( Module->GetLayer() == SILKSCREEN_N_CU + || Module->GetLayer() == ADHESIVE_N_CU + || Module->GetLayer() == CUIVRE_N ) + { pt_texte->m_Miroir = 0; + } break; diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 77774e26cc..cddb107cfa 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -815,7 +815,7 @@ bool WinEDA_PcbFrame::PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC ) /* Test the connections modified by the move * (only pad connection must be tested, track connection will be tested by test_1_net_connexion() ) */ - int masque_layer = g_TabOneLayerMask[Track->m_Layer]; + int masque_layer = g_TabOneLayerMask[Track->GetLayer()]; Track->start = Fast_Locate_Pad_Connecte( m_Pcb, Track->m_Start, masque_layer ); Track->end = Fast_Locate_Pad_Connecte( m_Pcb, Track->m_End, masque_layer ); } diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index f5c7060236..07180d6c3b 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -243,7 +243,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( wxDC* DC, int shape_type ) Module->m_Drawings = edge; edge->Pback = Module; edge->m_Shape = S_POLYGON; - edge->m_Layer = LAYER_CMP_N; + edge->SetLayer( LAYER_CMP_N ); edge->m_PolyCount = ii + 3; edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) ); ptr = edge->m_PolyList; @@ -574,7 +574,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( wxDC* DC ) Module->m_Drawings = edge; edge->Pback = Module; edge->m_Shape = S_POLYGON; - edge->m_Layer = LAYER_CMP_N; + edge->SetLayer( LAYER_CMP_N ); npoints = PolyEdgesCount; switch( PolyShapeType ) diff --git a/pcbnew/pcbcfg.cpp b/pcbnew/pcbcfg.cpp index 52c7a7aa4c..82ff04e897 100644 --- a/pcbnew/pcbcfg.cpp +++ b/pcbnew/pcbcfg.cpp @@ -120,9 +120,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName += wxT("module_edit"); FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - frame->ReadHotkeyConfigFile(FullFileName, s_module_edit_Hotkey_List, verbose); - - return TRUE; + return frame->ReadHotkeyConfigFile(FullFileName, s_module_edit_Hotkey_List, verbose); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 69ac844592..35f0fe2cae 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -12,7 +12,7 @@ #include "id.h" #if defined(DEBUG) -#include "class_collector.h" +#include "collectors.h" #endif @@ -169,77 +169,6 @@ END_EVENT_TABLE() -#if defined(DEBUG) -class RAT1COLLECTOR : public COLLECTOR -{ - ; -}; - - -class ARROWCOLLECTOR : public COLLECTOR -{ - const KICAD_T* m_ScanTypes; - - /** - * A place to hold collected objects which don't match precisely the search - * criteria, but would be acceptable if nothing else is found. - * "2nd" choice, which will be appended to the end of COLLECTOR's prime - * "list" at the end of the search. - */ - std::vector list2nd; - - -public: - ARROWCOLLECTOR() : - COLLECTOR(0), - m_ScanTypes(0) - { - } - - - void Empty2nd() - { - list2nd.clear(); - } - - - /** - * Function Inspect - * is the examining function within the INSPECTOR which is passed to the - * Iterate function. It is used primarily for searching, but not limited to - * that. It can also collect or modify the scanned objects. - * - * @param testItem An EDA_BaseStruct to examine. - * @param testData is arbitrary data needed by the inspector to determine - * if the EDA_BaseStruct under test meets its match criteria. - * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, - * else SCAN_CONTINUE; - */ - SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData ) - { - const wxPoint& refPos = *(const wxPoint*) testData; - - switch( testItem->m_StructType ) - { - case TYPEMODULE: - if( testItem->HitTest( refPos ) ) - Append( testItem ); - break; - } - - return SEARCH_CONTINUE; - } - - - void SetScanTypes( const KICAD_T* scanTypes ) - { - m_ScanTypes = scanTypes; - } -}; -#endif - - - ///////****************************///////////: /****************/ @@ -264,8 +193,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, m_SelViaSizeBox_Changed = FALSE; #if defined(DEBUG) - m_GeneralCollector = NULL; - m_RatsModuleCollector = NULL; + m_ArrowCollector = new ARROWCOLLECTOR(); #endif m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; @@ -313,6 +241,10 @@ WinEDA_PcbFrame::~WinEDA_PcbFrame( void ) { m_Parent->m_PcbFrame = NULL; m_CurrentScreen = ScreenPcb; + +#if defined(DEBUG) + delete m_ArrowCollector; +#endif } diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp index 00068a5c6e..10fca1ce3d 100644 --- a/pcbnew/pcbtexte.cpp +++ b/pcbnew/pcbtexte.cpp @@ -148,7 +148,7 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); } - m_SelLayerBox->SetSelection( TextPCB->m_Layer ); + m_SelLayerBox->SetSelection( TextPCB->GetLayer() ); wxString orient_msg[4] = { wxT( "0" ), wxT( "90" ), wxT( "180" ), wxT( "-90" ) }; @@ -216,7 +216,7 @@ void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept( wxCommandEvent& eve CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue(); CurrentTextPCB->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900; - CurrentTextPCB->m_Layer = m_SelLayerBox->GetChoice(); + CurrentTextPCB->SetLayer( m_SelLayerBox->GetChoice() ); CurrentTextPCB->CreateDrawData(); if( m_DC ) // Affichage nouveau texte { @@ -349,13 +349,13 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) TextePcb->Pback = (EDA_BaseStruct*) m_Pcb; if( m_Pcb->m_Drawings ) m_Pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; - m_Pcb->m_Drawings = (EDA_BaseStruct*) TextePcb; + m_Pcb->m_Drawings = TextePcb; /* Mise a jour des caracteristiques */ TextePcb->m_Flags = IS_NEW; - TextePcb->m_Layer = GetScreen()->m_Active_Layer; + TextePcb->SetLayer( GetScreen()->m_Active_Layer ); TextePcb->m_Miroir = 1; - if( TextePcb->m_Layer == CUIVRE_N ) + if( TextePcb->GetLayer() == CUIVRE_N ) TextePcb->m_Miroir = 0; TextePcb->m_Size = g_DesignSettings.m_PcbTextSize; diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index a5ca69a2c4..acd908bbb3 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -203,12 +203,12 @@ wxString msg; trace_val = Sel_Texte_Valeur; trace_ref = Sel_Texte_Reference; // les 2 autorisations de tracer sont donnees - if( (g_TabOneLayerMask[Module->m_Reference->m_Layer] & masque_layer) == 0) + if( (g_TabOneLayerMask[Module->m_Reference->GetLayer()] & masque_layer) == 0) trace_ref = FALSE; if(Module->m_Reference->m_NoShow && !Sel_Texte_Invisible) trace_ref = FALSE; - if( (g_TabOneLayerMask[Module->m_Value->m_Layer] & masque_layer) == 0) + if( (g_TabOneLayerMask[Module->m_Value->GetLayer()] & masque_layer) == 0) trace_val = FALSE; if(Module->m_Value->m_NoShow && !Sel_Texte_Invisible) trace_val = FALSE; @@ -238,7 +238,7 @@ wxString msg; if( !Sel_Texte_Divers ) continue; if( (pt_texte->m_NoShow) && !Sel_Texte_Invisible ) continue; - if( (g_TabOneLayerMask[pt_texte->m_Layer] & masque_layer) == 0) + if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0) continue; PlotTextModule(pt_texte); nb_items++ ; @@ -281,13 +281,13 @@ void PlotCotation( COTATION * Cotation, int format_plot,int masque_layer) { DRAWSEGMENT *DrawTmp; - if( (g_TabOneLayerMask[Cotation->m_Layer] & masque_layer) == 0) return; + if( (g_TabOneLayerMask[Cotation->GetLayer()] & masque_layer) == 0) return; DrawTmp = new DRAWSEGMENT(NULL); masque_layer |= EDGE_LAYER; DrawTmp->m_Width = Cotation->m_Width; - DrawTmp->m_Layer = Cotation->m_Layer; + DrawTmp->SetLayer( Cotation->GetLayer() ); PlotTextePcb( Cotation->m_Text,format_plot, masque_layer); @@ -330,13 +330,13 @@ void PlotMirePcb( MIREPCB* Mire, int format_plot,int masque_layer) DRAWSEGMENT *DrawTmp; int dx1,dx2, dy1, dy2, rayon; - if( (g_TabOneLayerMask[Mire->m_Layer] & masque_layer) == 0) return; + if( (g_TabOneLayerMask[Mire->GetLayer()] & masque_layer) == 0) return; DrawTmp = new DRAWSEGMENT(NULL); masque_layer |= EDGE_LAYER; DrawTmp->m_Width = Mire->m_Width; - DrawTmp->m_Layer = Mire->m_Layer; + DrawTmp->SetLayer( Mire->GetLayer() ); DrawTmp->m_Start.x = Mire->m_Pos.x; DrawTmp->m_Start.y = Mire->m_Pos.y; DrawTmp->m_End.x = DrawTmp->m_Start.x + (Mire->m_Size / 4); @@ -384,7 +384,7 @@ wxString msg; for ( ;PtEdge != NULL; PtEdge = (EDGE_MODULE*)PtEdge->Pnext) { if(PtEdge->m_StructType != TYPEEDGEMODULE) continue; - if( (g_TabOneLayerMask[PtEdge->m_Layer] & masque_layer) == 0) continue; + if( (g_TabOneLayerMask[PtEdge->GetLayer()] & masque_layer) == 0) continue; Plot_1_EdgeModule(format_plot, PtEdge); } /* Affichage du nombre de modules traites */ @@ -488,7 +488,7 @@ wxPoint pos; wxSize size; if( pt_texte->m_Text.IsEmpty() ) return; - if( (g_TabOneLayerMask[pt_texte->m_Layer] & masque_layer) == 0 ) return ; + if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0 ) return ; /* calcul des parametres du texte :*/ size = pt_texte->m_Size; @@ -615,7 +615,7 @@ wxPoint start, end; int epaisseur; int rayon = 0, StAngle = 0, EndAngle = 0; - if( (g_TabOneLayerMask[pt_segm->m_Layer] & masque_layer) == 0) return; + if( (g_TabOneLayerMask[pt_segm->GetLayer()] & masque_layer) == 0) return; epaisseur = pt_segm->m_Width; if ( Plot_Mode == FILAIRE) epaisseur = g_PlotLine_Width; diff --git a/pcbnew/plotgerb.cpp b/pcbnew/plotgerb.cpp index 140ca929d5..70b71cfb28 100644 --- a/pcbnew/plotgerb.cpp +++ b/pcbnew/plotgerb.cpp @@ -194,7 +194,7 @@ wxString msg; switch( PtStruct->m_StructType ) { case TYPEEDGEMODULE: - if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) + if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->GetLayer()] ) Plot_1_EdgeModule(PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct); break; @@ -289,7 +289,7 @@ wxString msg; wxPoint end; if ( track->m_StructType == TYPEVIA ) continue ; - if( (g_TabOneLayerMask[track->m_Layer] & masque_layer) == 0 ) continue; + if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 ) continue; size.x = size.y = track->m_Width; pos = track->m_Start; end = track->m_End; @@ -308,7 +308,7 @@ wxString msg; { wxPoint end; - if( (g_TabOneLayerMask[track->m_Layer] & masque_layer) == 0 ) continue; + if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 ) continue; size.x = size.y = track->m_Width; pos = track->m_Start; end = track->m_End; diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index 94dec875e8..81e329ad40 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -1,6 +1,6 @@ - /*******************************/ - /**** Routine de trace HPGL ****/ - /*******************************/ +/*******************************/ +/**** Routine de trace HPGL ****/ +/*******************************/ #include "fctsys.h" @@ -14,860 +14,887 @@ /* Variables locales : */ -static int pen_rayon; /* Rayon de la plume en unites pcb */ -static int pen_diam; /* Diametre de la plume en unites pcb */ -static int pen_recouvrement; /* recouvrement en remplissage en unites pcb */ +static int pen_rayon; /* Rayon de la plume en unites pcb */ +static int pen_diam; /* Diametre de la plume en unites pcb */ +static int pen_recouvrement; /* recouvrement en remplissage en unites pcb */ /* Routines Locales */ /*****************************************************************************/ -void WinEDA_BasePcbFrame::Genere_HPGL(const wxString & FullFileName, int Layer) +void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) /*****************************************************************************/ { -int modetrace; -wxSize SheetSize; -wxSize BoardSize; -wxPoint BoardCenter; -double scale_x, scale_y; -int marge = 0 * U_PCB; // Extra margin (set to 0) -bool Center = FALSE; + int modetrace; + wxSize SheetSize; + wxSize BoardSize; + wxPoint BoardCenter; + double scale_x, scale_y; + int marge = 0 * U_PCB; // Extra margin (set to 0) + bool Center = FALSE; - modetrace = Plot_Mode; + modetrace = Plot_Mode; - /* Calcul des echelles de conversion */ - scale_x = Scale_X * SCALE_HPGL; - scale_y = Scale_Y * SCALE_HPGL; + /* Calcul des echelles de conversion */ + scale_x = Scale_X * SCALE_HPGL; + scale_y = Scale_Y * SCALE_HPGL; - // calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce ) - SheetSize.x = m_CurrentScreen->m_CurrentSheet->m_Size.x * U_PCB; - SheetSize.y = m_CurrentScreen->m_CurrentSheet->m_Size.y * U_PCB; + // calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce ) + SheetSize.x = m_CurrentScreen->m_CurrentSheet->m_Size.x * U_PCB; + SheetSize.y = m_CurrentScreen->m_CurrentSheet->m_Size.y * U_PCB; - g_PlotOffset.x = 0 ; - g_PlotOffset.y = (int)(SheetSize.y * scale_y) ; + g_PlotOffset.x = 0; + g_PlotOffset.y = (int) (SheetSize.y * scale_y); - // Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units, - // with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam - // so apparent pen diam is real pen diam / Scale - pen_diam = (int) round((g_HPGL_Pen_Diam * 10.0) / Scale_X); // Assume Scale_X # Scale_Y - pen_rayon = pen_diam / 2; + // Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units, + // with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam + // so apparent pen diam is real pen diam / Scale + pen_diam = (int) round( (g_HPGL_Pen_Diam * 10.0) / Scale_X ); // Assume Scale_X # Scale_Y + pen_rayon = pen_diam / 2; - nb_plot_erreur = 0 ; - // compute pen_recouvrement (from g_HPGL_Pen_Recouvrement in mils) - // with plot scale - if(g_HPGL_Pen_Recouvrement < 0 ) g_HPGL_Pen_Recouvrement = 0 ; - if(g_HPGL_Pen_Recouvrement >= g_HPGL_Pen_Diam ) - g_HPGL_Pen_Recouvrement = g_HPGL_Pen_Diam - 1 ; - pen_recouvrement = (int) round(g_HPGL_Pen_Recouvrement * 10.0/Scale_X); + nb_plot_erreur = 0; - dest = wxFopen(FullFileName, wxT("wt")); - if (dest == NULL) - { - wxString msg = _("Unable to create ") + FullFileName; - DisplayError(this, msg); - return ; - } + // compute pen_recouvrement (from g_HPGL_Pen_Recouvrement in mils) + // with plot scale + if( g_HPGL_Pen_Recouvrement < 0 ) + g_HPGL_Pen_Recouvrement = 0; + if( g_HPGL_Pen_Recouvrement >= g_HPGL_Pen_Diam ) + g_HPGL_Pen_Recouvrement = g_HPGL_Pen_Diam - 1; + pen_recouvrement = (int) round( g_HPGL_Pen_Recouvrement * 10.0 / Scale_X ); - setlocale(LC_NUMERIC, "C"); + dest = wxFopen( FullFileName, wxT( "wt" ) ); + if( dest == NULL ) + { + wxString msg = _( "Unable to create " ) + FullFileName; + DisplayError( this, msg ); + return; + } - Affiche_1_Parametre(this, 0,_("File"),FullFileName,CYAN) ; + setlocale( LC_NUMERIC, "C" ); - PrintHeaderHPGL(dest, g_HPGL_Pen_Speed,g_HPGL_Pen_Num); + Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN ); - if ( Plot_Sheet_Ref && (g_PlotScaleOpt == 1) ) - { - int tmp = g_PlotOrient; g_PlotOrient = 0; - InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y, g_PlotOrient); - PlotWorkSheet( PLOT_FORMAT_HPGL, m_CurrentScreen); - g_PlotOrient = tmp; - } + PrintHeaderHPGL( dest, g_HPGL_Pen_Speed, g_HPGL_Pen_Num ); - /* calcul des dimensions et centre du PCB */ - m_Pcb->ComputeBoundaryBox(); - BoardSize = m_Pcb->m_BoundaryBox.GetSize(); - BoardCenter = m_Pcb->m_BoundaryBox.Centre(); + if( Plot_Sheet_Ref && (g_PlotScaleOpt == 1) ) + { + int tmp = g_PlotOrient; g_PlotOrient = 0; + InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_y, g_PlotOrient ); + PlotWorkSheet( PLOT_FORMAT_HPGL, m_CurrentScreen ); + g_PlotOrient = tmp; + } - if( g_PlotScaleOpt == 0 ) // Optimum scale - { - float Xscale, Yscale; - Xscale = (float) (SheetSize.x - ( 2 * marge)) / BoardSize.x; - Yscale = (float) (SheetSize.y - ( 2 * marge)) / BoardSize.y; - scale_x = scale_y = min( Xscale, Yscale) * SCALE_HPGL; - } + /* calcul des dimensions et centre du PCB */ + m_Pcb->ComputeBoundaryBox(); + BoardSize = m_Pcb->m_BoundaryBox.GetSize(); + BoardCenter = m_Pcb->m_BoundaryBox.Centre(); - BoardCenter.x = (int)(BoardCenter.x * scale_x); - BoardCenter.y = (int)(BoardCenter.y * scale_y); + if( g_PlotScaleOpt == 0 ) // Optimum scale + { + float Xscale, Yscale; + Xscale = (float) ( SheetSize.x - ( 2 * marge) ) / BoardSize.x; + Yscale = (float) ( SheetSize.y - ( 2 * marge) ) / BoardSize.y; + scale_x = scale_y = MIN( Xscale, Yscale ) * SCALE_HPGL; + } - if( g_PlotScaleOpt != 1 ) Center = TRUE; // Echelle != 1 + BoardCenter.x = (int) (BoardCenter.x * scale_x); + BoardCenter.y = (int) (BoardCenter.y * scale_y); - /* Calcul du cadrage */ - marge = (int)(marge * SCALE_HPGL); - if ( Center ) - g_PlotOffset.x = (int)(- SheetSize.x/2 * SCALE_HPGL) + - BoardCenter.x + marge; - switch ( g_PlotOrient) - { - default : - if ( Center ) - { - g_PlotOffset.y = (int)(SheetSize.y/2 * SCALE_HPGL) + - BoardCenter.y + marge; - } - break ; + if( g_PlotScaleOpt != 1 ) + Center = TRUE; // Echelle != 1 - case PLOT_MIROIR : - if ( Center ) - g_PlotOffset.y = (int)(- SheetSize.y/2 * SCALE_HPGL) + BoardCenter.y; - else g_PlotOffset.y = (int)((- SheetSize.y + - m_Pcb->m_BoundaryBox.GetBottom() + m_Pcb->m_BoundaryBox.GetY()) * SCALE_HPGL); - break ; - } + /* Calcul du cadrage */ + marge = (int) (marge * SCALE_HPGL); + if( Center ) + g_PlotOffset.x = (int) (-SheetSize.x / 2 * SCALE_HPGL) + + BoardCenter.x + marge; - InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y, g_PlotOrient); - switch( Layer ) - { - case CUIVRE_N : - case LAYER_N_2 : - case LAYER_N_3 : - case LAYER_N_4 : - case LAYER_N_5 : - case LAYER_N_6 : - case LAYER_N_7 : - case LAYER_N_8 : - case LAYER_N_9 : - case LAYER_N_10 : - case LAYER_N_11: - case LAYER_N_12: - case LAYER_N_13 : - case LAYER_N_14 : - case LAYER_N_15 : - case CMP_N : Plot_Layer_HPGL(dest,g_TabOneLayerMask[Layer], 0, 1, modetrace); - break; + switch( g_PlotOrient ) + { + default: + if( Center ) + { + g_PlotOffset.y = (int) (SheetSize.y / 2 * SCALE_HPGL) + + BoardCenter.y + marge; + } + break; - case SILKSCREEN_N_CU : - case SILKSCREEN_N_CMP : - Plot_Serigraphie(PLOT_FORMAT_HPGL,dest, g_TabOneLayerMask[Layer]); - break; + case PLOT_MIROIR: + if( Center ) + g_PlotOffset.y = (int) (-SheetSize.y / 2 * SCALE_HPGL) + BoardCenter.y; + else + g_PlotOffset.y = (int) ( ( -SheetSize.y + + m_Pcb->m_BoundaryBox.GetBottom() + + m_Pcb->m_BoundaryBox.GetY() ) * SCALE_HPGL ); + break; + } - case SOLDERMASK_N_CU : - case SOLDERMASK_N_CMP : /* Trace du vernis epargne */ - { - int tracevia; - if (g_DrawViaOnMaskLayer) tracevia = 1; - else tracevia = 0; - Plot_Layer_HPGL(dest,g_TabOneLayerMask[Layer], - g_DesignSettings.m_MaskMargin, tracevia, modetrace); - } - break; + InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_y, g_PlotOrient ); - case SOLDERPASTE_N_CU : - case SOLDERPASTE_N_CMP : /* Trace du masque de pate de soudure */ - Plot_Layer_HPGL(dest,g_TabOneLayerMask[Layer], 0, 0, modetrace); - break; + switch( Layer ) + { + case CUIVRE_N: + case LAYER_N_2: + case LAYER_N_3: + case LAYER_N_4: + case LAYER_N_5: + case LAYER_N_6: + case LAYER_N_7: + case LAYER_N_8: + case LAYER_N_9: + case LAYER_N_10: + case LAYER_N_11: + case LAYER_N_12: + case LAYER_N_13: + case LAYER_N_14: + case LAYER_N_15: + case CMP_N: + Plot_Layer_HPGL( dest, g_TabOneLayerMask[Layer], 0, 1, modetrace ); + break; - default : /* Trace des autres couches (dessin, adhesives,eco,comment) */ - Plot_Serigraphie(PLOT_FORMAT_HPGL,dest, g_TabOneLayerMask[Layer]); - break; - } - /* fin */ - CloseFileHPGL(dest) ; - setlocale(LC_NUMERIC, ""); + case SILKSCREEN_N_CU: + case SILKSCREEN_N_CMP: + Plot_Serigraphie( PLOT_FORMAT_HPGL, dest, g_TabOneLayerMask[Layer] ); + break; + case SOLDERMASK_N_CU: + case SOLDERMASK_N_CMP: /* Trace du vernis epargne */ + { + int tracevia; + if( g_DrawViaOnMaskLayer ) + tracevia = 1; + else + tracevia = 0; + Plot_Layer_HPGL( dest, g_TabOneLayerMask[Layer], + g_DesignSettings.m_MaskMargin, tracevia, modetrace ); + } + break; + + case SOLDERPASTE_N_CU: + case SOLDERPASTE_N_CMP: /* Trace du masque de pate de soudure */ + Plot_Layer_HPGL( dest, g_TabOneLayerMask[Layer], 0, 0, modetrace ); + break; + + default: /* Trace des autres couches (dessin, adhesives,eco,comment) */ + Plot_Serigraphie( PLOT_FORMAT_HPGL, dest, g_TabOneLayerMask[Layer] ); + break; + } + + /* fin */ + CloseFileHPGL( dest ); + setlocale( LC_NUMERIC, "" ); } /*********************************************************************/ -void WinEDA_BasePcbFrame::Plot_Layer_HPGL(FILE * File,int masque_layer, - int garde, int tracevia, int modetrace) +void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, + int garde, int tracevia, int modetrace ) /*********************************************************************/ /* Trace en format HPGL. d'une couche cuivre ou masque - 1 unite HPGL = 0.98 mils ( 1 mil = 1.02041 unite HPGL ) . -*/ + * 1 unite HPGL = 0.98 mils ( 1 mil = 1.02041 unite HPGL ) . + */ { -wxSize size; -wxPoint start, end; -MODULE * Module; -D_PAD * PtPad; -TRACK * pts ; -EDA_BaseStruct * PtStruct; -wxString msg; - - masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ + wxSize size; + wxPoint start, end; + MODULE* Module; + D_PAD* PtPad; + TRACK* pts; + BOARD_ITEM* PtStruct; + wxString msg; - /* trace des elements type Drawings Pcb : */ - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_HPGL, - masque_layer); - break; + masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ - case TYPETEXTE: - PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_HPGL, - masque_layer); - break; + /* trace des elements type Drawings Pcb : */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer ); + break; - case TYPECOTATION: - PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_HPGL, - masque_layer); - break; + case TYPETEXTE: + PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer ); + break; - case TYPEMIRE: - PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_HPGL, - masque_layer); - break; + case TYPECOTATION: + PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer ); + break; - case TYPEMARQUEUR: - break; + case TYPEMIRE: + PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer ); + break; - default: - DisplayError(this, wxT("Type Draw non gere")); - break; - } - } + case TYPEMARQUEUR: + break; + default: + DisplayError( this, wxT( "Type Draw non gere" ) ); + break; + } + } - /* Trace des Elements des modules autres que pads */ - nb_items = 0 ; - Affiche_1_Parametre(this, 48, wxT("DrawMod"),wxEmptyString,GREEN) ; - Module = m_Pcb->m_Modules; - for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) - { - PtStruct = Module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEEDGEMODULE: - if( masque_layer & - g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) - Plot_1_EdgeModule(PLOT_FORMAT_HPGL, (EDGE_MODULE*) PtStruct); - break; + /* Trace des Elements des modules autres que pads */ + nb_items = 0; + Affiche_1_Parametre( this, 48, wxT( "DrawMod" ), wxEmptyString, GREEN ); + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + if( masque_layer & + g_TabOneLayerMask[ PtStruct->GetLayer() ] ) + Plot_1_EdgeModule( PLOT_FORMAT_HPGL, (EDGE_MODULE*) PtStruct ); + break; - default: break; - } - } - } + default: + break; + } + } + } - /* Trace des Elements des modules : Pastilles */ - nb_items = 0 ; - Affiche_1_Parametre(this, 48, wxT("Pads "), wxEmptyString,GREEN) ; - Module = m_Pcb->m_Modules; - for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) - { - PtPad = (D_PAD*) Module->m_Pads; - for ( ; PtPad != NULL ;PtPad = (D_PAD*)PtPad->Pnext ) - { - wxPoint shape_pos; - if( (PtPad->m_Masque_Layer & masque_layer) == 0) - continue ; + /* Trace des Elements des modules : Pastilles */ + nb_items = 0; + Affiche_1_Parametre( this, 48, wxT( "Pads " ), wxEmptyString, GREEN ); + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + wxPoint shape_pos; + if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) + continue; - shape_pos = PtPad->ReturnShapePos(); - start = shape_pos; - size = PtPad->m_Size; - size.x += garde*2; size.y += garde*2; + shape_pos = PtPad->ReturnShapePos(); + start = shape_pos; + size = PtPad->m_Size; + size.x += garde * 2; size.y += garde * 2; - nb_items++ ; - switch (PtPad->m_PadShape & 0x7F) - { - case CIRCLE : - trace_1_pastille_RONDE_HPGL(start,size.x,modetrace) ; - break ; + nb_items++; - case OVALE : - { - trace_1_pastille_OVALE_HPGL(start,size, PtPad->m_Orient,modetrace) ; - break ; - } + switch( PtPad->m_PadShape & 0x7F ) + { + case CIRCLE: + trace_1_pastille_RONDE_HPGL( start, size.x, modetrace ); + break; - case TRAPEZE : - { - wxSize delta; - delta = PtPad->m_DeltaSize; - trace_1_pad_TRAPEZE_HPGL(start,size,delta, - PtPad->m_Orient, modetrace) ; - break ; - } + case OVALE: + { + trace_1_pastille_OVALE_HPGL( start, size, PtPad->m_Orient, modetrace ); + break; + } - case RECT : - default: - PlotRectangularPad_HPGL(start,size, - PtPad->m_Orient,modetrace) ; - break ; - } - msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 48, wxT("Pads"), msg,GREEN) ; - } - } + case TRAPEZE: + { + wxSize delta; + delta = PtPad->m_DeltaSize; + trace_1_pad_TRAPEZE_HPGL( start, size, delta, + PtPad->m_Orient, modetrace ); + break; + } - /* trace des VIAS : */ - if(tracevia) - { - TRACK * pts ; + case RECT: + default: + PlotRectangularPad_HPGL( start, size, + PtPad->m_Orient, modetrace ); + break; + } - nb_items = 0 ; - Affiche_1_Parametre(this, 56, wxT("Vias"), wxEmptyString, RED) ; + msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 48, wxT( "Pads" ), msg, GREEN ); + } + } - for(pts = m_Pcb->m_Track ;pts != NULL; pts = (TRACK*)pts->Pnext ) - { - if( pts->m_StructType != TYPEVIA ) continue; - SEGVIA * Via = (SEGVIA *) pts; - /* vias not plotted if not on selected layer, but if layer - == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , - if they are on a external copper layer - */ - int via_mask_layer = Via->ReturnMaskLayer(); - if ( (via_mask_layer & CUIVRE_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CU; - if ( (via_mask_layer & CMP_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CMP; - if( (via_mask_layer & masque_layer) == 0 ) continue; + /* trace des VIAS : */ + if( tracevia ) + { + TRACK* pts; - start = Via->m_Start; - size.x = Via->m_Width + (garde*2); + nb_items = 0; + Affiche_1_Parametre( this, 56, wxT( "Vias" ), wxEmptyString, RED ); - trace_1_pastille_RONDE_HPGL(start, size.x, modetrace) ; - nb_items++ ; msg.Printf( wxT("%d"), nb_items) ; - Affiche_1_Parametre(this, 56, wxT("Vias"), msg,RED) ; - } - fputs("PU;\n",dest) ; - } + for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) + { + if( pts->m_StructType != TYPEVIA ) + continue; + SEGVIA* Via = (SEGVIA*) pts; - /* 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 ) - { - if ( pts->m_StructType == TYPEVIA ) continue ; + /* vias not plotted if not on selected layer, but if layer + * == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , + * if they are on a external copper layer + */ + int via_mask_layer = Via->ReturnMaskLayer(); + if( (via_mask_layer & CUIVRE_LAYER ) ) + via_mask_layer |= SOLDERMASK_LAYER_CU; + if( (via_mask_layer & CMP_LAYER ) ) + via_mask_layer |= SOLDERMASK_LAYER_CMP; + if( (via_mask_layer & masque_layer) == 0 ) + continue; - if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) continue; + start = Via->m_Start; + size.x = Via->m_Width + (garde * 2); - size.x = size.y = pts->m_Width; - start = pts->m_Start; - end = pts->m_End; + trace_1_pastille_RONDE_HPGL( start, size.x, modetrace ); + nb_items++; msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 56, wxT( "Vias" ), msg, RED ); + } - if ( size.x > pen_diam )/* c.a.d si largeur piste > diam plume */ - trace_1_pastille_RONDE_HPGL(start, size.x, modetrace) ; + fputs( "PU;\n", dest ); + } - /* Trace d'un segment de piste */ - trace_1_segment_HPGL(start.x,start.y,end.x,end.y,size.x) ; - /* Complement de Trace en mode Remplissage */ - if( (Plot_Mode == FILLED) && (pen_diam <= size.x ) ) - { - while( (size.x -= (int)((pen_rayon - pen_recouvrement)*2) ) > 0 ) - { - trace_1_segment_HPGL(start.x,start.y,end.x,end.y, - max(size.x,pen_diam) ) ; - } - } + /* 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 ) + { + if( pts->m_StructType == TYPEVIA ) + continue; - if ( size.x > pen_diam) - trace_1_pastille_RONDE_HPGL(end, size.x, modetrace) ; + if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) + continue; - nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 64,wxEmptyString, msg,YELLOW) ; - } + size.x = size.y = pts->m_Width; + start = pts->m_Start; + end = pts->m_End; - /* 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 ) - { - if( g_TabOneLayerMask[pts->m_Layer] & masque_layer) - { - size.x = size.y = pts->m_Width; - start = pts->m_Start; - end = pts->m_End; + if( size.x > pen_diam ) /* c.a.d si largeur piste > diam plume */ + trace_1_pastille_RONDE_HPGL( start, size.x, modetrace ); - if ( size.x > pen_diam )/* c.a.d si largeur piste > diam plume */ - trace_1_pastille_RONDE_HPGL(start, size.x,modetrace) ; + /* Trace d'un segment de piste */ + trace_1_segment_HPGL( start.x, start.y, end.x, end.y, size.x ); + /* Complement de Trace en mode Remplissage */ + if( (Plot_Mode == FILLED) && (pen_diam <= size.x ) ) + { + while( ( size.x -= (int) ( (pen_rayon - pen_recouvrement) * 2 ) ) > 0 ) + { + trace_1_segment_HPGL( start.x, start.y, end.x, end.y, + MAX( size.x, pen_diam ) ); + } + } - /* Trace d'un segment de piste */ - trace_1_segment_HPGL(start.x,start.y,end.x,end.y,size.x) ; - /* Complement de Trace en mode Remplissage */ - if( (Plot_Mode == FILLED) && (pen_diam <= size.x ) ) - { - while( (size.x -= (int)((pen_rayon - pen_recouvrement)*2) ) > 0 ) - { - trace_1_segment_HPGL(start.x,start.y,end.x,end.y, - max(size.x,pen_diam)) ; - } - } + if( size.x > pen_diam ) + trace_1_pastille_RONDE_HPGL( end, size.x, modetrace ); - if ( size.x > pen_diam) - trace_1_pastille_RONDE_HPGL(end, size.x, modetrace) ; + nb_items++; msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 64, wxEmptyString, msg, YELLOW ); + } - nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 64,wxEmptyString, msg,YELLOW) ; - } - } + /* 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 ) + { + if( g_TabOneLayerMask[pts->GetLayer()] & masque_layer ) + { + size.x = size.y = pts->m_Width; + start = pts->m_Start; + end = pts->m_End; + + if( size.x > pen_diam ) /* c.a.d si largeur piste > diam plume */ + trace_1_pastille_RONDE_HPGL( start, size.x, modetrace ); + + /* Trace d'un segment de piste */ + trace_1_segment_HPGL( start.x, start.y, end.x, end.y, size.x ); + /* Complement de Trace en mode Remplissage */ + if( (Plot_Mode == FILLED) && (pen_diam <= size.x ) ) + { + while( ( size.x -= (int) ( (pen_rayon - pen_recouvrement) * 2 ) ) > 0 ) + { + trace_1_segment_HPGL( start.x, start.y, end.x, end.y, + MAX( size.x, pen_diam ) ); + } + } + + if( size.x > pen_diam ) + trace_1_pastille_RONDE_HPGL( end, size.x, modetrace ); + + nb_items++; msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 64, wxEmptyString, msg, YELLOW ); + } + } } /************************************************************************************/ -void trace_1_pastille_OVALE_HPGL(wxPoint pos, wxSize size, int orient, int modetrace) +void trace_1_pastille_OVALE_HPGL( wxPoint pos, wxSize size, int orient, int modetrace ) /************************************************************************************/ /* Trace 1 pastille OVALE en position pos_X,Y , de dim size.x, size.y */ { -int rayon, deltaxy , cx, cy; -int trace_orient = orient; + int rayon, deltaxy, cx, cy; + int trace_orient = orient; - /* la pastille est ramenee a une pastille ovale avec size.y > size.x - ( ovale vertical en orientation 0 ) */ - if(size.x > size.y ) - { - EXCHG(size.x,size.y); trace_orient += 900; - if ( orient >= 3600 ) trace_orient -= 3600; - } - deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */ - rayon = size.x / 2; + /* la pastille est ramenee a une pastille ovale avec size.y > size.x + * ( ovale vertical en orientation 0 ) */ + if( size.x > size.y ) + { + EXCHG( size.x, size.y ); trace_orient += 900; + if( orient >= 3600 ) + trace_orient -= 3600; + } + deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */ + rayon = size.x / 2; - if ( modetrace == FILLED ) - { - PlotRectangularPad_HPGL(pos, wxSize(size.x,deltaxy), - orient,modetrace) ; - cx = 0; cy = deltaxy/2; - RotatePoint(&cx, &cy, trace_orient); - trace_1_pastille_RONDE_HPGL(wxPoint(cx + pos.x, cy + pos.y), size.x, modetrace) ; - Plume_HPGL('U') ; - cx = 0; cy = -deltaxy/2; - RotatePoint(&cx, &cy, trace_orient); - trace_1_pastille_RONDE_HPGL(wxPoint(cx + pos.x, cy + pos.y), size.x, modetrace) ; - } + if( modetrace == FILLED ) + { + PlotRectangularPad_HPGL( pos, wxSize( size.x, deltaxy ), + orient, modetrace ); + cx = 0; cy = deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + trace_1_pastille_RONDE_HPGL( wxPoint( cx + pos.x, cy + pos.y ), size.x, modetrace ); + Plume_HPGL( 'U' ); + cx = 0; cy = -deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + trace_1_pastille_RONDE_HPGL( wxPoint( cx + pos.x, cy + pos.y ), size.x, modetrace ); + } + else /* Trace en mode FILAIRE */ + { + cx = -rayon; cy = -deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'U' ); + cx = -rayon; cy = deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'D' ); - else /* Trace en mode FILAIRE */ - { - cx = -rayon; cy = -deltaxy / 2; - RotatePoint(&cx, &cy, trace_orient); - Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'U'); - cx = -rayon; cy = deltaxy / 2; - RotatePoint(&cx, &cy, trace_orient); - Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'D'); + cx = rayon; cy = -deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'U' ); + cx = rayon; cy = deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'D' ); + Plume_HPGL( 'U' ); - cx = rayon; cy = - deltaxy / 2; - RotatePoint(&cx, &cy, trace_orient); - Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'U'); - cx = rayon; cy = deltaxy / 2; - RotatePoint(&cx, &cy, trace_orient); - Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'D'); - Plume_HPGL('U'); + cx = 0; cy = -deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + PlotArc( PLOT_FORMAT_HPGL, wxPoint( cx + pos.x, cy + pos.y ), + trace_orient, trace_orient + 1800, + size.x / 2, pen_diam ); + cx = 0; cy = deltaxy / 2; + RotatePoint( &cx, &cy, trace_orient ); + PlotArc( PLOT_FORMAT_HPGL, wxPoint( cx + pos.x, cy + pos.y ), + trace_orient + 1800, trace_orient, + size.x / 2, pen_diam ); + } - cx = 0; cy = - deltaxy / 2; - RotatePoint(&cx, &cy, trace_orient); - PlotArc(PLOT_FORMAT_HPGL, wxPoint(cx + pos.x, cy + pos.y), - trace_orient, trace_orient + 1800, - size.x / 2, pen_diam); - cx = 0; cy = deltaxy / 2; - RotatePoint(&cx, &cy, trace_orient); - PlotArc(PLOT_FORMAT_HPGL, wxPoint(cx + pos.x, cy + pos.y), - trace_orient + 1800, trace_orient, - size.x / 2, pen_diam); - } - - Plume_HPGL('U') ; + Plume_HPGL( 'U' ); } /**************************************************************************/ -void trace_1_pastille_RONDE_HPGL(wxPoint pos, int diametre, int modetrace) +void trace_1_pastille_RONDE_HPGL( wxPoint pos, int diametre, int modetrace ) /**************************************************************************/ /* Trace 1 pastille RONDE (via,pad rond) en position pos */ { -int rayon, delta; + int rayon, delta; - UserToDeviceCoordinate(pos); + UserToDeviceCoordinate( pos ); - delta = pen_diam - pen_recouvrement; - rayon = diametre / 2 ; - if(modetrace != FILAIRE) - { - rayon = (diametre - pen_diam ) /2 ; - } + delta = pen_diam - pen_recouvrement; + rayon = diametre / 2; + if( modetrace != FILAIRE ) + { + rayon = (diametre - pen_diam ) / 2; + } - if(rayon < 0 ) - { - rayon = 0 ; nb_plot_erreur++ ; Affiche_erreur(nb_plot_erreur) ; - } - wxSize rsize(rayon, rayon); - UserToDeviceSize( rsize ); + if( rayon < 0 ) + { + rayon = 0; nb_plot_erreur++; Affiche_erreur( nb_plot_erreur ); + } + wxSize rsize( rayon, rayon ); - Plume_HPGL('U'); - sprintf(cbuf,"PA %d,%d;CI %d;\n", pos.x, pos.y, rsize.x); - fputs(cbuf,dest) ; - if(modetrace == FILLED ) /* Trace en mode Remplissage */ - { - if(delta > 0 ) - { - while ( (rayon -= delta ) >= 0 ) - { - rsize.x = rsize.y = rayon; - UserToDeviceSize( rsize ); - sprintf(cbuf,"PA %d,%d; CI %d;\n", pos.x, pos.y, rsize.x); - fputs(cbuf,dest) ; - } - } - } - Plume_HPGL('U'); return ; + UserToDeviceSize( rsize ); + + Plume_HPGL( 'U' ); + sprintf( cbuf, "PA %d,%d;CI %d;\n", pos.x, pos.y, rsize.x ); + fputs( cbuf, dest ); + if( modetrace == FILLED ) /* Trace en mode Remplissage */ + { + if( delta > 0 ) + { + while( (rayon -= delta ) >= 0 ) + { + rsize.x = rsize.y = rayon; + UserToDeviceSize( rsize ); + sprintf( cbuf, "PA %d,%d; CI %d;\n", pos.x, pos.y, rsize.x ); + fputs( cbuf, dest ); + } + } + } + Plume_HPGL( 'U' ); return; } + /***************************************************************/ -void PlotRectangularPad_HPGL(wxPoint padpos, wxSize padsize, - int orient,int modetrace) +void PlotRectangularPad_HPGL( wxPoint padpos, wxSize padsize, + int orient, int modetrace ) /****************************************************************/ + /* - Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire ) - donne par son centre et ses dimensions X et Y - Units are user units -*/ + * Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire ) + * donne par son centre et ses dimensions X et Y + * Units are user units + */ { -wxSize size; -int delta; -int ox, oy, fx, fy; + wxSize size; + int delta; + int ox, oy, fx, fy; - size.x = padsize.x / 2; size.y = padsize.y / 2 ; - if(modetrace != FILAIRE) - { - size.x = (padsize.x - (int)pen_diam) / 2 ; - size.y = (padsize.y - (int)pen_diam) / 2 ; - } + size.x = padsize.x / 2; size.y = padsize.y / 2; + if( modetrace != FILAIRE ) + { + size.x = (padsize.x - (int) pen_diam) / 2; + size.y = (padsize.y - (int) pen_diam) / 2; + } - if ( (size.x < 0 ) || (size.y < 0) ) - { - nb_plot_erreur++ ; Affiche_erreur(nb_plot_erreur) ; - } - if ( size.x < 0 ) size.x = 0 ; if ( size.y < 0 ) size.y = 0 ; + if( (size.x < 0 ) || (size.y < 0) ) + { + nb_plot_erreur++; Affiche_erreur( nb_plot_erreur ); + } + if( size.x < 0 ) + size.x = 0;if( size.y < 0 ) + size.y = 0; - /* Si une des dimensions est nulle, le trace se reduit a 1 trait */ - if(size.x == 0 ) - { - ox = padpos.x; oy = padpos.y-size.y; - RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); - fx = padpos.x; fy = padpos.y+size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(ox, oy), 'U'); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); - Plume_HPGL('U'); return ; - } - if(size.y == 0 ) - { - ox = padpos.x - size.x; oy = padpos.y; - RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); - fx = padpos.x + size.x; fy = padpos.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(ox, oy), 'U'); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); - Plume_HPGL('U') ; return ; - } + /* Si une des dimensions est nulle, le trace se reduit a 1 trait */ + if( size.x == 0 ) + { + ox = padpos.x; oy = padpos.y - size.y; + RotatePoint( &ox, &oy, padpos.x, padpos.y, orient ); + fx = padpos.x; fy = padpos.y + size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( ox, oy ), 'U' ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); + Plume_HPGL( 'U' ); return; + } + if( size.y == 0 ) + { + ox = padpos.x - size.x; oy = padpos.y; + RotatePoint( &ox, &oy, padpos.x, padpos.y, orient ); + fx = padpos.x + size.x; fy = padpos.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( ox, oy ), 'U' ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); + Plume_HPGL( 'U' ); return; + } - ox = padpos.x - size.x; oy = padpos.y - size.y; - RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(ox, oy), 'U'); + ox = padpos.x - size.x; oy = padpos.y - size.y; + RotatePoint( &ox, &oy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( ox, oy ), 'U' ); - fx = padpos.x - size.x; fy = padpos.y + size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + fx = padpos.x - size.x; fy = padpos.y + size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); - fx = padpos.x + size.x; fy = padpos.y + size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + fx = padpos.x + size.x; fy = padpos.y + size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); - fx = padpos.x + size.x; fy = padpos.y - size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + fx = padpos.x + size.x; fy = padpos.y - size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); - Move_Plume_HPGL( wxPoint(ox, oy), 'D'); + Move_Plume_HPGL( wxPoint( ox, oy ), 'D' ); - if(modetrace != FILLED ) - { - Plume_HPGL('U'); return ; - } + if( modetrace != FILLED ) + { + Plume_HPGL( 'U' ); return; + } - /* Trace en mode Remplissage */ - delta = (int)(pen_diam - pen_recouvrement) ; - if(delta > 0 ) - while( (size.x > 0) && (size.y > 0) ) - { - size.x -= delta; size.y -= delta ; - if ( size.x < 0 ) size.x = 0 ; if ( size.y < 0 ) size.y = 0 ; + /* Trace en mode Remplissage */ + delta = (int) (pen_diam - pen_recouvrement); + if( delta > 0 ) + while( (size.x > 0) && (size.y > 0) ) + { + size.x -= delta; size.y -= delta; + if( size.x < 0 ) + size.x = 0;if( size.y < 0 ) + size.y = 0; - ox = padpos.x - size.x; oy = padpos.y - size.y; - RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(ox, oy), 'D'); + ox = padpos.x - size.x; oy = padpos.y - size.y; + RotatePoint( &ox, &oy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( ox, oy ), 'D' ); - fx = padpos.x - size.x; fy = padpos.y + size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + fx = padpos.x - size.x; fy = padpos.y + size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); - fx = padpos.x + size.x; fy = padpos.y + size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + fx = padpos.x + size.x; fy = padpos.y + size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); - fx = padpos.x + size.x; fy = padpos.y - size.y; - RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); - Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + fx = padpos.x + size.x; fy = padpos.y - size.y; + RotatePoint( &fx, &fy, padpos.x, padpos.y, orient ); + Move_Plume_HPGL( wxPoint( fx, fy ), 'D' ); - Move_Plume_HPGL( wxPoint(ox, oy), 'D'); - } - Plume_HPGL('U'); + Move_Plume_HPGL( wxPoint( ox, oy ), 'D' ); + } + + Plume_HPGL( 'U' ); } /********************************************************************/ -void trace_1_pad_TRAPEZE_HPGL(wxPoint padpos, wxSize size,wxSize delta, - int orient,int modetrace) +void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta, + int orient, int modetrace ) /********************************************************************/ + /* - Trace 1 pad trapezoidal donne par : - son centre padpos.x,padpos.y - ses dimensions dimX et dimY - les variations deltaX et deltaY - son orientation orient et 0.1 degres - le mode de trace (FILLED, SKETCH, FILAIRE) - Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY - = 0. - - les notation des sommets sont ( vis a vis de la table tracante ) - 0 ------------- 3 - . . - . . - . . - 1 --- 2 -*/ + * Trace 1 pad trapezoidal donne par : + * son centre padpos.x,padpos.y + * ses dimensions dimX et dimY + * les variations deltaX et deltaY + * son orientation orient et 0.1 degres + * le mode de trace (FILLED, SKETCH, FILAIRE) + * Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY + * = 0. + * + * les notation des sommets sont ( vis a vis de la table tracante ) + * 0 ------------- 3 + * . . + * . . + * . . + * 1 --- 2 + */ { -int ii , jj; -wxPoint polygone[4]; /* coord des sommets / centre du pad */ -wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */ -float fangle; /* angle d'inclinaison des cotes du trapeze */ -int rayon; /* rayon de la plume */ -int moveX, moveY; /* variation de position plume selon axe X et Y , lors - du remplissage du trapeze */ + int ii, jj; + wxPoint polygone[4]; /* coord des sommets / centre du pad */ + wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */ + float fangle; /* angle d'inclinaison des cotes du trapeze */ + int rayon; /* rayon de la plume */ + int moveX, moveY;/* variation de position plume selon axe X et Y , lors + * du remplissage du trapeze */ - rayon = (int) pen_rayon; if (modetrace == FILAIRE) rayon = 0; - moveX = moveY = rayon; + rayon = (int) pen_rayon; if( modetrace == FILAIRE ) + rayon = 0; + moveX = moveY = rayon; - size.x /= 2; size.y /= 2; - delta.x /= 2; delta.y /= 2; + size.x /= 2; size.y /= 2; + delta.x /= 2; delta.y /= 2; - polygone[0].x = - size.x - delta.y; polygone[0].y = + size.y + delta.x; - polygone[1].x = - size.x + delta.y; polygone[1].y = - size.y - delta.x; - polygone[2].x = + size.x - delta.y; polygone[2].y = - size.y + delta.x; - polygone[3].x = + size.x + delta.y; polygone[3].y = + size.y - delta.x; + polygone[0].x = -size.x - delta.y; polygone[0].y = +size.y + delta.x; + polygone[1].x = -size.x + delta.y; polygone[1].y = -size.y - delta.x; + polygone[2].x = +size.x - delta.y; polygone[2].y = -size.y + delta.x; + polygone[3].x = +size.x + delta.y; polygone[3].y = +size.y - delta.x; - /* Calcul du demi angle d'inclinaison des cotes du trapeze */ - if( delta.y ) /* Trapeze horizontal */ - { - fangle = atan2( (float)(polygone[1].y - polygone[0].y), - (float)(polygone[1].x - polygone[0].x) ) / 2 ; - } + /* Calcul du demi angle d'inclinaison des cotes du trapeze */ + if( delta.y ) /* Trapeze horizontal */ + { + fangle = atan2( (float) (polygone[1].y - polygone[0].y), + (float) (polygone[1].x - polygone[0].x) ) / 2; + } + else + { + fangle = atan2( (float) (polygone[3].y - polygone[0].y), + (float) (polygone[3].x - polygone[0].x) ) / 2; + } - else - { - fangle = atan2( (float)(polygone[3].y - polygone[0].y), - (float)(polygone[3].x - polygone[0].x) ) / 2 ; - } + /* Trace du contour */ + polygone[0].x += moveX; polygone[0].y -= moveY; + polygone[1].x += moveX; polygone[1].y += moveY; + polygone[2].x -= moveX; polygone[2].y += moveY; + polygone[3].x -= moveX; polygone[3].y -= moveY; - /* Trace du contour */ - polygone[0].x += moveX; polygone[0].y -= moveY; - polygone[1].x += moveX; polygone[1].y += moveY; - polygone[2].x -= moveX; polygone[2].y += moveY; - polygone[3].x -= moveX; polygone[3].y -= moveY; + for( ii = 0; ii < 4; ii++ ) + { + coord[ii].x = polygone[ii].x + padpos.x; + coord[ii].y = polygone[ii].y + padpos.y; + RotatePoint( &coord[ii], padpos, orient ); + } - for (ii = 0; ii < 4; ii++) - { - coord[ii].x = polygone[ii].x + padpos.x; - coord[ii].y = polygone[ii].y + padpos.y; - RotatePoint(&coord[ii], padpos, orient); - } + // Plot edge: + Move_Plume_HPGL( coord[0], 'U' ); + Move_Plume_HPGL( coord[1], 'D' ); + Move_Plume_HPGL( coord[2], 'D' ); + Move_Plume_HPGL( coord[3], 'D' ); + Move_Plume_HPGL( coord[0], 'D' ); - // Plot edge: - Move_Plume_HPGL( coord[0], 'U'); - Move_Plume_HPGL( coord[1], 'D'); - Move_Plume_HPGL( coord[2], 'D'); - Move_Plume_HPGL( coord[3], 'D'); - Move_Plume_HPGL( coord[0], 'D'); + if( modetrace != FILLED ) + { + Plume_HPGL( 'U' ); return; + } - if(modetrace != FILLED ) - { - Plume_HPGL('U'); return; - } + /* Fill the shape */ - /* Fill the shape */ + moveX = moveY = pen_diam - pen_recouvrement; + /* calcul de jj = hauteur du remplissage */ + if( delta.y ) /* Trapeze horizontal */ + { + jj = size.y - (int) ( pen_diam + (2 * pen_recouvrement) ); + } + else + { + jj = size.x - (int) ( pen_diam + (2 * pen_recouvrement) ); + } - moveX = moveY = pen_diam - pen_recouvrement; - /* calcul de jj = hauteur du remplissage */ - if( delta.y ) /* Trapeze horizontal */ - { - jj = size.y - (int)( pen_diam + (2 * pen_recouvrement) ); - } - else - { - jj = size.x - (int)( pen_diam + (2 * pen_recouvrement) ); - } - - /* Calcul de jj = nombre de segments a tracer pour le remplissage */ - jj = jj / (int)(pen_diam - pen_recouvrement); + /* Calcul de jj = nombre de segments a tracer pour le remplissage */ + jj = jj / (int) (pen_diam - pen_recouvrement); - /* Trace du contour */ - for( ; jj > 0 ; jj-- ) - { - polygone[0].x += moveX; polygone[0].y -= moveY; - polygone[1].x += moveX; polygone[1].y += moveY; - polygone[2].x -= moveX; polygone[2].y += moveY; - polygone[3].x -= moveX; polygone[3].y -= moveY; + /* Trace du contour */ + for( ; jj > 0; jj-- ) + { + polygone[0].x += moveX; polygone[0].y -= moveY; + polygone[1].x += moveX; polygone[1].y += moveY; + polygone[2].x -= moveX; polygone[2].y += moveY; + polygone[3].x -= moveX; polygone[3].y -= moveY; - /* Test de limitation de variation des dimensions : - si les sommets se "croisent", il ne faut plus modifier les - coordonnees correspondantes */ - if( polygone[0].x > polygone[3].x ) - { /* croisement sur axe X des 2 sommets 0 et 3 */ - polygone[0].x = polygone[3].x = 0; - } - if( polygone[1].x > polygone[2].x ) - { /* croisement sur axe X des 2 sommets 1 et 2 */ - polygone[1].x = polygone[2].x = 0; - } - if( polygone[1].y > polygone[0].y ) - { /* croisement sur axe Y des 2 sommets 0 et 1 */ - polygone[0].y = polygone[1].y = 0; - } - if( polygone[2].y > polygone[3].y ) - { /* croisement sur axe Y des 2 sommets 2 et 3 */ - polygone[2].y = polygone[3].y = 0; - } + /* Test de limitation de variation des dimensions : + * si les sommets se "croisent", il ne faut plus modifier les + * coordonnees correspondantes */ + if( polygone[0].x > polygone[3].x ) + { /* croisement sur axe X des 2 sommets 0 et 3 */ + polygone[0].x = polygone[3].x = 0; + } + if( polygone[1].x > polygone[2].x ) + { /* croisement sur axe X des 2 sommets 1 et 2 */ + polygone[1].x = polygone[2].x = 0; + } + if( polygone[1].y > polygone[0].y ) + { /* croisement sur axe Y des 2 sommets 0 et 1 */ + polygone[0].y = polygone[1].y = 0; + } + if( polygone[2].y > polygone[3].y ) + { /* croisement sur axe Y des 2 sommets 2 et 3 */ + polygone[2].y = polygone[3].y = 0; + } - for (ii = 0; ii < 4; ii++) - { - coord[ii].x = polygone[ii].x + padpos.x; - coord[ii].y = polygone[ii].y + padpos.y; - RotatePoint(&coord[ii], padpos, orient); - } + for( ii = 0; ii < 4; ii++ ) + { + coord[ii].x = polygone[ii].x + padpos.x; + coord[ii].y = polygone[ii].y + padpos.y; + RotatePoint( &coord[ii], padpos, orient ); + } - Move_Plume_HPGL( coord[0], 'U'); - Move_Plume_HPGL( coord[1], 'D'); - Move_Plume_HPGL( coord[2], 'D'); - Move_Plume_HPGL( coord[3], 'D'); - Move_Plume_HPGL( coord[0], 'D'); - } + Move_Plume_HPGL( coord[0], 'U' ); + Move_Plume_HPGL( coord[1], 'D' ); + Move_Plume_HPGL( coord[2], 'D' ); + Move_Plume_HPGL( coord[3], 'D' ); + Move_Plume_HPGL( coord[0], 'D' ); + } - Plume_HPGL('U'); + Plume_HPGL( 'U' ); } /********************************************************************/ -void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, - int epaisseur) +void trace_1_segment_HPGL( int pos_X0, int pos_Y0, int pos_X1, int pos_Y1, + int epaisseur ) /********************************************************************/ /* Trace 1 rectangle donne par son axe et son epaisseur (piste rectangulaire) - en mode SKETCH + * en mode SKETCH */ { -float alpha ; /* angle de l'axe du rectangle */ -wxSize size; /* coord relatives a l'origine du segment de sa fin */ -int dh ; /* demi epaisseur du segment compte tenu de la - largeur de la plume */ -int dx_rot; /* coord du segment en repere modifie ( size.y_rot etant nul )*/ -float sin_alpha, cos_alpha ; + float alpha; /* angle de l'axe du rectangle */ + wxSize size; /* coord relatives a l'origine du segment de sa fin */ + int dh; /* demi epaisseur du segment compte tenu de la + * largeur de la plume */ + int dx_rot; /* coord du segment en repere modifie ( size.y_rot etant nul )*/ + float sin_alpha, cos_alpha; - size.x = pos_X1 - pos_X0; size.y = pos_Y1 - pos_Y0 ; - dh = (epaisseur - (int)pen_diam ) / 2 ; - if ( dh < 0 ) - { - dh = 0 ; nb_plot_erreur++ ; Affiche_erreur(nb_plot_erreur) ; - } + size.x = pos_X1 - pos_X0; size.y = pos_Y1 - pos_Y0; + dh = (epaisseur - (int) pen_diam ) / 2; + if( dh < 0 ) + { + dh = 0; nb_plot_erreur++; Affiche_erreur( nb_plot_erreur ); + } - if ( (dh == 0) || (Plot_Mode == FILAIRE) ) /* Le trace se reduit a 1 trait */ - { - Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0) , 'U'); - Move_Plume_HPGL( wxPoint(pos_X1 , pos_Y1) , 'D'); - Plume_HPGL('U'); - return ; - } + if( (dh == 0) || (Plot_Mode == FILAIRE) ) /* Le trace se reduit a 1 trait */ + { + Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 ), 'U' ); + Move_Plume_HPGL( wxPoint( pos_X1, pos_Y1 ), 'D' ); + Plume_HPGL( 'U' ); + return; + } - if( size.x < 0 ) - { - EXCHG( pos_X0, pos_X1 ) ; EXCHG( pos_Y0, pos_Y1 ); - size.y = - size.y ;size.x = - size.x ; - } + if( size.x < 0 ) + { + EXCHG( pos_X0, pos_X1 ); EXCHG( pos_Y0, pos_Y1 ); + size.y = -size.y; size.x = -size.x; + } - if ( size.y == 0 ) /* segment horizontal */ - { - Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0 - dh) , 'U'); - Move_Plume_HPGL( wxPoint(pos_X1 , pos_Y1 - dh) , 'D'); - Move_Plume_HPGL( wxPoint(pos_X1 , pos_Y1 + dh) , 'D'); - Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0 + dh) , 'D'); - Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0 - dh) , 'D'); - } - else if ( size.x == 0 ) /* vertical */ - { - if( size.y < 0 ) dh = -dh ; - Move_Plume_HPGL( wxPoint(pos_X0 - dh , pos_Y0) , 'U'); - Move_Plume_HPGL( wxPoint(pos_X1 - dh , pos_Y1) , 'D'); - Move_Plume_HPGL( wxPoint(pos_X1 + dh , pos_Y1) , 'D'); - Move_Plume_HPGL( wxPoint(pos_X0 + dh , pos_Y0) , 'D'); - Move_Plume_HPGL( wxPoint(pos_X0 - dh , pos_Y0) , 'D'); - } - else /* piste inclinee */ - { - /* On calcule les coord des extremites du rectangle dans le repere - a axe x confondu avec l'axe du rect. puis on revient dans le repere - de trace par 2 rotations inverses - coord : xrot = x*cos + y*sin - yrot = y*cos - x*sin + if( size.y == 0 ) /* segment horizontal */ + { + Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 - dh ), 'U' ); + Move_Plume_HPGL( wxPoint( pos_X1, pos_Y1 - dh ), 'D' ); + Move_Plume_HPGL( wxPoint( pos_X1, pos_Y1 + dh ), 'D' ); + Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 + dh ), 'D' ); + Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 - dh ), 'D' ); + } + else if( size.x == 0 ) /* vertical */ + { + if( size.y < 0 ) + dh = -dh; + Move_Plume_HPGL( wxPoint( pos_X0 - dh, pos_Y0 ), 'U' ); + Move_Plume_HPGL( wxPoint( pos_X1 - dh, pos_Y1 ), 'D' ); + Move_Plume_HPGL( wxPoint( pos_X1 + dh, pos_Y1 ), 'D' ); + Move_Plume_HPGL( wxPoint( pos_X0 + dh, pos_Y0 ), 'D' ); + Move_Plume_HPGL( wxPoint( pos_X0 - dh, pos_Y0 ), 'D' ); + } + else /* piste inclinee */ + { + /* On calcule les coord des extremites du rectangle dans le repere + * a axe x confondu avec l'axe du rect. puis on revient dans le repere + * de trace par 2 rotations inverses + * coord : xrot = x*cos + y*sin + * yrot = y*cos - x*sin + * + * avec ici yrot = 0 puisque le segment est horizontal dans le nouveau repere + * Transformee inverse : + * coord : x = xrot*cos - yrot*sin + * y = yrot*cos + xrot*sin + */ - avec ici yrot = 0 puisque le segment est horizontal dans le nouveau repere - Transformee inverse : - coord : x = xrot*cos - yrot*sin - y = yrot*cos + xrot*sin - */ + int dx0, dy0, dx1, dy1; - int dx0,dy0, dx1,dy1; + if( size.x == size.y ) /* alpah = 45 degre */ + { + sin_alpha = cos_alpha = 0.70711; + } + else if( size.x == -size.y ) /* alpah = -45 degre */ + { + cos_alpha = 0.70711; sin_alpha = -0.70711; + } + else + { + alpha = atan2( (float) size.y, (float) size.x ); + sin_alpha = sin( alpha ); + cos_alpha = cos( alpha ); + } - if( size.x == size.y ) /* alpah = 45 degre */ - { - sin_alpha = cos_alpha = 0.70711 ; - } - else if( size.x == -size.y ) /* alpah = -45 degre */ - { - cos_alpha = 0.70711 ; sin_alpha = -0.70711 ; - } - else - { - alpha = atan2((float)size.y,(float)size.x) ; - sin_alpha = sin(alpha) ; - cos_alpha = cos(alpha) ; - } + dx_rot = (int) (size.x * cos_alpha + size.y * sin_alpha); + /* size.y_rot = (int)(size.y * cos_alpha - size.x * sin_alpha) ; doit etre NULL */ - dx_rot = (int)(size.x * cos_alpha + size.y * sin_alpha) ; - /* size.y_rot = (int)(size.y * cos_alpha - size.x * sin_alpha) ; doit etre NULL */ + /* calcul du point de coord 0,-dh */ + dx0 = (int) ( dh * sin_alpha); + dy0 = (int) (-dh * cos_alpha ); + Move_Plume_HPGL( wxPoint( pos_X0 + dx0, pos_Y0 + dy0 ), 'U' ); - /* calcul du point de coord 0,-dh */ - dx0 =(int) ( dh * sin_alpha) ; - dy0 =(int) (- dh*cos_alpha ) ; - Move_Plume_HPGL( wxPoint(pos_X0 + dx0 , pos_Y0 + dy0) , 'U'); + /* calcul du point de coord size.xrot,-dh */ + dx1 = (int) (dx_rot * cos_alpha + dh * sin_alpha); + dy1 = (int) (-dh * cos_alpha + dx_rot * sin_alpha ); + Move_Plume_HPGL( wxPoint( pos_X0 + dx1, pos_Y0 + dy1 ), 'D' ); - /* calcul du point de coord size.xrot,-dh */ - dx1 =(int) (dx_rot*cos_alpha + dh * sin_alpha) ; - dy1 =(int) (-dh*cos_alpha + dx_rot*sin_alpha ) ; - Move_Plume_HPGL( wxPoint(pos_X0 + dx1 , pos_Y0 + dy1) , 'D'); + /* calcul du point de coord size.xrot,+dh */ + dx1 = (int) (dx_rot * cos_alpha - dh * sin_alpha); + dy1 = (int) (dh * cos_alpha + dx_rot * sin_alpha ); + Move_Plume_HPGL( wxPoint( pos_X0 + dx1, pos_Y0 + dy1 ), 'D' ); - /* calcul du point de coord size.xrot,+dh */ - dx1 =(int) (dx_rot*cos_alpha - dh * sin_alpha) ; - dy1 =(int) (dh*cos_alpha + dx_rot*sin_alpha ) ; - Move_Plume_HPGL( wxPoint(pos_X0 + dx1 , pos_Y0 + dy1) , 'D'); + /* calcul du point de coord 0,+dh */ + dx1 = (int) ( -dh * sin_alpha); + dy1 = (int) (dh * cos_alpha ); + Move_Plume_HPGL( wxPoint( pos_X0 + dx1, pos_Y0 + dy1 ), 'D' ); - /* calcul du point de coord 0,+dh */ - dx1 =(int) ( - dh * sin_alpha) ; - dy1 =(int) (dh*cos_alpha ) ; - Move_Plume_HPGL( wxPoint(pos_X0 + dx1 , pos_Y0 + dy1) , 'D'); - - /* retour au point de depart */ - Move_Plume_HPGL( wxPoint(pos_X0 + dx0 , pos_Y0 + dy0) , 'D'); - } - Plume_HPGL('U'); + /* retour au point de depart */ + Move_Plume_HPGL( wxPoint( pos_X0 + dx0, pos_Y0 + dy0 ), 'D' ); + } + Plume_HPGL( 'U' ); } - - - diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index 7163ef5281..8d357579ad 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -1,6 +1,6 @@ - /*************************************/ - /**** Pcbnew: Routine de trace PS ****/ - /*************************************/ +/*************************************/ +/**** Pcbnew: Routine de trace PS ****/ +/*************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -16,407 +16,416 @@ #include "wx/defs.h" // Routines Locales -static void PrintDrillMark(BOARD * Pcb); -static Ki_PageDescr * SheetPS; +static void PrintDrillMark( BOARD* Pcb ); + +static Ki_PageDescr* SheetPS; // variables locales: -const int DRILL_MARK = 1; +const int DRILL_MARK = 1; /****************************************************************************/ -void WinEDA_BasePcbFrame::Genere_PS(const wxString & FullFileName, int Layer) +void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) /****************************************************************************/ /* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer * if layer < 0: all layers */ { -int modetrace, tracevia; -wxSize PcbSheetSize; -wxSize PaperSize; -wxSize BoardSize; -wxPoint BoardCenter; -bool Center = FALSE; -Ki_PageDescr * currentsheet = m_CurrentScreen->m_CurrentSheet; -double scale_format; // Facteur correctif pour conversion forlat Ax->A4 -double scale_x, scale_y; -int PlotMarge_in_mils = 0; + int modetrace, tracevia; + wxSize PcbSheetSize; + wxSize PaperSize; + wxSize BoardSize; + wxPoint BoardCenter; + bool Center = FALSE; + Ki_PageDescr* currentsheet = m_CurrentScreen->m_CurrentSheet; + double scale_format; // Facteur correctif pour conversion forlat Ax->A4 + double scale_x, scale_y; + int PlotMarge_in_mils = 0; - MsgPanel->EraseMsgBox(); + MsgPanel->EraseMsgBox(); - dest = wxFopen( FullFileName, wxT("wt") ); - if( dest == NULL ) - { - wxString msg = _("Unable to create file ") + FullFileName; - DisplayError(this, msg); - return; - } + dest = wxFopen( FullFileName, wxT( "wt" ) ); + if( dest == NULL ) + { + wxString msg = _( "Unable to create file " ) + FullFileName; + DisplayError( this, msg ); + return; + } - setlocale(LC_NUMERIC, "C"); + setlocale( LC_NUMERIC, "C" ); - Affiche_1_Parametre(this, 0, _("File"), FullFileName, CYAN); + Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN ); - if( g_PlotScaleOpt != 1 ) - Center = TRUE; // Echelle != 1 donc trace centree du PCB - modetrace = Plot_Mode; - scale_format = 1.0; - // Set default line width - if( g_PlotLine_Width < 1 ) - g_PlotLine_Width = 1; + if( g_PlotScaleOpt != 1 ) + Center = TRUE; // Echelle != 1 donc trace centree du PCB + modetrace = Plot_Mode; + scale_format = 1.0; - // calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce ) - PcbSheetSize.x = currentsheet->m_Size.x * U_PCB; - PcbSheetSize.y = currentsheet->m_Size.y * U_PCB; - if( g_ForcePlotPS_On_A4 ) - { - SheetPS = &g_Sheet_A4; - PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB; - PaperSize.y = g_Sheet_A4.m_Size.y * U_PCB; - scale_format = (float) PaperSize.x / PcbSheetSize.x; - } - else - { - SheetPS = currentsheet; - PaperSize = PcbSheetSize; - } + // Set default line width + if( g_PlotLine_Width < 1 ) + g_PlotLine_Width = 1; - // calcul de l'offset de trace: - // calcul du cadrage horizontal du mode paysage ( val algebr. plus grande = decalage a gauche ) - g_PlotOffset.x = PlotMarge_in_mils * U_PCB; - // cadrage vertical du mode paysage ( val algebr. plus grande = decalage vers le haut ) - g_PlotOffset.y = PaperSize.y - PlotMarge_in_mils * U_PCB; + // calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce ) + PcbSheetSize.x = currentsheet->m_Size.x * U_PCB; + PcbSheetSize.y = currentsheet->m_Size.y * U_PCB; + if( g_ForcePlotPS_On_A4 ) + { + SheetPS = &g_Sheet_A4; + PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB; + PaperSize.y = g_Sheet_A4.m_Size.y * U_PCB; + scale_format = (float) PaperSize.x / PcbSheetSize.x; + } + else + { + SheetPS = currentsheet; + PaperSize = PcbSheetSize; + } - int BBox[4]; - BBox[0] = BBox[1] = PlotMarge_in_mils; - BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; - BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; - scale_x = scale_y = 1.0; - InitPlotParametresPS( g_PlotOffset, SheetPS, 1.0 / m_InternalUnits, 1.0 / m_InternalUnits ); - SetDefaultLineWidthPS(g_PlotLine_Width); - PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, 1, BBox, wxLANDSCAPE); + // calcul de l'offset de trace: + // calcul du cadrage horizontal du mode paysage ( val algebr. plus grande = decalage a gauche ) + g_PlotOffset.x = PlotMarge_in_mils * U_PCB; - if( Plot_Sheet_Ref ) - { - int tmp = g_PlotOrient; - g_PlotOrient = 0; - SetPlotScale( 1.0, 1.0 ); - PlotWorkSheet( PLOT_FORMAT_POST, m_CurrentScreen ); - g_PlotOrient = tmp; - } + // cadrage vertical du mode paysage ( val algebr. plus grande = decalage vers le haut ) + g_PlotOffset.y = PaperSize.y - PlotMarge_in_mils * U_PCB; - // calcul des dimensions et centre du PCB - m_Pcb->ComputeBoundaryBox(); - BoardSize = m_Pcb->m_BoundaryBox.GetSize(); - BoardCenter = m_Pcb->m_BoundaryBox.Centre(); + int BBox[4]; + BBox[0] = BBox[1] = PlotMarge_in_mils; + BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; + BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; + scale_x = scale_y = 1.0; + InitPlotParametresPS( g_PlotOffset, SheetPS, 1.0 / m_InternalUnits, 1.0 / m_InternalUnits ); + SetDefaultLineWidthPS( g_PlotLine_Width ); + PrintHeaderPS( dest, wxT( "PCBNEW-PS" ), FullFileName, 1, BBox, wxLANDSCAPE ); - scale_x = Scale_X; - scale_y = Scale_Y; - if( g_PlotScaleOpt == 0 ) // Optimum scale - { - float Xscale, Yscale; - int noprint_size = 2 * PlotMarge_in_mils * U_PCB; - if( Plot_Sheet_Ref ) - noprint_size += 500 * U_PCB; - Xscale = (float) ( PaperSize.x - noprint_size ) / BoardSize.x; - Yscale = (float) ( PaperSize.y - noprint_size ) / BoardSize.y; - scale_x = scale_y = min( Xscale, Yscale ); - } + if( Plot_Sheet_Ref ) + { + int tmp = g_PlotOrient; + g_PlotOrient = 0; + SetPlotScale( 1.0, 1.0 ); + PlotWorkSheet( PLOT_FORMAT_POST, m_CurrentScreen ); + g_PlotOrient = tmp; + } - BoardCenter.x = (int)(BoardCenter.x * scale_x); - BoardCenter.y = (int)(BoardCenter.y * scale_y); + // calcul des dimensions et centre du PCB + m_Pcb->ComputeBoundaryBox(); + BoardSize = m_Pcb->m_BoundaryBox.GetSize(); + BoardCenter = m_Pcb->m_BoundaryBox.Centre(); - // Calcul du cadrage (echelle != 1 donc recadrage du trace) - if( Center ) - { - g_PlotOffset.x -= PaperSize.x / 2 - BoardCenter.x + PlotMarge_in_mils * U_PCB; - g_PlotOffset.y = PaperSize.y / 2 + BoardCenter.y; // cadrage horizontal du mode paysage - } + scale_x = Scale_X; + scale_y = Scale_Y; + if( g_PlotScaleOpt == 0 ) // Optimum scale + { + float Xscale, Yscale; + int noprint_size = 2 * PlotMarge_in_mils * U_PCB; + if( Plot_Sheet_Ref ) + noprint_size += 500 * U_PCB; + Xscale = (float) ( PaperSize.x - noprint_size ) / BoardSize.x; + Yscale = (float) ( PaperSize.y - noprint_size ) / BoardSize.y; + scale_x = scale_y = MIN( Xscale, Yscale ); + } - if( g_PlotOrient == PLOT_MIROIR ) - { - if( Center ) - g_PlotOffset.y = - PaperSize.y / 2 + BoardCenter.y; - else - g_PlotOffset.y = - PaperSize.y + m_Pcb->m_BoundaryBox.GetBottom() - + m_Pcb->m_BoundaryBox.GetY() + PlotMarge_in_mils * U_PCB; - } + BoardCenter.x = (int) (BoardCenter.x * scale_x); + BoardCenter.y = (int) (BoardCenter.y * scale_y); - InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y, g_PlotOrient ); + // Calcul du cadrage (echelle != 1 donc recadrage du trace) + if( Center ) + { + g_PlotOffset.x -= PaperSize.x / 2 - BoardCenter.x + PlotMarge_in_mils * U_PCB; + g_PlotOffset.y = PaperSize.y / 2 + BoardCenter.y; // cadrage horizontal du mode paysage + } - // If plot a negative board: - // Draw a black rectangle (background for plot board in white) - // and switch the current color to WHITE - if( g_Plot_PS_Negative ) - { - int Rectangle[10]; // Put here the board corners - int margin = 500; // Add a 0.1 inch margin around the board - Rectangle[0] = m_Pcb->m_BoundaryBox.GetX() - margin; - Rectangle[1] = m_Pcb->m_BoundaryBox.GetY() - margin; - Rectangle[2] = m_Pcb->m_BoundaryBox.GetRight() + margin; - Rectangle[3] = Rectangle[1]; - Rectangle[4] = Rectangle[2]; - Rectangle[5] = m_Pcb->m_BoundaryBox.GetBottom() + margin; - Rectangle[6] = Rectangle[0]; - Rectangle[7] = Rectangle[5]; - Rectangle[8] = Rectangle[0]; - Rectangle[9] = Rectangle[1]; - SetColorMapPS(BLACK); - PlotPolyPS( 5, Rectangle, TRUE ); - SetColorMapPS(WHITE); - } - - switch(Layer) - { - case -1: - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); - break; - - case CUIVRE_N : - case LAYER_N_2 : - case LAYER_N_3 : - case LAYER_N_4 : - case LAYER_N_5 : - case LAYER_N_6 : - case LAYER_N_7 : - case LAYER_N_8 : - case LAYER_N_9 : - case LAYER_N_10 : - case LAYER_N_11: - case LAYER_N_12: - case LAYER_N_13 : - case LAYER_N_14 : - case LAYER_N_15 : - case CMP_N : - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); - break; + if( g_PlotOrient == PLOT_MIROIR ) + { + if( Center ) + g_PlotOffset.y = -PaperSize.y / 2 + BoardCenter.y; + else + g_PlotOffset.y = -PaperSize.y + m_Pcb->m_BoundaryBox.GetBottom() + + m_Pcb->m_BoundaryBox.GetY() + PlotMarge_in_mils * U_PCB; + } - case SILKSCREEN_N_CU : - case SILKSCREEN_N_CMP : - Plot_Serigraphie(PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer]); - break; + InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y, g_PlotOrient ); - case SOLDERMASK_N_CU : - case SOLDERMASK_N_CMP : // Trace du vernis epargne - if( g_DrawViaOnMaskLayer ) - tracevia = 1; - else - tracevia = 0; - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], g_DesignSettings.m_MaskMargin, - tracevia, modetrace); - break; + // If plot a negative board: + // Draw a black rectangle (background for plot board in white) + // and switch the current color to WHITE + if( g_Plot_PS_Negative ) + { + int Rectangle[10]; // Put here the board corners + int margin = 500; // Add a 0.1 inch margin around the board + Rectangle[0] = m_Pcb->m_BoundaryBox.GetX() - margin; + Rectangle[1] = m_Pcb->m_BoundaryBox.GetY() - margin; + Rectangle[2] = m_Pcb->m_BoundaryBox.GetRight() + margin; + Rectangle[3] = Rectangle[1]; + Rectangle[4] = Rectangle[2]; + Rectangle[5] = m_Pcb->m_BoundaryBox.GetBottom() + margin; + Rectangle[6] = Rectangle[0]; + Rectangle[7] = Rectangle[5]; + Rectangle[8] = Rectangle[0]; + Rectangle[9] = Rectangle[1]; + SetColorMapPS( BLACK ); + PlotPolyPS( 5, Rectangle, TRUE ); + SetColorMapPS( WHITE ); + } - case SOLDERPASTE_N_CU : - case SOLDERPASTE_N_CMP : // Trace du masque de pate de soudure - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 0, modetrace); - break; + switch( Layer ) + { + case - 1: + Plot_Layer_PS( dest, g_TabOneLayerMask[Layer], 0, 1, modetrace ); + break; - default: - Plot_Serigraphie(PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer]); - break; - } - // fin - CloseFilePS(dest); - setlocale(LC_NUMERIC, ""); + case CUIVRE_N: + case LAYER_N_2: + case LAYER_N_3: + case LAYER_N_4: + case LAYER_N_5: + case LAYER_N_6: + case LAYER_N_7: + case LAYER_N_8: + case LAYER_N_9: + case LAYER_N_10: + case LAYER_N_11: + case LAYER_N_12: + case LAYER_N_13: + case LAYER_N_14: + case LAYER_N_15: + case CMP_N: + Plot_Layer_PS( dest, g_TabOneLayerMask[Layer], 0, 1, modetrace ); + break; + + case SILKSCREEN_N_CU: + case SILKSCREEN_N_CMP: + Plot_Serigraphie( PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer] ); + break; + + case SOLDERMASK_N_CU: + case SOLDERMASK_N_CMP: // Trace du vernis epargne + if( g_DrawViaOnMaskLayer ) + tracevia = 1; + else + tracevia = 0; + Plot_Layer_PS( dest, g_TabOneLayerMask[Layer], g_DesignSettings.m_MaskMargin, + tracevia, modetrace ); + break; + + case SOLDERPASTE_N_CU: + case SOLDERPASTE_N_CMP: // Trace du masque de pate de soudure + Plot_Layer_PS( dest, g_TabOneLayerMask[Layer], 0, 0, modetrace ); + break; + + default: + Plot_Serigraphie( PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer] ); + break; + } + + // fin + CloseFilePS( dest ); + setlocale( LC_NUMERIC, "" ); } /********************************************************************/ -void WinEDA_BasePcbFrame::Plot_Layer_PS(FILE * File,int masque_layer, - int garde, int tracevia, int modetrace) +void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, + int garde, int tracevia, int modetrace ) /********************************************************************/ /* Trace en format POSTSCRIPT d'une couche cuivre ou masque */ { -wxPoint pos, end; -wxSize size; -MODULE * Module; -D_PAD * PtPad; -TRACK * pts ; -EDA_BaseStruct * PtStruct; -wxString msg; - - masque_layer |= EDGE_LAYER; // Les elements de la couche EDGE sont tj traces + wxPoint pos, end; + wxSize size; + MODULE* Module; + D_PAD* PtPad; + TRACK* pts; + BOARD_ITEM* PtStruct; + wxString msg; - // trace des elements type Drawings Pcb : - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_POST, - masque_layer); - break; + masque_layer |= EDGE_LAYER; // Les elements de la couche EDGE sont tj traces - case TYPETEXTE: - PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_POST, - masque_layer); - break; + // trace des elements type Drawings Pcb : + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_POST, + masque_layer ); + break; - case TYPECOTATION: - PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_POST, - masque_layer); - break; + case TYPETEXTE: + PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_POST, + masque_layer ); + break; - case TYPEMIRE: - PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_POST, - masque_layer); - break; + case TYPECOTATION: + PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_POST, + masque_layer ); + break; - case TYPEMARQUEUR: - break; + case TYPEMIRE: + PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_POST, + masque_layer ); + break; - default: - DisplayError(this, wxT("WinEDA_BasePcbFrame::Plot_Layer_PS() : Unexpected Draw Type")); - break; - } - } + case TYPEMARQUEUR: + break; - // Trace des Elements des modules autres que pads - nb_items = 0; - Affiche_1_Parametre(this, 48, wxT("DrawMod"), wxEmptyString, GREEN); - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) - { - PtStruct = Module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEEDGEMODULE: - if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) - Plot_1_EdgeModule(PLOT_FORMAT_POST, (EDGE_MODULE*) PtStruct); - break; + default: + DisplayError( this, + wxT( "WinEDA_BasePcbFrame::Plot_Layer_PS() : Unexpected Draw Type" ) ); + break; + } + } - default: - break; - } - } - } + // Trace des Elements des modules autres que pads + nb_items = 0; + Affiche_1_Parametre( this, 48, wxT( "DrawMod" ), wxEmptyString, GREEN ); + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + if( masque_layer & g_TabOneLayerMask[ PtStruct->GetLayer() ] ) + Plot_1_EdgeModule( PLOT_FORMAT_POST, (EDGE_MODULE*) PtStruct ); + break; - // Trace des Elements des modules : Pastilles - nb_items = 0; - Affiche_1_Parametre(this, 48, wxT("Pads "), wxEmptyString, GREEN); - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) - { - PtPad = (D_PAD*) Module->m_Pads; - for( ; PtPad != NULL; PtPad = (D_PAD*)PtPad->Pnext ) - { - if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) - continue; - wxPoint shape_pos = PtPad->ReturnShapePos(); - pos = shape_pos; + default: + break; + } + } + } - size.x = PtPad->m_Size.x + garde * 2; - size.y = PtPad->m_Size.y + garde * 2; + // Trace des Elements des modules : Pastilles + nb_items = 0; + Affiche_1_Parametre( this, 48, wxT( "Pads " ), wxEmptyString, GREEN ); + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) + continue; + wxPoint shape_pos = PtPad->ReturnShapePos(); + pos = shape_pos; - nb_items++; + size.x = PtPad->m_Size.x + garde * 2; + size.y = PtPad->m_Size.y + garde * 2; - switch (PtPad->m_PadShape) - { - case CIRCLE : - trace_1_pastille_RONDE_POST(pos, size.x, modetrace); - break; + nb_items++; - case OVALE : - trace_1_pastille_OVALE_POST(pos, size, PtPad->m_Orient, modetrace); - break; + switch( PtPad->m_PadShape ) + { + case CIRCLE: + trace_1_pastille_RONDE_POST( pos, size.x, modetrace ); + break; - case TRAPEZE : - { - wxSize delta; - delta = PtPad->m_DeltaSize; - trace_1_pad_TRAPEZE_POST(pos, size, delta, - PtPad->m_Orient, modetrace); - break; - } + case OVALE: + trace_1_pastille_OVALE_POST( pos, size, PtPad->m_Orient, modetrace ); + break; - case RECT: - default: - trace_1_pad_rectangulaire_POST(pos, size, PtPad->m_Orient, modetrace); - break; - } - msg.Printf( wxT("%d"), nb_items ); - Affiche_1_Parametre(this, 48, wxT("Pads"), msg, GREEN); - } - } - // trace des VIAS : - if( tracevia ) - { - nb_items = 0; - Affiche_1_Parametre(this, 56,_("Vias"), wxEmptyString, RED); - for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) - { - if( pts->m_StructType != TYPEVIA ) - continue; - SEGVIA * Via = (SEGVIA *) pts; - // vias not plotted if not on selected layer, but if layer - // == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn, - // if they are on a external copper layer - int via_mask_layer = Via->ReturnMaskLayer(); - if( via_mask_layer & CUIVRE_LAYER ) - via_mask_layer |= SOLDERMASK_LAYER_CU; - if ( via_mask_layer & CMP_LAYER ) - via_mask_layer |= SOLDERMASK_LAYER_CMP; - if( (via_mask_layer & masque_layer) == 0 ) - continue; + case TRAPEZE: + { + wxSize delta; + delta = PtPad->m_DeltaSize; + trace_1_pad_TRAPEZE_POST( pos, size, delta, + PtPad->m_Orient, modetrace ); + break; + } - pos = Via->m_Start; - size.x = size.y = Via->m_Width + garde * 2; - trace_1_pastille_RONDE_POST(pos, size.x, modetrace); - nb_items++; - msg.Printf( wxT("%d"), nb_items ); - Affiche_1_Parametre(this, 56, wxEmptyString, msg, RED); - } - } - // trace des pistes et zones: - nb_items = 0; - Affiche_1_Parametre(this, 64, _("Tracks"), wxEmptyString, YELLOW); + case RECT: + default: + trace_1_pad_rectangulaire_POST( pos, size, PtPad->m_Orient, modetrace ); + break; + } - for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) - { - if( pts->m_StructType == TYPEVIA ) - continue; + msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 48, wxT( "Pads" ), msg, GREEN ); + } + } - if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) - continue; - size.x = size.y = pts->m_Width; - pos = pts->m_Start; - end = pts->m_End; + // trace des VIAS : + if( tracevia ) + { + nb_items = 0; + Affiche_1_Parametre( this, 56, _( "Vias" ), wxEmptyString, RED ); + for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) + { + if( pts->m_StructType != TYPEVIA ) + continue; + SEGVIA* Via = (SEGVIA*) pts; - PlotFilledSegmentPS(pos, end, size.x); + // vias not plotted if not on selected layer, but if layer + // == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn, + // if they are on a external copper layer + int via_mask_layer = Via->ReturnMaskLayer(); + if( via_mask_layer & CUIVRE_LAYER ) + via_mask_layer |= SOLDERMASK_LAYER_CU; + if( via_mask_layer & CMP_LAYER ) + via_mask_layer |= SOLDERMASK_LAYER_CMP; + if( (via_mask_layer & masque_layer) == 0 ) + continue; - nb_items++; - msg.Printf( wxT("%d"), nb_items ); - Affiche_1_Parametre(this, 64, wxEmptyString, msg, YELLOW); - } + pos = Via->m_Start; + size.x = size.y = Via->m_Width + garde * 2; + trace_1_pastille_RONDE_POST( pos, size.x, modetrace ); + nb_items++; + msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 56, wxEmptyString, msg, RED ); + } + } - nb_items = 0; - Affiche_1_Parametre(this, 64, wxT("Zones "), wxEmptyString, YELLOW); + // trace des pistes et zones: + nb_items = 0; + Affiche_1_Parametre( this, 64, _( "Tracks" ), wxEmptyString, YELLOW ); - for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext ) - { - if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) - continue; - size.x = size.y = pts->m_Width; - pos = pts->m_Start; - end = pts->m_End; - PlotFilledSegmentPS(pos, end, size.x); - nb_items++; - msg.Printf( wxT("%d"), nb_items ); - Affiche_1_Parametre(this, 64, wxEmptyString, msg, YELLOW); - } + for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) + { + if( pts->m_StructType == TYPEVIA ) + continue; - // Trace des trous de percage - if( modetrace == FILLED ) - PrintDrillMark(m_Pcb); + if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) + continue; + size.x = size.y = pts->m_Width; + pos = pts->m_Start; + end = pts->m_End; + + PlotFilledSegmentPS( pos, end, size.x ); + + nb_items++; + msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 64, wxEmptyString, msg, YELLOW ); + } + + nb_items = 0; + Affiche_1_Parametre( this, 64, wxT( "Zones " ), wxEmptyString, YELLOW ); + + for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext ) + { + if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) + continue; + size.x = size.y = pts->m_Width; + pos = pts->m_Start; + end = pts->m_End; + PlotFilledSegmentPS( pos, end, size.x ); + nb_items++; + msg.Printf( wxT( "%d" ), nb_items ); + Affiche_1_Parametre( this, 64, wxEmptyString, msg, YELLOW ); + } + + // Trace des trous de percage + if( modetrace == FILLED ) + PrintDrillMark( m_Pcb ); } /*************************************/ -static void PrintDrillMark(BOARD * Pcb) +static void PrintDrillMark( BOARD* Pcb ) /*************************************/ /* Draw a drill mark for pads and vias. @@ -424,64 +433,64 @@ static void PrintDrillMark(BOARD * Pcb) * redraw the drill mark on a pad or via */ { -const int SMALL_DRILL = 150; -wxPoint pos; -wxSize diam; -MODULE * Module; -D_PAD * PtPad; -TRACK * pts ; + const int SMALL_DRILL = 150; + wxPoint pos; + wxSize diam; + MODULE* Module; + D_PAD* PtPad; + TRACK* pts; - if( g_DrillShapeOpt == 0 ) - return; + if( g_DrillShapeOpt == 0 ) + return; - if( g_Plot_PS_Negative ) - fprintf(dest, " 0 setgray\n"); - else - fprintf(dest, " 1 setgray\n"); + if( g_Plot_PS_Negative ) + fprintf( dest, " 0 setgray\n" ); + else + fprintf( dest, " 1 setgray\n" ); - diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : - g_DesignSettings.m_ViaDrill; + diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : + g_DesignSettings.m_ViaDrill; - for( pts = Pcb->m_Track; pts != NULL; pts = (TRACK*)pts->Pnext ) - { - if( pts->m_StructType != TYPEVIA ) - continue; - pos = pts->m_Start; - if( g_DrillShapeOpt == DRILL_MARK ) - diam.x = diam.y = SMALL_DRILL; - else - { - if( pts->m_Drill < 0 ) - diam.x = diam.y = g_DesignSettings.m_ViaDrill; - else - diam.x = diam.y = pts->m_Drill; - } - trace_1_pastille_RONDE_POST(pos, diam.x, FILLED); - } + for( pts = Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) + { + if( pts->m_StructType != TYPEVIA ) + continue; + pos = pts->m_Start; + if( g_DrillShapeOpt == DRILL_MARK ) + diam.x = diam.y = SMALL_DRILL; + else + { + if( pts->m_Drill < 0 ) + diam.x = diam.y = g_DesignSettings.m_ViaDrill; + else + diam.x = diam.y = pts->m_Drill; + } + trace_1_pastille_RONDE_POST( pos, diam.x, FILLED ); + } - Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) - { - PtPad = (D_PAD*) Module->m_Pads; - for ( ; PtPad != NULL; PtPad = (D_PAD*)PtPad->Pnext ) - { - if( PtPad->m_Drill.x == 0 ) - continue; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + if( PtPad->m_Drill.x == 0 ) + continue; - // calcul de la position des trous, selon echelle - pos = PtPad->m_Pos; - diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : - PtPad->m_Drill.x; - trace_1_pastille_RONDE_POST(pos, diam.x, FILLED); - } - } + // calcul de la position des trous, selon echelle + pos = PtPad->m_Pos; + diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : + PtPad->m_Drill.x; + trace_1_pastille_RONDE_POST( pos, diam.x, FILLED ); + } + } - fprintf(dest, " 0 setgray\n"); + fprintf( dest, " 0 setgray\n" ); } /***********************************************************************************/ -void trace_1_pastille_OVALE_POST(wxPoint pos, wxSize size, int orient, int modetrace) +void trace_1_pastille_OVALE_POST( wxPoint pos, wxSize size, int orient, int modetrace ) /************************************************************************************/ /* Trace 1 pastille OVALE en position pos_X,Y: @@ -490,103 +499,104 @@ void trace_1_pastille_OVALE_POST(wxPoint pos, wxSize size, int orient, int modet * La forme est tracee comme un segment */ { -int x0, y0, x1, y1, delta; -int w, rayon; + int x0, y0, x1, y1, delta; + int w, rayon; - // la pastille est ramenee a une pastille ovale avec dy > dx - if( size.x > size.y ) - { - EXCHG(size.x, size.y); - orient += 900; - if( orient >= 3600 ) - orient -= 3600; - } + // la pastille est ramenee a une pastille ovale avec dy > dx + if( size.x > size.y ) + { + EXCHG( size.x, size.y ); + orient += 900; + if( orient >= 3600 ) + orient -= 3600; + } - delta = size.y - size.x; - x0 = 0; - y0 = -delta / 2; - x1 = 0; - y1 = delta / 2; - RotatePoint(&x0, &y0, orient); - RotatePoint(&x1, &y1, orient); + delta = size.y - size.x; + x0 = 0; + y0 = -delta / 2; + x1 = 0; + y1 = delta / 2; + RotatePoint( &x0, &y0, orient ); + RotatePoint( &x1, &y1, orient ); - if( modetrace == FILLED ) - { - PlotFilledSegmentPS(wxPoint(pos.x + x0, pos.y + y0), - wxPoint(pos.x + x1, pos.y + y1), size.x); - } - else - { - w = g_PlotLine_Width; - rayon = (size.x - w) / 2; - if( rayon < 1 ) - rayon = 1; - if( rayon < w ) - w = rayon; - PlotArcPS( wxPoint(pos.x + x1, pos.y + y1), -orient, -orient + 1800, rayon, w ); - PlotArcPS( wxPoint(pos.x + x0, pos.y + y0), -orient + 1800, -orient, rayon, w ); + if( modetrace == FILLED ) + { + PlotFilledSegmentPS( wxPoint( pos.x + x0, pos.y + y0 ), + wxPoint( pos.x + x1, pos.y + y1 ), size.x ); + } + else + { + w = g_PlotLine_Width; + rayon = (size.x - w) / 2; + if( rayon < 1 ) + rayon = 1; + if( rayon < w ) + w = rayon; + PlotArcPS( wxPoint( pos.x + x1, pos.y + y1 ), -orient, -orient + 1800, rayon, w ); + PlotArcPS( wxPoint( pos.x + x0, pos.y + y0 ), -orient + 1800, -orient, rayon, w ); - x0 = -rayon; - y0 = -delta / 2; - x1 = -rayon; - y1 = delta / 2; - RotatePoint(&x0, &y0, orient); - RotatePoint(&x1, &y1, orient); - PlotFilledSegmentPS( wxPoint(pos.x + x0, pos.y + y0), - wxPoint(pos.x + x1, pos.y + y1), w ); + x0 = -rayon; + y0 = -delta / 2; + x1 = -rayon; + y1 = delta / 2; + RotatePoint( &x0, &y0, orient ); + RotatePoint( &x1, &y1, orient ); + PlotFilledSegmentPS( wxPoint( pos.x + x0, pos.y + y0 ), + wxPoint( pos.x + x1, pos.y + y1 ), w ); - x0 = rayon; - y0 = -delta / 2; - x1 = rayon; - y1 = delta / 2; - RotatePoint(&x0, &y0, orient); - RotatePoint(&x1, &y1, orient); - PlotFilledSegmentPS( wxPoint(pos.x + x0, pos.y + y0), - wxPoint(pos.x + x1, pos.y + y1), w ); - } + x0 = rayon; + y0 = -delta / 2; + x1 = rayon; + y1 = delta / 2; + RotatePoint( &x0, &y0, orient ); + RotatePoint( &x1, &y1, orient ); + PlotFilledSegmentPS( wxPoint( pos.x + x0, pos.y + y0 ), + wxPoint( pos.x + x1, pos.y + y1 ), w ); + } } /*******************************************************************************/ -void trace_1_pastille_RONDE_POST(wxPoint centre, int diametre, int modetrace) +void trace_1_pastille_RONDE_POST( wxPoint centre, int diametre, int modetrace ) /*******************************************************************************/ /* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y */ { -int rayon, w; -wxSize diam(diametre, diametre); + int rayon, w; - UserToDeviceCoordinate(centre); - UserToDeviceSize(diam); + wxSize diam( diametre, diametre ); - if( modetrace == FILLED ) - { - fprintf(dest, "%d setlinewidth\n", g_PlotLine_Width); - rayon = diam.x / 2; - if( rayon < 1 ) - rayon = 1; - fprintf(dest, "newpath %d %d %d 0 360 arc fill stroke\n", - centre.x, centre.y, rayon); - } - else - { - w = g_PlotLine_Width; - rayon = (diam.x - w) / 2; - if( rayon < 1 ) - rayon = 1; - if( rayon < w ) - w = rayon; - fprintf(dest, "%d setlinewidth\n", w); - fprintf(dest, "newpath %d %d %d 0 360 arc stroke\n", - centre.x, centre.y, rayon); - } + UserToDeviceCoordinate( centre ); + UserToDeviceSize( diam ); + + if( modetrace == FILLED ) + { + fprintf( dest, "%d setlinewidth\n", g_PlotLine_Width ); + rayon = diam.x / 2; + if( rayon < 1 ) + rayon = 1; + fprintf( dest, "newpath %d %d %d 0 360 arc fill stroke\n", + centre.x, centre.y, rayon ); + } + else + { + w = g_PlotLine_Width; + rayon = (diam.x - w) / 2; + if( rayon < 1 ) + rayon = 1; + if( rayon < w ) + w = rayon; + fprintf( dest, "%d setlinewidth\n", w ); + fprintf( dest, "newpath %d %d %d 0 360 arc stroke\n", + centre.x, centre.y, rayon ); + } } /**************************************************************************/ -void trace_1_pad_rectangulaire_POST(wxPoint centre, - wxSize size, int orient, int modetrace) +void trace_1_pad_rectangulaire_POST( wxPoint centre, + wxSize size, int orient, int modetrace ) /**************************************************************************/ /* @@ -595,42 +605,42 @@ void trace_1_pad_rectangulaire_POST(wxPoint centre, * et son orientation orient */ { -int x0, y0, x1, y1, w; + int x0, y0, x1, y1, w; - if( modetrace == FILLED ) - { - x0 = centre.x - size.x / 2; - x1 = centre.x + size.x / 2; - y0 = y1 = centre.y; - w = size.y; + if( modetrace == FILLED ) + { + x0 = centre.x - size.x / 2; + x1 = centre.x + size.x / 2; + y0 = y1 = centre.y; + w = size.y; - RotatePoint(&x0, &y0, centre.x, centre.y, orient); - RotatePoint(&x1, &y1, centre.x, centre.y, orient); + RotatePoint( &x0, &y0, centre.x, centre.y, orient ); + RotatePoint( &x1, &y1, centre.x, centre.y, orient ); - fprintf(dest, "0 setlinewidth 0 setlinecap 0 setlinejoin\n"); - ForcePenReinit(); // Force init line width for PlotFilledSegmentPS - PlotFilledSegmentPS(wxPoint(x0, y0), wxPoint(x1, y1), w); - ForcePenReinit(); - SetCurrentLineWidthPS(0); // Force init line width to default - fprintf(dest, "1 setlinecap 1 setlinejoin\n"); - } - else - { - w = g_PlotLine_Width; - size.x -= w; - if( size.x < 1 ) - size.x = 1; - size.y -= w; - if( size.y < 1 ) - size.y = 1; - trace_1_contour_POST(centre, size, wxSize(0, 0), w, orient); - } + fprintf( dest, "0 setlinewidth 0 setlinecap 0 setlinejoin\n" ); + ForcePenReinit(); // Force init line width for PlotFilledSegmentPS + PlotFilledSegmentPS( wxPoint( x0, y0 ), wxPoint( x1, y1 ), w ); + ForcePenReinit(); + SetCurrentLineWidthPS( 0 ); // Force init line width to default + fprintf( dest, "1 setlinecap 1 setlinejoin\n" ); + } + else + { + w = g_PlotLine_Width; + size.x -= w; + if( size.x < 1 ) + size.x = 1; + size.y -= w; + if( size.y < 1 ) + size.y = 1; + trace_1_contour_POST( centre, size, wxSize( 0, 0 ), w, orient ); + } } /**************************************************************/ -void trace_1_contour_POST(wxPoint centre, wxSize size, wxSize delta, - int dim_trait, int orient) +void trace_1_contour_POST( wxPoint centre, wxSize size, wxSize delta, + int dim_trait, int orient ) /**************************************************************/ /* @@ -642,45 +652,45 @@ void trace_1_contour_POST(wxPoint centre, wxSize size, wxSize delta, * et son orientation orient (en 0.1 degres) */ { -int ii; -int dx, dy, lpen; -int ddx, ddy; -wxPoint coord[4]; + int ii; + int dx, dy, lpen; + int ddx, ddy; + wxPoint coord[4]; - lpen = dim_trait; + lpen = dim_trait; - dx = size.x / 2; - dy = size.y / 2; - ddx = delta.x >> 1; - ddy = delta.y >> 1; // demi dim dx et dy + dx = size.x / 2; + dy = size.y / 2; + ddx = delta.x >> 1; + ddy = delta.y >> 1; // demi dim dx et dy - coord[0].x = centre.x - dx - ddy; - coord[0].y = centre.y + dy + ddx; + coord[0].x = centre.x - dx - ddy; + coord[0].y = centre.y + dy + ddx; - coord[1].x = centre.x - dx + ddy; - coord[1].y = centre.y - dy - ddx; + coord[1].x = centre.x - dx + ddy; + coord[1].y = centre.y - dy - ddx; - coord[2].x = centre.x + dx - ddy; - coord[2].y = centre.y - dy + ddx; + coord[2].x = centre.x + dx - ddy; + coord[2].y = centre.y - dy + ddx; - coord[3].x = centre.x + dx + ddy; - coord[3].y = centre.y + dy - ddx; + coord[3].x = centre.x + dx + ddy; + coord[3].y = centre.y + dy - ddx; - for( ii = 0; ii < 4; ii++ ) - { - RotatePoint(&coord[ii], centre, orient); - } + for( ii = 0; ii < 4; ii++ ) + { + RotatePoint( &coord[ii], centre, orient ); + } - PlotFilledSegmentPS( coord[0], coord[1], lpen ); - PlotFilledSegmentPS( coord[1], coord[2], lpen ); - PlotFilledSegmentPS( coord[2], coord[3], lpen ); - PlotFilledSegmentPS( coord[3], coord[0], lpen ); + PlotFilledSegmentPS( coord[0], coord[1], lpen ); + PlotFilledSegmentPS( coord[1], coord[2], lpen ); + PlotFilledSegmentPS( coord[2], coord[3], lpen ); + PlotFilledSegmentPS( coord[3], coord[0], lpen ); } /*******************************************************************/ -void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, - int orient,int modetrace) +void trace_1_pad_TRAPEZE_POST( wxPoint centre, wxSize size, wxSize delta, + int orient, int modetrace ) /*******************************************************************/ /* @@ -695,7 +705,7 @@ void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, * = 0. * * les notation des sommets sont ( vis a vis de la table tracante ) - * + * * " 0 ------------- 3 " * " . . " * " . O . " @@ -725,56 +735,56 @@ void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, * " 1 " */ { -int ii; -int dx, dy; -wxPoint polygone[4]; // coord des sommets / centre du pad -int ddx, ddy; -int l_pen; // diam spot (plume) + int ii; + int dx, dy; + wxPoint polygone[4]; // coord des sommets / centre du pad + int ddx, ddy; + int l_pen; // diam spot (plume) - l_pen = 1; - if( modetrace == FILAIRE || Plot_Mode == FILAIRE ) - { - wxSize lsize(g_PlotLine_Width, g_PlotLine_Width); - UserToDeviceSize(lsize); - l_pen = lsize.x; - } + l_pen = 1; + if( modetrace == FILAIRE || Plot_Mode == FILAIRE ) + { + wxSize lsize( g_PlotLine_Width, g_PlotLine_Width ); - dx = size.x / 2; - dy = size.y / 2; - ddx = delta.x / 2; - ddy = delta.y / 2; + UserToDeviceSize( lsize ); + l_pen = lsize.x; + } - polygone[0].x = - dx - ddy; - polygone[0].y = + dy + ddx; - polygone[1].x = - dx + ddy; - polygone[1].y = - dy - ddx; - polygone[2].x = + dx - ddy; - polygone[2].y = - dy + ddx; - polygone[3].x = + dx + ddy; - polygone[3].y = + dy - ddx; + dx = size.x / 2; + dy = size.y / 2; + ddx = delta.x / 2; + ddy = delta.y / 2; - for( ii = 0; ii < 4; ii++ ) - { - RotatePoint(&polygone[ii].x, &polygone[ii].y, orient); - polygone[ii].x += centre.x; - polygone[ii].y += centre.y; - } + polygone[0].x = -dx - ddy; + polygone[0].y = +dy + ddx; + polygone[1].x = -dx + ddy; + polygone[1].y = -dy - ddx; + polygone[2].x = +dx - ddy; + polygone[2].y = -dy + ddx; + polygone[3].x = +dx + ddy; + polygone[3].y = +dy - ddx; - SetCurrentLineWidthPS( l_pen ); + for( ii = 0; ii < 4; ii++ ) + { + RotatePoint( &polygone[ii].x, &polygone[ii].y, orient ); + polygone[ii].x += centre.x; + polygone[ii].y += centre.y; + } - UserToDeviceCoordinate(polygone[0]); - fprintf(dest, "newpath %d %d moveto\n", polygone[0].x, polygone[0].y); + SetCurrentLineWidthPS( l_pen ); - for( ii = 1; ii < 4; ii++ ) - { - UserToDeviceCoordinate(polygone[ii]); - fprintf(dest, "%d %d lineto\n", polygone[ii].x, polygone[ii].y); - } + UserToDeviceCoordinate( polygone[0] ); + fprintf( dest, "newpath %d %d moveto\n", polygone[0].x, polygone[0].y ); - fprintf(dest, "%d %d lineto ", polygone[0].x, polygone[0].y); + for( ii = 1; ii < 4; ii++ ) + { + UserToDeviceCoordinate( polygone[ii] ); + fprintf( dest, "%d %d lineto\n", polygone[ii].x, polygone[ii].y ); + } - if( modetrace == FILLED ) - fprintf(dest, "fill "); - fprintf(dest, "stroke\n"); + fprintf( dest, "%d %d lineto ", polygone[0].x, polygone[0].y ); + + if( modetrace == FILLED ) + fprintf( dest, "fill " ); + fprintf( dest, "stroke\n" ); } - diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index de60d9cf3f..1f113e4fa4 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -1,9 +1,9 @@ - /************************************/ - /**** editeur de PCB ****/ - /* traitement du Chevelu (Rastnest) */ - /************************************/ +/************************************/ +/**** editeur de PCB ****/ +/* traitement du Chevelu (Rastnest) */ +/************************************/ - /* Fichier RATSNEST.CPP */ +/* Fichier RATSNEST.CPP */ #include "fctsys.h" #include "gr_basic.h" @@ -15,1241 +15,1313 @@ #include "protos.h" /* variables locales */ -CHEVELU * g_pt_chevelu ; -CHEVELU * local_liste_chevelu; // adresse de base du buffer des chevelus locaux -int nb_local_chevelu; // nbr de links du module en deplacement -int nb_pads_ref; // nbr de nodes du module en deplacement -int nb_pads_externes; // nbr de pads connectes au module en deplacement -bool DisplayRastnestInProgress; // autorise affichage chevelu en cours de calcul - // de celui-ci - +CHEVELU* g_pt_chevelu; +CHEVELU* local_liste_chevelu; // adresse de base du buffer des chevelus locaux +int nb_local_chevelu; // nbr de links du module en deplacement +int nb_pads_ref; // nbr de nodes du module en deplacement +int nb_pads_externes; // nbr de pads connectes au module en deplacement +bool DisplayRastnestInProgress; // autorise affichage chevelu en cours de calcul + // de celui-ci /******************************************************************************/ -void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC * DC, bool display_status_pcb ) +void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb ) /******************************************************************************/ + /* - Génère le chevelu complet de la carte. - Doit etre appelé APRES le calcul de connectivité - Doit etre appelé apres changement de structure de la carte (modif - de pads, de nets, de modules). - - Si display_status_pcb : affichage des résultats en bas d'ecran -*/ + * Génère le chevelu complet de la carte. + * Doit etre appelé APRES le calcul de connectivité + * Doit etre appelé apres changement de structure de la carte (modif + * de pads, de nets, de modules). + * + * Si display_status_pcb : affichage des résultats en bas d'ecran + */ { -wxString msg; - - DisplayRastnestInProgress = TRUE; + wxString msg; - /* construction de la liste des coordonnées des pastilles */ - m_Pcb->m_Status_Pcb = 0; /* réinit total du calcul */ - build_liste_pads() ; - MsgPanel->EraseMsgBox() ; /* effacement du bas d'ecran */ - msg.Printf( wxT(" %d"),m_Pcb->m_NbPads) ; - Affiche_1_Parametre(this, 1, wxT("pads"), msg,RED) ; + DisplayRastnestInProgress = TRUE; - msg.Printf( wxT(" %d"),m_Pcb->m_NbNets) ; - Affiche_1_Parametre(this, 8, wxT("Nets"), msg,CYAN) ; + /* construction de la liste des coordonnées des pastilles */ + m_Pcb->m_Status_Pcb = 0; /* réinit total du calcul */ + build_liste_pads(); + MsgPanel->EraseMsgBox(); /* effacement du bas d'ecran */ + msg.Printf( wxT( " %d" ), m_Pcb->m_NbPads ); + Affiche_1_Parametre( this, 1, wxT( "pads" ), msg, RED ); - reattribution_reference_piste(display_status_pcb); - Build_Board_Ratsnest(DC ); /* calcul du chevelu general */ - test_connexions(DC); /* determine les blocks de pads connectés par - les pistes existantes */ + msg.Printf( wxT( " %d" ), m_Pcb->m_NbNets ); + Affiche_1_Parametre( this, 8, wxT( "Nets" ), msg, CYAN ); - Tst_Ratsnest(DC, 0 ); /* calcul du chevelu actif */ + reattribution_reference_piste( display_status_pcb ); + Build_Board_Ratsnest( DC ); /* calcul du chevelu general */ + test_connexions( DC ); /* determine les blocks de pads connectés par + * les pistes existantes */ - // Reaffichage des chevelus actifs - if( g_Show_Ratsnest ) DrawGeneralRatsnest( DC, 0 ); + Tst_Ratsnest( DC, 0 ); /* calcul du chevelu actif */ - if ( display_status_pcb ) + // Reaffichage des chevelus actifs + if( g_Show_Ratsnest ) + DrawGeneralRatsnest( DC, 0 ); + + if( display_status_pcb ) m_Pcb->Display_Infos( this ); } /*****************************************************************/ -static int tri_par_net(LISTE_PAD * pt_ref, LISTE_PAD * pt_compare) +static int tri_par_net( LISTE_PAD* pt_ref, LISTE_PAD* pt_compare ) /****************************************************************/ /* routine utilisee par la foncion QSORT */ { - return( (*pt_ref)->m_NetCode - (*pt_compare)->m_NetCode ); + return (*pt_ref)->m_NetCode - (*pt_compare)->m_NetCode; } + /********************************************************/ -static int sort_by_length(CHEVELU * ref, CHEVELU * compare) +static int sort_by_length( CHEVELU* ref, CHEVELU* compare ) /********************************************************/ /* routine de tri par longueur des chevelus utilisee par la foncion QSORT */ { - return( ref->dist - compare->dist ); + return ref->dist - compare->dist; } /*****************************************************************************/ -static int gen_rats_block_to_block(WinEDA_DrawPanel * DrawPanel, wxDC * DC, - LISTE_PAD * pt_liste_pad, LISTE_PAD * pt_limite, int * nblinks) +static int gen_rats_block_to_block( WinEDA_DrawPanel* DrawPanel, wxDC* DC, + LISTE_PAD* pt_liste_pad, LISTE_PAD* pt_limite, int* nblinks ) /*****************************************************************************/ + /* - Routine utilisee par Build_Board_Ratsnest() - Routine generant le chevelu entre 2 blocks ( supposes du meme net ) - la recherche est faite entre les pads du block 1 et les autres blocks - le block n ( n > 1 ) est alors connecte au block 1 par leur 2 pads - les plus proches. - Entree : - pt_chain_pad = adresse de debut de recherche - pt_limite = adresse de fin de recherche (borne non comprise) - Sortie: - liste des chevelus ( structures) - mise a jour de g_pt_chevelu a la 1ere case libre - Retourne: - nombre de blocks non connectes entre eux + * Routine utilisee par Build_Board_Ratsnest() + * Routine generant le chevelu entre 2 blocks ( supposes du meme net ) + * la recherche est faite entre les pads du block 1 et les autres blocks + * le block n ( n > 1 ) est alors connecte au block 1 par leur 2 pads + * les plus proches. + * Entree : + * pt_chain_pad = adresse de debut de recherche + * pt_limite = adresse de fin de recherche (borne non comprise) + * Sortie: + * liste des chevelus ( structures) + * mise a jour de g_pt_chevelu a la 1ere case libre + * Retourne: + * nombre de blocks non connectes entre eux */ { -int dist_min, current_dist ; -int current_num_block = 1 ; -LISTE_PAD * pt_liste_pad_tmp, - * pt_liste_pad_aux, - * pt_liste_pad_block1 = NULL, - * pt_start_liste ; + int dist_min, current_dist; + int current_num_block = 1; + LISTE_PAD* pt_liste_pad_tmp, + * pt_liste_pad_aux, + * pt_liste_pad_block1 = NULL, + * pt_start_liste; - pt_liste_pad_tmp = NULL ; dist_min = 0x7FFFFFFF; - pt_start_liste = pt_liste_pad ; + pt_liste_pad_tmp = NULL; dist_min = 0x7FFFFFFF; + pt_start_liste = pt_liste_pad; - if ( DC ) GRSetDrawMode(DC, GR_XOR); + if( DC ) + GRSetDrawMode( DC, GR_XOR ); - /* Recherche du pad le plus proche du block 1 */ - for ( ; pt_liste_pad < pt_limite ; pt_liste_pad++ ) - { - D_PAD * ref_pad = *pt_liste_pad; - if(ref_pad->m_logical_connexion != 1) continue ; + /* Recherche du pad le plus proche du block 1 */ + for( ; pt_liste_pad < pt_limite; pt_liste_pad++ ) + { + D_PAD* ref_pad = *pt_liste_pad; + if( ref_pad->m_logical_connexion != 1 ) + continue; - for ( pt_liste_pad_aux = pt_start_liste ; ;pt_liste_pad_aux++) - { - D_PAD * curr_pad = *pt_liste_pad_aux; - if(pt_liste_pad_aux >= pt_limite ) break ; - if(curr_pad->m_logical_connexion == 1) continue ; + for( pt_liste_pad_aux = pt_start_liste; ; pt_liste_pad_aux++ ) + { + D_PAD* curr_pad = *pt_liste_pad_aux; + if( pt_liste_pad_aux >= pt_limite ) + break; + if( curr_pad->m_logical_connexion == 1 ) + continue; - /* Comparaison des distances des pastilles (calcul simplifie) */ - current_dist = - abs( curr_pad->m_Pos.x - ref_pad->m_Pos.x) - + abs( curr_pad->m_Pos.y - ref_pad->m_Pos.y) ; + /* Comparaison des distances des pastilles (calcul simplifie) */ + current_dist = + abs( curr_pad->m_Pos.x - ref_pad->m_Pos.x ) + + abs( curr_pad->m_Pos.y - ref_pad->m_Pos.y ); - if(dist_min > current_dist) - { - current_num_block = curr_pad->m_logical_connexion ; - dist_min = current_dist; - pt_liste_pad_tmp = pt_liste_pad_aux; - pt_liste_pad_block1 = pt_liste_pad; - } - } - } + if( dist_min > current_dist ) + { + current_num_block = curr_pad->m_logical_connexion; + dist_min = current_dist; + pt_liste_pad_tmp = pt_liste_pad_aux; + pt_liste_pad_block1 = pt_liste_pad; + } + } + } - if (current_num_block > 1) /* le block n a ete connecte au bloc 1 */ - { - /* le block n est fondu avec le bloc 1 : */ - for( pt_liste_pad = pt_start_liste; pt_liste_pad < pt_limite; pt_liste_pad++ ) - { - if( (*pt_liste_pad)->m_logical_connexion == current_num_block) - (*pt_liste_pad)->m_logical_connexion = 1; - } + if( current_num_block > 1 ) /* le block n a ete connecte au bloc 1 */ + { + /* le block n est fondu avec le bloc 1 : */ + for( pt_liste_pad = pt_start_liste; pt_liste_pad < pt_limite; pt_liste_pad++ ) + { + if( (*pt_liste_pad)->m_logical_connexion == current_num_block ) + (*pt_liste_pad)->m_logical_connexion = 1; + } - pt_liste_pad = pt_liste_pad_block1 ; + pt_liste_pad = pt_liste_pad_block1; - (*nblinks)++; - g_pt_chevelu->m_NetCode = (*pt_liste_pad)->m_NetCode; - g_pt_chevelu->status = CH_ACTIF|CH_VISIBLE; - g_pt_chevelu->dist = dist_min; - g_pt_chevelu->pad_start = *pt_liste_pad; - g_pt_chevelu->pad_end = *pt_liste_pad_tmp; + (*nblinks)++; + g_pt_chevelu->m_NetCode = (*pt_liste_pad)->m_NetCode; + g_pt_chevelu->status = CH_ACTIF | CH_VISIBLE; + g_pt_chevelu->dist = dist_min; + g_pt_chevelu->pad_start = *pt_liste_pad; + g_pt_chevelu->pad_end = *pt_liste_pad_tmp; - if( DisplayRastnestInProgress && DC ) - GRLine(&DrawPanel->m_ClipBox, DC, g_pt_chevelu->pad_start->m_Pos.x, - g_pt_chevelu->pad_start->m_Pos.y, - g_pt_chevelu->pad_end->m_Pos.x, - g_pt_chevelu->pad_end->m_Pos.y, - 0, g_DesignSettings.m_RatsnestColor) ; + if( DisplayRastnestInProgress && DC ) + GRLine( &DrawPanel->m_ClipBox, DC, g_pt_chevelu->pad_start->m_Pos.x, + g_pt_chevelu->pad_start->m_Pos.y, + g_pt_chevelu->pad_end->m_Pos.x, + g_pt_chevelu->pad_end->m_Pos.y, + 0, g_DesignSettings.m_RatsnestColor ); - g_pt_chevelu++ ; - } - return(current_num_block) ; + g_pt_chevelu++; + } + return current_num_block; } + /*****************************************************************************/ -static int gen_rats_pad_to_pad(WinEDA_DrawPanel * DrawPanel, wxDC * DC, - LISTE_PAD * pt_liste_pad, - LISTE_PAD * pt_limite,int current_num_block, int * nblinks) +static int gen_rats_pad_to_pad( WinEDA_DrawPanel* DrawPanel, wxDC* DC, + LISTE_PAD* pt_liste_pad, + LISTE_PAD* pt_limite, int current_num_block, int* nblinks ) /*****************************************************************************/ + /* - Routine utilisee par Build_Board_Ratsnest() - Routine generant le chevelu entre 2 pads ( supposes du meme net ) - la routine connecte 1 pad non deja connecte a un autre et crée donc un certqins nombre -de blocks de pads liées par un chevelu -Ces blocks sont donc constitués de 2 pads. - - Entree : - pt_chain_pad = adresse de debut de recherche - pt_limite = adresse de fin de recherche (borne non comprise) - current_num_block = numero du dernier block de pads (constitué par les connexions - de pistes existantes - - Sortie: - liste des chevelus ( structures) - mise a jour de g_pt_chevelu a la 1ere case libre - - Retourne: - nombre de blocks crees (paquets de pads) + * Routine utilisee par Build_Board_Ratsnest() + * Routine generant le chevelu entre 2 pads ( supposes du meme net ) + * la routine connecte 1 pad non deja connecte a un autre et crée donc un certqins nombre + * de blocks de pads liées par un chevelu + * Ces blocks sont donc constitués de 2 pads. + * + * Entree : + * pt_chain_pad = adresse de debut de recherche + * pt_limite = adresse de fin de recherche (borne non comprise) + * current_num_block = numero du dernier block de pads (constitué par les connexions + * de pistes existantes + * + * Sortie: + * liste des chevelus ( structures) + * mise a jour de g_pt_chevelu a la 1ere case libre + * + * Retourne: + * nombre de blocks crees (paquets de pads) */ { -int dist_min, current_dist ; -LISTE_PAD * pt_liste_pad_tmp; -LISTE_PAD * pt_liste_pad_aux ; -LISTE_PAD * pt_start_liste; -D_PAD * ref_pad, * pad; + int dist_min, current_dist; + LISTE_PAD* pt_liste_pad_tmp; + LISTE_PAD* pt_liste_pad_aux; + LISTE_PAD* pt_start_liste; + D_PAD* ref_pad, * pad; - pt_start_liste = pt_liste_pad ; + pt_start_liste = pt_liste_pad; - if ( DC ) GRSetDrawMode(DC, GR_XOR); + if( DC ) + GRSetDrawMode( DC, GR_XOR ); - for ( ; pt_liste_pad < pt_limite ; pt_liste_pad++ ) - { - ref_pad = *pt_liste_pad; - if(ref_pad->m_logical_connexion) continue; // Pad deja connecte + for( ; pt_liste_pad < pt_limite; pt_liste_pad++ ) + { + ref_pad = *pt_liste_pad; + if( ref_pad->m_logical_connexion ) + continue; // Pad deja connecte - pt_liste_pad_tmp = NULL ; dist_min = 0x7FFFFFFF; + pt_liste_pad_tmp = NULL; dist_min = 0x7FFFFFFF; - for ( pt_liste_pad_aux = pt_start_liste ; ;pt_liste_pad_aux++) - { - if (pt_liste_pad_aux >= pt_limite ) break ; - if(pt_liste_pad_aux == pt_liste_pad) continue ; + for( pt_liste_pad_aux = pt_start_liste; ; pt_liste_pad_aux++ ) + { + if( pt_liste_pad_aux >= pt_limite ) + break; + if( pt_liste_pad_aux == pt_liste_pad ) + continue; - pad = *pt_liste_pad_aux; - /* Comparaison des distances des pastilles (calcul simplifie) */ - current_dist = - abs( pad->m_Pos.x - ref_pad->m_Pos.x) - + abs( pad->m_Pos.y - ref_pad->m_Pos.y); + pad = *pt_liste_pad_aux; + /* Comparaison des distances des pastilles (calcul simplifie) */ + current_dist = + abs( pad->m_Pos.x - ref_pad->m_Pos.x ) + + abs( pad->m_Pos.y - ref_pad->m_Pos.y ); - if(dist_min > current_dist) - { - dist_min = current_dist; - pt_liste_pad_tmp = pt_liste_pad_aux; - } - } + if( dist_min > current_dist ) + { + dist_min = current_dist; + pt_liste_pad_tmp = pt_liste_pad_aux; + } + } - if (pt_liste_pad_tmp != NULL) - { - pad = *pt_liste_pad_tmp; + if( pt_liste_pad_tmp != NULL ) + { + pad = *pt_liste_pad_tmp; - /* Mise a jour du numero de block ( ou de sous graphe ) */ - /* si aucun des 2 pads n'est deja connecte : creation d'un nouveau block */ - if ( (pad->m_logical_connexion == 0) && (ref_pad->m_logical_connexion == 0) ) - { - current_num_block++ ; - pad->m_logical_connexion = current_num_block ; - ref_pad->m_logical_connexion = current_num_block ; - } - /* si 1 des 2 pads est deja connecte : mise a jour pour l'autre */ - else - { - ref_pad->m_logical_connexion = pad->m_logical_connexion; - } - (*nblinks)++; - g_pt_chevelu->m_NetCode = ref_pad->m_NetCode; - g_pt_chevelu->status = CH_ACTIF|CH_VISIBLE; - g_pt_chevelu->dist = dist_min; - g_pt_chevelu->pad_start = ref_pad; - g_pt_chevelu->pad_end = pad; + /* Mise a jour du numero de block ( ou de sous graphe ) */ + /* si aucun des 2 pads n'est deja connecte : creation d'un nouveau block */ + if( (pad->m_logical_connexion == 0) && (ref_pad->m_logical_connexion == 0) ) + { + current_num_block++; + pad->m_logical_connexion = current_num_block; + ref_pad->m_logical_connexion = current_num_block; + } + /* si 1 des 2 pads est deja connecte : mise a jour pour l'autre */ + else + { + ref_pad->m_logical_connexion = pad->m_logical_connexion; + } + (*nblinks)++; + g_pt_chevelu->m_NetCode = ref_pad->m_NetCode; + g_pt_chevelu->status = CH_ACTIF | CH_VISIBLE; + g_pt_chevelu->dist = dist_min; + g_pt_chevelu->pad_start = ref_pad; + g_pt_chevelu->pad_end = pad; - if(DisplayRastnestInProgress) - { - GRLine(&DrawPanel->m_ClipBox, DC, g_pt_chevelu->pad_start->m_Pos.x, - g_pt_chevelu->pad_start->m_Pos.y, - g_pt_chevelu->pad_end->m_Pos.x, - g_pt_chevelu->pad_end->m_Pos.y, - 0, g_DesignSettings.m_RatsnestColor); - } - g_pt_chevelu++ ; - } - } + if( DisplayRastnestInProgress ) + { + GRLine( &DrawPanel->m_ClipBox, DC, g_pt_chevelu->pad_start->m_Pos.x, + g_pt_chevelu->pad_start->m_Pos.y, + g_pt_chevelu->pad_end->m_Pos.x, + g_pt_chevelu->pad_end->m_Pos.y, + 0, g_DesignSettings.m_RatsnestColor ); + } + g_pt_chevelu++; + } + } - return(current_num_block) ; + return current_num_block; } /***********************************************************/ -void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC * DC ) +void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) /***********************************************************/ + /* Routine de calcul du chevelu complet du circuit (algorithme de LEE ) - les connexions physiques (pistes) ne sont pas ici prises en compte - Il s'agit donc du chevelu de base qui ne depend que de la disposition des pads. - - - etablit la liste complete des pads si nécessaire - les pads utiles (cad appartenant a un net ) sont appeles - nodes (noeuds) - et la trie par blocs de pads homogenes ( i.e. appartenant au meme net ) - - - puis calcule le ratsnest selon l'algorithme de LEE, consistant a - a - etablir le ratsnest entre 1 pad non "connecte" et son plus proche - voisin. Ceci cree des "blocks" ou sous graphes non connectes entre - eux - b - "connecter" (par un chevelu) entre eux ces blocks en prenant le 1er block et - en le connectant a son plus proche voisin par les 2 pads les plus - proches (Iteration jusqu'a ce qu'il n'y ait plus qu'un seul block). - - les chevelus calculés montrent les connexions "logiques" - - Entree = adr du buffer de classement (usuellement buf_work) - met a jour : - nb_nodes = nombre de pads connectes a un net ( pads "utiles") - nb_links = nombre min de liens : - il y a n-1 liens par equipotentielle comportant n pads. - -*/ -{ -LISTE_PAD * pt_liste_pad, * pt_start_liste, * pt_end_liste, * pt_liste_pad_limite; -D_PAD * pad; -int ii, num_block, nbpads; -CHEVELU * pt_deb_liste_ch; -int current_net_code, noconn; -EQUIPOT * equipot; - - m_Pcb->m_NbNoconnect = 0; - m_Pcb->m_NbLinks = 0 ; - - if( m_Pcb->m_NbPads == 0 ) return; - - /* Etablissement de la liste des pads et leur net_codes si necessaire */ - if( (m_Pcb->m_Status_Pcb & NET_CODES_OK) == 0 ) recalcule_pad_net_code(); - - pt_liste_pad = m_Pcb->m_Pads; - for( ii = m_Pcb->m_NbPads ; ii > 0 ; pt_liste_pad++, ii-- ) - { - pad = *pt_liste_pad; - pad->m_logical_connexion = 0; - } - - /* classement des pointeurs sur pads par nets */ - qsort(m_Pcb->m_Pads,m_Pcb->m_NbPads,sizeof(LISTE_PAD), - (int(*)(const void *, const void *))tri_par_net) ; - - /* Allocation memoire du buffer des chevelus: il y a nb_nodes - 1 chevelu - au maximum ( 1 node = 1 pad connecte ). - on alloue donc un buffer pour nb_nodes chevelus... (+ une petite marge) - le nombre reel de chevelus est nb_links - */ - if( m_Pcb->m_Ratsnest ) MyFree(m_Pcb->m_Ratsnest); - m_Pcb->m_Ratsnest = NULL; - - if( m_Pcb->m_NbNodes == 0 ) return; /* pas de connexions utiles */ - - m_Pcb->m_Ratsnest = (CHEVELU*)MyZMalloc( (m_Pcb->m_NbNodes + 10 ) * sizeof(CHEVELU) ); - if(m_Pcb->m_Ratsnest == NULL) return; - - - /* calcul du chevelu */ - DisplayRastnestInProgress = TRUE; - g_pt_chevelu = m_Pcb->m_Ratsnest ; - pt_liste_pad = pt_start_liste = m_Pcb->m_Pads; - pt_liste_pad_limite = pt_start_liste + m_Pcb->m_NbPads; - current_net_code = 1; // 1er net_code a analyser (net_code = 0 -> no connect) - equipot = m_Pcb->m_Equipots; - noconn = 0; - - for ( ; pt_liste_pad < pt_liste_pad_limite ; ) - { - pt_deb_liste_ch = g_pt_chevelu; - pad = *pt_liste_pad; - /* saut des pads non connectes */ - if(pad->m_NetCode == 0 ) - { - pt_liste_pad++; pt_start_liste = pt_liste_pad; - continue; - } - /* Recherche de la fin de la liste des pads du net courant */ - num_block = pad->m_logical_connexion; - nbpads = 0; - for( pt_end_liste = pt_liste_pad + 1 ; ; pt_end_liste++) - { - if (pt_end_liste >= pt_liste_pad_limite ) break ; - pad = *pt_end_liste; - if (pad->m_NetCode != current_net_code ) break ; - nbpads++; - if( num_block < pad->m_logical_connexion ) - num_block = pad->m_logical_connexion; - } - m_Pcb->m_NbLinks += nbpads; - - /* fin de liste trouvee: calcul du chevelu du net "net_code" */ - equipot = m_Pcb->FindNet( current_net_code); - if(equipot == NULL) - DisplayError(this, wxT("Gen ratsnest err: NULL equipot") ); - else - { - equipot->m_NbNodes = nbpads; - equipot->m_NbLink = nbpads+1; - equipot->m_PadzoneStart = pt_start_liste; - equipot->m_PadzoneEnd = pt_end_liste; - equipot->m_RatsnestStart = g_pt_chevelu; - } - - /* a - connexion des pads entre eux */ - ii = gen_rats_pad_to_pad(DrawPanel, DC, pt_start_liste, - pt_end_liste, num_block, &noconn); - - /* b - connexion des blocks formes precedemment (Iteration) */ - while (ii > 1 ) - { - ii = gen_rats_block_to_block(DrawPanel, DC, pt_liste_pad, - pt_end_liste, &noconn); - } - - if( equipot ) - { - equipot->m_RatsnestEnd = g_pt_chevelu; - /* classement des chevelus par longueur croissante */ - qsort(equipot->m_RatsnestStart, - equipot->m_RatsnestEnd - equipot->m_RatsnestStart, - sizeof(CHEVELU), - (int(*)(const void *, const void *))sort_by_length) ; - } - pt_liste_pad = pt_start_liste = pt_end_liste ; - pt_deb_liste_ch = g_pt_chevelu; - if(pt_start_liste < pt_liste_pad_limite) - current_net_code = (*pt_start_liste)->m_NetCode; - } - - - m_Pcb->m_NbNoconnect = noconn; - m_Pcb->m_Status_Pcb |= LISTE_CHEVELU_OK ; - adr_lowmem = buf_work; - - // Effacement du chevelu calcule - CHEVELU * Chevelu = (CHEVELU*)m_Pcb->m_Ratsnest; - GRSetDrawMode(DC, GR_XOR); - for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) - { - if( ! g_Show_Ratsnest ) Chevelu->status &= ~CH_VISIBLE; - if ( DC ) GRLine(&DrawPanel->m_ClipBox, DC, - Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, - Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y, - 0, g_DesignSettings.m_RatsnestColor); - } - -} - - -/**********************************************************************/ -void WinEDA_BasePcbFrame::ReCompile_Ratsnest_After_Changes(wxDC * DC ) -/**********************************************************************/ -/* recompile rastnest afet am module move, delete, .. -*/ -{ - if ( g_Show_Ratsnest && DC ) Compile_Ratsnest( DC, TRUE ); -} - - -/*********************************************************************/ -void WinEDA_BasePcbFrame::DrawGeneralRatsnest(wxDC * DC, int net_code) -/*********************************************************************/ -/* - Affiche le chevelu general du circuit - Affiche les chevelus dont le bit CH_VISIBLE du status du chevelu est a 1 - Si net_code > 0, affichage des seuls chevelus de net_code correspondant -*/ -{ -int ii; -CHEVELU * Chevelu; - - if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) return; - if( (m_Pcb->m_Status_Pcb & DO_NOT_SHOW_GENERAL_RASTNEST) ) return; - if ( DC == NULL ) return; - - Chevelu = m_Pcb->m_Ratsnest; - if( Chevelu == NULL ) return; - - GRSetDrawMode(DC, GR_XOR); - for( ii = m_Pcb->GetNumRatsnests() ;ii > 0; Chevelu++, ii--) - { - if( (Chevelu->status & (CH_VISIBLE|CH_ACTIF)) != (CH_VISIBLE|CH_ACTIF) ) - continue; - if( (net_code <= 0) || (net_code == Chevelu->m_NetCode) ) - { - GRLine(&DrawPanel->m_ClipBox, DC, - Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, - Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y, - 0, g_DesignSettings.m_RatsnestColor); - } - } -} - - - -/*****************************************************************************/ -static int tst_rats_block_to_block(WinEDA_DrawPanel * DrawPanel, wxDC * DC, - LISTE_PAD * pt_liste_pad_start, LISTE_PAD * pt_liste_pad_end, - CHEVELU* start_rat_list, CHEVELU* end_rat_list) -/*****************************************************************************/ -/* - Routine utilisee par Tst_Ratsnest() - Routine tres proche de gen_rats_block_to_block(..) - Routine testant le chevelu entre 2 blocks ( supposes du meme net ) - la recherche est faite entre les pads du block 1 et les autres blocks - le block n ( n > 1 ) est alors connecte au block 1 par le chevelu le plus court - A la différence de gen_rats_block_to_block(..), - l'analyse n'est pas faite pads a pads mais a travers la liste générale des chevelus. - La routine active alors le chevelu le plus court reliant le block 1 au block n - (etablissement d'une connexion "logique") - - Entree : - pt_chain_pad = adresse de debut de zone pad utile - pt_limite = adresse de fin de zone (borne non comprise) - Sortie: - Membre .state du chevelu sélectionné - Retourne: - nombre de blocks non connectes entre eux + * les connexions physiques (pistes) ne sont pas ici prises en compte + * Il s'agit donc du chevelu de base qui ne depend que de la disposition des pads. + * + * - etablit la liste complete des pads si nécessaire + * les pads utiles (cad appartenant a un net ) sont appeles + * nodes (noeuds) + * et la trie par blocs de pads homogenes ( i.e. appartenant au meme net ) + * + * - puis calcule le ratsnest selon l'algorithme de LEE, consistant a + * a - etablir le ratsnest entre 1 pad non "connecte" et son plus proche + * voisin. Ceci cree des "blocks" ou sous graphes non connectes entre + * eux + * b - "connecter" (par un chevelu) entre eux ces blocks en prenant le 1er block et + * en le connectant a son plus proche voisin par les 2 pads les plus + * proches (Iteration jusqu'a ce qu'il n'y ait plus qu'un seul block). + * + * les chevelus calculés montrent les connexions "logiques" + * + * Entree = adr du buffer de classement (usuellement buf_work) + * met a jour : + * nb_nodes = nombre de pads connectes a un net ( pads "utiles") + * nb_links = nombre min de liens : + * il y a n-1 liens par equipotentielle comportant n pads. + * */ { -int current_num_block, min_block ; -LISTE_PAD * pt_liste_pad; -CHEVELU * chevelu, * min_chevelu; + LISTE_PAD* pt_liste_pad, * pt_start_liste, * pt_end_liste, * pt_liste_pad_limite; + D_PAD* pad; + int ii, num_block, nbpads; + CHEVELU* pt_deb_liste_ch; + int current_net_code, noconn; + EQUIPOT* equipot; - /* Recherche du chevelu le plus court d'un block a un autre block */ - min_chevelu = NULL; - for ( chevelu = start_rat_list; chevelu < end_rat_list ; chevelu++ ) - { - if( chevelu->pad_start->m_logical_connexion == chevelu->pad_end->m_logical_connexion ) - continue ; - if( min_chevelu == NULL ) min_chevelu = chevelu; - else if(min_chevelu->dist > chevelu->dist) min_chevelu = chevelu; - } + m_Pcb->m_NbNoconnect = 0; + m_Pcb->m_NbLinks = 0; - if( min_chevelu == NULL ) return 1; + if( m_Pcb->m_NbPads == 0 ) + return; - min_chevelu->status |= CH_ACTIF; - current_num_block = min_chevelu->pad_start->m_logical_connexion; - min_block = min_chevelu->pad_end->m_logical_connexion; - if (min_block > current_num_block ) EXCHG(min_block, current_num_block); + /* Etablissement de la liste des pads et leur net_codes si necessaire */ + if( (m_Pcb->m_Status_Pcb & NET_CODES_OK) == 0 ) + recalcule_pad_net_code(); - /* les 2 blocks vont etre fondus */ - for( pt_liste_pad = pt_liste_pad_start; pt_liste_pad < pt_liste_pad_end; pt_liste_pad++ ) - { - if( (*pt_liste_pad)->m_logical_connexion == current_num_block) - { - (*pt_liste_pad)->m_logical_connexion = min_block; - } - } + pt_liste_pad = m_Pcb->m_Pads; + for( ii = m_Pcb->m_NbPads; ii > 0; pt_liste_pad++, ii-- ) + { + pad = *pt_liste_pad; + pad->m_logical_connexion = 0; + } - return(current_num_block) ; + /* classement des pointeurs sur pads par nets */ + qsort( m_Pcb->m_Pads, m_Pcb->m_NbPads, sizeof(LISTE_PAD), + ( int( * ) ( const void*, const void* ) )tri_par_net ); + + /* Allocation memoire du buffer des chevelus: il y a nb_nodes - 1 chevelu + * au maximum ( 1 node = 1 pad connecte ). + * on alloue donc un buffer pour nb_nodes chevelus... (+ une petite marge) + * le nombre reel de chevelus est nb_links + */ + if( m_Pcb->m_Ratsnest ) + MyFree( m_Pcb->m_Ratsnest ); + m_Pcb->m_Ratsnest = NULL; + + if( m_Pcb->m_NbNodes == 0 ) + return; /* pas de connexions utiles */ + + m_Pcb->m_Ratsnest = (CHEVELU*) MyZMalloc( (m_Pcb->m_NbNodes + 10 ) * sizeof(CHEVELU) ); + if( m_Pcb->m_Ratsnest == NULL ) + return; + + + /* calcul du chevelu */ + DisplayRastnestInProgress = TRUE; + g_pt_chevelu = m_Pcb->m_Ratsnest; + pt_liste_pad = pt_start_liste = m_Pcb->m_Pads; + pt_liste_pad_limite = pt_start_liste + m_Pcb->m_NbPads; + current_net_code = 1; // 1er net_code a analyser (net_code = 0 -> no connect) + equipot = m_Pcb->m_Equipots; + noconn = 0; + + for( ; pt_liste_pad < pt_liste_pad_limite; ) + { + pt_deb_liste_ch = g_pt_chevelu; + pad = *pt_liste_pad; + /* saut des pads non connectes */ + if( pad->m_NetCode == 0 ) + { + pt_liste_pad++; pt_start_liste = pt_liste_pad; + continue; + } + /* Recherche de la fin de la liste des pads du net courant */ + num_block = pad->m_logical_connexion; + nbpads = 0; + for( pt_end_liste = pt_liste_pad + 1; ; pt_end_liste++ ) + { + if( pt_end_liste >= pt_liste_pad_limite ) + break; + pad = *pt_end_liste; + if( pad->m_NetCode != current_net_code ) + break; + nbpads++; + if( num_block < pad->m_logical_connexion ) + num_block = pad->m_logical_connexion; + } + + m_Pcb->m_NbLinks += nbpads; + + /* fin de liste trouvee: calcul du chevelu du net "net_code" */ + equipot = m_Pcb->FindNet( current_net_code ); + if( equipot == NULL ) + DisplayError( this, wxT( "Gen ratsnest err: NULL equipot" ) ); + else + { + equipot->m_NbNodes = nbpads; + equipot->m_NbLink = nbpads + 1; + equipot->m_PadzoneStart = pt_start_liste; + equipot->m_PadzoneEnd = pt_end_liste; + equipot->m_RatsnestStart = g_pt_chevelu; + } + + /* a - connexion des pads entre eux */ + ii = gen_rats_pad_to_pad( DrawPanel, DC, pt_start_liste, + pt_end_liste, num_block, &noconn ); + + /* b - connexion des blocks formes precedemment (Iteration) */ + while( ii > 1 ) + { + ii = gen_rats_block_to_block( DrawPanel, DC, pt_liste_pad, + pt_end_liste, &noconn ); + } + + if( equipot ) + { + equipot->m_RatsnestEnd = g_pt_chevelu; + /* classement des chevelus par longueur croissante */ + qsort( equipot->m_RatsnestStart, + equipot->m_RatsnestEnd - equipot->m_RatsnestStart, + sizeof(CHEVELU), + ( int( * ) ( const void*, const void* ) )sort_by_length ); + } + pt_liste_pad = pt_start_liste = pt_end_liste; + pt_deb_liste_ch = g_pt_chevelu; + if( pt_start_liste < pt_liste_pad_limite ) + current_net_code = (*pt_start_liste)->m_NetCode; + } + + m_Pcb->m_NbNoconnect = noconn; + m_Pcb->m_Status_Pcb |= LISTE_CHEVELU_OK; + adr_lowmem = buf_work; + + // Effacement du chevelu calcule + CHEVELU* Chevelu = (CHEVELU*) m_Pcb->m_Ratsnest; + GRSetDrawMode( DC, GR_XOR ); + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) + { + if( !g_Show_Ratsnest ) + Chevelu->status &= ~CH_VISIBLE; + if( DC ) + GRLine( &DrawPanel->m_ClipBox, DC, + Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, + Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y, + 0, g_DesignSettings.m_RatsnestColor ); + } } -/*********************************************************************/ -static int tst_rats_pad_to_pad(WinEDA_DrawPanel * DrawPanel, wxDC * DC, - int current_num_block, - CHEVELU* start_rat_list, CHEVELU* end_rat_list) + +/**********************************************************************/ +void WinEDA_BasePcbFrame::ReCompile_Ratsnest_After_Changes( wxDC* DC ) /**********************************************************************/ -/* - Routine utilisee par Tst_Ratsnest_general() - Routine Activant le chevelu entre 2 pads ( supposes du meme net ) - la routine connecte 1 pad non deja connecte a un autre et active donc - un certain nombre de blocks de pads liées par un chevelu -Ces blocks sont donc constitués de 2 pads. - Entree : - pt_chain_pad = adresse de debut de zone pad - pt_limite = adresse de fin de recherche (borne non comprise) - current_num_block = numero du dernier block de pads (constitué par les connexions - de pistes existantes - - Sortie: - liste des chevelus ( structures) - mise a jour du membre .state du chevelu activé - - Retourne: - nombre de blocks crees (paquets de pads) -*/ +/* recompile rastnest afet am module move, delete, .. + */ { -D_PAD * pad_start, * pad_end; -CHEVELU * chevelu; + if( g_Show_Ratsnest && DC ) + Compile_Ratsnest( DC, TRUE ); +} - for ( chevelu = start_rat_list; chevelu < end_rat_list; chevelu++ ) - { - pad_start = chevelu->pad_start; pad_end = chevelu->pad_end; - /* Mise a jour du numero de block ( ou de sous graphe ) */ - /* si aucun des 2 pads n'est deja connecte : creation d'un nouveau block */ - if ( (pad_start->m_logical_connexion == 0) && (pad_end->m_logical_connexion == 0) ) - { - current_num_block++ ; - pad_start->m_logical_connexion = current_num_block ; - pad_end->m_logical_connexion = current_num_block; - chevelu->status |= CH_ACTIF; - } - /* si 1 des 2 pads est deja connecte : mise a jour pour l'autre */ - else if ( pad_start->m_logical_connexion == 0) - { - pad_start->m_logical_connexion = pad_end->m_logical_connexion; - chevelu->status |= CH_ACTIF; - } - else if ( pad_end->m_logical_connexion == 0) - { - pad_end->m_logical_connexion = pad_start->m_logical_connexion; - chevelu->status |= CH_ACTIF; - } - } +/*********************************************************************/ +void WinEDA_BasePcbFrame::DrawGeneralRatsnest( wxDC* DC, int net_code ) +/*********************************************************************/ - return(current_num_block) ; +/* + * Affiche le chevelu general du circuit + * Affiche les chevelus dont le bit CH_VISIBLE du status du chevelu est a 1 + * Si net_code > 0, affichage des seuls chevelus de net_code correspondant + */ +{ + int ii; + CHEVELU* Chevelu; + + if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + return; + if( (m_Pcb->m_Status_Pcb & DO_NOT_SHOW_GENERAL_RASTNEST) ) + return; + if( DC == NULL ) + return; + + Chevelu = m_Pcb->m_Ratsnest; + if( Chevelu == NULL ) + return; + + GRSetDrawMode( DC, GR_XOR ); + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; Chevelu++, ii-- ) + { + if( ( Chevelu->status & (CH_VISIBLE | CH_ACTIF) ) != (CH_VISIBLE | CH_ACTIF) ) + continue; + if( (net_code <= 0) || (net_code == Chevelu->m_NetCode) ) + { + GRLine( &DrawPanel->m_ClipBox, DC, + Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, + Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y, + 0, g_DesignSettings.m_RatsnestColor ); + } + } +} + + +/*****************************************************************************/ +static int tst_rats_block_to_block( WinEDA_DrawPanel* DrawPanel, wxDC* DC, + LISTE_PAD* pt_liste_pad_start, LISTE_PAD* pt_liste_pad_end, + CHEVELU* start_rat_list, CHEVELU* end_rat_list ) +/*****************************************************************************/ + +/* + * Routine utilisee par Tst_Ratsnest() + * Routine tres proche de gen_rats_block_to_block(..) + * Routine testant le chevelu entre 2 blocks ( supposes du meme net ) + * la recherche est faite entre les pads du block 1 et les autres blocks + * le block n ( n > 1 ) est alors connecte au block 1 par le chevelu le plus court + * A la différence de gen_rats_block_to_block(..), + * l'analyse n'est pas faite pads a pads mais a travers la liste générale des chevelus. + * La routine active alors le chevelu le plus court reliant le block 1 au block n + * (etablissement d'une connexion "logique") + * + * Entree : + * pt_chain_pad = adresse de debut de zone pad utile + * pt_limite = adresse de fin de zone (borne non comprise) + * Sortie: + * Membre .state du chevelu sélectionné + * Retourne: + * nombre de blocks non connectes entre eux + */ +{ + int current_num_block, min_block; + LISTE_PAD* pt_liste_pad; + CHEVELU* chevelu, * min_chevelu; + + /* Recherche du chevelu le plus court d'un block a un autre block */ + min_chevelu = NULL; + for( chevelu = start_rat_list; chevelu < end_rat_list; chevelu++ ) + { + if( chevelu->pad_start->m_logical_connexion == chevelu->pad_end->m_logical_connexion ) + continue; + if( min_chevelu == NULL ) + min_chevelu = chevelu; + else if( min_chevelu->dist > chevelu->dist ) + min_chevelu = chevelu; + } + + if( min_chevelu == NULL ) + return 1; + + min_chevelu->status |= CH_ACTIF; + current_num_block = min_chevelu->pad_start->m_logical_connexion; + min_block = min_chevelu->pad_end->m_logical_connexion; + if( min_block > current_num_block ) + EXCHG( min_block, current_num_block ); + + /* les 2 blocks vont etre fondus */ + for( pt_liste_pad = pt_liste_pad_start; pt_liste_pad < pt_liste_pad_end; pt_liste_pad++ ) + { + if( (*pt_liste_pad)->m_logical_connexion == current_num_block ) + { + (*pt_liste_pad)->m_logical_connexion = min_block; + } + } + + return current_num_block; +} + + +/*********************************************************************/ +static int tst_rats_pad_to_pad( WinEDA_DrawPanel* DrawPanel, wxDC* DC, + int current_num_block, + CHEVELU* start_rat_list, CHEVELU* end_rat_list ) +/**********************************************************************/ + +/* + * Routine utilisee par Tst_Ratsnest_general() + * Routine Activant le chevelu entre 2 pads ( supposes du meme net ) + * la routine connecte 1 pad non deja connecte a un autre et active donc + * un certain nombre de blocks de pads liées par un chevelu + * Ces blocks sont donc constitués de 2 pads. + * + * Entree : + * pt_chain_pad = adresse de debut de zone pad + * pt_limite = adresse de fin de recherche (borne non comprise) + * current_num_block = numero du dernier block de pads (constitué par les connexions + * de pistes existantes + * + * Sortie: + * liste des chevelus ( structures) + * mise a jour du membre .state du chevelu activé + * + * Retourne: + * nombre de blocks crees (paquets de pads) + */ +{ + D_PAD* pad_start, * pad_end; + CHEVELU* chevelu; + + for( chevelu = start_rat_list; chevelu < end_rat_list; chevelu++ ) + { + pad_start = chevelu->pad_start; pad_end = chevelu->pad_end; + /* Mise a jour du numero de block ( ou de sous graphe ) */ + + /* si aucun des 2 pads n'est deja connecte : creation d'un nouveau block */ + if( (pad_start->m_logical_connexion == 0) && (pad_end->m_logical_connexion == 0) ) + { + current_num_block++; + pad_start->m_logical_connexion = current_num_block; + pad_end->m_logical_connexion = current_num_block; + chevelu->status |= CH_ACTIF; + } + /* si 1 des 2 pads est deja connecte : mise a jour pour l'autre */ + else if( pad_start->m_logical_connexion == 0 ) + { + pad_start->m_logical_connexion = pad_end->m_logical_connexion; + chevelu->status |= CH_ACTIF; + } + else if( pad_end->m_logical_connexion == 0 ) + { + pad_end->m_logical_connexion = pad_start->m_logical_connexion; + chevelu->status |= CH_ACTIF; + } + } + + return current_num_block; } /******************************************************************/ -void WinEDA_BasePcbFrame::Tst_Ratsnest(wxDC * DC, int ref_netcode ) +void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode ) /*******************************************************************/ /* calcul du chevelu actif - Le chevelu général doit etre calculé - Determite les chevelus ACTIFS dans la liste générale des chevelus -*/ + * Le chevelu général doit etre calculé + * Determite les chevelus ACTIFS dans la liste générale des chevelus + */ { -LISTE_PAD * pt_liste_pad; -CHEVELU * chevelu; -D_PAD * pad; -int ii, num_block; -int net_code; -EQUIPOT * equipot; + LISTE_PAD* pt_liste_pad; + CHEVELU* chevelu; + D_PAD* pad; + int ii, num_block; + int net_code; + EQUIPOT* equipot; - if( m_Pcb->m_NbPads == 0 ) return; + if( m_Pcb->m_NbPads == 0 ) + return; - for ( net_code = 1; ; net_code++) - { - equipot = m_Pcb->FindNet( net_code ); - if(equipot == NULL ) break; - if( ref_netcode && (net_code != ref_netcode) ) continue; + for( net_code = 1; ; net_code++ ) + { + equipot = m_Pcb->FindNet( net_code ); + if( equipot == NULL ) + break; + if( ref_netcode && (net_code != ref_netcode) ) + continue; - num_block = 0; - pt_liste_pad = equipot->m_PadzoneStart; - for( ;pt_liste_pad < equipot->m_PadzoneEnd; pt_liste_pad++) - { - pad = *pt_liste_pad; - pad->m_logical_connexion = pad->m_physical_connexion; - num_block = max (num_block, pad->m_logical_connexion); - } + num_block = 0; + pt_liste_pad = equipot->m_PadzoneStart; + for( ; pt_liste_pad < equipot->m_PadzoneEnd; pt_liste_pad++ ) + { + pad = *pt_liste_pad; + pad->m_logical_connexion = pad->m_physical_connexion; + num_block = MAX( num_block, pad->m_logical_connexion ); + } - for ( chevelu = equipot->m_RatsnestStart; chevelu < equipot->m_RatsnestEnd; chevelu++ ) - { - chevelu->status &= ~CH_ACTIF; - } + for( chevelu = equipot->m_RatsnestStart; chevelu < equipot->m_RatsnestEnd; chevelu++ ) + { + chevelu->status &= ~CH_ACTIF; + } + /* a - tst connexion des pads entre eux */ + ii = tst_rats_pad_to_pad( DrawPanel, DC, num_block, + equipot->m_RatsnestStart, equipot->m_RatsnestEnd ); - /* a - tst connexion des pads entre eux */ - ii = tst_rats_pad_to_pad(DrawPanel, DC, num_block, - equipot->m_RatsnestStart, equipot->m_RatsnestEnd); + /* b - connexion des blocks formes precedemment (Iteration) */ + while( ii > 1 ) + { + ii = tst_rats_block_to_block( DrawPanel, DC, + equipot->m_PadzoneStart, equipot->m_PadzoneEnd, + equipot->m_RatsnestStart, equipot->m_RatsnestEnd ); + } + } - /* b - connexion des blocks formes precedemment (Iteration) */ - while (ii > 1 ) - { - ii = tst_rats_block_to_block(DrawPanel, DC, - equipot->m_PadzoneStart, equipot->m_PadzoneEnd, - equipot->m_RatsnestStart, equipot->m_RatsnestEnd); - } - } - - - m_Pcb->m_NbNoconnect = 0; - CHEVELU * Chevelu = m_Pcb->m_Ratsnest; - for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) - { - if( Chevelu->status & CH_ACTIF ) - m_Pcb->m_NbNoconnect++; - } + m_Pcb->m_NbNoconnect = 0; + CHEVELU* Chevelu = m_Pcb->m_Ratsnest; + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) + { + if( Chevelu->status & CH_ACTIF ) + m_Pcb->m_NbNoconnect++; + } } + /**************************************************************************/ -int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest(wxDC * DC, int ref_netcode) +int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest( wxDC* DC, int ref_netcode ) /**************************************************************************/ /* Calcule le chevelu du net net_code */ { + DisplayRastnestInProgress = FALSE; + DrawGeneralRatsnest( DC, ref_netcode ); + Tst_Ratsnest( DC, ref_netcode ); + DrawGeneralRatsnest( DC, ref_netcode ); - DisplayRastnestInProgress = FALSE; - DrawGeneralRatsnest(DC, ref_netcode); - Tst_Ratsnest(DC, ref_netcode ); - DrawGeneralRatsnest(DC, ref_netcode); - - return m_Pcb->GetNumRatsnests(); -} - -/*****************************************************/ -void WinEDA_BasePcbFrame::recalcule_pad_net_code(void) -/*****************************************************/ -/* - Calcule et met a jour les net_codes des PADS et des equipotentielles - met a jour le buffer des equipotentielles - A utiliser apres edition de nets sur un pad ou lecture d'une netliste - positionne a 1 le bit NET_CODE_OK du status_pcb; -*/ -{ -LISTE_PAD * pad_ref, *pad_courant; -int ii, jj; -EQUIPOT * pt_equipot; -EDA_BaseStruct * PtStruct; -EQUIPOT ** BufPtEquipot; - - /* construction de la liste des adr des PADS */ - build_liste_pads(); - - /* calcul des net_codes des pads */ - ii = m_Pcb->m_NbPads; - m_Pcb->m_NbNodes = 0; - m_Pcb->m_NbNets = 0; - - pad_courant = m_Pcb->m_Pads; - for( ; ii > 0 ; pad_courant++, ii-- ) - { - if( (*pad_courant)->m_Netname.IsEmpty()) // pad non connecte - { - (*pad_courant)->m_NetCode = 0 ; continue ; - } - m_Pcb->m_NbNodes++; - /* si le netname a deja ete rencontre: mise a jour , sinon nouveau net_code */ - pad_ref = m_Pcb->m_Pads ; - while (pad_ref < pad_courant ) - { - if( (*pad_ref)->m_Netname == (*pad_courant)->m_Netname ) - break; // sont du meme met - pad_ref++ ; - } - - /* si pad_ref = pad_courant: nouveau net sinon, deja net deja traite */ - if ( pad_ref == pad_courant ) - { - m_Pcb->m_NbNets++ ; (*pad_courant)->m_NetCode = m_Pcb->m_NbNets; - } - else (*pad_courant)->m_NetCode = (*pad_ref)->m_NetCode ; - } - - /* Construction ou correction de la liste des equipotentielles, - et construction d'un tableau d'adressage des equipots*/ - - BufPtEquipot = (EQUIPOT**)MyMalloc(sizeof(EQUIPOT*) * (m_Pcb->m_NbNets+1)); - pt_equipot = m_Pcb->m_Equipots; - PtStruct = (EDA_BaseStruct *) m_Pcb; - for( ii = 0 ; ii <= m_Pcb->m_NbNets ;ii++ ) - { - if(pt_equipot == NULL ) /* Creation d'une nouvelle equipot */ - { - pt_equipot = new EQUIPOT(m_Pcb); - - if( ii == 0 ) - { - m_Pcb->m_Equipots = pt_equipot; - pt_equipot->Pback = m_Pcb; - } - else - { - PtStruct->Pnext = pt_equipot; - pt_equipot->Pback = PtStruct; - } - pt_equipot->Pnext = NULL; - } - - pt_equipot->m_NetCode = ii; // Mise a jour du numero d'equipot - pt_equipot->m_NbNodes = 0; - pt_equipot->m_Netname.Empty(); - - BufPtEquipot[ii] = pt_equipot; - PtStruct = (EDA_BaseStruct *) pt_equipot; - pt_equipot = (EQUIPOT *) pt_equipot->Pnext; - } - - /* Effacement des equipots inutiles */ - - while ( pt_equipot ) - { - PtStruct = pt_equipot->Pnext; - DeleteStructure(pt_equipot); - pt_equipot = (EQUIPOT*) PtStruct; - } - - pad_courant = m_Pcb->m_Pads; - pt_equipot = m_Pcb->m_Equipots; - - /* Placement des noms de net en structure EQUIPOT */ - for( ii = m_Pcb->m_NbPads ; ii > 0 ; pad_courant++, ii-- ) - { - jj = (*pad_courant)->m_NetCode; - pt_equipot = BufPtEquipot[jj]; - pt_equipot->m_NbNodes ++; - if(pt_equipot->m_Netname.IsEmpty()) - { - pt_equipot->m_Netname = (*pad_courant)->m_Netname; - } - } - MyFree(BufPtEquipot); - m_Pcb->m_Status_Pcb |= NET_CODES_OK; + return m_Pcb->GetNumRatsnests(); } +/*****************************************************/ +void WinEDA_BasePcbFrame::recalcule_pad_net_code( void ) +/*****************************************************/ -/***********************************************/ -void WinEDA_BasePcbFrame::build_liste_pads(void) -/***********************************************/ /* - construction de la liste ( sous forme d'une liste de stucture ) - des caract utiles des pads du PCB pour autoroutage,DRC .. ) - parametres: - adresse du buffer de classement = buf_work - retourne: - 1ere adresse disponible si OK - NULL si trop de pastilles - - -Parametres de routage calcules et mis a jour -- parametre net_code: - numero de code interne de chaque net du PCB. - permet d'accelerer les calculs de chevelu et de connexions -- parametre .link est mis a jour - pour chaque pastille, il indique le nombre d'autres pastilles du meme net - appartenant au meme module. - -Variables globales mise a jour: - pointeur base_adr_liste_pad (adr de classement de la liste des pads) - nb_pads = nombre total de pastilles du PCB - nb_nets = nombre de nets differents - status_pcb |= LISTE_PAD_OK (flag permettant d'eviter la reexecution inutile - de cette routine) -*/ + * Calcule et met a jour les net_codes des PADS et des equipotentielles + * met a jour le buffer des equipotentielles + * A utiliser apres edition de nets sur un pad ou lecture d'une netliste + * positionne a 1 le bit NET_CODE_OK du status_pcb; + */ { -LISTE_PAD* pt_liste_pad; -MODULE * Module; -D_PAD * PtPad; + LISTE_PAD* pad_ref, * pad_courant; + int ii, jj; + EQUIPOT* pt_equipot; + EDA_BaseStruct* PtStruct; + EQUIPOT** BufPtEquipot; - if( m_Pcb->m_Status_Pcb & LISTE_PAD_OK ) return; + /* construction de la liste des adr des PADS */ + build_liste_pads(); - /* construction de la liste des pointeurs sur les structures D_PAD */ - if( m_Pcb->m_Pads ) MyFree(m_Pcb->m_Pads); - m_Pcb->m_Pads = NULL; + /* calcul des net_codes des pads */ + ii = m_Pcb->m_NbPads; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbNets = 0; - /* Calcul du nombre de pads */ - Module = m_Pcb->m_Modules; m_Pcb->m_NbPads = 0; - for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) - { - PtPad = (D_PAD*) Module->m_Pads; - for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) m_Pcb->m_NbPads++; - } + pad_courant = m_Pcb->m_Pads; + for( ; ii > 0; pad_courant++, ii-- ) + { + if( (*pad_courant)->m_Netname.IsEmpty() ) // pad non connecte + { + (*pad_courant)->m_NetCode = 0; continue; + } + m_Pcb->m_NbNodes++; + /* si le netname a deja ete rencontre: mise a jour , sinon nouveau net_code */ + pad_ref = m_Pcb->m_Pads; + while( pad_ref < pad_courant ) + { + if( (*pad_ref)->m_Netname == (*pad_courant)->m_Netname ) + break; // sont du meme met + pad_ref++; + } - if( m_Pcb->m_NbPads == 0 ) return; + /* si pad_ref = pad_courant: nouveau net sinon, deja net deja traite */ + if( pad_ref == pad_courant ) + { + m_Pcb->m_NbNets++; (*pad_courant)->m_NetCode = m_Pcb->m_NbNets; + } + else + (*pad_courant)->m_NetCode = (*pad_ref)->m_NetCode; + } - /* Allocation memoire du buffer */ - pt_liste_pad = m_Pcb->m_Pads - = (D_PAD**) MyZMalloc( (m_Pcb->m_NbPads+1) * sizeof(D_PAD*) ); - m_Pcb->m_NbNodes = 0; + /* Construction ou correction de la liste des equipotentielles, + * et construction d'un tableau d'adressage des equipots*/ - /* Initialisation du buffer et des variables de travail */ - Module = m_Pcb->m_Modules; - for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) - { - PtPad = (D_PAD*) Module->m_Pads; - for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) - { - *pt_liste_pad = PtPad; - PtPad->m_logical_connexion = 0 ; - PtPad->m_Parent = Module; - if(PtPad->m_NetCode) m_Pcb->m_NbNodes++; - pt_liste_pad++; - } - } + BufPtEquipot = (EQUIPOT**) MyMalloc( sizeof(EQUIPOT *) * (m_Pcb->m_NbNets + 1) ); + pt_equipot = m_Pcb->m_Equipots; + PtStruct = (EDA_BaseStruct*) m_Pcb; + for( ii = 0; ii <= m_Pcb->m_NbNets; ii++ ) + { + if( pt_equipot == NULL ) /* Creation d'une nouvelle equipot */ + { + pt_equipot = new EQUIPOT( m_Pcb ); - *pt_liste_pad = NULL; // fin de liste + if( ii == 0 ) + { + m_Pcb->m_Equipots = pt_equipot; + pt_equipot->Pback = m_Pcb; + } + else + { + PtStruct->Pnext = pt_equipot; + pt_equipot->Pback = PtStruct; + } + pt_equipot->Pnext = NULL; + } - adr_lowmem = buf_work; - if( m_Pcb->m_Ratsnest ) MyFree(m_Pcb->m_Ratsnest); - m_Pcb->m_Ratsnest = NULL; - m_Pcb->m_Status_Pcb = LISTE_PAD_OK; + pt_equipot->m_NetCode = ii; // Mise a jour du numero d'equipot + pt_equipot->m_NbNodes = 0; + pt_equipot->m_Netname.Empty(); + + BufPtEquipot[ii] = pt_equipot; + PtStruct = (EDA_BaseStruct*) pt_equipot; + pt_equipot = (EQUIPOT*) pt_equipot->Pnext; + } + + /* Effacement des equipots inutiles */ + + while( pt_equipot ) + { + PtStruct = pt_equipot->Pnext; + DeleteStructure( pt_equipot ); + pt_equipot = (EQUIPOT*) PtStruct; + } + + pad_courant = m_Pcb->m_Pads; + pt_equipot = m_Pcb->m_Equipots; + + /* Placement des noms de net en structure EQUIPOT */ + for( ii = m_Pcb->m_NbPads; ii > 0; pad_courant++, ii-- ) + { + jj = (*pad_courant)->m_NetCode; + pt_equipot = BufPtEquipot[jj]; + pt_equipot->m_NbNodes++; + if( pt_equipot->m_Netname.IsEmpty() ) + { + pt_equipot->m_Netname = (*pad_courant)->m_Netname; + } + } + + MyFree( BufPtEquipot ); + m_Pcb->m_Status_Pcb |= NET_CODES_OK; +} + + +/***********************************************/ +void WinEDA_BasePcbFrame::build_liste_pads( void ) +/***********************************************/ + +/* + * construction de la liste ( sous forme d'une liste de stucture ) + * des caract utiles des pads du PCB pour autoroutage,DRC .. ) + * parametres: + * adresse du buffer de classement = buf_work + * retourne: + * 1ere adresse disponible si OK + * NULL si trop de pastilles + * + * + * Parametres de routage calcules et mis a jour + * - parametre net_code: + * numero de code interne de chaque net du PCB. + * permet d'accelerer les calculs de chevelu et de connexions + * - parametre .link est mis a jour + * pour chaque pastille, il indique le nombre d'autres pastilles du meme net + * appartenant au meme module. + * + * Variables globales mise a jour: + * pointeur base_adr_liste_pad (adr de classement de la liste des pads) + * nb_pads = nombre total de pastilles du PCB + * nb_nets = nombre de nets differents + * status_pcb |= LISTE_PAD_OK (flag permettant d'eviter la reexecution inutile + * de cette routine) + */ +{ + LISTE_PAD* pt_liste_pad; + MODULE* Module; + D_PAD* PtPad; + + if( m_Pcb->m_Status_Pcb & LISTE_PAD_OK ) + return; + + /* construction de la liste des pointeurs sur les structures D_PAD */ + if( m_Pcb->m_Pads ) + MyFree( m_Pcb->m_Pads ); + m_Pcb->m_Pads = NULL; + + /* Calcul du nombre de pads */ + Module = m_Pcb->m_Modules; m_Pcb->m_NbPads = 0; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + m_Pcb->m_NbPads++; + } + + if( m_Pcb->m_NbPads == 0 ) + return; + + /* Allocation memoire du buffer */ + pt_liste_pad = m_Pcb->m_Pads + = (D_PAD**) MyZMalloc( (m_Pcb->m_NbPads + 1) * sizeof(D_PAD *) ); + m_Pcb->m_NbNodes = 0; + + /* Initialisation du buffer et des variables de travail */ + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + *pt_liste_pad = PtPad; + PtPad->m_logical_connexion = 0; + PtPad->m_Parent = Module; + if( PtPad->m_NetCode ) + m_Pcb->m_NbNodes++; + pt_liste_pad++; + } + } + + *pt_liste_pad = NULL; // fin de liste + + adr_lowmem = buf_work; + if( m_Pcb->m_Ratsnest ) + MyFree( m_Pcb->m_Ratsnest ); + m_Pcb->m_Ratsnest = NULL; + m_Pcb->m_Status_Pcb = LISTE_PAD_OK; } /*****************************************************************************/ -char * WinEDA_BasePcbFrame::build_ratsnest_module(wxDC * DC, MODULE * Module) +char* WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) /*****************************************************************************/ + /* - construction de la liste en mode de calcul rapide pour affichage - en temps reel lors des deplacements du chevelu d'un module. - - parametres d'appel: - Module = pointeur sur module dont le ratsnest est a calculer - - retourne: adresse memoire disponible - Le chevelu calcule comporte 2 parties - - un chevelu interne relatif aux pads du module appartenant a un - meme net. Il est calcule 1 seule fois - - le chevelu externe reliant un pad interne a un pad externe au module - Ce chevelu est recalcule a chaque deplacement -*/ + * construction de la liste en mode de calcul rapide pour affichage + * en temps reel lors des deplacements du chevelu d'un module. + * + * parametres d'appel: + * Module = pointeur sur module dont le ratsnest est a calculer + * + * retourne: adresse memoire disponible + * Le chevelu calcule comporte 2 parties + * - un chevelu interne relatif aux pads du module appartenant a un + * meme net. Il est calcule 1 seule fois + * - le chevelu externe reliant un pad interne a un pad externe au module + * Ce chevelu est recalcule a chaque deplacement + */ { -LISTE_PAD * pt_liste_pad, - * pt_liste_ref, - * pt_liste_generale; -D_PAD * pad_ref, - * pad_externe; -LISTE_PAD * pt_liste_pad_limite, - * pt_start_liste, - * pt_end_liste; -int ii, jj; -CHEVELU * local_chevelu; -static CHEVELU * pt_fin_int_chevelu; // pointeur sur la fin de la liste - // des chevelus internes au module -static int nb_int_chevelu; // nombre e chevelus internes -int current_net_code; -int increment, distance; // variables de calcul de ratsnest -int pad_pos_X, pad_pos_Y; // position reelle des pads du module en mouvement + LISTE_PAD* pt_liste_pad, + * pt_liste_ref, + * pt_liste_generale; + D_PAD* pad_ref, + * pad_externe; + LISTE_PAD* pt_liste_pad_limite, + * pt_start_liste, + * pt_end_liste; + int ii, jj; + CHEVELU* local_chevelu; + static CHEVELU* pt_fin_int_chevelu; // pointeur sur la fin de la liste + // des chevelus internes au module + static int nb_int_chevelu; // nombre e chevelus internes + int current_net_code; + int increment, distance; // variables de calcul de ratsnest + int pad_pos_X, pad_pos_Y; // position reelle des pads du module en mouvement - if((m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0 ) build_liste_pads(); + if( (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0 ) + build_liste_pads(); - /* construction de la liste des pads du module si necessaire */ - if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) != 0) goto calcul_chevelu_ext; + /* construction de la liste des pads du module si necessaire */ + if( (m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) != 0 ) + goto calcul_chevelu_ext; - /* calcul du chevelu "interne", c.a.d. liant les seuls pads du module */ - pt_liste_pad = (LISTE_PAD*) adr_lowmem; nb_pads_ref = 0; - pad_ref = Module->m_Pads; - for( ; pad_ref != NULL ; pad_ref = (D_PAD*)pad_ref->Pnext) - { - if(pad_ref->m_NetCode == 0) continue; - *pt_liste_pad = pad_ref; - pad_ref->m_logical_connexion = 0; - pad_ref->m_physical_connexion = 0; - pt_liste_pad++; nb_pads_ref++; - } + /* calcul du chevelu "interne", c.a.d. liant les seuls pads du module */ + pt_liste_pad = (LISTE_PAD*) adr_lowmem; nb_pads_ref = 0; + pad_ref = Module->m_Pads; + for( ; pad_ref != NULL; pad_ref = (D_PAD*) pad_ref->Pnext ) + { + if( pad_ref->m_NetCode == 0 ) + continue; + *pt_liste_pad = pad_ref; + pad_ref->m_logical_connexion = 0; + pad_ref->m_physical_connexion = 0; + pt_liste_pad++; nb_pads_ref++; + } - if(nb_pads_ref == 0) return( (char*)pt_liste_pad); /* pas de connexions! */ + if( nb_pads_ref == 0 ) + return (char*) pt_liste_pad; /* pas de connexions! */ - qsort(adr_lowmem,nb_pads_ref,sizeof(D_PAD*), - (int(*)(const void *, const void *))tri_par_net) ; + qsort( adr_lowmem, nb_pads_ref, sizeof(D_PAD *), + ( int( * ) ( const void*, const void* ) )tri_par_net ); - /* construction de la liste des pads connectes aux pads de ce module */ - DisplayRastnestInProgress = FALSE; - pt_liste_ref = (LISTE_PAD*) adr_lowmem; - nb_pads_externes = 0; current_net_code = 0; - for(ii = 0 ; ii < nb_pads_ref ; ii++) - { - pad_ref = pt_liste_ref[ii]; - if(pad_ref->m_NetCode == current_net_code) continue; - current_net_code = pad_ref->m_NetCode; + /* construction de la liste des pads connectes aux pads de ce module */ + DisplayRastnestInProgress = FALSE; + pt_liste_ref = (LISTE_PAD*) adr_lowmem; + nb_pads_externes = 0; current_net_code = 0; + for( ii = 0; ii < nb_pads_ref; ii++ ) + { + pad_ref = pt_liste_ref[ii]; + if( pad_ref->m_NetCode == current_net_code ) + continue; + current_net_code = pad_ref->m_NetCode; - pt_liste_generale = m_Pcb->m_Pads ; - for(jj = m_Pcb->m_NbPads ; jj > 0; jj--) - { - pad_externe = *pt_liste_generale ; pt_liste_generale++; - if(pad_externe->m_NetCode != current_net_code) continue; - if(pad_externe->m_Parent == Module) continue; - pad_externe->m_logical_connexion = 0; - pad_externe->m_physical_connexion = 0; - *pt_liste_pad = pad_externe ; pt_liste_pad++; - nb_pads_externes++; - } - } - /* tri par net_codes croissants de la liste des pads externes */ - qsort(pt_liste_ref+nb_pads_ref,nb_pads_externes,sizeof(D_PAD*), - (int(*)(const void *, const void *))tri_par_net) ; + pt_liste_generale = m_Pcb->m_Pads; + for( jj = m_Pcb->m_NbPads; jj > 0; jj-- ) + { + pad_externe = *pt_liste_generale; pt_liste_generale++; + if( pad_externe->m_NetCode != current_net_code ) + continue; + if( pad_externe->m_Parent == Module ) + continue; + pad_externe->m_logical_connexion = 0; + pad_externe->m_physical_connexion = 0; + *pt_liste_pad = pad_externe; pt_liste_pad++; + nb_pads_externes++; + } + } - /* calcul du chevelu interne au module: - Ce calcul est identique au calcul du chevelu general, mais il est - restreint aux seuls pads du module courant */ - 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; + /* tri par net_codes croissants de la liste des pads externes */ + qsort( pt_liste_ref + nb_pads_ref, nb_pads_externes, sizeof(D_PAD *), + ( int( * ) ( const void*, const void* ) )tri_par_net ); - g_pt_chevelu = local_liste_chevelu ; - pt_liste_pad = pt_start_liste = (LISTE_PAD *) adr_lowmem ; - pt_liste_pad_limite = pt_liste_pad + nb_pads_ref; - current_net_code = (*pt_liste_pad)->m_NetCode ; + /* calcul du chevelu interne au module: + * Ce calcul est identique au calcul du chevelu general, mais il est + * restreint aux seuls pads du module courant */ + 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; - for ( ; pt_liste_pad < pt_liste_pad_limite ; ) - { - /* Recherche de la fin de la liste des pads du net courant */ + g_pt_chevelu = local_liste_chevelu; + pt_liste_pad = pt_start_liste = (LISTE_PAD*) adr_lowmem; + pt_liste_pad_limite = pt_liste_pad + nb_pads_ref; + current_net_code = (*pt_liste_pad)->m_NetCode; - for( pt_end_liste = pt_liste_pad + 1 ; ; pt_end_liste++) - { - if (pt_end_liste >= pt_liste_pad_limite ) break ; - if ((*pt_end_liste)->m_NetCode != current_net_code ) break ; - } + for( ; pt_liste_pad < pt_liste_pad_limite; ) + { + /* Recherche de la fin de la liste des pads du net courant */ - /* fin de liste trouvee : */ - /* a - connexion des pads entre eux */ - ii = gen_rats_pad_to_pad(DrawPanel, DC, pt_start_liste,pt_end_liste, - 0, &nb_local_chevelu ) ; + for( pt_end_liste = pt_liste_pad + 1; ; pt_end_liste++ ) + { + if( pt_end_liste >= pt_liste_pad_limite ) + break; + if( (*pt_end_liste)->m_NetCode != current_net_code ) + break; + } - /* b - connexion des blocks formes precedemment (Iteration) */ - while (ii > 1 ) - { - ii = gen_rats_block_to_block(DrawPanel, DC, pt_liste_pad, - pt_end_liste, &nb_local_chevelu ) ; - } + /* fin de liste trouvee : */ + /* a - connexion des pads entre eux */ + ii = gen_rats_pad_to_pad( DrawPanel, DC, pt_start_liste, pt_end_liste, + 0, &nb_local_chevelu ); - pt_liste_pad = pt_start_liste = pt_end_liste ; - if(pt_start_liste < pt_liste_pad_limite) - current_net_code = (*pt_start_liste)->m_NetCode ; - } + /* b - connexion des blocks formes precedemment (Iteration) */ + while( ii > 1 ) + { + ii = gen_rats_block_to_block( DrawPanel, DC, pt_liste_pad, + pt_end_liste, &nb_local_chevelu ); + } - pt_fin_int_chevelu = local_chevelu = g_pt_chevelu; - nb_int_chevelu = nb_local_chevelu; + pt_liste_pad = pt_start_liste = pt_end_liste; + if( pt_start_liste < pt_liste_pad_limite ) + current_net_code = (*pt_start_liste)->m_NetCode; + } - /* Mise a 1 du flag LOCAL */ - g_pt_chevelu = local_liste_chevelu; - while(g_pt_chevelu < pt_fin_int_chevelu) - { - g_pt_chevelu->status = LOCAL_CHEVELU; g_pt_chevelu++; - } + pt_fin_int_chevelu = local_chevelu = g_pt_chevelu; + nb_int_chevelu = nb_local_chevelu; - m_Pcb->m_Status_Pcb |= CHEVELU_LOCAL_OK; + /* Mise a 1 du flag LOCAL */ + g_pt_chevelu = local_liste_chevelu; + while( g_pt_chevelu < pt_fin_int_chevelu ) + { + g_pt_chevelu->status = LOCAL_CHEVELU; g_pt_chevelu++; + } - ///////////////////////////////////////// - // calcul du chevelu externe au module // - ///////////////////////////////////////// + m_Pcb->m_Status_Pcb |= CHEVELU_LOCAL_OK; + + ///////////////////////////////////////// + // calcul du chevelu externe au module // + ///////////////////////////////////////// calcul_chevelu_ext: - /* Cette partie est executee a chaque deplacement du module: on calcule - pour chaque pad du module courant la + courte distance a un pad externe. - Pour chaque groupe de pad du module courant appartenant a un meme net, - on ne garde qu'un seul chevelu: le plus court. - */ - local_chevelu = pt_fin_int_chevelu; - nb_local_chevelu = nb_int_chevelu; - pt_liste_ref = (LISTE_PAD*) adr_lowmem; - pad_ref = *pt_liste_ref; - current_net_code = pad_ref->m_NetCode; - local_chevelu->dist = 0x7FFFFFFF; - local_chevelu->status = 0; - increment = 0; - for(ii = 0 ; ii < nb_pads_ref ; ii++) - { - pad_ref = *(pt_liste_ref+ii); - if(pad_ref->m_NetCode != current_net_code) - { /* un nouveau chevelu est cree (si necessaire) pour - chaque nouveau net */ - if(increment) - { - nb_local_chevelu++; local_chevelu++; - } - increment = 0; - current_net_code = pad_ref->m_NetCode; - local_chevelu->dist = 0x7FFFFFFF; - } - pad_pos_X = pad_ref->m_Pos.x - g_Offset_Module.x; - pad_pos_Y = pad_ref->m_Pos.y - g_Offset_Module.y; - pt_liste_generale = pt_liste_ref + nb_pads_ref ; + /* Cette partie est executee a chaque deplacement du module: on calcule + * pour chaque pad du module courant la + courte distance a un pad externe. + * Pour chaque groupe de pad du module courant appartenant a un meme net, + * on ne garde qu'un seul chevelu: le plus court. + */ + local_chevelu = pt_fin_int_chevelu; + nb_local_chevelu = nb_int_chevelu; + pt_liste_ref = (LISTE_PAD*) adr_lowmem; + pad_ref = *pt_liste_ref; + current_net_code = pad_ref->m_NetCode; + local_chevelu->dist = 0x7FFFFFFF; + local_chevelu->status = 0; + increment = 0; + for( ii = 0; ii < nb_pads_ref; ii++ ) + { + pad_ref = *(pt_liste_ref + ii); + if( pad_ref->m_NetCode != current_net_code ) + { /* un nouveau chevelu est cree (si necessaire) pour + * chaque nouveau net */ + if( increment ) + { + nb_local_chevelu++; local_chevelu++; + } + increment = 0; + current_net_code = pad_ref->m_NetCode; + local_chevelu->dist = 0x7FFFFFFF; + } - for(jj = nb_pads_externes ; jj > 0; jj--) - { - pad_externe = *pt_liste_generale ; pt_liste_generale++; - /* les netcodes doivent etre identiques */ - if(pad_externe->m_NetCode < pad_ref->m_NetCode) continue; - if(pad_externe->m_NetCode > pad_ref->m_NetCode) break; - distance = abs(pad_externe->m_Pos.x - pad_pos_X) + - abs(pad_externe->m_Pos.y - pad_pos_Y); - if(distance < local_chevelu->dist) - { - local_chevelu->pad_start = pad_ref; - local_chevelu->pad_end = pad_externe; - local_chevelu->m_NetCode = pad_ref->m_NetCode; - local_chevelu->dist = distance; - local_chevelu->status = 0; - increment = 1; - } - } - } - if(increment) // fin de balayage : le ratsnest courant doit etre memorise - { - nb_local_chevelu++; local_chevelu++; - } + pad_pos_X = pad_ref->m_Pos.x - g_Offset_Module.x; + pad_pos_Y = pad_ref->m_Pos.y - g_Offset_Module.y; + pt_liste_generale = pt_liste_ref + nb_pads_ref; - /* Retourne l'adr de la zone disponible */ - adr_max = max(adr_max, (char*)(local_chevelu+1)); + for( jj = nb_pads_externes; jj > 0; jj-- ) + { + pad_externe = *pt_liste_generale; pt_liste_generale++; + /* les netcodes doivent etre identiques */ + if( pad_externe->m_NetCode < pad_ref->m_NetCode ) + continue; + if( pad_externe->m_NetCode > pad_ref->m_NetCode ) + break; + distance = abs( pad_externe->m_Pos.x - pad_pos_X ) + + abs( pad_externe->m_Pos.y - pad_pos_Y ); + if( distance < local_chevelu->dist ) + { + local_chevelu->pad_start = pad_ref; + local_chevelu->pad_end = pad_externe; + local_chevelu->m_NetCode = pad_ref->m_NetCode; + local_chevelu->dist = distance; + local_chevelu->status = 0; + increment = 1; + } + } + } - return( (char*) (local_chevelu+1) ) ; /* la struct pointee par - local_chevelu est utilisee - pour des calculs temporaires */ + if( increment ) // fin de balayage : le ratsnest courant doit etre memorise + { + nb_local_chevelu++; local_chevelu++; + } + + /* Retourne l'adr de la zone disponible */ + adr_max = MAX( adr_max, (char*) (local_chevelu + 1) ); + + return (char*) (local_chevelu + 1); /* la struct pointee par + * local_chevelu est utilisee + * pour des calculs temporaires */ } /***********************************************************/ -void WinEDA_BasePcbFrame::trace_ratsnest_module(wxDC * DC) +void WinEDA_BasePcbFrame::trace_ratsnest_module( wxDC* DC ) /**********************************************************/ + /* - affiche le chevelu d'un module calcule en mode rapide. - retourne: rien -*/ + * affiche le chevelu d'un module calcule en mode rapide. + * retourne: rien + */ { -CHEVELU* local_chevelu; -int ii; + CHEVELU* local_chevelu; + int ii; - if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0) return ; + if( (m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0 ) + return; - local_chevelu = local_liste_chevelu; - ii = nb_local_chevelu; + local_chevelu = local_liste_chevelu; + ii = nb_local_chevelu; - GRSetDrawMode(DC, GR_XOR); + GRSetDrawMode( DC, GR_XOR ); - while( ii-- > 0 ) - { - if(local_chevelu->status & LOCAL_CHEVELU) - { - GRLine(&DrawPanel->m_ClipBox, DC, - local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x, - local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y, - local_chevelu->pad_end->m_Pos.x - g_Offset_Module.x, - local_chevelu->pad_end->m_Pos.y - g_Offset_Module.y, - 0, YELLOW); - } - else - { - GRLine(&DrawPanel->m_ClipBox, DC, - local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x, - local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y, - local_chevelu->pad_end->m_Pos.x, - local_chevelu->pad_end->m_Pos.y, - 0, g_DesignSettings.m_RatsnestColor); - } - local_chevelu++; - } + while( ii-- > 0 ) + { + if( local_chevelu->status & LOCAL_CHEVELU ) + { + GRLine( &DrawPanel->m_ClipBox, DC, + local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x, + local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y, + local_chevelu->pad_end->m_Pos.x - g_Offset_Module.x, + local_chevelu->pad_end->m_Pos.y - g_Offset_Module.y, + 0, YELLOW ); + } + else + { + GRLine( &DrawPanel->m_ClipBox, DC, + local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x, + local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y, + local_chevelu->pad_end->m_Pos.x, + local_chevelu->pad_end->m_Pos.y, + 0, g_DesignSettings.m_RatsnestColor ); + } + local_chevelu++; + } } - /*********************************************************************************************/ /* int * WinEDA_BasePcbFrame::build_ratsnest_pad(D_PAD * pad_ref, const wxPoint & refpos) */ /*********************************************************************************************/ /* - construction de la liste en mode de calcul rapide pour affichage - en temps reel du chevelu d'un pad lors des tracés d'une piste démarrant - sur ce pad. - - parametres d'appel: - pad_ref ( si null : mise a 0 du nombre de chevelus ) - ox, oy = coord de l'extremite de la piste en trace - init (flag) - = 0 : mise a jour des chevelu - <> 0: creation de la liste - retourne: adresse memoire disponible -*/ + * construction de la liste en mode de calcul rapide pour affichage + * en temps reel du chevelu d'un pad lors des tracés d'une piste démarrant + * sur ce pad. + * + * parametres d'appel: + * pad_ref ( si null : mise a 0 du nombre de chevelus ) + * ox, oy = coord de l'extremite de la piste en trace + * init (flag) + * = 0 : mise a jour des chevelu + * <> 0: creation de la liste + * retourne: adresse memoire disponible + */ /* routine locale de tri par longueur de links utilisee par la fonction QSORT */ -static int sort_by_localnetlength(int * ref, int * compare) +static int sort_by_localnetlength( int* ref, int* compare ) { -int * org = (int*)adr_lowmem; -int ox = *org++; -int oy = *org++; -int lengthref, lengthcmp; + int* org = (int*) adr_lowmem; + int ox = *org++; + int oy = *org++; + int lengthref, lengthcmp; - lengthref = abs( *ref - ox); - ref++; - lengthref += abs( *ref - oy); // = longueur entre point origine et pad ref - lengthcmp = abs( *compare - ox); - compare++; - lengthcmp += abs( *compare - oy); // = longueur entre point origine et pad comparé + lengthref = abs( *ref - ox ); + ref++; + lengthref += abs( *ref - oy ); // = longueur entre point origine et pad ref + lengthcmp = abs( *compare - ox ); + compare++; + lengthcmp += abs( *compare - oy ); // = longueur entre point origine et pad comparé - return( lengthref - lengthcmp ); + return lengthref - lengthcmp; } + /****************************************************************************************/ -int * WinEDA_BasePcbFrame::build_ratsnest_pad(EDA_BaseStruct * ref, - const wxPoint & refpos, bool init) +int* WinEDA_BasePcbFrame::build_ratsnest_pad( EDA_BaseStruct* ref, + const wxPoint& refpos, bool init ) /****************************************************************************************/ { -int ii; -int * pt_coord, * base_data; -int current_net_code = 0, conn_number = 0; -LISTE_PAD * padlist; -D_PAD * pad_ref = NULL; + int ii; + int* pt_coord, * base_data; + int current_net_code = 0, conn_number = 0; + LISTE_PAD* padlist; + D_PAD* pad_ref = NULL; - if( ((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) || - ((m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0) ) - { - nb_local_chevelu = 0; - return(NULL); - } + if( ( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + || ( (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0 ) ) + { + nb_local_chevelu = 0; + return NULL; + } - base_data = pt_coord = (int *) adr_lowmem; - local_liste_chevelu = (CHEVELU *) pt_coord; - if (init) - { - nb_local_chevelu = 0; - if(ref == NULL) return(NULL); + base_data = pt_coord = (int*) adr_lowmem; + local_liste_chevelu = (CHEVELU*) pt_coord; + if( init ) + { + nb_local_chevelu = 0; + if( ref == NULL ) + return NULL; - switch ( ref->m_StructType ) - { - case TYPEPAD: - pad_ref = (D_PAD*) ref; - current_net_code = pad_ref->m_NetCode; - conn_number = pad_ref->m_physical_connexion; - break; + switch( ref->m_StructType ) + { + case TYPEPAD: + pad_ref = (D_PAD*) ref; + current_net_code = pad_ref->m_NetCode; + conn_number = pad_ref->m_physical_connexion; + break; - case TYPETRACK: - case TYPEVIA: - { - TRACK *track_ref = (TRACK*) ref; - current_net_code = track_ref->m_NetCode; - conn_number = track_ref->m_Sous_Netcode; - break; - } - - } - if ( current_net_code <= 0 ) return NULL; + case TYPETRACK: + case TYPEVIA: + { + TRACK* track_ref = (TRACK*) ref; + current_net_code = track_ref->m_NetCode; + conn_number = track_ref->m_Sous_Netcode; + break; + } + } - *pt_coord = refpos.x; pt_coord++; - *pt_coord = refpos.y; pt_coord++; + if( current_net_code <= 0 ) + return NULL; - if( m_Pcb->m_Ratsnest == NULL ) return(NULL); + *pt_coord = refpos.x; pt_coord++; + *pt_coord = refpos.y; pt_coord++; - padlist = m_Pcb->m_Pads; - for( ii = 0 ;ii < m_Pcb->m_NbPads; padlist++, ii++) - { - D_PAD * pad = *padlist; - if( pad->m_NetCode != current_net_code ) continue; - if( pad == pad_ref ) continue; - if( !pad->m_physical_connexion || (pad->m_physical_connexion != conn_number) ) - { - *pt_coord = pad->m_Pos.x; pt_coord++; - *pt_coord = pad->m_Pos.y; pt_coord++; - nb_local_chevelu++; - } - } - } /* Fin Init */ + if( m_Pcb->m_Ratsnest == NULL ) + return NULL; - else if( nb_local_chevelu ) - { - *pt_coord = refpos.x; *(pt_coord+1) = refpos.y; - } + padlist = m_Pcb->m_Pads; + for( ii = 0; ii < m_Pcb->m_NbPads; padlist++, ii++ ) + { + D_PAD* pad = *padlist; + if( pad->m_NetCode != current_net_code ) + continue; + if( pad == pad_ref ) + continue; + if( !pad->m_physical_connexion || (pad->m_physical_connexion != conn_number) ) + { + *pt_coord = pad->m_Pos.x; pt_coord++; + *pt_coord = pad->m_Pos.y; pt_coord++; + nb_local_chevelu++; + } + } + } /* Fin Init */ + else if( nb_local_chevelu ) + { + *pt_coord = refpos.x; *(pt_coord + 1) = refpos.y; + } - qsort(base_data + 2,nb_local_chevelu,2*sizeof(int), - (int(*)(const void *, const void *))sort_by_localnetlength) ; - return pt_coord; + qsort( base_data + 2, nb_local_chevelu, 2 * sizeof(int), + ( int( * ) ( const void*, const void* ) )sort_by_localnetlength ); + return pt_coord; } + /*******************************************************/ -void WinEDA_BasePcbFrame::trace_ratsnest_pad(wxDC * DC) +void WinEDA_BasePcbFrame::trace_ratsnest_pad( wxDC* DC ) /*******************************************************/ + /* - affiche le "chevelu" d'un pad lors des trace de segments de piste -*/ + * affiche le "chevelu" d'un pad lors des trace de segments de piste + */ { -int * pt_coord; -int ii; -int refX, refY; + int* pt_coord; + int ii; + int refX, refY; - if((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0) return; - if( nb_local_chevelu == 0 ) return; - if ( local_liste_chevelu == NULL ) return; + if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + return; + if( nb_local_chevelu == 0 ) + return; + if( local_liste_chevelu == NULL ) + return; - pt_coord = (int*) local_liste_chevelu; - refX = *pt_coord; pt_coord++; - refY = *pt_coord; pt_coord++; + pt_coord = (int*) local_liste_chevelu; + refX = *pt_coord; pt_coord++; + refY = *pt_coord; pt_coord++; - GRSetDrawMode(DC, GR_XOR); - for( ii = 0; ii < nb_local_chevelu; ii++) - { - if ( ii >= g_MaxLinksShowed ) break; - GRLine(&DrawPanel->m_ClipBox, DC, refX, refY, *pt_coord, *(pt_coord+1), - 0, YELLOW); - pt_coord += 2; - } + GRSetDrawMode( DC, GR_XOR ); + for( ii = 0; ii < nb_local_chevelu; ii++ ) + { + if( ii >= g_MaxLinksShowed ) + break; + GRLine( &DrawPanel->m_ClipBox, DC, refX, refY, *pt_coord, *(pt_coord + 1), + 0, YELLOW ); + pt_coord += 2; + } } - diff --git a/pcbnew/router.cpp b/pcbnew/router.cpp index a0948d24cd..85e7e09bdd 100644 --- a/pcbnew/router.cpp +++ b/pcbnew/router.cpp @@ -1,6 +1,7 @@ - /****************************************/ - /* EDITEUR de PCB: Menus d'AUTOROUTAGE: */ - /****************************************/ +/****************************************/ +/* EDITEUR de PCB: Menus d'AUTOROUTAGE: */ +/****************************************/ + // #define ROUTER #include "fctsys.h" @@ -18,601 +19,651 @@ #define PSCALE 1 /* routines internes */ -static void Out_Pads(BOARD * Pcb, FILE * outfile); -static int GenEdges(BOARD * Pcb, FILE * outfile); -static void GenExistantTracks(BOARD * Pcb, FILE *outfile, int current_net_code, int type); -static void ReturnNbViasAndTracks(BOARD * Pcb, int netcode, int * nb_vias, int *nb_tracks); +static void Out_Pads( BOARD* Pcb, FILE* outfile ); +static int GenEdges( BOARD* Pcb, FILE* outfile ); +static void GenExistantTracks( BOARD* Pcb, FILE* outfile, int current_net_code, int type ); +static void ReturnNbViasAndTracks( BOARD* Pcb, int netcode, int* nb_vias, int* nb_tracks ); /* variables locales */ static int min_layer, max_layer; - /******************************************/ -void WinEDA_PcbFrame::GlobalRoute(wxDC * DC) +void WinEDA_PcbFrame::GlobalRoute( wxDC* DC ) /******************************************/ { #ifdef ROUTER -FILE * outfile; -wxString FullFileName, ExecFileName, msg; -int ii; -int net_number; + FILE* outfile; + wxString FullFileName, ExecFileName, msg; + int ii; + int net_number; #ifdef __UNIX__ - ExecFileName = FindKicadFile(wxT("anneal")); + ExecFileName = FindKicadFile( wxT( "anneal" ) ); #else - ExecFileName = FindKicadFile(wxT("anneal.exe")); + ExecFileName = FindKicadFile( wxT( "anneal.exe" ) ); #endif - /* test de la presence du fichier et execution si present */ - if( ! wxFileExists(ExecFileName) ) - { - msg.Printf( wxT("File <%s> not found"), ExecFileName.GetData()); - DisplayError(this, msg, 20) ; - return; - } + /* test de la presence du fichier et execution si present */ + if( !wxFileExists( ExecFileName ) ) + { + msg.Printf( wxT( "File <%s> not found" ), ExecFileName.GetData() ); + DisplayError( this, msg, 20 ); + return; + } - /* Calcule du nom du fichier intermediaire de communication */ - FullFileName = m_CurrentScreen->m_FileName; - ChangeFileNameExt(FullFileName,wxT(".ipt")); + /* Calcule du nom du fichier intermediaire de communication */ + FullFileName = m_CurrentScreen->m_FileName; + ChangeFileNameExt( FullFileName, wxT( ".ipt" ) ); - if( (outfile = wxFopen(FullFileName, wxT("wt"))) == NULL ) - { - msg = _("Unable to create temporary file ") + FullFileName; - DisplayError(this, msg,20); - return; - } + if( ( outfile = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) + { + msg = _( "Unable to create temporary file " ) + FullFileName; + DisplayError( this, msg, 20 ); + return; + } - msg = _("Create temporary file ") + FullFileName; - SetStatusText(msg); + msg = _( "Create temporary file " ) + FullFileName; + SetStatusText( msg ); - /* calcul ratsnest */ - m_Pcb->m_Status_Pcb = 0 ; - Compile_Ratsnest(DC, TRUE); + /* calcul ratsnest */ + m_Pcb->m_Status_Pcb = 0; + Compile_Ratsnest( DC, TRUE ); - m_Pcb->ComputeBoundaryBox(); - g_GridRoutingSize = GetScreen()->GetGrid().x; + m_Pcb->ComputeBoundaryBox(); + g_GridRoutingSize = GetScreen()->GetGrid().x; - // Sortie de la dimension hors tout du pcb (dimensions + marge + g_GridRoutingSize) + // Sortie de la dimension hors tout du pcb (dimensions + marge + g_GridRoutingSize) #define B_MARGE 1000 // en 1/10000 inch - fprintf(outfile,"j %d %d %d %d", - (-B_MARGE - g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetX() )/PSCALE, - (-B_MARGE - g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetY() )/PSCALE, - (B_MARGE + g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetRight() )/PSCALE, - (B_MARGE + g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetBottom() )/PSCALE); + fprintf( outfile, "j %d %d %d %d", + ( -B_MARGE - g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetX() ) / PSCALE, + ( -B_MARGE - g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetY() ) / PSCALE, + ( B_MARGE + g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetRight() ) / PSCALE, + ( B_MARGE + g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetBottom() ) / PSCALE ); - /* calcul du nombre de couches cuivre */ - min_layer = 1; /* -> couche soudure = min layer */ - max_layer = m_Pcb->m_BoardSettings->m_CopperLayerCount; + /* calcul du nombre de couches cuivre */ + min_layer = 1; /* -> couche soudure = min layer */ + max_layer = m_Pcb->m_BoardSettings->m_CopperLayerCount; - fprintf(outfile," %d %d", min_layer, max_layer); + fprintf( outfile, " %d %d", min_layer, max_layer ); - net_number = m_Pcb->m_NbNets; + net_number = m_Pcb->m_NbNets; - fprintf(outfile," %d", net_number); + fprintf( outfile, " %d", net_number ); - fprintf(outfile," %d", g_GridRoutingSize / PSCALE); + fprintf( outfile, " %d", g_GridRoutingSize / PSCALE ); - fprintf(outfile," %d %d %d", /* isolation Pad, track, via */ - g_DesignSettings.m_TrackClearence/PSCALE, - g_DesignSettings.m_TrackClearence/PSCALE, - g_DesignSettings.m_TrackClearence/PSCALE ); + fprintf( outfile, " %d %d %d", /* isolation Pad, track, via */ + g_DesignSettings.m_TrackClearence / PSCALE, + g_DesignSettings.m_TrackClearence / PSCALE, + g_DesignSettings.m_TrackClearence / PSCALE ); - fprintf(outfile," 0"); /* via type */ + fprintf( outfile, " 0" ); /* via type */ - fprintf(outfile," %d", g_DesignSettings.m_CurrentViaSize/PSCALE); /* via diam */ + fprintf( outfile, " %d", g_DesignSettings.m_CurrentViaSize / PSCALE ); /* via diam */ - fprintf(outfile," n"); /* via enterree non permise */ + fprintf( outfile, " n" ); /* via enterree non permise */ - fprintf(outfile," 0"); /* unused */ + fprintf( outfile, " 0" ); /* unused */ - fprintf(outfile," %d", g_DesignSettings.m_CurrentTrackWidth /PSCALE); /* default track width */ + fprintf( outfile, " %d", g_DesignSettings.m_CurrentTrackWidth / PSCALE ); /* default track width */ - fprintf(outfile," 0"); /* unused */ + fprintf( outfile, " 0" ); /* unused */ - fprintf(outfile," 0 0 0\n"); /* unused */ + fprintf( outfile, " 0 0 0\n" ); /* unused */ - fprintf(outfile,"k 0 0 0 0 0 0 0 0 0 0\n"); /* spare record */ + fprintf( outfile, "k 0 0 0 0 0 0 0 0 0 0\n" ); /* spare record */ - fprintf(outfile,"m 0 0 0 0 0 0 0 0 0 0\n"); /* cost record */ + fprintf( outfile, "m 0 0 0 0 0 0 0 0 0 0\n" ); /* cost record */ - for ( ii = min_layer; ii <= max_layer; ii++ ) - { - int dir; - dir = 3; /* horizontal */ - if (ii & 1 ) dir = 1; /* vertical */ - fprintf(outfile,"l %d %d\n", ii, dir); /* layer direction record */ - } + for( ii = min_layer; ii <= max_layer; ii++ ) + { + int dir; + dir = 3; /* horizontal */ + if( ii & 1 ) + dir = 1; /* vertical */ + fprintf( outfile, "l %d %d\n", ii, dir ); /* layer direction record */ + } - Out_Pads(m_Pcb, outfile); - GenEdges(m_Pcb, outfile); + Out_Pads( m_Pcb, outfile ); + GenEdges( m_Pcb, outfile ); - fclose( outfile ); + fclose( outfile ); - ExecFileName += wxT(" ") + FullFileName; + ExecFileName += wxT( " " ) + FullFileName; - Affiche_Message(ExecFileName); + Affiche_Message( ExecFileName ); - wxExecute(ExecFileName); + wxExecute( ExecFileName ); #else - wxMessageBox( wxT("TODO, currently not available")); + wxMessageBox( wxT( "TODO, currently not available" ) ); #endif } /************************************************/ -static void Out_Pads(BOARD * Pcb, FILE * outfile) +static void Out_Pads( BOARD* Pcb, FILE* outfile ) /************************************************/ { -D_PAD * pt_pad ; -//MODULE * Module; -int netcode, mod_num, nb_pads, plink; -LISTE_PAD * pt_liste_pad, * pt_start_liste, - * pt_end_liste, * pt_liste_pad_limite; -int pin_min_layer, pin_max_layer; -int no_conn = Pcb->m_NbPads+1; /* valeur incrementee pour indiquer - que le pad n'est pas deja connecte a une piste*/ + D_PAD* pt_pad; - pt_liste_pad = pt_start_liste = Pcb->m_Pads; - pt_liste_pad_limite = pt_start_liste + Pcb->m_NbPads; + //MODULE * Module; + int netcode, mod_num, nb_pads, plink; + LISTE_PAD* pt_liste_pad, * pt_start_liste, + * pt_end_liste, * pt_liste_pad_limite; + int pin_min_layer, pin_max_layer; + int no_conn = Pcb->m_NbPads + 1;/* valeur incrementee pour indiquer + * que le pad n'est pas deja connecte a une piste*/ - if( pt_liste_pad == NULL ) return; + pt_liste_pad = pt_start_liste = Pcb->m_Pads; + pt_liste_pad_limite = pt_start_liste + Pcb->m_NbPads; - netcode = (*pt_liste_pad)->m_NetCode; - nb_pads = 1; plink = 0; - for ( ; pt_liste_pad < pt_liste_pad_limite ; ) - { - /* Recherche de la fin de la liste des pads du net courant */ - for( pt_end_liste = pt_liste_pad + 1 ; ; pt_end_liste++) - { - if (pt_end_liste >= pt_liste_pad_limite ) break ; - if ((*pt_end_liste)->m_NetCode != netcode ) break ; - nb_pads++; - } + if( pt_liste_pad == NULL ) + return; - /* fin de liste trouvee : */ - if( netcode > 0 ) - { - int nb_vias, nb_tracks; - ReturnNbViasAndTracks(Pcb, netcode, &nb_vias, &nb_tracks); - if ( nb_pads < 2 ) - { - wxString Line; - EQUIPOT * equipot = Pcb->FindNet( netcode ); - Line.Printf( wxT("Warning: %d pad, net %s"), - nb_pads, equipot->m_Netname.GetData()); - DisplayError(NULL, Line,20); - } - fprintf(outfile,"r %d %d %d %d %d %d 1 1\n", - netcode, nb_pads, nb_vias+nb_pads, nb_tracks, 0, - g_DesignSettings.m_CurrentTrackWidth /PSCALE); - } + netcode = (*pt_liste_pad)->m_NetCode; + nb_pads = 1; plink = 0; + for( ; pt_liste_pad < pt_liste_pad_limite; ) + { + /* Recherche de la fin de la liste des pads du net courant */ + for( pt_end_liste = pt_liste_pad + 1; ; pt_end_liste++ ) + { + if( pt_end_liste >= pt_liste_pad_limite ) + break; + if( (*pt_end_liste)->m_NetCode != netcode ) + break; + nb_pads++; + } - for( ;pt_liste_pad < pt_end_liste ; pt_liste_pad++) - { - pt_pad = *pt_liste_pad; - netcode = pt_pad->m_NetCode; - plink = pt_pad->m_physical_connexion; - /* plink = numero unique si pad non deja connecte a une piste */ - if (plink <= 0 ) plink = no_conn++; + /* fin de liste trouvee : */ + if( netcode > 0 ) + { + int nb_vias, nb_tracks; + ReturnNbViasAndTracks( Pcb, netcode, &nb_vias, &nb_tracks ); + if( nb_pads < 2 ) + { + wxString Line; + EQUIPOT* equipot = Pcb->FindNet( netcode ); + Line.Printf( wxT( "Warning: %d pad, net %s" ), + nb_pads, equipot->m_Netname.GetData() ); + DisplayError( NULL, Line, 20 ); + } + fprintf( outfile, "r %d %d %d %d %d %d 1 1\n", + netcode, nb_pads, nb_vias + nb_pads, nb_tracks, 0, + g_DesignSettings.m_CurrentTrackWidth / PSCALE ); + } - if( netcode <= 0 ) /* pad non connecte */ - fprintf(outfile,"u 0"); - else - fprintf(outfile,"p %d", netcode); - /* position */ - fprintf(outfile," %d %d", - pt_pad->m_Pos.x/PSCALE, pt_pad->m_Pos.y/PSCALE); + for( ; pt_liste_pad < pt_end_liste; pt_liste_pad++ ) + { + pt_pad = *pt_liste_pad; + netcode = pt_pad->m_NetCode; + plink = pt_pad->m_physical_connexion; + /* plink = numero unique si pad non deja connecte a une piste */ + if( plink <= 0 ) + plink = no_conn++; - /* layers */ - pin_min_layer = 0; pin_max_layer = max_layer; + if( netcode <= 0 ) /* pad non connecte */ + fprintf( outfile, "u 0" ); + else + fprintf( outfile, "p %d", netcode ); + /* position */ + fprintf( outfile, " %d %d", + pt_pad->m_Pos.x / PSCALE, pt_pad->m_Pos.y / PSCALE ); - if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) - pin_min_layer = pin_max_layer = min_layer; + /* layers */ + pin_min_layer = 0; pin_max_layer = max_layer; - else if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) - pin_min_layer = pin_max_layer = max_layer; + if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) + pin_min_layer = pin_max_layer = min_layer; - fprintf(outfile," %d %d", pin_min_layer, pin_min_layer); + else if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) + pin_min_layer = pin_max_layer = max_layer; - /* link */ - fprintf(outfile," %d", plink); + fprintf( outfile, " %d %d", pin_min_layer, pin_min_layer ); - /* type of device (1 = IC, 2 = edge conn, 3 = discret, 4 = other */ - switch (pt_pad->m_Attribut) - { - case STANDARD: - case SMD: - fprintf(outfile," %d", 1); - break; - case CONN: fprintf(outfile," %d", 2); - break; - case P_HOLE: - case MECA: - fprintf(outfile," %d", 4); - break; - } + /* link */ + fprintf( outfile, " %d", plink ); - /* pin number */ - fprintf(outfile," %ld", (long)(pt_pad->m_Padname)); + /* type of device (1 = IC, 2 = edge conn, 3 = discret, 4 = other */ + switch( pt_pad->m_Attribut ) + { + case STANDARD: + case SMD: + fprintf( outfile, " %d", 1 ); + break; - /* layer size number (tj = 1) */ - fprintf(outfile," %d", 1); + case CONN: + fprintf( outfile, " %d", 2 ); + break; - /* device number */ - mod_num = 1; /* A CHANGER */ - fprintf(outfile," %d", mod_num); + case P_HOLE: + case MECA: + fprintf( outfile, " %d", 4 ); + break; + } - /* orientations pins 1 et 2 */ - fprintf(outfile," x"); + /* pin number */ + fprintf( outfile, " %ld", (long) (pt_pad->m_Padname) ); - /* spare */ - fprintf(outfile," 0 0\n"); + /* layer size number (tj = 1) */ + fprintf( outfile, " %d", 1 ); - /* output layer size record */ - fprintf(outfile,"q"); - switch (pt_pad->m_PadShape) /* out type, dims */ - { - case CIRCLE: - fprintf(outfile," c 0 %d 0", - pt_pad->m_Size.x/PSCALE ); - break; + /* device number */ + mod_num = 1; /* A CHANGER */ + fprintf( outfile, " %d", mod_num ); - case OVALE: - case RECT: - case TRAPEZE: - int lmax = pt_pad->m_Size.x; - int lmin = pt_pad->m_Size.y; - int angle = pt_pad->m_Orient/10; - while (angle < 0 ) angle += 180; - while (angle > 180 ) angle -= 180; - while (angle > 135 ) - { - angle -= 90; - EXCHG(lmax,lmin); - } - fprintf(outfile," r %d %d %d", - angle, - lmax /PSCALE, lmin/PSCALE ); - break; - } - /* layers */ - fprintf(outfile," %d %d\n", pin_min_layer, pin_max_layer); + /* orientations pins 1 et 2 */ + fprintf( outfile, " x" ); - } /* fin generation liste pads pour 1 net */ + /* spare */ + fprintf( outfile, " 0 0\n" ); - if(netcode) - { - GenExistantTracks(Pcb, outfile, netcode, TYPEVIA); - GenExistantTracks(Pcb, outfile, netcode, TYPETRACK); - } + /* output layer size record */ + fprintf( outfile, "q" ); - nb_pads = 1; - pt_liste_pad = pt_start_liste = pt_end_liste; - if(pt_start_liste < pt_liste_pad_limite) - netcode = (*pt_start_liste)->m_NetCode ; - } + switch( pt_pad->m_PadShape ) /* out type, dims */ + { + case CIRCLE: + fprintf( outfile, " c 0 %d 0", + pt_pad->m_Size.x / PSCALE ); + break; + + case OVALE: + case RECT: + case TRAPEZE: + int lmax = pt_pad->m_Size.x; + int lmin = pt_pad->m_Size.y; + int angle = pt_pad->m_Orient / 10; + while( angle < 0 ) + angle += 180; + + while( angle > 180 ) + angle -= 180; + + while( angle > 135 ) + { + angle -= 90; + EXCHG( lmax, lmin ); + } + + fprintf( outfile, " r %d %d %d", + angle, + lmax / PSCALE, lmin / PSCALE ); + break; + } + + /* layers */ + fprintf( outfile, " %d %d\n", pin_min_layer, pin_max_layer ); + } + + /* fin generation liste pads pour 1 net */ + + if( netcode ) + { + GenExistantTracks( Pcb, outfile, netcode, TYPEVIA ); + GenExistantTracks( Pcb, outfile, netcode, TYPETRACK ); + } + + nb_pads = 1; + pt_liste_pad = pt_start_liste = pt_end_liste; + if( pt_start_liste < pt_liste_pad_limite ) + netcode = (*pt_start_liste)->m_NetCode; + } } /**************************************************************************/ -static void ReturnNbViasAndTracks(BOARD * Pcb, int netcode, int * nb_vias, - int *nb_tracks) +static void ReturnNbViasAndTracks( BOARD* Pcb, int netcode, int* nb_vias, + int* nb_tracks ) /**************************************************************************/ + /* calcule le nombre de vias et segments de pistes pour le net netcode -*/ + */ { -TRACK * track; + TRACK* track; - *nb_vias = 0; - *nb_tracks = 0; + *nb_vias = 0; + *nb_tracks = 0; - track = Pcb->m_Track; - if( track == NULL ) return; + track = Pcb->m_Track; + if( track == NULL ) + return; - for ( ; track != NULL ; track = (TRACK*) track->Pnext ) - { - if( track->m_NetCode > netcode ) return; - if( track->m_NetCode != netcode ) continue; - if(track->m_StructType == TYPEVIA ) (*nb_vias)++; - if(track->m_StructType == TYPETRACK ) (*nb_tracks)++; - } + for( ; track != NULL; track = (TRACK*) track->Pnext ) + { + if( track->m_NetCode > netcode ) + return; + if( track->m_NetCode != netcode ) + continue; + if( track->m_StructType == TYPEVIA ) + (*nb_vias)++; + if( track->m_StructType == TYPETRACK ) + (*nb_tracks)++; + } } + /*************************************************************/ -static void GenExistantTracks(BOARD * Pcb, FILE *outfile, - int current_net_code, int type) +static void GenExistantTracks( BOARD* Pcb, FILE* outfile, + int current_net_code, int type ) /*************************************************************/ /* generation des pistes existantes */ { -int netcode, plink; -int via_min_layer, via_max_layer; -TRACK * track; + int netcode, plink; + int via_min_layer, via_max_layer; + TRACK* track; - track = Pcb->m_Track; - if( track == NULL ) return; + track = Pcb->m_Track; + if( track == NULL ) + return; - for ( ; track != NULL ; track = (TRACK*) track->Pnext ) - { - netcode = track->m_NetCode; - if( netcode > current_net_code ) return; - if( netcode != current_net_code ) continue; - plink = track->m_Sous_Netcode; - via_min_layer = track->m_Layer; + for( ; track != NULL; track = (TRACK*) track->Pnext ) + { + netcode = track->m_NetCode; + if( netcode > current_net_code ) + return; + if( netcode != current_net_code ) + continue; + plink = track->m_Sous_Netcode; + via_min_layer = track->GetLayer(); - if(track->m_StructType != type ) continue; + if( track->m_StructType != type ) + continue; - if(track->m_StructType == TYPEVIA ) - { - via_min_layer &= 15; - via_max_layer = (track->m_Layer >> 4) & 15; + if( track->m_StructType == TYPEVIA ) + { + via_min_layer &= 15; + via_max_layer = (track->GetLayer() >> 4) & 15; - if (via_min_layer == via_max_layer) - { - track->m_Layer = 0xF; - via_min_layer = 0; via_max_layer = 15; - } + if( via_min_layer == via_max_layer ) + { + track->SetLayer( 0xF ); + via_min_layer = 0; via_max_layer = 15; + } - if( via_max_layer < via_min_layer ) - EXCHG(via_max_layer,via_min_layer); + if( via_max_layer < via_min_layer ) + EXCHG( via_max_layer, via_min_layer ); - if(via_max_layer == CMP_N) via_max_layer = max_layer; - else via_max_layer++; + if( via_max_layer == CMP_N ) + via_max_layer = max_layer; + else + via_max_layer++; - if(via_min_layer == CUIVRE_N) via_min_layer = min_layer; - else via_min_layer++; + if( via_min_layer == CUIVRE_N ) + via_min_layer = min_layer; + else + via_min_layer++; - fprintf(outfile,"v 0 "); - fprintf(outfile," %d %d", track->m_Start.x/PSCALE, track->m_Start.y/PSCALE); - fprintf(outfile," %d %d", via_min_layer, via_max_layer); - fprintf(outfile," %d", plink); - fprintf(outfile," %d\n", 1); - /* layer size record */ - fprintf(outfile,"q c 0 %d 0 0 0\n", track->m_Width/PSCALE ); - } + fprintf( outfile, "v 0 " ); + fprintf( outfile, " %d %d", track->m_Start.x / PSCALE, track->m_Start.y / PSCALE ); + fprintf( outfile, " %d %d", via_min_layer, via_max_layer ); + fprintf( outfile, " %d", plink ); + fprintf( outfile, " %d\n", 1 ); + /* layer size record */ + fprintf( outfile, "q c 0 %d 0 0 0\n", track->m_Width / PSCALE ); + } - if(track->m_StructType == TYPETRACK ) - { - fprintf(outfile,"t 0 %d", track->m_Width/PSCALE); - fprintf(outfile," %d %d", track->m_Start.x/PSCALE, track->m_Start.y/PSCALE); - fprintf(outfile," %d %d", track->m_End.x/PSCALE, track->m_End.y/PSCALE); + if( track->m_StructType == TYPETRACK ) + { + fprintf( outfile, "t 0 %d", track->m_Width / PSCALE ); + fprintf( outfile, " %d %d", track->m_Start.x / PSCALE, track->m_Start.y / PSCALE ); + fprintf( outfile, " %d %d", track->m_End.x / PSCALE, track->m_End.y / PSCALE ); - if(via_min_layer == CMP_N) via_min_layer = max_layer; - else via_min_layer++; - fprintf(outfile," %d", via_min_layer); + if( via_min_layer == CMP_N ) + via_min_layer = max_layer; + else + via_min_layer++; + fprintf( outfile, " %d", via_min_layer ); - fprintf(outfile," %d\n", 1); /*Number of corners */ + fprintf( outfile, " %d\n", 1 ); /*Number of corners */ - /* output corner */ - fprintf(outfile,"c"); - fprintf(outfile," %d %d\n", track->m_End.x/PSCALE, track->m_End.y/PSCALE); - } - } + /* output corner */ + fprintf( outfile, "c" ); + fprintf( outfile, " %d %d\n", track->m_End.x / PSCALE, track->m_End.y / PSCALE ); + } + } } + /***********************************************/ -static int GenEdges(BOARD * Pcb, FILE * outfile) +static int GenEdges( BOARD* Pcb, FILE* outfile ) /***********************************************/ + /* Generation des contours (edges). - Il sont générés comme des segments de piste placés sur chaque couche routable. -*/ + * Il sont générés comme des segments de piste placés sur chaque couche routable. + */ { #define NB_CORNERS 4 -EDA_BaseStruct * PtStruct; -DRAWSEGMENT * PtDrawSegment; -int ii; -int dx, dy, width, angle; -int ox, oy, fx, fy; -wxPoint lim[4]; -int NbItems = 0; + EDA_BaseStruct* PtStruct; + DRAWSEGMENT* PtDrawSegment; + int ii; + int dx, dy, width, angle; + int ox, oy, fx, fy; + wxPoint lim[4]; + int NbItems = 0; - /* impression des contours */ - for ( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) - { - if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + /* impression des contours */ + for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) + continue; - PtDrawSegment = (DRAWSEGMENT *) PtStruct; - if( PtDrawSegment->m_Layer != EDGE_N) continue; + PtDrawSegment = (DRAWSEGMENT*) PtStruct; + if( PtDrawSegment->GetLayer() != EDGE_N ) + continue; - fx = PtDrawSegment->m_End.x;ox = PtDrawSegment->m_Start.x; - fy = PtDrawSegment->m_End.y; oy = PtDrawSegment->m_Start.y; - dx = fx - ox; dy = fy - oy; - if( (dx == 0) && (dy == 0) ) continue; + fx = PtDrawSegment->m_End.x; ox = PtDrawSegment->m_Start.x; + fy = PtDrawSegment->m_End.y; oy = PtDrawSegment->m_Start.y; + dx = fx - ox; dy = fy - oy; + if( (dx == 0) && (dy == 0) ) + continue; - /* elimination des segments non horizontaux, verticaux ou 45 degres, - non gérés par l'autorouteur */ - if( (dx != 0) && (dy != 0) && (abs(dx) != abs(dy)) ) - continue; + /* elimination des segments non horizontaux, verticaux ou 45 degres, + * non gérés par l'autorouteur */ + if( (dx != 0) && (dy != 0) && ( abs( dx ) != abs( dy ) ) ) + continue; - NbItems++; - if( outfile == NULL ) continue; /* car simple decompte des items */ + NbItems++; + if( outfile == NULL ) + continue; /* car simple decompte des items */ - /* generation de la zone interdite */ - if( dx < 0 ) - { - EXCHG(ox,fx); EXCHG(oy,fy); dx = -dx; dy = -dy; - } - if( (dx == 0) && (dy < 0 ) ) - { - EXCHG(oy,fy);dy = -dy; - } + /* generation de la zone interdite */ + if( dx < 0 ) + { + EXCHG( ox, fx ); EXCHG( oy, fy ); dx = -dx; dy = -dy; + } + if( (dx == 0) && (dy < 0 ) ) + { + EXCHG( oy, fy ); dy = -dy; + } - width = PtDrawSegment->m_Width; - width += g_GridRoutingSize; + width = PtDrawSegment->m_Width; + width += g_GridRoutingSize; - angle = - ArcTangente(dy, dx); - if (angle % 450)/* not H, V or X */ - { - wxBell(); - continue; - } + angle = -ArcTangente( dy, dx ); + if( angle % 450 )/* not H, V or X */ + { + wxBell(); + continue; + } - /* 1er point */ - dx = -width; dy = - width; - RotatePoint(&dx, &dy, angle); - lim[0].x = ox + dx; - lim[0].y = oy + dy; + /* 1er point */ + dx = -width; dy = -width; + RotatePoint( &dx, &dy, angle ); + lim[0].x = ox + dx; + lim[0].y = oy + dy; - /* 2eme point */ - RotatePoint(&dx, &dy, -900); - lim[1].x = fx + dx; - lim[1].y = fy + dy; + /* 2eme point */ + RotatePoint( &dx, &dy, -900 ); + lim[1].x = fx + dx; + lim[1].y = fy + dy; - /* 3eme point */ - RotatePoint(&dx, &dy, -900); - lim[2].x = fx + dx; - lim[2].y = fy + dy; + /* 3eme point */ + RotatePoint( &dx, &dy, -900 ); + lim[2].x = fx + dx; + lim[2].y = fy + dy; - /* 4eme point */ - RotatePoint(&dx, &dy, -900); - lim[3].x = ox + dx; - lim[3].y = oy + dy; + /* 4eme point */ + RotatePoint( &dx, &dy, -900 ); + lim[3].x = ox + dx; + lim[3].y = oy + dy; - if ( angle % 900 ) - { - } - /* mise a l'echelle */ - for( ii = 0; ii < 4; ii++ ) - { - lim[ii].x = (int)( ( (double)lim[ii].x + 0.5) / PSCALE); - lim[ii].y = (int)( ( (double)lim[ii].y + 0.5) / PSCALE); - } + if( angle % 900 ) + { + } + /* mise a l'echelle */ + for( ii = 0; ii < 4; ii++ ) + { + lim[ii].x = (int) ( ( (double) lim[ii].x + 0.5 ) / PSCALE ); + lim[ii].y = (int) ( ( (double) lim[ii].y + 0.5 ) / PSCALE ); + } - /* sortie du 1er point */ - fprintf(outfile,"n %d %d %ld %ld %d\n", - 0, /* layer number, 0 = all layers */ - 0, /* -1 (no via), 0 (no via no track), 1 (no track) */ - (long)lim[0].x, (long)lim[0].y, - NB_CORNERS); + /* sortie du 1er point */ + fprintf( outfile, "n %d %d %ld %ld %d\n", + 0, /* layer number, 0 = all layers */ + 0, /* -1 (no via), 0 (no via no track), 1 (no track) */ + (long) lim[0].x, (long) lim[0].y, + NB_CORNERS ); - /* sortie des autres points */ - for( ii = 1; ii < 4; ii++ ) - { - fprintf(outfile,"c %ld %ld\n", - (long)lim[ii].x, (long)lim[ii].y); - } - } + /* sortie des autres points */ + for( ii = 1; ii < 4; ii++ ) + { + fprintf( outfile, "c %ld %ld\n", + (long) lim[ii].x, (long) lim[ii].y ); + } + } - return NbItems; + return NbItems; } /****************************************************/ -void WinEDA_PcbFrame::ReadAutoroutedTracks(wxDC * DC) +void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC ) /****************************************************/ { -char Line[1024]; -wxString FullFileName, msg; -int LineNum = 0, NbTrack = 0, NetCode = 0; -FILE * File; -TRACK * NewTrack; -SEGVIA * NewVia; -int track_count, track_layer, image, track_width; -int via_layer1, via_layer2, via_size; -wxPoint track_start, track_end; -int max_layer = m_Pcb->m_BoardSettings->m_CopperLayerCount; + char Line[1024]; + wxString FullFileName, msg; + int LineNum = 0, NbTrack = 0, NetCode = 0; + FILE* File; + TRACK* NewTrack; + SEGVIA* NewVia; + int track_count, track_layer, image, track_width; + int via_layer1, via_layer2, via_size; + wxPoint track_start, track_end; + int max_layer = m_Pcb->m_BoardSettings->m_CopperLayerCount; - /* Calcule du nom du fichier intermediaire de communication */ - FullFileName = m_CurrentScreen->m_FileName; - ChangeFileNameExt(FullFileName, wxT(".trc")); + /* Calcule du nom du fichier intermediaire de communication */ + FullFileName = m_CurrentScreen->m_FileName; + ChangeFileNameExt( FullFileName, wxT( ".trc" ) ); - if( (File = wxFopen(FullFileName, wxT("rt"))) == NULL ) - { - msg = _("Unable to find data file ") + FullFileName; - DisplayError(this, msg, 20); - return; - } - else - { - msg = _("Reading autorouter data file ") + FullFileName; - Affiche_Message(msg); - } + if( ( File = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) + { + msg = _( "Unable to find data file " ) + FullFileName; + DisplayError( this, msg, 20 ); + return; + } + else + { + msg = _( "Reading autorouter data file " ) + FullFileName; + Affiche_Message( msg ); + } - setlocale(LC_NUMERIC, "C"); + setlocale( LC_NUMERIC, "C" ); - track_width = g_DesignSettings.m_CurrentTrackWidth; - via_size = g_DesignSettings.m_CurrentViaSize; - while( GetLine(File, Line, &LineNum ) != NULL ) - { - char ident = Line[0]; - switch ( ident ) - { - case 'j': // Header, not used - break; + track_width = g_DesignSettings.m_CurrentTrackWidth; + via_size = g_DesignSettings.m_CurrentViaSize; + while( GetLine( File, Line, &LineNum ) != NULL ) + { + char ident = Line[0]; - case 'R': // Net record - sscanf(Line+2, "%d", & NetCode); - break; - - case 'V': // via record: fmt = V symbol pos_x pos_y layer1 layer2 - sscanf(Line+2, "%d %d %d %d %d", & image, - & track_start.x, & track_start.y, & via_layer1, &via_layer2); - via_layer1--; via_layer2--; - if ( via_layer1 == max_layer-1 ) via_layer1 = CMP_N; - if ( via_layer2 == max_layer-1 ) via_layer2 = CMP_N; - NewVia = new SEGVIA(m_Pcb); - NewVia->m_Start = NewVia->m_End = track_start; - NewVia->m_Width = via_size; - NewVia->m_Layer = via_layer1 + (via_layer2<<4); - if ( NewVia->m_Layer == 0x0F || NewVia->m_Layer == 0xF0) - NewVia->m_Shape = VIA_NORMALE; - else NewVia->m_Shape = VIA_ENTERREE; - NewVia->Insert(m_Pcb, NULL); - NbTrack++; - break; - - case 'T': // Track list start: fmt = T image layer t_count - sscanf(Line+2, "%d %d %d", & image, & track_layer, & track_count); - track_layer--; - if ( (track_layer != CUIVRE_N) && (track_layer == max_layer-1) ) - track_layer = CMP_N; - // Read corners: fmt = C x_pos y_pos - for ( int ii = 0; ii < track_count; ii++ ) - { - if( GetLine(File, Line, &LineNum ) != NULL ) - { - if ( Line[0] != 'C' ) break; - if ( ii == 0 ) - sscanf(Line+2, "%d %d", & track_start.x, & track_start.y); - else - { - sscanf(Line+2, "%d %d", & track_end.x, & track_end.y); - NewTrack = new TRACK(m_Pcb); - NewTrack->m_Width = track_width; - NewTrack->m_Layer = track_layer; - NewTrack->m_Start = track_start; - NewTrack->m_End = track_end; - track_start = track_end; - NewTrack->Insert(m_Pcb, NULL); - NbTrack++; - } - } - else break; - } - break; - - default: - break; - } - } + switch( ident ) + { + case 'j': // Header, not used + break; - fclose(File); + case 'R': // Net record + sscanf( Line + 2, "%d", &NetCode ); + break; - setlocale(LC_NUMERIC, ""); + case 'V': // via record: fmt = V symbol pos_x pos_y layer1 layer2 + sscanf( Line + 2, "%d %d %d %d %d", &image, + &track_start.x, &track_start.y, &via_layer1, &via_layer2 ); + via_layer1--; via_layer2--; + if( via_layer1 == max_layer - 1 ) + via_layer1 = CMP_N; + if( via_layer2 == max_layer - 1 ) + via_layer2 = CMP_N; + NewVia = new SEGVIA( m_Pcb ); - if( NbTrack == 0 ) DisplayError(this, wxT("Warning: No tracks"), 10); - else - { - m_Pcb->m_Status_Pcb = 0; - m_CurrentScreen->SetModify(); - } + NewVia->m_Start = NewVia->m_End = track_start; + NewVia->m_Width = via_size; + NewVia->SetLayer( via_layer1 + (via_layer2 << 4) ); + if( NewVia->GetLayer() == 0x0F || NewVia->GetLayer() == 0xF0 ) + NewVia->m_Shape = VIA_NORMALE; + else + NewVia->m_Shape = VIA_ENTERREE; + NewVia->Insert( m_Pcb, NULL ); + NbTrack++; + break; - Compile_Ratsnest(DC, TRUE); - if( NbTrack ) m_CurrentScreen->SetRefreshReq(); + case 'T': // Track list start: fmt = T image layer t_count + sscanf( Line + 2, "%d %d %d", &image, &track_layer, &track_count ); + track_layer--; + if( (track_layer != CUIVRE_N) && (track_layer == max_layer - 1) ) + track_layer = CMP_N; + + // Read corners: fmt = C x_pos y_pos + for( int ii = 0; ii < track_count; ii++ ) + { + if( GetLine( File, Line, &LineNum ) != NULL ) + { + if( Line[0] != 'C' ) + break; + if( ii == 0 ) + sscanf( Line + 2, "%d %d", &track_start.x, &track_start.y ); + else + { + sscanf( Line + 2, "%d %d", &track_end.x, &track_end.y ); + NewTrack = new TRACK( m_Pcb ); + + NewTrack->m_Width = track_width; + NewTrack->SetLayer( track_layer ); + NewTrack->m_Start = track_start; + NewTrack->m_End = track_end; + track_start = track_end; + NewTrack->Insert( m_Pcb, NULL ); + NbTrack++; + } + } + else + break; + } + + break; + + default: + break; + } + } + + fclose( File ); + + setlocale( LC_NUMERIC, "" ); + + if( NbTrack == 0 ) + DisplayError( this, wxT( "Warning: No tracks" ), 10 ); + else + { + m_Pcb->m_Status_Pcb = 0; + m_CurrentScreen->SetModify(); + } + + Compile_Ratsnest( DC, TRUE ); + if( NbTrack ) + m_CurrentScreen->SetRefreshReq(); } - diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index 0ba2a51dab..e900010acf 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -1,8 +1,8 @@ - /***************************************/ - /* AUTOROUTAGE PCB : routine de calcul */ - /***************************************/ +/***************************************/ +/* AUTOROUTAGE PCB : routine de calcul */ +/***************************************/ - /* fichier SOLVE.Cpp */ +/* fichier SOLVE.Cpp */ #include "fctsys.h" #include "gr_basic.h" @@ -17,23 +17,24 @@ #include "cell.h" /* Routines definies ici : */ -static int Route_1_Trace(WinEDA_PcbFrame * pcbframe, wxDC * DC, int two_sides, int row_source,int col_source, - int row_target,int col_target, CHEVELU * pt_chevelu ); -static int Retrace(WinEDA_PcbFrame * pcbframe, wxDC * DC, int, int, int, int , int, int net_code); -static void OrCell_Trace(BOARD * pcb, int col,int row,int side,int orient, int current_net_code); -static void Place_Piste_en_Buffer(WinEDA_PcbFrame * pcbframe, wxDC * DC); +static int Route_1_Trace( WinEDA_PcbFrame* pcbframe, wxDC* DC, int two_sides, int row_source, + int col_source, + int row_target, int col_target, CHEVELU* pt_chevelu ); +static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, int, int, int, int, int, int net_code ); +static void OrCell_Trace( BOARD* pcb, int col, int row, int side, int orient, int current_net_code ); +static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ); /* Variables locales : */ -static int segm_oX, segm_oY; -static int segm_fX, segm_fY; /* Origine et fin de la piste en cours de trace */ +static int segm_oX, segm_oY; +static int segm_fX, segm_fY; /* Origine et fin de la piste en cours de trace */ static CHEVELU* pt_cur_ch; -static int Ncurrent; /* measures of progress */ +static int Ncurrent; /* measures of progress */ -#define NOSUCCESS 0 -#define STOP_FROM_ESC -1 -#define ERR_MEMORY -2 -#define SUCCESS 1 +#define NOSUCCESS 0 +#define STOP_FROM_ESC -1 +#define ERR_MEMORY -2 +#define SUCCESS 1 #define TRIVIAL_SUCCESS 2 /* @@ -49,616 +50,664 @@ static int Ncurrent; /* measures of progress */ */ /* for visiting neighbors on the same side: increments/decrements des coord - [][0] = row, []{1] = col a ajouter aux coord du point central pour - obtenir les coord des 8 points voisins */ + * [][0] = row, []{1] = col a ajouter aux coord du point central pour + * obtenir les coord des 8 points voisins */ static int delta[8][2] = { - { 1, -1 }, /* northwest */ - { 1, 0 }, /* north */ - { 1, 1 }, /* northeast */ - { 0, -1 }, /* west */ - { 0, 1 }, /* east */ - { -1, -1 }, /* southwest */ - { -1, 0 }, /* south */ - { -1, 1 } /* southeast */ - }; + { 1, -1 }, /* northwest */ + { 1, 0 }, /* north */ + { 1, 1 }, /* northeast */ + { 0, -1 }, /* west */ + { 0, 1 }, /* east */ + { -1, -1 }, /* southwest */ + { -1, 0 }, /* south */ + { -1, 1 } /* southeast */ +}; static int ndir[8] = { /* for building paths back to source */ - FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST, - FROM_EAST, FROM_WEST, - FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST - }; + FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST, + FROM_EAST, FROM_WEST, + FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST +}; /* blocking masks for neighboring cells */ -#define BLOCK_NORTHEAST ( DIAG_NEtoSW | BENT_StoNE | BENT_WtoNE \ - | ANGLE_NEtoSE | ANGLE_NWtoNE \ - | SHARP_NtoNE | SHARP_EtoNE | HOLE ) -#define BLOCK_SOUTHEAST ( DIAG_SEtoNW | BENT_NtoSE | BENT_WtoSE \ - | ANGLE_NEtoSE | ANGLE_SEtoSW \ - | SHARP_EtoSE | SHARP_StoSE | HOLE ) -#define BLOCK_SOUTHWEST ( DIAG_NEtoSW | BENT_NtoSW | BENT_EtoSW \ - | ANGLE_SEtoSW | ANGLE_SWtoNW \ - | SHARP_StoSW | SHARP_WtoSW | HOLE ) -#define BLOCK_NORTHWEST ( DIAG_SEtoNW | BENT_EtoNW | BENT_StoNW \ - | ANGLE_SWtoNW | ANGLE_NWtoNE \ - | SHARP_WtoNW | SHARP_NtoNW | HOLE ) -#define BLOCK_NORTH ( LINE_VERTICAL | BENT_NtoSE | BENT_NtoSW \ - | BENT_EtoNW | BENT_WtoNE \ - | BENT_StoNE | BENT_StoNW \ - | CORNER_NORTHEAST | CORNER_NORTHWEST \ - | ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_NWtoNE \ - | DIAG_NEtoSW | DIAG_SEtoNW \ - | SHARP_NtoNE | SHARP_NtoNW \ - | SHARP_EtoNE | SHARP_WtoNW | HOLE ) -#define BLOCK_EAST ( LINE_HORIZONTAL | BENT_EtoSW | BENT_EtoNW \ - | BENT_NtoSE | BENT_StoNE \ - | BENT_WtoNE | BENT_WtoSE \ - | CORNER_NORTHEAST | CORNER_SOUTHEAST \ - | ANGLE_NEtoSE | ANGLE_SEtoSW | ANGLE_NWtoNE \ - | DIAG_NEtoSW | DIAG_SEtoNW \ - | SHARP_EtoNE | SHARP_EtoSE \ - | SHARP_NtoNE | SHARP_StoSE | HOLE ) -#define BLOCK_SOUTH ( LINE_VERTICAL | BENT_StoNE | BENT_StoNW \ - | BENT_EtoSW | BENT_WtoSE \ - | BENT_NtoSE | BENT_NtoSW \ - | CORNER_SOUTHEAST | CORNER_SOUTHWEST \ - | ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_SEtoSW \ - | DIAG_NEtoSW | DIAG_SEtoNW \ - | SHARP_StoSE | SHARP_StoSW \ - | SHARP_EtoSE | SHARP_WtoSW | HOLE ) -#define BLOCK_WEST ( LINE_HORIZONTAL | BENT_WtoNE | BENT_WtoSE \ - | BENT_NtoSW | BENT_StoNW \ - | BENT_EtoSW | BENT_EtoNW \ - | CORNER_SOUTHWEST | CORNER_NORTHWEST \ - | ANGLE_SWtoNW | ANGLE_SEtoSW | ANGLE_NWtoNE \ - | DIAG_NEtoSW | DIAG_SEtoNW \ - | SHARP_WtoSW | SHARP_WtoNW \ - | SHARP_NtoNW | SHARP_StoSW | HOLE ) +#define BLOCK_NORTHEAST ( DIAG_NEtoSW | BENT_StoNE | BENT_WtoNE \ + | ANGLE_NEtoSE | ANGLE_NWtoNE \ + | SHARP_NtoNE | SHARP_EtoNE | HOLE ) +#define BLOCK_SOUTHEAST ( DIAG_SEtoNW | BENT_NtoSE | BENT_WtoSE \ + | ANGLE_NEtoSE | ANGLE_SEtoSW \ + | SHARP_EtoSE | SHARP_StoSE | HOLE ) +#define BLOCK_SOUTHWEST ( DIAG_NEtoSW | BENT_NtoSW | BENT_EtoSW \ + | ANGLE_SEtoSW | ANGLE_SWtoNW \ + | SHARP_StoSW | SHARP_WtoSW | HOLE ) +#define BLOCK_NORTHWEST ( DIAG_SEtoNW | BENT_EtoNW | BENT_StoNW \ + | ANGLE_SWtoNW | ANGLE_NWtoNE \ + | SHARP_WtoNW | SHARP_NtoNW | HOLE ) +#define BLOCK_NORTH ( LINE_VERTICAL | BENT_NtoSE | BENT_NtoSW \ + | BENT_EtoNW | BENT_WtoNE \ + | BENT_StoNE | BENT_StoNW \ + | CORNER_NORTHEAST | CORNER_NORTHWEST \ + | ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_NWtoNE \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_NtoNE | SHARP_NtoNW \ + | SHARP_EtoNE | SHARP_WtoNW | HOLE ) +#define BLOCK_EAST ( LINE_HORIZONTAL | BENT_EtoSW | BENT_EtoNW \ + | BENT_NtoSE | BENT_StoNE \ + | BENT_WtoNE | BENT_WtoSE \ + | CORNER_NORTHEAST | CORNER_SOUTHEAST \ + | ANGLE_NEtoSE | ANGLE_SEtoSW | ANGLE_NWtoNE \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_EtoNE | SHARP_EtoSE \ + | SHARP_NtoNE | SHARP_StoSE | HOLE ) +#define BLOCK_SOUTH ( LINE_VERTICAL | BENT_StoNE | BENT_StoNW \ + | BENT_EtoSW | BENT_WtoSE \ + | BENT_NtoSE | BENT_NtoSW \ + | CORNER_SOUTHEAST | CORNER_SOUTHWEST \ + | ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_SEtoSW \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_StoSE | SHARP_StoSW \ + | SHARP_EtoSE | SHARP_WtoSW | HOLE ) +#define BLOCK_WEST ( LINE_HORIZONTAL | BENT_WtoNE | BENT_WtoSE \ + | BENT_NtoSW | BENT_StoNW \ + | BENT_EtoSW | BENT_EtoNW \ + | CORNER_SOUTHWEST | CORNER_NORTHWEST \ + | ANGLE_SWtoNW | ANGLE_SEtoSW | ANGLE_NWtoNE \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_WtoSW | SHARP_WtoNW \ + | SHARP_NtoNW | SHARP_StoSW | HOLE ) -struct block { - int r1, c1; - long b1; - int r2, c2; - long b2; - }; +struct block +{ + int r1, c1; + long b1; + int r2, c2; + long b2; +}; -static struct block blocking[8] = { /* blocking masks for diagonal traces */ - { 0, -1, BLOCK_NORTHEAST, 1, 0, BLOCK_SOUTHWEST }, - { 0, 0, 0, 0, 0, 0 }, - { 1, 0, BLOCK_SOUTHEAST, 0, 1, BLOCK_NORTHWEST }, - { 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0 }, - { 0, -1, BLOCK_SOUTHEAST, -1, 0, BLOCK_NORTHWEST }, - { 0, 0, 0, 0, 0, 0 }, - { -1, 0, BLOCK_NORTHEAST, 0, 1, BLOCK_SOUTHWEST } - }; +static struct block blocking[8] = /* blocking masks for diagonal traces */ +{ { 0, -1, + BLOCK_NORTHEAST, + 1, 0, + BLOCK_SOUTHWEST }, + { 0, 0, 0, + 0, 0, 0 }, + { 1, 0, + BLOCK_SOUTHEAST, + 0, 1, + BLOCK_NORTHWEST }, + { 0, 0, 0, + 0, 0, 0 }, + { 0, 0, 0, + 0, 0, 0 }, + { 0, -1, + BLOCK_SOUTHEAST, + -1, 0, + BLOCK_NORTHWEST }, + { 0, 0, 0, + 0, 0, 0 }, + { -1, 0, + BLOCK_NORTHEAST, + 0, 1, + BLOCK_SOUTHWEST } }; /* mask for hole-related blocking effects */ -static struct { - long trace; - int present; - } selfok2[8] = { - { HOLE_NORTHWEST, 0 }, - { HOLE_NORTH, 0 }, - { HOLE_NORTHEAST, 0 }, - { HOLE_WEST, 0 }, - { HOLE_EAST, 0 }, - { HOLE_SOUTHWEST, 0 }, - { HOLE_SOUTH, 0 }, - { HOLE_SOUTHEAST, 0 } - }; +static struct +{ + long trace; + int present; +} selfok2[8] = { + { HOLE_NORTHWEST, 0 }, + { HOLE_NORTH, 0 }, + { HOLE_NORTHEAST, 0 }, + { HOLE_WEST, 0 }, + { HOLE_EAST, 0 }, + { HOLE_SOUTHWEST, 0 }, + { HOLE_SOUTH, 0 }, + { HOLE_SOUTHEAST, 0 } +}; static long newmask[8] = { /* patterns to mask out in neighbor cells */ - 0, CORNER_NORTHWEST|CORNER_NORTHEAST, 0, - CORNER_NORTHWEST|CORNER_SOUTHWEST, CORNER_NORTHEAST|CORNER_SOUTHEAST, - 0, CORNER_SOUTHWEST|CORNER_SOUTHEAST, 0 - }; + 0, CORNER_NORTHWEST | CORNER_NORTHEAST, 0, + CORNER_NORTHWEST | CORNER_SOUTHWEST, CORNER_NORTHEAST | CORNER_SOUTHEAST, + 0, CORNER_SOUTHWEST | CORNER_SOUTHEAST, 0 +}; /* Macro d'affichage de l'activite du routeur; */ #define AFFICHE_ACTIVITE_ROUTE \ - msg.Printf( wxT("%5.5d"),OpenNodes); \ - Affiche_1_Parametre(pcbframe, 24,wxT("Open"),msg,WHITE); \ - msg.Printf( wxT("%5.5d"),ClosNodes); \ - Affiche_1_Parametre(pcbframe, 32,wxT("Closed"),msg,WHITE);\ - msg.Printf( wxT("%5.5d"),MoveNodes); \ - Affiche_1_Parametre(pcbframe, 40,wxT("Moved"),msg,WHITE); \ - msg.Printf( wxT("%5.5d"),MaxNodes); \ - Affiche_1_Parametre(pcbframe, 48,wxT("Max"),msg,WHITE); \ - msg.Printf( wxT("%2.2d"),(ClosNodes*50)/(Nrows*Ncols) ); \ - Affiche_1_Parametre(pcbframe, 56, wxT("%"),msg,CYAN); + msg.Printf( wxT( "%5.5d" ), OpenNodes ); \ + Affiche_1_Parametre( pcbframe, 24, wxT( "Open" ), msg, WHITE ); \ + msg.Printf( wxT( "%5.5d" ), ClosNodes ); \ + Affiche_1_Parametre( pcbframe, 32, wxT( "Closed" ), msg, WHITE ); \ + msg.Printf( wxT( "%5.5d" ), MoveNodes ); \ + Affiche_1_Parametre( pcbframe, 40, wxT( "Moved" ), msg, WHITE ); \ + msg.Printf( wxT( "%5.5d" ), MaxNodes ); \ + Affiche_1_Parametre( pcbframe, 48, wxT( "Max" ), msg, WHITE ); \ + msg.Printf( wxT( "%2.2d" ), (ClosNodes * 50) / (Nrows * Ncols) ); \ + Affiche_1_Parametre( pcbframe, 56, wxT( "%" ), msg, CYAN ); - /********************************************************/ - /* int WinEDA_PcbFrame::Solve(wxDC * DC, int two_sides) */ - /********************************************************/ +/********************************************************/ +/* int WinEDA_PcbFrame::Solve(wxDC * DC, int two_sides) */ +/********************************************************/ - /* route all traces - Return: 1 si OK - -1 si Escape (arret en cours de routage) demande - -2 si defaut alloc memoire -*/ +/* route all traces + * Return: 1 si OK + * -1 si Escape (arret en cours de routage) demande + * -2 si defaut alloc memoire + */ -int WinEDA_PcbFrame::Solve(wxDC * DC, int two_sides) +int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides ) { -int current_net_code; -int row_source, col_source, row_target, col_target; -int success, nbsucces = 0, nbunsucces = 0; -EQUIPOT * pt_equipot; -bool stop = FALSE; -wxString msg; - - DrawPanel->m_AbortRequest = FALSE; - DrawPanel->m_AbortEnable = TRUE; + int current_net_code; + int row_source, col_source, row_target, col_target; + int success, nbsucces = 0, nbunsucces = 0; + EQUIPOT* pt_equipot; + bool stop = FALSE; + wxString msg; - Ncurrent = 0; - MsgPanel->EraseMsgBox(); - msg.Printf( wxT("%d "),m_Pcb->m_NbNoconnect); - Affiche_1_Parametre(this, 72, wxT("NoConn"),msg,LIGHTCYAN); + DrawPanel->m_AbortRequest = FALSE; + DrawPanel->m_AbortEnable = TRUE; + + Ncurrent = 0; + MsgPanel->EraseMsgBox(); + msg.Printf( wxT( "%d " ), m_Pcb->m_NbNoconnect ); + Affiche_1_Parametre( this, 72, wxT( "NoConn" ), msg, LIGHTCYAN ); - /* go until no more work to do */ - GetWork( &row_source, &col_source, ¤t_net_code, - &row_target, &col_target, &pt_cur_ch ); // 1er chevelu a router + /* go until no more work to do */ + GetWork( &row_source, &col_source, ¤t_net_code, + &row_target, &col_target, &pt_cur_ch ); // 1er chevelu a router - for ( ; row_source != ILLEGAL; GetWork( &row_source, &col_source, - ¤t_net_code, &row_target, &col_target, &pt_cur_ch )) - { - /* Tst demande d'arret de routage ( key ESCAPE actionnee ) */ - wxYield(); - if( DrawPanel->m_AbortRequest ) - { - if ( IsOK(this, _("Abort routing?" )) ) - { - success = STOP_FROM_ESC; - stop = TRUE; - break; - } - else DrawPanel->m_AbortRequest = 0; - } + for( ; row_source != ILLEGAL; GetWork( &row_source, &col_source, + ¤t_net_code, &row_target, &col_target, + &pt_cur_ch ) ) + { + /* Tst demande d'arret de routage ( key ESCAPE actionnee ) */ + wxYield(); + if( DrawPanel->m_AbortRequest ) + { + if( IsOK( this, _( "Abort routing?" ) ) ) + { + success = STOP_FROM_ESC; + stop = TRUE; + break; + } + else + DrawPanel->m_AbortRequest = 0; + } - Ncurrent++; - pt_equipot = m_Pcb->FindNet( current_net_code ); - if( pt_equipot) - { - msg.Printf( wxT("[%8.8s]"),pt_equipot->m_Netname.GetData()); - Affiche_1_Parametre(this, 1, wxT("Net route"), msg,YELLOW); - msg.Printf( wxT( "%d / %d"),Ncurrent, Ntotal); - Affiche_1_Parametre(this, 12, wxT("Activity"), msg,YELLOW); - } + Ncurrent++; + pt_equipot = m_Pcb->FindNet( current_net_code ); + if( pt_equipot ) + { + msg.Printf( wxT( "[%8.8s]" ), pt_equipot->m_Netname.GetData() ); + Affiche_1_Parametre( this, 1, wxT( "Net route" ), msg, YELLOW ); + msg.Printf( wxT( "%d / %d" ), Ncurrent, Ntotal ); + Affiche_1_Parametre( this, 12, wxT( "Activity" ), msg, YELLOW ); + } - pt_cur_ch = pt_cur_ch; - segm_oX = m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_source); - segm_oY = m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_source); - segm_fX = m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_target); - segm_fY = m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_target); + pt_cur_ch = pt_cur_ch; + segm_oX = m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_source); + segm_oY = m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_source); + segm_fX = m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_target); + segm_fY = m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_target); - /* Affiche Liaison */ - GRLine(&DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, 0, WHITE | GR_XOR); - pt_cur_ch->pad_start->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR | GR_SURBRILL); - pt_cur_ch->pad_end->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR|GR_SURBRILL); + /* Affiche Liaison */ + GRLine( &DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, 0, WHITE | GR_XOR ); + pt_cur_ch->pad_start->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR | GR_SURBRILL ); + pt_cur_ch->pad_end->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR | GR_SURBRILL ); - success = Route_1_Trace(this, DC, two_sides, row_source, col_source, - row_target, col_target, pt_cur_ch ); - switch (success) - { - case NOSUCCESS: - pt_cur_ch->status |= CH_UNROUTABLE; - nbunsucces++; - break; + success = Route_1_Trace( this, DC, two_sides, row_source, col_source, + row_target, col_target, pt_cur_ch ); - case STOP_FROM_ESC: - stop = TRUE; - break; + switch( success ) + { + case NOSUCCESS: + pt_cur_ch->status |= CH_UNROUTABLE; + nbunsucces++; + break; - case ERR_MEMORY: - stop = TRUE; - break; + case STOP_FROM_ESC: + stop = TRUE; + break; - default: - nbsucces++; - break; - } + case ERR_MEMORY: + stop = TRUE; + break; - msg.Printf( wxT("%d "),nbsucces); - Affiche_1_Parametre(this, 61, wxT("Ok"),msg,LIGHTGREEN); - msg.Printf( wxT("%d "),nbunsucces); - Affiche_1_Parametre(this, 66, wxT("Fail"),msg,LIGHTRED); - msg.Printf( wxT("%d "),m_Pcb->m_NbNoconnect); - Affiche_1_Parametre(this, 72, wxT("NoConn"),msg,LIGHTCYAN); + default: + nbsucces++; + break; + } - /* Effacement des affichages de routage sur l'ecran */ - pt_cur_ch->pad_start->Draw(DrawPanel, DC, wxPoint(0,0), GR_AND); - pt_cur_ch->pad_end->Draw(DrawPanel, DC,wxPoint(0,0), GR_AND); + msg.Printf( wxT( "%d " ), nbsucces ); + Affiche_1_Parametre( this, 61, wxT( "Ok" ), msg, LIGHTGREEN ); + msg.Printf( wxT( "%d " ), nbunsucces ); + Affiche_1_Parametre( this, 66, wxT( "Fail" ), msg, LIGHTRED ); + msg.Printf( wxT( "%d " ), m_Pcb->m_NbNoconnect ); + Affiche_1_Parametre( this, 72, wxT( "NoConn" ), msg, LIGHTCYAN ); - if ( stop ) break; - } + /* Effacement des affichages de routage sur l'ecran */ + pt_cur_ch->pad_start->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_AND ); + pt_cur_ch->pad_end->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_AND ); - DrawPanel->m_AbortEnable = FALSE; + if( stop ) + break; + } - return(SUCCESS); + DrawPanel->m_AbortEnable = FALSE; + + return SUCCESS; } - /**************************/ - /* int Route_1_Trace(xxx) */ - /**************************/ + +/**************************/ +/* int Route_1_Trace(xxx) */ +/**************************/ /* Route une piste du BOARD. - Parametres: - 1 face / 2 faces ( 0 / 1) - coord source (row,col) - coord destination (row,col) - net_code - pointeur sur le chevelu de reference - - Retourne : - SUCCESS si route trouvee - TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer) - NOSUCCESS si echec - STOP_FROM_ESC si Escape demande - ERR_MEMORY defaut alloc RAM -*/ -static int Route_1_Trace(WinEDA_PcbFrame * pcbframe, wxDC * DC, - int two_sides, int row_source,int col_source, - int row_target,int col_target, CHEVELU * pt_chevelu ) + * Parametres: + * 1 face / 2 faces ( 0 / 1) + * coord source (row,col) + * coord destination (row,col) + * net_code + * pointeur sur le chevelu de reference + * + * Retourne : + * SUCCESS si route trouvee + * TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer) + * NOSUCCESS si echec + * STOP_FROM_ESC si Escape demande + * ERR_MEMORY defaut alloc RAM + */ +static int Route_1_Trace( WinEDA_PcbFrame* pcbframe, wxDC* DC, + int two_sides, int row_source, int col_source, + int row_target, int col_target, CHEVELU* pt_chevelu ) { -int r, c, side , d, apx_dist, nr, nc; -int result, skip; -int i; -LISTE_PAD * ptr; -long curcell, newcell, buddy, lastopen, lastclos, lastmove; -int newdist, olddir, _self; -int current_net_code; -int marge, via_marge; -int pad_masque_layer_s; /* Masque des couches appartenant au pad de depart */ -int pad_masque_layer_e; /* Masque des couches appartenant au pad d'arrivee */ -int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP]; -int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM]; -int masque_layers; /* Masque des 2 couches de routage */ -int tab_mask[2]; /* permet le calcul du Masque de la couche en cours - de tst (side = TOP ou BOTTOM)*/ -int start_mask_layer = 0; -wxString msg; - - result = NOSUCCESS; + int r, c, side, d, apx_dist, nr, nc; + int result, skip; + int i; + LISTE_PAD* ptr; + long curcell, newcell, buddy, lastopen, lastclos, lastmove; + int newdist, olddir, _self; + int current_net_code; + int marge, via_marge; + int pad_masque_layer_s; /* Masque des couches appartenant au pad de depart */ + int pad_masque_layer_e; /* Masque des couches appartenant au pad d'arrivee */ + int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP]; + int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM]; + int masque_layers; /* Masque des 2 couches de routage */ + int tab_mask[2];/* permet le calcul du Masque de la couche en cours + * de tst (side = TOP ou BOTTOM)*/ + int start_mask_layer = 0; + wxString msg; - marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth / 2); - via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize / 2); + result = NOSUCCESS; - /* clear direction flags */ - i = Nrows * Ncols * sizeof(char); - memset(Board.m_DirSide[TOP], FROM_NOWHERE, i ); - memset(Board.m_DirSide[BOTTOM], FROM_NOWHERE, i ); + marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth / 2); + via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize / 2); - lastopen = lastclos = lastmove = 0; + /* clear direction flags */ + i = Nrows * Ncols * sizeof(char); + memset( Board.m_DirSide[TOP], FROM_NOWHERE, i ); + memset( Board.m_DirSide[BOTTOM], FROM_NOWHERE, i ); - /* Init tab_masque[side] pour tests de fin de routage */ - tab_mask[TOP] = masque_layer_TOP; - tab_mask[BOTTOM] = masque_layer_BOTTOM; - /* Init masque des couches actives */ - masque_layers = masque_layer_TOP | masque_layer_BOTTOM; + lastopen = lastclos = lastmove = 0; - pt_cur_ch = pt_chevelu; - current_net_code = pt_chevelu->m_NetCode; - pad_masque_layer_s = pt_cur_ch->pad_start->m_Masque_Layer; - pad_masque_layer_e = pt_cur_ch->pad_end->m_Masque_Layer; + /* Init tab_masque[side] pour tests de fin de routage */ + tab_mask[TOP] = masque_layer_TOP; + tab_mask[BOTTOM] = masque_layer_BOTTOM; + /* Init masque des couches actives */ + masque_layers = masque_layer_TOP | masque_layer_BOTTOM; - /* Test 1 Si routage possible c.a.d si les pads sont accessibles - sur les couches de routage */ + pt_cur_ch = pt_chevelu; + current_net_code = pt_chevelu->m_NetCode; + pad_masque_layer_s = pt_cur_ch->pad_start->m_Masque_Layer; + pad_masque_layer_e = pt_cur_ch->pad_end->m_Masque_Layer; - if( (masque_layers & pad_masque_layer_s) == 0 ) goto end_of_route; - if( (masque_layers & pad_masque_layer_e) == 0 ) goto end_of_route; + /* Test 1 Si routage possible c.a.d si les pads sont accessibles + * sur les couches de routage */ - /* Test 2 Si routage possible c.a.d si les pads sont accessibles - sur la grille de routage ( 1 point de grille doit etre dans le pad)*/ - { - int cX = (g_GridRoutingSize * col_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x; - int cY = (g_GridRoutingSize * row_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y; - int dx = pt_cur_ch->pad_start->m_Size.x / 2; - int dy = pt_cur_ch->pad_start->m_Size.y / 2; - int px = pt_cur_ch->pad_start->m_Pos.x; - int py = pt_cur_ch->pad_start->m_Pos.y; + if( (masque_layers & pad_masque_layer_s) == 0 ) + goto end_of_route; + if( (masque_layers & pad_masque_layer_e) == 0 ) + goto end_of_route; - if ( ((pt_cur_ch->pad_start->m_Orient/900)&1) != 0 ) EXCHG(dx,dy) ; - if ( (abs(cX - px) > dx ) || (abs(cY - py) > dy) ) goto end_of_route; + /* Test 2 Si routage possible c.a.d si les pads sont accessibles + * sur la grille de routage ( 1 point de grille doit etre dans le pad)*/ + { + int cX = (g_GridRoutingSize * col_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x; + int cY = (g_GridRoutingSize * row_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y; + int dx = pt_cur_ch->pad_start->m_Size.x / 2; + int dy = pt_cur_ch->pad_start->m_Size.y / 2; + int px = pt_cur_ch->pad_start->m_Pos.x; + int py = pt_cur_ch->pad_start->m_Pos.y; - cX = (g_GridRoutingSize * col_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x; - cY = (g_GridRoutingSize * row_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y; - dx = pt_cur_ch->pad_end->m_Size.x / 2; - dy = pt_cur_ch->pad_end->m_Size.y / 2; - px = pt_cur_ch->pad_end->m_Pos.x; - py = pt_cur_ch->pad_end->m_Pos.y; - if ( ((pt_cur_ch->pad_end->m_Orient/900)&1) != 0 ) EXCHG(dx,dy) ; + if( ( (pt_cur_ch->pad_start->m_Orient / 900) & 1 ) != 0 ) + EXCHG( dx, dy ); + if( (abs( cX - px ) > dx ) || (abs( cY - py ) > dy) ) + goto end_of_route; - if ( (abs(cX - px) > dx ) || (abs(cY - py) > dy) ) goto end_of_route; - } + cX = (g_GridRoutingSize * col_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x; + cY = (g_GridRoutingSize * row_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y; + dx = pt_cur_ch->pad_end->m_Size.x / 2; + dy = pt_cur_ch->pad_end->m_Size.y / 2; + px = pt_cur_ch->pad_end->m_Pos.x; + py = pt_cur_ch->pad_end->m_Pos.y; + if( ( (pt_cur_ch->pad_end->m_Orient / 900) & 1 ) != 0 ) + EXCHG( dx, dy ); - /* Test du cas trivial: connection directe par superposition des pads */ - if( (row_source == row_target) && (col_source == col_target) - && ( pad_masque_layer_e & pad_masque_layer_s & g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]) ) - { - result = TRIVIAL_SUCCESS; - goto end_of_route; - } + if( (abs( cX - px ) > dx ) || (abs( cY - py ) > dy) ) + goto end_of_route; + } + + /* Test du cas trivial: connection directe par superposition des pads */ + if( (row_source == row_target) && (col_source == col_target) + && ( pad_masque_layer_e & pad_masque_layer_s & + g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount - 1]) ) + { + result = TRIVIAL_SUCCESS; + goto end_of_route; + } + /* Placement du bit de suppression d'obstacle relative aux 2 pads a relier */ + pcbframe->Affiche_Message( wxT( "Gen Cells" ) ); - /* Placement du bit de suppression d'obstacle relative aux 2 pads a relier */ - pcbframe->Affiche_Message( wxT("Gen Cells") ); + Place_1_Pad_Board( pcbframe->m_Pcb, pt_cur_ch->pad_start, CURRENT_PAD, marge, WRITE_OR_CELL ); + Place_1_Pad_Board( pcbframe->m_Pcb, pt_cur_ch->pad_end, CURRENT_PAD, marge, WRITE_OR_CELL ); - Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_start,CURRENT_PAD ,marge,WRITE_OR_CELL); - Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_end, CURRENT_PAD ,marge,WRITE_OR_CELL); + /* Regenere les barrieres restantes (qui peuvent empieter sur le placement + * des bits precedents) */ + ptr = (LISTE_PAD*) pcbframe->m_Pcb->m_Pads; i = pcbframe->m_Pcb->m_NbPads; + for( ; i > 0; i--, ptr++ ) + { + if( (pt_cur_ch->pad_start != *ptr) && (pt_cur_ch->pad_end != *ptr) ) + { + Place_1_Pad_Board( pcbframe->m_Pcb, *ptr, ~CURRENT_PAD, marge, WRITE_AND_CELL ); + } + } - /* Regenere les barrieres restantes (qui peuvent empieter sur le placement - des bits precedents) */ - ptr = (LISTE_PAD*) pcbframe->m_Pcb->m_Pads; i = pcbframe->m_Pcb->m_NbPads; - for( ; i > 0 ; i-- , ptr++) - { - if((pt_cur_ch->pad_start != *ptr) && (pt_cur_ch->pad_end != *ptr) ) - { - Place_1_Pad_Board(pcbframe->m_Pcb, *ptr, ~CURRENT_PAD,marge,WRITE_AND_CELL); - } - } + InitQueue(); /* initialize the search queue */ + apx_dist = GetApxDist( row_source, col_source, row_target, col_target ); - InitQueue(); /* initialize the search queue */ - apx_dist = GetApxDist( row_source, col_source, row_target, col_target ); + /* Init 1ere recherche */ + if( two_sides ) /* orientation preferentielle */ + { + if( abs( row_target - row_source ) > abs( col_target - col_source ) ) + { + if( pad_masque_layer_s & masque_layer_TOP ) + { + start_mask_layer = 2; + if( SetQueue( row_source, col_source, TOP, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return ERR_MEMORY; + } + } + if( pad_masque_layer_s & masque_layer_BOTTOM ) + { + start_mask_layer |= 1; - /* Init 1ere recherche */ - if(two_sides) /* orientation preferentielle */ - { - if( abs(row_target-row_source) > abs(col_target-col_source) ) - { - if( pad_masque_layer_s & masque_layer_TOP ) - { - start_mask_layer = 2; - if(SetQueue( row_source, col_source, TOP, 0, apx_dist, - row_target, col_target ) == 0) - { - return(ERR_MEMORY); - } - } - if( pad_masque_layer_s & masque_layer_BOTTOM ) - { - start_mask_layer |= 1; + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return ERR_MEMORY; + } + } + } + else + { + if( pad_masque_layer_s & masque_layer_BOTTOM ) + { + start_mask_layer = 1; + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return ERR_MEMORY; + } + } + if( pad_masque_layer_s & masque_layer_TOP ) + { + start_mask_layer |= 2; - if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, - row_target, col_target ) == 0 ) - { - return(ERR_MEMORY); - } - } - } - else - { - if( pad_masque_layer_s & masque_layer_BOTTOM ) - { - start_mask_layer = 1; - if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, - row_target, col_target ) == 0 ) - { - return(ERR_MEMORY); - } - } - if( pad_masque_layer_s & masque_layer_TOP ) - { - start_mask_layer |= 2; + if( SetQueue( row_source, col_source, TOP, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return ERR_MEMORY; + } + } + } + } + else if( pad_masque_layer_s & masque_layer_BOTTOM ) + { + start_mask_layer = 1; - if (SetQueue( row_source, col_source, TOP, 0, apx_dist, - row_target, col_target ) == 0 ) - { - return(ERR_MEMORY); - } - } - } - } + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return ERR_MEMORY; + } + } - else - if( pad_masque_layer_s & masque_layer_BOTTOM ) - { - start_mask_layer = 1; + /* search until success or we exhaust all possibilities */ + GetQueue( &r, &c, &side, &d, &apx_dist ); + for( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) ) + { + curcell = GetCell( r, c, side ); + if( curcell & CURRENT_PAD ) + curcell &= ~HOLE; + if( (r == row_target) && (c == col_target) /* success si layer OK */ + && ( tab_mask[side] & pad_masque_layer_e) ) + { + /* Efface Liaison */ + GRSetDrawMode( DC, GR_XOR ); + GRLine( &pcbframe->DrawPanel->m_ClipBox, + DC, + segm_oX, + segm_oY, + segm_fX, + segm_fY, + 0, + WHITE ); - if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, - row_target, col_target ) == 0 ) - { - return(ERR_MEMORY); - } - } + /* Generation de la trace */ + if( Retrace( pcbframe, DC, row_source, col_source, + row_target, col_target, side, current_net_code ) ) + { + result = SUCCESS; /* Success : Route OK */ + } + break; /* Fin du routage */ + } + /* report every 300 new nodes or so */ + if( (OpenNodes - lastopen > 300) || (ClosNodes - lastclos > 300) || + (MoveNodes - lastmove > 300) ) + { + lastopen = (OpenNodes / 300) * 300; lastclos = (ClosNodes / 300) * 300; + lastmove = (MoveNodes / 300) * 300; - /* search until success or we exhaust all possibilities */ - GetQueue( &r, &c, &side, &d, &apx_dist ); - for ( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) ) - { - curcell = GetCell( r, c, side ); - if(curcell & CURRENT_PAD) curcell &= ~HOLE ; - if( (r == row_target) && (c == col_target) /* success si layer OK */ - && ( tab_mask[side] & pad_masque_layer_e) ) - { - /* Efface Liaison */ - GRSetDrawMode(DC, GR_XOR); - GRLine(&pcbframe->DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, 0, WHITE); + if( pcbframe->DrawPanel->m_AbortRequest ) + { + result = STOP_FROM_ESC; break; + } + AFFICHE_ACTIVITE_ROUTE; + } - /* Generation de la trace */ - if( Retrace(pcbframe, DC, row_source, col_source, - row_target, col_target, side, current_net_code) ) - { - result = SUCCESS; /* Success : Route OK */ - } - break; /* Fin du routage */ - } - /* report every 300 new nodes or so */ - if( (OpenNodes-lastopen > 300) || (ClosNodes-lastclos > 300) || (MoveNodes - lastmove > 300)) - { - lastopen = (OpenNodes/300)*300; lastclos = (ClosNodes/300)*300; - lastmove = (MoveNodes/300)*300; + _self = 0; + if( curcell & HOLE ) + { + _self = 5; + /* set 'present' bits */ + for( i = 0; i < 8; i++ ) + { + selfok2[i].present = 0; + if( (curcell & selfok2[i].trace) ) + selfok2[i].present = 1; + } + } - if( pcbframe->DrawPanel->m_AbortRequest ) - { - result = STOP_FROM_ESC; break; - } - AFFICHE_ACTIVITE_ROUTE; - } + for( i = 0; i < 8; i++ ) /* consider neighbors */ + { + nr = r + delta[i][0]; nc = c + delta[i][1]; - _self = 0; - if (curcell & HOLE) - { - _self = 5; - /* set 'present' bits */ - for (i = 0; i < 8; i++) - { - selfok2[i].present = 0; - if( (curcell & selfok2[i].trace) ) selfok2[i].present = 1; - } - } + /* off the edge? */ + if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols ) + continue;/* off the edge */ - for (i = 0; i < 8; i++) /* consider neighbors */ - { - nr = r+delta[i][0]; nc = c+delta[i][1]; + if( _self == 5 && selfok2[i].present ) + continue; + newcell = GetCell( nr, nc, side ); + if( newcell & CURRENT_PAD ) + newcell &= ~HOLE; - /* off the edge? */ - if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols) - continue; /* off the edge */ + /* check for non-target hole */ + if( newcell & HOLE ) + { + if( nr != row_target || nc != col_target ) + continue; + } + /* check for traces */ + else if( newcell & HOLE & ~(newmask[i]) ) + continue; - if (_self == 5 && selfok2[i].present) continue; - newcell = GetCell( nr, nc, side ); - if(newcell & CURRENT_PAD) newcell &= ~HOLE; + /* check blocking on corner neighbors */ + if( delta[i][0] && delta[i][1] ) + { + /* check first buddy */ + buddy = GetCell( r + blocking[i].r1, c + blocking[i].c1, side ); + if( buddy & CURRENT_PAD ) + buddy &= ~HOLE; + if( buddy & HOLE ) + continue; - /* check for non-target hole */ - if (newcell & HOLE) - { - if (nr != row_target || nc != col_target) continue; - } - - /* check for traces */ - else if (newcell & HOLE & ~(newmask[i])) continue; - - /* check blocking on corner neighbors */ - if (delta[i][0] && delta[i][1]) - { - /* check first buddy */ - buddy = GetCell( r+blocking[i].r1, c+blocking[i].c1, side ); - if(buddy & CURRENT_PAD) buddy &= ~HOLE; - if (buddy & HOLE) continue; // if (buddy & (blocking[i].b1)) continue; - /* check second buddy */ - buddy = GetCell( r+blocking[i].r2, c+blocking[i].c2, side ); - if(buddy & CURRENT_PAD) buddy &= ~HOLE; - if (buddy & HOLE) continue; + /* check second buddy */ + buddy = GetCell( r + blocking[i].r2, c + blocking[i].c2, side ); + if( buddy & CURRENT_PAD ) + buddy &= ~HOLE; + if( buddy & HOLE ) + continue; + // if (buddy & (blocking[i].b2)) continue; - } + } - olddir = GetDir( r, c, side ); - newdist = d + CalcDist( ndir[i], olddir, - (olddir == FROM_OTHERSIDE) ? GetDir( r, c, 1-side ) : 0 , side); + olddir = GetDir( r, c, side ); + newdist = d + CalcDist( ndir[i], olddir, + (olddir == FROM_OTHERSIDE) ? GetDir( r, + c, + 1 - side ) : 0, side ); - /* if (a) not visited yet, or (b) we have */ - /* found a better path, add it to queue */ - if (!GetDir( nr, nc, side )) - { - SetDir( nr, nc, side, ndir[i] ); - SetDist( nr, nc, side, newdist ); - if( SetQueue( nr, nc, side, newdist, - GetApxDist( nr, nc, row_target, col_target ), - row_target, col_target ) == 0 ) - { - return(ERR_MEMORY); - } - } + /* if (a) not visited yet, or (b) we have */ + /* found a better path, add it to queue */ + if( !GetDir( nr, nc, side ) ) + { + SetDir( nr, nc, side, ndir[i] ); + SetDist( nr, nc, side, newdist ); + if( SetQueue( nr, nc, side, newdist, + GetApxDist( nr, nc, row_target, col_target ), + row_target, col_target ) == 0 ) + { + return ERR_MEMORY; + } + } + else if( newdist < GetDist( nr, nc, side ) ) + { + SetDir( nr, nc, side, ndir[i] ); + SetDist( nr, nc, side, newdist ); + ReSetQueue( nr, nc, side, newdist, + GetApxDist( nr, nc, row_target, col_target ), + row_target, col_target ); + } + } - else if (newdist < GetDist( nr, nc, side )) - { - SetDir( nr, nc, side, ndir[i] ); - SetDist( nr, nc, side, newdist ); - ReSetQueue( nr, nc, side, newdist, - GetApxDist( nr, nc, row_target, col_target ), - row_target, col_target ); - } - } + /** etude de l'autre couche **/ + if( (two_sides) && !g_No_Via_Route ) + { + olddir = GetDir( r, c, side ); + if( olddir == FROM_OTHERSIDE ) + continue; /* useless move, so don't bother */ + if( curcell ) /* can't drill via if anything here */ + continue; + /* check for holes or traces on other side */ + if( ( newcell = GetCell( r, c, 1 - side ) ) != 0 ) + continue; + /* check for nearby holes or traces on both sides */ + for( skip = 0, i = 0; i < 8; i++ ) + { + nr = r + delta[i][0]; nc = c + delta[i][1]; - /** etude de l'autre couche **/ - if( (two_sides) && ! g_No_Via_Route ) - { - olddir = GetDir( r, c, side ); - if (olddir == FROM_OTHERSIDE) - continue; /* useless move, so don't bother */ - if (curcell) /* can't drill via if anything here */ - continue; - /* check for holes or traces on other side */ - if( (newcell = GetCell( r, c, 1-side )) != 0 ) - continue; - /* check for nearby holes or traces on both sides */ - for (skip = 0, i = 0; i < 8; i++) - { - nr = r + delta[i][0]; nc = c + delta[i][1]; + if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols ) + continue;/* off the edge !! */ - if (nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols) - continue; /* off the edge !! */ + if( GetCell( nr, nc, side ) /* & blocking2[i]*/ ) + { + skip = 1; /* can't drill via here */ + break; + } - if (GetCell( nr, nc, side )/* & blocking2[i]*/) - { - skip = 1; /* can't drill via here */ - break; - } + if( GetCell( nr, nc, 1 - side ) /* & blocking2[i]*/ ) + { + skip = 1; /* can't drill via here */ + break; + } + } - if (GetCell( nr, nc, 1-side )/* & blocking2[i]*/) - { - skip = 1; /* can't drill via here */ - break; - } - } + if( skip ) /* neighboring hole or trace? */ + continue; /* yes, can't drill via here */ - if (skip) /* neighboring hole or trace? */ - continue; /* yes, can't drill via here */ + newdist = d + CalcDist( FROM_OTHERSIDE, olddir, 0, side ); - newdist = d + CalcDist( FROM_OTHERSIDE, olddir, 0 , side); - - /* if (a) not visited yet, - or (b) we have found a better path, - add it to queue */ - if (!GetDir( r, c, 1-side )) - { - SetDir( r, c, 1-side, FROM_OTHERSIDE ); - SetDist( r, c, 1-side, newdist ); - if( SetQueue( r, c, 1-side, newdist, apx_dist, row_target, - col_target ) == 0 ) - { - return(ERR_MEMORY); - } - } - else if (newdist < GetDist( r, c, 1-side )) - { - SetDir( r, c, 1-side, FROM_OTHERSIDE ); - SetDist( r, c, 1-side, newdist ); - ReSetQueue( r, c, 1-side, newdist, apx_dist, row_target, col_target ); - } - } /* Fin de l'exploration de l'autre couche */ - } + /* if (a) not visited yet, + * or (b) we have found a better path, + * add it to queue */ + if( !GetDir( r, c, 1 - side ) ) + { + SetDir( r, c, 1 - side, FROM_OTHERSIDE ); + SetDist( r, c, 1 - side, newdist ); + if( SetQueue( r, c, 1 - side, newdist, apx_dist, row_target, + col_target ) == 0 ) + { + return ERR_MEMORY; + } + } + else if( newdist < GetDist( r, c, 1 - side ) ) + { + SetDir( r, c, 1 - side, FROM_OTHERSIDE ); + SetDist( r, c, 1 - side, newdist ); + ReSetQueue( r, c, 1 - side, newdist, apx_dist, row_target, col_target ); + } + } /* Fin de l'exploration de l'autre couche */ + } end_of_route: - Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_start,~CURRENT_PAD ,marge,WRITE_AND_CELL); - Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_end, ~CURRENT_PAD ,marge,WRITE_AND_CELL); + Place_1_Pad_Board( pcbframe->m_Pcb, pt_cur_ch->pad_start, ~CURRENT_PAD, marge, WRITE_AND_CELL ); + Place_1_Pad_Board( pcbframe->m_Pcb, pt_cur_ch->pad_end, ~CURRENT_PAD, marge, WRITE_AND_CELL ); - AFFICHE_ACTIVITE_ROUTE; - return(result); + AFFICHE_ACTIVITE_ROUTE; + return result; } + static long bit[8][9] = { /* OT=Otherside */ - /* N, NE, E, SE, S, SW, W, NW, OT */ -/* N */ { LINE_VERTICAL, BENT_StoNE, CORNER_SOUTHEAST, SHARP_StoSE, 0, - SHARP_StoSW, CORNER_SOUTHWEST, BENT_StoNW, (HOLE | HOLE_SOUTH) }, -/* NE */ { BENT_NtoSW, DIAG_NEtoSW, BENT_EtoSW, ANGLE_SEtoSW, SHARP_StoSW, - 0, SHARP_WtoSW, ANGLE_SWtoNW, (HOLE | HOLE_SOUTHWEST) }, -/* E */ { CORNER_NORTHWEST, BENT_WtoNE, LINE_HORIZONTAL, BENT_WtoSE, - CORNER_SOUTHWEST, SHARP_WtoSW, 0, SHARP_WtoNW, (HOLE | HOLE_WEST) }, -/* SE */ { SHARP_NtoNW, ANGLE_NWtoNE, BENT_EtoNW, DIAG_SEtoNW, BENT_StoNW, - ANGLE_SWtoNW, SHARP_WtoNW, 0, (HOLE | HOLE_NORTHWEST) }, -/* S */ { 0, SHARP_NtoNE, CORNER_NORTHEAST, BENT_NtoSE, LINE_VERTICAL, - BENT_NtoSW, CORNER_NORTHWEST, SHARP_NtoNW, (HOLE | HOLE_NORTH) }, -/* SW */ { SHARP_NtoNE, 0, SHARP_EtoNE, ANGLE_NEtoSE, BENT_StoNE, DIAG_NEtoSW, - BENT_WtoNE, ANGLE_NWtoNE, (HOLE | HOLE_NORTHEAST) }, -/* W */ { CORNER_NORTHEAST, SHARP_EtoNE, 0, SHARP_EtoSE, CORNER_SOUTHEAST, - BENT_EtoSW, LINE_HORIZONTAL, BENT_EtoNW, (HOLE | HOLE_EAST) }, -/* NW */ { BENT_NtoSE, ANGLE_NEtoSE, SHARP_EtoSE, 0, SHARP_StoSE, - ANGLE_SEtoSW, BENT_WtoSE, DIAG_SEtoNW, (HOLE | HOLE_SOUTHEAST) } - }; + /* N, NE, E, SE, S, SW, W, NW, OT */ +/* N */ { LINE_VERTICAL, BENT_StoNE, CORNER_SOUTHEAST, SHARP_StoSE, 0, + SHARP_StoSW, CORNER_SOUTHWEST, BENT_StoNW, (HOLE | HOLE_SOUTH) }, +/* NE */ { BENT_NtoSW, DIAG_NEtoSW, BENT_EtoSW, ANGLE_SEtoSW, SHARP_StoSW, + 0, SHARP_WtoSW, ANGLE_SWtoNW, (HOLE | HOLE_SOUTHWEST) }, +/* E */ { CORNER_NORTHWEST, BENT_WtoNE, LINE_HORIZONTAL, BENT_WtoSE, + CORNER_SOUTHWEST, SHARP_WtoSW, 0, SHARP_WtoNW, (HOLE | HOLE_WEST) }, +/* SE */ { SHARP_NtoNW, ANGLE_NWtoNE, BENT_EtoNW, DIAG_SEtoNW, BENT_StoNW, + ANGLE_SWtoNW, SHARP_WtoNW, 0, (HOLE | HOLE_NORTHWEST) }, +/* S */ { 0, SHARP_NtoNE, CORNER_NORTHEAST, BENT_NtoSE, LINE_VERTICAL, + BENT_NtoSW, CORNER_NORTHWEST, SHARP_NtoNW, (HOLE | HOLE_NORTH) }, +/* SW */ { SHARP_NtoNE, 0, SHARP_EtoNE, ANGLE_NEtoSE, BENT_StoNE, + DIAG_NEtoSW, + BENT_WtoNE, ANGLE_NWtoNE, (HOLE | HOLE_NORTHEAST) }, +/* W */ { CORNER_NORTHEAST, SHARP_EtoNE, 0, SHARP_EtoSE, CORNER_SOUTHEAST, + BENT_EtoSW, LINE_HORIZONTAL, BENT_EtoNW, (HOLE | HOLE_EAST) }, +/* NW */ { BENT_NtoSE, ANGLE_NEtoSE, SHARP_EtoSE, 0, SHARP_StoSE, + ANGLE_SEtoSW, BENT_WtoSE, DIAG_SEtoNW, (HOLE | HOLE_SOUTHEAST) } +}; /*****************************************************************/ /* int Retrace (COMMAND * Cmd, int row_source, int col_source */ @@ -667,332 +716,390 @@ static long bit[8][9] = { /* OT=Otherside */ /*****************************************************************/ /* work from target back to source, actually laying the traces - Parametres: - start on side target_side, aux coordonnees row_target, col_target. - arrivee sur side masque_layer_start, coord row_source, col_source - La recherche se fait en sens inverse du routage, - c.a.d du point d'arrivee (target) vers le point de depart (source) - du routeur. + * Parametres: + * start on side target_side, aux coordonnees row_target, col_target. + * arrivee sur side masque_layer_start, coord row_source, col_source + * La recherche se fait en sens inverse du routage, + * c.a.d du point d'arrivee (target) vers le point de depart (source) + * du routeur. + * + * target_side = cote (TOP / BOTTOM) de depart + * mask_layer_source = masque des couches d'arrivee + * + * Retourne: + * 0 si erreur + * > 0 si Ok + */ - target_side = cote (TOP / BOTTOM) de depart - mask_layer_source = masque des couches d'arrivee - - Retourne: - 0 si erreur - > 0 si Ok -*/ - -static int Retrace (WinEDA_PcbFrame * pcbframe, wxDC * DC, - int row_source, int col_source, - int row_target, int col_target, int target_side, - int current_net_code ) +static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, + int row_source, int col_source, + int row_target, int col_target, int target_side, + int current_net_code ) { -int r0, c0, s0; -int r1, c1, s1; /* row, col, side d'ou on vient */ -int r2, c2, s2; /* row, col, side ou on va */ -int x, y = -1; -long b; + int r0, c0, s0; + int r1, c1, s1; /* row, col, side d'ou on vient */ + int r2, c2, s2; /* row, col, side ou on va */ + int x, y = -1; + long b; - r1 = row_target; - c1 = col_target; /* start point is target ( end point is source )*/ - s1 = target_side; - r0 = c0 = s0 = ILLEGAL; + r1 = row_target; + c1 = col_target; /* start point is target ( end point is source )*/ + s1 = target_side; + r0 = c0 = s0 = ILLEGAL; - g_FirstTrackSegment = g_CurrentTrackSegment = NULL; - g_TrackSegmentCount = 0; + g_FirstTrackSegment = g_CurrentTrackSegment = NULL; + g_TrackSegmentCount = 0; - do { - /* find where we came from to get here */ - r2 = r1; c2 = c1; s2 = s1; - x = GetDir( r1, c1, s1 ); - switch ( x ) - { - case FROM_NORTH: r2++; break; - case FROM_EAST: c2++; break; - case FROM_SOUTH: r2--; break; - case FROM_WEST: c2--; break; - case FROM_NORTHEAST: r2++; c2++; break; - case FROM_SOUTHEAST: r2--; c2++; break; - case FROM_SOUTHWEST: r2--; c2--; break; - case FROM_NORTHWEST: r2++; c2--; break; - case FROM_OTHERSIDE: s2 = 1-s2; break; - default: - DisplayError(pcbframe, wxT("Retrace: internal error: no way back")); - return(0); - } + do { + /* find where we came from to get here */ + r2 = r1; c2 = c1; s2 = s1; + x = GetDir( r1, c1, s1 ); - if (r0 != ILLEGAL) y = GetDir( r0, c0, s0 ); + switch( x ) + { + case FROM_NORTH: + r2++; break; - /* see if target or hole */ - if( ( (r1 == row_target) && (c1 == col_target) ) - || (s1 != s0)) - { - int p_dir; - switch (x) - { - case FROM_NORTH: - p_dir = HOLE_NORTH; break; - case FROM_EAST: - p_dir = HOLE_EAST; break; - case FROM_SOUTH: - p_dir = HOLE_SOUTH; break; - case FROM_WEST: - p_dir = HOLE_WEST; break; - case FROM_NORTHEAST: - p_dir = HOLE_NORTHEAST; break; - case FROM_SOUTHEAST: - p_dir = HOLE_SOUTHEAST; break; - case FROM_SOUTHWEST: - p_dir = HOLE_SOUTHWEST; break; - case FROM_NORTHWEST: - p_dir = HOLE_NORTHWEST; break; + case FROM_EAST: + c2++; break; - case FROM_OTHERSIDE: - default: - DisplayError(pcbframe, wxT("Retrace: error 1")); - return(0); - } - OrCell_Trace(pcbframe->m_Pcb, r1, c1, s1, p_dir, current_net_code ); - } + case FROM_SOUTH: + r2--; break; - else { - if( (y == FROM_NORTH || y == FROM_NORTHEAST - || y == FROM_EAST || y == FROM_SOUTHEAST - || y == FROM_SOUTH || y == FROM_SOUTHWEST - || y == FROM_WEST || y == FROM_NORTHWEST) && - (x == FROM_NORTH || x == FROM_NORTHEAST - || x == FROM_EAST || x == FROM_SOUTHEAST - || x == FROM_SOUTH || x == FROM_SOUTHWEST - || x == FROM_WEST || x == FROM_NORTHWEST - || x == FROM_OTHERSIDE) && - ((b = bit[y-1][x-1]) != 0) ) - { - OrCell_Trace(pcbframe->m_Pcb, r1, c1, s1, b, current_net_code ); - if (b & HOLE) - OrCell_Trace(pcbframe->m_Pcb, r2, c2, s2, HOLE, current_net_code ); - } - else - { - DisplayError(pcbframe, wxT("Retrace: error 2")); - return(0); - } - } + case FROM_WEST: + c2--; break; - if( (r2 == row_source) && (c2 == col_source) ) - { /* see if source */ - int p_dir; - switch (x) - { - case FROM_NORTH: p_dir = HOLE_SOUTH; break; - case FROM_EAST: p_dir = HOLE_WEST; break; - case FROM_SOUTH: p_dir = HOLE_NORTH; break; - case FROM_WEST: p_dir = HOLE_EAST; break; - case FROM_NORTHEAST: p_dir = HOLE_SOUTHWEST; break; - case FROM_SOUTHEAST: p_dir = HOLE_NORTHWEST; break; - case FROM_SOUTHWEST: p_dir = HOLE_NORTHEAST; break; - case FROM_NORTHWEST: p_dir = HOLE_SOUTHEAST; break; + case FROM_NORTHEAST: + r2++; c2++; break; - case FROM_OTHERSIDE: - default: - DisplayError(pcbframe, wxT("Retrace: error 3")); - return(0); - } - OrCell_Trace(pcbframe->m_Pcb, r2, c2, s2, p_dir, current_net_code ); - } - /* move to next cell */ - r0 = r1; c0 = c1; s0 = s1; - r1 = r2; c1 = c2; s1 = s2; - } while( !( (r2 == row_source) && (c2 == col_source) ) ); + case FROM_SOUTHEAST: + r2--; c2++; break; - Place_Piste_en_Buffer(pcbframe, DC); - return(1); + case FROM_SOUTHWEST: + r2--; c2--; break; + + case FROM_NORTHWEST: + r2++; c2--; break; + + case FROM_OTHERSIDE: + s2 = 1 - s2; break; + + default: + DisplayError( pcbframe, wxT( "Retrace: internal error: no way back" ) ); + return 0; + } + + if( r0 != ILLEGAL ) + y = GetDir( r0, c0, s0 ); + + /* see if target or hole */ + if( ( (r1 == row_target) && (c1 == col_target) ) + || (s1 != s0) ) + { + int p_dir; + + switch( x ) + { + case FROM_NORTH: + p_dir = HOLE_NORTH; break; + + case FROM_EAST: + p_dir = HOLE_EAST; break; + + case FROM_SOUTH: + p_dir = HOLE_SOUTH; break; + + case FROM_WEST: + p_dir = HOLE_WEST; break; + + case FROM_NORTHEAST: + p_dir = HOLE_NORTHEAST; break; + + case FROM_SOUTHEAST: + p_dir = HOLE_SOUTHEAST; break; + + case FROM_SOUTHWEST: + p_dir = HOLE_SOUTHWEST; break; + + case FROM_NORTHWEST: + p_dir = HOLE_NORTHWEST; break; + + case FROM_OTHERSIDE: + default: + DisplayError( pcbframe, wxT( "Retrace: error 1" ) ); + return 0; + } + + OrCell_Trace( pcbframe->m_Pcb, r1, c1, s1, p_dir, current_net_code ); + } + else + { + if( (y == FROM_NORTH || y == FROM_NORTHEAST + || y == FROM_EAST || y == FROM_SOUTHEAST + || y == FROM_SOUTH || y == FROM_SOUTHWEST + || y == FROM_WEST || y == FROM_NORTHWEST) + && (x == FROM_NORTH || x == FROM_NORTHEAST + || x == FROM_EAST || x == FROM_SOUTHEAST + || x == FROM_SOUTH || x == FROM_SOUTHWEST + || x == FROM_WEST || x == FROM_NORTHWEST + || x == FROM_OTHERSIDE) + && ( (b = bit[y - 1][x - 1]) != 0 ) ) + { + OrCell_Trace( pcbframe->m_Pcb, r1, c1, s1, b, current_net_code ); + if( b & HOLE ) + OrCell_Trace( pcbframe->m_Pcb, r2, c2, s2, HOLE, current_net_code ); + } + else + { + DisplayError( pcbframe, wxT( "Retrace: error 2" ) ); + return 0; + } + } + + if( (r2 == row_source) && (c2 == col_source) ) + { /* see if source */ + int p_dir; + + switch( x ) + { + case FROM_NORTH: + p_dir = HOLE_SOUTH; break; + + case FROM_EAST: + p_dir = HOLE_WEST; break; + + case FROM_SOUTH: + p_dir = HOLE_NORTH; break; + + case FROM_WEST: + p_dir = HOLE_EAST; break; + + case FROM_NORTHEAST: + p_dir = HOLE_SOUTHWEST; break; + + case FROM_SOUTHEAST: + p_dir = HOLE_NORTHWEST; break; + + case FROM_SOUTHWEST: + p_dir = HOLE_NORTHEAST; break; + + case FROM_NORTHWEST: + p_dir = HOLE_SOUTHEAST; break; + + case FROM_OTHERSIDE: + default: + DisplayError( pcbframe, wxT( "Retrace: error 3" ) ); + return 0; + } + + OrCell_Trace( pcbframe->m_Pcb, r2, c2, s2, p_dir, current_net_code ); + } + /* move to next cell */ + r0 = r1; c0 = c1; s0 = s1; + r1 = r2; c1 = c2; s1 = s2; + } while( !( (r2 == row_source) && (c2 == col_source) ) ); + + Place_Piste_en_Buffer( pcbframe, DC ); + return 1; } /*****************************************************************************/ -static void OrCell_Trace(BOARD * pcb, int col,int row, - int side,int orient,int current_net_code) +static void OrCell_Trace( BOARD* pcb, int col, int row, + int side, int orient, int current_net_code ) /*****************************************************************************/ /* appelle la routine OrCell et place la piste reelle sur le pcb */ { -int dx0, dy0, dx1,dy1; -TRACK * NewTrack, *OldTrack; + int dx0, dy0, dx1, dy1; + TRACK* NewTrack, * OldTrack; - if(orient == HOLE) /* Placement d'une VIA */ - { - NewTrack = new SEGVIA(pcb); - g_TrackSegmentCount++; - NewTrack->Pback = g_CurrentTrackSegment; - if( g_CurrentTrackSegment) g_CurrentTrackSegment->Pnext = NewTrack; - else g_FirstTrackSegment = NewTrack; + if( orient == HOLE ) /* Placement d'une VIA */ + { + NewTrack = new SEGVIA( pcb ); - g_CurrentTrackSegment = NewTrack; + g_TrackSegmentCount++; + NewTrack->Pback = g_CurrentTrackSegment; + if( g_CurrentTrackSegment ) + g_CurrentTrackSegment->Pnext = NewTrack; + else + g_FirstTrackSegment = NewTrack; - g_CurrentTrackSegment->SetState(SEGM_AR, ON); - g_CurrentTrackSegment->m_Layer = 0x0F; - g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_End.x = - pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); - g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_End.y = - pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); - g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentViaSize; - g_CurrentTrackSegment->m_Shape = g_DesignSettings.m_CurrentViaType; - g_CurrentTrackSegment->m_NetCode = current_net_code; - } + g_CurrentTrackSegment = NewTrack; - else /* Placement d'un segment standard */ - { - NewTrack = new TRACK(pcb); - g_TrackSegmentCount++; - NewTrack->Pback = g_CurrentTrackSegment; - if( g_CurrentTrackSegment) g_CurrentTrackSegment->Pnext = NewTrack; - else g_FirstTrackSegment = NewTrack; + g_CurrentTrackSegment->SetState( SEGM_AR, ON ); + g_CurrentTrackSegment->SetLayer( 0x0F ); + g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_End.x = + pcb->m_BoundaryBox.m_Pos.x + + (g_GridRoutingSize * row); + g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_End.y = + pcb->m_BoundaryBox.m_Pos.y + + (g_GridRoutingSize * col); + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentViaSize; + g_CurrentTrackSegment->m_Shape = g_DesignSettings.m_CurrentViaType; + g_CurrentTrackSegment->m_NetCode = current_net_code; + } + else /* Placement d'un segment standard */ + { + NewTrack = new TRACK( pcb ); - g_CurrentTrackSegment = NewTrack; + g_TrackSegmentCount++; + NewTrack->Pback = g_CurrentTrackSegment; + if( g_CurrentTrackSegment ) + g_CurrentTrackSegment->Pnext = NewTrack; + else + g_FirstTrackSegment = NewTrack; - g_CurrentTrackSegment->m_Layer = Route_Layer_BOTTOM; - if (side == TOP) g_CurrentTrackSegment->m_Layer = Route_Layer_TOP; + g_CurrentTrackSegment = NewTrack; - g_CurrentTrackSegment->SetState(SEGM_AR,ON) ; - g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); - g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); - g_CurrentTrackSegment->m_NetCode = current_net_code; + g_CurrentTrackSegment->SetLayer( Route_Layer_BOTTOM ); + if( side == TOP ) + g_CurrentTrackSegment->SetLayer( Route_Layer_TOP ); - if ( g_CurrentTrackSegment->Pback == NULL ) /* Start Piste */ - { - g_CurrentTrackSegment->m_Start.x = segm_fX; - g_CurrentTrackSegment->m_Start.y = segm_fY; + g_CurrentTrackSegment->SetState( SEGM_AR, ON ); + g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); + g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); + g_CurrentTrackSegment->m_NetCode = current_net_code; - /* Replacement sur le centre du pad si hors grille */ - dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; - dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; - dx0 = pt_cur_ch->pad_end->m_Pos.x - g_CurrentTrackSegment->m_Start.x; - dy0 = pt_cur_ch->pad_end->m_Pos.y - g_CurrentTrackSegment->m_Start.y; + if( g_CurrentTrackSegment->Pback == NULL ) /* Start Piste */ + { + g_CurrentTrackSegment->m_Start.x = segm_fX; + g_CurrentTrackSegment->m_Start.y = segm_fY; - /* si aligne: modif du point origine */ - if(abs(dx0*dy1) == abs(dx1*dy0) ) /* Alignes ! */ - { - g_CurrentTrackSegment->m_Start.x = pt_cur_ch->pad_end->m_Pos.x; - g_CurrentTrackSegment->m_Start.y = pt_cur_ch->pad_end->m_Pos.y; - } + /* Replacement sur le centre du pad si hors grille */ + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + dx0 = pt_cur_ch->pad_end->m_Pos.x - g_CurrentTrackSegment->m_Start.x; + dy0 = pt_cur_ch->pad_end->m_Pos.y - g_CurrentTrackSegment->m_Start.y; - else /* Creation d'un segment suppl raccord */ - { - NewTrack = g_CurrentTrackSegment->Copy(); - g_TrackSegmentCount++; - NewTrack->Insert(pcb, g_CurrentTrackSegment); + /* si aligne: modif du point origine */ + if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) /* Alignes ! */ + { + g_CurrentTrackSegment->m_Start.x = pt_cur_ch->pad_end->m_Pos.x; + g_CurrentTrackSegment->m_Start.y = pt_cur_ch->pad_end->m_Pos.y; + } + else /* Creation d'un segment suppl raccord */ + { + NewTrack = g_CurrentTrackSegment->Copy(); + g_TrackSegmentCount++; + NewTrack->Insert( pcb, g_CurrentTrackSegment ); - g_CurrentTrackSegment->m_Start.x = pt_cur_ch->pad_end->m_Pos.x; - g_CurrentTrackSegment->m_Start.y = pt_cur_ch->pad_end->m_Pos.y; - NewTrack->m_Start.x = g_CurrentTrackSegment->m_End.x; - NewTrack->m_Start.y = g_CurrentTrackSegment->m_End.y; + g_CurrentTrackSegment->m_Start.x = pt_cur_ch->pad_end->m_Pos.x; + g_CurrentTrackSegment->m_Start.y = pt_cur_ch->pad_end->m_Pos.y; + NewTrack->m_Start.x = g_CurrentTrackSegment->m_End.x; + NewTrack->m_Start.y = g_CurrentTrackSegment->m_End.y; - g_CurrentTrackSegment = NewTrack; - } - } - else - { - if ( g_CurrentTrackSegment->Pback ) - { - 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_Width = g_DesignSettings.m_CurrentTrackWidth; + g_CurrentTrackSegment = NewTrack; + } + } + else + { + if( g_CurrentTrackSegment->Pback ) + { + 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_Width = g_DesignSettings.m_CurrentTrackWidth; - if ( (g_CurrentTrackSegment->m_Start.x != g_CurrentTrackSegment->m_End.x) || - (g_CurrentTrackSegment->m_Start.y != g_CurrentTrackSegment->m_End.y) ) - { - /* Reduction des segments alignes a 1 seul */ - OldTrack = (TRACK*) g_CurrentTrackSegment->Pback; - if ( OldTrack && (OldTrack->m_StructType != TYPEVIA) ) - { - dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; - dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; - dx0 = OldTrack->m_End.x - OldTrack->m_Start.x; - dy0 = OldTrack->m_End.y - OldTrack->m_Start.y; - if( abs(dx0*dy1) == abs(dx1*dy0) )/* le dernier segment est en ligne*/ - { - OldTrack->m_End.x = g_CurrentTrackSegment->m_End.x; - OldTrack->m_End.y = g_CurrentTrackSegment->m_End.y; - delete g_CurrentTrackSegment; - g_CurrentTrackSegment = OldTrack; - g_CurrentTrackSegment->Pnext = NULL; - g_TrackSegmentCount--; - } - } - } - } + if( (g_CurrentTrackSegment->m_Start.x != g_CurrentTrackSegment->m_End.x) + || (g_CurrentTrackSegment->m_Start.y != g_CurrentTrackSegment->m_End.y) ) + { + /* Reduction des segments alignes a 1 seul */ + OldTrack = (TRACK*) g_CurrentTrackSegment->Pback; + if( OldTrack && (OldTrack->m_StructType != TYPEVIA) ) + { + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + dx0 = OldTrack->m_End.x - OldTrack->m_Start.x; + dy0 = OldTrack->m_End.y - OldTrack->m_Start.y; + if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )/* le dernier segment est en ligne*/ + { + OldTrack->m_End.x = g_CurrentTrackSegment->m_End.x; + OldTrack->m_End.y = g_CurrentTrackSegment->m_End.y; + delete g_CurrentTrackSegment; + g_CurrentTrackSegment = OldTrack; + g_CurrentTrackSegment->Pnext = NULL; + g_TrackSegmentCount--; + } + } + } + } } - /*******************************************/ - /* static void Place_Piste_en_Buffer(void) */ - /*******************************************/ + +/*******************************************/ +/* static void Place_Piste_en_Buffer(void) */ +/*******************************************/ /* Insere la nouvelle piste creee dans la liste standard des pistes. - Modifie les points de debut et fin de piste pour qu'ils soient relies - au centre des pads corresponadants, meme hors grille -*/ -static void Place_Piste_en_Buffer(WinEDA_PcbFrame * pcbframe, wxDC * DC) + * Modifie les points de debut et fin de piste pour qu'ils soient relies + * au centre des pads corresponadants, meme hors grille + */ +static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) { -TRACK* pt_track; -int dx0, dy0, dx1,dy1; -int marge, via_marge; -WinEDA_DrawPanel * panel = pcbframe->DrawPanel; + TRACK* pt_track; + int dx0, dy0, dx1, dy1; + int marge, via_marge; + WinEDA_DrawPanel* panel = pcbframe->DrawPanel; - marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth /2); - via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize /2); + marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth / 2); + via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize / 2); - /* tst point d'arrivee : doit etre sur pad start */ + /* tst point d'arrivee : doit etre sur pad start */ - dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; - dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; - /* Replacement sur le centre du pad si hors grille */ + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + /* Replacement sur le centre du pad si hors grille */ - dx0 = pt_cur_ch->pad_start->m_Pos.x - g_CurrentTrackSegment->m_Start.x; - dy0 = pt_cur_ch->pad_start->m_Pos.y - g_CurrentTrackSegment->m_Start.y; + dx0 = pt_cur_ch->pad_start->m_Pos.x - g_CurrentTrackSegment->m_Start.x; + dy0 = pt_cur_ch->pad_start->m_Pos.y - g_CurrentTrackSegment->m_Start.y; - /* si aligne: modif du point origine */ - if(abs(dx0*dy1) == abs(dx1*dy0) ) /* Alignes ! */ - { - g_CurrentTrackSegment->m_End.x = pt_cur_ch->pad_start->m_Pos.x; - g_CurrentTrackSegment->m_End.y = pt_cur_ch->pad_start->m_Pos.y; - } - else /* Creation d'un segment suppl raccord */ - { - TRACK * NewTrack = g_CurrentTrackSegment->Copy(); - NewTrack->Insert(pcbframe->m_Pcb, g_CurrentTrackSegment); + /* si aligne: modif du point origine */ + if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) /* Alignes ! */ + { + g_CurrentTrackSegment->m_End.x = pt_cur_ch->pad_start->m_Pos.x; + g_CurrentTrackSegment->m_End.y = pt_cur_ch->pad_start->m_Pos.y; + } + else /* Creation d'un segment suppl raccord */ + { + TRACK* NewTrack = g_CurrentTrackSegment->Copy(); + NewTrack->Insert( pcbframe->m_Pcb, g_CurrentTrackSegment ); - NewTrack->m_End.x = pt_cur_ch->pad_start->m_Pos.x; - NewTrack->m_End.y = pt_cur_ch->pad_start->m_Pos.y; - NewTrack->m_Start.x = g_CurrentTrackSegment->m_End.x; - NewTrack->m_Start.y = g_CurrentTrackSegment->m_End.y; + NewTrack->m_End.x = pt_cur_ch->pad_start->m_Pos.x; + NewTrack->m_End.y = pt_cur_ch->pad_start->m_Pos.y; + NewTrack->m_Start.x = g_CurrentTrackSegment->m_End.x; + NewTrack->m_Start.y = g_CurrentTrackSegment->m_End.y; - g_CurrentTrackSegment = NewTrack; g_TrackSegmentCount++; - } + g_CurrentTrackSegment = NewTrack; g_TrackSegmentCount++; + } - g_FirstTrackSegment->start = Locate_Pad_Connecte(pcbframe->m_Pcb, g_FirstTrackSegment,START); - if(g_FirstTrackSegment->start) g_FirstTrackSegment->SetState(BEGIN_ONPAD,ON); + g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->m_Pcb, g_FirstTrackSegment, START ); + if( g_FirstTrackSegment->start ) + g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON ); - g_CurrentTrackSegment->end = Locate_Pad_Connecte(pcbframe->m_Pcb, g_CurrentTrackSegment,END); - if(g_CurrentTrackSegment->end) g_CurrentTrackSegment->SetState(END_ONPAD,ON); + g_CurrentTrackSegment->end = Locate_Pad_Connecte( pcbframe->m_Pcb, g_CurrentTrackSegment, END ); + if( g_CurrentTrackSegment->end ) + g_CurrentTrackSegment->SetState( END_ONPAD, ON ); - /* recherche de la zone de rangement et insertion de la nouvelle piste */ - pt_track = g_FirstTrackSegment->GetBestInsertPoint(pcbframe->m_Pcb); - g_FirstTrackSegment->Insert(pcbframe->m_Pcb, pt_track); + /* recherche de la zone de rangement et insertion de la nouvelle piste */ + pt_track = g_FirstTrackSegment->GetBestInsertPoint( pcbframe->m_Pcb ); + g_FirstTrackSegment->Insert( pcbframe->m_Pcb, pt_track ); - Trace_Une_Piste(panel, DC, g_FirstTrackSegment,g_TrackSegmentCount,GR_OR) ; + Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); - pcbframe->test_1_net_connexion(DC, g_FirstTrackSegment->m_NetCode ); + pcbframe->test_1_net_connexion( DC, g_FirstTrackSegment->m_NetCode ); - /* Trace de la forme exacte de la piste en BOARD */ - for ( pt_track = g_FirstTrackSegment; ; pt_track = (TRACK*)pt_track->Pnext) - { - TraceSegmentPcb(pcbframe->m_Pcb,pt_track,HOLE,marge,WRITE_CELL); - TraceSegmentPcb(pcbframe->m_Pcb,pt_track,VIA_IMPOSSIBLE,via_marge,WRITE_OR_CELL); - if(pt_track == g_CurrentTrackSegment ) break; - } + /* Trace de la forme exacte de la piste en BOARD */ + for( pt_track = g_FirstTrackSegment; ; pt_track = (TRACK*) pt_track->Pnext ) + { + TraceSegmentPcb( pcbframe->m_Pcb, pt_track, HOLE, marge, WRITE_CELL ); + TraceSegmentPcb( pcbframe->m_Pcb, pt_track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); + if( pt_track == g_CurrentTrackSegment ) + break; + } - ActiveScreen->SetModify(); + ActiveScreen->SetModify(); } - diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index fdf66eecec..9431ed529b 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -1,8 +1,8 @@ - /*******************************/ - /* Dialog frame to swap layers */ - /*******************************/ +/*******************************/ +/* Dialog frame to swap layers */ +/*******************************/ - /* Fichier swap_layers */ +/* Fichier swap_layers */ #include "fctsys.h" #include "common.h" @@ -14,11 +14,11 @@ static int New_Layer[32]; enum swap_layer_id { - ID_SWAP_LAYER_EXECUTE = 1800, - ID_SWAP_LAYER_CANCEL, - ID_SWAP_LAYER_BUTTON_SELECT, - ID_SWAP_LAYER_DESELECT, - ID_SWAP_LAYER_SELECT + ID_SWAP_LAYER_EXECUTE = 1800, + ID_SWAP_LAYER_CANCEL, + ID_SWAP_LAYER_BUTTON_SELECT, + ID_SWAP_LAYER_DESELECT, + ID_SWAP_LAYER_SELECT }; @@ -26,205 +26,220 @@ enum swap_layer_id { /* classe pour la frame de selection de layers */ /***********************************************/ -class WinEDA_SwapLayerFrame: public wxDialog +class WinEDA_SwapLayerFrame : public wxDialog { private: - WinEDA_BasePcbFrame *m_Parent; - wxRadioBox * m_LayerList; + WinEDA_BasePcbFrame* m_Parent; + wxRadioBox* m_LayerList; public: - // Constructor and destructor - WinEDA_SwapLayerFrame(WinEDA_BasePcbFrame *parent); - ~WinEDA_SwapLayerFrame(void) {}; + // Constructor and destructor + WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame * parent ); + ~WinEDA_SwapLayerFrame( void ) { }; private: - void Sel_Layer(wxCommandEvent& event); - void Cancel(wxCommandEvent& event); - void Execute(wxCommandEvent& event); - DECLARE_EVENT_TABLE() + void Sel_Layer( wxCommandEvent& event ); + void Cancel( wxCommandEvent& event ); + void Execute( wxCommandEvent& event ); + DECLARE_EVENT_TABLE() }; /* Table des evenements pour WinEDA_SwapLayerFrame */ -BEGIN_EVENT_TABLE(WinEDA_SwapLayerFrame, wxDialog) - EVT_BUTTON(ID_SWAP_LAYER_EXECUTE, WinEDA_SwapLayerFrame::Execute) - EVT_BUTTON(ID_SWAP_LAYER_CANCEL, WinEDA_SwapLayerFrame::Cancel) - EVT_BUTTON(ID_SWAP_LAYER_DESELECT, WinEDA_SwapLayerFrame::Sel_Layer) - EVT_BUTTON(ID_SWAP_LAYER_BUTTON_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) - EVT_RADIOBOX(ID_SWAP_LAYER_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) +BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog ) +EVT_BUTTON( ID_SWAP_LAYER_EXECUTE, WinEDA_SwapLayerFrame::Execute ) +EVT_BUTTON( ID_SWAP_LAYER_CANCEL, WinEDA_SwapLayerFrame::Cancel ) +EVT_BUTTON( ID_SWAP_LAYER_DESELECT, WinEDA_SwapLayerFrame::Sel_Layer ) +EVT_BUTTON( ID_SWAP_LAYER_BUTTON_SELECT, WinEDA_SwapLayerFrame::Sel_Layer ) +EVT_RADIOBOX( ID_SWAP_LAYER_SELECT, WinEDA_SwapLayerFrame::Sel_Layer ) END_EVENT_TABLE() /*************************************************************************/ -WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame(WinEDA_BasePcbFrame *parent): - wxDialog(parent, -1, _("Swap Layers:"),wxPoint(-1,-1), - wxSize(470, 450), DIALOG_STYLE ) +WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) : + wxDialog( parent, -1, _( "Swap Layers:" ), wxPoint( -1, -1 ), + wxSize( 470, 450 ), DIALOG_STYLE ) /*************************************************************************/ { #define START_Y 15 -wxButton * Button; -int ii; -wxPoint pos; -wxString g_Layer_Name_Pair[32]; -wxSize winsize; - - m_Parent = parent; - SetFont(*g_DialogFont); + wxButton* Button; + int ii; + wxPoint pos; + wxString g_Layer_Name_Pair[32]; + wxSize winsize; - for ( ii = 0; ii < NB_LAYERS; ii++ ) - { - g_Layer_Name_Pair[ii] = ReturnPcbLayerName(ii) + wxT(" -> ") + _("No Change"); - } - pos.x = 5; pos.y = START_Y; - m_LayerList = new wxRadioBox(this, ID_SWAP_LAYER_SELECT, _("Layers"), - pos, wxSize(-1,-1), 29, g_Layer_Name_Pair, 16, wxRA_SPECIFY_ROWS); - - winsize.y = m_LayerList->GetRect().GetBottom(); + m_Parent = parent; + SetFont( *g_DialogFont ); - pos.x = m_LayerList->GetRect().GetRight() + 12; - Button = new wxButton(this,ID_SWAP_LAYER_CANCEL, - _("Cancel"), pos); - Button->SetForegroundColour(*wxRED); - winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + for( ii = 0; ii < NB_LAYERS; ii++ ) + { + g_Layer_Name_Pair[ii] = ReturnPcbLayerName( ii ) + wxT( " -> " ) + _( "No Change" ); + } - pos.y += Button->GetSize().y + 5; - Button = new wxButton(this,ID_SWAP_LAYER_EXECUTE, - _("OK"), pos); - Button->SetForegroundColour(*wxBLUE); - winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + pos.x = 5; pos.y = START_Y; + m_LayerList = new wxRadioBox( this, ID_SWAP_LAYER_SELECT, _( "Layers" ), + pos, + wxSize( -1, -1 ), 29, g_Layer_Name_Pair, 16, wxRA_SPECIFY_ROWS ); - pos.y += Button->GetSize().y + 15; - Button = new wxButton(this,ID_SWAP_LAYER_DESELECT, - _("Deselect"), pos); - Button->SetForegroundColour(wxColour(0,100,0)); - winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + winsize.y = m_LayerList->GetRect().GetBottom(); - pos.y += Button->GetSize().y + 5; - Button = new wxButton(this,ID_SWAP_LAYER_BUTTON_SELECT, - _("Select"), pos); - Button->SetForegroundColour(wxColour(0,100,100)); - winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); - - winsize.x += 10; winsize.y += 10; - SetClientSize(winsize); + pos.x = m_LayerList->GetRect().GetRight() + 12; + Button = new wxButton( this, ID_SWAP_LAYER_CANCEL, + _( "Cancel" ), pos ); + Button->SetForegroundColour( *wxRED ); + winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton( this, ID_SWAP_LAYER_EXECUTE, + _( "OK" ), pos ); + + Button->SetForegroundColour( *wxBLUE ); + winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); + + pos.y += Button->GetSize().y + 15; + Button = new wxButton( this, ID_SWAP_LAYER_DESELECT, + _( "Deselect" ), pos ); + + Button->SetForegroundColour( wxColour( 0, 100, 0 ) ); + winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton( this, ID_SWAP_LAYER_BUTTON_SELECT, + _( "Select" ), pos ); + + Button->SetForegroundColour( wxColour( 0, 100, 100 ) ); + winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); + + winsize.x += 10; winsize.y += 10; + SetClientSize( winsize ); } /***************************************************************/ -void WinEDA_SwapLayerFrame::Sel_Layer(wxCommandEvent& event) +void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event ) /***************************************************************/ { - int ii, jj; + int ii, jj; - ii = m_LayerList->GetSelection(); + ii = m_LayerList->GetSelection(); - switch ( event.GetId()) - { - case ID_SWAP_LAYER_DESELECT: - if ( New_Layer[ii] != -1 ) - { - New_Layer[ii] = -1; - m_LayerList->SetString(ii, ReturnPcbLayerName(ii) + - + wxT(" -> ") + _("No Change") ); - } - break; + switch( event.GetId() ) + { + case ID_SWAP_LAYER_DESELECT: + if( New_Layer[ii] != -1 ) + { + New_Layer[ii] = -1; + m_LayerList->SetString( ii, ReturnPcbLayerName( ii ) + + + wxT( " -> " ) + _( "No Change" ) ); + } + break; - case ID_SWAP_LAYER_BUTTON_SELECT: - case ID_SWAP_LAYER_SELECT: - jj = m_Parent->SelectLayer(ii, -1, -1); - if ( (jj < 0) || (jj >= 29) ) return; + case ID_SWAP_LAYER_BUTTON_SELECT: + case ID_SWAP_LAYER_SELECT: + jj = m_Parent->SelectLayer( ii, -1, -1 ); + if( (jj < 0) || (jj >= 29) ) + return; - if ( ii != jj ) - { - New_Layer[ii] = jj; - m_LayerList->SetString(ii, - ReturnPcbLayerName(ii) + wxT(" -> ") + ReturnPcbLayerName(jj) ); - } - break; - } + if( ii != jj ) + { + New_Layer[ii] = jj; + m_LayerList->SetString( ii, + ReturnPcbLayerName( ii ) + wxT( " -> " ) + + ReturnPcbLayerName( jj ) ); + } + break; + } } -/*********************************************************/ -void WinEDA_SwapLayerFrame::Cancel(wxCommandEvent& event) -/*********************************************************/ -{ - EndModal(-1); -} /*********************************************************/ -void WinEDA_SwapLayerFrame::Execute(wxCommandEvent& event) +void WinEDA_SwapLayerFrame::Cancel( wxCommandEvent& event ) /*********************************************************/ { - EndModal(1); + EndModal( -1 ); +} + + +/*********************************************************/ +void WinEDA_SwapLayerFrame::Execute( wxCommandEvent& event ) +/*********************************************************/ +{ + EndModal( 1 ); } /********************************************************/ -void WinEDA_PcbFrame::Swap_Layers(wxCommandEvent & event) +void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) /********************************************************/ /* Swap layers */ { -int ii, jj ; -TRACK * pt_segm ; -DRAWSEGMENT * pt_drawsegm; -EDA_BaseStruct * PtStruct; + int ii, jj; + TRACK* pt_segm; + DRAWSEGMENT* pt_drawsegm; + EDA_BaseStruct* PtStruct; - /* Init default values */ - for ( ii = 0 ; ii < 32 ; ii++ ) New_Layer[ii] = -1 ; + /* Init default values */ + for( ii = 0; ii < 32; ii++ ) + New_Layer[ii] = -1; -WinEDA_SwapLayerFrame * frame = new WinEDA_SwapLayerFrame(this); - ii = frame->ShowModal(); frame->Destroy(); + WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( this ); - if ( ii != 1 ) return; + ii = frame->ShowModal(); frame->Destroy(); - /* Modifications des pistes */ - pt_segm = (TRACK*) m_Pcb->m_Track; - for ( ; pt_segm != NULL;pt_segm = (TRACK*)pt_segm->Pnext ) - { - m_CurrentScreen->SetModify(); - if( pt_segm->m_StructType == TYPEVIA ) - { - SEGVIA * Via = (SEGVIA *) pt_segm; - if ( Via->Shape() == VIA_NORMALE ) continue; - int top_layer, bottom_layer; - Via->ReturnLayerPair(&top_layer, &bottom_layer); - if( New_Layer[bottom_layer] >= 0) - bottom_layer = New_Layer[bottom_layer]; - if( New_Layer[top_layer] >= 0) - top_layer = New_Layer[top_layer]; - Via->SetLayerPair(top_layer, bottom_layer); - } - else - { - jj = pt_segm->m_Layer; - if( New_Layer[jj] >= 0) pt_segm->m_Layer = New_Layer[jj]; - } - } + if( ii != 1 ) + return; - /* Modifications des zones */ - pt_segm = (TRACK*) m_Pcb->m_Zone; - for ( ; pt_segm != NULL;pt_segm = (TRACK*)pt_segm->Pnext ) - { - m_CurrentScreen->SetModify(); - jj = pt_segm->m_Layer; - if( New_Layer[jj] >= 0) pt_segm->m_Layer = New_Layer[jj]; - } + /* Modifications des pistes */ + pt_segm = (TRACK*) m_Pcb->m_Track; + for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + m_CurrentScreen->SetModify(); + if( pt_segm->m_StructType == TYPEVIA ) + { + SEGVIA* Via = (SEGVIA*) pt_segm; + if( Via->Shape() == VIA_NORMALE ) + continue; + int top_layer, bottom_layer; + Via->ReturnLayerPair( &top_layer, &bottom_layer ); + if( New_Layer[bottom_layer] >= 0 ) + bottom_layer = New_Layer[bottom_layer]; + if( New_Layer[top_layer] >= 0 ) + top_layer = New_Layer[top_layer]; + Via->SetLayerPair( top_layer, bottom_layer ); + } + else + { + jj = pt_segm->GetLayer(); + if( New_Layer[jj] >= 0 ) + pt_segm->SetLayer( New_Layer[jj] ); + } + } - /* Modifications des autres segments */ - PtStruct = m_Pcb->m_Drawings; - for ( ; PtStruct != NULL ; PtStruct = PtStruct->Pnext ) - { - if( PtStruct->m_StructType == TYPEDRAWSEGMENT ) - { - m_CurrentScreen->SetModify(); - pt_drawsegm = (DRAWSEGMENT *) PtStruct; - jj = pt_drawsegm->m_Layer; - if( New_Layer[jj] >= 0) pt_drawsegm->m_Layer = New_Layer[jj]; - } - } - DrawPanel->Refresh(TRUE); + /* Modifications des zones */ + pt_segm = (TRACK*) m_Pcb->m_Zone; + for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + m_CurrentScreen->SetModify(); + jj = pt_segm->GetLayer(); + if( New_Layer[jj] >= 0 ) + pt_segm->SetLayer( New_Layer[jj] ); + } + + /* Modifications des autres segments */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType == TYPEDRAWSEGMENT ) + { + m_CurrentScreen->SetModify(); + pt_drawsegm = (DRAWSEGMENT*) PtStruct; + jj = pt_drawsegm->GetLayer(); + if( New_Layer[jj] >= 0 ) + pt_drawsegm->SetLayer( New_Layer[jj] ); + } + } + + DrawPanel->Refresh( TRUE ); } - - diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 9f76aaced2..ab4e332236 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -123,13 +123,13 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) if( !DisplayOpt.Show_Modules_Cmp ) { - if( Module->m_Layer == CMP_N ) + if( Module->GetLayer() == CMP_N ) display = FALSE; MaskLay &= ~CMP_LAYER; } if( !DisplayOpt.Show_Modules_Cu ) { - if( Module->m_Layer == CUIVRE_N ) + if( Module->GetLayer() == CUIVRE_N ) display = FALSE; MaskLay &= ~CUIVRE_LAYER; } diff --git a/pcbnew/track.cpp b/pcbnew/track.cpp index 6472bb1424..c0fd838c71 100644 --- a/pcbnew/track.cpp +++ b/pcbnew/track.cpp @@ -1,7 +1,7 @@ - /*********************************************/ - /* Edition des pistes: Routines d'effacement */ - /* Effacement de segment, piste, net et zone */ - /*********************************************/ +/*********************************************/ +/* Edition des pistes: Routines d'effacement */ +/* Effacement de segment, piste, net et zone */ +/*********************************************/ #include "fctsys.h" @@ -10,392 +10,413 @@ #include "protos.h" -class TSTSEGM /* memorisation des segments marques */ +class TSTSEGM /* memorisation des segments marques */ { public: - TSTSEGM *Pnext, *Pback; - TRACK * RefTrack; + TSTSEGM* Pnext, * Pback; + TRACK* RefTrack; public: - TSTSEGM(TRACK * Father) - { - Pback = Pnext = NULL; - RefTrack = Father; - } + TSTSEGM( TRACK * Father ) { + Pback = Pnext = NULL; + RefTrack = Father; + } }; /* Routines externes : */ -void Montre_Position_New_Piste(int flag); /* defini dans editrack.cc */ +void Montre_Position_New_Piste( int flag );/* defini dans editrack.cc */ /* Routines Locales */ -static void Marque_Chaine_segments(BOARD * Pcb, wxPoint ref_pos, int masklayer); +static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masklayer ); /* Variables locales */ -TSTSEGM * ListSegm = NULL; +TSTSEGM* ListSegm = NULL; /****************************************************************************/ -TRACK * Marque_Une_Piste(WinEDA_BasePcbFrame * frame, wxDC * DC, - TRACK* pt_segm, int * nb_segm, int flagcolor) +TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, + TRACK* pt_segm, int* nb_segm, int flagcolor ) /****************************************************************************/ + /* Routine de Marquage de 1 piste, a partir du segment pointe par pt_segm. - le segment pointe est marque puis les segments connectes - jusqu'a un pad ou un point de jonction de plus de 2 segments - le marquage est la mise a 1 du bit BUSY - Les segments sont ensuite reclasses pour etre contigus en liste chainee - Retourne: - adresse du 1er segment de la chaine creee - nombre de segments -*/ + * le segment pointe est marque puis les segments connectes + * jusqu'a un pad ou un point de jonction de plus de 2 segments + * le marquage est la mise a 1 du bit BUSY + * Les segments sont ensuite reclasses pour etre contigus en liste chainee + * Retourne: + * adresse du 1er segment de la chaine creee + * nombre de segments + */ { -int NbSegmBusy, masque_layer; -TRACK *Track, *FirstTrack, *NextTrack; -TSTSEGM * Segm, * NextSegm; + int NbSegmBusy, masque_layer; + TRACK* Track, * FirstTrack, * NextTrack; + TSTSEGM* Segm, * NextSegm; - *nb_segm = 0; - if (pt_segm == NULL ) return(NULL) ; + *nb_segm = 0; + if( pt_segm == NULL ) + return NULL; - /* Marquage du segment pointe */ - if(flagcolor) pt_segm->Draw(frame->DrawPanel, DC, flagcolor); + /* Marquage du segment pointe */ + if( flagcolor ) + pt_segm->Draw( frame->DrawPanel, DC, flagcolor ); - pt_segm->SetState(BUSY,ON); - masque_layer = pt_segm->ReturnMaskLayer(); - ListSegm = new TSTSEGM(pt_segm); + pt_segm->SetState( BUSY, ON ); + masque_layer = pt_segm->ReturnMaskLayer(); + ListSegm = new TSTSEGM( pt_segm ); - /* Traitement du segment pointe : si c'est un segment, le cas est simple. - Si c'est une via, on doit examiner le nombre de segments connectes. - Si <=2, on doit detecter une piste, si > 2 seule la via est marquee - */ - if( pt_segm->m_StructType == TYPEVIA) - { - TRACK * Segm1, *Segm2 = NULL, *Segm3 =NULL; - Segm1 = Fast_Locate_Piste(frame->m_Pcb->m_Track,NULL, - pt_segm->m_Start, masque_layer); - if(Segm1) - { - Segm2 = Fast_Locate_Piste((TRACK*)Segm1->Pnext,NULL, - pt_segm->m_Start, masque_layer); - } - if( Segm2 ) - { - Segm3 = Fast_Locate_Piste((TRACK*)Segm2->Pnext,NULL, - pt_segm->m_Start, masque_layer); - } - if(Segm3) - { - *nb_segm = 1; return (pt_segm); - } - if(Segm1) - { - masque_layer = Segm1->ReturnMaskLayer(); - Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_Start, masque_layer); - } - if(Segm2) - { - masque_layer = Segm2->ReturnMaskLayer(); - Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_Start, masque_layer); - } - } - else /* Marquage de la chaine connectee aux extremites du segment */ - { - Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_Start, masque_layer); - Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_End, masque_layer); - } + /* Traitement du segment pointe : si c'est un segment, le cas est simple. + * Si c'est une via, on doit examiner le nombre de segments connectes. + * Si <=2, on doit detecter une piste, si > 2 seule la via est marquee + */ + if( pt_segm->m_StructType == TYPEVIA ) + { + TRACK* Segm1, * Segm2 = NULL, * Segm3 = NULL; + Segm1 = Fast_Locate_Piste( frame->m_Pcb->m_Track, NULL, + pt_segm->m_Start, masque_layer ); + if( Segm1 ) + { + Segm2 = Fast_Locate_Piste( (TRACK*) Segm1->Pnext, NULL, + pt_segm->m_Start, masque_layer ); + } + if( Segm2 ) + { + Segm3 = Fast_Locate_Piste( (TRACK*) Segm2->Pnext, NULL, + pt_segm->m_Start, masque_layer ); + } + if( Segm3 ) + { + *nb_segm = 1; return pt_segm; + } + if( Segm1 ) + { + masque_layer = Segm1->ReturnMaskLayer(); + Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_Start, masque_layer ); + } + if( Segm2 ) + { + masque_layer = Segm2->ReturnMaskLayer(); + Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_Start, masque_layer ); + } + } + else /* Marquage de la chaine connectee aux extremites du segment */ + { + Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_Start, masque_layer ); + Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_End, masque_layer ); + } - /* marquage des vias (vias non connectees ou inutiles */ - for( Segm = ListSegm; Segm != NULL; Segm = Segm->Pnext ) - { - int layer; - if( Segm->RefTrack->m_StructType != TYPEVIA ) continue; - if( Segm->RefTrack == pt_segm ) continue; - Segm->RefTrack->SetState(BUSY,ON); - masque_layer = Segm->RefTrack->ReturnMaskLayer(); - Track = Fast_Locate_Piste(frame->m_Pcb->m_Track,NULL, - Segm->RefTrack->m_Start, - masque_layer); - if( Track == NULL ) continue; - /* Test des connexions: si via utile: suppression marquage */ - layer = Track->m_Layer; - while ( (Track = Fast_Locate_Piste((TRACK*)Track->Pnext,NULL, - Segm->RefTrack->m_Start, - masque_layer)) != NULL ) - { - if( layer != Track->m_Layer ) - { - Segm->RefTrack->SetState(BUSY,OFF); - break; - } - } - } + /* marquage des vias (vias non connectees ou inutiles */ + for( Segm = ListSegm; Segm != NULL; Segm = Segm->Pnext ) + { + int layer; + if( Segm->RefTrack->m_StructType != TYPEVIA ) + continue; + if( Segm->RefTrack == pt_segm ) + continue; + Segm->RefTrack->SetState( BUSY, ON ); + masque_layer = Segm->RefTrack->ReturnMaskLayer(); + Track = Fast_Locate_Piste( frame->m_Pcb->m_Track, NULL, + Segm->RefTrack->m_Start, + masque_layer ); + if( Track == NULL ) + continue; + /* Test des connexions: si via utile: suppression marquage */ + layer = Track->GetLayer(); + while( ( Track = Fast_Locate_Piste( (TRACK*) Track->Pnext, NULL, + Segm->RefTrack->m_Start, + masque_layer ) ) != NULL ) + { + if( layer != Track->GetLayer() ) + { + Segm->RefTrack->SetState( BUSY, OFF ); + break; + } + } + } - /* liberation memoire */ - for( Segm = ListSegm; Segm != NULL; Segm = NextSegm ) - { - NextSegm = Segm->Pnext; delete Segm; - } - ListSegm = NULL; + /* liberation memoire */ + for( Segm = ListSegm; Segm != NULL; Segm = NextSegm ) + { + NextSegm = Segm->Pnext; delete Segm; + } - /* Reclassement des segments marques en une chaine */ - FirstTrack = frame->m_Pcb->m_Track; NbSegmBusy = 0; - for ( ; FirstTrack != NULL; FirstTrack = (TRACK*)FirstTrack->Pnext ) - { /* recherche du debut de la liste des segments marques a BUSY */ - if ( FirstTrack->GetState(BUSY) ) - { - NbSegmBusy = 1; break; - } - } + ListSegm = NULL; - /* Reclassement de la chaine debutant a FirstTrack et finissant - au dernier segment marque. FirstTrack n'est pas modifie */ - Track = (TRACK*)FirstTrack->Pnext; - for ( ; Track != NULL; Track = NextTrack) - { - NextTrack = (TRACK*) Track->Pnext; - if ( Track->GetState(BUSY) ) - { - NbSegmBusy++; - Track->UnLink(); - Track->Insert(frame->m_Pcb, FirstTrack); - } - } + /* Reclassement des segments marques en une chaine */ + FirstTrack = frame->m_Pcb->m_Track; NbSegmBusy = 0; + for( ; FirstTrack != NULL; FirstTrack = (TRACK*) FirstTrack->Pnext ) + { /* recherche du debut de la liste des segments marques a BUSY */ + if( FirstTrack->GetState( BUSY ) ) + { + NbSegmBusy = 1; break; + } + } - *nb_segm = NbSegmBusy; + /* Reclassement de la chaine debutant a FirstTrack et finissant + * au dernier segment marque. FirstTrack n'est pas modifie */ + Track = (TRACK*) FirstTrack->Pnext; + for( ; Track != NULL; Track = NextTrack ) + { + NextTrack = (TRACK*) Track->Pnext; + if( Track->GetState( BUSY ) ) + { + NbSegmBusy++; + Track->UnLink(); + Track->Insert( frame->m_Pcb, FirstTrack ); + } + } - if(flagcolor) Trace_Une_Piste(frame->DrawPanel, DC, FirstTrack,NbSegmBusy,flagcolor); + *nb_segm = NbSegmBusy; - return(FirstTrack); + if( flagcolor ) + Trace_Une_Piste( frame->DrawPanel, DC, FirstTrack, NbSegmBusy, flagcolor ); + + return FirstTrack; } /********************************************************************************/ -static void Marque_Chaine_segments(BOARD * Pcb, wxPoint ref_pos, int masque_layer) +static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_layer ) /********************************************************************************/ + /* - routine utilisee par Supprime_1_Piste() - Positionne le bit BUSY dans la chaine de segments commencant - au point ox, oy sur la couche layer - - Les vias sont mises en liste des segments traites mais ne sont pas - marquees. -*/ + * routine utilisee par Supprime_1_Piste() + * Positionne le bit BUSY dans la chaine de segments commencant + * au point ox, oy sur la couche layer + * + * Les vias sont mises en liste des segments traites mais ne sont pas + * marquees. + */ { -TRACK *pt_segm, // Pointe le segment courant analyse - * pt_via, // pointe la via reperee, eventuellement a detruire - * MarqSegm; // pointe le segment a detruire (= NULL ou pt_segm -int NbSegm; -TSTSEGM * Segm; + TRACK* pt_segm, // Pointe le segment courant analyse + * pt_via, // pointe la via reperee, eventuellement a detruire + * MarqSegm; // pointe le segment a detruire (= NULL ou pt_segm + int NbSegm; + TSTSEGM* Segm; - if(Pcb->m_Track == NULL) return; + if( Pcb->m_Track == NULL ) + return; - /* Marquage de la chaine */ - for( ; ; ) - { - if( Fast_Locate_Pad_Connecte(Pcb, ref_pos,masque_layer) != NULL ) return; + /* Marquage de la chaine */ + for( ; ; ) + { + if( Fast_Locate_Pad_Connecte( Pcb, ref_pos, masque_layer ) != NULL ) + return; - /* Localisation d'une via (car elle connecte plusieurs segments) */ - pt_via = Fast_Locate_Via(Pcb->m_Track, NULL, ref_pos, masque_layer); - if(pt_via) - { - if(pt_via->GetState(EDIT)) return; - masque_layer = pt_via->ReturnMaskLayer(); - Segm = new TSTSEGM(pt_via); - Segm->Pnext = ListSegm; - ListSegm->Pback = Segm; - ListSegm = Segm; - } + /* Localisation d'une via (car elle connecte plusieurs segments) */ + pt_via = Fast_Locate_Via( Pcb->m_Track, NULL, ref_pos, masque_layer ); + if( pt_via ) + { + if( pt_via->GetState( EDIT ) ) + return; + masque_layer = pt_via->ReturnMaskLayer(); + Segm = new TSTSEGM( pt_via ); - /* Recherche des segments connectes au point ref_pos - si 1 segment: peut etre marque - si > 1 segment: - le segment ne peut etre marque - */ - pt_segm =Pcb->m_Track; MarqSegm = NULL; - NbSegm = 0; - while( (pt_segm = Fast_Locate_Piste(pt_segm, NULL, - ref_pos,masque_layer) ) != NULL ) - { - if(pt_segm->GetState(EDIT)) /* Fin de piste */ - return; + Segm->Pnext = ListSegm; + ListSegm->Pback = Segm; + ListSegm = Segm; + } - if(pt_segm->GetState(BUSY) ) - { - pt_segm = (TRACK*)pt_segm->Pnext; - continue; - } + /* Recherche des segments connectes au point ref_pos + * si 1 segment: peut etre marque + * si > 1 segment: + * le segment ne peut etre marque + */ + pt_segm = Pcb->m_Track; MarqSegm = NULL; + NbSegm = 0; + while( ( pt_segm = Fast_Locate_Piste( pt_segm, NULL, + ref_pos, masque_layer ) ) != NULL ) + { + if( pt_segm->GetState( EDIT ) ) /* Fin de piste */ + return; - if( pt_segm == pt_via) /* deja traite */ - { - pt_segm = (TRACK*)pt_segm->Pnext; - continue; - } + if( pt_segm->GetState( BUSY ) ) + { + pt_segm = (TRACK*) pt_segm->Pnext; + continue; + } - NbSegm++; - if( NbSegm == 1 ) /* 1ere detection de segment de piste */ - { - MarqSegm = pt_segm; - pt_segm = (TRACK*)pt_segm->Pnext; - } - else /* 2eme detection de segment -> fin de piste */ - { - return; - } - } + if( pt_segm == pt_via ) /* deja traite */ + { + pt_segm = (TRACK*) pt_segm->Pnext; + continue; + } - if( MarqSegm ) - { - /* preparation de la nouvelle recherche */ - masque_layer = MarqSegm->ReturnMaskLayer(); - if( ref_pos == MarqSegm->m_Start ) - { - ref_pos = MarqSegm->m_End; - } - else { - ref_pos = MarqSegm->m_Start; - } + NbSegm++; + if( NbSegm == 1 ) /* 1ere detection de segment de piste */ + { + MarqSegm = pt_segm; + pt_segm = (TRACK*) pt_segm->Pnext; + } + else /* 2eme detection de segment -> fin de piste */ + { + return; + } + } - pt_segm = Pcb->m_Track; /* reinit recherche des segments */ + if( MarqSegm ) + { + /* preparation de la nouvelle recherche */ + masque_layer = MarqSegm->ReturnMaskLayer(); + if( ref_pos == MarqSegm->m_Start ) + { + ref_pos = MarqSegm->m_End; + } + else + { + ref_pos = MarqSegm->m_Start; + } - /* Marquage et mise en liste du segment */ - Segm = new TSTSEGM(MarqSegm); - Segm->Pnext = ListSegm; - ListSegm->Pback = Segm; - ListSegm = Segm; - MarqSegm->SetState(BUSY,ON); - } - else return; - } + pt_segm = Pcb->m_Track; /* reinit recherche des segments */ + + /* Marquage et mise en liste du segment */ + Segm = new TSTSEGM( MarqSegm ); + + Segm->Pnext = ListSegm; + ListSegm->Pback = Segm; + ListSegm = Segm; + MarqSegm->SetState( BUSY, ON ); + } + else + return; + } } - /********************************************************/ -int ReturnEndsTrack(TRACK* RefTrack, int NbSegm, - TRACK ** StartTrack, TRACK ** EndTrack) +/********************************************************/ +int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, + TRACK** StartTrack, TRACK** EndTrack ) /**********************************************************/ + /* Calcule les coordonnes des extremites d'une piste - retourne 1 si OK, 0 si piste bouclee - Retourne dans *StartTrack en *EndTrack les segments de debut et fin - Les coord StartTrack->m_Start.x, m_Start.y contiennent le debut de la piste - Les coord EndTrack->m_End.x, m_End.y contiennent le debut de la piste - Les segments sont supposes chaines de facon consecutive -*/ + * retourne 1 si OK, 0 si piste bouclee + * Retourne dans *StartTrack en *EndTrack les segments de debut et fin + * Les coord StartTrack->m_Start.x, m_Start.y contiennent le debut de la piste + * Les coord EndTrack->m_End.x, m_End.y contiennent le debut de la piste + * Les segments sont supposes chaines de facon consecutive + */ { -TRACK * Track, *via, *segm, * TrackListEnd; -int NbEnds, masque_layer, ii, ok = 0; + TRACK* Track, * via, * segm, * TrackListEnd; + int NbEnds, masque_layer, ii, ok = 0; - if( NbSegm <= 1 ) - { - *StartTrack = *EndTrack = RefTrack; - return(1); /* cas trivial */ - } + if( NbSegm <= 1 ) + { + *StartTrack = *EndTrack = RefTrack; + return 1; /* cas trivial */ + } - /* calcul de la limite d'analyse */ - *StartTrack = *EndTrack = NULL; - TrackListEnd = Track = RefTrack; ii = 0; - for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*)Track->Pnext) - { - TrackListEnd = Track; - Track->m_Param = 0; - } + /* calcul de la limite d'analyse */ + *StartTrack = *EndTrack = NULL; + TrackListEnd = Track = RefTrack; ii = 0; + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Pnext ) + { + TrackListEnd = Track; + Track->m_Param = 0; + } - /* Calcul des extremites */ - NbEnds = 0; Track = RefTrack; ii = 0; - for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*)Track->Pnext) - { - if(Track->m_StructType == TYPEVIA) continue; + /* Calcul des extremites */ + NbEnds = 0; Track = RefTrack; ii = 0; + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Pnext ) + { + if( Track->m_StructType == TYPEVIA ) + continue; - masque_layer = Track->ReturnMaskLayer(); - via = Fast_Locate_Via(RefTrack, TrackListEnd, - Track->m_Start, masque_layer); - if( via ) - { - masque_layer |= via->ReturnMaskLayer(); - via->SetState(BUSY,ON); - } + masque_layer = Track->ReturnMaskLayer(); + via = Fast_Locate_Via( RefTrack, TrackListEnd, + Track->m_Start, masque_layer ); + if( via ) + { + masque_layer |= via->ReturnMaskLayer(); + via->SetState( BUSY, ON ); + } - Track->SetState(BUSY,ON); - segm = Fast_Locate_Piste(RefTrack, TrackListEnd, - Track->m_Start, masque_layer); - Track->SetState(BUSY,OFF); - if(via) via->SetState(BUSY,OFF); + Track->SetState( BUSY, ON ); + segm = Fast_Locate_Piste( RefTrack, TrackListEnd, + Track->m_Start, masque_layer ); + Track->SetState( BUSY, OFF ); + if( via ) + via->SetState( BUSY, OFF ); - if( segm == NULL ) - { - switch(NbEnds) - { - case 0: - *StartTrack = Track; NbEnds++; - break; + if( segm == NULL ) + { + switch( NbEnds ) + { + case 0: + *StartTrack = Track; NbEnds++; + break; - case 1: - int BeginPad, EndPad; - *EndTrack = Track; - /* permutation de ox,oy avec fx,fy */ - BeginPad = Track->GetState(BEGIN_ONPAD); - EndPad = Track->GetState(END_ONPAD); - Track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); - if( BeginPad ) - Track->SetState(END_ONPAD, ON); - if( EndPad ) - Track->SetState(BEGIN_ONPAD, ON); - EXCHG(Track->m_Start,Track->m_End); - EXCHG(Track->start,Track->end); - ok = 1; return(ok); - } - } + case 1: + int BeginPad, EndPad; + *EndTrack = Track; + /* permutation de ox,oy avec fx,fy */ + BeginPad = Track->GetState( BEGIN_ONPAD ); + EndPad = Track->GetState( END_ONPAD ); + Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + if( BeginPad ) + Track->SetState( END_ONPAD, ON ); + if( EndPad ) + Track->SetState( BEGIN_ONPAD, ON ); + EXCHG( Track->m_Start, Track->m_End ); + EXCHG( Track->start, Track->end ); + ok = 1; return ok; + } + } - masque_layer = Track->ReturnMaskLayer(); - via = Fast_Locate_Via(RefTrack, TrackListEnd, - Track->m_End, masque_layer); - if( via ) - { - masque_layer |= via->ReturnMaskLayer(); - via->SetState(BUSY,ON); - } + masque_layer = Track->ReturnMaskLayer(); + via = Fast_Locate_Via( RefTrack, TrackListEnd, + Track->m_End, masque_layer ); + if( via ) + { + masque_layer |= via->ReturnMaskLayer(); + via->SetState( BUSY, ON ); + } - Track->SetState(BUSY,ON); - segm = Fast_Locate_Piste(RefTrack, TrackListEnd, - Track->m_End, masque_layer); - Track->SetState(BUSY,OFF); - if (via) via->SetState(BUSY,OFF); - if ( segm == NULL ) - { - switch(NbEnds) - { - case 0: - int BeginPad, EndPad; - *StartTrack = Track; NbEnds++; - /* permutation de ox,oy avec fx,fy */ - BeginPad = Track->GetState(BEGIN_ONPAD); - EndPad = Track->GetState(END_ONPAD); - Track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); - if( BeginPad ) - Track->SetState(END_ONPAD, ON); - if( EndPad ) - Track->SetState(BEGIN_ONPAD, ON); - EXCHG(Track->m_Start,Track->m_End); - EXCHG(Track->start,Track->end); - break; + Track->SetState( BUSY, ON ); + segm = Fast_Locate_Piste( RefTrack, TrackListEnd, + Track->m_End, masque_layer ); + Track->SetState( BUSY, OFF ); + if( via ) + via->SetState( BUSY, OFF ); + if( segm == NULL ) + { + switch( NbEnds ) + { + case 0: + int BeginPad, EndPad; + *StartTrack = Track; NbEnds++; + /* permutation de ox,oy avec fx,fy */ + BeginPad = Track->GetState( BEGIN_ONPAD ); + EndPad = Track->GetState( END_ONPAD ); + Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + if( BeginPad ) + Track->SetState( END_ONPAD, ON ); + if( EndPad ) + Track->SetState( BEGIN_ONPAD, ON ); + EXCHG( Track->m_Start, Track->m_End ); + EXCHG( Track->start, Track->end ); + break; - case 1: - *EndTrack = Track; - ok = 1; return(ok); - } - } - } + case 1: + *EndTrack = Track; + ok = 1; return ok; + } + } + } - return(ok); + return ok; } /***************************************************************************/ -void ListSetState(EDA_BaseStruct * Start, int NbItem,int State, int onoff) +void ListSetState( EDA_BaseStruct* Start, int NbItem, int State, int onoff ) /***************************************************************************/ + /* Met a jour le membre .state d'une chaine de structures -*/ + */ { - if(Start == NULL ) return; - for( ; (Start != NULL) && (NbItem > 0); NbItem-- , Start = Start->Pnext ) - { - Start->SetState(State,onoff); - } + if( Start == NULL ) + return; + for( ; (Start != NULL) && (NbItem > 0); NbItem--, Start = Start->Pnext ) + { + Start->SetState( State, onoff ); + } } diff --git a/pcbnew/trpiste.cpp b/pcbnew/trpiste.cpp index 489f387dbb..59a9d2e501 100644 --- a/pcbnew/trpiste.cpp +++ b/pcbnew/trpiste.cpp @@ -14,148 +14,158 @@ /* variables locales : */ /*********************************************************************************/ -void Trace_Pistes(WinEDA_DrawPanel * panel, BOARD * Pcb, wxDC * DC, int drawmode) +void Trace_Pistes( WinEDA_DrawPanel* panel, BOARD* Pcb, wxDC* DC, int drawmode ) /********************************************************************************/ + /* Draw all tracks and zones. -*/ + */ { -TRACK * track; + TRACK* track; - track = Pcb->m_Track; - for ( ; track != NULL ; track = track->Next() ) - { - track->Draw(panel, DC, drawmode); - } + track = Pcb->m_Track; + for( ; track != NULL; track = track->Next() ) + { + track->Draw( panel, DC, drawmode ); + } - track = Pcb->m_Zone; - for ( ; track != NULL ; track = track->Next() ) - { - track->Draw(panel, DC, drawmode); - } + track = Pcb->m_Zone; + for( ; track != NULL; track = track->Next() ) + { + track->Draw( panel, DC, drawmode ); + } } +/************************************************************************/ +void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track, + int nbsegment, int draw_mode ) +/************************************************************************/ -/************************************************************************/ -void Trace_Une_Piste(WinEDA_DrawPanel * panel, wxDC * DC, TRACK * Track, - int nbsegment, int draw_mode) -/************************************************************************/ /* routine de trace de n segments consecutifs en memoire. - Utile pour monter une piste en cours de trace car les segments de cette - piste sont alors contigus en memoire -Parametres : - pt_start_piste = adresse de depart de la liste des segments - nbsegment = nombre de segments a tracer - draw_mode = mode ( GR_XOR, GR_OR..) -ATTENTION: - le point de depart d'une piste suivante DOIT exister: peut etre - donc mis a 0 avant appel a la routine si la piste a tracer est la derniere -*/ + * Utile pour monter une piste en cours de trace car les segments de cette + * piste sont alors contigus en memoire + * Parametres : + * pt_start_piste = adresse de depart de la liste des segments + * nbsegment = nombre de segments a tracer + * draw_mode = mode ( GR_XOR, GR_OR..) + * ATTENTION: + * le point de depart d'une piste suivante DOIT exister: peut etre + * donc mis a 0 avant appel a la routine si la piste a tracer est la derniere + */ { - if ( Track == NULL ) return; - for ( ;nbsegment > 0; nbsegment--, Track = (TRACK*)Track->Pnext) - { - if ( Track == NULL ) break; - Track->Draw(panel, DC, draw_mode) ; - } + if( Track == NULL ) + return; + for( ; nbsegment > 0; nbsegment--, Track = (TRACK*) Track->Pnext ) + { + if( Track == NULL ) + break; + Track->Draw( panel, DC, draw_mode ); + } } + /*************************************************************/ -void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC, - DRAWSEGMENT * PtDrawSegment, int draw_mode) +void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC, + DRAWSEGMENT* PtDrawSegment, int draw_mode ) /*************************************************************/ + /* Affichage d'un segment type drawing PCB: - draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND) - Les contours sont de differents type: - segment - cercle - arc -*/ + * draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND) + * Les contours sont de differents type: + * segment + * cercle + * arc + */ { -int ux0, uy0, dx, dy; -int l_piste; -int color, mode; -int zoom; -int rayon; + int ux0, uy0, dx, dy; + int l_piste; + int color, mode; + int zoom; + int rayon; - color = g_DesignSettings.m_LayerColor[PtDrawSegment->m_Layer]; - if(color & ITEM_NOT_SHOW ) return ; + color = g_DesignSettings.m_LayerColor[PtDrawSegment->GetLayer()]; + if( color & ITEM_NOT_SHOW ) + return; - if ( panel ) zoom = panel->GetZoom(); - else zoom = ActiveScreen->GetZoom(); + if( panel ) + zoom = panel->GetZoom(); + else + zoom = ActiveScreen->GetZoom(); - GRSetDrawMode(DC, draw_mode); - l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */ + GRSetDrawMode( DC, draw_mode ); + l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */ - /* coord de depart */ - ux0 = PtDrawSegment->m_Start.x; - uy0 = PtDrawSegment->m_Start.y; - /* coord d'arrivee */ - dx = PtDrawSegment->m_End.x; - dy = PtDrawSegment->m_End.y; + /* coord de depart */ + ux0 = PtDrawSegment->m_Start.x; + uy0 = PtDrawSegment->m_Start.y; + /* coord d'arrivee */ + dx = PtDrawSegment->m_End.x; + dy = PtDrawSegment->m_End.y; - mode = DisplayOpt.DisplayDrawItems; - if(PtDrawSegment->m_Flags & FORCE_SKETCH) mode = SKETCH; - if ( l_piste < (L_MIN_DESSIN * zoom) ) mode = FILAIRE; + mode = DisplayOpt.DisplayDrawItems; + if( PtDrawSegment->m_Flags & FORCE_SKETCH ) + mode = SKETCH; + if( l_piste < (L_MIN_DESSIN * zoom) ) + mode = FILAIRE; - switch (PtDrawSegment->m_Shape) - { - case S_CIRCLE: - rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); - if ( mode == FILAIRE) - { - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, color) ; - } - else if( mode == SKETCH) - { - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon-l_piste, color); - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon+l_piste, color); - } - else - { - GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width,color); - } - break; + switch( PtDrawSegment->m_Shape ) + { + case S_CIRCLE: + rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + if( mode == FILAIRE ) + { + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, color ); + } + else if( mode == SKETCH ) + { + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, color ); + } + else + { + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width, color ); + } + break; - case S_ARC: - { - int StAngle, EndAngle; - rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); - StAngle = (int) ArcTangente(dy-uy0, dx-ux0); - EndAngle = StAngle + PtDrawSegment->m_Angle; - if ( StAngle > EndAngle) EXCHG (StAngle, EndAngle); - if ( mode == FILAIRE) - GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color); - else if( mode == SKETCH) - { - GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon - l_piste, color); - GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon + l_piste, color); - } - else - { - GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon, PtDrawSegment->m_Width,color); - } - } - break; + case S_ARC: + { + int StAngle, EndAngle; + rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + StAngle = (int) ArcTangente( dy - uy0, dx - ux0 ); + EndAngle = StAngle + PtDrawSegment->m_Angle; + if( StAngle > EndAngle ) + EXCHG( StAngle, EndAngle ); + if( mode == FILAIRE ) + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color ); + else if( mode == SKETCH ) + { + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon - l_piste, color ); + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon + l_piste, color ); + } + else + { + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon, PtDrawSegment->m_Width, color ); + } + } + break; - default: - if( mode == FILAIRE) - GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color) ; - else if( mode == SKETCH) - { - GRCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, - PtDrawSegment->m_Width, color) ; - } - else - { - GRFillCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, - PtDrawSegment->m_Width, color) ; - } - break; - } + default: + if( mode == FILAIRE ) + GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color ); + else if( mode == SKETCH ) + { + GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color ); + } + else + { + GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color ); + } + break; + } } - diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 75eec67719..e9ba72d6a6 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -1,8 +1,8 @@ - /******************************/ - /* PCBNEW: echange de modules */ - /******************************/ +/******************************/ +/* PCBNEW: echange de modules */ +/******************************/ - /* Fichier xchmod.cpp */ +/* Fichier xchmod.cpp */ #include "fctsys.h" #include "gr_basic.h" @@ -14,612 +14,655 @@ /* variables locales */ -enum id_ExchangeModule -{ - ID_EXEC_EXCHANGE_MODULE = 1900, - ID_EXEC_EXCHANGE_ID_MODULES, - ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, - ID_EXEC_EXCHANGE_ALL_MODULES, - ID_CLOSE_EXCHANGE_MODULE, - ID_BROWSE_LIB_MODULES +enum id_ExchangeModule { + ID_EXEC_EXCHANGE_MODULE = 1900, + ID_EXEC_EXCHANGE_ID_MODULES, + ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, + ID_EXEC_EXCHANGE_ALL_MODULES, + ID_CLOSE_EXCHANGE_MODULE, + ID_BROWSE_LIB_MODULES }; - /************************************/ - /* class WinEDA_ExchangeModuleFrame */ - /************************************/ +/************************************/ +/* class WinEDA_ExchangeModuleFrame */ +/************************************/ -class WinEDA_ExchangeModuleFrame: public wxDialog +class WinEDA_ExchangeModuleFrame : public wxDialog { private: - WinEDA_BasePcbFrame * m_Parent; - wxDC * m_DC; - MODULE * m_CurrentModule; - WinEDA_EnterText * m_OldModule; - WinEDA_EnterText * m_OldValue; - WinEDA_EnterText * m_NewModule; - wxTextCtrl * m_WinMsg; + WinEDA_BasePcbFrame* m_Parent; + wxDC* m_DC; + MODULE* m_CurrentModule; + WinEDA_EnterText* m_OldModule; + WinEDA_EnterText* m_OldValue; + WinEDA_EnterText* m_NewModule; + wxTextCtrl* m_WinMsg; public: - // Constructor and destructor - WinEDA_ExchangeModuleFrame(WinEDA_BasePcbFrame *parent, - MODULE * Module, wxDC * DC, const wxPoint & pos); - ~WinEDA_ExchangeModuleFrame(void) - { - } + + // Constructor and destructor + WinEDA_ExchangeModuleFrame( WinEDA_BasePcbFrame * parent, + MODULE * Module, wxDC * DC, const wxPoint &pos ); + ~WinEDA_ExchangeModuleFrame( void ) + { + } private: - void OnQuit(wxCommandEvent& event); - void Change_Module(wxCommandEvent& event); - void Change_ModuleId(wxCommandEvent& event); - void Change_ModuleAll(wxCommandEvent& event); - int Maj_ListeCmp( - const wxString & reference, - const wxString & old_name, - const wxString & new_name, bool ShowError); - MODULE * Change_1_Module(MODULE * Module, const wxString& new_module, bool ShowError); - void Sel_NewMod_By_Liste(wxCommandEvent& event); + void OnQuit( wxCommandEvent& event ); + void Change_Module( wxCommandEvent& event ); + void Change_ModuleId( wxCommandEvent& event ); + void Change_ModuleAll( wxCommandEvent& event ); + int Maj_ListeCmp( + const wxString& reference, + const wxString& old_name, + const wxString& new_name, bool ShowError ); + MODULE* Change_1_Module( MODULE* Module, const wxString& new_module, bool ShowError ); + void Sel_NewMod_By_Liste( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_ExchangeModuleFrame, wxDialog) - EVT_BUTTON(ID_EXEC_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::Change_Module) - EVT_BUTTON(ID_EXEC_EXCHANGE_ID_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleId) - EVT_BUTTON(ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, WinEDA_ExchangeModuleFrame::Change_ModuleId) - EVT_BUTTON(ID_EXEC_EXCHANGE_ALL_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleAll) - EVT_BUTTON(ID_CLOSE_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::OnQuit) - EVT_BUTTON(ID_BROWSE_LIB_MODULES, WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste) +BEGIN_EVENT_TABLE( WinEDA_ExchangeModuleFrame, wxDialog ) +EVT_BUTTON( ID_EXEC_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::Change_Module ) +EVT_BUTTON( ID_EXEC_EXCHANGE_ID_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleId ) +EVT_BUTTON( ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, WinEDA_ExchangeModuleFrame::Change_ModuleId ) +EVT_BUTTON( ID_EXEC_EXCHANGE_ALL_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleAll ) +EVT_BUTTON( ID_CLOSE_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::OnQuit ) +EVT_BUTTON( ID_BROWSE_LIB_MODULES, WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste ) END_EVENT_TABLE() -WinEDA_ExchangeModuleFrame::WinEDA_ExchangeModuleFrame(WinEDA_BasePcbFrame *parent, - MODULE * Module,wxDC * DC, - const wxPoint & framepos): - wxDialog(parent, -1, _("Exchange Modules"), framepos, wxSize(360, 460), - DIALOG_STYLE) +WinEDA_ExchangeModuleFrame::WinEDA_ExchangeModuleFrame( WinEDA_BasePcbFrame* parent, + MODULE* Module, wxDC* DC, + const wxPoint& framepos ) : + wxDialog( parent, -1, _( "Exchange Modules" ), framepos, wxSize( 360, 460 ), + DIALOG_STYLE ) { -wxButton * Button; + wxButton* Button; - m_Parent = parent; - SetFont(*g_DialogFont); - m_DC = DC; - Centre(); + m_Parent = parent; + SetFont( *g_DialogFont ); + m_DC = DC; + Centre(); - m_CurrentModule = Module; + m_CurrentModule = Module; - wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(MainBoxSizer); - wxBoxSizer * UpperBoxSizer = new wxBoxSizer(wxHORIZONTAL); - MainBoxSizer->Add(UpperBoxSizer, 0, wxGROW|wxALL, 5); - wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); - UpperBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); - UpperBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxVERTICAL ); - /* Creation des boutons de commande */ - Button = new wxButton(this, ID_EXEC_EXCHANGE_MODULE, - _("Change module")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + SetSizer( MainBoxSizer ); + wxBoxSizer* UpperBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - Button = new wxButton(this, ID_EXEC_EXCHANGE_ID_MODULES, - _("Change same modules")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 ); + wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); - Button = new wxButton(this, ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, - _("Ch. same module+value")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); - Button = new wxButton(this, ID_EXEC_EXCHANGE_ALL_MODULES, - _("Change all")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + UpperBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); + UpperBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - Button = new wxButton(this, ID_BROWSE_LIB_MODULES, - _("Browse Libs modules")); - Button->SetForegroundColour(wxColour(0,100,0) ); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + /* Creation des boutons de commande */ + Button = new wxButton( this, ID_EXEC_EXCHANGE_MODULE, + _( "Change module" ) ); - Button = new wxButton(this, ID_CLOSE_EXCHANGE_MODULE, - _("Close")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - m_OldModule = new WinEDA_EnterText(this, _("Current Module"), - m_CurrentModule ? m_CurrentModule->m_LibRef.GetData() :wxEmptyString, - LeftBoxSizer, wxSize( 150,-1) ); - m_OldModule->Enable(FALSE); + Button = new wxButton( this, ID_EXEC_EXCHANGE_ID_MODULES, + _( "Change same modules" ) ); - m_OldValue = new WinEDA_EnterText(this, _("Current Value"), - m_CurrentModule ? m_CurrentModule->m_Value->m_Text.GetData() :wxEmptyString, - LeftBoxSizer, wxSize( 150,-1) ); - m_OldValue->Enable(FALSE); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); - m_NewModule = new WinEDA_EnterText(this, _("New Module"), - m_OldModule->GetValue(), LeftBoxSizer, wxSize( 150,-1) ); + Button = new wxButton( this, ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, + _( "Ch. same module+value" ) ); - m_WinMsg = new wxTextCtrl(this, -1,wxEmptyString, wxDefaultPosition, wxSize(340, 230), - wxTE_READONLY|wxTE_MULTILINE); - MainBoxSizer->Add(m_WinMsg, 0, wxGROW|wxALL, 5); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + Button = new wxButton( this, ID_EXEC_EXCHANGE_ALL_MODULES, + _( "Change all" ) ); + + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); + + Button = new wxButton( this, ID_BROWSE_LIB_MODULES, + _( "Browse Libs modules" ) ); + + Button->SetForegroundColour( wxColour( 0, 100, 0 ) ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); + + Button = new wxButton( this, ID_CLOSE_EXCHANGE_MODULE, + _( "Close" ) ); + + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + + m_OldModule = new WinEDA_EnterText( this, _( "Current Module" ), + m_CurrentModule ? + m_CurrentModule->m_LibRef.GetData () : wxEmptyString, + LeftBoxSizer, wxSize( 150, -1 ) ); + + m_OldModule->Enable( FALSE ); + + m_OldValue = new WinEDA_EnterText( this, _( "Current Value" ), + m_CurrentModule ? + m_CurrentModule->m_Value->m_Text.GetData () : wxEmptyString, + LeftBoxSizer, wxSize( 150, -1 ) ); + + m_OldValue->Enable( FALSE ); + + m_NewModule = new WinEDA_EnterText( this, _( "New Module" ), + m_OldModule->GetValue(), LeftBoxSizer, wxSize( 150, -1 ) ); + + m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxSize( 340, 230 ), + wxTE_READONLY | wxTE_MULTILINE ); + + MainBoxSizer->Add( m_WinMsg, 0, wxGROW | wxALL, 5 ); + + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); } /*********************************************************************/ -void WinEDA_BasePcbFrame::InstallExchangeModuleFrame( MODULE * Module, - wxDC * DC, const wxPoint & pos) +void WinEDA_BasePcbFrame::InstallExchangeModuleFrame( MODULE* Module, + wxDC* DC, const wxPoint& pos ) /*********************************************************************/ { - WinEDA_ExchangeModuleFrame * frame = new WinEDA_ExchangeModuleFrame(this, - Module, DC, pos); - frame->ShowModal(); frame->Destroy(); + WinEDA_ExchangeModuleFrame* frame = new WinEDA_ExchangeModuleFrame( this, + Module, DC, pos ); + + frame->ShowModal(); frame->Destroy(); } /**********************************************************************/ -void WinEDA_ExchangeModuleFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_ExchangeModuleFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - Close(true); // true is to force the frame to close + Close( true ); // true is to force the frame to close } - /************************************************************************/ int WinEDA_ExchangeModuleFrame::Maj_ListeCmp( - const wxString & reference, - const wxString & old_name, - const wxString & new_name, bool ShowError) + const wxString& reference, + const wxString& old_name, + const wxString& new_name, bool ShowError ) /************************************************************************/ + /* - Met a jour le fichier name.CMP (s'il existe) apres un echange de module - (par la commande changeMod), si les modules sont geres par ce fichier - - Si ShowError != 0 affiche message d'erreur si le fichier .cmp n'est pas - trouve. - Retoure 1 si erreur -*/ + * Met a jour le fichier name.CMP (s'il existe) apres un echange de module + * (par la commande changeMod), si les modules sont geres par ce fichier + * + * Si ShowError != 0 affiche message d'erreur si le fichier .cmp n'est pas + * trouve. + * Retoure 1 si erreur + */ { -wxString FileNameCmp, tmpfile; -FILE * FichCmp, *NewFile; -char Line[1024]; -wxString msg; - - if ( old_name == new_name ) return(0); /* pas de changement de nom */ + wxString FileNameCmp, tmpfile; + FILE* FichCmp, * NewFile; + char Line[1024]; + wxString msg; - /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ - if ( NetNameBuffer == wxEmptyString ) - FileNameCmp = m_Parent->m_CurrentScreen->m_FileName; - else FileNameCmp = NetNameBuffer; - ChangeFileNameExt(FileNameCmp,NetCmpExtBuffer) ; + if( old_name == new_name ) + return 0; /* pas de changement de nom */ - // Modification du fichier .cmp correcpondant - FichCmp = wxFopen(FileNameCmp, wxT("rt")); - if( FichCmp == NULL ) - { - if ( ShowError ) - { - msg.Printf( _("file %s not found"), FileNameCmp.GetData()); - m_WinMsg->WriteText(msg); - } - return(1); - } + /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ + if( NetNameBuffer == wxEmptyString ) + FileNameCmp = m_Parent->m_CurrentScreen->m_FileName; + else + FileNameCmp = NetNameBuffer; + ChangeFileNameExt( FileNameCmp, NetCmpExtBuffer ); - /* Analyse du fichier et modif */ - tmpfile = FileNameCmp; - ChangeFileNameExt(tmpfile, wxT(".$$$")); - NewFile = wxFopen(tmpfile, wxT("wt")); - if( NewFile == NULL ) - { - if ( ShowError ) - { - msg.Printf( _("Unable to create file %s"), tmpfile.GetData()); - m_WinMsg->WriteText(msg); - } - return(1); - } + // Modification du fichier .cmp correcpondant + FichCmp = wxFopen( FileNameCmp, wxT( "rt" ) ); + if( FichCmp == NULL ) + { + if( ShowError ) + { + msg.Printf( _( "file %s not found" ), FileNameCmp.GetData() ); + m_WinMsg->WriteText( msg ); + } + return 1; + } - fgets(Line, sizeof(Line), FichCmp); - fprintf(NewFile,"Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime(Line) ); + /* Analyse du fichier et modif */ + tmpfile = FileNameCmp; + ChangeFileNameExt( tmpfile, wxT( ".$$$" ) ); + NewFile = wxFopen( tmpfile, wxT( "wt" ) ); + if( NewFile == NULL ) + { + if( ShowError ) + { + msg.Printf( _( "Unable to create file %s" ), tmpfile.GetData() ); + m_WinMsg->WriteText( msg ); + } + return 1; + } - bool start_descr = FALSE; - while( fgets(Line, sizeof(Line), FichCmp) != NULL ) - { - if ( strnicmp( Line, "Reference = ", 9 ) == 0 ) - { - char buf[1024]; - strcpy( buf, Line + 12); - strtok(buf,";\n\r"); - if ( stricmp( buf , CONV_TO_UTF8(reference) ) == 0 ) - { - start_descr = TRUE; - } - } + fgets( Line, sizeof(Line), FichCmp ); + fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) ); - if ( (strnicmp( Line, "Begin", 5 ) == 0) || - (strnicmp( Line, "End", 3) == 0) ) - { - start_descr = FALSE; - } + bool start_descr = FALSE; + while( fgets( Line, sizeof(Line), FichCmp ) != NULL ) + { + if( strnicmp( Line, "Reference = ", 9 ) == 0 ) + { + char buf[1024]; + strcpy( buf, Line + 12 ); + strtok( buf, ";\n\r" ); + if( stricmp( buf, CONV_TO_UTF8( reference ) ) == 0 ) + { + start_descr = TRUE; + } + } - if ( start_descr && strnicmp( Line, "IdModule", 8 ) == 0 ) - { - sprintf(Line + 8," = %s;\n", CONV_TO_UTF8(new_name) ); + if( (strnicmp( Line, "Begin", 5 ) == 0) + || (strnicmp( Line, "End", 3 ) == 0) ) + { + start_descr = FALSE; + } - msg.Printf( wxT(" * in %s\n"), FileNameCmp.GetData()); - m_WinMsg->WriteText(msg); + if( start_descr && strnicmp( Line, "IdModule", 8 ) == 0 ) + { + sprintf( Line + 8, " = %s;\n", CONV_TO_UTF8( new_name ) ); - start_descr = FALSE; - } - fputs(Line, NewFile); - } + msg.Printf( wxT( " * in %s\n" ), FileNameCmp.GetData() ); + m_WinMsg->WriteText( msg ); - fclose(FichCmp); - fclose(NewFile); - wxRemoveFile(FileNameCmp); - wxRenameFile(tmpfile, FileNameCmp); - return(0); + start_descr = FALSE; + } + fputs( Line, NewFile ); + } + + fclose( FichCmp ); + fclose( NewFile ); + wxRemoveFile( FileNameCmp ); + wxRenameFile( tmpfile, FileNameCmp ); + return 0; } - /********************************************************************/ -void WinEDA_ExchangeModuleFrame::Change_Module(wxCommandEvent& event) +void WinEDA_ExchangeModuleFrame::Change_Module( wxCommandEvent& event ) /********************************************************************/ /* Routine de changement d'un module: - Change le module pointe par la souris, par un autre en conservant - - meme orientation - - meme position - - memes textes valeur et ref - - memes netnames pour pads de meme nom -*/ + * Change le module pointe par la souris, par un autre en conservant + * - meme orientation + * - meme position + * - memes textes valeur et ref + * - memes netnames pour pads de meme nom + */ { -wxString newmodulename = m_NewModule->GetValue(); + wxString newmodulename = m_NewModule->GetValue(); - if( newmodulename == wxEmptyString ) return; + if( newmodulename == wxEmptyString ) + return; - if( Change_1_Module(m_CurrentModule, newmodulename,TRUE ) ) - { - m_Parent->m_Pcb->m_Status_Pcb = 0; - m_Parent->build_liste_pads(); - } + if( Change_1_Module( m_CurrentModule, newmodulename, TRUE ) ) + { + m_Parent->m_Pcb->m_Status_Pcb = 0; + m_Parent->build_liste_pads(); + } } + /*********************************************************************/ -void WinEDA_ExchangeModuleFrame::Change_ModuleId(wxCommandEvent& event) +void WinEDA_ExchangeModuleFrame::Change_ModuleId( wxCommandEvent& event ) /**********************************************************************/ /* Routine de changement de tous les modules de meme nom lib que celui - selectionne, en conservant - - meme orientation - - meme position - - memes textes valeur et ref - - memes netnames pour pads de meme nom - et en remplacant l'ancien module par le noveau module - Attention: m_CurrentModule ne pointe plus sur le module de reference - puisque celui ci a ete change!! -*/ + * selectionne, en conservant + * - meme orientation + * - meme position + * - memes textes valeur et ref + * - memes netnames pour pads de meme nom + * et en remplacant l'ancien module par le noveau module + * Attention: m_CurrentModule ne pointe plus sur le module de reference + * puisque celui ci a ete change!! + */ { -wxString msg; -MODULE * PtModule, *PtBack; -bool change = FALSE; -wxString newmodulename = m_NewModule->GetValue(); -wxString value, lib_reference; // pour memo Reflib et value de reference -bool check_module_value = FALSE; -int ShowErr = 5; // Affiche 5 messages d'err maxi + wxString msg; + MODULE* PtModule, * PtBack; + bool change = FALSE; + wxString newmodulename = m_NewModule->GetValue(); + wxString value, lib_reference; // pour memo Reflib et value de reference + bool check_module_value = FALSE; + int ShowErr = 5; // Affiche 5 messages d'err maxi - if( m_Parent->m_Pcb->m_Modules == NULL ) return; - if( newmodulename == wxEmptyString ) return; + if( m_Parent->m_Pcb->m_Modules == NULL ) + return; + if( newmodulename == wxEmptyString ) + return; - lib_reference = m_CurrentModule->m_LibRef; - if ( event.GetId() == ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE ) - { - check_module_value = TRUE; - value = m_CurrentModule->m_Value->m_Text; - msg.Printf( _("Change modules <%s> -> <%s> (val = %s)?"), - m_CurrentModule->m_LibRef.GetData(), - newmodulename.GetData(), - m_CurrentModule->m_Value->m_Text.GetData() ); - } + lib_reference = m_CurrentModule->m_LibRef; + if( event.GetId() == ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE ) + { + check_module_value = TRUE; + value = m_CurrentModule->m_Value->m_Text; + msg.Printf( _( "Change modules <%s> -> <%s> (val = %s)?" ), + m_CurrentModule->m_LibRef.GetData(), + newmodulename.GetData(), + m_CurrentModule->m_Value->m_Text.GetData() ); + } + else + { + msg.Printf( _( "Change modules <%s> -> <%s> ?" ), + lib_reference.GetData(), newmodulename.GetData() ); + } - else - { - msg.Printf( _("Change modules <%s> -> <%s> ?"), - lib_reference.GetData(), newmodulename.GetData() ); - } + if( !IsOK( this, msg ) ) + return; - if( !IsOK(this, msg) ) return; + /* Le changement s'effectue a partir du dernier module car la routine + * Change_1_Module() modifie le dernier module de la liste + */ - /* Le changement s'effectue a partir du dernier module car la routine - Change_1_Module() modifie le dernier module de la liste - */ + PtModule = m_Parent->m_Pcb->m_Modules; + for( ; PtModule != NULL; PtModule = (MODULE*) PtModule->Pnext ) + { + if( PtModule->Pnext == NULL ) + break; + } - PtModule = m_Parent->m_Pcb->m_Modules; - for ( ; PtModule != NULL; PtModule = (MODULE*)PtModule->Pnext) - { - if(PtModule->Pnext == NULL) break; - } + /* Ici PtModule pointe le dernier module de la liste */ + for( ; PtModule != (MODULE*) m_Parent->m_Pcb; PtModule = PtBack ) + { + MODULE* module; + PtBack = (MODULE*) PtModule->Pback; + if( lib_reference.CmpNoCase( PtModule->m_LibRef ) != 0 ) + continue; + if( check_module_value ) + { + if( value.CmpNoCase( PtModule->m_Value->m_Text ) != 0 ) + continue; + } + module = Change_1_Module( PtModule, newmodulename.GetData(), ShowErr ); + if( module ) + change = TRUE; + else if( ShowErr ) + ShowErr--; + } - /* Ici PtModule pointe le dernier module de la liste */ - for ( ; PtModule != (MODULE*)m_Parent->m_Pcb; PtModule = PtBack) - { - MODULE * module; - PtBack = (MODULE*)PtModule->Pback; - if( lib_reference.CmpNoCase(PtModule->m_LibRef) != 0 ) - continue; - if ( check_module_value ) - { - if( value.CmpNoCase(PtModule->m_Value->m_Text) != 0 ) - continue; - } - module = Change_1_Module(PtModule, newmodulename.GetData(), ShowErr); - if ( module ) change = TRUE; - else if (ShowErr) ShowErr--; - } - if( change ) - { - m_Parent->m_Pcb->m_Status_Pcb = 0; - m_Parent->build_liste_pads(); - } + if( change ) + { + m_Parent->m_Pcb->m_Status_Pcb = 0; + m_Parent->build_liste_pads(); + } } + /***********************************************************************/ -void WinEDA_ExchangeModuleFrame::Change_ModuleAll(wxCommandEvent& event) +void WinEDA_ExchangeModuleFrame::Change_ModuleAll( wxCommandEvent& event ) /***********************************************************************/ + /* Routine de changement de tous les modules par les modules de meme nom lib: - en conservant - - meme orientation - - meme position - - memes textes valeur et ref - - memes netnames pour pads de meme nom -*/ + * en conservant + * - meme orientation + * - meme position + * - memes textes valeur et ref + * - memes netnames pour pads de meme nom + */ { -MODULE * PtModule, *PtBack; -bool change = FALSE; -int ShowErr = 5; // Affiche 5 messages d'err maxi + MODULE* PtModule, * PtBack; + bool change = FALSE; + int ShowErr = 5; // Affiche 5 messages d'err maxi - if(m_Parent->m_Pcb->m_Modules == NULL) return; + if( m_Parent->m_Pcb->m_Modules == NULL ) + return; - if( !IsOK(this, _("Change ALL modules ?")) ) return; + if( !IsOK( this, _( "Change ALL modules ?" ) ) ) + return; - /* Le changement s'effectue a partir du dernier module car la routine - Change_1_Module() modifie le dernier module de la liste - */ + /* Le changement s'effectue a partir du dernier module car la routine + * 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) - { - if(PtModule->Pnext == NULL) break; - } + PtModule = (MODULE*) m_Parent->m_Pcb->m_Modules; + for( ; PtModule != NULL; PtModule = (MODULE*) PtModule->Pnext ) + { + if( PtModule->Pnext == NULL ) + break; + } - /* Ici PtModule pointe le dernier module de la liste */ - for ( ; PtModule != (MODULE*)(m_Parent->m_Pcb); PtModule = PtBack) - { - PtBack = (MODULE*)PtModule->Pback; - if ( Change_1_Module(PtModule, PtModule->m_LibRef.GetData(), ShowErr) ) - change = TRUE; - else if (ShowErr) ShowErr--; - } + /* Ici PtModule pointe le dernier module de la liste */ + for( ; PtModule != (MODULE*) (m_Parent->m_Pcb); PtModule = PtBack ) + { + PtBack = (MODULE*) PtModule->Pback; + if( Change_1_Module( PtModule, PtModule->m_LibRef.GetData(), ShowErr ) ) + change = TRUE; + else if( ShowErr ) + ShowErr--; + } - if( change) - { - m_Parent->m_Pcb->m_Status_Pcb = 0; - m_Parent->build_liste_pads(); - } + if( change ) + { + m_Parent->m_Pcb->m_Status_Pcb = 0; + m_Parent->build_liste_pads(); + } } + /******************************************************************/ -MODULE * WinEDA_ExchangeModuleFrame::Change_1_Module(MODULE * PtModule, - const wxString& new_module, bool ShowError) +MODULE* WinEDA_ExchangeModuleFrame::Change_1_Module( MODULE* PtModule, + const wxString& new_module, bool ShowError ) /*******************************************************************/ + /* Routine de changement d'un module: - Change le module de numero empr, avec le module de nom new_module - - meme orientation - - meme position - - memes textes valeur et ref - - memes netnames pour pads de meme nom - Retourne : - 0 si pas de changement ( si le nouveau module n'est pas en libr) - 1 si OK -*/ + * Change le module de numero empr, avec le module de nom new_module + * - meme orientation + * - meme position + * - memes textes valeur et ref + * - memes netnames pour pads de meme nom + * Retourne : + * 0 si pas de changement ( si le nouveau module n'est pas en libr) + * 1 si OK + */ { -wxString namecmp, oldnamecmp; -MODULE * NewModule; -wxString Line; + wxString namecmp, oldnamecmp; + MODULE* NewModule; + wxString Line; - if(PtModule == NULL) return(NULL); + if( PtModule == NULL ) + return NULL; -wxBusyCursor dummy; + wxBusyCursor dummy; - /* Memorisation des parametres utiles de l'ancien module */ - oldnamecmp = PtModule->m_LibRef; - namecmp = new_module; + /* Memorisation des parametres utiles de l'ancien module */ + oldnamecmp = PtModule->m_LibRef; + namecmp = new_module; - /* Chargement du module */ - Line.Printf( _("Change module %s (%s) "), - PtModule->m_Reference->m_Text.GetData(), oldnamecmp.GetData()); - m_WinMsg->WriteText(Line); + /* Chargement du module */ + Line.Printf( _( "Change module %s (%s) " ), + PtModule->m_Reference->m_Text.GetData(), oldnamecmp.GetData() ); + m_WinMsg->WriteText( Line ); - namecmp.Trim(TRUE); - namecmp.Trim(FALSE); - NewModule = m_Parent->Get_Librairie_Module(this, wxEmptyString, namecmp, ShowError); - if( NewModule == NULL) /* Nouveau module NON trouve, reaffichage de l'ancien */ - { - m_WinMsg->WriteText( wxT("No\n")); - return(NULL); - } + namecmp.Trim( TRUE ); + namecmp.Trim( FALSE ); + NewModule = m_Parent->Get_Librairie_Module( this, wxEmptyString, namecmp, ShowError ); + if( NewModule == NULL ) /* Nouveau module NON trouve, reaffichage de l'ancien */ + { + m_WinMsg->WriteText( wxT( "No\n" ) ); + return NULL; + } - if ( PtModule == m_CurrentModule ) m_CurrentModule = NewModule; - m_WinMsg->WriteText( wxT("Ok\n")); + if( PtModule == m_CurrentModule ) + m_CurrentModule = NewModule; + m_WinMsg->WriteText( wxT( "Ok\n" ) ); - /* Effacement a l'ecran de l'ancien module */ - PtModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + /* Effacement a l'ecran de l'ancien module */ + PtModule->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR ); - m_Parent->Exchange_Module(this, PtModule, NewModule); + m_Parent->Exchange_Module( this, PtModule, NewModule ); - /* Affichage du nouveau module */ - NewModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0),GR_OR); + /* Affichage du nouveau module */ + NewModule->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); - Maj_ListeCmp(NewModule->m_Reference->m_Text, oldnamecmp, namecmp, ShowError); + Maj_ListeCmp( NewModule->m_Reference->m_Text, oldnamecmp, namecmp, ShowError ); - return(NewModule); + return NewModule; } + /***********************************************************************************/ -MODULE * WinEDA_BasePcbFrame::Exchange_Module(wxWindow * winaff, - MODULE * OldModule, MODULE * NewModule) +MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, + MODULE* OldModule, MODULE* NewModule ) /***********************************************************************************/ + /* -Remplace le module OldModule par le module NewModule (en conservant position, orientation..) -OldModule est supprimé de la memoire. -*/ + * Remplace le module OldModule par le module NewModule (en conservant position, orientation..) + * OldModule est supprimé de la memoire. + */ { -wxPoint oldpos; /* memorisation temporaire pos curseur */ -D_PAD * pt_pad, * pt_old_pad; + wxPoint oldpos;/* memorisation temporaire pos curseur */ + D_PAD* pt_pad, * pt_old_pad; - if ( (OldModule->m_StructType != TYPEMODULE) || (NewModule->m_StructType != TYPEMODULE) ) - { - DisplayError(winaff, wxT("WinEDA_BasePcbFrame::Exchange_Module() StuctType error" )); - } + if( (OldModule->m_StructType != TYPEMODULE) || (NewModule->m_StructType != TYPEMODULE) ) + { + DisplayError( winaff, wxT( "WinEDA_BasePcbFrame::Exchange_Module() StuctType error" ) ); + } - NewModule->m_Parent = m_Pcb; + NewModule->m_Parent = m_Pcb; - m_Pcb->m_Status_Pcb = 0 ; - oldpos = m_CurrentScreen->m_Curseur; - m_CurrentScreen->m_Curseur = OldModule->m_Pos; - Place_Module(NewModule, NULL); - m_CurrentScreen->m_Curseur = oldpos; + m_Pcb->m_Status_Pcb = 0; + oldpos = m_CurrentScreen->m_Curseur; + m_CurrentScreen->m_Curseur = OldModule->m_Pos; + Place_Module( NewModule, NULL ); + m_CurrentScreen->m_Curseur = oldpos; - /* Changement eventuel de couche */ - if( OldModule->m_Layer != NewModule->m_Layer) - { - Change_Side_Module(NewModule, NULL); - } + /* Changement eventuel de couche */ + if( OldModule->GetLayer() != NewModule->GetLayer() ) + { + Change_Side_Module( NewModule, NULL ); + } - /* Rotation eventuelle du module */ - if( OldModule->m_Orient != NewModule->m_Orient ) - { - Rotate_Module(NULL, NewModule,OldModule->m_Orient, FALSE ); - } + /* Rotation eventuelle du module */ + if( OldModule->m_Orient != NewModule->m_Orient ) + { + Rotate_Module( NULL, NewModule, OldModule->m_Orient, FALSE ); + } - /* Mise a jour des textes ref et val */ - NewModule->m_Reference->m_Text = OldModule->m_Reference->m_Text; - NewModule->m_Value->m_Text = OldModule->m_Value->m_Text; + /* Mise a jour des textes ref et val */ + NewModule->m_Reference->m_Text = OldModule->m_Reference->m_Text; + NewModule->m_Value->m_Text = OldModule->m_Value->m_Text; - /* Mise a jour des autres parametres */ - NewModule->m_TimeStamp = OldModule->m_TimeStamp; + /* Mise a jour des autres parametres */ + NewModule->m_TimeStamp = OldModule->m_TimeStamp; - /* 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) - { - pt_pad->m_Netname = wxEmptyString; - pt_pad->m_NetCode = 0; - pt_old_pad = OldModule->m_Pads; - for( ; pt_old_pad != NULL; pt_old_pad = (D_PAD*)pt_old_pad->Pnext ) - { - if(strnicmp( pt_pad->m_Padname, pt_old_pad->m_Padname,sizeof(pt_pad->m_Padname)) == 0) - { - pt_pad->m_Netname = pt_old_pad->m_Netname; - pt_pad->m_NetCode = pt_old_pad->m_NetCode; - } - } - } + /* 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 ) + { + pt_pad->m_Netname = wxEmptyString; + pt_pad->m_NetCode = 0; + pt_old_pad = OldModule->m_Pads; + for( ; pt_old_pad != NULL; pt_old_pad = (D_PAD*) pt_old_pad->Pnext ) + { + if( strnicmp( pt_pad->m_Padname, pt_old_pad->m_Padname, + sizeof(pt_pad->m_Padname) ) == 0 ) + { + pt_pad->m_Netname = pt_old_pad->m_Netname; + pt_pad->m_NetCode = pt_old_pad->m_NetCode; + } + } + } - /* Effacement de l'ancien module */ - DeleteStructure(OldModule); + /* Effacement de l'ancien module */ + DeleteStructure( OldModule ); - m_Pcb->m_Status_Pcb = 0; - NewModule->m_Flags = 0; - m_CurrentScreen->SetModify(); + m_Pcb->m_Status_Pcb = 0; + NewModule->m_Flags = 0; + m_CurrentScreen->SetModify(); - return NewModule; + return NewModule; } /***************************************************************************/ -void WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste(wxCommandEvent& event) +void WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste( wxCommandEvent& event ) /***************************************************************************/ /*affiche la liste des modules en librairie et selectione 1 nom */ { -wxString newname; + wxString newname; - newname = m_Parent->Select_1_Module_From_List( m_Parent, wxEmptyString, wxEmptyString, wxEmptyString); - if ( newname != wxEmptyString ) - m_NewModule->SetValue(newname); + newname = m_Parent->Select_1_Module_From_List( m_Parent, + wxEmptyString, + wxEmptyString, + wxEmptyString ); + if( newname != wxEmptyString ) + m_NewModule->SetValue( newname ); } /***************************************************/ -bool WinEDA_PcbFrame::RecreateCmpFileFromBoard(void) +bool WinEDA_PcbFrame::RecreateCmpFileFromBoard( void ) /***************************************************/ { -wxString FullFileNameCmp, mask; -FILE * FichCmp; -char Line[1024]; -MODULE * Module = m_Pcb->m_Modules; -wxString msg; - - if ( Module == NULL) - { - DisplayError(this, _("No Modules!") ); - return FALSE; - } + wxString FullFileNameCmp, mask; + FILE* FichCmp; + char Line[1024]; + MODULE* Module = m_Pcb->m_Modules; + wxString msg; - /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ - if ( NetNameBuffer == wxEmptyString ) - FullFileNameCmp = m_CurrentScreen->m_FileName; - else FullFileNameCmp = NetNameBuffer; - ChangeFileNameExt(FullFileNameCmp,NetCmpExtBuffer) ; + if( Module == NULL ) + { + DisplayError( this, _( "No Modules!" ) ); + return FALSE; + } - mask = wxT("*") + NetCmpExtBuffer; - FullFileNameCmp = EDA_FileSelector( _("Cmp files:"), - wxEmptyString, /* Chemin par defaut */ - FullFileNameCmp, /* nom fichier par defaut */ - NetCmpExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if ( FullFileNameCmp.IsEmpty() ) return FALSE; + /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ + if( NetNameBuffer == wxEmptyString ) + FullFileNameCmp = m_CurrentScreen->m_FileName; + else + FullFileNameCmp = NetNameBuffer; + ChangeFileNameExt( FullFileNameCmp, NetCmpExtBuffer ); + + mask = wxT( "*" ) + NetCmpExtBuffer; + FullFileNameCmp = EDA_FileSelector( _( "Cmp files:" ), + wxEmptyString, /* Chemin par defaut */ + FullFileNameCmp, /* nom fichier par defaut */ + NetCmpExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if( FullFileNameCmp.IsEmpty() ) + return FALSE; - FichCmp = wxFopen(FullFileNameCmp, wxT("wt")); - if( FichCmp == NULL ) - { - msg = _("Unable to create file ") + FullFileNameCmp; - DisplayError(this, msg); - return FALSE; - } + FichCmp = wxFopen( FullFileNameCmp, wxT( "wt" ) ); + if( FichCmp == NULL ) + { + msg = _( "Unable to create file " ) + FullFileNameCmp; + DisplayError( this, msg ); + return FALSE; + } - fgets(Line, sizeof(Line), FichCmp); - fprintf(FichCmp,"Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime(Line) ); + 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 ) - { - fprintf(FichCmp,"\nBeginCmp\n" ); - fprintf(FichCmp,"TimeStamp = %8.8lX\n", Module->m_TimeStamp); - fprintf(FichCmp,"Reference = %s;\n", - ! Module->m_Reference->m_Text.IsEmpty() ? - CONV_TO_UTF8(Module->m_Reference->m_Text) : "[NoRef]" ); - fprintf(FichCmp,"ValeurCmp = %s;\n", - !Module->m_Value->m_Text.IsEmpty() ? - CONV_TO_UTF8(Module->m_Value->m_Text) : "[NoVal]" ); - fprintf(FichCmp,"IdModule = %s;\n", CONV_TO_UTF8(Module->m_LibRef)); - fprintf(FichCmp,"EndCmp\n" ); - } + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + fprintf( FichCmp, "\nBeginCmp\n" ); + fprintf( FichCmp, "TimeStamp = %8.8lX\n", Module->m_TimeStamp ); + fprintf( FichCmp, "Reference = %s;\n", + !Module->m_Reference->m_Text.IsEmpty() ? + CONV_TO_UTF8( Module->m_Reference->m_Text ) : "[NoRef]" ); + fprintf( FichCmp, "ValeurCmp = %s;\n", + !Module->m_Value->m_Text.IsEmpty() ? + CONV_TO_UTF8( Module->m_Value->m_Text ) : "[NoVal]" ); + fprintf( FichCmp, "IdModule = %s;\n", CONV_TO_UTF8( Module->m_LibRef ) ); + fprintf( FichCmp, "EndCmp\n" ); + } - fprintf(FichCmp,"\nEndListe\n"); - fclose(FichCmp); + fprintf( FichCmp, "\nEndListe\n" ); + fclose( FichCmp ); - return TRUE; + return TRUE; } diff --git a/pcbnew/zones.cpp b/pcbnew/zones.cpp index d8b1bec01f..c805b189e9 100644 --- a/pcbnew/zones.cpp +++ b/pcbnew/zones.cpp @@ -683,7 +683,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( void ) newedge->Pback = oldedge; if( oldedge ) oldedge->Pnext = newedge; - newedge->m_Layer = GetScreen()->m_Active_Layer; + newedge->SetLayer( GetScreen()->m_Active_Layer ); newedge->m_Width = 2; /* Largeur minimum tracable */ newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur; @@ -702,7 +702,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( void ) oldedge->Pnext = newedge; newedge->m_Flags = IS_NEW | IS_MOVED; newedge->m_Start = newedge->m_End = oldedge->m_End; - newedge->m_Layer = GetScreen()->m_Active_Layer; + newedge->SetLayer( GetScreen()->m_Active_Layer ); m_Pcb->m_CurrentLimitZone = newedge; } } @@ -777,7 +777,7 @@ static void Show_Zone_Edge_While_MoveMouse( WinEDA_DrawPanel* panel, wxDC* DC, b edgezone = PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback ) { - PtLim->m_Layer = pcbframe->GetScreen()->m_Active_Layer; + PtLim->SetLayer( pcbframe->GetScreen()->m_Active_Layer ); } /* dessin de la nouvelle piste : mise a jour du point d'arrivee */ @@ -849,7 +849,7 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC ) for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback ) { Trace_DrawSegmentPcb( DrawPanel, DC, PtLim, GR_XOR ); - PtLim->m_Layer = GetScreen()->m_Active_Layer; + PtLim->SetLayer( GetScreen()->m_Active_Layer ); Trace_DrawSegmentPcb( DrawPanel, DC, PtLim, GR_XOR ); } @@ -922,7 +922,7 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC ) { if( g_HightLigth_NetCode != pt_segm->m_NetCode ) continue; - if( pt_segm->m_Layer != GetScreen()->m_Active_Layer ) + if( pt_segm->GetLayer() != GetScreen()->m_Active_Layer ) continue; if( pt_segm->m_StructType != TYPETRACK ) continue; @@ -1086,7 +1086,7 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code { /* un segment avait debute de longueur > 0 */ pt_track = new SEGZONE( frame->m_Pcb ); - pt_track->m_Layer = layer; + pt_track->SetLayer( layer ); pt_track->m_NetCode = net_code; pt_track->m_Width = g_GridRoutingSize; pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; @@ -1124,7 +1124,7 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code { /* un segment avait debute de longueur > 0 */ pt_track = new SEGZONE( frame->m_Pcb ); - pt_track->m_Layer = layer; + pt_track->SetLayer( layer ); pt_track->m_Width = g_GridRoutingSize; pt_track->m_NetCode = net_code; pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; @@ -1363,7 +1363,7 @@ static bool Genere_Pad_Connexion( WinEDA_PcbFrame* frame, wxDC* DC, int layer ) pt_track = new SEGZONE( frame->m_Pcb ); - pt_track->m_Layer = layer; + pt_track->SetLayer( layer ); pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; pt_track->m_NetCode = g_HightLigth_NetCode; pt_track->start = pt_pad;