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 )
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,37 +80,47 @@ 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;
LAYER_MSK layers_filter = ALL_LAYERS;
if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only
layers_filter = GetLayerMask( m_currentLayer );
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 :
* and are deleted but not put in undo buffer if exist
*/
pcb->m_Zone.DeleteAll();
while( item != NULL )
{
while( pcb->GetAreaCount() )
if( GetLayerMask( item->GetLayer() ) & layers_filter )
{
item = pcb->GetArea( 0 );
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
pcb->Remove( item );
gen_rastnest = true;
}
else
{
area_index++;
}
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 );
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;
......@@ -106,34 +128,54 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
if( m_DelBoardEdges->GetValue() )
masque_layer |= EDGE_LAYER;
layers_filter &= layers_filter;
masque_layer &= layers_filter;
for( item = pcb->m_Drawings; item != NULL; item = nextitem )
{
nextitem = item->Next();
bool removeme = GetLayerMask( item->GetLayer() ) & masque_layer;
if( ( item->Type() == PCB_TEXT_T ) && m_DelTexts->GetValue() )
removeme = true;
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( removeme )
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();
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 );
}
......@@ -30,6 +30,7 @@ private:
void AcceptPcbDelete();
void OnCheckDeleteTracks( wxCommandEvent& event );
void OnCheckDeleteModules( wxCommandEvent& event );
};
#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/
//
// 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 );
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") };
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 );
......
///////////////////////////////////////////////////////////////////////////
// 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(); }
......
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