diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 568defcb2f..fd479f22c9 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2022 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 @@ -190,6 +190,8 @@ static const wxChar ShowEventCounters[] = wxT( "ShowEventCounters" ); static const wxChar AllowManualCanvasScale[] = wxT( "AllowManualCanvasScale" ); static const wxChar UpdateUIEventInterval[] = wxT( "UpdateUIEventInterval" ); + +static const wxChar AllowTeardrops[] = wxT( "AllowTeardrops" ); } // namespace KEYS @@ -302,6 +304,8 @@ ADVANCED_CFG::ADVANCED_CFG() m_AllowManualCanvasScale = false; m_UpdateUIEventInterval = 0; + m_AllowTeardrops = false; + loadFromConfigFile(); } @@ -431,6 +435,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::AllowManualCanvasScale, &m_AllowManualCanvasScale, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::AllowTeardrops, + &m_AllowTeardrops, false ) ); + // Special case for trace mask setting...we just grab them and set them immediately // Because we even use wxLogTrace inside of advanced config wxString traceMasks = ""; diff --git a/include/advanced_config.h b/include/advanced_config.h index 5c686ddfc2..561f5cb29f 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2022 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 @@ -220,6 +220,11 @@ public: bool m_AllowManualCanvasScale; + /** + * Allows creating / deleting teardrops + */ + bool m_AllowTeardrops; + private: ADVANCED_CFG(); diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index e452d74af7..e42c08a0bd 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 Jean-Pierre Charras, jp.charras@wanadoo.fr - * Copyright (C) 2010-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2010-2022 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 @@ -482,6 +482,17 @@ public: */ void OnExportHyperlynx( wxCommandEvent& event ); + /** + * run teardrop tool + */ + void OnRunTeardropTool( wxCommandEvent& event ); + + /** + * Remove all teardrops + */ + void OnRemoveTeardropTool( wxCommandEvent& event ); + + /** * Create an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file. * diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 03d4f64aa8..b2745a22c1 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 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 @@ -48,6 +48,7 @@ ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent, bool aInFP ) : { m_CornerSelection = nullptr; // no corner is selected m_isFilled = false; // fill status : true when the zone is filled + m_teardropType = TEARDROP_TYPE::TD_NONE; m_borderStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; m_borderHatchPitch = GetDefaultHatchPitch(); m_priority = 0; @@ -128,6 +129,7 @@ void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone ) m_isFilled = aZone.m_isFilled; m_needRefill = aZone.m_needRefill; + m_teardropType = aZone.m_teardropType; m_thermalReliefGap = aZone.m_thermalReliefGap; m_thermalReliefSpokeWidth = aZone.m_thermalReliefSpokeWidth; @@ -1245,6 +1247,13 @@ double ZONE::CalculateFilledArea() } +double ZONE::CalculateOutlineArea() +{ + m_outlinearea = std::abs( m_Poly->Area() ); + return m_outlinearea; +} + + void ZONE::TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearance, SHAPE_POLY_SET* aBoardOutline ) const { diff --git a/pcbnew/zone.h b/pcbnew/zone.h index 0f0021a989..8f19768172 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 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 @@ -43,6 +43,18 @@ class BOARD; class ZONE; class MSG_PANEL_ITEM; +/** + * define the type of a teardrop: on a via or pad, or atrack end + */ +enum class TEARDROP_TYPE +{ + TD_NONE = 0, // Not a teardrop: just a standard zone + TD_UNSPECIFIED, // Not specified/unknown teardrop type + TD_VIAPAD, // a teardrop on a via or pad + TD_TRACKEND // a teardrop on a track end + // (when 2 tracks having different widths have a teardrop on the + // end of the largest track) +}; /** * Handle a list of polygons defining a copper zone. @@ -208,6 +220,12 @@ public: */ double CalculateFilledArea(); + /** + * Compute the area of the zone outline (not the filled area). + * @return the currently calculated area + */ + double CalculateOutlineArea(); + /** * This area is cached from the most recent call to CalculateFilledArea(). * @@ -218,6 +236,16 @@ public: return m_area; } + /** + * This area is cached from the most recent call to CalculateOutlineArea(). + * + * @return the outline area + */ + double GetOutlineArea() + { + return m_outlinearea; + } + std::mutex& GetLock() { return m_lock; @@ -725,6 +753,22 @@ public: EDA_ITEM* Clone() const override; + /** + * @return true if the zone is a teardrop area + */ + bool IsTeardropArea() const { return m_teardropType != TEARDROP_TYPE::TD_NONE; } + + /** + * Set the type of teardrop if the zone is a teardrop area + * for non teardrop area, the type must be TEARDROP_TYPE::TD_NONE + */ + void SetTeardropAreaType( TEARDROP_TYPE aType ) { m_teardropType = aType; } + + /** + * @return the type of the teardrop ( has meaning only if the zone is a teardrop area) + */ + TEARDROP_TYPE GetTeardropAreaType() const { return m_teardropType; } + /** * Accessors to parameters used in Rule Area zones: */ @@ -837,6 +881,12 @@ protected: */ bool m_isRuleArea; + /* A zone outline can be a teardrop zone with different rules for priority + * (alway bigger priority than copper zones) and never removed from a + * copper zone having the same netcode + */ + TEARDROP_TYPE m_teardropType; + /* For keepout zones only: * what is not allowed inside the keepout ( pads, tracks and vias ) */ @@ -931,6 +981,7 @@ protected: bool m_hv45; // constrain edges to horiz, vert or 45ยบ double m_area; // The filled zone area + double m_outlinearea; // The outline zone area /// Lock used for multi-threaded filling on multi-layer zones std::mutex m_lock;