KiCad PCB EDA Suite
pagelayout_editor/block.cpp File Reference

Block operations. More...

#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <pl_editor_frame.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>

Go to the source code of this file.

Functions

static void DrawMovingBlockOutlines (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool erase)
 
static void DrawMovingItems (EDA_DRAW_PANEL *aPanel, wxDC *aDC)
 
static void ConfigureDrawList (WS_DRAW_ITEM_LIST *aDrawList, PL_EDITOR_SCREEN *aScreen, PL_EDITOR_FRAME *aFrame)
 

Detailed Description

Block operations.

Definition in file pagelayout_editor/block.cpp.

Function Documentation

static void ConfigureDrawList ( WS_DRAW_ITEM_LIST aDrawList,
PL_EDITOR_SCREEN aScreen,
PL_EDITOR_FRAME aFrame 
)
static

Definition at line 47 of file pagelayout_editor/block.cpp.

References WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), PL_EDITOR_FRAME::GetCurrFileName(), PL_EDITOR_FRAME::GetPageSettings(), EDA_DRAW_FRAME::GetScreenDesc(), PL_EDITOR_FRAME::GetTitleBlock(), IU_PER_MILS, BASE_SCREEN::m_NumberOfScreens, BASE_SCREEN::m_ScreenNumber, RED, WS_DRAW_ITEM_LIST::SetFileName(), WS_DRAW_ITEM_LIST::SetMilsToIUfactor(), WS_DRAW_ITEM_LIST::SetPenSize(), WS_DRAW_ITEM_LIST::SetSheetCount(), WS_DRAW_ITEM_LIST::SetSheetName(), and WS_DRAW_ITEM_LIST::SetSheetNumber().

Referenced by PL_EDITOR_FRAME::Block_Move(), and DrawMovingItems().

49 {
50  aDrawList->SetPenSize( 0 );
51  aDrawList->SetMilsToIUfactor( IU_PER_MILS );
52  aDrawList->SetSheetNumber( aScreen->m_ScreenNumber );
53  aDrawList->SetSheetCount( aScreen->m_NumberOfScreens );
54  aDrawList->SetFileName( aFrame->GetCurrFileName() );
55  aDrawList->SetSheetName( aFrame->GetScreenDesc() );
56  aDrawList->BuildWorkSheetGraphicList( aFrame->GetPageSettings(),
57  aFrame->GetTitleBlock(), RED, RED );
58 }
int m_ScreenNumber
Definition: base_screen.h:216
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetPenSize(int aPenSize)
Function SetPenSize Set the default pen size to draw/plot lines and texts.
const PAGE_INFO & GetPageSettings() const override
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock, COLOR4D aColor, COLOR4D aAltColor)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
virtual wxString GetScreenDesc() const
void SetSheetCount(int aSheetCount)
Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units ( mils) to draw/plot units...
const TITLE_BLOCK & GetTitleBlock() const override
Definition: colors.h:60
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
#define IU_PER_MILS
Definition: plotter.cpp:134
int m_NumberOfScreens
Definition: base_screen.h:217
const wxString & GetCurrFileName() const
static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  erase 
)
static

Definition at line 185 of file pagelayout_editor/block.cpp.

References DrawMovingItems(), g_XorMode, EDA_DRAW_FRAME::GetCrossHairPosition(), EDA_DRAW_PANEL::GetParent(), and EDA_DRAW_PANEL::GetScreen().

Referenced by PL_EDITOR_FRAME::HandleBlockEnd().

187 {
188  auto screen = aPanel->GetScreen();
189  auto block = &screen->m_BlockLocate;
190 
191  if( aErase )
192  {
193  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
194  DrawMovingItems( aPanel, aDC );
195  }
196 
197  block->SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
198  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
199  DrawMovingItems( aPanel, aDC );
200 }
virtual BASE_SCREEN * GetScreen()=0
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
static void DrawMovingItems(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
virtual EDA_DRAW_FRAME * GetParent() const =0
Definition: solve.cpp:178
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
static void DrawMovingItems ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)
static

Definition at line 160 of file pagelayout_editor/block.cpp.

References ConfigureDrawList(), g_GhostColor, g_XorMode, WS_DRAW_ITEM_LIST::GetAllItems(), EDA_DRAW_PANEL::GetParent(), and EDA_DRAW_PANEL::GetScreen().

Referenced by DrawMovingBlockOutlines().

161 {
162  auto screen = static_cast<PL_EDITOR_SCREEN*>( aPanel->GetScreen() );
163  auto frame = static_cast<PL_EDITOR_FRAME*>( aPanel->GetParent() );
164 
165  // Get items
166  std::vector<WS_DRAW_ITEM_BASE*> items;
167  WS_DRAW_ITEM_LIST drawList;
168  ConfigureDrawList( &drawList, screen, frame );
169  drawList.GetAllItems( &items );
170 
171  // Draw items
172  for( auto item: items )
173  {
174  if( item->HitTest( screen->m_BlockLocate ) )
175  {
176  item->DrawWsItem( NULL, aDC, screen->m_BlockLocate.GetMoveVector(),
178  }
179  }
180 }
virtual BASE_SCREEN * GetScreen()=0
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
Class PL_EDITOR_FRAME is the main window used in the page layout editor.
void GetAllItems(std::vector< WS_DRAW_ITEM_BASE * > *aList)
virtual EDA_DRAW_FRAME * GetParent() const =0
COLOR4D g_GhostColor
Global variables definitions.
Definition: common.cpp:57
static void ConfigureDrawList(WS_DRAW_ITEM_LIST *aDrawList, PL_EDITOR_SCREEN *aScreen, PL_EDITOR_FRAME *aFrame)