2017-09-17 22:44:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
2022-07-12 01:03:45 +00:00
|
|
|
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-09-17 22:44:30 +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 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-08 21:48:22 +00:00
|
|
|
#ifndef GERBVIEW_SELECTION_TOOL_H
|
|
|
|
#define GERBVIEW_SELECTION_TOOL_H
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <math/vector2d.h>
|
|
|
|
#include <tool/tool_interactive.h>
|
2019-05-14 11:14:00 +00:00
|
|
|
#include <tool/action_menu.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <tool/selection_conditions.h>
|
2021-09-05 20:37:52 +00:00
|
|
|
#include <tool/selection_tool.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <tool/tool_menu.h>
|
2019-06-08 21:48:22 +00:00
|
|
|
#include <tools/gerbview_selection.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <gerbview_frame.h>
|
|
|
|
|
|
|
|
class SELECTION_AREA;
|
|
|
|
class GERBER_COLLECTOR;
|
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class GAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Selection tool for GerbView, based on the one in Pcbnew
|
2017-09-17 22:44:30 +00:00
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
class GERBVIEW_SELECTION_TOOL : public SELECTION_TOOL
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
GERBVIEW_SELECTION_TOOL();
|
|
|
|
~GERBVIEW_SELECTION_TOOL();
|
|
|
|
|
|
|
|
/// @copydoc TOOL_BASE::Init()
|
|
|
|
bool Init() override;
|
|
|
|
|
|
|
|
/// @copydoc TOOL_BASE::Reset()
|
|
|
|
void Reset( RESET_REASON aReason ) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main loop.
|
|
|
|
*/
|
|
|
|
int Main( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the set of currently selected items.
|
2017-09-17 22:44:30 +00:00
|
|
|
*/
|
2019-06-08 21:48:22 +00:00
|
|
|
GERBVIEW_SELECTION& GetSelection();
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
int ClearSelection( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int SelectItem( const TOOL_EVENT& aEvent );
|
|
|
|
int SelectItems( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int UnselectItem( const TOOL_EVENT& aEvent );
|
|
|
|
int UnselectItems( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Sets up handlers for various events.
|
2017-09-17 22:44:30 +00:00
|
|
|
void setTransitions() override;
|
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
protected:
|
|
|
|
SELECTION& selection() override { return m_selection; }
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
private:
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Select an item pointed by the parameter aWhere. If there is more than one item at that
|
2019-07-11 23:28:46 +00:00
|
|
|
* place, there is a menu displayed that allows one to choose the item.
|
2017-09-17 22:44:30 +00:00
|
|
|
*
|
|
|
|
* @param aWhere is the place where the item should be selected.
|
|
|
|
* @return True if an item was selected, false otherwise.
|
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
bool selectPoint( const VECTOR2I& aWhere );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Clear the current selection.
|
2017-09-17 22:44:30 +00:00
|
|
|
*/
|
|
|
|
void clearSelection();
|
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Check conditions for an item to be selected.
|
2017-09-17 22:44:30 +00:00
|
|
|
*
|
|
|
|
* @return True if the item fulfills conditions to be selected.
|
|
|
|
*/
|
|
|
|
bool selectable( const EDA_ITEM* aItem ) const;
|
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Take necessary action mark an item as selected.
|
2017-09-17 22:44:30 +00:00
|
|
|
*
|
|
|
|
* @param aItem is an item to be selected.
|
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
void select( EDA_ITEM* aItem ) override;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Take necessary action mark an item as unselected.
|
2017-09-17 22:44:30 +00:00
|
|
|
*
|
|
|
|
* @param aItem is an item to be unselected.
|
|
|
|
*/
|
2022-07-12 01:03:45 +00:00
|
|
|
void unselect( EDA_ITEM* aItem ) override;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Mark item as selected, but does not add it to the #ITEMS_PICKED_LIST.
|
|
|
|
*
|
2017-09-17 22:44:30 +00:00
|
|
|
* @param aItem is an item to be be marked.
|
|
|
|
*/
|
2017-09-25 01:12:58 +00:00
|
|
|
void selectVisually( EDA_ITEM* aItem );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Mark item as selected, but does not add it to the #ITEMS_PICKED_LIST.
|
|
|
|
*
|
2017-09-17 22:44:30 +00:00
|
|
|
* @param aItem is an item to be be marked.
|
|
|
|
*/
|
2017-09-25 01:12:58 +00:00
|
|
|
void unselectVisually( EDA_ITEM* aItem );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
/**
|
|
|
|
* Highlight the item visually.
|
|
|
|
*
|
|
|
|
* @param aItem is an item to be be highlighted.
|
|
|
|
* @param aHighlightMode should be either SELECTED or BRIGHTENED
|
|
|
|
* @param aGroup is the group to add the item to in the BRIGHTENED mode.
|
|
|
|
*/
|
|
|
|
void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override
|
|
|
|
{
|
|
|
|
// Currently not used in GerbView
|
|
|
|
};
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
/**
|
|
|
|
* Unhighlight the item visually.
|
|
|
|
*
|
|
|
|
* @param aItem is an item to be be highlighted.
|
|
|
|
* @param aHighlightMode should be either SELECTED or BRIGHTENED
|
|
|
|
* @param aGroup is the group to remove the item from.
|
|
|
|
*/
|
|
|
|
void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override
|
|
|
|
{
|
|
|
|
// Currently not used in GerbView
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
GERBVIEW_FRAME* m_frame; // Pointer to the parent frame.
|
|
|
|
GERBVIEW_SELECTION m_selection; // Current state of selection.
|
2017-09-17 22:44:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|