diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp new file mode 100644 index 0000000000..019be4fb6c --- /dev/null +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -0,0 +1,143 @@ +/** + * @file dialog_global_deletion.cpp + */ + + +#include "fctsys.h" +#include "common.h" +#include "class_drawpanel.h" +#include "confirm.h" +#include "pcbnew.h" +#include "wxPcbStruct.h" + +#include "dialog_global_deletion.h" + + +DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( WinEDA_PcbFrame* parent ) + : DIALOG_GLOBAL_DELETION_BASE( parent ) +{ + m_Parent = parent; + SetFocus(); + + GetSizer()->SetSizeHints(this); + Centre(); +} + + +/********************************************************************/ +void WinEDA_PcbFrame::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) +/********************************************************************/ +{ + DIALOG_GLOBAL_DELETION dlg( this ); + dlg.ShowModal(); +} + + +/***********************************************************************/ +void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) +/***********************************************************************/ +{ + bool gen_rastnest = false; + + m_Parent->SetCurItem( NULL ); + + if( m_DelAlls->GetValue() ) + { + m_Parent->Clear_Pcb( true ); + } + else + { + if( !IsOK( this, _( "Ok to delete selected items ?" ) ) ) + return; + + 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; + + /* ZEG_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.m_PickedItem = item; + pickersList.PushItem( itemPicker ); + pcb->Remove( item ); + } + } + + int masque_layer = 0; + if( m_DelDrawings->GetValue() ) + masque_layer = (~EDGE_LAYER) & 0x1FFF0000; + + if( m_DelBoardEdges->GetValue() ) + masque_layer |= EDGE_LAYER; + + for( item = pcb->m_Drawings; item != NULL; item = nextitem ) + { + nextitem = item->Next(); + bool removeme = (g_TabOneLayerMask[ item->GetLayer()] & masque_layer) != 0; + if( ( item->Type() == TYPE_TEXTE ) && m_DelTexts->GetValue() ) + removeme = true; + if( removeme ) + { + itemPicker.m_PickedItem = 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.m_PickedItem = item; + pickersList.PushItem( itemPicker ); + item->UnLink(); + } + } + + if( m_DelTracks->GetValue() ) + { + int track_mask_filter = 0; + if( !m_TrackFilterLocked->GetValue() ) + track_mask_filter |= SEGM_FIXE; + if( !m_TrackFilterAR->GetValue() ) + track_mask_filter |= SEGM_AR; + for( item = pcb->m_Track; item != NULL; item = nextitem ) + { + nextitem = item->Next(); + if( (item->GetState( SEGM_FIXE | SEGM_AR ) & track_mask_filter) != 0 ) + continue; + itemPicker.m_PickedItem = item; + pickersList.PushItem( itemPicker ); + item->UnLink(); + gen_rastnest = true; + } + } + + if( pickersList.GetCount() ) + m_Parent->SaveCopyInUndoList( pickersList, UR_DELETED ); + + if( m_DelMarkers->GetValue() ) + pcb->DeleteMARKERs(); + + if( gen_rastnest ) + m_Parent->Compile_Ratsnest( NULL, true ); + } + + m_Parent->DrawPanel->Refresh(); + m_Parent->OnModify(); + + EndModal( 1 ); +} + diff --git a/pcbnew/dialogs/dialog_global_deletion.h b/pcbnew/dialogs/dialog_global_deletion.h new file mode 100644 index 0000000000..7890f65d67 --- /dev/null +++ b/pcbnew/dialogs/dialog_global_deletion.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_global_deletion.h +///////////////////////////////////////////////////////////////////////////// + +#ifndef _DIALOG_GLOBAL_DELETION_H_ +#define _DIALOG_GLOBAL_DELETION_H_ + +#include "dialog_global_deletion_base.h" + +class DIALOG_GLOBAL_DELETION: public DIALOG_GLOBAL_DELETION_BASE +{ +private: + WinEDA_PcbFrame * m_Parent; + +public: + DIALOG_GLOBAL_DELETION( WinEDA_PcbFrame* parent ); + +private: + void OnOkClick( wxCommandEvent& event ) + { + AcceptPcbDelete(); + EndModal(wxID_OK); + } + void OnCancelClick( wxCommandEvent& event ) + { + EndModal(wxID_CANCEL); + } + + void AcceptPcbDelete(); + +}; + +#endif + // _DIALOG_GLOBAL_DELETION_H_ diff --git a/pcbnew/dialogs/dialog_global_deletion_base.cpp b/pcbnew/dialogs/dialog_global_deletion_base.cpp new file mode 100644 index 0000000000..71a3b3eca0 --- /dev/null +++ b/pcbnew/dialogs/dialog_global_deletion_base.cpp @@ -0,0 +1,90 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_global_deletion_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_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 ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticBoxSizer* sbSizerLeft; + sbSizerLeft = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Items to delete") ), wxVERTICAL ); + + m_DelZones = new wxCheckBox( this, wxID_ANY, _("Delete Zones"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelZones, 0, wxALL, 5 ); + + m_DelTexts = new wxCheckBox( this, wxID_ANY, _("Delete Texts"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelTexts, 0, wxALL, 5 ); + + m_DelBoardEdges = new wxCheckBox( this, wxID_ANY, _("Delete Board Outlines"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelBoardEdges, 0, wxALL, 5 ); + + m_DelDrawings = new wxCheckBox( this, wxID_ANY, _("Delete Drawings"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelDrawings, 0, wxALL, 5 ); + + m_DelModules = new wxCheckBox( this, wxID_ANY, _("Delete Modules"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelModules, 0, wxALL, 5 ); + + m_DelTracks = new wxCheckBox( this, wxID_ANY, _("Delete Tracks"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelTracks, 0, wxALL, 5 ); + + m_DelMarkers = new wxCheckBox( this, wxID_ANY, _("Delete Markers"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelMarkers, 0, wxALL, 5 ); + + m_DelAlls = new wxCheckBox( this, wxID_ANY, _("Clear Board"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerLeft->Add( m_DelAlls, 0, wxALL, 5 ); + + bSizerMain->Add( sbSizerLeft, 1, wxEXPAND|wxALL, 5 ); + + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizerTrackFilter; + sbSizerTrackFilter = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Track Filter") ), wxVERTICAL ); + + m_TrackFilterAR = new wxCheckBox( this, wxID_ANY, _("Include AutoRouted Tracks"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerTrackFilter->Add( m_TrackFilterAR, 0, wxALL, 5 ); + + m_TrackFilterLocked = new wxCheckBox( this, wxID_ANY, _("Include Locked Tracks"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerTrackFilter->Add( m_TrackFilterLocked, 0, wxALL, 5 ); + + bSizer2->Add( sbSizerTrackFilter, 0, wxALL|wxEXPAND, 5 ); + + + bSizer2->Add( 0, 10, 0, 0, 5 ); + + m_buttonOK = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonOK->SetDefault(); + bSizer2->Add( m_buttonOK, 0, wxALL|wxEXPAND, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_buttonCancel, 0, wxALL|wxEXPAND, 5 ); + + bSizerMain->Add( bSizer2, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + this->SetSizer( bSizerMain ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnOkClick ), NULL, this ); + m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCancelClick ), NULL, this ); +} + +DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE() +{ + // Disconnect Events + m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnOkClick ), NULL, this ); + m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::OnCancelClick ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_global_deletion_base.fbp b/pcbnew/dialogs/dialog_global_deletion_base.fbp new file mode 100644 index 0000000000..714e9cfa69 --- /dev/null +++ b/pcbnew/dialogs/dialog_global_deletion_base.fbp @@ -0,0 +1,823 @@ + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_global_deletion_base + 1000 + none + 1 + dialog_global_deletion + + . + + 1 + 1 + 0 + 0 + + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_GLOBAL_DELETION_BASE + + 365,242 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxHORIZONTAL + none + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + Items to delete + + sbSizerLeft + wxVERTICAL + none + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Zones + + + m_DelZones + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Texts + + + m_DelTexts + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Board Outlines + + + m_DelBoardEdges + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Drawings + + + m_DelDrawings + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Modules + + + m_DelModules + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Tracks + + + m_DelTracks + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Delete Markers + + + m_DelMarkers + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Clear Board + + + m_DelAlls + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 1 + + + bSizer2 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + wxID_ANY + Track Filter + + sbSizerTrackFilter + wxVERTICAL + none + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Include AutoRouted Tracks + + + m_TrackFilterAR + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Include Locked Tracks + + + m_TrackFilterLocked + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 10 + protected + 0 + + + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + 1 + 1 + + + 0 + wxID_OK + &OK + + + m_buttonOK + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_CANCEL + &Cancel + + + m_buttonCancel + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_global_deletion_base.h b/pcbnew/dialogs/dialog_global_deletion_base.h new file mode 100644 index 0000000000..4b08fae6b9 --- /dev/null +++ b/pcbnew/dialogs/dialog_global_deletion_base.h @@ -0,0 +1,61 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_global_deletion_base__ +#define __dialog_global_deletion_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_GLOBAL_DELETION_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_GLOBAL_DELETION_BASE : public wxDialog +{ + private: + + protected: + wxCheckBox* m_DelZones; + wxCheckBox* m_DelTexts; + wxCheckBox* m_DelBoardEdges; + wxCheckBox* m_DelDrawings; + wxCheckBox* m_DelModules; + wxCheckBox* m_DelTracks; + wxCheckBox* m_DelMarkers; + wxCheckBox* m_DelAlls; + wxCheckBox* m_TrackFilterAR; + wxCheckBox* m_TrackFilterLocked; + + wxButton* m_buttonOK; + wxButton* m_buttonCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 365,242 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_GLOBAL_DELETION_BASE(); + +}; + +#endif //__dialog_global_deletion_base__