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 
30 #include <wx/arrstr.h>
31 
32 class GRAPHICS_IMPORTER;
33 
38 {
39 public:
41  {
42  }
43 
47  virtual void SetImporter( GRAPHICS_IMPORTER* aImporter )
48  {
49  m_importer = aImporter;
50  }
51 
57  virtual const wxString GetName() const = 0;
58 
62  virtual const std::vector<std::string> GetFileExtensions() const = 0;
63 
68  wxString GetWildcards() const
69  {
70  wxString ret;
71  bool first = true;
72 
73  for( const auto& extension : GetFileExtensions() )
74  {
75  if( first )
76  first = false;
77  else
78  ret += ";";
79 
80  ret += "*." + formatWildcardExt( extension );
81  }
82 
83  return ret;
84  }
85 
91  virtual bool Load( const wxString& aFileName ) = 0;
92 
98  virtual double GetImageHeight() const = 0;
99 
105  virtual double GetImageWidth() const = 0;
106 
112  virtual bool Import() = 0;
113 
114  virtual void SetLineWidthMM( double aLineWidth ) {}
115 
121  const virtual std::string& GetMessages() const = 0;
122 
123 protected:
126 };
127 
128 
129 #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 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.