KiCad PCB EDA Suite
graphics_import_plugin.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 CERN
5  * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef GRAPHICS_IMPORT_PLUGIN_H
28 #define GRAPHICS_IMPORT_PLUGIN_H
29 
31 #include <wx/arrstr.h>
32 
33 class GRAPHICS_IMPORTER;
34 
39 {
40 public:
42  {
43  }
44 
48  virtual void SetImporter( GRAPHICS_IMPORTER* aImporter )
49  {
50  m_importer = aImporter;
51  }
52 
58  virtual const wxString GetName() const = 0;
59 
63  virtual const std::vector<std::string> GetFileExtensions() const = 0;
64 
69  wxString GetWildcards() const
70  {
71  wxString ret;
72  bool first = true;
73 
74  for( const auto& extension : GetFileExtensions() )
75  {
76  if( first )
77  first = false;
78  else
79  ret += ";";
80 
81  ret += "*." + formatWildcardExt( extension );
82  }
83 
84  return ret;
85  }
86 
92  virtual bool Load( const wxString& aFileName ) = 0;
93 
99  virtual double GetImageHeight() const = 0;
100 
106  virtual double GetImageWidth() const = 0;
107 
113  virtual bool Import() = 0;
114 
115  virtual void SetLineWidthMM( double aLineWidth ) {}
116 
122  const virtual wxString& GetMessages() const = 0;
123 
124 protected:
127 };
128 
129 
130 #endif /* GRAPHICS_IMPORT_PLUGIN_H */
Interface that creates objects representing shapes for a given data model.
Interface for vector graphics import plugins.
virtual const wxString & GetMessages() const =0
Collect warning and error messages after loading/importing.
virtual bool Import()=0
Actually imports the file.
virtual const wxString GetName() const =0
Return the plugin name.
virtual double GetImageWidth() const =0
Return image width from original imported file.
virtual const std::vector< std::string > GetFileExtensions() const =0
Return a vector of the file extensions handled by this plugin.
Definition of file extensions used in Kicad.
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
virtual double GetImageHeight() const =0
Return image height from original imported file.
virtual void SetLineWidthMM(double aLineWidth)
virtual void SetImporter(GRAPHICS_IMPORTER *aImporter)
Set the receiver of the imported shapes.
GRAPHICS_IMPORTER * m_importer
< Importer used to create objects representing the imported shapes.
wxString GetWildcards() const
Return a list of wildcards that contains the file extensions handled by this plugin,...
virtual bool Load(const wxString &aFileName)=0
Load file for import.