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 <pcb_edit_frame.h>
#include <base_units.h>
#include <dialog_text_entry.h>
#include <footprint_edit_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 267 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().

268 {
269  EDGE_MODULE* edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
270 
271  Panel->SetMouseCapture( NULL, NULL );
272 
273  if( edge && ( edge->Type() == PCB_MODULE_EDGE_T ) )
274  {
275  if( edge->IsNew() ) // On aborting, delete new outline.
276  {
277  MODULE* module = (MODULE*) edge->GetParent();
278  edge->Draw( Panel, DC, GR_XOR, MoveVector );
279  edge->DeleteStructure();
280  module->CalculateBoundingBox();
281  }
282  else // On aborting, move existing outline to its initial position.
283  {
284  edge->Draw( Panel, DC, GR_XOR, MoveVector );
285  edge->ClearFlags();
286  edge->Draw( Panel, DC, GR_OR );
287  }
288  }
289 
290  Panel->GetScreen()->SetCurItem( NULL );
291 }
virtual BASE_SCREEN * GetScreen()=0
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
BOARD_ITEM_CONTAINER * GetParent() const
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
static wxPoint MoveVector
Definition: edgemod.cpp:58
bool IsNew() const
Definition: base_struct.h:219
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:94
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
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:38
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
static void ShowCurrentOutlineWhileMoving ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 99 of file edgemod.cpp.

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

Referenced by FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod().

101 {
102  BASE_SCREEN* screen = aPanel->GetScreen();
103  EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
104 
105  if( edge == NULL )
106  return;
107 
108  MODULE* module = (MODULE*) edge->GetParent();
109 
110  if( aErase )
111  {
112  edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
113  }
114 
116 
117  edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
118 
119  module->CalculateBoundingBox();
120 }
virtual BASE_SCREEN * GetScreen()=0
BOARD_ITEM_CONTAINER * GetParent() const
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
static wxPoint MoveVector
Definition: edgemod.cpp:58
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
virtual EDA_DRAW_FRAME * GetParent() const =0
static wxPoint CursorInitialPosition
Definition: edgemod.cpp:59
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
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.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
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 126 of file edgemod.cpp.

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

Referenced by FOOTPRINT_EDIT_FRAME::Begin_Edge_Module().

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

Variable Documentation

double ArcValue = 900
static

Definition at line 57 of file edgemod.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::Begin_Edge_Module().

wxPoint CursorInitialPosition
static

Definition at line 59 of file edgemod.cpp.

Referenced by ShowCurrentOutlineWhileMoving().

wxPoint MoveVector
static

Definition at line 58 of file edgemod.cpp.