KiCad PCB EDA Suite
symbdraw.cpp File Reference

Create, move . More...

#include <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <class_sch_screen.h>
#include <base_units.h>
#include <msgpanel.h>
#include <eeschema_id.h>
#include <general.h>
#include <libeditframe.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 133 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().

134 {
135  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
136  LIB_ITEM* item = parent->GetDrawItem();
137 
138  if( item == NULL )
139  return;
140 
141  bool newItem = item->IsNew();
142  item->EndEdit( parent->GetCrossHairPosition( true ), true );
143 
144  if( newItem )
145  {
146  delete item;
147  }
148  else
149  parent->RestoreComponent();
150 
151  parent->SetDrawItem( NULL );
152  Panel->Refresh();
153 }
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:332
bool IsNew() const
Definition: base_struct.h:243
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)
Definition: libeditframe.h:442
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:181
The symbol library editor main window.
Definition: libeditframe.h:59
LIB_ITEM * GetDrawItem() const
Definition: libeditframe.h:440
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 269 of file symbdraw.cpp.

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

Referenced by LIB_EDIT_FRAME::StartMoveDrawSymbol().

271 {
272  LIB_ITEM* item;
273 
274  item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
275 
276  if( item == NULL )
277  return;
278 
279  item->SetEraseLastDrawItem( aErase );
280 
281  // if item is the reference field, we must add the current unit id
282  if( item->Type() == LIB_FIELD_T )
283  {
284  int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
285  wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
286 
287  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
288  COLOR4D::UNSPECIFIED, g_XorMode, &text,
290  }
291  else
292  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
293  COLOR4D::UNSPECIFIED, g_XorMode, NULL,
295 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
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:181
The symbol library editor main window.
Definition: libeditframe.h:59
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 336 of file symbdraw.cpp.

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

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

338 {
339  LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
340 
341  if( item == NULL )
342  return;
343 
344  item->SetEraseLastDrawItem( aErase );
345  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
346  COLOR4D::UNSPECIFIED, g_XorMode, NULL, DefaultTransform );
347 }
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:181
The symbol library editor main window.
Definition: libeditframe.h:59
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...