KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_sch_selection_filter.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) 2024 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22#include <sch_base_frame.h>
23#include <tool/tool_manager.h>
26
27
30 m_frame( dynamic_cast<SCH_BASE_FRAME*>( aParent ) ),
31 m_onlyCheckbox( nullptr )
32{
33 wxFont font = KIUI::GetInfoFont( this );
34 m_cbLockedItems->SetFont( font );
35 m_cbSymbols->SetFont( font );
36 m_cbText->SetFont( font );
37 m_cbWires->SetFont( font );
38 m_cbLabels->SetFont( font );
39 m_cbPins->SetFont( font );
40 m_cbGraphics->SetFont( font );
41 m_cbImages->SetFont( font );
42 m_cbOtherItems->SetFont( font );
43 m_cbAllItems->SetFont( font );
44 m_cbRuleAreas->SetFont( font );
45
46 SetBorders( true, false, false, false );
47
48 wxASSERT( m_frame );
50 wxASSERT( m_tool );
51
54
55 m_cbSymbols->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
56 m_cbText->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
57 m_cbWires->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
58 m_cbLabels->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
59 m_cbPins->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
60 m_cbGraphics->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
61 m_cbImages->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
62 m_cbOtherItems->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
63 m_cbRuleAreas->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
64
66 {
67 Freeze();
68 m_gridSizer->SetItemPosition( m_cbSymbols, wxGBPosition( 6, 0 ) );
69 m_gridSizer->SetItemPosition( m_cbWires, wxGBPosition( 6, 1 ) );
70 m_gridSizer->SetItemPosition( m_cbLabels, wxGBPosition( 7, 0 ) );
71 m_gridSizer->SetItemPosition( m_cbImages, wxGBPosition( 7, 1 ) );
72 m_cbSymbols->Hide();
73 m_cbWires->Hide();
74 m_cbLabels->Hide();
75 m_cbImages->Hide();
76 m_cbRuleAreas->Hide();
77
78 m_gridSizer->SetItemPosition( m_cbPins, wxGBPosition( 1, 0 ) );
79 m_gridSizer->SetItemPosition( m_cbText, wxGBPosition( 1, 1 ) );
80 m_gridSizer->SetItemPosition( m_cbGraphics, wxGBPosition( 2, 0 ) );
81 m_gridSizer->SetItemPosition( m_cbOtherItems, wxGBPosition( 2, 1 ) );
82 Thaw();
83 }
84
85 m_frame->Bind( EDA_LANG_CHANGED, &PANEL_SCH_SELECTION_FILTER::OnLanguageChanged, this );
86}
87
88
90{
91 m_frame->Unbind( EDA_LANG_CHANGED, &PANEL_SCH_SELECTION_FILTER::OnLanguageChanged, this );
92}
93
94
96{
97 Freeze();
98
99 m_cbLockedItems->SetValue( aOptions.lockedItems );
100 m_cbSymbols->SetValue( aOptions.symbols );
101 m_cbText->SetValue( aOptions.text );
102 m_cbWires->SetValue( aOptions.wires );
103 m_cbLabels->SetValue( aOptions.labels );
104 m_cbPins->SetValue( aOptions.pins );
105 m_cbGraphics->SetValue( aOptions.graphics );
106 m_cbImages->SetValue( aOptions.images );
107 m_cbRuleAreas->SetValue( aOptions.ruleAreas );
108 m_cbOtherItems->SetValue( aOptions.otherItems );
109
110 m_cbAllItems->SetValue( aOptions.All() );
111
112 Thaw();
113}
114
115
117{
118 if( aEvent.GetEventObject() == m_cbAllItems )
119 {
120 bool newState = m_cbAllItems->GetValue();
121
122 m_cbSymbols->SetValue( newState );
123 m_cbText->SetValue( newState );
124 m_cbWires->SetValue( newState );
125 m_cbLabels->SetValue( newState );
126 m_cbPins->SetValue( newState );
127 m_cbGraphics->SetValue( newState );
128 m_cbImages->SetValue( newState );
129 m_cbRuleAreas->SetValue( newState );
130 m_cbOtherItems->SetValue( newState );
131 }
132
134
135 // If any of the other checkboxes turned off, turn off the All Items checkbox
136 bool allChecked = setFilterFromCheckboxes( opts );
137 m_cbAllItems->SetValue( allChecked );
138}
139
140
142{
143 aOptions.lockedItems = m_cbLockedItems->GetValue();
144 aOptions.symbols = m_cbSymbols->GetValue();
145 aOptions.text = m_cbText->GetValue();
146 aOptions.wires = m_cbWires->GetValue();
147 aOptions.labels = m_cbLabels->GetValue();
148 aOptions.pins = m_cbPins->GetValue();
149 aOptions.graphics = m_cbGraphics->GetValue();
150 aOptions.images = m_cbImages->GetValue();
151 aOptions.ruleAreas = m_cbRuleAreas->GetValue();
152 aOptions.otherItems = m_cbOtherItems->GetValue();
153
154 return aOptions.All();
155}
156
157
159{
160 wxMenu menu;
161
162 wxCheckBox* cb = dynamic_cast<wxCheckBox*>( aEvent.GetEventObject() );
163
164 if( !cb )
165 return;
166
167 m_onlyCheckbox = cb;
168
169 wxString label;
170 label.Printf( _( "Only %s" ), cb->GetLabel().Lower() );
171
172 menu.Append( new wxMenuItem( &menu, wxID_ANY, label, wxEmptyString, wxITEM_NORMAL ) );
173
174 menu.Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SCH_SELECTION_FILTER::onPopupSelection, this );
175
176 PopupMenu( &menu );
177}
178
179
181{
182 if( !m_onlyCheckbox )
183 return;
184
185 m_cbAllItems->SetValue( false );
186 m_cbSymbols->SetValue( false );
187 m_cbText->SetValue( false );
188 m_cbWires->SetValue( false );
189 m_cbLabels->SetValue( false );
190 m_cbPins->SetValue( false );
191 m_cbGraphics->SetValue( false );
192 m_cbImages->SetValue( false );
193 m_cbOtherItems->SetValue( false );
194 m_cbRuleAreas->SetValue( false );
195
196 m_onlyCheckbox->SetValue( true );
197 m_onlyCheckbox = nullptr;
198
199 wxCommandEvent dummy;
201}
202
203
205{
206 m_cbAllItems->SetLabel( _( "All items" ) );
207 m_cbLockedItems->SetLabel( _( "Locked items" ) );
208 m_cbLockedItems->SetToolTip( _( "Allow selection of locked items" ) );
209 m_cbSymbols->SetLabel( _( "Symbols" ) );
210 m_cbText->SetLabel( _( "Text" ) );
211 m_cbWires->SetLabel( _( "Wires" ) );
212 m_cbLabels->SetLabel( _( "Labels" ) );
213 m_cbPins->SetLabel( _( "Pins" ) );
214 m_cbGraphics->SetLabel( _( "Graphics" ) );
215 m_cbImages->SetLabel( _( "Images" ) );
216 m_cbRuleAreas->SetLabel( _( "Rule Areas" ) );
217 m_cbOtherItems->SetLabel( _( "Other items" ) );
218
219 m_cbAllItems->GetParent()->Layout();
220
221 aEvent.Skip();
222}
FRAME_T GetFrameType() const
Class PANEL_SCH_SELECTION_FILTER_BASE.
bool setFilterFromCheckboxes(SCH_SELECTION_FILTER_OPTIONS &aOptions)
void OnLanguageChanged(wxCommandEvent &aEvent)
void SetCheckboxesFromFilter(SCH_SELECTION_FILTER_OPTIONS &aOptions)
void onRightClick(wxMouseEvent &aEvent)
void OnFilterChanged(wxCommandEvent &aEvent) override
void onPopupSelection(wxCommandEvent &aEvent)
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_SELECTION_FILTER_OPTIONS & GetFilter()
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
void SetBorders(bool aLeft, bool aRight, bool aTop, bool aBottom)
Definition: wx_panel.h:39
#define _(s)
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156
std::vector< FAB_LAYER_COLOR > dummy
bool symbols
Allow selecting symbols and sheet symbols.
bool labels
Net and bus labels.
bool pins
Symbol and sheet pins.
bool graphics
Graphic lines, shapes, polygons.
bool lockedItems
Allow selecting locked items.
bool images
Bitmap/vector images.
bool otherItems
Anything not fitting one of the above categories.
bool wires
Net and bus wires and junctions.