90 bool hasConnectables =
false;
97 hasConnectables =
true;
106 double lineSnapMinCornerDistance = 50.0 / worldScale;
112 double minDist = std::numeric_limits<double>::max();
116 minDist = nearestOrigin->
Distance( aMousePos );
117 best = nearestOrigin;
122 double dist = nearestCorner->
Distance( aMousePos );
127 best = nearestCorner;
133 double dist = nearestOutline->
Distance( aMousePos );
135 if( minDist > lineSnapMinCornerDistance && dist < minDist )
136 best = nearestOutline;
139 return best ? best->
pos : aMousePos;
147 skipItems.
Add( aSkip );
159 VECTOR2I snapDist( snapRange, snapRange );
160 bool snapLineX =
false;
161 bool snapLineY =
false;
162 bool snapPoint =
false;
163 bool gridChecked =
false;
165 BOX2I bb(
VECTOR2I( aOrigin.
x - snapRange / 2, aOrigin.
y - snapRange / 2 ),
181 ad->AddAnchor( a.pos );
183 ad->SetNearest( nearest ?
OPT_VECTOR2I( nearest->
pos ) : std::nullopt );
195 if(
std::abs( snapLineOrigin->x - aOrigin.
x ) < snapDist.
x )
197 pt.
x = snapLineOrigin->x;
202 if(
std::abs( snapLineOrigin->y - aOrigin.
y ) < snapDist.
y )
204 pt.
y = snapLineOrigin->y;
211 pt.
x = nearestGrid.
x;
212 snapDist.
x =
std::abs( nearestGrid.
x - aOrigin.
x );
218 pt.
y = nearestGrid.
y;
219 snapDist.
y =
std::abs( nearestGrid.
y - aOrigin.
y );
232 snapDist.
x =
std::abs( nearestGrid.
x - aOrigin.
x );
233 snapDist.
y =
std::abs( nearestGrid.
y - aOrigin.
y );
252 if( snapLineX || snapLineY )
285 if( !
grid.overrides_enabled )
291 if(
grid.override_connected )
292 idx =
grid.override_connected_idx;
297 if(
grid.override_wires )
298 idx =
grid.override_wires_idx;
303 if(
grid.override_text )
304 idx =
grid.override_text_idx;
309 if(
grid.override_graphics )
310 idx =
grid.override_graphics_idx;
318 if( idx >= 0 && idx < (
int)
grid.grids.size() )
340 std::set<SCH_ITEM*> items;
341 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
346 view->
Query( aArea, selectedItems );
350 if( !it.first->IsSCH_ITEM() )
370 items.insert ( item );
373 for(
EDA_ITEM* skipItem : aSkipList )
374 items.erase(
static_cast<SCH_ITEM*
>( skipItem ) );
402 switch( aItem->
Type() )
431 if(
static_cast<const SCH_LINE*
>( aItem )->IsConnectable() )
446 if(
group->GetItems().empty() )
474 switch( aItem->
Type() )
518 if( isGraphicLine && !aIncludeText )
557 if( aItem->
Type() ==
SCH_LINE_T && ( aIncludeText || !isGraphicLine ) )
583 double minDist = std::numeric_limits<double>::max();
588 if( ( aFlags & a.flags ) != aFlags )
592 if( !a.items.empty() )
603 double dist = a.Distance( aPos );
constexpr EDA_IU_SCALE schIUScale
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
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.
GRID_HELPER_GRIDS GetSelectionGrid(const SELECTION &aItem) const override
Gets the coarsest grid that applies to a selecion of items.
~EE_GRID_HELPER() override
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Get the coarsest grid that applies to an item.
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, GRID_HELPER_GRIDS aGrid, const SCH_SELECTION &aItems)
std::set< SCH_ITEM * > queryVisible(const BOX2I &aArea, const SCH_SELECTION &aSkipList) const
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM *aSkip)
ANCHOR * nearestAnchor(const VECTOR2I &aPos, int aFlags, GRID_HELPER_GRIDS aGrid)
VECTOR2D GetGridSize(GRID_HELPER_GRIDS aGrid) const override
Return the size of the specified grid.
SCH_ITEM * GetSnapped() const
Function GetSnapped If the EE_GRID_HELPER has highlighted a snap point (target shown),...
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,...
void addAnchor(const VECTOR2I &aPos, int aFlags, EDA_ITEM *aItem, int aPointTypes=POINT_TYPE::PT_NONE)
SNAP_MANAGER & getSnapManager()
void showConstructionGeometry(bool aShow)
bool canUseGrid() const
Check whether it is possible to use the grid – this depends both on local grid helper settings and gl...
std::optional< ANCHOR > m_snapItem
KIGFX::ANCHOR_DEBUG * enableAndGetAnchorDebug()
Enable the anchor debug if permitted and return it.
KIGFX::SNAP_INDICATOR m_viewSnapPoint
virtual VECTOR2I Align(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
KIGFX::ORIGIN_VIEWITEM m_viewAxis
std::vector< ANCHOR > m_anchors
View item to draw debug items for anchors.
A color representation with 4 components: red, green, blue, alpha.
const VECTOR2D & GetGridSize() const
Return the grid size.
double GetWorldScale() const
Get the world scale.
void SetPosition(const VECTOR2I &aPosition) override
void SetColor(const KIGFX::COLOR4D &aColor)
void SetStyle(MARKER_STYLE aStyle)
void SetDrawAtZero(bool aDrawFlag)
Set the draw at zero flag.
virtual double ViewGetLOD(int aLayer, const 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 void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
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.
A set of SCH_ITEMs (i.e., without duplicates).
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,...
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
virtual void Add(EDA_ITEM *aItem)
A class that manages the geometry of a "snap line".
void ClearSnapLine()
Clear the snap line origin and end points.
void SetSnapLineOrigin(const VECTOR2I &aOrigin)
The snap point is a special point that is located at the last point the cursor snapped to.
void SetSnapLineEnd(const OPT_VECTOR2I &aSnapPoint)
Set the end point of the snap line.
const OPT_VECTOR2I & GetSnapLineOrigin() const
SNAP_LINE_MANAGER & GetSnapLineManager()
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
@ FRAME_SCH_SYMBOL_EDITOR
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)
Class to handle a set of SCH_ITEMs.
std::optional< VECTOR2I > OPT_VECTOR2I
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.
VECTOR2< int32_t > VECTOR2I