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 (C) 1992-2022 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 <pgm_base.h>
28#include <pcbnew_settings.h>
30#include <board.h>
31#include <pcb_base_frame.h>
32#include <tool/selection.h>
34
35#include <functional>
36#include <wx/debug.h>
37
38using namespace std::placeholders;
39
40
42{
43 // Requires a PCB_BASE_FRAME
44 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
45
46 wxASSERT( drwFrame );
47
48 return std::bind( &PCB_EDITOR_CONDITIONS::hasItemsFunc, _1, drwFrame );
49}
50
51
53{
54 // Requires a PCB_BASE_FRAME
55 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
56
57 wxASSERT( drwFrame );
58
59 return std::bind( &PCB_EDITOR_CONDITIONS::padNumberDisplayFunc, _1, drwFrame );
60}
61
62
64{
65 // Requires a PCB_BASE_FRAME
66 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
67
68 wxASSERT( drwFrame );
69
70 return std::bind( &PCB_EDITOR_CONDITIONS::padFillDisplayFunc, _1, drwFrame );
71}
72
73
75{
76 // Requires a PCB_BASE_FRAME
77 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
78
79 wxASSERT( drwFrame );
80
81 return std::bind( &PCB_EDITOR_CONDITIONS::textFillDisplayFunc, _1, drwFrame );
82}
83
84
86{
87 // Requires a PCB_BASE_FRAME
88 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
89
90 wxASSERT( drwFrame );
91
92 return std::bind( &PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc, _1, drwFrame );
93}
94
95
97{
98 // Requires a PCB_BASE_FRAME
99 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
100
101 wxASSERT( drwFrame );
102
103 return std::bind( &PCB_EDITOR_CONDITIONS::viaFillDisplayFunc, _1, drwFrame );
104}
105
106
108{
109 // Requires a PCB_BASE_FRAME
110 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
111
112 wxASSERT( drwFrame );
113
114 return std::bind( &PCB_EDITOR_CONDITIONS::trackFillDisplayFunc, _1, drwFrame );
115}
116
117
119{
120 // Requires a PCB_BASE_FRAME
121 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
122
123 wxASSERT( drwFrame );
124
125 return std::bind( &PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc, _1, drwFrame, aMode );
126}
127
128
130{
131 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
132
133 wxASSERT( drwFrame );
134
135 return std::bind( &PCB_EDITOR_CONDITIONS::get45degModeFunc, _1, drwFrame );
136}
137
138
140{
141 BOARD* board = aFrame->GetBoard();
142
143 return board && !board->IsEmpty();
144}
145
146
148{
150}
151
152
154{
156}
157
158
160{
162}
163
164
166{
168}
169
170
172{
174}
175
176
178{
180}
181
182
184 ZONE_DISPLAY_MODE aMode )
185{
186 return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
187}
188
190{
192
193 if( aFrame->IsType( FRAME_PCB_EDITOR ) )
194 return mgr.GetAppSettings<PCBNEW_SETTINGS>()->m_Use45DegreeLimit;
195 else
196 return mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
197}
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
bool IsEmpty() const
Definition: board.h:386
bool IsType(FRAME_T aType) const
EDA_BASE_FRAME * m_frame
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)
Helper function used by Line45degMode()
static bool get45degModeFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
SELECTION_CONDITION ZoneDisplayMode(ZONE_DISPLAY_MODE aMode)
Create a functor that tests the current zone display mode in the frame.
static bool textFillDisplayFunc(const SELECTION &aSelection, PCB_BASE_FRAME *aFrame)
Helper function used by GraphicsFillDisplay()
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 Get45degMode()
Create a functor that tests whether only 45 degree lines should be allowed.
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.
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.