KiCad PCB EDA Suite
dimension.cpp File Reference

Dialog and code for editing a dimension object. More...

#include <fctsys.h>
#include <confirm.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <pcb_edit_frame.h>
#include <draw_graphic_text.h>
#include <dialog_helpers.h>
#include <macros.h>
#include <base_units.h>
#include <board_commit.h>
#include <widgets/text_ctrl_eval.h>
#include <class_board.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <pcbnew.h>
#include <dialog_dimension_editor_base.h>
#include <pcb_layer_box_selector.h>

Go to the source code of this file.

Classes

class  DIALOG_DIMENSION_EDITOR
 

Functions

static void BuildDimension (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 
static void MoveDimensionText (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 
static void AbortMoveDimensionText (EDA_DRAW_PANEL *aPanel, wxDC *aDC)
 
static void AbortBuildDimension (EDA_DRAW_PANEL *Panel, wxDC *aDC)
 

Variables

static int status_dimension
 
static wxPoint initialTextPosition
 

Detailed Description

Dialog and code for editing a dimension object.

Definition in file dimension.cpp.

Function Documentation

static void AbortBuildDimension ( EDA_DRAW_PANEL Panel,
wxDC *  aDC 
)
static

Definition at line 238 of file dimension.cpp.

References BOARD_ITEM::DeleteStructure(), DIMENSION::Draw(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_OR, GR_XOR, EDA_ITEM::IsNew(), and status_dimension.

Referenced by PCB_EDIT_FRAME::EditDimension().

239 {
240  DIMENSION* dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
241 
242  if( dimension )
243  {
244  if( dimension->IsNew() )
245  {
246  dimension->Draw( Panel, aDC, GR_XOR );
247  dimension->DeleteStructure();
248  }
249  else
250  {
251  dimension->Draw( Panel, aDC, GR_OR );
252  }
253  }
254 
255  status_dimension = 0;
256  ((PCB_EDIT_FRAME*)Panel->GetParent())->SetCurItem( NULL );
257 }
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
bool IsNew() const
Definition: base_struct.h:227
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aColorMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
static int status_dimension
Definition: dimension.cpp:61
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
Definition: gr_basic.h:38
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
Class DIMENSION.
void AbortMoveDimensionText ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)
static

Definition at line 426 of file dimension.cpp.

References EDA_ITEM::ClearFlags(), DIMENSION::Draw(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_OR, GR_XOR, EDA_DRAW_PANEL::SetMouseCapture(), EDA_TEXT::SetTextPos(), and DIMENSION::Text().

Referenced by PCB_EDIT_FRAME::BeginMoveDimensionText().

427 {
428  DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
429  ( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL );
430 
431  aPanel->SetMouseCapture( NULL, NULL );
432 
433  if( dimension == NULL ) // Should not occur
434  return;
435 
436  dimension->Draw( aPanel, aDC, GR_XOR );
437  dimension->Text().SetTextPos( initialTextPosition );
438  dimension->ClearFlags();
439  dimension->Draw( aPanel, aDC, GR_OR );
440 }
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aColorMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
static wxPoint initialTextPosition
Definition: dimension.cpp:380
Definition: gr_basic.h:38
TEXTE_PCB & Text()
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
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...
Class DIMENSION.
static void BuildDimension ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 316 of file dimension.cpp.

References DIMENSION::AdjustDimensionDetails(), PNS::angle(), delta, DIMENSION::Draw(), DIMENSION::GetAngle(), EDA_DRAW_FRAME::GetCrossHairPosition(), PCB_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, PCB_SCREEN::m_Active_Layer, DIMENSION::m_crossBarF, DIMENSION::m_featureLineDO, DIMENSION::SetHeight(), DIMENSION::SetLayer(), status_dimension, wxPoint::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::EditDimension().

318 {
319  PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
320  DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem();
321  wxPoint pos = aPanel->GetParent()->GetCrossHairPosition();
322 
323  if( Dimension == NULL )
324  return;
325 
326  // Erase previous dimension.
327  if( aErase )
328  {
329  Dimension->Draw( aPanel, aDC, GR_XOR );
330  }
331 
332  Dimension->SetLayer( screen->m_Active_Layer );
333 
334  if( status_dimension == 1 )
335  {
336  Dimension->m_featureLineDO = pos;
337  Dimension->m_crossBarF = Dimension->m_featureLineDO;
338  Dimension->AdjustDimensionDetails( );
339  }
340  else
341  {
342  /* Calculating the direction of travel perpendicular to the selected axis. */
343  double angle = Dimension->GetAngle() + (M_PI / 2);
344 
345  wxPoint delta = pos - Dimension->m_featureLineDO;
346  double depl = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
347  Dimension->SetHeight( depl );
348  }
349 
350  Dimension->Draw( aPanel, aDC, GR_XOR );
351 }
wxPoint m_crossBarF
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aColorMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
double GetAngle() const
Function GetAngle Returns angle of the crossbar.
PCB_LAYER_ID m_Active_Layer
Definition: pcb_screen.h:44
static const int delta[8][2]
Definition: solve.cpp:112
void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
static int status_dimension
Definition: dimension.cpp:61
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void AdjustDimensionDetails(bool aDoNotChangeText=false)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension...
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
wxPoint m_featureLineDO
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
Class DIMENSION.
static void MoveDimensionText ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 404 of file dimension.cpp.

References DIMENSION::Draw(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), GR_XOR, EDA_TEXT::SetTextPos(), and DIMENSION::Text().

Referenced by PCB_EDIT_FRAME::BeginMoveDimensionText().

406 {
407  DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
408 
409  if( dimension == NULL )
410  return;
411 
412  if( aErase )
413  dimension->Draw( aPanel, aDC, GR_XOR );
414 
415  dimension->Text().SetTextPos( aPanel->GetParent()->GetCrossHairPosition() );
416 
417  dimension->Draw( aPanel, aDC, GR_XOR );
418 }
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aColorMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
TEXTE_PCB & Text()
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...
Class DIMENSION.

Variable Documentation

wxPoint initialTextPosition
static

Definition at line 380 of file dimension.cpp.

int status_dimension
static