2015-06-18 17:51:51 +02:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2021-01-27 17:15:38 -05:00
|
|
|
*
|
2015-06-18 17:51:51 +02:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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_PICKER_TOOL_H
|
|
|
|
#define PCB_PICKER_TOOL_H
|
2015-06-18 17:51:51 +02:00
|
|
|
|
2021-07-29 10:47:43 +01:00
|
|
|
#include <layer_ids.h>
|
2021-01-31 09:50:19 -05:00
|
|
|
#include <tool/picker_tool.h>
|
2019-05-12 12:49:58 +01:00
|
|
|
#include <tools/pcb_tool_base.h>
|
2015-06-18 17:51:51 +02:00
|
|
|
|
|
|
|
/**
|
2021-01-27 17:15:38 -05:00
|
|
|
*Generic tool for picking an item.
|
2015-06-18 17:51:51 +02:00
|
|
|
*/
|
2021-01-31 09:50:19 -05:00
|
|
|
class PCB_PICKER_TOOL : public PCB_TOOL_BASE, public PICKER_TOOL_BASE
|
2015-06-18 17:51:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2024-10-28 21:23:56 +08:00
|
|
|
/**
|
|
|
|
* Interface class for something that receives picked points
|
|
|
|
* or items from this tool. Examples could be a dialog that's
|
|
|
|
* asking the user to pick a point.
|
|
|
|
*/
|
|
|
|
class RECEIVER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint ) = 0;
|
|
|
|
virtual void UpdatePickedItem( const EDA_ITEM* aItem ) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
~RECEIVER() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct INTERACTIVE_PARAMS
|
|
|
|
{
|
|
|
|
RECEIVER* m_Receiver = nullptr;
|
|
|
|
wxString m_Prompt;
|
2024-11-24 12:00:20 -05:00
|
|
|
std::function<bool(EDA_ITEM*)> m_ItemFilter = nullptr;
|
2024-10-28 21:23:56 +08:00
|
|
|
};
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_PICKER_TOOL();
|
2021-01-31 09:50:19 -05:00
|
|
|
virtual ~PCB_PICKER_TOOL() = default;
|
2015-06-18 17:51:51 +02:00
|
|
|
|
2024-09-11 21:40:43 +01:00
|
|
|
///< @copydoc TOOL_BASE::Init()
|
|
|
|
bool Init() override;
|
|
|
|
|
2021-01-27 17:15:38 -05:00
|
|
|
///< Main event loop.
|
2015-06-18 17:51:51 +02:00
|
|
|
int Main( const TOOL_EVENT& aEvent );
|
|
|
|
|
2018-10-03 22:10:50 -07:00
|
|
|
/**
|
2021-01-27 17:15:38 -05:00
|
|
|
* Set the tool's snap layer set.
|
2018-10-03 22:10:50 -07:00
|
|
|
*/
|
2025-03-23 20:33:22 +00:00
|
|
|
inline void SetLayerSet( const LSET& aLayerSet ) { m_layerMask = aLayerSet; }
|
2018-10-03 22:10:50 -07:00
|
|
|
|
2024-10-28 21:23:56 +08:00
|
|
|
int SelectPointInteractively( const TOOL_EVENT& aEvent );
|
|
|
|
int SelectItemInteractively( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-31 09:50:19 -05:00
|
|
|
protected:
|
2021-01-27 17:15:38 -05:00
|
|
|
///< @copydoc TOOL_INTERACTIVE::setTransitions();
|
2017-07-31 14:30:51 +02:00
|
|
|
void setTransitions() override;
|
2015-06-18 17:51:51 +02:00
|
|
|
|
2021-01-31 09:50:19 -05:00
|
|
|
///< Applies the requested VIEW_CONTROLS settings.
|
2015-07-24 10:58:47 +02:00
|
|
|
void setControls();
|
2019-07-16 00:44:01 +01:00
|
|
|
|
2021-01-31 09:50:19 -05:00
|
|
|
///< Reinitialize tool to its initial state.
|
|
|
|
void reset() override;
|
|
|
|
|
2019-07-16 00:44:01 +01:00
|
|
|
private:
|
2021-01-27 17:15:38 -05:00
|
|
|
///< The layer set to use for optional snapping.
|
2019-07-16 00:44:01 +01:00
|
|
|
LSET m_layerMask;
|
2015-06-18 17:51:51 +02:00
|
|
|
};
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
#endif /* PCB_PICKER_TOOL_H */
|