2016-08-22 05:50:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2021-07-18 14:06:48 +00:00
|
|
|
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-08-22 05:50:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2021-07-18 14:06:48 +00:00
|
|
|
* This plugin implements a STEP/IGES model renderer for KiCad via OCE
|
2016-08-22 05:50:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <wx/filename.h>
|
|
|
|
#include "plugins/3d/3d_plugin.h"
|
|
|
|
#include "plugins/3dapi/ifsg_all.h"
|
|
|
|
|
2020-08-17 22:48:20 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-08-22 05:50:38 +00:00
|
|
|
SCENEGRAPH* LoadModel( char const* filename );
|
|
|
|
|
|
|
|
#define PLUGIN_OCE_MAJOR 1
|
2022-09-09 01:43:11 +00:00
|
|
|
#define PLUGIN_OCE_MINOR 4
|
|
|
|
#define PLUGIN_OCE_PATCH 0
|
2016-08-22 05:50:38 +00:00
|
|
|
#define PLUGIN_OCE_REVNO 0
|
|
|
|
|
|
|
|
|
|
|
|
const char* GetKicadPluginName( void )
|
|
|
|
{
|
|
|
|
return "PLUGIN_3D_OCE";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GetPluginVersion( unsigned char* Major,
|
|
|
|
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
|
|
|
|
{
|
|
|
|
if( Major )
|
|
|
|
*Major = PLUGIN_OCE_MAJOR;
|
|
|
|
|
|
|
|
if( Minor )
|
|
|
|
*Minor = PLUGIN_OCE_MINOR;
|
|
|
|
|
|
|
|
if( Patch )
|
|
|
|
*Patch = PLUGIN_OCE_PATCH;
|
|
|
|
|
|
|
|
if( Revision )
|
|
|
|
*Revision = PLUGIN_OCE_REVNO;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2016-08-22 05:50:38 +00:00
|
|
|
static struct FILE_DATA
|
|
|
|
{
|
2020-08-17 22:48:20 +00:00
|
|
|
std::vector<std::string> extensions;
|
|
|
|
std::vector<std::string> filters;
|
2016-08-22 05:50:38 +00:00
|
|
|
|
|
|
|
FILE_DATA()
|
|
|
|
{
|
2020-08-17 22:48:20 +00:00
|
|
|
#ifdef _WIN32
|
2020-10-17 22:01:54 +00:00
|
|
|
extensions = { "stp","step","stpz","stp.gz","step.gz","igs","iges" };
|
2021-07-18 14:06:48 +00:00
|
|
|
filters = {
|
|
|
|
"STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz",
|
|
|
|
"IGES (*.igs;*.iges)|*.igs;*.iges" };
|
2020-08-17 22:48:20 +00:00
|
|
|
#else
|
2021-07-18 14:06:48 +00:00
|
|
|
extensions = {
|
|
|
|
"stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ",
|
|
|
|
"igs","IGS","iges","IGES"
|
|
|
|
};
|
|
|
|
|
|
|
|
filters = {
|
|
|
|
"STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;"
|
|
|
|
"*.STEP.GZ)|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;"
|
|
|
|
"*.step.gz;*.STEP.GZ",
|
|
|
|
"IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES"
|
|
|
|
};
|
2016-08-22 05:50:38 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
} file_data;
|
|
|
|
|
|
|
|
|
|
|
|
int GetNExtensions( void )
|
|
|
|
{
|
2020-08-17 22:48:20 +00:00
|
|
|
return file_data.extensions.size();
|
2016-08-22 05:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char const* GetModelExtension( int aIndex )
|
|
|
|
{
|
2020-08-17 22:48:20 +00:00
|
|
|
if( aIndex < 0 || aIndex >= int( file_data.extensions.size() ) )
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-08-22 05:50:38 +00:00
|
|
|
|
2020-08-17 22:48:20 +00:00
|
|
|
return file_data.extensions[aIndex].c_str();
|
2016-08-22 05:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GetNFilters( void )
|
|
|
|
{
|
2020-08-17 22:48:20 +00:00
|
|
|
return file_data.filters.size();
|
2016-08-22 05:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char const* GetFileFilter( int aIndex )
|
|
|
|
{
|
2020-08-17 22:48:20 +00:00
|
|
|
if( aIndex < 0 || aIndex >= int( file_data.filters.size() ) )
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-08-22 05:50:38 +00:00
|
|
|
|
2020-08-17 22:48:20 +00:00
|
|
|
return file_data.filters[aIndex].c_str();
|
2016-08-22 05:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CanRender( void )
|
|
|
|
{
|
|
|
|
// this plugin supports rendering of IDF component outlines
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCENEGRAPH* Load( char const* aFileName )
|
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == aFileName )
|
|
|
|
return nullptr;
|
2016-08-22 05:50:38 +00:00
|
|
|
|
|
|
|
wxString fname = wxString::FromUTF8Unchecked( aFileName );
|
|
|
|
|
|
|
|
if( !wxFileName::FileExists( fname ) )
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-08-22 05:50:38 +00:00
|
|
|
|
|
|
|
return LoadModel( aFileName );
|
|
|
|
}
|