KiCad PCB EDA Suite
panel_pcbnew_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-2018 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 <fctsys.h>
22 #include <class_drawpanel.h>
23 #include <pcbnew.h>
24 #include <pcb_edit_frame.h>
25 #include <pcb_display_options.h>
26 #include <config_map.h>
27 #include <pcbnew_id.h>
29 #include <class_draw_panel_gal.h>
30 #include <pcb_view.h>
31 #include <pcb_painter.h>
32 #include <widgets/paged_dialog.h>
33 
35 
36 
38 {
44 };
45 
46 
48  PAGED_DIALOG* aParent ) :
49  PANEL_PCBNEW_DISPLAY_OPTIONS_BASE( aParent->GetTreebook() ),
50  m_frame( aFrame )
51 {
53  m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
54 
55  m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
56 }
57 
58 
60 {
62 
65 
66  m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol );
67  m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum );
69  m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode );
70 
72 
73  return true;
74 }
75 
76 
77 /*
78  * Update variables with new options
79  */
81 {
83 
86 
87  displ_opts->m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
88  displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
89 
91 
92  displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
93 
95 
96  // Apply changes to the GAL
98  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
99  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
100  settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() );
101  view->RecacheAllItems();
103 
104  m_frame->GetCanvas()->Refresh();
105 
106  return true;
107 }
108 
109 
bool ShowPageLimits() const
Definition: draw_frame.h:385
show a marker on pads with no nets
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:388
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:939
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1392
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:211
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
Auxiliary rendering target (noncached)
Definition: definitions.h:42
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
static const UTIL::CFG_MAP< PCB_DISPLAY_OPTIONS::TRACE_CLEARANCE_DISPLAY_MODE_T > traceClearanceSelectMap
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:223
bool TransferDataToWindow() override
Load the panel controls from the given opt.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:596
PANEL_PCBNEW_DISPLAY_OPTIONS(PCB_EDIT_FRAME *aFrame, PAGED_DIALOG *aWindow)
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
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
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS *aOptions, bool aShowPageLimits)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode...
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:921
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
Class VIEW.
Definition: view.h:61
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
Definition of PCB_DISPLAY_OPTIONS class.
Class PANEL_PCBNEW_DISPLAY_OPTIONS_BASE.
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.