From 2bd88d356ce364bcacb104d41b51a0f5821f4433 Mon Sep 17 00:00:00 2001 From: CHARRAS Date: Tue, 4 Sep 2007 14:28:20 +0000 Subject: [PATCH] small changes in editrack-part2.cpp (translation of some comments from french to english) are some explanations relatives to the todo remark --- change_log.txt | 6 ++++ eeschema/block.cpp | 67 +++++++++++++++-------------------- gerbview/export_to_pcbnew.cpp | 15 ++++---- pcbnew/editrack-part2.cpp | 48 ++++++++++++++++--------- todo.txt | 6 +++- 5 files changed, 78 insertions(+), 64 deletions(-) diff --git a/change_log.txt b/change_log.txt index 4a53e5d4b0..2a3f562b4c 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,12 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-sept-04 UPDATE Jean-Pierre Charras +================================================================================ ++ pcbnew + better comments in editrack-part2 (the todo remark solved) ++ todo.txt: note about editrack-part2 modified (problem solved) + 2007-Aug-31 UPDATE Dick Hollenbeck ================================================================================ diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 529d8e278b..c3a4a14553 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -21,9 +21,9 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* screen, EDA_BaseStruct* DrawStruct ); static void CollectStructsToDrag( SCH_SCREEN* screen ); -static void AddPickedItem( SCH_SCREEN* screen, int px, int py ); +static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ); static LibEDA_BaseStruct* GetNextPinPosition( EDA_SchComponentStruct* DrawLibItem, - int* px, int* py ); + wxPoint & position ); static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static EDA_BaseStruct* SaveStructListForPaste( EDA_BaseStruct* DrawStruct ); static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, @@ -1441,14 +1441,14 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) if( Struct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE ) { LibEDA_BaseStruct* DrawItem; - int x, y; - DrawItem = GetNextPinPosition( (EDA_SchComponentStruct*) Struct, &x, &y ); + wxPoint pos; + DrawItem = GetNextPinPosition( (EDA_SchComponentStruct*) Struct, pos ); while( DrawItem ) { - if( (x < ox) || (x > fx) || (y < oy) || (y > fy) ) - AddPickedItem( screen, x, y ); + if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) ) + AddPickedItem( screen, pos ); - DrawItem = GetNextPinPosition( NULL, &x, &y ); + DrawItem = GetNextPinPosition( NULL, pos ); } } @@ -1458,7 +1458,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) while( SLabel ) { if( SLabel->Type() == DRAW_SHEETLABEL_STRUCT_TYPE ) - AddPickedItem( screen, SLabel->m_Pos.x, SLabel->m_Pos.y ); + AddPickedItem( screen, SLabel->m_Pos ); SLabel = (DrawSheetLabelStruct*) SLabel->Pnext; } } @@ -1466,15 +1466,15 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) if( Struct->Type() == DRAW_BUSENTRY_STRUCT_TYPE ) { DrawBusEntryStruct* item = (DrawBusEntryStruct*) Struct; - AddPickedItem( screen, item->m_Pos.x, item->m_Pos.y ); - AddPickedItem( screen, item->m_End().x, item->m_End().y ); + AddPickedItem( screen, item->m_Pos ); + AddPickedItem( screen, item->m_End() ); } } } /******************************************************************/ -static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) +static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) /******************************************************************/ { DrawPickedStruct* DrawStructs; @@ -1492,10 +1492,10 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) case DRAW_SEGMENT_STRUCT_TYPE: #undef STRUCT #define STRUCT ( (EDA_DrawLineStruct*) Struct ) - if( (STRUCT->m_Start.x == px) && (STRUCT->m_Start.y == py) ) + if( STRUCT->m_Start == position ) STRUCT->m_Flags &= ~STARTPOINT; - if( (STRUCT->m_End.x == px) && (STRUCT->m_End.y == py) ) + if( STRUCT->m_End == position ) STRUCT->m_Flags &= ~ENDPOINT; break; @@ -1524,9 +1524,7 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) #define STRUCT ( (DrawJunctionStruct*) Struct ) if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) - break; - if( STRUCT->m_Pos.y != py ) + if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1539,7 +1537,7 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) #define STRUCT ( (EDA_DrawLineStruct*) Struct ) if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( (STRUCT->m_Start.x == px ) && ( STRUCT->m_Start.y == py ) ) + if( STRUCT->m_Start == position ) { DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1548,7 +1546,7 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags &= ~STARTPOINT; } - else if( (STRUCT->m_End.x == px ) && ( STRUCT->m_End.y == py ) ) + else if( STRUCT->m_End == position ) { DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1569,10 +1567,8 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) #undef STRUCT #define STRUCT ( (DrawLabelStruct*) Struct ) if( Struct->m_Flags & SELECTED ) - break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) - break; - if( STRUCT->m_Pos.y != py ) + break; /* Already in list */ + if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1585,10 +1581,8 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) #undef STRUCT #define STRUCT ( (DrawGlobalLabelStruct*) Struct ) if( Struct->m_Flags & SELECTED ) - break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) - break; - if( STRUCT->m_Pos.y != py ) + break; /* Already in list */ + if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1613,10 +1607,8 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) #undef STRUCT #define STRUCT ( (DrawMarkerStruct*) Struct ) if( Struct->m_Flags & SELECTED ) - break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) - break; - if( STRUCT->m_Pos.y != py ) + break; /* Already in list */ + if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1629,10 +1621,8 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) #undef STRUCT #define STRUCT ( (DrawNoConnectStruct*) Struct ) if( Struct->m_Flags & SELECTED ) - break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) - break; - if( STRUCT->m_Pos.y != py ) + break; /* Already in list */ + if( STRUCT->m_Pos != position ) break; DrawStructs = new DrawPickedStruct( Struct ); DrawStructs->Pnext = @@ -1651,14 +1641,14 @@ static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) /*********************************************************************************/ static LibEDA_BaseStruct* GetNextPinPosition( EDA_SchComponentStruct* DrawLibItem, - int* px, int* py ) + wxPoint & position ) /*********************************************************************************/ { EDA_LibComponentStruct* Entry; static LibEDA_BaseStruct* NextItem; static int Multi, convert, PartX, PartY, TransMat[2][2]; LibEDA_BaseStruct* DEntry; - int x2, y2, orient; + int orient; LibDrawPin* Pin; if( DrawLibItem ) @@ -1693,11 +1683,10 @@ static LibEDA_BaseStruct* GetNextPinPosition( EDA_SchComponentStruct* DrawLibIte orient = Pin->ReturnPinDrawOrient( TransMat ); /* Calcul de la position du point de reference */ - x2 = PartX + (TransMat[0][0] * Pin->m_Pos.x) + position.x = PartX + (TransMat[0][0] * Pin->m_Pos.x) + (TransMat[0][1] * Pin->m_Pos.y); - y2 = PartY + (TransMat[1][0] * Pin->m_Pos.x) + position.y = PartY + (TransMat[1][0] * Pin->m_Pos.x) + (TransMat[1][1] * Pin->m_Pos.y); - *px = x2; *py = y2; NextItem = DEntry->Next(); return DEntry; } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index b9c89db647..70ef60474f 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -90,12 +90,12 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File ) { int NbLayers; - /* generation du masque des couches autorisees */ + /* Print the copper layer count */ NbLayers = Pcb->m_BoardSettings->m_CopperLayerCount; fprintf( File, "$GENERAL\n" ); fprintf( File, "LayerCount %d\n", NbLayers ); - /* Generation des coord du rectangle d'encadrement */ + /* Compute and print the board bounding box */ Pcb->ComputeBoundaryBox(); fprintf( File, "Di %d %d %d %d\n", Pcb->m_BoundaryBox.GetX(), Pcb->m_BoundaryBox.GetY(), @@ -112,10 +112,11 @@ 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 +/* Routine to save the board + * @param frame = pointer to the main frame + * @param File = FILE * pointer to an already opened file + * @param LayerLookUpTable = look up table: pcbnew layer for each gerber layer + * @return 1 if OK, 0 if fail */ { char Line[256]; @@ -260,7 +261,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File, delete Pcb; - setlocale( LC_NUMERIC, "" ); // revert to the current locale + setlocale( LC_NUMERIC, "" ); // revert to the current locale wxEndBusyCursor(); return 1; } diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index fbadf53bdd..178577a5ff 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -157,8 +157,11 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) /****************************************************************/ /* - * Change de couche active pour le routage. - * Si une piste est en cours de trace : placement d'une Via + * if no track in progress : + * swap the active layer between m_Route_Layer_TOP and m_Route_Layer_BOTTOM + * if a track is in progress : + * put (if possible, i.e. if no DRC problem) a Via on the end of the current + * track, swap the current active layer and start a new trac segment on the new layer */ { TRACK* pt_segm; @@ -177,7 +180,7 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) return; } - /* Les vias ne doivent pas etre inutilement empilees: */ + /* Avoid more than one via on the current location: */ if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) return; pt_segm = g_FirstTrackSegment; @@ -188,17 +191,20 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) return; } - /* Test si segment possible a placer */ + /* Is the current segment Ok (no DRC error) */ if( Drc_On ) if( Drc( this, DC, g_CurrentTrackSegment, m_Pcb->m_Track, 1 ) == BAD_DRC ) + /* DRC error, the change layer is not made */ return; - /* save etat actuel pour regeneration si via impossible a placer */ + /* Saving current state before placing a via. + If the via canot be placed this current state will be reused */ itmp = g_TrackSegmentCount; Begin_Route( g_CurrentTrackSegment, DC ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + /* create the via */ Via = new SEGVIA( m_Pcb ); Via->m_Flags = IS_NEW; Via->m_Width = g_DesignSettings.m_CurrentViaSize; @@ -206,9 +212,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->SetLayer( GetScreen()->m_Active_Layer ); - - // Provisoirement. indicate the first layer (?) + int old_layer = GetScreen()->m_Active_Layer ); //swap the layers. if( GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP ) @@ -216,36 +220,46 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) else GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM; + /* Adjust the via layer pair */ if( (Via->m_Shape & 15) == VIA_ENTERREE ) { - Via->SetLayer( Via->GetLayer() | GetScreen()->m_Active_Layer << 4 ); + Via->SetLayer( old_layer | 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->SetLayer( Via->GetLayer() | GetScreen()->m_Active_Layer << 4 ); + Via->SetLayer( old_layer | GetScreen()->m_Active_Layer << 4 ); } else - Via->SetLayer( 0x0F ); + Via->SetLayer( 0x0F ); // Usual via is from copper to component; layer pair is 0 and 0x0F if( Drc_On &&( Drc( this, DC, Via, m_Pcb->m_Track, 1 ) == BAD_DRC ) ) { - /* Via impossible a placer ici */ + /* DRC fault: the Via cannot be placed here ... */ delete Via; - GetScreen()->m_Active_Layer = g_CurrentTrackSegment->GetLayer(); + GetScreen()->m_Active_Layer = old_layer; DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); return; } - /* la via est OK et est inseree apres le segment courant */ + /* A new via was created. It was Ok. + Put it in linked list, after the g_CurrentTrackSegment */ Via->Pback = g_CurrentTrackSegment; g_CurrentTrackSegment->Pnext = Via; g_TrackSegmentCount++; - // @todo: is this a memory leak bug? is g_CurrentTrackSegment's original lost or is it on some list? - g_CurrentTrackSegment = g_CurrentTrackSegment->Copy(); + /* The g_CurrentTrackSegment is now in linked list and we need a new track segment + after the via, starting at via location. + it will become the new curren segment (from via to the mouse cursor) + */ + g_CurrentTrackSegment = g_CurrentTrackSegment->Copy(); /* create a new segment + from the last entered segment, with the current width, flags, netcode, etc... values + layer, start and end point are not correct, and will be modified next */ - g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); + g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); // set the layer to the new value + /* the start point is the via position, + and the end point is the cursor which also is on the via (will change when moving mouse) + */ g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End = Via->m_Start; g_TrackSegmentCount++; diff --git a/todo.txt b/todo.txt index 69856fceed..f21eef88bc 100644 --- a/todo.txt +++ b/todo.txt @@ -3,11 +3,15 @@ Here are some source code maintenance tasks that need to be done, and maybe some folks will see these items and volunteer to do them. -*** Look at @todo in editrack-part2.cpp. Is this is a bug? + +*** Look at @todo in editrack-part2.cpp. Is this is a bug? ** Done (JP Charras) ** Concerns: a) Isn't there a problem with losing the memory of the original? b) If this is supposed to duplicate a SEGVIA to, then this call should be changed to the new TRACK::Copy(), i.e. g_CurrentTrackSegment->Copy() +>> (JP Charras:) No problem. the code is correct. + I have put comments to explain this code section and modified some line for a more intelligible code + *** Set up a DOXYGEN environment starting with a configuration file that: