|
KiCad PCB EDA Suite
|
Import a raster image by tracing its dark areas into filled polygons. More...
#include <bitmap_import_plugin.h>
Public Member Functions | |
| const wxString | GetName () const override |
| Return the plugin name. | |
| const std::vector< std::string > | GetFileExtensions () const override |
| Return a vector of the file extensions handled by this plugin. | |
| const wxString & | GetMessages () const override |
| Collect warning and error messages after loading/importing. | |
| void | ReportMsg (const wxString &aMessage) override |
| bool | Load (const wxString &aFileName) override |
| Load file for import. | |
| bool | LoadFromMemory (const wxMemoryBuffer &aMemBuffer) override |
| Set memory buffer with content for import. | |
| bool | Import () override |
| Actually imports the file. | |
| double | GetImageWidth () const override |
| Return image width from original imported file. | |
| double | GetImageHeight () const override |
| Return image height from original imported file. | |
| BOX2D | GetImageBBox () const override |
| Return image bounding box from original imported file. | |
| const wxImage & | GetImage () const |
| The loaded image, so a caller showing a preview does not have to read the file again. | |
| void | SetThreshold (double aThreshold) |
| Brightness cut deciding which pixels are traced, from 0 to 1. | |
| void | SetInvert (bool aInvert) |
| Invert the image before the threshold is applied. | |
| virtual void | SetImporter (GRAPHICS_IMPORTER *aImporter) |
| Set the receiver of the imported shapes. | |
| wxString | GetWildcards () const |
| Return a list of wildcards that contains the file extensions handled by this plugin, separated with a semi-colon. | |
| virtual void | SetLineWidthMM (double aLineWidth) |
Static Public Attributes | |
| static constexpr double | DEFAULT_THRESHOLD = 0.5 |
| Used when the caller offers the user no threshold setting. | |
| static constexpr int | DEFAULT_DPI = 300 |
| Resolution assumed for images that do not carry one. | |
Protected Attributes | |
| GRAPHICS_IMPORTER * | m_importer |
| Importer used to create objects representing the imported shapes. | |
Private Member Functions | |
| double | pixelSizeXmm () const |
| double | pixelSizeYmm () const |
Private Attributes | |
| wxImage | m_image |
| double | m_threshold = DEFAULT_THRESHOLD |
| bool | m_invert = false |
| wxString | m_messages |
Import a raster image by tracing its dark areas into filled polygons.
The image is reduced to black and white at a threshold, then traced. Geometry is reported in millimetres, taken from the image resolution.
Definition at line 35 of file bitmap_import_plugin.h.
|
inlineoverridevirtual |
Return a vector of the file extensions handled by this plugin.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 46 of file bitmap_import_plugin.h.
|
inline |
The loaded image, so a caller showing a preview does not have to read the file again.
Definition at line 65 of file bitmap_import_plugin.h.
References m_image.
|
overridevirtual |
Return image bounding box from original imported file.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 109 of file bitmap_import_plugin.cpp.
References GetImageHeight(), and GetImageWidth().
|
overridevirtual |
Return image height from original imported file.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 103 of file bitmap_import_plugin.cpp.
References m_image, and pixelSizeYmm().
Referenced by BOOST_FIXTURE_TEST_CASE(), and GetImageBBox().
|
overridevirtual |
Return image width from original imported file.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 97 of file bitmap_import_plugin.cpp.
References m_image, and pixelSizeXmm().
Referenced by BOOST_FIXTURE_TEST_CASE(), and GetImageBBox().
|
inlineoverridevirtual |
Collect warning and error messages after loading/importing.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 52 of file bitmap_import_plugin.h.
References m_messages.
|
inlineoverridevirtual |
Return the plugin name.
This string will be used as the description in the file dialog.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 44 of file bitmap_import_plugin.h.
|
inlineinherited |
Return a list of wildcards that contains the file extensions handled by this plugin, separated with a semi-colon.
Definition at line 61 of file graphics_import_plugin.h.
References formatWildcardExt(), and GetFileExtensions().
|
overridevirtual |
Actually imports the file.
It is necessary to have loaded the file beforehand.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 115 of file bitmap_import_plugin.cpp.
References ConvertImageToBilevel(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), m_image, GRAPHICS_IMPORT_PLUGIN::m_importer, m_invert, m_threshold, SHAPE_POLY_SET::OutlineCount(), pixelSizeXmm(), pixelSizeYmm(), SHAPE_LINE_CHAIN::PointCount(), reporter, ReportMsg(), SOLID, TRACE_SUBUNITS, TraceBilevelImage(), COLOR4D::UNSPECIFIED, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().
|
overridevirtual |
Load file for import.
It is necessary to have the GRAPHICS_IMPORTER object set before.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 45 of file bitmap_import_plugin.cpp.
References m_image.
|
overridevirtual |
Set memory buffer with content for import.
It is necessary to have the GRAPHICS_IMPORTER object set before.
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 55 of file bitmap_import_plugin.cpp.
References m_image.
Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().
|
private |
Definition at line 85 of file bitmap_import_plugin.cpp.
References DEFAULT_DPI, imageResolution(), m_image, and MM_PER_INCH.
Referenced by GetImageWidth(), and Import().
|
private |
Definition at line 91 of file bitmap_import_plugin.cpp.
References DEFAULT_DPI, imageResolution(), m_image, and MM_PER_INCH.
Referenced by GetImageHeight(), and Import().
|
overridevirtual |
Implements GRAPHICS_IMPORT_PLUGIN.
Definition at line 38 of file bitmap_import_plugin.cpp.
References m_messages.
Referenced by Import().
|
inlinevirtualinherited |
Set the receiver of the imported shapes.
Reimplemented in DXF_IMPORT_PLUGIN.
Definition at line 43 of file graphics_import_plugin.h.
References m_importer.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), ConvertSVGToLibShapes(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), SCH_EASYEDAPRO_V3_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSymbol(), SCH_EASYEDAPRO_V3_PARSER::ParseSymbol(), SCH_EASYEDA_PARSER::ParseSymbolShapes(), and DXF_IMPORT_PLUGIN::SetImporter().
|
inline |
Invert the image before the threshold is applied.
Definition at line 71 of file bitmap_import_plugin.h.
References m_invert.
|
inlinevirtualinherited |
Reimplemented in DXF_IMPORT_PLUGIN.
Definition at line 121 of file graphics_import_plugin.h.
|
inline |
Brightness cut deciding which pixels are traced, from 0 to 1.
Definition at line 68 of file bitmap_import_plugin.h.
References m_threshold.
|
staticconstexpr |
Resolution assumed for images that do not carry one.
Definition at line 42 of file bitmap_import_plugin.h.
Referenced by pixelSizeXmm(), and pixelSizeYmm().
|
staticconstexpr |
Used when the caller offers the user no threshold setting.
Definition at line 39 of file bitmap_import_plugin.h.
|
private |
Definition at line 77 of file bitmap_import_plugin.h.
Referenced by GetImage(), GetImageHeight(), GetImageWidth(), Import(), Load(), LoadFromMemory(), pixelSizeXmm(), and pixelSizeYmm().
|
protectedinherited |
Importer used to create objects representing the imported shapes.
Definition at line 134 of file graphics_import_plugin.h.
Referenced by BITMAP_IMPORT_PLUGIN::Import(), DXF_IMPORT_PLUGIN::Import(), SVG_IMPORT_PLUGIN::Import(), SVG_IMPORT_PLUGIN::Load(), SVG_IMPORT_PLUGIN::LoadFromMemory(), DXF_IMPORT_PLUGIN::SetImporter(), and SetImporter().
|
private |
Definition at line 79 of file bitmap_import_plugin.h.
Referenced by Import(), and SetInvert().
|
private |
Definition at line 80 of file bitmap_import_plugin.h.
Referenced by GetMessages(), and ReportMsg().
|
private |
Definition at line 78 of file bitmap_import_plugin.h.
Referenced by Import(), and SetThreshold().