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 (C) 2024 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
45 SetBorders( true, false, false, false );
46
47 wxASSERT( m_frame );
49 wxASSERT( m_tool );
50
53
54 m_cbSymbols->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
55 m_cbText->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
56 m_cbWires->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
57 m_cbLabels->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
58 m_cbPins->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
59 m_cbGraphics->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
60 m_cbImages->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
61 m_cbOtherItems->Bind( wxEVT_RIGHT_DOWN, &PANEL_SCH_SELECTION_FILTER::onRightClick, this );
62
64 {
65 Freeze();
66 m_gridSizer->SetItemPosition( m_cbSymbols, wxGBPosition( 5, 0 ) );
67 m_gridSizer->SetItemPosition( m_cbWires, wxGBPosition( 5, 1 ) );
68 m_gridSizer->SetItemPosition( m_cbLabels, wxGBPosition( 6, 0 ) );
69 m_gridSizer->SetItemPosition( m_cbImages, wxGBPosition( 6, 1 ) );
70 m_cbSymbols->Hide();
71 m_cbWires->Hide();
72 m_cbLabels->Hide();
73 m_cbImages->Hide();
74
75 m_gridSizer->SetItemPosition( m_cbPins, wxGBPosition( 1, 0 ) );
76 m_gridSizer->SetItemPosition( m_cbText, wxGBPosition( 1, 1 ) );
77 m_gridSizer->SetItemPosition( m_cbGraphics, wxGBPosition( 2, 0 ) );
78 m_gridSizer->SetItemPosition( m_cbOtherItems, wxGBPosition( 2, 1 ) );
79 Thaw();
80 }
81
82 m_frame->Bind( EDA_LANG_CHANGED, &PANEL_SCH_SELECTION_FILTER::OnLanguageChanged, this );
83}
84
85
87{
88 m_frame->Unbind( EDA_LANG_CHANGED, &PANEL_SCH_SELECTION_FILTER::OnLanguageChanged, this );
89}
90
91
93{
94 Freeze();
95
96 m_cbLockedItems->SetValue( aOptions.lockedItems );
97 m_cbSymbols->SetValue( aOptions.symbols );
98 m_cbText->SetValue( aOptions.text );
99 m_cbWires->SetValue( aOptions.wires );
100 m_cbLabels->SetValue( aOptions.labels );
101 m_cbPins->SetValue( aOptions.pins );
102 m_cbGraphics->SetValue( aOptions.graphics );
103 m_cbImages->SetValue( aOptions.images );
104 m_cbOtherItems->SetValue( aOptions.otherItems );
105
106 m_cbAllItems->SetValue( aOptions.All() );
107
108 Thaw();
109}
110
111
113{
114 if( aEvent.GetEventObject() == m_cbAllItems )
115 {
116 bool newState = m_cbAllItems->GetValue();
117
118 m_cbSymbols->SetValue( newState );
119 m_cbText->SetValue( newState );
120 m_cbWires->SetValue( newState );
121 m_cbLabels->SetValue( newState );
122 m_cbPins->SetValue( newState );
123 m_cbGraphics->SetValue( newState );
124 m_cbImages->SetValue( newState );
125 m_cbOtherItems->SetValue( newState );
126 }
127
129
130 // If any of the other checkboxes turned off, turn off the All Items checkbox
131 bool allChecked = setFilterFromCheckboxes( opts );
132 m_cbAllItems->SetValue( allChecked );
133}
134
135
137{
138 aOptions.lockedItems = m_cbLockedItems->GetValue();
139 aOptions.symbols = m_cbSymbols->GetValue();
140 aOptions.text = m_cbText->GetValue();
141 aOptions.wires = m_cbWires->GetValue();
142 aOptions.labels = m_cbLabels->GetValue();
143 aOptions.pins = m_cbPins->GetValue();
144 aOptions.graphics = m_cbGraphics->GetValue();
145 aOptions.images = m_cbImages->GetValue();
146 aOptions.otherItems = m_cbOtherItems->GetValue();
147
148 return aOptions.All();
149}
150
151
153{
154 wxMenu menu;
155
156 wxCheckBox* cb = dynamic_cast<wxCheckBox*>( aEvent.GetEventObject() );
157
158 if( !cb )
159 return;
160
161 m_onlyCheckbox = cb;
162
163 wxString label;
164 label.Printf( _( "Only %s" ), cb->GetLabel().Lower() );
165
166 menu.Append( new wxMenuItem( &menu, wxID_ANY, label, wxEmptyString, wxITEM_NORMAL ) );
167
168 menu.Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SCH_SELECTION_FILTER::onPopupSelection, this );
169
170 PopupMenu( &menu );
171}
172
173
175{
176 if( !m_onlyCheckbox )
177 return;
178
179 m_cbAllItems->SetValue( false );
180 m_cbSymbols->SetValue( false );
181 m_cbText->SetValue( false );
182 m_cbWires->SetValue( false );
183 m_cbLabels->SetValue( false );
184 m_cbPins->SetValue( false );
185 m_cbGraphics->SetValue( false );
186 m_cbImages->SetValue( false );
187 m_cbOtherItems->SetValue( false );
188
189 m_onlyCheckbox->SetValue( true );
190 m_onlyCheckbox = nullptr;
191
192 wxCommandEvent dummy;
194}
195
196
198{
199 m_cbAllItems->SetLabel( _( "All items" ) );
200 m_cbLockedItems->SetLabel( _( "Locked items" ) );
201 m_cbLockedItems->SetToolTip( _( "Allow selection of locked items" ) );
202 m_cbSymbols->SetLabel( _( "Symbols" ) );
203 m_cbText->SetLabel( _( "Text" ) );
204 m_cbWires->SetLabel( _( "Wires" ) );
205 m_cbLabels->SetLabel( _( "Labels" ) );
206 m_cbPins->SetLabel( _( "Pins" ) );
207 m_cbGraphics->SetLabel( _( "Graphics" ) );
208 m_cbImages->SetLabel( _( "Images" ) );
209 m_cbOtherItems->SetLabel( _( "Other items" ) );
210
211 m_cbAllItems->GetParent()->Layout();
212
213 aEvent.Skip();
214}
FRAME_T GetFrameType() const
SCH_SELECTION_FILTER_OPTIONS & GetFilter()
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,...
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:154
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.