KiCad PCB EDA Suite
pcbnew/block.cpp File Reference
#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <block_commande.h>
#include <wxPcbStruct.h>
#include <trigo.h>
#include <class_board.h>
#include <class_track.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_mire.h>
#include <class_module.h>
#include <class_dimension.h>
#include <class_zone.h>
#include <dialog_block_options.h>
#include <pcbnew.h>
#include <protos.h>
#include <connectivity.h>

Go to the source code of this file.

Macros

#define BLOCK_OUTLINE_COLOR   YELLOW
 
#define INVERT(pos)   (pos) = center.y - ( (pos) - center.y )
 

Functions

static void drawPickedItems (EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint aOffset)
 Function drawPickedItems draws items currently selected in a block. More...
 
static void drawMovingBlock (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 Function drawMovingBlock handles drawing of a moving block. More...
 
static bool InstallBlockCmdFrame (PCB_BASE_FRAME *parent, const wxString &title)
 

Variables

static DIALOG_BLOCK_OPTIONS::OPTIONS blockOpts
 

Macro Definition Documentation

#define BLOCK_OUTLINE_COLOR   YELLOW

Definition at line 55 of file pcbnew/block.cpp.

Referenced by drawMovingBlock().

#define INVERT (   pos)    (pos) = center.y - ( (pos) - center.y )

Function Documentation

static void drawMovingBlock ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Function drawMovingBlock handles drawing of a moving block.

Parameters
aPanel= Current draw panel
aDC= Current device context
aPositionThe cursor position in logical (drawing) units.
aErase= Erase block at current position

Definition at line 486 of file pcbnew/block.cpp.

References BLOCK_OUTLINE_COLOR, BLOCK_SELECTOR::Draw(), DIALOG_BLOCK_OPTIONS::OPTIONS::drawItems, drawPickedItems(), EDA_DRAW_FRAME::GetCrossHairPosition(), EDA_DRAW_PANEL::GetDisplayOptions(), BLOCK_SELECTOR::GetLastCursorPosition(), BLOCK_SELECTOR::GetMoveVector(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), BLOCK_SELECTOR::GetState(), GR_XOR, BASE_SCREEN::m_BlockLocate, DISPLAY_OPTIONS::m_Show_Module_Ratsnest, BLOCK_SELECTOR::SetMoveVector(), STATE_BLOCK_STOP, wxPoint::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::HandleBlockEnd().

488 {
489  BASE_SCREEN* screen = aPanel->GetScreen();
490 
491  // do not show local module rastnest in block move, it is not usable.
492  DISPLAY_OPTIONS* displ_opts = (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 }
static DIALOG_BLOCK_OPTIONS::OPTIONS blockOpts
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
void SetMoveVector(const wxPoint &aMoveVector)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
static void drawPickedItems(EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint aOffset)
Function drawPickedItems draws items currently selected in a block.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
#define BLOCK_OUTLINE_COLOR
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
wxPoint GetLastCursorPosition() const
BLOCK_STATE_T GetState() const
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
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
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
wxPoint GetMoveVector() const
static void drawPickedItems ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
wxPoint  aOffset 
)
static

Function drawPickedItems draws items currently selected in a block.

Parameters
aPanel= Current draw panel
aDC= Current device context
aOffset= Drawing offset

Definition at line 444 of file pcbnew/block.cpp.

References BOARD_ITEM::Draw(), g_Offset_Module, PCB_BASE_FRAME::GetBoard(), PICKED_ITEMS_LIST::GetCount(), BLOCK_SELECTOR::GetItems(), EDA_DRAW_PANEL::GetParent(), PICKED_ITEMS_LIST::GetPickedItem(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, BASE_SCREEN::m_BlockLocate, BOARD::m_Status_Pcb, PCB_DIMENSION_T, PCB_LINE_T, PCB_MARKER_T, PCB_MODULE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, RATSNEST_ITEM_LOCAL_OK, and EDA_ITEM::Type().

Referenced by drawMovingBlock().

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 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
BOARD * GetBoard() const
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.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
class MODULE, a footprint
Definition: typeinfo.h:101
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:113
unsigned GetCount() const
Function GetCount.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:111
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
PICKED_ITEMS_LIST & GetItems()
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:237
static bool InstallBlockCmdFrame ( PCB_BASE_FRAME parent,
const wxString &  title 
)
static

Definition at line 81 of file pcbnew/block.cpp.

References EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetCrossHairPosition(), EDA_DRAW_PANEL::MoveCursorToCrossHair(), EDA_DRAW_FRAME::SetCrossHairPosition(), and EDA_DRAW_PANEL::SetIgnoreMouseEvents().

Referenced by PCB_EDIT_FRAME::HandleBlockEnd().

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 }
static DIALOG_BLOCK_OPTIONS::OPTIONS blockOpts
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:348
void SetIgnoreMouseEvents(bool aIgnore)
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...

Variable Documentation

Definition at line 78 of file pcbnew/block.cpp.