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 <wxPcbStruct.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 
53 #include <connectivity_data.h>
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  if( blockOpts.includeTracks )
338  {
339  for( TRACK* track = m_Pcb->m_Track; track != NULL; track = track->Next() )
340  {
341  if( track->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
342  {
343  if( blockOpts.includeItemsOnInvisibleLayers
344  || m_Pcb->IsLayerVisible( track->GetLayer() ) )
345  {
346  picker.SetItem( track );
347  itemsList->PushItem( picker );
348  }
349  }
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_ZONE_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  wxPoint centre; // rotation cent-re for the rotation transform
592  int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg.
593 
594  centre = GetScreen()->m_BlockLocate.Centre();
595 
596  OnModify();
597 
599  itemsList->m_Status = UR_CHANGED;
600 
601  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
602  {
603  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
604  wxASSERT( item );
605  itemsList->SetPickedItemStatus( UR_CHANGED, ii );
606 
607  switch( item->Type() )
608  {
609  case PCB_MODULE_T:
610  ( (MODULE*) item )->ClearFlags();
611  m_Pcb->m_Status_Pcb = 0;
612  break;
613 
614  // Move and rotate the track segments
615  case PCB_TRACE_T: // a track segment (segment on a copper layer)
616  case PCB_VIA_T: // a via (like track segment on a copper layer)
617  m_Pcb->m_Status_Pcb = 0;
618  break;
619 
620  case PCB_ZONE_AREA_T:
621  case PCB_LINE_T:
622  case PCB_TEXT_T:
623  case PCB_TARGET_T:
624  case PCB_DIMENSION_T:
625  break;
626 
627  // This item is not put in undo list
628  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
629  itemsList->RemovePicker( ii );
630  ii--;
631  break;
632 
633  default:
634  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Rotate( ) error: unexpected type" ) );
635  break;
636  }
637  }
638 
639  // Save all the block items in there current state before applying the rotation.
640  SaveCopyInUndoList( *itemsList, UR_CHANGED, centre );
641 
642  // Now perform the rotation.
643  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
644  {
645  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
646  wxASSERT( item );
647  item->Rotate( centre, rotAngle );
648  GetBoard()->GetConnectivity()->Update( item );
649  }
650 
651  Compile_Ratsnest( NULL, true );
652  m_canvas->Refresh( true );
653 }
654 
655 
657 {
658 #define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
659  wxPoint center; // Position of the axis for inversion of all elements
660 
661  OnModify();
662 
664  itemsList->m_Status = UR_FLIPPED;
665 
666  center = GetScreen()->m_BlockLocate.Centre();
667 
668  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
669  {
670  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
671  wxASSERT( item );
672  itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
673  item->Flip( center );
674  GetBoard()->GetConnectivity()->Update( item );
675 
676  // If a connected item is flipped, the ratsnest is no more OK
677  switch( item->Type() )
678  {
679  case PCB_MODULE_T:
680  item->ClearFlags();
681  m_Pcb->m_Status_Pcb = 0;
682  break;
683 
684  case PCB_TRACE_T:
685  case PCB_VIA_T:
686  m_Pcb->m_Status_Pcb = 0;
687  break;
688 
689  case PCB_ZONE_AREA_T:
690  case PCB_LINE_T:
691  case PCB_TEXT_T:
692  case PCB_TARGET_T:
693  case PCB_DIMENSION_T:
694  break;
695 
696  // This item is not put in undo list
697  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
698  itemsList->RemovePicker( ii );
699  ii--;
700  break;
701 
702 
703  default:
704  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
705  break;
706  }
707  }
708 
709  SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
710  Compile_Ratsnest( NULL, true );
711  m_canvas->Refresh( true );
712 }
713 
714 
716 {
717  OnModify();
718 
720 
722  itemsList->m_Status = UR_MOVED;
723 
724  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
725  {
726  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
727  itemsList->SetPickedItemStatus( UR_MOVED, ii );
728  item->Move( MoveVector );
729  GetBoard()->GetConnectivity()->Update( item );
730  item->ClearFlags( IS_MOVED );
731 
732  switch( item->Type() )
733  {
734  case PCB_MODULE_T:
735  m_Pcb->m_Status_Pcb = 0;
736  item->ClearFlags();
737  break;
738 
739  // Move track segments
740  case PCB_TRACE_T: // a track segment (segment on a copper layer)
741  case PCB_VIA_T: // a via (like a track segment on a copper layer)
742  m_Pcb->m_Status_Pcb = 0;
743  break;
744 
745  case PCB_ZONE_AREA_T:
746  case PCB_LINE_T:
747  case PCB_TEXT_T:
748  case PCB_TARGET_T:
749  case PCB_DIMENSION_T:
750  break;
751 
752  // This item is not put in undo list
753  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
754  itemsList->RemovePicker( ii );
755  ii--;
756  break;
757 
758  default:
759  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Move( ) error: unexpected type" ) );
760  break;
761  }
762  }
763 
764  SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
765 
766  Compile_Ratsnest( NULL, true );
767  m_canvas->Refresh( true );
768 }
769 
770 
771 void PCB_EDIT_FRAME::Block_Duplicate( bool aIncrement )
772 {
774 
775  OnModify();
776 
778 
779  PICKED_ITEMS_LIST newList;
780  newList.m_Status = UR_NEW;
781 
782  ITEM_PICKER picker( NULL, UR_NEW );
783  BOARD_ITEM* newitem;
784 
785  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
786  {
787  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
788 
789  newitem = (BOARD_ITEM*)item->Clone();
790 
791  if( item->Type() == PCB_MODULE_T )
792  m_Pcb->m_Status_Pcb = 0;
793 
794  m_Pcb->Add( newitem );
795 
796  if( newitem )
797  {
798  newitem->Move( MoveVector );
799  picker.SetItem ( newitem );
800  newList.PushItem( picker );
801  }
802  }
803 
804  if( newList.GetCount() )
805  SaveCopyInUndoList( newList, UR_NEW );
806 
807  Compile_Ratsnest( NULL, true );
808  m_canvas->Refresh( true );
809 }
wxPoint MoveVector
Definition: edtxtmod.cpp:54
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:994
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
wxPoint g_Offset_Module
Definition: pcbnew.cpp:73
static DIALOG_BLOCK_OPTIONS::OPTIONS blockOpts
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
static void drawMovingBlock(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function drawMovingBlock handles drawing of a moving block.
TEXTE_PCB class definition.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
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...
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:331
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:120
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:178
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
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
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()
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...
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
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:264
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.
#define GR_KB_ALT
Definition: common.h:65
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...
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.
#define GR_KB_SHIFT
Definition: common.h:66
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
bool IsMouseCaptured() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
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:52
static void drawPickedItems(EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint aOffset)
Function drawPickedItems draws items currently selected in a block.
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:97
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
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:199
#define BLOCK_OUTLINE_COLOR
void SetItem(EDA_ITEM *aItem)
#define GR_KB_SHIFTCTRL
Definition: common.h:67
void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
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:56
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:93
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...
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
TRACK * Next() const
Definition: class_track.h:100
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:982
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:245
int GetToolId() const
Definition: draw_frame.h:465
#define MOUSE_MIDDLE
Definition: common.h:68
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:657
void SetIgnoreMouseEvents(bool aIgnore)
void Block_Rotate()
Function Block_Rotate Rotate all items within the selected block.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
int GetWidth() const
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
Function GetScreen returns 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:281
void Window_Zoom(EDA_RECT &Rect)
Compute the zoom factor and the new draw offset to draw the selected area (Rect) in full window scree...
Definition: zoom.cpp:103
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< TRACK > m_Track
Definition: class_board.h:246
Module description (excepted pads)
void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_panel.cpp:181
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
#define GR_KB_CTRL
Definition: common.h:64
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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:290
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.
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:251
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:451
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:237
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126