KiCad PCB EDA Suite
edgemod.cpp File Reference

: More...

#include <fctsys.h>
#include <trigo.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <module_editor_frame.h>
#include <class_board.h>
#include <class_module.h>
#include <class_edge_mod.h>
#include <pcbnew.h>

Go to the source code of this file.

Functions

static void ShowNewEdgeModule (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool erase)
 
static void Abort_Move_ModuleOutline (EDA_DRAW_PANEL *Panel, wxDC *DC)
 
static void ShowCurrentOutlineWhileMoving (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 

Variables

static double ArcValue = 900
 
static wxPoint MoveVector
 
static wxPoint CursorInitialPosition
 

Detailed Description

:

Functions to edit graphic items used to draw footprint edges.

Todo:
  • Arc functions not compete but menus are ready to use.

Definition in file edgemod.cpp.

Function Documentation

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

Definition at line 295 of file edgemod.cpp.

References MODULE::CalculateBoundingBox(), EDA_ITEM::ClearFlags(), BOARD_ITEM::DeleteStructure(), EDGE_MODULE::Draw(), BASE_SCREEN::GetCurItem(), BOARD_ITEM::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_OR, GR_XOR, EDA_ITEM::IsNew(), PCB_MODULE_EDGE_T, BASE_SCREEN::SetCurItem(), EDA_DRAW_PANEL::SetMouseCapture(), and EDA_ITEM::Type().

Referenced by FOOTPRINT_EDIT_FRAME::Begin_Edge_Module(), and FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod().

296 {
297  EDGE_MODULE* edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
298 
299  Panel->SetMouseCapture( NULL, NULL );
300 
301  if( edge && ( edge->Type() == PCB_MODULE_EDGE_T ) )
302  {
303  if( edge->IsNew() ) // On aborting, delete new outline.
304  {
305  MODULE* module = (MODULE*) edge->GetParent();
306  edge->Draw( Panel, DC, GR_XOR, MoveVector );
307  edge->DeleteStructure();
308  module->CalculateBoundingBox();
309  }
310  else // On aborting, move existing outline to its initial position.
311  {
312  edge->Draw( Panel, DC, GR_XOR, MoveVector );
313  edge->ClearFlags();
314  edge->Draw( Panel, DC, GR_OR );
315  }
316  }
317 
318  Panel->GetScreen()->SetCurItem( NULL );
319 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
BOARD_ITEM_CONTAINER * GetParent() const
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
EDA_ITEM * GetCurItem() const
static wxPoint MoveVector
Definition: edgemod.cpp:57
bool IsNew() const
Definition: base_struct.h:230
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
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:42
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
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...
static void ShowCurrentOutlineWhileMoving ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 102 of file edgemod.cpp.

References MODULE::CalculateBoundingBox(), CursorInitialPosition, EDGE_MODULE::Draw(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), BOARD_ITEM::GetParent(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), and GR_XOR.

Referenced by FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod().

104 {
105  BASE_SCREEN* screen = aPanel->GetScreen();
106  EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
107 
108  if( edge == NULL )
109  return;
110 
111  MODULE* module = (MODULE*) edge->GetParent();
112 
113  if( aErase )
114  {
115  edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
116  }
117 
119 
120  edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
121 
122  module->CalculateBoundingBox();
123 }
BOARD_ITEM_CONTAINER * GetParent() const
EDA_ITEM * GetCurItem() const
static wxPoint MoveVector
Definition: edgemod.cpp:57
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
static wxPoint CursorInitialPosition
Definition: edgemod.cpp:58
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
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.
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...
static void ShowNewEdgeModule ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  erase 
)
static

Definition at line 129 of file edgemod.cpp.

References MODULE::CalculateBoundingBox(), EDGE_MODULE::Draw(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), DRAWSEGMENT::GetEnd(), EDGE_MODULE::GetEnd0(), MODULE::GetOrientation(), BOARD_ITEM::GetParent(), EDA_DRAW_PANEL::GetParent(), MODULE::GetPosition(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, RotatePoint(), DRAWSEGMENT::SetEnd(), and EDGE_MODULE::SetEnd0().

Referenced by FOOTPRINT_EDIT_FRAME::Begin_Edge_Module().

131 {
132  BASE_SCREEN* screen = aPanel->GetScreen();
133  EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
134 
135  if( edge == NULL )
136  return;
137 
138  MODULE* module = (MODULE*) edge->GetParent();
139 
140  // if( erase )
141  {
142  edge->Draw( aPanel, aDC, GR_XOR );
143  }
144 
145  edge->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
146 
147  // Update relative coordinate.
148  edge->SetEnd0( edge->GetEnd() - module->GetPosition() );
149 
150  wxPoint pt( edge->GetEnd0() );
151 
152  RotatePoint( &pt, -module->GetOrientation() );
153 
154  edge->SetEnd0( pt );
155 
156  edge->Draw( aPanel, aDC, GR_XOR );
157 
158  module->CalculateBoundingBox();
159 }
void SetEnd0(const wxPoint &aPoint)
BOARD_ITEM_CONTAINER * GetParent() const
EDA_ITEM * GetCurItem() const
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
const wxPoint & GetPosition() const override
Definition: class_module.h:155
const wxPoint & GetEnd0() const
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
double GetOrientation() const
Definition: class_module.h:160
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
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.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
void SetEnd(const wxPoint &aEnd)
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...

Variable Documentation

double ArcValue = 900
static

Definition at line 56 of file edgemod.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::Begin_Edge_Module().

wxPoint CursorInitialPosition
static

Definition at line 58 of file edgemod.cpp.

Referenced by ShowCurrentOutlineWhileMoving().

wxPoint MoveVector
static

Definition at line 57 of file edgemod.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::Place_EdgeMod().