KiCad PCB EDA Suite
3d_plugin.h File Reference

describes the runtime-loadable interface to support loading and parsing of 3D models. More...

Go to the source code of this file.

Macros

#define KICAD_PLUGIN_CLASS   "PLUGIN_3D"
 
#define MAJOR   1
 
#define MINOR   0
 
#define REVISION   0
 
#define PATCH   0
 

Functions

KICAD_PLUGIN_EXPORT char const * GetKicadPluginClass (void)
 Function GetKicadPluginClass returns the name of the implemented plugin class; for example 3DPLUGIN. More...
 
KICAD_PLUGIN_EXPORT void GetClassVersion (unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
 Function GetClassVersion retrieves the version of the Plugin Class. More...
 
KICAD_PLUGIN_EXPORT bool CheckClassVersion (unsigned char Major, unsigned char Minor, unsigned char Patch, unsigned char Revision)
 Function CheckClassVersion returns true if the class version reported by the Plugin Loader is compatible with the specific implementation of a plugin. More...
 
KICAD_PLUGIN_EXPORT int GetNExtensions (void)
 Function GetNExtensions. More...
 
KICAD_PLUGIN_EXPORT char const * GetModelExtension (int aIndex)
 Function GetModelExtension. More...
 
KICAD_PLUGIN_EXPORT int GetNFilters (void)
 Function GetNFilters. More...
 
KICAD_PLUGIN_EXPORT char const * GetFileFilter (int aIndex)
 Function GetFileFilter. More...
 
KICAD_PLUGIN_EXPORT bool CanRender (void)
 Function CanRender. More...
 
KICAD_PLUGIN_EXPORT SCENEGRAPHLoad (char const *aFileName)
 reads a model file and creates a generic display structure More...
 

Detailed Description

describes the runtime-loadable interface to support loading and parsing of 3D models.

Definition in file 3d_plugin.h.

Macro Definition Documentation

◆ KICAD_PLUGIN_CLASS

#define KICAD_PLUGIN_CLASS   "PLUGIN_3D"

Definition at line 40 of file 3d_plugin.h.

◆ MAJOR

#define MAJOR   1

Definition at line 41 of file 3d_plugin.h.

◆ MINOR

#define MINOR   0

Definition at line 42 of file 3d_plugin.h.

◆ PATCH

#define PATCH   0

Definition at line 44 of file 3d_plugin.h.

◆ REVISION

#define REVISION   0

Definition at line 43 of file 3d_plugin.h.

Function Documentation

◆ CanRender()

KICAD_PLUGIN_EXPORT bool CanRender ( void  )

Function CanRender.

Returns
true if the plugin can render a model, that is the Load() function is implemented

Definition at line 297 of file s3d_plugin_idf.cpp.

298 {
299  // this plugin supports rendering of IDF component outlines
300  return true;
301 }

◆ CheckClassVersion()

KICAD_PLUGIN_EXPORT bool CheckClassVersion ( unsigned char  Major,
unsigned char  Minor,
unsigned char  Patch,
unsigned char  Revision 
)

Function CheckClassVersion returns true if the class version reported by the Plugin Loader is compatible with the specific implementation of a plugin.

This function must be defined by each specific plugin and it is the plugin developer's responsibility to ensure that the Plugin is in fact compatible with the Plugin Loader. The Plugin Loader shall reject any Plugin with a different Major number regardless of the return value of this function.

Definition at line 73 of file 3d_plugin.h.

75 {
76  if( Major != MAJOR )
77  return false;
78 
79  // at the moment there are no incompatibility rules other than the Major Version check
80  return true;
81 }
#define MAJOR
Definition: 3d_plugin.h:41

References MAJOR.

◆ GetClassVersion()

KICAD_PLUGIN_EXPORT void GetClassVersion ( unsigned char *  Major,
unsigned char *  Minor,
unsigned char *  Patch,
unsigned char *  Revision 
)

Function GetClassVersion retrieves the version of the Plugin Class.

This value is used to ensure API compatibility of a plugin as per typical practice. This must be implemented in a source module which is compiled as part of every implementation of a specific plugin class

Parameters
Majorwill hold the Plugin Class Major version
Minorwill hold the Plugin Class Minor version
Revisionwill hold the Plugin Class Revision
Patchwill hold the Plugin Class Patch level

Definition at line 55 of file 3d_plugin.h.

57 {
58  if( Major )
59  *Major = MAJOR;
60 
61  if( Minor )
62  *Minor = MINOR;
63 
64  if( Patch )
65  *Patch = PATCH;
66 
67  if( Revision )
68  *Revision = REVISION;
69 
70  return;
71 }
#define MAJOR
Definition: 3d_plugin.h:41
#define MINOR
Definition: 3d_plugin.h:42
#define REVISION
Definition: 3d_plugin.h:43
#define PATCH
Definition: 3d_plugin.h:44

References MAJOR, MINOR, PATCH, and REVISION.

◆ GetFileFilter()

KICAD_PLUGIN_EXPORT char const* GetFileFilter ( int  aIndex)

Function GetFileFilter.

Returns
the file filter string for the given index

Definition at line 288 of file s3d_plugin_idf.cpp.

289 {
290  if( aIndex < 0 || aIndex >= NFILS )
291  return nullptr;
292 
293  return file_data.filters[aIndex];
294 }
#define NFILS
char const * filters[NFILS]
static struct FILE_DATA file_data

References file_data, FILE_DATA::filters, and NFILS.

◆ GetKicadPluginClass()

KICAD_PLUGIN_EXPORT char const* GetKicadPluginClass ( void  )

Function GetKicadPluginClass returns the name of the implemented plugin class; for example 3DPLUGIN.

This should be implemented in a source module which is compiled as part of every implementation of a specific plugin class.

Returns
is the NULL-terminated UTF-8 string representing the plugin class

Definition at line 49 of file 3d_plugin.h.

50 {
51  return KICAD_PLUGIN_CLASS;
52 }
#define KICAD_PLUGIN_CLASS
Definition: 3d_plugin.h:40

References KICAD_PLUGIN_CLASS.

◆ GetModelExtension()

KICAD_PLUGIN_EXPORT char const* GetModelExtension ( int  aIndex)

Function GetModelExtension.

Parameters
aIndexis the extension to return; valid values are 0 to GetNExtensions() - 1.
Returns
the requested extension or a null string if aIndex was invalid.

Definition at line 273 of file s3d_plugin_idf.cpp.

274 {
275  if( aIndex < 0 || aIndex >= NEXTS )
276  return nullptr;
277 
278  return file_data.extensions[aIndex];
279 }
#define NEXTS
char const * extensions[NEXTS]
static struct FILE_DATA file_data

References FILE_DATA::extensions, file_data, and NEXTS.

◆ GetNExtensions()

KICAD_PLUGIN_EXPORT int GetNExtensions ( void  )

Function GetNExtensions.

Returns
the number of extensions supported by the plugin

Definition at line 267 of file s3d_plugin_idf.cpp.

268 {
269  return NEXTS;
270 }
#define NEXTS

References FILE_DATA::extensions, file_data, and NEXTS.

◆ GetNFilters()

KICAD_PLUGIN_EXPORT int GetNFilters ( void  )

Function GetNFilters.

Returns
the number of file filters

Definition at line 282 of file s3d_plugin_idf.cpp.

283 {
284  return NFILS;
285 }
#define NFILS

References file_data, FILE_DATA::filters, and NFILS.

◆ Load()

KICAD_PLUGIN_EXPORT SCENEGRAPH* Load ( char const *  aFileName)

reads a model file and creates a generic display structure

Parameters
aFileNameis the full path of the model file
Returns
a SCENEGRAPH pointer to the display structure if the model was successfully loaded and NULL if there is no rendering support for the model or there were problems reading the model

Definition at line 304 of file s3d_plugin_idf.cpp.

305 {
306  if( nullptr == aFileName )
307  return nullptr;
308 
309  wxFileName fname;
310  fname.Assign( wxString::FromUTF8Unchecked( aFileName ) );
311 
312  wxString ext = fname.GetExt();
313 
314  SCENEGRAPH* data = nullptr;
315 
316  if( !ext.Cmp( wxT( "idf" ) ) || !ext.Cmp( wxT( "IDF" ) ) )
317  {
318  data = loadIDFOutline( fname.GetFullPath() );
319  }
320 
321  if( !ext.Cmp( wxT( "emn" ) ) || !ext.Cmp( wxT( "EMN" ) ) )
322  {
323  data = loadIDFBoard( fname.GetFullPath() );
324  }
325 
326  // DEBUG: WRITE OUT IDF FILE TO CONFIRM NORMALS
327 #if defined( DEBUG_IDF ) && DEBUG_IDF > 3
328  if( data )
329  {
330  wxFileName fn( aFileName );
331  wxString output = wxT( "_idf-" );
332  output.append( fn.GetName() );
333  output.append( wxT( ".wrl" ) );
334  S3D::WriteVRML( output.ToUTF8(), true, (SGNODE*) ( data ), true, true );
335  }
336 #endif
337 
338  return data;
339 }
static SCENEGRAPH * loadIDFOutline(const wxString &aFileName)
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
SGLIB_API bool WriteVRML(const char *filename, bool overwrite, SGNODE *aTopNode, bool reuse, bool renameNodes)
Function WriteVRML writes out the given node and its subnodes to a VRML2 file.
Definition: ifsg_api.cpp:76
static SCENEGRAPH * loadIDFBoard(const wxString &aFileName)
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:44

References loadIDFBoard(), loadIDFOutline(), LoadModel(), LoadVRML(), LoadX3D(), and S3D::WriteVRML().

Referenced by CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse().