Finished refactor and introduction of generic Plugin scheme

This commit is contained in:
Cirilo Bernardo 2015-12-14 14:51:28 +11:00
parent 3ff8ca0caf
commit a2fe783f53
23 changed files with 463 additions and 412 deletions

View File

@ -135,7 +135,9 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
#endif
fn.Assign( wxStandardPaths::Get().GetPluginsDir() );
#ifndef _WIN32 // suppress 'kicad' subdir since it is redundant on MSWin
fn.AppendDir( wxT( "kicad" ) );
#endif
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );

View File

@ -3,7 +3,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/3d-viewer
)
add_library( s3d_sg SHARED
add_library( kicad_3dsg SHARED
sg_base.cpp
sg_node.cpp
sg_helpers.cpp
@ -31,21 +31,60 @@ add_library( s3d_sg SHARED
ifsg_api.cpp
)
# Define a flag to expose the appropriate EXPORT macro at build time
target_compile_definitions( s3d_sg PRIVATE -DCOMPILE_SGLIB )
find_file( S3DSG_VERSION_FILE sg_version.h
PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH )
target_link_libraries( s3d_sg ${wxWidgets_LIBRARIES} )
if( NOT ${S3DSG_VERSION_FILE} STREQUAL "S3DSG_VERSION_FILE-NOTFOUND" )
if( APPLE )
install( TARGETS
s3d_sg
DESTINATION /Applications/kicad.app/SharedSupport
COMPONENT binary
)
# extract the "#define SG_VERSION_*" lines
file( STRINGS ${S3DSG_VERSION_FILE} _version
REGEX "^[' ','\t']*#define[' ','\t']*SG_VERSION_.*" )
foreach( SVAR ${_version} )
string( REGEX MATCH SG_VERSION_[M,A,J,O,R,I,N,P,T,C,H,E,V]* _VARNAME ${SVAR} )
string( REGEX MATCH [0-9]+ _VALUE ${SVAR} )
if( NOT ${_VARNAME} STREQUAL "" )
message( "INFO: " ${_VARNAME} " = " ${_VALUE} )
if( NOT ${_VALUE} STREQUAL "" )
set( ${_VARNAME} ${_VALUE} )
else()
set( ${_VARNAME} 0 )
endif()
endif()
endforeach()
if( NOT SG_VERSION_MAJOR AND NOT ${SG_VERSION_MAJOR} STREQUAL "0" )
message( FATAL_ERROR "Cannot determine the S3DSG library version" )
endif()
#ensure that NOT SG_VERSION* will evaluate to '0'
if( NOT SG_VERSION_MINOR )
set( SG_VERSION_MINOR 0 )
endif()
if( NOT SG_VERSION_PATCH )
set( SG_VERSION_PATCH 0 )
endif()
set_target_properties( kicad_3dsg
PROPERTIES SOVERSION
${SG_VERSION_MAJOR}.${SG_VERSION_MINOR}.${SG_VERSION_PATCH} )
else()
message( FATAL_ERROR "Cannot determine the S3DSG library version" )
endif()
unset( S3DSG_VERSION_FILE CACHE )
# Define a flag to expose the appropriate EXPORT macro at build time
target_compile_definitions( kicad_3dsg PRIVATE -DCOMPILE_SGLIB )
target_link_libraries( kicad_3dsg ${wxWidgets_LIBRARIES} )
install( TARGETS
s3d_sg
DESTINATION lib/kicad
kicad_3dsg
DESTINATION ${KICAD_LIB}
COMPONENT binary
)
endif()

View File

@ -39,6 +39,7 @@
#include "3d_cache/sg/sg_faceset.h"
#include "3d_cache/sg/sg_normals.h"
#include "3d_cache/sg/sg_shape.h"
#include "3d_cache/sg/sg_version.h"
#include "3d_info.h"
#include "plugins/3dapi/c3dmodel.h"
@ -411,3 +412,22 @@ void S3D::Init3DMesh( SMESH& aMesh )
return;
}
void S3D::GetLibVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = SG_VERSION_MAJOR;
if( Minor )
*Minor = SG_VERSION_MINOR;
if( Revision )
*Revision = SG_VERSION_REVNO;
if( Patch )
*Patch = SG_VERSION_PATCH;
return;
}

View File

@ -22,37 +22,17 @@
*/
/**
* @file 3d_plugin_dummy.h
* is a sample dummy plugin which doesn't do much other than serve as
* an example of how a plugin must be built.
* @file sg_version.h
* defines the version number of 3DSG library. This file is parsed by
* CMake to determine the version number of the 3DSG library.
*/
#ifndef SG_VERSION_H
#define SG_VERSION_H
#ifndef PLUGIN_3D_DUMMY_H
#define PLUGIN_3D_DUMMY_H
#define SG_VERSION_MAJOR 1
#define SG_VERSION_MINOR 0
#define SG_VERSION_PATCH 0
#define SG_VERSION_REVNO 0
#include <vector>
#include <plugins/3d/3d_plugin.h>
class SCENEGRAPH;
class S3D_PLUGIN_DUMMY : public S3D_PLUGIN
{
private:
std::vector< wxString > m_extensions; // supported extensions
std::vector< wxString > m_filters; // file filters
public:
S3D_PLUGIN_DUMMY();
virtual ~S3D_PLUGIN_DUMMY();
virtual int GetNExtensions( void ) const;
virtual const wxString GetModelExtension( int aIndex ) const;
virtual int GetNFilters( void ) const;
virtual const wxString GetFileFilter( int aIndex ) const;
bool CanRender( void ) const;
SCENEGRAPH* Load( const wxString& aFileName );
};
#endif // PLUGIN_3D_DUMMY_H
#endif // SG_VERSION_H

View File

@ -147,9 +147,9 @@ elseif(NOT GLM_ENABLE_FAST_MATH)
endif()
if( WIN32 )
target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} s3d_sg )
target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} kicad_3dsg )
else()
target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} s3d_sg dl )
target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} kicad_3dsg dl )
endif()
add_subdirectory( 3d_cache )

View File

@ -341,9 +341,22 @@ if( NOT APPLE )
if( WIN32 )
set( KICAD_PLUGINS ${KICAD_BIN}/scripting/plugins
CACHE PATH "Location of KiCad plugins." )
set( KICAD_LIB ${KICAD_BIN}
CACHE PATH "Location of KiCad shared objects" )
set( KICAD_USER_PLUGIN ${KICAD_BIN}/plugins
CACHE PATH "Location of KiCad user-loaded plugins" )
else()
set( KICAD_PLUGINS lib/kicad/plugins
CACHE PATH "Location of KiCad plugins." )
set( KICAD_LIB ${CMAKE_INSTALL_PREFIX}/lib
CACHE PATH "Location of KiCad shared objects" )
set( KICAD_USER_PLUGIN ${CMAKE_INSTALL_PREFIX}/lib/kicad/plugins
CACHE PATH "Location of KiCad user-loaded plugins" )
endif()
set( KICAD_DATA share/kicad
@ -360,6 +373,12 @@ else()
set( KICAD_BIN ${CMAKE_INSTALL_PREFIX}
CACHE PATH "Location of KiCad binaries." FORCE )
set( KICAD_LIB /Applications/kicad.app/Contents/Macos
CACHE PATH "Location of KiCad shared objects" FORCE )
set( KICAD_USER_PLUGIN /Applications/kicad.app/SharedSupport/plugins
CACHE PATH "Location of KiCad user-loaded plugins" FORCE )
# some paths to single app bundle
set( OSX_BUNDLE_MAIN "kicad.app" )
set( OSX_BUNDLE_BIN_DIR "Contents/MacOS" )
@ -411,6 +430,8 @@ endif()
mark_as_advanced( KICAD_BIN
KICAD_PLUGINS
KICAD_USER_PLUGIN
KICAD_LIB
KICAD_DATA
KICAD_DOCS
KICAD_DEMOS

View File

@ -53,7 +53,7 @@ KICAD_PLUGIN_EXPORT char const* GetKicadPluginClass( void )
KICAD_PLUGIN_EXPORT void GetClassVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Revision, unsigned char* Patch )
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = MAJOR;
@ -61,17 +61,17 @@ KICAD_PLUGIN_EXPORT void GetClassVersion( unsigned char* Major,
if( Minor )
*Minor = MINOR;
if( Revision )
*Revision = REVISION;
if( Patch )
*Patch = PATCH;
if( Revision )
*Revision = REVISION;
return;
}
KICAD_PLUGIN_EXPORT bool CheckClassVersion( unsigned char Major,
unsigned char Minor, unsigned char Revision, unsigned char Patch )
unsigned char Minor, unsigned char Patch, unsigned char Revision )
{
if( Major != MAJOR )
return false;

View File

@ -178,6 +178,9 @@ namespace S3D
* creates and initializes an SMESH struct
*/
SGLIB_API void Init3DMesh( SMESH& aMesh );
SGLIB_API void GetLibVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Patch, unsigned char* Revision );
};
#endif // IFSG_API_H

View File

@ -30,6 +30,7 @@
#ifndef IFSG_COLORS_H
#define IFSG_COLORS_H
#include <cstdlib>
#include "plugins/3dapi/ifsg_node.h"

View File

@ -67,7 +67,7 @@ KICAD_PLUGIN_EXPORT char const* GetKicadPluginClass( void );
* @param Patch will hold the Plugin Class Patch level
*/
KICAD_PLUGIN_EXPORT void GetClassVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Revision, unsigned char* Patch );
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision );
/**
* Function CheckClassVersion
@ -80,7 +80,7 @@ KICAD_PLUGIN_EXPORT void GetClassVersion( unsigned char* Major,
* of the return value of this function.
*/
KICAD_PLUGIN_EXPORT bool CheckClassVersion( unsigned char Major,
unsigned char Minor, unsigned char Revision, unsigned char Patch );
unsigned char Minor, unsigned char Patch, unsigned char Revision );
/**
* Function GetKicadPluginName
@ -103,10 +103,10 @@ KICAD_PLUGIN_EXPORT const char* GetKicadPluginName( void );
*
* @param Major will hold the Plugin Major version
* @param Minor will hold the Plugin Minor version
* @param Revision will hold the Plugin Revision
* @param Patch will hold the Plugin Patch level
* @param Revision will hold the Plugin Revision
*/
KICAD_PLUGIN_EXPORT void GetVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Revision, unsigned char* Patch );
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision );
#endif // KICAD_PLUGIN_H

View File

@ -1,3 +1,2 @@
#add_subdirectory( dummy )
#add_subdirectory( tetra )
add_subdirectory( demo )
add_subdirectory( idf )

View File

@ -0,0 +1,19 @@
add_library( s3d_plugin_demo1 MODULE
s3d_plugin_demo1.cpp
)
target_link_libraries( s3d_plugin_demo1 ${wxWidgets_LIBRARIES} )
add_library( s3d_plugin_demo2 MODULE
s3d_plugin_demo2.cpp
)
target_link_libraries( s3d_plugin_demo2 kicad_3dsg ${wxWidgets_LIBRARIES} )
install( TARGETS
s3d_plugin_demo1
s3d_plugin_demo2
DESTINATION ${KICAD_USER_PLUGIN}/3d
COMPONENT binary
)

View File

@ -0,0 +1,181 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
*/
/*
* NOTES:
*
* 1. Notice that the plugin class is instantiated as a static; this
* ensures that it created an destroyed.
*/
#include <iostream>
#include "plugins/3d/3d_plugin.h"
#define PLUGIN_3D_DEMO1_MAJOR 1
#define PLUGIN_3D_DEMO1_MINOR 0
#define PLUGIN_3D_DEMO1_PATCH 0
#define PLUGIN_3D_DEMO1_REVNO 0
const char* GetKicadPluginName( void )
{
return "PLUGIN_3D_DEMO1";
}
void GetVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = PLUGIN_3D_DEMO1_MAJOR;
if( Minor )
*Minor = PLUGIN_3D_DEMO1_MINOR;
if( Patch )
*Patch = PLUGIN_3D_DEMO1_PATCH;
if( Revision )
*Revision = PLUGIN_3D_DEMO1_REVNO;
return;
}
// number of extensions supported
#ifdef _WIN32
#define NEXTS 7
#else
#define NEXTS 14
#endif
// number of filter sets supported
#define NFILS 5
static char ext0[] = "wrl";
static char ext1[] = "x3d";
static char ext2[] = "emn";
static char ext3[] = "iges";
static char ext4[] = "igs";
static char ext5[] = "stp";
static char ext6[] = "step";
#ifdef _WIN32
static char fil0[] = "VRML 1.0/2.0 (*.wrl)|*.wrl";
static char fil1[] = "X3D (*.x3d)|*.x3d";
static char fil2[] = "IDF 2.0/3.0 (*.emn)|*.emn";
static char fil3[] = "IGESv5.3 (*.igs;*.iges)|*.igs;*.iges";
static char fil4[] = "STEP (*.stp;*.step)|*.stp;*.step";
#else
static char ext7[] = "WRL";
static char ext8[] = "X3D";
static char ext9[] = "EMN";
static char ext10[] = "IGES";
static char ext11[] = "IGS";
static char ext12[] = "STP";
static char ext13[] = "STEP";
static char fil0[] = "VRML 1.0/2.0 (*.wrl;*.WRL)|*.wrl;*.WRL";
static char fil1[] = "X3D (*.x3d;*.X3D)|*.x3d;*.X3D";
static char fil2[] = "IDF 2.0/3.0 (*.emn;*.EMN)|*.emn;*.EMN";
static char fil3[] = "IGESv5.3 (*.igs;*.iges;*.IGS;*.IGES)|*.igs;*.iges;*.IGS;*.IGES";
static char fil4[] = "STEP (*.stp;*.step;*.STP;*.STEP)|*.stp;*.step;*.STP;*.STEP";
#endif
static struct FILE_DATA
{
char const* extensions[NEXTS];
char const* filters[NFILS];
FILE_DATA()
{
extensions[0] = ext0;
extensions[1] = ext1;
extensions[2] = ext2;
extensions[3] = ext3;
extensions[4] = ext4;
extensions[5] = ext5;
extensions[6] = ext6;
filters[0] = fil0;
filters[1] = fil1;
filters[2] = fil2;
filters[3] = fil3;
filters[4] = fil4;
#ifndef _WIN32
extensions[7] = ext7;
extensions[8] = ext8;
extensions[9] = ext9;
extensions[10] = ext10;
extensions[11] = ext11;
extensions[12] = ext12;
extensions[13] = ext13;
#endif
return;
}
} file_data;
int GetNExtensions( void )
{
return NEXTS;
}
char const* GetModelExtension( int aIndex )
{
if( aIndex < 0 || aIndex >= NEXTS )
return NULL;
return file_data.extensions[aIndex];
}
int GetNFilters( void )
{
return NFILS;
}
char const* GetFileFilter( int aIndex )
{
if( aIndex < 0 || aIndex >= NFILS )
return NULL;
return file_data.filters[aIndex];
}
bool CanRender( void )
{
// this dummy plugin does not support rendering of any models
return false;
}
SCENEGRAPH* Load( char const* aFileName )
{
// this dummy plugin does not support rendering of any models
return NULL;
}

