From 65f5ebd8f2faa860184cbeb0920780f55a07f10d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 27 Jun 2020 18:48:34 -0400 Subject: [PATCH] ADDED: Persistent selection filter UI for PcbNew --- pcbnew/CMakeLists.txt | 3 + pcbnew/pcb_base_edit_frame.cpp | 3 +- pcbnew/pcb_base_edit_frame.h | 4 + pcbnew/pcb_edit_frame.cpp | 17 +- pcbnew/toolbars_pcb_editor.cpp | 1 + pcbnew/tools/selection_tool.cpp | 109 ++- pcbnew/tools/selection_tool.h | 33 + pcbnew/widgets/panel_selection_filter.cpp | 145 +++ pcbnew/widgets/panel_selection_filter.h | 56 ++ .../widgets/panel_selection_filter_base.cpp | 108 +++ .../widgets/panel_selection_filter_base.fbp | 883 ++++++++++++++++++ pcbnew/widgets/panel_selection_filter_base.h | 56 ++ 12 files changed, 1415 insertions(+), 3 deletions(-) create mode 100644 pcbnew/widgets/panel_selection_filter.cpp create mode 100644 pcbnew/widgets/panel_selection_filter.h create mode 100644 pcbnew/widgets/panel_selection_filter_base.cpp create mode 100644 pcbnew/widgets/panel_selection_filter_base.fbp create mode 100644 pcbnew/widgets/panel_selection_filter_base.h diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 5ca87c5fc8..052431f496 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -336,6 +336,9 @@ set( PCBNEW_CLASS_SRCS footprint_preview_panel.cpp footprint_tree_pane.cpp + + widgets/panel_selection_filter.cpp + widgets/panel_selection_filter_base.cpp ) set( PCBNEW_SRCS diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index b58ad462e7..38201e2b4f 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -44,7 +44,8 @@ PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, const wxString& aFrameName ) : PCB_BASE_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ), m_rotationAngle( 900 ), m_undoRedoBlocked( false ), - m_Layers( nullptr ) + m_Layers( nullptr ), + m_selectionFilterPanel( nullptr ) { if( !GFootprintList.GetCount() ) { diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index 42f96d7307..7d69f7f456 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -29,6 +29,7 @@ class BOARD_ITEM_CONTAINER; class PCB_LAYER_WIDGET; +class PANEL_SELECTION_FILTER; /** * Common, abstract interface for edit frames. @@ -195,6 +196,9 @@ protected: /// Layer manager. It is the responsibility of the child frames to instantiate this PCB_LAYER_WIDGET* m_Layers; + + /// AUI panel for changing the selection tool filter controls + PANEL_SELECTION_FILTER* m_selectionFilterPanel; }; #endif diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index fd781f9eaa..cb2ada5148 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -86,6 +86,7 @@ #include #include // for DIALOG_DRC_WINDOW_NAME definition #include +#include #include @@ -220,10 +221,13 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : ReCreateOptToolbar(); ReCreateMicrowaveVToolbar(); + m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this ); + // Create the infobar m_infoBar = new WX_INFOBAR( this, &m_auimgr ); m_auimgr.SetManagedWindow( this ); + m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE ); // Horizontal items; layers 4 - 6 m_auimgr.AddPane( m_mainToolBar, @@ -246,11 +250,16 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(4) .Caption( _( "Layers Manager" ) ).PaneBorder( false ) - .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) ); + .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ).Maximize() ); + m_auimgr.AddPane( m_selectionFilterPanel, + EDA_PANE().Palette().Name( "SelectionFilter" ).Right().Layer( 4 ) + .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 ) + .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) ); m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools ); + m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools ); m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools ); m_Layers->ReFillRender(); // Update colors in Render after the config is read @@ -258,6 +267,9 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // because contents establish size syncLayerWidgetLayer(); + // The selection filter doesn't need to grow in the vertical direction when docked + m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0; + // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before // hidding it. m_auimgr.Update(); @@ -349,6 +361,9 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME() // Shutdown all running tools if( m_toolManager ) m_toolManager->ShutdownAllTools(); + + delete m_selectionFilterPanel; + delete m_Layers; } diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 0e3d40f0cf..9508ce5654 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -643,6 +643,7 @@ void PCB_EDIT_FRAME::ToggleLayersManager() // show auxiliary Vertical layers and visibility manager toolbar m_show_layer_manager_tools = !m_show_layer_manager_tools; m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools ); + m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools ); m_auimgr.Update(); } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index a4ca1a061a..0fe920c34b 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -120,6 +120,17 @@ SELECTION_TOOL::SELECTION_TOOL() : m_locked( true ), m_priv( std::make_unique() ) { + m_filter.lockedItems = true; + m_filter.footprints = true; + m_filter.text = true; + m_filter.tracks = true; + m_filter.vias = true; + m_filter.pads = true; + m_filter.graphics = true; + m_filter.zones = true; + m_filter.keepouts = true; + m_filter.dimensions = true; + m_filter.otherItems = true; } @@ -435,6 +446,9 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag, if( aClientFilter ) aClientFilter( aWhere, collector ); + // Apply the stateful filter + filterCollectedItems( collector ); + // Apply some ugly heuristics to avoid disambiguation menus whenever possible if( collector.GetCount() > 1 && !m_skip_heuristics ) { @@ -592,7 +606,7 @@ bool SELECTION_TOOL::selectMultiple() { BOARD_ITEM* item = static_cast( it->first ); - if( !item || !Selectable( item ) ) + if( !item || !Selectable( item ) || !itemPassesFilter( item ) ) continue; if( item->HitTest( selectionRect, windowSelection ) ) @@ -1311,6 +1325,99 @@ int SELECTION_TOOL::filterSelection( const TOOL_EVENT& aEvent ) } +void SELECTION_TOOL::filterCollectedItems( GENERAL_COLLECTOR& aCollector ) +{ + if( aCollector.GetCount() == 0 ) + return; + + std::set rejected; + + for( EDA_ITEM* i : aCollector ) + { + BOARD_ITEM* item = static_cast( i ); + + if( !itemPassesFilter( item ) ) + rejected.insert( item ); + } + + for( BOARD_ITEM* item : rejected ) + aCollector.Remove( item ); +} + + +bool SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem ) +{ + if( aItem->IsLocked() && !m_filter.lockedItems ) + return false; + + switch( aItem->Type() ) + { + case PCB_MODULE_T: + if( !m_filter.footprints ) + return false; + + break; + + case PCB_PAD_T: + if( !m_filter.pads ) + return false; + + break; + + case PCB_TRACE_T: + case PCB_ARC_T: + if( !m_filter.tracks ) + return false; + + break; + + case PCB_VIA_T: + if( !m_filter.vias ) + return false; + + break; + + case PCB_ZONE_AREA_T: + { + ZONE_CONTAINER* zone = static_cast( aItem ); + + if( ( !m_filter.zones && !zone->GetIsKeepout() ) + || ( !m_filter.keepouts && zone->GetIsKeepout() ) ) + { + return false; + } + + break; + } + case PCB_LINE_T: + case PCB_TARGET_T: + if( !m_filter.graphics ) + return false; + + break; + + case PCB_MODULE_TEXT_T: + case PCB_TEXT_T: + if( !m_filter.text ) + return false; + + break; + + case PCB_DIMENSION_T: + if( !m_filter.dimensions ) + return false; + + break; + + default: + if( !m_filter.otherItems ) + return false; + } + + return true; +} + + void SELECTION_TOOL::ClearSelection( bool aQuietMode ) { if( m_selection.Empty() ) diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 5901c23449..d2cd81780f 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -49,6 +49,26 @@ namespace KIGFX typedef void (*CLIENT_SELECTION_FILTER)( const VECTOR2I&, GENERAL_COLLECTOR& ); +/** + * Selection filtering that applies all the time (not the "filter selection" dialog that modifies + * the current selection) + */ +struct SELECTION_FILTER_OPTIONS +{ + bool lockedItems; ///< Allow selecting locked items + bool footprints; ///< Allow selecting entire footprints + bool text; ///< Text (free or attached to a footprint) + bool tracks; ///< Copper tracks + bool vias; ///< Vias (all types> + bool pads; ///< Footprint pads + bool graphics; ///< Graphic lines, shapes, polygons + bool zones; ///< Copper zones + bool keepouts; ///< Keepout zones + bool dimensions; ///< Dimension items + bool otherItems; ///< Anything not fitting one of the above categories +}; + + /** * SELECTION_TOOL * @@ -156,6 +176,11 @@ public: */ void RebuildSelection(); + SELECTION_FILTER_OPTIONS& GetFilter() + { + return m_filter; + } + ///> Sets up handlers for various events. void setTransitions() override; @@ -269,6 +294,12 @@ private: ///> Invoke filter dialog and modify current selection int filterSelection( const TOOL_EVENT& aEvent ); + ///> Applies the SELECTION_FILTER_OPTIONS to a collection of items + void filterCollectedItems( GENERAL_COLLECTOR& aCollector ); + + ///> Returns true if the given item passes the current SELECTION_FILTER_OPTIONS + bool itemPassesFilter( BOARD_ITEM* aItem ); + /** * Function pickSmallestComponent() * Allows one to find the smallest (in terms of bounding box area) item from the list. @@ -333,6 +364,8 @@ private: PCB_BASE_FRAME* m_frame; // Pointer to the parent frame PCBNEW_SELECTION m_selection; // Current state of selection + SELECTION_FILTER_OPTIONS m_filter; + bool m_additive; // Items should be added to selection (instead of replacing) bool m_subtractive; // Items should be removed from selection bool m_exclusive_or; // Items' selection state should be toggled diff --git a/pcbnew/widgets/panel_selection_filter.cpp b/pcbnew/widgets/panel_selection_filter.cpp new file mode 100644 index 0000000000..45d85f4b55 --- /dev/null +++ b/pcbnew/widgets/panel_selection_filter.cpp @@ -0,0 +1,145 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 Jon Evans + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include +#include +#include + + +PANEL_SELECTION_FILTER::PANEL_SELECTION_FILTER( wxWindow* aParent ) : + PANEL_SELECTION_FILTER_BASE( aParent ), + m_frame( dynamic_cast( aParent ) ), + m_onlyCheckbox( nullptr ) +{ + wxASSERT( m_frame ); + m_tool = m_frame->GetToolManager()->GetTool(); + wxASSERT( m_tool ); + + m_cbAllItems->SetValue( true ); + + wxCommandEvent dummy; + OnFilterChanged( dummy ); + + m_cbFootprints->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbText->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbTracks->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbVias->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbPads->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbGraphics->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbZones->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbKeepouts->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbDimensions->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); + m_cbOtherItems->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this ); +} + + +void PANEL_SELECTION_FILTER::OnFilterChanged( wxCommandEvent& aEvent ) +{ + if( aEvent.GetEventObject() == m_cbAllItems ) + { + bool newState = m_cbAllItems->GetValue(); + + m_cbLockedItems->SetValue( newState ); + m_cbFootprints->SetValue( newState ); + m_cbText->SetValue( newState ); + m_cbTracks->SetValue( newState ); + m_cbVias->SetValue( newState ); + m_cbPads->SetValue( newState ); + m_cbGraphics->SetValue( newState ); + m_cbZones->SetValue( newState ); + m_cbKeepouts->SetValue( newState ); + m_cbDimensions->SetValue( newState ); + m_cbOtherItems->SetValue( newState ); + } + + SELECTION_FILTER_OPTIONS& opts = m_tool->GetFilter(); + + // If any of the other checkboxes turned off, turn off the All Items checkbox + bool allChecked = setFilterFromCheckboxes( opts ); + m_cbAllItems->SetValue( allChecked ); +} + + +bool PANEL_SELECTION_FILTER::setFilterFromCheckboxes( SELECTION_FILTER_OPTIONS& aOptions ) +{ + aOptions.lockedItems = m_cbLockedItems->GetValue(); + aOptions.footprints = m_cbFootprints->GetValue(); + aOptions.text = m_cbText->GetValue(); + aOptions.tracks = m_cbTracks->GetValue(); + aOptions.vias = m_cbVias->GetValue(); + aOptions.pads = m_cbPads->GetValue(); + aOptions.graphics = m_cbGraphics->GetValue(); + aOptions.zones = m_cbZones->GetValue(); + aOptions.keepouts = m_cbKeepouts->GetValue(); + aOptions.dimensions = m_cbDimensions->GetValue(); + aOptions.otherItems = m_cbOtherItems->GetValue(); + + return ( aOptions.lockedItems && aOptions.footprints && aOptions.text && aOptions.tracks + && aOptions.vias && aOptions.pads && aOptions.graphics && aOptions.zones + && aOptions.keepouts && aOptions.dimensions && aOptions.otherItems ); +} + + +void PANEL_SELECTION_FILTER::onRightClick( wxMouseEvent& aEvent ) +{ + wxMenu menu; + + wxCheckBox* cb = dynamic_cast( aEvent.GetEventObject() ); + + if( !cb ) + return; + + m_onlyCheckbox = cb; + + wxString label; + label.Printf( _( "Only %s" ), cb->GetLabel().Lower() ); + + menu.Append( new wxMenuItem( &menu, wxID_ANY, label, wxEmptyString, wxITEM_NORMAL ) ); + + menu.Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SELECTION_FILTER::onPopupSelection, this ); + + PopupMenu( &menu ); +} + + +void PANEL_SELECTION_FILTER::onPopupSelection( wxCommandEvent& aEvent ) +{ + if( !m_onlyCheckbox ) + return; + + m_cbAllItems->SetValue( false ); + m_cbFootprints->SetValue( false ); + m_cbText->SetValue( false ); + m_cbTracks->SetValue( false ); + m_cbVias->SetValue( false ); + m_cbPads->SetValue( false ); + m_cbGraphics->SetValue( false ); + m_cbZones->SetValue( false ); + m_cbKeepouts->SetValue( false ); + m_cbDimensions->SetValue( false ); + m_cbOtherItems->SetValue( false ); + + m_onlyCheckbox->SetValue( true ); + m_onlyCheckbox = nullptr; + + wxCommandEvent dummy; + OnFilterChanged( dummy ); +} diff --git a/pcbnew/widgets/panel_selection_filter.h b/pcbnew/widgets/panel_selection_filter.h new file mode 100644 index 0000000000..784d833ca8 --- /dev/null +++ b/pcbnew/widgets/panel_selection_filter.h @@ -0,0 +1,56 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 Jon Evans + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef KICAD_PANEL_SELECTION_FILTER_H +#define KICAD_PANEL_SELECTION_FILTER_H + +#include + + +class SELECTION_TOOL; +struct SELECTION_FILTER_OPTIONS; + + +class PANEL_SELECTION_FILTER : public PANEL_SELECTION_FILTER_BASE +{ +public: + PANEL_SELECTION_FILTER( wxWindow* aParent ); + + ~PANEL_SELECTION_FILTER() = default; + +protected: + void OnFilterChanged( wxCommandEvent& aEvent ) override; + +private: + bool setFilterFromCheckboxes( SELECTION_FILTER_OPTIONS& aOptions ); + + void onRightClick( wxMouseEvent& aEvent ); + + void onPopupSelection( wxCommandEvent& aEvent ); + + PCB_BASE_EDIT_FRAME* m_frame; + + SELECTION_TOOL* m_tool; + + wxCheckBox* m_onlyCheckbox; +}; + + +#endif // KICAD_PANEL_SELECTION_FILTER_H diff --git a/pcbnew/widgets/panel_selection_filter_base.cpp b/pcbnew/widgets/panel_selection_filter_base.cpp new file mode 100644 index 0000000000..0baf98c5f5 --- /dev/null +++ b/pcbnew/widgets/panel_selection_filter_base.cpp @@ -0,0 +1,108 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_selection_filter_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_SELECTION_FILTER_BASE::PANEL_SELECTION_FILTER_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + this->SetFont( wxFont( 9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); + + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 0, 0 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_cbAllItems = new wxCheckBox( this, wxID_ANY, wxT("All items"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbAllItems->SetValue(true); + gbSizer1->Add( m_cbAllItems, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxLEFT|wxTOP, 5 ); + + m_cbLockedItems = new wxCheckBox( this, wxID_ANY, wxT("Locked items"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbLockedItems->SetValue(true); + m_cbLockedItems->SetToolTip( wxT("Allow selection of locked items") ); + + gbSizer1->Add( m_cbLockedItems, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT|wxTOP, 5 ); + + m_cbFootprints = new wxCheckBox( this, wxID_ANY, wxT("Footprints"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbFootprints->SetValue(true); + gbSizer1->Add( m_cbFootprints, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbText = new wxCheckBox( this, wxID_ANY, wxT("Text"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbText->SetValue(true); + gbSizer1->Add( m_cbText, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbTracks = new wxCheckBox( this, wxID_ANY, wxT("Tracks"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbTracks->SetValue(true); + gbSizer1->Add( m_cbTracks, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbVias = new wxCheckBox( this, wxID_ANY, wxT("Vias"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbVias->SetValue(true); + gbSizer1->Add( m_cbVias, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbPads = new wxCheckBox( this, wxID_ANY, wxT("Pads"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbPads->SetValue(true); + gbSizer1->Add( m_cbPads, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbGraphics = new wxCheckBox( this, wxID_ANY, wxT("Graphics"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbGraphics->SetValue(true); + gbSizer1->Add( m_cbGraphics, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbZones = new wxCheckBox( this, wxID_ANY, wxT("Zones"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbZones->SetValue(true); + gbSizer1->Add( m_cbZones, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbKeepouts = new wxCheckBox( this, wxID_ANY, wxT("Keepouts"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbKeepouts->SetValue(true); + gbSizer1->Add( m_cbKeepouts, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxLEFT|wxRIGHT, 5 ); + + m_cbDimensions = new wxCheckBox( this, wxID_ANY, wxT("Dimensions"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbDimensions->SetValue(true); + gbSizer1->Add( m_cbDimensions, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + + m_cbOtherItems = new wxCheckBox( this, wxID_ANY, wxT("Other items"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbOtherItems->SetValue(true); + gbSizer1->Add( m_cbOtherItems, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + + + this->SetSizer( gbSizer1 ); + this->Layout(); + + // Connect Events + this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SELECTION_FILTER_BASE::OnUpdateUI ) ); + m_cbAllItems->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbLockedItems->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbFootprints->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbText->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbTracks->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbVias->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbPads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbGraphics->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbZones->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbKeepouts->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbDimensions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbOtherItems->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); +} + +PANEL_SELECTION_FILTER_BASE::~PANEL_SELECTION_FILTER_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SELECTION_FILTER_BASE::OnUpdateUI ) ); + m_cbAllItems->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbLockedItems->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbFootprints->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbText->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbTracks->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbVias->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbPads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbGraphics->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbZones->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbKeepouts->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbDimensions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + m_cbOtherItems->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SELECTION_FILTER_BASE::OnFilterChanged ), NULL, this ); + +} diff --git a/pcbnew/widgets/panel_selection_filter_base.fbp b/pcbnew/widgets/panel_selection_filter_base.fbp new file mode 100644 index 0000000000..5f43bee923 --- /dev/null +++ b/pcbnew/widgets/panel_selection_filter_base.fbp @@ -0,0 +1,883 @@ + + + + + ; + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_selection_filter_base + 1000 + none + + 0 + Selection Filter + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + ,90,90,9,70,0 + 0 + wxID_ANY + + + PANEL_SELECTION_FILTER_BASE + + 249,146 + ; ; forward_declare + + + + wxTAB_TRAVERSAL + OnUpdateUI + + + wxBOTH + + + 0 + + gbSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + + 5 + 1 + 0 + wxLEFT|wxTOP + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + All items + + 0 + + + 0 + + 1 + m_cbAllItems + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 1 + wxLEFT|wxRIGHT|wxTOP + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Locked items + + 0 + + + 0 + + 1 + m_cbLockedItems + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Allow selection of locked items + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 0 + wxLEFT|wxRIGHT + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Footprints + + 0 + + + 0 + + 1 + m_cbFootprints + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 1 + wxLEFT|wxRIGHT + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text + + 0 + + + 0 + + 1 + m_cbText + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 0 + wxLEFT|wxRIGHT + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Tracks + + 0 + + + 0 + + 1 + m_cbTracks + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 1 + wxLEFT|wxRIGHT + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Vias + + 0 + + + 0 + + 1 + m_cbVias + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 0 + wxLEFT|wxRIGHT + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pads + + 0 + + + 0 + + 1 + m_cbPads + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 1 + wxLEFT|wxRIGHT + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Graphics + + 0 + + + 0 + + 1 + m_cbGraphics + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 0 + wxLEFT|wxRIGHT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Zones + + 0 + + + 0 + + 1 + m_cbZones + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 1 + wxLEFT|wxRIGHT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Keepouts + + 0 + + + 0 + + 1 + m_cbKeepouts + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 0 + wxBOTTOM|wxLEFT|wxRIGHT + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Dimensions + + 0 + + + 0 + + 1 + m_cbDimensions + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + 5 + 1 + 1 + wxBOTTOM|wxLEFT|wxRIGHT + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Other items + + 0 + + + 0 + + 1 + m_cbOtherItems + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnFilterChanged + + + + + + diff --git a/pcbnew/widgets/panel_selection_filter_base.h b/pcbnew/widgets/panel_selection_filter_base.h new file mode 100644 index 0000000000..a37416b66e --- /dev/null +++ b/pcbnew/widgets/panel_selection_filter_base.h @@ -0,0 +1,56 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_SELECTION_FILTER_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_SELECTION_FILTER_BASE : public wxPanel +{ + private: + + protected: + wxCheckBox* m_cbAllItems; + wxCheckBox* m_cbLockedItems; + wxCheckBox* m_cbFootprints; + wxCheckBox* m_cbText; + wxCheckBox* m_cbTracks; + wxCheckBox* m_cbVias; + wxCheckBox* m_cbPads; + wxCheckBox* m_cbGraphics; + wxCheckBox* m_cbZones; + wxCheckBox* m_cbKeepouts; + wxCheckBox* m_cbDimensions; + wxCheckBox* m_cbOtherItems; + + // Virtual event handlers, overide them in your derived class + virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void OnFilterChanged( wxCommandEvent& event ) { event.Skip(); } + + + public: + + PANEL_SELECTION_FILTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 249,146 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_SELECTION_FILTER_BASE(); + +}; +