prepare teardrops, round 2

This commit is contained in:
jean-pierre charras 2022-01-08 16:56:41 +01:00
parent 2b20a58615
commit 9c29cc945c
5 changed files with 88 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -190,6 +190,8 @@ static const wxChar ShowEventCounters[] = wxT( "ShowEventCounters" );
static const wxChar AllowManualCanvasScale[] = wxT( "AllowManualCanvasScale" ); static const wxChar AllowManualCanvasScale[] = wxT( "AllowManualCanvasScale" );
static const wxChar UpdateUIEventInterval[] = wxT( "UpdateUIEventInterval" ); static const wxChar UpdateUIEventInterval[] = wxT( "UpdateUIEventInterval" );
static const wxChar AllowTeardrops[] = wxT( "AllowTeardrops" );
} // namespace KEYS } // namespace KEYS
@ -302,6 +304,8 @@ ADVANCED_CFG::ADVANCED_CFG()
m_AllowManualCanvasScale = false; m_AllowManualCanvasScale = false;
m_UpdateUIEventInterval = 0; m_UpdateUIEventInterval = 0;
m_AllowTeardrops = false;
loadFromConfigFile(); loadFromConfigFile();
} }
@ -431,6 +435,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::AllowManualCanvasScale, configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::AllowManualCanvasScale,
&m_AllowManualCanvasScale, false ) ); &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 // Special case for trace mask setting...we just grab them and set them immediately
// Because we even use wxLogTrace inside of advanced config // Because we even use wxLogTrace inside of advanced config
wxString traceMasks = ""; wxString traceMasks = "";

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -220,6 +220,11 @@ public:
bool m_AllowManualCanvasScale; bool m_AllowManualCanvasScale;
/**
* Allows creating / deleting teardrops
*/
bool m_AllowTeardrops;
private: private:
ADVANCED_CFG(); ADVANCED_CFG();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras@wanadoo.fr * 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 * 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 * under the terms of the GNU General Public License as published by the
@ -482,6 +482,17 @@ public:
*/ */
void OnExportHyperlynx( wxCommandEvent& event ); 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. * Create an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file.
* *

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -48,6 +48,7 @@ ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent, bool aInFP ) :
{ {
m_CornerSelection = nullptr; // no corner is selected m_CornerSelection = nullptr; // no corner is selected
m_isFilled = false; // fill status : true when the zone is filled 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_borderStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE;
m_borderHatchPitch = GetDefaultHatchPitch(); m_borderHatchPitch = GetDefaultHatchPitch();
m_priority = 0; m_priority = 0;
@ -128,6 +129,7 @@ void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone )
m_isFilled = aZone.m_isFilled; m_isFilled = aZone.m_isFilled;
m_needRefill = aZone.m_needRefill; m_needRefill = aZone.m_needRefill;
m_teardropType = aZone.m_teardropType;
m_thermalReliefGap = aZone.m_thermalReliefGap; m_thermalReliefGap = aZone.m_thermalReliefGap;
m_thermalReliefSpokeWidth = aZone.m_thermalReliefSpokeWidth; 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, void ZONE::TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearance,
SHAPE_POLY_SET* aBoardOutline ) const SHAPE_POLY_SET* aBoardOutline ) const
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -43,6 +43,18 @@ class BOARD;
class ZONE; class ZONE;
class MSG_PANEL_ITEM; 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. * Handle a list of polygons defining a copper zone.
@ -208,6 +220,12 @@ public:
*/ */
double CalculateFilledArea(); 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(). * This area is cached from the most recent call to CalculateFilledArea().
* *
@ -218,6 +236,16 @@ public:
return m_area; 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() std::mutex& GetLock()
{ {
return m_lock; return m_lock;
@ -725,6 +753,22 @@ public:
EDA_ITEM* Clone() const override; 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: * Accessors to parameters used in Rule Area zones:
*/ */
@ -837,6 +881,12 @@ protected:
*/ */
bool m_isRuleArea; 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: /* For keepout zones only:
* what is not allowed inside the keepout ( pads, tracks and vias ) * 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º bool m_hv45; // constrain edges to horiz, vert or 45º
double m_area; // The filled zone area double m_area; // The filled zone area
double m_outlinearea; // The outline zone area
/// Lock used for multi-threaded filling on multi-layer zones /// Lock used for multi-threaded filling on multi-layer zones
std::mutex m_lock; std::mutex m_lock;