KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_eeschema_annotation_options.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) 2022 Mike Williams <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <pgm_base.h>
26#include <refdes_tracker.h>
29#include <schematic.h>
30#include <schematic_settings.h>
31#include <sch_edit_frame.h>
33
34
43
44
46{
47 int annotateStartNum = aCfg->m_AnnotateStartNum;
48
49 switch( aCfg->m_AnnotateSortOrder )
50 {
51 default:
52 case SORT_BY_X_POSITION: m_rbSortBy_X_Position->SetValue( true ); break;
53 case SORT_BY_Y_POSITION: m_rbSortBy_Y_Position->SetValue( true ); break;
54 }
55
56 switch( aCfg->m_AnnotateMethod )
57 {
58 default:
59 case INCREMENTAL_BY_REF: m_rbFirstFree->SetValue( true ); break;
60 case SHEET_NUMBER_X_100: m_rbSheetX100->SetValue( true ); break;
61 case SHEET_NUMBER_X_1000: m_rbSheetX1000->SetValue( true ); break;
62 }
63
64 m_textNumberAfter->SetValue( wxString::Format( wxT( "%d" ), annotateStartNum ) );
65
66 if( aCfg->m_SubpartFirstId == 'A' )
67 {
68 switch( aCfg->m_SubpartIdSeparator )
69 {
70 default:
71 case 0: m_choiceSeparatorRefId->SetSelection( 0 ); break;
72 case '.': m_choiceSeparatorRefId->SetSelection( 1 ); break;
73 case '-': m_choiceSeparatorRefId->SetSelection( 2 ); break;
74 case '_': m_choiceSeparatorRefId->SetSelection( 3 ); break;
75 }
76 }
77 else
78 {
79 switch( aCfg->m_SubpartIdSeparator )
80 {
81 default:
82 case '.': m_choiceSeparatorRefId->SetSelection( 4 ); break;
83 case '-': m_choiceSeparatorRefId->SetSelection( 5 ); break;
84 case '_': m_choiceSeparatorRefId->SetSelection( 6 ); break;
85 }
86 }
87
89}
90
91
93{
94 if( SCH_EDIT_FRAME* schFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_schSettingsProvider ) )
95 loadEEschemaSettings( &schFrame->Schematic().Settings() );
96
97 return true;
98}
99
100
102{
103 if( SCH_EDIT_FRAME* schFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_schSettingsProvider ) )
104 {
105 SCHEMATIC_SETTINGS& projSettings = schFrame->Schematic().Settings();
106
107 projSettings.m_AnnotateSortOrder = m_rbSortBy_Y_Position->GetValue() ?
109
110 if( m_rbSheetX100->GetValue() )
112 else if( m_rbSheetX1000->GetValue() )
114 else
116
118 projSettings.m_refDesTracker->SetReuseRefDes( m_checkReuseRefdes->GetValue() );
119
120 switch( m_choiceSeparatorRefId->GetSelection() )
121 {
122 default:
123 case 0: projSettings.m_SubpartFirstId = 'A'; projSettings.m_SubpartIdSeparator = 0; break;
124 case 1: projSettings.m_SubpartFirstId = 'A'; projSettings.m_SubpartIdSeparator = '.'; break;
125 case 2: projSettings.m_SubpartFirstId = 'A'; projSettings.m_SubpartIdSeparator = '-'; break;
126 case 3: projSettings.m_SubpartFirstId = 'A'; projSettings.m_SubpartIdSeparator = '_'; break;
127 case 4: projSettings.m_SubpartFirstId = '1'; projSettings.m_SubpartIdSeparator = '.'; break;
128 case 5: projSettings.m_SubpartFirstId = '1'; projSettings.m_SubpartIdSeparator = '-'; break;
129 case 6: projSettings.m_SubpartFirstId = '1'; projSettings.m_SubpartIdSeparator = '_'; break;
130 }
131
132 }
133
134 return true;
135}
136
137
143
144
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
@ annotate_down_right
@ annotate_right_down
The base frame for deriving all KiCad main window classes.
PANEL_EESCHEMA_ANNOTATION_OPTIONS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void ImportSettingsFrom(SCHEMATIC_SETTINGS &aSettings)
void ResetPanel() override
Reset the contents of this panel.
PANEL_EESCHEMA_ANNOTATION_OPTIONS(wxWindow *aWindow, EDA_BASE_FRAME *schSettingsProvider)
void SetReuseRefDes(bool aReuse)
bool GetReuseRefDes() const
These are loaded from Eeschema settings but then overwritten by the project settings.
std::shared_ptr< REFDES_TRACKER > m_refDesTracker
A list of previously used schematic reference designators.
Schematic editor (Eeschema) main window.
KICOMMON_API long long int ValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue in aUnits to internal units used by the application.
see class PGM_BASE
@ SORT_BY_X_POSITION
Annotate by X position from left to right.
@ SORT_BY_Y_POSITION
Annotate by Y position from top to bottom.
@ SHEET_NUMBER_X_1000
Annotate using the first free reference number starting at the sheet number * 1000.
@ INCREMENTAL_BY_REF
Annotate incrementally using the first free reference number.
@ SHEET_NUMBER_X_100
Annotate using the first free reference number starting at the sheet number * 100.