Commit f3e17179 authored by jean-pierre charras's avatar jean-pierre charras

Make Gerbview working with USE_PCBNEW_NANOMETRES option ON

parent 47a41f9c
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
/** /**
* Function scale * Function scaletoIU
* converts a distance given in floating point to our deci-mils * converts a distance given in floating point to our internal units
*/ */
extern int scale( double aCoord, bool isMetric ); // defined it rs274d.cpp extern int scaletoIU( double aCoord, bool isMetric ); // defined it rs274d_read_XY_and_IJ_coordiantes.cpp
/* Format Gerber: NOTES: /* Format Gerber: NOTES:
* Tools and D_CODES * Tools and D_CODES
...@@ -301,9 +301,9 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem ) ...@@ -301,9 +301,9 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
continue; continue;
GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem ); GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem );
wxPoint move_vector; wxPoint move_vector;
move_vector.x = scale( ii * GetLayerParams().m_StepForRepeat.x, move_vector.x = scaletoIU( ii * GetLayerParams().m_StepForRepeat.x,
GetLayerParams().m_StepForRepeatMetric ); GetLayerParams().m_StepForRepeatMetric );
move_vector.y = scale( jj * GetLayerParams().m_StepForRepeat.y, move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y,
GetLayerParams().m_StepForRepeatMetric ); GetLayerParams().m_StepForRepeatMetric );
dupItem->MoveXY( move_vector ); dupItem->MoveXY( move_vector );
m_Parent->GetBoard()->m_Drawings.Append( dupItem ); m_Parent->GetBoard()->m_Drawings.Append( dupItem );
......
...@@ -39,10 +39,10 @@ ...@@ -39,10 +39,10 @@
/** /**
* Function scale * Function scaletoIU
* converts a distance given in floating point to our deci-mils * converts a distance given in floating point to our internal units
*/ */
extern int scale( double aCoord, bool isMetric ); // defined it rs274d.cpp extern int scaletoIU( double aCoord, bool isMetric ); // defined it rs274d_read_XY_and_IJ_coordiantes.cpp
/** /**
* Function mapPt * Function mapPt
...@@ -52,7 +52,7 @@ extern int scale( double aCoord, bool isMetric ); // defined it rs274d ...@@ -52,7 +52,7 @@ extern int scale( double aCoord, bool isMetric ); // defined it rs274d
*/ */
static wxPoint mapPt( double x, double y, bool isMetric ) static wxPoint mapPt( double x, double y, bool isMetric )
{ {
wxPoint ret( scale( x, isMetric ), scale( y, isMetric ) ); wxPoint ret( scaletoIU( x, isMetric ), scaletoIU( y, isMetric ) );
return ret; return ret;
} }
...@@ -157,7 +157,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -157,7 +157,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
*/ */
curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric ); curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric );
curPos = aParent->GetABPosition( curPos ); curPos = aParent->GetABPosition( curPos );
int radius = scale( params[1].GetValue( tool ), m_GerbMetric ) / 2; int radius = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ) / 2;
if( !aFilledShape ) if( !aFilledShape )
GRCircle( aClipBox, aDC, curPos, radius, 0, aColor ); GRCircle( aClipBox, aDC, curPos, radius, 0, aColor );
else else
...@@ -300,9 +300,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -300,9 +300,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
* type(6), pos.x, pos.y, diam, penwidth, gap, circlecount, crosshair thickness, crosshaire len, rotation * type(6), pos.x, pos.y, diam, penwidth, gap, circlecount, crosshair thickness, crosshaire len, rotation
* type is not stored in parameters list, so the first parameter is pos.x * type is not stored in parameters list, so the first parameter is pos.x
*/ */
int outerDiam = scale( params[2].GetValue( tool ), m_GerbMetric ); int outerDiam = scaletoIU( params[2].GetValue( tool ), m_GerbMetric );
int penThickness = scale( params[3].GetValue( tool ), m_GerbMetric ); int penThickness = scaletoIU( params[3].GetValue( tool ), m_GerbMetric );
int gap = scale( params[4].GetValue( tool ), m_GerbMetric ); int gap = scaletoIU( params[4].GetValue( tool ), m_GerbMetric );
int numCircles = wxRound( params[5].GetValue( tool ) ); int numCircles = wxRound( params[5].GetValue( tool ) );
// Draw circles: // Draw circles:
...@@ -358,8 +358,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -358,8 +358,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
for( int i = 0; i<numPoints + 1; ++i ) for( int i = 0; i<numPoints + 1; ++i )
{ {
int jj = i * 2 + 2; int jj = i * 2 + 2;
pos.x = scale( params[jj].GetValue( tool ), m_GerbMetric ); pos.x = scaletoIU( params[jj].GetValue( tool ), m_GerbMetric );
pos.y = scale( params[jj + 1].GetValue( tool ), m_GerbMetric ); pos.y = scaletoIU( params[jj + 1].GetValue( tool ), m_GerbMetric );
polybuffer.push_back(pos); polybuffer.push_back(pos);
} }
// rotate polygon and move it to the actual position // rotate polygon and move it to the actual position
...@@ -438,7 +438,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, ...@@ -438,7 +438,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
case AMP_LINE2: case AMP_LINE2:
case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation) case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation)
{ {
int width = scale( params[1].GetValue( tool ), m_GerbMetric ); int width = scaletoIU( params[1].GetValue( tool ), m_GerbMetric );
wxPoint start = mapPt( params[2].GetValue( tool ), wxPoint start = mapPt( params[2].GetValue( tool ),
params[3].GetValue( tool ), m_GerbMetric ); params[3].GetValue( tool ), m_GerbMetric );
wxPoint end = mapPt( params[4].GetValue( tool ), wxPoint end = mapPt( params[4].GetValue( tool ),
...@@ -509,9 +509,9 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, ...@@ -509,9 +509,9 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
// Only 1/4 of the full shape is built, because the other 3 shapes will be draw from this first // Only 1/4 of the full shape is built, because the other 3 shapes will be draw from this first
// rotated by 90, 180 and 270 deg. // rotated by 90, 180 and 270 deg.
// params = center.x (unused here), center.y (unused here), outside diam, inside diam, crosshair thickness // params = center.x (unused here), center.y (unused here), outside diam, inside diam, crosshair thickness
int outerRadius = scale( params[2].GetValue( tool ), m_GerbMetric ) / 2; int outerRadius = scaletoIU( params[2].GetValue( tool ), m_GerbMetric ) / 2;
int innerRadius = scale( params[3].GetValue( tool ), m_GerbMetric ) / 2; int innerRadius = scaletoIU( params[3].GetValue( tool ), m_GerbMetric ) / 2;
int halfthickness = scale( params[4].GetValue( tool ), m_GerbMetric ) / 2; int halfthickness = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2;
int angle_start = wxRound( asin( int angle_start = wxRound( asin(
(double) halfthickness / innerRadius ) * 1800 / M_PI ); (double) halfthickness / innerRadius ) * 1800 / M_PI );
...@@ -560,8 +560,8 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, ...@@ -560,8 +560,8 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
case AMP_MOIRE: // A cross hair with n concentric circles. Only the cros is build as polygon case AMP_MOIRE: // A cross hair with n concentric circles. Only the cros is build as polygon
// because circles can be drawn easily // because circles can be drawn easily
{ {
int crossHairThickness = scale( params[6].GetValue( tool ), m_GerbMetric ); int crossHairThickness = scaletoIU( params[6].GetValue( tool ), m_GerbMetric );
int crossHairLength = scale( params[7].GetValue( tool ), m_GerbMetric ); int crossHairLength = scaletoIU( params[7].GetValue( tool ), m_GerbMetric );
// Create cross. First create 1/4 of the shape. // Create cross. First create 1/4 of the shape.
// Others point are the same, totated by 90, 180 and 270 deg // Others point are the same, totated by 90, 180 and 270 deg
...@@ -594,7 +594,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, ...@@ -594,7 +594,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
case AMP_POLYGON: // Creates a regular polygon case AMP_POLYGON: // Creates a regular polygon
{ {
int vertexcount = wxRound( params[1].GetValue( tool ) ); int vertexcount = wxRound( params[1].GetValue( tool ) );
int radius = scale( params[4].GetValue( tool ), m_GerbMetric ) / 2; int radius = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2;
// rs274x said: vertex count = 3 ... 10, and the first corner is on the X axis // rs274x said: vertex count = 3 ... 10, and the first corner is on the X axis
if( vertexcount < 3 ) if( vertexcount < 3 )
vertexcount = 3; vertexcount = 3;
...@@ -635,12 +635,12 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) ...@@ -635,12 +635,12 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
{ {
case AMP_CIRCLE: case AMP_CIRCLE:
// params = exposure, diameter, pos.x, pos.y // params = exposure, diameter, pos.x, pos.y
dim = scale( params[1].GetValue( tool ), m_GerbMetric ); // Diameter dim = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ); // Diameter
break; break;
case AMP_LINE2: case AMP_LINE2:
case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation) case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation)
dim = scale( params[1].GetValue( tool ), m_GerbMetric ); // linne width dim = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ); // linne width
break; break;
case AMP_LINE_CENTER: case AMP_LINE_CENTER:
...@@ -662,12 +662,12 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) ...@@ -662,12 +662,12 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
// Only 1/4 of the full shape is built, because the other 3 shapes will be draw from this first // Only 1/4 of the full shape is built, because the other 3 shapes will be draw from this first
// rotated by 90, 180 and 270 deg. // rotated by 90, 180 and 270 deg.
// params = center.x (unused here), center.y (unused here), outside diam, inside diam, crosshair thickness // params = center.x (unused here), center.y (unused here), outside diam, inside diam, crosshair thickness
dim = scale( params[2].GetValue( tool ), m_GerbMetric ) / 2; // Outer diam dim = scaletoIU( params[2].GetValue( tool ), m_GerbMetric ) / 2; // Outer diam
} }
break; break;
case AMP_MOIRE: // A cross hair with n concentric circles. case AMP_MOIRE: // A cross hair with n concentric circles.
dim = scale( params[7].GetValue( tool ), m_GerbMetric ); // = cross hair len dim = scaletoIU( params[7].GetValue( tool ), m_GerbMetric ); // = cross hair len
break; break;
case AMP_OUTLINE: // a free polygon : case AMP_OUTLINE: // a free polygon :
...@@ -681,8 +681,8 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) ...@@ -681,8 +681,8 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
for( int i = 0; i<numPoints + 1; ++i ) for( int i = 0; i<numPoints + 1; ++i )
{ {
int jj = i * 2 + 2; int jj = i * 2 + 2;
pos.x = scale( params[jj].GetValue( tool ), m_GerbMetric ); pos.x = scaletoIU( params[jj].GetValue( tool ), m_GerbMetric );
pos.y = scale( params[jj + 1].GetValue( tool ), m_GerbMetric ); pos.y = scaletoIU( params[jj + 1].GetValue( tool ), m_GerbMetric );
if( i == 0 ) if( i == 0 )
pos_min = pos_max = pos; pos_min = pos_max = pos;
else else
...@@ -708,7 +708,7 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) ...@@ -708,7 +708,7 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
break; break;
case AMP_POLYGON: // Regular polygon case AMP_POLYGON: // Regular polygon
dim = scale( params[4].GetValue( tool ), m_GerbMetric ) / 2; // Radius dim = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2; // Radius
break; break;
case AMP_COMMENT: case AMP_COMMENT:
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <macros.h> #include <macros.h>
#include <trigo.h> #include <trigo.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <base_units.h>
#include <gerbview.h> #include <gerbview.h>
#include <class_gerber_draw_item.h> #include <class_gerber_draw_item.h>
...@@ -155,7 +156,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) ...@@ -155,7 +156,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName ) int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName )
{ {
int current_Dcode, ii, dcode_scale; int current_Dcode, ii;
char* ptcar; char* ptcar;
int dimH, dimV, drill, dummy; int dimH, dimV, drill, dummy;
float fdimH, fdimV, fdrill; float fdimH, fdimV, fdrill;
...@@ -174,8 +175,7 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName ...@@ -174,8 +175,7 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
/* Updating gerber scale: */ /* Updating gerber scale: */
dcode_scale = 10; /* By uniting dCode = mil, internal unit = 0.1 mil double dcode_scale = MILS_TO_IU_SCALAR; // By uniting dCode = mil, internal unit = MILS_TO_IU_SCALAR
* -> 1 unite dcode = 10 unit PCB */
current_Dcode = 0; current_Dcode = 0;
if( D_Code_FullFileName.IsEmpty() ) if( D_Code_FullFileName.IsEmpty() )
......
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project> <wxFormBuilder_Project>
<FileVersion major="1" minor="10" /> <FileVersion major="1" minor="11" />
<object class="Project" expanded="1"> <object class="Project" expanded="1">
<property name="class_decoration"></property> <property name="class_decoration"></property>
<property name="code_generation">C++</property> <property name="code_generation">C++</property>
<property name="disconnect_events">1</property> <property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property> <property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property> <property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property> <property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property> <property name="encoding">UTF-8</property>
...@@ -19,66 +20,33 @@ ...@@ -19,66 +20,33 @@
<property name="path">.</property> <property name="path">.</property>
<property name="precompiled_header"></property> <property name="precompiled_header"></property>
<property name="relative_path">1</property> <property name="relative_path">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property> <property name="skip_python_events">1</property>
<property name="use_enum">0</property> <property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_managed">0</property> <property name="aui_managed">0</property>
<property name="aui_name"></property> <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center"></property> <property name="center"></property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="event_handler">impl_virtual</property> <property name="event_handler">impl_virtual</property>
<property name="extra_style"></property> <property name="extra_style"></property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="layer"></property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">DIALOG_PAGE_SHOW_PAGE_BORDERS_BASE</property> <property name="name">DIALOG_PAGE_SHOW_PAGE_BORDERS_BASE</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size">263,254</property> <property name="size">263,254</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="title">Page Borders</property> <property name="title">Page Borders</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
...@@ -150,7 +118,10 @@ ...@@ -150,7 +118,10 @@
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
<property name="TopDockable">1</property> <property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property> <property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property> <property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property> <property name="caption"></property>
...@@ -172,7 +143,6 @@ ...@@ -172,7 +143,6 @@
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Show Page Limits:</property> <property name="label">Show Page Limits:</property>
<property name="layer"></property>
<property name="majorDimension">1</property> <property name="majorDimension">1</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
...@@ -188,9 +158,7 @@ ...@@ -188,9 +158,7 @@
<property name="permission">protected</property> <property name="permission">protected</property>
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="row"></property>
<property name="selection">0</property> <property name="selection">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
...@@ -244,7 +212,10 @@ ...@@ -244,7 +212,10 @@
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
<property name="TopDockable">1</property> <property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property> <property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property> <property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property> <property name="caption"></property>
...@@ -264,7 +235,6 @@ ...@@ -264,7 +235,6 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="layer"></property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -279,19 +249,13 @@ ...@@ -279,19 +249,13 @@
<property name="permission">protected</property> <property name="permission">protected</property>
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property> <property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
......
...@@ -25,62 +25,28 @@ ...@@ -25,62 +25,28 @@
<property name="use_enum">0</property> <property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_managed">0</property> <property name="aui_managed">0</property>
<property name="aui_name"></property> <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center"></property> <property name="center"></property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="event_handler">impl_virtual</property> <property name="event_handler">impl_virtual</property>
<property name="extra_style"></property> <property name="extra_style"></property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">DIALOG_DISPLAY_OPTIONS_BASE</property> <property name="name">DIALOG_DISPLAY_OPTIONS_BASE</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size">446,330</property> <property name="size">446,330</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="title">Gerbview Options</property> <property name="title">Gerbview Options</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
...@@ -1140,10 +1106,6 @@ ...@@ -1140,10 +1106,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#include <gerbview.h> #include <gerbview.h>
#include <trigo.h> #include <trigo.h>
#include <macros.h> #include <macros.h>
#include <base_units.h>
#include <class_gerber_draw_item.h> #include <class_gerber_draw_item.h>
#include <class_GERBER.h> #include <class_GERBER.h>
#include <class_excellon.h> #include <class_excellon.h>
...@@ -430,7 +431,11 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) ...@@ -430,7 +431,11 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
dcode = GetDCODE( iprm + FIRST_DCODE ); // Remember: dcodes are >= FIRST_DCODE dcode = GetDCODE( iprm + FIRST_DCODE ); // Remember: dcodes are >= FIRST_DCODE
if( dcode == NULL ) if( dcode == NULL )
break; break;
double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT; // conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000;
if( m_GerbMetric )
conv_scale /= 25.4;
dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale ); dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale );
dcode->m_Shape = APT_CIRCLE; dcode->m_Shape = APT_CIRCLE;
break; break;
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
#include <class_gerber_draw_item.h> #include <class_gerber_draw_item.h>
#include <select_layers_to_pcb.h> #include <select_layers_to_pcb.h>
#include <build_version.h> // BOARD_FILE_VERSION #include <build_version.h>
#include <wildcards_and_files_ext.h>
/* A helper class to export a Gerber set of files to Pcbnew /* A helper class to export a Gerber set of files to Pcbnew
...@@ -88,29 +89,24 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) ...@@ -88,29 +89,24 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
return; return;
} }
wxString fileName, msg; wxString fileName;
wxString path = wxGetCwd();;
wxString PcbExt( wxT( ".brd" ) );
wxFileDialog filedlg( this, _( "Board file name:" ),
msg = wxT( "*" ) + PcbExt; path, fileName, LegacyPcbFileWildcard,
fileName = EDA_FileSelector( _( "Board file name:" ), wxFD_OPEN );
wxEmptyString,
wxEmptyString, if( filedlg.ShowModal() == wxID_CANCEL )
PcbExt,
msg,
this,
wxFD_SAVE,
false
);
if( fileName == wxEmptyString )
return; return;
fileName = filedlg.GetPath();
/* Install a dialog frame to choose the mapping /* Install a dialog frame to choose the mapping
* between gerber layers and Pcbnew layers * between gerber layers and Pcbnew layers
*/ */
LAYERS_MAP_DIALOG* dlg = new LAYERS_MAP_DIALOG( this ); LAYERS_MAP_DIALOG* layerdlg = new LAYERS_MAP_DIALOG( this );
int ok = dlg->ShowModal(); int ok = layerdlg->ShowModal();
dlg->Destroy(); layerdlg->Destroy();
if( ok != wxID_OK ) if( ok != wxID_OK )
return; return;
...@@ -123,7 +119,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) ...@@ -123,7 +119,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName ); GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName );
gbr_exporter.ExportPcb( dlg->GetLayersLookUpTable() ); gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable() );
} }
...@@ -184,8 +180,18 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable ) ...@@ -184,8 +180,18 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
try try
{ {
wxFileName pcbFileName( m_file_name );
PROPERTIES props;
wxString header = wxString::Format(
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by GerbView%s\n\n" ),
LEGACY_BOARD_FILE_VERSION, DateAndTime().GetData(),
GetBuildVersion().GetData() );
props["header"] = header;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
pi->Save( m_file_name, m_pcb ); pi->Save( m_file_name, m_pcb, &props );
} }
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
......
...@@ -3,6 +3,29 @@ ...@@ -3,6 +3,29 @@
* @brief GERBVIEW main file. * @brief GERBVIEW main file.
*/ */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 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
*/
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <build_version.h> #include <build_version.h>
#include <macros.h> #include <macros.h>
#include <base_units.h>
#include <class_layer_box_selector.h> #include <class_layer_box_selector.h>
#include <gerbview.h> #include <gerbview.h>
...@@ -407,7 +408,7 @@ void GERBVIEW_FRAME::Liste_D_Codes() ...@@ -407,7 +408,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
D_CODE* pt_D_code; D_CODE* pt_D_code;
wxString Line; wxString Line;
wxArrayString list; wxArrayString list;
int scale = 10000; double scale = MILS_TO_IU_SCALAR * 1000;
int curr_layer = getActiveLayer(); int curr_layer = getActiveLayer();
for( int layer = 0; layer < 32; layer++ ) for( int layer = 0; layer < 32; layer++ )
......
...@@ -8,11 +8,50 @@ ...@@ -8,11 +8,50 @@
#include <gerbview.h> #include <gerbview.h>
#include <macros.h> #include <macros.h>
#include <class_GERBER.h> #include <class_GERBER.h>
#include <base_units.h>
/* These routines read the text string point from Text. /* These routines read the text string point from Text.
* On exit, Text points the beginning of the sequence unread * On exit, Text points the beginning of the sequence unread
*/ */
// convertion scale from gerber file units to Gerbview internal units
// depending on the gerber file format
// this scale list assumes gerber units are imperial.
// for metric gerber units, the imperial to metric conversion is made in read functions
static double scale_list[10] =
{
1000.0 * MILS_TO_IU_SCALAR,
100.0 * MILS_TO_IU_SCALAR,
10.0 * MILS_TO_IU_SCALAR,
1.0 * MILS_TO_IU_SCALAR,
0.1 * MILS_TO_IU_SCALAR,
0.01 * MILS_TO_IU_SCALAR,
0.001 * MILS_TO_IU_SCALAR,
0.0001 * MILS_TO_IU_SCALAR,
0.00001 * MILS_TO_IU_SCALAR,
0.000001 * MILS_TO_IU_SCALAR
};
/**
* Function scale
* converts a distance given in floating point to our internal units
* (deci-mils or nano units)
*/
int scaletoIU( double aCoord, bool isMetric )
{
int ret;
if( isMetric )
ret = wxRound( aCoord * MILS_TO_IU_SCALAR / 0.00254 );
else
ret = wxRound( aCoord * MILS_TO_IU_SCALAR );
return ret;
}
wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text ) wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
{ {
wxPoint pos; wxPoint pos;
...@@ -53,10 +92,11 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text ) ...@@ -53,10 +92,11 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
*text = 0; *text = 0;
if( is_float ) if( is_float )
{ {
if( m_GerbMetric ) // When X or Y values are float numbers, they are given in mm or inches
current_coord = wxRound( atof( line ) / 0.00254 ); if( m_GerbMetric ) // units are mm
else current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
current_coord = wxRound( atof( line ) * PCB_INTERNAL_UNIT ); else // units are inches
current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
} }
else else
{ {
...@@ -74,14 +114,7 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text ) ...@@ -74,14 +114,7 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
*text = 0; *text = 0;
} }
current_coord = atoi( line ); current_coord = atoi( line );
double real_scale = 1.0; double real_scale = scale_list[fmt_scale];
double scale_list[10] =
{
10000.0, 1000.0, 100.0, 10.0,
1,
0.1, 0.01, 0.001, 0.0001,0.00001
};
real_scale = scale_list[fmt_scale];
if( m_GerbMetric ) if( m_GerbMetric )
real_scale = real_scale / 25.4; real_scale = real_scale / 25.4;
...@@ -150,10 +183,11 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text ) ...@@ -150,10 +183,11 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
*text = 0; *text = 0;
if( is_float ) if( is_float )
{ {
if( m_GerbMetric ) // When X or Y values are float numbers, they are given in mm or inches
current_coord = wxRound( atof( line ) / 0.00254 ); if( m_GerbMetric ) // units are mm
else current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
current_coord = wxRound( atof( line ) * PCB_INTERNAL_UNIT ); else // units are inches
current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
} }
else else
{ {
...@@ -172,18 +206,11 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text ) ...@@ -172,18 +206,11 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
*text = 0; *text = 0;
} }
current_coord = atoi( line ); current_coord = atoi( line );
double real_scale = 1.0;
if( fmt_scale < 0 || fmt_scale > 9 ) if( fmt_scale < 0 || fmt_scale > 9 )
fmt_scale = 4; // select scale 1.0 fmt_scale = 4; // select scale 1.0
double scale_list[10] = double real_scale = scale_list[fmt_scale];
{
10000.0, 1000.0, 100.0, 10.0,
1,
0.1, 0.01, 0.001, 0.0001,0.00001
};
real_scale = scale_list[fmt_scale];
if( m_GerbMetric ) if( m_GerbMetric )
real_scale = real_scale / 25.4; real_scale = real_scale / 25.4;
current_coord = wxRound( current_coord * real_scale ); current_coord = wxRound( current_coord * real_scale );
......
...@@ -543,23 +543,6 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command ) ...@@ -543,23 +543,6 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
} }
/**
* Function scale
* converts a distance given in floating point to our deci-mils
*/
int scale( double aCoord, bool isMetric )
{
int ret;
if( isMetric )
ret = wxRound( aCoord / 0.00254 );
else
ret = wxRound( aCoord * PCB_INTERNAL_UNIT );
return ret;
}
bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
{ {
wxSize size( 15, 15 ); wxSize size( 15, 15 );
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <macros.h> #include <macros.h>
#include <base_units.h>
#include <gerbview.h> #include <gerbview.h>
#include <class_GERBER.h> #include <class_GERBER.h>
...@@ -157,7 +158,11 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -157,7 +158,11 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
char line[GERBER_BUFZ]; char line[GERBER_BUFZ];
wxString msg; wxString msg;
double fcoord; double fcoord;
double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT;
// conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000;
if( m_GerbMetric )
conv_scale /= 25.4;
// D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); ) // D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment