KiCad PCB EDA Suite
WS_DRAW_ITEM_BITMAP Class Reference

#include <worksheet_shape_builder.h>

Inheritance diagram for WS_DRAW_ITEM_BITMAP:
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_BITMAP (WORKSHEET_DATAITEM *aParent, wxPoint aPos)
 
 WS_DRAW_ITEM_BITMAP ()
 
 ~WS_DRAW_ITEM_BITMAP ()
 
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_BITMAP. More...
 
virtual bool HitTest (const wxPoint &aPosition) const override
 Virtual function return true if the point aPosition is on bitmap. 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 reference point of this item. More...
 
const wxPoint GetPosition () const
 
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...
 
virtual bool HitTestEndPoint (wxDC *aDC, const wxPoint &aPosition)
 return true if the point aPosition is near the ending point of this item This is avirtual function which should be overriden for items defien by 2 points the maxi dist is WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 More...
 

Public Attributes

int m_Flags
 

Protected Attributes

WS_DRAW_TYPE m_type
 
COLOR4D m_color
 
WORKSHEET_DATAITEMm_parent
 

Private Attributes

wxPoint m_pos
 

Detailed Description

Definition at line 324 of file worksheet_shape_builder.h.

Member Enumeration Documentation

◆ WS_DRAW_TYPE

Constructor & Destructor Documentation

◆ WS_DRAW_ITEM_BITMAP() [1/2]

WS_DRAW_ITEM_BITMAP::WS_DRAW_ITEM_BITMAP ( WORKSHEET_DATAITEM aParent,
wxPoint  aPos 
)
inline

Definition at line 329 of file worksheet_shape_builder.h.

330  :WS_DRAW_ITEM_BASE( aParent, wsg_bitmap, COLOR4D::UNSPECIFIED )
331  {
332  m_pos = aPos;
333  }
WS_DRAW_ITEM_BASE(WORKSHEET_DATAITEM *aParent, WS_DRAW_TYPE aType, COLOR4D aColor)

References m_pos.

◆ WS_DRAW_ITEM_BITMAP() [2/2]

WS_DRAW_ITEM_BITMAP::WS_DRAW_ITEM_BITMAP ( )
inline

Definition at line 335 of file worksheet_shape_builder.h.

336  :WS_DRAW_ITEM_BASE( NULL, wsg_bitmap, COLOR4D::UNSPECIFIED )
337  {
338  }
WS_DRAW_ITEM_BASE(WORKSHEET_DATAITEM *aParent, WS_DRAW_TYPE aType, COLOR4D aColor)

◆ ~WS_DRAW_ITEM_BITMAP()

WS_DRAW_ITEM_BITMAP::~WS_DRAW_ITEM_BITMAP ( )
inline

Definition at line 340 of file worksheet_shape_builder.h.

340 {}

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_BITMAP::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_BITMAP.

Implements WS_DRAW_ITEM_BASE.

Definition at line 486 of file page_layout_graphic_items.cpp.

488 {
490 
491  if( parent->m_ImageBitmap )
492  {
493  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
494  parent->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
495  GRSetDrawMode( aDC, GR_COPY );
496  }
497 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
WORKSHEET_DATAITEM * GetParent() const
void DrawBitmap(wxDC *aDC, const wxPoint &aPos)

References BITMAP_BASE::DrawBitmap(), WS_DRAW_ITEM_BASE::GetParent(), GR_COPY, GRSetDrawMode(), WORKSHEET_DATAITEM_BITMAP::m_ImageBitmap, m_pos, and UNSPECIFIED_DRAWMODE.

◆ GetColor()

◆ GetParent()

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::GetParent ( void  ) const
inlineinherited

◆ GetPosition()

const wxPoint WS_DRAW_ITEM_BITMAP::GetPosition ( ) const
inline

Definition at line 364 of file worksheet_shape_builder.h.

364 { return m_pos; }

References m_pos.

Referenced by KIGFX::WORKSHEET_VIEWITEM::draw(), WS_DRAW_ITEM_LIST::Draw(), and PlotWorkSheet().

◆ 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_BITMAP::HitTest ( const wxPoint &  aPosition) const
overridevirtual

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

Implements WS_DRAW_ITEM_BASE.

Definition at line 500 of file page_layout_graphic_items.cpp.

501 {
502  const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
503 
504  if( parent->m_ImageBitmap == NULL )
505  return false;
506 
507  EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
508  rect.Move( m_pos );
509  return rect.Contains( aPosition );
510 }
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
bool Contains(const wxPoint &aPoint) const
Function Contains.
const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
WORKSHEET_DATAITEM * GetParent() const
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

References EDA_RECT::Contains(), BITMAP_BASE::GetBoundingBox(), WS_DRAW_ITEM_BASE::GetParent(), WORKSHEET_DATAITEM_BITMAP::m_ImageBitmap, m_pos, and EDA_RECT::Move().

◆ HitTest() [2/2]

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

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

Implements WS_DRAW_ITEM_BASE.

Definition at line 513 of file page_layout_graphic_items.cpp.

514 {
515  const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
516 
517  if( parent->m_ImageBitmap == NULL )
518  return false;
519 
520  EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
521  rect.Move( m_pos );
522  return rect.Intersects( aRect );
523 }
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
WORKSHEET_DATAITEM * GetParent() const
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.

References BITMAP_BASE::GetBoundingBox(), WS_DRAW_ITEM_BASE::GetParent(), EDA_RECT::Intersects(), WORKSHEET_DATAITEM_BITMAP::m_ImageBitmap, m_pos, and EDA_RECT::Move().

◆ HitTestEndPoint()

virtual bool WS_DRAW_ITEM_BASE::HitTestEndPoint ( wxDC *  aDC,
const wxPoint &  aPosition 
)
inlinevirtualinherited

return true if the point aPosition is near the ending point of this item This is avirtual function which should be overriden for items defien by 2 points the maxi dist is WORKSHEET_DATAITEM::GetMarkerSizeUi()/2

Reimplemented in WS_DRAW_ITEM_RECT, and WS_DRAW_ITEM_LINE.

Definition at line 130 of file worksheet_shape_builder.h.

131  {
132  return false;
133  }

◆ HitTestStartPoint()

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

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

Implements WS_DRAW_ITEM_BASE.

Definition at line 529 of file page_layout_graphic_items.cpp.

530 {
531  wxPoint dist = m_pos - aPosition;
532  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
533 
534  if( std::abs( dist.x) <= marker_size / 2 &&
535  std::abs( dist.y) <= marker_size / 2 )
536  return true;
537 
538  return false;
539 }
static const int dist[10][10]
Definition: ar_matrix.cpp:320
#define abs(a)
Definition: auxiliary.h:84
static double getScaleFromZoom(wxDC *aDC)
static int GetMarkerSizeUi(double aZoomScale=1.0)

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

Member Data Documentation

◆ m_color

COLOR4D WS_DRAW_ITEM_BASE::m_color
protectedinherited

◆ m_Flags

int WS_DRAW_ITEM_BASE::m_Flags
inherited

◆ m_parent

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::m_parent
protectedinherited

◆ m_pos

wxPoint WS_DRAW_ITEM_BITMAP::m_pos
private

◆ m_type

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::m_type
protectedinherited

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