Move DRC dialogs to wxDataView.

This allows for hierarchy and better selection handling.
This commit is contained in:
Jeff Young 2020-02-24 23:17:30 +00:00
parent c5077aeb97
commit a4837f7d32
14 changed files with 681 additions and 1101 deletions

View File

@ -1,11 +1,7 @@
/**
* @file dialog_cleaning_options.cpp
*/
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -26,9 +22,8 @@
*/ */
#include <wx/wx.h> #include <wx/wx.h>
#include "dialog_drclistbox.h" #include <drc/drc_tree_model.h>
#include <board_commit.h> #include <board_commit.h>
#include <collectors.h>
#include <dialog_cleanup_tracks_and_vias.h> #include <dialog_cleanup_tracks_and_vias.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
@ -37,7 +32,6 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <tracks_cleaner.h> #include <tracks_cleaner.h>
#include <wx_html_report_panel.h>
DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS( PCB_EDIT_FRAME* aParentFrame ): DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS( PCB_EDIT_FRAME* aParentFrame ):
@ -52,6 +46,10 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS( PCB_EDIT_FRAME*
m_cleanShortCircuitOpt->SetValue( cfg->m_Cleanup.cleanup_short_circuits ); m_cleanShortCircuitOpt->SetValue( cfg->m_Cleanup.cleanup_short_circuits );
m_deleteTracksInPadsOpt->SetValue( cfg->m_Cleanup.cleanup_tracks_in_pad ); m_deleteTracksInPadsOpt->SetValue( cfg->m_Cleanup.cleanup_tracks_in_pad );
m_changesDataView->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, 4000 );
m_changesTreeModel = new DRC_TREE_MODEL( m_changesDataView );
m_changesDataView->AssociateModel( m_changesTreeModel );
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
// that requires us to correct the button labels here. // that requires us to correct the button labels here.
m_sdbSizerOK->SetLabel( _( "Update PCB" ) ); m_sdbSizerOK->SetLabel( _( "Update PCB" ) );
@ -74,6 +72,8 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS::~DIALOG_CLEANUP_TRACKS_AND_VIAS()
for( DRC_ITEM* item : m_items ) for( DRC_ITEM* item : m_items )
delete item; delete item;
m_changesTreeModel->DecRef();
} }
@ -125,7 +125,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun )
if( aDryRun ) if( aDryRun )
{ {
m_ItemsListBox->SetList( GetUserUnits(), new DRC_LIST_GENERIC( &m_items ) ); m_changesTreeModel->SetProvider( new VECTOR_DRC_ITEMS_PROVIDER( &m_items ) );
} }
else if( modified ) else if( modified )
{ {
@ -136,22 +136,13 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun )
} }
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem( wxCommandEvent& event ) void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem( wxDataViewEvent& event )
{ {
int selection = event.GetSelection(); BOARD_ITEM* item = DRC_TREE_MODEL::ToBoardItem( m_parentFrame->GetBoard(), event.GetItem() );
WINDOW_THAWER thawer( m_parentFrame );
if( selection != wxNOT_FOUND ) m_parentFrame->FocusOnItem( item );
{ m_parentFrame->GetCanvas()->Refresh();
// Find the selected DRC_ITEM in the listbox, position cursor there.
const DRC_ITEM* item = m_ItemsListBox->GetItem( selection );
if( item )
{
m_parentFrame->FocusOnLocation( item->GetPointA() );
WINDOW_THAWER thawer( m_parentFrame );
m_parentFrame->GetCanvas()->Refresh();
}
}
event.Skip(); event.Skip();
} }
@ -161,44 +152,10 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnLeftDClickItem( wxMouseEvent& event )
{ {
event.Skip(); event.Skip();
int selection = m_ItemsListBox->GetSelection(); if( m_changesDataView->GetCurrentItem().IsOk() )
if( selection != wxNOT_FOUND )
{ {
// Find the selected DRC_ITEM in the listbox, position cursor there. if( !IsModal() )
// Then hide the dialog. Show( false );
const DRC_ITEM* item = m_ItemsListBox->GetItem( selection );
if( item )
{
m_parentFrame->FocusOnLocation( item->GetPointA() );
if( !IsModal() )
Show( false );
}
}
}
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnRightUpItem( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
int selection = m_ItemsListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
const DRC_ITEM* item = m_ItemsListBox->GetItem( selection );
GENERAL_COLLECTOR items;
items.Append( item->GetMainItem( m_parentFrame->GetBoard() ) );
if( item->HasSecondItem() )
items.Append( item->GetAuxiliaryItem( m_parentFrame->GetBoard() ) );
WINDOW_THAWER thawer( m_parentFrame );
m_parentFrame->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items );
m_parentFrame->GetCanvas()->Refresh();
} }
} }

View File

@ -31,19 +31,20 @@
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
class DRC_TREE_MODEL;
class DIALOG_CLEANUP_TRACKS_AND_VIAS: public DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE class DIALOG_CLEANUP_TRACKS_AND_VIAS: public DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE
{ {
PCB_EDIT_FRAME* m_parentFrame; PCB_EDIT_FRAME* m_parentFrame;
DRC_LIST m_items; DRC_LIST m_items;
DRC_TREE_MODEL* m_changesTreeModel;
void doCleanup( bool aDryRun ); void doCleanup( bool aDryRun );
void OnCheckBox( wxCommandEvent& anEvent ) override; void OnCheckBox( wxCommandEvent& anEvent ) override;
void OnSelectItem( wxCommandEvent& event ) override; void OnSelectItem( wxDataViewEvent& event ) override;
void OnLeftDClickItem( wxMouseEvent& event ) override; void OnLeftDClickItem( wxMouseEvent& event ) override;
void OnRightUpItem( wxMouseEvent& event ) override;
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;

View File

@ -1,12 +1,10 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version v3.8.0) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_drclistbox.h"
#include "dialog_cleanup_tracks_and_vias_base.h" #include "dialog_cleanup_tracks_and_vias_base.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -57,8 +55,8 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWind
staticChangesLabel->Wrap( -1 ); staticChangesLabel->Wrap( -1 );
bLowerSizer->Add( staticChangesLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bLowerSizer->Add( staticChangesLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ItemsListBox = new DRCLISTBOX( this, ID_CLEANUP_ITEMS_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_changesDataView = new wxDataViewCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
bLowerSizer->Add( m_ItemsListBox, 1, wxEXPAND | wxALL, 5 ); bLowerSizer->Add( m_changesDataView, 1, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bLowerSizer, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( bLowerSizer, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
@ -85,9 +83,8 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWind
m_mergeSegmOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this ); m_mergeSegmOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
m_deleteUnconnectedOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this ); m_deleteUnconnectedOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
m_deleteTracksInPadsOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this ); m_deleteTracksInPadsOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
m_ItemsListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLeftDClickItem ), NULL, this ); m_changesDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnSelectItem ), NULL, this );
m_ItemsListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnSelectItem ), NULL, this ); m_changesDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLeftDClickItem ), NULL, this );
m_ItemsListBox->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnRightUpItem ), NULL, this );
} }
DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::~DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE() DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::~DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE()
@ -98,8 +95,7 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::~DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE()
m_mergeSegmOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this ); m_mergeSegmOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
m_deleteUnconnectedOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this ); m_deleteUnconnectedOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
m_deleteTracksInPadsOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this ); m_deleteTracksInPadsOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
m_ItemsListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLeftDClickItem ), NULL, this ); m_changesDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnSelectItem ), NULL, this );
m_ItemsListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnSelectItem ), NULL, this ); m_changesDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLeftDClickItem ), NULL, this );
m_ItemsListBox->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnRightUpItem ), NULL, this );
} }

View File

@ -53,7 +53,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerMain</property> <property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
@ -394,11 +394,11 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property> <property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size">660,250</property> <property name="minimum_size">660,250</property>
<property name="name">bLowerSizer</property> <property name="name">bLowerSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
@ -464,70 +464,33 @@
<property name="wrap">-1</property> <property name="wrap">-1</property>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxListBox" expanded="0"> <object class="wxDataViewCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">ID_CLEANUP_ITEMS_LIST</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="name">m_changesDataView</property>
<property name="name">m_ItemsListBox</property> <property name="permission">protected</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style"></property>
<property name="subclass">DRCLISTBOX; dialog_drclistbox.h; forward_declare</property> <property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnDataViewCtrlSelectionChanged">OnSelectItem</event>
<event name="OnLeftDClick">OnLeftDClickItem</event> <event name="OnLeftDClick">OnLeftDClickItem</event>
<event name="OnListBox">OnSelectItem</event>
<event name="OnRightUp">OnRightUpItem</event>
</object> </object>
</object> </object>
</object> </object>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version v3.8.0) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -10,8 +10,6 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DRCLISTBOX;
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
@ -21,13 +19,12 @@ class DRCLISTBOX;
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/listbox.h> #include <wx/dataview.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#define ID_CLEANUP_ITEMS_LIST 1000
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE /// Class DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE
@ -43,19 +40,18 @@ class DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE : public DIALOG_SHIM
wxCheckBox* m_deleteUnconnectedOpt; wxCheckBox* m_deleteUnconnectedOpt;
wxCheckBox* m_deleteTracksInPadsOpt; wxCheckBox* m_deleteTracksInPadsOpt;
wxStaticText* staticChangesLabel; wxStaticText* staticChangesLabel;
wxDataViewCtrl* m_changesDataView;
wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel; wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSelectItem( wxDataViewEvent& event ) { event.Skip(); }
virtual void OnLeftDClickItem( wxMouseEvent& event ) { event.Skip(); } virtual void OnLeftDClickItem( wxMouseEvent& event ) { event.Skip(); }
virtual void OnSelectItem( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRightUpItem( wxMouseEvent& event ) { event.Skip(); }
public: public:
DRCLISTBOX* m_ItemsListBox;
DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Cleanup Tracks and Vias"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Cleanup Tracks and Vias"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE(); ~DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -35,22 +35,16 @@
#include <pgm_base.h> #include <pgm_base.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <view/view.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <drc/drc_tree_model.h>
#include <wx/wupdlock.h>
/* class DIALOG_DRC_CONTROL: a dialog to set DRC parameters (clearance, min cooper size) DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFrame,
* and run DRC tests wxWindow* aParent ) :
*/ DIALOG_DRC_CONTROL_BASE( aParent ),
m_trackMinWidth( aEditorFrame, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true ),
m_viaMinSize( aEditorFrame, m_ViaMinLabel, m_ViaMinCtrl, m_ViaMinUnits, true ),
DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( m_uviaMinSize( aEditorFrame, m_uViaMinLabel, m_uViaMinCtrl, m_uViaMinUnits, true )
DRC* aTester, PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent )
: DIALOG_DRC_CONTROL_BASE( aParent ),
m_trackMinWidth( aEditorFrame, m_TrackMinWidthTitle, m_SetTrackMinWidthCtrl,
m_TrackMinWidthUnit, true ),
m_viaMinSize( aEditorFrame, m_ViaMinTitle, m_SetViaMinSizeCtrl, m_ViaMinUnit, true ),
m_uviaMinSize( aEditorFrame, m_MicroViaMinTitle, m_SetMicroViakMinSizeCtrl,
m_MicroViaMinUnit, true )
{ {
SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
@ -61,6 +55,18 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL(
m_BrowseButton->SetBitmap( KiBitmap( folder_xpm ) ); m_BrowseButton->SetBitmap( KiBitmap( folder_xpm ) );
m_markerDataView->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, 4000 );
m_markerTreeModel = new DRC_TREE_MODEL( m_markerDataView );
m_markerDataView->AssociateModel( m_markerTreeModel );
m_unconnectedDataView->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, 4000 );
m_unconnectedTreeModel = new DRC_TREE_MODEL( m_unconnectedDataView );
m_unconnectedDataView->AssociateModel( m_unconnectedTreeModel );
m_footprintsDataView->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, 4000 );
m_footprintsTreeModel = new DRC_TREE_MODEL( m_footprintsDataView );
m_footprintsDataView->AssociateModel( m_footprintsTreeModel );
// We use a sdbSizer here to get the order right, which is platform-dependent // We use a sdbSizer here to get the order right, which is platform-dependent
m_sdbSizer1OK->SetLabel( _( "Run DRC" ) ); m_sdbSizer1OK->SetLabel( _( "Run DRC" ) );
m_sdbSizer1Cancel->SetLabel( _( "Close" ) ); m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
@ -81,6 +87,8 @@ DIALOG_DRC_CONTROL::~DIALOG_DRC_CONTROL()
cfg->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue(); cfg->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue();
cfg->m_DrcDialog.test_track_to_zone = m_cbReportAllTrackErrors->GetValue(); cfg->m_DrcDialog.test_track_to_zone = m_cbReportAllTrackErrors->GetValue();
cfg->m_DrcDialog.test_footprints = m_cbTestFootprints->GetValue(); cfg->m_DrcDialog.test_footprints = m_cbTestFootprints->GetValue();
m_markerTreeModel->DecRef();
} }
@ -119,8 +127,6 @@ void DIALOG_DRC_CONTROL::InitValues()
m_unconnectedTitleTemplate = m_Notebook->GetPageText( 1 ); m_unconnectedTitleTemplate = m_Notebook->GetPageText( 1 );
m_footprintsTitleTemplate = m_Notebook->GetPageText( 2 ); m_footprintsTitleTemplate = m_Notebook->GetPageText( 2 );
m_DeleteCurrentMarkerButton->Enable( false );
DisplayDRCValues(); DisplayDRCValues();
auto cfg = m_brdEditor->GetSettings(); auto cfg = m_brdEditor->GetSettings();
@ -137,9 +143,9 @@ void DIALOG_DRC_CONTROL::InitValues()
void DIALOG_DRC_CONTROL::SetDRCParameters() void DIALOG_DRC_CONTROL::SetDRCParameters()
{ {
m_BrdSettings.m_TrackMinWidth = m_trackMinWidth.GetValue(); m_BrdSettings.m_TrackMinWidth = (int) m_trackMinWidth.GetValue();
m_BrdSettings.m_ViasMinSize = m_viaMinSize.GetValue(); m_BrdSettings.m_ViasMinSize = (int) m_viaMinSize.GetValue();
m_BrdSettings.m_MicroViasMinSize = m_uviaMinSize.GetValue(); m_BrdSettings.m_MicroViasMinSize = (int) m_uviaMinSize.GetValue();
m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings ); m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings );
} }
@ -159,7 +165,7 @@ void DIALOG_DRC_CONTROL::GetRptSettings( bool* aEnable, wxString& aFileName )
} }
void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event ) void DIALOG_DRC_CONTROL::OnRunDRCClick( wxCommandEvent& event )
{ {
wxString reportName, msg; wxString reportName, msg;
@ -220,6 +226,68 @@ void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event )
} }
void DIALOG_DRC_CONTROL::SetMarkersProvider( DRC_ITEMS_PROVIDER* aProvider )
{
m_markerTreeModel->SetProvider( aProvider );
}
void DIALOG_DRC_CONTROL::SetUnconnectedProvider(class DRC_ITEMS_PROVIDER * aProvider)
{
m_unconnectedTreeModel->SetProvider( aProvider );
}
void DIALOG_DRC_CONTROL::SetFootprintsProvider( DRC_ITEMS_PROVIDER* aProvider )
{
m_footprintsTreeModel->SetProvider( aProvider );
}
void DIALOG_DRC_CONTROL::OnDRCItemSelected( wxDataViewEvent& event )
{
BOARD_ITEM* item = DRC_TREE_MODEL::ToBoardItem( m_brdEditor->GetBoard(), event.GetItem() );
WINDOW_THAWER thawer( m_brdEditor );
m_brdEditor->FocusOnItem( item );
m_brdEditor->GetCanvas()->Refresh();
event.Skip();
}
void DIALOG_DRC_CONTROL::OnDClick( wxDataViewCtrl* ctrl, wxMouseEvent& event )
{
event.Skip();
if( ctrl->GetCurrentItem().IsOk() )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
if( !IsModal() )
Show( false );
}
}
void DIALOG_DRC_CONTROL::OnMarkerDClick( wxMouseEvent& event )
{
OnDClick( m_markerDataView, event );
}
void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
{
OnDClick( m_unconnectedDataView, event );
}
void DIALOG_DRC_CONTROL::OnLeftDClickFootprints( wxMouseEvent& event )
{
OnDClick( m_footprintsDataView, event );
}
void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event ) void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event )
{ {
DelDRCMarkers(); DelDRCMarkers();
@ -235,7 +303,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& )
wxString prj_path = Prj().GetProjectPath(); wxString prj_path = Prj().GetProjectPath();
wxFileDialog dlg( this, _( "Save DRC Report File" ), prj_path, fn.GetFullName(), wxFileDialog dlg( this, _( "Save DRC Report File" ), prj_path, fn.GetFullName(),
ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
@ -269,248 +337,15 @@ void DIALOG_DRC_CONTROL::OnReportFilenameEdited( wxCommandEvent& event )
} }
void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event ) void DIALOG_DRC_CONTROL::OnChangingNotebookPage( wxNotebookEvent& event )
{
event.Skip();
int selection = m_ClearanceListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
if( focusOnItem( m_ClearanceListBox->GetItem( selection ) ) )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
if( !IsModal() )
Show( false );
}
}
}
void DIALOG_DRC_CONTROL::OnRightUpFootprints( wxMouseEvent& event )
{
int selection = rightUpClicSelection( m_FootprintsListBox, event );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_FootprintsListBox->GetItem( selection ) );
}
void DIALOG_DRC_CONTROL::OnLeftUpClearance( wxMouseEvent& event )
{
int selection = m_ClearanceListBox->GetSelection();
if( selection != wxNOT_FOUND )
focusOnItem( m_ClearanceListBox->GetItem( selection ) );
}
bool DIALOG_DRC_CONTROL::focusOnItem( const DRC_ITEM* aItem )
{
if( !aItem )
return false;
auto toolmgr = m_brdEditor->GetToolManager();
auto pos = aItem->GetPointA();
auto marker = static_cast<MARKER_PCB*>( aItem->GetParent() );
if( marker )
{
pos = marker->GetPos();
toolmgr->RunAction( PCB_ACTIONS::selectionClear, true );
toolmgr->RunAction( PCB_ACTIONS::selectItem, true, marker );
}
m_brdEditor->FocusOnLocation( pos );
m_brdEditor->GetCanvas()->Refresh();
return true;
}
int DIALOG_DRC_CONTROL::rightUpClicSelection( DRCLISTBOX* aListBox, wxMouseEvent& event )
{
#if wxCHECK_VERSION( 3, 1, 3 )
// wxWidgets 3.1.3 has a bug in HitTest(): one cannot have the item selection
// on a right click: the returned value is always 10 so do not try to select
// an item on the right click. Just use the current selection (if any)
int selection = aListBox->GetSelection();
#else
// Check if user right-clicked on a different item, and select the right clicked item
int selection = aListBox->HitTest( event.GetPosition() );
if( selection >= (int) aListBox->GetItemCount() ) // Should not happen.
selection = wxNOT_FOUND;
#endif
if( selection == wxNOT_FOUND )
selection = aListBox->GetSelection();
else if( aListBox->GetSelection() != selection )
aListBox->SetSelection( selection );
return selection;
}
void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
int selection = rightUpClicSelection( m_UnconnectedListBox, event );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_UnconnectedListBox->GetItem( selection ) );
}
void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
int selection = rightUpClicSelection( m_ClearanceListBox, event );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_ClearanceListBox->GetItem( selection ) );
}
void DIALOG_DRC_CONTROL::doSelectionMenu( const DRC_ITEM* aItem )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
BOARD_ITEM* first = aItem->GetMainItem( m_brdEditor->GetBoard() );
BOARD_ITEM* second = nullptr;
GENERAL_COLLECTOR items;
items.Append( first );
if( aItem->HasSecondItem() )
{
second = aItem->GetAuxiliaryItem( m_brdEditor->GetBoard() );
items.Append( second );
}
WINDOW_THAWER thawer( m_brdEditor );
m_brdEditor->GetToolManager()->VetoContextMenuMouseWarp();
m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items );
// If we got an item, focus on it
BOARD_ITEM* selection = items.GetCount() ? items[0] : nullptr;
if( selection && ( selection == first || selection == second ) )
m_brdEditor->FocusOnLocation( selection->GetPosition() );
m_brdEditor->GetCanvas()->Refresh();
}
void DIALOG_DRC_CONTROL::OnLeftDClickFootprints( wxMouseEvent& event )
{
event.Skip();
int selection = m_FootprintsListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
// Find the selected DRC_ITEM in the listbox, position cursor there.
// Then hide the dialog.
if( focusOnItem( m_FootprintsListBox->GetItem( selection ) ) )
{
if( !IsModal() )
Show( false );
}
}
}
void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
{
event.Skip();
int selection = m_UnconnectedListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
if( focusOnItem( m_UnconnectedListBox->GetItem( selection ) ) )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
if( !IsModal() )
Show( false );
}
}
}
void DIALOG_DRC_CONTROL::OnLeftUpUnconnected( wxMouseEvent& event )
{
int selection = m_UnconnectedListBox->GetSelection();
if( selection != wxNOT_FOUND )
focusOnItem( m_UnconnectedListBox->GetItem( selection ) );
}
void DIALOG_DRC_CONTROL::OnChangingMarkerList( wxNotebookEvent& event )
{ {
// Shouldn't be necessary, but is on at least OSX // Shouldn't be necessary, but is on at least OSX
if( event.GetSelection() >= 0 ) if( event.GetSelection() >= 0 )
m_Notebook->ChangeSelection( (unsigned) event.GetSelection() ); m_Notebook->ChangeSelection( (unsigned) event.GetSelection() );
m_DeleteCurrentMarkerButton->Enable( false ); m_markerDataView->UnselectAll();
m_ClearanceListBox->SetSelection( -1 ); m_unconnectedDataView->UnselectAll();
m_UnconnectedListBox->SetSelection( -1 ); m_footprintsDataView->UnselectAll();
}
void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event )
{
int selection = event.GetSelection();
if( selection != wxNOT_FOUND )
{
// until a MARKER is selected, this button is not enabled.
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there.
focusOnItem( m_ClearanceListBox->GetItem( selection ) );
}
event.Skip();
}
void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
{
int selection = event.GetSelection();
if( selection != wxNOT_FOUND )
{
// until a MARKER is selected, this button is not enabled.
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there.
focusOnItem( m_UnconnectedListBox->GetItem( selection ) );
}
event.Skip();
}
void DIALOG_DRC_CONTROL::OnFootprintsSelectionEvent( wxCommandEvent& event )
{
int selection = event.GetSelection();
if( selection != wxNOT_FOUND )
{
// until a MARKER is selected, this button is not enabled.
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there.
focusOnItem( m_FootprintsListBox->GetItem( selection ) );
}
event.Skip();
} }
@ -527,9 +362,8 @@ void DIALOG_DRC_CONTROL::DelDRCMarkers()
// Clear current selection list to avoid selection of deleted items // Clear current selection list to avoid selection of deleted items
m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true ); m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_ClearanceListBox->DeleteAllItems(); m_markerTreeModel->DeleteAllItems();
m_UnconnectedListBox->DeleteAllItems(); m_unconnectedTreeModel->DeleteAllItems();
m_DeleteCurrentMarkerButton->Enable( false );
} }
@ -571,26 +405,26 @@ bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName )
fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) ); fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) );
count = m_ClearanceListBox->GetItemCount(); count = m_markerTreeModel->GetDRCItemCount();
fprintf( fp, "\n** Found %d DRC errors **\n", count ); fprintf( fp, "\n** Found %d DRC errors **\n", count );
for( int i = 0; i < count; ++i ) for( int i = 0; i < count; ++i )
fprintf( fp, "%s", TO_UTF8( m_ClearanceListBox->GetItem( i )->ShowReport( units ) ) ); fprintf( fp, "%s", TO_UTF8( m_markerTreeModel->GetDRCItem( i )->ShowReport( units ) ) );
count = m_UnconnectedListBox->GetItemCount(); count = m_unconnectedTreeModel->GetDRCItemCount();
fprintf( fp, "\n** Found %d unconnected pads **\n", count ); fprintf( fp, "\n** Found %d unconnected pads **\n", count );
for( int i = 0; i < count; ++i ) for( int i = 0; i < count; ++i )
fprintf( fp, "%s", TO_UTF8( m_UnconnectedListBox->GetItem( i )->ShowReport( units ) ) ); fprintf( fp, "%s", TO_UTF8( m_unconnectedTreeModel->GetDRCItem( i )->ShowReport( units ) ) );
count = m_FootprintsListBox->GetItemCount(); count = m_footprintsTreeModel->GetDRCItemCount();
fprintf( fp, "\n** Found %d Footprint errors **\n", count ); fprintf( fp, "\n** Found %d Footprint errors **\n", count );
for( int i = 0; i < count; ++i ) for( int i = 0; i < count; ++i )
fprintf( fp, "%s", TO_UTF8( m_FootprintsListBox->GetItem( i )->ShowReport( units ) ) ); fprintf( fp, "%s", TO_UTF8( m_footprintsTreeModel->GetDRCItem( i )->ShowReport( units ) ) );
fprintf( fp, "\n** End of Report **\n" ); fprintf( fp, "\n** End of Report **\n" );
@ -603,50 +437,19 @@ bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName )
void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event ) void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event )
{ {
ssize_t selectedIndex; if( m_Notebook->GetSelection() == 0 )
int curTab = m_Notebook->GetSelection();
if( curTab == 0 )
{ {
selectedIndex = m_ClearanceListBox->GetSelection(); // Clear the selection. It may be the selected DRC marker.
m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
if( selectedIndex != wxNOT_FOUND ) m_markerTreeModel->DeleteCurrentItem();
{
// Clear the selection. It may be the selected DRC marker.
m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
ssize_t newIndex = wxNOT_FOUND; // redraw the pcb
RedrawDrawPanel();
if( m_ClearanceListBox->GetItemCount() > 1 )
{
newIndex = std::min( selectedIndex,
static_cast<ssize_t>( m_ClearanceListBox->GetItemCount() - 2 ) );
}
m_ClearanceListBox->DeleteItem( selectedIndex );
if( newIndex != wxNOT_FOUND )
{
focusOnItem( m_ClearanceListBox->GetItem( newIndex ) );
m_ClearanceListBox->SetSelection( newIndex );
}
// redraw the pcb
RedrawDrawPanel();
}
} }
else if( curTab == 1 ) else if( m_Notebook->GetSelection() == 1 )
{ {
selectedIndex = m_UnconnectedListBox->GetSelection(); m_unconnectedTreeModel->DeleteCurrentItem();
if( selectedIndex != wxNOT_FOUND )
{
m_UnconnectedListBox->DeleteItem( selectedIndex );
/* these unconnected DRC_ITEMs are not currently visible on the pcb
* RedrawDrawPanel();
*/
}
} }
UpdateDisplayedCounts(); UpdateDisplayedCounts();
@ -659,14 +462,14 @@ void DIALOG_DRC_CONTROL::UpdateDisplayedCounts()
if( m_tester->m_drcRun ) if( m_tester->m_drcRun )
{ {
msg.sprintf( m_markersTitleTemplate, (int) m_ClearanceListBox->GetItemCount() ); msg.sprintf( m_markersTitleTemplate, m_markerTreeModel->GetDRCItemCount() );
m_Notebook->SetPageText( 0, msg ); m_Notebook->SetPageText( 0, msg );
msg.sprintf( m_unconnectedTitleTemplate, (int) m_UnconnectedListBox->GetItemCount() ); msg.sprintf( m_unconnectedTitleTemplate, (int) m_unconnectedTreeModel->GetDRCItemCount() );
m_Notebook->SetPageText( 1, msg ); m_Notebook->SetPageText( 1, msg );
if( m_tester->m_footprintsTested ) if( m_tester->m_footprintsTested )
msg.sprintf( m_footprintsTitleTemplate, (int) m_FootprintsListBox->GetItemCount() ); msg.sprintf( m_footprintsTitleTemplate, (int) m_footprintsTreeModel->GetDRCItemCount() );
else else
{ {
msg = m_footprintsTitleTemplate; msg = m_footprintsTitleTemplate;

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2011 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2011 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -34,12 +34,12 @@
#include <class_marker_pcb.h> #include <class_marker_pcb.h>
#include <class_board.h> #include <class_board.h>
#include <dialog_drc_base.h> #include <dialog_drc_base.h>
#include <dialog_drclistbox.h>
#include <widgets/unit_binder.h> #include <widgets/unit_binder.h>
// forward declarations // forward declarations
class DRCLISTBOX; class DRC_ITEMS_PROVIDER;
class BOARD_DESIGN_SETTINGS; class BOARD_DESIGN_SETTINGS;
class DRC_TREE_MODEL;
//end forward declarations //end forward declarations
@ -66,8 +66,11 @@ public:
void GetRptSettings( bool* aEnable, wxString& aFileName ); void GetRptSettings( bool* aEnable, wxString& aFileName );
void UpdateDisplayedCounts(); void SetMarkersProvider( DRC_ITEMS_PROVIDER* aProvider );
void SetUnconnectedProvider( DRC_ITEMS_PROVIDER* aProvider );
void SetFootprintsProvider( DRC_ITEMS_PROVIDER* aProvider );
void UpdateDisplayedCounts();
private: private:
/** /**
@ -92,73 +95,33 @@ private:
void SetDRCParameters( ); void SetDRCParameters( );
/// @return the selection on a right click on a DRCLISTBOX
/// return wxNOT_FOUND if no selection
int rightUpClicSelection( DRCLISTBOX* aListBox, wxMouseEvent& event );
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_RPT_FILE
void OnReportCheckBoxClicked( wxCommandEvent& event ) override; void OnReportCheckBoxClicked( wxCommandEvent& event ) override;
/// wxEVT_COMMAND_TEXT_UPDATED event handler for m_RptFilenameCtrl
void OnReportFilenameEdited( wxCommandEvent &event ) override; void OnReportFilenameEdited( wxCommandEvent &event ) override;
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_RPT_FILE
void OnButtonBrowseRptFileClick( wxCommandEvent& event ) override; void OnButtonBrowseRptFileClick( wxCommandEvent& event ) override;
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_STARTDRC void OnRunDRCClick( wxCommandEvent& event ) override;
void OnStartdrcClick( wxCommandEvent& event ) override;
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ALL
void OnDeleteAllClick( wxCommandEvent& event ) override; void OnDeleteAllClick( wxCommandEvent& event ) override;
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE
void OnDeleteOneClick( wxCommandEvent& event ) override; void OnDeleteOneClick( wxCommandEvent& event ) override;
/// wxEVT_LEFT_DCLICK event handler for ID_CLEARANCE_LIST void OnDRCItemSelected( wxDataViewEvent& event ) override;
void OnLeftDClickClearance( wxMouseEvent& event ) override;
/// wxEVT_LEFT_UP event handler for ID_CLEARANCE_LIST void OnDClick( wxDataViewCtrl* ctrl, wxMouseEvent& event );
void OnLeftUpClearance( wxMouseEvent& event ) override; void OnMarkerDClick( wxMouseEvent& event ) override;
/// wxEVT_RIGHT_UP event handler for ID_CLEARANCE_LIST
void OnRightUpClearance( wxMouseEvent& event ) override;
/// wxEVT_LEFT_DCLICK event handler for ID_UNCONNECTED_LIST
void OnLeftDClickUnconnected( wxMouseEvent& event ) override; void OnLeftDClickUnconnected( wxMouseEvent& event ) override;
/// wxEVT_LEFT_UP event handler for ID_UNCONNECTED_LIST
void OnLeftUpUnconnected( wxMouseEvent& event ) override;
/// wxEVT_RIGHT_UP event handler for ID_UNCONNECTED_LIST
void OnRightUpUnconnected( wxMouseEvent& event ) override;
/// wxEVT_LEFT_DCLICK event handler for ID_FOOTPRINTS_LIST
void OnLeftDClickFootprints( wxMouseEvent& event ) override; void OnLeftDClickFootprints( wxMouseEvent& event ) override;
/// wxEVT_RIGHT_UP event handler for ID_FOOTPRINTS_LIST
void OnRightUpFootprints( wxMouseEvent& event ) override;
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event ) override; void OnCancelClick( wxCommandEvent& event ) override;
/// handler for activate event, updating data which can be modified outside the dialog /// handler for activate event, updating data which can be modified outside the dialog
/// (DRC parameters) /// (DRC parameters)
void OnActivateDlg( wxActivateEvent& event ) override; void OnActivateDlg( wxActivateEvent& event ) override;
void OnMarkerSelectionEvent( wxCommandEvent& event ) override; void OnChangingNotebookPage( wxNotebookEvent& event ) override;
void OnUnconnectedSelectionEvent( wxCommandEvent& event ) override;
void OnFootprintsSelectionEvent( wxCommandEvent& event ) override;
void OnChangingMarkerList( wxNotebookEvent& event ) override;
void DelDRCMarkers(); void DelDRCMarkers();
void RedrawDrawPanel(); void RedrawDrawPanel();
/// Run the SELECTION_TOOL's disambiguation menu to highlight the two BOARD_ITEMs
/// in the DRC_ITEM.
void doSelectionMenu( const DRC_ITEM* aItem );
bool focusOnItem( const DRC_ITEM* aItem );
BOARD* m_currentBoard; // the board currently on test BOARD* m_currentBoard; // the board currently on test
DRC* m_tester; DRC* m_tester;
PCB_EDIT_FRAME* m_brdEditor; PCB_EDIT_FRAME* m_brdEditor;
@ -170,6 +133,10 @@ private:
UNIT_BINDER m_trackMinWidth; UNIT_BINDER m_trackMinWidth;
UNIT_BINDER m_viaMinSize; UNIT_BINDER m_viaMinSize;
UNIT_BINDER m_uviaMinSize; UNIT_BINDER m_uviaMinSize;
DRC_TREE_MODEL* m_markerTreeModel;
DRC_TREE_MODEL* m_unconnectedTreeModel;
DRC_TREE_MODEL* m_footprintsTreeModel;
}; };
#endif // _DIALOG_DRC_H_ #endif // _DIALOG_DRC_H_

View File

@ -1,12 +1,10 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version v3.8.0) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_drclistbox.h"
#include "dialog_drc_base.h" #include "dialog_drc_base.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -32,50 +30,50 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
fgMinValuesSizer->SetFlexibleDirection( wxHORIZONTAL ); fgMinValuesSizer->SetFlexibleDirection( wxHORIZONTAL );
fgMinValuesSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgMinValuesSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_TrackMinWidthTitle = new wxStaticText( this, wxID_ANY, _("Minimum track width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_MinWidthLabel = new wxStaticText( this, wxID_ANY, _("Minimum track width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackMinWidthTitle->Wrap( -1 ); m_MinWidthLabel->Wrap( -1 );
m_TrackMinWidthTitle->SetToolTip( _("Enter the minimum acceptable value for a track width") ); m_MinWidthLabel->SetToolTip( _("Enter the minimum acceptable value for a track width") );
fgMinValuesSizer->Add( m_TrackMinWidthTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT, 5 ); fgMinValuesSizer->Add( m_MinWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT, 5 );
m_SetTrackMinWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_MinWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgMinValuesSizer->Add( m_SetTrackMinWidthCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 ); fgMinValuesSizer->Add( m_MinWidthCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 );
m_TrackMinWidthUnit = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_MinWidthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_TrackMinWidthUnit->Wrap( -1 ); m_MinWidthUnits->Wrap( -1 );
m_TrackMinWidthUnit->SetToolTip( _("Enter the minimum acceptable value for a track width") ); m_MinWidthUnits->SetToolTip( _("Enter the minimum acceptable value for a track width") );
fgMinValuesSizer->Add( m_TrackMinWidthUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); fgMinValuesSizer->Add( m_MinWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_ViaMinTitle = new wxStaticText( this, wxID_ANY, _("Minimum via size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaMinLabel = new wxStaticText( this, wxID_ANY, _("Minimum via size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ViaMinTitle->Wrap( -1 ); m_ViaMinLabel->Wrap( -1 );
m_ViaMinTitle->SetHelpText( _("Enter the minimum acceptable diameter for a standard via") ); m_ViaMinLabel->SetHelpText( _("Enter the minimum acceptable diameter for a standard via") );
fgMinValuesSizer->Add( m_ViaMinTitle, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); fgMinValuesSizer->Add( m_ViaMinLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_SetViaMinSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_ViaMinCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgMinValuesSizer->Add( m_SetViaMinSizeCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 3 ); fgMinValuesSizer->Add( m_ViaMinCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 3 );
m_ViaMinUnit = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaMinUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_ViaMinUnit->Wrap( -1 ); m_ViaMinUnits->Wrap( -1 );
m_ViaMinUnit->SetHelpText( _("Enter the minimum acceptable diameter for a standard via") ); m_ViaMinUnits->SetHelpText( _("Enter the minimum acceptable diameter for a standard via") );
fgMinValuesSizer->Add( m_ViaMinUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); fgMinValuesSizer->Add( m_ViaMinUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_MicroViaMinTitle = new wxStaticText( this, wxID_ANY, _("Minimum uVia size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_uViaMinLabel = new wxStaticText( this, wxID_ANY, _("Minimum uVia size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_MicroViaMinTitle->Wrap( -1 ); m_uViaMinLabel->Wrap( -1 );
m_MicroViaMinTitle->SetToolTip( _("Enter the minimum acceptable diameter for a micro via") ); m_uViaMinLabel->SetToolTip( _("Enter the minimum acceptable diameter for a micro via") );
fgMinValuesSizer->Add( m_MicroViaMinTitle, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); fgMinValuesSizer->Add( m_uViaMinLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_SetMicroViakMinSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_uViaMinCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgMinValuesSizer->Add( m_SetMicroViakMinSizeCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 ); fgMinValuesSizer->Add( m_uViaMinCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 );
m_MicroViaMinUnit = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_uViaMinUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_MicroViaMinUnit->Wrap( -1 ); m_uViaMinUnits->Wrap( -1 );
m_MicroViaMinUnit->SetToolTip( _("Enter the minimum acceptable diameter for a micro via") ); m_uViaMinUnits->SetToolTip( _("Enter the minimum acceptable diameter for a micro via") );
fgMinValuesSizer->Add( m_MicroViaMinUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); fgMinValuesSizer->Add( m_uViaMinUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bSizerOptions->Add( fgMinValuesSizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); bSizerOptions->Add( fgMinValuesSizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
@ -148,11 +146,10 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerViolationsBox; wxBoxSizer* bSizerViolationsBox;
bSizerViolationsBox = new wxBoxSizer( wxVERTICAL ); bSizerViolationsBox = new wxBoxSizer( wxVERTICAL );
m_ClearanceListBox = new DRCLISTBOX( m_panelViolations, ID_CLEARANCE_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_markerDataView = new wxDataViewCtrl( m_panelViolations, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_NO_HEADER );
m_ClearanceListBox->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); m_markerDataView->SetToolTip( _("Click on items to highlight them on the board.") );
m_ClearanceListBox->SetToolTip( _("Left-click to center on problem marker. \nRight-click to highlight items.") );
bSizerViolationsBox->Add( m_ClearanceListBox, 1, wxEXPAND|wxALL, 5 ); bSizerViolationsBox->Add( m_markerDataView, 1, wxALL|wxEXPAND, 5 );
m_panelViolations->SetSizer( bSizerViolationsBox ); m_panelViolations->SetSizer( bSizerViolationsBox );
@ -163,10 +160,8 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerUnconnectedBox; wxBoxSizer* bSizerUnconnectedBox;
bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL ); bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL );
m_UnconnectedListBox = new DRCLISTBOX( m_panelUnconnectedItems, ID_UNCONNECTED_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_unconnectedDataView = new wxDataViewCtrl( m_panelUnconnectedItems, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_UnconnectedListBox->SetToolTip( _("Left-click to center on unconnected pair. \nRight-click to highlight unconnected items.") ); bSizerUnconnectedBox->Add( m_unconnectedDataView, 1, wxALL|wxEXPAND, 5 );
bSizerUnconnectedBox->Add( m_UnconnectedListBox, 1, wxALL|wxEXPAND, 5 );
m_panelUnconnectedItems->SetSizer( bSizerUnconnectedBox ); m_panelUnconnectedItems->SetSizer( bSizerUnconnectedBox );
@ -177,8 +172,8 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerFootprintsBox; wxBoxSizer* bSizerFootprintsBox;
bSizerFootprintsBox = new wxBoxSizer( wxVERTICAL ); bSizerFootprintsBox = new wxBoxSizer( wxVERTICAL );
m_FootprintsListBox = new DRCLISTBOX( m_panelFootprintWarnings, ID_FOOTPRINTS_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_footprintsDataView = new wxDataViewCtrl( m_panelFootprintWarnings, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
bSizerFootprintsBox->Add( m_FootprintsListBox, 1, wxALL|wxEXPAND, 5 ); bSizerFootprintsBox->Add( m_footprintsDataView, 1, wxALL|wxEXPAND, 5 );
m_panelFootprintWarnings->SetSizer( bSizerFootprintsBox ); m_panelFootprintWarnings->SetSizer( bSizerFootprintsBox );
@ -218,22 +213,17 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_CreateRptCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportCheckBoxClicked ), NULL, this ); m_CreateRptCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportCheckBoxClicked ), NULL, this );
m_RptFilenameCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportFilenameEdited ), NULL, this ); m_RptFilenameCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportFilenameEdited ), NULL, this );
m_BrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this ); m_BrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this );
m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingMarkerList ), NULL, this ); m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingNotebookPage ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickClearance ), NULL, this ); m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpClearance ), NULL, this ); m_markerDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerDClick ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerSelectionEvent ), NULL, this ); m_unconnectedDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpClearance ), NULL, this ); m_unconnectedDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this ); m_footprintsDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpUnconnected ), NULL, this ); m_footprintsDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnUnconnectedSelectionEvent ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpUnconnected ), NULL, this );
m_FootprintsListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this );
m_FootprintsListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnFootprintsSelectionEvent ), NULL, this );
m_FootprintsListBox->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpFootprints ), NULL, this );
m_DeleteCurrentMarkerButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteOneClick ), NULL, this ); m_DeleteCurrentMarkerButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteOneClick ), NULL, this );
m_DeleteAllMarkersButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteAllClick ), NULL, this ); m_DeleteAllMarkersButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteAllClick ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnStartdrcClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnRunDRCClick ), NULL, this );
} }
DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE() DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE()
@ -243,21 +233,16 @@ DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE()
m_CreateRptCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportCheckBoxClicked ), NULL, this ); m_CreateRptCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportCheckBoxClicked ), NULL, this );
m_RptFilenameCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportFilenameEdited ), NULL, this ); m_RptFilenameCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportFilenameEdited ), NULL, this );
m_BrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this ); m_BrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this );
m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingMarkerList ), NULL, this ); m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingNotebookPage ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickClearance ), NULL, this ); m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpClearance ), NULL, this ); m_markerDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerDClick ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerSelectionEvent ), NULL, this ); m_unconnectedDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpClearance ), NULL, this ); m_unconnectedDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this ); m_footprintsDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpUnconnected ), NULL, this ); m_footprintsDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnUnconnectedSelectionEvent ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpUnconnected ), NULL, this );
m_FootprintsListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this );
m_FootprintsListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnFootprintsSelectionEvent ), NULL, this );
m_FootprintsListBox->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpFootprints ), NULL, this );
m_DeleteCurrentMarkerButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteOneClick ), NULL, this ); m_DeleteCurrentMarkerButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteOneClick ), NULL, this );
m_DeleteAllMarkersButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteAllClick ), NULL, this ); m_DeleteAllMarkersButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteAllClick ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnStartdrcClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnRunDRCClick ), NULL, this );
} }

View File

@ -143,7 +143,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_TrackMinWidthTitle</property> <property name="name">m_MinWidthLabel</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -203,7 +203,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_SetTrackMinWidthCtrl</property> <property name="name">m_MinWidthCtrl</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -268,7 +268,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_TrackMinWidthUnit</property> <property name="name">m_MinWidthUnits</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -329,7 +329,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_ViaMinTitle</property> <property name="name">m_ViaMinLabel</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -389,7 +389,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_SetViaMinSizeCtrl</property> <property name="name">m_ViaMinCtrl</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -454,7 +454,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_ViaMinUnit</property> <property name="name">m_ViaMinUnits</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -515,7 +515,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_MicroViaMinTitle</property> <property name="name">m_uViaMinLabel</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -575,7 +575,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_SetMicroViakMinSizeCtrl</property> <property name="name">m_uViaMinCtrl</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -640,7 +640,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_MicroViaMinUnit</property> <property name="name">m_uViaMinUnits</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1281,7 +1281,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnNotebookPageChanged">OnChangingMarkerList</event> <event name="OnNotebookPageChanged">OnChangingNotebookPage</event>
<object class="notebookpage" expanded="1"> <object class="notebookpage" expanded="1">
<property name="bitmap"></property> <property name="bitmap"></property>
<property name="label">Violations / Markers (%d)</property> <property name="label">Violations / Markers (%d)</property>
@ -1342,71 +1342,33 @@
<property name="name">bSizerViolationsBox</property> <property name="name">bSizerViolationsBox</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxListBox" expanded="0"> <object class="wxDataViewCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property> <property name="font"></property>
<property name="font">,90,90,-1,70,0</property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">ID_CLEARANCE_LIST</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property> <property name="minimum_size"></property>
<property name="minimize_button">0</property> <property name="name">m_markerDataView</property>
<property name="minimum_size">-1,-1</property> <property name="permission">protected</property>
<property name="moveable">1</property>
<property name="name">m_ClearanceListBox</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style">wxDV_NO_HEADER</property>
<property name="subclass">DRCLISTBOX; dialog_drclistbox.h</property> <property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property> <property name="tooltip">Click on items to highlight them on the board.</property>
<property name="tooltip">Left-click to center on problem marker. &#x0A;Right-click to highlight items.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnLeftDClick">OnLeftDClickClearance</event> <event name="OnDataViewCtrlSelectionChanged">OnDRCItemSelected</event>
<event name="OnLeftUp">OnLeftUpClearance</event> <event name="OnLeftDClick">OnMarkerDClick</event>
<event name="OnListBox">OnMarkerSelectionEvent</event>
<event name="OnRightUp">OnRightUpClearance</event>
</object> </object>
</object> </object>
</object> </object>
@ -1472,71 +1434,33 @@
<property name="name">bSizerUnconnectedBox</property> <property name="name">bSizerUnconnectedBox</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxListBox" expanded="0"> <object class="wxDataViewCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">ID_UNCONNECTED_LIST</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="name">m_unconnectedDataView</property>
<property name="name">m_UnconnectedListBox</property> <property name="permission">protected</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style"></property>
<property name="subclass">DRCLISTBOX; </property> <property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property> <property name="tooltip"></property>
<property name="tooltip">Left-click to center on unconnected pair. &#x0A;Right-click to highlight unconnected items.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnDataViewCtrlSelectionChanged">OnDRCItemSelected</event>
<event name="OnLeftDClick">OnLeftDClickUnconnected</event> <event name="OnLeftDClick">OnLeftDClickUnconnected</event>
<event name="OnLeftUp">OnLeftUpUnconnected</event>
<event name="OnListBox">OnUnconnectedSelectionEvent</event>
<event name="OnRightUp">OnRightUpUnconnected</event>
</object> </object>
</object> </object>
</object> </object>
@ -1606,66 +1530,29 @@
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxListBox" expanded="1"> <object class="wxDataViewCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">ID_FOOTPRINTS_LIST</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="name">m_footprintsDataView</property>
<property name="name">m_FootprintsListBox</property> <property name="permission">protected</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style"></property>
<property name="subclass">DRCLISTBOX; ; forward_declare</property> <property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnDataViewCtrlSelectionChanged">OnDRCItemSelected</event>
<event name="OnLeftDClick">OnLeftDClickFootprints</event> <event name="OnLeftDClick">OnLeftDClickFootprints</event>
<event name="OnListBox">OnFootprintsSelectionEvent</event>
<event name="OnRightUp">OnRightUpFootprints</event>
</object> </object>
</object> </object>
</object> </object>
@ -1845,7 +1732,7 @@
<property name="name">m_sdbSizer1</property> <property name="name">m_sdbSizer1</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<event name="OnCancelButtonClick">OnCancelClick</event> <event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnOKButtonClick">OnStartdrcClick</event> <event name="OnOKButtonClick">OnRunDRCClick</event>
</object> </object>
</object> </object>
</object> </object>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version v3.8.0) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -10,8 +10,6 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DRCLISTBOX;
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/stattext.h> #include <wx/stattext.h>
@ -28,7 +26,7 @@ class DRCLISTBOX;
#include <wx/icon.h> #include <wx/icon.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/gbsizer.h> #include <wx/gbsizer.h>
#include <wx/listbox.h> #include <wx/dataview.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -38,9 +36,6 @@ class DRCLISTBOX;
#define ID_CHECKBOX_RPT_FILE 1000 #define ID_CHECKBOX_RPT_FILE 1000
#define ID_BUTTON_BROWSE_RPT_FILE 1001 #define ID_BUTTON_BROWSE_RPT_FILE 1001
#define ID_NOTEBOOK1 1002 #define ID_NOTEBOOK1 1002
#define ID_CLEARANCE_LIST 1003
#define ID_UNCONNECTED_LIST 1004
#define ID_FOOTPRINTS_LIST 1005
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_DRC_CONTROL_BASE /// Class DIALOG_DRC_CONTROL_BASE
@ -51,12 +46,12 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM
wxPanel* m_panelUnconnectedItems; wxPanel* m_panelUnconnectedItems;
protected: protected:
wxStaticText* m_TrackMinWidthTitle; wxStaticText* m_MinWidthLabel;
wxStaticText* m_TrackMinWidthUnit; wxStaticText* m_MinWidthUnits;
wxStaticText* m_ViaMinTitle; wxStaticText* m_ViaMinLabel;
wxStaticText* m_ViaMinUnit; wxStaticText* m_ViaMinUnits;
wxStaticText* m_MicroViaMinTitle; wxStaticText* m_uViaMinLabel;
wxStaticText* m_MicroViaMinUnit; wxStaticText* m_uViaMinUnits;
wxCheckBox* m_cbRefillZones; wxCheckBox* m_cbRefillZones;
wxCheckBox* m_cbReportAllTrackErrors; wxCheckBox* m_cbReportAllTrackErrors;
wxCheckBox* m_cbReportTracksToZonesErrors; wxCheckBox* m_cbReportTracksToZonesErrors;
@ -67,7 +62,10 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM
wxBitmapButton* m_BrowseButton; wxBitmapButton* m_BrowseButton;
wxNotebook* m_Notebook; wxNotebook* m_Notebook;
wxPanel* m_panelViolations; wxPanel* m_panelViolations;
wxDataViewCtrl* m_markerDataView;
wxDataViewCtrl* m_unconnectedDataView;
wxPanel* m_panelFootprintWarnings; wxPanel* m_panelFootprintWarnings;
wxDataViewCtrl* m_footprintsDataView;
wxBoxSizer* m_sizerButtons; wxBoxSizer* m_sizerButtons;
wxButton* m_DeleteCurrentMarkerButton; wxButton* m_DeleteCurrentMarkerButton;
wxButton* m_DeleteAllMarkersButton; wxButton* m_DeleteAllMarkersButton;
@ -80,31 +78,21 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM
virtual void OnReportCheckBoxClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnReportCheckBoxClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnReportFilenameEdited( wxCommandEvent& event ) { event.Skip(); } virtual void OnReportFilenameEdited( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonBrowseRptFileClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonBrowseRptFileClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnChangingMarkerList( wxNotebookEvent& event ) { event.Skip(); } virtual void OnChangingNotebookPage( wxNotebookEvent& event ) { event.Skip(); }
virtual void OnLeftDClickClearance( wxMouseEvent& event ) { event.Skip(); } virtual void OnDRCItemSelected( wxDataViewEvent& event ) { event.Skip(); }
virtual void OnLeftUpClearance( wxMouseEvent& event ) { event.Skip(); } virtual void OnMarkerDClick( wxMouseEvent& event ) { event.Skip(); }
virtual void OnMarkerSelectionEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRightUpClearance( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftDClickUnconnected( wxMouseEvent& event ) { event.Skip(); } virtual void OnLeftDClickUnconnected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftUpUnconnected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnUnconnectedSelectionEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRightUpUnconnected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftDClickFootprints( wxMouseEvent& event ) { event.Skip(); } virtual void OnLeftDClickFootprints( wxMouseEvent& event ) { event.Skip(); }
virtual void OnFootprintsSelectionEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRightUpFootprints( wxMouseEvent& event ) { event.Skip(); }
virtual void OnDeleteOneClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnDeleteOneClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDeleteAllClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnDeleteAllClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnStartdrcClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnRunDRCClick( wxCommandEvent& event ) { event.Skip(); }
public: public:
wxTextCtrl* m_SetTrackMinWidthCtrl; wxTextCtrl* m_MinWidthCtrl;
wxTextCtrl* m_SetViaMinSizeCtrl; wxTextCtrl* m_ViaMinCtrl;
wxTextCtrl* m_SetMicroViakMinSizeCtrl; wxTextCtrl* m_uViaMinCtrl;
DRCLISTBOX* m_ClearanceListBox;
DRCLISTBOX* m_UnconnectedListBox;
DRCLISTBOX* m_FootprintsListBox;
DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("DRC Control"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("DRC Control"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_DRC_CONTROL_BASE(); ~DIALOG_DRC_CONTROL_BASE();

View File

@ -1,308 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _DIALOG_DRCLISTBOX_H_
#define _DIALOG_DRCLISTBOX_H_
#include <wx/htmllbox.h>
#include <fctsys.h>
#include <pcbnew.h>
#include <drc/drc.h>
#include <class_marker_pcb.h>
#include <class_board.h>
#include <dialog_drc_base.h>
/**
* DRC_LIST_MARKERS
* is an implementation of the interface named DRC_ITEM_LIST which uses
* a BOARD instance to fulfill the interface. No ownership is taken of the
* BOARD.
*/
class DRC_LIST_MARKERS : public DRC_ITEM_LIST
{
BOARD* m_board;
public:
DRC_LIST_MARKERS( BOARD* aBoard ) :
m_board(aBoard)
{
}
/* no destructor since we do not own anything to delete, not even the BOARD.
~DRC_LIST_MARKERS() {}
*/
//-----<Interface DRC_ITEM_LIST>---------------------------------------
void DeleteAllItems() override
{
m_board->DeleteMARKERs();
}
const DRC_ITEM* GetItem( int aIndex ) override
{
const MARKER_PCB* marker = m_board->GetMARKER( aIndex );
if( marker )
return &marker->GetReporter();
return NULL;
}
void DeleteItem( int aIndex ) override
{
MARKER_PCB* marker = m_board->GetMARKER( aIndex );
if( marker )
m_board->Delete( marker );
}
/**
* Function GetCount
* returns the number of items in the list.
*/
int GetCount() override
{
return m_board->GetMARKERCount();
}
//-----</Interface DRC_ITEM_LIST>--------------------------------------
};
/**
* DRC_LIST_GENERIC
* is an implementation of the interface named DRC_ITEM_LIST which uses
* a vector of pointers to DRC_ITEMs to fulfill the interface. No ownership is taken of the
* vector, which will reside in class DRC
*/
class DRC_LIST_GENERIC : public DRC_ITEM_LIST
{
DRC_LIST* m_vector;
public:
DRC_LIST_GENERIC( DRC_LIST* aList ) :
m_vector(aList)
{
}
/* no destructor since we do not own anything to delete, not even the BOARD.
~DRC_LIST_GENERIC() {}
*/
//-----<Interface DRC_ITEM_LIST>---------------------------------------
void DeleteAllItems() override
{
if( m_vector )
{
for( unsigned i=0; i<m_vector->size(); ++i )
delete (*m_vector)[i];
m_vector->clear();
}
}
const DRC_ITEM* GetItem( int aIndex ) override
{
if( m_vector && (unsigned)aIndex < m_vector->size() )
{
const DRC_ITEM* item = (*m_vector)[aIndex];
return item;
}
return NULL;
}
void DeleteItem( int aIndex ) override
{
if( m_vector && (unsigned)aIndex < m_vector->size() )
{
delete (*m_vector)[aIndex];
m_vector->erase( m_vector->begin()+aIndex );
}
}
/**
* Function GetCount
* returns the number of items in the list.
*/
int GetCount() override
{
if( m_vector )
{
return m_vector->size();
}
return 0;
}
//-----</Interface DRC_ITEM_LIST>--------------------------------------
};
/**
* DRCLISTBOX
* is used to display a DRC_ITEM_LIST.
*/
class DRCLISTBOX : public wxHtmlListBox
{
private:
EDA_UNITS m_units;
DRC_ITEM_LIST* m_list; ///< wxHtmlListBox does not own the list, I do
public:
DRCLISTBOX( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString choices[] = NULL, int unused = 0)
: wxHtmlListBox( parent, id, pos, size, style )
{
m_units = EDA_UNITS::MILLIMETRES;
m_list = 0;
}
~DRCLISTBOX()
{
delete m_list; // I own it, I destroy it.
}
/**
* Function SetList
* sets the DRC_ITEM_LIST for this listbox. Ownership of the DRC_ITEM_LIST is
* transfered to this DRCLISTBOX.
* @param aList The DRC_ITEM_LIST* containing the DRC_ITEMs which will be
* displayed in the wxHtmlListBox
*/
void SetList( EDA_UNITS aUnits, DRC_ITEM_LIST* aList )
{
delete m_list;
m_units = aUnits;
m_list = aList;
SetItemCount( aList->GetCount() );
Refresh();
}
/**
* Function GetItem
* returns a requested DRC_ITEM* or NULL.
*/
const DRC_ITEM* GetItem( int aIndex )
{
if( m_list )
{
return m_list->GetItem( aIndex );
}
return NULL;
}
/**
* Function OnGetItem
* returns the html text associated with the DRC_ITEM given by index 'n'.
* @param n An index into the list.
* @return wxString - the simple html text to show in the listbox.
*/
wxString OnGetItem( size_t n ) const override
{
if( m_list )
{
const DRC_ITEM* item = m_list->GetItem( (int) n );
if( item )
{
wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
return wxString::Format( wxT( "<font color='%s'>%s</font>" ),
color.GetAsString( wxC2S_HTML_SYNTAX ),
item->ShowHtml( m_units ) );
}
}
return wxString();
}
/**
* Function OnGetItem
* returns the html text associated with the given index 'n'.
* @param n An index into the list.
* @return wxString - the simple html text to show in the listbox.
*/
wxString OnGetItemMarkup( size_t n ) const override
{
return OnGetItem( n );
}
/**
* Function DeleteElement
* will delete one of the items in the list.
* @param aIndex The index into the list to delete.
*/
void DeleteItem( int aIndex )
{
if( m_list )
{
int selection = GetSelection();
m_list->DeleteItem( aIndex );
int count = m_list->GetCount();
SetItemCount( count );
// if old selection >= new count
if( selection >= count )
SetSelection( count-1 ); // -1 is "no selection"
Refresh();
}
}
/**
* Function DeleteAllItems
* deletes all items in the list.
*/
void DeleteAllItems()
{
if( m_list )
{
m_list->DeleteAllItems();
SetItemCount(0);
SetSelection( -1 ); // -1 is no selection
Refresh();
}
}
};
#endif // _DIALOG_DRCLISTBOX_H_

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2004-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2004-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2017-2019 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2017-2020 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -34,12 +34,8 @@
#include <class_pad.h> #include <class_pad.h>
#include <class_zone.h> #include <class_zone.h>
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <geometry/seg.h> #include <geometry/seg.h>
#include <math_for_graphics.h> #include <math_for_graphics.h>
#include <geometry/geometry_utils.h>
#include <connectivity/connectivity_data.h>
#include <connectivity/connectivity_algo.h> #include <connectivity/connectivity_algo.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
@ -54,11 +50,11 @@
#include <dialog_drc.h> #include <dialog_drc.h>
#include <wx/progdlg.h> #include <wx/progdlg.h>
#include <board_commit.h> #include <board_commit.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_arc.h> #include <geometry/shape_arc.h>
#include <drc/courtyard_overlap.h> #include <drc/courtyard_overlap.h>
#include <tools/zone_filler_tool.h> #include <tools/zone_filler_tool.h>
#include "drc_tree_model.h"
DRC::DRC() : DRC::DRC() :
PCB_TOOL_BASE( "pcbnew.DRCTool" ), PCB_TOOL_BASE( "pcbnew.DRCTool" ),
@ -525,12 +521,9 @@ void DRC::updatePointers()
if( m_drcDialog ) // Use diag list boxes only in DRC dialog if( m_drcDialog ) // Use diag list boxes only in DRC dialog
{ {
m_drcDialog->m_ClearanceListBox->SetList( m_drcDialog->SetMarkersProvider( new BOARD_DRC_ITEMS_PROVIDER( m_pcb ) );
m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_MARKERS( m_pcb ) ); m_drcDialog->SetUnconnectedProvider( new VECTOR_DRC_ITEMS_PROVIDER( &m_unconnected ) );
m_drcDialog->m_UnconnectedListBox->SetList( m_drcDialog->SetFootprintsProvider( new VECTOR_DRC_ITEMS_PROVIDER( &m_footprints ) );
m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_GENERIC( &m_unconnected ) );
m_drcDialog->m_FootprintsListBox->SetList(
m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_GENERIC( &m_footprints ) );
m_drcDialog->UpdateDisplayedCounts(); m_drcDialog->UpdateDisplayedCounts();
} }

View File

@ -129,49 +129,6 @@ class wxString;
class wxTextCtrl; class wxTextCtrl;
/**
* Provide an abstract interface of a DRC_ITEM* list manager. The details
* of the actual list architecture are hidden from the caller. Any class
* that implements this interface can then be used by a DRCLISTBOX class without
* it knowing the actual architecture of the list.
*/
class DRC_ITEM_LIST
{
public:
/**
* Function DeleteAllItems
* removes and deletes all the items in the list.
*/
virtual void DeleteAllItems() = 0;
/**
* Function GetItem
* retrieves a DRC_ITEM by pointer. The actual item remains owned by the
* list container.
* @param aIndex The 0 based index into the list of the desired item.
* @return const DRC_ITEM* - the desired item or NULL if aIndex is out of range.
*/
virtual const DRC_ITEM* GetItem( int aIndex ) = 0;
/**
* Function DeleteAllItems
* removes and deletes desired item from the list.
* @param aIndex The 0 based index into the list of the desired item which
* is to be deleted.
*/
virtual void DeleteItem( int aIndex ) = 0;
/**
* Function GetCount
* returns the number of items in the list.
*/
virtual int GetCount() = 0;
virtual ~DRC_ITEM_LIST() { }
};
typedef std::vector<DRC_ITEM*> DRC_LIST; typedef std::vector<DRC_ITEM*> DRC_LIST;

395
pcbnew/drc/drc_tree_model.h Normal file
View File

@ -0,0 +1,395 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KICAD_DRC_TREE_MODEL_H
#define KICAD_DRC_TREE_MODEL_H
#include <drc/drc.h>
#include <wx/wupdlock.h>
/**
* Provide an abstract interface of a DRC_ITEM* list manager. The details
* of the actual list architecture are hidden from the caller. Any class
* that implements this interface can then be used by a DRC_TREE_MODEL class without
* it knowing the actual architecture of the list.
*/
class DRC_ITEMS_PROVIDER
{
public:
virtual int GetCount() = 0;
/**
* Function GetItem
* retrieves a DRC_ITEM by pointer. The actual item remains owned by the
* list container.
* @param aIndex The 0 based index into the list of the desired item.
* @return const DRC_ITEM* - the desired item or NULL if aIndex is out of range.
*/
virtual const DRC_ITEM* GetItem( int aIndex ) = 0;
/**
* Function DeleteItems
* removes and deletes desired item from the list.
* @param aIndex The 0 based index into the list of the desired item which
* is to be deleted.
*/
virtual void DeleteItem( int aIndex ) = 0;
/**
* Function DeleteAllItems
* removes and deletes all the items in the list.
*/
virtual void DeleteAllItems() = 0;
virtual ~DRC_ITEMS_PROVIDER() { }
};
/**
* BOARD_DRC_ITEMS_PROVIDER
* is an implementation of the interface named DRC_ITEM_LIST which uses a BOARD instance
* to fulfill the interface. No ownership is taken of the BOARD.
*/
class BOARD_DRC_ITEMS_PROVIDER : public DRC_ITEMS_PROVIDER
{
BOARD* m_board;
public:
BOARD_DRC_ITEMS_PROVIDER( BOARD* aBoard ) :
m_board( aBoard )
{
}
int GetCount() override
{
return m_board->GetMARKERCount();
}
const DRC_ITEM* GetItem( int aIndex ) override
{
const MARKER_PCB* marker = m_board->GetMARKER( aIndex );
return marker ? &marker->GetReporter() : nullptr;
}
void DeleteItem( int aIndex ) override
{
MARKER_PCB* marker = m_board->GetMARKER( aIndex );
if( marker )
m_board->Delete( marker );
}
void DeleteAllItems() override
{
m_board->DeleteMARKERs();
}
};
/**
* VECTOR_DRC_ITEMS_PROVIDER
* is an implementation of the interface named DRC_ITEMS_PROVIDER which uses a vector
* of pointers to DRC_ITEMs to fulfill the interface. No ownership is taken of the
* vector.
*/
class VECTOR_DRC_ITEMS_PROVIDER : public DRC_ITEMS_PROVIDER
{
std::vector<DRC_ITEM*>* m_vector;
public:
VECTOR_DRC_ITEMS_PROVIDER( std::vector<DRC_ITEM*>* aList ) :
m_vector( aList )
{
}
int GetCount() override
{
return m_vector ? (int) m_vector->size() : 0;
}
const DRC_ITEM* GetItem( int aIndex ) override
{
return (*m_vector)[aIndex];
}
void DeleteItem( int aIndex ) override
{
delete (*m_vector)[aIndex];
m_vector->erase( m_vector->begin() + aIndex );
}
void DeleteAllItems() override
{
if( m_vector )
{
for( DRC_ITEM* item : *m_vector )
delete item;
m_vector->clear();
}
}
};
class DRC_TREE_NODE
{
public:
enum NODE_TYPE { MARKER, MAIN_ITEM, AUX_ITEM };
DRC_TREE_NODE( DRC_TREE_NODE* aParent, const DRC_ITEM* aDrcItem, NODE_TYPE aType ) :
m_Type( aType ),
m_Parent( aParent ),
m_DrcItem( aDrcItem )
{}
NODE_TYPE m_Type;
DRC_TREE_NODE* m_Parent;
const DRC_ITEM* m_DrcItem;
std::vector<DRC_TREE_NODE> m_Children;
};
class DRC_TREE_MODEL : public wxDataViewModel
{
public:
static wxDataViewItem ToItem( DRC_TREE_NODE const* aNode )
{
return wxDataViewItem( const_cast<void*>( static_cast<void const*>( aNode ) ) );
}
static DRC_TREE_NODE* ToNode( wxDataViewItem aItem )
{
return static_cast<DRC_TREE_NODE*>( aItem.GetID() );
}
static BOARD_ITEM* ToBoardItem( BOARD* aBoard, wxDataViewItem aItem )
{
BOARD_ITEM* board_item = nullptr;
const DRC_TREE_NODE* node = DRC_TREE_MODEL::ToNode( aItem );
if( node )
{
const DRC_ITEM* drc_item = node->m_DrcItem;
switch( node->m_Type )
{
case DRC_TREE_NODE::MARKER:
board_item = static_cast<MARKER_PCB*>( drc_item->GetParent() );
break;
case DRC_TREE_NODE::MAIN_ITEM:
board_item = drc_item->GetMainItem( aBoard );
break;
case DRC_TREE_NODE::AUX_ITEM:
board_item = drc_item->GetAuxiliaryItem( aBoard );
break;
}
}
return board_item;
};
public:
DRC_TREE_MODEL( wxDataViewCtrl* aView ) :
m_view( aView ),
m_drcItemsProvider( nullptr )
{ }
~DRC_TREE_MODEL()
{
delete m_drcItemsProvider;
}
void RebuildView()
{
wxWindowUpdateLocker updateLock( m_view );
// Even with the updateLock, wxWidgets sometimes ties its knickers in
// a knot when trying to run a wxdataview_selection_changed_callback()
// on a row that has been deleted.
// https://bugs.launchpad.net/kicad/+bug/1756255
m_view->UnselectAll();
Cleared();
#if defined( __LINUX__ )
// The fastest method to update wxDataViewCtrl is to rebuild from
// scratch by calling Cleared(). Linux requires to reassociate model to
// display data, but Windows will create multiple associations.
// On MacOS, this crashes kicad. See https://gitlab.com/kicad/code/kicad/issues/3666
// and https://gitlab.com/kicad/code/kicad/issues/3653
AttachTo( m_markerDataView );
#endif
}
void SetProvider( DRC_ITEMS_PROVIDER* aProvider )
{
delete m_drcItemsProvider;
m_drcItemsProvider = aProvider;
m_tree.clear();
for( int i = 0; m_drcItemsProvider && i < m_drcItemsProvider->GetCount(); ++i )
{
const DRC_ITEM* drcItem = m_drcItemsProvider->GetItem( i );
m_tree.emplace_back( nullptr, drcItem, DRC_TREE_NODE::MARKER );
DRC_TREE_NODE& node = m_tree.back();
node.m_Children.emplace_back( &node, drcItem, DRC_TREE_NODE::MAIN_ITEM );
if( drcItem->HasSecondItem() )
node.m_Children.emplace_back( &node, drcItem, DRC_TREE_NODE::AUX_ITEM );
}
RebuildView();
ExpandAll();
}
int GetDRCItemCount() const { return m_tree.size(); }
const DRC_ITEM* GetDRCItem( int i ) const { return m_tree.at( i ).m_DrcItem; }
void ExpandAll()
{
for( DRC_TREE_NODE& markerNode : m_tree )
m_view->Expand( ToItem( &markerNode ) );
}
bool IsContainer( wxDataViewItem const& aItem ) const override
{
return ToNode( aItem )->m_Type == DRC_TREE_NODE::MARKER;
}
wxDataViewItem GetParent( wxDataViewItem const& aItem ) const override
{
return ToItem( ToNode( aItem)->m_Parent );
}
unsigned int GetChildren( wxDataViewItem const& aItem,
wxDataViewItemArray& aChildren ) const override
{
const DRC_TREE_NODE* parent = ToNode( aItem );
const std::vector<DRC_TREE_NODE>& children = parent ? parent->m_Children : m_tree;
for( const DRC_TREE_NODE& child: children )
aChildren.Add( ToItem( &child ) );
return children.size();
}
// Simple, single-text-column model
unsigned int GetColumnCount() const override { return 1; }
wxString GetColumnType( unsigned int aCol ) const override { return "string"; }
bool HasContainerColumns( wxDataViewItem const& aItem ) const override { return true; }
/**
* Called by the wxDataView to fetch an item's value.
*/
void GetValue( wxVariant& aVariant,
wxDataViewItem const& aItem,
unsigned int aCol ) const override
{
const DRC_TREE_NODE* node = ToNode( aItem );
wxASSERT( node );
switch( node->m_Type )
{
case DRC_TREE_NODE::MARKER: aVariant = node->m_DrcItem->GetErrorText(); break;
case DRC_TREE_NODE::MAIN_ITEM: aVariant = node->m_DrcItem->GetMainText(); break;
case DRC_TREE_NODE::AUX_ITEM: aVariant = node->m_DrcItem->GetAuxiliaryText(); break;
}
}
/**
* Called by the wxDataView to edit an item's content.
*/
bool SetValue( wxVariant const& aVariant,
wxDataViewItem const& aItem,
unsigned int aCol ) override
{
// Editing not supported
return false;
}
/**
* Called by the wxDataView to fetch an item's formatting. Return true iff the
* item has non-default attributes.
*/
bool GetAttr( wxDataViewItem const& aItem,
unsigned int aCol,
wxDataViewItemAttr& aAttr ) const override
{
const DRC_TREE_NODE* node = ToNode( aItem );
wxASSERT( node );
switch( node->m_Type )
{
case DRC_TREE_NODE::MARKER: aAttr.SetBold( true ); return true;
case DRC_TREE_NODE::MAIN_ITEM: return false;
case DRC_TREE_NODE::AUX_ITEM: return false;
}
}
void DeleteCurrentItem()
{
DRC_TREE_NODE* node = ToNode( m_view->GetCurrentItem() );
const DRC_ITEM* item = node ? node->m_DrcItem : nullptr;
if( !item )
{
wxBell();
return;
}
for( int i = 0; i < m_drcItemsProvider->GetCount(); ++i )
{
if( m_drcItemsProvider->GetItem( i ) == item )
{
m_drcItemsProvider->DeleteItem( i );
m_tree.erase( m_tree.begin() + i );
RebuildView();
break;
}
}
}
void DeleteAllItems()
{
if( m_drcItemsProvider )
{
m_drcItemsProvider->DeleteAllItems();
m_tree.clear();
RebuildView();
}
}
private:
wxDataViewCtrl* m_view;
DRC_ITEMS_PROVIDER* m_drcItemsProvider; // I own this, but not its contents
std::vector<DRC_TREE_NODE> m_tree; // I own this
};
#endif //KICAD_DRC_TREE_MODEL_H