KiCad PCB EDA Suite
WS_DRAW_ITEM_RECT Class Reference

#include <worksheet_shape_builder.h>

Inheritance diagram for WS_DRAW_ITEM_RECT:
WS_DRAW_ITEM_LINE WS_DRAW_ITEM_BASE

Public Types

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

Public Member Functions

 WS_DRAW_ITEM_RECT (WORKSHEET_DATAITEM *aParent, wxPoint aStart, wxPoint aEnd, int aPenWidth, COLOR4D aColor)
 
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_RECT. More...
 
virtual bool HitTest (const wxPoint &aPosition) const override
 Virtual function return true if the point aPosition is on one edge of the rectangle. 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...
 
int GetPenWidth () const
 
const wxPointGetStart () const
 
const wxPointGetEnd () const
 
virtual void DrawWsItem (EDA_RECT *aClipBox, wxDC *aDC)
 The function to draw a WS_DRAW_ITEM. More...
 
COLOR4D GetColor () const
 
WS_DRAW_TYPE GetType () const
 
WORKSHEET_DATAITEMGetParent () const
 

Public Attributes

int m_Flags
 

Protected Attributes

WS_DRAW_TYPE m_type
 
COLOR4D m_color
 
WORKSHEET_DATAITEMm_parent
 

Detailed Description

Definition at line 240 of file worksheet_shape_builder.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 243 of file worksheet_shape_builder.h.

References WS_DRAW_ITEM_BASE::m_type, and WS_DRAW_ITEM_BASE::wsg_rect.

245  :
246  WS_DRAW_ITEM_LINE( aParent, aStart, aEnd, aPenWidth, aColor )
247  {
248  m_type = wsg_rect;
249  }
WS_DRAW_ITEM_LINE(WORKSHEET_DATAITEM *aParent, wxPoint aStart, wxPoint aEnd, int aPenWidth, 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_RECT::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_RECT.

Reimplemented from WS_DRAW_ITEM_LINE.

Definition at line 291 of file page_layout_graphic_items.cpp.

References WS_DRAW_ITEM_BASE::GetColor(), WS_DRAW_ITEM_LINE::GetEnd(), WS_DRAW_ITEM_LINE::GetPenWidth(), WS_DRAW_ITEM_LINE::GetStart(), GR_COPY, GRRect(), GRSetDrawMode(), UNSPECIFIED_DRAWMODE, wxPoint::x, and wxPoint::y.

293 {
294  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
295  GRRect( aClipBox, aDC,
296  GetStart().x + aOffset.x, GetStart().y + aOffset.y,
297  GetEnd().x + aOffset.x, GetEnd().y + aOffset.y,
298  GetPenWidth(),
299  ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
300  GRSetDrawMode( aDC, GR_COPY );
301 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
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
inlineinherited
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_RECT::HitTest ( const wxPoint aPosition) const
overridevirtual

Virtual function return true if the point aPosition is on one edge of the rectangle.

Reimplemented from WS_DRAW_ITEM_LINE.

Definition at line 304 of file page_layout_graphic_items.cpp.

References dist, WS_DRAW_ITEM_LINE::GetEnd(), WS_DRAW_ITEM_LINE::GetPenWidth(), WS_DRAW_ITEM_LINE::GetStart(), TestSegmentHit(), wxPoint::x, and wxPoint::y.

305 {
306  int dist = GetPenWidth()/2;
307  wxPoint start = GetStart();
308  wxPoint end;
309  end.x = GetEnd().x;
310  end.y = start.y;
311 
312  // Upper line
313  if( TestSegmentHit( aPosition, start, end, dist ) )
314  return true;
315 
316  // Right line
317  start = end;
318  end.y = GetEnd().y;
319  if( TestSegmentHit( aPosition, start, end, dist ) )
320  return true;
321 
322  // lower line
323  start = end;
324  end.x = GetStart().x;
325  if( TestSegmentHit( aPosition, start, end, dist ) )
326  return true;
327 
328  // left line
329  start = end;
330  end = GetStart();
331  if( TestSegmentHit( aPosition, start, end, dist ) )
332  return true;
333 
334  return false;
335 }
static const int dist[10][10]
Definition: dist.cpp:57
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_RECT::HitTest ( const EDA_RECT aRect) const
overridevirtual

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

Reimplemented from WS_DRAW_ITEM_LINE.

Definition at line 338 of file page_layout_graphic_items.cpp.

References WS_DRAW_ITEM_LINE::GetEnd(), WS_DRAW_ITEM_LINE::GetStart(), EDA_RECT::Intersects(), wxPoint::x, and wxPoint::y.

339 {
340  wxPoint start = GetStart();
341  wxPoint end;
342  end.x = GetEnd().x;
343  end.y = start.y;
344 
345  // Upper line
346  if( aRect.Intersects( start, end ) )
347  return true;
348 
349  // Right line
350  start = end;
351  end.y = GetEnd().y;
352  if( aRect.Intersects( start, end ) )
353  return true;
354 
355  // lower line
356  start = end;
357  end.x = GetStart().x;
358  if( aRect.Intersects( start, end ) )
359  return true;
360 
361  // left line
362  start = end;
363  end = GetStart();
364  if( aRect.Intersects( start, end ) )
365  return true;
366 
367  return false;
368 }
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_RECT::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_LINE.

Definition at line 383 of file page_layout_graphic_items.cpp.

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

384 {
385  wxPoint pos = GetEnd();
386 
387  int dist = (int) hypot( pos.x - aPosition.x, pos.y - aPosition.y );
388 
389  if( dist <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
390  return true;
391 
392  return false;
393 }
static const int dist[10][10]
Definition: dist.cpp:57
const wxPoint & GetEnd() const
bool WS_DRAW_ITEM_RECT::HitTestStartPoint ( const wxPoint aPosition)
overridevirtual

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

Reimplemented from WS_DRAW_ITEM_LINE.

Definition at line 371 of file page_layout_graphic_items.cpp.

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

372 {
373  wxPoint dist = GetStart() - aPosition;
374 
375  if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
377  return true;
378 
379  return false;
380 }
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().

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

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::m_type
protectedinherited

Definition at line 65 of file worksheet_shape_builder.h.

Referenced by WS_DRAW_ITEM_BASE::GetType(), and WS_DRAW_ITEM_RECT().


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