KiCad PCB EDA Suite
pcbnew/dialogs/dialog_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-2016 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 /* functions relatives to the dialog opened from the main menu :
26  Preferences/display
27 */
28 
29 #include <fctsys.h>
30 #include <class_drawpanel.h>
31 #include <confirm.h>
32 #include <pcbnew.h>
33 #include <wxPcbStruct.h>
34 #include <pcbstruct.h>
35 #include <config_map.h>
36 
37 #include <pcbnew_id.h>
38 
39 #include <dialog_display_options.h>
41 
42 #include <class_draw_panel_gal.h>
43 #include <view/view.h>
44 #include <pcb_painter.h>
45 
47 
48 
50 {
52  { DO_NOT_SHOW_CLEARANCE, 0 },
55  { SHOW_CLEARANCE_ALWAYS, 4 },
56 };
57 
58 
59 void PCB_EDIT_FRAME::InstallDisplayOptionsDialog( wxCommandEvent& aEvent )
60 {
61  DIALOG_DISPLAY_OPTIONS dlg( this );
62  dlg.ShowModal();
63 }
64 
65 
68  m_parent( parent )
69 {
71  m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
72 
73  sLeftSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
74 
75  SetFocus();
76 
77  m_sdbSizerOK->SetDefault();
78 
79  // Now all widgets have the size fixed, call FinishDialogSettings
81 }
82 
83 
85 {
87 
88  m_OptDisplayTracks->SetValue( displ_opts->m_DisplayPcbTrackFill == SKETCH );
89 
92 
93  m_OptDisplayPads->SetValue( displ_opts->m_DisplayPadFill == SKETCH );
94  m_OptDisplayVias->SetValue( displ_opts->m_DisplayViaFill == SKETCH );
95 
97 
98  m_OptDisplayModTexts->SetValue( displ_opts->m_DisplayModTextFill == SKETCH );
99  m_OptDisplayModOutlines->SetValue( displ_opts->m_DisplayModEdgeFill == SKETCH );
100  m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol );
101  m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum );
103  m_OptDisplayDrawings->SetValue( displ_opts->m_DisplayDrawItemsFill == SKETCH );
104  m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode );
105 
107 
108  return true;
109 }
110 
111 
112 /*
113  * Update variables with new options
114  */
116 {
118 
120 
121  displ_opts->m_DisplayPcbTrackFill = not m_OptDisplayTracks->GetValue();
122 
125 
126  displ_opts->m_DisplayModTextFill = not m_OptDisplayModTexts->GetValue();
127  displ_opts->m_DisplayModEdgeFill = not m_OptDisplayModOutlines->GetValue();
128 
129  displ_opts->m_DisplayPadFill = not m_OptDisplayPads->GetValue();
130  displ_opts->m_DisplayViaFill = not m_OptDisplayVias->GetValue();
131 
132  displ_opts->m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
133 
134  displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
135 
137  m_OptDisplayPadNoConn->GetValue() );
138 
139  displ_opts->m_DisplayDrawItemsFill = not m_OptDisplayDrawings->GetValue();
140  displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
141 
143 
144  // Apply changes to the GAL
146  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
147  KIGFX::PCB_RENDER_SETTINGS* settings =
148  static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
149  settings->LoadDisplayOptions( displ_opts );
150  view->RecacheAllItems();
152 
153  m_parent->GetCanvas()->Refresh();
154 
155  return true;
156 }
bool ShowPageLimits() const
Definition: draw_frame.h:296
void InstallDisplayOptionsDialog(wxCommandEvent &aEvent)
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.
Definition: pcbframe.cpp:936
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:824
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
This file is part of the common library.
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1253
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool m_DisplayModEdgeFill
Definition: pcbstruct.h:69
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void LoadDisplayOptions(const DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode...
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:163
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Auxiliary rendering target (noncached)
Definition: definitions.h:42
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
bool m_DisplayPcbTrackFill
Definition: pcbstruct.h:71
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
Definition: pcbframe.cpp:930
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:175
bool TransferDataToWindow() override
Load the panel controls from the given opt.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:575
Classes and definitions used in Pcbnew.
bool m_DisplayDrawItemsFill
Definition: pcbstruct.h:84
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
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
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
Definition: pcbstruct.h:74
static const UTIL::CFG_MAP< TRACE_CLEARANCE_DISPLAY_MODE_T > traceClearanceSelectMap
bool m_DisplayPadFill
Definition: pcbstruct.h:65
bool m_DisplayPadIsol
Definition: pcbstruct.h:68
bool m_DisplayPadNum
Definition: pcbstruct.h:67
int m_DisplayNetNamesMode
Definition: pcbstruct.h:78
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:803
void SetShowPageLimits(bool aShow)
Definition: draw_frame.h:297
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:58
bool m_DisplayViaFill
Definition: pcbstruct.h:66
bool m_DisplayModTextFill
Definition: pcbstruct.h:70
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.