KiCad PCB EDA Suite
GRAPHICS_IMPORT_MGR Class Reference

Manage vector graphics importers. More...

#include <graphics_import_mgr.h>

Public Types

enum  GFX_FILE_T { DXF , SVG }
 < List of handled file types. More...
 
using TYPE_LIST = std::vector< GFX_FILE_T >
 

Public Member Functions

 GRAPHICS_IMPORT_MGR (const TYPE_LIST &aBlacklist)
 Construct an import plugin manager, with a specified list of filetypes that are not permitted (can be used for when some file type support is not available due to config or other reasons) More...
 
TYPE_LIST GetImportableFileTypes () const
 Returns a plugin that handles a specific file extension. More...
 
std::unique_ptr< GRAPHICS_IMPORT_PLUGINGetPluginByExt (const wxString &aExtension) const
 Returns a plugin instance for a specific file type. More...
 
std::unique_ptr< GRAPHICS_IMPORT_PLUGINGetPlugin (GFX_FILE_T aType) const
 

Private Attributes

TYPE_LIST m_importableTypes
 

Detailed Description

Manage vector graphics importers.

Definition at line 39 of file graphics_import_mgr.h.

Member Typedef Documentation

◆ TYPE_LIST

Definition at line 49 of file graphics_import_mgr.h.

Member Enumeration Documentation

◆ GFX_FILE_T

< List of handled file types.

Enumerator
DXF 
SVG 

Definition at line 43 of file graphics_import_mgr.h.

Constructor & Destructor Documentation

◆ GRAPHICS_IMPORT_MGR()

GRAPHICS_IMPORT_MGR::GRAPHICS_IMPORT_MGR ( const TYPE_LIST aBlacklist)

Construct an import plugin manager, with a specified list of filetypes that are not permitted (can be used for when some file type support is not available due to config or other reasons)

Vector containing all GFX_FILE_T values that can be imported.

Definition at line 34 of file graphics_import_mgr.cpp.

35{
36 // This is the full list of types, from which we'll subtract our blacklist
37 static const TYPE_LIST all_types = {
38 DXF,
39 SVG,
40 };
41
42 std::copy_if( all_types.begin(), all_types.end(), std::back_inserter( m_importableTypes ),
43 [&aBlacklist]( const GFX_FILE_T& arg )
44 {
45 return !alg::contains( aBlacklist, arg );
46 } );
47}
GFX_FILE_T
< List of handled file types.
std::vector< GFX_FILE_T > TYPE_LIST

References DXF, m_importableTypes, and SVG.

Member Function Documentation

◆ GetImportableFileTypes()

TYPE_LIST GRAPHICS_IMPORT_MGR::GetImportableFileTypes ( ) const
inline

Returns a plugin that handles a specific file extension.

Definition at line 59 of file graphics_import_mgr.h.

References m_importableTypes.

Referenced by GetPluginByExt().

◆ GetPlugin()

std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > GRAPHICS_IMPORT_MGR::GetPlugin ( GFX_FILE_T  aType) const

Definition at line 50 of file graphics_import_mgr.cpp.

51{
52 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> ret;
53
54 switch( aType )
55 {
56 case DXF: ret = std::make_unique<DXF_IMPORT_PLUGIN>(); break;
57
58 case SVG: ret = std::make_unique<SVG_IMPORT_PLUGIN>(); break;
59
60 default: throw std::runtime_error( "Unhandled graphics format" ); break;
61 }
62
63 return ret;
64}

References DXF, and SVG.

Referenced by BOOST_AUTO_TEST_CASE(), and GetPluginByExt().

◆ GetPluginByExt()

std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > GRAPHICS_IMPORT_MGR::GetPluginByExt ( const wxString &  aExtension) const

Returns a plugin instance for a specific file type.

Definition at line 67 of file graphics_import_mgr.cpp.

69{
70 for( auto fileType : GetImportableFileTypes() )
71 {
72 auto plugin = GetPlugin( fileType );
73 auto fileExtensions = plugin->GetFileExtensions();
74
75 if( compareFileExtensions( aExtension.ToStdString(), fileExtensions ) )
76 return plugin;
77 }
78
79 return {};
80}
TYPE_LIST GetImportableFileTypes() const
Returns a plugin that handles a specific file extension.
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > GetPlugin(GFX_FILE_T aType) const
bool compareFileExtensions(const std::string &aExtension, const std::vector< std::string > &aReference, bool aCaseSensitive)
Compare the given extension against the reference extensions to see if it matches any of the referenc...
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)

References compareFileExtensions(), fileType(), GetImportableFileTypes(), and GetPlugin().

Referenced by BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ m_importableTypes

TYPE_LIST GRAPHICS_IMPORT_MGR::m_importableTypes
private

Definition at line 71 of file graphics_import_mgr.h.

Referenced by GetImportableFileTypes(), and GRAPHICS_IMPORT_MGR().


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