2020-09-09 02:54:17 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
2021-01-16 23:17:32 +00:00
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-09-09 02:54:17 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@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
|
|
|
|
*/
|
|
|
|
|
2021-01-16 23:17:32 +00:00
|
|
|
#ifndef EE_GRID_HELPER_H
|
|
|
|
#define EE_GRID_HELPER_H
|
2020-12-03 15:10:23 +00:00
|
|
|
|
2020-09-09 02:54:17 +00:00
|
|
|
#include <math/vector2d.h>
|
|
|
|
#include <origin_viewitem.h>
|
2021-01-16 23:17:32 +00:00
|
|
|
#include <tool/grid_helper.h>
|
2020-12-02 23:17:56 +00:00
|
|
|
#include <ee_selection.h>
|
2020-09-09 02:54:17 +00:00
|
|
|
|
|
|
|
class SCH_ITEM;
|
2023-08-22 14:09:04 +00:00
|
|
|
class LIB_ITEM;
|
2020-09-09 02:54:17 +00:00
|
|
|
|
2020-12-03 15:10:23 +00:00
|
|
|
|
2021-01-16 23:17:32 +00:00
|
|
|
class EE_GRID_HELPER : public GRID_HELPER
|
2020-12-03 15:10:23 +00:00
|
|
|
{
|
2020-09-09 02:54:17 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
EE_GRID_HELPER( TOOL_MANAGER* aToolMgr );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetSnapped
|
|
|
|
* If the EE_GRID_HELPER has highlighted a snap point (target shown), this function
|
|
|
|
* will return a pointer to the item to which it snapped.
|
|
|
|
*
|
|
|
|
* @return NULL if not snapped. Pointer to snapped item otherwise
|
|
|
|
*/
|
|
|
|
SCH_ITEM* GetSnapped() const;
|
|
|
|
|
2023-08-23 17:05:08 +00:00
|
|
|
VECTOR2D GetGridSize( GRID_HELPER_GRIDS aGrid ) const override;
|
2023-07-23 17:51:42 +00:00
|
|
|
using GRID_HELPER::GetGrid;
|
|
|
|
|
2023-08-23 17:05:08 +00:00
|
|
|
GRID_HELPER_GRIDS GetSelectionGrid( const SELECTION& aItem ) const override;
|
|
|
|
GRID_HELPER_GRIDS GetItemGrid( const EDA_ITEM* aItem ) const override;
|
2023-07-23 17:51:42 +00:00
|
|
|
|
|
|
|
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, GRID_HELPER_GRIDS aGrid,
|
|
|
|
const EE_SELECTION& aItems );
|
2020-09-09 02:54:17 +00:00
|
|
|
|
2023-08-22 14:09:04 +00:00
|
|
|
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM* aSkip );
|
2023-07-23 17:51:42 +00:00
|
|
|
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, GRID_HELPER_GRIDS aGrid,
|
|
|
|
const EE_SELECTION& aSkip = {} );
|
2020-09-09 02:54:17 +00:00
|
|
|
|
|
|
|
private:
|
2021-01-16 23:17:32 +00:00
|
|
|
std::set<SCH_ITEM*> queryVisible( const BOX2I& aArea, const EE_SELECTION& aSkipList ) const;
|
2020-09-09 02:54:17 +00:00
|
|
|
|
2023-08-23 17:05:08 +00:00
|
|
|
ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, GRID_HELPER_GRIDS aGrid );
|
2020-09-09 02:54:17 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-14 18:00:08 +00:00
|
|
|
* Insert the local anchor points in to the grid helper for the specified
|
2020-09-09 02:54:17 +00:00
|
|
|
* schematic item, given the reference point and the direction of use for the point.
|
|
|
|
*
|
|
|
|
* @param aItem The schematic item for which to compute the anchors
|
2021-06-14 18:00:08 +00:00
|
|
|
* @param aRefPos The point for which to compute the anchors (if used by the symbol)
|
2020-09-09 02:54:17 +00:00
|
|
|
* @param aFrom Is this for an anchor that is designating a source point (aFrom=true) or not
|
2021-11-14 16:54:04 +00:00
|
|
|
* @param aIncludeText if true will compute anchors for text items
|
2020-09-09 02:54:17 +00:00
|
|
|
*/
|
2021-11-14 16:54:04 +00:00
|
|
|
void computeAnchors( SCH_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom = false,
|
|
|
|
bool aIncludeText = false );
|
2020-09-09 02:54:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|