From badd0bfa548c1fee1129537ccdf55ec306fef90e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 20 Sep 2019 13:13:19 +0200 Subject: [PATCH] Minot fixes in GERBER_JOBFILE_WRITER, due to recent changes in .gbrjob file format. --- .../stackup_predefined_prms.cpp | 4 ++-- pcbnew/exporters/gerber_jobfile_writer.cpp | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp b/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp index 950d5fb49a..bbe473ceb6 100644 --- a/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp +++ b/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp @@ -61,7 +61,8 @@ static wxString CopperFinishType[] = // A list of available colors for solder mask and silkscreen // These names are used in .gbrjob file, so they are not fully free. // Use only what is allowed in .gbrjob files. -// for other colors (user defined), the defined value is the html color syntax. +// for other colors (user defined), the defined value is the html color syntax +// and RGB In gbrjob file. static FAB_LAYER_COLOR solderMaskColors[] = { { _HKI( NOT_SPECIFIED ), wxColor( 80, 80, 80 ) }, // Not specified, not in .gbrjob file @@ -71,7 +72,6 @@ static FAB_LAYER_COLOR solderMaskColors[] = { _HKI( "Black" ), wxColor( 20, 20, 20 ) }, // used in .gbrjob file { _HKI( "White" ), wxColor( 200, 200, 200 ) }, // used in .gbrjob file { _HKI( "Yellow" ), wxColor( 128, 128, 0 ) }, // used in .gbrjob file - { _HKI( "Purple" ), wxColor( 100, 0, 100 ) }, // used in .gbrjob file { _HKI( USER_DEFINED ), wxColor( 128, 128, 128 ) }, //free. the name is a dummy name here { "", wxColor( 0, 0, 0 ) } // Sentinel }; diff --git a/pcbnew/exporters/gerber_jobfile_writer.cpp b/pcbnew/exporters/gerber_jobfile_writer.cpp index 566094c2ff..448dca46e8 100644 --- a/pcbnew/exporters/gerber_jobfile_writer.cpp +++ b/pcbnew/exporters/gerber_jobfile_writer.cpp @@ -657,7 +657,18 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup() if( item->IsColorEditable() && uptodate ) { if( !item->m_Color.IsEmpty() && item->m_Color != NOT_SPECIFIED ) - addJSONObject( wxString::Format( "\"Color\": \"%s\",\n", item->m_Color ) ); + { + wxString colorName = item->m_Color; + + if( colorName.StartsWith( "#" ) ) // This is a user defined color. + { + // In job file a color can be given by its RGB values (0...255) + wxColor color( colorName ); + colorName.Printf( "R%dG%dB%d", color.Red(), color.Green(), color.Blue() ); + } + + addJSONObject( wxString::Format( "\"Color\": \"%s\",\n", colorName ) ); + } } if( item->IsThicknessEditable() && uptodate ) @@ -672,8 +683,8 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup() // Do not add constrains that create more expensive boards. if( brd_stackup.m_HasDielectricConstrains ) { - addJSONObject( wxString::Format( "\"DielectricConstant\": %.1f,\n", item->m_EpsilonR ) ); - addJSONObject( wxString::Format( "\"LossTangent\": %f,\n", item->m_LossTangent ) ); + addJSONObject( wxString::Format( "\"DielectricConstant\": %s,\n", item->FormatEpsilonR() ) ); + addJSONObject( wxString::Format( "\"LossTangent\": %s,\n", item->FormatLossTangent() ) ); } PCB_LAYER_ID next_copper_layer = (PCB_LAYER_ID) (last_copper_layer+1);