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
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  {
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 
357  layerMask.set();
358 
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:
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  {
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  item->UnLink();
570  itemsList->RemovePicker( ii );
571  ii--;
572  item->DeleteStructure();
573  break;
574 
575  default:
576  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Delete( ) error: unexpected type" ) );
577  break;
578  }
579  }
580 
581  SaveCopyInUndoList( *itemsList, UR_DELETED );
582 
583  Compile_Ratsnest( NULL, true );
584  m_canvas->Refresh( true );
585 }
586 
587 
589 {
590  // 6.0 TODO: This is the legacy toolset version
591 
592  wxPoint centre; // rotation cent-re for the rotation transform
593  int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg.
594 
595  centre = GetScreen()->m_BlockLocate.Centre();
596 
597  OnModify();
598 
600  itemsList->m_Status = UR_CHANGED;
601 
602  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
603  {
604  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
605  wxASSERT( item );
606  itemsList->SetPickedItemStatus( UR_CHANGED, ii );
607 
608  switch( item->Type() )
609  {
610  case PCB_MODULE_T:
611  ( (MODULE*) item )->ClearFlags();
612  m_Pcb->m_Status_Pcb = 0;
613  break;
614 
615  // Move and rotate the track segments
616  case PCB_TRACE_T: // a track segment (segment on a copper layer)
617  case PCB_VIA_T: // a via (like track segment on a copper layer)
618  m_Pcb->m_Status_Pcb = 0;
619  break;
620 
621  case PCB_ZONE_AREA_T:
622  case PCB_LINE_T:
623  case PCB_TEXT_T:
624  case PCB_TARGET_T:
625  case PCB_DIMENSION_T:
626  break;
627 
628  default:
629  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Rotate( ) error: unexpected type" ) );
630  break;
631  }
632  }
633 
634  // Save all the block items in there current state before applying the rotation.
635  SaveCopyInUndoList( *itemsList, UR_CHANGED, centre );
636 
637  // Now perform the rotation.
638  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
639  {
640  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
641  wxASSERT( item );
642  item->Rotate( centre, rotAngle );
643  GetBoard()->GetConnectivity()->Update( item );
644  }
645 
646  Compile_Ratsnest( NULL, true );
647  m_canvas->Refresh( true );
648 }
649 
650 
652 {
653 #define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
654  wxPoint center; // Position of the axis for inversion of all elements
655 
656  OnModify();
657 
659  itemsList->m_Status = UR_FLIPPED;
660 
661  center = GetScreen()->m_BlockLocate.Centre();
662 
663  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
664  {
665  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
666  wxASSERT( item );
667  itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
668  item->Flip( center );
669  GetBoard()->GetConnectivity()->Update( item );
670 
671  // If a connected item is flipped, the ratsnest is no more OK
672  switch( item->Type() )
673  {
674  case PCB_MODULE_T:
675  item->ClearFlags();
676  m_Pcb->m_Status_Pcb = 0;
677  break;
678 
679  case PCB_TRACE_T:
680  case PCB_VIA_T:
681  m_Pcb->m_Status_Pcb = 0;
682  break;
683 
684  case PCB_ZONE_AREA_T:
685  case PCB_LINE_T:
686  case PCB_TEXT_T:
687  case PCB_TARGET_T:
688  case PCB_DIMENSION_T:
689  break;
690 
691  default:
692  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
693  break;
694  }
695  }
696 
697  SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
698  Compile_Ratsnest( NULL, true );
699  m_canvas->Refresh( true );
700 }
701 
702 
704 {
705  OnModify();
706 
708 
710  itemsList->m_Status = UR_MOVED;
711 
712  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
713  {
714  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
715  itemsList->SetPickedItemStatus( UR_MOVED, ii );
716  item->Move( MoveVector );
717  GetBoard()->GetConnectivity()->Update( item );
718  item->ClearFlags( IS_MOVED );
719 
720  switch( item->Type() )
721  {
722  case PCB_MODULE_T:
723  m_Pcb->m_Status_Pcb = 0;
724  item->ClearFlags();
725  break;
726 
727  // Move track segments
728  case PCB_TRACE_T: // a track segment (segment on a copper layer)
729  case PCB_VIA_T: // a via (like a track segment on a copper layer)
730  m_Pcb->m_Status_Pcb = 0;
731  break;
732 
733  case PCB_ZONE_AREA_T:
734  case PCB_LINE_T:
735  case PCB_TEXT_T:
736  case PCB_TARGET_T:
737  case PCB_DIMENSION_T:
738  break;
739 
740  default:
741  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Move( ) error: unexpected type" ) );
742  break;
743  }
744  }
745 
746  SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
747 
748  Compile_Ratsnest( NULL, true );
749  m_canvas->Refresh( true );
750 }
751 
752 
753 void PCB_EDIT_FRAME::Block_Duplicate( bool aIncrement )
754 {
756 
757  OnModify();
758 
760 
761  PICKED_ITEMS_LIST newList;
762  newList.m_Status = UR_NEW;
763 
764  ITEM_PICKER picker( NULL, UR_NEW );
765  BOARD_ITEM* newitem;
766 
767  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
768  {
769  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
770 
771  newitem = (BOARD_ITEM*)item->Clone();
772 
773  if( item->Type() == PCB_MODULE_T )
774  m_Pcb->m_Status_Pcb = 0;
775 
776  m_Pcb->Add( newitem );
777 
778  if( newitem )
779  {
780  newitem->Move( MoveVector );
781  picker.SetItem ( newitem );
782  newList.PushItem( picker );
783  }
784  }
785 
786  if( newList.GetCount() )
787  SaveCopyInUndoList( newList, UR_NEW );
788 
789  Compile_Ratsnest( NULL, true );
790  m_canvas->Refresh( true );
791 }
virtual BASE_SCREEN * GetScreen()=0
#define GR_KB_ALT
BLOCK_COMMAND_T GetCommand() const
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:59
#define MOUSE_MIDDLE
wxPoint g_Offset_Module
Definition: pcbnew.cpp:76
BLOCK_STATE_T GetState() const
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.
int GetCurrentCursor() const
Function GetCurrentCursor.
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,...
Class BOARD to handle a board.
void SetMoveVector(const wxPoint &aMoveVector)
static bool InstallBlockCmdFrame(PCB_BASE_FRAME *parent, const wxString &title)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:185
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
int GetWidth() const
Definition: eda_rect.h:117
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
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
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...
wxPoint GetMoveVector() const
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.
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.
wxPoint GetLastCursorPosition() const
unsigned GetCount() const
Function GetCount.
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
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:
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:981
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
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if a point is near an outline edge or a corner of this zone.
Definition: class_zone.cpp:653
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:292
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
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:71
static void drawPickedItems(EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint aOffset)
Function drawPickedItems draws items currently selected in a block.
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.
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:399
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:198
#define BLOCK_OUTLINE_COLOR
void SetItem(EDA_ITEM *aItem)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:99
void Compile_Ratsnest(wxDC *aDC, bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
Definition: ratsnest.cpp:53
int m_rotationAngle
User defined rotation angle (in tenths of a degree).
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:128
This file is part of the common library.
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:453
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:97
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.
DLIST< MODULE > m_Modules
Definition: class_board.h:248
void SetIgnoreMouseEvents(bool aIgnore)
void Block_Rotate()
Function Block_Rotate Rotate all items within the selected block.
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.
wxPoint Centre() const
Definition: eda_rect.h:60
PICKED_ITEMS_LIST & GetItems()
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
virtual void Window_Zoom(EDA_RECT &Rect)
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....
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:251
Module description (excepted pads)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:952
BOARD * GetBoard() const
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
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:244
int GetState(int type) const
Definition: base_struct.h:243
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)
int GetToolId() const
Definition: draw_frame.h:524
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:253
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
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