Cleaning up in preparation for merge

This commit is contained in:
Cirilo Bernardo 2015-12-19 14:57:02 +11:00
parent 86c54ce636
commit 396825d960
8 changed files with 1 additions and 535 deletions

View File

@ -1,132 +0,0 @@
This directory will contain code used in the refactoring of
the 3D viewer and 3D model management.
Notes on building the test program on Linux:
1. Configure to build KiCad; ensue you have "-DS3D_TEST=ON" to
enable the "test3dmm" test program.
mkdir build
cd build
cmake -DKICAD_SCRIPTING=ON \
-DKICAD_SCRIPTING_MODULES=ON \
-DBUILD_GITHUB_PLUGIN=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DKICAD_SKIP_BOOST=ON \
-DCMAKE_INSTALL_PREFIX=/usr \
-DS3D_TEST=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON ..
2. After configuring to build KiCad, descend into the 3dv build
directory:
cd 3dv
3. Build all files in the 3dv directory:
make -j8
4. Install to a directory within the build directory:
mkdir inst
make install DESTDIR=./inst
5. Set LD_LIBRARY_PATH so that the 3d manager code can be found:
export LD_LIBRARY_PATH=${PWD}/inst/usr/lib/kicad
( note: the previous step may have installed the library in
${PWD}/inst/usr/local/lib/kicad )
There is no need to include the plugins directory in
LD_LIBRARY_PATH since the manager should magically find
plugins there and load them.
6. Run the test program:
./inst/usr/bin/test3dmm
===========================
For OSX and MSWin
===========================
The dynamic plugin has only been built and tested on Linux; until
the dynamic plugin system can be made to work on MSWin and OSX, those
systems will not be able to use the 3D cache framework for anything
other than a filename resolver and model file browser. Without the
plugins the 3D viewer will not be able to use the new framework for
loading generic 3D model formats.
Dynamic plugins are managed in 3dv/3d_plugin_manager.cpp so that is the
only source file which developers need to modify to support plugins
on OSX and MSWin
1. OSX:
+ In general some attention is required wherever the __APPLE__
macro is found
+ void S3D_PLUGIN_MANAGER::loadPlugins( void )
In this function a list of reasonable search paths must be provided;
these paths will be checked for the existence of a plugin
+ void S3D_PLUGIN_MANAGER::listPlugins( ... )
In this function the list of suffixes to use in the plugin
discovery should be checked to ensure that they comply with
the expectations of OSX
+ bool S3D_PLUGIN_ITEM::Open( void )
This function loads the dynamic plugins. If OSX use the gcc dlopen
set of functions then there may be no further work to be done here.
2. MSWin:
+ In general some attention is required wherever the _WIN32 macro is found
+ void S3D_PLUGIN_MANAGER::loadPlugins( void )
In this function a list of reasonable search paths must be provided;
these paths will be checked for the existence of a plugin
+ bool S3D_PLUGIN_ITEM::Open( void )
This function loads the dynamic plugins. Since the gcc dlopen family
of functions do not exist on MSWin, some _WIN32 specific code must
be added to handle the library loading.
===
Q. How do you know the plugin system is working?
A. The plugin system is working if the dummy plugin is located and loaded.
If the plugin is located and the software was built with the DEBUG flag,
you will see a group of messages which, among other things, advertises
the file types supported by the dummy plugin:
~/code/kicad/branch_3d/3dv/3d_plugin_manager.cpp:loadPlugins:404:
* [DEBUG] searching path: '~/usr/lib/kicad/plugins'
XXX - Initializing S3D_PLUGIN_DUMMY
~/code/kicad/branch_3d/3dv/3d_plugin_manager.cpp:loadPlugins:426:
* [DEBUG] adding plugin
XXX - Destroying S3D_PLUGIN_DUMMY
~/code/kicad/branch_3d/3dv/3d_plugin_manager.cpp:loadPlugins:461:
* [DEBUG] plugins loaded
* Extension [plugin name]:
+ 'IDF' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'IGES' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'IGS' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'STEP' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'STP' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'WRL' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'X3D' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'idf' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'iges' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'igs' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'step' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'stp' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'wrl' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
+ 'x3d' [~/usr/lib/kicad/plugins/libs3d_plugin_dummy.so]
* File filters:
+ 'All Files (*.*)|*.*'
+ 'VRML 1.0/2.0 (*.wrl;*.WRL)|*.wrl;*.WRL'
+ 'X3D (*.x3d;*.X3D)|*.x3d;*.X3D'
+ 'IDF 2.0/3.0 (*.idf;*.IDF)|*.idf;*.IDF'
+ 'IGESv5.3 (*.igs;*.iges;*.IGS;*.IGES)|*.igs;*.iges;*.IGS;*.IGES'
+ 'STEP (*.stp;*.step;*.STP;*.STEP)|*.stp;*.step;*.STP;*.STEP'
The supported file extensions should appear in the list of file filters within the
model selection dialog; if no plugins are loaded then the only available file
filter will be the wildcard filter *.*

