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_zone.h>
37 
40 #include <math/util.h> // for KiROUND
41 #include <math/vector2d.h>
42 #include <painter.h>
43 #include <view/view.h>
44 #include <view/view_controls.h>
45 
46 #include "grid_helper.h"
47 
48 
50  m_frame( aFrame )
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_frame->GetCanvas()->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 {
87  PCB_SCREEN* screen = m_frame->GetScreen();
88 
89  const wxRealPoint& size = screen->GetGridSize();
90 
91  return VECTOR2I( KiROUND( size.x ), KiROUND( size.y ) );
92 }
93 
94 
96 {
97  return VECTOR2I( m_frame->GetGridOrigin() );
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_frame->GetCanvas()->GetView()->SetVisible( &m_viewAxis, true );
108  }
109  else
110  {
112  m_frame->GetCanvas()->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::BestDragOrigin( const VECTOR2I &aMousePos, std::vector<BOARD_ITEM*>& aItems )
180 {
181  clearAnchors();
182 
183  for( auto item : aItems )
184  computeAnchors( item, aMousePos, true );
185 
186  double worldScale = m_frame->GetCanvas()->GetGAL()->GetWorldScale();
187  double lineSnapMinCornerDistance = 50.0 / worldScale;
188 
189  ANCHOR* nearestOutline = nearestAnchor( aMousePos, OUTLINE, LSET::AllLayersMask() );
190  ANCHOR* nearestCorner = nearestAnchor( aMousePos, CORNER, LSET::AllLayersMask() );
191  ANCHOR* nearestOrigin = nearestAnchor( aMousePos, ORIGIN, LSET::AllLayersMask() );
192  ANCHOR* best = NULL;
193  double minDist = std::numeric_limits<double>::max();
194 
195  if( nearestOrigin )
196  {
197  minDist = nearestOrigin->Distance( aMousePos );
198  best = nearestOrigin;
199  }
200 
201  if( nearestCorner )
202  {
203  double dist = nearestCorner->Distance( aMousePos );
204 
205  if( dist < minDist )
206  {
207  minDist = dist;
208  best = nearestCorner;
209  }
210  }
211 
212  if( nearestOutline )
213  {
214  double dist = nearestOutline->Distance( aMousePos );
215 
216  if( minDist > lineSnapMinCornerDistance && dist < minDist )
217  best = nearestOutline;
218  }
219 
220  return best ? best->pos : aMousePos;
221 }
222 
223 
224 std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea,
225  const std::vector<BOARD_ITEM*>& aSkip ) const
226 {
227  std::set<BOARD_ITEM*> items;
228  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
229 
230  auto view = m_frame->GetCanvas()->GetView();
231  auto activeLayers = view->GetPainter()->GetSettings()->GetActiveLayers();
232  bool isHighContrast = view->GetPainter()->GetSettings()->GetHighContrast();
233  view->Query( aArea, selectedItems );
234 
235  for( auto it : selectedItems )
236  {
237  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
238 
239  // The item must be visible and on an active layer
240  if( view->IsVisible( item ) && ( !isHighContrast || activeLayers.count( it.second ) )
241  && item->ViewGetLOD( it.second, view ) < view->GetScale() )
242  items.insert ( item );
243  }
244 
245 
246  for( auto ii : aSkip )
247  items.erase( ii );
248 
249  return items;
250 }
251 
252 
253 VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem )
254 {
255  LSET layers;
256  std::vector<BOARD_ITEM*> item;
257 
258  if( aDraggedItem )
259  {
260  layers = aDraggedItem->GetLayerSet();
261  item.push_back( aDraggedItem );
262  }
263  else
264  layers = LSET::AllLayersMask();
265 
266  return BestSnapAnchor( aOrigin, layers, item );
267 }
268 
269 
270 VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
271  const std::vector<BOARD_ITEM*>& aSkip )
272 {
273  double worldScale = m_frame->GetCanvas()->GetGAL()->GetWorldScale();
274  int snapRange = (int) ( m_snapSize / worldScale );
275 
276  BOX2I bb( VECTOR2I( aOrigin.x - snapRange / 2, aOrigin.y - snapRange / 2 ), VECTOR2I( snapRange, snapRange ) );
277 
278  clearAnchors();
279 
280  for( BOARD_ITEM* item : queryVisible( bb, aSkip ) )
281  computeAnchors( item, aOrigin );
282 
283  ANCHOR* nearest = nearestAnchor( aOrigin, SNAPPABLE, aLayers );
284  VECTOR2I nearestGrid = Align( aOrigin );
285  double gridDist = ( nearestGrid - aOrigin ).EuclideanNorm();
286 
287  if( nearest && m_enableSnap )
288  {
289  double snapDist = nearest->Distance( aOrigin );
290 
291  if( !m_enableGrid || snapDist <= gridDist )
292  {
293  m_viewSnapPoint.SetPosition( nearest->pos );
294  m_viewSnapLine.SetPosition( nearest->pos );
296 
299  else
301 
302  m_snapItem = nearest;
303  return nearest->pos;
304  }
305  }
306 
308  {
309  bool snapLine = false;
310 
311  if( std::abs( m_viewSnapLine.GetPosition().x - aOrigin.x ) < GetGrid().x )
312  {
313  nearestGrid.x = m_viewSnapLine.GetPosition().x;
314  snapLine = true;
315  }
316 
317  if( std::abs( m_viewSnapLine.GetPosition().y - aOrigin.y ) < GetGrid().y )
318  {
319  nearestGrid.y = m_viewSnapLine.GetPosition().y;
320  snapLine = true;
321  }
322 
323  if( snapLine && m_skipPoint != VECTOR2I( m_viewSnapLine.GetPosition() ) )
324  {
325  m_viewSnapLine.SetEndPosition( nearestGrid );
327 
330  else
332 
333  return nearestGrid;
334  }
335  }
336 
337  m_snapItem = nullptr;
340  return nearestGrid;
341 }
342 
343 
345 {
346  if( !m_snapItem )
347  return nullptr;
348 
349  return m_snapItem->item;
350 }
351 
352 
353 void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom )
354 {
355  VECTOR2I origin;
356  auto view = m_frame->GetCanvas()->GetView();
357  auto activeLayers = view->GetPainter()->GetSettings()->GetActiveLayers();
358  bool isHighContrast = view->GetPainter()->GetSettings()->GetHighContrast();
359 
360  switch( aItem->Type() )
361  {
362  case PCB_MODULE_T:
363  {
364  MODULE* mod = static_cast<MODULE*>( aItem );
365 
366  for( auto pad : mod->Pads() )
367  {
368  // Getting pads from the module requires re-checking that the pad is shown
369  if( ( aFrom || m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS )
370  && pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) )
371  && view->IsVisible( pad )
372  && ( !isHighContrast || activeLayers.count( pad->GetLayer() ) )
373  && pad->ViewGetLOD( pad->GetLayer(), view ) < view->GetScale() )
374  {
375  addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
376  break;
377  }
378  }
379 
380  // if the cursor is not over a pad, then drag the module by its origin
381  addAnchor( mod->GetPosition(), ORIGIN | SNAPPABLE, mod );
382  break;
383  }
384 
385  case PCB_PAD_T:
386  {
387  if( aFrom || m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS )
388  {
389  D_PAD* pad = static_cast<D_PAD*>( aItem );
390  addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
391  }
392 
393  break;
394  }
395 
396  case PCB_MODULE_EDGE_T:
397  case PCB_LINE_T:
398  {
400  break;
401 
402  DRAWSEGMENT* dseg = static_cast<DRAWSEGMENT*>( aItem );
403  VECTOR2I start = dseg->GetStart();
404  VECTOR2I end = dseg->GetEnd();
405 
406  switch( dseg->GetShape() )
407  {
408  case S_CIRCLE:
409  {
410  int r = ( start - end ).EuclideanNorm();
411 
412  addAnchor( start, ORIGIN | SNAPPABLE, dseg );
413  addAnchor( start + VECTOR2I( -r, 0 ), OUTLINE | SNAPPABLE, dseg );
414  addAnchor( start + VECTOR2I( r, 0 ), OUTLINE | SNAPPABLE, dseg );
415  addAnchor( start + VECTOR2I( 0, -r ), OUTLINE | SNAPPABLE, dseg );
416  addAnchor( start + VECTOR2I( 0, r ), OUTLINE | SNAPPABLE, dseg );
417  break;
418  }
419 
420  case S_ARC:
421  origin = dseg->GetCenter();
422  addAnchor( dseg->GetArcStart(), CORNER | SNAPPABLE, dseg );
423  addAnchor( dseg->GetArcEnd(), CORNER | SNAPPABLE, dseg );
424  addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
425  break;
426 
427  case S_RECT:
428  addAnchor( start, CORNER | SNAPPABLE, dseg );
429  addAnchor( VECTOR2I( end.x, start.y ), CORNER | SNAPPABLE, dseg );
430  addAnchor( VECTOR2I( start.x, end.y ), CORNER | SNAPPABLE, dseg );
431  addAnchor( end, CORNER | SNAPPABLE, dseg );
432  break;
433 
434  case S_SEGMENT:
435  origin.x = start.x + ( start.x - end.x ) / 2;
436  origin.y = start.y + ( start.y - end.y ) / 2;
437  addAnchor( start, CORNER | SNAPPABLE, dseg );
438  addAnchor( end, CORNER | SNAPPABLE, dseg );
439  addAnchor( origin, ORIGIN, dseg );
440  break;
441 
442  case S_POLYGON:
443  for( const auto& p : dseg->BuildPolyPointsList() )
444  addAnchor( p, CORNER | SNAPPABLE, dseg );
445 
446  break;
447 
448  case S_CURVE:
449  addAnchor( start, CORNER | SNAPPABLE, dseg );
450  addAnchor( end, CORNER | SNAPPABLE, dseg );
451  //Fallthrough
452  default:
453  origin = dseg->GetStart();
454  addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
455  break;
456  }
457  break;
458  }
459 
460  case PCB_TRACE_T:
461  {
462  if( aFrom || m_frame->Settings().m_MagneticTracks == CAPTURE_ALWAYS )
463  {
464  TRACK* track = static_cast<TRACK*>( aItem );
465  VECTOR2I start = track->GetStart();
466  VECTOR2I end = track->GetEnd();
467  origin.x = start.x + ( start.x - end.x ) / 2;
468  origin.y = start.y + ( start.y - end.y ) / 2;
469  addAnchor( start, CORNER | SNAPPABLE, track );
470  addAnchor( end, CORNER | SNAPPABLE, track );
471  addAnchor( origin, ORIGIN, track);
472  }
473 
474  break;
475  }
476 
477  case PCB_MARKER_T:
478  case PCB_TARGET_T:
479  addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
480  break;
481 
482  case PCB_VIA_T:
483  {
484  if( aFrom || m_frame->Settings().m_MagneticTracks == CAPTURE_ALWAYS )
485  addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
486 
487  break;
488  }
489 
490  case PCB_ZONE_AREA_T:
491  {
492  const SHAPE_POLY_SET* outline = static_cast<const ZONE_CONTAINER*>( aItem )->Outline();
493 
494  SHAPE_LINE_CHAIN lc;
495  lc.SetClosed( true );
496 
497  for( auto iter = outline->CIterateWithHoles(); iter; iter++ )
498  {
499  addAnchor( *iter, CORNER, aItem );
500  lc.Append( *iter );
501  }
502 
503  addAnchor( lc.NearestPoint( aRefPos ), OUTLINE, aItem );
504 
505  break;
506  }
507 
508  case PCB_DIMENSION_T:
509  {
510  const DIMENSION* dim = static_cast<const DIMENSION*>( aItem );
511  addAnchor( dim->m_crossBarF, CORNER | SNAPPABLE, aItem );
512  addAnchor( dim->m_crossBarO, CORNER | SNAPPABLE, aItem );
513  addAnchor( dim->m_featureLineGO, CORNER | SNAPPABLE, aItem );
514  addAnchor( dim->m_featureLineDO, CORNER | SNAPPABLE, aItem );
515  break;
516  }
517 
518  case PCB_MODULE_TEXT_T:
519  case PCB_TEXT_T:
520  addAnchor( aItem->GetPosition(), ORIGIN, aItem );
521  break;
522 
523  default:
524  break;
525  }
526 }
527 
528 
529 GRID_HELPER::ANCHOR* GRID_HELPER::nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers )
530 {
531  double minDist = std::numeric_limits<double>::max();
532  ANCHOR* best = NULL;
533 
534  for( ANCHOR& a : m_anchors )
535  {
536  if( ( aMatchLayers & a.item->GetLayerSet() ) == 0 )
537  continue;
538 
539  if( ( aFlags & a.flags ) != aFlags )
540  continue;
541 
542  double dist = a.Distance( aPos );
543 
544  if( dist < minDist )
545  {
546  minDist = dist;
547  best = &a;
548  }
549  }
550 
551  return best;
552 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:123
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:279
OPT< VECTOR2I > m_auxAxis
Definition: grid_helper.h:149
ANCHOR * m_snapItem
Pointer to the currently snapped item in m_anchors (NULL if not snapped)
Definition: grid_helper.h:155
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:109
VIEW_CONTROLS class definition.
STROKE_T GetShape() const
GRID_HELPER(PCB_BASE_FRAME *aFrame)
Definition: grid_helper.cpp:49
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:160
VECTOR2I GetOrigin() const
Definition: grid_helper.cpp:95
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:101
PADS & Pads()
Definition: class_module.h:173
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
MAGNETIC_OPTIONS m_MagneticTracks
CONST_ITERATOR CIterateWithHoles(int aOutline) const
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
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:186
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, BOARD_ITEM *aDraggedItem)
void SetEndPosition(const VECTOR2D &aPosition)
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
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()
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:158
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)
MAGNETIC_OPTIONS m_MagneticPads
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:115
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:113
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
PCB_GENERAL_SETTINGS & Settings()
void SetSize(int aSize)
Arcs (with rounded ends)
void SetDrawAtZero(bool aDrawFlag)
Function SetDrawAtZero() Set the draw at zero flag.
bool Contains(const VECTOR2I &aP) const
Definition: seg.cpp:200
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
static LSET AllLayersMask()
Definition: lset.cpp:723
const wxPoint & GetArcStart() const
bool m_enableSnap
If true, allow snapping to other items on the layers.
Definition: grid_helper.h:151
Bezier Curve.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:99
bool m_enableSnapLine
If true, allow drawing lines from snap points.
Definition: grid_helper.h:153
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:100
virtual const wxPoint GetPosition() const =0
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 GetSettings 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:98
SHAPE_LINE_CHAIN.
PCB_BASE_FRAME * m_frame
Definition: grid_helper.h:148
VECTOR2I A
Definition: seg.h:47
int m_snapSize
Sets the radius in screen units for snapping to items.
Definition: grid_helper.h:154
VECTOR2I m_skipPoint
When drawing a line, we avoid snapping to the source point.
Definition: grid_helper.h:156
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:106
boost::optional< T > OPT
Definition: optional.h:7
void addAnchor(const VECTOR2I &aPos, int aFlags, BOARD_ITEM *aItem)
Definition: grid_helper.h:126
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:152
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
Module description (excepted pads)
KIGFX::ORIGIN_VIEWITEM m_viewSnapLine
Definition: grid_helper.h:159
VIEW.
Definition: view.h:61
void SetStyle(MARKER_STYLE aStyle)
const wxPoint GetPosition() const override
Definition: class_pad.h:241
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:121
wxPoint m_featureLineDO
const wxPoint GetPosition() const override
Definition: class_module.h:210
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
DIMENSION.
void clearAnchors()
Definition: grid_helper.h:143
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
Color has changed.
Definition: view_item.h:57
const std::set< unsigned int > GetActiveLayers()
Function GetActiveLayers() Returns the set of currently active layers.
Definition: painter.h:89
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
VECTOR2I B
Definition: seg.h:48