KiCad PCB EDA Suite
panel_display_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) 2015 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
5  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <pcb_edit_frame.h>
22 #include <pcb_display_options.h>
23 #include <pcbnew_settings.h>
24 #include <config_map.h>
25 #include <panel_display_options.h>
26 #include <pcb_view.h>
27 #include <pcb_painter.h>
28 #include <widgets/paged_dialog.h>
30 
31 
33 {
39 };
40 
41 
43  PAGED_DIALOG* aParent ) :
44  PANEL_DISPLAY_OPTIONS_BASE( aParent->GetTreebook() ),
45  m_frame( aFrame )
46 {
48  m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
49 
50  m_optionsBook->SetSelection( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) ? 1 : 0 );
51 }
52 
53 
55 {
56  PCB_EDIT_FRAME* pcbEdit = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
57 
58  if( pcbEdit )
59  {
60  const PCB_DISPLAY_OPTIONS& displ_opts = pcbEdit->GetDisplayOptions();
61 
64 
65  m_OptDisplayPadClearence->SetValue( displ_opts.m_DisplayPadIsol );
66  m_OptDisplayPadNumber->SetValue( displ_opts.m_DisplayPadNum );
68  m_ShowNetNamesOption->SetSelection( displ_opts.m_DisplayNetNamesMode );
69 
70  CROSS_PROBING_SETTINGS& crossProbing = pcbEdit->GetPcbNewSettings()->m_CrossProbing;
71 
72  m_checkCrossProbeCenter->SetValue( crossProbing.center_on_items );
73  m_checkCrossProbeZoom->SetValue( crossProbing.zoom_to_fit );
74  m_checkCrossProbeAutoHighlight->SetValue( crossProbing.auto_highlight );
75  }
76 
78 
79  return true;
80 }
81 
82 
83 /*
84  * Update variables with new options
85  */
87 {
89 
90  // Apply changes to the GAL
91  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
92  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
93  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
94 
95  PCB_EDIT_FRAME* pcbEdit = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
96 
97  if( pcbEdit )
98  {
99  PCB_DISPLAY_OPTIONS displ_opts = pcbEdit->GetDisplayOptions();
100 
103 
104  displ_opts.m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
105  displ_opts.m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
106 
108 
109  displ_opts.m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
110 
111  pcbEdit->SetDisplayOptions( displ_opts );
112  settings->LoadDisplayOptions( displ_opts, pcbEdit->ShowPageLimits() );
114 
115  CROSS_PROBING_SETTINGS& crossProbing = pcbEdit->GetPcbNewSettings()->m_CrossProbing;
116 
117  crossProbing.center_on_items = m_checkCrossProbeCenter->GetValue();
118  crossProbing.zoom_to_fit = m_checkCrossProbeZoom->GetValue();
119  crossProbing.auto_highlight = m_checkCrossProbeAutoHighlight->GetValue();
120  }
121 
122  view->RecacheAllItems();
124 
125  return true;
126 }
127 
128 
bool TransferDataFromWindow() override
show a marker on pads with no nets
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Change the visibility of an element category.
static const UTIL::CFG_MAP< PCB_DISPLAY_OPTIONS::TRACE_CLEARANCE_DISPLAY_MODE_T > traceClearanceSelectMap
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1372
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Class PANEL_DISPLAY_OPTIONS_BASE.
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:241
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
bool ShowPageLimits() const
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
GAL_OPTIONS_PANEL * m_galOptsPanel
PCB specific render settings.
Definition: pcb_painter.h:64
Cross-probing behavior.
Definition: app_settings.h:30
Container for display options like enable/disable some optional drawings.
bool TransferDataToWindow() override
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:247
PANEL_DISPLAY_OPTIONS(PCB_BASE_FRAME *aFrame, PAGED_DIALOG *aWindow)
bool TransferDataToWindow() override
Load the panel controls from the given opt.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:574
static CFG_NATIVE_VAL< MAP > GetValFromConfig(const MAP &aMap, long aConf)
Get the native value corresponding to the config value (read from file or UI, probably) and find it i...
Definition: config_map.h:96
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:33
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:34
The main frame for Pcbnew.
PCBNEW_SETTINGS * GetPcbNewSettings() const
std::vector< std::pair< T, long > > CFG_MAP
A config value table is a list of native values (usually enums) to a different set of values,...
Definition: config_map.h:49
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:167
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:32
Definition of PCB_DISPLAY_OPTIONS class.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static long GetConfigForVal(const MAP &aMap, CFG_NATIVE_VAL< MAP > aVal)
Get the mapped config value (the one to write to file, or use in an index) from the given native (pro...
Definition: config_map.h:69
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.