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, 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>
35
36#include <functional>
37#include <wx/debug.h>
38
39using namespace std::placeholders;
40
41
43{
44 // Requires a PCB_BASE_FRAME
45 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
46
47 wxASSERT( drwFrame );
48
49 return std::bind( &PCB_EDITOR_CONDITIONS::hasItemsFunc, _1, drwFrame );
50}
51
52
54{
55 // Requires a PCB_BASE_FRAME
56 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
57
58 wxASSERT( drwFrame );
59
60 return std::bind( &PCB_EDITOR_CONDITIONS::padNumberDisplayFunc, _1, drwFrame );
61}
62
63
65{
66 // Requires a PCB_BASE_FRAME
67 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
68
69 wxASSERT( drwFrame );
70
71 return std::bind( &PCB_EDITOR_CONDITIONS::padFillDisplayFunc, _1, drwFrame );
72}
73
74
76{
77 // Requires a PCB_BASE_FRAME
78 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
79
80 wxASSERT( drwFrame );
81
82 return std::bind( &PCB_EDITOR_CONDITIONS::textFillDisplayFunc, _1, drwFrame );
83}
84
85
87{
88 // Requires a PCB_BASE_FRAME
89 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
90
91 wxASSERT( drwFrame );
92
93 return std::bind( &PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc, _1, drwFrame );
94}
95
96
98{
99 // Requires a PCB_BASE_FRAME
100 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
101
102 wxASSERT( drwFrame );
103
104 return std::bind( &PCB_EDITOR_CONDITIONS::viaFillDisplayFunc, _1, drwFrame );
105}
106
107
109{
110 // Requires a PCB_BASE_FRAME
111 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
112
113 wxASSERT( drwFrame );
114
115 return std::bind( &PCB_EDITOR_CONDITIONS::trackFillDisplayFunc, _1, drwFrame );
116}
117
118
120{
121 // Requires a PCB_BASE_FRAME
122 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
123
124 wxASSERT( drwFrame );
125
126 return std::bind( &PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc, _1, drwFrame, aMode );
127}
128
129
131{
132 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
133
134 wxASSERT( drwFrame );
135
136 return std::bind( &PCB_EDITOR_CONDITIONS::get45degModeFunc, _1, drwFrame );
137}
138
139
141{
142 PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
143
144 wxASSERT( drwFrame );
145
146 return std::bind( &PCB_EDITOR_CONDITIONS::footprintViewerAutoZoom, _1, drwFrame );
147}
148
149
151{
152 BOARD* board = aFrame->GetBoard();
153
154 return board && !board->IsEmpty();
155}
156
157
162
163
168
169
174
175
180
181
183{
185}
186
187
192
193
195 ZONE_DISPLAY_MODE aMode )
196{
197 return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
198}
199
200
202{
203 if( aFrame->IsType( FRAME_PCB_EDITOR ) )
204 return GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode != LEADER_MODE::DIRECT;
205 else if( aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
206 return GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" )->m_AngleSnapMode != LEADER_MODE::DIRECT;
207 else
209}
210
211
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
bool IsEmpty() const
Definition board.cpp:559
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
bool IsType(FRAME_T aType) const
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)
Helper function used by Get45degMode()
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.
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 Get45degMode()
Create a functor that tests whether angle constraints are enabled.
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
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
a few functions useful in geometry calculations.
@ DIRECT
Unconstrained point-to-point.
see class PGM_BASE
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
T * GetAppSettings(const char *aFilename)