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 component (lines, arcs ..)

Definition in file symbdraw.cpp.

Function Documentation

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

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

126 {
127  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
128  LIB_ITEM* item = parent->GetDrawItem();
129 
130  if( item == NULL )
131  return;
132 
133  bool newItem = item->IsNew();
134  item->EndEdit( parent->GetCrossHairPosition( true ), true );
135 
136  if( newItem )
137  {
138  delete item;
139  }
140  else
141  parent->RestoreComponent();
142 
143  parent->SetDrawItem( NULL );
144  Panel->Refresh();
145 }
LIB_ITEM * GetDrawItem()
Definition: libeditframe.h:399
void RestoreComponent()
Function 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:325
bool IsNew() const
Definition: base_struct.h:230
virtual void EndEdit(const wxPoint &aPosition, bool aAbort=false)
End an object editing action.
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
void SetDrawItem(LIB_ITEM *drawItem)
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
The component library editor main window.
Definition: libeditframe.h:51
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 259 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().

261 {
262  LIB_ITEM* item;
263 
264  item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
265 
266  if( item == NULL )
267  return;
268 
269  item->SetEraseLastDrawItem( aErase );
270 
271  // if item is the reference field, we must add the current unit id
272  if( item->Type() == LIB_FIELD_T )
273  {
274  int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
275  wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
276 
277  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
278  COLOR4D::UNSPECIFIED, g_XorMode, &text,
280  }
281  else
282  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
283  COLOR4D::UNSPECIFIED, g_XorMode, NULL,
285 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void SetEraseLastDrawItem(bool aErase=true)
Class LIB_FIELD is used in symbol libraries.
Definition: lib_field.h:60
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
The component library editor main window.
Definition: libeditframe.h:51
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 322 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().

324 {
325  LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
326 
327  if( item == NULL )
328  return;
329 
330  item->SetEraseLastDrawItem( aErase );
331  item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
332  COLOR4D::UNSPECIFIED, g_XorMode, NULL, DefaultTransform );
333 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
void SetEraseLastDrawItem(bool aErase=true)
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
The component library editor main window.
Definition: libeditframe.h:51
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...