Commit ee194b63 authored by lifekidyeaa's avatar lifekidyeaa

Changed the functionality of the 'insert' modified footprint module in the

module editor to a more sensible replace and update functionality. 
parent b2051634
...@@ -55,7 +55,7 @@ wxClientDC dc(DrawPanel); ...@@ -55,7 +55,7 @@ wxClientDC dc(DrawPanel);
pos.y += 20; pos.y += 20;
switch ( id ) // Arret eventuel de la commande de dplacement en cours switch ( id ) // Arret eventuel de la commande de dplacement en cours
{ {
case wxID_CUT: case wxID_CUT:
case wxID_COPY: case wxID_COPY:
...@@ -95,7 +95,7 @@ wxClientDC dc(DrawPanel); ...@@ -95,7 +95,7 @@ wxClientDC dc(DrawPanel);
} }
break; break;
default: // Arret dea commande de dplacement en cours default: // Arret dea commande de dplacement en cours
if( DrawPanel->ManageCurseur && if( DrawPanel->ManageCurseur &&
DrawPanel->ForceCloseManageCurseur ) DrawPanel->ForceCloseManageCurseur )
{ {
...@@ -149,20 +149,104 @@ wxClientDC dc(DrawPanel); ...@@ -149,20 +149,104 @@ wxClientDC dc(DrawPanel);
if ( m_Draw3DFrame ) if ( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay(); m_Draw3DFrame->NewDisplay();
break; break;
case ID_MODEDIT_SAVE_MODULE_IN_BOARD:{
// seems that this should update modules in the current board,
// not just add it to the board with total disregard for the
// netlist...?
WinEDA_PcbFrame * pcbframe = m_Parent->m_PcbFrame;
BOARD * mainpcb = pcbframe->m_Pcb;
MODULE * presmod = m_Pcb->m_Modules; //the module being edited.
//i guess we need to search through the modules here.. they are in a linked list.
//replace based on m_libref?
MODULE* mod = mainpcb->m_Modules;
do{
//need to be careful in this doubly linked-list to maintain order & link
// also have to maintain netname on all the pads according to m_NumPadName.
if(mod->m_LibRef == presmod->m_LibRef){//have to be careful with this test of similarity?
wprintf(L"replace: mod->m_LibRef = %S @ %d %d orient: %d\n", mod->m_LibRef.c_str(),
mod->m_Pos.x, mod->m_Pos.y, mod->m_Orient);
MODULE* newmod = new MODULE(mainpcb);
newmod->Copy(presmod); //this will copy the padstack layers etc
newmod->m_Parent = mainpcb; //modify after the copy above
newmod->m_Layer = mod->m_Layer;
newmod->m_Pos = mod->m_Pos;
newmod->m_Orient =0; //otherwise the pads will be rotated with respect to the module.
//copy data into the pads...
D_PAD* newpad = newmod->m_Pads;
for(; newpad != NULL; newpad = (D_PAD*)newpad->Pnext){
D_PAD* pad = mod->m_Pads;
for(; pad != NULL; pad = (D_PAD*)pad->Pnext){
if(pad->m_NumPadName == newpad->m_NumPadName){
wprintf(L" pad->NumPadName %d @ %d %d :new %d %d, orient: %d\n", pad->m_NumPadName,
pad->m_Pos.x, pad->m_Pos.y, newpad->m_Pos.x, newpad->m_Pos.y, pad->m_Orient);
wprintf(L" pad->m_Netname %S\n", pad->m_Netname.c_str());
newpad->m_Netname = pad->m_Netname;
newpad->m_NetCode = pad->m_NetCode;
newpad->m_logical_connexion = pad->m_logical_connexion;
newpad->m_physical_connexion = pad->m_physical_connexion;
newpad->m_Pos.x += newmod->m_Pos.x; //the pad positions are apparently in global coordinates.
newpad->m_Pos.y += newmod->m_Pos.y;
newpad->m_Orient = pad->m_Orient;
}
}
}
case ID_MODEDIT_SAVE_MODULE_IN_BOARD: //not sure what to do about m_Drawings..assume they are ok?
//copy only the text in m_Ref and m_Val;
//leave the size and position as in the module in edit.
newmod->m_Reference->m_Text = mod->m_Reference->m_Text;
newmod->m_Value->m_Text = mod->m_Value->m_Text;
wprintf(L"replace: mod->m_Reference = %S\n", newmod->m_Reference->m_Text.c_str());
wprintf(L"replace: mod->m_Value = %S\n", newmod->m_Value->m_Text.c_str());
newmod->m_Attributs = mod->m_Attributs;
newmod->m_Orient = mod->m_Orient;
newmod->flag = mod->flag;
newmod->m_Flags = 0; //inherited from EDA_BaseStruct.
newmod->m_ModuleStatus = mod->m_ModuleStatus;
//redo the boundary boxes
newmod->Set_Rectangle_Encadrement();
newmod->SetRectangleExinscrit();
newmod->m_CntRot90 = mod->m_CntRot90;
newmod->m_CntRot180 = mod->m_CntRot180;
newmod->m_Surface = mod->m_Surface;
pcbframe->Rotate_Module(NULL, newmod, mod->m_Orient, false);
//now, need to replace 'mod' in the linked list with 'newmod'.
//this does not seem to be working correctly..
MODULE* oldmod = mod;
mod = (MODULE*)mod->Pnext;
oldmod->UnLink();
delete oldmod;
//insert the new one.
newmod->Pnext = mainpcb->m_Modules;
mainpcb->m_Modules->Pback = newmod; // check this!
mainpcb->m_Modules = newmod;
newmod->Pback = mainpcb;
wprintf(L"-----\n");
}else{
mod = (MODULE*)mod->Pnext;
}
}while(mod != NULL);
GetScreen()->ClrModify();
pcbframe->GetScreen()->m_CurrentItem = NULL;
mainpcb->m_Status_Pcb = 0;
}
break;
/*case ID_MODEDIT_SAVE_MODULE_IN_BOARD:
{ {
WinEDA_PcbFrame * pcbframe = m_Parent->m_PcbFrame; WinEDA_PcbFrame * pcbframe = m_Parent->m_PcbFrame;
BOARD * mainpcb = pcbframe->m_Pcb; BOARD * mainpcb = pcbframe->m_Pcb;
MODULE * oldmodule = NULL; MODULE * oldmodule = NULL;
MODULE * module_in_edit = m_Pcb->m_Modules; MODULE * module_in_edit = m_Pcb->m_Modules;
// creation du nouveau module sur le PCB en cours // creation du nouveau module sur le PCB en cours
// create a new unit on the PCB, of course.
MODULE * newmodule = new MODULE(mainpcb); MODULE * newmodule = new MODULE(mainpcb);
newmodule->Copy(module_in_edit); newmodule->Copy(module_in_edit);
newmodule->m_Parent = mainpcb; // modifie par la copie newmodule->m_Parent = mainpcb; // modifie par la copie
newmodule->m_Link = 0; newmodule->m_Link = 0;
// Recherche de l'ancien module correspondant // Recherche de l'ancien module correspondant
//(qui a pu changer ou disparaitre a la suite d'ditions) //(qui a pu changer ou disparaitre a la suite d'�ditions)
//locate the corresponding former unit, which may have a different revision.
if ( module_in_edit->m_Link ) if ( module_in_edit->m_Link )
{ {
oldmodule = mainpcb->m_Modules; oldmodule = mainpcb->m_Modules;
...@@ -196,7 +280,7 @@ wxClientDC dc(DrawPanel); ...@@ -196,7 +280,7 @@ wxClientDC dc(DrawPanel);
pcbframe->GetScreen()->m_CurrentItem = NULL; pcbframe->GetScreen()->m_CurrentItem = NULL;
mainpcb->m_Status_Pcb = 0; mainpcb->m_Status_Pcb = 0;
} }
break; break;*/
case ID_LIBEDIT_IMPORT_PART: case ID_LIBEDIT_IMPORT_PART:
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
...@@ -224,19 +308,29 @@ wxClientDC dc(DrawPanel); ...@@ -224,19 +308,29 @@ wxClientDC dc(DrawPanel);
case ID_MODEDIT_SHEET_SET: case ID_MODEDIT_SHEET_SET:
break; break;
case ID_MODEDIT_LOAD_MODULE: case ID_MODEDIT_LOAD_MODULE:{
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
GetScreen()->m_CurrentItem = NULL; GetScreen()->m_CurrentItem = NULL;
Clear_Pcb(&dc, TRUE); Clear_Pcb(&dc, TRUE);
GetScreen()->m_Curseur = wxPoint(0,0); GetScreen()->m_Curseur = wxPoint(0,0);
Load_Module_From_Library(m_CurrentLib, &dc); Load_Module_From_Library(m_CurrentLib, &dc);
if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0;
//if either m_Reference or m_Value are gone, reinstate them -
//otherwise it becomes hard to see what you are working with in the layout!
TEXTE_MODULE* ref = m_Pcb->m_Modules->m_Reference;
TEXTE_MODULE* val = m_Pcb->m_Modules->m_Value;
ref->m_NoShow = 0;
val->m_NoShow = 0;
ref->m_Type = 0;
val->m_Type = 1;
if(ref->m_Text.Length() == 0) ref->m_Text = L"Ref**";
if(val->m_Text.Length() == 0) val->m_Text = L"Val**";
GetScreen()->ClrModify(); GetScreen()->ClrModify();
Zoom_Automatique(TRUE); Zoom_Automatique(TRUE);
if ( m_Draw3DFrame ) if ( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay(); m_Draw3DFrame->NewDisplay();
break; break;
}
case ID_MODEDIT_PAD_SETTINGS: case ID_MODEDIT_PAD_SETTINGS:
InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) ); InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) );
...@@ -509,10 +603,10 @@ wxClientDC dc(DrawPanel); ...@@ -509,10 +603,10 @@ wxClientDC dc(DrawPanel);
/******************************************************************************/ /******************************************************************************/
void WinEDA_ModuleEditFrame::Transform(MODULE* module, wxDC * DC, int transform) void WinEDA_ModuleEditFrame::Transform(MODULE* module, wxDC * DC, int transform)
/******************************************************************************/ /******************************************************************************/
/* Execute les transformations de la reprsentation des modules. /* Execute les transformations de la reprsentation des modules.
le module, apres transformation est toujours en position de reference: le module, apres transformation est toujours en position de reference:
position 0,0 position 0,0
orientation 0, cot composant. orientation 0, cot composant.
*/ */
{ {
D_PAD * pad = module->m_Pads; D_PAD * pad = module->m_Pads;
......
...@@ -70,11 +70,11 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar(void) ...@@ -70,11 +70,11 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar(void)
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString, m_HToolBar->AddTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
BITMAP(load_module_board_xpm), BITMAP(load_module_board_xpm),
_("Load module from current BOARD")); _("Load module from current board"));
m_HToolBar->AddTool(ID_MODEDIT_SAVE_MODULE_IN_BOARD, wxEmptyString, m_HToolBar->AddTool(ID_MODEDIT_SAVE_MODULE_IN_BOARD, wxEmptyString,
BITMAP(repl_module_board_xpm), BITMAP(repl_module_board_xpm),
_("Replace module in current BOARD")); _("Update module in current board"));
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_LIBEDIT_IMPORT_PART, wxEmptyString, m_HToolBar->AddTool(ID_LIBEDIT_IMPORT_PART, wxEmptyString,
......
...@@ -202,7 +202,7 @@ wxString title = _("Zone clearance value:") + ReturnUnitSymbol(g_UnitMetric); ...@@ -202,7 +202,7 @@ wxString title = _("Zone clearance value:") + ReturnUnitSymbol(g_UnitMetric);
if ( Zone_45_Only ) m_OrientEdgesOpt->SetSelection(1); if ( Zone_45_Only ) m_OrientEdgesOpt->SetSelection(1);
int GridList[4] = { 50,100,250,500}, selection = 0; int GridList[4] = { 50,100,250,500}, selection = 0;
for ( unsigned int ii = 0; ii < m_GridCtrl->GetCount(); ii++ ) for ( int ii = 0; ii < m_GridCtrl->GetCount(); ii++ )
{ {
wxString msg = ReturnStringFromValue(g_UnitMetric, GridList[ii], m_Parent->m_InternalUnits); wxString msg = ReturnStringFromValue(g_UnitMetric, GridList[ii], m_Parent->m_InternalUnits);
m_GridCtrl->SetString(ii,msg); m_GridCtrl->SetString(ii,msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment