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

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

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