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 wxPointGetStart () const
 
const wxPointGetEnd () 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 (const wxPoint &aPosition) override
 return true if the point aPosition is on the starting point of this item. More...
 
virtual bool HitTestEndPoint (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

Constructor & Destructor Documentation

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)

Member Function Documentation

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.

References UNSPECIFIED_DRAWMODE.

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.
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 396 of file page_layout_graphic_items.cpp.

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

398 {
399  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
400  GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset,
401  GetPenWidth(),
402  ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
403  GRSetDrawMode( aDC, GR_COPY );
404 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
const wxPoint & GetEnd() const
COLOR4D GetColor() const
const wxPoint & GetStart() const
WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::GetParent ( void  ) const
inlineinherited
int WS_DRAW_ITEM_LINE::GetPenWidth ( ) const
inline
WS_DRAW_TYPE WS_DRAW_ITEM_BASE::GetType ( ) const
inlineinherited

Definition at line 85 of file worksheet_shape_builder.h.

References WS_DRAW_ITEM_BASE::m_type.

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

85 { return m_type; };
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 407 of file page_layout_graphic_items.cpp.

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

408 {
409  return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 );
410 }
const wxPoint & GetEnd() 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:142
const wxPoint & GetStart() const
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 413 of file page_layout_graphic_items.cpp.

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

414 {
415  return aRect.Intersects( GetStart(), GetEnd() );
416 }
const wxPoint & GetEnd() const
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
const wxPoint & GetStart() const
bool WS_DRAW_ITEM_LINE::HitTestEndPoint ( 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 431 of file page_layout_graphic_items.cpp.

References abs, dist, GetEnd(), WORKSHEET_DATAITEM::GetMarkerSizeUi(), wxPoint::x, and wxPoint::y.

432 {
433  wxPoint dist = GetEnd() - aPosition;
434 
435  if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
437  return true;
438 
439  return false;
440 }
static const int dist[10][10]
Definition: dist.cpp:57
#define abs(a)
Definition: auxiliary.h:84
const wxPoint & GetEnd() const
bool WS_DRAW_ITEM_LINE::HitTestStartPoint ( 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 419 of file page_layout_graphic_items.cpp.

References abs, dist, WORKSHEET_DATAITEM::GetMarkerSizeUi(), GetStart(), wxPoint::x, and wxPoint::y.

420 {
421  wxPoint dist = GetStart() - aPosition;
422 
423  if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
425  return true;
426 
427  return false;
428 }
static const int dist[10][10]
Definition: dist.cpp:57
#define abs(a)
Definition: auxiliary.h:84
const wxPoint & GetStart() const

Member Data Documentation

COLOR4D WS_DRAW_ITEM_BASE::m_color
protectedinherited

Definition at line 66 of file worksheet_shape_builder.h.

Referenced by WS_DRAW_ITEM_BASE::GetColor().

wxPoint WS_DRAW_ITEM_LINE::m_end
private

Definition at line 140 of file worksheet_shape_builder.h.

Referenced by GetEnd().

int WS_DRAW_ITEM_BASE::m_Flags
inherited

Definition at line 61 of file worksheet_shape_builder.h.

Referenced by PL_EDITOR_FRAME::Locate().

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::m_parent
protectedinherited

Definition at line 67 of file worksheet_shape_builder.h.

Referenced by WS_DRAW_ITEM_BASE::GetParent().

int WS_DRAW_ITEM_LINE::m_penWidth
private

Definition at line 141 of file worksheet_shape_builder.h.

Referenced by GetPenWidth().

wxPoint WS_DRAW_ITEM_LINE::m_start
private

Definition at line 139 of file worksheet_shape_builder.h.

Referenced by GetStart().

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::m_type
protectedinherited

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