View File

@ -22,72 +22,119 @@
*/
#include <cmath>
#include <s3d_plugin_tetra.h>
#include <plugins/3dapi/ifsg_all.h>
#include "plugins/3d/3d_plugin.h"
#include "plugins/3dapi/ifsg_all.h"
S3D_PLUGIN_TETRA::S3D_PLUGIN_TETRA()
#define PLUGIN_3D_DEMO2_MAJOR 1
#define PLUGIN_3D_DEMO2_MINOR 0
#define PLUGIN_3D_DEMO2_PATCH 0
#define PLUGIN_3D_DEMO2_REVNO 0
const char* GetKicadPluginName( void )
{
m_extensions.push_back( wxString::FromUTF8Unchecked( "wrl" ) );
return "PLUGIN_3D_DEMO2";
}
void GetVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = PLUGIN_3D_DEMO2_MAJOR;
if( Minor )
*Minor = PLUGIN_3D_DEMO2_MINOR;
if( Patch )
*Patch = PLUGIN_3D_DEMO2_PATCH;
if( Revision )
*Revision = PLUGIN_3D_DEMO2_REVNO;
return;
}
// number of extensions supported
#ifdef _WIN32
#define NEXTS 1
#else
#define NEXTS 2
#endif
// number of filter sets supported
#define NFILS 1
static char ext0[] = "wrl";
#ifdef _WIN32
// assume a case-insensitive file system
m_filters.push_back( wxT( "VRML 1.0/2.0 (*.wrl)|*.wrl" ) );
static char fil0[] = "VRML 1.0/2.0 (*.wrl)|*.wrl";
#else
// assume the filesystem is case sensitive
m_extensions.push_back( wxString::FromUTF8Unchecked( "WRL" ) );
static char ext1[] = "WRL";
m_filters.push_back( wxT( "VRML 1.0/2.0 (*.wrl;*.WRL)|*.wrl;*.WRL" ) );
static char fil0[] = "VRML 1.0/2.0 (*.wrl;*.WRL)|*.wrl;*.WRL";
#endif
static struct FILE_DATA
{
char const* extensions[NEXTS];
char const* filters[NFILS];
FILE_DATA()
{
extensions[0] = ext0;
filters[0] = fil0;
#ifndef _WIN32
extensions[1] = ext1;
#endif
return;
}
} file_data;
S3D_PLUGIN_TETRA::~S3D_PLUGIN_TETRA()
int GetNExtensions( void )
{
return;
return NEXTS;
}
int S3D_PLUGIN_TETRA::GetNExtensions( void ) const
char const* GetModelExtension( int aIndex )
{
return (int) m_extensions.size();
if( aIndex < 0 || aIndex >= NEXTS )
return NULL;
return file_data.extensions[aIndex];
}
const wxString S3D_PLUGIN_TETRA::GetModelExtension( int aIndex ) const
int GetNFilters( void )
{
if( aIndex < 0 || aIndex >= (int) m_extensions.size() )
return wxString( "" );
return m_extensions[aIndex];
return NFILS;
}
int S3D_PLUGIN_TETRA::GetNFilters( void ) const
char const* GetFileFilter( int aIndex )
{
return (int)m_filters.size();
if( aIndex < 0 || aIndex >= NFILS )
return NULL;
return file_data.filters[aIndex];
}
const wxString S3D_PLUGIN_TETRA::GetFileFilter( int aIndex ) const
{
if( aIndex < 0 || aIndex >= (int)m_filters.size() )
return wxEmptyString;
return m_filters[aIndex];
}
bool S3D_PLUGIN_TETRA::CanRender( void ) const
bool CanRender( void )
{
// this dummy pretends to render a VRML model
return true;
}
SCENEGRAPH* S3D_PLUGIN_TETRA::Load( const wxString& aFileName )
SCENEGRAPH* Load( char const* aFileName )
{
// For this demonstration we create a tetrahedron and
// paint its faces Magenta Red Green Blue. Steps:
@ -234,18 +281,3 @@ SCENEGRAPH* S3D_PLUGIN_TETRA::Load( const wxString& aFileName )
return (SCENEGRAPH*)data;
}
static S3D_PLUGIN_TETRA plugin_3d_tetra;
#ifndef _WIN32
extern "C" __attribute__((__visibility__("default"))) S3D_PLUGIN* Get3DPlugin( void )
{
return &plugin_3d_tetra;
}
#else
extern "C" __declspec( dllexport ) S3D_PLUGIN* Get3DPlugin( void )
{
return &plugin_3d_tetra;
}
#endif

