From c9b791ca2a2b563ea85dcaa52dd9c0eb258f5cfa Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 8 Nov 2017 10:21:45 +0100 Subject: [PATCH] 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. --- pcbnew/dialogs/dialog_gencad_export_options.cpp | 4 +++- pcbnew/dialogs/dialog_gencad_export_options.h | 4 +++- pcbnew/exporters/export_gencad.cpp | 11 +++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pcbnew/dialogs/dialog_gencad_export_options.cpp b/pcbnew/dialogs/dialog_gencad_export_options.cpp index bb0d756c04..684172a7f6 100644 --- a/pcbnew/dialogs/dialog_gencad_export_options.cpp +++ b/pcbnew/dialogs/dialog_gencad_export_options.cpp @@ -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 ) diff --git a/pcbnew/dialogs/dialog_gencad_export_options.h b/pcbnew/dialogs/dialog_gencad_export_options.h index 103b0a5481..a0d01c237a 100644 --- a/pcbnew/dialogs/dialog_gencad_export_options.h +++ b/pcbnew/dialogs/dialog_gencad_export_options.h @@ -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) }; diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index aa8ebac35f..d9c582b8bf 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -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 );