From 9ba9be706ed8dea8c83975259cc818fcf652cbe7 Mon Sep 17 00:00:00 2001 From: CHARRAS Date: Fri, 25 Jan 2008 13:16:24 +0000 Subject: [PATCH] void Change_Side_Module( MODULE* Module, wxDC* DC ) is now member of class BOARD (as asked in todo list) --- change_log.txt | 8 +++++ include/wxPcbStruct.h | 1 - pcbnew/block.cpp | 2 +- pcbnew/class_board.h | 5 ++++ pcbnew/dialog_edit_module.cpp | 2 +- pcbnew/edit.cpp | 2 +- pcbnew/export_gencad.cpp | 4 +-- pcbnew/hotkeys.cpp | 2 +- pcbnew/loadcmp.cpp | 2 +- pcbnew/modules.cpp | 55 +++++++++++++++++++---------------- pcbnew/specctra_export.cpp | 9 ++++-- pcbnew/xchgmod.cpp | 2 +- todo.txt | 11 ------- 13 files changed, 57 insertions(+), 48 deletions(-) diff --git a/change_log.txt b/change_log.txt index 42fda6eb01..3cff2f7c03 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,14 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. + + +2008-Jan-25 UPDATE Jean-Pierre Charras +================================================================================ ++pcbnew: + void Change_Side_Module( MODULE* Module, wxDC* DC ) is now member of class BOARD. + + 2008-Jan-24 UPDATE Dick Hollenbeck ================================================================================ +pcbnew: diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 373dc392f4..235cde50d3 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -187,7 +187,6 @@ public: MODULE* module, int angle, bool incremental ); - void Change_Side_Module( MODULE* Module, wxDC* DC ); void Place_Module( MODULE* module, wxDC* DC ); void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule, wxDC* DC, const wxPoint& pos ); diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 6b9a91467f..8294a4600c 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -801,7 +801,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) Place_Module( module, NULL ); /* inversion du module */ - Change_Side_Module( module, DC ); + m_Pcb->Change_Side_Module( module, DC ); /* regeneration des valeurs originelles */ GetScreen()->m_Curseur = memo; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 2d3fb72da4..0c0ff0e8d1 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -246,6 +246,11 @@ public: #endif + /**************************/ + /* footprint operations : */ + /**************************/ + void Change_Side_Module( MODULE* Module, wxDC* DC ); + /*************************/ /* Copper Areas handling */ /*************************/ diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index 1c16a6f0bb..96f1e67cf2 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -525,7 +525,7 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event ) if( change_layer ) { - m_Parent->Change_Side_Module( m_CurrentModule, m_DC ); + m_Parent->m_Pcb->Change_Side_Module( m_CurrentModule, m_DC ); } if( m_AutoPlaceCtrl->GetSelection() == 1 ) diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 21999ab774..455ec4d304 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -618,7 +618,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) SetCurItem( GetCurItem()->GetParent() ); if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) break; - Change_Side_Module( (MODULE*) GetCurItem(), &dc ); + m_Pcb->Change_Side_Module( (MODULE*) GetCurItem(), &dc ); break; case ID_POPUP_PCB_EDIT_MODULE: diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 46d0d5651c..f8abed3add 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -103,7 +103,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) module->flag = 0; if( module->GetLayer() == COPPER_LAYER_N ) { - Change_Side_Module( module, NULL ); + m_Pcb->Change_Side_Module( module, NULL ); module->flag = 1; } } @@ -135,7 +135,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) { if( module->flag ) { - Change_Side_Module( module, NULL ); + m_Pcb->Change_Side_Module( module, NULL ); module->flag = 0; } } diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index d3e3bfa819..cdaa4e6ae1 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -507,7 +507,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_FLIP_FOOTPRINT: // move to other side - Change_Side_Module( module, DC ); + m_Pcb->Change_Side_Module( module, DC ); break; case HK_DRAG_FOOTPRINT: // Start move (and drag) module diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 0cc7af70c9..7493497d9e 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -80,7 +80,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->GetLayer() != CMP_N ) - Change_Side_Module( Module, NULL ); + m_Pcb->Change_Side_Module( Module, NULL ); Rotate_Module( NULL, Module, 0, FALSE ); m_CurrentScreen->ClrModify(); Zoom_Automatique( TRUE ); diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 47de424b73..69601fb431 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -193,7 +193,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) if( ModuleInitOrient != module->m_Orient ) pcbframe->Rotate_Module( NULL, module, ModuleInitOrient, FALSE ); if( ModuleInitLayer != module->GetLayer() ) - pcbframe->Change_Side_Module( module, NULL ); + pcbframe->m_Pcb->Change_Side_Module( module, NULL ); module->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); } g_Drag_Pistes_On = FALSE; @@ -320,14 +320,18 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, wxDC* DC ) } -/**********************************************************************/ -void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) -/**********************************************************************/ +/****************************************************************************/ +void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) +/****************************************************************************/ -/* Change de cote un composant : il y a inversion MIROIR autour de l'axe X - * Le changement n'est fait que si la couche est - * - CUIVRE ou CMP - * Si DC == NULL, il n'y a pas de redessin du composant et du chevelu +/** + * Function Change_Side_Module + * Filp a footprint (switch layer from component or component to copper) + * The mirroring is made from X axis + * if a footprint is not on copper or component layer it is not flipped + * (it could be on an adhesive layer, not supported at this time) + * @param Module the footprint to fli^p + * @param DC Current Device Context. if NULL, no redraw */ { D_PAD* pt_pad; @@ -340,17 +344,17 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) if( (Module->GetLayer() != CMP_N) && (Module->GetLayer() != COPPER_LAYER_N) ) return; - m_CurrentScreen->SetModify(); + m_PcbFrame->GetScreen()->SetModify(); if( !(Module->m_Flags & IS_MOVED) ) { - m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); - if( DC ) - Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); + if( DC && m_PcbFrame ) + Module->Draw( m_PcbFrame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); /* Effacement chevelu general si necessaire */ if( DC && g_Show_Ratsnest ) - DrawGeneralRatsnest( DC ); + m_PcbFrame->DrawGeneralRatsnest( DC ); /* Init des variables utilisees dans la routine Dessine_Drag_segment() */ g_Offset_Module.x = 0; @@ -359,10 +363,10 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) else // Module en deplacement { /* efface empreinte ( vue en contours) si elle a ete deja dessinee */ - if( DC ) + if( DC && m_PcbFrame ) { - DrawModuleOutlines( DrawPanel, DC, Module ); - Dessine_Segments_Dragges( DrawPanel, DC ); + DrawModuleOutlines( m_PcbFrame->DrawPanel, DC, Module ); + Dessine_Segments_Dragges( m_PcbFrame->DrawPanel, DC ); } } @@ -485,33 +489,34 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) break; default: - DisplayError( this, wxT( "Unknown Draw Type" ) ); break; + DisplayError( m_PcbFrame, wxT( "Unknown Draw Type" ) ); break; } } /* calcul du rectangle d'encadrement */ Module->Set_Rectangle_Encadrement(); - Module->Display_Infos( this ); + if ( m_PcbFrame ) + Module->Display_Infos( m_PcbFrame ); if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */ { - if( DC ) + if( DC && m_PcbFrame ) { - Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + Module->Draw( m_PcbFrame->DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); /* affichage chevelu general si necessaire */ - ReCompile_Ratsnest_After_Changes( DC ); + m_PcbFrame->ReCompile_Ratsnest_After_Changes( DC ); } } else { - if( DC ) + if( DC && m_PcbFrame ) { - DrawModuleOutlines( DrawPanel, DC, Module ); - Dessine_Segments_Dragges( DrawPanel, DC ); + DrawModuleOutlines( m_PcbFrame->DrawPanel, DC, Module ); + Dessine_Segments_Dragges( m_PcbFrame->DrawPanel, DC ); } - m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + m_Status_Pcb &= ~CHEVELU_LOCAL_OK; } } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index da6f5389bc..e14c8290b6 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -76,7 +76,7 @@ void WinEDA_PcbFrame::ExportToSPECCTRA( wxCommandEvent& event ) module->flag = 0; if( module->GetLayer() == COPPER_LAYER_N ) { - Change_Side_Module( module, NULL ); + m_Pcb->Change_Side_Module( module, NULL ); module->flag = 1; } } @@ -103,7 +103,7 @@ void WinEDA_PcbFrame::ExportToSPECCTRA( wxCommandEvent& event ) { if( module->flag ) { - Change_Side_Module( module, NULL ); + m_Pcb->Change_Side_Module( module, NULL ); module->flag = 0; } } @@ -242,7 +242,8 @@ static void makePADSTACKs( BOARD* aBoard, TYPE_COLLECTOR& aPads, { if( aPads.GetCount() ) { - qsort( (void*) aPads.BasePtr(), aPads.GetCount(), sizeof(D_PAD*), Pad_list_Sort_by_Shapes ); +#warning "uncomment next line asap" +//JPC qsort( (void*) aPads.BasePtr(), aPads.GetCount(), sizeof(D_PAD*), Pad_list_Sort_by_Shapes ); } D_PAD* old_pad = NULL; @@ -591,8 +592,10 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError ) makePADSTACKs( aBoard, pads, pcb->library, pcb->library->padstacks ); +#if defined(DEBUG) for( int p=0; pShow( 0, std::cout ); +#endif /* static const KICAD_T scanMODULEs[] = { TYPEMODULE, EOT }; diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 4b0d2b8f56..ab3328861d 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -538,7 +538,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, /* Changement eventuel de couche */ if( OldModule->GetLayer() != NewModule->GetLayer() ) { - Change_Side_Module( NewModule, NULL ); + m_Pcb->Change_Side_Module( NewModule, NULL ); } /* Rotation eventuelle du module */ diff --git a/todo.txt b/todo.txt index 5e7a19a8d8..17835221d2 100644 --- a/todo.txt +++ b/todo.txt @@ -71,14 +71,3 @@ asked by: jp Charras Use the collector classes in eeschema. -2008-Jan-24 Assigned To: nobody -asked by: Dick Hollenbeck -================================================================================ -See specctra.h's such comment -* @todo -* I would have liked to put the flipping logic into the ExportToSPECCTRA() -* function directly, but for some strange reason, -* void Change_Side_Module( MODULE* Module, wxDC* DC ) is a member of -* of class WinEDA_BasePcbFrame rather than class BOARD. -* -