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 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef GRAPHICS_IMPORT_PLUGIN_H
27 #define GRAPHICS_IMPORT_PLUGIN_H
28 
29 #include <wx/arrstr.h>
30 
31 class GRAPHICS_IMPORTER;
32 
37 {
38 public:
40  {
41  }
42 
46  virtual void SetImporter( GRAPHICS_IMPORTER* aImporter )
47  {
48  m_importer = aImporter;
49  }
50 
56  virtual const wxString GetName() const = 0;
57 
61  virtual const wxArrayString GetFileExtensions() const = 0;
62 
67  wxString GetWildcards() const
68  {
69  wxString ret;
70  bool first = true;
71 
72  for( const auto& extension : GetFileExtensions() )
73  {
74  if( first )
75  first = false;
76  else
77  ret += ", ";
78 
79  ret += "*." + extension;
80  }
81 
82  return ret;
83  }
84 
90  virtual bool Load( const wxString& aFileName ) = 0;
91 
97  virtual double GetImageHeight() const = 0;
98 
104  virtual double GetImageWidth() const = 0;
105 
111  virtual bool Import() = 0;
112 
113  virtual void SetLineWidthMM( double aLineWidth ) {}
114 
120  const virtual std::string& GetMessages() const = 0;
121 
122 protected:
125 };
126 
127 
128 #endif /* GRAPHICS_IMPORT_PLUGIN_H */
Interface that creates objects representing shapes for a given data model.
virtual const std::string & GetMessages() const =0
Collect warning and error messages after loading/importing.
Interface for vector graphics import plugins.
virtual const wxArrayString GetFileExtensions() const =0
Return a string array of the file extensions handled by this plugin.
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 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.