KiCad PCB EDA Suite
Loading...
Searching...
No Matches
oce.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 (C) 2016 Cirilo Bernardo <[email protected]>
5 * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25/*
26 * This plugin implements a STEP/IGES model renderer for KiCad via OCE
27 */
28
29#include <wx/filename.h>
32
33#include <string>
34#include <vector>
35
36SCENEGRAPH* LoadModel( char const* filename );
37
38#define PLUGIN_OCE_MAJOR 1
39#define PLUGIN_OCE_MINOR 4
40#define PLUGIN_OCE_PATCH 2
41#define PLUGIN_OCE_REVNO 0
42
43
44const char* GetKicadPluginName( void )
45{
46 return "PLUGIN_3D_OCE";
47}
48
49
50void GetPluginVersion( unsigned char* Major,
51 unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
52{
53 if( Major )
54 *Major = PLUGIN_OCE_MAJOR;
55
56 if( Minor )
57 *Minor = PLUGIN_OCE_MINOR;
58
59 if( Patch )
60 *Patch = PLUGIN_OCE_PATCH;
61
62 if( Revision )
63 *Revision = PLUGIN_OCE_REVNO;
64
65 return;
66}
67
68
69static struct FILE_DATA
70{
71 std::vector<std::string> extensions;
72 std::vector<std::string> filters;
73
75 {
76#ifdef _WIN32
77 extensions = { "stp","step","stpz","stp.gz","step.gz","igs","iges" };
78 filters = {
79 "STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz",
80 "IGES (*.igs;*.iges)|*.igs;*.iges" };
81#else
82 extensions = {
83 "stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ",
84 "igs","IGS","iges","IGES"
85 };
86
87 filters = {
88 "STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;"
89 "*.STEP.GZ)|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;"
90 "*.step.gz;*.STEP.GZ",
91 "IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES"
92 };
93#endif
94 }
95
97
98
99int GetNExtensions( void )
100{
101 return file_data.extensions.size();
102}
103
104
105char const* GetModelExtension( int aIndex )
106{
107 if( aIndex < 0 || aIndex >= int( file_data.extensions.size() ) )
108 return nullptr;
109
110 return file_data.extensions[aIndex].c_str();
111}
112
113
114int GetNFilters( void )
115{
116 return file_data.filters.size();
117}
118
119
120char const* GetFileFilter( int aIndex )
121{
122 if( aIndex < 0 || aIndex >= int( file_data.filters.size() ) )
123 return nullptr;
124
125 return file_data.filters[aIndex].c_str();
126}
127
128
129bool CanRender( void )
130{
131 // this plugin supports rendering of IDF component outlines
132 return true;
133}
134
135
136SCENEGRAPH* Load( char const* aFileName )
137{
138 if( nullptr == aFileName )
139 return nullptr;
140
141 wxString fname = wxString::FromUTF8Unchecked( aFileName );
142
143 if( !wxFileName::FileExists( fname ) )
144 return nullptr;
145
146 return LoadModel( aFileName );
147}
describes 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:45
collects header files for all SG* wrappers and the API
static struct FILE_DATA file_data
char const * GetModelExtension(int aIndex)
Function GetModelExtension.
Definition: oce.cpp:105
bool CanRender(void)
Function CanRender.
Definition: oce.cpp:129
#define PLUGIN_OCE_MAJOR
Definition: oce.cpp:38
SCENEGRAPH * Load(char const *aFileName)
reads a model file and creates a generic display structure
Definition: oce.cpp:136
char const * GetFileFilter(int aIndex)
Function GetFileFilter.
Definition: oce.cpp:120
#define PLUGIN_OCE_PATCH
Definition: oce.cpp:40
void GetPluginVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
Function GetPluginVersion retrieves the version of the instantiated plugin for informational purposes...
Definition: oce.cpp:50
SCENEGRAPH * LoadModel(char const *filename)
Definition: loadmodel.cpp:699
const char * GetKicadPluginName(void)
Function GetKicadPluginName returns the name of the plugin instance; for example IDFv3.
Definition: oce.cpp:44
#define PLUGIN_OCE_MINOR
Definition: oce.cpp:39
int GetNExtensions(void)
Function GetNExtensions.
Definition: oce.cpp:99
int GetNFilters(void)
Function GetNFilters.
Definition: oce.cpp:114
#define PLUGIN_OCE_REVNO
Definition: oce.cpp:41
char const * extensions[NEXTS]
FILE_DATA()
Definition: oce.cpp:74
std::vector< std::string > filters
Definition: oce.cpp:72
char const * filters[NFILS]
std::vector< std::string > extensions
Definition: oce.cpp:71