Pcbnew: Rework on dialog global deletions.

This commit is contained in:
jean-pierre charras 2015-09-01 11:13:22 +02:00
parent 330b253018
commit dba0494b02
6 changed files with 381 additions and 326 deletions

View File

@ -94,13 +94,16 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
m_Parent->SetCurItem( NULL );
bool delAll = false;
if( m_DelAlls->GetValue() )
{
m_Parent->Clear_Pcb( true );
if( !IsOK( this, _( "Are you sure you want to delete the entire board?" ) ) )
return;
delAll = true;
}
else
{
if( !IsOK( this, _( "Are you sure you want to delete the selected items?" ) ) )
else if( !IsOK( this, _( "Are you sure you want to delete the selected items?" ) ) )
return;
BOARD* pcb = m_Parent->GetBoard();
@ -115,14 +118,14 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only
layers_filter = LSET( ToLAYER_ID( m_currentLayer ) );
if( m_DelZones->GetValue() )
if( delAll || m_DelZones->GetValue() )
{
int area_index = 0;
item = pcb->GetArea( area_index );
while( item )
{
if( layers_filter[item->GetLayer()] )
if( delAll || layers_filter[item->GetLayer()] )
{
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
@ -140,7 +143,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
}
}
if( m_DelDrawings->GetValue() || m_DelBoardEdges->GetValue() )
if( delAll || m_DelDrawings->GetValue() || m_DelBoardEdges->GetValue() )
{
LSET masque_layer;
@ -156,7 +159,8 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
{
nextitem = item->Next();
if( item->Type() == PCB_LINE_T && masque_layer[item->GetLayer()] )
if( delAll ||
( item->Type() == PCB_LINE_T && masque_layer[item->GetLayer()] ) )
{
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
@ -166,7 +170,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
}
}
if( m_DelTexts->GetValue() )
if( delAll || m_DelTexts->GetValue() )
{
LSET del_text_layers = layers_filter;
@ -174,7 +178,8 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
{
nextitem = item->Next();
if( item->Type() == PCB_TEXT_T && del_text_layers[item->GetLayer()] )
if( delAll ||
( item->Type() == PCB_TEXT_T && del_text_layers[item->GetLayer()] ) )
{
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
@ -184,15 +189,20 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
}
}
if( m_DelModules->GetValue() )
if( delAll || m_DelModules->GetValue() )
{
for( item = pcb->m_Modules; item; item = nextitem )
{
nextitem = item->Next();
bool del_fp = delAll;
if( layers_filter[item->GetLayer()] &&
( ( m_ModuleFilterNormal->GetValue() && !item->IsLocked() ) ||
( m_ModuleFilterLocked->GetValue() && item->IsLocked() ) ) )
del_fp = true;
if( del_fp )
{
itemPicker.SetItem( item );
pickersList.PushItem( itemPicker );
@ -206,7 +216,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
}
}
if( m_DelTracks->GetValue() )
if( delAll || m_DelTracks->GetValue() )
{
STATUS_FLAGS track_mask_filter = 0;
@ -222,6 +232,8 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
{
nexttrack = track->Next();
if( !delAll )
{
if( ( track->GetState( TRACK_LOCKED | TRACK_AR ) & track_mask_filter ) != 0 )
continue;
@ -234,6 +246,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
if( ( track->GetLayerSet() & layers_filter ) == 0 )
continue;
}
itemPicker.SetItem( track );
pickersList.PushItem( itemPicker );
@ -256,8 +269,6 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
if( m_Parent->IsGalCanvasActive() )
pcb->GetRatsnest()->Recalculate();
}
m_Parent->GetCanvas()->Refresh();
m_Parent->OnModify();
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 9 2015)
// C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -22,28 +22,28 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
wxStaticBoxSizer* sbSizerLeft;
sbSizerLeft = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Items to Delete") ), wxVERTICAL );
m_DelZones = new wxCheckBox( this, wxID_ANY, _("Zones"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelZones = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Zones"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelZones, 0, wxALL, 5 );
m_DelTexts = new wxCheckBox( this, wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelTexts = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelTexts, 0, wxALL, 5 );
m_DelBoardEdges = new wxCheckBox( this, wxID_ANY, _("Board outlines"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelBoardEdges = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Board outlines"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelBoardEdges, 0, wxALL, 5 );
m_DelDrawings = new wxCheckBox( this, wxID_ANY, _("Drawings"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelDrawings = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Drawings"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelDrawings, 0, wxALL, 5 );
m_DelModules = new wxCheckBox( this, wxID_ANY, _("Footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelModules = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Footprints"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelModules, 0, wxALL, 5 );
m_DelTracks = new wxCheckBox( this, wxID_ANY, _("Tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelTracks = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Tracks"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelTracks, 0, wxALL, 5 );
m_DelMarkers = new wxCheckBox( this, wxID_ANY, _("Markers"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelMarkers = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Markers"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelMarkers, 0, wxALL, 5 );
m_DelAlls = new wxCheckBox( this, wxID_ANY, _("Clear Board"), wxDefaultPosition, wxDefaultSize, 0 );
m_DelAlls = new wxCheckBox( sbSizerLeft->GetStaticBox(), wxID_ANY, _("Clear Board"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerLeft->Add( m_DelAlls, 0, wxALL, 5 );
@ -54,25 +54,25 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
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( sbFilter->GetStaticBox(), wxID_ANY, _("Automatically routed tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterAR->SetValue(true);
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( sbFilter->GetStaticBox(), wxID_ANY, _("Locked tracks"), wxDefaultPosition, wxDefaultSize, 0 );
sbFilter->Add( m_TrackFilterLocked, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TrackFilterNormal = new wxCheckBox( this, wxID_ANY, _("Unlocked tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterNormal = new wxCheckBox( sbFilter->GetStaticBox(), wxID_ANY, _("Unlocked tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterNormal->SetValue(true);
sbFilter->Add( m_TrackFilterNormal, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TrackFilterVias = new wxCheckBox( this, wxID_ANY, _("Vias"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterVias = new wxCheckBox( sbFilter->GetStaticBox(), wxID_ANY, _("Vias"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackFilterVias->SetValue(true);
sbFilter->Add( m_TrackFilterVias, 0, wxALL, 5 );
m_ModuleFilterLocked = new wxCheckBox( this, wxID_ANY, _("Locked footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_ModuleFilterLocked = new wxCheckBox( sbFilter->GetStaticBox(), 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 = new wxCheckBox( sbFilter->GetStaticBox(), wxID_ANY, _("Unlocked footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_ModuleFilterNormal->SetValue(true);
sbFilter->Add( m_ModuleFilterNormal, 0, wxALL, 5 );
@ -85,22 +85,31 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
m_rbLayersOption->SetSelection( 0 );
bSizerRight->Add( m_rbLayersOption, 0, wxALL|wxEXPAND, 5 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Current layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bSizerRight->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlCurrLayer = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_textCtrlCurrLayer->SetMaxLength( 0 );
bSizerRight->Add( m_textCtrlCurrLayer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerUpper->Add( bSizerRight, 3, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxALL|wxEXPAND, 5 );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer1->AddGrowableCol( 1 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Current layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
fgSizer1->Add( m_staticText1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_textCtrlCurrLayer = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_textCtrlCurrLayer->SetMaxLength( 0 );
fgSizer1->Add( m_textCtrlCurrLayer, 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( fgSizer1, 0, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
@ -114,7 +123,6 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );

View File

@ -44,7 +44,7 @@
<property name="minimum_size"></property>
<property name="name">DIALOG_GLOBAL_DELETION_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="size">339,365</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Delete Items</property>
@ -1461,9 +1461,29 @@
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer1</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -1546,7 +1566,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="flag">wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
@ -1637,11 +1657,9 @@
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 9 2015)
// C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -72,7 +72,7 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM
public:
DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Delete Items"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Delete Items"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 339,365 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_GLOBAL_DELETION_BASE();
};

View File

@ -66,6 +66,10 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
{
fn = GetBoard()->GetFileName();
fn.SetExt( NetlistFileExtension );
if( fn.GetName().IsEmpty() )
netlistName.Clear();
else
netlistName = fn.GetFullPath();
}
@ -152,8 +156,20 @@ void DIALOG_NETLIST::OnOpenNetlistClick( wxCommandEvent& event )
void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )
{
wxString msg;
wxString netlistFileName = m_NetlistFilenameCtrl->GetValue();
wxFileName fn = netlistFileName;
if( !fn.IsOk() )
{
wxMessageBox( _("Please, choose a valid netlist file") );
return;
}
if( !fn.FileExists() )
{
wxMessageBox( _("The netlist file does not exist") );
return;
}
// Give the user a chance to bail out when making changes from a netlist.
if( !m_checkDryRun->GetValue() && !m_silentMode
@ -167,6 +183,7 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )
wxBusyCursor busy;
wxString msg;
msg.Printf( _( "Reading netlist file \"%s\".\n" ), GetChars( netlistFileName ) );
reporter.Report( msg, REPORTER::RPT_INFO );

View File

@ -41,7 +41,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
if( GetBoard() == NULL )
return false;
if( aQuery && GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
if( aQuery && !GetBoard()->IsEmpty() )
{
if( !IsOK( this,
_( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
@ -83,6 +83,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
ReCreateLayerBox();
ReCreateAuxiliaryToolbar();
ReFillLayerWidget();
UpdateTitle();
Zoom_Automatique( false );