2013-08-02 14:53:50 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-01-17 16:46:33 +00:00
|
|
|
* Copyright (C) 2013-2017 CERN
|
2023-12-17 21:43:35 +00:00
|
|
|
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2013-08-02 14:53:50 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-09-19 15:02:57 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
2013-08-02 14:53:50 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
#ifndef PCB_SELECTION_TOOL_H
|
|
|
|
#define PCB_SELECTION_TOOL_H
|
2013-08-02 14:53:50 +00:00
|
|
|
|
2016-11-04 21:29:47 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2013-08-02 14:53:50 +00:00
|
|
|
#include <math/vector2d.h>
|
2020-07-11 17:40:23 +00:00
|
|
|
#include <project/board_project_settings.h>
|
2019-05-14 11:14:00 +00:00
|
|
|
#include <tool/action_menu.h>
|
2021-09-05 20:37:52 +00:00
|
|
|
#include <tool/selection_tool.h>
|
2017-02-28 03:04:44 +00:00
|
|
|
#include <tool/tool_menu.h>
|
2020-07-11 17:40:23 +00:00
|
|
|
#include <tools/pcb_selection_conditions.h>
|
|
|
|
#include <tools/pcb_tool_base.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection.h>
|
2014-07-09 13:10:32 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
class PCB_BASE_FRAME;
|
2013-08-02 14:53:50 +00:00
|
|
|
class BOARD_ITEM;
|
|
|
|
class GENERAL_COLLECTOR;
|
2024-01-15 17:29:55 +00:00
|
|
|
class PCB_TABLE;
|
2013-08-02 14:53:50 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
namespace KIGFX
|
2013-10-02 08:21:05 +00:00
|
|
|
{
|
2016-11-04 21:29:47 +00:00
|
|
|
class GAL;
|
2013-10-02 08:21:05 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 00:10:20 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
typedef void (*CLIENT_SELECTION_FILTER)( const VECTOR2I&, GENERAL_COLLECTOR&, PCB_SELECTION_TOOL* );
|
2018-01-05 23:44:37 +00:00
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
|
2013-08-02 14:53:50 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* The selection tool: currently supports:
|
2013-08-02 14:53:50 +00:00
|
|
|
* - pick single objects (click LMB)
|
|
|
|
* - add objects to existing selection (Shift+LMB)
|
|
|
|
* - draw selection box (drag LMB)
|
2020-11-14 19:16:42 +00:00
|
|
|
* - handles FOOTPRINTs properly (i.e. selects either FOOTPRINT or its PADs, TEXTs, etc.)
|
2013-09-19 15:02:57 +00:00
|
|
|
* - takes into account high-contrast & layer visibility settings
|
2013-12-03 15:09:03 +00:00
|
|
|
* - invokes InteractiveEdit tool when user starts to drag selected items
|
2013-08-02 14:53:50 +00:00
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
class PCB_SELECTION_TOOL : public SELECTION_TOOL
|
2013-08-02 14:53:50 +00:00
|
|
|
{
|
2013-08-06 07:31:08 +00:00
|
|
|
public:
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL();
|
|
|
|
~PCB_SELECTION_TOOL();
|
2013-08-02 14:53:50 +00:00
|
|
|
|
2015-04-30 08:46:05 +00:00
|
|
|
/// @copydoc TOOL_BASE::Init()
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Init() override;
|
2015-04-30 08:46:05 +00:00
|
|
|
|
|
|
|
/// @copydoc TOOL_BASE::Reset()
|
2016-09-24 18:53:15 +00:00
|
|
|
void Reset( RESET_REASON aReason ) override;
|
2013-09-04 08:56:06 +00:00
|
|
|
|
2021-04-12 10:10:22 +00:00
|
|
|
void OnIdle( wxIdleEvent& aEvent );
|
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
bool IsFootprintEditor()
|
|
|
|
{
|
|
|
|
return m_isFootprintEditor;
|
|
|
|
}
|
|
|
|
|
2013-09-04 08:56:06 +00:00
|
|
|
/**
|
|
|
|
* The main loop.
|
|
|
|
*/
|
2015-02-14 20:28:47 +00:00
|
|
|
int Main( const TOOL_EVENT& aEvent );
|
2013-09-04 08:56:06 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* @return the set of currently selected items.
|
2013-09-04 08:56:06 +00:00
|
|
|
*/
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& GetSelection();
|
2013-08-02 14:53:50 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Return the current selection, filtered according to aClientFilter.
|
2017-03-03 12:42:28 +00:00
|
|
|
*
|
|
|
|
* If the set is empty, performs the legacy-style hover selection.
|
2020-12-10 17:34:26 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aClientFilter A callback to allow tool- or action-specific filtering.
|
|
|
|
* @param aConfirmLockedItems [optional] Signals that the user shall be asked if they want
|
|
|
|
* to drop locked items from the selection or override the locks.
|
2017-03-03 12:42:28 +00:00
|
|
|
*/
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter,
|
|
|
|
bool aConfirmLockedItems = false );
|
2015-04-30 08:46:08 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Select a single item under cursor event handler.
|
2015-02-14 20:28:47 +00:00
|
|
|
int CursorSelection( const TOOL_EVENT& aEvent );
|
2014-07-09 14:50:31 +00:00
|
|
|
|
2024-03-09 19:19:47 +00:00
|
|
|
int SelectColumns( const TOOL_EVENT& aEvent );
|
|
|
|
int SelectRows( const TOOL_EVENT& aEvent );
|
|
|
|
int SelectTable( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Clear current selection event handler.
|
2015-02-14 20:28:47 +00:00
|
|
|
int ClearSelection( const TOOL_EVENT& aEvent );
|
2019-09-08 18:43:54 +00:00
|
|
|
void ClearSelection( bool aQuietMode = false );
|
2014-07-09 14:50:31 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Select all items on the board
|
2020-08-19 22:15:44 +00:00
|
|
|
int SelectAll( const TOOL_EVENT& aEvent );
|
|
|
|
|
2023-09-06 23:44:39 +00:00
|
|
|
///< Unselect all items on the board
|
|
|
|
int UnselectAll( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-08-27 17:15:51 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Take necessary actions to mark an item as found.
|
2021-08-27 17:15:51 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aItem The item that was found and needs to be highlighted/focused/etc.
|
2021-08-27 17:15:51 +00:00
|
|
|
*/
|
|
|
|
void FindItem( BOARD_ITEM* aItem );
|
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Take necessary action mark an item as selected.
|
2020-08-11 19:37:07 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aItem The item to be selected.
|
2020-08-11 19:37:07 +00:00
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
void select( EDA_ITEM* aItem ) override;
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2019-05-11 10:06:28 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* @return true if an item fulfills conditions to be selected.
|
2019-05-11 10:06:28 +00:00
|
|
|
*/
|
2019-07-28 18:30:56 +00:00
|
|
|
bool Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly = false ) const;
|
|
|
|
|
2022-09-03 20:33:56 +00:00
|
|
|
/**
|
|
|
|
* Select all items with the given net code.
|
|
|
|
*
|
|
|
|
* @param aNetCode is the target net to select
|
|
|
|
* @param aSelect is true to add the items to the selection, false to remove them (deselect)
|
|
|
|
*/
|
|
|
|
void SelectAllItemsOnNet( int aNetCode, bool aSelect = true );
|
|
|
|
|
2019-07-28 18:30:56 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Try to guess best selection candidates in case multiple items are clicked, by doing
|
2019-07-28 18:30:56 +00:00
|
|
|
* some brain-dead heuristics.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aCollector [in, out] The collector that has a list of items to be narrowed.
|
|
|
|
* @param aWhere The selection point to consider.
|
2019-07-28 18:30:56 +00:00
|
|
|
*/
|
|
|
|
void GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector, const VECTOR2I& aWhere ) const;
|
2019-05-11 10:06:28 +00:00
|
|
|
|
2019-07-28 18:30:56 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Rebuild the selection from the EDA_ITEMs' selection flags.
|
|
|
|
*
|
|
|
|
* Commonly called after rolling back an undo state to make sure there aren't any stale
|
|
|
|
* pointers.
|
2019-07-28 18:30:56 +00:00
|
|
|
*/
|
|
|
|
void RebuildSelection();
|
|
|
|
|
2024-02-25 22:39:14 +00:00
|
|
|
PCB_SELECTION_FILTER_OPTIONS& GetFilter()
|
2020-06-27 22:48:34 +00:00
|
|
|
{
|
|
|
|
return m_filter;
|
|
|
|
}
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Set up handlers for various events.
|
2017-07-31 12:30:51 +00:00
|
|
|
void setTransitions() override;
|
2015-04-30 08:46:03 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Zoom the screen to center and fit the current selection.
|
2018-11-11 20:06:23 +00:00
|
|
|
void zoomFitSelection();
|
2017-03-02 23:42:23 +00:00
|
|
|
|
2022-01-16 20:29:03 +00:00
|
|
|
///< Zoom the screen to fit the bounding box for cross probing/selection sync.
|
2022-08-31 12:56:58 +00:00
|
|
|
void ZoomFitCrossProbeBBox( const BOX2I& bbox );
|
2022-01-16 20:29:03 +00:00
|
|
|
|
2022-08-22 10:58:09 +00:00
|
|
|
/**
|
|
|
|
* Enter the group at the head of the current selection.
|
|
|
|
*/
|
2020-08-11 19:37:07 +00:00
|
|
|
void EnterGroup();
|
2020-09-02 01:09:34 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Leave the currently-entered group.
|
2020-09-02 01:09:34 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aSelectGroup [optional] Select the group after leaving.
|
2020-09-02 01:09:34 +00:00
|
|
|
*/
|
|
|
|
void ExitGroup( bool aSelectGroup = false );
|
|
|
|
|
2022-08-22 10:58:09 +00:00
|
|
|
/**
|
|
|
|
* @return the currently-entered group.
|
|
|
|
*/
|
2020-08-12 11:23:30 +00:00
|
|
|
PCB_GROUP* GetEnteredGroup() { return m_enteredGroup; }
|
2020-08-19 22:15:44 +00:00
|
|
|
|
2022-09-08 22:42:18 +00:00
|
|
|
PCB_LAYER_ID GetActiveLayer() { return m_frame->GetActiveLayer(); }
|
|
|
|
|
2021-04-26 17:41:35 +00:00
|
|
|
/**
|
|
|
|
* In general we don't want to select both a parent and any of it's children. This includes
|
|
|
|
* both footprints and their items, and groups and their members.
|
|
|
|
*/
|
2021-04-28 22:53:31 +00:00
|
|
|
void FilterCollectorForHierarchy( GENERAL_COLLECTOR& aCollector, bool aMultiselect ) const;
|
2021-04-26 17:41:35 +00:00
|
|
|
|
2021-12-06 14:27:53 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Check the "allow free pads" setting and if disabled, replace any pads in the collector
|
|
|
|
* with their parent footprints.
|
2021-12-06 14:27:53 +00:00
|
|
|
*/
|
2023-09-03 21:04:00 +00:00
|
|
|
void FilterCollectorForFreePads( GENERAL_COLLECTOR& aCollector,
|
|
|
|
bool aForcePromotion = false ) const;
|
2021-12-08 13:07:18 +00:00
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
/**
|
|
|
|
* Promote any table cell selections to the whole table.
|
|
|
|
*/
|
|
|
|
void FilterCollectorForTableCells( GENERAL_COLLECTOR& aCollector ) const;
|
|
|
|
|
2022-08-22 10:58:09 +00:00
|
|
|
/**
|
|
|
|
* Drop any PCB_MARKERs from the collector.
|
|
|
|
*/
|
2021-12-08 13:07:18 +00:00
|
|
|
void FilterCollectorForMarkers( GENERAL_COLLECTOR& aCollector ) const;
|
2021-12-06 14:27:53 +00:00
|
|
|
|
2022-08-22 10:58:09 +00:00
|
|
|
/**
|
|
|
|
* Apply the SELECTION_FITLER_OPTIONS to the collector.
|
|
|
|
*/
|
2021-09-24 17:57:22 +00:00
|
|
|
void FilterCollectedItems( GENERAL_COLLECTOR& aCollector, bool aMultiSelect );
|
2020-10-13 01:07:57 +00:00
|
|
|
|
2023-08-01 17:37:19 +00:00
|
|
|
/**
|
|
|
|
* Drop footprints that are not directly selected
|
|
|
|
*/
|
2023-12-18 13:32:41 +00:00
|
|
|
void FilterCollectorForFootprints( GENERAL_COLLECTOR& aCollector,
|
|
|
|
const VECTOR2I& aWhere ) const;
|
2023-08-01 17:37:19 +00:00
|
|
|
|
2022-06-16 17:05:48 +00:00
|
|
|
protected:
|
2022-07-12 01:03:45 +00:00
|
|
|
KIGFX::PCB_VIEW* view() const
|
|
|
|
{
|
|
|
|
return static_cast<KIGFX::PCB_VIEW*>( getView() );
|
|
|
|
}
|
|
|
|
|
|
|
|
KIGFX::VIEW_CONTROLS* controls() const
|
|
|
|
{
|
|
|
|
return getViewControls();
|
|
|
|
}
|
|
|
|
|
2024-02-05 12:39:50 +00:00
|
|
|
PCB_BASE_FRAME* frame() const
|
|
|
|
{
|
|
|
|
return getEditFrame<PCB_BASE_FRAME>();
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame() const
|
2022-07-12 01:03:45 +00:00
|
|
|
{
|
|
|
|
return getEditFrame<PCB_BASE_EDIT_FRAME>();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOARD* board() const
|
|
|
|
{
|
|
|
|
return getModel<BOARD>();
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_DRAW_PANEL_GAL* canvas() const
|
|
|
|
{
|
|
|
|
return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetCanvas() );
|
|
|
|
}
|
|
|
|
|
2022-06-16 17:05:48 +00:00
|
|
|
virtual bool ctrlClickHighlights() override;
|
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
SELECTION& selection() override { return m_selection; }
|
|
|
|
|
2013-08-06 07:31:08 +00:00
|
|
|
private:
|
2014-07-09 11:50:27 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Select an item pointed by the parameter \a aWhere.
|
|
|
|
*
|
|
|
|
* If there is more than one item at that place, there is a menu displayed that allows
|
|
|
|
* one to choose the item.
|
2014-07-09 11:50:27 +00:00
|
|
|
*
|
|
|
|
* @param aWhere is the place where the item should be selected.
|
2018-01-01 20:50:50 +00:00
|
|
|
* @param aOnDrag indicates whether a drag operation is being performed.
|
|
|
|
* @param aSelectionCancelledFlag allows the function to inform its caller that a selection
|
2021-01-27 22:15:38 +00:00
|
|
|
* was canceled (for instance, by clicking outside of the
|
|
|
|
* disambiguation menu).
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aClientFilter a callback to allow tool- or action-specific filtering.
|
|
|
|
* @return whether or not the selection is empty.
|
2014-07-09 11:50:27 +00:00
|
|
|
*/
|
2018-01-01 20:50:50 +00:00
|
|
|
bool selectPoint( const VECTOR2I& aWhere, bool aOnDrag = false,
|
2021-07-19 23:56:05 +00:00
|
|
|
bool* aSelectionCancelledFlag = nullptr,
|
|
|
|
CLIENT_SELECTION_FILTER aClientFilter = nullptr );
|
2015-07-09 15:11:34 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Select an item under the cursor unless there is something already selected.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aForceSelect [optional] Forces an item to be selected even if there is already a
|
|
|
|
* selection.
|
|
|
|
* @param aClientFilter A callback to allow tool- or action-specific filtering.
|
|
|
|
* @return whether or not the selection is empty.
|
2015-07-09 15:11:34 +00:00
|
|
|
*/
|
2019-04-21 23:45:34 +00:00
|
|
|
bool selectCursor( bool aForceSelect = false,
|
2021-07-19 23:56:05 +00:00
|
|
|
CLIENT_SELECTION_FILTER aClientFilter = nullptr );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2013-09-04 08:56:06 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Handle drawing a selection box that allows one to select many items at the same time.
|
2013-09-06 14:04:12 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return true if the function was canceled (i.e. CancelEvent was received).
|
2013-09-04 08:56:06 +00:00
|
|
|
*/
|
2013-09-06 14:04:12 +00:00
|
|
|
bool selectMultiple();
|
2013-09-04 08:56:06 +00:00
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
bool selectTableCells( PCB_TABLE* aTable );
|
|
|
|
|
2021-09-05 20:37:52 +00:00
|
|
|
/**
|
|
|
|
* Handle disambiguation actions including displaying the menu.
|
|
|
|
*/
|
|
|
|
int disambiguateCursor( const TOOL_EVENT& aEvent );
|
|
|
|
|
2019-11-22 19:29:07 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Expand the current connected-item selection to the next boundary (junctions, pads, or all)
|
2019-11-22 19:29:07 +00:00
|
|
|
*/
|
2019-05-14 19:21:10 +00:00
|
|
|
int expandConnection( const TOOL_EVENT& aEvent );
|
2018-02-13 10:20:14 +00:00
|
|
|
|
2022-09-13 18:04:57 +00:00
|
|
|
/**
|
|
|
|
* Unroute the selected board connected items.
|
|
|
|
*/
|
|
|
|
int unrouteSelected( const TOOL_EVENT& aEvent );
|
|
|
|
|
2017-02-04 06:44:17 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* Select all copper connections belonging to the same net(s) as the items in the selection.
|
2017-02-04 06:44:17 +00:00
|
|
|
*/
|
2015-03-10 08:36:04 +00:00
|
|
|
int selectNet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2022-09-20 13:35:47 +00:00
|
|
|
/**
|
|
|
|
* Select nearest unconnected footprints on same net as selected items.
|
|
|
|
*/
|
|
|
|
int selectUnconnected( const TOOL_EVENT& aEvent );
|
|
|
|
|
2022-09-22 18:25:44 +00:00
|
|
|
/**
|
|
|
|
* Select and move other nearest footprint unconnected on same net as selected items.
|
|
|
|
*/
|
|
|
|
int grabUnconnected( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-03-27 21:56:39 +00:00
|
|
|
enum STOP_CONDITION
|
|
|
|
{
|
2021-01-27 22:15:38 +00:00
|
|
|
/**
|
|
|
|
* Stop at any place where more than two traces meet.
|
2020-03-27 21:56:39 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Because vias are also traces, this makes selection stop at a via if there is a trace
|
|
|
|
* on another layer as well, but a via with only one connection will be selected.
|
|
|
|
*/
|
2020-03-27 21:56:39 +00:00
|
|
|
STOP_AT_JUNCTION,
|
2021-01-27 22:15:38 +00:00
|
|
|
/** Stop when reaching a pad. */
|
2020-03-27 21:56:39 +00:00
|
|
|
STOP_AT_PAD,
|
2021-01-27 22:15:38 +00:00
|
|
|
/** Select the entire net. */
|
2020-03-27 21:56:39 +00:00
|
|
|
STOP_NEVER
|
|
|
|
};
|
|
|
|
|
2017-02-04 06:44:17 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Select connected tracks and vias.
|
2019-11-22 17:31:03 +00:00
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aStopCondition Indicates where to stop selecting more items.
|
2017-02-04 06:44:17 +00:00
|
|
|
*/
|
2022-01-16 20:29:03 +00:00
|
|
|
void selectAllConnectedTracks( const std::vector<BOARD_CONNECTED_ITEM*>& aStartItems,
|
2022-08-22 10:58:09 +00:00
|
|
|
STOP_CONDITION aStopCondition );
|
2017-02-04 06:44:17 +00:00
|
|
|
|
2023-08-02 01:14:58 +00:00
|
|
|
/**
|
2023-12-18 13:32:41 +00:00
|
|
|
* Select all non-closed shapes that are graphically connected to the given start items.
|
|
|
|
*
|
2023-08-02 01:14:58 +00:00
|
|
|
* @param aStartItems is a list of one or more non-closed shapes
|
|
|
|
*/
|
|
|
|
void selectAllConnectedShapes( const std::vector<PCB_SHAPE*>& aStartItems );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the given item is an open PCB_SHAPE on a non-copper layer
|
|
|
|
*/
|
|
|
|
bool isExpandableGraphicShape( const EDA_ITEM* aItem ) const;
|
|
|
|
|
2022-01-16 20:29:03 +00:00
|
|
|
/*
|
|
|
|
* Select tracks and vias connected to specified board items.
|
|
|
|
*/
|
|
|
|
void selectConnections( const std::vector<BOARD_ITEM*>& aItems );
|
|
|
|
|
2017-03-02 21:07:45 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Select all items with the given sheet timestamp/UUID name (the sheet path).
|
|
|
|
*
|
|
|
|
* The path of the root sheet is "/".
|
2017-03-02 21:07:45 +00:00
|
|
|
*/
|
2020-04-02 12:20:28 +00:00
|
|
|
void selectAllItemsOnSheet( wxString& aSheetPath );
|
2017-03-02 23:42:23 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Select all footprints belonging to same sheet, from Eeschema using cross-probing.
|
2019-05-14 19:21:10 +00:00
|
|
|
int selectSheetContents( const TOOL_EVENT& aEvent );
|
2017-03-02 21:07:45 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Select all footprints belonging to same hierarchical sheet as the selected footprint
|
|
|
|
///< (same sheet path).
|
2017-02-08 16:32:41 +00:00
|
|
|
int selectSameSheet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2022-01-16 20:29:03 +00:00
|
|
|
///< Set selection to items passed by parameter and connected nets (optionally).
|
|
|
|
///< Zooms to fit, if enabled
|
|
|
|
int syncSelection( const TOOL_EVENT& aEvent );
|
|
|
|
int syncSelectionWithNets( const TOOL_EVENT& aEvent );
|
|
|
|
void doSyncSelection( const std::vector<BOARD_ITEM*>& aItems, bool aWithNets );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Invoke filter dialog and modify current selection
|
2017-02-07 06:40:38 +00:00
|
|
|
int filterSelection( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if the given item passes the current SELECTION_FILTER_OPTIONS.
|
2021-09-24 17:57:22 +00:00
|
|
|
bool itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect );
|
2020-06-27 22:48:34 +00:00
|
|
|
|
2013-09-26 16:38:58 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Take necessary action mark an item as unselected.
|
2013-09-26 16:38:58 +00:00
|
|
|
*
|
2014-11-21 10:49:54 +00:00
|
|
|
* @param aItem is an item to be unselected.
|
2013-09-26 16:38:58 +00:00
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
void unselect( EDA_ITEM* aItem ) override;
|
2013-12-18 13:33:34 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Highlight the item visually.
|
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aItem The item to be highlighted.
|
|
|
|
* @param aHighlightMode Either SELECTED or BRIGHTENED
|
|
|
|
* @param aGroup [optional A group to add the item to.
|
2013-12-18 13:33:34 +00:00
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
|
2013-12-18 13:33:34 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Unhighlight the item visually.
|
|
|
|
*
|
2022-08-22 10:58:09 +00:00
|
|
|
* @param aItem The item to be highlighted.
|
|
|
|
* @param aHighlightMode Either SELECTED or BRIGHTENED
|
|
|
|
* @param aGroup [optional] A group to remove the item from.
|
2013-12-18 13:33:34 +00:00
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override;
|
2013-09-26 16:38:58 +00:00
|
|
|
|
2013-09-19 15:02:57 +00:00
|
|
|
/**
|
2022-08-22 10:58:09 +00:00
|
|
|
* @return true if the given point is contained in any of selected items' bounding boxes.
|
2013-09-19 15:02:57 +00:00
|
|
|
*/
|
2014-02-27 15:13:27 +00:00
|
|
|
bool selectionContains( const VECTOR2I& aPoint ) const;
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2022-08-22 10:58:09 +00:00
|
|
|
/**
|
2023-12-18 13:32:41 +00:00
|
|
|
* @return the distance from \a aWhere to \a aItem, up to and including \a aMaxDistance.
|
2022-08-22 10:58:09 +00:00
|
|
|
*/
|
2023-02-19 03:40:07 +00:00
|
|
|
int hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aItem, int aMaxDistance ) const;
|
2020-12-01 14:03:34 +00:00
|
|
|
|
2017-04-20 10:06:58 +00:00
|
|
|
/**
|
|
|
|
* Event handler to update the selection VIEW_ITEM.
|
|
|
|
*/
|
|
|
|
int updateSelection( const TOOL_EVENT& aEvent );
|
|
|
|
|
2023-12-17 21:43:35 +00:00
|
|
|
void pruneObscuredSelectionCandidates( GENERAL_COLLECTOR& aCollector ) const;
|
|
|
|
|
2017-10-31 15:13:41 +00:00
|
|
|
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const;
|
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
private:
|
2022-07-12 01:03:45 +00:00
|
|
|
void highlightInternal( EDA_ITEM* aItem, int aHighlightMode, bool aUsingOverlay );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
void unhighlightInternal( EDA_ITEM* aItem, int aHighlightMode, bool aUsingOverlay );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2021-04-12 10:10:22 +00:00
|
|
|
private:
|
|
|
|
PCB_BASE_FRAME* m_frame; // Pointer to the parent frame
|
2022-07-12 01:03:45 +00:00
|
|
|
bool m_isFootprintEditor;
|
|
|
|
|
2021-04-12 10:10:22 +00:00
|
|
|
PCB_SELECTION m_selection; // Current state of selection
|
2019-06-08 21:48:22 +00:00
|
|
|
|
2024-02-25 22:39:14 +00:00
|
|
|
PCB_SELECTION_FILTER_OPTIONS m_filter;
|
2020-06-27 22:48:34 +00:00
|
|
|
|
2021-04-12 10:10:22 +00:00
|
|
|
KICURSOR m_nonModifiedCursor; // Cursor in the absence of shift/ctrl/alt
|
2020-09-25 21:48:07 +00:00
|
|
|
|
2021-04-12 10:10:22 +00:00
|
|
|
PCB_GROUP* m_enteredGroup; // If non-null, selections are limited to
|
|
|
|
// members of this group
|
|
|
|
KIGFX::VIEW_GROUP m_enteredGroupOverlay; // Overlay for the entered group's frame.
|
2014-07-09 14:50:31 +00:00
|
|
|
|
2017-02-07 06:40:38 +00:00
|
|
|
/// Private state (opaque pointer/compilation firewall)
|
|
|
|
class PRIV;
|
2021-04-12 10:10:22 +00:00
|
|
|
std::unique_ptr<PRIV> m_priv;
|
2013-08-02 14:53:50 +00:00
|
|
|
};
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
#endif /* PCB_SELECTION_TOOL_H */
|