KiCad PCB EDA Suite
Loading...
Searching...
No Matches
REFERENCE_IMAGE Class Reference

A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference for the user. More...

#include <reference_image.h>

Public Member Functions

 REFERENCE_IMAGE (const EDA_IU_SCALE &aIuScale)
 
 REFERENCE_IMAGE (const REFERENCE_IMAGE &aOther)
 
 ~REFERENCE_IMAGE ()
 
REFERENCE_IMAGEoperator= (const REFERENCE_IMAGE &aOther)
 
bool operator== (const REFERENCE_IMAGE &aOther) const
 
double Similarity (const REFERENCE_IMAGE &aOther) const
 
BOX2I GetBoundingBox () const
 
bool HitTest (const BOX2I &aRect, bool aContained, int aAccuracy) const
 
VECTOR2I GetPosition () const
 
void SetPosition (const VECTOR2I &aPos)
 
VECTOR2I GetSize () const
 
double GetImageScale () const
 
void SetImageScale (double aScale)
 Set the image "zoom" value.
 
void SetWidth (int aWidth)
 
void SetHeight (int aHeight)
 
void Flip (const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
 
void Rotate (const VECTOR2I &aCenter, const EDA_ANGLE &aAngle)
 
bool ReadImageFile (const wxString &aFullFilename)
 Read and store an image file.
 
bool ReadImageFile (wxMemoryBuffer &aBuf)
 Read and store an image file.
 
bool SetImage (const wxImage &aImage)
 Set the image from an existing wxImage.
 
void SwapData (REFERENCE_IMAGE &aItem)
 
const BITMAP_BASEGetImage () const
 Get the underlying image.
 
BITMAP_BASEMutableImage () const
 Only use this if you really need to modify the underlying image.
 
VECTOR2I GetTransformOriginOffset () const
 Get the center of scaling, etc, relative to the image center (GetPosition()).
 
void SetTransformOriginOffset (const VECTOR2I &aCenter)
 

Private Member Functions

void scaleBy (double ratio)
 
void updatePixelSizeInIU ()
 

Private Attributes

const EDA_IU_SCALEm_iuScale
 
VECTOR2I m_pos
 XY coordinates of center of the bitmap.
 
VECTOR2I m_transformOriginOffset
 Center of scaling, etc, relative to the image center.
 
std::unique_ptr< BITMAP_BASEm_bitmapBase
 

Detailed Description

A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference for the user.

Definition at line 42 of file reference_image.h.

Constructor & Destructor Documentation

◆ REFERENCE_IMAGE() [1/2]

REFERENCE_IMAGE::REFERENCE_IMAGE ( const EDA_IU_SCALE & aIuScale)

◆ REFERENCE_IMAGE() [2/2]

REFERENCE_IMAGE::REFERENCE_IMAGE ( const REFERENCE_IMAGE & aOther)

◆ ~REFERENCE_IMAGE()

REFERENCE_IMAGE::~REFERENCE_IMAGE ( )

Definition at line 49 of file reference_image.cpp.

Member Function Documentation

◆ Flip()

void REFERENCE_IMAGE::Flip ( const VECTOR2I & aCentre,
FLIP_DIRECTION aFlipDirection )

◆ GetBoundingBox()

BOX2I REFERENCE_IMAGE::GetBoundingBox ( ) const

◆ GetImage()

const BITMAP_BASE & REFERENCE_IMAGE::GetImage ( ) const

◆ GetImageScale()

double REFERENCE_IMAGE::GetImageScale ( ) const
Returns
the image "zoom" value. scale = 1.0 = original size of bitmap. scale < 1.0 = the bitmap is drawn smaller than its original size. scale > 1.0 = the bitmap is drawn bigger than its original size.

Definition at line 194 of file reference_image.cpp.

References m_bitmapBase.

Referenced by BOOST_DATA_TEST_CASE_F(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_IO_KICAD_SEXPR::format(), SCH_IO_KICAD_LEGACY::loadBitmap(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), SCH_IO_KICAD_LEGACY::saveBitmap(), SCH_IO_KICAD_SEXPR::saveBitmap(), BITMAP_POINT_EDIT_BEHAVIOR::UpdateItem(), and REFERENCE_IMAGE_POINT_EDIT_BEHAVIOR::UpdateItem().

◆ GetPosition()

◆ GetSize()

◆ GetTransformOriginOffset()

◆ HitTest()

bool REFERENCE_IMAGE::HitTest ( const BOX2I & aRect,
bool aContained,
int aAccuracy ) const

References REFERENCE_IMAGE().

◆ MutableImage()

BITMAP_BASE & REFERENCE_IMAGE::MutableImage ( ) const

Only use this if you really need to modify the underlying image.

Definition at line 310 of file reference_image.cpp.

References m_bitmapBase.

Referenced by DIALOG_REFERENCE_IMAGE_PROPERTIES::DIALOG_REFERENCE_IMAGE_PROPERTIES(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), and DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow().

◆ operator=()

REFERENCE_IMAGE & REFERENCE_IMAGE::operator= ( const REFERENCE_IMAGE & aOther)

◆ operator==()

◆ ReadImageFile() [1/2]

bool REFERENCE_IMAGE::ReadImageFile ( const wxString & aFullFilename)

Read and store an image file.

Initialize the bitmap used to draw this item format.

Parameters
aFullFilenameis the full filename of the image file to read.
Returns
true if success reading else false.

Definition at line 267 of file reference_image.cpp.

References m_bitmapBase, and updatePixelSizeInIU().

Referenced by SCH_IO_KICAD_LEGACY::loadBitmap(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), SCH_IO_ALTIUM::ParseImage(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), SCH_EASYEDA_PARSER::ParseSchematic(), and SCH_EASYEDAPRO_PARSER::ParseSchematic().

◆ ReadImageFile() [2/2]

bool REFERENCE_IMAGE::ReadImageFile ( wxMemoryBuffer & aBuf)

Read and store an image file.

Initialize the bitmap used to draw this item format.

Parameters
aBufis the memory buffer containing the image file to read.
Returns
true if success reading else false.

Definition at line 279 of file reference_image.cpp.

References m_bitmapBase, and updatePixelSizeInIU().

◆ Rotate()

void REFERENCE_IMAGE::Rotate ( const VECTOR2I & aCenter,
const EDA_ANGLE & aAngle )

◆ scaleBy()

void REFERENCE_IMAGE::scaleBy ( double ratio)
private

◆ SetHeight()

void REFERENCE_IMAGE::SetHeight ( int aHeight)

Definition at line 184 of file reference_image.cpp.

References m_bitmapBase, and scaleBy().

◆ SetImage()

bool REFERENCE_IMAGE::SetImage ( const wxImage & aImage)

Set the image from an existing wxImage.

Definition at line 291 of file reference_image.cpp.

References m_bitmapBase, and updatePixelSizeInIU().

◆ SetImageScale()

void REFERENCE_IMAGE::SetImageScale ( double aScale)

Set the image "zoom" value.

The image is scaled such that the position of the image's transform origin is unchanged.

If the scale is negative or the image would overflow the the coordinate system, nothing is updated.

Definition at line 200 of file reference_image.cpp.

References m_bitmapBase, and scaleBy().

Referenced by SCH_IO_KICAD_LEGACY::loadBitmap(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), SCH_IO_ALTIUM::ParseImage(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), BITMAP_POINT_EDIT_BEHAVIOR::UpdateItem(), and REFERENCE_IMAGE_POINT_EDIT_BEHAVIOR::UpdateItem().

◆ SetPosition()

void REFERENCE_IMAGE::SetPosition ( const VECTOR2I & aPos)

Definition at line 145 of file reference_image.cpp.

References BOX2< VECTOR2D >::ByCenter(), IsBOX2Safe(), m_bitmapBase, and m_pos.

◆ SetTransformOriginOffset()

void REFERENCE_IMAGE::SetTransformOriginOffset ( const VECTOR2I & aCenter)

◆ SetWidth()

void REFERENCE_IMAGE::SetWidth ( int aWidth)

Definition at line 174 of file reference_image.cpp.

References m_bitmapBase, and scaleBy().

◆ Similarity()

◆ SwapData()

void REFERENCE_IMAGE::SwapData ( REFERENCE_IMAGE & aItem)

Definition at line 316 of file reference_image.cpp.

References m_bitmapBase, m_pos, m_transformOriginOffset, and REFERENCE_IMAGE().

◆ updatePixelSizeInIU()

void REFERENCE_IMAGE::updatePixelSizeInIU ( )
private

Member Data Documentation

◆ m_bitmapBase

◆ m_iuScale

const EDA_IU_SCALE& REFERENCE_IMAGE::m_iuScale
private

◆ m_pos

VECTOR2I REFERENCE_IMAGE::m_pos
private

XY coordinates of center of the bitmap.

Definition at line 143 of file reference_image.h.

Referenced by Flip(), GetBoundingBox(), GetPosition(), operator=(), operator==(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), Rotate(), scaleBy(), SetPosition(), Similarity(), and SwapData().

◆ m_transformOriginOffset

VECTOR2I REFERENCE_IMAGE::m_transformOriginOffset
private

Center of scaling, etc, relative to the image center.

Definition at line 146 of file reference_image.h.

Referenced by GetTransformOriginOffset(), operator=(), operator==(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), scaleBy(), SetTransformOriginOffset(), and SwapData().


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