KiCad PCB EDA Suite
edtxtmod.cpp File Reference

Edit texts in footprints. More...

#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
#include <class_drawpanel.h>
#include <draw_graphic_text.h>
#include <trigo.h>
#include <pcb_base_frame.h>
#include <macros.h>
#include <pcbnew.h>
#include <pcb_edit_frame.h>
#include <footprint_edit_frame.h>
#include <class_board.h>
#include <class_module.h>
#include <class_text_mod.h>
#include <class_pcb_text.h>

Go to the source code of this file.

Functions

static void Show_MoveTexte_Module (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 
static void AbortMoveTextModule (EDA_DRAW_PANEL *Panel, wxDC *DC)
 Abort text move in progress. More...
 

Variables

wxPoint MoveVector
 
static wxPoint TextInitialPosition
 
static double TextInitialOrientation
 

Detailed Description

Edit texts in footprints.

Definition in file edtxtmod.cpp.

Function Documentation

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

Abort text move in progress.

If a text is selected, its initial coordinates are regenerated.

Definition at line 153 of file edtxtmod.cpp.

References EDA_ITEM::ClearFlags(), TEXTE_MODULE::Draw(), TEXTE_MODULE::DrawUmbilical(), TEXTE_MODULE::GetBoundingBox(), BASE_SCREEN::GetCurItem(), BOARD_ITEM::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, EDA_ITEM::IsMoving(), EDA_DRAW_PANEL::RefreshDrawingRect(), BASE_SCREEN::SetCurItem(), EDA_DRAW_PANEL::SetMouseCapture(), TEXTE_MODULE::SetTextAngle(), TextInitialOrientation, wxPoint::x, and wxPoint::y.

Referenced by PCB_BASE_FRAME::StartMoveTexteModule().

154 {
155  BASE_SCREEN* screen = Panel->GetScreen();
156  TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
157  MODULE* Module;
158 
159  Panel->SetMouseCapture( NULL, NULL );
160 
161  if( Text == NULL )
162  return;
163 
164  Module = static_cast<MODULE*>( Text->GetParent() );
165 
166  Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
167  Text->Draw( Panel, DC, GR_XOR, MoveVector );
168 
169  // If the text was moved (the move does not change internal data)
170  // it could be rotated while moving. So set old value for orientation
171  if( Text->IsMoving() )
173 
174  // Redraw the text
175  Panel->RefreshDrawingRect( Text->GetBoundingBox() );
176 
177  // leave it at (0,0) so we can use it Rotate when not moving.
178  MoveVector.x = MoveVector.y = 0;
179 
180  Text->ClearFlags();
181  Module->ClearFlags();
182 
183  screen->SetCurItem( NULL );
184 }
virtual BASE_SCREEN * GetScreen()=0
BOARD_ITEM_CONTAINER * GetParent() const
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
bool IsMoving() const
Definition: base_struct.h:221
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
wxPoint MoveVector
Definition: edtxtmod.cpp:54
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
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...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw Draw the text according to the footprint pos and orient.
void DrawUmbilical(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset)
Function DrawUmbilical draws a line from the TEXTE_MODULE origin to parent MODULE origin...
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void SetTextAngle(double aAngle)
static double TextInitialOrientation
Definition: edtxtmod.cpp:58
static void Show_MoveTexte_Module ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 262 of file edtxtmod.cpp.

References TEXTE_MODULE::Draw(), TEXTE_MODULE::DrawUmbilical(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, wxPoint::x, and wxPoint::y.

Referenced by PCB_BASE_FRAME::StartMoveTexteModule().

264 {
265  BASE_SCREEN* screen = aPanel->GetScreen();
266  TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
267 
268  if( Text == NULL )
269  return;
270 
271  // Erase umbilical and text if necessary
272  if( aErase )
273  {
274  Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
275  Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
276  }
277 
279 
280  // Draw umbilical if text moved
281  if( MoveVector.x || MoveVector.y )
282  Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
283 
284  // Redraw text
285  Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
286 }
virtual BASE_SCREEN * GetScreen()=0
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
wxPoint MoveVector
Definition: edtxtmod.cpp:54
virtual EDA_DRAW_FRAME * GetParent() const =0
static wxPoint TextInitialPosition
Definition: edtxtmod.cpp:56
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw Draw the text according to the footprint pos and orient.
void DrawUmbilical(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset)
Function DrawUmbilical draws a line from the TEXTE_MODULE origin to parent MODULE origin...
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.

Variable Documentation

wxPoint MoveVector

Definition at line 54 of file edtxtmod.cpp.

Referenced by PCB_EDIT_FRAME::Block_Duplicate(), and PCB_EDIT_FRAME::Block_Move().

double TextInitialOrientation
static
wxPoint TextInitialPosition
static

Definition at line 56 of file edtxtmod.cpp.