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 <wxPcbStruct.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <gr_basic.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_mire.h>
#include <pcbnew.h>
#include <dialog_target_properties_base.h>

Go to the source code of this file.

Classes

class  TARGET_PROPERTIES_DIALOG_EDITOR
 

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

173 {
174  BASE_SCREEN* screen = Panel->GetScreen();
175  PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem();
176 
177  ( (PCB_EDIT_FRAME*) Panel->GetParent() )->SetCurItem( NULL );
178 
179  Panel->SetMouseCapture( NULL, NULL );
180 
181  if( target == NULL )
182  return;
183 
184  target->Draw( Panel, DC, GR_XOR );
185 
186  if( target->IsNew() ) // If it is new, delete it
187  {
188  target->Draw( Panel, DC, GR_XOR );
189  target->DeleteStructure();
190  target = NULL;
191  }
192  else // it is an existing item: retrieve initial values of parameters
193  {
194  if( ( target->GetFlags() & (IN_EDIT | IS_MOVED) ) )
195  {
196  target->SetPosition( s_TargetCopy.GetPosition() );
197  target->SetWidth( s_TargetCopy.GetWidth() );
198  target->SetSize( s_TargetCopy.GetSize() );
199  target->SetShape( s_TargetCopy.GetShape() );
200  }
201 
202  target->ClearFlags();
203  target->Draw( Panel, DC, GR_OR );
204  }
205 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:269
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:125
EDA_ITEM * GetCurItem() const
int GetWidth() const
Definition: class_mire.h:72
bool IsNew() const
Definition: base_struct.h:230
void SetSize(int aSize)
Definition: class_mire.h:68
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
static PCB_TARGET s_TargetCopy(NULL)
int GetShape() const
Definition: class_mire.h:66
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
void SetPosition(const wxPoint &aPos) override
Definition: class_mire.h:62
void SetShape(int aShape)
Definition: class_mire.h:65
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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: class_mire.cpp:78
Definition: gr_basic.h:42
const wxPoint & GetPosition() const override
Definition: class_mire.h:63
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
void SetWidth(int aWidth)
Definition: class_mire.h:71
int GetSize() const
Definition: class_mire.h:69
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126
static void ShowTargetShapeWhileMovingMouse ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

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

278 {
279  BASE_SCREEN* screen = aPanel->GetScreen();
280  PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem();
281 
282  if( target == NULL )
283  return;
284 
285  if( aErase )
286  target->Draw( aPanel, aDC, GR_XOR );
287 
288  target->SetPosition( aPanel->GetParent()->GetCrossHairPosition() );
289 
290  target->Draw( aPanel, aDC, GR_XOR );
291 }
EDA_ITEM * GetCurItem() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
void SetPosition(const wxPoint &aPos) override
Definition: class_mire.h:62
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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: class_mire.cpp:78
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...

Variable Documentation

int MireDefaultSize = Millimeter2iu( 5 )
static