KiCad PCB EDA Suite
pcb_editor_conditions.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 Ian McInerney <ian.s.mcinerney at ieee.org>
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
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 
26 #include "pcbnew_settings.h"
27 #include <board.h>
28 #include <pcb_base_frame.h>
29 #include <tool/selection.h>
31 
32 #include <functional>
33 #include <wx/debug.h>
34 
35 using namespace std::placeholders;
36 
37 
39 {
40  // Requires a PCB_BASE_FRAME
41  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
42 
43  wxASSERT( drwFrame );
44 
45  return std::bind( &PCB_EDITOR_CONDITIONS::hasItemsFunc, _1, drwFrame );
46 }
47 
48 
50 {
51  // Requires a PCB_BASE_FRAME
52  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
53 
54  wxASSERT( drwFrame );
55 
56  return std::bind( &PCB_EDITOR_CONDITIONS::padNumberDisplayFunc, _1, drwFrame );
57 }
58 
59 
61 {
62  // Requires a PCB_BASE_FRAME
63  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
64 
65  wxASSERT( drwFrame );
66 
67  return std::bind( &PCB_EDITOR_CONDITIONS::padFillDisplayFunc, _1, drwFrame );
68 }
69 
70 
72 {
73  // Requires a PCB_BASE_FRAME
74  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
75 
76  wxASSERT( drwFrame );
77 
78  return std::bind( &PCB_EDITOR_CONDITIONS::textFillDisplayFunc, _1, drwFrame );
79 }
80 
81 
83 {
84  // Requires a PCB_BASE_FRAME
85  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
86 
87  wxASSERT( drwFrame );
88 
89  return std::bind( &PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc, _1, drwFrame );
90 }
91 
92 
94 {
95  // Requires a PCB_BASE_FRAME
96  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
97 
98  wxASSERT( drwFrame );
99 
100  return std::bind( &PCB_EDITOR_CONDITIONS::viaFillDisplayFunc, _1, drwFrame );
101 }
102 
103 
105 {
106  // Requires a PCB_BASE_FRAME
107  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
108 
109  wxASSERT( drwFrame );
110 
111  return std::bind( &PCB_EDITOR_CONDITIONS::trackFillDisplayFunc, _1, drwFrame );
112 }
113 
114 
116 {
117  // Requires a PCB_BASE_FRAME
118  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
119 
120  wxASSERT( drwFrame );
121 
122  return std::bind( &PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc, _1, drwFrame, aMode );
123 }
124 
125 
127 {
128  PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
129 
130  wxASSERT( drwFrame );
131 
132  return std::bind( &PCB_EDITOR_CONDITIONS::line45degModeFunc, _1, drwFrame );
133 }
134 
135 
137 {
138  BOARD* board = aFrame->GetBoard();
139 
140  return board && !board->IsEmpty();
141 }
142 
143 
145 {
146  return aFrame->GetDisplayOptions().m_DisplayPadNum;
147 }
148 
149 
151 {
152  return aFrame->GetDisplayOptions().m_DisplayPadFill;
153 }
154 
155 
157 {
158  return aFrame->GetDisplayOptions().m_DisplayTextFill;
159 }
160 
161 
163 {
164  return aFrame->GetDisplayOptions().m_DisplayGraphicsFill;
165 }
166 
167 
169 {
170  return aFrame->GetDisplayOptions().m_DisplayViaFill;
171 }
172 
173 
175 {
176  return aFrame->GetDisplayOptions().m_DisplayPcbTrackFill;
177 }
178 
179 
181  ZONE_DISPLAY_MODE aMode )
182 {
183  return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
184 }
185 
187 {
188  return aFrame->Settings().m_Use45DegreeGraphicSegments;
189 }
SELECTION_CONDITION HasItems()
Create a functor that tests if there are items in the board.
SELECTION_CONDITION TrackFillDisplay()
Create a functor that tests if the frame fills tracks.
static bool padFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by TextFillDisplay()
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
static bool viaFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by TrackFillDisplay()
SELECTION_CONDITION Line45degMode()
Create a functor that tests whether only 45 degree graphic lines should be drawn.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
PCB_BASE_FRAME * m_frame
Classes used in Pcbnew, CvPcb and GerbView.
static bool graphicsFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by ViaFillDisplay()
bool m_Use45DegreeGraphicSegments
static bool trackFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by ZoneDisplayMode()
static bool line45degModeFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
static bool padNumberDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by PadFillDisplay()
std::function< bool(const SELECTION &)> SELECTION_CONDITION
< Functor type that checks a specific condition for selected items.
SELECTION_CONDITION ZoneDisplayMode(ZONE_DISPLAY_MODE aMode)
Create a functor that tests the current zone display mode in the frame.
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
static bool zoneDisplayModeFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame, ZONE_DISPLAY_MODE aMode)
Helper function used by Line45degMode()
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
ZONE_DISPLAY_MODE m_ZoneDisplayMode
PCBNEW_SETTINGS & Settings()
SELECTION_CONDITION ViaFillDisplay()
Create a functor that tests if the frame fills vias.
BOARD * GetBoard() const
static bool hasItemsFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
< Helper function used by HasItems()
bool IsEmpty() const
Definition: board.h:281
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static bool textFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by GraphicsFillDisplay()