KiCad PCB EDA Suite
edtxtmod.cpp File Reference

Edit module text. More...

#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
#include <class_drawpanel.h>
#include <drawtxt.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <macros.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <module_editor_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)
 

Variables

wxPoint MoveVector
 
static wxPoint TextInitialPosition
 
static double TextInitialOrientation
 

Detailed Description

Edit module text.

Definition in file edtxtmod.cpp.

Function Documentation

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

Definition at line 163 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().

164 {
165  BASE_SCREEN* screen = Panel->GetScreen();
166  TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
167  MODULE* Module;
168 
169  Panel->SetMouseCapture( NULL, NULL );
170 
171  if( Text == NULL )
172  return;
173 
174  Module = static_cast<MODULE*>( Text->GetParent() );
175 
176  Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
177  Text->Draw( Panel, DC, GR_XOR, MoveVector );
178 
179  // If the text was moved (the move does not change internal data)
180  // it could be rotated while moving. So set old value for orientation
181  if( Text->IsMoving() )
183 
184  // Redraw the text
185  Panel->RefreshDrawingRect( Text->GetBoundingBox() );
186 
187  // leave it at (0,0) so we can use it Rotate when not moving.
188  MoveVector.x = MoveVector.y = 0;
189 
190  Text->ClearFlags();
191  Module->ClearFlags();
192 
193  screen->SetCurItem( NULL );
194 }
BOARD_ITEM_CONTAINER * GetParent() const
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
bool IsMoving() const
Definition: base_struct.h:218
EDA_ITEM * GetCurItem() const
void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
Definition: draw_panel.cpp:306
wxPoint MoveVector
Definition: edtxtmod.cpp:54
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
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.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
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:254
void SetTextAngle(double aAngle)
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 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 276 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().

278 {
279  BASE_SCREEN* screen = aPanel->GetScreen();
280  TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
281 
282  if( Text == NULL )
283  return;
284 
285  // Erase umbilical and text if necessary
286  if( aErase )
287  {
288  Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
289  Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
290  }
291 
293 
294  // Draw umbilical if text moved
295  if( MoveVector.x || MoveVector.y )
296  Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
297 
298  // Redraw text
299  Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
300 }
EDA_ITEM * GetCurItem() const
wxPoint MoveVector
Definition: edtxtmod.cpp:54
static wxPoint TextInitialPosition
Definition: edtxtmod.cpp:56
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
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.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
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
Function GetCrossHairPosition 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.