KiCad PCB EDA Suite
ee_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) 2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <functional>
25 using namespace std::placeholders;
26 
27 #include "ee_point_editor.h"
28 #include <tool/tool_manager.h>
29 #include <view/view_controls.h>
31 #include <geometry/seg.h>
32 #include <confirm.h>
33 
34 #include <tools/ee_actions.h>
36 #include <bitmaps.h>
37 #include <status_popup.h>
38 #include <sch_edit_frame.h>
39 #include <sch_line.h>
40 #include <sch_sheet.h>
41 #include <lib_edit_frame.h>
42 #include <lib_arc.h>
43 #include <lib_circle.h>
44 #include <lib_rectangle.h>
45 #include <lib_polyline.h>
47 
48 
49 // Point editor
50 TOOL_ACTION EE_ACTIONS::pointEditorAddCorner( "eeschema.PointEditor.addCorner",
51  AS_GLOBAL, 0,
52  _( "Create Corner" ), _( "Create a corner" ), add_corner_xpm );
53 
54 TOOL_ACTION EE_ACTIONS::pointEditorRemoveCorner( "eeschema.PointEditor.removeCorner",
55  AS_GLOBAL, 0,
56  _( "Remove Corner" ), _( "Remove corner" ), delete_xpm );
57 
58 
59 // Few constants to avoid using bare numbers for point indices
61 {
63 };
64 
66 {
68 };
69 
71 {
73 };
74 
76 {
78 };
79 
81 {
82 public:
83  static std::shared_ptr<EDIT_POINTS> Make( EDA_ITEM* aItem, SCH_BASE_FRAME* frame )
84  {
85  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
86 
87  if( !aItem )
88  return points;
89 
90  // Generate list of edit points based on the item type
91  switch( aItem->Type() )
92  {
93  case LIB_ARC_T:
94  {
95  LIB_ARC* arc = (LIB_ARC*) aItem;
96 
97  points->AddPoint( mapCoords( arc->GetPosition() ) );
98  points->AddPoint( mapCoords( arc->GetStart() ) );
99  points->AddPoint( mapCoords( arc->GetEnd() ) );
100  break;
101  }
102  case LIB_CIRCLE_T:
103  {
104  LIB_CIRCLE* circle = (LIB_CIRCLE*) aItem;
105 
106  points->AddPoint( mapCoords( circle->GetPosition() ) );
107  points->AddPoint( mapCoords( circle->GetEnd() ) );
108  break;
109  }
110  case LIB_POLYLINE_T:
111  {
112  LIB_POLYLINE* lines = (LIB_POLYLINE*) aItem;
113  const std::vector<wxPoint>& pts = lines->GetPolyPoints();
114 
115  for( wxPoint pt : pts )
116  points->AddPoint( mapCoords( pt ) );
117 
118  break;
119  }
120  case LIB_RECTANGLE_T:
121  {
122  LIB_RECTANGLE* rect = (LIB_RECTANGLE*) aItem;
123  wxPoint topLeft = rect->GetPosition();
124  wxPoint botRight = rect->GetEnd();
125 
126  points->AddPoint( mapCoords( topLeft ) );
127  points->AddPoint( mapCoords( botRight.x, topLeft.y ) );
128  points->AddPoint( mapCoords( topLeft.x, botRight.y ) );
129  points->AddPoint( mapCoords( botRight ) );
130  break;
131  }
132  case SCH_SHEET_T:
133  {
134  SCH_SHEET* sheet = (SCH_SHEET*) aItem;
135  wxPoint topLeft = sheet->GetPosition();
136  wxPoint botRight = sheet->GetPosition() + sheet->GetSize();
137 
138  points->AddPoint( (wxPoint) topLeft );
139  points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
140  points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
141  points->AddPoint( (wxPoint) botRight );
142  break;
143  }
144  case SCH_LINE_T:
145  {
146  SCH_LINE* line = (SCH_LINE*) aItem;
147  SCH_LINE* connectedStart = nullptr;
148  SCH_LINE* connectedEnd = nullptr;
149 
150  for( SCH_ITEM* test = frame->GetScreen()->GetDrawItems(); test; test = test->Next() )
151  {
152  if( test->Type() != SCH_LINE_T || test->GetLayer() != LAYER_NOTES )
153  continue;
154 
155  if( test == aItem )
156  continue;
157 
158  SCH_LINE* testLine = (SCH_LINE*) test;
159  testLine->ClearFlags( STARTPOINT | ENDPOINT );
160 
161  if( testLine->GetStartPoint() == line->GetStartPoint() )
162  {
163  connectedStart = testLine;
164  testLine->SetFlags( STARTPOINT );
165  }
166  else if( testLine->GetEndPoint() == line->GetStartPoint() )
167  {
168  connectedStart = testLine;
169  testLine->SetFlags( ENDPOINT );
170  }
171  else if( testLine->GetStartPoint() == line->GetEndPoint() )
172  {
173  connectedEnd = testLine;
174  testLine->SetFlags( STARTPOINT );
175  }
176  else if( testLine->GetEndPoint() == line->GetEndPoint() )
177  {
178  connectedEnd = testLine;
179  testLine->SetFlags( ENDPOINT );
180  }
181  }
182 
183  points->AddPoint( line->GetStartPoint(), connectedStart );
184  points->AddPoint( line->GetEndPoint(), connectedEnd );
185  break;
186  }
187  default:
188  points.reset();
189  break;
190  }
191 
192  return points;
193  }
194 
195 private:
197 };
198 
199 
201  EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.PointEditor" ),
202  m_editedPoint( nullptr )
203 {
204 }
205 
206 
208 {
209  EE_TOOL_BASE::Reset( aReason );
210 
211  m_editPoints.reset();
212 }
213 
214 
216 {
218 
219  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
221  std::bind( &EE_POINT_EDITOR::addCornerCondition, this, _1 ) );
223  std::bind( &EE_POINT_EDITOR::removeCornerCondition, this, _1 ) );
224 
225  return true;
226 }
227 
228 
230 {
231  EDIT_POINT* point = m_editedPoint;
232 
233  if( aEvent.IsMotion() )
234  {
235  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
236  }
237  else if( aEvent.IsDrag( BUT_LEFT ) )
238  {
239  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
240  }
241 
242  if( m_editedPoint != point )
243  setEditedPoint( point );
244 }
245 
246 
247 int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
248 {
249  static KICAD_T pointTypes[] = { LIB_ARC_T, LIB_CIRCLE_T, LIB_POLYLINE_T, LIB_RECTANGLE_T,
251 
252  if( !m_selectionTool )
253  return 0;
254 
255  const SELECTION& selection = m_selectionTool->GetSelection();
256 
257  if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) )
258  return 0;
259 
260  Activate();
261 
263  KIGFX::VIEW* view = getView();
264  int savedToolID = m_frame->GetToolId();
265  wxString savedToolMsg = m_frame->GetToolMsg();
266  EDA_ITEM* item = (EDA_ITEM*) selection.Front();
267 
268  controls->ShowCursor( true );
269 
271 
272  if( !m_editPoints )
273  return 0;
274 
275  view->Add( m_editPoints.get() );
276  setEditedPoint( nullptr );
277  bool inDrag = false;
278  bool modified = false;
279 
280  // Main loop: keep receiving events
281  while( OPT_TOOL_EVENT evt = Wait() )
282  {
283  if( !m_editPoints
284  || evt->Matches( EVENTS::ClearedEvent )
285  || evt->Matches( EVENTS::UnselectedEvent )
286  || evt->Matches( EVENTS::SelectedEvent ) )
287  {
288  break;
289  }
290 
291  if ( !inDrag )
292  updateEditedPoint( *evt );
293 
294  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
295  {
296  m_frame->SetToolID( ID_DRAG_POINT, -1, _( "Drag Point" ) );
297 
298  if( !inDrag )
299  {
300  saveItemsToUndo();
301  controls->ForceCursorPosition( false );
302  inDrag = true;
303  modified = true;
304  }
305 
306  m_editedPoint->SetPosition( controls->GetCursorPosition( !evt->Modifier( MD_ALT ) ) );
307 
308  updateItem();
309  updatePoints();
310 
311  view->Redraw();
312  }
313 
314  else if( evt->IsMouseUp( BUT_LEFT ) )
315  {
316  controls->SetAutoPan( false );
317  m_frame->SetToolID( savedToolID, -1, savedToolMsg );
318 
319  inDrag = false;
320 
321  m_toolMgr->PassEvent();
322  }
323 
324  else if( evt->IsCancel() )
325  {
326  if( inDrag ) // Restore the last change
327  {
329  modified = false;
330  }
331 
332  m_frame->SetToolID( savedToolID, -1, savedToolMsg );
333  break;
334  }
335 
336  else
337  {
338  m_toolMgr->PassEvent();
339  }
340 
341  controls->SetAutoPan( inDrag );
342  controls->CaptureCursor( inDrag );
343  }
344 
345  controls->SetAutoPan( false );
346  controls->CaptureCursor( false );
347  m_frame->SetToolID( savedToolID, -1, savedToolMsg );
348 
349  if( m_editPoints )
350  {
351  view->Remove( m_editPoints.get() );
352 
353  if( modified )
354  m_frame->OnModify();
355 
356  m_editPoints.reset();
357  m_frame->GetCanvas()->Refresh();
358  }
359 
360  return 0;
361 }
362 
363 
364 void pinEditedCorner( int editedPointIndex, int minWidth, int minHeight, VECTOR2I& topLeft,
365  VECTOR2I& topRight, VECTOR2I& botLeft, VECTOR2I& botRight )
366 {
367  switch( editedPointIndex )
368  {
369  case RECT_TOPLEFT:
370  // pin edited point within opposite corner
371  topLeft.x = std::min( topLeft.x, botRight.x - minWidth );
372  topLeft.y = std::min( topLeft.y, botRight.y - minHeight );
373 
374  // push edited point edges to adjacent corners
375  topRight.y = topLeft.y;
376  botLeft.x = topLeft.x;
377 
378  break;
379 
380  case RECT_TOPRIGHT:
381  // pin edited point within opposite corner
382  topRight.x = std::max( topRight.x, botLeft.x + minWidth );
383  topRight.y = std::min( topRight.y, botLeft.y - minHeight );
384 
385  // push edited point edges to adjacent corners
386  topLeft.y = topRight.y;
387  botRight.x = topRight.x;
388 
389  break;
390 
391  case RECT_BOTLEFT:
392  // pin edited point within opposite corner
393  botLeft.x = std::min( botLeft.x, topRight.x - minWidth );
394  botLeft.y = std::max( botLeft.y, topRight.y + minHeight );
395 
396  // push edited point edges to adjacent corners
397  botRight.y = botLeft.y;
398  topLeft.x = botLeft.x;
399 
400  break;
401 
402  case RECT_BOTRIGHT:
403  // pin edited point within opposite corner
404  botRight.x = std::max( botRight.x, topLeft.x + minWidth );
405  botRight.y = std::max( botRight.y, topLeft.y + minHeight );
406 
407  // push edited point edges to adjacent corners
408  botLeft.y = botRight.y;
409  topRight.x = botRight.x;
410 
411  break;
412  }
413 }
414 
415 
417 {
418  EDA_ITEM* item = m_editPoints->GetParent();
419 
420  if( !item )
421  return;
422 
423  switch( item->Type() )
424  {
425  case LIB_ARC_T:
426  {
427  LIB_ARC* arc = (LIB_ARC*) item;
428 
429  arc->SetPosition( mapCoords( m_editPoints->Point( ARC_CENTER ).GetPosition() ) );
430  arc->SetStart( mapCoords( m_editPoints->Point( ARC_START ).GetPosition() ) );
431  arc->SetEnd( mapCoords( m_editPoints->Point( ARC_END ).GetPosition() ) );
432  break;
433  }
434 
435  case LIB_CIRCLE_T:
436  {
437  LIB_CIRCLE* circle = (LIB_CIRCLE*) item;
438 
439  circle->SetPosition( mapCoords( m_editPoints->Point( CIRC_CENTER ).GetPosition() ) );
440  circle->SetEnd( mapCoords( m_editPoints->Point( CIRC_END ).GetPosition() ) );
441  break;
442  }
443 
444  case LIB_POLYLINE_T:
445  {
446  LIB_POLYLINE* lines = (LIB_POLYLINE*) item;
447 
448  lines->ClearPoints();
449 
450  for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i )
451  lines->AddPoint( mapCoords( m_editPoints->Point( i ).GetPosition() ) );
452 
453  break;
454  }
455 
456  case LIB_RECTANGLE_T:
457  {
458  LIB_RECTANGLE* rect = (LIB_RECTANGLE*) item;
459  VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition();
460  VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition();
461  VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition();
462  VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition();
463 
464  pinEditedCorner( getEditedPointIndex(), Mils2iu( 1 ), Mils2iu( 1 ),
465  topLeft, topRight, botLeft, botRight );
466 
467  rect->SetPosition( mapCoords( topLeft ) );
468  rect->SetEnd( mapCoords( botRight ) );
469  break;
470  }
471 
472  case SCH_SHEET_T:
473  {
474  SCH_SHEET* sheet = (SCH_SHEET*) item;
475  VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition();
476  VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition();
477  VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition();
478  VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition();
479 
481  topLeft, topRight, botLeft, botRight );
482 
483  sheet->SetPosition( (wxPoint) topLeft );
484  sheet->SetSize( wxSize( botRight.x - topLeft.x, botRight.y - topLeft.y ) );
485  break;
486  }
487 
488  case SCH_LINE_T:
489  {
490  SCH_LINE* line = (SCH_LINE*) item;
491 
492  line->SetStartPoint( (wxPoint) m_editPoints->Point( LINE_START ).GetPosition() );
493  line->SetEndPoint( (wxPoint) m_editPoints->Point( LINE_END ).GetPosition() );
494 
495  SCH_LINE* connection = (SCH_LINE*) ( m_editPoints->Point( LINE_START ).GetConnection() );
496 
497  if( connection )
498  {
499  if( ( connection->GetFlags() & STARTPOINT ) != 0 )
500  connection->SetStartPoint( line->GetPosition() );
501  else if( ( connection->GetFlags() & ENDPOINT ) != 0 )
502  connection->SetEndPoint( line->GetPosition() );
503 
504  getView()->Update( connection, KIGFX::GEOMETRY );
505  }
506 
507  connection = (SCH_LINE*) ( m_editPoints->Point( LINE_END ).GetConnection() );
508 
509  if( connection )
510  {
511  if( ( connection->GetFlags() & STARTPOINT ) != 0 )
512  connection->SetStartPoint( line->GetEndPoint() );
513  else if( ( connection->GetFlags() & ENDPOINT ) != 0 )
514  connection->SetEndPoint( line->GetEndPoint() );
515 
516  getView()->Update( connection, KIGFX::GEOMETRY );
517  }
518 
519  break;
520  }
521 
522  default:
523  break;
524  }
525 
526  updateView( item );
527  m_frame->SetMsgPanel( item );
528 }
529 
530 
532 {
533  if( !m_editPoints )
534  return;
535 
536  EDA_ITEM* item = m_editPoints->GetParent();
537 
538  if( !item )
539  return;
540 
541  switch( item->Type() )
542  {
543  case LIB_ARC_T:
544  {
545  LIB_ARC* arc = (LIB_ARC*) item;
546 
547  m_editPoints->Point( ARC_CENTER ).SetPosition( mapCoords( arc->GetPosition() ) );
548  m_editPoints->Point( ARC_START ).SetPosition( mapCoords( arc->GetStart() ) );
549  m_editPoints->Point( ARC_END ).SetPosition( mapCoords( arc->GetEnd() ) );
550  break;
551  }
552 
553  case LIB_CIRCLE_T:
554  {
555  LIB_CIRCLE* circle = (LIB_CIRCLE*) item;
556 
557  m_editPoints->Point( CIRC_CENTER ).SetPosition( mapCoords( circle->GetPosition() ) );
558  m_editPoints->Point( CIRC_END ).SetPosition( mapCoords( circle->GetEnd() ) );
559  break;
560  }
561 
562  case LIB_POLYLINE_T:
563  {
564  LIB_POLYLINE* lines = (LIB_POLYLINE*) item;
565  const std::vector<wxPoint>& pts = lines->GetPolyPoints();
566 
567  if( m_editPoints->PointsSize() != (unsigned) pts.size() )
568  {
569  getView()->Remove( m_editPoints.get() );
570  m_editedPoint = nullptr;
572  getView()->Add(m_editPoints.get() );
573  }
574  else
575  {
576  for( unsigned i = 0; i < pts.size(); i++ )
577  m_editPoints->Point( i ).SetPosition( mapCoords( pts[i] ) );
578  }
579 
580  break;
581  }
582 
583  case LIB_RECTANGLE_T:
584  {
585  LIB_RECTANGLE* rect = (LIB_RECTANGLE*) item;
586  wxPoint topLeft = rect->GetPosition();
587  wxPoint botRight = rect->GetEnd();
588 
589  m_editPoints->Point( RECT_TOPLEFT ).SetPosition( mapCoords( topLeft ) );
590  m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( mapCoords( botRight.x, topLeft.y ) );
591  m_editPoints->Point( RECT_BOTLEFT ).SetPosition( mapCoords( topLeft.x, botRight.y ) );
592  m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( mapCoords( botRight ) );
593  break;
594  }
595 
596  case SCH_SHEET_T:
597  {
598  SCH_SHEET* sheet = (SCH_SHEET*) item;
599  wxPoint topLeft = sheet->GetPosition();
600  wxPoint botRight = sheet->GetPosition() + sheet->GetSize();
601 
602  m_editPoints->Point( RECT_TOPLEFT ).SetPosition( topLeft );
603  m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( botRight.x, topLeft.y );
604  m_editPoints->Point( RECT_BOTLEFT ).SetPosition( topLeft.x, botRight.y );
605  m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight );
606  break;
607  }
608 
609  case SCH_LINE_T:
610  {
611  SCH_LINE* line = (SCH_LINE*) item;
612 
613  m_editPoints->Point( LINE_START ).SetPosition( line->GetStartPoint() );
614  m_editPoints->Point( LINE_END ).SetPosition( line->GetEndPoint() );
615  break;
616  }
617 
618  default:
619  break;
620  }
621 
622  getView()->Update( m_editPoints.get() );
623 }
624 
625 
627 {
629 
630  if( aPoint )
631  {
632  controls->ForceCursorPosition( true, aPoint->GetPosition() );
633  controls->ShowCursor( true );
634  }
635  else
636  {
637  controls->ShowCursor( false );
638  controls->ForceCursorPosition( false );
639  }
640 
641  m_editedPoint = aPoint;
642 }
643 
644 
646 {
647  if( !m_editPoints || !m_editedPoint )
648  return false;
649 
650  LIB_POLYLINE* polyLine = dynamic_cast<LIB_POLYLINE*>( m_editPoints->GetParent() );
651 
652  if( !polyLine || polyLine->GetCornerCount() < 3 )
653  return false;
654 
655  const std::vector<wxPoint>& pts = polyLine->GetPolyPoints();
656 
657  for( unsigned i = 0; i < polyLine->GetCornerCount(); ++i )
658  {
659  if( pts[i] == mapCoords( m_editedPoint->GetPosition() ) )
660  return true;
661  }
662 
663  return false;
664 }
665 
666 
668 {
669  if( !m_editPoints || !m_editedPoint )
670  return false;
671 
672  LIB_POLYLINE* polyLine = dynamic_cast<LIB_POLYLINE*>( m_editPoints->GetParent() );
673 
674  if( !polyLine )
675  return false;
676 
677  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
678  double threshold = getView()->ToWorld( EDIT_POINT::POINT_SIZE );
679 
680  return polyLine->HitTest( mapCoords( cursorPos ), (int) threshold );
681 }
682 
683 
685 {
686  if( !m_editPoints )
687  return 0;
688 
689  LIB_POLYLINE* polyLine = dynamic_cast<LIB_POLYLINE*>( m_editPoints->GetParent() );
690 
691  if( !polyLine )
692  return false;
693 
694  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
695  polyLine->AddCorner( mapCoords( cursorPos ) );
696 
697  updateView( polyLine );
698  updatePoints();
699 
700  return 0;
701 }
702 
703 
705 {
706  if( !m_editPoints || !m_editedPoint )
707  return 0;
708 
709  LIB_POLYLINE* polyLine = dynamic_cast<LIB_POLYLINE*>( m_editPoints->GetParent() );
710 
711  if( !polyLine || polyLine->GetCornerCount() < 3 )
712  return 0;
713 
714  polyLine->RemoveCorner( getEditedPointIndex() );
715 
716  updateView( polyLine );
717  updatePoints();
718 
719  return 0;
720 }
721 
722 
724 {
725  updatePoints();
726  return 0;
727 }
728 
729 
731 {
732  if( m_isLibEdit )
733  {
734  saveCopyInUndoList( m_editPoints->GetParent()->GetParent(), UR_LIBEDIT );
735  }
736  else
737  {
739 
740  if( m_editPoints->GetParent()->Type() == SCH_LINE_T )
741  {
742  EDA_ITEM* connection = m_editPoints->Point( LINE_START ).GetConnection();
743 
744  if( connection )
745  saveCopyInUndoList( (SCH_ITEM*) connection, UR_CHANGED, true );
746 
747  connection = m_editPoints->Point( LINE_END ).GetConnection();
748 
749  if( connection )
750  saveCopyInUndoList( (SCH_ITEM*) connection, UR_CHANGED, true );
751  }
752  }
753 }
754 
755 
757 {
758  if( m_isLibEdit )
759  static_cast<LIB_EDIT_FRAME*>( m_frame )->RollbackPartFromUndo();
760  else
761  static_cast<SCH_EDIT_FRAME*>( m_frame )->RollbackSchematicFromUndo();
762 }
763 
764 
766 {
771 }
772 
773 
int Main(const TOOL_EVENT &aEvent)
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
SELECTION & GetSelection()
Function GetSelection()
void AddCorner(const wxPoint &aPosition)
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Definition: ee_tool_base.h:90
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
Definition: actions.h:132
wxPoint GetStartPoint() const
Definition: sch_line.h:90
void SetPosition(const wxPoint &aPosition)
wxPoint GetEnd() const
Definition: lib_rectangle.h:97
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
Definition: actions.h:133
TOOL_MENU & GetToolMenu()
This file is part of the common library.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:475
SCH_ITEM * Next() const
Definition: sch_item.h:153
VIEW_CONTROLS class definition.
static TOOL_ACTION pointEditorAddCorner
Definition: ee_actions.h:144
void pinEditedCorner(int editedPointIndex, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight)
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
void updateEditedPoint(const TOOL_EVENT &aEvent)
Updates which point is being edited.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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()
bool IsMotion() const
Definition: tool_event.h:290
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_circle.h:79
virtual bool IsType(const KICAD_T aScanTypes[])
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:287
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
void updatePoints()
Updates edit points with item's points.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
CIRCLE_POINTS
int modifiedSelection(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
unsigned GetCornerCount() const
Definition: lib_polyline.h:79
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
bool addCornerCondition(const SELECTION &aSelection)
void PassEvent()
Allows a tool to pass the already handled event to the next tool on the stack.
Definition: tool_manager.h:356
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:66
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:280
wxPoint GetEnd() const
Definition: lib_circle.h:82
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:129
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
static TOOL_ACTION pointEditorRemoveCorner
Definition: ee_actions.h:145
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void Redraw()
Function Redraw() Immediately redraws the whole view.
Definition: view.cpp:1144
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Class TOOL_EVENT.
Definition: tool_event.h:167
int removeCorner(const TOOL_EVENT &aEvent)
wxPoint GetStart() const
Definition: lib_arc.h:125
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
Definition: sch_sheet.cpp:301
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
const VECTOR2D DragOrigin() const
Returns the point where dragging has started.
Definition: tool_event.h:264
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Definition: actions.h:134
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
void AddPoint(const wxPoint &aPoint)
All active tools
Definition: tool_event.h:143
static VECTOR2D mapCoords(const wxPoint &aCoord)
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
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:530
LINE_POINTS
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.
bool removeCornerCondition(const SELECTION &aSelection)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
void SetSize(const wxSize &aSize)
Definition: sch_sheet.h:271
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:316
void ClearPoints()
Definition: lib_polyline.h:62
int GetMinWidth() const
Return the minimum width of the sheet based on the widths of the sheet pin text.
Definition: sch_sheet.cpp:261
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:107
void SetEnd(const wxPoint &aEnd)
Definition: lib_rectangle.h:96
void updateItem() const
Updates item's points with edit points.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
#define max(a, b)
Definition: auxiliary.h:86
int getEditedPointIndex() const
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_line.h:191
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.cpp:693
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:120
wxPoint GetEnd() const
Definition: lib_arc.h:128
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:120
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
static const int POINT_SIZE
Single point size in pixels
Definition: edit_points.h:185
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
void Activate()
Function Activate() Runs the tool.
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:126
Class EE_TOOL_BASE.
Definition: ee_tool_base.h:49
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
Class EDIT_POINT.
Definition: edit_points.h:46
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
Class VIEW.
Definition: view.h:61
void RemoveCorner(int aIdx)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:261
void setTransitions() override
Sets up handlers for various events.
RECTANGLE_POINTS
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
wxSize GetSize()
Definition: sch_sheet.h:270
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:258
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_rectangle.h:84
int GetToolId() const
Definition: draw_frame.h:524
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
ARC_POINTS
void SetEnd(const wxPoint &aPosition)
Definition: lib_circle.h:81
EDA_ITEM * Front() const
Definition: selection.h:155
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#define min(a, b)
Definition: auxiliary.h:85
Color has changed.
Definition: view_item.h:57
wxString GetToolMsg()
Definition: draw_frame.h:747
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:103
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:119
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, KIGFX::GAL *aGal)
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:105
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153
wxPoint GetEndPoint() const
Definition: sch_line.h:93