Commit 5916688f authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Fix error message in Module Editor after a global pad change.

Minor other enhancements and code cleaning.
parent 8985a180
This diff is collapsed.
This diff is collapsed.
...@@ -325,7 +325,26 @@ public: ...@@ -325,7 +325,26 @@ public:
void PlacePad( D_PAD* Pad, wxDC* DC ); void PlacePad( D_PAD* Pad, wxDC* DC );
void Export_Pad_Settings( D_PAD* aPad ); void Export_Pad_Settings( D_PAD* aPad );
void Import_Pad_Settings( D_PAD* aPad, bool aDraw ); void Import_Pad_Settings( D_PAD* aPad, bool aDraw );
void Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw );
/**
* Function GlobalChange_PadSettings
* Function to change pad caracteristics for the given footprint
* or all footprints which look like the given footprint
* @param aPad is the pattern. The given footprint is the parent of this pad
* @param aSameFootprints: if true, make changes on all identical footprints
* @param aPadShapeFilter: if true, make changes only on pads having the same shape as aPad
* @param aPadOrientFilter: if true, make changes only on pads having the same orientation as aPad
* @param aPadLayerFilter: if true, make changes only on pads having the same layers as aPad
* @param aRedraw: if true: redraws the footprint
* @param aSaveForUndo: if true: create an entry in the Undo/Redo list
* (usually: true in Schematic editor, false in Module editor)
*/
void GlobalChange_PadSettings( D_PAD* aPad,
bool aSameFootprints,
bool aPadShapeFilter,
bool aPadOrientFilter,
bool aPadLayerFilter,
bool aRedraw, bool aSaveForUndo );
// loading footprints // loading footprints
......
...@@ -877,6 +877,16 @@ public: ...@@ -877,6 +877,16 @@ public:
void InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ); void InstallModuleOptionsFrame( MODULE* Module, wxDC* DC );
void StartMove_Module( MODULE* module, wxDC* DC ); void StartMove_Module( MODULE* module, wxDC* DC );
/**
* Function DlgGlobalChange_PadSettings
* Function to change pad caracteristics for the given footprint
* or all footprints which look like the given footprint
* Options are set by the opened dialog.
* @param aPad is the pattern. The given footprint is the parent of this pad
* @param aRedraw: if true: redraws the footprint
*/
void DlgGlobalChange_PadSettings( D_PAD* aPad, bool aRedraw );
/** /**
* Function Delete Module * Function Delete Module
* Remove a footprint from m_Modules linked list and put it in undelete buffer * Remove a footprint from m_Modules linked list and put it in undelete buffer
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Jun 30 2011)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_global_pads_edition_base.h" #include "dialog_global_pads_edition_base.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_GLOBAL_PADS_EDITION_BASE::DIALOG_GLOBAL_PADS_EDITION_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) DIALOG_GLOBAL_PADS_EDITION_BASE::DIALOG_GLOBAL_PADS_EDITION_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{ {
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer; wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxHORIZONTAL ); bMainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bLeftSizer; wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL ); bLeftSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizer1; wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pad Filter :") ), wxVERTICAL ); sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pad Filter :") ), wxVERTICAL );
m_Pad_Shape_Filter_CB = new wxCheckBox( this, wxID_ANY, _("Do not modify pads having a different shape"), wxDefaultPosition, wxDefaultSize, 0 ); m_Pad_Shape_Filter_CB = new wxCheckBox( this, wxID_ANY, _("Do not modify pads having a different shape"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer1->Add( m_Pad_Shape_Filter_CB, 0, wxALL, 5 );
sbSizer1->Add( m_Pad_Shape_Filter_CB, 0, wxALL, 5 );
m_Pad_Layer_Filter_CB = new wxCheckBox( this, wxID_ANY, _("Do not modify pads having different layers"), wxDefaultPosition, wxDefaultSize, 0 );
m_Pad_Layer_Filter_CB = new wxCheckBox( this, wxID_ANY, _("Do not modify pads having different layers"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer1->Add( m_Pad_Layer_Filter_CB, 0, wxALL, 5 );
sbSizer1->Add( m_Pad_Layer_Filter_CB, 0, wxALL, 5 ); m_Pad_Orient_Filter_CB = new wxCheckBox( this, wxID_ANY, _("Do not modify pads having a different orientation"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer1->Add( m_Pad_Orient_Filter_CB, 0, wxALL, 5 );
m_Pad_Orient_Filter_CB = new wxCheckBox( this, wxID_ANY, _("Do not modify pads having a different orientation"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftSizer->Add( sbSizer1, 1, wxEXPAND, 5 );
sbSizer1->Add( m_Pad_Orient_Filter_CB, 0, wxALL, 5 );
bMainSizer->Add( bLeftSizer, 1, wxEXPAND, 5 );
bLeftSizer->Add( sbSizer1, 1, wxEXPAND, 5 );
wxBoxSizer* bRightSizer;
bMainSizer->Add( bLeftSizer, 1, wxEXPAND, 5 ); bRightSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bRightSizer; m_buttonPadEditor = new wxButton( this, ID_CHANGE_GET_PAD_SETTINGS, _("Pad Editor"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer = new wxBoxSizer( wxVERTICAL ); bRightSizer->Add( m_buttonPadEditor, 0, wxALL|wxEXPAND, 5 );
m_buttonPadEditor = new wxButton( this, ID_CHANGE_GET_PAD_SETTINGS, _("Pad Editor"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonPadEditor, 0, wxALL|wxEXPAND, 5 ); bRightSizer->Add( 10, 10, 0, 0, 5 );
m_buttonChangeModule = new wxButton( this, ID_CHANGE_CURRENT_MODULE, _("Change Pads on Module"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( 10, 10, 0, 0, 5 ); bRightSizer->Add( m_buttonChangeModule, 0, wxALL|wxEXPAND, 5 );
m_button2 = new wxButton( this, ID_CHANGE_CURRENT_MODULE, _("Change Pads on Module"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonIdModules = new wxButton( this, ID_CHANGE_ID_MODULES, _("Change Pads on Same Modules"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_button2, 0, wxALL|wxEXPAND, 5 ); bRightSizer->Add( m_buttonIdModules, 0, wxALL|wxEXPAND, 5 );
m_button3 = new wxButton( this, ID_CHANGE_ID_MODULES, _("Change Pads on Same Modules"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonCancel = new wxButton( this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_button3, 0, wxALL|wxEXPAND, 5 ); bRightSizer->Add( m_buttonCancel, 0, wxALL|wxEXPAND, 5 );
m_button4 = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); bMainSizer->Add( bRightSizer, 0, wxEXPAND, 5 );
bRightSizer->Add( m_button4, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
bMainSizer->Add( bRightSizer, 0, wxEXPAND, 5 ); this->Layout();
this->SetSizer( bMainSizer ); // Connect Events
this->Layout(); m_buttonPadEditor->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::InstallPadEditor ), NULL, this );
m_buttonChangeModule->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this );
// Connect Events m_buttonIdModules->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this );
m_buttonPadEditor->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::InstallPadEditor ), NULL, this ); m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::OnCancelClick ), NULL, this );
m_button2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this ); }
m_button3->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this );
m_button4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::OnCancelClick ), NULL, this ); DIALOG_GLOBAL_PADS_EDITION_BASE::~DIALOG_GLOBAL_PADS_EDITION_BASE()
} {
// Disconnect Events
DIALOG_GLOBAL_PADS_EDITION_BASE::~DIALOG_GLOBAL_PADS_EDITION_BASE() m_buttonPadEditor->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::InstallPadEditor ), NULL, this );
{ m_buttonChangeModule->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this );
// Disconnect Events m_buttonIdModules->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this );
m_buttonPadEditor->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::InstallPadEditor ), NULL, this ); m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::OnCancelClick ), NULL, this );
m_button2->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this );
m_button3->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this ); }
m_button4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::OnCancelClick ), NULL, this );
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Jun 30 2011)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_global_pads_edition_base__ #ifndef __DIALOG_GLOBAL_PADS_EDITION_BASE_H__
#define __dialog_global_pads_edition_base__ #define __DIALOG_GLOBAL_PADS_EDITION_BASE_H__
#include <wx/string.h> #include <wx/artprov.h>
#include <wx/checkbox.h> #include <wx/xrc/xmlres.h>
#include <wx/gdicmn.h> #include <wx/intl.h>
#include <wx/font.h> #include <wx/string.h>
#include <wx/colour.h> #include <wx/checkbox.h>
#include <wx/settings.h> #include <wx/gdicmn.h>
#include <wx/sizer.h> #include <wx/font.h>
#include <wx/statbox.h> #include <wx/colour.h>
#include <wx/button.h> #include <wx/settings.h>
#include <wx/dialog.h> #include <wx/sizer.h>
#include <wx/statbox.h>
/////////////////////////////////////////////////////////////////////////// #include <wx/button.h>
#include <wx/dialog.h>
#define ID_CHANGE_GET_PAD_SETTINGS 1000
#define ID_CHANGE_CURRENT_MODULE 1001 ///////////////////////////////////////////////////////////////////////////
#define ID_CHANGE_ID_MODULES 1002
#define ID_CHANGE_GET_PAD_SETTINGS 1000
/////////////////////////////////////////////////////////////////////////////// #define ID_CHANGE_CURRENT_MODULE 1001
/// Class DIALOG_GLOBAL_PADS_EDITION_BASE #define ID_CHANGE_ID_MODULES 1002
///////////////////////////////////////////////////////////////////////////////
class DIALOG_GLOBAL_PADS_EDITION_BASE : public wxDialog ///////////////////////////////////////////////////////////////////////////////
{ /// Class DIALOG_GLOBAL_PADS_EDITION_BASE
private: ///////////////////////////////////////////////////////////////////////////////
class DIALOG_GLOBAL_PADS_EDITION_BASE : public wxDialog
protected: {
wxCheckBox* m_Pad_Shape_Filter_CB; private:
wxCheckBox* m_Pad_Layer_Filter_CB;
wxCheckBox* m_Pad_Orient_Filter_CB; protected:
wxButton* m_buttonPadEditor; wxCheckBox* m_Pad_Shape_Filter_CB;
wxCheckBox* m_Pad_Layer_Filter_CB;
wxButton* m_button2; wxCheckBox* m_Pad_Orient_Filter_CB;
wxButton* m_button3; wxButton* m_buttonPadEditor;
wxButton* m_button4; wxButton* m_buttonChangeModule;
wxButton* m_buttonCancel;
// Virtual event handlers, overide them in your derived class
virtual void InstallPadEditor( wxCommandEvent& event ){ event.Skip(); } // Virtual event handlers, overide them in your derived class
virtual void PadPropertiesAccept( wxCommandEvent& event ){ event.Skip(); } virtual void InstallPadEditor( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } virtual void PadPropertiesAccept( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_GLOBAL_PADS_EDITION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _( "Global Pads Edition" ), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 482,165 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); public:
~DIALOG_GLOBAL_PADS_EDITION_BASE(); wxButton* m_buttonIdModules;
}; DIALOG_GLOBAL_PADS_EDITION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Global Pads Edition"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 482,165 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_GLOBAL_PADS_EDITION_BASE();
#endif //__dialog_global_pads_edition_base__
};
#endif //__DIALOG_GLOBAL_PADS_EDITION_BASE_H__
...@@ -813,7 +813,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -813,7 +813,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Global_Import_Pad_Settings( (D_PAD*) GetCurItem(), true ); DlgGlobalChange_PadSettings( (D_PAD*) GetCurItem(), true );
break; break;
case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "wxBasePcbFrame.h" #include "wxPcbStruct.h"
#include "pcbcommon.h" #include "pcbcommon.h"
#include "module_editor_frame.h"
#include "class_board.h" #include "class_board.h"
#include "class_module.h" #include "class_module.h"
...@@ -105,24 +106,22 @@ void DIALOG_GLOBAL_PADS_EDITION::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -105,24 +106,22 @@ void DIALOG_GLOBAL_PADS_EDITION::PadPropertiesAccept( wxCommandEvent& event )
} }
/** /*
* Function Global_Import_Pad_Settings * PCB_EDIT_FRAME::Function DlgGlobalChange_PadSettings
* Function to change pad caracteristics for the given footprint * Function to change pad caracteristics for the given footprint
* or alls footprints which look like the given footprint * or alls footprints which look like the given footprint
* @param aPad pad to use as pattern. The given footprint is the parent of * Options are set by the opened dialog.
* this pad * aPad is the pattern. The given footprint is the parent of this pad
* @param aDraw: if true: redraws the footprint * aRedraw: if true: redraws the footprint
*/ */
void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) void PCB_EDIT_FRAME::DlgGlobalChange_PadSettings( D_PAD* aPad, bool aRedraw )
{ {
MODULE* Module_Ref, * Module;
int diag; int diag;
bool edit_Same_Modules = false;
if( aPad == NULL ) if( aPad == NULL )
aPad = &g_Pad_Master; aPad = &g_Pad_Master;
Module = (MODULE*) aPad->GetParent(); MODULE* Module = (MODULE*) aPad->GetParent();
if( Module == NULL ) if( Module == NULL )
{ {
...@@ -140,88 +139,172 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -140,88 +139,172 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( diag == -1 ) if( diag == -1 )
return; return;
bool edit_Same_Modules = false;
if( diag == 1 ) if( diag == 1 )
edit_Same_Modules = true; edit_Same_Modules = true;
/* Search and copy the name of library reference. */ GlobalChange_PadSettings( aPad,edit_Same_Modules,
Module_Ref = Module; DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter,
int pad_orient = aPad->m_Orient - Module_Ref->m_Orient; DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter,
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter,
aRedraw, true );
}
// Prepare an undo list: /*
PICKED_ITEMS_LIST itemsList; * FOOTPRINT_EDIT_FRAME::Function DlgGlobalChange_PadSettings
Module = (MODULE*) m_Pcb->m_Modules; * Function to change pad caracteristics for the given footprint
for( ; Module != NULL; Module = Module->Next() ) * or alls footprints which look like the given footprint
* Options are set by the opened dialog.
* aPad is the pattern. The given footprint is the parent of this pad
*/
void FOOTPRINT_EDIT_FRAME::DlgGlobalChange_PadSettings( D_PAD* aPad )
{
int diag;
if( aPad == NULL )
aPad = &g_Pad_Master;
MODULE* Module = (MODULE*) aPad->GetParent();
if( Module == NULL )
{ {
if( !edit_Same_Modules && (Module != Module_Ref) ) DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
continue; return;
}
if( Module->m_LibRef != Module_Ref->m_LibRef ) Module->DisplayInfo( this );
continue;
bool saveMe = false; DIALOG_GLOBAL_PADS_EDITION* dlg = new DIALOG_GLOBAL_PADS_EDITION( this, aPad );
D_PAD* pt_pad = (D_PAD*) Module->m_Pads; dlg->m_buttonIdModules->Enable( false );
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) diag = dlg->ShowModal();
dlg->Destroy();
if( diag == -1 )
return;
bool edit_Same_Modules = false;
if( diag == 1 )
edit_Same_Modules = true;
GlobalChange_PadSettings( aPad,edit_Same_Modules,
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter,
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter,
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter,
true, false );
}
/*
* Function GlobalChange_PadSettings
* Function to change pad caracteristics for the given footprint
* or alls footprints which look like the given footprint
* aPad is the pattern. The given footprint is the parent of this pad
* aSameFootprints: if true, make changes on all identical footprints
* aPadShapeFilter: if true, make changes only on pads having the same shape as aPad
* aPadOrientFilter: if true, make changes only on pads having the same orientation as aPad
* aPadLayerFilter: if true, make changes only on pads having the same layers as aPad
* aRedraw: if true: redraws the footprint
* aSaveForUndo: if true: create an entry in the Undo/Redo list
* (usually: true in Schematic editor, false in Module editor)
*/
void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
bool aSameFootprints,
bool aPadShapeFilter,
bool aPadOrientFilter,
bool aPadLayerFilter,
bool aRedraw, bool aSaveForUndo )
{
if( aPad == NULL )
aPad = &g_Pad_Master;
MODULE* Module = (MODULE*) aPad->GetParent();
if( Module == NULL )
{
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
return;
}
/* Search and copy the name of library reference. */
MODULE* Module_Ref = Module;
int pad_orient = aPad->m_Orient - Module_Ref->m_Orient;
// Prepare an undo list:
if( aSaveForUndo )
{
PICKED_ITEMS_LIST itemsList;
Module = (MODULE*) m_Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{ {
/* Filters changes prohibited. */ if( !aSameFootprints && (Module != Module_Ref) )
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter
&& ( pt_pad->m_PadShape != aPad->m_PadShape ) )
continue; continue;
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter if( Module->m_LibRef != Module_Ref->m_LibRef )
&& ( (pt_pad->m_Orient - Module->m_Orient) != pad_orient ) )
continue; continue;
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter bool saveMe = false;
&& ( pt_pad->m_layerMask != aPad->m_layerMask ) ) D_PAD* pt_pad = (D_PAD*) Module->m_Pads;
continue;
saveMe = true; for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
} {
/* Filters changes prohibited. */
if( aPadShapeFilter && ( pt_pad->m_PadShape != aPad->m_PadShape ) )
continue;
if( saveMe ) int currpad_orient = pt_pad->m_Orient - Module->m_Orient;
{ if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
ITEM_PICKER itemWrapper( Module, UR_CHANGED ); continue;
itemWrapper.m_PickedItemType = Module->Type();
itemsList.PushItem( itemWrapper ); if( aPadLayerFilter
&& ( pt_pad->m_layerMask != aPad->m_layerMask ) )
continue;
saveMe = true;
}
if( saveMe )
{
ITEM_PICKER itemWrapper( Module, UR_CHANGED );
itemWrapper.m_PickedItemType = Module->Type();
itemsList.PushItem( itemWrapper );
}
} }
}
SaveCopyInUndoList( itemsList, UR_CHANGED ); SaveCopyInUndoList( itemsList, UR_CHANGED );
}
/* Update the current module and same others modules if requested. */ /* Update the current module and same others modules if requested. */
Module = (MODULE*) m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
{ {
if( !edit_Same_Modules && (Module != Module_Ref) ) if( !aSameFootprints && (Module != Module_Ref) )
continue; continue;
if( Module->m_LibRef != Module_Ref->m_LibRef ) if( Module->m_LibRef != Module_Ref->m_LibRef )
continue; continue;
/* Erase module on screen */ /* Erase module on screen */
if( aDraw ) if( aRedraw )
{ {
Module->SetFlags( DO_NOT_DRAW ); Module->SetFlags( DO_NOT_DRAW );
m_canvas->RefreshDrawingRect( Module->GetBoundingBox() ); m_canvas->RefreshDrawingRect( Module->GetBoundingBox() );
Module->ClearFlags( DO_NOT_DRAW ); Module->ClearFlags( DO_NOT_DRAW );
} }
D_PAD* pt_pad = (D_PAD*) Module->m_Pads; D_PAD* pt_pad = Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{ {
/* Filters changes prohibited. */ // Filters changes prohibited.
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter if( aPadShapeFilter && ( pt_pad->m_PadShape != aPad->m_PadShape ) )
&& ( pt_pad->m_PadShape != aPad->m_PadShape ) )
continue; continue;
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter if( aPadOrientFilter
&& ( (pt_pad->m_Orient - Module->m_Orient) != pad_orient ) ) && ( (pt_pad->m_Orient - Module->m_Orient) != pad_orient ) )
continue; continue;
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter ) if( aPadLayerFilter )
{ {
if( pt_pad->m_layerMask != aPad->m_layerMask ) if( pt_pad->m_layerMask != aPad->m_layerMask )
continue; continue;
...@@ -229,7 +312,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -229,7 +312,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK); m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK);
} }
/* Change characteristics.: */ // Change characteristics:
pt_pad->m_Attribut = aPad->m_Attribut; pt_pad->m_Attribut = aPad->m_Attribut;
pt_pad->m_PadShape = aPad->m_PadShape; pt_pad->m_PadShape = aPad->m_PadShape;
...@@ -278,7 +361,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -278,7 +361,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->CalculateBoundingBox(); Module->CalculateBoundingBox();
if( aDraw ) if( aRedraw )
m_canvas->RefreshDrawingRect( Module->GetBoundingBox() ); m_canvas->RefreshDrawingRect( Module->GetBoundingBox() );
} }
......
...@@ -512,7 +512,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -512,7 +512,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Global_Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true ); // Calls the global change dialog:
DlgGlobalChange_PadSettings( (D_PAD*) GetScreen()->GetCurItem() );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
break; break;
......
...@@ -334,6 +334,15 @@ public: ...@@ -334,6 +334,15 @@ public:
/* Function to place a graphic item type EDGE_MODULE currently moved */ /* Function to place a graphic item type EDGE_MODULE currently moved */
void Place_EdgeMod( EDGE_MODULE* drawitem ); void Place_EdgeMod( EDGE_MODULE* drawitem );
/**
* Function DlgGlobalChange_PadSettings
* Function to change pad caracteristics for the given footprint
* or all footprints which look like the given footprint
* Options are set by the opened dialog.
* @param aPad is the pattern. The given footprint is the parent of this pad
*/
void DlgGlobalChange_PadSettings( D_PAD* aPad );
// handlers for libraries: // handlers for libraries:
void Delete_Module_In_Library( const wxString& libname ); void Delete_Module_In_Library( const wxString& libname );
......
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