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
47 virtual void SetImporter( GRAPHICS_IMPORTER* aImporter ) { m_importer = aImporter; }
48
54 virtual const wxString GetName() const = 0;
55
59 virtual const std::vector<std::string> GetFileExtensions() const = 0;
60
65 wxString GetWildcards() const
66 {
67 wxString ret;
68 bool first = true;
69
70 for( const auto& extension : GetFileExtensions() )
71 {
72 if( first )
73 first = false;
74 else
75 ret += wxT( ";" );
76
77 ret += wxT( "*." ) + formatWildcardExt( extension );
78 }
79
80 return ret;
81 }
82
88 virtual bool Load( const wxString& aFileName ) = 0;
89
95 virtual bool LoadFromMemory( const wxMemoryBuffer& aMemBuffer ) = 0;
96
102 virtual double GetImageHeight() const = 0;
103
109 virtual double GetImageWidth() const = 0;
110
116 virtual BOX2D GetImageBBox() const = 0;
117
123 virtual bool Import() = 0;
124
125 virtual void SetLineWidthMM( double aLineWidth ) {}
126
132 const virtual wxString& GetMessages() const = 0;
133
134 virtual void ReportMsg( const wxString& aMessage ) = 0;
135
136protected:
139};
140
141
142#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 void ReportMsg(const wxString &aMessage)=0
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.