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>

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 53 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 484 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().

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 }
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 442 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().

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 }
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:240
static bool InstallBlockCmdFrame ( PCB_BASE_FRAME parent,
const wxString &  title 
)
static

Definition at line 79 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().

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 }
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 76 of file pcbnew/block.cpp.