KiCad PCB EDA Suite
point_editor.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) 2013-2019 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <functional>
26 using namespace std::placeholders;
27 
28 #include <tool/tool_manager.h>
29 #include <view/view_controls.h>
31 #include <geometry/seg.h>
32 #include <confirm.h>
33 
34 #include "pcb_actions.h"
35 #include "selection_tool.h"
36 #include "point_editor.h"
37 #include "grid_helper.h"
38 #include <board_commit.h>
39 #include <bitmaps.h>
40 #include <status_popup.h>
41 
42 #include <pcb_edit_frame.h>
43 #include <class_edge_mod.h>
44 #include <class_dimension.h>
45 #include <class_zone.h>
46 #include <class_board.h>
47 #include <class_module.h>
50 
51 #include "zone_filler.h"
52 
53 // Point editor
54 TOOL_ACTION PCB_ACTIONS::pointEditorAddCorner( "pcbnew.PointEditor.addCorner",
55  AS_GLOBAL, WXK_INSERT,
56  _( "Create Corner" ), _( "Create a corner" ), add_corner_xpm );
57 
58 TOOL_ACTION PCB_ACTIONS::pointEditorRemoveCorner( "pcbnew.PointEditor.removeCorner",
59  AS_GLOBAL, 0,
60  _( "Remove Corner" ), _( "Remove corner" ), delete_xpm );
61 
62 
63 // Few constants to avoid using bare numbers for point indices
65 {
67 };
68 
70 {
72 };
73 
75 {
77 };
78 
80 {
85 };
86 
88 {
93 };
94 
96 {
97 private:
98 
99  static void buildForPolyOutline( std::shared_ptr<EDIT_POINTS> points,
100  const SHAPE_POLY_SET* aOutline, KIGFX::GAL* aGal )
101  {
102 
103  int cornersCount = aOutline->TotalVertices();
104 
105  for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
106  {
107  points->AddPoint( *iterator );
108 
109  if( iterator.IsEndContour() )
110  points->AddBreak();
111  }
112 
113  // Lines have to be added after creating edit points,
114  // as they use EDIT_POINT references
115  for( int i = 0; i < cornersCount - 1; ++i )
116  {
117  if( points->IsContourEnd( i ) )
118  {
119  points->AddLine( points->Point( i ),
120  points->Point( points->GetContourStartIdx( i ) ) );
121  }
122  else
123  {
124  points->AddLine( points->Point( i ), points->Point( i + 1 ) );
125  }
126 
127  points->Line( i ).SetConstraint( new EC_SNAPLINE( points->Line( i ),
128  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
129  }
130 
131  // The last missing line, connecting the last and the first polygon point
132  points->AddLine( points->Point( cornersCount - 1 ),
133  points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
134 
135  points->Line( points->LinesSize() - 1 ).SetConstraint(
136  new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
137  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
138  }
139 
140 public:
141  static std::shared_ptr<EDIT_POINTS> Make( EDA_ITEM* aItem, KIGFX::GAL* aGal )
142  {
143  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
144 
145  if( !aItem )
146  return points;
147 
148  // Generate list of edit points basing on the item type
149  switch( aItem->Type() )
150  {
151  case PCB_LINE_T:
152  case PCB_MODULE_EDGE_T:
153  {
154  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( aItem );
155 
156  switch( segment->GetShape() )
157  {
158  case S_SEGMENT:
159  points->AddPoint( segment->GetStart() );
160  points->AddPoint( segment->GetEnd() );
161  break;
162 
163  case S_ARC:
164  points->AddPoint( segment->GetCenter() );
165  points->AddPoint( segment->GetArcStart() );
166  points->AddPoint( segment->GetArcEnd() );
167 
168  // Set constraints
169  // Arc end has to stay at the same radius as the start
170  points->Point( ARC_END ).SetConstraint( new EC_CIRCLE( points->Point( ARC_END ),
171  points->Point( ARC_CENTER ),
172  points->Point( ARC_START ) ) );
173  break;
174 
175  case S_CIRCLE:
176  points->AddPoint( segment->GetCenter() );
177  points->AddPoint( segment->GetEnd() );
178 
179  break;
180 
181  case S_POLYGON:
182  buildForPolyOutline( points, &segment->GetPolyShape(), aGal );
183  break;
184 
185  case S_CURVE:
186  points->AddPoint( segment->GetStart() );
187  points->AddPoint( segment->GetBezControl1() );
188  points->AddPoint( segment->GetBezControl2() );
189  points->AddPoint( segment->GetEnd() );
190  break;
191 
192  default: // suppress warnings
193  break;
194  }
195 
196  break;
197  }
198 
199  case PCB_ZONE_AREA_T:
200  {
201  auto zone = static_cast<const ZONE_CONTAINER*>( aItem );
202  buildForPolyOutline( points, zone->Outline(), aGal );
203  break;
204  }
205 
206  case PCB_DIMENSION_T:
207  {
208  const DIMENSION* dimension = static_cast<const DIMENSION*>( aItem );
209 
210  points->AddPoint( dimension->m_crossBarO );
211  points->AddPoint( dimension->m_crossBarF );
212  points->AddPoint( dimension->m_featureLineGO );
213  points->AddPoint( dimension->m_featureLineDO );
214 
215  // Dimension height setting - edit points should move only along the feature lines
216  points->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARO ),
217  points->Point( DIM_FEATUREGO ) ) );
218  points->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARF ),
219  points->Point( DIM_FEATUREDO ) ) );
220 
221  break;
222  }
223 
224  default:
225  points.reset();
226  break;
227  }
228 
229  return points;
230  }
231 
232 private:
234 };
235 
236 
238  PCB_TOOL( "pcbnew.PointEditor" ), m_selectionTool( NULL ), m_editedPoint( NULL ),
239  m_original( VECTOR2I( 0, 0 ) ), m_altConstrainer( VECTOR2I( 0, 0 ) ), m_refill( false )
240 {
241 }
242 
243 
245 {
246  m_refill = false;
247  m_editPoints.reset();
248  m_altConstraint.reset();
249  getViewControls()->SetAutoPan( false );
250 
251  m_statusPopup.reset( new STATUS_TEXT_POPUP( getEditFrame<PCB_BASE_EDIT_FRAME>() ) );
252  m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
253  m_statusPopup->SetText( _( "Self-intersecting polygons are not allowed" ) );
254 }
255 
256 
258 {
259  // Find the selection tool, so they can cooperate
260  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
261 
262  if( !m_selectionTool )
263  {
264  DisplayError( NULL, _( "pcbnew.InteractiveSelection tool is not available" ) );
265  return false;
266  }
267 
268  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
271  std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
272 
273  return true;
274 }
275 
276 
278 {
279  EDIT_POINT* point = m_editedPoint;
280 
281  if( aEvent.IsMotion() )
282  {
283  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
284  }
285  else if( aEvent.IsDrag( BUT_LEFT ) )
286  {
287  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
288  }
289 
290  if( m_editedPoint != point )
291  setEditedPoint( point );
292 }
293 
294 
296 {
297  if( !m_selectionTool )
298  return 0;
299 
301 
302  if( selection.Size() != 1 )
303  return 0;
304 
305  Activate();
306 
308  KIGFX::VIEW* view = getView();
309  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
310 
311  controls->ShowCursor( true );
312 
313  GRID_HELPER grid( editFrame );
314  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
315 
316  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
317 
318  if( !m_editPoints )
319  return 0;
320 
321  view->Add( m_editPoints.get() );
322  setEditedPoint( nullptr );
323  m_refill = false;
324  bool modified = false;
325  bool revert = false;
326 
327  BOARD_COMMIT commit( editFrame );
328  LSET snapLayers = item->GetLayerSet();
329 
330  if( item->Type() == PCB_DIMENSION_T )
331  snapLayers = LSET::AllLayersMask();
332 
333  // Main loop: keep receiving events
334  while( OPT_TOOL_EVENT evt = Wait() )
335  {
336  if( revert )
337  break;
338 
339  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
340  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
341  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
342 
343  if( !m_editPoints ||
344  evt->Matches( m_selectionTool->ClearedEvent ) ||
345  evt->Matches( m_selectionTool->UnselectedEvent ) ||
346  evt->Matches( m_selectionTool->SelectedEvent ) )
347  {
348  break;
349  }
350 
351  if ( !modified )
352  updateEditedPoint( *evt );
353 
354  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
355  {
356  if( !modified )
357  {
358  commit.StageItems( selection, CHT_MODIFY );
359 
360  controls->ForceCursorPosition( false );
361  m_original = *m_editedPoint; // Save the original position
362  controls->SetAutoPan( true );
363  modified = true;
364  grid.SetAuxAxes( true, m_original.GetPosition(), true );
365  }
366 
367  //TODO: unify the constraints to solve simultaneously instead of sequentially
368  m_editedPoint->SetPosition( grid.BestSnapAnchor( evt->Position(),
369  snapLayers, { item } ) );
370  bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
371 
372  if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
373  setAltConstraint( enableAltConstraint );
374 
375  if( m_altConstraint )
376  m_altConstraint->Apply();
377  else
379 
381  snapLayers, { item } ) );
382 
383  updateItem();
384  updatePoints();
385  }
386 
387  else if( evt->IsMouseUp( BUT_LEFT ) )
388  {
389  controls->SetAutoPan( false );
390  setAltConstraint( false );
391 
392  if( modified )
393  {
394  commit.Push( _( "Drag a corner" ) );
395  modified = false;
396  m_refill = true;
397  }
398 
399  m_toolMgr->PassEvent();
400  }
401 
402  else if( evt->IsCancel() )
403  {
404  if( modified ) // Restore the last change
405  revert = true;
406 
407  // Let the selection tool receive the event too
408  m_toolMgr->PassEvent();
409 
410  // Do not exit right now, let the selection clear the selection
411  //break;
412  }
413 
414  else
415  {
416  m_toolMgr->PassEvent();
417  }
418  }
419 
420  if( m_editPoints )
421  {
422  view->Remove( m_editPoints.get() );
423 
424  if( modified && revert )
425  commit.Revert();
426 
427  finishItem();
428  m_editPoints.reset();
429  }
430 
431  frame()->UpdateMsgPanel();
432 
433  return 0;
434 }
435 
436 
438 {
439  EDA_ITEM* item = m_editPoints->GetParent();
440 
441  if( !item )
442  return;
443 
444  switch( item->Type() )
445  {
446  case PCB_LINE_T:
447  case PCB_MODULE_EDGE_T:
448  {
449  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
450  switch( segment->GetShape() )
451  {
452  case S_SEGMENT:
453  if( isModified( m_editPoints->Point( SEG_START ) ) )
454  segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
455  m_editPoints->Point( SEG_START ).GetPosition().y ) );
456 
457  else if( isModified( m_editPoints->Point( SEG_END ) ) )
458  segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
459  m_editPoints->Point( SEG_END ).GetPosition().y ) );
460 
461  break;
462 
463  case S_ARC:
464  {
465  const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
466  const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
467  const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
468 
469  if( center != segment->GetCenter() )
470  {
471  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
472  segment->Move( moveVector );
473 
474  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
475  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
476  }
477 
478  else
479  {
480  segment->SetArcStart( wxPoint( start.x, start.y ) );
481 
482  VECTOR2D startLine = start - center;
483  VECTOR2I endLine = end - center;
484  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
485 
486  // Adjust the new angle to (counter)clockwise setting
487  bool clockwise = ( segment->GetAngle() > 0 );
488 
489  if( clockwise && newAngle < 0.0 )
490  newAngle += 3600.0;
491  else if( !clockwise && newAngle > 0.0 )
492  newAngle -= 3600.0;
493 
494  segment->SetAngle( newAngle );
495  }
496 
497  break;
498  }
499 
500  case S_CIRCLE:
501  {
502  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
503  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
504 
505  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
506  {
507  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
508  segment->Move( moveVector );
509  }
510  else
511  {
512  segment->SetEnd( wxPoint( end.x, end.y ) );
513  }
514 
515  break;
516  }
517 
518  case S_POLYGON:
519  {
520  SHAPE_POLY_SET& outline = segment->GetPolyShape();
521 
522  for( int i = 0; i < outline.TotalVertices(); ++i )
523  outline.Vertex( i ) = m_editPoints->Point( i ).GetPosition();
524 
525  validatePolygon( outline );
526  break;
527  }
528 
529  case S_CURVE:
530  if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) )
531  segment->SetStart( wxPoint( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition().x,
532  m_editPoints->Point( BEZIER_CURVE_START ).GetPosition().y ) );
533  else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) )
534  segment->SetBezControl1( wxPoint( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition().x,
535  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition().y ) );
536  else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) )
537  segment->SetBezControl2( wxPoint( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition().x,
538  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition().y ) );
539  else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) )
540  segment->SetEnd( wxPoint( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition().x,
541  m_editPoints->Point( BEZIER_CURVE_END ).GetPosition().y ) );
542 
543  segment->RebuildBezierToSegmentsPointsList( segment->GetWidth() );
544  break;
545 
546  default: // suppress warnings
547  break;
548  }
549 
550  // Update relative coordinates for module edges
551  if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
552  edge->SetLocalCoord();
553 
554  break;
555  }
556 
557  case PCB_ZONE_AREA_T:
558  {
559  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
560  zone->ClearFilledPolysList();
561  SHAPE_POLY_SET& outline = *zone->Outline();
562 
563  for( int i = 0; i < outline.TotalVertices(); ++i )
564  {
565  if( outline.Vertex( i ) != m_editPoints->Point( i ).GetPosition() )
566  zone->SetNeedRefill( true );
567 
568  outline.Vertex( i ) = m_editPoints->Point( i ).GetPosition();
569  }
570 
571  validatePolygon( outline );
572  zone->Hatch();
573  break;
574  }
575 
576  case PCB_DIMENSION_T:
577  {
578  DIMENSION* dimension = static_cast<DIMENSION*>( item );
579 
580  // Check which point is currently modified and updated dimension's points respectively
581  if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
582  {
583  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
584  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
585 
586  if( featureLine.Cross( crossBar ) > 0 )
587  dimension->SetHeight( -featureLine.EuclideanNorm() );
588  else
589  dimension->SetHeight( featureLine.EuclideanNorm() );
590  }
591 
592  else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
593  {
594  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
595  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
596 
597  if( featureLine.Cross( crossBar ) > 0 )
598  dimension->SetHeight( -featureLine.EuclideanNorm() );
599  else
600  dimension->SetHeight( featureLine.EuclideanNorm() );
601  }
602 
603  else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
604  {
605  dimension->SetOrigin( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) );
606  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
607  m_editPoints->Point( DIM_FEATUREGO ) ) );
608  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
609  m_editPoints->Point( DIM_FEATUREDO ) ) );
610  }
611 
612  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
613  {
614  dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) );
615  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
616  m_editPoints->Point( DIM_FEATUREGO ) ) );
617  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
618  m_editPoints->Point( DIM_FEATUREDO ) ) );
619  }
620 
621  break;
622  }
623 
624  default:
625  break;
626  }
627 
628  if( frame() )
629  frame()->SetMsgPanel( item );
630 }
631 
632 
634 {
635  auto item = m_editPoints->GetParent();
636 
637  if( !item )
638  return;
639 
640  if( item->Type() == PCB_ZONE_AREA_T )
641  {
642  auto zone = static_cast<ZONE_CONTAINER*>( item );
643 
644  if( zone->IsFilled() && m_refill && zone->NeedRefill() )
645  {
646  ZONE_FILLER filler( board() );
647  // A progress reporter can be usefull. However it works fine only on Windows
648  // so enable it only on Windows.
649  // On Linux, the filled areas are incorrectly shown: the insulated islands
650  // remain displayed, although they are removed from the actual filled areas list
651  //
652  // Fix me: try to make it working on Linux.
653  //
654  #ifdef __WINDOWS__
655  WX_PROGRESS_REPORTER reporter( getEditFrame<PCB_BASE_FRAME>(), _( "Refill Zones" ), 4 );
656  filler.SetProgressReporter( &reporter );
657  #endif
658  filler.Fill( { zone } );
659  }
660  }
661 }
662 
663 
664 bool POINT_EDITOR::validatePolygon( SHAPE_POLY_SET& aModified, const SHAPE_POLY_SET* aOriginal ) const
665 {
666  if( !aModified.IsSelfIntersecting() )
667  {
668  m_statusPopup->Hide();
669  return true;
670  }
671 
672  if( m_statusPopup )
673  {
674  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
675  m_statusPopup->Move( p );
676  m_statusPopup->Popup( getEditFrame<PCB_BASE_FRAME>() );
677  m_statusPopup->Expire( 1500 );
678  }
679 
680  if( aOriginal )
681  aModified = *aOriginal;
682 
683  return false;
684 }
685 
686 
688 {
689  if( !m_editPoints )
690  return;
691 
692  EDA_ITEM* item = m_editPoints->GetParent();
693 
694  if( !item )
695  return;
696 
697  switch( item->Type() )
698  {
699  case PCB_LINE_T:
700  case PCB_MODULE_EDGE_T:
701  {
702  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
703 
704  switch( segment->GetShape() )
705  {
706  case S_SEGMENT:
707  m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
708  m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
709  break;
710 
711  case S_ARC:
712  m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
713  m_editPoints->Point( ARC_START).SetPosition( segment->GetArcStart() );
714  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
715  break;
716 
717  case S_CIRCLE:
718  m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
719  m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
720  break;
721 
722  case S_POLYGON:
723  {
724  const auto& points = segment->BuildPolyPointsList();
725 
726  if( m_editPoints->PointsSize() != (unsigned) points.size() )
727  {
728  getView()->Remove( m_editPoints.get() );
729  m_editedPoint = nullptr;
730  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
731  getView()->Add( m_editPoints.get() );
732  }
733  else
734  {
735  for( unsigned i = 0; i < points.size(); i++ )
736  m_editPoints->Point( i ).SetPosition( points[i] );
737  }
738  break;
739  }
740 
741  case S_CURVE:
742  m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( segment->GetStart() );
743  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( segment->GetBezControl1() );
744  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( segment->GetBezControl2() );
745  m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( segment->GetEnd() );
746  break;
747 
748  default: // suppress warnings
749  break;
750  }
751 
752  break;
753  }
754 
755  case PCB_ZONE_AREA_T:
756  {
757  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
758  const SHAPE_POLY_SET* outline = zone->Outline();
759 
760  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
761  {
762  getView()->Remove( m_editPoints.get() );
763  m_editedPoint = nullptr;
764  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
765  getView()->Add( m_editPoints.get() );
766  }
767  else
768  {
769  for( int i = 0; i < outline->TotalVertices(); ++i )
770  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
771  }
772 
773  break;
774  }
775 
776  case PCB_DIMENSION_T:
777  {
778  const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
779 
780  m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
781  m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
782  m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
783  m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
784  break;
785  }
786 
787  default:
788  break;
789  }
790 
791  getView()->Update( m_editPoints.get() );
792 }
793 
794 
796 {
798 
799  if( aPoint )
800  {
801  controls->ForceCursorPosition( true, aPoint->GetPosition() );
802  controls->ShowCursor( true );
803  }
804  else
805  {
806  controls->ShowCursor( false );
807  controls->ForceCursorPosition( false );
808  }
809 
810  m_editedPoint = aPoint;
811 }
812 
813 
814 void POINT_EDITOR::setAltConstraint( bool aEnabled )
815 {
816  if( aEnabled )
817  {
818  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
819 
820  if( line && m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
821  {
823  }
824  else
825  {
826  // Find a proper constraining point for 45 degrees mode
829  }
830  }
831  else
832  {
833  m_altConstraint.reset();
834  }
835 }
836 
837 
839 {
840  EDA_ITEM* item = m_editPoints->GetParent();
841 
842  switch( item->Type() )
843  {
844  case PCB_LINE_T:
845  case PCB_MODULE_EDGE_T:
846  {
847  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
848  {
849  switch( segment->GetShape() )
850  {
851  case S_SEGMENT:
852  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
853 
854  case S_ARC:
855  case S_CIRCLE:
856  return m_editPoints->Point( CIRC_CENTER );
857 
858  default: // suppress warnings
859  break;
860  }
861  }
862 
863  break;
864  }
865 
866  case PCB_DIMENSION_T:
867  {
868  // Constraint for crossbar
869  if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
870  return m_editPoints->Point( DIM_FEATUREDO );
871 
872  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
873  return m_editPoints->Point( DIM_FEATUREGO );
874 
875  else
876  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
877 
878  break;
879  }
880 
881  default:
882  break;
883  }
884 
885  // In any other case we may align item to its original position
886  return m_original;
887 }
888 
889 
891 {
897 }
898 
899 
901 {
902  const auto type = aItem.Type();
903 
904  // Works only for zones and line segments
905  return type == PCB_ZONE_AREA_T ||
906  ( ( type == PCB_LINE_T || type == PCB_MODULE_EDGE_T ) &&
907  ( static_cast<const DRAWSEGMENT&>( aItem ).GetShape() == S_SEGMENT ||
908  static_cast<const DRAWSEGMENT&>( aItem ).GetShape() == S_POLYGON ) );
909 }
910 
911 
913 {
914  if( aSelection.Size() != 1 )
915  return false;
916 
917  const EDA_ITEM* item = aSelection.Front();
918 
919  return ( item != nullptr ) && canAddCorner( *item );
920 }
921 
922 
923 // Finds a corresponding vertex in a polygon set
924 static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
925 findVertex( SHAPE_POLY_SET& aPolySet, const EDIT_POINT& aPoint )
926 {
927  for( auto it = aPolySet.IterateWithHoles(); it; ++it )
928  {
929  auto vertexIdx = it.GetIndex();
930 
931  if( aPolySet.Vertex( vertexIdx ) == aPoint.GetPosition() )
932  return std::make_pair( true, vertexIdx );
933  }
934 
935  return std::make_pair( false, SHAPE_POLY_SET::VERTEX_INDEX() );
936 }
937 
938 
940 {
941  if( !m_editPoints || !m_editedPoint )
942  return false;
943 
944  EDA_ITEM* item = m_editPoints->GetParent();
945 
946  if( !item || !( item->Type() == PCB_ZONE_AREA_T ||
947  ( ( item->Type() == PCB_MODULE_EDGE_T || item->Type() == PCB_LINE_T ) &&
948  static_cast<DRAWSEGMENT*>( item )->GetShape() == S_POLYGON ) ) )
949  return false;
950 
951  SHAPE_POLY_SET *polyset;
952 
953  if( item->Type() == PCB_ZONE_AREA_T )
954  polyset = static_cast<ZONE_CONTAINER*>( item )->Outline();
955  else
956  polyset = &static_cast<DRAWSEGMENT*>( item )->GetPolyShape();
957 
958  auto vertex = findVertex( *polyset, *m_editedPoint );
959 
960  if( !vertex.first )
961  return false;
962 
963  const auto& vertexIdx = vertex.second;
964 
965  // Check if there are enough vertices so one can be removed without
966  // degenerating the polygon.
967  // The first condition allows one to remove all corners from holes (when
968  // there are only 2 vertices left, a hole is removed).
969  if( vertexIdx.m_contour == 0 && polyset->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
970  return false;
971 
972  // Remove corner does not work with lines
973  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
974  return false;
975 
976  return m_editedPoint != NULL;
977 }
978 
979 
981 {
982  if( !m_editPoints )
983  return 0;
984 
985  EDA_ITEM* item = m_editPoints->GetParent();
986  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
987  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
988 
989  // called without an active edited polygon
990  if( !item || !canAddCorner( *item ) )
991  return 0;
992 
993  DRAWSEGMENT* graphicItem = dynamic_cast<DRAWSEGMENT*>( item );
994  BOARD_COMMIT commit( frame );
995 
996  if( item->Type() == PCB_ZONE_AREA_T ||
997  ( graphicItem && graphicItem->GetShape() == S_POLYGON ) )
998  {
999  unsigned int nearestIdx = 0;
1000  unsigned int nextNearestIdx = 0;
1001  unsigned int nearestDist = INT_MAX;
1002  unsigned int firstPointInContour = 0;
1003  SHAPE_POLY_SET* zoneOutline;
1004 
1005  if( item->Type() == PCB_ZONE_AREA_T )
1006  {
1007  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
1008  zoneOutline = zone->Outline();
1009  zone->SetNeedRefill( true );
1010  }
1011  else
1012  zoneOutline = &( graphicItem->GetPolyShape() );
1013 
1014  commit.Modify( item );
1015 
1016  // Search the best outline segment to add a new corner
1017  // and therefore break this segment into two segments
1018 
1019  // Object to iterate through the corners of the outlines (main contour and its holes)
1020  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
1021  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
1022  int curr_idx = 0;
1023 
1024  // Iterate through all the corners of the outlines and search the best segment
1025  for( ; iterator; iterator++, curr_idx++ )
1026  {
1027  int jj = curr_idx+1;
1028 
1029  if( iterator.IsEndContour() )
1030  { // We reach the last point of the current contour (main or hole)
1031  jj = firstPointInContour;
1032  firstPointInContour = curr_idx+1; // Prepare next contour analysis
1033  }
1034 
1035  SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
1036 
1037  unsigned int distance = curr_segment.Distance( cursorPos );
1038 
1039  if( distance < nearestDist )
1040  {
1041  nearestDist = distance;
1042  nearestIdx = curr_idx;
1043  nextNearestIdx = jj;
1044  }
1045  }
1046 
1047  // Find the point on the closest segment
1048  VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
1049  VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
1050  SEG nearestSide( sideOrigin, sideEnd );
1051  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
1052 
1053  // Do not add points that have the same coordinates as ones that already belong to polygon
1054  // instead, add a point in the middle of the side
1055  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
1056  nearestPoint = ( sideOrigin + sideEnd ) / 2;
1057 
1058  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
1059 
1060  // We re-hatch the filled zones but not polygons
1061  if( item->Type() == PCB_ZONE_AREA_T )
1062  static_cast<ZONE_CONTAINER*>( item )->Hatch();
1063 
1064 
1065  commit.Push( _( "Add a zone corner" ) );
1066  }
1067 
1068  else if( graphicItem && graphicItem->GetShape() == S_SEGMENT )
1069  {
1070  commit.Modify( graphicItem );
1071 
1072  SEG seg( graphicItem->GetStart(), graphicItem->GetEnd() );
1073  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
1074 
1075  // Move the end of the line to the break point..
1076  graphicItem->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
1077 
1078  // and add another one starting from the break point
1079  DRAWSEGMENT* newSegment;
1080 
1081  if( item->Type() == PCB_MODULE_EDGE_T )
1082  {
1083  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( graphicItem );
1084  assert( edge->GetParent()->Type() == PCB_MODULE_T );
1085  newSegment = new EDGE_MODULE( *edge );
1086  }
1087  else
1088  {
1089  newSegment = new DRAWSEGMENT( *graphicItem );
1090  }
1091 
1092  newSegment->ClearSelected();
1093  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
1094  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
1095 
1096  commit.Add( newSegment );
1097  commit.Push( _( "Split segment" ) );
1098  }
1099 
1100  updatePoints();
1101  return 0;
1102 }
1103 
1104 
1106 {
1107  if( !m_editPoints || !m_editedPoint )
1108  return 0;
1109 
1110  EDA_ITEM* item = m_editPoints->GetParent();
1111 
1112  if( !item )
1113  return 0;
1114 
1115  SHAPE_POLY_SET* polygon = nullptr;
1116 
1117  if( item->Type() == PCB_ZONE_AREA_T)
1118  {
1119  auto zone = static_cast<ZONE_CONTAINER*>( item );
1120  polygon = zone->Outline();
1121  zone->SetNeedRefill( true );
1122  }
1123  else if( (item->Type() == PCB_MODULE_EDGE_T ) || ( item->Type() == PCB_LINE_T ) )
1124  {
1125  auto ds = static_cast<DRAWSEGMENT*>( item );
1126 
1127  if( ds->GetShape() == S_POLYGON )
1128  polygon = &ds->GetPolyShape();
1129  }
1130 
1131  if( !polygon )
1132  return 0;
1133 
1134  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
1135  BOARD_COMMIT commit( frame );
1136  auto vertex = findVertex( *polygon, *m_editedPoint );
1137 
1138  if( vertex.first )
1139  {
1140  const auto& vertexIdx = vertex.second;
1141  auto& outline = polygon->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
1142  bool valid = true;
1143 
1144  if( outline.PointCount() > 3 )
1145  {
1146  // the usual case: remove just the corner when there are >3 vertices
1147  commit.Modify( item );
1148  polygon->RemoveVertex( vertexIdx );
1149  valid = validatePolygon( *polygon );
1150  }
1151  else
1152  {
1153  // either remove a hole or the polygon when there are <= 3 corners
1154  if( vertexIdx.m_contour > 0 )
1155  {
1156  // remove hole
1157  commit.Modify( item );
1158  polygon->RemoveContour( vertexIdx.m_contour );
1159  }
1160  else
1161  {
1163  commit.Remove( item );
1164  }
1165  }
1166 
1167  setEditedPoint( nullptr );
1168 
1169  if( valid )
1170  commit.Push( _( "Remove a zone/polygon corner" ) );
1171  else
1172  commit.Revert();
1173 
1174  // Refresh zone hatching
1175  if( item->Type() == PCB_ZONE_AREA_T)
1176  static_cast<ZONE_CONTAINER*>( item )->Hatch();
1177 
1178  updatePoints();
1179  }
1180 
1181  return 0;
1182 }
1183 
1184 
1186 {
1187  m_refill = true; // zone has been modified outside the point editor tool
1188  updatePoints();
1189  return 0;
1190 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
int TotalVertices() const
Returns total number of vertices stored in the set.
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
Class EC_CONVERGING.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
int OnSelectionChange(const TOOL_EVENT &aEvent)
Function OnSelected()
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:199
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:138
void setTransitions() override
Sets up handlers for various events.
int OutlineCount() const
Returns the number of outlines in the set
bool IsEndContour() const
Function IsEndContour.
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
This file is part of the common library.
wxPoint m_crossBarF
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void addCorner(const VECTOR2I &aPoint)
Adds a new edit point on a zone outline/line.
const wxPoint GetCenter() const override
Function GetCenter()
void ClearSelected()
Definition: base_struct.h:234
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
VIEW_CONTROLS class definition.
STROKE_T GetShape() const
const wxPoint GetArcEnd() const
void updateEditedPoint(const TOOL_EVENT &aEvent)
Updates which point is being edited.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
Class BOARD to handle a board.
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
const SELECTION & selection() const
Definition: pcb_tool.cpp:251
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:137
polygon (not yet used for tracks, but could be in microwave apps)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Class EDIT_LINE.
Definition: edit_points.h:189
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:246
CONST_ITERATOR CIterateWithHoles(int aOutline) const
bool IsMotion() const
Definition: tool_event.h:299
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
double RAD2DECIDEG(double rad)
Definition: trigo.h:204
Struct VERTEX_INDEX.
Classes to handle copper zones.
void setAltConstraint(bool aEnabled)
Sets up an alternative constraint (typically enabled upon a modifier key being pressed).
usual segment : line with rounded ends
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, BOARD_ITEM *aDraggedItem)
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:112
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: point_editor.h:86
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
CIRCLE_POINTS
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...
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void SetBezControl2(const wxPoint &aPoint)
Class EC_LINE.
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
Class EC_45DEGREE.
void updateItem() const
Updates item's points with edit points.
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
bool removeCornerCondition(const SELECTION &aSelection)
Condition to display "Remove corner" context menu entry.
Class EC_CIRCLE.
VECTOR2I & Vertex(int aIndex, int aOutline, int aHole)
Returns the index-th vertex in a given hole outline within a given outline
wxPoint m_featureLineGO
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
void PassEvent()
Allows a tool to pass the already handled event to the next tool on the stack.
Definition: tool_manager.h:351
DIMENSION class definition.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
void finishItem()
Applies the last changes to the edited item.
class MODULE, a footprint
Definition: typeinfo.h:89
void SetProgressReporter(WX_PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:78
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:289
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
Class LSET is a set of PCB_LAYER_IDs.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
const wxPoint & GetEnd()
Function GetEnd.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
ITERATOR IterateWithHoles(int aOutline)
Function IterateWithHoles.
Class SHAPE_POLY_SET.
SEG_POINTS
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
BOARD * board() const
Definition: pcb_tool.h:140
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:227
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:230
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
Arcs (with rounded ends)
Class TOOL_EVENT.
Definition: tool_event.h:168
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:78
COMMIT & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
Definition: commit.h:116
bool Fill(std::vector< ZONE_CONTAINER * > aZones, bool aCheck=false)
Definition: zone_filler.cpp:83
bool validatePolygon(SHAPE_POLY_SET &aModified, const SHAPE_POLY_SET *aOriginal=nullptr) const
Validates a polygon and restores it to its original version if available.
DIMENSION_POINTS
SELECTION & GetSelection()
Function GetSelection()
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
Definition: seg.h:374
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
const VECTOR2D DragOrigin() const
Returns the point where dragging has started.
Definition: tool_event.h:265
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static LSET AllLayersMask()
Definition: lset.cpp:713
const wxPoint & GetArcStart() const
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
SHAPE_POLY_SET & GetPolyShape()
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:66
Bezier Curve.
const wxPoint & GetOrigin() const
Function GetOrigin.
All active tools
Definition: tool_event.h:144
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:306
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:1539
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
int GetWidth() const
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
void SetStart(const wxPoint &aStart)
void SetSnap(bool aSnap)
Definition: grid_helper.h:72
Definition: seg.h:36
EDIT_POINT get45DegConstrainer() const
Returns a point that should be used as a constrainer for 45 degrees mode.
double GetAngle() const
Common, abstract interface for edit frames.
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
void RemoveVertex(int aGlobalIndex)
Function RemoveVertex deletes the aGlobalIndex-th vertex.
Class ITERATOR_TEMPLATE.
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
static bool canAddCorner(const EDA_ITEM &aItem)
Determine if the tool can currently add a corner to the given item
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone's...
const wxPoint & GetBezControl2() const
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0), bool aEnableDiagonal=false)
void removeCorner(EDIT_POINT *aPoint)
Removes a corner.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
void updatePoints()
Updates edit points with item's points.
void SetEnd(const wxPoint &aEnd)
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:72
void Activate()
Function Activate() Runs the tool.
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
wxPoint m_crossBarO
BEZIER_CURVE_POINTS
const wxPoint & GetBezControl1() const
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
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
void SetUseGrid(bool aGrid=true)
Definition: grid_helper.h:77
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Class EDIT_POINT.
Definition: edit_points.h:46
Module description (excepted pads)
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
Class VIEW.
Definition: view.h:61
EDIT_POINT m_altConstrainer
Definition: point_editor.h:81
void UpdateMsgPanel() override
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
bool IsSelfIntersecting()
Function IsSelfIntersecting Checks whether any of the polygons in the set is self intersecting.
BOARD_ITEM_CONTAINER * GetParent() const
wxPoint m_featureLineDO
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:243
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Class EC_SNAPLINE.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
static void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline, KIGFX::GAL *aGal)
Class DIMENSION.
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:259
virtual void ApplyConstraint()
Function ApplyConstraint()
Definition: edit_points.h:159
int modifiedSelection(const TOOL_EVENT &aEvent)
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
ARC_POINTS
EDA_ITEM * Front() const
Definition: selection.h:152
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:556
static bool addCornerCondition(const SELECTION &aSelection)
Condition to display "Create corner" context menu entry.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class GAL is the abstract interface for drawing on a 2D-surface.
void SetBezControl1(const wxPoint &aPoint)
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, KIGFX::GAL *aGal)
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Function RemoveContour deletes the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:97
void SetNeedRefill(bool aNeedRefill)
Definition: class_zone.h:192