KiCad PCB EDA Suite
pcbnew/block.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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <class_drawpanel.h>
34 #include <confirm.h>
35 #include <block_commande.h>
36 #include <pcb_edit_frame.h>
37 #include <trigo.h>
38 
39 #include <class_board.h>
40 #include <class_track.h>
41 #include <class_drawsegment.h>
42 #include <class_pcb_text.h>
43 #include <class_pcb_target.h>
44 #include <class_module.h>
45 #include <class_dimension.h>
46 #include <class_zone.h>
47 
48 #include <dialog_block_options.h>
49 
50 #include <pcbnew.h>
51 #include <protos.h>
52 
54 
55 #define BLOCK_OUTLINE_COLOR YELLOW
56 
64 static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset );
65 
74 static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
75  bool aErase );
76 
77 
79 
80 
81 static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title )
82 {
83  wxPoint oldpos = parent->GetCrossHairPosition();
84 
85  parent->GetCanvas()->SetIgnoreMouseEvents( true );
86  DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, blockOpts, true, title );
87 
88  int cmd = dlg->ShowModal();
89  dlg->Destroy();
90 
91  parent->SetCrossHairPosition( oldpos );
92  parent->GetCanvas()->MoveCursorToCrossHair();
93  parent->GetCanvas()->SetIgnoreMouseEvents( false );
94 
95  return cmd == wxID_OK;
96 }
97 
98 
100 {
101  int cmd = 0;
102 
103  switch( aKey )
104  {
105  default:
106  cmd = aKey & 0xFF;
107  break;
108 
109  case 0:
110  cmd = BLOCK_MOVE;
111  break;
112 
113  case GR_KB_SHIFT:
114  cmd = BLOCK_DUPLICATE;
115  break;
116 
117  case GR_KB_CTRL:
118  cmd = BLOCK_ROTATE;
119  break;
120 
121  case GR_KB_SHIFTCTRL:
122  cmd = BLOCK_DELETE;
123  break;
124 
125  case GR_KB_ALT:
126  cmd = BLOCK_FLIP;
127  break;
128 
129  case MOUSE_MIDDLE:
130  cmd = BLOCK_ZOOM;
131  break;
132  }
133 
134  return cmd;
135 }
136 
137 
139 {
141 
142  if( !m_canvas->IsMouseCaptured() )
143  {
144  DisplayError( this, wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
145  }
146 
148 
149  const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
150 
151  switch( command )
152  {
153  case BLOCK_IDLE:
154  break;
155 
156  case BLOCK_DRAG: // Drag
157  case BLOCK_MOVE: // Move
158  case BLOCK_PRESELECT_MOVE: // Move with preselection list
159  if( m_canvas->IsMouseCaptured() )
160  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
161 
162  Block_Move();
164  break;
165 
166  case BLOCK_DUPLICATE: // Duplicate
168  if( m_canvas->IsMouseCaptured() )
169  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
170 
173  break;
174 
175  case BLOCK_PASTE:
176  break;
177 
178  case BLOCK_ZOOM: // Handled by HandleBlockEnd()
179  default:
180  break;
181  }
182 
183  OnModify();
184 
185  m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
187 
188  if( GetScreen()->m_BlockLocate.GetCount() )
189  {
190  DisplayError( this, wxT( "Error in HandleBlockPLace some items left in list" ) );
192  }
193 }
194 
195 
197 {
198  bool nextcmd = false; // Will be set to true if a block place is needed
199  bool cancelCmd = false;
200  // If coming here after cancel block, clean up and exit
201  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
202  {
204  false );
206  return false;
207  }
208 
209  // Show dialog if there are no selected items and we're not zooming
210  if( !GetScreen()->m_BlockLocate.GetCount()
212  {
213  if( InstallBlockCmdFrame( this, _( "Block Operation" ) ) == false )
214  {
215  cancelCmd = true;
216 
217  // undraw block outline
218  if( DC )
219  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
220  }
221  else
222  {
223  DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
225 
226  // Exit if no items found
227  if( !GetScreen()->m_BlockLocate.GetCount() )
228  cancelCmd = true;
229  }
230  }
231 
232  if( !cancelCmd && m_canvas->IsMouseCaptured() )
233  {
234  switch( GetScreen()->m_BlockLocate.GetCommand() )
235  {
236  case BLOCK_IDLE:
237  DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
238  break;
239 
240  case BLOCK_DRAG: // Drag (not used, for future enhancements)
241  case BLOCK_MOVE: // Move
242  case BLOCK_DUPLICATE: // Duplicate
243  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
244  case BLOCK_PRESELECT_MOVE: // Move with preselection list
246  nextcmd = true;
248  if( DC )
249  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
250  break;
251 
252  case BLOCK_DELETE: // Delete
255  Block_Delete();
256  break;
257 
258  case BLOCK_ROTATE: // Rotation
261  Block_Rotate();
262  break;
263 
264  case BLOCK_FLIP: // Flip
267  Block_Flip();
268  break;
269 
270  case BLOCK_COPY: // Copy
272 
273  if( GetScreen()->m_BlockLocate.GetCount() )
274  {
275  // @todo (if useful) Save_Block( );
276  }
277  break;
278 
279  case BLOCK_PASTE:
280  break;
281 
282  case BLOCK_ZOOM: // Window Zoom
283 
284  // Turn off the redraw block routine now so it is not displayed
285  // with one corner at the new center of the screen
287  Window_Zoom( GetScreen()->m_BlockLocate );
288  break;
289 
290  default:
291  break;
292  }
293  }
294 
295  if( ! nextcmd )
296  {
300  false );
301  }
302 
303  return nextcmd;
304 }
305 
306 
308 {
309  LSET layerMask;
310  bool selectOnlyComplete = GetScreen()->m_BlockLocate.GetWidth() > 0 ;
311 
313 
315  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
316 
317  // Add modules
318  if( blockOpts.includeModules )
319  {
320  for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
321  {
322  PCB_LAYER_ID layer = module->GetLayer();
323 
324  if( module->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete )
325  && ( !module->IsLocked() || blockOpts.includeLockedModules ) )
326  {
327  if( blockOpts.includeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) )
328  {
329  picker.SetItem ( module );
330  itemsList->PushItem( picker );
331  }
332  }
333  }
334  }
335 
336  // Add tracks and vias
337  for( auto PtStruct : m_Pcb->Tracks() )
338  {
339  if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && !blockOpts.includeItemsOnInvisibleLayers )
340  continue;
341 
342  if( !( blockOpts.includeTracks && PtStruct->Type() == PCB_TRACE_T ) &&
343  !( blockOpts.includeVias && PtStruct->Type() == PCB_VIA_T) )
344  continue;
345 
346  if( PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
347  {
348  picker.SetItem ( PtStruct );
349  itemsList->PushItem( picker );
350  }
351  }
352 
353  // Add graphic items
354  layerMask = LSET( Edge_Cuts );
355 
356  if( blockOpts.includeItemsOnTechLayers )
357  layerMask.set();
358 
359  if( !blockOpts.includeBoardOutlineLayer )
360  layerMask.set( Edge_Cuts, false );
361 
362  for( auto PtStruct : m_Pcb->Drawings() )
363  {
364  if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && ! blockOpts.includeItemsOnInvisibleLayers)
365  continue;
366 
367  bool select_me = false;
368 
369  switch( PtStruct->Type() )
370  {
371  case PCB_LINE_T:
372  if( !layerMask[PtStruct->GetLayer()] )
373  break;
374 
375  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
376  break;
377 
378  select_me = true; // This item is in bloc: select it
379  break;
380 
381  case PCB_TEXT_T:
382  if( !blockOpts.includePcbTexts )
383  break;
384 
385  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
386  break;
387 
388  select_me = true; // This item is in bloc: select it
389  break;
390 
391  case PCB_TARGET_T:
392  if( !layerMask[PtStruct->GetLayer()] )
393  break;
394 
395  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
396  break;
397 
398  select_me = true; // This item is in bloc: select it
399  break;
400 
401  case PCB_DIMENSION_T:
402  if( !layerMask[PtStruct->GetLayer()] )
403  break;
404 
405  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
406  break;
407 
408  select_me = true; // This item is in bloc: select it
409  break;
410 
411  default:
412  break;
413  }
414 
415  if( select_me )
416  {
417  picker.SetItem ( PtStruct );
418  itemsList->PushItem( picker );
419  }
420  }
421 
422  // Add zones
423  if( blockOpts.includeZones )
424  {
425  for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
426  {
427  ZONE_CONTAINER* area = m_Pcb->GetArea( ii );
428 
429  if( area->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
430  {
431  if( blockOpts.includeItemsOnInvisibleLayers
432  || m_Pcb->IsLayerVisible( area->GetLayer() ) )
433  {
434  BOARD_ITEM* zone_c = (BOARD_ITEM*) area;
435  picker.SetItem ( zone_c );
436  itemsList->PushItem( picker );
437  }
438  }
439  }
440  }
441 }
442 
443 
444 static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset )
445 {
446  PICKED_ITEMS_LIST* itemsList = &aPanel->GetScreen()->m_BlockLocate.GetItems();
447  PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
448 
449  g_Offset_Module = -aOffset;
450 
451  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
452  {
453  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
454 
455  switch( item->Type() )
456  {
457  case PCB_MODULE_T:
459  ((MODULE*) item)->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
460  break;
461 
462  case PCB_LINE_T:
463  case PCB_TEXT_T:
464  case PCB_TRACE_T:
465  case PCB_VIA_T:
466  case PCB_TARGET_T:
467  case PCB_DIMENSION_T: // Currently markers are not affected by block commands
468  case PCB_MARKER_T:
469  item->Draw( aPanel, aDC, GR_XOR, aOffset );
470  break;
471 
472  case PCB_ZONE_AREA_T:
473  item->Draw( aPanel, aDC, GR_XOR, aOffset );
474  ((ZONE_CONTAINER*) item)->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
475  break;
476 
477  default:
478  break;
479  }
480  }
481 
482  g_Offset_Module = wxPoint( 0, 0 );
483 }
484 
485 
486 static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
487  bool aErase )
488 {
489  BASE_SCREEN* screen = aPanel->GetScreen();
490 
491  // do not show local module rastnest in block move, it is not usable.
492  auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() );
493  bool showRats = displ_opts->m_Show_Module_Ratsnest;
494  displ_opts->m_Show_Module_Ratsnest = false;
495 
496  if( aErase )
497  {
498  if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
499  {
500  screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
502 
503  if( blockOpts.drawItems )
504  drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
505  }
506  }
507 
508 
509  if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP )
510  {
513  }
514 
515  if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
516  {
517  screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
519 
520  if( blockOpts.drawItems )
521  drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
522  }
523 
524  displ_opts->m_Show_Module_Ratsnest = showRats;
525 }
526 
527 
529 {
530  OnModify();
531  SetCurItem( NULL );
532 
534  itemsList->m_Status = UR_DELETED;
535 
536  // unlink items and clear flags
537  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
538  {
539  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
540  itemsList->SetPickedItemStatus( UR_DELETED, ii );
541  GetBoard()->GetConnectivity()->Remove( item );
542 
543  switch( item->Type() )
544  {
545  case PCB_MODULE_T:
546  {
547  MODULE* module = (MODULE*) item;
548  module->ClearFlags();
549  module->UnLink();
550  m_Pcb->m_Status_Pcb = 0;
551  }
552  break;
553 
554  case PCB_ZONE_AREA_T: // a zone area
555  m_Pcb->Remove( item );
556  break;
557 
558  case PCB_LINE_T: // a segment not on copper layers
559  case PCB_TEXT_T: // a text on a layer
560  case PCB_TRACE_T: // a track segment (segment on a copper layer)
561  case PCB_VIA_T: // a via (like track segment on a copper layer)
562  case PCB_DIMENSION_T: // a dimension (graphic item)
563  case PCB_TARGET_T: // a target (graphic item)
564  item->UnLink();
565  break;
566 
567  // These items are deleted, but not put in undo list
568  case PCB_MARKER_T: // a marker used to show something
569  case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
570  item->UnLink();
571  itemsList->RemovePicker( ii );
572  ii--;
573  item->DeleteStructure();
574  break;
575 
576  default:
577  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Delete( ) error: unexpected type" ) );
578  break;
579  }
580  }
581 
582  SaveCopyInUndoList( *itemsList, UR_DELETED );
583 
584  Compile_Ratsnest( NULL, true );
585  m_canvas->Refresh( true );
586 }
587 
588 
590 {
591  // 6.0 TODO: This is the legacy toolset version
592 
593  wxPoint centre; // rotation cent-re for the rotation transform
594  int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg.
595 
596  centre = GetScreen()->m_BlockLocate.Centre();
597 
598  OnModify();
599 
601  itemsList->m_Status = UR_CHANGED;
602 
603  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
604  {
605  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
606  wxASSERT( item );
607  itemsList->SetPickedItemStatus( UR_CHANGED, ii );
608 
609  switch( item->Type() )
610  {
611  case PCB_MODULE_T:
612  ( (MODULE*) item )->ClearFlags();
613  m_Pcb->m_Status_Pcb = 0;
614  break;
615 
616  // Move and rotate the track segments
617  case PCB_TRACE_T: // a track segment (segment on a copper layer)
618  case PCB_VIA_T: // a via (like track segment on a copper layer)
619  m_Pcb->m_Status_Pcb = 0;
620  break;
621 
622  case PCB_ZONE_AREA_T:
623  case PCB_LINE_T:
624  case PCB_TEXT_T:
625  case PCB_TARGET_T:
626  case PCB_DIMENSION_T:
627  break;
628 
629  // This item is not put in undo list
630  case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
631  itemsList->RemovePicker( ii );
632  ii--;
633  break;
634 
635  default:
636  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Rotate( ) error: unexpected type" ) );
637  break;
638  }
639  }
640 
641  // Save all the block items in there current state before applying the rotation.
642  SaveCopyInUndoList( *itemsList, UR_CHANGED, centre );
643 
644  // Now perform the rotation.
645  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
646  {
647  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
648  wxASSERT( item );
649  item->Rotate( centre, rotAngle );
650  GetBoard()->GetConnectivity()->Update( item );
651  }
652 
653  Compile_Ratsnest( NULL, true );
654  m_canvas->Refresh( true );
655 }
656 
657 
659 {
660 #define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
661  wxPoint center; // Position of the axis for inversion of all elements
662 
663  OnModify();
664 
666  itemsList->m_Status = UR_FLIPPED;
667 
668  center = GetScreen()->m_BlockLocate.Centre();
669 
670  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
671  {
672  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
673  wxASSERT( item );
674  itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
675  item->Flip( center );
676  GetBoard()->GetConnectivity()->Update( item );
677 
678  // If a connected item is flipped, the ratsnest is no more OK
679  switch( item->Type() )
680  {
681  case PCB_MODULE_T:
682  item->ClearFlags();
683  m_Pcb->m_Status_Pcb = 0;
684  break;
685 
686  case PCB_TRACE_T:
687  case PCB_VIA_T:
688  m_Pcb->m_Status_Pcb = 0;
689  break;
690 
691  case PCB_ZONE_AREA_T:
692  case PCB_LINE_T:
693  case PCB_TEXT_T:
694  case PCB_TARGET_T:
695  case PCB_DIMENSION_T:
696  break;
697 
698  // This item is not put in undo list
699  case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
700  itemsList->RemovePicker( ii );
701  ii--;
702  break;
703 
704 
705  default:
706  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
707  break;
708  }
709  }
710 
711  SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
712  Compile_Ratsnest( NULL, true );
713  m_canvas->Refresh( true );
714 }
715 
716 
718 {
719  OnModify();
720 
722 
724  itemsList->m_Status = UR_MOVED;
725 
726  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
727  {
728  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
729  itemsList->SetPickedItemStatus( UR_MOVED, ii );
730  item->Move( MoveVector );
731  GetBoard()->GetConnectivity()->Update( item );
732  item->ClearFlags( IS_MOVED );
733 
734  switch( item->Type() )
735  {
736  case PCB_MODULE_T:
737  m_Pcb->m_Status_Pcb = 0;
738  item->ClearFlags();
739  break;
740 
741  // Move track segments
742  case PCB_TRACE_T: // a track segment (segment on a copper layer)
743  case PCB_VIA_T: // a via (like a track segment on a copper layer)
744  m_Pcb->m_Status_Pcb = 0;
745  break;
746 
747  case PCB_ZONE_AREA_T:
748  case PCB_LINE_T:
749  case PCB_TEXT_T:
750  case PCB_TARGET_T:
751  case PCB_DIMENSION_T:
752  break;
753 
754  // This item is not put in undo list
755  case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
756  itemsList->RemovePicker( ii );
757  ii--;
758  break;
759 
760  default:
761  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Move( ) error: unexpected type" ) );
762  break;
763  }
764  }
765 
766  SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
767 
768  Compile_Ratsnest( NULL, true );
769  m_canvas->Refresh( true );
770 }
771 
772 
773 void PCB_EDIT_FRAME::Block_Duplicate( bool aIncrement )
774 {
776 
777  OnModify();
778 
780 
781  PICKED_ITEMS_LIST newList;
782  newList.m_Status = UR_NEW;
783 
784  ITEM_PICKER picker( NULL, UR_NEW );
785  BOARD_ITEM* newitem;
786 
787  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
788  {
789  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
790 
791  newitem = (BOARD_ITEM*)item->Clone();
792 
793  if( item->Type() == PCB_MODULE_T )
794  m_Pcb->m_Status_Pcb = 0;
795 
796  m_Pcb->Add( newitem );
797 
798  if( newitem )
799  {
800  newitem->Move( MoveVector );
801  picker.SetItem ( newitem );
802  newList.PushItem( picker );
803  }
804  }
805 
806  if( newList.GetCount() )
807  SaveCopyInUndoList( newList, UR_NEW );
808 
809  Compile_Ratsnest( NULL, true );
810  m_canvas->Refresh( true );
811 }
virtual BASE_SCREEN * GetScreen()=0
#define GR_KB_ALT
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
#define MOUSE_MIDDLE
wxPoint g_Offset_Module
Definition: pcbnew.cpp:75
static DIALOG_BLOCK_OPTIONS::OPTIONS blockOpts
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
static void drawMovingBlock(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function drawMovingBlock handles drawing of a moving block.
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:388
TEXTE_PCB class definition.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
int GetCurrentCursor() const
Function GetCurrentCursor.
Class BOARD to handle a board.
void SetMoveVector(const wxPoint &aMoveVector)
static bool InstallBlockCmdFrame(PCB_BASE_FRAME *parent, const wxString &title)
MODULE * Next() const
Definition: class_module.h:123
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:175
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
BLOCK_COMMAND_T
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
#define GR_KB_CTRL
BOARD * GetBoard() const
Classes to handle copper zones.
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
void ClearBlockCommand()
Definition: base_screen.h:501
wxPoint MoveVector
Definition: edtxtmod.cpp:54
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
void Block_Flip()
Function Block_Flip Flip items within the selected block.
virtual void UnLink()
Function UnLink detaches this object from its owner.
int GetState(int type) const
Definition: base_struct.h:240
virtual void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset)=0
Function Draw BOARD_ITEMs have their own color information.
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
virtual EDA_DRAW_FRAME * GetParent() const =0
void SetState(BLOCK_STATE_T aState)
DIMENSION class definition.
Struct that will be set with the result of the user choices in the dialog.
class MODULE, a footprint
Definition: typeinfo.h:89
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
void Block_Delete()
Function Block_Delete deletes all items within the selected block.
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
void DrawAndSizingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function DrawAndSizingBlockOutlines redraws the outlines of the block which shows the search area for...
virtual bool HandleBlockEnd(wxDC *DC) override
Function HandleBlockEnd() Handle the "end" of a block command, i.e.
void Block_SelectItems()
Function Block_SelectItems Uses GetScreen()->m_BlockLocate select items within the selected block...
uint32_t EDA_KEY
Definition: common.h:73
static void drawPickedItems(EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint aOffset)
Function drawPickedItems draws items currently selected in a block.
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1025
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.
bool RemovePicker(unsigned aIdx)
Function RemovePicker removes one entry (one picker) from the list of picked items.
wxPoint Centre() const
Definition: eda_rect.h:60
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
#define GR_KB_SHIFT
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:202
#define BLOCK_OUTLINE_COLOR
void SetItem(EDA_ITEM *aItem)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
void Compile_Ratsnest(wxDC *aDC, bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
Definition: ratsnest.cpp:53
unsigned GetCount() const
Function GetCount.
int m_rotationAngle
User defined rotation angle (in tenths of a degree).
wxPoint GetLastCursorPosition() const
void Normalize()
Function Normalize ensures that the height ant width are positive.
virtual void Flip(const wxPoint &aCentre)
Function Flip Flip this object, i.e.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
This file is part of the common library.
virtual void HandleBlockPlace(wxDC *DC) override
Function HandleBlockPlace() Called after HandleBlockEnd, when a block command needs to be executed af...
#define GR_KB_SHIFTCTRL
void Block_Move()
Function Block_Move move all items within the selected block.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:996
bool SetPickedItemStatus(UNDO_REDO_T aStatus, unsigned aIdx)
Function SetPickedItemStatus sets the type of undo/redo operation for a given picked item...
Class to handle a graphic segment.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
BLOCK_STATE_T GetState() const
DLIST< MODULE > m_Modules
Definition: class_board.h:248
int GetToolId() const
Definition: draw_frame.h:519
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if a point is near an outline edge or a corner of this zone.
Definition: class_zone.cpp:652
void SetIgnoreMouseEvents(bool aIgnore)
void Block_Rotate()
Function Block_Rotate Rotate all items within the selected block.
int GetWidth() const
Definition: eda_rect.h:117
bool IsModuleLayerVisible(PCB_LAYER_ID aLayer)
Function IsModuleLayerVisible expects either of the two layers on which a module can reside...
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PICKED_ITEMS_LIST & GetItems()
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
virtual void Window_Zoom(EDA_RECT &Rect)
BLOCK_COMMAND_T GetCommand() const
PCB_TARGET class definition.
void Block_Duplicate(bool aIncrement)
Function Block_Duplicate Duplicate all items within the selected block.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual int BlockCommand(EDA_KEY aKey) override
Function BlockCommand Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when block command is started by dragging the mouse.
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:253
Module description (excepted pads)
virtual void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
class SEGZONE, a segment used to fill a zone area (segment on a
Definition: typeinfo.h:97
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:296
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void Remove(BOARD_ITEM *aBoardItem) override
Removes an item from the container.
virtual void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:255
wxPoint GetMoveVector() const
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:457
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:240
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113