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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21/*
22 * This plugin implements a STEP/IGES model renderer for KiCad via OCE
23 */
24
25#include <wx/filename.h>
28
29#include <string>
30#include <vector>
31
32SCENEGRAPH* LoadModel( char const* filename );
33
34#define PLUGIN_OCE_MAJOR 1
35#define PLUGIN_OCE_MINOR 4
36#define PLUGIN_OCE_PATCH 2
37#define PLUGIN_OCE_REVNO 0
38
39
40const char* GetKicadPluginName( void )
41{
42 return "PLUGIN_3D_OCE";
43}
44
45
46void GetPluginVersion( unsigned char* Major,
47 unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
48{
49 if( Major )
50 *Major = PLUGIN_OCE_MAJOR;
51
52 if( Minor )
53 *Minor = PLUGIN_OCE_MINOR;
54
55 if( Patch )
56 *Patch = PLUGIN_OCE_PATCH;
57
58 if( Revision )
59 *Revision = PLUGIN_OCE_REVNO;
60
61 return;
62}
63
64
65static struct FILE_DATA
66{
67 std::vector<std::string> extensions;
68 std::vector<std::string> filters;
69
71 {
72#ifdef _WIN32
73 extensions = { "stp","step","stpz","stp.gz","step.gz","igs","iges" };
74 filters = {
75 "STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz",
76 "IGES (*.igs;*.iges)|*.igs;*.iges" };
77#else
78 extensions = {
79 "stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ",
80 "igs","IGS","iges","IGES"
81 };
82
83 filters = {
84 "STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;"
85 "*.STEP.GZ)|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;"
86 "*.step.gz;*.STEP.GZ",
87 "IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES"
88 };
89#endif
90 }
91
93
94
95int GetNExtensions( void )
96{
97 return file_data.extensions.size();
98}
99
100
101char const* GetModelExtension( int aIndex )
102{
103 if( aIndex < 0 || aIndex >= int( file_data.extensions.size() ) )
104 return nullptr;
105
106 return file_data.extensions[aIndex].c_str();
107}
108
109
110int GetNFilters( void )
111{
112 return file_data.filters.size();
113}
114
115
116char const* GetFileFilter( int aIndex )
117{
118 if( aIndex < 0 || aIndex >= int( file_data.filters.size() ) )
119 return nullptr;
120
121 return file_data.filters[aIndex].c_str();
122}
123
124
125bool CanRender( void )
126{
127 // this plugin supports rendering of IDF component outlines
128 return true;
129}
130
131
132SCENEGRAPH* Load( char const* aFileName )
133{
134 if( nullptr == aFileName )
135 return nullptr;
136
137 wxString fname = wxString::FromUTF8Unchecked( aFileName );
138
139 if( !wxFileName::FileExists( fname ) )
140 return nullptr;
141
142 return LoadModel( aFileName );
143}
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
collects header files for all SG* wrappers and the API
char const * GetModelExtension(int aIndex)
Definition oce.cpp:101
bool CanRender(void)
Definition oce.cpp:125
#define PLUGIN_OCE_MAJOR
Definition oce.cpp:34
SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
Definition oce.cpp:132
char const * GetFileFilter(int aIndex)
Definition oce.cpp:116
#define PLUGIN_OCE_PATCH
Definition oce.cpp:36
void GetPluginVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
Retrieve the version of the instantiated plugin for informational purposes.
Definition oce.cpp:46
SCENEGRAPH * LoadModel(char const *filename)
const char * GetKicadPluginName(void)
Return the name of the plugin instance, for example IDFv3.
Definition oce.cpp:40
#define PLUGIN_OCE_MINOR
Definition oce.cpp:35
int GetNExtensions(void)
Definition oce.cpp:95
int GetNFilters(void)
Definition oce.cpp:110
#define PLUGIN_OCE_REVNO
Definition oce.cpp:37
static struct FILE_DATA file_data
char const * extensions[NEXTS]
FILE_DATA()
Definition oce.cpp:70
char const * filters[NFILS]