View File

@ -1,23 +0,0 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
add_library( s3d_plugin_dummy MODULE
s3d_plugin_dummy.cpp
)
target_link_libraries( s3d_plugin_dummy ${wxWidgets_LIBRARIES} )
if( APPLE )
install( TARGETS
s3d_plugin_dummy
DESTINATION /Applications/kicad.app/SharedSupport/plugins/3d
COMPONENT binary
)
else()
install( TARGETS
s3d_plugin_dummy
DESTINATION lib/kicad/plugins/3d
COMPONENT binary
)
endif()

View File

@ -1,136 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
*/
/*
* NOTES:
*
* 1. Notice that the plugin class is instantiated as a static; this
* ensures that it created an destroyed.
*/
#include <iostream>
#include <s3d_plugin_dummy.h>
S3D_PLUGIN_DUMMY::S3D_PLUGIN_DUMMY()
{
m_extensions.push_back( wxString::FromUTF8Unchecked( "wrl" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "x3d" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "idf" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "iges" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "igs" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "stp" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "step" ) );
#ifdef _WIN32
// assume a case-insensitive file system
m_filters.push_back( wxT( "VRML 1.0/2.0 (*.wrl)|*.wrl" ) );
m_filters.push_back( wxT( "X3D (*.x3d)|*.x3d" ) );
m_filters.push_back( wxT( "IDF 2.0/3.0 (*.idf)|*.idf" ) );
m_filters.push_back( wxT( "IGESv5.3 (*.igs;*.iges)|*.igs;*.iges" ) );
m_filters.push_back( wxT( "STEP (*.stp;*.step)|*.stp;*.step" ) );
#else
// assume the filesystem is case sensitive
m_extensions.push_back( wxString::FromUTF8Unchecked( "WRL" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "X3D" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "IDF" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "IGES" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "IGS" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "STP" ) );
m_extensions.push_back( wxString::FromUTF8Unchecked( "STEP" ) );
m_filters.push_back( wxT( "VRML 1.0/2.0 (*.wrl;*.WRL)|*.wrl;*.WRL" ) );
m_filters.push_back( wxT( "X3D (*.x3d;*.X3D)|*.x3d;*.X3D" ) );
m_filters.push_back( wxT( "IDF 2.0/3.0 (*.idf;*.IDF)|*.idf;*.IDF" ) );
m_filters.push_back( wxT( "IGESv5.3 (*.igs;*.iges;*.IGS;*.IGES)|*.igs;*.iges;*.IGS;*.IGES" ) );
m_filters.push_back( wxT( "STEP (*.stp;*.step;*.STP;*.STEP)|*.stp;*.step;*.STP;*.STEP" ) );
#endif
return;
}
S3D_PLUGIN_DUMMY::~S3D_PLUGIN_DUMMY()
{
return;
}
int S3D_PLUGIN_DUMMY::GetNExtensions( void ) const
{
return (int) m_extensions.size();
}
const wxString S3D_PLUGIN_DUMMY::GetModelExtension( int aIndex ) const
{
if( aIndex < 0 || aIndex >= (int) m_extensions.size() )
return wxString( "" );
return m_extensions[aIndex];
}
int S3D_PLUGIN_DUMMY::GetNFilters( void ) const
{
return (int)m_filters.size();
}
const wxString S3D_PLUGIN_DUMMY::GetFileFilter( int aIndex ) const
{
if( aIndex < 0 || aIndex >= (int)m_filters.size() )
return wxEmptyString;
return m_filters[aIndex];
}
bool S3D_PLUGIN_DUMMY::CanRender( void ) const
{
// this dummy plugin does not support rendering of any models
return false;
}
SCENEGRAPH* S3D_PLUGIN_DUMMY::Load( const wxString& aFileName )
{
// this dummy plugin does not support rendering of any models
return NULL;
}
static S3D_PLUGIN_DUMMY dummy;
#ifndef _WIN32
extern "C" __attribute__((__visibility__("default"))) S3D_PLUGIN* Get3DPlugin( void )
{
return &dummy;
}
#else
extern "C" __declspec( dllexport ) S3D_PLUGIN* Get3DPlugin( void )
{
return &dummy;
}
#endif

