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 (C) 2020-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 <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{
42 wxSize minSize = m_dashLengthCtrl->GetMinSize();
43 int minWidth = m_dashLengthCtrl->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
44
45 m_dashLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
46 m_gapLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
47
48 m_dashedLineHelp->SetFont( KIUI::GetInfoFont( this ).Italic() );
49}
50
51
52void PANEL_SETUP_FORMATTING::onCheckBoxIref( wxCommandEvent& event )
53{
54 bool enabled = m_showIntersheetsReferences->GetValue();
55
56 m_radioFormatStandard->Enable( enabled );
57 m_radioFormatAbbreviated->Enable( enabled );
58 m_prefixLabel->Enable( enabled );
59 m_prefixCtrl->Enable( enabled );
60 m_suffixLabel->Enable( enabled );
61 m_suffixCtrl->Enable( enabled );
62 m_listOwnPage->Enable( enabled );
63}
64
65
67{
69
70 // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
71 int refStyleSelection;
72
74 {
75 default:
76 case 0: refStyleSelection = 0; break;
77 case '.': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 4 : 1; break;
78 case '-': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 5 : 2; break;
79 case '_': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 6 : 3; break;
80 }
81
82 m_choiceSeparatorRefId->SetSelection( refStyleSelection );
83
84 m_textSize.SetUnits( EDA_UNITS::MILS );
85 m_lineWidth.SetUnits( EDA_UNITS::MILS );
86 m_pinSymbolSize.SetUnits( EDA_UNITS::MILS );
87
91 m_choiceJunctionDotSize->SetSelection( settings.m_JunctionSizeChoice );
92
94
97 m_prefixLabel->Enable( settings.m_IntersheetRefsShow );
98 m_prefixCtrl->Enable( settings.m_IntersheetRefsShow );
99 m_suffixLabel->Enable( settings.m_IntersheetRefsShow );
100 m_suffixCtrl->Enable( settings.m_IntersheetRefsShow );
101 m_listOwnPage->Enable( settings.m_IntersheetRefsShow );
102
105 m_prefixCtrl->ChangeValue( settings.m_IntersheetRefsPrefix );
106 m_suffixCtrl->ChangeValue( settings.m_IntersheetRefsSuffix );
107 m_listOwnPage->SetValue( settings.m_IntersheetRefsListOwnPage );
108
109#define SET_VALUE( ctrl, units, value ) \
110 ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
111
112 SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, settings.m_TextOffsetRatio * 100.0 );
113 SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineDashRatio );
114 SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineGapRatio );
115 SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, settings.m_LabelSizeRatio * 100.0 );
116
117#undef SET_VALUE
118
119 m_vPrecisionCtrl->SetValue( settings.m_OPO_VPrecision );
120 m_vRangeCtrl->SetStringSelection( settings.m_OPO_VRange );
121 m_iPrecisionCtrl->SetValue( settings.m_OPO_IPrecision );
122 m_iRangeCtrl->SetStringSelection( settings.m_OPO_IRange );
123
124 return true;
125}
126
127
129{
131
132 // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
133 int firstRefId, refSeparator;
134
135 switch( m_choiceSeparatorRefId->GetSelection() )
136 {
137 default:
138 case 0: firstRefId = 'A'; refSeparator = 0; break;
139 case 1: firstRefId = 'A'; refSeparator = '.'; break;
140 case 2: firstRefId = 'A'; refSeparator = '-'; break;
141 case 3: firstRefId = 'A'; refSeparator = '_'; break;
142 case 4: firstRefId = '1'; refSeparator = '.'; break;
143 case 5: firstRefId = '1'; refSeparator = '-'; break;
144 case 6: firstRefId = '1'; refSeparator = '_'; break;
145 }
146
147 if( refSeparator != LIB_SYMBOL::GetSubpartIdSeparator() ||
148 firstRefId != LIB_SYMBOL::GetSubpartFirstId() )
149 {
150 LIB_SYMBOL::SetSubpartIdNotation( refSeparator, firstRefId );
151 }
152
153 settings.m_DefaultTextSize = (int) m_textSize.GetValue();
154 settings.m_DefaultLineWidth = (int) m_lineWidth.GetValue();
155 settings.m_PinSymbolSize = (int) m_pinSymbolSize.GetValue();
156
157 if( m_choiceJunctionDotSize->GetSelection() != wxNOT_FOUND )
158 settings.m_JunctionSizeChoice = m_choiceJunctionDotSize->GetSelection();
159
162 settings.m_IntersheetRefsPrefix = m_prefixCtrl->GetValue();
163 settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue();
164 settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue();
165
166#define GET_VALUE( units, str ) EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, units, str )
167
168 settings.m_TextOffsetRatio = GET_VALUE( EDA_UNITS::PERCENT, m_textOffsetRatioCtrl->GetValue() ) / 100.0;
169 settings.m_DashedLineDashRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() );
170 settings.m_DashedLineGapRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() );
171 settings.m_LabelSizeRatio = GET_VALUE( EDA_UNITS::PERCENT, m_labelSizeRatioCtrl->GetValue() ) / 100.0;
172
173#undef GET_VALUE
174
175 settings.m_OPO_VPrecision = m_vPrecisionCtrl->GetValue();
176
177 if( m_vRangeCtrl->GetSelection() == 0 )
178 settings.m_OPO_VRange = wxS( "~V" );
179 else
180 settings.m_OPO_VRange = m_vRangeCtrl->GetStringSelection();
181
182 settings.m_OPO_IPrecision = m_iPrecisionCtrl->GetValue();
183
184 if( m_iRangeCtrl->GetSelection() == 0 )
185 settings.m_OPO_IRange = wxS( "~A" );
186 else
187 settings.m_OPO_IRange = m_iRangeCtrl->GetStringSelection();
188
189 return true;
190}
191
192
194{
198
202 m_prefixCtrl->ChangeValue( aSettings.m_IntersheetRefsPrefix );
203 m_suffixCtrl->ChangeValue( aSettings.m_IntersheetRefsSuffix );
204 m_listOwnPage->SetValue( aSettings.m_IntersheetRefsListOwnPage );
205
206#define SET_VALUE( ctrl, units, value ) \
207 ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
208
209 SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_TextOffsetRatio * 100.0 );
210 SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineDashRatio );
211 SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineGapRatio );
212 SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_LabelSizeRatio * 100.0 );
213
214#undef SET_VALUE
215}
static int GetSubpartIdSeparator()
Definition: lib_symbol.h:577
static int GetSubpartFirstId()
Definition: lib_symbol.h:583
static void SetSubpartIdNotation(int aSep, int aFirstId)
Set the separator char between the subpart id and the reference 0 (no separator) or '.
PANEL_SETUP_FORMATTING(wxWindow *aWindow, SCH_EDIT_FRAME *aFrame)
void onCheckBoxIref(wxCommandEvent &event) override
void ImportSettingsFrom(SCHEMATIC_SETTINGS &aSettings)
These settings were stored in SCH_BASE_FRAME previously.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
virtual long long int GetValue()
Return the current value in Internal Units.
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 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)
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156