KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#include <pgm_base.h>
24#include <pcbnew_settings.h>
26#include <board.h>
27#include <pcb_base_frame.h>
28#include <tool/selection.h>
31
32#include <functional>
33#include <wx/debug.h>
34
35using 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::footprintViewerAutoZoom, _1, drwFrame );
133}
134
135
137{
138 BOARD* board = aFrame->GetBoard();
139
140 return board && !board->IsEmpty();
141}
142
143
148
149
154
155
160
161
166
167
169{
171}
172
173
178
179
181 ZONE_DISPLAY_MODE aMode )
182{
183 return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
184}
185
186
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
bool IsEmpty() const
Definition board.cpp:662
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
EDA_BASE_FRAME * m_frame
The frame to apply the conditions to.
DISPLAY_OPTIONS m_Display
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual PCB_VIEWERS_SETTINGS_BASE * GetViewerSettingsBase() const
BOARD * GetBoard() const
ZONE_DISPLAY_MODE m_ZoneDisplayMode
static bool hasItemsFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
< Helper function used by HasItems()
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
static bool padNumberDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by PadFillDisplay()
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 HasItems()
Create a functor that tests if there are items in the board.
static bool graphicsFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by ViaFillDisplay()
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
static bool zoneDisplayModeFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame, ZONE_DISPLAY_MODE aMode)
SELECTION_CONDITION ZoneDisplayMode(ZONE_DISPLAY_MODE aMode)
Create a functor that tests the current zone display mode in the frame.
SELECTION_CONDITION FootprintViewerAutoZoom()
Create a functor that tests if the footprint viewer should auto zoom on new footprints.
static bool textFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by GraphicsFillDisplay()
static bool footprintViewerAutoZoom(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by FootprintViewerAutoZoom()
static bool viaFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by TrackFillDisplay()
SELECTION_CONDITION ViaFillDisplay()
Create a functor that tests if the frame fills vias.
static bool trackFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by ZoneDisplayMode()
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
a few functions useful in geometry calculations.
see class PGM_BASE
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.