KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/dialogs/panel_setup_formatting.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 The 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 <sch_edit_frame.h>
25#include <sch_painter.h>
26#include <kiface_base.h>
28#include <sch_junction.h>
29#include <schematic.h>
30#include <schematic_settings.h>
33
34
37 m_frame( aFrame ),
38 m_textSize( aFrame, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ),
39 m_lineWidth( aFrame, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
40 m_pinSymbolSize( aFrame, m_pinSymbolSizeLabel, m_pinSymbolSizeCtrl, m_pinSymbolSizeUnits ),
41 m_connectionGridSize( aFrame, m_connectionGridLabel, m_connectionGridCtrl,
42 m_connectionGridUnits )
43{
44 wxSize minSize = m_dashLengthCtrl->GetMinSize();
45 int minWidth = m_dashLengthCtrl->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
46
47 m_dashLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
48 m_gapLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
49
50 m_dashedLineHelp->SetFont( KIUI::GetInfoFont( this ).Italic() );
51}
52
53
54void PANEL_SETUP_FORMATTING::onCheckBoxIref( wxCommandEvent& event )
55{
56 bool enabled = m_showIntersheetsReferences->GetValue();
57
58 m_radioFormatStandard->Enable( enabled );
59 m_radioFormatAbbreviated->Enable( enabled );
60 m_prefixLabel->Enable( enabled );
61 m_prefixCtrl->Enable( enabled );
62 m_suffixLabel->Enable( enabled );
63 m_suffixCtrl->Enable( enabled );
64 m_listOwnPage->Enable( enabled );
65}
66
67
68int getRefStyleMenuIndex( int aSubpartIdSeparator, int aFirstSubpartId )
69{
70 // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
71 switch( aSubpartIdSeparator )
72 {
73 default:
74 case 0: return 0;
75 case '.': return aFirstSubpartId == '1' ? 4 : 1;
76 case '-': return aFirstSubpartId == '1' ? 5 : 2;
77 case '_': return aFirstSubpartId == '1' ? 6 : 3;
78 }
79}
80
81
83{
85
87 settings.m_SubpartFirstId ) );
88
89 m_textSize.SetUnits( EDA_UNITS::MILS );
90 m_lineWidth.SetUnits( EDA_UNITS::MILS );
91 m_pinSymbolSize.SetUnits( EDA_UNITS::MILS );
92 m_connectionGridSize.SetUnits( EDA_UNITS::MILS );
93
97 m_choiceJunctionDotSize->SetSelection( settings.m_JunctionSizeChoice );
99
101
104 m_prefixLabel->Enable( settings.m_IntersheetRefsShow );
105 m_prefixCtrl->Enable( settings.m_IntersheetRefsShow );
106 m_suffixLabel->Enable( settings.m_IntersheetRefsShow );
107 m_suffixCtrl->Enable( settings.m_IntersheetRefsShow );
108 m_listOwnPage->Enable( settings.m_IntersheetRefsShow );
109
112 m_prefixCtrl->ChangeValue( settings.m_IntersheetRefsPrefix );
113 m_suffixCtrl->ChangeValue( settings.m_IntersheetRefsSuffix );
114 m_listOwnPage->SetValue( settings.m_IntersheetRefsListOwnPage );
115
116#define SET_VALUE( ctrl, units, value ) \
117 ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
118
119 SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, settings.m_TextOffsetRatio * 100.0 );
120 SET_VALUE( m_overbarHeightCtrl, EDA_UNITS::PERCENT,
121 settings.m_FontMetrics.m_OverbarHeight * 100.0 );
122 SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineDashRatio );
123 SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineGapRatio );
124 SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, settings.m_LabelSizeRatio * 100.0 );
125
126#undef SET_VALUE
127
128 m_vPrecisionCtrl->SetValue( settings.m_OPO_VPrecision );
129 m_vRangeCtrl->SetStringSelection( settings.m_OPO_VRange );
130 m_iPrecisionCtrl->SetValue( settings.m_OPO_IPrecision );
131 m_iRangeCtrl->SetStringSelection( settings.m_OPO_IRange );
132
133 return true;
134}
135
136
138{
139 if( !m_connectionGridSize.Validate( MIN_CONNECTION_GRID_MILS, 10000, EDA_UNITS::MILS ) )
140 return false;
141
143
144 // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
145 switch( m_choiceSeparatorRefId->GetSelection() )
146 {
147 default:
148 case 0: settings.m_SubpartFirstId = 'A'; settings.m_SubpartIdSeparator = 0; break;
149 case 1: settings.m_SubpartFirstId = 'A'; settings.m_SubpartIdSeparator = '.'; break;
150 case 2: settings.m_SubpartFirstId = 'A'; settings.m_SubpartIdSeparator = '-'; break;
151 case 3: settings.m_SubpartFirstId = 'A'; settings.m_SubpartIdSeparator = '_'; break;
152 case 4: settings.m_SubpartFirstId = '1'; settings.m_SubpartIdSeparator = '.'; break;
153 case 5: settings.m_SubpartFirstId = '1'; settings.m_SubpartIdSeparator = '-'; break;
154 case 6: settings.m_SubpartFirstId = '1'; settings.m_SubpartIdSeparator = '_'; break;
155 }
156
161
162 if( m_choiceJunctionDotSize->GetSelection() != wxNOT_FOUND )
163 settings.m_JunctionSizeChoice = m_choiceJunctionDotSize->GetSelection();
164
167 settings.m_IntersheetRefsPrefix = m_prefixCtrl->GetValue();
168 settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue();
169 settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue();
170
171#define GET_VALUE( units, str ) EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, units, str )
172
173 settings.m_TextOffsetRatio = GET_VALUE( EDA_UNITS::PERCENT,
174 m_textOffsetRatioCtrl->GetValue() ) / 100.0;
175 settings.m_FontMetrics.m_OverbarHeight = GET_VALUE( EDA_UNITS::PERCENT,
176 m_overbarHeightCtrl->GetValue() ) / 100.0;
177 settings.m_DashedLineDashRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() );
178 settings.m_DashedLineGapRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() );
179 settings.m_LabelSizeRatio = GET_VALUE( EDA_UNITS::PERCENT,
180 m_labelSizeRatioCtrl->GetValue() ) / 100.0;
181
182#undef GET_VALUE
183
184 settings.m_OPO_VPrecision = m_vPrecisionCtrl->GetValue();
185
186 if( m_vRangeCtrl->GetSelection() == 0 )
187 settings.m_OPO_VRange = wxS( "~V" );
188 else
189 settings.m_OPO_VRange = m_vRangeCtrl->GetStringSelection();
190
191 settings.m_OPO_IPrecision = m_iPrecisionCtrl->GetValue();
192
193 if( m_iRangeCtrl->GetSelection() == 0 )
194 settings.m_OPO_IRange = wxS( "~A" );
195 else
196 settings.m_OPO_IRange = m_iRangeCtrl->GetStringSelection();
197
198 return true;
199}
200
201
203{
205 aSettings.m_SubpartFirstId ) );
206
211
215 m_prefixCtrl->ChangeValue( aSettings.m_IntersheetRefsPrefix );
216 m_suffixCtrl->ChangeValue( aSettings.m_IntersheetRefsSuffix );
217 m_listOwnPage->SetValue( aSettings.m_IntersheetRefsListOwnPage );
218
219#define SET_VALUE( ctrl, units, value ) \
220 ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
221
222 SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_TextOffsetRatio * 100.0 );
223 SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineDashRatio );
224 SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineGapRatio );
225 SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_LabelSizeRatio * 100.0 );
226
227#undef SET_VALUE
228}
double m_OverbarHeight
Definition: font.h:123
PANEL_SETUP_FORMATTING(wxWindow *aWindow, SCH_EDIT_FRAME *aFrame)
void onCheckBoxIref(wxCommandEvent &event) override
void ImportSettingsFrom(SCHEMATIC_SETTINGS &aSettings)
These are loaded from Eeschema settings but then overwritten by the project settings.
KIFONT::METRICS m_FontMetrics
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
int GetIntValue()
Definition: unit_binder.h:129
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
const int minSize
Push and Shove router track width and via size dialog.
#define SET_VALUE(ctrl, units, value)
#define GET_VALUE(units, str)
int getRefStyleMenuIndex(int aSubpartIdSeparator, int aFirstSubpartId)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:155
#define MIN_CONNECTION_GRID_MILS