KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
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
30#include <math/box2.h>
32#include <wx/arrstr.h>
33
35
40{
41public:
43 {
44 }
45
49 virtual void SetImporter( GRAPHICS_IMPORTER* aImporter )
50 {
51 m_importer = aImporter;
52 }
53
59 virtual const wxString GetName() const = 0;
60
64 virtual const std::vector<std::string> GetFileExtensions() const = 0;
65
70 wxString GetWildcards() const
71 {
72 wxString ret;
73 bool first = true;
74
75 for( const auto& extension : GetFileExtensions() )
76 {
77 if( first )
78 first = false;
79 else
80 ret += wxT( ";" );
81
82 ret += wxT( "*." ) + formatWildcardExt( extension );
83 }
84
85 return ret;
86 }
87
93 virtual bool Load( const wxString& aFileName ) = 0;
94
100 virtual bool LoadFromMemory( const wxMemoryBuffer& aMemBuffer ) = 0;
101
107 virtual double GetImageHeight() const = 0;
108
114 virtual double GetImageWidth() const = 0;
115
121 virtual BOX2D GetImageBBox() const = 0;
122
128 virtual bool Import() = 0;
129
130 virtual void SetLineWidthMM( double aLineWidth ) {}
131
137 const virtual wxString& GetMessages() const = 0;
138
139protected:
142};
143
144
145#endif /* GRAPHICS_IMPORT_PLUGIN_H */
Interface that creates objects representing shapes for a given data model.
Interface for vector graphics import plugins.
virtual bool LoadFromMemory(const wxMemoryBuffer &aMemBuffer)=0
Set memory buffer with content for import.
virtual bool Load(const wxString &aFileName)=0
Load file for import.
virtual double GetImageHeight() const =0
Return image height from original imported file.
virtual const std::vector< std::string > GetFileExtensions() const =0
Return a vector of the file extensions handled by this plugin.
virtual void SetLineWidthMM(double aLineWidth)
virtual BOX2D GetImageBBox() const =0
Return image bounding box from original imported file.
GRAPHICS_IMPORTER * m_importer
< Importer used to create objects representing the imported shapes.
virtual const wxString & GetMessages() const =0
Collect warning and error messages after loading/importing.
wxString GetWildcards() const
Return a list of wildcards that contains the file extensions handled by this plugin,...
virtual double GetImageWidth() const =0
Return image width from original imported file.
virtual void SetImporter(GRAPHICS_IMPORTER *aImporter)
Set the receiver of the imported shapes.
virtual bool Import()=0
Actually imports the file.
virtual const wxString GetName() const =0
Return the plugin name.
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
Definition of file extensions used in Kicad.