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  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef GRAPHICS_IMPORT_PLUGIN_H
26 #define GRAPHICS_IMPORT_PLUGIN_H
27 
28 #include <wx/arrstr.h>
29 
30 class GRAPHICS_IMPORTER;
31 
36 {
37 public:
39  {
40  }
41 
45  void SetImporter( GRAPHICS_IMPORTER* aImporter )
46  {
47  m_importer = aImporter;
48  }
49 
55  virtual const wxString GetName() const = 0;
56 
60  virtual const wxArrayString GetFileExtensions() const = 0;
61 
66  wxString GetWildcards() const
67  {
68  wxString ret;
69  bool first = true;
70 
71  for( const auto& extension : GetFileExtensions() )
72  {
73  if( first )
74  first = false;
75  else
76  ret += ", ";
77 
78  ret += "*." + extension;
79  }
80 
81  return ret;
82  }
83 
89  virtual bool Load( const wxString& aFileName ) = 0;
90 
96  virtual double GetImageHeight() const = 0;
97 
103  virtual double GetImageWidth() const = 0;
104 
110  virtual bool Import() = 0;
111 
116  const virtual std::string& GetMessages() const = 0;
117 
118 
119 
120 protected:
123 };
124 
125 
126 #endif /* GRAPHICS_IMPORT_PLUGIN_H */
127 
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
Returns 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
@breif Returns 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.
void SetImporter(GRAPHICS_IMPORTER *aImporter)
Sets the receiver of the imported shapes.
GRAPHICS_IMPORTER * m_importer
Importer used to create objects representing the imported shapes.
wxString GetWildcards() const
Returns a list of wildcards that contains the file extensions handled by this plugin,...
virtual bool Load(const wxString &aFileName)=0
Loads file for import.