KiCad PCB EDA Suite
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 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 <fctsys.h>
25 #include <sch_edit_frame.h>
26 #include <sch_painter.h>
27 #include <class_libentry.h>
28 #include <panel_setup_formatting.h>
29 #include <sch_junction.h>
30 #include <gr_text.h>
31 #include <schematic.h>
32 #include <schematic_settings.h>
33 
34 
36  PANEL_SETUP_FORMATTING_BASE( aWindow ),
37  m_frame( aFrame ),
38  m_textSize( aFrame, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
39  m_lineWidth( aFrame, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ),
40  m_busWidth( aFrame, m_busWidthLabel, m_busWidthCtrl, m_busWidthUnits, true ),
41  m_wireWidth( aFrame, m_wireWidthLabel, m_wireWidthCtrl, m_wireWidthUnits, true ),
42  m_pinSymbolSize( aFrame, m_pinSymbolSizeLabel, m_pinSymbolSizeCtrl, m_pinSymbolSizeUnits, true ),
43  m_junctionSize( aFrame, m_jctSizeLabel, m_jctSizeCtrl, m_jctSizeUnits, true )
44 {
45 }
46 
47 
49 {
51 
52  // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
53  int refStyleSelection;
54 
56  {
57  default:
58  case 0: refStyleSelection = 0; break;
59  case '.': refStyleSelection = LIB_PART::GetSubpartFirstId() == '1' ? 4 : 1; break;
60  case '-': refStyleSelection = LIB_PART::GetSubpartFirstId() == '1' ? 5 : 2; break;
61  case '_': refStyleSelection = LIB_PART::GetSubpartFirstId() == '1' ? 6 : 3; break;
62  }
63 
64  m_choiceSeparatorRefId->SetSelection( refStyleSelection );
65 
72 
79 
80  wxString offsetRatio = wxString::Format( "%f", settings.m_TextOffsetRatio * 100.0 );
81  m_textOffsetRatioCtrl->SetValue( offsetRatio );
82 
83  return true;
84 }
85 
86 
88 {
90 
91  // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
92  int firstRefId, refSeparator;
93 
94  switch( m_choiceSeparatorRefId->GetSelection() )
95  {
96  default:
97  case 0: firstRefId = 'A'; refSeparator = 0; break;
98  case 1: firstRefId = 'A'; refSeparator = '.'; break;
99  case 2: firstRefId = 'A'; refSeparator = '-'; break;
100  case 3: firstRefId = 'A'; refSeparator = '_'; break;
101  case 4: firstRefId = '1'; refSeparator = '.'; break;
102  case 5: firstRefId = '1'; refSeparator = '-'; break;
103  case 6: firstRefId = '1'; refSeparator = '_'; break;
104  }
105 
106  if( refSeparator != LIB_PART::GetSubpartIdSeparator() ||
107  firstRefId != LIB_PART::GetSubpartFirstId() )
108  {
109  LIB_PART::SetSubpartIdNotation( refSeparator, firstRefId );
110  }
111 
112  settings.m_DefaultTextSize = (int) m_textSize.GetValue();
113  settings.m_DefaultLineWidth = (int) m_lineWidth.GetValue();
114  settings.m_DefaultWireThickness = (int) m_wireWidth.GetValue();
115  settings.m_DefaultBusThickness = (int) m_busWidth.GetValue();
116  settings.m_PinSymbolSize = (int) m_pinSymbolSize.GetValue();
117  settings.m_JunctionSize = (int) m_junctionSize.GetValue();
118 
120 
121  double dtmp = 0.0;
122  wxString msg = m_textOffsetRatioCtrl->GetValue();
123  msg.ToDouble( &dtmp );
124  settings.m_TextOffsetRatio = dtmp / 100.0;
125 
132 
135  m_frame->GetCanvas()->Refresh();
136 
137  return true;
138 }
139 
140 
142 {
149 
150  wxString offsetRatio = wxString::Format( "%f", aSettings.m_TextOffsetRatio * 100.0 );
151  m_textOffsetRatioCtrl->SetValue( offsetRatio );
152 }
153 
154 
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
PANEL_SETUP_FORMATTING(wxWindow *aWindow, SCH_EDIT_FRAME *aFrame)
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:138
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1444
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
Schematic editor (Eeschema) main window.
bool TransferDataFromWindow() override
Class PANEL_SETUP_FORMATTING_BASE.
static int GetSubpartIdSeparator()
Item is being added to the view.
Definition: view_item.h:62
static int GetSubpartFirstId()
Class LIB_PIN definition.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static void SetSubpartIdNotation(int aSep, int aFirstId)
Set the separator char between the subpart id and the reference 0 (no separator) or '.
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
These settings were stored in SCH_BASE_FRAME previously.
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
void ImportSettingsFrom(SCHEMATIC_SETTINGS &aSettings)
void SetDefaultPenWidth(int aWidth)
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:610
virtual void SetUnits(EDA_UNITS aUnits, bool aUseMils=false)
Function SetUnits Normally not needed (as the UNIT_BINDER inherits from the parent frame),...
Definition: unit_binder.cpp:79