2018-10-13 18:37:28 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 CERN
|
2019-04-03 15:29:17 +00:00
|
|
|
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-10-13 18:37:28 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRAPHICS_IMPORT_PLUGIN_H
|
|
|
|
#define GRAPHICS_IMPORT_PLUGIN_H
|
|
|
|
|
|
|
|
#include <wx/arrstr.h>
|
|
|
|
|
|
|
|
class GRAPHICS_IMPORTER;
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Interface for vector graphics import plugins.
|
2018-10-13 18:37:28 +00:00
|
|
|
*/
|
|
|
|
class GRAPHICS_IMPORT_PLUGIN
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GRAPHICS_IMPORT_PLUGIN()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Set the receiver of the imported shapes.
|
2018-10-13 18:37:28 +00:00
|
|
|
*/
|
2019-04-03 15:29:17 +00:00
|
|
|
virtual void SetImporter( GRAPHICS_IMPORTER* aImporter )
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
m_importer = aImporter;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Return the plugin name.
|
2018-10-13 18:37:28 +00:00
|
|
|
*
|
|
|
|
* This string will be used as the description in the file dialog.
|
|
|
|
*/
|
|
|
|
virtual const wxString GetName() const = 0;
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Return a string array of the file extensions handled by this plugin.
|
2018-10-13 18:37:28 +00:00
|
|
|
*/
|
|
|
|
virtual const wxArrayString GetFileExtensions() const = 0;
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Return a list of wildcards that contains the file extensions
|
2018-10-13 18:37:28 +00:00
|
|
|
* handled by this plugin, separated with a coma.
|
|
|
|
*/
|
|
|
|
wxString GetWildcards() const
|
|
|
|
{
|
|
|
|
wxString ret;
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
for( const auto& extension : GetFileExtensions() )
|
|
|
|
{
|
|
|
|
if( first )
|
|
|
|
first = false;
|
|
|
|
else
|
|
|
|
ret += ", ";
|
|
|
|
|
|
|
|
ret += "*." + extension;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Load file for import.
|
2018-10-13 18:37:28 +00:00
|
|
|
*
|
|
|
|
* It is necessary to have the GRAPHICS_IMPORTER object set before.
|
|
|
|
*/
|
|
|
|
virtual bool Load( const wxString& aFileName ) = 0;
|
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Return image height from original imported file.
|
2018-10-13 18:37:28 +00:00
|
|
|
*
|
2018-11-05 16:04:05 +00:00
|
|
|
* @return Original Image height in mm.
|
2018-10-13 18:37:28 +00:00
|
|
|
*/
|
2018-11-05 16:04:05 +00:00
|
|
|
virtual double GetImageHeight() const = 0;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Return image width from original imported file.
|
2018-10-13 18:37:28 +00:00
|
|
|
*
|
2018-11-05 16:04:05 +00:00
|
|
|
* @return Original Image width in mm.
|
2018-10-13 18:37:28 +00:00
|
|
|
*/
|
2018-11-05 16:04:05 +00:00
|
|
|
virtual double GetImageWidth() const = 0;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Actually imports the file.
|
2018-10-13 18:37:28 +00:00
|
|
|
*
|
|
|
|
* It is necessary to have loaded the file beforehand.
|
|
|
|
*/
|
2018-11-05 16:04:05 +00:00
|
|
|
virtual bool Import() = 0;
|
|
|
|
|
2019-04-03 15:29:17 +00:00
|
|
|
virtual void SetLineWidthMM( double aLineWidth ) {}
|
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
/**
|
2019-04-03 15:29:17 +00:00
|
|
|
* Collect warning and error messages after loading/importing.
|
|
|
|
*
|
2018-11-05 16:04:05 +00:00
|
|
|
* @return the list of messages in one string. Each message ends by '\n'
|
|
|
|
*/
|
|
|
|
const virtual std::string& GetMessages() const = 0;
|
|
|
|
|
2018-10-13 18:37:28 +00:00
|
|
|
protected:
|
|
|
|
///> Importer used to create objects representing the imported shapes.
|
|
|
|
GRAPHICS_IMPORTER* m_importer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* GRAPHICS_IMPORT_PLUGIN_H */
|