KiCad PCB EDA Suite
symbdraw.cpp File Reference

Create, move . More...

#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <base_units.h>
#include <msgpanel.h>
#include <eeschema_id.h>
#include <lib_edit_frame.h>
#include <class_libentry.h>
#include <lib_arc.h>
#include <lib_circle.h>
#include <lib_polyline.h>
#include <lib_rectangle.h>
#include <lib_text.h>
#include <dialogs/dialog_lib_edit_draw_item.h>

Go to the source code of this file.

Functions

static void SymbolDisplayDraw (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 Manage mouse events when creating new graphic object or modifying an graphic object. More...
 
static void RedrawWhileMovingCursor (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 
static void AbortSymbolTraceOn (EDA_DRAW_PANEL *Panel, wxDC *DC)
 

Detailed Description

Create, move .

. graphic shapes used to build and draw a symbol (lines, arcs ..)

Definition in file symbdraw.cpp.

Function Documentation

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

Definition at line 130 of file symbdraw.cpp.

References LIB_ITEM::EndEdit(), EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetDrawItem(), EDA_DRAW_PANEL::GetParent(), EDA_ITEM::IsNew(), EDA_DRAW_PANEL::Refresh(), LIB_EDIT_FRAME::RestoreComponent(), and LIB_EDIT_FRAME::SetDrawItem().

Referenced by LIB_EDIT_FRAME::CreateGraphicItem(), LIB_EDIT_FRAME::StartModifyDrawSymbol(), and LIB_EDIT_FRAME::StartMoveDrawSymbol().

131 {
132  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
133  LIB_ITEM* item = parent->GetDrawItem();
134 
135  if( item == NULL )
136  return;
137 
138  bool newItem = item->IsNew();
139  item->EndEdit( parent->GetCrossHairPosition( true ), true );
140 
141  if( newItem )
142  {
143  delete item;
144  }
145  else
146  parent->RestoreComponent();
147 
148  parent->SetDrawItem( NULL );
149  Panel->Refresh();
150 }
void RestoreComponent()
Restore the current edited component from its temporary copy.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
bool IsNew() const
Definition: base_struct.h:227
virtual void EndEdit(const wxPoint &aPosition, bool aAbort=false)
End an object editing action.
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
void SetDrawItem(LIB_ITEM *drawItem)
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
The symbol library editor main window.
LIB_ITEM * GetDrawItem() const
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
static void RedrawWhileMovingCursor ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 266 of file symbdraw.cpp.

References DefaultTransform, LIB_ITEM::Draw(), g_XorMode, EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetDrawItem(), EDA_DRAW_PANEL::GetParent(), LIB_EDIT_FRAME::GetUnit(), LIB_FIELD_T, LIB_ITEM::SetEraseLastDrawItem(), and EDA_ITEM::Type().

Referenced by LIB_EDIT_FRAME::StartMoveDrawSymbol().

268 {
269  LIB_ITEM* item;
270 
271  item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
272 
273  if( item == NULL )
274  return;
275 
276  item->SetEraseLastDrawItem( aErase );
277 
278  // if item is the reference field, we must add the current unit id
279  if( item->Type() == LIB_FIELD_T )
280  {
281  int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
282  wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
283 
284  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
285  COLOR4D::UNSPECIFIED, g_XorMode, &text,
287  }
288  else
289  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
290  COLOR4D::UNSPECIFIED, g_XorMode, NULL,
292 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
void SetEraseLastDrawItem(bool aErase=true)
Field object used in symbol libraries.
Definition: lib_field.h:59
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
The symbol library editor main window.
TRANSFORM DefaultTransform
Definition: eeschema.cpp:58
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform)
Draw an item.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
static void SymbolDisplayDraw ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Manage mouse events when creating new graphic object or modifying an graphic object.

Definition at line 329 of file symbdraw.cpp.

References DefaultTransform, LIB_ITEM::Draw(), g_XorMode, EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetDrawItem(), EDA_DRAW_PANEL::GetParent(), and LIB_ITEM::SetEraseLastDrawItem().

Referenced by LIB_EDIT_FRAME::CreateGraphicItem(), and LIB_EDIT_FRAME::StartModifyDrawSymbol().

331 {
332  LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
333 
334  if( item == NULL )
335  return;
336 
337  item->SetEraseLastDrawItem( aErase );
338  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
339  COLOR4D::UNSPECIFIED, g_XorMode, NULL, DefaultTransform );
340 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
void SetEraseLastDrawItem(bool aErase=true)
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
The symbol library editor main window.
TRANSFORM DefaultTransform
Definition: eeschema.cpp:58
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform)
Draw an item.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...