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 <pcb_edit_frame.h>
30 
31 #include <class_board.h>
32 #include <class_dimension.h>
33 #include <class_draw_panel_gal.h>
34 #include <class_edge_mod.h>
35 #include <class_module.h>
36 #include <class_track.h>
37 #include <class_zone.h>
38 
41 #include <macros.h>
42 #include <math/util.h> // for KiROUND
43 #include <math/vector2d.h>
44 #include <painter.h>
45 #include <pcbnew_settings.h>
46 #include <view/view.h>
47 #include <view/view_controls.h>
48 
49 #include "grid_helper.h"
50 
51 
53  m_frame( aFrame )
54 {
55  m_enableSnap = true;
56  m_enableGrid = true;
57  m_enableSnapLine = true;
58  m_snapSize = 100;
59  m_snapItem = nullptr;
60  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
61 
62  m_viewAxis.SetSize( 20000 );
64  m_viewAxis.SetColor( COLOR4D( 1.0, 1.0, 1.0, 0.4 ) );
65  m_viewAxis.SetDrawAtZero( true );
66  view->Add( &m_viewAxis );
67  view->SetVisible( &m_viewAxis, false );
68 
70  m_viewSnapPoint.SetColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
72  view->Add( &m_viewSnapPoint );
73  view->SetVisible( &m_viewSnapPoint, false );
74 
76  m_viewSnapLine.SetColor( COLOR4D( 0.33, 0.55, 0.95, 1.0 ) );
78  view->Add( &m_viewSnapLine );
79  view->SetVisible( &m_viewSnapLine, false );
80 }
81 
82 
84 {
85 }
86 
87 
89 {
90  PCB_SCREEN* screen = m_frame->GetScreen();
91 
92  const wxRealPoint& size = screen->GetGridSize();
93 
94  return VECTOR2I( KiROUND( size.x ), KiROUND( size.y ) );
95 }
96 
97 
99 {
100  return VECTOR2I( m_frame->GetGridOrigin() );
101 }
102 
103 
104 void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin )
105 {
106  if( aEnable )
107  {
108  m_auxAxis = aOrigin;
109  m_viewAxis.SetPosition( aOrigin );
110  m_frame->GetCanvas()->GetView()->SetVisible( &m_viewAxis, true );
111  }
112  else
113  {
115  m_frame->GetCanvas()->GetView()->SetVisible( &m_viewAxis, false );
116  }
117 }
118 
119 
120 VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint ) const
121 {
122  if( !m_enableGrid )
123  return aPoint;
124 
125  const VECTOR2D gridOffset( GetOrigin() );
126  const VECTOR2D grid( GetGrid() );
127 
128  VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / grid.x ) * grid.x + gridOffset.x,
129  KiROUND( ( aPoint.y - gridOffset.y ) / grid.y ) * grid.y + gridOffset.y );
130 
131  if( !m_auxAxis )
132  return nearest;
133 
134  if( std::abs( m_auxAxis->x - aPoint.x ) < std::abs( nearest.x - aPoint.x ) )
135  nearest.x = m_auxAxis->x;
136 
137  if( std::abs( m_auxAxis->y - aPoint.y ) < std::abs( nearest.y - aPoint.y ) )
138  nearest.y = m_auxAxis->y;
139 
140  return nearest;
141 }
142 
143 
144 VECTOR2I GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSeg )
145 {
146  OPT_VECTOR2I pts[6];
147 
148  if( !m_enableSnap )
149  return aPoint;
150 
151  const VECTOR2D gridOffset( GetOrigin() );
152  const VECTOR2D gridSize( GetGrid() );
153 
154  VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
155  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
156 
157  pts[0] = aSeg.A;
158  pts[1] = aSeg.B;
159  pts[2] = aSeg.IntersectLines( SEG( nearest + VECTOR2I( -1, 1 ), nearest + VECTOR2I( 1, -1 ) ) );
160  pts[3] = aSeg.IntersectLines( SEG( nearest + VECTOR2I( -1, -1 ), nearest + VECTOR2I( 1, 1 ) ) );
161 
162  int min_d = std::numeric_limits<int>::max();
163 
164  for( int i = 0; i < 4; i++ )
165  {
166  if( pts[i] && aSeg.Contains( *pts[i] ) )
167  {
168  int d = (*pts[i] - aPoint).EuclideanNorm();
169 
170  if( d < min_d )
171  {
172  min_d = d;
173  nearest = *pts[i];
174  }
175  }
176  }
177 
178  return nearest;
179 }
180 
181 
182 VECTOR2I GRID_HELPER::AlignToArc( const VECTOR2I& aPoint, const SHAPE_ARC& aArc )
183 {
184  OPT_VECTOR2I pts[6];
185 
186  if( !m_enableSnap )
187  return aPoint;
188 
189  const VECTOR2D gridOffset( GetOrigin() );
190  const VECTOR2D gridSize( GetGrid() );
191 
192  VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
193  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
194 
195  auto line = aArc.ConvertToPolyline();
196  int min_d = std::numeric_limits<int>::max();
197 
198  for( auto pt : line.CPoints() )
199  {
200  int d = ( pt - aPoint ).EuclideanNorm();
201 
202  if( d < min_d )
203  {
204  min_d = d;
205  nearest = pt;
206  }
207  else
208  break;
209  }
210 
211  return nearest;
212 }
213 
214 
215 VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, std::vector<BOARD_ITEM*>& aItems )
216 {
217  clearAnchors();
218 
219  for( auto item : aItems )
220  computeAnchors( item, aMousePos, true );
221 
222  double worldScale = m_frame->GetCanvas()->GetGAL()->GetWorldScale();
223  double lineSnapMinCornerDistance = 50.0 / worldScale;
224 
225  ANCHOR* nearestOutline = nearestAnchor( aMousePos, OUTLINE, LSET::AllLayersMask() );
226  ANCHOR* nearestCorner = nearestAnchor( aMousePos, CORNER, LSET::AllLayersMask() );
227  ANCHOR* nearestOrigin = nearestAnchor( aMousePos, ORIGIN, LSET::AllLayersMask() );
228  ANCHOR* best = NULL;
229  double minDist = std::numeric_limits<double>::max();
230 
231  if( nearestOrigin )
232  {
233  minDist = nearestOrigin->Distance( aMousePos );
234  best = nearestOrigin;
235  }
236 
237  if( nearestCorner )
238  {
239  double dist = nearestCorner->Distance( aMousePos );
240 
241  if( dist < minDist )
242  {
243  minDist = dist;
244  best = nearestCorner;
245  }
246  }
247 
248  if( nearestOutline )
249  {
250  double dist = nearestOutline->Distance( aMousePos );
251 
252  if( minDist > lineSnapMinCornerDistance && dist < minDist )
253  best = nearestOutline;
254  }
255 
256  return best ? best->pos : aMousePos;
257 }
258 
259 
260 std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea,
261  const std::vector<BOARD_ITEM*>& aSkip ) const
262 {
263  std::set<BOARD_ITEM*> items;
264  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
265 
266  auto view = m_frame->GetCanvas()->GetView();
267  auto activeLayers = view->GetPainter()->GetSettings()->GetActiveLayers();
268  bool isHighContrast = view->GetPainter()->GetSettings()->GetHighContrast();
269  view->Query( aArea, selectedItems );
270 
271  for( auto it : selectedItems )
272  {
273  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
274 
275  // The item must be visible and on an active layer
276  if( view->IsVisible( item ) && ( !isHighContrast || activeLayers.count( it.second ) )
277  && item->ViewGetLOD( it.second, view ) < view->GetScale() )
278  items.insert ( item );
279  }
280 
281 
282  for( auto ii : aSkip )
283  items.erase( ii );
284 
285  return items;
286 }
287 
288 
289 VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem )
290 {
291  LSET layers;
292  std::vector<BOARD_ITEM*> item;
293 
294  if( aDraggedItem )
295  {
296  layers = aDraggedItem->GetLayerSet();
297  item.push_back( aDraggedItem );
298  }
299  else
300  layers = LSET::AllLayersMask();
301 
302  return BestSnapAnchor( aOrigin, layers, item );
303 }
304 
305 
306 VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
307  const std::vector<BOARD_ITEM*>& aSkip )
308 {
309  double worldScale = m_frame->GetCanvas()->GetGAL()->GetWorldScale();
310  int snapRange = (int) ( m_snapSize / worldScale );
311 
312  BOX2I bb( VECTOR2I( aOrigin.x - snapRange / 2, aOrigin.y - snapRange / 2 ), 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  auto view = m_frame->GetCanvas()->GetView();
393  auto activeLayers = view->GetPainter()->GetSettings()->GetActiveLayers();
394  bool isHighContrast = view->GetPainter()->GetSettings()->GetHighContrast();
395 
396  switch( aItem->Type() )
397  {
398  case PCB_MODULE_T:
399  {
400  MODULE* mod = static_cast<MODULE*>( aItem );
401 
402  for( auto pad : mod->Pads() )
403  {
404  // Getting pads from the module requires re-checking that the pad is shown
405  if( ( aFrom ||
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 auto& 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 
568 GRID_HELPER::ANCHOR* GRID_HELPER::nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers )
569 {
570  double minDist = std::numeric_limits<double>::max();
571  ANCHOR* best = NULL;
572 
573  for( ANCHOR& a : m_anchors )
574  {
575  if( ( aMatchLayers & a.item->GetLayerSet() ) == 0 )
576  continue;
577 
578  if( ( aFlags & a.flags ) != aFlags )
579  continue;
580 
581  double dist = a.Distance( aPos );
582 
583  if( dist < minDist )
584  {
585  minDist = dist;
586  best = &a;
587  }
588  }
589 
590  return best;
591 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:284
OPT< VECTOR2I > m_auxAxis
Definition: grid_helper.h:153
#define KI_FALLTHROUGH
ANCHOR * m_snapItem
Pointer to the currently snapped item in m_anchors (NULL if not snapped)
Definition: grid_helper.h:159
static const int dist[10][10]
Definition: ar_matrix.cpp:326
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
wxPoint m_crossBarF
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
const wxPoint GetCenter() const override
Function GetCenter()
const wxPoint & GetStart() const
Definition: class_track.h:118
VIEW_CONTROLS class definition.
STROKE_T GetShape() const
GRID_HELPER(PCB_BASE_FRAME *aFrame)
Definition: grid_helper.cpp:52
const wxPoint GetArcEnd() 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:140
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
polygon (not yet used for tracks, but could be in microwave apps)
KIGFX::ORIGIN_VIEWITEM m_viewAxis
Definition: grid_helper.h:164
VECTOR2I GetOrigin() const
Definition: grid_helper.cpp:98
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
PADS & Pads()
Definition: class_module.h:169
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
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 MAGNETIC_SETTINGS * GetMagneticItemsSettings()
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.
virtual const wxPoint GetPosition() const
Definition: base_struct.h:344
VECTOR2I GetGrid() const
Definition: grid_helper.cpp:88
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:162
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:119
void SetPosition(const VECTOR2D &aPosition)
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1526
BOARD_ITEM * item
Definition: grid_helper.h:117
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)
void SetDrawAtZero(bool aDrawFlag)
Function SetDrawAtZero() Set the draw at zero flag.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
static LSET AllLayersMask()
Definition: lset.cpp:749
const wxPoint & GetArcStart() const
bool m_enableSnap
If true, allow snapping to other items on the layers.
Definition: grid_helper.h:155
Bezier Curve.
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
bool m_enableSnapLine
If true, allow drawing lines from snap points.
Definition: grid_helper.h:157
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
const wxPoint GetPosition() const override
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
VECTOR2I Align(const VECTOR2I &aPoint) 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.
PCB_BASE_FRAME * m_frame
Definition: grid_helper.h:152
VECTOR2I A
Definition: seg.h:47
int m_snapSize
Sets the radius in screen units for snapping to items.
Definition: grid_helper.h:158
MAGNETIC_OPTIONS pads
VECTOR2I m_skipPoint
When drawing a line, we avoid snapping to the source point.
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:61
void SetColor(const KIGFX::COLOR4D &aColor)
std::set< BOARD_ITEM * > queryVisible(const BOX2I &aArea, const std::vector< BOARD_ITEM * > &aSkip) const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const wxPoint & GetEnd() const
Definition: class_track.h:115
boost::optional< T > OPT
Definition: optional.h:7
void addAnchor(const VECTOR2I &aPos, int aFlags, BOARD_ITEM *aItem)
Definition: grid_helper.h:130
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1486
wxPoint m_crossBarO
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
bool m_enableGrid
If true, allow snapping to grid.
Definition: grid_helper.h:156
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:346
KIGFX::ORIGIN_VIEWITEM m_viewSnapLine
Definition: grid_helper.h:163
VIEW.
Definition: view.h:61
void SetStyle(MARKER_STYLE aStyle)
const wxPoint GetPosition() const override
Definition: class_pad.h:226
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:125
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=500.0) const
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:274
wxPoint m_featureLineDO
const wxPoint GetPosition() const override
Definition: class_module.h:206
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
DIMENSION.
void clearAnchors()
Definition: grid_helper.h:147
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
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
Color has changed.
Definition: view_item.h:57
const std::set< unsigned int > GetActiveLayers()
Function GetActiveLayers() Returns the set of currently active layers.
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:40
VECTOR2I B
Definition: seg.h:48