View File

@ -11,18 +11,10 @@ add_library( s3d_plugin_idf MODULE
set_target_properties( s3d_plugin_idf PROPERTIES
LINK_FLAGS -L${CMAKE_BINARY_DIR}/utils/idftools )
target_link_libraries( s3d_plugin_idf s3d_sg idf3 ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} )
target_link_libraries( s3d_plugin_idf kicad_3dsg idf3 ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} )
if( APPLE )
install( TARGETS
s3d_plugin_idf
DESTINATION /Applications/kicad.app/SharedSupport/plugins/3d
DESTINATION ${KICAD_USER_PLUGIN}/3d
COMPONENT binary
)
else()
install( TARGETS
s3d_plugin_idf
DESTINATION lib/kicad/plugins/3d
COMPONENT binary
)
endif()

View File

@ -33,18 +33,18 @@
#define PLUGIN_3D_IDF_MAJOR 1
#define PLUGIN_3D_IDF_MINOR 0
#define PLUGIN_3D_IDF_REVNO 0
#define PLUGIN_3D_IDF_PATCH 0
#define PLUGIN_3D_IDF_REVNO 0
KICAD_PLUGIN_EXPORT const char* GetKicadPluginName( void )
const char* GetKicadPluginName( void )
{
return "PLUGIN_3D_IDF";
}
KICAD_PLUGIN_EXPORT void GetVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Revision, unsigned char* Patch )
void GetVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = PLUGIN_3D_IDF_MAJOR;
@ -52,12 +52,12 @@ KICAD_PLUGIN_EXPORT void GetVersion( unsigned char* Major,
if( Minor )
*Minor = PLUGIN_3D_IDF_MINOR;
if( Revision )
*Revision = PLUGIN_3D_IDF_REVNO;
if( Patch )
*Patch = PLUGIN_3D_IDF_PATCH;
if( Revision )
*Revision = PLUGIN_3D_IDF_REVNO;
return;
}
@ -72,11 +72,12 @@ KICAD_PLUGIN_EXPORT void GetVersion( unsigned char* Major,
#define NFILS 1
static char ext0[] = "idf";
static char fil0[] = "IDF 2.0/3.0 (*.idf)|*.idf";
#ifndef _WIN32
#ifdef _WIN32
static char fil0[] = "IDF 2.0/3.0 (*.idf)|*.idf";
#else
static char ext1[] = "IDF";
static char fil1[] = "IDF 2.0/3.0 (*.idf;*.IDF)|*.idf;*.IDF";
static char fil0[] = "IDF 2.0/3.0 (*.idf;*.IDF)|*.idf;*.IDF";
#endif
static struct FILE_DATA
@ -91,7 +92,6 @@ static struct FILE_DATA
#ifndef _WIN32
extensions[1] = ext1;
filters[1] = fil1;
#endif
return;
@ -104,13 +104,13 @@ static bool PopulateVRML( VRML_LAYER& model, const std::list< IDF_OUTLINE* >* it
static bool AddSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg );
KICAD_PLUGIN_EXPORT int GetNExtensions( void )
int GetNExtensions( void )
{
return NEXTS;
}
KICAD_PLUGIN_EXPORT char const* GetModelExtension( int aIndex )
char const* GetModelExtension( int aIndex )
{
if( aIndex < 0 || aIndex >= NEXTS )
return NULL;
@ -119,13 +119,13 @@ KICAD_PLUGIN_EXPORT char const* GetModelExtension( int aIndex )
}
KICAD_PLUGIN_EXPORT int GetNFilters( void )
int GetNFilters( void )
{
return NFILS;
}
KICAD_PLUGIN_EXPORT char const* GetFileFilter( int aIndex )
char const* GetFileFilter( int aIndex )
{
if( aIndex < 0 || aIndex >= NFILS )
return NULL;
@ -134,14 +134,14 @@ KICAD_PLUGIN_EXPORT char const* GetFileFilter( int aIndex )
}
KICAD_PLUGIN_EXPORT bool CanRender( void )
bool CanRender( void )
{
// this plugin supports rendering of IDF component outlines
return true;
}
KICAD_PLUGIN_EXPORT SCENEGRAPH* Load( char const* aFileName )
SCENEGRAPH* Load( char const* aFileName )
{
if( NULL == aFileName )
return NULL;

View File

@ -1,23 +0,0 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
add_library( s3d_plugin_tetra MODULE
s3d_plugin_tetra.cpp
)
target_link_libraries( s3d_plugin_tetra s3d_sg ${wxWidgets_LIBRARIES} )
if( APPLE )
install( TARGETS
s3d_plugin_tetra
DESTINATION /Applications/kicad.app/SharedSupport/plugins/3d
COMPONENT binary
)
else()
install( TARGETS
s3d_plugin_tetra
DESTINATION lib/kicad/plugins/3d
COMPONENT binary
)
endif()

View File

@ -1,60 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
*/
/**
* @file 3d_plugin_tetra.h
* is a sample plugin which demonstrates the basic use of the SG*
* classes for the intermediate representation of objects. The plugin
* accepts any *.wrl filename but does not actually load any files,
* instead the Load() routine only creates a magenta tetrahedron.
*/
#ifndef PLUGIN_3D_TETRA_H
#define PLUGIN_3D_TETRA_H
#include <vector>
#include <plugins/3d/3d_plugin.h>
class SCENEGRAPH;
class S3D_PLUGIN_TETRA : public S3D_PLUGIN
{
private:
std::vector< wxString > m_extensions; // supported extensions
std::vector< wxString > m_filters; // file filters
public:
S3D_PLUGIN_TETRA();
virtual ~S3D_PLUGIN_TETRA();
virtual int GetNExtensions( void ) const;
virtual const wxString GetModelExtension( int aIndex ) const;
virtual int GetNFilters( void ) const;
virtual const wxString GetFileFilter( int aIndex ) const;
bool CanRender( void ) const;
SCENEGRAPH* Load( const wxString& aFileName );
};
#endif // PLUGIN_3D_TETRA_H

View File

@ -28,8 +28,8 @@
#define PLUGIN_CLASS_3D "PLUGIN_3D"
#define PLUGIN_3D_MAJOR 1
#define PLUGIN_3D_MINOR 0
#define PLUGIN_3D_REVISION 0
#define PLUGIN_3D_PATCH 0
#define PLUGIN_3D_REVISION 0
KICAD_PLUGIN_LDR_3D::KICAD_PLUGIN_LDR_3D()
@ -182,9 +182,13 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
void KICAD_PLUGIN_LDR_3D::Close( void )
{
#ifdef DEBUG
if( ok )
{
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
std::cerr << " * [INFO] closing plugin\n";
}
#endif
ok = false;
m_getNExtensions = NULL;
m_getModelExtension = NULL;
@ -199,7 +203,7 @@ void KICAD_PLUGIN_LDR_3D::Close( void )
void KICAD_PLUGIN_LDR_3D::GetLoaderVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Revision, unsigned char* Patch ) const
unsigned char* Patch, unsigned char* Revision ) const
{
if( Major )
*Major = PLUGIN_3D_MAJOR;
@ -207,12 +211,12 @@ void KICAD_PLUGIN_LDR_3D::GetLoaderVersion( unsigned char* Major, unsigned char*
if( Minor )
*Minor = PLUGIN_3D_MINOR;
if( Revision )
*Revision = PLUGIN_3D_REVISION;
if( Patch )
*Patch = PLUGIN_3D_PATCH;
if( Revision )
*Revision = PLUGIN_3D_REVISION;
return;
}

View File

@ -188,15 +188,15 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
// perform a universally enforced version check (major number must match)
unsigned char lMajor;
unsigned char lMinor;
unsigned char lRevno;
unsigned char lPatch;
unsigned char lRevno;
unsigned char pMajor;
unsigned char pMinor;
unsigned char pRevno;
unsigned char pPatch;
unsigned char pRevno;
m_getClassVersion( &pMajor, &pMinor, &pRevno, &pPatch );
GetLoaderVersion( &lMajor, &lMinor, &lRevno, &lPatch );
m_getClassVersion( &pMajor, &pMinor, &pPatch, &pRevno );
GetLoaderVersion( &lMajor, &lMinor, &lPatch, &lRevno );
// major version changes by definition are incompatible and
// that is enforced here.
@ -211,12 +211,12 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
return false;
}
if( !m_checkClassVersion( lMajor, lMinor, lRevno, lPatch ) )
if( !m_checkClassVersion( lMajor, lMinor, lPatch, lRevno ) )
{
std::ostringstream ostr;
ostr << "Plugin Version (" << pMajor << "." << pMinor << "." << pRevno << "." << pPatch;
ostr << "Plugin Version (" << pMajor << "." << pMinor << "." << pPatch << "." << pRevno;
ostr << ") does not support Loader Version (" << pMajor << "." << pMinor;
ostr << "." << pRevno << "." << pPatch << ")";
ostr << "." << pPatch << "." << pRevno << ")";
m_error = ostr.str();
close();
@ -307,7 +307,7 @@ char const* KICAD_PLUGIN_LDR::GetKicadPluginClass( void )
bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Revision, unsigned char* Patch )
unsigned char* Patch, unsigned char* Revision )
{
m_error.clear();
@ -317,16 +317,16 @@ bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Min
if( Minor )
*Minor = 0;
if( Revision )
*Revision = 0;
if( Patch )
*Patch = 0;
if( Revision )
*Revision = 0;
unsigned char major;
unsigned char minor;
unsigned char revno;
unsigned char patch;
unsigned char revno;
if( !ok && !reopen() )
{
@ -344,7 +344,7 @@ bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Min
return false;
}
m_getClassVersion( &major, &minor, &revno, &patch );
m_getClassVersion( &major, &minor, &patch, &revno );
if( Major )
*Major = major;
@ -352,18 +352,18 @@ bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Min
if( Minor )
*Minor = minor;
if( Revision )
*Revision = revno;
if( Patch )
*Patch = patch;
if( Revision )
*Revision = revno;
return true;
}
bool KICAD_PLUGIN_LDR::CheckClassVersion( unsigned char Major, unsigned char Minor,
unsigned char Revision, unsigned char Patch )
unsigned char Patch, unsigned char Revision )
{
m_error.clear();
@ -383,7 +383,7 @@ bool KICAD_PLUGIN_LDR::CheckClassVersion( unsigned char Major, unsigned char Min
return NULL;
}
return m_checkClassVersion( Major, Minor, Revision, Patch );
return m_checkClassVersion( Major, Minor, Patch, Revision );
}
@ -412,7 +412,7 @@ const char* KICAD_PLUGIN_LDR::GetKicadPluginName( void )
bool KICAD_PLUGIN_LDR::GetVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Revision, unsigned char* Patch )
unsigned char* Patch, unsigned char* Revision )
{
m_error.clear();
@ -432,7 +432,7 @@ bool KICAD_PLUGIN_LDR::GetVersion( unsigned char* Major, unsigned char* Minor,
return false;
}
m_getVersion( Major, Minor, Revision, Patch );
m_getVersion( Major, Minor, Patch, Revision );
return true;
}

View File

@ -110,7 +110,7 @@ public:
* for plugin compatibility checking.
*/
virtual void GetLoaderVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Revision, unsigned char* Patch ) const = 0;
unsigned char* Patch, unsigned char* Revision ) const = 0;
/**
* Function Open
@ -141,18 +141,18 @@ public:
// returns false if no plugin loaded
bool GetClassVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Revision, unsigned char* Patch );
unsigned char* Patch, unsigned char* Revision );
// returns false if the class version check fails or no plugin is loaded
bool CheckClassVersion( unsigned char Major, unsigned char Minor,
unsigned char Revision, unsigned char Patch );
unsigned char Patch, unsigned char Revision );
// returns the Plugin Name or NULL if no plugin loaded
const char* GetKicadPluginName( void );
// returns false if no plugin is loaded
bool GetVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Revision, unsigned char* Patch );
unsigned char* Patch, unsigned char* Revision );
};
#endif // PLUGINLDR_H