KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew/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 <pcb_edit_frame.h>
25#include <pcb_painter.h>
26#include <board.h>
29
30
32 PANEL_SETUP_FORMATTING_BASE( aParentWindow ),
33 m_frame( aFrame )
34{
35 wxSize minSize = m_dashLengthCtrl->GetMinSize();
36 int minWidth = m_dashLengthCtrl->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
37
38 m_dashLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
39 m_gapLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
40
41 m_dashedLineHelp->SetFont( KIUI::GetInfoFont( this ).Italic() );
42}
43
44
46{
47 const PCB_PLOT_PARAMS& settings = m_frame->GetBoard()->GetPlotOptions();
48
50 settings.GetDashedLineDashRatio() ) );
51
52 m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
53 settings.GetDashedLineGapRatio() ) );
54
55 BOARD_DESIGN_SETTINGS& bds = m_frame->GetBoard()->GetDesignSettings();
56
57 m_styleFields->SetValue( bds.m_StyleFPFields );
58 m_styleText->SetValue( bds.m_StyleFPText );
59 m_styleShapes->SetValue( bds.m_StyleFPShapes );
60
61 return true;
62}
63
64
66{
67 PCB_PLOT_PARAMS settings = m_frame->GetBoard()->GetPlotOptions();
68
71
72 m_frame->GetBoard()->SetPlotOptions( settings );
73
74 BOARD_DESIGN_SETTINGS& bds = m_frame->GetBoard()->GetDesignSettings();
75
76 bds.m_StyleFPFields = m_styleFields->GetValue();
77 bds.m_StyleFPText = m_styleText->GetValue();
78 bds.m_StyleFPShapes = m_styleShapes->GetValue();
79
81
84
86 [] ( KIGFX::VIEW_ITEM* aItem ) -> bool
87 {
88 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
89 return item && item->Type() == PCB_SHAPE_T;
90 } );
92
93 return true;
94}
95
96
98{
99 const PCB_PLOT_PARAMS& importedSettings = aBoard->GetPlotOptions();
100
101 m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
102 importedSettings.GetDashedLineDashRatio() ) );
103
104 m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
105 importedSettings.GetDashedLineGapRatio() ) );
106
107 m_styleFields->SetValue( aBoard->GetDesignSettings().m_StyleFPFields );
108 m_styleText->SetValue( aBoard->GetDesignSettings().m_StyleFPText );
109 m_styleShapes->SetValue( aBoard->GetDesignSettings().m_StyleFPShapes );
110}
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:111
Container for design settings for a BOARD object.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:692
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:892
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:217
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1555
PANEL_SETUP_FORMATTING(wxWindow *aWindow, SCH_EDIT_FRAME *aFrame)
void ImportSettingsFrom(SCHEMATIC_SETTINGS &aSettings)
The main frame for Pcbnew.
Parameters and options when plotting/printing a board.
void SetDashedLineGapRatio(double aVal)
void SetDashedLineDashRatio(double aVal)
double GetDashedLineGapRatio() const
double GetDashedLineDashRatio() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
const int minSize
Push and Shove router track width and via size dialog.
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:300
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:576
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88