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 296 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().

297 {
298  EDGE_MODULE* edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
299 
300  Panel->SetMouseCapture( NULL, NULL );
301 
302  if( edge && ( edge->Type() == PCB_MODULE_EDGE_T ) )
303  {
304  if( edge->IsNew() ) // On aborting, delete new outline.
305  {
306  MODULE* module = (MODULE*) edge->GetParent();
307  edge->Draw( Panel, DC, GR_XOR, MoveVector );
308  edge->DeleteStructure();
309  module->CalculateBoundingBox();
310  }
311  else // On aborting, move existing outline to its initial position.
312  {
313  edge->Draw( Panel, DC, GR_XOR, MoveVector );
314  edge->ClearFlags();
315  edge->Draw( Panel, DC, GR_OR );
316  }
317  }
318 
319  Panel->GetScreen()->SetCurItem( NULL );
320 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
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:227
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
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
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
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 103 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().

105 {
106  BASE_SCREEN* screen = aPanel->GetScreen();
107  EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
108 
109  if( edge == NULL )
110  return;
111 
112  MODULE* module = (MODULE*) edge->GetParent();
113 
114  if( aErase )
115  {
116  edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
117  }
118 
120 
121  edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
122 
123  module->CalculateBoundingBox();
124 }
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.
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
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
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:193
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 130 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().

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

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.

Referenced by FOOTPRINT_EDIT_FRAME::Place_EdgeMod().