KiCad PCB EDA Suite
target_edit.cpp File Reference

Functions to edit targets (class PCB_TARGET). More...

#include <fctsys.h>
#include <class_drawpanel.h>
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <gr_basic.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_pcb_target.h>
#include <pcbnew.h>
#include <dialog_target_properties_base.h>
#include <widgets/unit_binder.h>

Go to the source code of this file.

Classes

class  DIALOG_TARGET_PROPERTIES
 

Functions

static void AbortMoveAndEditTarget (EDA_DRAW_PANEL *Panel, wxDC *DC)
 
static void ShowTargetShapeWhileMovingMouse (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 

Variables

static int MireDefaultSize = Millimeter2iu( 5 )
 
static PCB_TARGET s_TargetCopy (NULL)
 

Detailed Description

Functions to edit targets (class PCB_TARGET).

Definition in file target_edit.cpp.

Function Documentation

static void AbortMoveAndEditTarget ( EDA_DRAW_PANEL Panel,
wxDC *  DC 
)
static

Definition at line 164 of file target_edit.cpp.

References EDA_ITEM::ClearFlags(), BOARD_ITEM::DeleteStructure(), PCB_TARGET::Draw(), BASE_SCREEN::GetCurItem(), EDA_ITEM::GetFlags(), EDA_DRAW_PANEL::GetParent(), PCB_TARGET::GetPosition(), EDA_DRAW_PANEL::GetScreen(), PCB_TARGET::GetShape(), PCB_TARGET::GetSize(), PCB_TARGET::GetWidth(), GR_OR, GR_XOR, IN_EDIT, IS_MOVED, EDA_ITEM::IsNew(), s_TargetCopy, EDA_DRAW_PANEL::SetMouseCapture(), PCB_TARGET::SetPosition(), PCB_TARGET::SetShape(), PCB_TARGET::SetSize(), and PCB_TARGET::SetWidth().

Referenced by PCB_EDIT_FRAME::BeginMoveTarget().

165 {
166  BASE_SCREEN* screen = Panel->GetScreen();
167  PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem();
168 
169  ( (PCB_EDIT_FRAME*) Panel->GetParent() )->SetCurItem( NULL );
170 
171  Panel->SetMouseCapture( NULL, NULL );
172 
173  if( target == NULL )
174  return;
175 
176  target->Draw( Panel, DC, GR_XOR );
177 
178  if( target->IsNew() ) // If it is new, delete it
179  {
180  target->Draw( Panel, DC, GR_XOR );
181  target->DeleteStructure();
182  target = NULL;
183  }
184  else // it is an existing item: retrieve initial values of parameters
185  {
186  if( ( target->GetFlags() & (IN_EDIT | IS_MOVED) ) )
187  {
188  target->SetPosition( s_TargetCopy.GetPosition() );
189  target->SetWidth( s_TargetCopy.GetWidth() );
190  target->SetSize( s_TargetCopy.GetSize() );
191  target->SetShape( s_TargetCopy.GetShape() );
192  }
193 
194  target->ClearFlags();
195  target->Draw( Panel, DC, GR_OR );
196  }
197 }
virtual BASE_SCREEN * GetScreen()=0
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:112
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
int GetWidth() const
bool IsNew() const
Definition: base_struct.h:219
void SetSize(int aSize)
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
virtual EDA_DRAW_FRAME * GetParent() const =0
static PCB_TARGET s_TargetCopy(NULL)
int GetShape() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void SetPosition(const wxPoint &aPos) override
void SetShape(int aShape)
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
Definition: gr_basic.h:38
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
void SetWidth(int aWidth)
int GetSize() const
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
const wxPoint GetPosition() const override
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
static void ShowTargetShapeWhileMovingMouse ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint &  aPosition,
bool  aErase 
)
static

Definition at line 268 of file target_edit.cpp.

References PCB_TARGET::Draw(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, and PCB_TARGET::SetPosition().

Referenced by PCB_EDIT_FRAME::BeginMoveTarget().

270 {
271  BASE_SCREEN* screen = aPanel->GetScreen();
272  PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem();
273 
274  if( target == NULL )
275  return;
276 
277  if( aErase )
278  target->Draw( aPanel, aDC, GR_XOR );
279 
280  target->SetPosition( aPanel->GetParent()->GetCrossHairPosition() );
281 
282  target->Draw( aPanel, aDC, GR_XOR );
283 }
virtual BASE_SCREEN * GetScreen()=0
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual EDA_DRAW_FRAME * GetParent() const =0
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void SetPosition(const wxPoint &aPos) override
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.

Variable Documentation

int MireDefaultSize = Millimeter2iu( 5 )
static

Definition at line 54 of file target_edit.cpp.

Referenced by PCB_EDIT_FRAME::CreateTarget().