KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plugin.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
19 */
20
23#include "loadmodel.h"
24
25#include <string>
26#include <vector>
27
28#define PLUGIN_VRML_MAJOR 1
29#define PLUGIN_VRML_MINOR 3
30#define PLUGIN_VRML_PATCH 2
31#define PLUGIN_VRML_REVNO 2
32
33
34const char* GetKicadPluginName()
35{
36 return "PLUGIN_3D_VRML";
37}
38
39
40void GetPluginVersion( unsigned char* aMajor, unsigned char* aMinor, unsigned char* aPatch,
41 unsigned char* aRevision )
42{
43 if( aMajor )
44 *aMajor = PLUGIN_VRML_MAJOR;
45
46 if( aMinor )
47 *aMinor = PLUGIN_VRML_MINOR;
48
49 if( aPatch )
50 *aPatch = PLUGIN_VRML_PATCH;
51
52 if( aRevision )
53 *aRevision = PLUGIN_VRML_REVNO;
54}
55
56
57// Windows file matching is case insensitive, so the case variants would only duplicate entries.
58#ifdef _WIN32
59static const std::vector<std::string> extensions = { "wrl", "wrz", "x3d" };
60static const std::vector<std::string> filters = { "VRML 1.0/2.0 (*.wrl;*.wrz)|*.wrl;*.wrz",
61 "X3D (*.x3d)|*.x3d" };
62#else
63static const std::vector<std::string> extensions = { "wrl", "WRL", "wrz", "WRZ", "x3d", "X3D" };
64static const std::vector<std::string> filters = {
65 "VRML 1.0/2.0 (*.wrl;*.WRL;*.wrz;*.WRZ)|*.wrl;*.WRL;*.wrz;*.WRZ",
66 "X3D (*.x3d;*.X3D)|*.x3d;*.X3D"
67};
68#endif
69
70
72{
73 return static_cast<int>( extensions.size() );
74}
75
76
77char const* GetModelExtension( int aIndex )
78{
79 return aIndex >= 0 && aIndex < GetNExtensions() ? extensions[aIndex].c_str() : nullptr;
80}
81
82
84{
85 return static_cast<int>( filters.size() );
86}
87
88
89char const* GetFileFilter( int aIndex )
90{
91 return aIndex >= 0 && aIndex < GetNFilters() ? filters[aIndex].c_str() : nullptr;
92}
93
94
96{
97 return true;
98}
99
100
101SCENEGRAPH* Load( char const* aFileName )
102{
103 return aFileName ? LoadVRMLModel( aFileName ) : nullptr;
104}
Describe the runtime-loadable interface to support loading and parsing of 3D models.
Define the basic data set required to represent a 3D model.
Definition scenegraph.h:41
defines the API calls for the manipulation of SG* classes
#define PLUGIN_VRML_MAJOR
Definition plugin.cpp:28
char const * GetModelExtension(int aIndex)
Definition plugin.cpp:77
SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
Definition plugin.cpp:101
char const * GetFileFilter(int aIndex)
Definition plugin.cpp:89
#define PLUGIN_VRML_MINOR
Definition plugin.cpp:29
static const std::vector< std::string > filters
Definition plugin.cpp:64
int GetNFilters()
Definition plugin.cpp:83
int GetNExtensions()
Definition plugin.cpp:71
static const std::vector< std::string > extensions
Definition plugin.cpp:63
bool CanRender()
Definition plugin.cpp:95
#define PLUGIN_VRML_PATCH
Definition plugin.cpp:30
void GetPluginVersion(unsigned char *aMajor, unsigned char *aMinor, unsigned char *aPatch, unsigned char *aRevision)
Retrieve the version of the instantiated plugin for informational purposes.
Definition plugin.cpp:40
const char * GetKicadPluginName()
Return the name of the plugin instance, for example IDFv3.
Definition plugin.cpp:34
#define PLUGIN_VRML_REVNO
Definition plugin.cpp:31
KICAD_3D_IMPORT_API SCENEGRAPH * LoadVRMLModel(const char *aFileName, const S3D::MODEL_IMPORT_OPTIONS *aOptions=nullptr)
Definition vrml.cpp:330