KiCad PCB EDA Suite
GRAPHICS_IMPORT_MGR Class Reference

Class to 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
 

Vector containing all GFX_FILE_T values that can be imported.

More...
 
std::unique_ptr< GRAPHICS_IMPORT_PLUGINGetPluginByExt (const wxString &aExtension) const
 

Returns a plugin that handles a specific file extension.

More...
 
std::unique_ptr< GRAPHICS_IMPORT_PLUGINGetPlugin (GFX_FILE_T aType) const
 

Returns a plugin instance for a specific file type.

More...
 

Private Attributes

TYPE_LIST m_importableTypes
 

Detailed Description

Class to manage vector graphics importers.

Definition at line 37 of file graphics_import_mgr.h.

Member Typedef Documentation

Definition at line 47 of file graphics_import_mgr.h.

Member Enumeration Documentation

List of handled file types.

Enumerator
DXF 
SVG 

Definition at line 41 of file graphics_import_mgr.h.

Constructor & Destructor Documentation

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)

Definition at line 31 of file graphics_import_mgr.cpp.

References DXF, m_importableTypes, and SVG.

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

Member Function Documentation

TYPE_LIST GRAPHICS_IMPORT_MGR::GetImportableFileTypes ( ) const
inline

Vector containing all GFX_FILE_T values that can be imported.

Definition at line 57 of file graphics_import_mgr.h.

References GetPlugin(), GetPluginByExt(), and m_importableTypes.

Referenced by GetPluginByExt().

58  {
59  return m_importableTypes;
60  }
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > GRAPHICS_IMPORT_MGR::GetPlugin ( GFX_FILE_T  aType) const

Returns a plugin instance for a specific file type.

Definition at line 47 of file graphics_import_mgr.cpp.

References DXF, and SVG.

Referenced by GetImportableFileTypes(), and GetPluginByExt().

48 {
49  std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> ret;
50 
51  switch( aType )
52  {
53  case DXF: ret = std::make_unique<DXF_IMPORT_PLUGIN>(); break;
54 
55  case SVG: ret = std::make_unique<SVG_IMPORT_PLUGIN>(); break;
56 
57  default: throw std::runtime_error( "Unhandled graphics format" ); break;
58  }
59 
60  return ret;
61 }
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > GRAPHICS_IMPORT_MGR::GetPluginByExt ( const wxString &  aExtension) const

Returns a plugin that handles a specific file extension.

Definition at line 64 of file graphics_import_mgr.cpp.

References GetImportableFileTypes(), and GetPlugin().

Referenced by GetImportableFileTypes().

66 {
67  for( auto fileType : GetImportableFileTypes() )
68  {
69  auto plugin = GetPlugin( fileType );
70  auto fileExtensions = plugin->GetFileExtensions();
71 
72  for( const auto& fileExt : fileExtensions )
73  {
74  if( aExtension.IsSameAs( fileExt, false ) )
75  return plugin;
76  }
77  }
78 
79  return {};
80 }
TYPE_LIST GetImportableFileTypes() const
Vector containing all GFX_FILE_T values that can be imported.
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > GetPlugin(GFX_FILE_T aType) const
Returns a plugin instance for a specific file type.

Member Data Documentation

TYPE_LIST GRAPHICS_IMPORT_MGR::m_importableTypes
private

Definition at line 69 of file graphics_import_mgr.h.

Referenced by GetImportableFileTypes(), and GRAPHICS_IMPORT_MGR().


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