71 bool includeText = ( aItems.
Size() == 1
78 double lineSnapMinCornerDistance = 50.0 / worldScale;
84 double minDist = std::numeric_limits<double>::max();
88 minDist = nearestOrigin->
Distance( aMousePos );
94 double dist = nearestCorner->
Distance( aMousePos );
105 double dist = nearestOutline->
Distance( aMousePos );
107 if( minDist > lineSnapMinCornerDistance && dist < minDist )
108 best = nearestOutline;
111 return best ? best->
pos : aMousePos;
118 skipItems.
Add( aSkip );
130 VECTOR2I snapDist( snapRange, snapRange );
131 bool snapLineX =
false;
132 bool snapLineY =
false;
133 bool snapPoint =
false;
134 bool gridChecked =
false;
136 BOX2I bb(
VECTOR2I( aOrigin.
x - snapRange / 2, aOrigin.
y - snapRange / 2 ),
165 pt.
x = nearestGrid.
x;
166 snapDist.
x =
std::abs( nearestGrid.
x - aOrigin.
x );
172 pt.
y = nearestGrid.
y;
173 snapDist.
y =
std::abs( nearestGrid.
y - aOrigin.
y );
186 snapDist.
x =
std::abs( nearestGrid.
x - aOrigin.
x );
187 snapDist.
y =
std::abs( nearestGrid.
y - aOrigin.
y );
198 snapLineX = snapLineY =
false;
205 if( snapLineX || snapLineY )
248 std::set<SCH_ITEM*> items;
249 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
253 view->
Query( aArea, selectedItems );
261 items.insert ( item );
264 for(
EDA_ITEM* skipItem : aSkipList )
265 items.erase(
static_cast<SCH_ITEM*
>( skipItem ) );
274 switch( aItem->
Type() )
313 if(
SCH_LINE* line = dyn_cast<SCH_LINE*>( aItem ) )
317 if( line->GetStartPoint().x == line->GetEndPoint().x )
319 VECTOR2I possible( line->GetStartPoint().x, pt.
y );
321 if(
TestSegmentHit( possible, line->GetStartPoint(), line->GetEndPoint(), 0 ) )
324 else if( line->GetStartPoint().y == line->GetEndPoint().y )
326 VECTOR2I possible( pt.
x, line->GetStartPoint().y );
328 if(
TestSegmentHit( possible, line->GetStartPoint(), line->GetEndPoint(), 0 ) )
339 double minDist = std::numeric_limits<double>::max();
346 if( ( aFlags & a.flags ) != aFlags )
354 double dist = a.Distance( aPos );
constexpr EDA_IU_SCALE schIUScale
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
KICAD_T Type() const
Returns the type of object.
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, int aLayer, SCH_ITEM *aDraggedItem)
std::set< SCH_ITEM * > queryVisible(const BOX2I &aArea, const EE_SELECTION &aSkipList) const
SCH_ITEM * GetSnapped() const
Function GetSnapped If the EE_GRID_HELPER has highlighted a snap point (target shown),...
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, int aLayer, const EE_SELECTION &aItems)
EE_GRID_HELPER(TOOL_MANAGER *aToolMgr)
void computeAnchors(SCH_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom=false, bool aIncludeText=false)
Insert the local anchor points in to the grid helper for the specified schematic item,...
ANCHOR * nearestAnchor(const VECTOR2I &aPos, int aFlags, int aMatchLayer)
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
void addAnchor(const VECTOR2I &aPos, int aFlags, EDA_ITEM *aItem)
bool canUseGrid() const
Check whether it is possible to use the grid – this depends both on local grid helper settings and gl...
KIGFX::ORIGIN_VIEWITEM m_viewSnapPoint
KIGFX::ORIGIN_VIEWITEM m_viewSnapLine
KIGFX::ORIGIN_VIEWITEM m_viewAxis
std::vector< ANCHOR > m_anchors
A color representation with 4 components: red, green, blue, alpha.
double GetWorldScale() const
Get the world scale.
void SetPosition(const VECTOR2I &aPosition) override
void SetColor(const KIGFX::COLOR4D &aColor)
VECTOR2I GetPosition() const override
void SetStyle(MARKER_STYLE aStyle)
void SetDrawAtZero(bool aDrawFlag)
Set the draw at zero flag.
void SetEndPosition(const VECTOR2D &aPosition)
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire,...
virtual void Add(EDA_ITEM *aItem)
int Size() const
Returns the number of selected parts.
bool OnlyContains(std::vector< KICAD_T > aList) const
Checks if all items in the selection have a type in aList.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
@ GEOMETRY
Position or shape has changed.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
double Distance(const VECTOR2I &aP) const
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
double EuclideanNorm(const VECTOR2I &vector)