View File

@ -30,7 +30,7 @@
#include "3d_cache/sg/sg_node.h"
#include "plugins/3dapi/c3dmodel.h"
static const std::string node_names[S3D::SGTYPE_END + 1] = {
static const std::string node_names[V2_END + 1] = {
"TXFM",
"APP",
"COL",

View File

@ -1,17 +0,0 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
add_library( s3d_plugin_vrml MODULE
vrml.cpp
vrml1.cpp
vrml2.cpp
)
target_link_libraries( s3d_plugin_vrml kicad_3dsg ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} )
install( TARGETS
s3d_plugin_vrml
DESTINATION ${KICAD_USER_PLUGIN}/3d
COMPONENT binary
)

View File

@ -1,202 +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
*/
/*
* Description:
* This plugin implements the legacy kicad VRML1/VRML2 parsers.
* This VRML plugin will invoke a VRML1 or VRML2 parser depending
* on the identifying information in the file header:
*
* #VRML V1.0 ascii
* #VRML V2.0 utf8
*/
#include <locale.h>
#include <fstream>
#include <iostream>
#include <cmath>
#include <string>
#include <wx/string.h>
#include <wx/filename.h>
#include "plugins/3d/3d_plugin.h"
#include "plugins/3dapi/ifsg_all.h"
#include "vrml1.h"
#include "vrml2.h"
#define PLUGIN_VRML_MAJOR 1
#define PLUGIN_VRML_MINOR 0
#define PLUGIN_VRML_PATCH 0
#define PLUGIN_VRML_REVNO 0
const char* GetKicadPluginName( void )
{
return "PLUGIN_3D_VRML";
}
void GetPluginVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = PLUGIN_VRML_MAJOR;
if( Minor )
*Minor = PLUGIN_VRML_MINOR;
if( Patch )
*Patch = PLUGIN_VRML_PATCH;
if( Revision )
*Revision = PLUGIN_VRML_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
static char fil0[] = "VRML 1.0/2.0 (*.wrl)|*.wrl";
#else
static char ext1[] = "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;
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 plugin supports rendering of IDF component outlines
return true;
}
class LOCALESWITCH
{
public:
LOCALESWITCH()
{
setlocale( LC_NUMERIC, "C" );
}
~LOCALESWITCH()
{
setlocale( LC_NUMERIC, "" );
}
};
SCENEGRAPH* Load( char const* aFileName )
{
if( NULL == aFileName )
return NULL;
wxString fname = wxString::FromUTF8Unchecked( aFileName );
if( !wxFileName::FileExists( fname ) )
return NULL;
LOCALESWITCH switcher;
std::ifstream ifile;
ifile.open( fname.ToUTF8() );
if( !ifile.is_open() )
return NULL;
std::string iline;
std::getline( ifile, iline );
if( iline.find( "#VRML V1.0 ascii" ) == 0 )
{
PARSER_3D_VRML1 parser;
return parser.Load( ifile );
}
if( iline.find( "#VRML V2.0 utf8" ) == 0 )
{
PARSER_3D_VRML2 parser;
return parser.Load( ifile );
}
return NULL;
}

View File

@ -1,50 +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
*/
/*
* Description:
* This module implements a VRML1 parser
*/
#include "vrml1.h"
PARSER_3D_VRML1::PARSER_3D_VRML1()
{
// XXX - TO BE IMPLEMENTED
return;
}
PARSER_3D_VRML1::~PARSER_3D_VRML1()
{
// XXX - TO BE IMPLEMENTED
return;
}
SCENEGRAPH* PARSER_3D_VRML1::Load( std::ifstream& aModelFile )
{
// XXX - TO BE IMPLEMENTED
return NULL;
}

View File

@ -1,41 +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 vrml1.h
*/
#include <fstream>
class SCENEGRAPH;
class PARSER_3D_VRML1
{
public:
PARSER_3D_VRML1();
~PARSER_3D_VRML1();
SCENEGRAPH* Load( std::ifstream& aModelFile );
};

View File

@ -1,51 +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
*/
/*
* Description:
* This module implements a VRML2 parser which supports only
* the features required for rendering static models.
*/
#include "vrml2.h"
PARSER_3D_VRML2::PARSER_3D_VRML2()
{
// XXX - TO BE IMPLEMENTED
return;
}
PARSER_3D_VRML2::~PARSER_3D_VRML2()
{
// XXX - TO BE IMPLEMENTED
return;
}
SCENEGRAPH* PARSER_3D_VRML2::Load( std::ifstream& aModelFile )
{
// XXX - TO BE IMPLEMENTED
return NULL;
}

View File

@ -1,41 +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 vrml2.h
*/
#include <fstream>
class SCENEGRAPH;
class PARSER_3D_VRML2
{
public:
PARSER_3D_VRML2();
~PARSER_3D_VRML2();
SCENEGRAPH* Load( std::ifstream& aModelFile );
};