KiCad PCB EDA Suite
WS_DRAW_ITEM_LINE Class Reference

#include <worksheet_shape_builder.h>

Inheritance diagram for WS_DRAW_ITEM_LINE:
WS_DRAW_ITEM_BASE WS_DRAW_ITEM_RECT

Public Types

enum  WS_DRAW_TYPE {
  wsg_line, wsg_rect, wsg_poly, wsg_text,
  wsg_bitmap
}
 

Public Member Functions

 WS_DRAW_ITEM_LINE (WORKSHEET_DATAITEM *aParent, wxPoint aStart, wxPoint aEnd, int aPenWidth, COLOR4D aColor)
 
int GetPenWidth () const
 
const wxPoint & GetStart () const
 
const wxPoint & GetEnd () const
 
virtual void DrawWsItem (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
 The function to draw a WS_DRAW_ITEM_LINE. More...
 
virtual bool HitTest (const wxPoint &aPosition) const override
 Virtual function return true if the point aPosition is on the line. More...
 
virtual bool HitTest (const EDA_RECT &aRect) const override
 Virtual function return true if the rect aRect intersects on the item. More...
 
virtual bool HitTestStartPoint (wxDC *aDC, const wxPoint &aPosition) override
 return true if the point aPosition is on the starting point of this item. More...
 
virtual bool HitTestEndPoint (wxDC *aDC, const wxPoint &aPosition) override
 return true if the point aPosition is on the ending point of this item This is avirtual function which should be overriden for items defien by 2 points More...
 
COLOR4D GetColor () const
 
WS_DRAW_TYPE GetType () const
 
WORKSHEET_DATAITEMGetParent () const
 
virtual void DrawWsItem (EDA_RECT *aClipBox, wxDC *aDC)
 The function to draw a WS_DRAW_ITEM. More...
 

Public Attributes

int m_Flags
 

Protected Attributes

WS_DRAW_TYPE m_type
 
COLOR4D m_color
 
WORKSHEET_DATAITEMm_parent
 

Private Attributes

wxPoint m_start
 
wxPoint m_end
 
int m_penWidth
 

Detailed Description

Definition at line 137 of file worksheet_shape_builder.h.

Member Enumeration Documentation

◆ WS_DRAW_TYPE

Constructor & Destructor Documentation

◆ WS_DRAW_ITEM_LINE()

WS_DRAW_ITEM_LINE::WS_DRAW_ITEM_LINE ( WORKSHEET_DATAITEM aParent,
wxPoint  aStart,
wxPoint  aEnd,
int  aPenWidth,
COLOR4D  aColor 
)
inline

Definition at line 144 of file worksheet_shape_builder.h.

146  :
147  WS_DRAW_ITEM_BASE( aParent, wsg_line, aColor )
148  {
149  m_start = aStart;
150  m_end = aEnd;
151  m_penWidth = aPenWidth;
152  }
WS_DRAW_ITEM_BASE(WORKSHEET_DATAITEM *aParent, WS_DRAW_TYPE aType, COLOR4D aColor)

References m_end, m_penWidth, and m_start.

Member Function Documentation

◆ DrawWsItem() [1/2]

virtual void WS_DRAW_ITEM_BASE::DrawWsItem ( EDA_RECT aClipBox,
wxDC *  aDC 
)
inlinevirtualinherited

The function to draw a WS_DRAW_ITEM.

Definition at line 91 of file worksheet_shape_builder.h.

92  {
93  wxPoint offset( 0, 0 );
94  DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, COLOR4D::UNSPECIFIED );
95  }
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC)
The function to draw a WS_DRAW_ITEM.

References UNSPECIFIED_DRAWMODE.

◆ DrawWsItem() [2/2]

void WS_DRAW_ITEM_LINE::DrawWsItem ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aOffset,
GR_DRAWMODE  aDrawMode,
COLOR4D  aColor = COLOR4D::UNSPECIFIED 
)
overridevirtual

The function to draw a WS_DRAW_ITEM_LINE.

Implements WS_DRAW_ITEM_BASE.

Reimplemented in WS_DRAW_ITEM_RECT.

Definition at line 409 of file page_layout_graphic_items.cpp.

