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_teardropMaxHeightRound( aFrame, m_stTdMaxSize, m_tcMaxHeight, m_stMaxHeightUnits ),
36 m_teardropMaxLenRect( aFrame, m_stMaxLen1, m_tcTdMaxLen1, m_stMaxLenUnits1 ),
37 m_teardropMaxHeightRect( aFrame, m_stTdMaxSize1, m_tcMaxHeight1, m_stMaxHeightUnits1 ),
38 m_teardropMaxLenTrack( aFrame, m_stMaxLen2, m_tcTdMaxLen2, m_stMaxLenUnits2 ),
39 m_teardropMaxHeightTrack( aFrame, m_stTdMaxSize2, m_tcMaxHeight2, m_stMaxHeightUnits2 )
40{
41 m_bitmapTeardrop->SetBitmap( KiBitmap( BITMAPS::teardrop_sizes ) );
42 m_bitmapTeardrop1->SetBitmap( KiBitmap( BITMAPS::teardrop_rect_sizes ) );
43 m_bitmapTeardrop2->SetBitmap( KiBitmap( BITMAPS::teardrop_track_sizes ) );
44
45 wxFont infoFont = KIUI::GetInfoFont( this ).Italic();
46 m_minTrackWidthHint->SetFont( infoFont );
47 m_minTrackWidthHint1->SetFont( infoFont );
48 m_minTrackWidthHint2->SetFont( infoFont );
49}
50
51
53{
55
59 m_spTeardropLenPercent->SetValue( prms->m_BestLengthRatio *100.0 );
60 m_spTeardropSizePercent->SetValue( prms->m_BestWidthRatio *100.0 );
61 m_spTeardropHDPercent->SetValue( prms->m_WidthtoSizeFilterRatio*100.0 );
64
65 if( prms->IsCurved() )
66 {
67 m_rbCurved->SetValue( true );
68 m_curvePointsCtrl->SetValue( prms->m_CurveSegCount );
69 }
70 else
71 {
72 m_rbStraightLines->SetValue( true );
73 m_curvePointsCtrl->SetValue( 5 );
74 }
75
76 prms = prmsList->GetParameters( TARGET_RECT );
79 m_spTeardropLenPercent1->SetValue( prms->m_BestLengthRatio *100.0 );
80 m_spTeardropSizePercent1->SetValue( prms->m_BestWidthRatio *100.0 );
81 m_spTeardropHDPercent1->SetValue( prms->m_WidthtoSizeFilterRatio*100.0 );
84
85 if( prms->IsCurved() )
86 {
87 m_rbCurved1->SetValue( true );
88 m_curvePointsCtrl1->SetValue( prms->m_CurveSegCount );
89 }
90 else
91 {
92 m_rbStraightLines1->SetValue( true );
93 m_curvePointsCtrl1->SetValue( 5 );
94 }
95
96 prms = prmsList->GetParameters( TARGET_TRACK );
99 m_spTeardropLenPercent2->SetValue( prms->m_BestLengthRatio *100.0 );
100 m_spTeardropSizePercent2->SetValue( prms->m_BestWidthRatio *100.0 );
101 m_spTeardropHDPercent2->SetValue( prms->m_WidthtoSizeFilterRatio*100.0 );
103
104 if( prms->IsCurved() )
105 {
106 m_rbCurved2->SetValue( true );
107 m_curvePointsCtrl2->SetValue( prms->m_CurveSegCount );
108 }
109 else
110 {
111 m_rbStraightLines2->SetValue( true );
112 m_curvePointsCtrl2->SetValue( 5 );
113 }
114
115 return true;
116}
117
118
120{
122
124 prms->m_BestLengthRatio = m_spTeardropLenPercent->GetValue() / 100.0;
125 prms->m_BestWidthRatio = m_spTeardropSizePercent->GetValue() / 100.0;
128 prms->m_CurveSegCount = m_rbStraightLines->GetValue() ? 0 : m_curvePointsCtrl->GetValue();
129 prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercent->GetValue() / 100.0;
130 prms->m_TdOnPadsInZones = !m_cbPreferZoneConnection->GetValue();
132
133 prms = prmsList->GetParameters( TARGET_RECT );
134 prms->m_BestLengthRatio = m_spTeardropLenPercent1->GetValue() / 100.0;
135 prms->m_BestWidthRatio = m_spTeardropSizePercent1->GetValue() / 100.0;
138 prms->m_CurveSegCount = m_rbStraightLines1->GetValue() ? 0 : m_curvePointsCtrl1->GetValue();
139 prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercent1->GetValue() / 100.0;
140 prms->m_TdOnPadsInZones = !m_cbPreferZoneConnection1->GetValue();
142
143 prms = prmsList->GetParameters( TARGET_TRACK );
144 prms->m_BestLengthRatio = m_spTeardropLenPercent2->GetValue() / 100.0;
145 prms->m_BestWidthRatio = m_spTeardropSizePercent2->GetValue() / 100.0;
148 prms->m_CurveSegCount = m_rbStraightLines2->GetValue() ? 0 : m_curvePointsCtrl2->GetValue();
149 prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercent2->GetValue() / 100.0;
151
152 return true;
153}
154
155
157{
158 BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
159
160 m_BrdSettings = &aBoard->GetDesignSettings();
162
163 m_BrdSettings = savedSettings;
164}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:106
Container for design settings for a BOARD object.
TEARDROP_PARAMETERS_LIST * GetTeadropParamsList()
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:271
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:731
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.
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:160
BOARD * GetBoard()
@ TARGET_ROUND
@ TARGET_RECT
@ TARGET_TRACK