GenCAD exporter: added origin settings

Added an option to the exporter dialog allowing the user to choose
either the absolute or the auxiliary origin. Also, the ORIGIN field in
the exported file can be set to contain the information about the origin
point or set to (0, 0) for compatibility with other CAD tools.
This commit is contained in:
Maciej Suminski 2017-11-08 10:21:45 +01:00
parent 0b34d09bc0
commit c9b791ca2a
3 changed files with 13 additions and 6 deletions

View File

@ -129,7 +129,9 @@ void DIALOG_GENCAD_EXPORT_OPTIONS::createOptCheckboxes()
{
{ FLIP_BOTTOM_PADS, _( "Flip bottom components padstacks" ) },
{ UNIQUE_PIN_NAMES, _( "Generate unique pin names" ) },
{ INDIVIDUAL_SHAPES, _( "Generate a new shape for each component (do not reuse shapes)" ) }
{ INDIVIDUAL_SHAPES, _( "Generate a new shape for each component instance (do not reuse shapes)" ) },
{ USE_AUX_ORIGIN, _( "Use auxiliary axis as origin" ) },
{ STORE_ORIGIN_COORDS, _( "Save the origin coordinates in the file" ) }
};
for( const auto& option : opts )

View File

@ -35,7 +35,9 @@ enum GENCAD_EXPORT_OPT
{
FLIP_BOTTOM_PADS, // flip bottom components padstacks geometry
UNIQUE_PIN_NAMES, // generate unique pin names
INDIVIDUAL_SHAPES // generate a shape for each component
INDIVIDUAL_SHAPES, // generate a shape for each component
USE_AUX_ORIGIN, // use auxiliary axis as origin
STORE_ORIGIN_COORDS // saves the origin point coordinates or (0, 0)
};

View File

@ -229,6 +229,7 @@ static std::string fmt_mask( LSET aSet )
static bool flipBottomPads;
static bool uniquePins;
static bool individualShapes;
static bool storeOriginCoords;
// These are the export origin (the auxiliary axis)
static int GencadOffsetX, GencadOffsetY;
@ -292,6 +293,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );
uniquePins = optionsDialog.GetOption( UNIQUE_PIN_NAMES );
individualShapes = optionsDialog.GetOption( INDIVIDUAL_SHAPES );
storeOriginCoords = optionsDialog.GetOption( STORE_ORIGIN_COORDS );
// Switch the locale to standard C (needed to print floating point numbers)
LOCALE_IO toggle;
@ -300,8 +302,8 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
GetBoard()->ComputeBoundingBox();
// Save the auxiliary origin for the rest of the module
GencadOffsetX = GetAuxOrigin().x;
GencadOffsetY = GetAuxOrigin().y;
GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().x : 0;
GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().y : 0;
// No idea on *why* this should be needed... maybe to fix net names?
Compile_Ratsnest( NULL, true );
@ -999,9 +1001,10 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
fputs( TO_UTF8( msg ), aFile );
fputs( "UNITS INCH\n", aFile );
// giving 0 as the argument to Map{X,Y}To returns the scaled origin point
msg.Printf( wxT( "ORIGIN %g %g\n" ),
MapXTo( aFrame->GetAuxOrigin().x ),
MapYTo( aFrame->GetAuxOrigin().y ) );
storeOriginCoords ? MapXTo( 0 ) : 0,
storeOriginCoords ? MapYTo( 0 ) : 0 );
fputs( TO_UTF8( msg ), aFile );
fputs( "INTERTRACK 0\n", aFile );