2013-01-13 16:55:07 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009-2013 Lorenzo Mercantonio
|
2014-01-06 20:14:24 +00:00
|
|
|
* Copyright (C) 2014 Cirilo Bernado
|
2013-01-13 16:55:07 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2014-01-06 20:14:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE:
|
|
|
|
* 1. for improved looks, create a DRILL layer for PTH drills.
|
|
|
|
* To render the improved board, render the vertical outline only
|
|
|
|
* for the board (no added drill holes), then render the
|
|
|
|
* outline only for PTH, and finally render the top and bottom
|
|
|
|
* of the board. NOTE: if we don't want extra eye-candy then
|
|
|
|
* we must maintain the current board export.
|
|
|
|
* Additional bits needed for improved eyecandy:
|
|
|
|
* + CalcOutline: calculates only the outline of a VRML_LAYER or
|
|
|
|
* a VERTICAL_HOLES
|
|
|
|
* + WriteVerticalIndices: writes the indices of only the vertical
|
|
|
|
* facets of a VRML_LAYER or a VRML_HOLES.
|
|
|
|
* + WriteVerticalVertices: writes only the outline vertices to
|
|
|
|
* form vertical walls; applies to VRML_LAYER and VRML_HOLES
|
|
|
|
*
|
|
|
|
* 2. How can we suppress fiducials such as those in the corners of the pic-programmer demo?
|
|
|
|
*
|
|
|
|
* 3. Export Graphics to Layer objects (see 3d_draw.cpp for clues) to ensure that custom
|
|
|
|
* tracks/fills/logos are rendered.
|
2014-02-15 07:39:06 +00:00
|
|
|
* module->TransformGraphicShapesWithClearanceToPolygonSet
|
2014-01-06 20:14:24 +00:00
|
|
|
*
|
|
|
|
* For mechanical correctness, we should use the following settings with arcs:
|
|
|
|
* 1. max. deviation: the number of edges should be determined by the max.
|
|
|
|
* mechanical deviation and the minimum number of edges shall be 6.
|
|
|
|
* 2. for very large features we may introduce too many edges in a circle;
|
|
|
|
* to control this, we should specify a MAX number of edges or a threshold
|
|
|
|
* radius and a deviation for larger features
|
|
|
|
*
|
|
|
|
* For example, many mechanical fits are to within +/-0.05mm, so specifying
|
|
|
|
* a max. deviation of 0.02mm will yield a hole near the max. material
|
|
|
|
* condition. Calculating sides for a 10mm radius hole will yield about
|
|
|
|
* 312 points; such large holes (and arcs) will typically have a specified
|
|
|
|
* tolerance of +/-0.2mm in which case we can set the MAX edges to 32
|
|
|
|
* provided none of the important holes requires > 32 edges.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <trigo.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <3d_struct.h>
|
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
2014-01-06 20:14:24 +00:00
|
|
|
#include <class_zone.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_pcb_text.h>
|
2012-11-05 20:20:34 +00:00
|
|
|
#include <convert_from_iu.h>
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2013-03-27 18:34:23 +00:00
|
|
|
#include "../3d-viewer/modelparsers.h"
|
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <cmath>
|
2014-01-06 20:14:24 +00:00
|
|
|
#include <vrml_board.h>
|
2012-06-19 19:25:41 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
/* helper function:
|
|
|
|
* some characters cannot be used in names,
|
|
|
|
* this function change them to "_"
|
|
|
|
*/
|
2014-01-06 20:14:24 +00:00
|
|
|
static void ChangeIllegalCharacters( wxString& aFileName, bool aDirSepIsIllegal );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
struct VRML_COLOR
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
float diffuse_red;
|
|
|
|
float diffuse_grn;
|
|
|
|
float diffuse_blu;
|
2013-01-13 16:55:07 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
float spec_red;
|
|
|
|
float spec_grn;
|
|
|
|
float spec_blu;
|
2013-01-13 16:55:07 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
float emit_red;
|
|
|
|
float emit_grn;
|
|
|
|
float emit_blu;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
float ambient;
|
|
|
|
float transp;
|
|
|
|
float shiny;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_COLOR()
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
// default green
|
|
|
|
diffuse_red = 0.13;
|
|
|
|
diffuse_grn = 0.81;
|
|
|
|
diffuse_blu = 0.22;
|
|
|
|
spec_red = 0.13;
|
|
|
|
spec_grn = 0.81;
|
|
|
|
spec_blu = 0.22;
|
|
|
|
emit_red = 0.0;
|
|
|
|
emit_grn = 0.0;
|
|
|
|
emit_blu = 0.0;
|
|
|
|
|
|
|
|
ambient = 1.0;
|
|
|
|
transp = 0;
|
|
|
|
shiny = 0.2;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_COLOR( float dr, float dg, float db,
|
|
|
|
float sr, float sg, float sb,
|
|
|
|
float er, float eg, float eb,
|
|
|
|
float am, float tr, float sh )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
diffuse_red = dr;
|
|
|
|
diffuse_grn = dg;
|
|
|
|
diffuse_blu = db;
|
|
|
|
spec_red = sr;
|
|
|
|
spec_grn = sg;
|
|
|
|
spec_blu = sb;
|
|
|
|
emit_red = er;
|
|
|
|
emit_grn = eg;
|
|
|
|
emit_blu = eb;
|
|
|
|
|
|
|
|
ambient = am;
|
|
|
|
transp = tr;
|
|
|
|
shiny = sh;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
enum VRML_COLOR_INDEX
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_COLOR_PCB = 0,
|
|
|
|
VRML_COLOR_TRACK,
|
|
|
|
VRML_COLOR_SILK,
|
|
|
|
VRML_COLOR_TIN,
|
|
|
|
VRML_COLOR_LAST
|
2010-11-27 13:09:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
class MODEL_VRML
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
private:
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double layer_z[NB_LAYERS];
|
|
|
|
VRML_COLOR colors[VRML_COLOR_LAST];
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
public:
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_LAYER holes;
|
|
|
|
VRML_LAYER board;
|
|
|
|
VRML_LAYER top_copper;
|
|
|
|
VRML_LAYER bot_copper;
|
|
|
|
VRML_LAYER top_silk;
|
|
|
|
VRML_LAYER bot_silk;
|
|
|
|
VRML_LAYER top_tin;
|
|
|
|
VRML_LAYER bot_tin;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double scale; // board internal units to output scaling
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double tx; // global translation along X
|
|
|
|
double ty; // global translation along Y
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double board_thickness; // depth of the PCB
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
LAYER_NUM s_text_layer;
|
|
|
|
int s_text_width;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
MODEL_VRML()
|
|
|
|
{
|
|
|
|
for( int i = 0; i < NB_LAYERS; ++i )
|
|
|
|
layer_z[i] = 0;
|
|
|
|
|
|
|
|
// this default only makes sense if the output is in mm
|
|
|
|
board_thickness = 1.6;
|
|
|
|
|
|
|
|
// pcb green
|
|
|
|
colors[ VRML_COLOR_PCB ] = VRML_COLOR( .07, .3, .12, .07, .3, .12,
|
|
|
|
0, 0, 0, 1, 0, 0.2 );
|
|
|
|
// track green
|
|
|
|
colors[ VRML_COLOR_TRACK ] = VRML_COLOR( .08, .5, .1, .08, .5, .1,
|
|
|
|
0, 0, 0, 1, 0, 0.2 );
|
|
|
|
// silkscreen white
|
|
|
|
colors[ VRML_COLOR_SILK ] = VRML_COLOR( .9, .9, .9, .9, .9, .9,
|
|
|
|
0, 0, 0, 1, 0, 0.2 );
|
|
|
|
// pad silver
|
|
|
|
colors[ VRML_COLOR_TIN ] = VRML_COLOR( .749, .756, .761, .749, .756, .761,
|
|
|
|
0, 0, 0, 0.8, 0, 0.8 );
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_COLOR& GetColor( VRML_COLOR_INDEX aIndex )
|
|
|
|
{
|
|
|
|
return colors[aIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetOffset( double aXoff, double aYoff )
|
|
|
|
{
|
|
|
|
tx = aXoff;
|
|
|
|
ty = aYoff;
|
|
|
|
}
|
|
|
|
|
|
|
|
double GetLayerZ( LAYER_NUM aLayer )
|
|
|
|
{
|
|
|
|
if( aLayer >= NB_LAYERS )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return layer_z[ aLayer ];
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
void SetLayerZ( LAYER_NUM aLayer, double aValue )
|
|
|
|
{
|
|
|
|
layer_z[aLayer] = aValue;
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
void SetMaxDev( double dev )
|
|
|
|
{
|
|
|
|
holes.SetMaxDev( dev );
|
|
|
|
board.SetMaxDev( dev );
|
|
|
|
top_copper.SetMaxDev( dev );
|
|
|
|
bot_copper.SetMaxDev( dev );
|
|
|
|
top_silk.SetMaxDev( dev );
|
|
|
|
bot_silk.SetMaxDev( dev );
|
|
|
|
top_tin.SetMaxDev( dev );
|
|
|
|
bot_tin.SetMaxDev( dev );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// static var. for dealing with text
|
|
|
|
namespace VRMLEXPORT
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
static MODEL_VRML* model_vrml;
|
|
|
|
bool GetLayer( MODEL_VRML& aModel, LAYER_NUM layer, VRML_LAYER** vlayer );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// select the VRML layer object to draw on; return true if
|
|
|
|
// a layer has been selected.
|
|
|
|
bool VRMLEXPORT::GetLayer( MODEL_VRML& aModel, LAYER_NUM layer, VRML_LAYER** vlayer )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
switch( layer )
|
|
|
|
{
|
|
|
|
case FIRST_COPPER_LAYER:
|
|
|
|
*vlayer = &aModel.bot_copper;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_COPPER_LAYER:
|
|
|
|
*vlayer = &aModel.top_copper;
|
|
|
|
break;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
case SILKSCREEN_N_BACK:
|
|
|
|
*vlayer = &aModel.bot_silk;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SILKSCREEN_N_FRONT:
|
|
|
|
*vlayer = &aModel.top_silk;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
return true;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void write_triangle_bag( FILE* output_file, VRML_COLOR& color,
|
|
|
|
VRML_LAYER* layer, bool plane, bool top,
|
|
|
|
double top_z, double bottom_z )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
|
|
|
/* A lot of nodes are not required, but blender sometimes chokes
|
|
|
|
* without them */
|
|
|
|
static const char* shape_boiler[] =
|
|
|
|
{
|
|
|
|
"Transform {\n",
|
|
|
|
" children [\n",
|
|
|
|
" Group {\n",
|
|
|
|
" children [\n",
|
|
|
|
" Shape {\n",
|
|
|
|
" appearance Appearance {\n",
|
|
|
|
" material Material {\n",
|
2014-01-06 20:14:24 +00:00
|
|
|
0, // Material marker
|
2010-11-27 13:09:18 +00:00
|
|
|
" }\n",
|
|
|
|
" }\n",
|
|
|
|
" geometry IndexedFaceSet {\n",
|
2012-06-19 19:25:41 +00:00
|
|
|
" solid TRUE\n",
|
2010-11-27 13:09:18 +00:00
|
|
|
" coord Coordinate {\n",
|
|
|
|
" point [\n",
|
2014-01-06 20:14:24 +00:00
|
|
|
0, // Coordinates marker
|
2010-11-27 13:09:18 +00:00
|
|
|
" ]\n",
|
|
|
|
" }\n",
|
|
|
|
" coordIndex [\n",
|
2014-01-06 20:14:24 +00:00
|
|
|
0, // Index marker
|
2010-11-27 13:09:18 +00:00
|
|
|
" ]\n",
|
|
|
|
" }\n",
|
|
|
|
" }\n",
|
|
|
|
" ]\n",
|
|
|
|
" }\n",
|
|
|
|
" ]\n",
|
|
|
|
"}\n",
|
2014-01-06 20:14:24 +00:00
|
|
|
0 // End marker
|
2010-11-27 13:09:18 +00:00
|
|
|
};
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
int marker_found = 0, lineno = 0;
|
|
|
|
|
|
|
|
while( marker_found < 4 )
|
|
|
|
{
|
|
|
|
if( shape_boiler[lineno] )
|
|
|
|
fputs( shape_boiler[lineno], output_file );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
marker_found++;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
switch( marker_found )
|
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
case 1: // Material marker
|
|
|
|
fprintf( output_file,
|
|
|
|
" diffuseColor %g %g %g\n",
|
|
|
|
color.diffuse_red,
|
|
|
|
color.diffuse_grn,
|
|
|
|
color.diffuse_blu );
|
|
|
|
fprintf( output_file,
|
|
|
|
" specularColor %g %g %g\n",
|
|
|
|
color.spec_red,
|
|
|
|
color.spec_grn,
|
|
|
|
color.spec_blu );
|
2010-11-27 13:09:18 +00:00
|
|
|
fprintf( output_file,
|
2014-01-06 20:14:24 +00:00
|
|
|
" emissiveColor %g %g %g\n",
|
|
|
|
color.emit_red,
|
|
|
|
color.emit_grn,
|
|
|
|
color.emit_blu );
|
2010-11-27 13:09:18 +00:00
|
|
|
fprintf( output_file,
|
2014-01-06 20:14:24 +00:00
|
|
|
" ambientIntensity %g\n", color.ambient );
|
2010-11-27 13:09:18 +00:00
|
|
|
fprintf( output_file,
|
2014-01-06 20:14:24 +00:00
|
|
|
" transparency %g\n", color.transp );
|
|
|
|
fprintf( output_file,
|
|
|
|
" shininess %g\n", color.shiny );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2014-01-06 20:14:24 +00:00
|
|
|
|
|
|
|
if( plane )
|
|
|
|
layer->WriteVertices( top_z, output_file );
|
|
|
|
else
|
|
|
|
layer->Write3DVertices( top_z, bottom_z, output_file );
|
|
|
|
|
|
|
|
fprintf( output_file, "\n" );
|
|
|
|
break;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
|
|
|
case 3:
|
2014-01-06 20:14:24 +00:00
|
|
|
|
|
|
|
if( plane )
|
|
|
|
layer->WriteIndices( top, output_file );
|
|
|
|
else
|
|
|
|
layer->Write3DIndices( output_file );
|
|
|
|
|
|
|
|
fprintf( output_file, "\n" );
|
|
|
|
break;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
lineno++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void write_layers( MODEL_VRML& aModel, FILE* output_file, BOARD* aPcb )
|
|
|
|
{
|
|
|
|
// VRML_LAYER board;
|
|
|
|
aModel.board.Tesselate( &aModel.holes );
|
|
|
|
double brdz = aModel.board_thickness / 2.0 - 40000 * aModel.scale;
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_PCB ),
|
|
|
|
&aModel.board, false, false, brdz, -brdz );
|
|
|
|
|
|
|
|
// VRML_LAYER top_copper;
|
|
|
|
aModel.top_copper.Tesselate( &aModel.holes );
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ),
|
|
|
|
&aModel.top_copper, true, true,
|
|
|
|
aModel.GetLayerZ( LAST_COPPER_LAYER ), 0 );
|
|
|
|
|
|
|
|
// VRML_LAYER top_tin;
|
|
|
|
aModel.top_tin.Tesselate( &aModel.holes );
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
|
|
|
|
&aModel.top_tin, true, true,
|
|
|
|
aModel.GetLayerZ( LAST_COPPER_LAYER ), 0 );
|
|
|
|
|
|
|
|
// VRML_LAYER bot_copper;
|
|
|
|
aModel.bot_copper.Tesselate( &aModel.holes );
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ),
|
|
|
|
&aModel.bot_copper, true, false,
|
|
|
|
aModel.GetLayerZ( FIRST_COPPER_LAYER ), 0 );
|
|
|
|
|
|
|
|
// VRML_LAYER bot_tin;
|
|
|
|
aModel.bot_tin.Tesselate( &aModel.holes );
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
|
|
|
|
&aModel.bot_tin, true, false,
|
|
|
|
aModel.GetLayerZ( FIRST_COPPER_LAYER ), 0 );
|
|
|
|
|
|
|
|
// VRML_LAYER top_silk;
|
|
|
|
aModel.top_silk.Tesselate( &aModel.holes );
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ),
|
|
|
|
&aModel.top_silk, true, true,
|
|
|
|
aModel.GetLayerZ( SILKSCREEN_N_FRONT ), 0 );
|
|
|
|
|
|
|
|
// VRML_LAYER bot_silk;
|
|
|
|
aModel.bot_silk.Tesselate( &aModel.holes );
|
|
|
|
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ),
|
|
|
|
&aModel.bot_silk, true, false,
|
|
|
|
aModel.GetLayerZ( SILKSCREEN_N_BACK ), 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void compute_layer_Zs( MODEL_VRML& aModel, BOARD* pcb )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
int copper_layers = pcb->GetCopperLayerCount();
|
2010-11-27 13:09:18 +00:00
|
|
|
|
|
|
|
// We call it 'layer' thickness, but it's the whole board thickness!
|
2014-01-06 20:14:24 +00:00
|
|
|
aModel.board_thickness = pcb->GetDesignSettings().GetBoardThickness() * aModel.scale;
|
|
|
|
double half_thickness = aModel.board_thickness / 2;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Compute each layer's Z value, more or less like the 3d view
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM i = FIRST_LAYER; i <= LAYER_N_FRONT; ++i )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
|
|
|
if( i < copper_layers )
|
2014-01-06 20:14:24 +00:00
|
|
|
aModel.SetLayerZ( i, aModel.board_thickness * i / (copper_layers - 1) - half_thickness );
|
2010-11-27 13:09:18 +00:00
|
|
|
else
|
2014-01-06 20:14:24 +00:00
|
|
|
aModel.SetLayerZ( i, half_thickness ); // component layer
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* To avoid rounding interference, we apply an epsilon to each
|
|
|
|
* successive layer */
|
2014-01-06 20:14:24 +00:00
|
|
|
double epsilon_z = Millimeter2iu( 0.02 ) * aModel.scale;
|
|
|
|
aModel.SetLayerZ( SOLDERPASTE_N_BACK, -half_thickness - epsilon_z * 4 );
|
|
|
|
aModel.SetLayerZ( ADHESIVE_N_BACK, -half_thickness - epsilon_z * 3 );
|
|
|
|
aModel.SetLayerZ( SILKSCREEN_N_BACK, -half_thickness - epsilon_z * 2 );
|
|
|
|
aModel.SetLayerZ( SOLDERMASK_N_BACK, -half_thickness - epsilon_z );
|
|
|
|
aModel.SetLayerZ( SOLDERMASK_N_FRONT, half_thickness + epsilon_z );
|
|
|
|
aModel.SetLayerZ( SILKSCREEN_N_FRONT, half_thickness + epsilon_z * 2 );
|
|
|
|
aModel.SetLayerZ( ADHESIVE_N_FRONT, half_thickness + epsilon_z * 3 );
|
|
|
|
aModel.SetLayerZ( SOLDERPASTE_N_FRONT, half_thickness + epsilon_z * 4 );
|
|
|
|
aModel.SetLayerZ( DRAW_N, half_thickness + epsilon_z * 5 );
|
|
|
|
aModel.SetLayerZ( COMMENT_N, half_thickness + epsilon_z * 6 );
|
|
|
|
aModel.SetLayerZ( ECO1_N, half_thickness + epsilon_z * 7 );
|
|
|
|
aModel.SetLayerZ( ECO2_N, half_thickness + epsilon_z * 8 );
|
|
|
|
aModel.SetLayerZ( EDGE_N, 0 );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_line( MODEL_VRML& aModel, LAYER_NUM layer,
|
|
|
|
double startx, double starty,
|
|
|
|
double endx, double endy, double width )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_LAYER* vlayer;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( !VRMLEXPORT::GetLayer( aModel, layer, &vlayer ) )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
starty = -starty;
|
|
|
|
endy = -endy;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double angle = atan2( endy - starty, endx - startx );
|
|
|
|
double length = Distance( startx, starty, endx, endy ) + width;
|
|
|
|
double cx = ( startx + endx ) / 2.0;
|
|
|
|
double cy = ( starty + endy ) / 2.0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
vlayer->AddSlot( cx, cy, length, width, angle, 1, false );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_circle( MODEL_VRML& aModel, LAYER_NUM layer,
|
|
|
|
double startx, double starty,
|
|
|
|
double endx, double endy, double width )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_LAYER* vlayer;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( !VRMLEXPORT::GetLayer( aModel, layer, &vlayer ) )
|
|
|
|
return;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
starty = -starty;
|
|
|
|
endy = -endy;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double hole, radius;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
radius = Distance( startx, starty, endx, endy ) + ( width / 2);
|
|
|
|
hole = radius - width;
|
2012-06-19 19:25:41 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
vlayer->AddCircle( startx, starty, radius, 1, false );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( hole > 0.0001 )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
vlayer->AddCircle( startx, starty, hole, 1, true );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_arc( MODEL_VRML& aModel, LAYER_NUM layer,
|
|
|
|
double centerx, double centery,
|
|
|
|
double arc_startx, double arc_starty,
|
|
|
|
double width, double arc_angle )
|
2012-06-19 19:25:41 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
VRML_LAYER* vlayer;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( !VRMLEXPORT::GetLayer( aModel, layer, &vlayer ) )
|
|
|
|
return;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
centery = -centery;
|
|
|
|
arc_starty = -arc_starty;
|
2012-06-19 19:25:41 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
arc_angle *= -M_PI / 180;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
vlayer->AddArc( centerx, centery, arc_startx, arc_starty,
|
|
|
|
width, arc_angle, 1, false );
|
2012-06-19 19:25:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_drawsegment( MODEL_VRML& aModel, DRAWSEGMENT* drawseg )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer = drawseg->GetLayer();
|
2014-01-06 20:14:24 +00:00
|
|
|
double w = drawseg->GetWidth() * aModel.scale;
|
|
|
|
double x = drawseg->GetStart().x * aModel.scale + aModel.tx;
|
|
|
|
double y = drawseg->GetStart().y * aModel.scale + aModel.ty;
|
|
|
|
double xf = drawseg->GetEnd().x * aModel.scale + aModel.tx;
|
|
|
|
double yf = drawseg->GetEnd().y * aModel.scale + aModel.ty;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// Items on the edge layer are handled elsewhere; just return
|
2010-11-27 13:09:18 +00:00
|
|
|
if( layer == EDGE_N )
|
2014-01-06 20:14:24 +00:00
|
|
|
return;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
switch( drawseg->GetShape() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
case S_ARC:
|
|
|
|
export_vrml_arc( aModel, layer,
|
|
|
|
(double) drawseg->GetCenter().x,
|
|
|
|
(double) drawseg->GetCenter().y,
|
|
|
|
(double) drawseg->GetArcStart().x,
|
|
|
|
(double) drawseg->GetArcStart().y,
|
|
|
|
w, drawseg->GetAngle() / 10 );
|
|
|
|
break;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
case S_CIRCLE:
|
|
|
|
export_vrml_circle( aModel, layer, x, y, xf, yf, w );
|
|
|
|
break;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
default:
|
|
|
|
export_vrml_line( aModel, layer, x, y, xf, yf, w );
|
|
|
|
break;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* C++ doesn't have closures and neither continuation forms... this is
|
|
|
|
* for coupling the vrml_text_callback with the common parameters */
|
|
|
|
static void vrml_text_callback( int x0, int y0, int xf, int yf )
|
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
LAYER_NUM s_text_layer = VRMLEXPORT::model_vrml->s_text_layer;
|
|
|
|
int s_text_width = VRMLEXPORT::model_vrml->s_text_width;
|
|
|
|
double scale = VRMLEXPORT::model_vrml->scale;
|
|
|
|
double tx = VRMLEXPORT::model_vrml->tx;
|
|
|
|
double ty = VRMLEXPORT::model_vrml->ty;
|
|
|
|
|
|
|
|
export_vrml_line( *VRMLEXPORT::model_vrml, s_text_layer,
|
|
|
|
x0 * scale + tx, y0 * scale + ty,
|
|
|
|
xf * scale + tx, yf * scale + ty,
|
|
|
|
s_text_width * scale );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
VRMLEXPORT::model_vrml->s_text_layer = text->GetLayer();
|
|
|
|
VRMLEXPORT::model_vrml->s_text_width = text->GetThickness();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
wxSize size = text->GetSize();
|
|
|
|
|
|
|
|
if( text->IsMirrored() )
|
2010-11-27 13:09:18 +00:00
|
|
|
NEGATE( size.x );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-04-19 16:05:58 +00:00
|
|
|
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( text->IsMultilineAllowed() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2013-03-13 18:53:58 +00:00
|
|
|
wxArrayString* list = wxStringSplit( text->GetText(), '\n' );
|
2014-04-19 16:05:58 +00:00
|
|
|
std::vector<wxPoint> positions;
|
|
|
|
positions.reserve( list->Count() );
|
|
|
|
text->GetPositionsOfLinesOfMultilineText( positions, list->Count() );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-04-19 16:05:58 +00:00
|
|
|
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-04-19 16:05:58 +00:00
|
|
|
wxString txt = list->Item( ii );
|
|
|
|
DrawGraphicText( NULL, NULL, positions[ii], color,
|
|
|
|
txt, text->GetOrientation(), size,
|
|
|
|
text->GetHorizJustify(), text->GetVertJustify(),
|
|
|
|
text->GetThickness(), text->IsItalic(),
|
|
|
|
true,
|
|
|
|
vrml_text_callback );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete (list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-19 16:05:58 +00:00
|
|
|
DrawGraphicText( NULL, NULL, text->GetTextPosition(), color,
|
|
|
|
text->GetText(), text->GetOrientation(), size,
|
|
|
|
text->GetHorizJustify(), text->GetVertJustify(),
|
|
|
|
text->GetThickness(), text->IsItalic(),
|
|
|
|
true,
|
|
|
|
vrml_text_callback );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_drawings( MODEL_VRML& aModel, BOARD* pcb )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// draw graphic items
|
2014-01-06 20:14:24 +00:00
|
|
|
for( EDA_ITEM* drawing = pcb->m_Drawings; drawing != 0; drawing = drawing->Next() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
LAYER_NUM layer = ( (DRAWSEGMENT*) drawing )->GetLayer();
|
|
|
|
|
|
|
|
if( layer != FIRST_COPPER_LAYER && layer != LAST_COPPER_LAYER
|
|
|
|
&& layer != SILKSCREEN_N_BACK && layer != SILKSCREEN_N_FRONT )
|
|
|
|
continue;
|
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
switch( drawing->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_drawsegment( aModel, (DRAWSEGMENT*) drawing );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_pcbtext( aModel, (TEXTE_PCB*) drawing );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// board edges and cutouts
|
|
|
|
static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
|
|
|
|
{
|
|
|
|
CPOLYGONS_LIST bufferPcbOutlines; // stores the board main outlines
|
|
|
|
CPOLYGONS_LIST allLayerHoles; // Contains through holes, calculated only once
|
|
|
|
|
|
|
|
allLayerHoles.reserve( 20000 );
|
|
|
|
|
|
|
|
// Build a polygon from edge cut items
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines,
|
|
|
|
allLayerHoles, &msg ) )
|
|
|
|
{
|
|
|
|
msg << wxT( "\n\n" ) <<
|
|
|
|
_( "Unable to calculate the board outlines;\n"
|
|
|
|
"fall back to using the board boundary box." );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
double scale = aModel.scale;
|
|
|
|
double dx = aModel.tx;
|
|
|
|
double dy = aModel.ty;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
int seg;
|
|
|
|
|
|
|
|
// deal with the solid outlines
|
|
|
|
int nvert = bufferPcbOutlines.GetCornersCount();
|
|
|
|
|
|
|
|
while( i < nvert )
|
|
|
|
{
|
|
|
|
seg = aModel.board.NewContour();
|
|
|
|
|
|
|
|
if( seg < 0 )
|
|
|
|
{
|
|
|
|
msg << wxT( "\n\n" ) <<
|
|
|
|
_( "VRML Export Failed:\nCould not add outline to contours." );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( i < nvert )
|
|
|
|
{
|
|
|
|
aModel.board.AddVertex( seg, bufferPcbOutlines[i].x * scale + dx,
|
|
|
|
-(bufferPcbOutlines[i].y * scale + dy) );
|
|
|
|
|
|
|
|
if( bufferPcbOutlines[i].end_contour )
|
|
|
|
break;
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
aModel.board.EnsureWinding( seg, false );
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// deal with the holes
|
|
|
|
nvert = allLayerHoles.GetCornersCount();
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while( i < nvert )
|
|
|
|
{
|
|
|
|
seg = aModel.holes.NewContour();
|
|
|
|
|
|
|
|
if( seg < 0 )
|
|
|
|
{
|
|
|
|
msg << wxT( "\n\n" ) <<
|
|
|
|
_( "VRML Export Failed:\nCould not add holes to contours." );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( i < nvert )
|
|
|
|
{
|
|
|
|
aModel.holes.AddVertex( seg, allLayerHoles[i].x * scale + dx,
|
|
|
|
-(allLayerHoles[i].y * scale + dy) );
|
|
|
|
|
|
|
|
if( allLayerHoles[i].end_contour )
|
|
|
|
break;
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
aModel.holes.EnsureWinding( seg, true );
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void export_round_padstack( MODEL_VRML& aModel, BOARD* pcb,
|
|
|
|
double x, double y, double r,
|
|
|
|
LAYER_NUM bottom_layer, LAYER_NUM top_layer,
|
|
|
|
double hole )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
LAYER_NUM layer = top_layer;
|
|
|
|
bool thru = true;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// if not a thru hole do not put a hole in the board
|
|
|
|
if( top_layer != LAST_COPPER_LAYER || bottom_layer != FIRST_COPPER_LAYER )
|
|
|
|
thru = false;
|
|
|
|
|
|
|
|
while( 1 )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
if( layer == FIRST_COPPER_LAYER )
|
|
|
|
{
|
|
|
|
aModel.bot_copper.AddCircle( x, -y, r, 1 );
|
|
|
|
|
|
|
|
if( hole > 0 )
|
|
|
|
{
|
|
|
|
if( thru )
|
|
|
|
aModel.holes.AddCircle( x, -y, hole, 1, true );
|
|
|
|
else
|
|
|
|
aModel.bot_copper.AddCircle( x, -y, hole, 1, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( layer == LAST_COPPER_LAYER )
|
|
|
|
{
|
|
|
|
aModel.top_copper.AddCircle( x, -y, r, 1 );
|
|
|
|
|
|
|
|
if( hole > 0 )
|
|
|
|
{
|
|
|
|
if( thru )
|
|
|
|
aModel.holes.AddCircle( x, -y, hole, 1, true );
|
|
|
|
else
|
|
|
|
aModel.top_copper.AddCircle( x, -y, hole, 1, true );
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( layer == bottom_layer )
|
|
|
|
break;
|
|
|
|
|
|
|
|
layer = bottom_layer;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
static void export_vrml_via( MODEL_VRML& aModel, BOARD* pcb, const VIA* via )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
|
|
|
double x, y, r, hole;
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM top_layer, bottom_layer;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
hole = via->GetDrillValue() * aModel.scale / 2.0;
|
|
|
|
r = via->GetWidth() * aModel.scale / 2.0;
|
|
|
|
x = via->GetStart().x * aModel.scale + aModel.tx;
|
|
|
|
y = via->GetStart().y * aModel.scale + aModel.ty;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
via->LayerPair( &top_layer, &bottom_layer );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// do not render a buried via
|
|
|
|
if( top_layer != LAST_COPPER_LAYER && bottom_layer != FIRST_COPPER_LAYER )
|
|
|
|
return;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// Export the via padstack
|
|
|
|
export_round_padstack( aModel, pcb, x, y, r, bottom_layer, top_layer, hole );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_tracks( MODEL_VRML& aModel, BOARD* pcb )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
|
|
|
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2014-01-06 20:14:24 +00:00
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
export_vrml_via( aModel, pcb, (const VIA*) track );
|
2014-01-06 20:14:24 +00:00
|
|
|
}
|
|
|
|
else if( track->GetLayer() == FIRST_COPPER_LAYER
|
|
|
|
|| track->GetLayer() == LAST_COPPER_LAYER )
|
|
|
|
export_vrml_line( aModel, track->GetLayer(),
|
|
|
|
track->GetStart().x * aModel.scale + aModel.tx,
|
|
|
|
track->GetStart().y * aModel.scale + aModel.ty,
|
|
|
|
track->GetEnd().x * aModel.scale + aModel.tx,
|
|
|
|
track->GetEnd().y * aModel.scale + aModel.ty,
|
|
|
|
track->GetWidth() * aModel.scale );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
double scale = aModel.scale;
|
|
|
|
double dx = aModel.tx;
|
|
|
|
double dy = aModel.ty;
|
|
|
|
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
ZONE_CONTAINER* zone = aPcb->GetArea( ii );
|
|
|
|
|
|
|
|
VRML_LAYER* vl;
|
2011-08-29 03:04:59 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( !VRMLEXPORT::GetLayer( aModel, zone->GetLayer(), &vl ) )
|
2010-11-27 13:09:18 +00:00
|
|
|
continue;
|
2011-08-29 03:04:59 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( !zone->IsFilled() )
|
|
|
|
{
|
|
|
|
zone->SetFillMode( 0 ); // use filled polygons
|
|
|
|
zone->BuildFilledSolidAreasPolygons( aPcb );
|
|
|
|
}
|
|
|
|
const CPOLYGONS_LIST& poly = zone->GetFilledPolysList();
|
|
|
|
|
|
|
|
int nvert = poly.GetCornersCount();
|
|
|
|
int i = 0;
|
2013-03-18 19:36:07 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
while( i < nvert )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
int seg = vl->NewContour();
|
|
|
|
bool first = true;
|
2011-08-29 03:04:59 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( seg < 0 )
|
|
|
|
break;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
while( i < nvert )
|
|
|
|
{
|
|
|
|
x = poly.GetX(i) * scale + dx;
|
|
|
|
y = -(poly.GetY(i) * scale + dy);
|
|
|
|
vl->AddVertex( seg, x, y );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( poly.IsEndContour(i) )
|
|
|
|
break;
|
2011-08-29 03:04:59 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
++i;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
2014-01-06 20:14:24 +00:00
|
|
|
|
|
|
|
// KiCad ensures that the first polygon is the outline
|
|
|
|
// and all others are holes
|
|
|
|
vl->EnsureWinding( seg, first ? false : true );
|
|
|
|
|
|
|
|
if( first )
|
|
|
|
first = false;
|
|
|
|
|
|
|
|
++i;
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
|
|
|
|
static void export_vrml_text_module( TEXTE_MODULE* module )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2011-12-12 08:37:05 +00:00
|
|
|
if( module->IsVisible() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
wxSize size = module->GetSize();
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( module->IsMirrored() )
|
2014-01-06 20:14:24 +00:00
|
|
|
NEGATE( size.x ); // Text is mirrored
|
|
|
|
|
|
|
|
VRMLEXPORT::model_vrml->s_text_layer = module->GetLayer();
|
|
|
|
VRMLEXPORT::model_vrml->s_text_width = module->GetThickness();
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
DrawGraphicText( NULL, NULL, module->GetTextPosition(), BLACK,
|
2014-01-06 20:14:24 +00:00
|
|
|
module->GetText(), module->GetDrawRotation(), size,
|
|
|
|
module->GetHorizJustify(), module->GetVertJustify(),
|
|
|
|
module->GetThickness(), module->IsItalic(),
|
|
|
|
true,
|
|
|
|
vrml_text_callback );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-15 07:39:06 +00:00
|
|
|
static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline,
|
|
|
|
double aOrientation )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer = aOutline->GetLayer();
|
2014-01-06 20:14:24 +00:00
|
|
|
double x = aOutline->GetStart().x * aModel.scale + aModel.tx;
|
|
|
|
double y = aOutline->GetStart().y * aModel.scale + aModel.ty;
|
|
|
|
double xf = aOutline->GetEnd().x * aModel.scale + aModel.tx;
|
|
|
|
double yf = aOutline->GetEnd().y * aModel.scale + aModel.ty;
|
|
|
|
double w = aOutline->GetWidth() * aModel.scale;
|
2012-06-19 19:25:41 +00:00
|
|
|
|
|
|
|
switch( aOutline->GetShape() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-02-15 07:39:06 +00:00
|
|
|
case S_SEGMENT:
|
|
|
|
export_vrml_line( aModel, layer, x, y, xf, yf, w );
|
|
|
|
break;
|
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
case S_ARC:
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_arc( aModel, layer, x, y, xf, yf, w, aOutline->GetAngle() / 10 );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_circle( aModel, layer, x, y, xf, yf, w );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-15 07:39:06 +00:00
|
|
|
case S_POLYGON:
|
|
|
|
{
|
|
|
|
VRML_LAYER* vl;
|
|
|
|
|
|
|
|
if( !VRMLEXPORT::GetLayer( aModel, layer, &vl ) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
int nvert = aOutline->GetPolyPoints().size();
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if( nvert < 3 ) break;
|
|
|
|
|
|
|
|
int seg = vl->NewContour();
|
|
|
|
|
|
|
|
if( seg < 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
while( i < nvert )
|
|
|
|
{
|
|
|
|
CPolyPt corner( aOutline->GetPolyPoints()[i] );
|
|
|
|
RotatePoint( &corner.x, &corner.y, aOrientation );
|
|
|
|
corner.x += aOutline->GetPosition().x;
|
|
|
|
corner.y += aOutline->GetPosition().y;
|
|
|
|
|
|
|
|
x = corner.x * aModel.scale + aModel.tx;
|
|
|
|
y = - ( corner.y * aModel.scale + aModel.ty );
|
|
|
|
vl->AddVertex( seg, x, y );
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
vl->EnsureWinding( seg, false );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aLayer,
|
|
|
|
VRML_LAYER* aTinLayer, D_PAD* aPad )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
// The (maybe offset) pad position
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxPoint pad_pos = aPad->ShapePos();
|
2014-01-06 20:14:24 +00:00
|
|
|
double pad_x = pad_pos.x * aModel.scale + aModel.tx;
|
|
|
|
double pad_y = pad_pos.y * aModel.scale + aModel.ty;
|
|
|
|
wxSize pad_delta = aPad->GetDelta();
|
|
|
|
|
|
|
|
double pad_dx = pad_delta.x * aModel.scale / 2.0;
|
|
|
|
double pad_dy = pad_delta.y * aModel.scale / 2.0;
|
|
|
|
|
|
|
|
double pad_w = aPad->GetSize().x * aModel.scale / 2.0;
|
|
|
|
double pad_h = aPad->GetSize().y * aModel.scale / 2.0;
|
|
|
|
|
|
|
|
switch( aPad->GetShape() )
|
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
|
|
|
aLayer->AddCircle( pad_x, -pad_y, pad_w, 1, true );
|
|
|
|
aTinLayer->AddCircle( pad_x, -pad_y, pad_w, 1, false );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
|
|
|
aLayer->AddSlot( pad_x, -pad_y, pad_w * 2.0, pad_h * 2.0,
|
|
|
|
DECIDEG2RAD( aPad->GetOrientation() ), 1, true );
|
|
|
|
aTinLayer->AddSlot( pad_x, -pad_y, pad_w * 2.0, pad_h * 2.0,
|
|
|
|
DECIDEG2RAD( aPad->GetOrientation() ), 1, false );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
// Just to be sure :D
|
|
|
|
pad_dx = 0;
|
|
|
|
pad_dy = 0;
|
|
|
|
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
{
|
|
|
|
double coord[8] =
|
|
|
|
{
|
|
|
|
-pad_w + pad_dy, -pad_h - pad_dx,
|
|
|
|
-pad_w - pad_dy, pad_h + pad_dx,
|
|
|
|
+pad_w - pad_dy, -pad_h + pad_dx,
|
|
|
|
+pad_w + pad_dy, pad_h - pad_dx
|
|
|
|
};
|
|
|
|
|
|
|
|
for( int i = 0; i < 4; i++ )
|
|
|
|
{
|
|
|
|
RotatePoint( &coord[i * 2], &coord[i * 2 + 1], aPad->GetOrientation() );
|
|
|
|
coord[i * 2] += pad_x;
|
|
|
|
coord[i * 2 + 1] += pad_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
int lines = aLayer->NewContour();
|
|
|
|
|
|
|
|
if( lines < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
aLayer->AddVertex( lines, coord[2], -coord[3] );
|
|
|
|
aLayer->AddVertex( lines, coord[6], -coord[7] );
|
|
|
|
aLayer->AddVertex( lines, coord[4], -coord[5] );
|
|
|
|
aLayer->AddVertex( lines, coord[0], -coord[1] );
|
|
|
|
aLayer->EnsureWinding( lines, true );
|
|
|
|
|
|
|
|
lines = aTinLayer->NewContour();
|
|
|
|
|
|
|
|
if( lines < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
aTinLayer->AddVertex( lines, coord[0], -coord[1] );
|
|
|
|
aTinLayer->AddVertex( lines, coord[4], -coord[5] );
|
|
|
|
aTinLayer->AddVertex( lines, coord[6], -coord[7] );
|
|
|
|
aTinLayer->AddVertex( lines, coord[2], -coord[3] );
|
|
|
|
aTinLayer->EnsureWinding( lines, false );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void export_vrml_pad( MODEL_VRML& aModel, BOARD* pcb, D_PAD* aPad )
|
|
|
|
{
|
|
|
|
double hole_drill_w = (double) aPad->GetDrillSize().x * aModel.scale / 2.0;
|
|
|
|
double hole_drill_h = (double) aPad->GetDrillSize().y * aModel.scale / 2.0;
|
|
|
|
double hole_drill = std::min( hole_drill_w, hole_drill_h );
|
|
|
|
double hole_x = aPad->GetPosition().x * aModel.scale + aModel.tx;
|
|
|
|
double hole_y = aPad->GetPosition().y * aModel.scale + aModel.ty;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export the hole on the edge layer
|
2010-11-27 13:09:18 +00:00
|
|
|
if( hole_drill > 0 )
|
|
|
|
{
|
2014-01-26 14:20:58 +00:00
|
|
|
if( aPad->GetDrillShape() == PAD_DRILL_OBLONG )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// Oblong hole (slot)
|
2014-01-06 20:14:24 +00:00
|
|
|
aModel.holes.AddSlot( hole_x, -hole_y, hole_drill_w * 2.0, hole_drill_h * 2.0,
|
|
|
|
DECIDEG2RAD( aPad->GetOrientation() ), 1, true );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Drill a round hole
|
2014-01-06 20:14:24 +00:00
|
|
|
aModel.holes.AddCircle( hole_x, -hole_y, hole_drill, 1, true );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// The pad proper, on the selected layers
|
2014-01-06 20:14:24 +00:00
|
|
|
LAYER_MSK layer_mask = aPad->GetLayerMask();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( layer_mask & LAYER_BACK )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_padshape( aModel, &aModel.bot_copper, &aModel.bot_tin, aPad );
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
if( layer_mask & LAYER_FRONT )
|
|
|
|
{
|
|
|
|
export_vrml_padshape( aModel, &aModel.top_copper, &aModel.top_tin, aPad );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// From axis/rot to quaternion
|
2010-11-27 13:09:18 +00:00
|
|
|
static void build_quat( double x, double y, double z, double a, double q[4] )
|
|
|
|
{
|
|
|
|
double sina = sin( a / 2 );
|
|
|
|
|
|
|
|
q[0] = x * sina;
|
|
|
|
q[1] = y * sina;
|
|
|
|
q[2] = z * sina;
|
|
|
|
q[3] = cos( a / 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// From quaternion to axis/rot
|
2010-11-27 13:09:18 +00:00
|
|
|
static void from_quat( double q[4], double rot[4] )
|
|
|
|
{
|
|
|
|
rot[3] = acos( q[3] ) * 2;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
for( int i = 0; i < 3; i++ )
|
|
|
|
{
|
|
|
|
rot[i] = q[i] / sin( rot[3] / 2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Quaternion composition
|
2010-11-27 13:09:18 +00:00
|
|
|
static void compose_quat( double q1[4], double q2[4], double qr[4] )
|
|
|
|
{
|
|
|
|
double tmp[4];
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
tmp[0] = q2[3] * q1[0] + q2[0] * q1[3] + q2[1] * q1[2] - q2[2] * q1[1];
|
|
|
|
tmp[1] = q2[3] * q1[1] + q2[1] * q1[3] + q2[2] * q1[0] - q2[0] * q1[2];
|
|
|
|
tmp[2] = q2[3] * q1[2] + q2[2] * q1[3] + q2[0] * q1[1] - q2[1] * q1[0];
|
|
|
|
tmp[3] = q2[3] * q1[3] - q2[0] * q1[0] - q2[1] * q1[1] - q2[2] * q1[2];
|
|
|
|
|
|
|
|
qr[0] = tmp[0];
|
|
|
|
qr[1] = tmp[1];
|
|
|
|
qr[2] = tmp[2];
|
|
|
|
qr[3] = tmp[3];
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule,
|
|
|
|
FILE* aOutputFile,
|
|
|
|
double aVRMLModelsToBiu,
|
|
|
|
bool aExport3DFiles, const wxString& a3D_Subdir )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// Reference and value
|
2014-01-06 20:14:24 +00:00
|
|
|
if( aModule->Reference().IsVisible() )
|
|
|
|
export_vrml_text_module( &aModule->Reference() );
|
|
|
|
|
|
|
|
if( aModule->Value().IsVisible() )
|
|
|
|
export_vrml_text_module( &aModule->Value() );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export module edges
|
2014-01-06 20:14:24 +00:00
|
|
|
for( EDA_ITEM* item = aModule->GraphicalItems(); item != NULL; item = item->Next() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2013-03-28 16:51:22 +00:00
|
|
|
export_vrml_text_module( dynamic_cast<TEXTE_MODULE*>( item ) );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2014-02-15 07:39:06 +00:00
|
|
|
export_vrml_edge_module( aModel, dynamic_cast<EDGE_MODULE*>( item ),
|
|
|
|
aModule->GetOrientation() );
|
2010-11-27 13:09:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export pads
|
2014-01-06 20:14:24 +00:00
|
|
|
for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
|
|
|
|
export_vrml_pad( aModel, aPcb, pad );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
|
|
|
bool isFlipped = aModule->GetLayer() == LAYER_N_BACK;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export the object VRML model(s)
|
2014-02-03 21:39:42 +00:00
|
|
|
for( S3D_MASTER* vrmlm = aModule->Models(); vrmlm; vrmlm = vrmlm->Next() )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-01-25 12:23:29 +00:00
|
|
|
if( !vrmlm->Is3DType( S3D_MASTER::FILE3D_VRML ) )
|
2010-11-27 13:09:18 +00:00
|
|
|
continue;
|
|
|
|
|
2014-02-08 10:44:55 +00:00
|
|
|
wxString fname = vrmlm->GetShape3DFullFilename();
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
fname.Replace( wxT( "\\" ), wxT( "/" ) );
|
2010-11-27 13:09:18 +00:00
|
|
|
wxString source_fname = fname;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-18 11:41:53 +00:00
|
|
|
if( aExport3DFiles )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-02-18 11:41:53 +00:00
|
|
|
// Change illegal characters in filenames
|
2011-03-12 09:50:21 +00:00
|
|
|
ChangeIllegalCharacters( fname, true );
|
2013-03-28 16:51:22 +00:00
|
|
|
fname = a3D_Subdir + wxT( "/" ) + fname;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
if( !wxFileExists( fname ) )
|
|
|
|
wxCopyFile( source_fname, fname );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate 3D shape rotation:
|
|
|
|
* this is the rotation parameters, with an additional 180 deg rotation
|
|
|
|
* for footprints that are flipped
|
|
|
|
* When flipped, axis rotation is the horizontal axis (X axis)
|
|
|
|
*/
|
2014-01-06 20:14:24 +00:00
|
|
|
double rotx = -vrmlm->m_MatRotation.x;
|
|
|
|
double roty = -vrmlm->m_MatRotation.y;
|
|
|
|
double rotz = -vrmlm->m_MatRotation.z;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( isFlipped )
|
2011-01-15 18:06:10 +00:00
|
|
|
{
|
|
|
|
rotx += 180.0;
|
2013-03-13 18:53:58 +00:00
|
|
|
NEGATE( roty );
|
|
|
|
NEGATE( rotz );
|
2011-01-15 18:06:10 +00:00
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Do some quaternion munching
|
2010-11-27 13:09:18 +00:00
|
|
|
double q1[4], q2[4], rot[4];
|
2013-05-01 17:32:36 +00:00
|
|
|
build_quat( 1, 0, 0, DEG2RAD( rotx ), q1 );
|
|
|
|
build_quat( 0, 1, 0, DEG2RAD( roty ), q2 );
|
2010-11-27 13:09:18 +00:00
|
|
|
compose_quat( q1, q2, q1 );
|
2013-05-01 17:32:36 +00:00
|
|
|
build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 );
|
2010-11-27 13:09:18 +00:00
|
|
|
compose_quat( q1, q2, q1 );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Note here aModule->GetOrientation() is in 0.1 degrees,
|
2013-05-02 18:06:58 +00:00
|
|
|
// so module rotation has to be converted to radians
|
|
|
|
build_quat( 0, 0, 1, DECIDEG2RAD( aModule->GetOrientation() ), q2 );
|
2010-11-27 13:09:18 +00:00
|
|
|
compose_quat( q1, q2, q1 );
|
|
|
|
from_quat( q1, rot );
|
|
|
|
|
|
|
|
fprintf( aOutputFile, "Transform {\n" );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// A null rotation would fail the acos!
|
2010-11-27 13:09:18 +00:00
|
|
|
if( rot[3] != 0.0 )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
fprintf( aOutputFile, " rotation %g %g %g %g\n", rot[0], rot[1], rot[2], rot[3] );
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-02-19 09:21:55 +00:00
|
|
|
// adjust 3D shape local offset position
|
|
|
|
// they are given in inch, so they are converted in board IU.
|
|
|
|
double offsetx = vrmlm->m_MatPosition.x * IU_PER_MILS * 1000.0;
|
|
|
|
double offsety = vrmlm->m_MatPosition.y * IU_PER_MILS * 1000.0;
|
|
|
|
double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0;
|
2011-01-15 20:21:46 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( isFlipped )
|
2014-01-06 20:14:24 +00:00
|
|
|
NEGATE( offsetz );
|
|
|
|
else // In normal mode, Y axis is reversed in Pcbnew.
|
|
|
|
NEGATE( offsety );
|
2011-01-19 10:34:56 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
RotatePoint( &offsetx, &offsety, aModule->GetOrientation() );
|
2011-01-15 20:21:46 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
fprintf( aOutputFile, " translation %g %g %g\n",
|
2014-01-06 20:14:24 +00:00
|
|
|
(offsetx + aModule->GetPosition().x) * aModel.scale + aModel.tx,
|
|
|
|
-(offsety + aModule->GetPosition().y) * aModel.scale - aModel.ty,
|
|
|
|
(offsetz * aModel.scale ) + aModel.GetLayerZ( aModule->GetLayer() ) );
|
2013-01-12 10:35:08 +00:00
|
|
|
|
|
|
|
fprintf( aOutputFile, " scale %g %g %g\n",
|
2014-01-06 20:14:24 +00:00
|
|
|
vrmlm->m_MatScale.x * aVRMLModelsToBiu,
|
|
|
|
vrmlm->m_MatScale.y * aVRMLModelsToBiu,
|
|
|
|
vrmlm->m_MatScale.z * aVRMLModelsToBiu );
|
2013-01-12 10:35:08 +00:00
|
|
|
|
2013-03-27 18:34:23 +00:00
|
|
|
if( fname.EndsWith( wxT( "x3d" ) ) )
|
|
|
|
{
|
2013-03-28 16:51:22 +00:00
|
|
|
X3D_MODEL_PARSER* parser = new X3D_MODEL_PARSER( vrmlm );
|
2013-03-27 18:34:23 +00:00
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
if( parser )
|
2013-03-27 18:34:23 +00:00
|
|
|
{
|
|
|
|
// embed x3d model in vrml format
|
2013-03-28 16:51:22 +00:00
|
|
|
parser->Load( fname );
|
2013-03-27 18:34:23 +00:00
|
|
|
fprintf( aOutputFile,
|
2014-01-06 20:14:24 +00:00
|
|
|
" children [\n %s ]\n", TO_UTF8( parser->VRML_representation() ) );
|
2013-03-27 18:34:23 +00:00
|
|
|
fprintf( aOutputFile, " }\n" );
|
|
|
|
delete parser;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf( aOutputFile,
|
2014-01-06 20:14:24 +00:00
|
|
|
" children [\n Inline {\n url \"%s\"\n } ]\n",
|
|
|
|
TO_UTF8( fname ) );
|
2013-03-27 18:34:23 +00:00
|
|
|
fprintf( aOutputFile, " }\n" );
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName,
|
|
|
|
double aMMtoWRMLunit, bool aExport3DFiles,
|
|
|
|
const wxString& a3D_Subdir )
|
2010-11-27 13:09:18 +00:00
|
|
|
{
|
2014-02-03 21:39:42 +00:00
|
|
|
wxString msg;
|
|
|
|
FILE* output_file;
|
|
|
|
BOARD* pcb = GetBoard();
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
MODEL_VRML model3d;
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
VRMLEXPORT::model_vrml = &model3d;
|
2010-11-27 13:09:18 +00:00
|
|
|
|
|
|
|
output_file = wxFopen( aFullFileName, wxT( "wt" ) );
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2010-11-27 13:09:18 +00:00
|
|
|
if( output_file == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
|
|
|
SetLocaleTo_C_standard();
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Begin with the usual VRML boilerplate
|
2011-03-12 09:50:21 +00:00
|
|
|
wxString name = aFullFileName;
|
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
name.Replace( wxT( "\\" ), wxT( "/" ) );
|
2011-03-12 09:50:21 +00:00
|
|
|
ChangeIllegalCharacters( name, false );
|
2010-11-27 13:09:18 +00:00
|
|
|
fprintf( output_file, "#VRML V2.0 utf8\n"
|
|
|
|
"WorldInfo {\n"
|
2011-09-30 18:15:37 +00:00
|
|
|
" title \"%s - Generated by Pcbnew\"\n"
|
2011-03-12 09:50:21 +00:00
|
|
|
"}\n", TO_UTF8( name ) );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2013-01-12 10:35:08 +00:00
|
|
|
// Global VRML scale to export to a different scale.
|
2014-01-06 20:14:24 +00:00
|
|
|
model3d.scale = aMMtoWRMLunit / MM_PER_IU;
|
2014-02-03 21:39:42 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// Set the mechanical deviation limit (in this case 0.02mm)
|
|
|
|
// XXX - NOTE: the value should be set via the GUI
|
|
|
|
model3d.SetMaxDev( 20000 * model3d.scale );
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
fprintf( output_file, "Transform {\n" );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// compute the offset to center the board on (0, 0, 0)
|
|
|
|
// XXX - NOTE: we should allow the user a GUI option to specify the offset
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
EDA_RECT bbbox = pcb->ComputeBoundingBox();
|
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
model3d.SetOffset( -model3d.scale * bbbox.Centre().x, -model3d.scale * bbbox.Centre().y );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
fprintf( output_file, " children [\n" );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Preliminary computation: the z value for each layer
|
2014-01-06 20:14:24 +00:00
|
|
|
compute_layer_Zs( model3d, pcb );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2014-01-06 20:14:24 +00:00
|
|
|
// board edges and cutouts
|
|
|
|
export_vrml_board( model3d, pcb );
|
|
|
|
|
|
|
|
// Drawing and text on the board
|
|
|
|
export_vrml_drawings( model3d, pcb );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export vias and trackage
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_tracks( model3d, pcb );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export zone fills
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_zones( model3d, pcb);
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2013-01-12 10:35:08 +00:00
|
|
|
/* scaling factor to convert 3D models to board units (decimils)
|
|
|
|
* Usually we use Wings3D to create thems.
|
|
|
|
* One can consider the 3D units is 0.1 inch (2.54 mm)
|
|
|
|
* So the scaling factor from 0.1 inch to board units
|
2013-01-13 16:55:07 +00:00
|
|
|
* is 2.54 * aMMtoWRMLunit
|
2013-01-12 10:35:08 +00:00
|
|
|
*/
|
2013-01-13 16:55:07 +00:00
|
|
|
double wrml_3D_models_scaling_factor = 2.54 * aMMtoWRMLunit;
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Export footprints
|
2011-09-07 19:41:04 +00:00
|
|
|
for( MODULE* module = pcb->m_Modules; module != 0; module = module->Next() )
|
2014-01-06 20:14:24 +00:00
|
|
|
export_vrml_module( model3d, pcb, module, output_file,
|
|
|
|
wrml_3D_models_scaling_factor,
|
|
|
|
aExport3DFiles, a3D_Subdir );
|
|
|
|
|
|
|
|
// write out the board and all layers
|
|
|
|
write_layers( model3d, output_file, pcb );
|
2010-11-27 13:09:18 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Close the outer 'transform' node
|
2010-11-27 13:09:18 +00:00
|
|
|
fputs( "]\n}\n", output_file );
|
|
|
|
|
|
|
|
// End of work
|
|
|
|
fclose( output_file );
|
|
|
|
SetLocaleTo_Default(); // revert to the current locale
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-03-12 09:50:21 +00:00
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
/*
|
|
|
|
* some characters cannot be used in filenames,
|
|
|
|
* this function change them to "_"
|
|
|
|
*/
|
2014-01-06 20:14:24 +00:00
|
|
|
static void ChangeIllegalCharacters( wxString& aFileName, bool aDirSepIsIllegal )
|
2011-03-12 09:50:21 +00:00
|
|
|
{
|
|
|
|
if( aDirSepIsIllegal )
|
2013-03-28 16:51:22 +00:00
|
|
|
aFileName.Replace( wxT( "/" ), wxT( "_" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-28 16:51:22 +00:00
|
|
|
aFileName.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
aFileName.Replace( wxT( ":" ), wxT( "_" ) );
|
2011-03-12 09:50:21 +00:00
|
|
|
}
|