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 <wxPcbStruct.h>
#include <drawtxt.h>
#include <dialog_helpers.h>
#include <macros.h>
#include <base_units.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <pcbnew.h>
#include <dialog_dimension_editor_base.h>
#include <class_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 237 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().

238 {
239  DIMENSION* dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
240 
241  if( dimension )
242  {
243  if( dimension->IsNew() )
244  {
245  dimension->Draw( Panel, aDC, GR_XOR );
246  dimension->DeleteStructure();
247  }
248  else
249  {
250  dimension->Draw( Panel, aDC, GR_OR );
251  }
252  }
253 
254  status_dimension = 0;
255  ((PCB_EDIT_FRAME*)Panel->GetParent())->SetCurItem( NULL );
256 }
EDA_ITEM * GetCurItem() const
bool IsNew() const
Definition: base_struct.h:216
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:60
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
Definition: gr_basic.h:42
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
Class DIMENSION.
void AbortMoveDimensionText ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)
static

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

426 {
427  DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
428  ( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL );
429 
430  aPanel->SetMouseCapture( NULL, NULL );
431 
432  if( dimension == NULL ) // Should not occur
433  return;
434 
435  dimension->Draw( aPanel, aDC, GR_XOR );
436  dimension->Text().SetTextPos( initialTextPosition );
437  dimension->ClearFlags();
438  dimension->Draw( aPanel, aDC, GR_OR );
439 }
EDA_ITEM * GetCurItem() const
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
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:175
static wxPoint initialTextPosition
Definition: dimension.cpp:379
Definition: gr_basic.h:42
TEXTE_PCB & Text()
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
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 315 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().

317 {
318  PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
319  DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem();
320  wxPoint pos = aPanel->GetParent()->GetCrossHairPosition();
321 
322  if( Dimension == NULL )
323  return;
324 
325  // Erase previous dimension.
326  if( aErase )
327  {
328  Dimension->Draw( aPanel, aDC, GR_XOR );
329  }
330 
331  Dimension->SetLayer( screen->m_Active_Layer );
332 
333  if( status_dimension == 1 )
334  {
335  Dimension->m_featureLineDO = pos;
336  Dimension->m_crossBarF = Dimension->m_featureLineDO;
337  Dimension->AdjustDimensionDetails( );
338  }
339  else
340  {
341  /* Calculating the direction of travel perpendicular to the selected axis. */
342  double angle = Dimension->GetAngle() + (M_PI / 2);
343 
344  wxPoint delta = pos - Dimension->m_featureLineDO;
345  double depl = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
346  Dimension->SetHeight( depl );
347  }
348 
349  Dimension->Draw( aPanel, aDC, GR_XOR );
350 }
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.
static const int delta[8][2]
Definition: solve.cpp:112
void SetLayer(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().
static int status_dimension
Definition: dimension.cpp:60
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
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)
LAYER_ID m_Active_Layer
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
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 403 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().

405 {
406  DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
407 
408  if( dimension == NULL )
409  return;
410 
411  if( aErase )
412  dimension->Draw( aPanel, aDC, GR_XOR );
413 
414  dimension->Text().SetTextPos( aPanel->GetParent()->GetCrossHairPosition() );
415 
416  dimension->Draw( aPanel, aDC, GR_XOR );
417 }
EDA_ITEM * GetCurItem() const
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
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:175
TEXTE_PCB & Text()
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
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 379 of file dimension.cpp.

int status_dimension
static