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

◆ AbortMoveTextModule()

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 155 of file edtxtmod.cpp.

156 {
157  BASE_SCREEN* screen = Panel->GetScreen();
158  TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
159  MODULE* Module;
160 
161  Panel->SetMouseCapture( NULL, NULL );
162 
163  if( Text == NULL )
164  return;
165 
166  Module = static_cast<MODULE*>( Text->GetParent() );
167 
168  Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
169  Text->Draw( Panel, DC, GR_XOR, MoveVector );
170 
171  // If the text was moved (the move does not change internal data)
172  // it could be rotated while moving. So set old value for orientation
173  if( Text->IsMoving() )
175 
176  // Redraw the text
177  Panel->RefreshDrawingRect( Text->GetBoundingBox() );
178 
179  // leave it at (0,0) so we can use it Rotate when not moving.
180  MoveVector.x = MoveVector.y = 0;
181 
182  Text->ClearFlags();
183  Module->ClearFlags();
184 
185  screen->SetCurItem( NULL );
186 }
virtual BASE_SCREEN * GetScreen()=0
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
BOARD_ITEM_CONTAINER * GetParent() const

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(), MoveVector, EDA_DRAW_PANEL::RefreshDrawingRect(), BASE_SCREEN::SetCurItem(), EDA_DRAW_PANEL::SetMouseCapture(), TEXTE_MODULE::SetTextAngle(), and TextInitialOrientation.

Referenced by PCB_BASE_FRAME::StartMoveTexteModule().

◆ Show_MoveTexte_Module()

static void Show_MoveTexte_Module ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint &  aPosition,
bool  aErase 
)
static

Definition at line 264 of file edtxtmod.cpp.

266 {
267  BASE_SCREEN* screen = aPanel->GetScreen();
268  TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
269 
270  if( Text == NULL )
271  return;
272 
273  // Erase umbilical and text if necessary
274  if( aErase )
275  {
276  Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
277  Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
278  }
279 
281 
282  // Draw umbilical if text moved
283  if( MoveVector.x || MoveVector.y )
284  Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
285 
286  // Redraw text
287  Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
288 }
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.

References TEXTE_MODULE::Draw(), TEXTE_MODULE::DrawUmbilical(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, MoveVector, and TextInitialPosition.

Referenced by PCB_BASE_FRAME::StartMoveTexteModule().

Variable Documentation

◆ MoveVector

◆ TextInitialOrientation

double TextInitialOrientation
static

◆ TextInitialPosition

wxPoint TextInitialPosition
static

Definition at line 56 of file edtxtmod.cpp.

Referenced by Show_MoveTexte_Module(), and PCB_BASE_FRAME::StartMoveTexteModule().