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 <class_board.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <pcbnew.h>
#include <pcb_layer_box_selector.h>
#include <dialogs/dialog_text_properties.h>

Go to the source code of this file.

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 75 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().

76 {
77  DIMENSION* dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
78 
79  if( dimension )
80  {
81  if( dimension->IsNew() )
82  {
83  dimension->Draw( Panel, aDC, GR_XOR );
84  dimension->DeleteStructure();
85  }
86  else
87  {
88  dimension->Draw( Panel, aDC, GR_OR );
89  }
90  }
91 
92  status_dimension = 0;
93  ((PCB_EDIT_FRAME*)Panel->GetParent())->SetCurItem( NULL );
94 }
virtual BASE_SCREEN * GetScreen()=0
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
bool IsNew() const
Definition: base_struct.h:219
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...
virtual EDA_DRAW_FRAME * GetParent() const =0
static int status_dimension
Definition: dimension.cpp:60
Definition: gr_basic.h:38
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
Class DIMENSION.
void AbortMoveDimensionText ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)
static

Definition at line 258 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, PCB_BASE_FRAME::SetCurItem(), EDA_DRAW_PANEL::SetMouseCapture(), EDA_TEXT::SetTextPos(), and DIMENSION::Text().

Referenced by PCB_EDIT_FRAME::BeginMoveDimensionText().

259 {
260  DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
261  ( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL );
262 
263  aPanel->SetMouseCapture( NULL, NULL );
264 
265  if( dimension == NULL ) // Should not occur
266  return;
267 
268  dimension->Draw( aPanel, aDC, GR_XOR );
269  dimension->Text().SetTextPos( initialTextPosition );
270  dimension->ClearFlags();
271  dimension->Draw( aPanel, aDC, GR_OR );
272 }
virtual BASE_SCREEN * GetScreen()=0
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
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.
virtual EDA_DRAW_FRAME * GetParent() const =0
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...
static wxPoint initialTextPosition
Definition: dimension.cpp:212
Definition: gr_basic.h:38
TEXTE_PCB & Text()
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
Class DIMENSION.
static void BuildDimension ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

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

150 {
151  PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
152  DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem();
153  wxPoint pos = aPanel->GetParent()->GetCrossHairPosition();
154 
155  if( Dimension == NULL )
156  return;
157 
158  // Erase previous dimension.
159  if( aErase )
160  {
161  Dimension->Draw( aPanel, aDC, GR_XOR );
162  }
163 
164  Dimension->SetLayer( screen->m_Active_Layer );
165 
166  if( status_dimension == 1 )
167  {
168  Dimension->m_featureLineDO = pos;
169  Dimension->m_crossBarF = Dimension->m_featureLineDO;
170  Dimension->AdjustDimensionDetails();
171  }
172  else
173  {
174  /* Calculating the direction of travel perpendicular to the selected axis. */
175  double angle = Dimension->GetAngle() + (M_PI / 2);
176 
177  wxPoint delta = pos - Dimension->m_featureLineDO;
178  double depl = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
179  Dimension->SetHeight( depl );
180  }
181 
182  Dimension->Draw( aPanel, aDC, GR_XOR );
183 }
virtual BASE_SCREEN * GetScreen()=0
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.
virtual EDA_DRAW_FRAME * GetParent() const =0
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:60
void AdjustDimensionDetails()
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)
wxPoint m_featureLineDO
wxPoint GetCrossHairPosition(bool aInvertY=false) const
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 236 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().

238 {
239  DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
240 
241  if( dimension == NULL )
242  return;
243 
244  if( aErase )
245  dimension->Draw( aPanel, aDC, GR_XOR );
246 
247  dimension->Text().SetTextPos( aPanel->GetParent()->GetCrossHairPosition() );
248 
249  dimension->Draw( aPanel, aDC, GR_XOR );
250 }
virtual BASE_SCREEN * GetScreen()=0
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
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.
virtual EDA_DRAW_FRAME * GetParent() const =0
TEXTE_PCB & Text()
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
Class DIMENSION.

Variable Documentation

wxPoint initialTextPosition
static

Definition at line 212 of file dimension.cpp.

int status_dimension
static