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 160 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().

161 {
162  BASE_SCREEN* screen = Panel->GetScreen();
163  PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem();
164 
165  ( (PCB_EDIT_FRAME*) Panel->GetParent() )->SetCurItem( NULL );
166 
167  Panel->SetMouseCapture( NULL, NULL );
168 
169  if( target == NULL )
170  return;
171 
172  target->Draw( Panel, DC, GR_XOR );
173 
174  if( target->IsNew() ) // If it is new, delete it
175  {
176  target->Draw( Panel, DC, GR_XOR );
177  target->DeleteStructure();
178  target = NULL;
179  }
180  else // it is an existing item: retrieve initial values of parameters
181  {
182  if( ( target->GetFlags() & (IN_EDIT | IS_MOVED) ) )
183  {
184  target->SetPosition( s_TargetCopy.GetPosition() );
185  target->SetWidth( s_TargetCopy.GetWidth() );
186  target->SetSize( s_TargetCopy.GetSize() );
187  target->SetShape( s_TargetCopy.GetShape() );
188  }
189 
190  target->ClearFlags();
191  target->Draw( Panel, DC, GR_OR );
192  }
193 }
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 264 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().

266 {
267  BASE_SCREEN* screen = aPanel->GetScreen();
268  PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem();
269 
270  if( target == NULL )
271  return;
272 
273  if( aErase )
274  target->Draw( aPanel, aDC, GR_XOR );
275 
276  target->SetPosition( aPanel->GetParent()->GetCrossHairPosition() );
277 
278  target->Draw( aPanel, aDC, GR_XOR );
279 }
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().