411 {
412  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
413  GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset,
414  GetPenWidth(),
415  ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
416  GRSetDrawMode( aDC, GR_COPY );
417 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
const wxPoint & GetEnd() const
const wxPoint & GetStart() const
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285

References WS_DRAW_ITEM_BASE::GetColor(), GetEnd(), GetPenWidth(), GetStart(), GR_COPY, GRLine(), GRSetDrawMode(), and UNSPECIFIED_DRAWMODE.

◆ GetColor()

◆ GetEnd()

◆ GetParent()

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::GetParent ( void  ) const
inlineinherited

◆ GetPenWidth()

int WS_DRAW_ITEM_LINE::GetPenWidth ( ) const
inline

◆ GetStart()

◆ GetType()

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::GetType ( ) const
inlineinherited

Definition at line 85 of file worksheet_shape_builder.h.

85 { return m_type; };

References WS_DRAW_ITEM_BASE::m_type.

Referenced by KIGFX::WORKSHEET_VIEWITEM::ViewDraw().

◆ HitTest() [1/2]

bool WS_DRAW_ITEM_LINE::HitTest ( const wxPoint &  aPosition) const
overridevirtual

Virtual function return true if the point aPosition is on the line.

Implements WS_DRAW_ITEM_BASE.

Reimplemented in WS_DRAW_ITEM_RECT.

Definition at line 420 of file page_layout_graphic_items.cpp.

421 {
422  return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 );
423 }
const wxPoint & GetEnd() const
const wxPoint & GetStart() const
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:122

References GetEnd(), GetPenWidth(), GetStart(), and TestSegmentHit().

◆ HitTest() [2/2]

bool WS_DRAW_ITEM_LINE::HitTest ( const EDA_RECT aRect) const
overridevirtual

Virtual function return true if the rect aRect intersects on the item.

Implements WS_DRAW_ITEM_BASE.

Reimplemented in WS_DRAW_ITEM_RECT.

Definition at line 426 of file page_layout_graphic_items.cpp.

427 {
428  return aRect.Intersects( GetStart(), GetEnd() );
429 }
const wxPoint & GetEnd() const
const wxPoint & GetStart() const
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.

References GetEnd(), GetStart(), and EDA_RECT::Intersects().

◆ HitTestEndPoint()

bool WS_DRAW_ITEM_LINE::HitTestEndPoint ( wxDC *  aDC,
const wxPoint &  aPosition 
)
overridevirtual

return true if the point aPosition is on the ending point of this item This is avirtual function which should be overriden for items defien by 2 points

Reimplemented from WS_DRAW_ITEM_BASE.

Reimplemented in WS_DRAW_ITEM_RECT.

Definition at line 445 of file page_layout_graphic_items.cpp.

446 {
447  wxPoint dist = GetEnd() - aPosition;
448  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
449 
450  if( std::abs( dist.x) <= marker_size / 2 &&
451  std::abs( dist.y) <= marker_size / 2 )
452  return true;
453 
454  return false;
455 }
static const int dist[10][10]
Definition: ar_matrix.cpp:320
const wxPoint & GetEnd() const
#define abs(a)
Definition: auxiliary.h:84
static double getScaleFromZoom(wxDC *aDC)
static int GetMarkerSizeUi(double aZoomScale=1.0)

References abs, dist, GetEnd(), WORKSHEET_DATAITEM::GetMarkerSizeUi(), and getScaleFromZoom().

◆ HitTestStartPoint()

bool WS_DRAW_ITEM_LINE::HitTestStartPoint ( wxDC *  aDC,
const wxPoint &  aPosition 
)
overridevirtual

return true if the point aPosition is on the starting point of this item.

Implements WS_DRAW_ITEM_BASE.

Reimplemented in WS_DRAW_ITEM_RECT.

Definition at line 432 of file page_layout_graphic_items.cpp.

433 {
434  wxPoint dist = GetStart() - aPosition;
435  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
436 
437  if( std::abs( dist.x) <= marker_size / 2 &&
438  std::abs( dist.y) <= marker_size / 2 )
439  return true;
440 
441  return false;
442 }
static const int dist[10][10]
Definition: ar_matrix.cpp:320
#define abs(a)
Definition: auxiliary.h:84
const wxPoint & GetStart() const
static double getScaleFromZoom(wxDC *aDC)
static int GetMarkerSizeUi(double aZoomScale=1.0)

References abs, dist, WORKSHEET_DATAITEM::GetMarkerSizeUi(), getScaleFromZoom(), and GetStart().

Member Data Documentation

◆ m_color

COLOR4D WS_DRAW_ITEM_BASE::m_color
protectedinherited

◆ m_end

wxPoint WS_DRAW_ITEM_LINE::m_end
private

Definition at line 140 of file worksheet_shape_builder.h.

Referenced by GetEnd(), and WS_DRAW_ITEM_LINE().

◆ m_Flags

int WS_DRAW_ITEM_BASE::m_Flags
inherited

◆ m_parent

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::m_parent
protectedinherited

◆ m_penWidth

int WS_DRAW_ITEM_LINE::m_penWidth
private

Definition at line 141 of file worksheet_shape_builder.h.

Referenced by GetPenWidth(), and WS_DRAW_ITEM_LINE().

◆ m_start

wxPoint WS_DRAW_ITEM_LINE::m_start
private

Definition at line 139 of file worksheet_shape_builder.h.

Referenced by GetStart(), and WS_DRAW_ITEM_LINE().

◆ m_type

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::m_type
protectedinherited

The documentation for this class was generated from the following files: