From 85c2e0d23a730571024f7d30cece8103c7dd7571 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 28 Feb 2020 00:05:40 +0000 Subject: [PATCH] Add user-defined severities, exclusions and colors to DRC markers. Exclusions are currently persisted in the project file. Fixes https://gitlab.com/kicad/code/kicad/issues/1989 --- 3d-viewer/3d_cache/dialogs/panel_prev_model.h | 1 - 3d-viewer/3d_canvas/status_text_reporter.h | 2 +- common/colors_design_settings.cpp | 253 -- common/common.cpp | 15 +- common/config_params.cpp | 60 +- common/dialogs/dialog_page_settings.cpp | 2 +- common/dialogs/wx_html_report_panel.cpp | 131 +- common/dialogs/wx_html_report_panel.h | 6 +- common/dialogs/wx_html_report_panel_base.cpp | 68 +- common/dialogs/wx_html_report_panel_base.fbp | 800 ++--- common/dialogs/wx_html_report_panel_base.h | 22 +- common/marker_base.cpp | 73 +- common/reporter.cpp | 22 +- common/settings/color_settings.cpp | 20 +- common/widgets/ui_common.cpp | 80 +- eeschema/annotate.cpp | 6 +- eeschema/component_references_lister.cpp | 10 +- eeschema/dialogs/dialog_erc.cpp | 6 +- eeschema/dialogs/dialog_netlist.cpp | 2 +- eeschema/dialogs/dialog_plot_schematic.cpp | 4 +- eeschema/dialogs/dialog_symbol_remap.cpp | 38 +- .../panel_eeschema_display_options.cpp | 2 +- eeschema/dialogs/panel_eeschema_settings.cpp | 2 +- eeschema/drc_erc_item.cpp | 10 +- eeschema/eeschema_config.cpp | 13 +- eeschema/files-io.cpp | 2 +- eeschema/netlist_generator.cpp | 16 +- eeschema/plot_schematic_DXF.cpp | 13 +- eeschema/plot_schematic_HPGL.cpp | 13 +- eeschema/plot_schematic_PDF.cpp | 16 +- eeschema/plot_schematic_PS.cpp | 13 +- eeschema/plot_schematic_SVG.cpp | 14 +- eeschema/sch_edit_frame.h | 4 +- eeschema/sch_marker.cpp | 24 +- eeschema/sch_marker.h | 3 + eeschema/sch_preview_panel.h | 2 - eeschema/sim/sim_plot_frame.cpp | 2 +- eeschema/tools/backannotate.cpp | 32 +- .../widgets/widget_eeschema_color_config.cpp | 4 +- gerbview/files.cpp | 32 +- gerbview/gerbview_draw_panel_gal.h | 2 - gerbview/gerbview_painter.h | 2 - gerbview/job_file_reader.cpp | 4 +- include/board_design_settings.h | 41 +- include/colors_design_settings.h | 118 - include/config_params.h | 36 +- include/drc_item.h | 190 +- include/eda_base_frame.h | 2 +- include/layers_id_colors_and_visibility.h | 4 +- include/marker_base.h | 146 +- include/reporter.h | 43 +- include/widgets/ui_common.h | 18 + pcbnew/CMakeLists.txt | 3 +- pcbnew/board_design_settings.cpp | 112 +- pcbnew/class_board.cpp | 19 +- pcbnew/class_board.h | 29 +- pcbnew/class_marker_pcb.cpp | 141 +- pcbnew/class_marker_pcb.h | 36 +- pcbnew/dialogs/dialog_board_setup.cpp | 3 + pcbnew/dialogs/dialog_board_setup.h | 2 + .../dialog_cleanup_tracks_and_vias.cpp | 5 +- pcbnew/dialogs/dialog_drc.cpp | 318 +- pcbnew/dialogs/dialog_drc.h | 39 +- pcbnew/dialogs/dialog_drc_base.cpp | 46 +- pcbnew/dialogs/dialog_drc_base.fbp | 1002 ++++--- pcbnew/dialogs/dialog_drc_base.h | 7 +- pcbnew/dialogs/dialog_exchange_footprints.cpp | 4 +- pcbnew/dialogs/dialog_export_step.cpp | 10 +- pcbnew/dialogs/dialog_export_svg.cpp | 5 +- pcbnew/dialogs/dialog_find.cpp | 4 +- pcbnew/dialogs/dialog_netlist.cpp | 6 +- pcbnew/dialogs/dialog_plot.cpp | 14 +- pcbnew/dialogs/panel_setup_drc_severities.cpp | 143 + .../panel_setup_drc_severities.h} | 42 +- .../panel_setup_feature_constraints.cpp | 6 - .../panel_setup_feature_constraints_base.cpp | 199 +- .../panel_setup_feature_constraints_base.fbp | 2599 ++++++----------- .../panel_setup_feature_constraints_base.h | 24 +- pcbnew/drc/courtyard_overlap.cpp | 58 +- pcbnew/drc/courtyard_overlap.h | 5 +- pcbnew/drc/drc.cpp | 207 +- pcbnew/drc/drc.h | 35 +- pcbnew/drc/drc_clearance_test_functions.cpp | 256 +- pcbnew/drc/drc_item.cpp | 54 +- pcbnew/drc/drc_marker_factory.cpp | 159 - pcbnew/drc/drc_marker_factory.h | 104 - pcbnew/drc/drc_provider.h | 26 +- pcbnew/drc/drc_tree_model.cpp | 113 +- pcbnew/drc/drc_tree_model.h | 196 +- pcbnew/exporters/export_hyperlynx.cpp | 2 +- pcbnew/exporters/gen_footprints_placefile.cpp | 36 +- pcbnew/exporters/gerber_jobfile_writer.cpp | 8 +- pcbnew/files.cpp | 9 +- pcbnew/kicad_plugin.cpp | 5 +- .../netlist_reader/board_netlist_updater.cpp | 56 +- pcbnew/netlist_reader/netlist.cpp | 11 +- pcbnew/pcb_draw_panel_gal.cpp | 11 +- pcbnew/pcb_edit_frame.cpp | 53 +- pcbnew/pcb_edit_frame.h | 14 +- pcbnew/pcb_layer_widget.cpp | 48 +- pcbnew/pcb_painter.cpp | 3 +- pcbnew/pcb_painter.h | 2 - pcbnew/pcb_parser.cpp | 8 +- pcbnew/pcb_parser.h | 2 + pcbnew/pcbnew_config.cpp | 18 +- pcbnew/tools/selection_tool.cpp | 3 - qa/pcbnew/drc/test_drc_courtyard_invalid.cpp | 17 +- qa/pcbnew/drc/test_drc_courtyard_overlap.cpp | 17 +- qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp | 27 +- 109 files changed, 4057 insertions(+), 4768 deletions(-) delete mode 100644 common/colors_design_settings.cpp delete mode 100644 include/colors_design_settings.h create mode 100644 pcbnew/dialogs/panel_setup_drc_severities.cpp rename pcbnew/{drc/drc_provider.cpp => dialogs/panel_setup_drc_severities.h} (54%) delete mode 100644 pcbnew/drc/drc_marker_factory.cpp delete mode 100644 pcbnew/drc/drc_marker_factory.h diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.h b/3d-viewer/3d_cache/dialogs/panel_prev_model.h index 619e3de127..568121e4d4 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.h @@ -67,7 +67,6 @@ class FILENAME_RESOLVER; class BOARD; class CINFO3D_VISU; class MODULE; -class COLORS_DESIGN_SETTINGS; class PANEL_PREV_3D: public PANEL_PREV_3D_BASE { diff --git a/3d-viewer/3d_canvas/status_text_reporter.h b/3d-viewer/3d_canvas/status_text_reporter.h index 5be930f319..0bae5beb7f 100644 --- a/3d-viewer/3d_canvas/status_text_reporter.h +++ b/3d-viewer/3d_canvas/status_text_reporter.h @@ -50,7 +50,7 @@ public: m_hasMessage = false; } - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override { if( !aText.IsEmpty() ) m_hasMessage = true; diff --git a/common/colors_design_settings.cpp b/common/colors_design_settings.cpp deleted file mode 100644 index 36c1711ab2..0000000000 --- a/common/colors_design_settings.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014 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 - */ - -/** - * @file colors_design_settings.cpp - * @brief Handle colors used to draw all items or layers. - */ -#include -#include - -#include - -/* Class for handle list of color settings for designs - * in Eeschema, Pcbnew and GerbView - */ - -/* Initial colors values: optimized for Pcbnew up to 64 layers. - * The table is not actually used by Eeschema. - * these values are superseded by config reading - */ -static const EDA_COLOR_T default_layer_color[] = { - // Copper layers - RED, YELLOW, LIGHTMAGENTA, LIGHTRED, - CYAN, GREEN, BLUE, DARKGRAY, - MAGENTA, LIGHTGRAY, MAGENTA, RED, - BROWN, LIGHTGRAY, BLUE, GREEN, - - RED, YELLOW, LIGHTMAGENTA, LIGHTRED, - CYAN, GREEN, BLUE, DARKGRAY, - MAGENTA, LIGHTGRAY, MAGENTA, RED, - BROWN, LIGHTGRAY, BLUE, GREEN, - - // tech layers - BLUE, MAGENTA, // B_Adhes, F_Adhes - LIGHTCYAN, RED, // B_Paste, F_Paste - MAGENTA, CYAN, // B_SilkS, F_SilkS - BROWN, MAGENTA, // B_Mask, F_Mask - - // user layers - LIGHTGRAY, BLUE, GREEN, YELLOW, // Dwgs_User, Cmts_User, Eco1_User, Eco2_User - - // Special layers - YELLOW, // Edge_Cuts - LIGHTMAGENTA, // Margin - DARKGRAY, LIGHTGRAY, // B_CrtYd, F_CrtYd, - BLUE, DARKGRAY // B_Fab, F_Fab -}; - - -// for color order, see enum GAL_LAYER_ID -static const EDA_COLOR_T default_items_color[] = { - LIGHTGRAY, // unused (LAYER_VIAS = GAL_LAYER_ID_START) - CYAN, // LAYER_VIA_MICROVIA - BROWN, // LAYER_VIA_BBLIND - LIGHTGRAY, // LAYER_VIA_THROUGH - YELLOW, // LAYER_NON_PLATED - LIGHTGRAY, // LAYER_MOD_TEXT_FR - BLUE, // LAYER_MOD_TEXT_BK - DARKGRAY, // LAYER_MOD_TEXT_INVISIBLE - BLUE, // LAYER_ANCHOR - RED, // LAYER_PAD_FR - GREEN, // LAYER_PAD_BK - LIGHTGRAY, // LAYER_RATSNEST - DARKGRAY, // LAYER_GRID - LIGHTRED, // LAYER_GRID_AXES - BLUE, // LAYER_NO_CONNECTS - LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_FR, LAYER_MOD_BK - LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_VALUES, LAYER_MOD_REFERENCES - LIGHTGRAY, // LAYER_TRACKS - YELLOW, LIGHTGRAY, // LAYER_PADS, LAYER_PADS_PLATEDHOLES - LIGHTGRAY, // LAYER_VIAS_HOLES - LIGHTGRAY, // LAYER_DRC - DARKRED, // LAYER_WORKSHEET - LIGHTGRAY, // LAYER_GP_OVERLAY - LIGHTGRAY, // LAYER_SELECT_OVERLAY - BLACK, // LAYER_PCB_BACKGROUND - WHITE, // LAYER_CURSOR - WHITE, // LAYER_AUX_ITEMS - LIGHTGRAY, // LAYER_DRAW_BITMAPS - LIGHTGRAY // unused (GAL_LAYER_ID_BITMASK_END) -}; - - -COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS( FRAME_T aFrameType ) -{ - m_frameType = aFrameType; - - for( unsigned src = 0, dst = 0; dst < arrayDim( m_LayersColors ); ++dst ) - { - m_LayersColors[dst] = COLOR4D( default_layer_color[src++] ); - - if( src >= arrayDim( default_layer_color ) ) - src = 0; // wrap the source. - } - - for( unsigned src = 0, dst = LAYER_VIAS; src < arrayDim( default_items_color ); ++dst, ++src ) - { - m_LayersColors[dst] = COLOR4D( default_items_color[src] ); - } - - setupConfigParams(); -} - - -COLOR4D COLORS_DESIGN_SETTINGS::GetDefaultLayerColor( LAYER_NUM aLayer ) -{ - if( (unsigned) aLayer < arrayDim( default_layer_color ) ) - return COLOR4D( default_layer_color[aLayer] ); - - return COLOR4D::UNSPECIFIED; -} - - -COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const -{ - if( (unsigned) aLayer < arrayDim( m_LayersColors ) ) - return m_LayersColors[aLayer]; - - return COLOR4D::UNSPECIFIED; -} - - -void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor ) -{ - if( (unsigned) aLayer < arrayDim( m_LayersColors ) ) - m_LayersColors[aLayer] = aColor; -} - - -COLOR4D COLORS_DESIGN_SETTINGS::GetDefaultItemColor( int aItemIdx ) -{ - unsigned int idx = (unsigned) aItemIdx - LAYER_VIAS; - if( idx < arrayDim( default_items_color ) ) - return COLOR4D( default_items_color[idx] ); - - return COLOR4D::UNSPECIFIED; -} - - -COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const -{ - if( (unsigned) aItemIdx < arrayDim( m_LayersColors ) ) - return m_LayersColors[aItemIdx]; - - return COLOR4D::UNSPECIFIED; -} - - -void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor ) -{ - if( (unsigned) aItemIdx < arrayDim( m_LayersColors ) ) - m_LayersColors[aItemIdx] = aColor; -} - - -void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor ) -{ - for( unsigned ii = 0; ii < arrayDim(m_LayersColors); ii++ ) - m_LayersColors[ii] = aColor; -} - -#define LOC_COLOR(layer) &m_LayersColors[layer] -#define ITEM_COLOR(item_visible) &m_LayersColors[item_visible] - -void COLORS_DESIGN_SETTINGS::setupConfigParams() -{ - wxASSERT( arrayDim( m_LayersColors ) >= PCB_LAYER_ID_COUNT ); - - wxString currprefix = GetConfigPrefix(); - - switch( m_frameType ) - { - case FRAME_GERBER: - case FRAME_PCB_EDITOR: /* no prefix */ break; - - case FRAME_CVPCB_DISPLAY: - case FRAME_FOOTPRINT_VIEWER: - case FRAME_FOOTPRINT_VIEWER_MODAL: - case FRAME_FOOTPRINT_WIZARD: - case FRAME_FOOTPRINT_PREVIEW: - case FRAME_FOOTPRINT_EDITOR: SetConfigPrefix( "ModEdit" ); break; - - case FRAME_PCB_DISPLAY3D: SetConfigPrefix( "fp3d_" ); break; - - default: break; - } - - wxString fmt( "Color4DPCBLayer_%s" ); - - for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i ) - { - wxString cfgkey = wxString::Format( fmt, LSET::Name( PCB_LAYER_ID( i ) ) ); - Add( cfgkey, LOC_COLOR(i), m_LayersColors[i] ); - } - - Add( "Color4DTxtFrontEx", ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY ); - Add( "Color4DTxtBackEx", ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE ); - Add( "Color4DTxtInvisEx", ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY ); - Add( "Color4DPadBackEx", ITEM_COLOR( LAYER_PAD_BK ), GREEN ); - Add( "Color4DAnchorEx", ITEM_COLOR( LAYER_ANCHOR ), BLUE ); - Add( "Color4DPadFrontEx", ITEM_COLOR( LAYER_PAD_FR ), RED ); - Add( "Color4DPadThruHoleEx", ITEM_COLOR( LAYER_PADS_TH ), YELLOW ); - Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATEDHOLES ), YELLOW ); - Add( "Color4DPCBBackground", ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK ); - Add( "Color4DPCBCursor", ITEM_COLOR( LAYER_CURSOR ), WHITE ); - Add( "Color4DAuxItems", ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE ); - Add( "Color4DWorksheet", ITEM_COLOR( LAYER_WORKSHEET ), DARKRED ); - Add( "Color4DGrid", ITEM_COLOR( LAYER_GRID ), DARKGRAY ); - - - // Add prms only relevant in board editor - if( m_frameType == FRAME_PCB_EDITOR ) - { - Add( "Color4DViaThruEx", ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY ); - Add( "Color4DViaBBlindEx", ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN ); - Add( "Color4DViaMicroEx", ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN ); - Add( "Color4DRatsEx", ITEM_COLOR( LAYER_RATSNEST ), WHITE ); - Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE ); - } - - SetConfigPrefix( currprefix ); -} - -void COLORS_DESIGN_SETTINGS::Load( wxConfigBase *aConfig ) -{ - SETTINGS::Load(aConfig); -} - -void COLORS_DESIGN_SETTINGS::Save( wxConfigBase *aConfig ) -{ - SETTINGS::Save(aConfig); -} diff --git a/common/common.cpp b/common/common.cpp index ca876869d6..cc76132c3a 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -563,9 +563,9 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, if( aReporter ) { msg.Printf( _( "Cannot make path \"%s\" absolute with respect to \"%s\"." ), - GetChars( aTargetFullFileName->GetPath() ), - GetChars( baseFilePath ) ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + aTargetFullFileName->GetPath(), + baseFilePath ); + aReporter->Report( msg, SEVERITY_ERROR ); } return false; @@ -580,8 +580,8 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, { if( aReporter ) { - msg.Printf( _( "Output directory \"%s\" created.\n" ), GetChars( outputPath ) ); - aReporter->Report( msg, REPORTER::RPT_INFO ); + msg.Printf( _( "Output directory \"%s\" created.\n" ), outputPath ); + aReporter->Report( msg, SEVERITY_INFO ); return true; } } @@ -589,9 +589,8 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, { if( aReporter ) { - msg.Printf( _( "Cannot create output directory \"%s\".\n" ), - GetChars( outputPath ) ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Cannot create output directory \"%s\".\n" ), outputPath ); + aReporter->Report( msg, SEVERITY_ERROR ); } return false; diff --git a/common/config_params.cpp b/common/config_params.cpp index f079c797f6..1ff4e010c8 100644 --- a/common/config_params.cpp +++ b/common/config_params.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 1992-2017 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 * modify it under the terms of the GNU General Public License @@ -33,7 +33,6 @@ #include // for wxASSERT #include // for wxString, operator!=, operator== - void wxConfigLoadParams( wxConfigBase* aCfg, const std::vector& aList, const wxString& aGroup ) { @@ -446,6 +445,63 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const } +PARAM_CFG_WXSTRING_SET::PARAM_CFG_WXSTRING_SET( const wxString& ident, std::set* ptparam, + const wxChar* group ) : + PARAM_CFG( ident, PARAM_WXSTRING_SET, group ) +{ + m_Pt_param = ptparam; +} + + +PARAM_CFG_WXSTRING_SET::PARAM_CFG_WXSTRING_SET( bool Insetup, const wxString& ident, + std::set* ptparam, const wxChar* group ) : + PARAM_CFG( ident, PARAM_WXSTRING, group ) +{ + m_Pt_param = ptparam; + m_Setup = Insetup; +} + + +void PARAM_CFG_WXSTRING_SET::ReadParam( wxConfigBase* aConfig ) const +{ + if( !m_Pt_param || !aConfig ) + return; + + for( int i = 1; true; ++i ) + { + wxString key, data; + + key = m_Ident; + key << i; + data = aConfig->Read( key, wxT( "" ) ); + + if( data.IsEmpty() ) + break; + + m_Pt_param->insert( data ); + } +} + + +void PARAM_CFG_WXSTRING_SET::SaveParam( wxConfigBase* aConfig ) const +{ + if( !m_Pt_param || !aConfig ) + return; + + int i = 1; + + for( const wxString& str : *m_Pt_param ) + { + wxString key, data; + + key = m_Ident; + key << i++; + + aConfig->Write( key, str ); + } +} + + PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam, const wxChar* group ) : diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index b5c85673c1..3130c282fb 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -263,7 +263,7 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event ) m_screen->SetModify(); if( LocalPrjConfigChanged() ) - m_parent->SaveProjectSettings( false ); + m_parent->SaveProjectSettings(); // Call the post processing (if any) after changes m_parent->OnPageSettingsChange(); diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp index 41952c3408..3920d6bb1d 100644 --- a/common/dialogs/wx_html_report_panel.cpp +++ b/common/dialogs/wx_html_report_panel.cpp @@ -34,7 +34,7 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, long style ) : WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ), m_reporter( this ), - m_severities( REPORTER::RPT_ALL ), + m_severities( -1 ), m_lazyUpdate( false ) { syncCheckboxes(); @@ -63,8 +63,8 @@ REPORTER& WX_HTML_REPORT_PANEL::Reporter() } -void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSeverity, - REPORTER::LOCATION aLocation ) +void WX_HTML_REPORT_PANEL::Report( const wxString& aText, SEVERITY aSeverity, + REPORTER::LOCATION aLocation ) { REPORT_LINE line; line.message = aText; @@ -130,80 +130,13 @@ void WX_HTML_REPORT_PANEL::scrollToBottom() } -#define BADGE_SIZE 20 -#define BADGE_FONT_SIZE 10 - -static wxBitmap makeBadge( REPORTER::SEVERITY aStyle, int aCount, wxWindow* aWindow ) -{ - wxSize size( BADGE_SIZE, BADGE_SIZE ); - wxBitmap bitmap( size ); - wxBrush brush; - wxMemoryDC badgeDC; - wxColour badgeColour; - wxColour textColour; - int fontSize = BADGE_FONT_SIZE; - - if( aCount > 99 ) - fontSize--; - - badgeDC.SelectObject( bitmap ); - - brush.SetStyle( wxBRUSHSTYLE_SOLID ); - // We're one level deep in staticBoxes; each level is darkened by 210 - brush.SetColour( aWindow->GetParent()->GetBackgroundColour().MakeDisabled( 210 ) ); - badgeDC.SetBackground( brush ); - badgeDC.Clear(); - - if( aCount == 0 ) - return bitmap; - - switch( aStyle ) - { - case REPORTER::RPT_ERROR: - badgeColour = *wxRED; - textColour = *wxWHITE; - break; - case REPORTER::RPT_WARNING: - badgeColour = wxColour( 235, 120, 80 ); // Orange - textColour = *wxWHITE; - break; - case REPORTER::RPT_ACTION: - badgeColour = *wxGREEN; - textColour = *wxWHITE; - break; - case REPORTER::RPT_INFO: - default: - badgeColour = *wxLIGHT_GREY; - textColour = *wxBLACK; - break; - } - - brush.SetStyle( wxBRUSHSTYLE_SOLID ); - brush.SetColour( badgeColour ); - badgeDC.SetBrush( brush ); - badgeDC.SetPen( wxPen( badgeColour, 0 ) ); - badgeDC.DrawCircle( size.x / 2 - 1, size.y / 2, ( std::max( size.x, size.y ) / 2 ) - 1 ); - - wxFont font( fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); - badgeDC.SetFont( font ); - - wxString text = wxString::Format( wxT( "%d" ), aCount ); - wxSize textExtent = badgeDC.GetTextExtent( text ); - - badgeDC.SetTextForeground( textColour ); - badgeDC.DrawText( text, size.x / 2 - textExtent.x / 2 - 1, size.y / 2 - textExtent.y / 2 ); - - return bitmap; -} - - void WX_HTML_REPORT_PANEL::updateBadges() { - int count = Count( REPORTER::RPT_ERROR ); - m_errorsBadge->SetBitmap( makeBadge( REPORTER::RPT_ERROR, count, m_errorsBadge ) ); + int count = Count( SEVERITY_ERROR ); + m_errorsBadge->SetBitmap( MakeBadge( SEVERITY_ERROR, count, m_errorsBadge, 2 ) ); - count = Count( REPORTER::RPT_WARNING ); - m_warningsBadge->SetBitmap( makeBadge( REPORTER::RPT_WARNING, count, m_warningsBadge ) ); + count = Count( SEVERITY_WARNING ); + m_warningsBadge->SetBitmap( MakeBadge( SEVERITY_WARNING, count, m_warningsBadge, 2 ) ); } @@ -240,19 +173,19 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine ) switch( aLine.severity ) { - case REPORTER::RPT_ERROR: + case SEVERITY_ERROR: retv = "" + _( "Error: " ) + "" + aLine.message + "
"; break; - case REPORTER::RPT_WARNING: + case SEVERITY_WARNING: retv = "" + _( "Warning: " ) + "" + aLine.message + "
"; break; - case REPORTER::RPT_INFO: + case SEVERITY_INFO: retv = "" + _( "Info: " ) + "" + aLine.message + "
"; break; - case REPORTER::RPT_ACTION: + case SEVERITY_ACTION: retv = "" + aLine.message + "
"; break; default: @@ -267,11 +200,11 @@ wxString WX_HTML_REPORT_PANEL::generatePlainText( const REPORT_LINE& aLine ) { switch( aLine.severity ) { - case REPORTER::RPT_ERROR: + case SEVERITY_ERROR: return _( "Error: " ) + aLine.message + wxT( "\n" ); - case REPORTER::RPT_WARNING: + case SEVERITY_WARNING: return _( "Warning: " ) + aLine.message + wxT( "\n" ); - case REPORTER::RPT_INFO: + case SEVERITY_INFO: return _( "Info: " ) + aLine.message + wxT( "\n" ); default: return aLine.message + wxT( "\n" ); @@ -303,12 +236,16 @@ void WX_HTML_REPORT_PANEL::onMenuEvent( wxMenuEvent& event ) } +// Don't globally define this; different facilities use different definitions of "ALL" +static int SEVERITY_ALL = SEVERITY_WARNING | SEVERITY_ERROR | SEVERITY_INFO | SEVERITY_ACTION; + + void WX_HTML_REPORT_PANEL::onCheckBoxShowAll( wxCommandEvent& event ) { if( event.IsChecked() ) - m_severities = REPORTER::RPT_ALL; + m_severities = SEVERITY_ALL; else - m_severities = 0; + m_severities = SEVERITY_ERROR; syncCheckboxes(); Flush( true ); @@ -317,20 +254,20 @@ void WX_HTML_REPORT_PANEL::onCheckBoxShowAll( wxCommandEvent& event ) void WX_HTML_REPORT_PANEL::syncCheckboxes() { - m_checkBoxShowAll->SetValue( m_severities == REPORTER::RPT_ALL ); - m_checkBoxShowWarnings->SetValue( m_severities & REPORTER::RPT_WARNING ); - m_checkBoxShowErrors->SetValue( m_severities & REPORTER::RPT_ERROR ); - m_checkBoxShowInfos->SetValue( m_severities & REPORTER::RPT_INFO ); - m_checkBoxShowActions->SetValue( m_severities & REPORTER::RPT_ACTION ); + m_checkBoxShowAll->SetValue( m_severities == SEVERITY_ALL ); + m_checkBoxShowWarnings->SetValue( m_severities & SEVERITY_WARNING ); + m_checkBoxShowErrors->SetValue( m_severities & SEVERITY_ERROR ); + m_checkBoxShowInfos->SetValue( m_severities & SEVERITY_INFO ); + m_checkBoxShowActions->SetValue( m_severities & SEVERITY_ACTION ); } void WX_HTML_REPORT_PANEL::onCheckBoxShowWarnings( wxCommandEvent& event ) { if( event.IsChecked() ) - m_severities |= REPORTER::RPT_WARNING; + m_severities |= SEVERITY_WARNING; else - m_severities &= ~REPORTER::RPT_WARNING; + m_severities &= ~SEVERITY_WARNING; syncCheckboxes(); Flush( true ); @@ -340,9 +277,9 @@ void WX_HTML_REPORT_PANEL::onCheckBoxShowWarnings( wxCommandEvent& event ) void WX_HTML_REPORT_PANEL::onCheckBoxShowErrors( wxCommandEvent& event ) { if( event.IsChecked() ) - m_severities |= REPORTER::RPT_ERROR; + m_severities |= SEVERITY_ERROR; else - m_severities &= ~REPORTER::RPT_ERROR; + m_severities &= ~SEVERITY_ERROR; syncCheckboxes(); Flush( true ); @@ -352,9 +289,9 @@ void WX_HTML_REPORT_PANEL::onCheckBoxShowErrors( wxCommandEvent& event ) void WX_HTML_REPORT_PANEL::onCheckBoxShowInfos( wxCommandEvent& event ) { if( event.IsChecked() ) - m_severities |= REPORTER::RPT_INFO; + m_severities |= SEVERITY_INFO; else - m_severities &= ~REPORTER::RPT_INFO; + m_severities &= ~SEVERITY_INFO; syncCheckboxes(); Flush( true ); @@ -364,9 +301,9 @@ void WX_HTML_REPORT_PANEL::onCheckBoxShowInfos( wxCommandEvent& event ) void WX_HTML_REPORT_PANEL::onCheckBoxShowActions( wxCommandEvent& event ) { if( event.IsChecked() ) - m_severities |= REPORTER::RPT_ACTION; + m_severities |= SEVERITY_ACTION; else - m_severities &= ~REPORTER::RPT_ACTION; + m_severities &= ~SEVERITY_ACTION; syncCheckboxes(); Flush( true ); @@ -426,7 +363,7 @@ void WX_HTML_REPORT_PANEL::SetLabel( const wxString& aLabel ) void WX_HTML_REPORT_PANEL::SetVisibleSeverities( int aSeverities ) { if( aSeverities < 0 ) - m_severities = REPORTER::RPT_ALL; + m_severities = SEVERITY_ALL; else m_severities = aSeverities; diff --git a/common/dialogs/wx_html_report_panel.h b/common/dialogs/wx_html_report_panel.h index 1741170850..96cc18ddc5 100644 --- a/common/dialogs/wx_html_report_panel.h +++ b/common/dialogs/wx_html_report_panel.h @@ -58,8 +58,8 @@ public: * @param aSeverity string classification level bitfield * @param aLocation REPORTER::LOCATION enum for placement of message */ - void Report( const wxString& aText, REPORTER::SEVERITY aSeverity, - REPORTER::LOCATION aLocation = REPORTER::LOC_BODY ); + void Report( const wxString& aText, SEVERITY aSeverity, + REPORTER::LOCATION aLocation = REPORTER::LOC_BODY ); ///> clears the report panel void Clear(); @@ -90,7 +90,7 @@ public: private: struct REPORT_LINE { - REPORTER::SEVERITY severity; + SEVERITY severity; wxString message; }; diff --git a/common/dialogs/wx_html_report_panel_base.cpp b/common/dialogs/wx_html_report_panel_base.cpp index 46b22973fd..7b56fa70f6 100644 --- a/common/dialogs/wx_html_report_panel_base.cpp +++ b/common/dialogs/wx_html_report_panel_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,77 +9,77 @@ /////////////////////////////////////////////////////////////////////////// -WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { m_box = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output Messages") ), wxVERTICAL ); - - m_box->SetMinSize( wxSize( -1,130 ) ); + + m_box->SetMinSize( wxSize( -1,130 ) ); m_fgSizer = new wxFlexGridSizer( 2, 1, 0, 0 ); m_fgSizer->AddGrowableCol( 0 ); m_fgSizer->AddGrowableRow( 0 ); m_fgSizer->SetFlexibleDirection( wxBOTH ); m_fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_htmlView = new wxHtmlWindow( m_box->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); m_htmlView->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - + m_fgSizer->Add( m_htmlView, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 2 ); - + wxBoxSizer* bSizerBottom; bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); - + m_staticTextShow = new wxStaticText( m_box->GetStaticBox(), wxID_ANY, _("Show:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextShow->Wrap( -1 ); bSizerBottom->Add( m_staticTextShow, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - + m_checkBoxShowAll = new wxCheckBox( m_box->GetStaticBox(), wxID_ANY, _("All"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxShowAll->SetValue(true); + m_checkBoxShowAll->SetValue(true); bSizerBottom->Add( m_checkBoxShowAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - - bSizerBottom->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - + + + bSizerBottom->Add( 20, 0, 0, wxEXPAND, 5 ); + m_checkBoxShowErrors = new wxCheckBox( m_box->GetStaticBox(), wxID_ANY, _("Errors"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBottom->Add( m_checkBoxShowErrors, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - + m_errorsBadge = new wxStaticBitmap( m_box->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); m_errorsBadge->SetMinSize( wxSize( 20,20 ) ); - + bSizerBottom->Add( m_errorsBadge, 0, wxBOTTOM|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, 4 ); - + m_checkBoxShowWarnings = new wxCheckBox( m_box->GetStaticBox(), wxID_ANY, _("Warnings"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBottom->Add( m_checkBoxShowWarnings, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - + m_warningsBadge = new wxStaticBitmap( m_box->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); m_warningsBadge->SetMinSize( wxSize( 20,20 ) ); - + bSizerBottom->Add( m_warningsBadge, 0, wxBOTTOM|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, 4 ); - + m_checkBoxShowActions = new wxCheckBox( m_box->GetStaticBox(), wxID_ANY, _("Actions"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBottom->Add( m_checkBoxShowActions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - + + bSizerBottom->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - + m_checkBoxShowInfos = new wxCheckBox( m_box->GetStaticBox(), wxID_ANY, _("Infos"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBottom->Add( m_checkBoxShowInfos, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - + + bSizerBottom->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - + m_btnSaveReportToFile = new wxButton( m_box->GetStaticBox(), wxID_ANY, _("Save..."), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBottom->Add( m_btnSaveReportToFile, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - + + m_fgSizer->Add( bSizerBottom, 0, wxEXPAND, 5 ); - - + + m_box->Add( m_fgSizer, 1, wxEXPAND, 5 ); - - + + this->SetSizer( m_box ); this->Layout(); - + // Connect Events m_htmlView->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( WX_HTML_REPORT_PANEL_BASE::onRightClick ), NULL, this ); m_checkBoxShowAll->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowAll ), NULL, this ); @@ -100,5 +100,5 @@ WX_HTML_REPORT_PANEL_BASE::~WX_HTML_REPORT_PANEL_BASE() m_checkBoxShowActions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowActions ), NULL, this ); m_checkBoxShowInfos->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowInfos ), NULL, this ); m_btnSaveReportToFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onBtnSaveToFile ), NULL, this ); - + } diff --git a/common/dialogs/wx_html_report_panel_base.fbp b/common/dialogs/wx_html_report_panel_base.fbp index 13a9f867aa..80569ac082 100644 --- a/common/dialogs/wx_html_report_panel_base.fbp +++ b/common/dialogs/wx_html_report_panel_base.fbp @@ -2,7 +2,7 @@ - + C++ 1 source_name @@ -14,12 +14,12 @@ wx_html_report_panel_base 1000 none - + 1 WX_HTML_REPORT_PANEL_BASE - + . - + 1 1 1 @@ -30,55 +30,25 @@ 0 wxAUI_MGR_DEFAULT - - + + 1 1 impl_virtual - - + + 0 wxID_ANY - - + + WX_HTML_REPORT_PANEL_BASE - + 567,228 - - - - + + + + wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - wxID_ANY Output Messages @@ -87,7 +57,6 @@ wxVERTICAL 1 protected - 5 wxEXPAND @@ -98,7 +67,7 @@ 0 0 0 - + m_fgSizer wxFLEX_GROWMODE_SPECIFIED protected @@ -113,79 +82,54 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 0 0 Dock 0 Left 1 - + 1 ,90,90,10,70,0 0 0 wxID_ANY - + 0 - - + + 0 -1,-1 1 m_htmlView 1 - - + + protected 1 - + Resizable 1 - + wxHW_SCROLLBAR_AUTO - + 0 - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + onRightClick - - - @@ -193,7 +137,7 @@ wxEXPAND 0 - + bSizerBottom wxHORIZONTAL none @@ -206,78 +150,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Show: - + 0 + 0 - - + + 0 - + 1 m_staticTextShow 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -289,93 +211,70 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY All - + 0 - - + + 0 - + 1 m_checkBoxShowAll 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onCheckBoxShowAll - - - - - - - - - - - - - - - - - - - - - - - 10 - wxEXPAND|wxRIGHT|wxLEFT + 5 + wxEXPAND 0 0 protected - 0 + 20 @@ -387,83 +286,60 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Errors - + 0 - - + + 0 - + 1 m_checkBoxShowErrors 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onCheckBoxShowErrors - - - - - - - - - - - - - - - - - - - - - - @@ -475,76 +351,53 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 20,20 1 m_errorsBadge 1 - - + + protected 1 - + Resizable 1 - + ; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -556,83 +409,60 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Warnings - + 0 - - + + 0 - + 1 m_checkBoxShowWarnings 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onCheckBoxShowWarnings - - - - - - - - - - - - - - - - - - - - - - @@ -644,76 +474,53 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 20,20 1 m_warningsBadge 1 - - + + protected 1 - + Resizable 1 - + ; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -725,83 +532,60 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Actions - + 0 - - + + 0 - + 1 m_checkBoxShowActions 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onCheckBoxShowActions - - - - - - - - - - - - - - - - - - - - - - @@ -823,83 +607,60 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Infos - + 0 - - + + 0 - + 1 m_checkBoxShowInfos 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onCheckBoxShowInfos - - - - - - - - - - - - - - - - - - - - - - @@ -921,83 +682,68 @@ 1 1 1 - - - - - - - + + + + + + + + 1 0 1 - + 1 + 0 0 + Dock 0 Left 1 - + 1 - + + 0 0 wxID_ANY Save... - + + 0 + 0 -1,-1 - + 0 - + 1 m_btnSaveReportToFile 1 - - + + protected 1 - + + + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + onBtnSaveToFile - - - - - - - - - - - - - - - - - - - - - - - diff --git a/common/dialogs/wx_html_report_panel_base.h b/common/dialogs/wx_html_report_panel_base.h index 36dd6f007c..e5a45b210a 100644 --- a/common/dialogs/wx_html_report_panel_base.h +++ b/common/dialogs/wx_html_report_panel_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __WX_HTML_REPORT_PANEL_BASE_H__ -#define __WX_HTML_REPORT_PANEL_BASE_H__ +#pragma once #include #include @@ -34,10 +33,10 @@ /////////////////////////////////////////////////////////////////////////////// /// Class WX_HTML_REPORT_PANEL_BASE /////////////////////////////////////////////////////////////////////////////// -class WX_HTML_REPORT_PANEL_BASE : public wxPanel +class WX_HTML_REPORT_PANEL_BASE : public wxPanel { private: - + protected: wxStaticBoxSizer* m_box; wxFlexGridSizer* m_fgSizer; @@ -51,7 +50,7 @@ class WX_HTML_REPORT_PANEL_BASE : public wxPanel wxCheckBox* m_checkBoxShowActions; wxCheckBox* m_checkBoxShowInfos; wxButton* m_btnSaveReportToFile; - + // Virtual event handlers, overide them in your derived class virtual void onRightClick( wxMouseEvent& event ) { event.Skip(); } virtual void onCheckBoxShowAll( wxCommandEvent& event ) { event.Skip(); } @@ -60,13 +59,12 @@ class WX_HTML_REPORT_PANEL_BASE : public wxPanel virtual void onCheckBoxShowActions( wxCommandEvent& event ) { event.Skip(); } virtual void onCheckBoxShowInfos( wxCommandEvent& event ) { event.Skip(); } virtual void onBtnSaveToFile( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 567,228 ), long style = wxTAB_TRAVERSAL ); + + WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 567,228 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~WX_HTML_REPORT_PANEL_BASE(); - + }; -#endif //__WX_HTML_REPORT_PANEL_BASE_H__ diff --git a/common/marker_base.cpp b/common/marker_base.cpp index 430e6d40bc..2a3c93ab23 100644 --- a/common/marker_base.cpp +++ b/common/marker_base.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-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 @@ -65,8 +65,8 @@ const unsigned CORNERS_COUNT = arrayDim( MarkerShapeCorners ); void MARKER_BASE::init() { m_MarkerType = MARKER_UNSPEC; + m_Excluded = false; m_ErrorLevel = MARKER_SEVERITY_UNSPEC; - m_Color = RED; const VECTOR2I* point_shape = GetShapePolygon(); wxPoint start( point_shape->x, point_shape->y ); wxPoint end = start; @@ -90,7 +90,6 @@ MARKER_BASE::MARKER_BASE( const MARKER_BASE& aMarker ) m_Pos = aMarker.m_Pos; m_ErrorLevel = aMarker.m_ErrorLevel; m_MarkerType = aMarker.m_MarkerType; - m_Color = aMarker.m_Color; m_ShapeBoundingBox = aMarker.m_ShapeBoundingBox; m_ScalingFactor = aMarker.m_ScalingFactor; } @@ -104,8 +103,8 @@ MARKER_BASE::MARKER_BASE( int aScalingFactor ) MARKER_BASE::MARKER_BASE( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, - EDA_ITEM* aItem, const wxPoint& aPos, EDA_ITEM* bItem, const wxPoint& bPos, - int aScalingFactor ) + EDA_ITEM* aItem, const wxPoint& aPos, + EDA_ITEM* bItem, const wxPoint& bPos, int aScalingFactor ) { m_ScalingFactor = aScalingFactor; init(); @@ -114,6 +113,17 @@ MARKER_BASE::MARKER_BASE( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMark } +MARKER_BASE::MARKER_BASE( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + EDA_ITEM* aItem, + EDA_ITEM* bItem, int aScalingFactor ) +{ + m_ScalingFactor = aScalingFactor; + init(); + + SetData( aUnits, aErrorCode, aMarkerPos, aItem, bItem ); +} + + MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, const wxString& aText, const wxPoint& aPos, const wxString& bText, const wxPoint& bPos, int aScalingFactor ) @@ -126,12 +136,24 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, - const wxString& aText, const wxPoint& aPos, int aScalingFactor ) + const wxString& aText, + const wxString& bText, int aScalingFactor ) { m_ScalingFactor = aScalingFactor; init(); - SetData( aErrorCode, aMarkerPos, aText, aPos ); + SetData( aErrorCode, aMarkerPos, aText, bText ); +} + + +MARKER_BASE::MARKER_BASE( int aErrorCode, + const wxString& aText, + const wxString& bText, int aScalingFactor ) +{ + m_ScalingFactor = aScalingFactor; + init(); + + SetData( aErrorCode, wxPoint(), aText, bText ); } @@ -141,7 +163,8 @@ MARKER_BASE::~MARKER_BASE() void MARKER_BASE::SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, - EDA_ITEM* aItem, const wxPoint& aPos, EDA_ITEM* bItem, const wxPoint& bPos ) + EDA_ITEM* aItem, const wxPoint& aPos, + EDA_ITEM* bItem, const wxPoint& bPos ) { m_Pos = aMarkerPos; m_drc.SetData( aUnits, aErrorCode, aItem, aPos, bItem, bPos ); @@ -159,6 +182,36 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, } +void MARKER_BASE::SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + EDA_ITEM* aItem, + EDA_ITEM* bItem ) +{ + m_Pos = aMarkerPos; + m_drc.SetData( aUnits, aErrorCode, aItem, bItem ); + m_drc.SetParent( this ); +} + + +void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, + const wxString& aText, + const wxString& bText ) +{ + m_Pos = aMarkerPos; + m_drc.SetData( aErrorCode, aText, bText ); + m_drc.SetParent( this ); +} + + +void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, + const wxString& aText, const KIID& aID, + const wxString& bText, const KIID& bID ) +{ + m_Pos = aMarkerPos; + m_drc.SetData( aErrorCode, aText, aID, bText, bID ); + m_drc.SetParent( this ); +} + + bool MARKER_BASE::HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const { EDA_RECT bbox = GetBoundingBoxMarker(); @@ -246,11 +299,11 @@ void MARKER_BASE::PrintMarker( wxDC* aDC, const wxPoint& aOffset ) for( int ii = 0; ii < ccount; ii++ ) { shape.emplace_back( GetShapePolygonCorner( ii ).x * MarkerScale(), - GetShapePolygonCorner( ii ).y * MarkerScale() ); + GetShapePolygonCorner( ii ).y * MarkerScale() ); } for( int ii = 0; ii < ccount; ii++ ) shape[ii] += m_Pos + aOffset; - GRClosedPoly( nullptr, aDC, ccount, &shape[0], true, 0, m_Color, m_Color ); + GRClosedPoly( nullptr, aDC, ccount, &shape[0], true, 0, getColor(), getColor() ); } diff --git a/common/reporter.cpp b/common/reporter.cpp index b9dce9e91f..5573d8bd76 100644 --- a/common/reporter.cpp +++ b/common/reporter.cpp @@ -29,14 +29,14 @@ #include #include -REPORTER& REPORTER::Report( const char* aText, REPORTER::SEVERITY aSeverity ) +REPORTER& REPORTER::Report( const char* aText, SEVERITY aSeverity ) { Report( FROM_UTF8( aText ) ); return *this; } -REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, REPORTER::SEVERITY aSeverity ) +REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) { wxCHECK_MSG( m_textCtrl != NULL, *this, wxT( "No wxTextCtrl object defined in WX_TEXT_CTRL_REPORTER." ) ); @@ -50,7 +50,7 @@ bool WX_TEXT_CTRL_REPORTER::HasMessage() const return !m_textCtrl->IsEmpty(); } -REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, REPORTER::SEVERITY aSeverity ) +REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) { wxCHECK_MSG( m_string != NULL, *this, wxT( "No wxString object defined in WX_STRING_REPORTER." ) ); @@ -93,7 +93,7 @@ REPORTER& WX_HTML_PANEL_REPORTER::ReportHead( const wxString& aText, SEVERITY aS bool WX_HTML_PANEL_REPORTER::HasMessage() const { - return m_panel->Count( REPORTER::RPT_ERROR | REPORTER::RPT_WARNING ) > 0; + return m_panel->Count( SEVERITY_ERROR | SEVERITY_WARNING ) > 0; } REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) @@ -106,9 +106,7 @@ REPORTER& NULL_REPORTER::GetInstance() static REPORTER* s_nullReporter = NULL; if( !s_nullReporter ) - { s_nullReporter = new NULL_REPORTER(); - } return *s_nullReporter; } @@ -118,11 +116,11 @@ REPORTER& STDOUT_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) { switch( aSeverity ) { - case RPT_UNDEFINED: std::cout << "RPT_UNDEFINED: "; break; - case RPT_INFO: std::cout << "RPT_INFO: "; break; - case RPT_WARNING: std::cout << "RPT_WARNING: "; break; - case RPT_ERROR: std::cout << "RPT_ERROR: "; break; - case RPT_ACTION: std::cout << "RPT_ACTION: "; break; + case SEVERITY_UNDEFINED: std::cout << "SEVERITY_UNDEFINED: "; break; + case SEVERITY_INFO: std::cout << "SEVERITY_INFO: "; break; + case SEVERITY_WARNING: std::cout << "SEVERITY_WARNING: "; break; + case SEVERITY_ERROR: std::cout << "SEVERITY_ERROR: "; break; + case SEVERITY_ACTION: std::cout << "SEVERITY_ACTION: "; break; } std::cout << aText << std::endl; @@ -136,9 +134,7 @@ REPORTER& STDOUT_REPORTER::GetInstance() static REPORTER* s_stdoutReporter = nullptr; if( !s_stdoutReporter ) - { s_stdoutReporter = new STDOUT_REPORTER(); - } return *s_stdoutReporter; } diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index c89de93280..21ab37d8ed 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -56,7 +56,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : // TODO(JE) in actual usage, how long does the default palette need to be? m_params.emplace_back( new PARAM_LIST( "palette", &m_Palette, default_palette ) ); -#define CLR( x, y, z ) m_params.emplace_back( new COLOR_MAP_PARAM( x, y, z, &m_colors ) ); +#define CLR( x, y, z ) m_params.emplace_back( new COLOR_MAP_PARAM( x, y, z, &m_colors ) ) CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) ); CLR( "schematic.brightened", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) ); @@ -64,8 +64,8 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) ); CLR( "schematic.component_outline", LAYER_DEVICE, COLOR4D( RED ) ); CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) ); - CLR( "schematic.erc_error", LAYER_ERC_ERR, COLOR4D( RED ).WithAlpha( 0.8 ) ); - CLR( "schematic.erc_warning", LAYER_ERC_WARN, COLOR4D( GREEN ).WithAlpha( 0.8 ) ); + CLR( "schematic.erc_error", LAYER_ERC_ERR, COLOR4D( RED ).WithAlpha( 0.8 ) ); + CLR( "schematic.erc_warning", LAYER_ERC_WARN, COLOR4D( GREEN ).WithAlpha( 0.8 ) ); CLR( "schematic.fields", LAYER_FIELDS, COLOR4D( MAGENTA ) ); CLR( "schematic.grid", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) ); CLR( "schematic.hidden", LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) ); @@ -113,7 +113,8 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : CLR( "board.aux_items", LAYER_AUX_ITEMS, COLOR4D( WHITE ) ); CLR( "board.background", LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) ); CLR( "board.cursor", LAYER_CURSOR, COLOR4D( WHITE ) ); - CLR( "board.drc", LAYER_DRC, COLOR4D( LIGHTGRAY ) ); + CLR( "board.drc_error", LAYER_DRC_ERROR, COLOR4D( PURERED ) ); + CLR( "board.drc_warning", LAYER_DRC_WARNING, COLOR4D( PUREYELLOW ) ); CLR( "board.footprint_text_back", LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) ); CLR( "board.footprint_text_front", LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) ); CLR( "board.footprint_text_invisible", LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) ); @@ -203,7 +204,8 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : CLR( "fpedit.aux_items", FL + LAYER_AUX_ITEMS, COLOR4D( WHITE ) ); CLR( "fpedit.background", FL + LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) ); CLR( "fpedit.cursor", FL + LAYER_CURSOR, COLOR4D( WHITE ) ); - CLR( "fpedit.drc", FL + LAYER_DRC, COLOR4D( LIGHTGRAY ) ); + CLR( "fpedit.drc_error", FL + LAYER_DRC_ERROR, COLOR4D( PURERED ) ); + CLR( "fpedit.drc_warning", FL + LAYER_DRC_WARNING, COLOR4D( PUREYELLOW ) ); CLR( "fpedit.footprint_text_back", FL + LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) ); CLR( "fpedit.footprint_text_front", FL + LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) ); CLR( "fpedit.footprint_text_invisible", FL + LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) ); @@ -281,11 +283,11 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : // Colors for 3D viewer, which are used as defaults unless overridden by the board CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) ); CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) ); - CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 1.0 ) ); + CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 1.0 ) ); CLR( "3d_viewer.copper", LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) ); CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) ); CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) ); - CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 1.0 ) ); + CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 1.0 ) ); CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) ); } @@ -302,7 +304,9 @@ COLOR4D COLOR_SETTINGS::GetColor( int aLayer ) const { if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START && aLayer <= GAL_LAYER_ID_END ) + { aLayer += FPEDIT_LAYER_ID_START; + } return m_colors.at( aLayer ); } @@ -319,7 +323,9 @@ COLOR4D COLOR_SETTINGS::GetDefaultColor( int aLayer ) { if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START && aLayer <= GAL_LAYER_ID_END ) + { aLayer += FPEDIT_LAYER_ID_START; + } COLOR_MAP_PARAM* p = nullptr; diff --git a/common/widgets/ui_common.cpp b/common/widgets/ui_common.cpp index 7cb0ca04ca..dea795a352 100644 --- a/common/widgets/ui_common.cpp +++ b/common/widgets/ui_common.cpp @@ -17,6 +17,7 @@ * with this program. If not, see . */ +#include #include @@ -24,4 +25,81 @@ int KIUI::GetStdMargin() { // This is the value used in (most) wxFB dialogs return 5; -} \ No newline at end of file +} + + +#define BADGE_SIZE 20 +#define BADGE_FONT_SIZE 10 + +wxBitmap MakeBadge( SEVERITY aStyle, int aCount, wxWindow* aWindow, int aDepth ) +{ + wxSize size( BADGE_SIZE, BADGE_SIZE ); + wxBitmap bitmap( size ); + wxBrush brush; + wxMemoryDC badgeDC; + wxColour badgeColour; + wxColour textColour; + wxColour backColour; + int fontSize = BADGE_FONT_SIZE; + + if( aCount > 99 ) + fontSize--; + + badgeDC.SelectObject( bitmap ); + + brush.SetStyle( wxBRUSHSTYLE_SOLID ); + + backColour = aWindow->GetParent()->GetBackgroundColour(); + + // Each level inside staticBoxes is darkened by 210 + for( int i = 1; i < aDepth; ++i ) + backColour = backColour.MakeDisabled( 210 ); + + brush.SetColour( backColour ); + badgeDC.SetBackground( brush ); + badgeDC.Clear(); + + if( aCount == 0 ) + return bitmap; + + switch( aStyle ) + { + case SEVERITY_ERROR: + badgeColour = *wxRED; + textColour = *wxWHITE; + break; + case SEVERITY_WARNING: + badgeColour = *wxYELLOW; + textColour = *wxBLACK; + break; + case SEVERITY_ACTION: + badgeColour = *wxGREEN; + textColour = *wxWHITE; + break; + case SEVERITY_EXCLUSION: + case SEVERITY_INFO: + default: + badgeColour = *wxLIGHT_GREY; + textColour = *wxBLACK; + break; + } + + brush.SetStyle( wxBRUSHSTYLE_SOLID ); + brush.SetColour( badgeColour ); + badgeDC.SetBrush( brush ); + badgeDC.SetPen( wxPen( badgeColour, 0 ) ); + badgeDC.DrawCircle( size.x / 2 - 1, size.y / 2, ( std::max( size.x, size.y ) / 2 ) - 1 ); + + wxFont font( fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); + badgeDC.SetFont( font ); + + wxString text = wxString::Format( wxT( "%d" ), aCount ); + wxSize textExtent = badgeDC.GetTextExtent( text ); + + badgeDC.SetTextForeground( textColour ); + badgeDC.DrawText( text, size.x / 2 - textExtent.x / 2 - 1, size.y / 2 - textExtent.y / 2 ); + + return bitmap; +} + + diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index c31f1dfb95..836012dd55 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -114,7 +114,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, { wxString msg; msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count ); - aReporter.ReportTail( msg, REPORTER::RPT_WARNING ); + aReporter.ReportTail( msg, SEVERITY_WARNING ); } } @@ -221,12 +221,12 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, newRef ); } - aReporter.Report( msg, REPORTER::RPT_ACTION ); + aReporter.Report( msg, SEVERITY_ACTION ); } // Final control (just in case ... ). if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) ) - aReporter.ReportTail( _( "Annotation complete." ), REPORTER::RPT_ACTION ); + aReporter.ReportTail( _( "Annotation complete." ), SEVERITY_ACTION ); // Update on screen references, that can be modified by previous calculations: g_CurrentSheet->UpdateAllScreenReferences(); diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 81aaf06d28..f9698176ec 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -525,7 +525,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( REPORTER& aReporter ) tmp ); } - aReporter.Report( msg, REPORTER::RPT_WARNING ); + aReporter.Report( msg, SEVERITY_WARNING ); error++; break; } @@ -547,7 +547,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( REPORTER& aReporter ) flatList[ii].m_Unit, flatList[ii].GetLibPart()->GetUnitCount() ); - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); error++; break; } @@ -591,7 +591,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( REPORTER& aReporter ) tmp ); } - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); error++; continue; } @@ -621,7 +621,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( REPORTER& aReporter ) tmp ); } - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); error++; } @@ -640,7 +640,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( REPORTER& aReporter ) LIB_PART::SubReference( flatList[next].m_Unit ), flatList[next].m_Value->GetText() ); - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); error++; } } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 3cd5d0dde2..99c6ef9067 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -100,7 +100,7 @@ DIALOG_ERC::~DIALOG_ERC() if( m_settings != m_parent->GetErcSettings() ) { m_parent->UpdateErcSettings( m_settings ); - m_parent->SaveProjectSettings( false ); + m_parent->SaveProjectSettings(); } } @@ -489,7 +489,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter ) if( m_parent->CheckAnnotate( aReporter, false ) ) { if( aReporter.HasMessage() ) - aReporter.ReportTail( _( "Annotation required!" ), REPORTER::RPT_ERROR ); + aReporter.ReportTail( _( "Annotation required!" ), SEVERITY_ERROR ); return; } @@ -622,7 +622,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter ) m_parent->GetCanvas()->Refresh(); // Display message - aReporter.ReportTail( _( "Finished" ), REPORTER::RPT_INFO ); + aReporter.ReportTail( _( "Finished" ), SEVERITY_INFO ); if( m_settings.write_erc_file ) { diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index 984c43574a..ec4818f3d4 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -711,7 +711,7 @@ int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller ) aCaller->SetNetListFormatName( dlg.m_DefaultNetFmtName ); // can have temporary changed if( curr_default_netformat != dlg.m_DefaultNetFmtName ) - aCaller->SaveProjectSettings( false ); + aCaller->SaveProjectSettings(); return ret; } diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 5ba2d11042..57ffc6639e 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -50,7 +50,7 @@ void SCH_EDIT_FRAME::PlotSchematic() // save project config if the prj config has changed: if( dlg.PrjConfigChanged() ) - SaveProjectSettings( false ); + SaveProjectSettings(); } @@ -331,7 +331,7 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirecto { wxString msg = wxString::Format( _( "Could not write plot files to folder \"%s\"." ), outputDir.GetPath() ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + aReporter->Report( msg, SEVERITY_ERROR ); } wxFileName fn( plotFileName ); diff --git a/eeschema/dialogs/dialog_symbol_remap.cpp b/eeschema/dialogs/dialog_symbol_remap.cpp index 221306f592..aad5bb786c 100644 --- a/eeschema/dialogs/dialog_symbol_remap.cpp +++ b/eeschema/dialogs/dialog_symbol_remap.cpp @@ -203,7 +203,7 @@ void DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable( REPORTER& aReporter ) { msg.Printf( _( "Adding library \"%s\", file \"%s\" to project symbol library table." ), libName, fullFileName ); - aReporter.Report( msg, REPORTER::RPT_INFO ); + aReporter.Report( msg, SEVERITY_INFO ); prjLibTable.InsertRow( new SYMBOL_LIB_TABLE_ROW( libName, fullFileName, pluginType ) ); @@ -211,7 +211,7 @@ void DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable( REPORTER& aReporter ) else { msg.Printf( _( "Library \"%s\" not found." ), fullFileName ); - aReporter.Report( msg, REPORTER::RPT_WARNING ); + aReporter.Report( msg, SEVERITY_WARNING ); } } @@ -229,10 +229,10 @@ void DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable( REPORTER& aReporter ) { msg.Printf( _( "Failed to write project symbol library table. Error:\n %s" ), ioe.What() ); - aReporter.ReportTail( msg, REPORTER::RPT_ERROR ); + aReporter.ReportTail( msg, SEVERITY_ERROR ); } - aReporter.ReportTail( _( "Created project symbol library table.\n" ), REPORTER::RPT_INFO ); + aReporter.ReportTail( _( "Created project symbol library table.\n" ), SEVERITY_INFO ); } } } @@ -254,21 +254,21 @@ void DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable( REPORTER& aReporter ) if( !remapSymbolToLibTable( symbol ) ) { msg.Printf( _( "No symbol \"%s\" found in symbol library table." ), - symbol->GetLibId().GetLibItemName().wx_str() ); - aReporter.Report( msg, REPORTER::RPT_WARNING ); + symbol->GetLibId().GetLibItemName().wx_str() ); + aReporter.Report( msg, SEVERITY_WARNING ); } else { msg.Printf( _( "Symbol \"%s\" mapped to symbol library \"%s\"." ), - symbol->GetLibId().GetLibItemName().wx_str(), - symbol->GetLibId().GetLibNickname().wx_str() ); - aReporter.Report( msg, REPORTER::RPT_ACTION ); + symbol->GetLibId().GetLibItemName().wx_str(), + symbol->GetLibId().GetLibNickname().wx_str() ); + aReporter.Report( msg,SEVERITY_ACTION ); screen->SetModify(); } } } - aReporter.Report( _( "Symbol library table mapping complete!" ), REPORTER::RPT_INFO ); + aReporter.Report( _( "Symbol library table mapping complete!" ), SEVERITY_INFO ); schematic.UpdateSymbolLinks( true ); } @@ -363,7 +363,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ), srcFileName.GetFullPath(), destFileName.GetFullPath() ); - aReporter.Report( tmp, REPORTER::RPT_INFO ); + aReporter.Report( tmp, SEVERITY_INFO ); if( wxFileName::Exists( srcFileName.GetFullPath() ) && !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) ) @@ -396,7 +396,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ), screen->GetFileName(), destFileName.GetFullPath() ); - aReporter.Report( tmp, REPORTER::RPT_INFO ); + aReporter.Report( tmp, SEVERITY_INFO ); if( !destFileName.DirExists() && !destFileName.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) ) { @@ -420,7 +420,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ), Prj().GetProjectFullName(), destFileName.GetFullPath() ); - aReporter.Report( tmp, REPORTER::RPT_INFO ); + aReporter.Report( tmp, SEVERITY_INFO ); if( wxFileName::Exists( Prj().GetProjectFullName() ) && !wxCopyFile( Prj().GetProjectFullName(), destFileName.GetFullPath() ) ) @@ -440,7 +440,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ), srcFileName.GetFullPath(), destFileName.GetFullPath() ); - aReporter.Report( tmp, REPORTER::RPT_INFO ); + aReporter.Report( tmp, SEVERITY_INFO ); if( srcFileName.Exists() && !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) ) @@ -454,8 +454,9 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) destFileName.SetName( srcFileName.GetName() + timeStamp ); tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ), - srcFileName.GetFullPath(), destFileName.GetFullPath() ); - aReporter.Report( tmp, REPORTER::RPT_INFO ); + srcFileName.GetFullPath(), + destFileName.GetFullPath() ); + aReporter.Report( tmp, SEVERITY_INFO ); if( srcFileName.Exists() && !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) ) @@ -469,8 +470,9 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) destFileName.SetExt( srcFileName.GetExt() ); tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ), - srcFileName.GetFullPath(), destFileName.GetFullPath() ); - aReporter.Report( tmp, REPORTER::RPT_INFO ); + srcFileName.GetFullPath(), + destFileName.GetFullPath() ); + aReporter.Report( tmp, SEVERITY_INFO ); if( srcFileName.Exists() && !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) ) diff --git a/eeschema/dialogs/panel_eeschema_display_options.cpp b/eeschema/dialogs/panel_eeschema_display_options.cpp index c7c337173b..64f8345fd7 100644 --- a/eeschema/dialogs/panel_eeschema_display_options.cpp +++ b/eeschema/dialogs/panel_eeschema_display_options.cpp @@ -115,7 +115,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow() firstRefId != LIB_PART::GetSubpartFirstId() ) { LIB_PART::SetSubpartIdNotation( refSeparator, firstRefId ); - m_frame->SaveProjectSettings( false ); + m_frame->SaveProjectSettings(); } SetDefaultBusThickness( m_busWidth.GetValue() ); diff --git a/eeschema/dialogs/panel_eeschema_settings.cpp b/eeschema/dialogs/panel_eeschema_settings.cpp index e1f5cf83e8..c7c3d53227 100644 --- a/eeschema/dialogs/panel_eeschema_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_settings.cpp @@ -73,7 +73,7 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataFromWindow() if( textSize != GetDefaultTextSize() ) { SetDefaultTextSize( textSize ); - m_frame->SaveProjectSettings( false ); + m_frame->SaveProjectSettings(); } m_frame->SetRepeatStep( diff --git a/eeschema/drc_erc_item.cpp b/eeschema/drc_erc_item.cpp index 65f5763a17..41786e78e2 100644 --- a/eeschema/drc_erc_item.cpp +++ b/eeschema/drc_erc_item.cpp @@ -106,14 +106,14 @@ wxString DRC_ITEM::ShowHtml( EDA_UNITS aUnits ) const wxColour hrefColour = wxSystemSettings::GetColour( wxSYS_COLOUR_HOTLIGHT ); - if( m_noCoordinate ) + if( !m_hasPositions ) { // omit the coordinate, a NETCLASS has no location return wxString::Format( "

%s
   %s", errText, mainText ); } else if( m_hasSecondItem ) { - wxString auxText = m_AuxiliaryText; + wxString auxText = m_AuxText; auxText.Replace( wxT("<"), wxT("<") ); auxText.Replace( wxT(">"), wxT(">") ); @@ -124,7 +124,7 @@ wxString DRC_ITEM::ShowHtml( EDA_UNITS aUnits ) const hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), ShowCoord( aUnits, m_MainPosition ), mainText, - ShowCoord( aUnits, m_AuxiliaryPosition ), + ShowCoord( aUnits, m_AuxPosition ), auxText ); } else @@ -147,8 +147,8 @@ wxString DRC_ITEM::ShowReport( EDA_UNITS aUnits ) const GetErrorText(), ShowCoord( aUnits, m_MainPosition ), m_MainText, - ShowCoord( aUnits, m_AuxiliaryPosition ), - m_AuxiliaryText ); + ShowCoord( aUnits, m_AuxPosition ), + m_AuxText ); } else { diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 48a9aff7cd..bfd69e2351 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -264,7 +264,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile() } -void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) +void SCH_EDIT_FRAME::SaveProjectSettings() { PROJECT& prj = Prj(); wxFileName fn = g_RootSheet->GetScreen()->GetFileName(); //ConfigFileName @@ -274,17 +274,6 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) if( !IsWritable( fn ) ) return; - if( aAskForSave ) - { - wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(), - ProjectFileWildcard(), wxFD_SAVE ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - fn = dlg.GetPath(); - } - wxString path = fn.GetFullPath(); // Convert default text size from internal units temporarily. diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index b2ead0dc3a..318c206230 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -661,7 +661,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) g_RootSheet->SetFileName( newfilename.GetFullPath() ); GetScreen()->SetFileName( newfilename.GetFullPath() ); GetScreen()->SetModify(); - SaveProjectSettings( false ); + SaveProjectSettings(); UpdateFileHistory( aFileName ); SCH_SCREENS schematic; diff --git a/eeschema/netlist_generator.cpp b/eeschema/netlist_generator.cpp index 9433c35a57..a113f310c1 100644 --- a/eeschema/netlist_generator.cpp +++ b/eeschema/netlist_generator.cpp @@ -119,33 +119,33 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST* aConnectedItemsList, msg << _( "Run command:" ) << wxT( "\n" ) << commandLine << wxT( "\n\n" ); - aReporter->ReportHead( msg, REPORTER::RPT_ACTION ); + aReporter->ReportHead( msg, SEVERITY_ACTION ); if( diag != 0 ) aReporter->ReportTail( wxString::Format( - _("Command error. Return code %d" ), diag ), - REPORTER::RPT_ERROR ); + _("Command error. Return code %d" ), diag ), + SEVERITY_ERROR ); else - aReporter->ReportTail( _( "Success" ), REPORTER::RPT_INFO ); + aReporter->ReportTail( _( "Success" ), SEVERITY_INFO ); if( output.GetCount() ) { msg.Empty(); msg << wxT( "\n" ) << _( "Info messages:" ) << wxT( "\n" ); - aReporter->Report( msg, REPORTER::RPT_INFO ); + aReporter->Report( msg, SEVERITY_INFO ); for( unsigned ii = 0; ii < output.GetCount(); ii++ ) - aReporter->Report( output[ii] + wxT( "\n" ), REPORTER::RPT_INFO ); + aReporter->Report( output[ii] + wxT( "\n" ), SEVERITY_INFO ); } if( errors.GetCount() ) { msg.Empty(); msg << wxT("\n") << _( "Error messages:" ) << wxT( "\n" ); - aReporter->Report( msg, REPORTER::RPT_INFO ); + aReporter->Report( msg, SEVERITY_INFO ); for( unsigned ii = 0; ii < errors.GetCount(); ii++ ) - aReporter->Report( errors[ii] + wxT( "\n" ), REPORTER::RPT_ERROR ); + aReporter->Report( errors[ii] + wxT( "\n" ), SEVERITY_ERROR ); } } else diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index ea7e184c30..89b07c038c 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -76,20 +76,19 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) if( PlotOneSheetDXF( plotFileName.GetFullPath(), screen, plot_offset, 1.0, aPlotFrameRef ) ) { - msg.Printf( _( "Plot: \"%s\" OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ACTION ); + msg.Printf( _( "Plot: \"%s\" OK.\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ACTION ); } else // Error { - msg.Printf( _( "Unable to create file \"%s\".\n" ), - GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Unable to create file \"%s\".\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ERROR ); } } catch( IO_ERROR& e ) { - msg.Printf( wxT( "DXF Plotter exception: %s"), GetChars( e.What() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( wxT( "DXF Plotter exception: %s"), e.What() ); + reporter.Report( msg, SEVERITY_ERROR ); schframe->SetCurrentSheet( oldsheetpath ); schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index ed571a9539..0948cf3bad 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -148,20 +148,19 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) if( Plot_1_Page_HPGL( plotFileName.GetFullPath(), screen, plotPage, plotOffset, plot_scale, aPlotFrameRef ) ) { - msg.Printf( _( "Plot: \"%s\" OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ACTION ); + msg.Printf( _( "Plot: \"%s\" OK.\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ACTION ); } else { - msg.Printf( _( "Unable to create file \"%s\".\n" ), - GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Unable to create file \"%s\".\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ERROR ); } } catch( IO_ERROR& e ) { - msg.Printf( wxT( "HPGL Plotter exception: %s"), GetChars( e.What() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( wxT( "HPGL Plotter exception: %s"), e.What() ); + reporter.Report( msg, SEVERITY_ERROR ); } } diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index d7bc491156..34bf6b6ab8 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -83,14 +83,12 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) { wxString fname = m_parent->GetUniqueFilenameForCurrentSheet(); wxString ext = PDF_PLOTTER::GetDefaultFileExtension(); - plotFileName = createPlotFileName( m_outputDirectoryName, - fname, ext, &reporter ); + plotFileName = createPlotFileName( m_outputDirectoryName, fname, ext, &reporter ); if( !plotter->OpenFile( plotFileName.GetFullPath() ) ) { - msg.Printf( _( "Unable to create file \"%s\".\n" ), - GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Unable to create file \"%s\".\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ERROR ); delete plotter; return; } @@ -102,8 +100,8 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) catch( const IO_ERROR& e ) { // Cannot plot PDF file - msg.Printf( wxT( "PDF Plotter exception: %s" ), GetChars( e.What() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() ); + reporter.Report( msg, SEVERITY_ERROR ); restoreEnvironment( plotter, oldsheetpath ); return; @@ -123,8 +121,8 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) } // Everything done, close the plot and restore the environment - msg.Printf( _( "Plot: \"%s\" OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ACTION ); + msg.Printf( _( "Plot: \"%s\" OK.\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ACTION ); restoreEnvironment( plotter, oldsheetpath ); } diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index d20e976609..505832e782 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -103,22 +103,21 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) if( plotOneSheetPS( plotFileName.GetFullPath(), screen, plotPage, plot_offset, scale, aPlotFrameRef ) ) { - msg.Printf( _( "Plot: \"%s\" OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ACTION ); + msg.Printf( _( "Plot: \"%s\" OK.\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ACTION ); } else { // Error - msg.Printf( _( "Unable to create file \"%s\".\n" ), - GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Unable to create file \"%s\".\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ERROR ); } } catch( IO_ERROR& e ) { - msg.Printf( wxT( "PS Plotter exception: %s"), GetChars( e.What() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( wxT( "PS Plotter exception: %s"), e.What() ); + reporter.Report( msg, SEVERITY_ERROR ); } } diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index 6f551ca714..64c710def7 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -73,22 +73,20 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) if( !success ) { - msg.Printf( _( "Cannot create file \"%s\".\n" ), - GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Cannot create file \"%s\".\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ERROR ); } else { - msg.Printf( _( "Plot: \"%s\" OK.\n" ), - GetChars( plotFileName.GetFullPath() ) ); - reporter.Report( msg, REPORTER::RPT_ACTION ); + msg.Printf( _( "Plot: \"%s\" OK.\n" ), plotFileName.GetFullPath() ); + reporter.Report( msg, SEVERITY_ACTION ); } } catch( const IO_ERROR& e ) { // Cannot plot SVG file - msg.Printf( wxT( "SVG Plotter exception: %s" ), GetChars( e.What() ) ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() ); + reporter.Report( msg, SEVERITY_ERROR ); break; } } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 4576278697..13dff10aa2 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -257,10 +257,8 @@ public: /** * Save changes to the project settings to the project (.pro) file. - * - * @param aAskForSave = true to open a dialog before saving the settings */ - void SaveProjectSettings( bool aAskForSave ) override; + void SaveProjectSettings() override; /** * Loads the KiCad project file (*.pro) settings specific to Eeschema. diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index a25f0530c2..894742e3be 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -35,14 +35,16 @@ #define SCALING_FACTOR Millimeter2iu( 0.1 ) +// JEY TODO: retire this; there's no reason not to use the next one... SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE( SCALING_FACTOR ) { } +// JEY TODO: pass in ERCE code so we can get severity from it... SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) : SCH_ITEM( NULL, SCH_MARKER_T ), - MARKER_BASE( 0, pos, text, pos, SCALING_FACTOR ) + MARKER_BASE( 0, pos, text, pos, wxEmptyString, wxPoint(), SCALING_FACTOR ) { } @@ -70,18 +72,20 @@ void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const #endif +KIGFX::COLOR4D SCH_MARKER::getColor() const +{ + if( IsExcluded() ) + return GetLayerColor( LAYER_HIDDEN ); + else if( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) + return GetLayerColor( LAYER_ERC_ERR ); + else + return GetLayerColor( LAYER_ERC_WARN ); +} + + void SCH_MARKER::Print( wxDC* aDC, const wxPoint& aOffset ) { - COLOR4D tmp = m_Color; - - if( GetMarkerType() == MARKER_BASE::MARKER_ERC ) - { - m_Color = ( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) ? - GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN ); - } - PrintMarker( aDC, aOffset ); - m_Color = tmp; } diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 8c694c842f..4d7d4b8d1a 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -105,6 +105,9 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override; #endif + +protected: + KIGFX::COLOR4D getColor() const override; }; #endif // TYPE_SCH_MARKER_H_ diff --git a/eeschema/sch_preview_panel.h b/eeschema/sch_preview_panel.h index b340409508..13d1aed541 100644 --- a/eeschema/sch_preview_panel.h +++ b/eeschema/sch_preview_panel.h @@ -38,8 +38,6 @@ namespace KIGFX { }; }; -class COLORS_DESIGN_SETTINGS; - class SCH_PREVIEW_PANEL : public EDA_DRAW_PANEL_GAL { diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index a80423067a..306061704b 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -61,7 +61,7 @@ public: { } - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override { wxCommandEvent* event = new wxCommandEvent( EVT_SIM_REPORT ); event->SetString( aText ); diff --git a/eeschema/tools/backannotate.cpp b/eeschema/tools/backannotate.cpp index 0879ecafa9..4b44fb52ad 100644 --- a/eeschema/tools/backannotate.cpp +++ b/eeschema/tools/backannotate.cpp @@ -61,7 +61,7 @@ bool BACK_ANNOTATE::BackAnnotateSymbols( const std::string& aNetlist ) && !m_settings.processReferences ) { m_settings.reporter.ReportTail( - _( "Select at least one property to back annotate" ), REPORTER::RPT_ERROR ); + _( "Select at least one property to back annotate" ), SEVERITY_ERROR ); return false; } @@ -85,16 +85,16 @@ bool BACK_ANNOTATE::BackAnnotateSymbols( const std::string& aNetlist ) if( !m_settings.dryRun ) { msg.Printf( _( "Schematic is back-annotated. %d changes applied." ), m_changesCount ); - m_settings.reporter.ReportTail( msg, REPORTER::RPT_ACTION ); + m_settings.reporter.ReportTail( msg, SEVERITY_ACTION ); } else m_settings.reporter.ReportTail( - _( "No errors during dry run. Ready to go." ), REPORTER::RPT_ACTION ); + _( "No errors during dry run. Ready to go." ), SEVERITY_ACTION ); } else { msg.Printf( _( "Found %d errors. Fix them and run back annotation." ), errors ); - m_settings.reporter.ReportTail( msg, REPORTER::RPT_ERROR ); + m_settings.reporter.ReportTail( msg, SEVERITY_ERROR ); } return !errors; @@ -149,7 +149,7 @@ int BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload ) if( path == "" ) { msg.Printf( _( "Footprint \"%s\" has no symbol associated." ), ref ); - m_settings.reporter.ReportHead( msg, REPORTER::RPT_WARNING ); + m_settings.reporter.ReportHead( msg, SEVERITY_WARNING ); continue; } footprint = UTF8( item.second.get_child( "fpid" ).front().first ); @@ -168,7 +168,7 @@ int BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload ) // Module with this path already exists - generate error msg.Printf( _( "Pcb footprints \"%s\" and \"%s\" linked to same symbol" ), nearestItem->second->ref, ref ); - m_settings.reporter.ReportHead( msg, REPORTER::RPT_ERROR ); + m_settings.reporter.ReportHead( msg, SEVERITY_ERROR ); ++errors; } else @@ -223,7 +223,7 @@ int BACK_ANNOTATE::getChangeList() wxString msg; msg.Printf( _( "Cannot find symbol for \"%s\" footprint" ), pcbData->ref ); ++errors; - m_settings.reporter.ReportTail( msg, REPORTER::RPT_ERROR ); + m_settings.reporter.ReportTail( msg, SEVERITY_ERROR ); } } return errors; @@ -248,7 +248,7 @@ int BACK_ANNOTATE::checkForUnusedSymbols() ++errors; wxString msg; msg.Printf( _( "Cannot find footprint for \"%s\" symbol" ), m_refs[i++].GetFullRef() ); - m_settings.reporter.ReportTail( msg, REPORTER::RPT_ERROR ); + m_settings.reporter.ReportTail( msg, SEVERITY_ERROR ); } ++i; @@ -309,8 +309,8 @@ int BACK_ANNOTATE::checkSharedSchematicErrors() wxString msg; msg.Printf( _( "\"%s\" and \"%s\" use the same schematic symbol.\n" "They cannot have different footprints or values." ), - ( it + 1 )->second->ref, it->second->ref ); - m_settings.reporter.ReportTail( msg, REPORTER::RPT_ERROR ); + ( it + 1 )->second->ref, it->second->ref ); + m_settings.reporter.ReportTail( msg, SEVERITY_ERROR ); } } else @@ -327,8 +327,8 @@ int BACK_ANNOTATE::checkSharedSchematicErrors() wxString msg; msg.Printf( _( "Unable to change \"%s\" footprint or value because associated" " symbol is reused in the another project" ), - it->second->ref ); - m_settings.reporter.ReportTail( msg, REPORTER::RPT_ERROR ); + it->second->ref ); + m_settings.reporter.ReportTail( msg, SEVERITY_ERROR ); ++errors; } } @@ -359,7 +359,7 @@ void BACK_ANNOTATE::applyChangelist() msg.Printf( _( "Change \"%s\" reference to \"%s\"." ), ref.GetFullRef(), module.ref ); if( !m_settings.dryRun ) ref.GetComp()->SetRef( &ref.GetSheetPath(), module.ref ); - m_settings.reporter.ReportHead( msg, REPORTER::RPT_ACTION ); + m_settings.reporter.ReportHead( msg, SEVERITY_ACTION ); } if( m_settings.processFootprints && oldFootprint != module.footprint ) @@ -370,7 +370,7 @@ void BACK_ANNOTATE::applyChangelist() if( !m_settings.dryRun ) ref.GetComp()->GetField( FOOTPRINT )->SetText( module.footprint ); - m_settings.reporter.ReportHead( msg, REPORTER::RPT_ACTION ); + m_settings.reporter.ReportHead( msg, SEVERITY_ACTION ); } if( m_settings.processValues && oldValue != module.value ) @@ -380,12 +380,12 @@ void BACK_ANNOTATE::applyChangelist() getTextFromField( ref, VALUE ), module.value ); if( !m_settings.dryRun ) item.first.GetComp()->GetField( VALUE )->SetText( module.value ); - m_settings.reporter.ReportHead( msg, REPORTER::RPT_ACTION ); + m_settings.reporter.ReportHead( msg, SEVERITY_ACTION ); } if( changesCountBefore == m_changesCount ) ++leftUnchanged; } msg.Printf( _( "%d symbols left unchanged" ), leftUnchanged ); - m_settings.reporter.ReportHead( msg, REPORTER::RPT_INFO ); + m_settings.reporter.ReportHead( msg, SEVERITY_INFO ); } diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp index 4bc5f4f18a..0358c728c5 100644 --- a/eeschema/widgets/widget_eeschema_color_config.cpp +++ b/eeschema/widgets/widget_eeschema_color_config.cpp @@ -94,12 +94,12 @@ static COLORBUTTON miscColorButtons[] = { { _( "ERC warning" ), LAYER_ERC_WARN }, { _( "ERC error" ), LAYER_ERC_ERR }, { _( "Brightened" ), LAYER_BRIGHTENED }, - { _( "Hidden items" ), LAYER_HIDDEN }, + { _( "Hidden item" ), LAYER_HIDDEN }, { _( "Worksheet" ), LAYER_SCHEMATIC_WORKSHEET }, { _( "Cursor" ), LAYER_SCHEMATIC_CURSOR }, { _( "Grid" ), LAYER_SCHEMATIC_GRID }, { _( "Background" ), LAYER_SCHEMATIC_BACKGROUND }, - { _( "Selection Highlight" ), LAYER_SELECTION_SHADOWS }, + { _( "Selection highlight" ), LAYER_SELECTION_SHADOWS }, { wxT( "" ), -1 } // Sentinel marking end of list. }; diff --git a/gerbview/files.cpp b/gerbview/files.cpp index ae9f9674e1..79d101a63b 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -308,7 +308,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath, wxString warning; warning << "" << _( "File not found:" ) << "
" << filename.GetFullPath() << "
"; - reporter.Report( warning, REPORTER::RPT_WARNING ); + reporter.Report( warning, SEVERITY_WARNING ); success = false; continue; } @@ -350,7 +350,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath, if( layer == NO_AVAILABLE_LAYERS && ii < aFilenameList.GetCount()-1 ) { success = false; - reporter.Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); + reporter.Report( MSG_NO_MORE_LAYER, SEVERITY_ERROR ); // Report the name of not loaded files: ii += 1; @@ -358,7 +358,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath, { filename = aFilenameList[ii++]; wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() ); - reporter.Report( txt, REPORTER::RPT_ERROR ); + reporter.Report( txt, SEVERITY_ERROR ); } break; } @@ -471,7 +471,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { success = false; - reporter.Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); + reporter.Report( MSG_NO_MORE_LAYER, SEVERITY_ERROR ); // Report the name of not loaded files: ii += 1; @@ -479,7 +479,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) { filename = filenamesList[ii++]; wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() ); - reporter.Report( txt, REPORTER::RPT_ERROR ); + reporter.Report( txt, SEVERITY_ERROR ); } break; } @@ -521,8 +521,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR { if( aReporter ) { - msg.Printf( _( "Zip file \"%s\" cannot be opened" ), GetChars( aFullFileName ) ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _( "Zip file \"%s\" cannot be opened" ), aFullFileName ); + aReporter->Report( msg, SEVERITY_ERROR ); } return false; @@ -563,9 +563,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR { if( aReporter ) { - msg.Printf( _( "Info: skip file \"%s\" (unknown type)\n" ), - GetChars( entry->GetName() ) ); - aReporter->Report( msg, REPORTER::RPT_WARNING ); + msg.Printf( _( "Info: skip file \"%s\" (unknown type)\n" ), entry->GetName() ); + aReporter->Report( msg, SEVERITY_WARNING ); } continue; @@ -580,13 +579,13 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR if( aReporter ) { if( !reported_no_more_layer ) - aReporter->Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); + aReporter->Report( MSG_NO_MORE_LAYER, SEVERITY_ERROR ); reported_no_more_layer = true; // Report the name of not loaded files: msg.Printf( MSG_NOT_LOADED, GetChars( entry->GetName() ) ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + aReporter->Report( msg, SEVERITY_ERROR ); } delete entry; @@ -606,8 +605,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR if( aReporter ) { msg.Printf( _( "Unable to create temporary file \"%s\"\n"), - GetChars( unzipped_tempfile ) ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + unzipped_tempfile ); + aReporter->Report( msg, SEVERITY_ERROR ); } } } @@ -635,9 +634,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR if( aReporter ) { - msg.Printf( _("unzipped file %s read error\n"), - GetChars( unzipped_tempfile ) ); - aReporter->Report( msg, REPORTER::RPT_ERROR ); + msg.Printf( _("unzipped file %s read error\n"), unzipped_tempfile ); + aReporter->Report( msg, SEVERITY_ERROR ); } } else diff --git a/gerbview/gerbview_draw_panel_gal.h b/gerbview/gerbview_draw_panel_gal.h index 0d8ff43a09..b185fa9e96 100644 --- a/gerbview/gerbview_draw_panel_gal.h +++ b/gerbview/gerbview_draw_panel_gal.h @@ -28,8 +28,6 @@ namespace KIGFX class WS_PROXY_VIEW_ITEM; } -class COLORS_DESIGN_SETTINGS; - class GERBVIEW_DRAW_PANEL_GAL : public EDA_DRAW_PANEL_GAL { diff --git a/gerbview/gerbview_painter.h b/gerbview/gerbview_painter.h index fcc7c3c09d..efd399974c 100644 --- a/gerbview/gerbview_painter.h +++ b/gerbview/gerbview_painter.h @@ -32,8 +32,6 @@ class EDA_ITEM; -class COLORS_DESIGN_SETTINGS; - class GERBER_DRAW_ITEM; class GERBER_FILE_IMAGE; diff --git a/gerbview/job_file_reader.cpp b/gerbview/job_file_reader.cpp index 310ddb1495..d3043f9d81 100644 --- a/gerbview/job_file_reader.cpp +++ b/gerbview/job_file_reader.cpp @@ -151,8 +151,8 @@ bool GERBER_JOBFILE_READER::ReadGerberJobFile() else { if( m_reporter ) - m_reporter->ReportTail( _( "This job file uses an outdated format. Please, recreate it." ), - REPORTER::RPT_WARNING ); + m_reporter->ReportTail( _( "This job file uses an outdated format. Please recreate it." ), + SEVERITY_WARNING ); return false; } diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 3540f5d599..24c7147a40 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -188,17 +188,17 @@ public: bool m_BlindBuriedViaAllowed; ///< true to allow blind/buried vias VIATYPE m_CurrentViaType; ///< (VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA) - bool m_RequireCourtyards; ///< require courtyard definitions in footprints - bool m_ProhibitOverlappingCourtyards; ///< check for overlapping courtyards in DRC - - // if true, when creating a new track starting on an existing track, use this track width - bool m_UseConnectedTrackWidth; - int m_TrackMinWidth; ///< track min value for width ((min copper size value - int m_ViasMinSize; ///< vias (not micro vias) min diameter - int m_ViasMinDrill; ///< vias (not micro vias) min drill diameter - int m_MicroViasMinSize; ///< micro vias (not vias) min diameter - int m_MicroViasMinDrill; ///< micro vias (not vias) min drill diameter + bool m_UseConnectedTrackWidth; // use width of existing track when creating a new, + // connected track + int m_TrackMinWidth; // track min value for width ((min copper size value + int m_ViasMinSize; // vias (not micro vias) min diameter + int m_ViasMinDrill; // vias (not micro vias) min drill diameter + int m_MicroViasMinSize; // micro vias min diameter + int m_MicroViasMinDrill; // micro vias min drill diameter int m_CopperEdgeClearance; + int m_HoleToHoleMin; // Min width of peninsula between two drilled holes + + std::map< int, int > m_DRCSeverities; // Map from DRCErrorCode to SEVERITY /** Option to handle filled polygons in zones: * the "legacy" option is using thick outlines around filled polygons: give the best shape @@ -220,8 +220,6 @@ public: double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size ///< The final margin is the sum of these 2 values - int m_HoleToHoleMin; ///< Min width of peninsula between two drilled holes - // Arrays of default values for the various layer classes. int m_LineThickness[ LAYER_CLASS_COUNT ]; wxSize m_TextSize[ LAYER_CLASS_COUNT ]; @@ -303,6 +301,13 @@ public: BOARD_STACKUP& GetStackupDescriptor() { return m_stackup; } + int GetSeverity( int aDRCErrorCode ); + + /** + * returns true if the DRC error code's severity is SEVERITY_IGNORE + */ + bool Ignore( int aDRCErrorCode ); + /** * Function GetDefault * @return the default netclass. @@ -678,18 +683,6 @@ public: */ void SetCopperEdgeClearance( int aDistance ); - /** - * Function SetRequireCourtyardDefinitions - * @param aRequire Set to true to generate DRC violations from missing courtyards. - */ - void SetRequireCourtyardDefinitions( bool aRequire ); - - /** - * Function SetProhibitOverlappingCourtyards - * @param aProhibit Set to true to generate DRC violations from overlapping courtyards. - */ - void SetProhibitOverlappingCourtyards( bool aProhibit ); - /** * Function GetVisibleLayers * returns a bit-mask of all the layers that are visible diff --git a/include/colors_design_settings.h b/include/colors_design_settings.h deleted file mode 100644 index 8a93e47f15..0000000000 --- a/include/colors_design_settings.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016 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 - */ - -/** - * @file colors_design_settings.h - * @brief Handle colors used to draw all items or layers. - */ - -#ifndef COLORS_DESIGN_SETTING_H -#define COLORS_DESIGN_SETTING_H -#include -#include -#include - -using KIGFX::COLOR4D; - -class wxConfigBase; -class wxString; -#include - -class PARAM_CFG; - -/** - * COLORS_DESIGN_SETTINGS - * is a list of color settings for designs in Pcbnew - */ -class COLORS_DESIGN_SETTINGS : public SETTINGS -{ -public: - // Color options for screen display of the Printed Board or schematic: - COLOR4D m_LayersColors[LAYER_ID_COUNT]; ///< Layer colors (tracks and graphic items) - -public: - COLORS_DESIGN_SETTINGS( FRAME_T aFrameType ); - - ~COLORS_DESIGN_SETTINGS() override - {} - - virtual void Load( wxConfigBase *aConfig ) override; - virtual void Save( wxConfigBase *aConfig ) override; - - /** - * Function GetDefaultLayerColor - * @return the default color for aLayer which is one of the item indices given in - * enum PCB_LAYER_ID - */ - static COLOR4D GetDefaultLayerColor( LAYER_NUM aLayer ); - - /** - * Function GetLayerColor - * @return the color for aLayer which is one of the item indices given in - * enum PCB_LAYER_ID - */ - COLOR4D GetLayerColor( LAYER_NUM aLayer ) const; - - /** - * Function SetLayerColor - * sets the color for aLayer which is one of the item indices given in - * enum PCB_LAYER_ID - */ - void SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor ); - - /** - * Function GetDefaultItemColor - * @return the default color for the an item which is one of the item - * indices given in enum GAL_LAYER_ID - */ - static COLOR4D GetDefaultItemColor( int aItemIdx ); - - /** - * Function GetItemColor - * @return the color for an item which is one of the item indices given - * in enum GAL_LAYER_ID - */ - COLOR4D GetItemColor( int aItemIdx ) const; - - /** - * Function SetItemColor - * sets the color for an item which is one of the item indices given - * in enum GAL_LAYER_ID - */ - void SetItemColor( int aItemIdx, COLOR4D aColor ); - - /** - * Function SetAllColorsAs - * sets alls colors to aColor - * Usefull to create a monochrome color selection for printing purpose - */ - void SetAllColorsAs( COLOR4D aColor ); - -private: - FRAME_T m_frameType; - - void setupConfigParams(); -}; - -#endif // COLORS_DESIGN_SETTING_H diff --git a/include/config_params.h b/include/config_params.h index 90d56e4a12..5dc94528e3 100644 --- a/include/config_params.h +++ b/include/config_params.h @@ -3,7 +3,7 @@ * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 1992-2011 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 * modify it under the terms of the GNU General Public License @@ -26,16 +26,13 @@ #ifndef CONFIG_PARAMS_H_ #define CONFIG_PARAMS_H_ -/** - * The common library - * @file config_params.h - */ +#include +#include #include #include #include #include -#include using KIGFX::COLOR4D; @@ -77,14 +74,15 @@ enum paramcfg_id { PARAM_BOOL, PARAM_LIBNAME_LIST, PARAM_WXSTRING, + PARAM_WXSTRING_SET, PARAM_FILENAME, PARAM_COMMAND_ERASE, - PARAM_FIELDNAME_LIST, PARAM_LAYERS, PARAM_TRACKWIDTHS, PARAM_VIADIMENSIONS, PARAM_DIFFPAIRDIMENSIONS, - PARAM_NETCLASSES + PARAM_NETCLASSES, + PARAM_SEVERITIES }; @@ -279,6 +277,28 @@ public: }; +/** + * Configuration parameter - std::set + * + */ +class PARAM_CFG_WXSTRING_SET : public PARAM_CFG +{ +public: + std::set* m_Pt_param; ///< Pointer to the parameter value + +public: + PARAM_CFG_WXSTRING_SET( const wxString& ident, std::set* ptparam, const wxChar* group = NULL ); + + PARAM_CFG_WXSTRING_SET( bool Insetup, + const wxString& ident, + std::set* ptparam, + const wxChar* group = NULL ); + + virtual void ReadParam( wxConfigBase* aConfig ) const override; + virtual void SaveParam( wxConfigBase* aConfig ) const override; +}; + + /** * Configuration parameter - PARAM_CFG_FILENAME Class * Same as PARAM_CFG_WXSTRING, but stores "\" as "/". diff --git a/include/drc_item.h b/include/drc_item.h index 88fcabb706..468e86475b 100644 --- a/include/drc_item.h +++ b/include/drc_item.h @@ -44,11 +44,11 @@ class DRC_ITEM protected: int m_ErrorCode; // the error code's numeric value wxString m_MainText; // text for the first EDA_ITEM - wxString m_AuxiliaryText; // text for the second EDA_ITEM + wxString m_AuxText; // text for the second EDA_ITEM wxPoint m_MainPosition; // the location of the first EDA_ITEM - wxPoint m_AuxiliaryPosition; // the location of the second EDA_ITEM + wxPoint m_AuxPosition; // the location of the second EDA_ITEM + bool m_hasPositions; bool m_hasSecondItem; // true when 2 items create a DRC/ERC error - bool m_noCoordinate; MARKER_BASE* m_parent; // The marker this item belongs to, if any KIID m_mainItemUuid; KIID m_auxItemUuid; @@ -57,29 +57,32 @@ public: DRC_ITEM() { - m_ErrorCode = 0; - m_hasSecondItem = false; - m_noCoordinate = false; - m_parent = nullptr; - m_mainItemUuid = niluuid; - m_auxItemUuid = niluuid; + m_ErrorCode = 0; + m_hasPositions = false; + m_hasSecondItem = false; + m_parent = nullptr; + m_mainItemUuid = niluuid; + m_auxItemUuid = niluuid; } - DRC_ITEM( EDA_UNITS aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos, - EDA_ITEM* bAuxiliaryItem, const wxPoint& bAuxiliaryPos ) + DRC_ITEM( EDA_UNITS aUnits, int aErrorCode, + EDA_ITEM* aMainItem, + EDA_ITEM* bAuxItem = nullptr ) { - SetData( aUnits, aErrorCode, aMainItem, aMainPos, bAuxiliaryItem, bAuxiliaryPos ); + SetData( aUnits, aErrorCode, aMainItem, bAuxItem ); } - DRC_ITEM( EDA_UNITS aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos ) + DRC_ITEM( EDA_UNITS aUnits, int aErrorCode, + EDA_ITEM* aMainItem, const wxPoint& aMainPos, + EDA_ITEM* bAuxItem = nullptr, const wxPoint& bAuxPos = wxPoint() ) { - SetData( aUnits, aErrorCode, aMainItem, aMainPos ); + SetData( aUnits, aErrorCode, aMainItem, aMainPos, bAuxItem, bAuxPos ); } DRC_ITEM( int aErrorCode, const wxString& aMainText ) { SetData( aErrorCode, aMainText, wxPoint() ); - SetShowNoCoordinate(); + m_hasPositions = false; } /** @@ -87,27 +90,24 @@ public: * initialize all data in item * @param aErrorCode = error code * @param aMainItem = the first (main) schematic or board item - * @param bAuxiliaryItem = the second schematic or board item - * @param aMainPos = position the first item and therefore of this issue - * @param bAuxiliaryPos = position the second item + * @param bAuxItem = the second schematic or board item */ - void SetData( EDA_UNITS aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos, - EDA_ITEM* bAuxiliaryItem = nullptr, const wxPoint& bAuxiliaryPos = wxPoint() ) + void SetData( EDA_UNITS aUnits, int aErrorCode, + EDA_ITEM* aMainItem, + EDA_ITEM* bAuxItem = nullptr ) { - m_ErrorCode = aErrorCode; - m_MainText = aMainItem->GetSelectMenuText( aUnits ); - m_AuxiliaryText = wxEmptyString; - m_MainPosition = aMainPos; - m_AuxiliaryPosition = bAuxiliaryPos; - m_hasSecondItem = bAuxiliaryItem != nullptr; - m_noCoordinate = false; - m_parent = nullptr; - m_mainItemUuid = aMainItem->m_Uuid; + m_ErrorCode = aErrorCode; + m_MainText = aMainItem->GetSelectMenuText( aUnits ); + m_AuxText = wxEmptyString; + m_hasPositions = false; + m_hasSecondItem = bAuxItem != nullptr; + m_parent = nullptr; + m_mainItemUuid = aMainItem->m_Uuid; if( m_hasSecondItem ) { - m_AuxiliaryText = bAuxiliaryItem->GetSelectMenuText( aUnits ); - m_auxItemUuid = bAuxiliaryItem->m_Uuid; + m_AuxText = bAuxItem->GetSelectMenuText( aUnits ); + m_auxItemUuid = bAuxItem->m_Uuid; } } @@ -116,24 +116,98 @@ public: * initialize all data in item * @param aErrorCode = error code * @param aMainItem = the first (main) schematic or board item - * @param bAuxiliaryItem = the second schematic or board item + * @param bAuxItem = the second schematic or board item * @param aMainPos = position the first item and therefore of this issue - * @param bAuxiliaryPos = position the second item + * @param bAuxPos = position the second item */ - void SetData( int aErrorCode, const wxString& aMainText, const wxPoint& aMainPos, - const wxString& bAuxiliaryText = wxEmptyString, - const wxPoint& bAuxiliaryPos = wxPoint() ) + void SetData( EDA_UNITS aUnits, int aErrorCode, + EDA_ITEM* aMainItem, const wxPoint& aMainPos, + EDA_ITEM* bAuxItem = nullptr, const wxPoint& bAuxPos = wxPoint() ) { - m_ErrorCode = aErrorCode; - m_MainText = aMainText; - m_AuxiliaryText = bAuxiliaryText; - m_MainPosition = aMainPos; - m_AuxiliaryPosition = bAuxiliaryPos; - m_hasSecondItem = bAuxiliaryText.Length(); - m_noCoordinate = false; - m_parent = nullptr; - m_mainItemUuid = niluuid; - m_auxItemUuid = niluuid; + m_ErrorCode = aErrorCode; + m_MainText = aMainItem->GetSelectMenuText( aUnits ); + m_AuxText = wxEmptyString; + m_MainPosition = aMainPos; + m_AuxPosition = bAuxPos; + m_hasPositions = true; + m_hasSecondItem = bAuxItem != nullptr; + m_parent = nullptr; + m_mainItemUuid = aMainItem->m_Uuid; + + if( m_hasSecondItem ) + { + m_AuxText = bAuxItem->GetSelectMenuText( aUnits ); + m_auxItemUuid = bAuxItem->m_Uuid; + } + } + + /** + * Function SetData + * initialize all data in item + * @param aErrorCode = error code + * @param aMainText = a description of the first (main) item + * @param bAuxText = a description of the second item + */ + void SetData( int aErrorCode, + const wxString& aMainText, + const wxString& bAuxText = wxEmptyString ) + { + m_ErrorCode = aErrorCode; + m_MainText = aMainText; + m_AuxText = bAuxText; + m_hasPositions = false; + m_hasSecondItem = !bAuxText.IsEmpty(); + m_parent = nullptr; + m_mainItemUuid = niluuid; + m_auxItemUuid = niluuid; + } + + /** + * Function SetData + * initialize all data in item + * @param aErrorCode = error code + * @param aMainText = a description of the first (main) item + * @param aMainPos = position the first item and therefore of this issue + * @param bAuxText = a description of the second item + * @param bAuxPos = position the second item + */ + void SetData( int aErrorCode, + const wxString& aMainText, const wxPoint& aMainPos, + const wxString& bAuxText = wxEmptyString, const wxPoint& bAuxPos = wxPoint() ) + { + m_ErrorCode = aErrorCode; + m_MainText = aMainText; + m_AuxText = bAuxText; + m_MainPosition = aMainPos; + m_AuxPosition = bAuxPos; + m_hasPositions = true; + m_hasSecondItem = !bAuxText.IsEmpty(); + m_parent = nullptr; + m_mainItemUuid = niluuid; + m_auxItemUuid = niluuid; + } + + /** + * Function SetData + * initialize all data in item + * @param aErrorCode = error code + * @param aMainText = a description of the first (main) item + * @param aMainID = UUID of the main item + * @param bAuxText = a description of the second item + * @param bAuxID = UUID of the second item + */ + void SetData( int aErrorCode, + const wxString& aMainText, const KIID& aMainID, + const wxString& bAuxText, const KIID& bAuxID ) + { + m_ErrorCode = aErrorCode; + m_MainText = aMainText; + m_AuxText = bAuxText; + m_hasPositions = false; + m_hasSecondItem = !bAuxText.IsEmpty() || bAuxID != niluuid; + m_parent = nullptr; + m_mainItemUuid = aMainID; + m_auxItemUuid = bAuxID; } /** @@ -144,10 +218,10 @@ public: */ void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos ) { - m_AuxiliaryText = aAuxiliaryText; - m_AuxiliaryPosition = aAuxiliaryPos; - m_hasSecondItem = true; - m_auxItemUuid = niluuid; + m_AuxText = aAuxiliaryText; + m_AuxPosition = aAuxiliaryPos; + m_hasSecondItem = true; + m_auxItemUuid = niluuid; } void SetParent( MARKER_BASE* aMarker ) { m_parent = aMarker; } @@ -155,13 +229,13 @@ public: bool HasSecondItem() const { return m_hasSecondItem; } - void SetShowNoCoordinate() { m_noCoordinate = true; } + bool HasPositions() { return m_hasPositions; } /** * Access to A and B texts */ wxString GetMainText() const { return m_MainText; } - wxString GetAuxiliaryText() const { return m_AuxiliaryText; } + wxString GetAuxiliaryText() const { return m_AuxText; } /** * Access to A and B items for BOARDs @@ -169,6 +243,9 @@ public: BOARD_ITEM* GetMainItem( BOARD* aBoard ) const; BOARD_ITEM* GetAuxiliaryItem( BOARD* aBoard ) const; + KIID GetMainItemID() const { return m_mainItemUuid; } + KIID GetAuxItemID() const { return m_auxItemUuid; } + /** * Function ShowHtml * translates this object into a fragment of HTML suitable for the wxHtmlListBox class. @@ -183,10 +260,7 @@ public: */ wxString ShowReport( EDA_UNITS aUnits ) const; - int GetErrorCode() const - { - return m_ErrorCode; - } + int GetErrorCode() const { return m_ErrorCode; } /** * Function GetErrorText @@ -195,10 +269,10 @@ public: wxString GetErrorText() const; const wxString& GetTextA() const { return m_MainText; } - const wxString& GetTextB() const { return m_AuxiliaryText; } + const wxString& GetTextB() const { return m_AuxText; } const wxPoint& GetPointA() const { return m_MainPosition; } - const wxPoint& GetPointB() const { return m_AuxiliaryPosition; } + const wxPoint& GetPointB() const { return m_AuxPosition; } /** * Function ShowCoord diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 737e5559d7..1ba7cc2bb9 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -386,7 +386,7 @@ public: * The base method do nothing * @param aAskForSave = true to open a dialog before saving the settings */ - virtual void SaveProjectSettings( bool aAskForSave ) {}; + virtual void SaveProjectSettings() {}; // Read/Save and Import/export hotkeys config diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 4b4352e687..7b724ee1cc 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -193,7 +193,8 @@ enum GAL_LAYER_ID: int LAYER_PADS_TH, ///< multilayer pads, usually with holes LAYER_PADS_PLATEDHOLES, ///< to draw pad holes (plated) LAYER_VIAS_HOLES, ///< to draw via holes (pad holes do not use this layer) - LAYER_DRC, ///< drc markers + LAYER_DRC_ERROR, ///< layer for drc markers with SEVERITY_ERROR + LAYER_DRC_WARNING, ///< layer for drc markers with SEVERITY_WARNING LAYER_WORKSHEET, ///< worksheet frame LAYER_GP_OVERLAY, ///< general purpose overlay LAYER_SELECT_OVERLAY, ///< currently selected items overlay @@ -350,7 +351,6 @@ enum LAYER_3D_ID : int // after loading a board for instance #define MIN_VISIBILITY_MASK int( ( 1 << GAL_LAYER_INDEX( LAYER_PADS_PLATEDHOLES ) ) +\ ( 1 << GAL_LAYER_INDEX( LAYER_VIAS_HOLES ) ) +\ - ( 1 << GAL_LAYER_INDEX( LAYER_DRC ) ) +\ ( 1 << GAL_LAYER_INDEX( LAYER_SELECT_OVERLAY ) ) +\ ( 1 << GAL_LAYER_INDEX( LAYER_GP_OVERLAY ) ) +\ ( 1 << GAL_LAYER_INDEX( LAYER_RATSNEST ) ) ) diff --git a/include/marker_base.h b/include/marker_base.h index b401e7bbfc..7446984251 100644 --- a/include/marker_base.h +++ b/include/marker_base.h @@ -38,13 +38,14 @@ class SHAPE_LINE_CHAIN; class MARKER_BASE { public: - enum TYPEMARKER { // Marker type: can be used to identify the purpose of the marker + enum TYPEMARKER { MARKER_UNSPEC, MARKER_ERC, MARKER_PCB, MARKER_SIMUL }; - enum MARKER_SEVERITY { // Severity of the marker: this is the level of error + + enum MARKER_SEVERITY { MARKER_SEVERITY_UNSPEC, MARKER_SEVERITY_INFO, MARKER_SEVERITY_WARNING, @@ -54,13 +55,17 @@ public: wxPoint m_Pos; ///< position of the marker protected: - int m_ScalingFactor; ///< Scaling factor to convert corners coordinates - ///< to internat units coordinates - TYPEMARKER m_MarkerType; ///< The type of marker (useful to filter markers) - MARKER_SEVERITY m_ErrorLevel; ///< Specify the severity of the error - COLOR4D m_Color; ///< color - EDA_RECT m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative - ///< to the position of the shape, in marker shape units + int m_ScalingFactor; // Scaling factor to convert corners coordinates + // to internat units coordinates + TYPEMARKER m_MarkerType; // The type of marker (useful to filter markers) + + // JEY TODO: retire this; error levels come from DRC_ITEM + MARKER_SEVERITY m_ErrorLevel; // Specify the severity of the error (Eeschema only) + bool m_Excluded; // User has excluded this specific error + + EDA_RECT m_ShapeBoundingBox; // Bounding box of the graphic symbol, relative + // to the position of the shape, in marker shape + // units DRC_ITEM m_drc; void init(); @@ -79,8 +84,21 @@ public: * @param bPos The position of the second of two objects * @param aScalingFactor the scaling factor to convert the shape coordinates to IU coordinates */ - MARKER_BASE( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, EDA_ITEM* aItem, - const wxPoint& aPos, EDA_ITEM* bItem, const wxPoint& bPos, int aScalingFactor ); + MARKER_BASE( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + EDA_ITEM* aItem, const wxPoint& aPos, + EDA_ITEM* bItem, const wxPoint& bPos, int aScalingFactor ); + + /** + * Constructor + * @param aErrorCode The categorizing identifier for an error + * @param aMarkerPos The position of the MARKER on the BOARD + * @param aItem The first of two objects + * @param bItem The second of the two conflicting objects + * @param aScalingFactor the scaling factor to convert the shape coordinates to IU coordinates + */ + MARKER_BASE( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + EDA_ITEM* aItem, + EDA_ITEM* bItem, int aScalingFactor ); /** * Constructor @@ -100,12 +118,24 @@ public: * Constructor * @param aErrorCode The categorizing identifier for an error * @param aMarkerPos The position of the MARKER on the BOARD - * @param aText Text describing the object - * @param aPos The position of the object + * @param aText Text describing the first of two objects + * @param bText Text describing the second of the two conflicting objects * @param aScalingFactor the scaling factor to convert the shape coordinates to IU coordinates */ MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, - const wxString& aText, const wxPoint& aPos, int aScalingFactor ); + const wxString& aText, + const wxString& bText, int aScalingFactor ); + + /** + * Constructor + * @param aErrorCode The categorizing identifier for an error + * @param aText Text describing the object + * @param bText Text describing the second of the two conflicting objects + * @param aScalingFactor the scaling factor to convert the shape coordinates to IU coordinates + */ + MARKER_BASE( int aErrorCode, + const wxString& aText, + const wxString& bText, int aScalingFactor ); /** * Contructor @@ -115,7 +145,7 @@ public: */ MARKER_BASE( const MARKER_BASE& aMarker ); - ~MARKER_BASE(); + virtual ~MARKER_BASE(); /** The scaling factor to convert polygonal shape coordinates to internal units */ @@ -154,39 +184,17 @@ public: return m_Pos; } - /** - * Function SetColor - * Set the color of this marker - */ - void SetColor( COLOR4D aColor ) - { - m_Color = aColor; - } - /** * accessors to set/get error levels (warning, error, fatal error..) */ - void SetErrorLevel( MARKER_SEVERITY aErrorLevel ) - { - m_ErrorLevel = aErrorLevel; - } + void SetErrorLevel( MARKER_SEVERITY aErrorLevel ) { m_ErrorLevel = aErrorLevel; } + MARKER_SEVERITY GetErrorLevel() const { return m_ErrorLevel; } - MARKER_SEVERITY GetErrorLevel() const - { - return m_ErrorLevel; - } - - /** accessors to set/get marker type (DRC, ERC, or other) + /** + * accessors to set/get marker type (DRC, ERC, or other) */ - void SetMarkerType( enum TYPEMARKER aMarkerType ) - { - m_MarkerType = aMarkerType; - } - - enum TYPEMARKER GetMarkerType() const - { - return m_MarkerType; - } + void SetMarkerType( enum TYPEMARKER aMarkerType ) { m_MarkerType = aMarkerType; } + enum TYPEMARKER GetMarkerType() const { return m_MarkerType; } /** * Function SetData @@ -198,8 +206,9 @@ public: * @param bItem The second of the two conflicting objects * @param bPos The position of the second of two objects */ - void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, EDA_ITEM* aItem, - const wxPoint& aPos, EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() ); + void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + EDA_ITEM* aItem, const wxPoint& aPos, + EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() ); /** * Function SetData @@ -215,6 +224,38 @@ public: const wxString& aText, const wxPoint& aPos, const wxString& bText = wxEmptyString, const wxPoint& bPos = wxPoint() ); + /** + * Function SetData + * fills in all the reportable data associated with a MARKER. + * @param aErrorCode The categorizing identifier for an error + * @param aMarkerPos The position of the MARKER on the BOARD + * @param aItem The first of two objects + * @param aPos The position of the first of two objects + * @param bItem The second of the two conflicting objects + * @param bPos The position of the second of two objects + */ + void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + EDA_ITEM* aItem, + EDA_ITEM* bItem = nullptr ); + + /** + * Function SetData + * fills in all the reportable data associated with a MARKER. + * @param aErrorCode The categorizing identifier for an error + * @param aMarkerPos The position of the MARKER on the BOARD + * @param aText Text describing the first of two objects + * @param aPos The position of the first of two objects + * @param bText Text describing the second of the two conflicting objects + * @param bPos The position of the second of two objects + */ + void SetData( int aErrorCode, const wxPoint& aMarkerPos, + const wxString& aText, + const wxString& bText = wxEmptyString ); + + void SetData( int aErrorCode, const wxPoint& aMarkerPos, + const wxString& aText, const KIID& aID, + const wxString& bText, const KIID& bID ); + /** * Function SetAuxiliaryData * initialize data for the second (auxiliary) item @@ -227,10 +268,8 @@ public: m_drc.SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos ); } - void SetShowNoCoordinate() - { - m_drc.SetShowNoCoordinate(); - } + bool IsExcluded() const { return m_Excluded; } + void SetExcluded( bool aExcluded ) { m_Excluded = aExcluded; } /** * Function GetReporter @@ -238,10 +277,8 @@ public: * interface may be used. * @return const& DRC_ITEM */ - const DRC_ITEM& GetReporter() const - { - return m_drc; - } + DRC_ITEM& GetReporter() { return m_drc; } + const DRC_ITEM& GetReporter() const { return m_drc; } /** * Function DisplayMarkerInfo @@ -264,6 +301,9 @@ public: * It is OK to overestimate the size by a few counts. */ EDA_RECT GetBoundingBoxMarker() const; + +protected: + virtual KIGFX::COLOR4D getColor() const = 0; }; diff --git a/include/reporter.h b/include/reporter.h index b5d97545df..ffcb944bee 100644 --- a/include/reporter.h +++ b/include/reporter.h @@ -26,6 +26,7 @@ #define _REPORTER_H_ #include +#include /** * @file reporter.h @@ -61,26 +62,6 @@ class WX_HTML_REPORT_PANEL; class REPORTER { public: - /** - * Severity of the reported messages. - * Undefined are default status messages - * Info are processing messages for which no action is taken - * Action messages are items that modify the file(s) as expected - * Warning messages are items that might be problematic but don't prevent - * the process from completing - * Error messages are items that prevent the process from completing - */ - // - enum SEVERITY { - RPT_UNDEFINED = 0x0, - RPT_INFO = 0x1, - RPT_ACTION = 0x2, - RPT_WARNING = 0x4, - RPT_ERROR = 0x8 - }; - - static constexpr int RPT_ALL = RPT_INFO | RPT_ACTION | RPT_WARNING | RPT_ERROR; - /** * Location where the message is to be reported. * LOC_HEAD messages are printed before all others (typically intro messages) @@ -102,13 +83,13 @@ public: * RPT_ERROR, RPT_ACTION ) used to filter and format messages */ - virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) = 0; + virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) = 0; /** * Function ReportTail * Places the report at the end of the list, for objects that support report ordering */ - virtual REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) + virtual REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) { return Report( aText, aSeverity ); } @@ -117,12 +98,12 @@ public: * Function ReportHead * Places the report at the beginning of the list for objects that support ordering */ - virtual REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) + virtual REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) { return Report( aText, aSeverity ); } - REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_UNDEFINED ); + REPORTER& Report( const char* aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ); REPORTER& operator <<( const wxString& aText ) { return Report( aText ); } REPORTER& operator <<( const wxChar* aText ) { return Report( wxString( aText ) ); } @@ -160,7 +141,7 @@ public: { } - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; bool HasMessage() const override; }; @@ -185,7 +166,7 @@ public: { } - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; bool HasMessage() const override; }; @@ -210,11 +191,11 @@ public: { } - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; - REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; - REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; bool HasMessage() const override; }; @@ -238,7 +219,7 @@ public: static REPORTER& GetInstance(); - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; bool HasMessage() const override { return false; } }; @@ -261,7 +242,7 @@ public: static REPORTER& GetInstance(); - REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = SEVERITY_UNDEFINED ) override; bool HasMessage() const override { return false; } }; diff --git a/include/widgets/ui_common.h b/include/widgets/ui_common.h index 132b3cc66f..2d73a8dd88 100644 --- a/include/widgets/ui_common.h +++ b/include/widgets/ui_common.h @@ -26,6 +26,9 @@ #ifndef UI_COMMON_H #define UI_COMMON_H +#include + + namespace KIUI { @@ -38,4 +41,19 @@ int GetStdMargin(); } +enum SEVERITY { + SEVERITY_UNDEFINED = 0x00, + SEVERITY_INFO = 0x01, + SEVERITY_EXCLUSION = 0x02, + SEVERITY_ACTION = 0x04, + SEVERITY_WARNING = 0x08, + SEVERITY_ERROR = 0x10, + SEVERITY_IGNORE = 0x20 +}; + +wxBitmap MakeBadge( SEVERITY aStyle, int aCount, wxWindow* aWindow, int aDepth = 1 ); + + + + #endif // UI_COMMON_H \ No newline at end of file diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index aab4374b82..dd9bc98eaa 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -168,6 +168,7 @@ set( PCBNEW_DIALOGS dialogs/panel_setup_text_and_graphics_base.cpp dialogs/panel_setup_tracks_and_vias.cpp dialogs/panel_setup_tracks_and_vias_base.cpp + dialogs/panel_setup_drc_severities.cpp footprint_wizard.cpp footprint_wizard_frame.cpp footprint_wizard_frame_functions.cpp @@ -228,8 +229,6 @@ set( PCBNEW_DRC_SRCS drc/courtyard_overlap.cpp drc/drc.cpp drc/drc_clearance_test_functions.cpp - drc/drc_marker_factory.cpp - drc/drc_provider.cpp drc/drc_tree_model.cpp ) diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index aaa17705cf..6ee6b4af31 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -34,7 +34,8 @@ #include #include #include - +#include +#include #define CopperLayerCountKey wxT( "CopperLayerCount" ) #define BoardThicknessKey wxT( "BoardThickness" ) @@ -56,6 +57,74 @@ #define dPairViaGapKey wxT( "dPairViaGap" ) +class PARAM_CFG_SEVERITIES : public PARAM_CFG +{ +protected: + BOARD* m_Pt_param; ///< Pointer to the parameter value + +public: + PARAM_CFG_SEVERITIES( BOARD* ptparam, const wxChar* group = nullptr ) : + PARAM_CFG( wxEmptyString, PARAM_SEVERITIES, group ) + { + m_Pt_param = ptparam; + } + + void ReadParam( wxConfigBase* aConfig ) const override + { + if( !m_Pt_param || !aConfig ) + return; + + BOARD* board = m_Pt_param; + BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); + wxString oldPath = aConfig->GetPath(); + + // Read legacy settings first so that modern settings will overwrite them + bool flag; + + if( aConfig->Read( wxT( "RequireCourtyardDefinitions" ), &flag, false ) ) + { + if( flag ) + bds.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_ERROR; + else + bds.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_IGNORE; + } + + if( aConfig->Read( wxT( "ProhibitOverlappingCourtyards" ), &flag, false ) ) + { + if( flag ) + bds.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = SEVERITY_ERROR; + else + bds.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = SEVERITY_IGNORE; + } + + // TO DO: figure out what we're going to use as keys here so we can read/write these.... + + aConfig->SetPath( oldPath ); + } + + void SaveParam( wxConfigBase* aConfig ) const override + { + if( !m_Pt_param || !aConfig ) + return; + + BOARD* board = m_Pt_param; + BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); + wxString oldPath = aConfig->GetPath(); + + // TO DO: figure out what we're going to use as keys here so we can read/write these.... + + // TO DO: for now just write out the legacy ones so we don't lose them + // TO DO: remove this once the new scheme is in place + aConfig->Write( wxT( "RequireCourtyardDefinitions" ), + bds.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] != SEVERITY_IGNORE ); + aConfig->Write( wxT( "ProhibitOverlappingCourtyards" ), + bds.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] != SEVERITY_IGNORE ); + + aConfig->SetPath( oldPath ); + } +}; + + // // NOTE: layer configuration info is stored in both the BOARD and BOARD_DESIGN_SETTINGS so one // of the two needs to read/write the config so we don't end up with order dependency issues. @@ -501,6 +570,11 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : m_CopperEdgeClearance = Millimeter2iu( DEFAULT_COPPEREDGECLEARANCE ); m_HoleToHoleMin = Millimeter2iu( DEFAULT_HOLETOHOLEMIN ); + for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode ) + m_DRCSeverities[ errorCode ] = SEVERITY_ERROR; + + m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_IGNORE; + m_MaxError = ARC_HIGH_DEF; m_ZoneUseNoOutlineInFill = false; // Use compatibility mode by default @@ -518,10 +592,6 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : m_trackWidthIndex = 0; m_diffPairIndex = 0; - // Courtyard defaults - m_RequireCourtyards = false; - m_ProhibitOverlappingCourtyards = true; - // Default ref text on fp creation. If empty, use footprint name as default m_RefDefaultText = "REF**"; m_RefDefaultVisibility = true; @@ -544,12 +614,6 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, std::vectorpush_back( new PARAM_CFG_BOOL( wxT( "AllowBlindVias" ), &m_BlindBuriedViaAllowed, false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "RequireCourtyardDefinitions" ), - &m_RequireCourtyards, false ) ); - - aResult->push_back( new PARAM_CFG_BOOL( wxT( "ProhibitOverlappingCourtyards" ), - &m_ProhibitOverlappingCourtyards, true ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinTrackWidth" ), &m_TrackMinWidth, Millimeter2iu( DEFAULT_TRACKMINWIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), @@ -580,6 +644,8 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, std::vectorpush_back( new PARAM_CFG_SEVERITIES( aBoard ) ); + // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method // based on the edge cut thicknesses. aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperEdgeClearance" ), @@ -707,6 +773,18 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, std::vector AllConnectedItems(); /// zone contour currently in progress @@ -310,7 +315,6 @@ public: */ void BuildConnectivity(); - /** * Function DeleteMARKERs * deletes ALL MARKERS from the board. @@ -323,29 +327,6 @@ public: */ void DeleteZONEOutlines(); - /** - * Function GetMARKER - * returns the MARKER at a given index. - * @param index The array type index into a collection of MARKER_PCBS. - * @return MARKER_PCB* - a pointer to the MARKER_PCB or NULL if index out of range. - */ - MARKER_PCB* GetMARKER( int index ) const - { - if( (unsigned) index < m_markers.size() ) - return m_markers[index]; - - return NULL; - } - - /** - * Function GetMARKERCount - * @return int - The number of MARKER_PCBS. - */ - int GetMARKERCount() const - { - return (int) m_markers.size(); - } - /** * Function SetAuxOrigin * sets the origin point used for plotting. diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp index ab7836d190..220513150c 100644 --- a/pcbnew/class_marker_pcb.cpp +++ b/pcbnew/class_marker_pcb.cpp @@ -1,8 +1,3 @@ -/** - * @file class_marker_pcb.cpp - * @brief Functions to handle markers used to show something (usually a drc problem) - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -35,38 +30,62 @@ #include #include #include +#include +#include #include +#include #include +#include +#include +#include +#include /// Factor to convert the maker unit shape to internal units: #define SCALING_FACTOR Millimeter2iu( 0.1 ) MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) : - BOARD_ITEM( aParent, PCB_MARKER_T ), - MARKER_BASE( SCALING_FACTOR ), m_item( nullptr ) + BOARD_ITEM( aParent, PCB_MARKER_T ), + MARKER_BASE( SCALING_FACTOR ), m_item( nullptr ) { - m_Color = WHITE; } MARKER_PCB::MARKER_PCB( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, - BOARD_ITEM* aItem, const wxPoint& aPos, BOARD_ITEM* bItem, const wxPoint& bPos ) - : BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() - MARKER_BASE( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos, SCALING_FACTOR ), - m_item( nullptr ) + BOARD_ITEM* aItem, + BOARD_ITEM* bItem ) : + BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() + MARKER_BASE( aUnits, aErrorCode, aMarkerPos, aItem, bItem, SCALING_FACTOR ), + m_item( nullptr ) +{ +} + + +MARKER_PCB::MARKER_PCB( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + BOARD_ITEM* aItem, const wxPoint& aPos, + BOARD_ITEM* bItem, const wxPoint& bPos ) : + BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() + MARKER_BASE( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos, SCALING_FACTOR ), + m_item( nullptr ) { - m_Color = WHITE; } MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos, const wxString& aText, const wxPoint& aPos, const wxString& bText, const wxPoint& bPos ) : - BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() - MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos, SCALING_FACTOR ), m_item( nullptr ) + BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() + MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos, SCALING_FACTOR ), m_item( nullptr ) +{ +} + + +MARKER_PCB::MARKER_PCB( int aErrorCode, + const wxString& aText, + const wxString& bText) : + BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() + MARKER_BASE( aErrorCode, aText, bText, SCALING_FACTOR ), m_item( nullptr ) { - m_Color = WHITE; } @@ -75,6 +94,34 @@ MARKER_PCB::~MARKER_PCB() { } + +wxString MARKER_PCB::Serialize() const +{ + return wxString::Format( wxT( "%d|%d|%d|%s|%s|%s|%s" ), + m_drc.GetErrorCode(), + m_Pos.x, + m_Pos.y, + m_drc.GetMainText(), + m_drc.GetMainItemID().AsString(), + m_drc.GetAuxiliaryText(), + m_drc.GetAuxItemID().AsString() ); +} + + +MARKER_PCB* MARKER_PCB::Deserialize( const wxString& data ) +{ + wxArrayString props = wxSplit( data, '|' ); + int errorCode = (int) strtol( props[0].c_str(), nullptr, 10 ); + MARKER_PCB* marker = new MARKER_PCB( nullptr ); // parent set during BOARD::Add() + + marker->m_Pos.x = (int) strtol( props[1].c_str(), nullptr, 10 ); + marker->m_Pos.y = (int) strtol( props[2].c_str(), nullptr, 10 ); + marker->m_drc.SetData( errorCode, props[3], KIID( props[4] ), props[5], KIID( props[6] ) ); + marker->m_drc.SetParent( marker ); + return marker; +} + + /* tests to see if this object is on the given layer. * DRC markers are not really on a copper layer, but * MARKER_PCB::IsOnCopperLayer return true if aLayer is a cooper layer, @@ -87,22 +134,14 @@ bool MARKER_PCB::IsOnLayer( PCB_LAYER_ID aLayer ) const return IsCopperLayer( aLayer ); } + void MARKER_PCB::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& aList ) { - wxString errorTxt, txtA, txtB; - aList.emplace_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) ); - errorTxt.Printf( _( "ErrType (%d)- %s:" ), m_drc.GetErrorCode(), m_drc.GetErrorText() ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Violation" ), m_drc.GetErrorText(), RED ) ); - aList.emplace_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) ); - - txtA.Printf( wxT( "%s: %s" ), DRC_ITEM::ShowCoord( aUnits, m_drc.GetPointA() ), m_drc.GetTextA() ); - - if( m_drc.HasSecondItem() ) - txtB.Printf( wxT( "%s: %s" ), DRC_ITEM::ShowCoord( aUnits, m_drc.GetPointB() ), m_drc.GetTextB() ); - - aList.emplace_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) ); + aList.emplace_back( MSG_PANEL_ITEM( m_drc.GetTextA(), m_drc.GetTextB(), DARKBROWN ) ); } @@ -123,9 +162,7 @@ void MARKER_PCB::Flip(const wxPoint& aCentre, bool aFlipLeftRight ) wxString MARKER_PCB::GetSelectMenuText( EDA_UNITS aUnits ) const { - return wxString::Format( _( "Marker @(%s, %s)" ), - MessageTextFromValue( aUnits, m_Pos.x ), - MessageTextFromValue( aUnits, m_Pos.y ) ); + return wxString::Format( _( "Marker (%s)" ), GetReporter().GetErrorText() ); } @@ -138,9 +175,51 @@ BITMAP_DEF MARKER_PCB::GetMenuImage() const void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 1; - aLayers[0] = LAYER_DRC; + + BOARD_ITEM_CONTAINER* ancestor = GetParent(); + + while( ancestor->GetParent() ) + ancestor = ancestor->GetParent(); + + BOARD* board = static_cast( ancestor ); + + switch( board->GetDesignSettings().GetSeverity( m_drc.GetErrorCode() ) ) + { + default: + case SEVERITY::SEVERITY_ERROR: aLayers[0] = LAYER_DRC_ERROR; break; + case SEVERITY::SEVERITY_WARNING: aLayers[0] = LAYER_DRC_WARNING; break; + } } + +GAL_LAYER_ID MARKER_PCB::GetColorLayer() const +{ + if( IsExcluded() ) + return LAYER_AUX_ITEMS; + + BOARD_ITEM_CONTAINER* ancestor = GetParent(); + + while( ancestor->GetParent() ) + ancestor = ancestor->GetParent(); + + BOARD* board = static_cast( ancestor ); + + switch( board->GetDesignSettings().GetSeverity( m_drc.GetErrorCode() ) ) + { + default: + case SEVERITY::SEVERITY_ERROR: return LAYER_DRC_ERROR; + case SEVERITY::SEVERITY_WARNING: return LAYER_DRC_WARNING; + } +} + + +KIGFX::COLOR4D MARKER_PCB::getColor() const +{ + COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings(); + return colors->GetColor( GetColorLayer() ); +} + + const EDA_RECT MARKER_PCB::GetBoundingBox() const { EDA_RECT bbox = m_ShapeBoundingBox; diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 0f56e667a8..b77c50be89 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -46,6 +46,17 @@ public: MARKER_PCB( BOARD_ITEM* aParent ); + /** + * Constructor + * @param aErrorCode The categorizing identifier for an error + * @param aMarkerPos The position of the MARKER_PCB on the BOARD + * @param aItem The first of two objects + * @param bItem The second of the two conflicting objects + */ + MARKER_PCB( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + BOARD_ITEM* aItem, + BOARD_ITEM* bItem = nullptr ); + /** * Constructor * @param aErrorCode The categorizing identifier for an error @@ -55,8 +66,9 @@ public: * @param bItem The second of the two conflicting objects * @param bPos The position of the second of two objects */ - MARKER_PCB( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, BOARD_ITEM* aItem, - const wxPoint& aPos, BOARD_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() ); + MARKER_PCB( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos, + BOARD_ITEM* aItem, const wxPoint& aPos, + BOARD_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() ); /** * Constructor @@ -71,6 +83,17 @@ public: const wxString& aText, const wxPoint& aPos, const wxString& bText = wxEmptyString, const wxPoint& bPos = wxPoint() ); + /** + * Constructor + * @param aErrorCode The categorizing identifier for an error + * @param aMarkerPos The position of the MARKER_PCB on the BOARD + * @param aText Text describing the first of two objects + * @param bText Text describing the second of the two conflicting objects + */ + MARKER_PCB( int aErrorCode, + const wxString& aText, + const wxString& bText = wxEmptyString ); + ~MARKER_PCB(); static inline bool ClassOf( const EDA_ITEM* aItem ) @@ -78,6 +101,10 @@ public: return aItem && PCB_MARKER_T == aItem->Type(); } + wxString Serialize() const; + + static MARKER_PCB* Deserialize( const wxString& data ); + void Move(const wxPoint& aMoveVector) override { m_Pos += aMoveVector; @@ -102,6 +129,8 @@ public: bool IsOnLayer( PCB_LAYER_ID aLayer ) const override; + GAL_LAYER_ID GetColorLayer() const; + void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& aList ) override; bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override @@ -131,6 +160,9 @@ public: return wxT( "MARKER_PCB" ); } +protected: + KIGFX::COLOR4D getColor() const override; + protected: ///> Pointer to BOARD_ITEM that causes DRC error. const BOARD_ITEM* m_item; diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 1c5d2dba6c..f83d665b9a 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -28,6 +28,7 @@ #include "dialog_import_settings.h" #include "dialog_board_setup.h" +#include "panel_setup_drc_severities.h" DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : PAGED_DIALOG( aFrame, _( "Board Setup" ), _( "Import Settings from Another Project..." ) ), @@ -40,6 +41,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : m_tracksAndVias = new PANEL_SETUP_TRACKS_AND_VIAS( this, aFrame, m_constraints ); m_maskAndPaste = new PANEL_SETUP_MASK_AND_PASTE( this, aFrame ); m_physicalStackup = new PANEL_SETUP_BOARD_STACKUP( this, aFrame, m_layers ); + m_drcSeverities = new PANEL_SETUP_DRC_SEVERITIES( this, aFrame ); /* * WARNING: If you change page names you MUST update calls to DoShowBoardSetupDialog(). @@ -59,6 +61,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : m_treebook->AddPage( new wxPanel( this ), _( "Design Rules" ) ); m_treebook->AddSubPage( m_constraints, _( "Constraints" ) ); m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) ); + m_treebook->AddSubPage( m_drcSeverities, _( "Violation Severity" ) ); // Connect Events m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED, diff --git a/pcbnew/dialogs/dialog_board_setup.h b/pcbnew/dialogs/dialog_board_setup.h index deabe7ad41..b746922e11 100644 --- a/pcbnew/dialogs/dialog_board_setup.h +++ b/pcbnew/dialogs/dialog_board_setup.h @@ -22,6 +22,7 @@ #define KICAD_DIALOG_BOARD_SETUP_H #include +#include "panel_setup_drc_severities.h" class PCB_EDIT_FRAME; class PANEL_SETUP_FEATURE_CONSTRAINTS; @@ -51,6 +52,7 @@ protected: PANEL_SETUP_TRACKS_AND_VIAS* m_tracksAndVias; PANEL_SETUP_MASK_AND_PASTE* m_maskAndPaste; PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; + PANEL_SETUP_DRC_SEVERITIES* m_drcSeverities; // event handlers void OnPageChange( wxBookCtrlEvent& event ); diff --git a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp index aee5a475f2..54560cfd30 100644 --- a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp @@ -46,7 +46,7 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS( PCB_EDIT_FRAME* m_cleanShortCircuitOpt->SetValue( cfg->m_Cleanup.cleanup_short_circuits ); m_deleteTracksInPadsOpt->SetValue( cfg->m_Cleanup.cleanup_tracks_in_pad ); - m_changesTreeModel = new DRC_TREE_MODEL( m_changesDataView ); + m_changesTreeModel = new DRC_TREE_MODEL( m_parentFrame, m_changesDataView ); m_changesDataView->AssociateModel( m_changesTreeModel ); // We use a sdbSizer to get platform-dependent ordering of the action buttons, but @@ -124,7 +124,8 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun ) if( aDryRun ) { - m_changesTreeModel->SetProvider( new VECTOR_DRC_ITEMS_PROVIDER( &m_items ) ); + DRC_ITEMS_PROVIDER* provider = new VECTOR_DRC_ITEMS_PROVIDER( m_parentFrame, &m_items ); + m_changesTreeModel->SetProvider( provider ); } else if( modified ) { diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 8dee8ef315..9ce7c953a6 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -38,14 +38,21 @@ #include #include #include - +#include DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFrame, 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 ), - m_uviaMinSize( aEditorFrame, m_uViaMinLabel, m_uViaMinCtrl, m_uViaMinUnits, true ) + m_uviaMinSize( aEditorFrame, m_uViaMinLabel, m_uViaMinCtrl, m_uViaMinUnits, true ), + m_markersProvider( nullptr ), + m_markerTreeModel( nullptr ), + m_unconnectedItemsProvider( nullptr ), + m_unconnectedTreeModel( nullptr ), + m_footprintWarningsProvider( nullptr ), + m_footprintWarningsTreeModel( nullptr ), + m_severities( SEVERITY_ERROR | SEVERITY_WARNING ) { SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it @@ -54,14 +61,14 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFra m_currentBoard = m_brdEditor->GetBoard(); m_BrdSettings = m_brdEditor->GetBoard()->GetDesignSettings(); - m_markerTreeModel = new DRC_TREE_MODEL( m_markerDataView ); + m_markerTreeModel = new DRC_TREE_MODEL( m_brdEditor, m_markerDataView ); m_markerDataView->AssociateModel( m_markerTreeModel ); - m_unconnectedTreeModel = new DRC_TREE_MODEL( m_unconnectedDataView ); + m_unconnectedTreeModel = new DRC_TREE_MODEL( m_brdEditor, m_unconnectedDataView ); m_unconnectedDataView->AssociateModel( m_unconnectedTreeModel ); - m_footprintsTreeModel = new DRC_TREE_MODEL( m_footprintsDataView ); - m_footprintsDataView->AssociateModel( m_footprintsTreeModel ); + m_footprintWarningsTreeModel = new DRC_TREE_MODEL( m_brdEditor, m_footprintsDataView ); + m_footprintsDataView->AssociateModel( m_footprintWarningsTreeModel ); m_Notebook->SetSelection( 0 ); @@ -73,6 +80,7 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFra m_sdbSizer1OK->SetDefault(); initValues(); + syncCheckboxes(); FinishDialogSettings(); } @@ -94,6 +102,10 @@ DIALOG_DRC_CONTROL::~DIALOG_DRC_CONTROL() void DIALOG_DRC_CONTROL::SetSettings( int aSeverities ) { m_severities = aSeverities; + + m_markerTreeModel->SetSeverities( m_severities ); + m_unconnectedTreeModel->SetSeverities( m_severities ); + m_footprintWarningsTreeModel->SetSeverities( m_severities ); } @@ -103,7 +115,7 @@ void DIALOG_DRC_CONTROL::GetSettings( int* aSeverities ) } -void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event ) +void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& aEvent ) { if( m_currentBoard != m_brdEditor->GetBoard() ) { @@ -121,6 +133,11 @@ void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event ) // because the dialog is not modal m_BrdSettings = m_brdEditor->GetBoard()->GetDesignSettings(); displayDRCValues(); + + m_markerTreeModel->SetProvider( m_markersProvider ); + m_unconnectedTreeModel->SetProvider( m_unconnectedItemsProvider ); + m_footprintWarningsTreeModel->SetProvider( m_footprintWarningsProvider ); + updateDisplayedCounts(); } @@ -162,16 +179,20 @@ void DIALOG_DRC_CONTROL::setDRCParameters() } +// Don't globally define this; different facilities use different definitions of "ALL" +static int SEVERITY_ALL = SEVERITY_WARNING | SEVERITY_ERROR | SEVERITY_EXCLUSION; + + void DIALOG_DRC_CONTROL::syncCheckboxes() { - m_showAll->SetValue( m_severities == ( DRC_SHOW_ERRORS | DRC_SHOW_WARNINGS | DRC_SHOW_INFOS ) ); - m_showErrors->SetValue( m_severities & DRC_SHOW_ERRORS ); - m_showWarnings->SetValue( m_severities & DRC_SHOW_WARNINGS ); - m_showInfos->SetValue( m_severities & DRC_SHOW_INFOS ); + m_showAll->SetValue( m_severities == SEVERITY_ALL ); + m_showErrors->SetValue( m_severities & SEVERITY_ERROR ); + m_showWarnings->SetValue( m_severities & SEVERITY_WARNING ); + m_showExclusions->SetValue( m_severities & SEVERITY_EXCLUSION ); } -void DIALOG_DRC_CONTROL::OnRunDRCClick( wxCommandEvent& event ) +void DIALOG_DRC_CONTROL::OnRunDRCClick( wxCommandEvent& aEvent ) { setDRCParameters(); m_tester->m_doZonesTest = m_cbReportTracksToZonesErrors->GetValue(); @@ -179,7 +200,8 @@ void DIALOG_DRC_CONTROL::OnRunDRCClick( wxCommandEvent& event ) m_tester->m_reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue(); m_tester->m_testFootprints = m_cbTestFootprints->GetValue(); - DelDRCMarkers(); + m_brdEditor->RecordDRCExclusions(); + deleteAllMarkers(); wxBeginBusyCursor(); wxWindowDisabler disabler; @@ -188,48 +210,56 @@ void DIALOG_DRC_CONTROL::OnRunDRCClick( wxCommandEvent& event ) m_Messages->Clear(); wxSafeYield(); // Allows time slice to refresh the Messages m_tester->RunTests( m_Messages ); + m_Notebook->ChangeSelection( 0 ); // display the "Problems/Markers" tab wxEndBusyCursor(); - RefreshBoardEditor(); + refreshBoardEditor(); SetFocus(); + m_Notebook->GetPage( m_Notebook->GetSelection() )->SetFocus(); } void DIALOG_DRC_CONTROL::SetMarkersProvider( DRC_ITEMS_PROVIDER* aProvider ) { - m_markerTreeModel->SetProvider( aProvider ); + m_markersProvider = aProvider; + m_markerTreeModel->SetProvider( m_markersProvider ); + updateDisplayedCounts(); } -void DIALOG_DRC_CONTROL::SetUnconnectedProvider(class DRC_ITEMS_PROVIDER * aProvider) +void DIALOG_DRC_CONTROL::SetUnconnectedProvider(class DRC_ITEMS_PROVIDER * aProvider ) { - m_unconnectedTreeModel->SetProvider( aProvider ); + m_unconnectedItemsProvider = aProvider; + m_unconnectedTreeModel->SetProvider( m_unconnectedItemsProvider ); + updateDisplayedCounts(); } void DIALOG_DRC_CONTROL::SetFootprintsProvider( DRC_ITEMS_PROVIDER* aProvider ) { - m_footprintsTreeModel->SetProvider( aProvider ); + m_footprintWarningsProvider = aProvider; + m_footprintWarningsTreeModel->SetProvider( m_footprintWarningsProvider ); + updateDisplayedCounts(); } -void DIALOG_DRC_CONTROL::OnDRCItemSelected( wxDataViewEvent& event ) +void DIALOG_DRC_CONTROL::OnDRCItemSelected( wxDataViewEvent& aEvent ) { - BOARD_ITEM* item = DRC_TREE_MODEL::ToBoardItem( m_brdEditor->GetBoard(), event.GetItem() ); + BOARD_ITEM* item = DRC_TREE_MODEL::ToBoardItem( m_brdEditor->GetBoard(), aEvent.GetItem() ); WINDOW_THAWER thawer( m_brdEditor ); m_brdEditor->FocusOnItem( item ); m_brdEditor->GetCanvas()->Refresh(); - event.Skip(); + aEvent.Skip(); } -void DIALOG_DRC_CONTROL::OnDRCItemDClick( wxDataViewEvent& event ) +void DIALOG_DRC_CONTROL::OnDRCItemDClick( wxDataViewEvent& aEvent ) { - if( event.GetItem().IsOk() ) + if( aEvent.GetItem().IsOk() ) { // turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window, // no destruction so we can preserve listbox cursor @@ -237,43 +267,153 @@ void DIALOG_DRC_CONTROL::OnDRCItemDClick( wxDataViewEvent& event ) Show( false ); } - event.Skip(); + aEvent.Skip(); } -void DIALOG_DRC_CONTROL::OnSeverity( wxCommandEvent& event ) +void DIALOG_DRC_CONTROL::OnDRCItemRClick( wxDataViewEvent& aEvent ) +{ + DRC_TREE_NODE* node = DRC_TREE_MODEL::ToNode( aEvent.GetItem() ); + + if( !node ) + return; + + DRC_ITEM* drcItem = node->m_DrcItem; + wxString listName; + wxMenu menu; + + switch( m_BrdSettings.m_DRCSeverities[ drcItem->GetErrorCode() ] ) + { + case SEVERITY_ERROR: listName = _( "errors" ); break; + case SEVERITY_WARNING: listName = _( "warnings" ); break; + default: listName = _( "appropriate" ); break; + } + + if( drcItem->GetParent()->IsExcluded() ) + { + menu.Append( 1, _( "Remove exclusion for this violation" ), + wxString::Format( _( "It will be placed back in the %s list" ), listName ) ); + } + else + { + menu.Append( 2, _( "Exclude this violation" ), + wxString::Format( _( "It will be excluded from the %s list" ), listName ) ); + } + + menu.AppendSeparator(); + + if( m_BrdSettings.m_DRCSeverities[ drcItem->GetErrorCode() ] == SEVERITY_WARNING ) + { + menu.Append( 3, wxString::Format( _( "Change severity to Error for all '%s' violations" ), + drcItem->GetErrorText(), + _( "Violation severities can also be edited in the Board Setup... dialog" ) ) ); + } + else + { + menu.Append( 4, wxString::Format( _( "Change severity to Warning for all '%s' violations" ), + drcItem->GetErrorText(), + _( "Violation severities can also be edited in the Board Setup... dialog" ) ) ); + } + + menu.Append( 5, wxString::Format( _( "Ignore all '%s' violations" ), + drcItem->GetErrorText() ), + _( "Violations will not be checked or reported" ) ); + + switch( GetPopupMenuSelectionFromUser( menu ) ) + { + case 1: + node->m_DrcItem->GetParent()->SetExcluded( false ); + + // Update view + static_cast( aEvent.GetModel() )->ValueChanged( node ); + updateDisplayedCounts(); + break; + + case 2: + node->m_DrcItem->GetParent()->SetExcluded( true ); + + // Update view + if( m_severities & SEVERITY_EXCLUSION ) + static_cast( aEvent.GetModel() )->ValueChanged( node ); + else + static_cast( aEvent.GetModel() )->DeleteCurrentItem( false ); + + updateDisplayedCounts(); + break; + + case 3: + m_BrdSettings.m_DRCSeverities[ drcItem->GetErrorCode() ] = SEVERITY_ERROR; + m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings ); + + // Rebuild model and view + static_cast( aEvent.GetModel() )->SetProvider( m_markersProvider ); + updateDisplayedCounts(); + break; + + case 4: + m_BrdSettings.m_DRCSeverities[ drcItem->GetErrorCode() ] = SEVERITY_WARNING; + m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings ); + + // Rebuild model and view + static_cast( aEvent.GetModel() )->SetProvider( m_markersProvider ); + updateDisplayedCounts(); + break; + + case 5: + m_BrdSettings.m_DRCSeverities[ drcItem->GetErrorCode() ] = SEVERITY_IGNORE; + m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings ); + + for( MARKER_PCB* marker : m_brdEditor->GetBoard()->Markers() ) + { + if( marker->GetReporter().GetErrorCode() == drcItem->GetErrorCode() ) + m_brdEditor->GetBoard()->Delete( marker ); + } + + // Rebuild model and view + static_cast( aEvent.GetModel() )->SetProvider( m_markersProvider ); + updateDisplayedCounts(); + break; + } +} + + +void DIALOG_DRC_CONTROL::OnSeverity( wxCommandEvent& aEvent ) { int flag = 0; - if( event.GetEventObject() == m_showAll ) - flag = DRC_SHOW_ERRORS | DRC_SHOW_WARNINGS | DRC_SHOW_INFOS; - else if( event.GetEventObject() == m_showErrors ) - flag = DRC_SHOW_ERRORS; - else if( event.GetEventObject() == m_showWarnings ) - flag = DRC_SHOW_WARNINGS; - else if( event.GetEventObject() == m_showInfos ) - flag = DRC_SHOW_INFOS; + if( aEvent.GetEventObject() == m_showAll ) + flag = SEVERITY_ALL; + else if( aEvent.GetEventObject() == m_showErrors ) + flag = SEVERITY_ERROR; + else if( aEvent.GetEventObject() == m_showWarnings ) + flag = SEVERITY_WARNING; + else if( aEvent.GetEventObject() == m_showExclusions ) + flag = SEVERITY_EXCLUSION; - if( event.IsChecked() ) + if( aEvent.IsChecked() ) m_severities |= flag; + else if( aEvent.GetEventObject() == m_showAll ) + m_severities = SEVERITY_ERROR; else m_severities &= ~flag; syncCheckboxes(); - // JEY TODO: - /* - * pass the severity level to the providers... - * or create new providers with the level... - * and then - m_markerTreeModel->SetProvider( ... ); - m_unconnectedTreeModel->SetProvider( ... ); - m_footprintsTreeModel->SetProvider( ... ); - */ + // Set the provider's severity levels through the TreeModel so that the old tree + // can be torn down before the severity changes. + // + // It's not clear this is required, but we've had a lot of issues with wxDataView + // being cranky on various platforms. + + m_markerTreeModel->SetSeverities( m_severities ); + m_unconnectedTreeModel->SetSeverities( m_severities ); + m_footprintWarningsTreeModel->SetSeverities( m_severities ); + + updateDisplayedCounts(); } -void DIALOG_DRC_CONTROL::OnSaveReport( wxCommandEvent& event ) +void DIALOG_DRC_CONTROL::OnSaveReport( wxCommandEvent& aEvent ) { wxFileName fn( "./DRC." + ReportFileExtension ); @@ -307,7 +447,7 @@ void DIALOG_DRC_CONTROL::OnSaveReport( wxCommandEvent& event ) } -void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& event ) +void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& aEvent ) { m_brdEditor->FocusOnItem( nullptr ); @@ -320,11 +460,11 @@ void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& event ) } -void DIALOG_DRC_CONTROL::OnChangingNotebookPage( wxNotebookEvent& event ) +void DIALOG_DRC_CONTROL::OnChangingNotebookPage( wxNotebookEvent& aEvent ) { // Shouldn't be necessary, but is on at least OSX - if( event.GetSelection() >= 0 ) - m_Notebook->ChangeSelection( (unsigned) event.GetSelection() ); + if( aEvent.GetSelection() >= 0 ) + m_Notebook->ChangeSelection( (unsigned) aEvent.GetSelection() ); m_markerDataView->UnselectAll(); m_unconnectedDataView->UnselectAll(); @@ -332,7 +472,7 @@ void DIALOG_DRC_CONTROL::OnChangingNotebookPage( wxNotebookEvent& event ) } -void DIALOG_DRC_CONTROL::RefreshBoardEditor() +void DIALOG_DRC_CONTROL::refreshBoardEditor() { WINDOW_THAWER thawer( m_brdEditor ); @@ -340,7 +480,7 @@ void DIALOG_DRC_CONTROL::RefreshBoardEditor() } -void DIALOG_DRC_CONTROL::DelDRCMarkers() +void DIALOG_DRC_CONTROL::deleteAllMarkers() { // Clear current selection list to avoid selection of deleted items m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true ); @@ -366,26 +506,26 @@ bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName ) fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) ); - count = m_markerTreeModel->GetDRCItemCount(); + count = m_markersProvider->GetCount(); - fprintf( fp, "\n** Found %d DRC errors **\n", count ); + fprintf( fp, "\n** Found %d DRC violations **\n", count ); for( int i = 0; i < count; ++i ) - fprintf( fp, "%s", TO_UTF8( m_markerTreeModel->GetDRCItem( i )->ShowReport( units ) ) ); + fprintf( fp, "%s", TO_UTF8( m_markersProvider->GetItem( i )->ShowReport( units ) ) ); - count = m_unconnectedTreeModel->GetDRCItemCount(); + count = m_unconnectedItemsProvider->GetCount(); fprintf( fp, "\n** Found %d unconnected pads **\n", count ); for( int i = 0; i < count; ++i ) - fprintf( fp, "%s", TO_UTF8( m_unconnectedTreeModel->GetDRCItem( i )->ShowReport( units ) ) ); + fprintf( fp, "%s", TO_UTF8( m_unconnectedItemsProvider->GetItem( i )->ShowReport( units ) ) ); - count = m_footprintsTreeModel->GetDRCItemCount(); + count = m_footprintWarningsProvider->GetCount(); fprintf( fp, "\n** Found %d Footprint errors **\n", count ); for( int i = 0; i < count; ++i ) - fprintf( fp, "%s", TO_UTF8( m_footprintsTreeModel->GetDRCItem( i )->ShowReport( units ) ) ); + fprintf( fp, "%s", TO_UTF8( m_footprintWarningsProvider->GetItem( i )->ShowReport( units ) ) ); fprintf( fp, "\n** End of Report **\n" ); @@ -396,49 +536,57 @@ bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName ) } -void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event ) +void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& aEvent ) { if( m_Notebook->GetSelection() == 0 ) { // Clear the selection. It may be the selected DRC marker. m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true ); - m_markerTreeModel->DeleteCurrentItem(); + m_markerTreeModel->DeleteCurrentItem( true ); // redraw the pcb - RefreshBoardEditor(); + refreshBoardEditor(); } else if( m_Notebook->GetSelection() == 1 ) { - m_unconnectedTreeModel->DeleteCurrentItem(); + m_unconnectedTreeModel->DeleteCurrentItem( true ); + } + else if( m_Notebook->GetSelection() == 2 ) + { + m_footprintWarningsTreeModel->DeleteCurrentItem( true ); } - UpdateDisplayedCounts(); + updateDisplayedCounts(); } -void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event ) +void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& aEvent ) { - DelDRCMarkers(); - RefreshBoardEditor(); - UpdateDisplayedCounts(); + deleteAllMarkers(); + + refreshBoardEditor(); + updateDisplayedCounts(); } -void DIALOG_DRC_CONTROL::UpdateDisplayedCounts() +void DIALOG_DRC_CONTROL::updateDisplayedCounts() { wxString msg; + // First the tab headers: + // + if( m_tester->m_drcRun ) { msg.sprintf( m_markersTitleTemplate, m_markerTreeModel->GetDRCItemCount() ); m_Notebook->SetPageText( 0, msg ); - msg.sprintf( m_unconnectedTitleTemplate, (int) m_unconnectedTreeModel->GetDRCItemCount() ); + msg.sprintf( m_unconnectedTitleTemplate, m_unconnectedTreeModel->GetDRCItemCount() ); m_Notebook->SetPageText( 1, msg ); if( m_tester->m_footprintsTested ) - msg.sprintf( m_footprintsTitleTemplate, (int) m_footprintsTreeModel->GetDRCItemCount() ); + msg.sprintf( m_footprintsTitleTemplate, m_footprintWarningsTreeModel->GetDRCItemCount() ); else { msg = m_footprintsTitleTemplate; @@ -460,4 +608,36 @@ void DIALOG_DRC_CONTROL::UpdateDisplayedCounts() msg.Replace( wxT( "(%d)" ), wxEmptyString ); m_Notebook->SetPageText( 2, msg ); } + + // And now the badges: + // + + int numErrors = 0; + int numWarnings = 0; + int numExcluded = 0; + + if( m_markersProvider ) + { + numErrors += m_markersProvider->GetCount( SEVERITY_ERROR ); + numWarnings += m_markersProvider->GetCount( SEVERITY_WARNING ); + numExcluded += m_markersProvider->GetCount( SEVERITY_EXCLUSION ); + } + + if( m_unconnectedItemsProvider ) + { + numErrors += m_unconnectedItemsProvider->GetCount( SEVERITY_ERROR ); + numWarnings += m_unconnectedItemsProvider->GetCount( SEVERITY_WARNING ); + numExcluded += m_unconnectedItemsProvider->GetCount( SEVERITY_EXCLUSION ); + } + + if( m_footprintWarningsProvider ) + { + numErrors += m_footprintWarningsProvider->GetCount( SEVERITY_ERROR ); + numWarnings += m_footprintWarningsProvider->GetCount( SEVERITY_WARNING ); + numExcluded += m_footprintWarningsProvider->GetCount( SEVERITY_EXCLUSION ); + } + + m_errorsBadge->SetBitmap( MakeBadge( SEVERITY_ERROR, numErrors, m_errorsBadge ) ); + m_warningsBadge->SetBitmap( MakeBadge( SEVERITY_WARNING, numWarnings, m_warningsBadge ) ); + m_exclusionsBadge->SetBitmap( MakeBadge( SEVERITY_EXCLUSION, numExcluded, m_exclusionsBadge ) ); } diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index b71199f297..2c051e1c84 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -42,10 +42,6 @@ class BOARD_DESIGN_SETTINGS; class DRC_TREE_MODEL; -#define DRC_SHOW_ERRORS 0x0001 -#define DRC_SHOW_WARNINGS 0x0002 -#define DRC_SHOW_INFOS 0x0004 - #define DIALOG_DRC_WINDOW_NAME "DialogDrcWindowName" class @@ -65,8 +61,6 @@ public: void SetUnconnectedProvider( DRC_ITEMS_PROVIDER* aProvider ); void SetFootprintsProvider( DRC_ITEMS_PROVIDER* aProvider ); - void UpdateDisplayedCounts(); - private: /** * Function writeReport @@ -81,26 +75,28 @@ private: void displayDRCValues(); void setDRCParameters(); void syncCheckboxes(); + void updateDisplayedCounts(); - void OnDRCItemSelected( wxDataViewEvent& event ) override; - void OnDRCItemDClick( wxDataViewEvent& event ) override; + void OnDRCItemSelected( wxDataViewEvent& aEvent ) override; + void OnDRCItemDClick( wxDataViewEvent& aEvent ) override; + void OnDRCItemRClick( wxDataViewEvent& aEvent ) override; - void OnSeverity( wxCommandEvent& event ) override; - void OnSaveReport( wxCommandEvent& event ) override; + void OnSeverity( wxCommandEvent& aEvent ) override; + void OnSaveReport( wxCommandEvent& aEvent ) override; - void OnDeleteOneClick( wxCommandEvent& event ) override; - void OnDeleteAllClick( wxCommandEvent& event ) override; - void OnRunDRCClick( wxCommandEvent& event ) override; - void OnCancelClick( wxCommandEvent& event ) override; + void OnDeleteOneClick( wxCommandEvent& aEvent ) override; + void OnDeleteAllClick( wxCommandEvent& aEvent ) override; + void OnRunDRCClick( wxCommandEvent& aEvent ) override; + void OnCancelClick( wxCommandEvent& aEvent ) override; /// handler for activate event, updating data which can be modified outside the dialog /// (DRC parameters) - void OnActivateDlg( wxActivateEvent& event ) override; + void OnActivateDlg( wxActivateEvent& aEvent ) override; - void OnChangingNotebookPage( wxNotebookEvent& event ) override; + void OnChangingNotebookPage( wxNotebookEvent& aEvent ) override; - void DelDRCMarkers(); - void RefreshBoardEditor(); + void deleteAllMarkers(); + void refreshBoardEditor(); BOARD* m_currentBoard; // the board currently on test DRC* m_tester; @@ -114,9 +110,14 @@ private: UNIT_BINDER m_viaMinSize; UNIT_BINDER m_uviaMinSize; + DRC_ITEMS_PROVIDER* m_markersProvider; DRC_TREE_MODEL* m_markerTreeModel; + + DRC_ITEMS_PROVIDER* m_unconnectedItemsProvider; DRC_TREE_MODEL* m_unconnectedTreeModel; - DRC_TREE_MODEL* m_footprintsTreeModel; + + DRC_ITEMS_PROVIDER* m_footprintWarningsProvider; + DRC_TREE_MODEL* m_footprintWarningsTreeModel; int m_severities; }; diff --git a/pcbnew/dialogs/dialog_drc_base.cpp b/pcbnew/dialogs/dialog_drc_base.cpp index 59f92a50d5..a8c2db2c5d 100644 --- a/pcbnew/dialogs/dialog_drc_base.cpp +++ b/pcbnew/dialogs/dialog_drc_base.cpp @@ -106,7 +106,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i m_Messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTE_MULTILINE|wxTE_READONLY ); m_Messages->SetMinSize( wxSize( 280,-1 ) ); - gbSizer1->Add( m_Messages, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxTOP|wxLEFT, 5 ); + gbSizer1->Add( m_Messages, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); gbSizer1->AddGrowableCol( 0 ); @@ -158,33 +158,55 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i m_MainSizer->Add( m_Notebook, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSeveritySizer; bSeveritySizer = new wxBoxSizer( wxHORIZONTAL ); m_showLabel = new wxStaticText( this, wxID_ANY, _("Show:"), wxDefaultPosition, wxDefaultSize, 0 ); m_showLabel->Wrap( -1 ); - bSeveritySizer->Add( m_showLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + bSeveritySizer->Add( m_showLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_showAll = new wxCheckBox( this, wxID_ANY, _("All"), wxDefaultPosition, wxDefaultSize, 0 ); - bSeveritySizer->Add( m_showAll, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSeveritySizer->Add( m_showAll, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + + bSeveritySizer->Add( 35, 0, 0, wxEXPAND, 5 ); m_showErrors = new wxCheckBox( this, wxID_ANY, _("Errors"), wxDefaultPosition, wxDefaultSize, 0 ); - bSeveritySizer->Add( m_showErrors, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSeveritySizer->Add( m_showErrors, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_errorsBadge = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_errorsBadge->SetMinSize( wxSize( 20,20 ) ); + + bSeveritySizer->Add( m_errorsBadge, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 25 ); m_showWarnings = new wxCheckBox( this, wxID_ANY, _("Warnings"), wxDefaultPosition, wxDefaultSize, 0 ); - bSeveritySizer->Add( m_showWarnings, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSeveritySizer->Add( m_showWarnings, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_showInfos = new wxCheckBox( this, wxID_ANY, _("Infos"), wxDefaultPosition, wxDefaultSize, 0 ); - bSeveritySizer->Add( m_showInfos, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_warningsBadge = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_warningsBadge->SetMinSize( wxSize( 20,20 ) ); + + bSeveritySizer->Add( m_warningsBadge, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 25 ); + + m_showExclusions = new wxCheckBox( this, wxID_ANY, _("Exclusions"), wxDefaultPosition, wxDefaultSize, 0 ); + bSeveritySizer->Add( m_showExclusions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_exclusionsBadge = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + bSeveritySizer->Add( m_exclusionsBadge, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 25 ); bSeveritySizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_saveReport = new wxButton( this, wxID_ANY, _("Save..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSeveritySizer->Add( m_saveReport, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSeveritySizer->Add( m_saveReport, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_MainSizer->Add( bSeveritySizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + bSizer9->Add( bSeveritySizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + + m_MainSizer->Add( bSizer9, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_MainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); @@ -218,6 +240,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_CONTROL_BASE::OnActivateDlg ) ); m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingNotebookPage ), NULL, this ); m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); + m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemRClick ), NULL, this ); m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); m_unconnectedDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_unconnectedDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); @@ -226,7 +249,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i m_showAll->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); m_showErrors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); m_showWarnings->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); - m_showInfos->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); + m_showExclusions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); m_saveReport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSaveReport ), 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 ); @@ -240,6 +263,7 @@ DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE() this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_CONTROL_BASE::OnActivateDlg ) ); m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingNotebookPage ), NULL, this ); m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); + m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemRClick ), NULL, this ); m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); m_unconnectedDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_unconnectedDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); @@ -248,7 +272,7 @@ DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE() m_showAll->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); m_showErrors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); m_showWarnings->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); - m_showInfos->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); + m_showExclusions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSeverity ), NULL, this ); m_saveReport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnSaveReport ), 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 ); diff --git a/pcbnew/dialogs/dialog_drc_base.fbp b/pcbnew/dialogs/dialog_drc_base.fbp index 1ccd96ddd5..323c7eefe7 100644 --- a/pcbnew/dialogs/dialog_drc_base.fbp +++ b/pcbnew/dialogs/dialog_drc_base.fbp @@ -935,7 +935,7 @@ 5 1 1 - wxEXPAND|wxTOP|wxLEFT + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -1144,6 +1144,7 @@ OnDRCItemDClick + OnDRCItemRClick OnDRCItemSelected @@ -1337,416 +1338,611 @@ - 10 - wxEXPAND|wxRIGHT|wxLEFT + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - bSeveritySizer - wxHORIZONTAL + bSizer9 + wxVERTICAL none 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + wxEXPAND|wxRIGHT|wxLEFT 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show: - 0 - - 0 - - - 0 + - 1 - m_showLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - All - - 0 - - - 0 - - 1 - m_showAll - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSeverity - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Errors - - 0 - - - 0 - - 1 - m_showErrors - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSeverity - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Warnings - - 0 - - - 0 - - 1 - m_showWarnings - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSeverity - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Infos - - 0 - - - 0 - - 1 - m_showInfos - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSeverity - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Save... - - 0 - - 0 - - - 0 - - 1 - m_saveReport - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSaveReport + bSeveritySizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show: + 0 + + 0 + + + 0 + + 1 + m_showLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + All + + 0 + + + 0 + + 1 + m_showAll + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSeverity + + + + 5 + wxEXPAND + 0 + + 0 + protected + 35 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Errors + + 0 + + + 0 + + 1 + m_showErrors + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSeverity + + + + 25 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 20,20 + 1 + m_errorsBadge + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Warnings + + 0 + + + 0 + + 1 + m_showWarnings + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSeverity + + + + 25 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 20,20 + 1 + m_warningsBadge + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclusions + + 0 + + + 0 + + 1 + m_showExclusions + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSeverity + + + + 25 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_exclusionsBadge + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Save... + + 0 + + 0 + + + 0 + + 1 + m_saveReport + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSaveReport + + diff --git a/pcbnew/dialogs/dialog_drc_base.h b/pcbnew/dialogs/dialog_drc_base.h index f61908f6c0..625082a713 100644 --- a/pcbnew/dialogs/dialog_drc_base.h +++ b/pcbnew/dialogs/dialog_drc_base.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -64,8 +65,11 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM wxStaticText* m_showLabel; wxCheckBox* m_showAll; wxCheckBox* m_showErrors; + wxStaticBitmap* m_errorsBadge; wxCheckBox* m_showWarnings; - wxCheckBox* m_showInfos; + wxStaticBitmap* m_warningsBadge; + wxCheckBox* m_showExclusions; + wxStaticBitmap* m_exclusionsBadge; wxButton* m_saveReport; wxStaticLine* m_staticline1; wxBoxSizer* m_sizerButtons; @@ -79,6 +83,7 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM virtual void OnActivateDlg( wxActivateEvent& event ) { event.Skip(); } virtual void OnChangingNotebookPage( wxNotebookEvent& event ) { event.Skip(); } virtual void OnDRCItemDClick( wxDataViewEvent& event ) { event.Skip(); } + virtual void OnDRCItemRClick( wxDataViewEvent& event ) { event.Skip(); } virtual void OnDRCItemSelected( wxDataViewEvent& event ) { event.Skip(); } virtual void OnSeverity( wxCommandEvent& event ) { event.Skip(); } virtual void OnSaveReport( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index dfd0f6190c..99cabe3178 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -366,7 +366,7 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processModule( MODULE* aModule, const LIB_ID& a if( !newModule ) { msg << ": " << _( "*** footprint not found ***" ); - m_MessageWindow->Report( msg, REPORTER::RPT_ERROR ); + m_MessageWindow->Report( msg, SEVERITY_ERROR ); return false; } @@ -380,7 +380,7 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processModule( MODULE* aModule, const LIB_ID& a m_currentModule = newModule; msg += ": OK"; - m_MessageWindow->Report( msg, REPORTER::RPT_ACTION ); + m_MessageWindow->Report( msg, SEVERITY_ACTION ); return true; } diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 40abb31cd7..e77dab3495 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -337,7 +337,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) bool success = false; wxArrayString output, errors; REPORTER& reporter = m_messagesPanel->Reporter(); - reporter.ReportHead( wxString::Format( _( "Executing '%s'" ), cmdK2S ), REPORTER::RPT_ACTION ); + reporter.ReportHead( wxString::Format( _( "Executing '%s'" ), cmdK2S ), SEVERITY_ACTION ); { wxBusyCursor dummy; @@ -356,23 +356,23 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) } for( auto& err : errors ) - reporter.Report( err, REPORTER::RPT_WARNING ); + reporter.Report( err, SEVERITY_WARNING ); if( result ) // Any troubles? { if( !success ) { reporter.ReportTail( _( "Unable to create STEP file. Check that the board has a " - "valid outline and models." ), REPORTER::RPT_ERROR ); + "valid outline and models." ), SEVERITY_ERROR ); } else { reporter.ReportTail( _( "STEP file has been created, but there are warnings." ), - REPORTER::RPT_INFO ); + SEVERITY_INFO ); } } else { - reporter.ReportTail( _( "STEP file has been created successfully." ), REPORTER::RPT_INFO ); + reporter.ReportTail( _( "STEP file has been created successfully." ), SEVERITY_INFO ); } } diff --git a/pcbnew/dialogs/dialog_export_svg.cpp b/pcbnew/dialogs/dialog_export_svg.cpp index 498de3d823..e6e6442b0a 100644 --- a/pcbnew/dialogs/dialog_export_svg.cpp +++ b/pcbnew/dialogs/dialog_export_svg.cpp @@ -262,13 +262,12 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile ) if( CreateSVGFile( path ) ) { - reporter.Report( wxString::Format( _( "Exported \"%s\"." ), path ), - REPORTER::RPT_ACTION ); + reporter.Report( wxString::Format( _( "Exported \"%s\"." ), path ), SEVERITY_ACTION ); } else // Error { reporter.Report( wxString::Format( _( "Unable to create file \"%s\"." ), path ), - REPORTER::RPT_ERROR ); + SEVERITY_ERROR ); } if( aOnlyOneFile ) diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp index 5ccce9c23a..e402e753de 100644 --- a/pcbnew/dialogs/dialog_find.cpp +++ b/pcbnew/dialogs/dialog_find.cpp @@ -264,10 +264,8 @@ void DIALOG_FIND::search( bool aDirection ) if( FindIncludeMarkers ) { - for( int i = 0; i < m_frame->GetBoard()->GetMARKERCount(); ++i ) + for( MARKER_PCB* marker : m_frame->GetBoard()->Markers() ) { - MARKER_PCB* marker = m_frame->GetBoard()->GetMARKER( i ); - if( marker->Matches( m_frame->GetFindReplaceData(), nullptr ) ) m_hitList.push_back( marker ); } diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index e6d50d9be4..a72052035f 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -222,7 +222,7 @@ void DIALOG_NETLIST::onFilenameChanged() { m_MessageWindow->Clear(); REPORTER& reporter = m_MessageWindow->Reporter(); - reporter.Report( _( "The netlist file does not exist." ), REPORTER::RPT_ERROR ); + reporter.Report( _( "The netlist file does not exist." ), SEVERITY_ERROR ); } } } @@ -272,14 +272,14 @@ void DIALOG_NETLIST::loadNetlist( bool aDryRun ) wxString msg; msg.Printf( _( "Reading netlist file \"%s\".\n" ), GetChars( netlistFileName ) ); - reporter.ReportHead( msg, REPORTER::RPT_INFO ); + reporter.ReportHead( msg, SEVERITY_INFO ); if( m_matchByTimestamp->GetSelection() == 1 ) msg = _( "Using references to match components and footprints.\n" ); else msg = _( "Using time stamp fields (UUID) to match components and footprints.\n" ); - reporter.ReportHead( msg, REPORTER::RPT_INFO ); + reporter.ReportHead( msg, SEVERITY_INFO ); m_MessageWindow->SetLazyUpdate( true ); // Use lazy update to speed the creation of the report // (the window is not updated for each message) m_matchByUUID = m_matchByTimestamp->GetSelection() == 0; diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 2403ccffa8..f9076546ca 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -613,7 +613,7 @@ void DIALOG_PLOT::applyPlotSettings() { m_defaultPenSize.SetValue( tempOptions.GetHPGLPenDiameter() * IU_PER_MILS ); msg.Printf( _( "HPGL pen size constrained." ) ); - reporter.Report( msg, REPORTER::RPT_INFO ); + reporter.Report( msg, SEVERITY_INFO ); } } else // keep the last value (initial value if no HPGL plot made) @@ -624,7 +624,7 @@ void DIALOG_PLOT::applyPlotSettings() { m_defaultLineWidth.SetValue( tempOptions.GetLineWidth() ); msg.Printf( _( "Default line width constrained." ) ); - reporter.Report( msg, REPORTER::RPT_INFO ); + reporter.Report( msg, SEVERITY_INFO ); } // X scale @@ -637,7 +637,7 @@ void DIALOG_PLOT::applyPlotSettings() msg.Printf( wxT( "%f" ), m_XScaleAdjust ); m_fineAdjustXCtrl->SetValue( msg ); msg.Printf( _( "X scale constrained." ) ); - reporter.Report( msg, REPORTER::RPT_INFO ); + reporter.Report( msg, SEVERITY_INFO ); } // Y scale @@ -649,7 +649,7 @@ void DIALOG_PLOT::applyPlotSettings() msg.Printf( wxT( "%f" ), m_YScaleAdjust ); m_fineAdjustYCtrl->SetValue( msg ); msg.Printf( _( "Y scale constrained." ) ); - reporter.Report( msg, REPORTER::RPT_INFO ); + reporter.Report( msg, SEVERITY_INFO ); } auto cfg = m_parent->GetSettings(); @@ -670,7 +670,7 @@ void DIALOG_PLOT::applyPlotSettings() StringFromValue( GetUserUnits(), m_widthAdjustMinValue, false, true ), StringFromValue( GetUserUnits(), m_widthAdjustMaxValue, false, true ), GetAbbreviatedUnitsLabel( GetUserUnits(), true ) ); - reporter.Report( msg, REPORTER::RPT_WARNING ); + reporter.Report( msg, SEVERITY_WARNING ); } // Store m_PSWidthAdjust in mm in user config @@ -856,12 +856,12 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) delete plotter; msg.Printf( _( "Plot file \"%s\" created." ), fn.GetFullPath() ); - reporter.Report( msg, REPORTER::RPT_ACTION ); + reporter.Report( msg, SEVERITY_ACTION ); } else { msg.Printf( _( "Unable to create file \"%s\"." ), fn.GetFullPath() ); - reporter.Report( msg, REPORTER::RPT_ERROR ); + reporter.Report( msg, SEVERITY_ERROR ); } wxSafeYield(); // displays report message. diff --git a/pcbnew/dialogs/panel_setup_drc_severities.cpp b/pcbnew/dialogs/panel_setup_drc_severities.cpp new file mode 100644 index 0000000000..6fc2339f18 --- /dev/null +++ b/pcbnew/dialogs/panel_setup_drc_severities.cpp @@ -0,0 +1,143 @@ +/* + * 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 + */ + +#include +#include +#include +#include "panel_setup_drc_severities.h" + + +PANEL_SETUP_DRC_SEVERITIES::PANEL_SETUP_DRC_SEVERITIES( PAGED_DIALOG* aParent, + PCB_EDIT_FRAME* aFrame ) : + wxPanel( aParent->GetTreebook() ), + m_brdSettings( aFrame->GetBoard()->GetDesignSettings() ) +{ + wxString severities[] = { _( "Error" ), _( "Warning" ), _( "Ignore" ) }; + int baseID = 1000; + wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL ); + wxScrolledWindow* scrollWin = new wxScrolledWindow( this, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL | wxVSCROLL ); + scrollWin->SetScrollRate( 0, 5 ); + + wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 5 ); + gridSizer->SetFlexibleDirection( wxBOTH ); + + for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode ) + { + DRC_ITEM drcItem( errorCode, wxEmptyString ); + wxString msg = drcItem.GetErrorText(); + + if( !msg.IsEmpty() ) + { + wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) ); + gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 ); + + // OSX can't handle more than 100 radio buttons in a single window (yes, seriously), + // so we have to create a window for each set + wxPanel* radioPanel = new wxPanel( scrollWin ); + wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL ); + + for( int i = 0; i < sizeof( severities ) / sizeof( wxString ); ++i ) + { + m_buttonMap[errorCode][i] = new wxRadioButton( radioPanel, + baseID + errorCode * 10 + i, + severities[i], + wxDefaultPosition, + wxDefaultSize, + i == 0 ? wxRB_GROUP : 0 ); + radioSizer->Add( m_buttonMap[errorCode][i], 1, + wxALIGN_CENTER_VERTICAL | wxRIGHT | wxEXPAND, 25 ); + } + + radioPanel->SetSizer( radioSizer ); + radioPanel->Layout(); + gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 ); + } + } + + scrollWin->SetSizer( gridSizer ); + scrollWin->Layout(); + gridSizer->Fit( scrollWin ); + panelSizer->Add( scrollWin, 1, wxEXPAND | wxALL, 5 ); + + this->SetSizer( panelSizer ); + this->Layout(); + panelSizer->Fit( this ); +} + + +void PANEL_SETUP_DRC_SEVERITIES::ImportSettingsFrom( BOARD* aBoard ) +{ + for( auto const& entry : aBoard->GetDesignSettings().m_DRCSeverities ) + { + if( m_buttonMap.count( entry.first ) ) + { + switch( entry.second ) + { + case SEVERITY_ERROR: m_buttonMap[entry.first][0]->SetValue( true ); break; + case SEVERITY_WARNING: m_buttonMap[entry.first][1]->SetValue( true ); break; + case SEVERITY_IGNORE: m_buttonMap[entry.first][2]->SetValue( true ); break; + } + } + } +} + + +bool PANEL_SETUP_DRC_SEVERITIES::TransferDataToWindow() +{ + for( auto const& entry : m_brdSettings.m_DRCSeverities ) + { + if( m_buttonMap.count( entry.first ) ) + { + switch( entry.second ) + { + case SEVERITY_ERROR: m_buttonMap[entry.first][0]->SetValue( true ); break; + case SEVERITY_WARNING: m_buttonMap[entry.first][1]->SetValue( true ); break; + case SEVERITY_IGNORE: m_buttonMap[entry.first][2]->SetValue( true ); break; + } + } + } + + return true; +} + + +bool PANEL_SETUP_DRC_SEVERITIES::TransferDataFromWindow() +{ + for( auto const& entry : m_buttonMap ) + { + int severity = SEVERITY_UNDEFINED; + + if( entry.second[0]->GetValue() ) + severity = SEVERITY_ERROR; + else if( entry.second[1]->GetValue() ) + severity = SEVERITY_WARNING; + else if( entry.second[2]->GetValue() ) + severity = SEVERITY_IGNORE; + + m_brdSettings.m_DRCSeverities[ entry.first ] = severity; + } + + return true; +} diff --git a/pcbnew/drc/drc_provider.cpp b/pcbnew/dialogs/panel_setup_drc_severities.h similarity index 54% rename from pcbnew/drc/drc_provider.cpp rename to pcbnew/dialogs/panel_setup_drc_severities.h index 6b7d0c9d62..58f48d94a7 100644 --- a/pcbnew/drc/drc_provider.cpp +++ b/pcbnew/dialogs/panel_setup_drc_severities.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -21,24 +21,36 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include + +#ifndef KICAD_PANEL_SETUP_DRC_SEVERITIES_H +#define KICAD_PANEL_SETUP_DRC_SEVERITIES_H + +#include +#include -DRC_PROVIDER::DRC_PROVIDER( const DRC_MARKER_FACTORY& aMarkerMaker, MARKER_HANDLER aMarkerHandler ) - : m_marker_factory( aMarkerMaker ), m_marker_handler( aMarkerHandler ) +class BOARD; +class BOARD_DESIGN_SETTINGS; +class PAGED_DIALOG; +class PCB_EDIT_FRAME; +class wxRadioBox; + + +class PANEL_SETUP_DRC_SEVERITIES : public wxPanel { -} +private: + BOARD_DESIGN_SETTINGS& m_brdSettings; + std::map m_buttonMap; // map from DRC error code to button group +public: + PANEL_SETUP_DRC_SEVERITIES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ); + ~PANEL_SETUP_DRC_SEVERITIES( ) { }; -const DRC_MARKER_FACTORY& DRC_PROVIDER::GetMarkerFactory() const -{ - return m_marker_factory; -} + void ImportSettingsFrom( BOARD* aBoard ); +private: + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; +}; -void DRC_PROVIDER::HandleMarker( std::unique_ptr aMarker ) const -{ - // The marker hander currently takes a raw pointer, - // but it also assumes ownership - m_marker_handler( aMarker.release() ); -} +#endif //KICAD_PANEL_SETUP_DRC_SEVERITIES_H diff --git a/pcbnew/dialogs/panel_setup_feature_constraints.cpp b/pcbnew/dialogs/panel_setup_feature_constraints.cpp index 34717467e0..b636acec49 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints.cpp +++ b/pcbnew/dialogs/panel_setup_feature_constraints.cpp @@ -68,9 +68,6 @@ bool PANEL_SETUP_FEATURE_CONSTRAINTS::TransferDataToWindow() m_edgeClearance.SetValue( m_BrdSettings->m_CopperEdgeClearance ); - m_OptRequireCourtyards->SetValue( m_BrdSettings->m_RequireCourtyards ); - m_OptOverlappingCourtyards->SetValue( m_BrdSettings->m_ProhibitOverlappingCourtyards ); - m_maxError.SetValue( m_BrdSettings->m_MaxError ); m_cbOutlinePolygonFastest->SetValue( m_BrdSettings->m_ZoneUseNoOutlineInFill ); @@ -100,9 +97,6 @@ bool PANEL_SETUP_FEATURE_CONSTRAINTS::TransferDataFromWindow() m_BrdSettings->SetCopperEdgeClearance( m_edgeClearance.GetValue() ); - m_BrdSettings->SetRequireCourtyardDefinitions( m_OptRequireCourtyards->GetValue() ); - m_BrdSettings->SetProhibitOverlappingCourtyards( m_OptOverlappingCourtyards->GetValue() ); - m_BrdSettings->m_MaxError = Clamp( IU_PER_MM * MINIMUM_ERROR_SIZE_MM, m_maxError.GetValue(), IU_PER_MM * MAXIMUM_ERROR_SIZE_MM ); diff --git a/pcbnew/dialogs/panel_setup_feature_constraints_base.cpp b/pcbnew/dialogs/panel_setup_feature_constraints_base.cpp index f0e7c1fd9e..793dd6d6eb 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints_base.cpp +++ b/pcbnew/dialogs/panel_setup_feature_constraints_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,240 +9,231 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::PANEL_SETUP_FEATURE_CONSTRAINTS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::PANEL_SETUP_FEATURE_CONSTRAINTS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* sbFeatureRules; sbFeatureRules = new wxBoxSizer( wxVERTICAL ); - + m_OptAllowBlindBuriedVias = new wxCheckBox( this, wxID_ANY, _("Allow blind/buried vias"), wxDefaultPosition, wxDefaultSize, 0 ); sbFeatureRules->Add( m_OptAllowBlindBuriedVias, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - + m_OptAllowMicroVias = new wxCheckBox( this, wxID_ANY, _("Allow micro vias (uVias)"), wxDefaultPosition, wxDefaultSize, 0 ); sbFeatureRules->Add( m_OptAllowMicroVias, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - - sbFeatureRules->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - m_OptRequireCourtyards = new wxCheckBox( this, wxID_ANY, _("Require courtyard definitions in footprints"), wxDefaultPosition, wxDefaultSize, 0 ); - sbFeatureRules->Add( m_OptRequireCourtyards, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_OptOverlappingCourtyards = new wxCheckBox( this, wxID_ANY, _("Prohibit overlapping courtyards"), wxDefaultPosition, wxDefaultSize, 0 ); - sbFeatureRules->Add( m_OptOverlappingCourtyards, 0, wxALL, 5 ); - - - sbFeatureRules->Add( 0, 0, 0, wxEXPAND|wxBOTTOM, 5 ); - + + + sbFeatureRules->Add( 0, 5, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + wxBoxSizer* bSizerArcToPoly; bSizerArcToPoly = new wxBoxSizer( wxVERTICAL ); - + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerArcToPoly->Add( m_staticline2, 0, wxEXPAND | wxALL, 2 ); - + m_stCircleToPolyOpt = new wxStaticText( this, wxID_ANY, _("Arc/circle drawing"), wxDefaultPosition, wxDefaultSize, 0 ); m_stCircleToPolyOpt->Wrap( -1 ); m_stCircleToPolyOpt->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - + bSizerArcToPoly->Add( m_stCircleToPolyOpt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - + wxFlexGridSizer* fgSizer2; fgSizer2 = new wxFlexGridSizer( 0, 4, 3, 0 ); fgSizer2->AddGrowableCol( 2 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - + + fgSizer2->Add( 15, 0, 1, wxEXPAND, 5 ); - + m_maxErrorTitle = new wxStaticText( this, wxID_ANY, _("Maximum deviation:"), wxDefaultPosition, wxDefaultSize, 0 ); m_maxErrorTitle->Wrap( -1 ); m_maxErrorTitle->SetToolTip( _("This is the maximum distance between a circle and the polygonal shape that approximate it.\nThe error max defines the number of segments of this polygon.") ); - + fgSizer2->Add( m_maxErrorTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT, 5 ); - + m_maxErrorCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizer2->Add( m_maxErrorCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - + m_maxErrorUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_maxErrorUnits->Wrap( -1 ); fgSizer2->Add( m_maxErrorUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - + + bSizerArcToPoly->Add( fgSizer2, 0, wxEXPAND|wxBOTTOM, 5 ); - - + + sbFeatureRules->Add( bSizerArcToPoly, 0, wxEXPAND|wxTOP, 5 ); - + m_bSizerPolygonFillOption = new wxBoxSizer( wxVERTICAL ); - + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_bSizerPolygonFillOption->Add( m_staticline1, 0, wxEXPAND | wxALL, 2 ); - + m_stZoneFilledPolysOpt = new wxStaticText( this, wxID_ANY, _("Zone fill strategy"), wxDefaultPosition, wxDefaultSize, 0 ); m_stZoneFilledPolysOpt->Wrap( -1 ); m_stZoneFilledPolysOpt->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - + m_bSizerPolygonFillOption->Add( m_stZoneFilledPolysOpt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - + wxBoxSizer* bSizer5; bSizer5 = new wxBoxSizer( wxVERTICAL ); - + m_cbOutlinePolygonBestQ = new wxCheckBox( this, wxID_ANY, _("Stroked outlines (legacy)"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer5->Add( m_cbOutlinePolygonBestQ, 0, wxALL, 4 ); - + m_cbOutlinePolygonFastest = new wxCheckBox( this, wxID_ANY, _("Smoothed polygons (best performance)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_cbOutlinePolygonFastest->SetValue(true); + m_cbOutlinePolygonFastest->SetValue(true); bSizer5->Add( m_cbOutlinePolygonFastest, 0, wxBOTTOM|wxRIGHT|wxLEFT, 4 ); - - + + m_bSizerPolygonFillOption->Add( bSizer5, 1, wxEXPAND|wxLEFT, 15 ); - - + + sbFeatureRules->Add( m_bSizerPolygonFillOption, 0, wxEXPAND|wxTOP, 5 ); - - + + bMainSizer->Add( sbFeatureRules, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - + + bMainSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 15 ); - + wxBoxSizer* sbFeatureConstraints; sbFeatureConstraints = new wxBoxSizer( wxVERTICAL ); - + wxFlexGridSizer* fgFeatureConstraints; fgFeatureConstraints = new wxFlexGridSizer( 0, 3, 2, 0 ); fgFeatureConstraints->AddGrowableCol( 1 ); fgFeatureConstraints->SetFlexibleDirection( wxBOTH ); fgFeatureConstraints->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_TrackMinWidthTitle = new wxStaticText( this, wxID_ANY, _("Minimum track width:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_TrackMinWidthTitle->Wrap( -1 ); fgFeatureConstraints->Add( m_TrackMinWidthTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 ); - + m_TrackMinWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_TrackMinWidthCtrl->SetMinSize( wxSize( 120,-1 ) ); - + fgFeatureConstraints->Add( m_TrackMinWidthCtrl, 0, wxALIGN_LEFT|wxALIGN_TOP|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + m_TrackMinWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_TrackMinWidthUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_TrackMinWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxALL|wxEXPAND, 5 ); - + m_ViaMinTitle = new wxStaticText( this, wxID_ANY, _("Minimum via diameter:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_ViaMinTitle->Wrap( -1 ); fgFeatureConstraints->Add( m_ViaMinTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - + m_SetViasMinSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgFeatureConstraints->Add( m_SetViasMinSizeCtrl, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_ViaMinUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_ViaMinUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_ViaMinUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - + m_ViaMinDrillTitle = new wxStaticText( this, wxID_ANY, _("Minimum via drill:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_ViaMinDrillTitle->Wrap( -1 ); fgFeatureConstraints->Add( m_ViaMinDrillTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - + m_SetViasMinDrillCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgFeatureConstraints->Add( m_SetViasMinDrillCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + m_ViaMinDrillUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_ViaMinDrillUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_ViaMinDrillUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND|wxTOP, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND|wxTOP, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND|wxTOP, 5 ); - + m_uviaMinSizeLabel = new wxStaticText( this, wxID_ANY, _("Minimum uVia diameter:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_uviaMinSizeLabel->Wrap( -1 ); fgFeatureConstraints->Add( m_uviaMinSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - + m_uviaMinSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgFeatureConstraints->Add( m_uviaMinSizeCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - + m_uviaMinSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_uviaMinSizeUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_uviaMinSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - + m_uviaMinDrillLabel = new wxStaticText( this, wxID_ANY, _("Minimum uVia drill:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_uviaMinDrillLabel->Wrap( -1 ); fgFeatureConstraints->Add( m_uviaMinDrillLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - + m_uviaMinDrillCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgFeatureConstraints->Add( m_uviaMinDrillCtrl, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_uviaMinDrillUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_uviaMinDrillUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_uviaMinDrillUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND, 5 ); - + m_HoleToHoleTitle = new wxStaticText( this, wxID_ANY, _("Minimum hole to hole:"), wxDefaultPosition, wxDefaultSize, 0 ); m_HoleToHoleTitle->Wrap( -1 ); fgFeatureConstraints->Add( m_HoleToHoleTitle, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); - + m_SetHoleToHoleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgFeatureConstraints->Add( m_SetHoleToHoleCtrl, 0, wxEXPAND|wxALL, 5 ); - + m_HoleToHoleUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_HoleToHoleUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_HoleToHoleUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND|wxTOP, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND, 5 ); - - + + fgFeatureConstraints->Add( 0, 0, 1, wxEXPAND, 5 ); - + m_EdgeClearanceLabel = new wxStaticText( this, wxID_ANY, _("Copper edge clearance:"), wxDefaultPosition, wxDefaultSize, 0 ); m_EdgeClearanceLabel->Wrap( -1 ); fgFeatureConstraints->Add( m_EdgeClearanceLabel, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); - + m_EdgeClearanceCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgFeatureConstraints->Add( m_EdgeClearanceCtrl, 0, wxALL|wxEXPAND, 5 ); - + m_EdgeClearanceUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_EdgeClearanceUnits->Wrap( -1 ); fgFeatureConstraints->Add( m_EdgeClearanceUnits, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); - - + + sbFeatureConstraints->Add( fgFeatureConstraints, 1, wxEXPAND|wxTOP|wxLEFT, 5 ); - - + + bMainSizer->Add( sbFeatureConstraints, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - + + this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); - + // Connect Events m_cbOutlinePolygonBestQ->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::onChangeOutlineOpt ), NULL, this ); m_cbOutlinePolygonFastest->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::onChangeOutlineOpt ), NULL, this ); @@ -253,5 +244,5 @@ PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::~PANEL_SETUP_FEATURE_CONSTRAINTS_BASE() // Disconnect Events m_cbOutlinePolygonBestQ->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::onChangeOutlineOpt ), NULL, this ); m_cbOutlinePolygonFastest->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_FEATURE_CONSTRAINTS_BASE::onChangeOutlineOpt ), NULL, this ); - + } diff --git a/pcbnew/dialogs/panel_setup_feature_constraints_base.fbp b/pcbnew/dialogs/panel_setup_feature_constraints_base.fbp index cbc585e37d..76b1c55c3b 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints_base.fbp +++ b/pcbnew/dialogs/panel_setup_feature_constraints_base.fbp @@ -2,7 +2,7 @@ - + C++ 1 source_name @@ -14,11 +14,12 @@ panel_setup_feature_constraints_base 1000 none + 1 panel_setup_feature_constraints_base - + . - + 1 1 1 @@ -29,57 +30,27 @@ 0 wxAUI_MGR_DEFAULT - - + + 1 1 impl_virtual - - + + 0 wxID_ANY - - + + PANEL_SETUP_FEATURE_CONSTRAINTS_BASE - + -1,-1 ; forward_declare - - - + + + wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + bMainSizer wxHORIZONTAL none @@ -88,7 +59,7 @@ wxEXPAND|wxRIGHT|wxLEFT 0 - + sbFeatureRules wxVERTICAL none @@ -101,83 +72,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Allow blind/buried vias - + 0 - - + + 0 - + 1 m_OptAllowBlindBuriedVias 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -189,83 +136,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Allow micro vias (uVias) - + 0 - - + + 0 - + 1 m_OptAllowMicroVias 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -273,193 +196,7 @@ wxEXPAND|wxTOP|wxBOTTOM 0 - 0 - protected - 0 - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Require courtyard definitions in footprints - - 0 - - - 0 - - 1 - m_OptRequireCourtyards - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Prohibit overlapping courtyards - - 0 - - - 0 - - 1 - m_OptOverlappingCourtyards - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM - 0 - - 0 + 5 protected 0 @@ -469,7 +206,7 @@ wxEXPAND|wxTOP 0 - + bSizerArcToPoly wxVERTICAL none @@ -482,76 +219,53 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 - + 1 m_staticline2 1 - - + + protected 1 - + Resizable 1 - + wxLI_HORIZONTAL ; ; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -563,78 +277,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 ,90,90,-1,70,0 0 0 wxID_ANY Arc/circle drawing - + 0 + 0 - - + + 0 - + 1 m_stCircleToPolyOpt 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -645,9 +337,9 @@ 4 wxBOTH 2 - + 0 - + fgSizer2 wxFLEX_GROWMODE_SPECIFIED none @@ -672,78 +364,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Maximum deviation: - + 0 + 0 - - + + 0 - + 1 m_maxErrorTitle 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 This is the maximum distance between a circle and the polygonal shape that approximate it. The error max defines the number of segments of this polygon. - - - + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -755,86 +425,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_maxErrorCtrl 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 - + wxString wxFILTER_NUMERIC wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -846,78 +489,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_maxErrorUnits 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -929,7 +550,7 @@ wxEXPAND|wxTOP 0 - + m_bSizerPolygonFillOption wxVERTICAL protected @@ -942,76 +563,53 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 - + 1 m_staticline1 1 - - + + protected 1 - + Resizable 1 - + wxLI_HORIZONTAL ; ; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -1023,78 +621,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 ,90,90,-1,70,0 0 0 wxID_ANY Zone fill strategy - + 0 + 0 - - + + 0 - + 1 m_stZoneFilledPolysOpt 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1102,7 +678,7 @@ wxEXPAND|wxLEFT 1 - + bSizer5 wxVERTICAL none @@ -1115,83 +691,60 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Stroked outlines (legacy) - + 0 - - + + 0 - + 1 m_cbOutlinePolygonBestQ 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onChangeOutlineOpt - - - - - - - - - - - - - - - - - - - - - - @@ -1203,83 +756,60 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Smoothed polygons (best performance) - + 0 - - + + 0 - + 1 m_cbOutlinePolygonFastest 1 - - + + protected 1 - + Resizable 1 - - + + ; ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - + + + + onChangeOutlineOpt - - - - - - - - - - - - - - - - - - - - - - @@ -1303,7 +833,7 @@ wxEXPAND|wxRIGHT|wxLEFT 0 - + sbFeatureConstraints wxVERTICAL none @@ -1315,9 +845,9 @@ 3 wxBOTH 1 - + 0 - + fgFeatureConstraints wxFLEX_GROWMODE_SPECIFIED none @@ -1332,78 +862,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Minimum track width: - + 0 + 0 - - + + 0 - + 1 m_TrackMinWidthTitle 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1415,86 +923,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 120,-1 1 m_TrackMinWidthCtrl 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - + wxString wxFILTER_NUMERIC wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -1506,78 +987,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_TrackMinWidthUnits 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1619,78 +1078,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Minimum via diameter: - + 0 + 0 - - + + 0 - + 1 m_ViaMinTitle 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1702,86 +1139,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_SetViasMinSizeCtrl 1 - - + + protected 1 - + Resizable 1 - - + + ; 0 - + wxString wxFILTER_NUMERIC wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -1793,78 +1203,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_ViaMinUnits 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1876,78 +1264,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Minimum via drill: - + 0 + 0 - - + + 0 - + 1 m_ViaMinDrillTitle 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1959,86 +1325,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_SetViasMinDrillCtrl 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NUMERIC wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -2050,78 +1389,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_ViaMinDrillUnits 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2163,78 +1480,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Minimum uVia diameter: - + 0 + 0 - - + + 0 - + 1 m_uviaMinSizeLabel 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2246,86 +1541,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_uviaMinSizeCtrl 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NUMERIC wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -2337,78 +1605,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_uviaMinSizeUnits 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2420,78 +1666,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Minimum uVia drill: - + 0 + 0 - - + + 0 - + 1 m_uviaMinDrillLabel 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2503,86 +1727,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_uviaMinDrillCtrl 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NUMERIC wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -2594,78 +1791,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_uviaMinDrillUnits 1 - - + + protected 1 - + Resizable 1 - + wxALIGN_LEFT - + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2707,78 +1882,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Minimum hole to hole: - + 0 + 0 - - + + 0 - + 1 m_HoleToHoleTitle 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2790,86 +1943,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_SetHoleToHoleCtrl 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -2881,78 +2007,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_HoleToHoleUnits 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2994,78 +2098,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Copper edge clearance: - + 0 + 0 - - + + 0 - + 1 m_EdgeClearanceLabel 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -3077,86 +2159,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_EdgeClearanceCtrl 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -3168,78 +2223,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY mm - + 0 + 0 - - + + 0 - + 1 m_EdgeClearanceUnits 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcbnew/dialogs/panel_setup_feature_constraints_base.h b/pcbnew/dialogs/panel_setup_feature_constraints_base.h index bc25a7ab8a..33f287d6d5 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints_base.h +++ b/pcbnew/dialogs/panel_setup_feature_constraints_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __PANEL_SETUP_FEATURE_CONSTRAINTS_BASE_H__ -#define __PANEL_SETUP_FEATURE_CONSTRAINTS_BASE_H__ +#pragma once #include #include @@ -29,15 +28,13 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_SETUP_FEATURE_CONSTRAINTS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_SETUP_FEATURE_CONSTRAINTS_BASE : public wxPanel +class PANEL_SETUP_FEATURE_CONSTRAINTS_BASE : public wxPanel { private: - + protected: wxCheckBox* m_OptAllowBlindBuriedVias; wxCheckBox* m_OptAllowMicroVias; - wxCheckBox* m_OptRequireCourtyards; - wxCheckBox* m_OptOverlappingCourtyards; wxStaticLine* m_staticline2; wxStaticText* m_stCircleToPolyOpt; wxStaticText* m_maxErrorTitle; @@ -69,16 +66,15 @@ class PANEL_SETUP_FEATURE_CONSTRAINTS_BASE : public wxPanel wxStaticText* m_EdgeClearanceLabel; wxTextCtrl* m_EdgeClearanceCtrl; wxStaticText* m_EdgeClearanceUnits; - + // Virtual event handlers, overide them in your derived class virtual void onChangeOutlineOpt( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - PANEL_SETUP_FEATURE_CONSTRAINTS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + + PANEL_SETUP_FEATURE_CONSTRAINTS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_SETUP_FEATURE_CONSTRAINTS_BASE(); - + }; -#endif //__PANEL_SETUP_FEATURE_CONSTRAINTS_BASE_H__ diff --git a/pcbnew/drc/courtyard_overlap.cpp b/pcbnew/drc/courtyard_overlap.cpp index 881f908755..85a419e3bb 100644 --- a/pcbnew/drc/courtyard_overlap.cpp +++ b/pcbnew/drc/courtyard_overlap.cpp @@ -33,8 +33,9 @@ #include #include -#include +#include +#include /** * Flag to enable courtyard DRC debug tracing. @@ -46,14 +47,13 @@ static const wxChar* DRC_COURTYARD_TRACE = wxT( "KICAD_DRC_COURTYARD" ); -DRC_COURTYARD_OVERLAP::DRC_COURTYARD_OVERLAP( - const DRC_MARKER_FACTORY& aMarkerFactory, MARKER_HANDLER aMarkerHandler ) - : DRC_PROVIDER( aMarkerFactory, aMarkerHandler ) +DRC_COURTYARD_OVERLAP::DRC_COURTYARD_OVERLAP( MARKER_HANDLER aMarkerHandler ) : + DRC_PROVIDER( aMarkerHandler ) { } -bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const +bool DRC_COURTYARD_OVERLAP::RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) const { wxLogTrace( DRC_COURTYARD_TRACE, "Running DRC: Courtyard" ); @@ -62,40 +62,34 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const wxString msg; bool success = true; - const DRC_MARKER_FACTORY& marker_factory = GetMarkerFactory(); - // Update courtyard polygons, and test for missing courtyard definition: - for( auto footprint : aBoard.Modules() ) + for( MODULE* footprint : aBoard.Modules() ) { wxPoint pos = footprint->GetPosition(); bool is_ok = footprint->BuildPolyCourtyard(); - if( !is_ok && aBoard.GetDesignSettings().m_ProhibitOverlappingCourtyards ) + if( !is_ok && !aBoard.GetDesignSettings().Ignore( DRCE_OVERLAPPING_FOOTPRINTS ) ) { - auto marker = std::unique_ptr( marker_factory.NewMarker( - pos, - footprint, - DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT ) ); - HandleMarker( std::move( marker ) ); + auto m = std::make_unique( aUnits, DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT, + pos, footprint ); + HandleMarker( std::move( m ) ); success = false; } - if( !aBoard.GetDesignSettings().m_RequireCourtyards ) + if( aBoard.GetDesignSettings().Ignore( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) ) continue; if( footprint->GetPolyCourtyardFront().OutlineCount() == 0 && footprint->GetPolyCourtyardBack().OutlineCount() == 0 && is_ok ) { - auto marker = std::unique_ptr( marker_factory.NewMarker( - pos, - footprint, - DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) ); - HandleMarker( std::move( marker ) ); + auto m = std::make_unique( aUnits, DRCE_MISSING_COURTYARD_IN_FOOTPRINT, + pos, footprint ); + HandleMarker( std::move( m ) ); success = false; } } - if( !aBoard.GetDesignSettings().m_ProhibitOverlappingCourtyards ) + if( aBoard.GetDesignSettings().Ignore( DRCE_OVERLAPPING_FOOTPRINTS ) ) return success; wxLogTrace( DRC_COURTYARD_TRACE, "Checking for courtyard overlap" ); @@ -129,13 +123,10 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const if( courtyard.OutlineCount() ) { //Overlap between footprint and candidate - auto& pos = courtyard.CVertex( 0, 0, -1 ); - auto marker = std::unique_ptr( marker_factory.NewMarker( - (wxPoint) pos, - footprint, - candidate, - DRCE_OVERLAPPING_FOOTPRINTS ) ); - HandleMarker( std::move( marker ) ); + auto m = std::make_unique( aUnits, DRCE_OVERLAPPING_FOOTPRINTS, + (wxPoint) courtyard.CVertex( 0, 0, -1 ), + footprint, candidate ); + HandleMarker( std::move( m ) ); success = false; } } @@ -168,13 +159,10 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const if( courtyard.OutlineCount() ) { //Overlap between footprint and candidate - auto& pos = courtyard.CVertex( 0, 0, -1 ); - auto marker = std::unique_ptr( marker_factory.NewMarker( - (wxPoint) pos, - footprint, - candidate, - DRCE_OVERLAPPING_FOOTPRINTS ) ); - HandleMarker( std::move( marker ) ); + auto m = std::make_unique( aUnits, DRCE_OVERLAPPING_FOOTPRINTS, + (wxPoint) courtyard.CVertex( 0, 0, -1 ), + footprint, candidate ); + HandleMarker( std::move( m ) ); success = false; } } diff --git a/pcbnew/drc/courtyard_overlap.h b/pcbnew/drc/courtyard_overlap.h index 3e54618567..71ba99ba62 100644 --- a/pcbnew/drc/courtyard_overlap.h +++ b/pcbnew/drc/courtyard_overlap.h @@ -35,10 +35,9 @@ class DRC_COURTYARD_OVERLAP : public DRC_PROVIDER { public: - DRC_COURTYARD_OVERLAP( - const DRC_MARKER_FACTORY& aMarkerFactory, MARKER_HANDLER aMarkerHandler ); + DRC_COURTYARD_OVERLAP( MARKER_HANDLER aMarkerHandler ); - bool RunDRC( BOARD& aBoard ) const override; + bool RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) const override; }; #endif // DRC_COURTYARD_OVERLAP__H \ No newline at end of file diff --git a/pcbnew/drc/drc.cpp b/pcbnew/drc/drc.cpp index 3ab411c835..a0e6a03367 100644 --- a/pcbnew/drc/drc.cpp +++ b/pcbnew/drc/drc.cpp @@ -58,7 +58,6 @@ DRC::DRC() : PCB_TOOL_BASE( "pcbnew.DRCTool" ), - m_currentMarker( nullptr ), m_pcbEditorFrame( nullptr ), m_pcb( nullptr ), m_drcDialog( nullptr ) @@ -75,7 +74,7 @@ DRC::DRC() : m_drcRun = false; m_footprintsTested = false; - m_severities = DRC_SHOW_ERRORS | DRC_SHOW_WARNINGS | DRC_SHOW_INFOS; + m_severities = SEVERITY_ERROR | SEVERITY_WARNING; m_segmAngle = 0; m_segmLength = 0; @@ -107,8 +106,6 @@ void DRC::Reset( RESET_REASON aReason ) DestroyDRCDialog( wxID_OK ); m_pcb = m_pcbEditorFrame->GetBoard(); - - m_markerFactory.SetUnitsProvider( [=]() { return m_pcbEditorFrame->GetUserUnits(); } ); } } @@ -177,10 +174,9 @@ void DRC::DestroyDRCDialog( int aReason ) } -int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) +int DRC::TestZoneToZoneOutlines() { BOARD* board = m_pcbEditorFrame->GetBoard(); - BOARD_COMMIT commit( m_pcbEditorFrame ); int nerrors = 0; std::vector smoothed_polys; @@ -203,13 +199,9 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) if( !zoneRef->IsOnCopperLayer() ) continue; - // When testing only a single area, skip all others - if( aZone && ( aZone != zoneRef) ) - continue; - // If we are testing a single zone, then iterate through all other zones // Otherwise, we have already tested the zone combination - for( int ia2 = ( aZone ? 0 : ia + 1 ); ia2 < board->GetAreaCount(); ia2++ ) + for( int ia2 = ia + 1; ia2 < board->GetAreaCount(); ia2++ ) { ZONE_CONTAINER* zoneToTest = board->GetArea( ia2 ); @@ -252,10 +244,8 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) if( smoothed_polys[ia2].Contains( currentVertex ) ) { - if( aCreateMarkers ) - commit.Add( m_markerFactory.NewMarker( pt, zoneRef, zoneToTest, - DRCE_ZONES_INTERSECT ) ); - + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_ZONES_INTERSECT, pt, + zoneRef, zoneToTest ) ); nerrors++; } } @@ -268,10 +258,8 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) if( smoothed_polys[ia].Contains( currentVertex ) ) { - if( aCreateMarkers ) - commit.Add( m_markerFactory.NewMarker( pt, zoneToTest, zoneRef, - DRCE_ZONES_INTERSECT ) ); - + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_ZONES_INTERSECT, pt, + zoneToTest, zoneRef ) ); nerrors++; } } @@ -317,18 +305,13 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) for( wxPoint pt : conflictPoints ) { - if( aCreateMarkers ) - commit.Add( m_markerFactory.NewMarker( pt, zoneRef, zoneToTest, - DRCE_ZONES_TOO_CLOSE ) ); - + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_ZONES_TOO_CLOSE, pt, + zoneRef, zoneToTest ) ); nerrors++; } } } - if( aCreateMarkers ) - commit.Push( wxEmptyString, false, false ); - return nerrors; } @@ -454,8 +437,8 @@ void DRC::RunTests( wxTextCtrl* aMessages ) testCopperTextAndGraphics(); // find overlapping courtyard ares. - if( m_pcb->GetDesignSettings().m_ProhibitOverlappingCourtyards - || m_pcb->GetDesignSettings().m_RequireCourtyards ) + if( !m_pcb->GetDesignSettings().Ignore( DRCE_OVERLAPPING_FOOTPRINTS ) + && !m_pcb->GetDesignSettings().Ignore( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) ) { if( aMessages ) { @@ -518,13 +501,15 @@ void DRC::updatePointers() // update my pointers, m_pcbEditorFrame is the only unchangeable one m_pcb = m_pcbEditorFrame->GetBoard(); + m_pcbEditorFrame->ResolveDRCExclusions(); + if( m_drcDialog ) // Use diag list boxes only in DRC dialog { m_drcDialog->SetMarkersProvider( new BOARD_DRC_ITEMS_PROVIDER( m_pcb ) ); - m_drcDialog->SetUnconnectedProvider( new VECTOR_DRC_ITEMS_PROVIDER( &m_unconnected ) ); - m_drcDialog->SetFootprintsProvider( new VECTOR_DRC_ITEMS_PROVIDER( &m_footprints ) ); - - m_drcDialog->UpdateDisplayedCounts(); + m_drcDialog->SetUnconnectedProvider( new RATSNEST_DRC_ITEMS_PROVIDER( m_pcbEditorFrame, + &m_unconnected ) ); + m_drcDialog->SetFootprintsProvider( new VECTOR_DRC_ITEMS_PROVIDER( m_pcbEditorFrame, + &m_footprints ) ); } } @@ -546,8 +531,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg ) FmtVal( g.m_TrackClearance ) ); - addMarkerToPcb( fillMarker( DRCE_NETCLASS_CLEARANCE, msg, m_currentMarker ) ); - m_currentMarker = nullptr; + addMarkerToPcb( new MARKER_PCB( DRCE_NETCLASS_CLEARANCE, msg ) ); ret = false; } #endif @@ -560,7 +544,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg ) FmtVal( g.m_TrackMinWidth ) ); - addMarkerToPcb( m_markerFactory.NewMarker( DRCE_NETCLASS_TRACKWIDTH, msg ) ); + addMarkerToPcb( new MARKER_PCB( DRCE_NETCLASS_TRACKWIDTH, msg ) ); ret = false; } @@ -572,7 +556,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg ) FmtVal( g.m_ViasMinSize ) ); - addMarkerToPcb( m_markerFactory.NewMarker( DRCE_NETCLASS_VIASIZE, msg ) ); + addMarkerToPcb( new MARKER_PCB( DRCE_NETCLASS_VIASIZE, msg ) ); ret = false; } @@ -584,7 +568,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg ) FmtVal( g.m_ViasMinDrill ) ); - addMarkerToPcb( m_markerFactory.NewMarker( DRCE_NETCLASS_VIADRILLSIZE, msg ) ); + addMarkerToPcb( new MARKER_PCB( DRCE_NETCLASS_VIADRILLSIZE, msg ) ); ret = false; } @@ -595,7 +579,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg ) FmtVal( nc->GetuViaDiameter() ), FmtVal( g.m_MicroViasMinSize ) ); - addMarkerToPcb( m_markerFactory.NewMarker( DRCE_NETCLASS_uVIASIZE, msg ) ); + addMarkerToPcb( new MARKER_PCB( DRCE_NETCLASS_uVIASIZE, msg ) ); ret = false; } @@ -606,7 +590,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg ) FmtVal( nc->GetuViaDrill() ), FmtVal( g.m_MicroViasMinDrill ) ); - addMarkerToPcb( m_markerFactory.NewMarker( DRCE_NETCLASS_uVIADRILLSIZE, msg ) ); + addMarkerToPcb( new MARKER_PCB( DRCE_NETCLASS_uVIADRILLSIZE, msg ) ); ret = false; } @@ -666,12 +650,7 @@ void DRC::testPad2Pad() { int x_limit = pad->GetClearance() + pad->GetBoundingRadius() + pad->GetPosition().x; - if( !doPadToPadsDrc( pad, &pad, listEnd, max_size + x_limit ) ) - { - wxASSERT( m_currentMarker ); - addMarkerToPcb ( m_currentMarker ); - m_currentMarker = nullptr; - } + doPadToPadsDrc( pad, &pad, listEnd, max_size + x_limit ); } } @@ -791,14 +770,7 @@ void DRC::testTracks( wxWindow *aActiveWindow, bool aShowProgressBar ) } // Test new segment against tracks and pads, optionally against copper zones - if( !doTrackDrc( *seg_it, seg_it + 1, m_pcb->Tracks().end(), m_doZonesTest ) ) - { - if( m_currentMarker ) - { - addMarkerToPcb ( m_currentMarker ); - m_currentMarker = nullptr; - } - } + doTrackDrc( *seg_it, seg_it + 1, m_pcb->Tracks().end(), m_doZonesTest ); } if( progressDialog ) @@ -863,13 +835,13 @@ void DRC::testZones() if( ( netcode < 0 ) || pads_in_net == 0 ) { wxPoint markerPos = zone->GetPosition(); - addMarkerToPcb( m_markerFactory.NewMarker( markerPos, zone, - DRCE_SUSPICIOUS_NET_FOR_ZONE_OUTLINE ) ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_SUSPICIOUS_NET_FOR_ZONE_OUTLINE, + markerPos, zone ) ); } } // Test copper areas outlines, and create markers when needed - TestZoneToZoneOutline( NULL, true ); + TestZoneToZoneOutlines(); } @@ -899,8 +871,10 @@ void DRC::testKeepoutAreas() SEG trackSeg( segm->GetStart(), segm->GetEnd() ); if( area->Outline()->Distance( trackSeg, segm->GetWidth() ) == 0 ) - addMarkerToPcb( - m_markerFactory.NewMarker( segm, area, DRCE_TRACK_INSIDE_KEEPOUT ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_INSIDE_KEEPOUT, + getLocation( segm, area ), segm, area ) ); + } } else if( segm->Type() == PCB_VIA_T ) { @@ -913,8 +887,10 @@ void DRC::testKeepoutAreas() continue; if( area->Outline()->Distance( segm->GetPosition() ) < segm->GetWidth()/2 ) - addMarkerToPcb( - m_markerFactory.NewMarker( segm, area, DRCE_VIA_INSIDE_KEEPOUT ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_VIA_INSIDE_KEEPOUT, + getLocation( segm, area ), segm, area ) ); + } } } // Test pads: TODO @@ -1034,11 +1010,17 @@ void DRC::testCopperDrawItem( DRAWSEGMENT* aItem ) if( trackAsSeg.Distance( itemSeg ) < minDist ) { if( track->Type() == PCB_VIA_T ) - addMarkerToPcb( m_markerFactory.NewMarker( - track, aItem, itemSeg, DRCE_VIA_NEAR_COPPER ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_VIA_NEAR_COPPER, + getLocation( track, aItem, itemSeg ), + track, aItem ) ); + } else - addMarkerToPcb( m_markerFactory.NewMarker( - track, aItem, itemSeg, DRCE_TRACK_NEAR_COPPER ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_COPPER, + getLocation( track, aItem, itemSeg ), + track, aItem ) ); + } break; } } @@ -1061,7 +1043,8 @@ void DRC::testCopperDrawItem( DRAWSEGMENT* aItem ) { if( padOutline.Distance( itemSeg, itemWidth ) == 0 ) { - addMarkerToPcb( m_markerFactory.NewMarker( pad, aItem, DRCE_PAD_NEAR_COPPER ) ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_PAD_NEAR_COPPER, + pad->GetPosition(), pad, aItem ) ); break; } } @@ -1108,11 +1091,17 @@ void DRC::testCopperTextItem( BOARD_ITEM* aTextItem ) if( trackAsSeg.Distance( textSeg ) < minDist ) { if( track->Type() == PCB_VIA_T ) - addMarkerToPcb( m_markerFactory.NewMarker( - track, aTextItem, textSeg, DRCE_VIA_NEAR_COPPER ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_VIA_NEAR_COPPER, + getLocation( track, aTextItem, textSeg ), + track, aTextItem ) ); + } else - addMarkerToPcb( m_markerFactory.NewMarker( - track, aTextItem, textSeg, DRCE_TRACK_NEAR_COPPER ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_COPPER, + getLocation( track, aTextItem, textSeg ), + track, aTextItem ) ); + } break; } } @@ -1143,7 +1132,8 @@ void DRC::testCopperTextItem( BOARD_ITEM* aTextItem ) if( padOutline.Distance( textSeg, 0 ) <= minDist ) { - addMarkerToPcb( m_markerFactory.NewMarker( pad, aTextItem, DRCE_PAD_NEAR_COPPER ) ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_PAD_NEAR_COPPER, + pad->GetPosition(), pad, aTextItem ) ); break; } } @@ -1159,7 +1149,7 @@ void DRC::testOutline() if( !m_pcb->GetBoardPolygonOutlines( m_board_outlines, nullptr, &error_loc ) ) { - addMarkerToPcb( m_markerFactory.NewMarker( error_loc, m_pcb, DRCE_INVALID_OUTLINE ) ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_INVALID_OUTLINE, error_loc, m_pcb ) ); return; } } @@ -1175,8 +1165,8 @@ void DRC::testDisabledLayers() disabledLayers &= LSET::AllCuMask(); auto createMarker = [&]( BOARD_ITEM* aItem ) { - addMarkerToPcb( m_markerFactory.NewMarker( - aItem->GetPosition(), aItem, DRCE_DISABLED_LAYER_ITEM ) ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_DISABLED_LAYER_ITEM, + aItem->GetPosition(), aItem ) ); }; for( auto track : board->Tracks() ) @@ -1187,7 +1177,8 @@ void DRC::testDisabledLayers() for( auto module : board->Modules() ) { - module->RunOnChildren( [&]( BOARD_ITEM* aItem ) + module->RunOnChildren( + [&]( BOARD_ITEM* aItem ) { if( disabledLayers.test( aItem->GetLayer() ) ) createMarker( aItem ); @@ -1274,7 +1265,8 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li if( !checkClearancePadToPad( aRefPad, &dummypad ) ) { // here we have a drc error on pad! - m_currentMarker = m_markerFactory.NewMarker( pad, aRefPad, DRCE_HOLE_NEAR_PAD ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_HOLE_NEAR_PAD, + pad->GetPosition(), pad, aRefPad ) ); return false; } } @@ -1290,7 +1282,8 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li if( !checkClearancePadToPad( pad, &dummypad ) ) { // here we have a drc error on aRefPad! - m_currentMarker = m_markerFactory.NewMarker( aRefPad, pad, DRCE_HOLE_NEAR_PAD ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_HOLE_NEAR_PAD, + aRefPad->GetPosition(), aRefPad, pad ) ); return false; } } @@ -1325,7 +1318,8 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li if( !checkClearancePadToPad( aRefPad, pad ) ) { // here we have a drc error! - m_currentMarker = m_markerFactory.NewMarker( aRefPad, pad, DRCE_PAD_NEAR_PAD1 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_PAD_NEAR_PAD1, + aRefPad->GetPosition(), aRefPad, pad ) ); return false; } } @@ -1336,10 +1330,9 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li void DRC::doOverlappingCourtyardsDrc() { - DRC_COURTYARD_OVERLAP drc_overlap( - m_markerFactory, [&]( MARKER_PCB* aMarker ) { addMarkerToPcb( aMarker ); } ); + DRC_COURTYARD_OVERLAP drc_overlap( [&]( MARKER_PCB* aMarker ) { addMarkerToPcb( aMarker ); } ); - drc_overlap.RunDRC( *m_pcb ); + drc_overlap.RunDRC( userUnits(), *m_pcb ); } @@ -1400,4 +1393,58 @@ void DRC::setTransitions() } +const int EPSILON = Mils2iu( 5 ); + + +wxPoint DRC::getLocation( TRACK* aTrack, ZONE_CONTAINER* aConflictZone ) const +{ + SHAPE_POLY_SET* conflictOutline; + + if( aConflictZone->IsFilled() ) + conflictOutline = const_cast( &aConflictZone->GetFilledPolysList() ); + else + conflictOutline = aConflictZone->Outline(); + + wxPoint pt1 = aTrack->GetPosition(); + wxPoint pt2 = aTrack->GetEnd(); + + // If the mid-point is in the zone, then that's a fine place for the marker + if( conflictOutline->Distance( ( pt1 + pt2 ) / 2 ) == 0 ) + return ( pt1 + pt2 ) / 2; + + // Otherwise do a binary search for a "good enough" marker location + else + { + while( GetLineLength( pt1, pt2 ) > EPSILON ) + { + if( conflictOutline->Distance( pt1 ) < conflictOutline->Distance( pt2 ) ) + pt2 = ( pt1 + pt2 ) / 2; + else + pt1 = ( pt1 + pt2 ) / 2; + } + + // Once we're within EPSILON pt1 and pt2 are "equivalent" + return pt1; + } +} + + +wxPoint DRC::getLocation( TRACK* aTrack, BOARD_ITEM* aConflitItem, const SEG& aConflictSeg ) const +{ + wxPoint pt1 = aTrack->GetPosition(); + wxPoint pt2 = aTrack->GetEnd(); + + // Do a binary search along the track for a "good enough" marker location + while( GetLineLength( pt1, pt2 ) > EPSILON ) + { + if( aConflictSeg.Distance( pt1 ) < aConflictSeg.Distance( pt2 ) ) + pt2 = ( pt1 + pt2 ) / 2; + else + pt1 = ( pt1 + pt2 ) / 2; + } + + // Once we're within EPSILON pt1 and pt2 are "equivalent" + return pt1; +} + diff --git a/pcbnew/drc/drc.h b/pcbnew/drc/drc.h index 7660c700b7..4baa4cb4ed 100644 --- a/pcbnew/drc/drc.h +++ b/pcbnew/drc/drc.h @@ -27,12 +27,12 @@ #include #include +#include #include #include #include #include #include -#include #define OK_DRC 0 #define BAD_DRC 1 @@ -43,24 +43,16 @@ // and using #define that shows each numerical value helps for debug. /// DRC error codes: -#define DRCE_ 1 // not used yet +#define DRCE_FIRST 2 #define DRCE_UNCONNECTED_ITEMS 2 ///< items are unconnected #define DRCE_TRACK_NEAR_THROUGH_HOLE 3 ///< thru hole is too close to track #define DRCE_TRACK_NEAR_PAD 4 ///< pad too close to track #define DRCE_TRACK_NEAR_VIA 5 ///< track too close to via #define DRCE_VIA_NEAR_VIA 6 ///< via too close to via #define DRCE_VIA_NEAR_TRACK 7 ///< via too close to track -#define DRCE_TRACK_ENDS1 8 ///< 2 parallel track segments too close: fine start point test -#define DRCE_TRACK_ENDS2 9 ///< 2 parallel track segments too close: fine start point test -#define DRCE_TRACK_ENDS3 10 ///< 2 parallel track segments too close: fine end point test -#define DRCE_TRACK_ENDS4 11 ///< 2 parallel track segments too close: fine end point test +#define DRCE_TRACK_ENDS 8 ///< track ends are too close #define DRCE_TRACK_SEGMENTS_TOO_CLOSE 12 ///< 2 parallel track segments too close: segm ends between segref ends #define DRCE_TRACKS_CROSSING 13 ///< tracks are crossing -#define DRCE_ENDS_PROBLEM1 14 ///< track ends are too close -#define DRCE_ENDS_PROBLEM2 15 ///< track ends are too close -#define DRCE_ENDS_PROBLEM3 16 ///< track ends are too close -#define DRCE_ENDS_PROBLEM4 17 ///< track ends are too close -#define DRCE_ENDS_PROBLEM5 18 ///< track ends are too close #define DRCE_PAD_NEAR_PAD1 19 ///< pad too close to pad #define DRCE_VIA_HOLE_BIGGER 20 ///< via's hole is bigger than its diameter #define DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR 21 ///< micro via's layer pair incorrect (layers must be adjacent) @@ -110,6 +102,8 @@ #define DRCE_ZERO_LENGTH_TRACK 64 #define DRCE_TRACK_IN_PAD 65 +#define DRCE_LAST 65 + class PCB_EDIT_FRAME; class DIALOG_DRC_CONTROL; @@ -163,8 +157,6 @@ private: bool m_testFootprints; // Test footprints against schematic int m_severities; // Severities of DRC violations to display - MARKER_PCB* m_currentMarker; - /* In DRC functions, many calculations are using coordinates relative * to the position of the segment under test (segm to segm DRC, segm to pad DRC * Next variables store coordinates relative to the start point of this segment @@ -192,7 +184,6 @@ private: BOARD* m_pcb; SHAPE_POLY_SET m_board_outlines; ///< The board outline including cutouts DIALOG_DRC_CONTROL* m_drcDialog; - DRC_MARKER_FACTORY m_markerFactory; ///< Class that generates markers DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs DRC_LIST m_footprints; ///< list of footprint warnings, as DRC_ITEMs @@ -208,11 +199,19 @@ private: */ void updatePointers(); + EDA_UNITS userUnits() const { return m_pcbEditorFrame->GetUserUnits(); } + /** * Adds a DRC marker to the PCB through the COMMIT mechanism. */ void addMarkerToPcb( MARKER_PCB* aMarker ); + /** + * Fetches a reasonable point for marking a violoation between two non-point objects. + */ + wxPoint getLocation( TRACK* aTrack, ZONE_CONTAINER* aConflictZone ) const; + wxPoint getLocation( TRACK* aTrack, BOARD_ITEM* aConflitItem, const SEG& aConflictSeg ) const; + //---------------------------------------------- /** @@ -289,7 +288,7 @@ private: * @return bool - true if no problems, else false and m_currentMarker is * filled in with the problem information. */ - bool doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterator aEndIt, + void doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterator aEndIt, bool aTestZones ); /** @@ -355,13 +354,9 @@ public: /** * Tests whether distance between zones complies with the DRC rules. * - * @param aZone: zone to compare with other zones, or if NULL then - * all zones are compared to all others. - * @param aCreateMarkers: if true create DRC markers. - * False: do not create markers. only fing drc errors * @return Errors count */ - int TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ); + int TestZoneToZoneOutlines(); /** * Test the board footprints against a netlist. Will report DRCE_MISSING_FOOTPRINT, diff --git a/pcbnew/drc/drc_clearance_test_functions.cpp b/pcbnew/drc/drc_clearance_test_functions.cpp index 04930d0ae5..5219a8062b 100644 --- a/pcbnew/drc/drc_clearance_test_functions.cpp +++ b/pcbnew/drc/drc_clearance_test_functions.cpp @@ -107,50 +107,19 @@ bool poly2segmentDRC( wxPoint* aTref, int aTrefCount, wxPoint aSegStart, wxPoint } -#define PUSH_NEW_MARKER_3( a, b, c ) push_back( m_markerFactory.NewMarker( a, b, c ) ) -#define PUSH_NEW_MARKER_4( a, b, c, d ) push_back( m_markerFactory.NewMarker( a, b, c, d ) ) - - -bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterator aEndIt, +void DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterator aEndIt, bool aTestZones ) { TRACK* track; wxPoint delta; // length on X and Y axis of segments wxPoint shape_pos; - std::vector markers; - - auto commitMarkers = [&]() - { - BOARD_COMMIT commit( m_pcbEditorFrame ); - - for( MARKER_PCB* marker : markers ) - commit.Add( marker ); - - commit.Push( wxEmptyString, false, false ); - }; - - // Returns false if we should return false from call site, or true to continue - auto handleNewMarker = [&]() -> bool - { - if( !m_reportAllTrackErrors ) - { - if( markers.size() > 0 ) - commitMarkers(); - - return false; - } - else - return true; - }; - NETCLASSPTR netclass = aRefSeg->GetNetClass(); BOARD_DESIGN_SETTINGS& dsnSettings = m_pcb->GetDesignSettings(); - /* In order to make some calculations more easier or faster, - * pads and tracks coordinates will be made relative to the reference segment origin - */ - wxPoint origin = aRefSeg->GetStart(); // origin will be the origin of other coordinates + // In order to make some calculations more easier or faster, pads and tracks + // coordinates will be made relative to the reference segment origin + wxPoint origin = aRefSeg->GetStart(); m_segmEnd = delta = aRefSeg->GetEnd() - origin; m_segmAngle = 0; @@ -168,43 +137,34 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( aRefSeg->Type() == PCB_VIA_T ) { VIA *refvia = static_cast( aRefSeg ); - wxPoint refviaPos = refvia->GetPosition(); // test if the via size is smaller than minimum if( refvia->GetViaType() == VIATYPE::MICROVIA ) { if( refvia->GetWidth() < dsnSettings.m_MicroViasMinSize ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_TOO_SMALL_MICROVIA ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TOO_SMALL_MICROVIA, + refvia->GetPosition(), refvia ) ); } if( refvia->GetDrillValue() < dsnSettings.m_MicroViasMinDrill ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_TOO_SMALL_MICROVIA_DRILL ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TOO_SMALL_MICROVIA_DRILL, + refvia->GetPosition(), refvia ) ); } } else { if( refvia->GetWidth() < dsnSettings.m_ViasMinSize ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_TOO_SMALL_VIA ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TOO_SMALL_VIA, + refvia->GetPosition(), refvia ) ); } if( refvia->GetDrillValue() < dsnSettings.m_ViasMinDrill ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_TOO_SMALL_VIA_DRILL ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TOO_SMALL_VIA_DRILL, + refvia->GetPosition(), refvia ) ); } } @@ -213,28 +173,22 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato // and a default via hole can be bigger than some vias sizes if( refvia->GetDrillValue() > refvia->GetWidth() ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_VIA_HOLE_BIGGER ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_VIA_HOLE_BIGGER, + refvia->GetPosition(), refvia ) ); } // test if the type of via is allowed due to design rules if( refvia->GetViaType() == VIATYPE::MICROVIA && !dsnSettings.m_MicroViasAllowed ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_MICRO_VIA_NOT_ALLOWED ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_MICRO_VIA_NOT_ALLOWED, + refvia->GetPosition(), refvia ) ); } // test if the type of via is allowed due to design rules if( refvia->GetViaType() == VIATYPE::BLIND_BURIED && !dsnSettings.m_BlindBuriedViaAllowed ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_BURIED_VIA_NOT_ALLOWED ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_BURIED_VIA_NOT_ALLOWED, + refvia->GetPosition(), refvia ) ); } // For microvias: test if they are blind vias and only between 2 layers @@ -257,10 +211,8 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( err ) { - markers.PUSH_NEW_MARKER_3( refviaPos, refvia, DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR, + refvia->GetPosition(), refvia ) ); } } @@ -271,10 +223,8 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato { wxPoint refsegMiddle = ( aRefSeg->GetStart() + aRefSeg->GetEnd() ) / 2; - markers.PUSH_NEW_MARKER_3( refsegMiddle, aRefSeg, DRCE_TOO_SMALL_TRACK_WIDTH ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TOO_SMALL_TRACK_WIDTH, + refsegMiddle, aRefSeg ) ); } } @@ -328,17 +278,20 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato dummypad.SetSize( pad->GetDrillSize() ); dummypad.SetPosition( pad->GetPosition() ); dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ? - PAD_SHAPE_OVAL : PAD_SHAPE_CIRCLE ); + PAD_SHAPE_OVAL : + PAD_SHAPE_CIRCLE ); dummypad.SetOrientation( pad->GetOrientation() ); m_padToTestPos = dummypad.GetPosition() - origin; if( !checkClearanceSegmToPad( &dummypad, ref_seg_width, ref_seg_clearance ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, pad, padSeg, DRCE_TRACK_NEAR_THROUGH_HOLE ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_THROUGH_HOLE, + getLocation( aRefSeg, pad, padSeg ), + aRefSeg, pad ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } continue; @@ -357,10 +310,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( !checkClearanceSegmToPad( pad, ref_seg_width, segToPadClearance ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, pad, padSeg, DRCE_TRACK_NEAR_PAD ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_PAD, + getLocation( aRefSeg, pad, padSeg ), + aRefSeg, pad ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } } @@ -403,17 +358,17 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato { delta = track->GetEnd() - track->GetStart(); segStartPoint = aRefSeg->GetStart() - track->GetStart(); - wxPoint pos = aRefSeg->GetPosition(); if( track->Type() == PCB_VIA_T ) { // Test distance between two vias, i.e. two circles, trivial case if( EuclideanNorm( segStartPoint ) < w_dist ) { - markers.PUSH_NEW_MARKER_4( pos, aRefSeg, track, DRCE_VIA_NEAR_VIA ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_VIA_NEAR_VIA, + aRefSeg->GetPosition(), aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } else // test via to segment @@ -427,10 +382,11 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( !checkMarginToCircle( segStartPoint, w_dist, delta.x ) ) { - markers.PUSH_NEW_MARKER_4( pos, aRefSeg, track, DRCE_VIA_NEAR_TRACK ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_VIA_NEAR_TRACK, + aRefSeg->GetPosition(), aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } @@ -453,10 +409,11 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) ) continue; - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_TRACK_NEAR_VIA ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_VIA, + getLocation( aRefSeg, track, seg ), aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } /* We have changed axis: @@ -481,18 +438,22 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato // Fine test : we consider the rounded shape of each end of the track segment: if( segStartPoint.x >= 0 && segStartPoint.x <= m_segmLength ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_TRACK_ENDS1 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } if( !checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_TRACK_ENDS2 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } @@ -504,18 +465,22 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato // Fine test : we consider the rounded shape of the ends if( segEndPoint.x >= 0 && segEndPoint.x <= m_segmLength ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_TRACK_ENDS3 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } if( !checkMarginToCircle( segEndPoint, w_dist, m_segmLength ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_TRACK_ENDS4 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } @@ -526,10 +491,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato // handled) // X.............X // O--REF--+ - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_TRACK_SEGMENTS_TOO_CLOSE ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_SEGMENTS_TOO_CLOSE, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } else if( segStartPoint.x == segEndPoint.x ) // perpendicular segments @@ -543,29 +510,32 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( ( segStartPoint.y < 0 ) && ( segEndPoint.y > 0 ) ) { - MARKER_PCB* m = m_markerFactory.NewMarker( aRefSeg, track, seg, - DRCE_TRACKS_CROSSING ); - m->SetPosition( wxPoint( track->GetStart().x, aRefSeg->GetStart().y ) ); - markers.push_back( m ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACKS_CROSSING, + wxPoint( track->GetStart().x, aRefSeg->GetStart().y ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } // At this point the drc error is due to an end near a reference segm end if( !checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_ENDS_PROBLEM1 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } if( !checkMarginToCircle( segEndPoint, w_dist, m_segmLength ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_ENDS_PROBLEM2 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } else // segments quelconques entre eux @@ -592,24 +562,23 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( !checkLine( segStartPoint, segEndPoint ) ) { wxPoint failurePoint; - MARKER_PCB* m; if( SegmentIntersectsSegment( aRefSeg->GetStart(), aRefSeg->GetEnd(), track->GetStart(), track->GetEnd(), &failurePoint ) ) { - m = m_markerFactory.NewMarker( aRefSeg, track, seg, DRCE_TRACKS_CROSSING ); - m->SetPosition( failurePoint ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACKS_CROSSING, + failurePoint, aRefSeg, track ) ); } else { - m = m_markerFactory.NewMarker( aRefSeg, track, seg, DRCE_ENDS_PROBLEM3 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); } - markers.push_back( m ); - - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } else // The drc error is due to the starting or the ending point of the reference segment { @@ -635,18 +604,22 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato if( !checkMarginToCircle( relStartPos, w_dist, delta.x ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_ENDS_PROBLEM4 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } if( !checkMarginToCircle( relEndPos, w_dist, delta.x ) ) { - markers.PUSH_NEW_MARKER_4( aRefSeg, track, seg, DRCE_ENDS_PROBLEM5 ); + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_ENDS, + getLocation( aRefSeg, track, seg ), + aRefSeg, track ) ); - if( !handleNewMarker() ) - return false; + if( !m_reportAllTrackErrors ) + return; } } } @@ -682,7 +655,10 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato // (1 micron) #define THRESHOLD_DIST Millimeter2iu( 0.001 ) if( error > THRESHOLD_DIST ) - addMarkerToPcb( m_markerFactory.NewMarker( aRefSeg, zone, DRCE_TRACK_NEAR_ZONE ) ); + { + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_ZONE, + getLocation( aRefSeg, zone ), aRefSeg, zone ) ); + } } } @@ -725,25 +701,11 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACKS::iterator aStartIt, TRACKS::iterato // Best-efforts search for edge segment BOARD::IterateForward( m_pcb->Drawings(), inspector, nullptr, types ); - if( edge ) - markers.PUSH_NEW_MARKER_4( (wxPoint) pt, aRefSeg, edge, DRCE_TRACK_NEAR_EDGE ); - else - markers.PUSH_NEW_MARKER_3( (wxPoint) pt, aRefSeg, DRCE_TRACK_NEAR_EDGE ); - - if( !handleNewMarker() ) - return false; + addMarkerToPcb( new MARKER_PCB( userUnits(), DRCE_TRACK_NEAR_EDGE, (wxPoint) pt, + aRefSeg, edge ) ); } } } - - - if( markers.size() > 0 ) - { - commitMarkers(); - return false; - } - else - return true; } diff --git a/pcbnew/drc/drc_item.cpp b/pcbnew/drc/drc_item.cpp index 0055e0bedd..681725ae71 100644 --- a/pcbnew/drc/drc_item.cpp +++ b/pcbnew/drc/drc_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2015-2018 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015-2020 KiCad Developers, see change_log.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 @@ -49,15 +49,7 @@ wxString DRC_ITEM::GetErrorText() const return wxString( _( "Via too close to via" ) ); case DRCE_VIA_NEAR_TRACK: return wxString( _( "Via too close to track" ) ); - case DRCE_TRACK_ENDS1: - case DRCE_TRACK_ENDS2: - case DRCE_TRACK_ENDS3: - case DRCE_TRACK_ENDS4: - case DRCE_ENDS_PROBLEM1: - case DRCE_ENDS_PROBLEM2: - case DRCE_ENDS_PROBLEM3: - case DRCE_ENDS_PROBLEM4: - case DRCE_ENDS_PROBLEM5: + case DRCE_TRACK_ENDS: return wxString( _( "Two track ends too close" ) ); case DRCE_TRACK_SEGMENTS_TOO_CLOSE: return wxString( _( "Two parallel track segments too close" ) ); @@ -108,17 +100,17 @@ wxString DRC_ITEM::GetErrorText() const // use < since this is text ultimately embedded in HTML case DRCE_NETCLASS_TRACKWIDTH: - return wxString( _( "NetClass Track Width < global limit" ) ); + return wxString( _( "NetClass Track Width < global limit" ) ); case DRCE_NETCLASS_CLEARANCE: - return wxString( _( "NetClass Clearance < global limit" ) ); + return wxString( _( "NetClass Clearance < global limit" ) ); case DRCE_NETCLASS_VIASIZE: - return wxString( _( "NetClass Via Dia < global limit" ) ); + return wxString( _( "NetClass Via Dia < global limit" ) ); case DRCE_NETCLASS_VIADRILLSIZE: - return wxString( _( "NetClass Via Drill < global limit" ) ); + return wxString( _( "NetClass Via Drill < global limit" ) ); case DRCE_NETCLASS_uVIASIZE: - return wxString( _( "NetClass uVia Dia < global limit" ) ); + return wxString( _( "NetClass uVia Dia < global limit" ) ); case DRCE_NETCLASS_uVIADRILLSIZE: - return wxString( _( "NetClass uVia Drill < global limit" ) ); + return wxString( _( "NetClass uVia Drill < global limit" ) ); case DRCE_VIA_INSIDE_KEEPOUT: return wxString( _( "Via inside keepout area" ) ); @@ -168,7 +160,7 @@ wxString DRC_ITEM::GetErrorText() const return wxString( _( "Remove track inside pad" ) ); default: - return wxString::Format( _( "Unknown DRC error code %d" ), m_ErrorCode ); + return wxEmptyString; } } @@ -194,39 +186,23 @@ wxString DRC_ITEM::ShowHtml( EDA_UNITS aUnits ) const errText.Replace( wxT(">"), wxT(">") ); - if( m_noCoordinate ) + if( m_hasSecondItem ) { - // omit the coordinate, a NETCLASS has no location - return wxString::Format( wxT( "%s
   %s" ), - errText, - mainText ); - } - else if( m_hasSecondItem ) - { - wxString auxText = m_AuxiliaryText; + wxString auxText = m_AuxText; auxText.Replace( wxT("<"), wxT("<") ); auxText.Replace( wxT(">"), wxT(">") ); // an html fragment for the entire message in the listbox. feel free // to add color if you want: - return wxString::Format( wxT( "%s
" - "   %s: %s
" - "   %s: %s" ), + return wxString::Format( wxT( "%s
   %s
   %s" ), errText, - m_mainItemUuid.AsString(), - ShowCoord( aUnits, m_MainPosition ), mainText, - m_auxItemUuid.AsString(), - ShowCoord( aUnits, m_AuxiliaryPosition ), auxText ); } else { - return wxString::Format( wxT( "%s
" - "   %s: %s" ), + return wxString::Format( wxT( "%s
   %s" ), errText, - m_mainItemUuid.AsString(), - ShowCoord( aUnits, m_MainPosition ), mainText ); } } @@ -241,8 +217,8 @@ wxString DRC_ITEM::ShowReport( EDA_UNITS aUnits ) const GetErrorText(), ShowCoord( aUnits, m_MainPosition ), m_MainText, - ShowCoord( aUnits, m_AuxiliaryPosition ), - m_AuxiliaryText ); + ShowCoord( aUnits, m_AuxPosition ), + m_AuxText ); } else { diff --git a/pcbnew/drc/drc_marker_factory.cpp b/pcbnew/drc/drc_marker_factory.cpp deleted file mode 100644 index 98ea72f969..0000000000 --- a/pcbnew/drc/drc_marker_factory.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2010 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2018-2019 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 - */ - -#include "drc_marker_factory.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -const int EPSILON = Mils2iu( 5 ); - - -DRC_MARKER_FACTORY::DRC_MARKER_FACTORY() -{ - SetUnits( EDA_UNITS::MILLIMETRES ); -} - - -void DRC_MARKER_FACTORY::SetUnitsProvider( UNITS_PROVIDER aUnitsProvider ) -{ - m_units_provider = aUnitsProvider; -} - - -void DRC_MARKER_FACTORY::SetUnits( EDA_UNITS aUnits ) -{ - m_units_provider = [=]() { return aUnits; }; -} - - -MARKER_PCB* DRC_MARKER_FACTORY::NewMarker( - TRACK* aTrack, ZONE_CONTAINER* aConflictZone, int aErrorCode ) const -{ - SHAPE_POLY_SET* conflictOutline; - - if( aConflictZone->IsFilled() ) - conflictOutline = const_cast( &aConflictZone->GetFilledPolysList() ); - else - conflictOutline = aConflictZone->Outline(); - - wxPoint markerPos; - wxPoint pt1 = aTrack->GetPosition(); - wxPoint pt2 = aTrack->GetEnd(); - - // If the mid-point is in the zone, then that's a fine place for the marker - if( conflictOutline->Distance( ( pt1 + pt2 ) / 2 ) == 0 ) - markerPos = ( pt1 + pt2 ) / 2; - - // Otherwise do a binary search for a "good enough" marker location - else - { - while( GetLineLength( pt1, pt2 ) > EPSILON ) - { - if( conflictOutline->Distance( pt1 ) < conflictOutline->Distance( pt2 ) ) - pt2 = ( pt1 + pt2 ) / 2; - else - pt1 = ( pt1 + pt2 ) / 2; - } - - // Once we're within EPSILON pt1 and pt2 are "equivalent" - markerPos = pt1; - } - - return new MARKER_PCB( getCurrentUnits(), aErrorCode, markerPos, aTrack, aTrack->GetPosition(), - aConflictZone, aConflictZone->GetPosition() ); -} - - -MARKER_PCB* DRC_MARKER_FACTORY::NewMarker( - TRACK* aTrack, BOARD_ITEM* aConflitItem, const SEG& aConflictSeg, int aErrorCode ) const -{ - wxPoint markerPos; - wxPoint pt1 = aTrack->GetPosition(); - wxPoint pt2 = aTrack->GetEnd(); - - // Do a binary search along the track for a "good enough" marker location - while( GetLineLength( pt1, pt2 ) > EPSILON ) - { - if( aConflictSeg.Distance( pt1 ) < aConflictSeg.Distance( pt2 ) ) - pt2 = ( pt1 + pt2 ) / 2; - else - pt1 = ( pt1 + pt2 ) / 2; - } - - // Once we're within EPSILON pt1 and pt2 are "equivalent" - markerPos = pt1; - - return new MARKER_PCB( getCurrentUnits(), aErrorCode, markerPos, aTrack, aTrack->GetPosition(), - aConflitItem, aConflitItem->GetPosition() ); -} - - -MARKER_PCB* DRC_MARKER_FACTORY::NewMarker( - D_PAD* aPad, BOARD_ITEM* aConflictItem, int aErrorCode ) const -{ - return new MARKER_PCB( getCurrentUnits(), aErrorCode, aPad->GetPosition(), aPad, - aPad->GetPosition(), aConflictItem, aConflictItem->GetPosition() ); -} - - -MARKER_PCB* DRC_MARKER_FACTORY::NewMarker( - const wxPoint& aPos, BOARD_ITEM* aItem, int aErrorCode ) const -{ - return new MARKER_PCB( - getCurrentUnits(), aErrorCode, aPos, aItem, aPos, nullptr, wxPoint() ); -} - - -MARKER_PCB* DRC_MARKER_FACTORY::NewMarker( - const wxPoint& aPos, BOARD_ITEM* aItem, BOARD_ITEM* bItem, int aErrorCode ) const -{ - return new MARKER_PCB( getCurrentUnits(), aErrorCode, aPos, aItem, aItem->GetPosition(), bItem, - bItem->GetPosition() ); -} - - -MARKER_PCB* DRC_MARKER_FACTORY::NewMarker( int aErrorCode, const wxString& aMessage ) const -{ - MARKER_PCB* marker = new MARKER_PCB( aErrorCode, wxPoint(), aMessage, wxPoint() ); - - marker->SetShowNoCoordinate(); - - return marker; -} diff --git a/pcbnew/drc/drc_marker_factory.h b/pcbnew/drc/drc_marker_factory.h deleted file mode 100644 index f3cf5d1aad..0000000000 --- a/pcbnew/drc/drc_marker_factory.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 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 DRC_DRC_MARKER_FACTORY__H -#define DRC_DRC_MARKER_FACTORY__H - - -#include -#include // for EDA_UNITS - - -class ZONE_CONTAINER; -class TRACK; -class D_PAD; -class SEG; - -/** - * Class that constructs DRC markers of various kinds - * with messages according to items and error code - */ -class DRC_MARKER_FACTORY -{ -public: - using UNITS_PROVIDER = std::function; - - DRC_MARKER_FACTORY(); - - /** - * Set the provider for the units (this will be called for each new - * marker constructed) - * @param aUnitsProvider a callable that returns the current units to use - */ - void SetUnitsProvider( UNITS_PROVIDER aUnitsProvider ); - - /** - * Set the units provider to a function returning a constant value. - * This is a shorthand for #SetUnitProvider. - */ - void SetUnits( EDA_UNITS aUnits ); - - /** - * Creates a marker on a track, via or pad. - * - * @param aTrack/aPad The reference item. - * @param aConflitItem Another item on the board which is in conflict with the - * reference item. - * @param aErrorCode An ID for the particular type of error that is being reported. - */ - MARKER_PCB* NewMarker( TRACK* aTrack, BOARD_ITEM* aConflitItem, const SEG& aConflictSeg, - int aErrorCode ) const; - - MARKER_PCB* NewMarker( TRACK* aTrack, ZONE_CONTAINER* aConflictZone, int aErrorCode ) const; - - MARKER_PCB* NewMarker( D_PAD* aPad, BOARD_ITEM* aConflictItem, int aErrorCode ) const; - - /** - * Creates a marker at a given location. - * - * @param aItem The reference item. - * @param aPos Usually the position of the item, but could be more specific for a zone. - * @param aErrorCode An ID for the particular type of error that is being reported. - */ - MARKER_PCB* NewMarker( const wxPoint& aPos, BOARD_ITEM* aItem, int aErrorCode ) const; - - MARKER_PCB* NewMarker( const wxPoint& aPos, BOARD_ITEM* aItem, BOARD_ITEM* bItem, - int aErrorCode ) const; - - /** - * Create a MARKER which will report on a generic problem with the board which is - * not geographically locatable. - */ - MARKER_PCB* NewMarker( int aErrorCode, const wxString& aMessage ) const; - -private: - EDA_UNITS getCurrentUnits() const - { - return m_units_provider(); - } - - UNITS_PROVIDER m_units_provider; -}; - -#endif // DRC_DRC_MARKER_FACTORY__H \ No newline at end of file diff --git a/pcbnew/drc/drc_provider.h b/pcbnew/drc/drc_provider.h index 04ecda0caa..7301e99e75 100644 --- a/pcbnew/drc/drc_provider.h +++ b/pcbnew/drc/drc_provider.h @@ -28,8 +28,6 @@ #include #include -#include - #include @@ -57,26 +55,26 @@ public: * Note: Board is non-const, as some DRC functions modify the board * (e.g. zone fill or polygon coalescing) */ - virtual bool RunDRC( BOARD& aBoard ) const = 0; + virtual bool RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) const = 0; protected: - DRC_PROVIDER( const DRC_MARKER_FACTORY& aMarkerMaker, MARKER_HANDLER aMarkerHandler ); - - /** - * Access to the stored reference to a marker constructor - */ - const DRC_MARKER_FACTORY& GetMarkerFactory() const; + DRC_PROVIDER( MARKER_HANDLER aMarkerHandler ) : + m_marker_handler( std::move( aMarkerHandler ) ) + { + } /** * Pass a given marker to the marker handler */ - void HandleMarker( std::unique_ptr aMarker ) const; + void HandleMarker( std::unique_ptr aMarker ) const + { + // The marker hander currently takes a raw pointer, + // but it also assumes ownership + m_marker_handler( aMarker.release() ); + } + private: - - /// A marker generator to make markers in the right context - const DRC_MARKER_FACTORY& m_marker_factory; - /// The handler for any generated markers MARKER_HANDLER m_marker_handler; }; diff --git a/pcbnew/drc/drc_tree_model.cpp b/pcbnew/drc/drc_tree_model.cpp index b7b710945e..645d88d994 100644 --- a/pcbnew/drc/drc_tree_model.cpp +++ b/pcbnew/drc/drc_tree_model.cpp @@ -24,7 +24,7 @@ #include #include - +#include #define WX_DATAVIEW_WINDOW_PADDING 6 @@ -56,7 +56,8 @@ BOARD_ITEM* DRC_TREE_MODEL::ToBoardItem( BOARD* aBoard, wxDataViewItem aItem ) } -DRC_TREE_MODEL::DRC_TREE_MODEL( wxDataViewCtrl* aView ) : +DRC_TREE_MODEL::DRC_TREE_MODEL( PCB_BASE_FRAME* aParentFrame, wxDataViewCtrl* aView ) : + m_parentFrame( aParentFrame ), m_view( aView ), m_drcItemsProvider( nullptr ) { @@ -69,10 +70,12 @@ DRC_TREE_MODEL::DRC_TREE_MODEL( wxDataViewCtrl* aView ) : DRC_TREE_MODEL::~DRC_TREE_MODEL() { delete m_drcItemsProvider; + + // m_tree is all std::unique_ptr based, so it will look after itself } -void DRC_TREE_MODEL::SetProvider( DRC_ITEMS_PROVIDER* aProvider ) +void DRC_TREE_MODEL::rebuildModel( DRC_ITEMS_PROVIDER* aProvider, int aSeverities ) { wxWindowUpdateLocker updateLock( m_view ); @@ -83,22 +86,33 @@ void DRC_TREE_MODEL::SetProvider( DRC_ITEMS_PROVIDER* aProvider ) Cleared(); - delete m_drcItemsProvider; - m_drcItemsProvider = aProvider; + if( aProvider != m_drcItemsProvider ) + { + delete m_drcItemsProvider; + m_drcItemsProvider = aProvider; + } + + wxASSERT( m_drcItemsProvider ); + + if( aSeverities != m_severities ) + m_severities = aSeverities; + + m_drcItemsProvider->SetSeverities( m_severities ); + m_tree.clear(); #define PUSH_NODE( p, item, type ) push_back( std::make_unique( p, item, type ) ) for( int i = 0; m_drcItemsProvider && i < m_drcItemsProvider->GetCount(); ++i ) { - const DRC_ITEM* drcItem = m_drcItemsProvider->GetItem( i ); + DRC_ITEM* drcItem = m_drcItemsProvider->GetItem( i ); m_tree.PUSH_NODE( nullptr, drcItem, DRC_TREE_NODE::MARKER ); DRC_TREE_NODE* node = m_tree.back().get(); node->m_Children.PUSH_NODE( node, drcItem, DRC_TREE_NODE::MAIN_ITEM ); - if( drcItem->HasSecondItem() ) + if( drcItem->GetAuxItemID() != niluuid ) node->m_Children.PUSH_NODE( node, drcItem, DRC_TREE_NODE::AUX_ITEM ); } @@ -119,6 +133,18 @@ void DRC_TREE_MODEL::SetProvider( DRC_ITEMS_PROVIDER* aProvider ) } +void DRC_TREE_MODEL::SetProvider( DRC_ITEMS_PROVIDER* aProvider ) +{ + rebuildModel( aProvider, m_severities ); +} + + +void DRC_TREE_MODEL::SetSeverities( int aSeverities ) +{ + rebuildModel( m_drcItemsProvider, aSeverities ); +} + + void DRC_TREE_MODEL::ExpandAll() { for( std::unique_ptr& markerNode : m_tree ) @@ -162,13 +188,30 @@ void DRC_TREE_MODEL::GetValue( wxVariant& aVariant, unsigned int aCol ) const { const DRC_TREE_NODE* node = ToNode( aItem ); - wxASSERT( node ); + const DRC_ITEM* drcItem = node->m_DrcItem; 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; + case DRC_TREE_NODE::MARKER: + { + auto& bds = m_parentFrame->GetBoard()->GetDesignSettings(); + bool excluded = drcItem->GetParent() && drcItem->GetParent()->IsExcluded(); + bool error = bds.m_DRCSeverities[ drcItem->GetErrorCode() ] == SEVERITY_ERROR; + wxString prefix = wxString::Format( wxT( "%s%s" ), + excluded ? _( "Excluded " ) : wxEmptyString, + error ? _( "Error: " ) : _( "Warning: " ) ); + + aVariant = prefix + drcItem->GetErrorText(); + } + break; + + case DRC_TREE_NODE::MAIN_ITEM: + aVariant = drcItem->GetMainText(); + break; + + case DRC_TREE_NODE::AUX_ITEM: + aVariant = drcItem->GetAuxiliaryText(); + break; } } @@ -184,18 +227,50 @@ bool DRC_TREE_MODEL::GetAttr( wxDataViewItem const& aItem, const DRC_TREE_NODE* node = ToNode( aItem ); wxASSERT( node ); - switch( node->m_Type ) + bool ret = false; + bool heading = node->m_Type == DRC_TREE_NODE::MARKER; + + if( heading ) { - 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; + aAttr.SetBold( true ); + ret = true; } - return false; + if( node->m_DrcItem->GetParent() && node->m_DrcItem->GetParent()->IsExcluded() ) + { + wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT ); + + if( KIGFX::COLOR4D( textColour ).GetBrightness() > 0.5 ) + aAttr.SetColour( textColour.ChangeLightness( heading ? 30 : 35 ) ); + else + aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) ); + + aAttr.SetItalic( true ); // Strikethrough would be better, if wxWidgets supported it + ret = true; + } + + return ret; } -void DRC_TREE_MODEL::DeleteCurrentItem() +void DRC_TREE_MODEL::ValueChanged( DRC_TREE_NODE* aNode ) +{ + if( aNode->m_Type == DRC_TREE_NODE::MAIN_ITEM || aNode->m_Type == DRC_TREE_NODE::AUX_ITEM ) + { + ValueChanged( aNode->m_Parent ); + } + + if( aNode->m_Type == DRC_TREE_NODE::MARKER ) + { + wxDataViewModel::ValueChanged( ToItem( aNode ), 0 ); + + for( auto & child : aNode->m_Children ) + wxDataViewModel::ValueChanged( ToItem( child.get() ), 0 ); + } +} + + +void DRC_TREE_MODEL::DeleteCurrentItem( bool aDeep ) { wxDataViewItem dataViewItem = m_view->GetCurrentItem(); DRC_TREE_NODE* tree_node = ToNode( dataViewItem ); @@ -211,10 +286,10 @@ void DRC_TREE_MODEL::DeleteCurrentItem() { if( m_drcItemsProvider->GetItem( i ) == drc_item ) { - m_drcItemsProvider->DeleteItem( i ); + m_drcItemsProvider->DeleteItem( i, aDeep ); m_tree.erase( m_tree.begin() + i ); - ItemDeleted( ToItem( nullptr ), dataViewItem ); + ItemDeleted( ToItem( tree_node->m_Parent ), dataViewItem ); break; } } diff --git a/pcbnew/drc/drc_tree_model.h b/pcbnew/drc/drc_tree_model.h index 0b4a968626..56c2cf9f3c 100644 --- a/pcbnew/drc/drc_tree_model.h +++ b/pcbnew/drc/drc_tree_model.h @@ -26,7 +26,7 @@ #define KICAD_DRC_TREE_MODEL_H #include -#include +#include #define WX_DATAVIEW_WINDOW_PADDING 6 @@ -41,7 +41,9 @@ class DRC_ITEMS_PROVIDER { public: - virtual int GetCount() = 0; + virtual void SetSeverities( int aSeverities ) = 0; + + virtual int GetCount( int aSeverity = -1 ) = 0; /** * Function GetItem @@ -50,15 +52,15 @@ public: * @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; + virtual 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. + * @param aIndex The 0 based index into the list of the desired item which is to be deleted. + * @param aDeep If true, the source item should be deleted as well as the filtered item. */ - virtual void DeleteItem( int aIndex ) = 0; + virtual void DeleteItem( int aIndex, bool aDeep ) = 0; /** * Function DeleteAllItems @@ -76,31 +78,78 @@ public: */ class BOARD_DRC_ITEMS_PROVIDER : public DRC_ITEMS_PROVIDER { - BOARD* m_board; +private: + BOARD* m_board; + + int m_severities; + std::vector m_filteredMarkers; public: BOARD_DRC_ITEMS_PROVIDER( BOARD* aBoard ) : - m_board( aBoard ) + m_board( aBoard ), + m_severities( 0 ) { } - int GetCount() override + void SetSeverities( int aSeverities ) override { - return m_board->GetMARKERCount(); + m_severities = aSeverities; + + BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings(); + + m_filteredMarkers.clear(); + + for( MARKER_PCB* marker : m_board->Markers() ) + { + int markerSeverity; + + if( marker->IsExcluded() ) + markerSeverity = SEVERITY_EXCLUSION; + else + markerSeverity = bds.GetSeverity( marker->GetReporter().GetErrorCode() ); + + if( markerSeverity & m_severities ) + m_filteredMarkers.push_back( marker ); + } } - const DRC_ITEM* GetItem( int aIndex ) override + int GetCount( int aSeverity = -1 ) override { - const MARKER_PCB* marker = m_board->GetMARKER( aIndex ); + if( aSeverity < 0 ) + return m_filteredMarkers.size(); + + int count = 0; + BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings(); + + for( MARKER_PCB* marker : m_board->Markers() ) + { + int markerSeverity; + + if( marker->IsExcluded() ) + markerSeverity = SEVERITY_EXCLUSION; + else + markerSeverity = bds.GetSeverity( marker->GetReporter().GetErrorCode() ); + + if( markerSeverity == aSeverity ) + count++; + } + + return count; + } + + DRC_ITEM* GetItem( int aIndex ) override + { + MARKER_PCB* marker = m_filteredMarkers[ aIndex ]; return marker ? &marker->GetReporter() : nullptr; } - void DeleteItem( int aIndex ) override + void DeleteItem( int aIndex, bool aDeep ) override { - MARKER_PCB* marker = m_board->GetMARKER( aIndex ); + MARKER_PCB* marker = m_filteredMarkers[ aIndex ]; + m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex ); - if( marker ) + if( aDeep ) m_board->Delete( marker ); } @@ -119,59 +168,128 @@ public: */ class VECTOR_DRC_ITEMS_PROVIDER : public DRC_ITEMS_PROVIDER { - std::vector* m_vector; + PCB_BASE_FRAME* m_frame; + std::vector* m_sourceVector; // owns its DRC_ITEMs + + int m_severities; + std::vector m_filteredVector; // does not own its DRC_ITEMs public: - VECTOR_DRC_ITEMS_PROVIDER( std::vector* aList ) : - m_vector( aList ) + VECTOR_DRC_ITEMS_PROVIDER( PCB_BASE_FRAME* aFrame, std::vector* aList ) : + m_frame( aFrame ), + m_sourceVector( aList ), + m_severities( 0 ) { } - int GetCount() override + void SetSeverities( int aSeverities ) override { - return m_vector ? (int) m_vector->size() : 0; + m_severities = aSeverities; + + BOARD_DESIGN_SETTINGS& bds = m_frame->GetBoard()->GetDesignSettings(); + + m_filteredVector.clear(); + + if( m_sourceVector ) + { + for( DRC_ITEM* item : *m_sourceVector ) + { + if( bds.GetSeverity( item->GetErrorCode() ) & aSeverities ) + m_filteredVector.push_back( item ); + } + } } - const DRC_ITEM* GetItem( int aIndex ) override + int GetCount( int aSeverity = -1 ) override { - return (*m_vector)[aIndex]; + if( aSeverity < 0 ) + return m_filteredVector.size(); + + int count = 0; + BOARD_DESIGN_SETTINGS& bds = m_frame->GetBoard()->GetDesignSettings(); + + if( m_sourceVector ) + { + for( DRC_ITEM* item : *m_sourceVector ) + { + if( bds.GetSeverity( item->GetErrorCode() ) == aSeverity ) + count++; + } + } + + return count; } - void DeleteItem( int aIndex ) override + DRC_ITEM* GetItem( int aIndex ) override { - delete (*m_vector)[aIndex]; - m_vector->erase( m_vector->begin() + aIndex ); + return (m_filteredVector)[aIndex]; + } + + void DeleteItem( int aIndex, bool aDeep ) override + { + DRC_ITEM* item = m_filteredVector[aIndex]; + m_filteredVector.erase( m_filteredVector.begin() + aIndex ); + + if( aDeep ) + { + for( int i = 0; i < m_sourceVector->size(); ++i ) + { + if( m_sourceVector->at( i ) == item ) + { + delete item; + m_sourceVector->erase( m_sourceVector->begin() + i ); + break; + } + } + } } void DeleteAllItems() override { - if( m_vector ) + if( m_sourceVector ) { - for( DRC_ITEM* item : *m_vector ) + for( DRC_ITEM* item : *m_sourceVector ) delete item; - m_vector->clear(); + m_sourceVector->clear(); } + + m_filteredVector.clear(); // no ownership of DRC_ITEM pointers } }; +/** + * RATSNEST_DRC_ITEMS_PROVIDER + */ +class RATSNEST_DRC_ITEMS_PROVIDER : public VECTOR_DRC_ITEMS_PROVIDER +{ + // TODO: for now this is just a vector, but we need to map it to some board-level + // data-structure so that deleting/excluding things can do a deep delete/exclusion + // which will be reflected in the ratsnest.... +public: + RATSNEST_DRC_ITEMS_PROVIDER( PCB_BASE_FRAME* aFrame, std::vector* aList ) : + VECTOR_DRC_ITEMS_PROVIDER( aFrame, aList ) + { } +}; + + 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 ) : + DRC_TREE_NODE( DRC_TREE_NODE* aParent, DRC_ITEM* aDrcItem, NODE_TYPE aType ) : m_Type( aType ), m_Parent( aParent ), m_DrcItem( aDrcItem ) {} - NODE_TYPE m_Type; - DRC_TREE_NODE* m_Parent; + NODE_TYPE m_Type; + DRC_TREE_NODE* m_Parent; - const DRC_ITEM* m_DrcItem; + DRC_ITEM* m_DrcItem; std::vector> m_Children; }; @@ -193,16 +311,15 @@ public: static BOARD_ITEM* ToBoardItem( BOARD* aBoard, wxDataViewItem aItem ); public: - DRC_TREE_MODEL( wxDataViewCtrl* aView ); + DRC_TREE_MODEL( PCB_BASE_FRAME* aParentFrame, wxDataViewCtrl* aView ); ~DRC_TREE_MODEL(); void SetProvider( DRC_ITEMS_PROVIDER* aProvider ); + void SetSeverities( int aSeverities ); int GetDRCItemCount() const { return m_tree.size(); } - const DRC_ITEM* GetDRCItem( int i ) const { return m_tree.at( i )->m_DrcItem; } - void ExpandAll(); bool IsContainer( wxDataViewItem const& aItem ) const override; @@ -243,16 +360,23 @@ public: unsigned int aCol, wxDataViewItemAttr& aAttr ) const override; - void DeleteCurrentItem(); + void ValueChanged( DRC_TREE_NODE* aNode ); + + void DeleteCurrentItem( bool aDeep ); void DeleteAllItems(); +private: + void rebuildModel( DRC_ITEMS_PROVIDER* aProvider, int aSeverities ); void onSizeView( wxSizeEvent& aEvent ); private: + PCB_BASE_FRAME* m_parentFrame; wxDataViewCtrl* m_view; + int m_severities; DRC_ITEMS_PROVIDER* m_drcItemsProvider; // I own this, but not its contents std::vector> m_tree; // I own this }; + #endif //KICAD_DRC_TREE_MODEL_H diff --git a/pcbnew/exporters/export_hyperlynx.cpp b/pcbnew/exporters/export_hyperlynx.cpp index a6544e6608..b832473e75 100644 --- a/pcbnew/exporters/export_hyperlynx.cpp +++ b/pcbnew/exporters/export_hyperlynx.cpp @@ -191,7 +191,7 @@ private: _( "File contains pad shapes that are not supported by the Hyperlynx exporter\n" "(Supported shapes are oval, rectangle, circle.)\n" "They have been exported as oval pads." ), - REPORTER::RPT_WARNING ); + SEVERITY_WARNING ); } break; } diff --git a/pcbnew/exporters/gen_footprints_placefile.cpp b/pcbnew/exporters/gen_footprints_placefile.cpp index 64f8dd1ee2..e43be20889 100644 --- a/pcbnew/exporters/gen_footprints_placefile.cpp +++ b/pcbnew/exporters/gen_footprints_placefile.cpp @@ -270,15 +270,15 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles() { msg.Printf( _( "Unable to create \"%s\"." ), fn.GetFullPath() ); wxMessageBox( msg ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); return false; } msg.Printf( _( "Front side (top side) place file: \"%s\"." ), filename ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); msg.Printf( _( "Component count: %d." ), fpcount ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); // Create the Back or Bottom side placement file fullcount = fpcount; @@ -290,24 +290,24 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles() if( fpcount < 0 ) { msg.Printf( _( "Unable to create file \"%s\"." ), filename ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); wxMessageBox( msg ); return false; } // Display results msg.Printf( _( "Back side (bottom side) place file: \"%s\"." ), filename ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); msg.Printf( _( "Component count: %d." ), fpcount ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); fullcount += fpcount; msg.Printf( _( "Full component count: %d\n" ), fullcount ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); - m_reporter->Report( _( "Component Placement File generation OK." ), REPORTER::RPT_ACTION ); + m_reporter->Report( _( "Component Placement File generation OK." ), SEVERITY_ACTION ); return true; } @@ -343,7 +343,7 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() for( MODULE* item : fp_no_smd_list ) { msg.Printf( _( "footprint %s (not set as SMD) forced in list" ), item->GetReference() ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); } } } @@ -395,7 +395,7 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() { msg.Printf( _( "Unable to create \"%s\"." ), fn.GetFullPath() ); wxMessageBox( msg ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); return false; } @@ -404,14 +404,14 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() else msg.Printf( _( "Front side (top side) place file: \"%s\"." ), fn.GetFullPath() ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); msg.Printf( _( "Component count: %d." ), fpcount ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); if( singleFile ) { - m_reporter->Report( _( "Component Placement File generation OK." ), REPORTER::RPT_ACTION ); + m_reporter->Report( _( "Component Placement File generation OK." ), SEVERITY_ACTION ); return true; } @@ -437,7 +437,7 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() if( fpcount < 0 ) { msg.Printf( _( "Unable to create file \"%s\"." ), fn.GetFullPath() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); wxMessageBox( msg ); return false; } @@ -446,21 +446,21 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() if( !singleFile ) { msg.Printf( _( "Back side (bottom side) place file: \"%s\"." ), fn.GetFullPath() ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); msg.Printf( _( "Component count: %d." ), fpcount ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); } if( !singleFile ) { fullcount += fpcount; msg.Printf( _( "Full component count: %d\n" ), fullcount ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); } - m_reporter->Report( _( "Component Placement File generation OK." ), REPORTER::RPT_ACTION ); + m_reporter->Report( _( "Component Placement File generation OK." ), SEVERITY_ACTION ); return true; } diff --git a/pcbnew/exporters/gerber_jobfile_writer.cpp b/pcbnew/exporters/gerber_jobfile_writer.cpp index 3c97153d1a..7ad197ad13 100644 --- a/pcbnew/exporters/gerber_jobfile_writer.cpp +++ b/pcbnew/exporters/gerber_jobfile_writer.cpp @@ -150,13 +150,13 @@ bool GERBER_JOBFILE_WRITER::CreateJobFile( const wxString& aFullFilename ) if( m_reporter ) { msg.Printf( _( "Unable to create job file \"%s\"" ), aFullFilename ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); } } else if( m_reporter ) { msg.Printf( _( "Create Gerber job file \"%s\"" ), aFullFilename ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); } return success; @@ -404,7 +404,7 @@ void GERBER_JOBFILE_WRITER::addJSONFilesAttributes() default: skip_file = true; - m_reporter->Report( "Unexpected layer id in job file", REPORTER::RPT_ERROR ); + m_reporter->Report( "Unexpected layer id in job file", SEVERITY_ERROR ); break; } } @@ -555,7 +555,7 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup() if( !uptodate && m_pcb->GetDesignSettings().m_HasStackup ) m_reporter->Report( _( "Board stackup settings not up to date\n" "Please fix the stackup" ), - REPORTER::RPT_ERROR ); + SEVERITY_ERROR ); PCB_LAYER_ID last_copper_layer = F_Cu; diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 7b66af2abb..a375b3423f 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -552,8 +552,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // from there. BOARD_DESIGN_SETTINGS& configBds = GetBoard()->GetDesignSettings(); - bds.m_RequireCourtyards = configBds.m_RequireCourtyards; - bds.m_ProhibitOverlappingCourtyards = configBds.m_ProhibitOverlappingCourtyards; + bds.m_DRCSeverities = configBds.m_DRCSeverities; bds.m_HoleToHoleMin = configBds.m_HoleToHoleMin; bds.m_LineThickness[LAYER_CLASS_OTHERS] = configBds.m_LineThickness[LAYER_CLASS_OTHERS]; bds.m_TextSize[LAYER_CLASS_OTHERS] = configBds.m_TextSize[LAYER_CLASS_OTHERS]; @@ -573,15 +572,15 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // 6.0 TODO: some of the 5.1 settings still haven't moved because they're waiting on // the new DRC architecture BOARD_DESIGN_SETTINGS& configBds = GetBoard()->GetDesignSettings(); - bds.m_RequireCourtyards = configBds.m_RequireCourtyards; - bds.m_ProhibitOverlappingCourtyards = configBds.m_ProhibitOverlappingCourtyards; - bds.m_HoleToHoleMin = configBds.m_HoleToHoleMin; + bds.m_DRCSeverities = configBds.m_DRCSeverities; + bds.m_HoleToHoleMin = configBds.m_HoleToHoleMin; SetBoard( loadedBoard ); // we should not ask PLUGINs to do these items: loadedBoard->BuildListOfNets(); loadedBoard->SynchronizeNetsAndNetClasses(); + ResolveDRCExclusions(); if( loadedBoard->IsModified() ) OnModify(); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index d7763c2ef6..b8275bd65c 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1577,6 +1577,8 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const m_out->Print( aNestLevel+1, ")" ); // end of (basic_shapes } + m_out->Print( 0, " (tstamp %s)", TO_UTF8( aPad->m_Uuid.AsString() ) ); + m_out->Print( 0, ")\n" ); } @@ -1615,7 +1617,8 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const case TEXTE_MODULE::TEXT_is_DIVERS: type = "user"; } - m_out->Print( aNestLevel, "(fp_text %s %s (at %s", type.c_str(), + m_out->Print( aNestLevel, "(fp_text %s %s (at %s", + type.c_str(), m_out->Quotew( aText->GetText() ).c_str(), FormatInternalUnits( aText->GetPos0() ).c_str() ); diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index 55e44e8948..8be1321ae6 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -145,7 +145,7 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent ) msg.Printf( _( "Cannot add %s (no footprint assigned)." ), aComponent->GetReference(), aComponent->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); ++m_errorCount; return nullptr; } @@ -157,7 +157,7 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent ) msg.Printf( _( "Cannot add %s (footprint \"%s\" not found)." ), aComponent->GetReference(), aComponent->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); ++m_errorCount; return nullptr; } @@ -165,7 +165,7 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent ) msg.Printf( _( "Add %s (footprint \"%s\")." ), aComponent->GetReference(), aComponent->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); // Set the pads ratsnest settings to the global settings bool set_ratsnest = m_frame->GetDisplayOptions().m_ShowGlobalRatsnest; @@ -201,7 +201,7 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb msg.Printf( _( "Cannot update %s (no footprint assigned)." ), aNewComponent->GetReference(), aNewComponent->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); ++m_errorCount; return nullptr; } @@ -213,7 +213,7 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb msg.Printf( _( "Cannot update %s (footprint \"%s\" not found)." ), aNewComponent->GetReference(), aNewComponent->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); ++m_errorCount; return nullptr; } @@ -222,7 +222,7 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcb aPcbComponent->GetReference(), aPcbComponent->GetFPID().Format().wx_str(), aNewComponent->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); m_newFootprintsCount++; @@ -253,7 +253,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent, msg.Printf( _( "Change %s reference to %s." ), aPcbComponent->GetReference(), aNewComponent->GetReference() ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if ( !m_isDryRun ) { @@ -269,7 +269,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent, aPcbComponent->GetReference(), aPcbComponent->GetValue(), aNewComponent->GetValue() ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if( !m_isDryRun ) { @@ -285,7 +285,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent, aPcbComponent->GetReference(), aPcbComponent->GetPath().AsString(), aNewComponent->GetPath().AsString() ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); if( !m_isDryRun ) { @@ -341,7 +341,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent msg.Printf( _( "Disconnect %s pin %s." ), aPcbComponent->GetReference(), pad->GetName() ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); } else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() ) { @@ -349,7 +349,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent msg.Printf( _( "No net for component %s pin %s." ), aPcbComponent->GetReference(), pad->GetName() ); - m_reporter->Report( msg, REPORTER::RPT_WARNING); + m_reporter->Report( msg, SEVERITY_WARNING); } if( !m_isDryRun ) @@ -397,7 +397,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent m_addedNets[netName] = netinfo; msg.Printf( _( "Add net %s." ), UnescapeString( netName ) ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); } if( !pad->GetNetname().IsEmpty() ) @@ -417,7 +417,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent pad->GetName(), UnescapeString( netName ) ); } - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if( !m_isDryRun ) { @@ -488,7 +488,7 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist ) { msg.Printf( _( "Reconnect via from %s to %s." ), UnescapeString( via->GetNetname() ), UnescapeString( updatedNetname ) ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if( !m_isDryRun ) { @@ -508,7 +508,7 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist ) { msg.Printf( _( "Via connected to unknown net (%s)." ), UnescapeString( via->GetNetname() ) ); - m_reporter->Report( msg, REPORTER::RPT_WARNING ); + m_reporter->Report( msg, SEVERITY_WARNING ); ++m_warningCount; } } @@ -550,7 +550,7 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist ) msg.Printf( _( "Reconnect copper zone from %s to %s." ), UnescapeString( zone->GetNetname() ), UnescapeString( updatedNetname ) ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if( !m_isDryRun ) { @@ -570,7 +570,7 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist ) { msg.Printf( _( "Copper zone (%s) has no pads connected." ), UnescapeString( zone->GetNetname() ) ); - m_reporter->Report( msg, REPORTER::RPT_WARNING ); + m_reporter->Report( msg, SEVERITY_WARNING ); ++m_warningCount; } } @@ -598,12 +598,12 @@ bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist ) if( module->IsLocked() ) { msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), module->GetReference() ); - m_reporter->Report( msg, REPORTER::RPT_WARNING ); + m_reporter->Report( msg, SEVERITY_WARNING ); continue; } msg.Printf( _( "Remove unused footprint %s." ), module->GetReference() ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if( !m_isDryRun ) m_commit.Remove( module ); @@ -662,7 +662,7 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets() { msg.Printf( _( "Remove single pad net %s." ), UnescapeString( getNetname( previouspad ) ) ); - m_reporter->Report( msg, REPORTER::RPT_ACTION ); + m_reporter->Report( msg, SEVERITY_ACTION ); if( !m_isDryRun ) previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED ); @@ -727,7 +727,7 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist ) component->GetReference(), padname, footprint->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); ++m_errorCount; } } @@ -765,7 +765,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) msg.Printf( _( "Processing component \"%s:%s\"." ), component->GetReference(), component->GetFPID().Format().wx_str() ); - m_reporter->Report( msg, REPORTER::RPT_INFO ); + m_reporter->Report( msg, SEVERITY_INFO ); for( auto footprint : m_board->Modules() ) { @@ -816,7 +816,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) { msg.Printf( _( "Multiple footprints found for \"%s\"." ), component->GetReference() ); - m_reporter->Report( msg, REPORTER::RPT_ERROR ); + m_reporter->Report( msg, SEVERITY_ERROR ); } } @@ -850,20 +850,20 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) } // Update the ratsnest - m_reporter->ReportTail( wxT( "" ), REPORTER::RPT_ACTION ); - m_reporter->ReportTail( wxT( "" ), REPORTER::RPT_ACTION ); + m_reporter->ReportTail( wxT( "" ), SEVERITY_ACTION ); + m_reporter->ReportTail( wxT( "" ), SEVERITY_ACTION ); msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount ); - m_reporter->ReportTail( msg, REPORTER::RPT_ACTION ); + m_reporter->ReportTail( msg, SEVERITY_ACTION ); if( m_errorCount ) { m_reporter->ReportTail( _( "Errors occurred during the netlist update. Unless you fix them " "your board will not be consistent with the schematics." ), - REPORTER::RPT_ERROR ); + SEVERITY_ERROR ); return false; } - m_reporter->ReportTail( _( "Netlist update successful!" ), REPORTER::RPT_ACTION ); + m_reporter->ReportTail( _( "Netlist update successful!" ), SEVERITY_ACTION ); return true; } diff --git a/pcbnew/netlist_reader/netlist.cpp b/pcbnew/netlist_reader/netlist.cpp index 7dd1093b64..9435521bc8 100644 --- a/pcbnew/netlist_reader/netlist.cpp +++ b/pcbnew/netlist_reader/netlist.cpp @@ -32,14 +32,11 @@ using namespace std::placeholders; #include #include -#include #include -#include #include #include "pcb_netlist.h" #include "netlist_reader.h" #include -#include #include #include #include @@ -161,7 +158,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter ) { msg.Printf( _( "No footprint defined for symbol \"%s\".\n" ), component->GetReference() ); - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); continue; } @@ -181,7 +178,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter ) component->GetReference(), GetChars( fpOnBoard->GetFPID().Format() ), GetChars( component->GetFPID().Format() ) ); - aReporter.Report( msg, REPORTER::RPT_WARNING ); + aReporter.Report( msg, SEVERITY_WARNING ); continue; } @@ -207,7 +204,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter ) msg.Printf( _( "%s footprint ID \"%s\" is not valid." ), component->GetReference(), GetChars( component->GetFPID().Format() ) ); - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); continue; } @@ -224,7 +221,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter ) msg.Printf( _( "%s footprint \"%s\" not found in any libraries in the footprint library table.\n" ), component->GetReference(), GetChars( component->GetFPID().GetLibItemName() ) ); - aReporter.Report( msg, REPORTER::RPT_ERROR ); + aReporter.Report( msg, SEVERITY_ERROR ); continue; } diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index d7c8bbe240..958a87acef 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -51,7 +51,7 @@ const LAYER_NUM GAL_LAYER_ORDER[] = { LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY, - LAYER_DRC, + LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_PADS_NETNAMES, LAYER_VIAS_NETNAMES, Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts, @@ -178,10 +178,8 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard ) m_view->Add( module ); // DRC markers - for( int marker_idx = 0; marker_idx < aBoard->GetMARKERCount(); ++marker_idx ) - { - m_view->Add( aBoard->GetMARKER( marker_idx ) ); - } + for( auto marker : aBoard->Markers() ) + m_view->Add( marker ); // Finalize the triangulation threads while( count_done < parallelThreadCount ) @@ -278,7 +276,7 @@ void PCB_DRAW_PANEL_GAL::SetTopLayer( PCB_LAYER_ID aLayer ) LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, LAYER_VIAS_NETNAMES, LAYER_PADS_TH, LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES, LAYER_NON_PLATEDHOLES, LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY, - LAYER_RATSNEST, LAYER_DRC + LAYER_RATSNEST, LAYER_DRC_ERROR, LAYER_DRC_WARNING }; for( auto layer : layers ) @@ -496,7 +494,6 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps() m_view->SetLayerTarget( LAYER_WORKSHEET, KIGFX::TARGET_NONCACHED ); m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ; m_view->SetLayerDisplayOnly( LAYER_GRID ); - m_view->SetLayerDisplayOnly( LAYER_DRC ); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 5b5c4424fd..d7be66021b 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -463,6 +463,46 @@ void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event ) } +void PCB_EDIT_FRAME::RecordDRCExclusions() +{ + m_drcExclusions.clear(); + + for( MARKER_PCB* marker : GetBoard()->Markers() ) + { + if( marker->IsExcluded() ) + m_drcExclusions.insert( marker->Serialize() ); + } +} + + +void PCB_EDIT_FRAME::ResolveDRCExclusions() +{ + for( MARKER_PCB* marker : GetBoard()->Markers() ) + { + auto i = m_drcExclusions.find( marker->Serialize() ); + + if( i != m_drcExclusions.end() ) + { + marker->SetExcluded( true ); + m_drcExclusions.erase( i ); + } + } + + BOARD_COMMIT commit( this ); + + for( const wxString& exclusionData : m_drcExclusions ) + { + MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData ); + marker->SetExcluded( true ); + commit.Add( marker ); + } + + m_drcExclusions.clear(); + + commit.Push( wxEmptyString, false, false ); +} + + void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) { // Shutdown blocks must be determined and vetoed as early as possible @@ -473,15 +513,18 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) return; } - // First close the DRC dialog. - // For some reason, if the board editor frame is destroyed when the DRC - // dialog currently open, Pcbnew crashes, At least on Windows. + // First close the DRC dialog. For some reason, if the board editor frame is destroyed + // when the DRC dialog currently open, Pcbnew crashes, at least on Windows. DIALOG_DRC_CONTROL* open_dlg = static_cast( wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME ) ); if( open_dlg ) open_dlg->Close( true ); + // Save various DRC parameters, such as violation severities (which may have been + // edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc. + SaveProjectSettings(); + if( IsContentModified() ) { wxFileName fileName = GetBoard()->GetFileName(); @@ -564,7 +607,7 @@ void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage, if( dlg.ShowModal() == wxID_OK ) { - SaveProjectSettings( false ); + SaveProjectSettings(); UpdateUserInterface(); ReCreateAuxiliaryToolbar(); @@ -789,7 +832,7 @@ void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPat if( relativeFileName.GetFullPath() != m_lastPath[ aType ] ) { m_lastPath[ aType ] = relativeFileName.GetFullPath(); - SaveProjectSettings( false ); + SaveProjectSettings(); } } diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index cef85b27ef..17be8eb314 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -106,6 +106,7 @@ protected: wxString m_lastPath[ LAST_PATH_SIZE ]; + std::set m_drcExclusions; /** * Store the previous layer toolbar icon state information @@ -401,9 +402,8 @@ public: /** * Function SaveProjectSettings * saves changes to the project settings to the project (.pro) file. - * @param aAskForSave = true to open a dialog before saving the settings */ - void SaveProjectSettings( bool aAskForSave ) override; + void SaveProjectSettings() override; /** * Load the current project's file configuration settings which are pertinent @@ -436,6 +436,16 @@ public: */ void SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath ); + /** + * Scan existing markers and record data from any that are Excluded. + */ + void RecordDRCExclusions(); + + /** + * Update markers to match recorded exclusions. + */ + void ResolveDRCExclusions(); + void OnCloseWindow( wxCloseEvent& Event ) override; void Process_Special_Functions( wxCommandEvent& event ); void Tracks_and_Vias_Size_Event( wxCommandEvent& event ); diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index 5df16ab765..6401328734 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -57,31 +57,33 @@ const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = { #define NOCOLOR COLOR4D::UNSPECIFIED // specify rows that do not have a color selector icon // text id color tooltip - RR( _( "Footprints Front" ), LAYER_MOD_FR, NOCOLOR, _( "Show footprints that are on board's front") ), - RR( _( "Footprints Back" ), LAYER_MOD_BK, NOCOLOR, _( "Show footprints that are on board's back") ), - RR( _( "Values" ), LAYER_MOD_VALUES, NOCOLOR, _( "Show footprint values") ), - RR( _( "References" ), LAYER_MOD_REFERENCES, NOCOLOR, _( "Show footprint references") ), - RR( _( "Footprint Text Front" ), LAYER_MOD_TEXT_FR, NOCOLOR, _( "Show footprint text on board's front" ) ), - RR( _( "Footprint Text Back" ), LAYER_MOD_TEXT_BK, NOCOLOR, _( "Show footprint text on board's back" ) ), - RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ), - RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ), - RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ), - RR( _( "Through Hole Pads" ), LAYER_PADS_TH, YELLOW, _( "Show through hole pads in specific color") ), + RR( _( "Footprints Front" ), LAYER_MOD_FR, NOCOLOR, _( "Show footprints that are on board's front") ), + RR( _( "Footprints Back" ), LAYER_MOD_BK, NOCOLOR, _( "Show footprints that are on board's back") ), + RR( _( "Values" ), LAYER_MOD_VALUES, NOCOLOR, _( "Show footprint values") ), + RR( _( "References" ), LAYER_MOD_REFERENCES, NOCOLOR, _( "Show footprint references") ), + RR( _( "Footprint Text Front" ), LAYER_MOD_TEXT_FR, NOCOLOR, _( "Show footprint text on board's front" ) ), + RR( _( "Footprint Text Back" ), LAYER_MOD_TEXT_BK, NOCOLOR, _( "Show footprint text on board's back" ) ), + RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ), + RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ), + RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ), + RR( _( "Through Hole Pads" ), LAYER_PADS_TH, YELLOW, _( "Show through hole pads in specific color") ), RR(), - RR( _( "Tracks" ), LAYER_TRACKS, NOCOLOR, _( "Show tracks" ) ), - RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ), - RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ), - RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ), - RR( _( "Non Plated Holes" ),LAYER_NON_PLATEDHOLES,WHITE, _( "Show non plated holes in specific color") ), + RR( _( "Tracks" ), LAYER_TRACKS, NOCOLOR, _( "Show tracks" ) ), + RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ), + RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ), + RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ), + RR( _( "Non Plated Holes" ), LAYER_NON_PLATEDHOLES, WHITE, _( "Show non plated holes in specific color") ), RR(), - RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ), - RR( _( "No-Connects" ), LAYER_NO_CONNECTS, BLUE, _( "Show a marker on pads which have no net connected" ) ), - RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ), - RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ), - RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ), - RR( _( "Aux items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxiliary items (rulers, assistants, axes, etc.)" ), true, false ), - RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ), - RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false ) + RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ), + RR( _( "No-Connects" ), LAYER_NO_CONNECTS, BLUE, _( "Show a marker on pads which have no net connected" ) ), + RR( _( "DRC Warnings" ), LAYER_DRC_WARNING, YELLOW, _( "DRC violations with a Warning severity" ) ), + RR( _( "DRC Errors" ), LAYER_DRC_ERROR, PURERED, _( "DRC violations with an Error severity" ) ), + RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ), + RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ), + RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ), + RR( _( "Aux Items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxiliary items (rulers, assistants, axes, etc.)" ), true, false ), + RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ), + RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false ) }; static int s_allowed_in_FpEditor[] = diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index b6b430c2d2..4b0548393c 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -99,7 +99,6 @@ void PCB_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings ) m_layerColors[LAYER_PADS_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 ); m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 ); m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 ); - m_layerColors[LAYER_DRC] = COLOR4D( 1.0, 0.0, 0.0, 0.8 ); // LAYER_PADS_TH, LAYER_NON_PLATEDHOLES, LAYER_ANCHOR ,LAYER_RATSNEST, // LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA @@ -1226,7 +1225,7 @@ void PCB_PAINTER::draw( const MARKER_PCB* aMarker ) SHAPE_LINE_CHAIN polygon; aMarker->ShapeToPolygon( polygon ); - auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC ); + auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() ); m_gal->Save(); m_gal->Translate( aMarker->GetPosition() ); diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index e873232f14..d0c39b6be5 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -33,9 +33,7 @@ class EDA_ITEM; -class COLORS_DESIGN_SETTINGS; class PCB_DISPLAY_OPTIONS; - class BOARD_ITEM; class ARC; class BOARD; diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 171611cfb2..2619974852 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -3287,9 +3287,15 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) } break; + case T_tstamp: + NextTok(); + const_cast( pad->m_Uuid ) = KIID( CurStr() ); + NeedRIGHT(); + break; + default: Expecting( "at, drill, layers, net, die_length, solder_mask_margin, roundrect_rratio,\n" - "solder_paste_margin, solder_paste_margin_ratio, clearance,\n" + "solder_paste_margin, solder_paste_margin_ratio, clearance, tstamp,\n" "zone_connect, fp_poly, primitives, thermal_width, or thermal_gap" ); } } diff --git a/pcbnew/pcb_parser.h b/pcbnew/pcb_parser.h index e23626fed3..be19b43088 100644 --- a/pcbnew/pcb_parser.h +++ b/pcbnew/pcb_parser.h @@ -56,6 +56,7 @@ class MODULE; class PCB_TARGET; class VIA; class ZONE_CONTAINER; +class MARKER_PCB; class MODULE_3D_SETTINGS; struct LAYER; @@ -161,6 +162,7 @@ class PCB_PARSER : public PCB_LEXER VIA* parseVIA(); ZONE_CONTAINER* parseZONE_CONTAINER( BOARD_ITEM_CONTAINER* aParent ); PCB_TARGET* parsePCB_TARGET(); + MARKER_PCB* parseMARKER( BOARD_ITEM_CONTAINER* aParent ); BOARD* parseBOARD(); /** diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 2ed296bb09..6e2aa9e27a 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -92,23 +92,16 @@ bool PCB_EDIT_FRAME::LoadProjectSettings() } -void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) +void PCB_EDIT_FRAME::SaveProjectSettings() { wxFileName fn = Prj().GetProjectFullName(); - if( aAskForSave ) - { - wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(), - ProjectFileWildcard(), wxFD_SAVE | wxFD_CHANGE_DIR ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - fn = dlg.GetPath(); - } + if( !IsWritable( fn ) ) + return; wxString pro_name = fn.GetFullPath(); + RecordDRCExclusions(); Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name ); } @@ -141,6 +134,9 @@ std::vector& PCB_EDIT_FRAME::GetProjectFileParameters() m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastGenCADExportPath" ), &m_lastPath[ LAST_PATH_GENCAD ] ) ); + m_projectFileParams.push_back( new PARAM_CFG_WXSTRING_SET( wxT( "DRCExclusion" ), + &m_drcExclusions ) ); + GetBoard()->GetDesignSettings().AppendConfigs( GetBoard(), &m_projectFileParams); return m_projectFileParams; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 55b1a805d6..bb095e51df 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1475,9 +1475,6 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn // Filter out items that do not belong to active layers std::set activeLayers = getView()->GetPainter()->GetSettings()->GetActiveLayers(); - // The markers layer is considered to be always active - activeLayers.insert( (unsigned int) LAYER_DRC ); - aItem->ViewGetLayers( layers, layers_count ); if( highContrast ) diff --git a/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp b/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp index 34983eb02f..a4aa24c4a2 100644 --- a/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp +++ b/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "../board_test_utils.h" #include "drc_test_utils.h" @@ -242,10 +243,10 @@ static BOARD_DESIGN_SETTINGS GetOverlapCheckDesignSettings() // do the overlap tests - that's a different test, but if not set, // the invalid courtyard checks don't run either - des_settings.m_ProhibitOverlappingCourtyards = true; + des_settings.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = SEVERITY_ERROR; // we will also check for missing courtyards here - des_settings.m_RequireCourtyards = true; + des_settings.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_ERROR; return des_settings; } @@ -306,8 +307,6 @@ static void CheckInvalidsMatchExpected( BOARD& aBoard, void DoCourtyardInvalidTest( const COURTYARD_INVALID_CASE& aCase, const KI_TEST::BOARD_DUMPER& aDumper ) { - DRC_MARKER_FACTORY marker_factory; - auto board = MakeBoard( aCase.m_mods ); // Dump if env var set @@ -318,11 +317,13 @@ void DoCourtyardInvalidTest( // list of markers to collect std::vector> markers; - DRC_COURTYARD_OVERLAP drc_overlap( marker_factory, [&]( MARKER_PCB* aMarker ) { - markers.push_back( std::unique_ptr( aMarker ) ); - } ); + DRC_COURTYARD_OVERLAP drc_overlap( + [&]( MARKER_PCB* aMarker ) + { + markers.push_back( std::unique_ptr( aMarker ) ); + } ); - drc_overlap.RunDRC( *board ); + drc_overlap.RunDRC( EDA_UNITS::MILLIMETRES, *board ); CheckInvalidsMatchExpected( *board, markers, aCase.m_exp_errors ); } diff --git a/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp b/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp index 7aec9a2a0c..0e2a4f16bb 100644 --- a/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp +++ b/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "../board_test_utils.h" #include "drc_test_utils.h" @@ -447,10 +448,10 @@ static void CheckCollisionsMatchExpected( BOARD& aBoard, static BOARD_DESIGN_SETTINGS GetOverlapCheckDesignSettings() { BOARD_DESIGN_SETTINGS des_settings; - des_settings.m_ProhibitOverlappingCourtyards = true; + des_settings.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = SEVERITY_ERROR; // we might not always have courtyards - that's a separate test - des_settings.m_RequireCourtyards = false; + des_settings.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_IGNORE; return des_settings; } @@ -463,8 +464,6 @@ static BOARD_DESIGN_SETTINGS GetOverlapCheckDesignSettings() static void DoCourtyardOverlapTest( const COURTYARD_OVERLAP_TEST_CASE& aCase, const KI_TEST::BOARD_DUMPER& aDumper ) { - DRC_MARKER_FACTORY marker_factory; - auto board = MakeBoard( aCase.m_mods ); // Dump if env var set @@ -475,11 +474,13 @@ static void DoCourtyardOverlapTest( // list of markers to collect std::vector> markers; - DRC_COURTYARD_OVERLAP drc_overlap( marker_factory, [&]( MARKER_PCB* aMarker ) { - markers.push_back( std::unique_ptr( aMarker ) ); - } ); + DRC_COURTYARD_OVERLAP drc_overlap( + [&]( MARKER_PCB* aMarker ) + { + markers.push_back( std::unique_ptr( aMarker ) ); + } ); - drc_overlap.RunDRC( *board ); + drc_overlap.RunDRC( EDA_UNITS::MILLIMETRES, *board ); CheckCollisionsMatchExpected( *board, markers, aCase.m_collisions ); } diff --git a/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp b/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp index 57576926df..822fe1e207 100644 --- a/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp +++ b/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp @@ -21,7 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include @@ -32,13 +31,12 @@ #include // DRC +#include +#include #include -#include -#include #include - using DRC_DURATION = std::chrono::microseconds; /** @@ -88,7 +86,7 @@ public: DRC_DURATION duration; { SCOPED_PROF_COUNTER timer( duration ); - drc_prov->RunDRC( aBoard ); + drc_prov->RunDRC( EDA_UNITS::MILLIMETRES, aBoard ); } // report results @@ -99,12 +97,6 @@ public: reportMarkers( markers ); } -protected: - const DRC_MARKER_FACTORY& getMarkerFactory() const - { - return m_marker_factory; - } - private: /** * Get the introduction text for this DRC runner @@ -141,7 +133,6 @@ private: } const EXECUTION_CONTEXT m_exec_context; - DRC_MARKER_FACTORY m_marker_factory; }; @@ -168,8 +159,8 @@ private: BOARD_DESIGN_SETTINGS getDesignSettings() const override { BOARD_DESIGN_SETTINGS des_settings; - des_settings.m_RequireCourtyards = false; - des_settings.m_ProhibitOverlappingCourtyards = true; + des_settings.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_IGNORE; + des_settings.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = SEVERITY_ERROR; return des_settings; } @@ -177,7 +168,7 @@ private: std::unique_ptr createDrcProvider( BOARD& aBoard, DRC_PROVIDER::MARKER_HANDLER aHandler ) override { - return std::make_unique( getMarkerFactory(), aHandler ); + return std::make_unique( aHandler ); } }; @@ -205,8 +196,8 @@ private: BOARD_DESIGN_SETTINGS getDesignSettings() const override { BOARD_DESIGN_SETTINGS des_settings; - des_settings.m_RequireCourtyards = true; - des_settings.m_ProhibitOverlappingCourtyards = false; + des_settings.m_DRCSeverities[ DRCE_MISSING_COURTYARD_IN_FOOTPRINT ] = SEVERITY_ERROR; + des_settings.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = SEVERITY_IGNORE; return des_settings; } @@ -214,7 +205,7 @@ private: std::unique_ptr createDrcProvider( BOARD& aBoard, DRC_PROVIDER::MARKER_HANDLER aHandler ) override { - return std::make_unique( getMarkerFactory(), aHandler ); + return std::make_unique( aHandler ); } };