KiCad PCB EDA Suite
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-2022 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 m_dashedLineHelp->SetFont( KIUI::GetInfoFont( this ).Italic() );
43}
44
45
46void PANEL_SETUP_FORMATTING::onCheckBoxIref( wxCommandEvent& event )
47{
48 bool enabled = m_showIntersheetsReferences->GetValue();
49
50 m_radioFormatStandard->Enable( enabled );
51 m_radioFormatAbbreviated->Enable( enabled );
52 m_prefixLabel->Enable( enabled );
53 m_prefixCtrl->Enable( enabled );
54 m_suffixLabel->Enable( enabled );
55 m_suffixCtrl->Enable( enabled );
56 m_listOwnPage->Enable( enabled );
57}
58
59
61{
63
64 // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
65 int refStyleSelection;
66
68 {
69 default:
70 case 0: refStyleSelection = 0; break;
71 case '.': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 4 : 1; break;
72 case '-': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 5 : 2; break;
73 case '_': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 6 : 3; break;
74 }
75
76 m_choiceSeparatorRefId->SetSelection( refStyleSelection );
77
81
85 m_choiceJunctionDotSize->SetSelection( settings.m_JunctionSizeChoice );
86
88
91 m_prefixLabel->Enable( settings.m_IntersheetRefsShow );
92 m_prefixCtrl->Enable( settings.m_IntersheetRefsShow );
93 m_suffixLabel->Enable( settings.m_IntersheetRefsShow );
94 m_suffixCtrl->Enable( settings.m_IntersheetRefsShow );
95 m_listOwnPage->Enable( settings.m_IntersheetRefsShow );
96
99 m_prefixCtrl->ChangeValue( settings.m_IntersheetRefsPrefix );
100 m_suffixCtrl->ChangeValue( settings.m_IntersheetRefsSuffix );
101 m_listOwnPage->SetValue( settings.m_IntersheetRefsListOwnPage );
102
103#define SET_VALUE( ctrl, units, value ) \
104 ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
105
110
111#undef SET_VALUE
112
113 return true;
114}
115
116
118{
120
121 // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
122 int firstRefId, refSeparator;
123
124 switch( m_choiceSeparatorRefId->GetSelection() )
125 {
126 default:
127 case 0: firstRefId = 'A'; refSeparator = 0; break;
128 case 1: firstRefId = 'A'; refSeparator = '.'; break;
129 case 2: firstRefId = 'A'; refSeparator = '-'; break;
130 case 3: firstRefId = 'A'; refSeparator = '_'; break;
131 case 4: firstRefId = '1'; refSeparator = '.'; break;
132 case 5: firstRefId = '1'; refSeparator = '-'; break;
133 case 6: firstRefId = '1'; refSeparator = '_'; break;
134 }
135
136 if( refSeparator != LIB_SYMBOL::GetSubpartIdSeparator() ||
137 firstRefId != LIB_SYMBOL::GetSubpartFirstId() )
138 {
139 LIB_SYMBOL::SetSubpartIdNotation( refSeparator, firstRefId );
140 }
141
142 settings.m_DefaultTextSize = (int) m_textSize.GetValue();
143 settings.m_DefaultLineWidth = (int) m_lineWidth.GetValue();
144 settings.m_PinSymbolSize = (int) m_pinSymbolSize.GetValue();
145
146 if( m_choiceJunctionDotSize->GetSelection() != wxNOT_FOUND )
147 settings.m_JunctionSizeChoice = m_choiceJunctionDotSize->GetSelection();
148
151 settings.m_IntersheetRefsPrefix = m_prefixCtrl->GetValue();
152 settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue();
153 settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue();
154
155#define GET_VALUE( units, str ) EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, units, str )
156
157 settings.m_TextOffsetRatio = GET_VALUE( EDA_UNITS::PERCENT, m_textOffsetRatioCtrl->GetValue() ) / 100.0;
160 settings.m_LabelSizeRatio = GET_VALUE( EDA_UNITS::PERCENT, m_labelSizeRatioCtrl->GetValue() ) / 100.0;
161
162#undef GET_VALUE
163
164 return true;
165}
166
167
169{
173
177 m_prefixCtrl->ChangeValue( aSettings.m_IntersheetRefsPrefix );
178 m_suffixCtrl->ChangeValue( aSettings.m_IntersheetRefsSuffix );
179 m_listOwnPage->SetValue( aSettings.m_IntersheetRefsListOwnPage );
180
181#define SET_VALUE( ctrl, units, value ) \
182 ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
183
188
189#undef SET_VALUE
190}
static int GetSubpartIdSeparator()
Definition: lib_symbol.h:581
static int GetSubpartFirstId()
Definition: lib_symbol.h:587
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:172
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.
#define SET_VALUE(ctrl, units, value)
#define GET_VALUE(units, str)
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144