Commit 7c3918da authored by Martin Janitschke's avatar Martin Janitschke Committed by Wayne Stambaugh

Pcbnew: fix global deletion bug and minor dialog changes. (fixes lp:1263795)

* Handle different item global deletions correctly.  No more removing of text
  if graphics is selected.
* Layer settings are always obeyed for modules, zones, text, and graphics.
* Text will be removed from copper layers if all layers are selected or
  according to the current layer.
* Added check boxes for "normal" and "locked" footprints to be consistent
  with the naming for the track deletion options.
parent 47e5026c
...@@ -27,9 +27,11 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent ) ...@@ -27,9 +27,11 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent )
m_TrackFilterLocked->Enable( m_DelTracks->GetValue() ); m_TrackFilterLocked->Enable( m_DelTracks->GetValue() );
m_TrackFilterNormal->Enable( m_DelTracks->GetValue() ); m_TrackFilterNormal->Enable( m_DelTracks->GetValue() );
m_TrackFilterVias->Enable( m_DelTracks->GetValue() ); m_TrackFilterVias->Enable( m_DelTracks->GetValue() );
m_ModuleFilterLocked->Enable( m_DelModules->GetValue() );
m_ModuleFilterNormal->Enable( m_DelModules->GetValue() );
SetFocus(); SetFocus();
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
Centre(); Centre();
} }
...@@ -42,12 +44,14 @@ void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) ...@@ -42,12 +44,14 @@ void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos )
dlg.ShowModal(); dlg.ShowModal();
} }
void DIALOG_GLOBAL_DELETION::SetCurrentLayer( LAYER_NUM aLayer ) void DIALOG_GLOBAL_DELETION::SetCurrentLayer( LAYER_NUM aLayer )
{ {
m_currentLayer = aLayer; m_currentLayer = aLayer;
m_textCtrlCurrLayer->SetValue( m_Parent->GetBoard()->GetLayerName( aLayer ) ); m_textCtrlCurrLayer->SetValue( m_Parent->GetBoard()->GetLayerName( aLayer ) );
} }
void DIALOG_GLOBAL_DELETION::OnCheckDeleteTracks( wxCommandEvent& event ) void DIALOG_GLOBAL_DELETION::OnCheckDeleteTracks( wxCommandEvent& event )
{ {
m_TrackFilterAR->Enable( m_DelTracks->GetValue() ); m_TrackFilterAR->Enable( m_DelTracks->GetValue() );
...@@ -56,6 +60,14 @@ void DIALOG_GLOBAL_DELETION::OnCheckDeleteTracks( wxCommandEvent& event ) ...@@ -56,6 +60,14 @@ void DIALOG_GLOBAL_DELETION::OnCheckDeleteTracks( wxCommandEvent& event )
m_TrackFilterVias->Enable( m_DelTracks->GetValue() ); m_TrackFilterVias->Enable( m_DelTracks->GetValue() );
} }
void DIALOG_GLOBAL_DELETION::OnCheckDeleteModules( wxCommandEvent& event )
{
m_ModuleFilterLocked->Enable( m_DelModules->GetValue() );
m_ModuleFilterNormal->Enable( m_DelModules->GetValue() );
}
void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
{ {
bool gen_rastnest = false; bool gen_rastnest = false;
...@@ -68,72 +80,102 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -68,72 +80,102 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
} }
else else
{ {
if( !IsOK( this, _( "OK to delete selected items ?" ) ) )
if( !IsOK( this, _( "Are you sure you want to delete the selected items?" ) ) )
return; return;
BOARD * pcb = m_Parent->GetBoard(); BOARD* pcb = m_Parent->GetBoard();
PICKED_ITEMS_LIST pickersList; PICKED_ITEMS_LIST pickersList;
ITEM_PICKER itemPicker( NULL, UR_DELETED ); ITEM_PICKER itemPicker( NULL, UR_DELETED );
BOARD_ITEM* item, * nextitem; BOARD_ITEM* item, * nextitem;
LAYER_MSK layers_filter = ALL_LAYERS;
if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only
layers_filter = GetLayerMask( m_currentLayer );
if( m_DelZones->GetValue() ) if( m_DelZones->GetValue() )
{ {
gen_rastnest = true; int area_index = 0;
item = pcb->GetArea( area_index );
/* SEG_ZONE items used in Zone filling selection are now deprecated : while( item != NULL )
* and are deleted but not put in undo buffer if exist
*/
pcb->m_Zone.DeleteAll();
while( pcb->GetAreaCount() )
{ {
item = pcb->GetArea( 0 );
itemPicker.SetItem( item ); if( GetLayerMask( item->GetLayer() ) & layers_filter )
pickersList.PushItem( itemPicker ); {
pcb->Remove( item ); itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
pcb->Remove( item );
gen_rastnest = true;
}
else
{
area_index++;
}
item = pcb->GetArea( area_index );
} }
} }
LAYER_MSK masque_layer = NO_LAYERS; if( m_DelDrawings->GetValue() || m_DelBoardEdges->GetValue() )
LAYER_MSK layers_filter = ALL_LAYERS; {
if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only LAYER_MSK masque_layer = NO_LAYERS;
layers_filter = GetLayerMask( m_currentLayer );
if( m_DelDrawings->GetValue() )
masque_layer = (~EDGE_LAYER) & ALL_NO_CU_LAYERS;
if( m_DelDrawings->GetValue() ) if( m_DelBoardEdges->GetValue() )
masque_layer = (~EDGE_LAYER) & ALL_NO_CU_LAYERS; masque_layer |= EDGE_LAYER;
if( m_DelBoardEdges->GetValue() ) masque_layer &= layers_filter;
masque_layer |= EDGE_LAYER;
layers_filter &= layers_filter; for( item = pcb->m_Drawings; item != NULL; item = nextitem )
{
nextitem = item->Next();
for( item = pcb->m_Drawings; item != NULL; item = nextitem ) if( ( item->Type() == PCB_LINE_T ) && ( GetLayerMask( item->GetLayer() ) & masque_layer) )
{ {
nextitem = item->Next(); itemPicker.SetItem( item );
bool removeme = GetLayerMask( item->GetLayer() ) & masque_layer; pickersList.PushItem( itemPicker );
item->UnLink();
}
}
}
if( ( item->Type() == PCB_TEXT_T ) && m_DelTexts->GetValue() ) if( m_DelTexts->GetValue() )
removeme = true; {
LAYER_MSK del_text_layers = ALL_LAYERS & layers_filter;
if( removeme ) for( item = pcb->m_Drawings; item != NULL; item = nextitem )
{ {
itemPicker.SetItem( item ); nextitem = item->Next();
pickersList.PushItem( itemPicker );
item->UnLink(); if( ( item->Type() == PCB_TEXT_T ) && ( GetLayerMask( item->GetLayer() ) & del_text_layers ) )
{
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
item->UnLink();
}
} }
} }
if( m_DelModules->GetValue() ) if( m_DelModules->GetValue() )
{ {
gen_rastnest = true;
for( item = pcb->m_Modules; item; item = nextitem ) for( item = pcb->m_Modules; item; item = nextitem )
{ {
nextitem = item->Next(); nextitem = item->Next();
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker ); if( ( GetLayerMask( item->GetLayer() ) & layers_filter ) &&
item->UnLink(); ( ( m_ModuleFilterNormal->GetValue() && !item->IsLocked() ) ||
( m_ModuleFilterLocked->GetValue() && item->IsLocked() ) ) )
{
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
item->UnLink();
gen_rastnest = true;
}
} }
} }
...@@ -148,6 +190,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -148,6 +190,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
track_mask_filter |= TRACK_AR; track_mask_filter |= TRACK_AR;
TRACK * nexttrack; TRACK * nexttrack;
for( TRACK *track = pcb->m_Track; track != NULL; track = nexttrack ) for( TRACK *track = pcb->m_Track; track != NULL; track = nexttrack )
{ {
nexttrack = track->Next(); nexttrack = track->Next();
...@@ -180,6 +223,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -180,6 +223,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
if( gen_rastnest ) if( gen_rastnest )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
} }
m_Parent->GetCanvas()->Refresh(); m_Parent->GetCanvas()->Refresh();
...@@ -187,4 +231,3 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -187,4 +231,3 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
EndModal( 1 ); EndModal( 1 );
} }
...@@ -30,6 +30,7 @@ private: ...@@ -30,6 +30,7 @@ private:
void AcceptPcbDelete(); void AcceptPcbDelete();
void OnCheckDeleteTracks( wxCommandEvent& event ); void OnCheckDeleteTracks( wxCommandEvent& event );
void OnCheckDeleteModules( wxCommandEvent& event );
}; };
#endif // _DIALOG_GLOBAL_DELETION_H_ #endif // _DIALOG_GLOBAL_DELETION_H_
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Feb 26 2014)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -52,25 +52,32 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi ...@@ -52,25 +52,32 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
wxBoxSizer* bSizerRight; wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL ); bSizerRight = new wxBoxSizer( wxVERTICAL );
sbTrackFilter = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Track Filter") ), wxVERTICAL ); sbFilter = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Filter Settings") ), wxVERTICAL );
m_TrackFilterAR = new wxCheckBox( this, wxID_ANY, _("Automatically routed tracks"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackFilterAR = new wxCheckBox( this, wxID_ANY, _("Automatically routed tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterAR->SetValue(true); m_TrackFilterAR->SetValue(true);
sbTrackFilter->Add( m_TrackFilterAR, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbFilter->Add( m_TrackFilterAR, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TrackFilterLocked = new wxCheckBox( this, wxID_ANY, _("Locked tracks"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackFilterLocked = new wxCheckBox( this, wxID_ANY, _("Locked tracks"), wxDefaultPosition, wxDefaultSize, 0 );
sbTrackFilter->Add( m_TrackFilterLocked, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbFilter->Add( m_TrackFilterLocked, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TrackFilterNormal = new wxCheckBox( this, wxID_ANY, _("Normal tracks"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackFilterNormal = new wxCheckBox( this, wxID_ANY, _("Unlocked tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterNormal->SetValue(true); m_TrackFilterNormal->SetValue(true);
sbTrackFilter->Add( m_TrackFilterNormal, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbFilter->Add( m_TrackFilterNormal, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TrackFilterVias = new wxCheckBox( this, wxID_ANY, _("Vias"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackFilterVias = new wxCheckBox( this, wxID_ANY, _("Vias"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterVias->SetValue(true); m_TrackFilterVias->SetValue(true);
sbTrackFilter->Add( m_TrackFilterVias, 0, wxALL, 5 ); sbFilter->Add( m_TrackFilterVias, 0, wxALL, 5 );
m_ModuleFilterLocked = new wxCheckBox( this, wxID_ANY, _("Locked footprints"), wxDefaultPosition, wxDefaultSize, 0 );
sbFilter->Add( m_ModuleFilterLocked, 0, wxALL, 5 );
bSizerRight->Add( sbTrackFilter, 0, wxALL|wxEXPAND, 5 ); m_ModuleFilterNormal = new wxCheckBox( this, wxID_ANY, _("Unlocked footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_ModuleFilterNormal->SetValue(true);
sbFilter->Add( m_ModuleFilterNormal, 0, wxALL, 5 );
bSizerRight->Add( sbFilter, 0, wxALL|wxEXPAND, 5 );
wxString m_rbLayersOptionChoices[] = { _("All layers"), _("Current layer only") }; wxString m_rbLayersOptionChoices[] = { _("All layers"), _("Current layer only") };
int m_rbLayersOptionNChoices = sizeof( m_rbLayersOptionChoices ) / sizeof( wxString ); int m_rbLayersOptionNChoices = sizeof( m_rbLayersOptionChoices ) / sizeof( wxString );
...@@ -112,6 +119,7 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi ...@@ -112,6 +119,7 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events // Connect Events
m_DelModules->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCheckDeleteModules ), NULL, this );
m_DelTracks->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCheckDeleteTracks ), NULL, this ); m_DelTracks->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCheckDeleteTracks ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnOkClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnOkClick ), NULL, this );
...@@ -120,6 +128,7 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi ...@@ -120,6 +128,7 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE() DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE()
{ {
// Disconnect Events // Disconnect Events
m_DelModules->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCheckDeleteModules ), NULL, this );
m_DelTracks->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCheckDeleteTracks ), NULL, this ); m_DelTracks->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCheckDeleteTracks ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnOkClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnOkClick ), NULL, this );
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Feb 26 2014)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -48,11 +48,13 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM ...@@ -48,11 +48,13 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM
wxCheckBox* m_DelTracks; wxCheckBox* m_DelTracks;
wxCheckBox* m_DelMarkers; wxCheckBox* m_DelMarkers;
wxCheckBox* m_DelAlls; wxCheckBox* m_DelAlls;
wxStaticBoxSizer* sbTrackFilter; wxStaticBoxSizer* sbFilter;
wxCheckBox* m_TrackFilterAR; wxCheckBox* m_TrackFilterAR;
wxCheckBox* m_TrackFilterLocked; wxCheckBox* m_TrackFilterLocked;
wxCheckBox* m_TrackFilterNormal; wxCheckBox* m_TrackFilterNormal;
wxCheckBox* m_TrackFilterVias; wxCheckBox* m_TrackFilterVias;
wxCheckBox* m_ModuleFilterLocked;
wxCheckBox* m_ModuleFilterNormal;
wxRadioBox* m_rbLayersOption; wxRadioBox* m_rbLayersOption;
wxStaticText* m_staticText1; wxStaticText* m_staticText1;
wxTextCtrl* m_textCtrlCurrLayer; wxTextCtrl* m_textCtrlCurrLayer;
...@@ -62,6 +64,7 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM ...@@ -62,6 +64,7 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM
wxButton* m_sdbSizer1Cancel; wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCheckDeleteModules( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCheckDeleteTracks( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckDeleteTracks( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
......
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