diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index cce6a7b4b5..69eec16422 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -27,9 +27,11 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent ) m_TrackFilterLocked->Enable( m_DelTracks->GetValue() ); m_TrackFilterNormal->Enable( m_DelTracks->GetValue() ); m_TrackFilterVias->Enable( m_DelTracks->GetValue() ); + m_ModuleFilterLocked->Enable( m_DelModules->GetValue() ); + m_ModuleFilterNormal->Enable( m_DelModules->GetValue() ); SetFocus(); - GetSizer()->SetSizeHints(this); + GetSizer()->SetSizeHints( this ); Centre(); } @@ -42,12 +44,14 @@ void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) dlg.ShowModal(); } + void DIALOG_GLOBAL_DELETION::SetCurrentLayer( LAYER_NUM aLayer ) { m_currentLayer = aLayer; m_textCtrlCurrLayer->SetValue( m_Parent->GetBoard()->GetLayerName( aLayer ) ); } + void DIALOG_GLOBAL_DELETION::OnCheckDeleteTracks( wxCommandEvent& event ) { m_TrackFilterAR->Enable( m_DelTracks->GetValue() ); @@ -56,6 +60,14 @@ void DIALOG_GLOBAL_DELETION::OnCheckDeleteTracks( wxCommandEvent& event ) 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( ) { bool gen_rastnest = false; @@ -68,72 +80,102 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) } else { - if( !IsOK( this, _( "OK to delete selected items ?" ) ) ) + + if( !IsOK( this, _( "Are you sure you want to delete the selected items?" ) ) ) return; - BOARD * pcb = m_Parent->GetBoard(); + BOARD* pcb = m_Parent->GetBoard(); PICKED_ITEMS_LIST pickersList; ITEM_PICKER itemPicker( NULL, UR_DELETED ); BOARD_ITEM* item, * nextitem; - if( m_DelZones->GetValue() ) - { - gen_rastnest = true; - - /* SEG_ZONE items used in Zone filling selection are now deprecated : - * 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 ); - pickersList.PushItem( itemPicker ); - pcb->Remove( item ); - } - } - - LAYER_MSK masque_layer = NO_LAYERS; LAYER_MSK layers_filter = ALL_LAYERS; + if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only layers_filter = GetLayerMask( m_currentLayer ); - - if( m_DelDrawings->GetValue() ) - masque_layer = (~EDGE_LAYER) & ALL_NO_CU_LAYERS; - - if( m_DelBoardEdges->GetValue() ) - masque_layer |= EDGE_LAYER; - - layers_filter &= layers_filter; - - for( item = pcb->m_Drawings; item != NULL; item = nextitem ) + if( m_DelZones->GetValue() ) { - nextitem = item->Next(); - bool removeme = GetLayerMask( item->GetLayer() ) & masque_layer; + int area_index = 0; + item = pcb->GetArea( area_index ); - if( ( item->Type() == PCB_TEXT_T ) && m_DelTexts->GetValue() ) - removeme = true; - - if( removeme ) + while( item != NULL ) { - itemPicker.SetItem( item ); - pickersList.PushItem( itemPicker ); - item->UnLink(); + + if( GetLayerMask( item->GetLayer() ) & layers_filter ) + { + itemPicker.SetItem( item ); + pickersList.PushItem( itemPicker ); + pcb->Remove( item ); + gen_rastnest = true; + } + else + { + area_index++; + } + + item = pcb->GetArea( area_index ); + } + } + + if( m_DelDrawings->GetValue() || m_DelBoardEdges->GetValue() ) + { + LAYER_MSK masque_layer = NO_LAYERS; + + if( m_DelDrawings->GetValue() ) + masque_layer = (~EDGE_LAYER) & ALL_NO_CU_LAYERS; + + if( m_DelBoardEdges->GetValue() ) + masque_layer |= EDGE_LAYER; + + masque_layer &= layers_filter; + + for( item = pcb->m_Drawings; item != NULL; item = nextitem ) + { + nextitem = item->Next(); + + if( ( item->Type() == PCB_LINE_T ) && ( GetLayerMask( item->GetLayer() ) & masque_layer) ) + { + itemPicker.SetItem( item ); + pickersList.PushItem( itemPicker ); + item->UnLink(); + } + } + } + + if( m_DelTexts->GetValue() ) + { + LAYER_MSK del_text_layers = ALL_LAYERS & layers_filter; + + for( item = pcb->m_Drawings; item != NULL; item = nextitem ) + { + nextitem = item->Next(); + + if( ( item->Type() == PCB_TEXT_T ) && ( GetLayerMask( item->GetLayer() ) & del_text_layers ) ) + { + itemPicker.SetItem( item ); + pickersList.PushItem( itemPicker ); + item->UnLink(); + } } } if( m_DelModules->GetValue() ) { - gen_rastnest = true; for( item = pcb->m_Modules; item; item = nextitem ) { nextitem = item->Next(); - itemPicker.SetItem( item ); - pickersList.PushItem( itemPicker ); - item->UnLink(); + + if( ( GetLayerMask( item->GetLayer() ) & layers_filter ) && + ( ( 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( ) track_mask_filter |= TRACK_AR; TRACK * nexttrack; + for( TRACK *track = pcb->m_Track; track != NULL; track = nexttrack ) { nexttrack = track->Next(); @@ -180,6 +223,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) if( gen_rastnest ) m_Parent->Compile_Ratsnest( NULL, true ); + } m_Parent->GetCanvas()->Refresh(); @@ -187,4 +231,3 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) EndModal( 1 ); } - diff --git a/pcbnew/dialogs/dialog_global_deletion.h b/pcbnew/dialogs/dialog_global_deletion.h index 1983409708..4742a9ea04 100644 --- a/pcbnew/dialogs/dialog_global_deletion.h +++ b/pcbnew/dialogs/dialog_global_deletion.h @@ -30,6 +30,7 @@ private: void AcceptPcbDelete(); void OnCheckDeleteTracks( wxCommandEvent& event ); + void OnCheckDeleteModules( wxCommandEvent& event ); }; #endif // _DIALOG_GLOBAL_DELETION_H_ diff --git a/pcbnew/dialogs/dialog_global_deletion_base.cpp b/pcbnew/dialogs/dialog_global_deletion_base.cpp index 29317e86d0..b56bae82e5 100644 --- a/pcbnew/dialogs/dialog_global_deletion_base.cpp +++ b/pcbnew/dialogs/dialog_global_deletion_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Feb 26 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -52,25 +52,32 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi wxBoxSizer* bSizerRight; 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->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 ); - 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); - 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->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 ); + + 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( sbTrackFilter, 0, wxALL|wxEXPAND, 5 ); + bSizerRight->Add( sbFilter, 0, wxALL|wxEXPAND, 5 ); wxString m_rbLayersOptionChoices[] = { _("All layers"), _("Current layer only") }; int m_rbLayersOptionNChoices = sizeof( m_rbLayersOptionChoices ) / sizeof( wxString ); @@ -112,6 +119,7 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi this->Centre( wxBOTH ); // 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_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 ); @@ -120,6 +128,7 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE() { // 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_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 ); diff --git a/pcbnew/dialogs/dialog_global_deletion_base.fbp b/pcbnew/dialogs/dialog_global_deletion_base.fbp index f4a139f955..1053aa1bf2 100644 --- a/pcbnew/dialogs/dialog_global_deletion_base.fbp +++ b/pcbnew/dialogs/dialog_global_deletion_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -527,7 +529,7 @@ - + OnCheckDeleteModules @@ -833,9 +835,9 @@ 0 wxID_ANY - Track Filter + Filter Settings - sbTrackFilter + sbFilter wxVERTICAL protected @@ -1048,7 +1050,7 @@ 0 0 wxID_ANY - Normal tracks + Unlocked tracks 0 @@ -1191,6 +1193,182 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Locked footprints + + 0 + + + 0 + + 1 + m_ModuleFilterLocked + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unlocked footprints + + 0 + + + 0 + + 1 + m_ModuleFilterNormal + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_global_deletion_base.h b/pcbnew/dialogs/dialog_global_deletion_base.h index dca068674f..d9d8042b78 100644 --- a/pcbnew/dialogs/dialog_global_deletion_base.h +++ b/pcbnew/dialogs/dialog_global_deletion_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Feb 26 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -48,11 +48,13 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM wxCheckBox* m_DelTracks; wxCheckBox* m_DelMarkers; wxCheckBox* m_DelAlls; - wxStaticBoxSizer* sbTrackFilter; + wxStaticBoxSizer* sbFilter; wxCheckBox* m_TrackFilterAR; wxCheckBox* m_TrackFilterLocked; wxCheckBox* m_TrackFilterNormal; wxCheckBox* m_TrackFilterVias; + wxCheckBox* m_ModuleFilterLocked; + wxCheckBox* m_ModuleFilterNormal; wxRadioBox* m_rbLayersOption; wxStaticText* m_staticText1; wxTextCtrl* m_textCtrlCurrLayer; @@ -62,6 +64,7 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM wxButton* m_sdbSizer1Cancel; // 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 OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }