KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_teardrops.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pcb_edit_frame.h>
25#include <pcb_painter.h>
26#include <board.h>
29
30
32 PANEL_SETUP_TEARDROPS_BASE( aParentWindow ),
33 m_BrdSettings( &aFrame->GetBoard()->GetDesignSettings() ),
34 m_teardropMaxLenRound( aFrame, m_stMaxLen, m_tcTdMaxLen, m_stMaxLenUnits ),
35 m_teardropMaxWidthRound( aFrame, m_stMaxWidthLabel, m_tcMaxWidth, m_stMaxWidthUnits ),
36 m_teardropMaxLenRect( aFrame, m_stMaxLen1, m_tcTdMaxLen1, m_stMaxLen1Units ),
37 m_teardropMaxWidthRect( aFrame, m_stMaxWidth2Label, m_tcMaxWidth1, m_stMaxWidth1Units ),
38 m_teardropMaxLenT2T( aFrame, m_stMaxLen2, m_tcTdMaxLen2, m_stMaxLen2Units ),
39 m_teardropMaxWidthT2T( aFrame, m_stMaxWidth2Label, m_tcMaxWidth2, m_stMaxWidth2Units )
40{
41 m_bitmapTeardrop->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_sizes ) );
42 m_bitmapTeardrop1->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_rect_sizes ) );
43 m_bitmapTeardrop2->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_track_sizes ) );
44
45 wxFont infoFont = KIUI::GetInfoFont( this ).Italic();
46}
47
48
50{
52
56 m_spLenPercent->SetValue( prms->m_BestLengthRatio *100.0 );
57 m_spWidthPercent->SetValue( prms->m_BestWidthRatio *100.0 );
58 m_spTeardropHDPercent->SetValue( prms->m_WidthtoSizeFilterRatio*100.0 );
61
62 if( prms->IsCurved() )
63 {
64 m_rbCurved->SetValue( true );
65 m_curvePointsCtrl->SetValue( prms->m_CurveSegCount );
66 }
67 else
68 {
69 m_rbStraightLines->SetValue( true );
70 m_curvePointsCtrl->SetValue( 5 );
71 }
72
73 prms = prmsList->GetParameters( TARGET_RECT );
76 m_spLenPercent1->SetValue( prms->m_BestLengthRatio *100.0 );
77 m_spWidthPercent1->SetValue( prms->m_BestWidthRatio *100.0 );
78 m_spTeardropHDPercent1->SetValue( prms->m_WidthtoSizeFilterRatio*100.0 );
81
82 if( prms->IsCurved() )
83 {
84 m_rbCurved1->SetValue( true );
85 m_curvePointsCtrl1->SetValue( prms->m_CurveSegCount );
86 }
87 else
88 {
89 m_rbStraightLines1->SetValue( true );
90 m_curvePointsCtrl1->SetValue( 5 );
91 }
92
93 prms = prmsList->GetParameters( TARGET_TRACK );
96 m_spLenPercent2->SetValue( prms->m_BestLengthRatio *100.0 );
97 m_spWidthPercent2->SetValue( prms->m_BestWidthRatio *100.0 );
98 m_spTeardropHDPercent2->SetValue( prms->m_WidthtoSizeFilterRatio*100.0 );
100
101 if( prms->IsCurved() )
102 {
103 m_rbCurved2->SetValue( true );
104 m_curvePointsCtrl2->SetValue( prms->m_CurveSegCount );
105 }
106 else
107 {
108 m_rbStraightLines2->SetValue( true );
109 m_curvePointsCtrl2->SetValue( 5 );
110 }
111
112 return true;
113}
114
115
117{
119
121 prms->m_BestLengthRatio = m_spLenPercent->GetValue() / 100.0;
122 prms->m_BestWidthRatio = m_spWidthPercent->GetValue() / 100.0;
125 prms->m_CurveSegCount = m_rbStraightLines->GetValue() ? 0 : m_curvePointsCtrl->GetValue();
126 prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercent->GetValue() / 100.0;
127 prms->m_TdOnPadsInZones = !m_cbPreferZoneConnection->GetValue();
129
130 prms = prmsList->GetParameters( TARGET_RECT );
131 prms->m_BestLengthRatio = m_spLenPercent1->GetValue() / 100.0;
132 prms->m_BestWidthRatio = m_spWidthPercent1->GetValue() / 100.0;
135 prms->m_CurveSegCount = m_rbStraightLines1->GetValue() ? 0 : m_curvePointsCtrl1->GetValue();
136 prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercent1->GetValue() / 100.0;
137 prms->m_TdOnPadsInZones = !m_cbPreferZoneConnection1->GetValue();
139
140 prms = prmsList->GetParameters( TARGET_TRACK );
141 prms->m_BestLengthRatio = m_spLenPercent2->GetValue() / 100.0;
142 prms->m_BestWidthRatio = m_spWidthPercent2->GetValue() / 100.0;
145 prms->m_CurveSegCount = m_rbStraightLines2->GetValue() ? 0 : m_curvePointsCtrl2->GetValue();
146 prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercent2->GetValue() / 100.0;
148
149 return true;
150}
151
152
154{
155 BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
156
157 m_BrdSettings = &aBoard->GetDesignSettings();
159
160 m_BrdSettings = savedSettings;
161}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
Container for design settings for a BOARD object.
TEARDROP_PARAMETERS_LIST * GetTeadropParamsList()
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:281
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:797
Class PANEL_SETUP_TEARDROPS_BASE.
BOARD_DESIGN_SETTINGS * m_BrdSettings
void ImportSettingsFrom(BOARD *aBoard)
PANEL_SETUP_TEARDROPS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
The main frame for Pcbnew.
TEARDROP_PARAMETERS_LIST is a helper class to handle the list of TEARDROP_PARAMETERS needed to build ...
TEARDROP_PARAMETERS * GetParameters(TARGET_TD aTdType)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
int GetIntValue()
Definition: unit_binder.h:127
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:151
BOARD * GetBoard()
@ TARGET_ROUND
@ TARGET_RECT
@ TARGET_TRACK