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_mire.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 #define BLOCK_OUTLINE_COLOR YELLOW
54 
62 static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset );
63 
72 static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
73  bool aErase );
74 
75 
77 
78 
79 static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title )
80 {
81  wxPoint oldpos = parent->GetCrossHairPosition();
82 
83  parent->GetCanvas()->SetIgnoreMouseEvents( true );
84  DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, blockOpts, true, title );
85 
86  int cmd = dlg->ShowModal();
87  dlg->Destroy();
88 
89  parent->SetCrossHairPosition( oldpos );
90  parent->GetCanvas()->MoveCursorToCrossHair();
91  parent->GetCanvas()->SetIgnoreMouseEvents( false );
92 
93  return cmd == wxID_OK;
94 }
95 
96 
98 {
99  int cmd = 0;
100 
101  switch( aKey )
102  {
103  default:
104  cmd = aKey & 0xFF;
105  break;
106 
107  case 0:
108  cmd = BLOCK_MOVE;
109  break;
110 
111  case GR_KB_SHIFT:
112  cmd = BLOCK_COPY;
113  break;
114 
115  case GR_KB_CTRL:
116  cmd = BLOCK_ROTATE;
117  break;
118 
119  case GR_KB_SHIFTCTRL:
120  cmd = BLOCK_DELETE;
121  break;
122 
123  case GR_KB_ALT:
124  cmd = BLOCK_FLIP;
125  break;
126 
127  case MOUSE_MIDDLE:
128  cmd = BLOCK_ZOOM;
129  break;
130  }
131 
132  return cmd;
133 }
134 
135 
137 {
139 
140  if( !m_canvas->IsMouseCaptured() )
141  {
142  DisplayError( this, wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
143  }
144 
146 
147  const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
148 
149  switch( command )
150  {
151  case BLOCK_IDLE:
152  break;
153 
154  case BLOCK_DRAG: // Drag
155  case BLOCK_MOVE: // Move
156  case BLOCK_PRESELECT_MOVE: // Move with preselection list
157  if( m_canvas->IsMouseCaptured() )
158  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
159 
160  Block_Move();
162  break;
163 
164  case BLOCK_COPY: // Copy
166  if( m_canvas->IsMouseCaptured() )
167  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
168 
171  break;
172 
173  case BLOCK_PASTE:
174  break;
175 
176  case BLOCK_ZOOM: // Handled by HandleBlockEnd()
177  default:
178  break;
179  }
180 
181  OnModify();
182 
183  m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
185 
186  if( GetScreen()->m_BlockLocate.GetCount() )
187  {
188  DisplayError( this, wxT( "Error in HandleBlockPLace some items left in list" ) );
190  }
191 }
192 
193 
195 {
196  bool nextcmd = false; // Will be set to true if a block place is needed
197  bool cancelCmd = false;
198  // If coming here after cancel block, clean up and exit
199  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
200  {
202  false );
204  return false;
205  }
206 
207  // Show dialog if there are no selected items and we're not zooming
208  if( !GetScreen()->m_BlockLocate.GetCount()
210  {
211  if( InstallBlockCmdFrame( this, _( "Block Operation" ) ) == false )
212  {
213  cancelCmd = true;
214 
215  // undraw block outline
216  if( DC )
217  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
218  }
219  else
220  {
221  DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
223 
224  // Exit if no items found
225  if( !GetScreen()->m_BlockLocate.GetCount() )
226  cancelCmd = true;
227  }
228  }
229 
230  if( !cancelCmd && m_canvas->IsMouseCaptured() )
231  {
232  switch( GetScreen()->m_BlockLocate.GetCommand() )
233  {
234  case BLOCK_IDLE:
235  DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
236  break;
237 
238  case BLOCK_DRAG: // Drag (not used, for future enhancements)
239  case BLOCK_MOVE: // Move
240  case BLOCK_COPY: // Copy
241  case BLOCK_COPY_AND_INCREMENT: // Copy and increment relevant references
242  case BLOCK_PRESELECT_MOVE: // Move with preselection list
244  nextcmd = true;
246  if( DC )
247  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
248  break;
249 
250  case BLOCK_DELETE: // Delete
253  Block_Delete();
254  break;
255 
256  case BLOCK_ROTATE: // Rotation
259  Block_Rotate();
260  break;
261 
262  case BLOCK_FLIP: // Flip
265  Block_Flip();
266  break;
267 
268  case BLOCK_SAVE: // Save (not used, for future enhancements)
270 
271  if( GetScreen()->m_BlockLocate.GetCount() )
272  {
273  // @todo (if useful) Save_Block( );
274  }
275  break;
276 
277  case BLOCK_PASTE:
278  break;
279 
280  case BLOCK_ZOOM: // Window Zoom
281 
282  // Turn off the redraw block routine now so it is not displayed
283  // with one corner at the new center of the screen
285  Window_Zoom( GetScreen()->m_BlockLocate );
286  break;
287 
288  default:
289  break;
290  }
291  }
292 
293  if( ! nextcmd )
294  {
298  false );
299  }
300 
301  return nextcmd;
302 }
303 
304 
306 {
307  LSET layerMask;
308  bool selectOnlyComplete = GetScreen()->m_BlockLocate.GetWidth() > 0 ;
309 
311 
313  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
314 
315  // Add modules
316  if( blockOpts.includeModules )
317  {
318  for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
319  {
320  PCB_LAYER_ID layer = module->GetLayer();
321 
322  if( module->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete )
323  && ( !module->IsLocked() || blockOpts.includeLockedModules ) )
324  {
325  if( blockOpts.includeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) )
326  {
327  picker.SetItem ( module );
328  itemsList->PushItem( picker );
329  }
330  }
331  }
332  }
333 
334  // Add tracks and vias
335  if( blockOpts.includeTracks )
336  {
337  for( TRACK* track = m_Pcb->m_Track; track != NULL; track = track->Next() )
338  {
339  if( track->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
340  {
341  if( blockOpts.includeItemsOnInvisibleLayers
342  || m_Pcb->IsLayerVisible( track->GetLayer() ) )
343  {
344  picker.SetItem( track );
345  itemsList->PushItem( picker );
346  }
347  }
348  }
349  }
350 
351  // Add graphic items
352  layerMask = LSET( Edge_Cuts );
353 
354  if( blockOpts.includeItemsOnTechLayers )
355  layerMask.set();
356 
357  if( !blockOpts.includeBoardOutlineLayer )
358  layerMask.set( Edge_Cuts, false );
359 
360  for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
361  {
362  if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && ! blockOpts.includeItemsOnInvisibleLayers)
363  continue;
364 
365  bool select_me = false;
366 
367  switch( PtStruct->Type() )
368  {
369  case PCB_LINE_T:
370  if( !layerMask[PtStruct->GetLayer()] )
371  break;
372 
373  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
374  break;
375 
376  select_me = true; // This item is in bloc: select it
377  break;
378 
379  case PCB_TEXT_T:
380  if( !blockOpts.includePcbTexts )
381  break;
382 
383  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
384  break;
385 
386  select_me = true; // This item is in bloc: select it
387  break;
388 
389  case PCB_TARGET_T:
390  if( !layerMask[PtStruct->GetLayer()] )
391  break;
392 
393  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
394  break;
395 
396  select_me = true; // This item is in bloc: select it
397  break;
398 
399  case PCB_DIMENSION_T:
400  if( !layerMask[PtStruct->GetLayer()] )
401  break;
402 
403  if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
404  break;
405 
406  select_me = true; // This item is in bloc: select it
407  break;
408 
409  default:
410  break;
411  }
412 
413  if( select_me )
414  {
415  picker.SetItem ( PtStruct );
416  itemsList->PushItem( picker );
417  }
418  }
419 
420  // Add zones
421  if( blockOpts.includeZones )
422  {
423  for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
424  {
425  ZONE_CONTAINER* area = m_Pcb->GetArea( ii );
426 
427  if( area->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
428  {
429  if( blockOpts.includeItemsOnInvisibleLayers
430  || m_Pcb->IsLayerVisible( area->GetLayer() ) )
431  {
432  BOARD_ITEM* zone_c = (BOARD_ITEM*) area;
433  picker.SetItem ( zone_c );
434  itemsList->PushItem( picker );
435  }
436  }
437  }
438  }
439 }
440 
441 
442 static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset )
443 {
444  PICKED_ITEMS_LIST* itemsList = &aPanel->GetScreen()->m_BlockLocate.GetItems();
445  PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
446 
447  g_Offset_Module = -aOffset;
448 
449  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
450  {
451  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
452 
453  switch( item->Type() )
454  {
455  case PCB_MODULE_T:
457  ((MODULE*) item)->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
458  break;
459 
460  case PCB_LINE_T:
461  case PCB_TEXT_T:
462  case PCB_TRACE_T:
463  case PCB_VIA_T:
464  case PCB_TARGET_T:
465  case PCB_DIMENSION_T: // Currently markers are not affected by block commands
466  case PCB_MARKER_T:
467  item->Draw( aPanel, aDC, GR_XOR, aOffset );
468  break;
469 
470  case PCB_ZONE_AREA_T:
471  item->Draw( aPanel, aDC, GR_XOR, aOffset );
472  ((ZONE_CONTAINER*) item)->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
473  break;
474 
475  default:
476  break;
477  }
478  }
479 
480  g_Offset_Module = wxPoint( 0, 0 );
481 }
482 
483 
484 static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
485  bool aErase )
486 {
487  BASE_SCREEN* screen = aPanel->GetScreen();
488 
489  // do not show local module rastnest in block move, it is not usable.
490  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions();
491  bool showRats = displ_opts->m_Show_Module_Ratsnest;
492  displ_opts->m_Show_Module_Ratsnest = false;
493 
494  if( aErase )
495  {
496  if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
497  {
498  screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
500 
501  if( blockOpts.drawItems )
502  drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
503  }
504  }
505 
506 
507  if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP )
508  {
511  }
512 
513  if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
514  {
515  screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
517 
518  if( blockOpts.drawItems )
519  drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
520  }
521 
522  displ_opts->m_Show_Module_Ratsnest = showRats;
523 }
524 
525 
527 {
528  OnModify();
529  SetCurItem( NULL );
530 
532  itemsList->m_Status = UR_DELETED;
533 
534  // unlink items and clear flags
535  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
536  {
537  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
538  itemsList->SetPickedItemStatus( UR_DELETED, ii );
539 
540  switch( item->Type() )
541  {
542  case PCB_MODULE_T:
543  {
544  MODULE* module = (MODULE*) item;
545  module->ClearFlags();
546  module->UnLink();
547  m_Pcb->m_Status_Pcb = 0;
548  }
549  break;
550 
551  case PCB_ZONE_AREA_T: // a zone area
552  m_Pcb->Remove( item );
553  break;
554 
555  case PCB_LINE_T: // a segment not on copper layers
556  case PCB_TEXT_T: // a text on a layer
557  case PCB_TRACE_T: // a track segment (segment on a copper layer)
558  case PCB_VIA_T: // a via (like track segment on a copper layer)
559  case PCB_DIMENSION_T: // a dimension (graphic item)
560  case PCB_TARGET_T: // a target (graphic item)
561  item->UnLink();
562  break;
563 
564  // These items are deleted, but not put in undo list
565  case PCB_MARKER_T: // a marker used to show something
566  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
567  item->UnLink();
568  itemsList->RemovePicker( ii );
569  ii--;
570  item->DeleteStructure();
571  break;
572 
573  default:
574  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Delete( ) error: unexpected type" ) );
575  break;
576  }
577  }
578 
579  SaveCopyInUndoList( *itemsList, UR_DELETED );
580 
581  Compile_Ratsnest( NULL, true );
582  m_canvas->Refresh( true );
583 }
584 
585 
587 {
588  wxPoint centre; // rotation cent-re for the rotation transform
589  int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg.
590 
591  centre = GetScreen()->m_BlockLocate.Centre();
592 
593  OnModify();
594 
596  itemsList->m_Status = UR_CHANGED;
597 
598  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
599  {
600  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
601  wxASSERT( item );
602  itemsList->SetPickedItemStatus( UR_CHANGED, ii );
603 
604  switch( item->Type() )
605  {
606  case PCB_MODULE_T:
607  ( (MODULE*) item )->ClearFlags();
608  m_Pcb->m_Status_Pcb = 0;
609  break;
610 
611  // Move and rotate the track segments
612  case PCB_TRACE_T: // a track segment (segment on a copper layer)
613  case PCB_VIA_T: // a via (like track segment on a copper layer)
614  m_Pcb->m_Status_Pcb = 0;
615  break;
616 
617  case PCB_ZONE_AREA_T:
618  case PCB_LINE_T:
619  case PCB_TEXT_T:
620  case PCB_TARGET_T:
621  case PCB_DIMENSION_T:
622  break;
623 
624  // This item is not put in undo list
625  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
626  itemsList->RemovePicker( ii );
627  ii--;
628  break;
629 
630  default:
631  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Rotate( ) error: unexpected type" ) );
632  break;
633  }
634  }
635 
636  // Save all the block items in there current state before applying the rotation.
637  SaveCopyInUndoList( *itemsList, UR_CHANGED, centre );
638 
639  // Now perform the rotation.
640  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
641  {
642  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
643  wxASSERT( item );
644  item->Rotate( centre, rotAngle );
645  }
646 
647  Compile_Ratsnest( NULL, true );
648  m_canvas->Refresh( true );
649 }
650 
651 
653 {
654 #define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
655  wxPoint center; // Position of the axis for inversion of all elements
656 
657  OnModify();
658 
660  itemsList->m_Status = UR_FLIPPED;
661 
662  center = GetScreen()->m_BlockLocate.Centre();
663 
664  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
665  {
666  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
667  wxASSERT( item );
668  itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
669  item->Flip( center );
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  // This item is not put in undo list
692  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
693  itemsList->RemovePicker( ii );
694  ii--;
695  break;
696 
697 
698  default:
699  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
700  break;
701  }
702  }
703 
704  SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
705  Compile_Ratsnest( NULL, true );
706  m_canvas->Refresh( true );
707 }
708 
709 
711 {
712  OnModify();
713 
715 
717  itemsList->m_Status = UR_MOVED;
718 
719  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
720  {
721  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
722  itemsList->SetPickedItemStatus( UR_MOVED, ii );
723  item->Move( MoveVector );
724  item->ClearFlags( IS_MOVED );
725 
726  switch( item->Type() )
727  {
728  case PCB_MODULE_T:
729  m_Pcb->m_Status_Pcb = 0;
730  item->ClearFlags();
731  break;
732 
733  // Move track segments
734  case PCB_TRACE_T: // a track segment (segment on a copper layer)
735  case PCB_VIA_T: // a via (like a track segment on a copper layer)
736  m_Pcb->m_Status_Pcb = 0;
737  break;
738 
739  case PCB_ZONE_AREA_T:
740  case PCB_LINE_T:
741  case PCB_TEXT_T:
742  case PCB_TARGET_T:
743  case PCB_DIMENSION_T:
744  break;
745 
746  // This item is not put in undo list
747  case PCB_ZONE_T: // SEG_ZONE items are now deprecated
748  itemsList->RemovePicker( ii );
749  ii--;
750  break;
751 
752  default:
753  wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Move( ) error: unexpected type" ) );
754  break;
755  }
756  }
757 
758  SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
759 
760  Compile_Ratsnest( NULL, true );
761  m_canvas->Refresh( true );
762 }
763 
764 
765 void PCB_EDIT_FRAME::Block_Duplicate( bool aIncrement )
766 {
768 
769  OnModify();
770 
772 
773  PICKED_ITEMS_LIST newList;
774  newList.m_Status = UR_NEW;
775 
776  ITEM_PICKER picker( NULL, UR_NEW );
777  BOARD_ITEM* newitem;
778 
779  for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
780  {
781  BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
782 
783  newitem = (BOARD_ITEM*)item->Clone();
784 
785  if( item->Type() == PCB_MODULE_T )
786  m_Pcb->m_Status_Pcb = 0;
787 
788  m_Pcb->Add( newitem );
789 
790  if( newitem )
791  {
792  newitem->Move( MoveVector );
793  picker.SetItem ( newitem );
794  newList.PushItem( picker );
795  }
796  }
797 
798  if( newList.GetCount() )
799  SaveCopyInUndoList( newList, UR_NEW );
800 
801  Compile_Ratsnest( NULL, true );
802  m_canvas->Refresh( true );
803 }
wxPoint MoveVector
Definition: edtxtmod.cpp:54
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:996
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
wxPoint g_Offset_Module
Definition: pcbnew.cpp:83
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.
PCB_TARGET class definition.
TEXTE_PCB class definition.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
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:299
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 return the current cursor shape, depending on the current selected tool...
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:100
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
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:104
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:348
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:237
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:107
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
BOARD_ITEM * Next() const
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:101
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
>
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...
DLIST< BOARD_ITEM > m_Drawings
Definition: class_board.h:242
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:109
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.
bool IsModuleLayerVisible(PCB_LAYER_ID layer)
Function IsModuleLayerVisible expects either of the two layers on which a module can reside...
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:172
#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:112
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:113
void Compile_Ratsnest(wxDC *aDC, bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
Definition: ratsnest.cpp:165
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
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:92
This file is part of the common library.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:111
TRACK * Next() const
Definition: class_track.h:98
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
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:243
int GetToolId() const
Definition: draw_frame.h:406
#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:483
void SetIgnoreMouseEvents(bool aIgnore)
void Block_Rotate()
Function Block_Rotate Rotate all items within the selected block.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
int GetWidth() const
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:254
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
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:108
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:244
Module description (excepted pads)
void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_panel.cpp:182
bool m_Show_Module_Ratsnest
Definition: pcbstruct.h:87
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:103
#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:69
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void Remove(BOARD_ITEM *aBoardItem) override
>
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:440
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:112