|
KiCad PCB EDA Suite
|
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_IMAGE & | operator= (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) |
| bool | Flip (const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) |
| void | Rotate (const VECTOR2I &aCenter, const EDA_ANGLE &aAngle) |
| Rotate the image about aCenter. | |
| EDA_ANGLE | GetOrientation () const |
| void | SetOrientation (const EDA_ANGLE &aAngle) |
| Set the rotation of the image content relative to the stored raster. | |
| double | GetOpacity () const |
| void | SetOpacity (double aOpacity) |
| 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 | PackToBytes (std::string &aOutputBytes) const |
| bool | UnpackFromBytes (const std::string &aInputBytes) |
| void | SwapData (REFERENCE_IMAGE &aItem) |
| const BITMAP_BASE & | GetImage () const |
| Get the underlying image. | |
| BITMAP_BASE & | MutableImage () const |
| Only use this if you really need to modify the underlying image. | |
| void | PlotImage (PLOTTER *aPlotter, const VECTOR2I &aPos, const KIGFX::COLOR4D &aDefaultColor, int aDefaultPensize) const |
| Plot the image on a plotter, turned to its stored orientation. | |
| 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 () |
| VECTOR2I | boundingSize () const |
Private Attributes | |
| const EDA_IU_SCALE & | m_iuScale |
| VECTOR2I | m_pos |
| XY coordinates of center of the bitmap. | |
| VECTOR2I | m_transformOriginOffset |
| Center of scaling, etc, relative to the image center. | |
| EDA_ORIENTATION | m_orientation |
| Rotation of the image content relative to the raster, in [0, 360). | |
| double | m_opacity |
| The opacity of the image, in the range [0, 1]. | |
| std::unique_ptr< BITMAP_BASE > | m_bitmapBase |
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 41 of file reference_image.h.
| REFERENCE_IMAGE::REFERENCE_IMAGE | ( | const EDA_IU_SCALE & | aIuScale | ) |
Definition at line 67 of file reference_image.cpp.
References ANGLE_0, m_bitmapBase, m_iuScale, m_opacity, m_orientation, m_pos, m_transformOriginOffset, and updatePixelSizeInIU().
Referenced by operator=(), operator==(), REFERENCE_IMAGE(), Similarity(), and SwapData().
| REFERENCE_IMAGE::REFERENCE_IMAGE | ( | const REFERENCE_IMAGE & | aOther | ) |
Definition at line 79 of file reference_image.cpp.
References m_bitmapBase, m_iuScale, m_opacity, m_orientation, m_pos, m_transformOriginOffset, REFERENCE_IMAGE(), and updatePixelSizeInIU().
| REFERENCE_IMAGE::~REFERENCE_IMAGE | ( | ) |
Definition at line 91 of file reference_image.cpp.
|
private |
Definition at line 189 of file reference_image.cpp.
References std::abs(), EDA_ANGLE::Cos(), EDA_ANGLE::IsHorizontal(), EDA_ANGLE::IsVertical(), KiROUND(), m_bitmapBase, m_orientation, EDA_ANGLE::Sin(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by Flip(), GetBoundingBox(), scaleBy(), and SetPosition().
| bool REFERENCE_IMAGE::Flip | ( | const VECTOR2I & | aCentre, |
| FLIP_DIRECTION | aFlipDirection ) |
| aCentre | |
| aFlipDirection | LEFT_RIGHT or TOP_BOTTOM |
Definition at line 311 of file reference_image.cpp.
References boundingSize(), BOX2< VECTOR2D >::ByCenter(), IsBOX2Safe(), m_bitmapBase, m_orientation, m_pos, m_transformOriginOffset, and MIRROR().
Referenced by BOOST_FIXTURE_TEST_CASE().
| BOX2I REFERENCE_IMAGE::GetBoundingBox | ( | ) | const |
Definition at line 183 of file reference_image.cpp.
References boundingSize(), BOX2< VECTOR2I >::ByCenter(), and m_pos.
Referenced by PCB_GRID_HELPER::AddConstructionItems(), BOOST_FIXTURE_TEST_CASE(), and PCB_GRID_HELPER::computeAnchors().
| const BITMAP_BASE & REFERENCE_IMAGE::GetImage | ( | ) | const |
Get the underlying image.
This will always return a valid reference, but it may be to an empty image.
Definition at line 424 of file reference_image.cpp.
References m_bitmapBase.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_DATA_TEST_CASE_F(), BOOST_FIXTURE_TEST_CASE(), checkTransformedBoardUsesOnlyKnownTokens(), checkTransformedSchematicUsesOnlyKnownTokens(), compensateImageScale(), compensateReferenceImageScales(), DIALOG_IMAGE_PROPERTIES::DIALOG_IMAGE_PROPERTIES(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_IO_KICAD_SEXPR::format(), PCB_WRITER_V10::format(), PCB_WRITER_V9::format(), SCH_IO_KICAD_LEGACY::loadBitmap(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), ORCAD_CONVERTER::placeBitmap(), SCH_IO_KICAD_LEGACY::saveBitmap(), SCH_IO_KICAD_SEXPR::saveBitmap(), SCH_WRITER_V10::saveBitmap(), and SCH_WRITER_V9::saveBitmap().
| double REFERENCE_IMAGE::GetImageScale | ( | ) | const |
Definition at line 267 of file reference_image.cpp.
References m_bitmapBase.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_DATA_TEST_CASE_F(), checkTransformedBoardUsesOnlyKnownTokens(), checkTransformedSchematicUsesOnlyKnownTokens(), compensateImageScale(), compensateReferenceImageScales(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_IO_KICAD_SEXPR::format(), PCB_WRITER_V10::format(), PCB_WRITER_V9::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(), SCH_WRITER_V10::saveBitmap(), and SCH_WRITER_V9::saveBitmap().
|
inline |
Definition at line 112 of file reference_image.h.
References m_opacity.
Referenced by BOOST_AUTO_TEST_CASE(), countBitmapsWithOpacity(), countReferenceImageOpacities(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_IO_KICAD_SEXPR::format(), and SCH_IO_KICAD_SEXPR::saveBitmap().
| EDA_ANGLE REFERENCE_IMAGE::GetOrientation | ( | ) | const |
Definition at line 341 of file reference_image.cpp.
References m_orientation.
Referenced by BOOST_FIXTURE_TEST_CASE(), DRAWING_TOOL::ConvertImageToOutlines(), SCH_EDIT_TOOL::ConvertImageToOutlines(), countReferenceImageRotations(), countRotatedBitmaps(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_IO_KICAD_SEXPR::format(), and SCH_IO_KICAD_SEXPR::saveBitmap().
| VECTOR2I REFERENCE_IMAGE::GetPosition | ( | ) | const |
Definition at line 212 of file reference_image.cpp.
References m_pos.
Referenced by PCB_GRID_HELPER::AddConstructionItems(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), DRAWING_TOOL::ConvertImageToOutlines(), SCH_EDIT_TOOL::ConvertImageToOutlines(), KIGFX::PCB_PAINTER::draw(), SCH_IO_KICAD_SEXPR::saveBitmap(), SCH_WRITER_V10::saveBitmap(), and SCH_WRITER_V9::saveBitmap().
| VECTOR2I REFERENCE_IMAGE::GetSize | ( | ) | const |
Definition at line 241 of file reference_image.cpp.
References m_bitmapBase.
Referenced by BOOST_FIXTURE_TEST_CASE(), DRAWING_TOOL::ConvertImageToOutlines(), SCH_EDIT_TOOL::ConvertImageToOutlines(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseFootprint(), SCH_IO_ALTIUM::ParseImage(), SCH_IO_GEDA::parsePicture(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), SCH_EASYEDAPRO_V3_PARSER::ParseSchematic(), and ORCAD_CONVERTER::placeBitmap().
| VECTOR2I REFERENCE_IMAGE::GetTransformOriginOffset | ( | ) | const |
Get the center of scaling, etc, relative to the image center (GetPosition()).
Definition at line 229 of file reference_image.cpp.
References m_transformOriginOffset.
Referenced by PCB_GRID_HELPER::AddConstructionItems(), BOOST_FIXTURE_TEST_CASE(), and PCB_GRID_HELPER::computeAnchors().
| bool REFERENCE_IMAGE::HitTest | ( | const BOX2I & | aRect, |
| bool | aContained, | ||
| int | aAccuracy ) const |
| BITMAP_BASE & REFERENCE_IMAGE::MutableImage | ( | ) | const |
Only use this if you really need to modify the underlying image.
Definition at line 431 of file reference_image.cpp.
References m_bitmapBase.
Referenced by DRAWING_TOOL::ConvertImageToOutlines(), SCH_EDIT_TOOL::ConvertImageToOutlines(), DIALOG_REFERENCE_IMAGE_PROPERTIES::DIALOG_REFERENCE_IMAGE_PROPERTIES(), TARGET3001_SCH_BUILDER::makePicture(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseFootprint(), and DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow().
| REFERENCE_IMAGE & REFERENCE_IMAGE::operator= | ( | const REFERENCE_IMAGE & | aOther | ) |
Definition at line 103 of file reference_image.cpp.
References EDA_IU_SCALE::IU_PER_MILS, m_bitmapBase, m_iuScale, m_opacity, m_orientation, m_pos, m_transformOriginOffset, REFERENCE_IMAGE(), and updatePixelSizeInIU().
| bool REFERENCE_IMAGE::operator== | ( | const REFERENCE_IMAGE & | aOther | ) | const |
Definition at line 124 of file reference_image.cpp.
References compareImages(), BITMAP_BASE::GetPPI(), BITMAP_BASE::GetScale(), BITMAP_BASE::GetSize(), m_bitmapBase, m_opacity, m_orientation, m_pos, m_transformOriginOffset, and REFERENCE_IMAGE().
| void REFERENCE_IMAGE::PackToBytes | ( | std::string & | aOutputBytes | ) | const |
Definition at line 395 of file reference_image.cpp.
References m_bitmapBase.
| void REFERENCE_IMAGE::PlotImage | ( | PLOTTER * | aPlotter, |
| const VECTOR2I & | aPos, | ||
| const KIGFX::COLOR4D & | aDefaultColor, | ||
| int | aDefaultPensize ) const |
Plot the image on a plotter, turned to its stored orientation.
This may resample the image depending on the orientation.
| aPlotter | the plotter to use. |
| aPos | the position of the center of the image. |
| aDefaultColor | the color used to plot the rectangle when bitmap is not supported. |
| aDefaultPensize | the pen size used to plot the rectangle when bitmap is not supported. |
Definition at line 437 of file reference_image.cpp.
References ANGLE_180, ANGLE_270, ANGLE_90, EDA_ANGLE::AsRadians(), image, EDA_ANGLE::IsZero(), KiROUND(), m_bitmapBase, m_opacity, m_orientation, PLOTTER::PlotImage(), PLOTTER::SetColor(), and PLOTTER::SetCurrentLineWidth().
| bool REFERENCE_IMAGE::ReadImageFile | ( | const wxString & | aFullFilename | ) |
Read and store an image file.
Initialize the bitmap used to draw this item format.
| aFullFilename | is the full filename of the image file to read. |
Definition at line 359 of file reference_image.cpp.
References m_bitmapBase, and updatePixelSizeInIU().
Referenced by addTransformFeatures(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), SCH_IO_KICAD_LEGACY::loadBitmap(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseFootprint(), SCH_IO_ALTIUM::ParseImage(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), SCH_IO_GEDA::parsePicture(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), SCH_EASYEDAPRO_V3_PARSER::ParseSchematic(), ORCAD_CONVERTER::placeBitmap(), and UnpackFromBytes().
| bool REFERENCE_IMAGE::ReadImageFile | ( | wxMemoryBuffer & | aBuf | ) |
Read and store an image file.
Initialize the bitmap used to draw this item format.
| aBuf | is the memory buffer containing the image file to read. |
Definition at line 371 of file reference_image.cpp.
References m_bitmapBase, and updatePixelSizeInIU().
Rotate the image about aCenter.
The position and the transform origin follow aAngle exactly. The rotation is stored rather than turned into the raster, so the image keeps its resolution and a save followed by a load is lossless for the formats that carry the rotation.
Definition at line 332 of file reference_image.cpp.
References m_orientation, m_pos, m_transformOriginOffset, and RotatePoint().
Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and TARGET3001_SCH_BUILDER::makePicture().
|
private |
Definition at line 283 of file reference_image.cpp.
References boundingSize(), BOX2< VECTOR2D >::ByCenter(), IsBOX2Safe(), IsVec2SafeXY(), KiROUND(), m_bitmapBase, m_pos, m_transformOriginOffset, and SetTransformOriginOffset().
Referenced by SetHeight(), SetImageScale(), and SetWidth().
| void REFERENCE_IMAGE::SetHeight | ( | int | aHeight | ) |
Definition at line 257 of file reference_image.cpp.
References m_bitmapBase, and scaleBy().
| bool REFERENCE_IMAGE::SetImage | ( | const wxImage & | aImage | ) |
Set the image from an existing wxImage.
Definition at line 383 of file reference_image.cpp.
References m_bitmapBase, and updatePixelSizeInIU().
Referenced by BOOST_FIXTURE_TEST_CASE(), TARGET3001_SCH_BUILDER::makePicture(), and ORCAD_CONVERTER::placeBitmap().
| 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 273 of file reference_image.cpp.
References m_bitmapBase, and scaleBy().
Referenced by addTransformFeatures(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), compensateImageScale(), compensateReferenceImageScales(), SCH_IO_KICAD_LEGACY::loadBitmap(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_V3_PARSER::ParseFootprint(), SCH_IO_ALTIUM::ParseImage(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), SCH_IO_GEDA::parsePicture(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), SCH_EASYEDAPRO_V3_PARSER::ParseSchematic(), and ORCAD_CONVERTER::placeBitmap().
| void REFERENCE_IMAGE::SetOpacity | ( | double | aOpacity | ) |
Definition at line 353 of file reference_image.cpp.
References m_opacity.
Referenced by BOOST_AUTO_TEST_CASE(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), and DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow().
| void REFERENCE_IMAGE::SetOrientation | ( | const EDA_ANGLE & | aAngle | ) |
Set the rotation of the image content relative to the stored raster.
Definition at line 347 of file reference_image.cpp.
References m_orientation.
Referenced by BOOST_AUTO_TEST_CASE(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), and DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow().
| void REFERENCE_IMAGE::SetPosition | ( | const VECTOR2I & | aPos | ) |
Definition at line 218 of file reference_image.cpp.
References boundingSize(), BOX2< VECTOR2D >::ByCenter(), IsBOX2Safe(), and m_pos.
Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and TARGET3001_SCH_BUILDER::makePicture().
| void REFERENCE_IMAGE::SetTransformOriginOffset | ( | const VECTOR2I & | aCenter | ) |
Definition at line 235 of file reference_image.cpp.
References m_transformOriginOffset.
Referenced by BOOST_FIXTURE_TEST_CASE(), and scaleBy().
| void REFERENCE_IMAGE::SetWidth | ( | int | aWidth | ) |
Definition at line 247 of file reference_image.cpp.
References m_bitmapBase, and scaleBy().
Referenced by TARGET3001_SCH_BUILDER::makePicture().
| double REFERENCE_IMAGE::Similarity | ( | const REFERENCE_IMAGE & | aOther | ) | const |
Definition at line 154 of file reference_image.cpp.
References compareImages(), BITMAP_BASE::GetPPI(), BITMAP_BASE::GetScale(), BITMAP_BASE::GetSize(), m_bitmapBase, m_opacity, m_orientation, m_pos, and REFERENCE_IMAGE().
| void REFERENCE_IMAGE::SwapData | ( | REFERENCE_IMAGE & | aItem | ) |
Definition at line 505 of file reference_image.cpp.
References m_bitmapBase, m_opacity, m_orientation, m_pos, m_transformOriginOffset, and REFERENCE_IMAGE().
| bool REFERENCE_IMAGE::UnpackFromBytes | ( | const std::string & | aInputBytes | ) |
Definition at line 412 of file reference_image.cpp.
References ReadImageFile().
|
private |
Definition at line 96 of file reference_image.cpp.
References m_bitmapBase, and m_iuScale.
Referenced by operator=(), ReadImageFile(), ReadImageFile(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), and SetImage().
|
private |
Definition at line 200 of file reference_image.h.
Referenced by boundingSize(), Flip(), GetImage(), GetImageScale(), GetSize(), MutableImage(), operator=(), operator==(), PackToBytes(), PlotImage(), ReadImageFile(), ReadImageFile(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), scaleBy(), SetHeight(), SetImage(), SetImageScale(), SetWidth(), Similarity(), SwapData(), and updatePixelSizeInIU().
|
private |
Definition at line 187 of file reference_image.h.
Referenced by operator=(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), and updatePixelSizeInIU().
|
private |
The opacity of the image, in the range [0, 1].
Definition at line 198 of file reference_image.h.
Referenced by GetOpacity(), operator=(), operator==(), PlotImage(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), SetOpacity(), Similarity(), and SwapData().
|
private |
Rotation of the image content relative to the raster, in [0, 360).
Definition at line 195 of file reference_image.h.
Referenced by boundingSize(), Flip(), GetOrientation(), operator=(), operator==(), PlotImage(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), Rotate(), SetOrientation(), Similarity(), and SwapData().
|
private |
XY coordinates of center of the bitmap.
Definition at line 189 of file reference_image.h.
Referenced by Flip(), GetBoundingBox(), GetPosition(), operator=(), operator==(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), Rotate(), scaleBy(), SetPosition(), Similarity(), and SwapData().
|
private |
Center of scaling, etc, relative to the image center.
Definition at line 192 of file reference_image.h.
Referenced by Flip(), GetTransformOriginOffset(), operator=(), operator==(), REFERENCE_IMAGE(), REFERENCE_IMAGE(), Rotate(), scaleBy(), SetTransformOriginOffset(), and SwapData().