KiCad PCB EDA Suite
grid_helper.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <functional>
27 using namespace std::placeholders;
28 
29 #include <class_board.h>
30 #include <class_dimension.h>
31 #include <class_edge_mod.h>
32 #include <class_module.h>
33 #include <class_track.h>
34 #include <class_zone.h>
35 #include <tool/tool_manager.h>
37 #include <macros.h>
38 #include <math/util.h> // for KiROUND
39 #include <math/vector2d.h>
40 #include <painter.h>
41 #include <pcbnew_settings.h>
42 #include <view/view.h>
43 #include <view/view_controls.h>
44 
45 #include "grid_helper.h"
46 
47 
48 GRID_HELPER::GRID_HELPER( TOOL_MANAGER* aToolMgr, MAGNETIC_SETTINGS* aMagneticSettings ) :
49  m_toolMgr( aToolMgr ),
50  m_magneticSettings( aMagneticSettings )
51 {
52  m_enableSnap = true;
53  m_enableGrid = true;
54  m_enableSnapLine = true;
55  m_snapSize = 100;
56  m_snapItem = nullptr;
57  KIGFX::VIEW* view = m_toolMgr->GetView();
58 
59  m_viewAxis.SetSize( 20000 );
61  m_viewAxis.SetColor( COLOR4D( 1.0, 1.0, 1.0, 0.4 ) );
62  m_viewAxis.SetDrawAtZero( true );
63  view->Add( &m_viewAxis );
64  view->SetVisible( &m_viewAxis, false );
65 
67  m_viewSnapPoint.SetColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
69  view->Add( &m_viewSnapPoint );
70  view->SetVisible( &m_viewSnapPoint, false );
71 
73  m_viewSnapLine.SetColor( COLOR4D( 0.33, 0.55, 0.95, 1.0 ) );
75  view->Add( &m_viewSnapLine );
76  view->SetVisible( &m_viewSnapLine, false );
77 }
78 
79 
81 {
82 }
83 
84 
86 {
88 
89  return VECTOR2I( KiROUND( size.x ), KiROUND( size.y ) );
90 }
91 
92 
94 {
95  VECTOR2D origin = m_toolMgr->GetView()->GetGAL()->GetGridOrigin();
96 
97  return VECTOR2I( origin );
98 }
99 
100 
101 void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin )
102 {
103  if( aEnable )
104  {
105  m_auxAxis = aOrigin;
106  m_viewAxis.SetPosition( aOrigin );
107  m_toolMgr->GetView()->SetVisible( &m_viewAxis, true );
108  }
109  else
110  {
112  m_toolMgr->GetView()->SetVisible( &m_viewAxis, false );
113  }
114 }
115 
116 
117 VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint ) const
118 {
119  if( !m_enableGrid )
120  return aPoint;
121 
122  const VECTOR2D gridOffset( GetOrigin() );
123  const VECTOR2D grid( GetGrid() );
124 
125  VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / grid.x ) * grid.x + gridOffset.x,
126  KiROUND( ( aPoint.y - gridOffset.y ) / grid.y ) * grid.y + gridOffset.y );
127 
128  if( !m_auxAxis )
129  return nearest;
130 
131  if( std::abs( m_auxAxis->x - aPoint.x ) < std::abs( nearest.x - aPoint.x ) )
132  nearest.x = m_auxAxis->x;
133 
134  if( std::abs( m_auxAxis->y - aPoint.y ) < std::abs( nearest.y - aPoint.y ) )
135  nearest.y = m_auxAxis->y;
136 
137  return nearest;
138 }
139 
140 
141 VECTOR2I GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSeg )
142 {
143  OPT_VECTOR2I pts[6];
144 
145  if( !m_enableSnap )
146  return aPoint;
147 
148  const VECTOR2D gridOffset( GetOrigin() );
149  const VECTOR2D gridSize( GetGrid() );
150 
151  VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
152  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
153 
154  pts[0] = aSeg.A;
155  pts[1] = aSeg.B;
156  pts[2] = aSeg.IntersectLines( SEG( nearest + VECTOR2I( -1, 1 ), nearest + VECTOR2I( 1, -1 ) ) );
157  pts[3] = aSeg.IntersectLines( SEG( nearest + VECTOR2I( -1, -1 ), nearest + VECTOR2I( 1, 1 ) ) );
158 
159  int min_d = std::numeric_limits<int>::max();
160 
161  for( int i = 0; i < 4; i++ )
162  {
163  if( pts[i] && aSeg.Contains( *pts[i] ) )
164  {
165  int d = (*pts[i] - aPoint).EuclideanNorm();
166 
167  if( d < min_d )
168  {
169  min_d = d;
170  nearest = *pts[i];
171  }
172  }
173  }
174 
175  return nearest;
176 }
177 
178 
179 VECTOR2I GRID_HELPER::AlignToArc( const VECTOR2I& aPoint, const SHAPE_ARC& aArc )
180 {
181  if( !m_enableSnap )
182  return aPoint;
183 
184  const VECTOR2D gridOffset( GetOrigin() );
185  const VECTOR2D gridSize( GetGrid() );
186 
187  VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
188  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
189 
190  int min_d = std::numeric_limits<int>::max();
191 
192  for( auto pt : { aArc.GetP0(), aArc.GetP1() } )
193  {
194  int d = ( pt - aPoint ).EuclideanNorm();
195 
196  if( d < min_d )
197  {
198  min_d = d;
199  nearest = pt;
200  }
201  else
202  break;
203  }
204 
205  return nearest;
206 }
207 
208 
209 VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, std::vector<BOARD_ITEM*>& aItems )
210 {
211  clearAnchors();
212 
213  for( BOARD_ITEM* item : aItems )
214  computeAnchors( item, aMousePos, true );
215 
216  double worldScale = m_toolMgr->GetView()->GetGAL()->GetWorldScale();
217  double lineSnapMinCornerDistance = 50.0 / worldScale;
218 
219  ANCHOR* nearestOutline = nearestAnchor( aMousePos, OUTLINE, LSET::AllLayersMask() );
220  ANCHOR* nearestCorner = nearestAnchor( aMousePos, CORNER, LSET::AllLayersMask() );
221  ANCHOR* nearestOrigin = nearestAnchor( aMousePos, ORIGIN, LSET::AllLayersMask() );
222  ANCHOR* best = NULL;
223  double minDist = std::numeric_limits<double>::max();
224 
225  if( nearestOrigin )
226  {
227  minDist = nearestOrigin->Distance( aMousePos );
228  best = nearestOrigin;
229  }
230 
231  if( nearestCorner )
232  {
233  double dist = nearestCorner->Distance( aMousePos );
234 
235  if( dist < minDist )
236  {
237  minDist = dist;
238  best = nearestCorner;
239  }
240  }
241 
242  if( nearestOutline )
243  {
244  double dist = nearestOutline->Distance( aMousePos );
245 
246  if( minDist > lineSnapMinCornerDistance && dist < minDist )
247  best = nearestOutline;
248  }
249 
250  return best ? best->pos : aMousePos;
251 }
252 
253 
254 std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea,
255  const std::vector<BOARD_ITEM*>& aSkip ) const
256 {
257  std::set<BOARD_ITEM*> items;
258  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
259 
260  KIGFX::VIEW* view = m_toolMgr->GetView();
261  RENDER_SETTINGS* settings = view->GetPainter()->GetSettings();
262  const std::set<unsigned int>& activeLayers = settings->GetActiveLayers();
263  bool isHighContrast = settings->GetHighContrast();
264 
265  view->Query( aArea, selectedItems );
266 
267  for( const KIGFX::VIEW::LAYER_ITEM_PAIR& it : selectedItems )
268  {
269  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
270 
271  // The item must be visible and on an active layer
272  if( view->IsVisible( item )
273  && ( !isHighContrast || activeLayers.count( it.second ) )
274  && item->ViewGetLOD( it.second, view ) < view->GetScale() )
275  {
276  items.insert ( item );
277  }
278  }
279 
280 
281  for( BOARD_ITEM* skipItem : aSkip )
282  items.erase( skipItem );
283 
284  return items;
285 }
286 
287 
288 VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem )
289 {
290  LSET layers;
291  std::vector<BOARD_ITEM*> item;
292 
293  if( aDraggedItem )
294  {
295  layers = aDraggedItem->GetLayerSet();
296  item.push_back( aDraggedItem );
297  }
298  else
299  layers = LSET::AllLayersMask();
300 
301  return BestSnapAnchor( aOrigin, layers, item );
302 }
303 
304 
305 VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
306  const std::vector<BOARD_ITEM*>& aSkip )
307 {
308  double worldScale = m_toolMgr->GetView()->GetGAL()->GetWorldScale();
309  int snapRange = (int) ( m_snapSize / worldScale );
310 
311  BOX2I bb( VECTOR2I( aOrigin.x - snapRange / 2, aOrigin.y - snapRange / 2 ),
312  VECTOR2I( snapRange, snapRange ) );
313 
314  clearAnchors();
315 
316  for( BOARD_ITEM* item : queryVisible( bb, aSkip ) )
317  computeAnchors( item, aOrigin );
318 
319  ANCHOR* nearest = nearestAnchor( aOrigin, SNAPPABLE, aLayers );
320  VECTOR2I nearestGrid = Align( aOrigin );
321  double gridDist = ( nearestGrid - aOrigin ).EuclideanNorm();
322 
323  if( nearest && m_enableSnap )
324  {
325  double snapDist = nearest->Distance( aOrigin );
326 
327  if( !m_enableGrid || snapDist <= gridDist )
328  {
329  m_viewSnapPoint.SetPosition( nearest->pos );
330  m_viewSnapLine.SetPosition( nearest->pos );
332 
335  else
337 
338  m_snapItem = nearest;
339  return nearest->pos;
340  }
341  }
342 
344  {
345  bool snapLine = false;
346 
347  if( std::abs( m_viewSnapLine.GetPosition().x - aOrigin.x ) < GetGrid().x )
348  {
349  nearestGrid.x = m_viewSnapLine.GetPosition().x;
350  snapLine = true;
351  }
352 
353  if( std::abs( m_viewSnapLine.GetPosition().y - aOrigin.y ) < GetGrid().y )
354  {
355  nearestGrid.y = m_viewSnapLine.GetPosition().y;
356  snapLine = true;
357  }
358 
359  if( snapLine && m_skipPoint != VECTOR2I( m_viewSnapLine.GetPosition() ) )
360  {
361  m_viewSnapLine.SetEndPosition( nearestGrid );
363 
366  else
368 
369  return nearestGrid;
370  }
371  }
372 
373  m_snapItem = nullptr;
376  return nearestGrid;
377 }
378 
379 
381 {
382  if( !m_snapItem )
383  return nullptr;
384 
385  return m_snapItem->item;
386 }
387 
388 
389 void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom )
390 {
391  VECTOR2I origin;
392  KIGFX::VIEW* view = m_toolMgr->GetView();
393  RENDER_SETTINGS* settings = view->GetPainter()->GetSettings();
394  const std::set<unsigned int>& activeLayers = settings->GetActiveLayers();
395  bool isHighContrast = settings->GetHighContrast();
396 
397  switch( aItem->Type() )
398  {
399  case PCB_MODULE_T:
400  {
401  MODULE* mod = static_cast<MODULE*>( aItem );
402 
403  for( D_PAD* pad : mod->Pads() )
404  {
405  // Getting pads from the module requires re-checking that the pad is shown
407  && pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) )
408  && view->IsVisible( pad )
409  && ( !isHighContrast || activeLayers.count( pad->GetLayer() ) )
410  && pad->ViewGetLOD( pad->GetLayer(), view ) < view->GetScale() )
411  {
412  addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
413  break;
414  }
415  }
416 
417  // if the cursor is not over a pad, then drag the module by its origin
418  addAnchor( mod->GetPosition(), ORIGIN | SNAPPABLE, mod );
419  break;
420  }
421 
422  case PCB_PAD_T:
423  {
425  {
426  D_PAD* pad = static_cast<D_PAD*>( aItem );
427  addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
428  }
429 
430  break;
431  }
432 
433  case PCB_MODULE_EDGE_T:
434  case PCB_LINE_T:
435  {
437  break;
438 
439  DRAWSEGMENT* dseg = static_cast<DRAWSEGMENT*>( aItem );
440  VECTOR2I start = dseg->GetStart();
441  VECTOR2I end = dseg->GetEnd();
442 
443  switch( dseg->GetShape() )
444  {
445  case S_CIRCLE:
446  {
447  int r = ( start - end ).EuclideanNorm();
448 
449  addAnchor( start, ORIGIN | SNAPPABLE, dseg );
450  addAnchor( start + VECTOR2I( -r, 0 ), OUTLINE | SNAPPABLE, dseg );
451  addAnchor( start + VECTOR2I( r, 0 ), OUTLINE | SNAPPABLE, dseg );
452  addAnchor( start + VECTOR2I( 0, -r ), OUTLINE | SNAPPABLE, dseg );
453  addAnchor( start + VECTOR2I( 0, r ), OUTLINE | SNAPPABLE, dseg );
454  break;
455  }
456 
457  case S_ARC:
458  origin = dseg->GetCenter();
459  addAnchor( dseg->GetArcStart(), CORNER | SNAPPABLE, dseg );
460  addAnchor( dseg->GetArcEnd(), CORNER | SNAPPABLE, dseg );
461  addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
462  break;
463 
464  case S_RECT:
465  addAnchor( start, CORNER | SNAPPABLE, dseg );
466  addAnchor( VECTOR2I( end.x, start.y ), CORNER | SNAPPABLE, dseg );
467  addAnchor( VECTOR2I( start.x, end.y ), CORNER | SNAPPABLE, dseg );
468  addAnchor( end, CORNER | SNAPPABLE, dseg );
469  break;
470 
471  case S_SEGMENT:
472  origin.x = start.x + ( start.x - end.x ) / 2;
473  origin.y = start.y + ( start.y - end.y ) / 2;
474  addAnchor( start, CORNER | SNAPPABLE, dseg );
475  addAnchor( end, CORNER | SNAPPABLE, dseg );
476  addAnchor( origin, ORIGIN, dseg );
477  break;
478 
479  case S_POLYGON:
480  for( const VECTOR2I& p : dseg->BuildPolyPointsList() )
481  addAnchor( p, CORNER | SNAPPABLE, dseg );
482 
483  break;
484 
485  case S_CURVE:
486  addAnchor( start, CORNER | SNAPPABLE, dseg );
487  addAnchor( end, CORNER | SNAPPABLE, dseg );
489 
490  default:
491  origin = dseg->GetStart();
492  addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
493  break;
494  }
495  break;
496  }
497 
498  case PCB_TRACE_T:
499  case PCB_ARC_T:
500  {
502  {
503  TRACK* track = static_cast<TRACK*>( aItem );
504  VECTOR2I start = track->GetStart();
505  VECTOR2I end = track->GetEnd();
506  origin.x = start.x + ( start.x - end.x ) / 2;
507  origin.y = start.y + ( start.y - end.y ) / 2;
508  addAnchor( start, CORNER | SNAPPABLE, track );
509  addAnchor( end, CORNER | SNAPPABLE, track );
510  addAnchor( origin, ORIGIN, track);
511  }
512 
513  break;
514  }
515 
516  case PCB_MARKER_T:
517  case PCB_TARGET_T:
518  addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
519  break;
520 
521  case PCB_VIA_T:
522  {
524  addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
525 
526  break;
527  }
528 
529  case PCB_ZONE_AREA_T:
530  {
531  const SHAPE_POLY_SET* outline = static_cast<const ZONE_CONTAINER*>( aItem )->Outline();
532 
533  SHAPE_LINE_CHAIN lc;
534  lc.SetClosed( true );
535 
536  for( auto iter = outline->CIterateWithHoles(); iter; iter++ )
537  {
538  addAnchor( *iter, CORNER, aItem );
539  lc.Append( *iter );
540  }
541 
542  addAnchor( lc.NearestPoint( aRefPos ), OUTLINE, aItem );
543 
544  break;
545  }
546 
547  case PCB_DIMENSION_T:
548  {
549  const DIMENSION* dim = static_cast<const DIMENSION*>( aItem );
550  addAnchor( dim->m_crossBarF, CORNER | SNAPPABLE, aItem );
551  addAnchor( dim->m_crossBarO, CORNER | SNAPPABLE, aItem );
552  addAnchor( dim->m_featureLineGO, CORNER | SNAPPABLE, aItem );
553  addAnchor( dim->m_featureLineDO, CORNER | SNAPPABLE, aItem );
554  break;
555  }
556 
557  case PCB_MODULE_TEXT_T:
558  case PCB_TEXT_T:
559  addAnchor( aItem->GetPosition(), ORIGIN, aItem );
560  break;
561 
562  default:
563  break;
564  }
565 }
566 
567 
569  LSET aMatchLayers )
570 {
571  double minDist = std::numeric_limits<double>::max();
572  ANCHOR* best = NULL;
573 
574  for( ANCHOR& a : m_anchors )
575  {
576  if( ( aMatchLayers & a.item->GetLayerSet() ) == 0 )
577  continue;
578 
579  if( ( aFlags & a.flags ) != aFlags )
580  continue;
581 
582  double dist = a.Distance( aPos );
583 
584  if( dist < minDist )
585  {
586  minDist = dist;
587  best = &a;
588  }
589  }
590 
591  return best;
592 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
OPT< VECTOR2I > m_auxAxis
Definition: grid_helper.h:152
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:284
wxPoint GetArcStart() const
#define KI_FALLTHROUGH
wxPoint GetPosition() const override
ANCHOR * m_snapItem
Definition: grid_helper.h:158
wxPoint GetArcEnd() const
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
wxPoint m_crossBarF
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
wxPoint GetPosition() const override
Definition: class_pad.h:165
const wxPoint & GetStart() const
Definition: class_track.h:118
VIEW_CONTROLS class definition.
STROKE_T GetShape() const
virtual unsigned int ViewGetLOD(int aLayer, VIEW *aView) const
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
Definition: view_item.h:141
TOOL_MANAGER * m_toolMgr
Definition: grid_helper.h:151
polygon (not yet used for tracks, but could be in microwave apps)
KIGFX::ORIGIN_VIEWITEM m_viewAxis
Definition: grid_helper.h:166
VECTOR2I GetOrigin() const
Definition: grid_helper.cpp:93
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
PADS & Pads()
Definition: class_module.h:173
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
CONST_ITERATOR CIterateWithHoles(int aOutline) const
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
usual segment : line with rounded ends
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Function IntersectLines()
Definition: seg.h:191
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, BOARD_ITEM *aDraggedItem)
void SetEndPosition(const VECTOR2D &aPosition)
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
This file contains miscellaneous commonly used macros and functions.
VECTOR2I GetGrid() const
Definition: grid_helper.cpp:85
wxPoint m_featureLineGO
BOARD_ITEM * GetSnapped() const
Function GetSnapped If the GRID_HELPER has highlighted a snap point (target shown),...
KIGFX::ORIGIN_VIEWITEM m_viewSnapPoint
Definition: grid_helper.h:164
TOOL_MANAGER.
Definition: tool_manager.h:51
DIMENSION class definition.
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:89
void SetClosed(bool aClosed)
Function SetClosed()
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
void computeAnchors(BOARD_ITEM *aItem, const VECTOR2I &aRefPos, bool aFrom=false)
computeAnchors inserts the local anchor points in to the grid helper for the specified board item,...
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, std::vector< BOARD_ITEM * > &aItem)
LSET is a set of PCB_LAYER_IDs.
ANCHOR * nearestAnchor(const VECTOR2I &aPos, int aFlags, LSET aMatchLayers)
#define NULL
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:37
double Distance(const VECTOR2I &aP) const
Definition: grid_helper.h:118
GRID_HELPER(TOOL_MANAGER *aToolMgr, MAGNETIC_SETTINGS *aMagneticSettings)
Definition: grid_helper.cpp:48
void SetPosition(const VECTOR2D &aPosition)
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1530
BOARD_ITEM * item
Definition: grid_helper.h:116
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
void SetSize(int aSize)
Arcs (with rounded ends)
const VECTOR2I & GetP0() const
Definition: shape_arc.h:69
void SetDrawAtZero(bool aDrawFlag)
Function SetDrawAtZero() Set the draw at zero flag.
static LSET AllLayersMask()
Definition: lset.cpp:749
bool m_enableSnap
Definition: grid_helper.h:154
Bezier Curve.
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1544
const std::set< unsigned int > GetActiveLayers() const
Function GetActiveLayers() Returns the set of currently active layers.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
bool m_enableSnapLine
Definition: grid_helper.h:156
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:39
const VECTOR2D & GetGridSize() const
Returns the grid size.
VECTOR2I Align(const VECTOR2I &aPoint) const
bool GetHighContrast() const
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
SHAPE_LINE_CHAIN.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:66
VECTOR2I A
Definition: seg.h:47
MAGNETIC_OPTIONS pads
VECTOR2I m_skipPoint
Definition: grid_helper.h:160
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
void SetColor(const KIGFX::COLOR4D &aColor)
std::set< BOARD_ITEM * > queryVisible(const BOX2I &aArea, const std::vector< BOARD_ITEM * > &aSkip) const
const wxPoint & GetEnd() const
Definition: class_track.h:115
boost::optional< T > OPT
Definition: optional.h:7
const VECTOR2D & GetGridOrigin() const
void addAnchor(const VECTOR2I &aPos, int aFlags, BOARD_ITEM *aItem)
Definition: grid_helper.h:129
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1490
MAGNETIC_SETTINGS * m_magneticSettings
Definition: grid_helper.h:162
wxPoint m_crossBarO
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
bool m_enableGrid
Definition: grid_helper.h:155
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:350
wxPoint GetPosition() const override
Definition: class_module.h:216
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Function Query() Finds all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:456
KIGFX::ORIGIN_VIEWITEM m_viewSnapLine
Definition: grid_helper.h:165
VIEW.
Definition: view.h:61
void SetStyle(MARKER_STYLE aStyle)
double GetScale() const
Function GetScale()
Definition: view.h:257
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
double GetWorldScale() const
Get the world scale.
std::vector< ANCHOR > m_anchors
Definition: grid_helper.h:124
wxPoint m_featureLineDO
const VECTOR2I & GetP1() const
Definition: shape_arc.h:70
DIMENSION.
void clearAnchors()
Definition: grid_helper.h:146
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
MAGNETIC_OPTIONS tracks
wxPoint GetCenter() const override
Function GetCenter()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
Color has changed.
Definition: view_item.h:59
bool Contains(const SEG &aSeg) const
Definition: seg.h:299
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
VECTOR2I B
Definition: seg.h:48