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

Define MM_TO_IU_SCALING_FACTOR (scaling factor from mm to internal units) only in convert_to_biu.h

Other scaling factors (MILS_TO_IU_SCALING_FACTOR and DECIMILS_TO_IU_SCALING_FACTOR)
also defined only in convert_to_biu.h.
Allows different scaling value for Gerbview.
Needs more tests.
parent e3b6385c
...@@ -83,7 +83,6 @@ add_library(common STATIC ${COMMON_SRCS}) ...@@ -83,7 +83,6 @@ add_library(common STATIC ${COMMON_SRCS})
set(PCB_COMMON_SRCS set(PCB_COMMON_SRCS
base_screen.cpp base_screen.cpp
base_units.cpp
eda_text.cpp eda_text.cpp
class_page_info.cpp class_page_info.cpp
pcbcommon.cpp pcbcommon.cpp
...@@ -120,7 +119,6 @@ set(PCB_COMMON_SRCS ...@@ -120,7 +119,6 @@ set(PCB_COMMON_SRCS
../pcbnew/legacy_plugin.cpp ../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp ../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.cpp pcb_plot_params_keywords.cpp
dialogs/dialog_page_settings.cpp
) )
......
...@@ -40,25 +40,13 @@ ...@@ -40,25 +40,13 @@
#include <base_units.h> #include <base_units.h>
#if defined( PCBNEW ) #if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA )
#if defined( USE_PCBNEW_NANOMETRES ) #define IU_TO_MM( x ) ( x / MM_TO_IU_SCALING_FACTOR )
#define IU_TO_MM( x ) ( x * 1e-6 ) #define IU_TO_IN( x ) ( x / MILS_TO_IU_SCALING_FACTOR / 1000 )
#define IU_TO_IN( x ) ( ( x * 1e-6 ) / 25.4 ) #define MM_TO_IU( x ) ( x * MM_TO_IU_SCALING_FACTOR )
#define MM_TO_IU( x ) ( x * 1e6 ) #define IN_TO_IU( x ) ( x * MILS_TO_IU_SCALING_FACTOR * 1000 )
#define IN_TO_IU( x ) ( ( x * 25.4 ) * 1e6 )
#else
#define IU_TO_MM( x ) ( ( x * 0.0001 ) * 25.4 )
#define IU_TO_IN( x ) ( x * 0.0001 )
#define MM_TO_IU( x ) ( ( x / 25.4 ) * 10000.0 )
#define IN_TO_IU( x ) ( x * 10000.0 )
#endif
#elif defined( EESCHEMA )
#define IU_TO_MM( x ) ( ( x * 0.001 ) * 25.4 )
#define IU_TO_IN( x ) ( x * 0.001 )
#define MM_TO_IU( x ) ( ( x / 25.4 ) * 1000.0 )
#define IN_TO_IU( x ) ( x * 1000.0 )
#else #else
#error "Cannot resolve internal units due to no definition of EESCHEMA or PCBNEW." #error "Cannot resolve internal units due to no definition of EESCHEMA, CVPCB or PCBNEW."
#endif #endif
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <class_title_block.h> #include <class_title_block.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <class_base_screen.h> #include <class_base_screen.h>
#include <base_units.h> // MILS_TO_IU_SCALAR
#include <wx/valgen.h> #include <wx/valgen.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
...@@ -617,7 +616,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() ...@@ -617,7 +616,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
m_Parent->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), m_Parent->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ),
wxSize( INT_MAX / 2, INT_MAX / 2 ) ) ); wxSize( INT_MAX / 2, INT_MAX / 2 ) ) );
// Calculate layout preview scale. // Calculate layout preview scale.
int appScale = MILS_TO_IU_SCALAR; int appScale = m_Screen->MilsToIuScalar();
double scaleW = (double) lyWidth / clamped_layout_size.x / appScale; double scaleW = (double) lyWidth / clamped_layout_size.x / appScale;
double scaleH = (double) lyHeight / clamped_layout_size.y / appScale; double scaleH = (double) lyHeight / clamped_layout_size.y / appScale;
......
...@@ -37,11 +37,7 @@ ...@@ -37,11 +37,7 @@
// Conversion to application internal units defined at build time. // Conversion to application internal units defined at build time.
#if defined( PCBNEW ) #if defined( PCBNEW )
#include <class_board_item.h> #include <class_board_item.h>
#if defined( USE_PCBNEW_NANOMETRES ) #define MILS_TO_IU( x ) ( x * MILS_TO_IU_SCALING_FACTOR );
#define MILS_TO_IU( x ) ( x * 25400 );
#else
#define MILS_TO_IU( x ) ( x * 10 )
#endif
#elif defined( EESCHEMA ) #elif defined( EESCHEMA )
#include <sch_item_struct.h> #include <sch_item_struct.h>
#define MILS_TO_IU( x ) ( x ) #define MILS_TO_IU( x ) ( x )
......
...@@ -26,6 +26,7 @@ set(CVPCB_DIALOGS ...@@ -26,6 +26,7 @@ set(CVPCB_DIALOGS
) )
set(CVPCB_SRCS set(CVPCB_SRCS
../common/base_units.cpp
../pcbnew/netlist_reader_common.cpp ../pcbnew/netlist_reader_common.cpp
../pcbnew/netlist_reader_kicad.cpp ../pcbnew/netlist_reader_kicad.cpp
../pcbnew/netlist_reader_firstformat.cpp ../pcbnew/netlist_reader_firstformat.cpp
......
...@@ -237,7 +237,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, ...@@ -237,7 +237,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
sheetSize.y/2) ); sheetSize.y/2) );
if( aPrint_Sheet_Ref ) if( aPrint_Sheet_Ref )
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALING_FACTOR );
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
panel->SetClipBox( tmp ); panel->SetClipBox( tmp );
......
...@@ -378,7 +378,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) ...@@ -378,7 +378,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE ); aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference ) if( printReference )
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALING_FACTOR );
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
aScreen->m_IsPrinting = false; aScreen->m_IsPrinting = false;
......
...@@ -71,7 +71,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -71,7 +71,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE ); GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALING_FACTOR );
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
if( IsShown() ) if( IsShown() )
......
...@@ -863,7 +863,7 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) ...@@ -863,7 +863,7 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData ) void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
{ {
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALING_FACTOR );
} }
......
...@@ -33,6 +33,7 @@ set(GERBVIEW_SRCS ...@@ -33,6 +33,7 @@ set(GERBVIEW_SRCS
class_am_param.cpp class_am_param.cpp
class_aperture_macro.cpp class_aperture_macro.cpp
class_DCodeSelectionbox.cpp class_DCodeSelectionbox.cpp
class_gbr_screen.cpp
class_GERBER.cpp class_GERBER.cpp
class_gerber_draw_item.cpp class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp class_gerbview_layer_widget.cpp
...@@ -63,9 +64,10 @@ set(GERBVIEW_SRCS ...@@ -63,9 +64,10 @@ set(GERBVIEW_SRCS
) )
### ###
# We need some extra sources from pcbnew # We need some extra sources from common and pcbnew
### ###
set(GERBVIEW_EXTRA_SRCS set(GERBVIEW_EXTRA_SRCS
../common/base_units.cpp
../pcbnew/layer_widget.cpp ../pcbnew/layer_widget.cpp
../pcbnew/printout_controler.cpp ../pcbnew/printout_controler.cpp
../pcbnew/class_drc_item.cpp ../pcbnew/class_drc_item.cpp
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
...@@ -175,7 +175,8 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName ...@@ -175,7 +175,8 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
/* Updating gerber scale: */ /* Updating gerber scale: */
double dcode_scale = MILS_TO_IU_SCALAR; // By uniting dCode = mil, internal unit = MILS_TO_IU_SCALAR double dcode_scale = MILS_TO_IU_SCALING_FACTOR; // By uniting dCode = mil,
// internal unit = MILS_TO_IU_SCALING_FACTOR
current_Dcode = 0; current_Dcode = 0;
if( D_Code_FullFileName.IsEmpty() ) if( D_Code_FullFileName.IsEmpty() )
......
...@@ -107,7 +107,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -107,7 +107,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsElementVisible( DCODES_VISIBLE ) ) if( IsElementVisible( DCODES_VISIBLE ) )
DrawItemsDCodeID( DC, GR_COPY ); DrawItemsDCodeID( DC, GR_COPY );
TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR ); TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALING_FACTOR );
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......
...@@ -432,7 +432,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) ...@@ -432,7 +432,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
if( dcode == NULL ) if( dcode == NULL )
break; break;
// conv_scale = scaling factor from inch to Internal Unit // conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000; double conv_scale = MILS_TO_IU_SCALING_FACTOR * 1000;
if( m_GerbMetric ) if( m_GerbMetric )
conv_scale /= 25.4; conv_scale /= 25.4;
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h> #include <class_DCodeSelectionbox.h>
#include <class_gerbview_layer_widget.h> #include <class_gerbview_layer_widget.h>
#include <class_gbr_screen.h>
...@@ -93,7 +94,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, ...@@ -93,7 +94,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
PAGE_INFO pageInfo( wxT( "GERBER" ) ); PAGE_INFO pageInfo( wxT( "GERBER" ) );
GetBoard()->SetPageSettings( pageInfo ); GetBoard()->SetPageSettings( pageInfo );
SetScreen( new PCB_SCREEN( pageInfo.GetSizeIU() ) ); SetScreen( new GBR_SCREEN( pageInfo.GetSizeIU() ) );
// Create the PCB_LAYER_WIDGET *after* SetBoard(): // Create the PCB_LAYER_WIDGET *after* SetBoard():
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
...@@ -179,7 +180,7 @@ double GERBVIEW_FRAME::BestZoom() ...@@ -179,7 +180,7 @@ double GERBVIEW_FRAME::BestZoom()
{ {
// gives a minimal value to zoom, if no item in list // gives a minimal value to zoom, if no item in list
if( GetBoard()->m_Drawings == NULL ) if( GetBoard()->m_Drawings == NULL )
return 160.0; return ZOOM_FACTOR( 160.0 );
EDA_RECT bbox; EDA_RECT bbox;
BOARD_ITEM* item = GetBoard()->m_Drawings; BOARD_ITEM* item = GetBoard()->m_Drawings;
...@@ -210,7 +211,8 @@ void GERBVIEW_FRAME::LoadSettings() ...@@ -210,7 +211,8 @@ void GERBVIEW_FRAME::LoadSettings()
if( config == NULL ) if( config == NULL )
return; return;
PCB_BASE_FRAME::LoadSettings(); // PCB_BASE_FRAME::LoadSettings();
EDA_DRAW_FRAME::LoadSettings();
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() ); wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
...@@ -255,7 +257,8 @@ void GERBVIEW_FRAME::SaveSettings() ...@@ -255,7 +257,8 @@ void GERBVIEW_FRAME::SaveSettings()
if( config == NULL ) if( config == NULL )
return; return;
PCB_BASE_FRAME::SaveSettings(); // PCB_BASE_FRAME::SaveSettings();
EDA_DRAW_FRAME::SaveSettings();
wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() ); wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
...@@ -408,7 +411,7 @@ void GERBVIEW_FRAME::Liste_D_Codes() ...@@ -408,7 +411,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;
double scale = MILS_TO_IU_SCALAR * 1000; double scale = MILS_TO_IU_SCALING_FACTOR * 1000;
int curr_layer = getActiveLayer(); int curr_layer = getActiveLayer();
for( int layer = 0; layer < 32; layer++ ) for( int layer = 0; layer < 32; layer++ )
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <wxBasePcbFrame.h> #include <wxBasePcbFrame.h>
#include <../pcbnew/class_board.h> #include <../pcbnew/class_board.h>
#include <class_gbr_screen.h>
class DCODE_SELECTION_BOX; class DCODE_SELECTION_BOX;
...@@ -53,7 +54,6 @@ class GERBER_DRAW_ITEM; ...@@ -53,7 +54,6 @@ class GERBER_DRAW_ITEM;
class GERBVIEW_FRAME : public PCB_BASE_FRAME class GERBVIEW_FRAME : public PCB_BASE_FRAME
{ {
friend class PCB_LAYER_WIDGET;
protected: protected:
GERBER_LAYER_WIDGET* m_LayersManager; GERBER_LAYER_WIDGET* m_LayersManager;
...@@ -84,7 +84,7 @@ private: ...@@ -84,7 +84,7 @@ private:
bool m_show_layer_manager_tools; bool m_show_layer_manager_tools;
// An array sting to store warning messages when reaging a gerber file. // An array string to store warning messages when reading a gerber file.
wxArrayString m_Messages; wxArrayString m_Messages;
public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
...@@ -226,7 +226,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, ...@@ -226,7 +226,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/ */
void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true ) void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true )
{ {
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer; ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
if( doLayerWidgetUpdate ) if( doLayerWidgetUpdate )
syncLayerWidget(); syncLayerWidget();
...@@ -239,7 +239,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, ...@@ -239,7 +239,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/ */
int getActiveLayer() int getActiveLayer()
{ {
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
} }
...@@ -440,8 +440,6 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, ...@@ -440,8 +440,6 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/ */
void Block_Duplicate( wxDC* DC ); void Block_Duplicate( wxDC* DC );
void ToPostProcess( wxCommandEvent& event );
/** /**
* Function ToPlotter * Function ToPlotter
* Open a dialog frame to create plot and drill files * Open a dialog frame to create plot and drill files
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
*/ */
void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{ {
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg; wxString msg;
if( GetToolId() == ID_NO_TOOL_SELECTED ) if( GetToolId() == ID_NO_TOOL_SELECTED )
...@@ -36,7 +36,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -36,7 +36,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
else else
{ {
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE ); DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
if( DrawStruct == NULL ) if( DrawStruct == NULL )
{ {
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ]; GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ];
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{ {
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg; wxString msg;
bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle(); bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
bool busy = DrawStruct && DrawStruct->GetFlags(); bool busy = DrawStruct && DrawStruct->GetFlags();
...@@ -71,7 +71,7 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -71,7 +71,7 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true; return true;
if( DrawStruct ) if( DrawStruct )
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
return true; return true;
} }
...@@ -36,28 +36,20 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -36,28 +36,20 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH: case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
if( state ) if( state )
{ DisplayOpt.DisplayPadFill = false;
DisplayOpt.DisplayPadFill = m_DisplayPadFill = false;
}
else else
{ DisplayOpt.DisplayPadFill = true;
DisplayOpt.DisplayPadFill = m_DisplayPadFill = true; m_DisplayPadFill = DisplayOpt.DisplayPadFill;
}
m_canvas->Refresh( true ); m_canvas->Refresh( true );
break; break;
case ID_TB_OPTIONS_SHOW_LINES_SKETCH: case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
if(state ) if(state )
{
m_DisplayPcbTrackFill = false;
DisplayOpt.DisplayPcbTrackFill = false; DisplayOpt.DisplayPcbTrackFill = false;
}
else else
{
m_DisplayPcbTrackFill = true;
DisplayOpt.DisplayPcbTrackFill = true; DisplayOpt.DisplayPcbTrackFill = true;
} m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_canvas->Refresh( true ); m_canvas->Refresh( true );
break; break;
......
...@@ -21,16 +21,16 @@ ...@@ -21,16 +21,16 @@
// for metric gerber units, the imperial to metric conversion is made in read functions // for metric gerber units, the imperial to metric conversion is made in read functions
static double scale_list[10] = static double scale_list[10] =
{ {
1000.0 * MILS_TO_IU_SCALAR, 1000.0 * MILS_TO_IU_SCALING_FACTOR,
100.0 * MILS_TO_IU_SCALAR, 100.0 * MILS_TO_IU_SCALING_FACTOR,
10.0 * MILS_TO_IU_SCALAR, 10.0 * MILS_TO_IU_SCALING_FACTOR,
1.0 * MILS_TO_IU_SCALAR, 1.0 * MILS_TO_IU_SCALING_FACTOR,
0.1 * MILS_TO_IU_SCALAR, 0.1 * MILS_TO_IU_SCALING_FACTOR,
0.01 * MILS_TO_IU_SCALAR, 0.01 * MILS_TO_IU_SCALING_FACTOR,
0.001 * MILS_TO_IU_SCALAR, 0.001 * MILS_TO_IU_SCALING_FACTOR,
0.0001 * MILS_TO_IU_SCALAR, 0.0001 * MILS_TO_IU_SCALING_FACTOR,
0.00001 * MILS_TO_IU_SCALAR, 0.00001 * MILS_TO_IU_SCALING_FACTOR,
0.000001 * MILS_TO_IU_SCALAR 0.000001 * MILS_TO_IU_SCALING_FACTOR
}; };
...@@ -44,9 +44,9 @@ int scaletoIU( double aCoord, bool isMetric ) ...@@ -44,9 +44,9 @@ int scaletoIU( double aCoord, bool isMetric )
int ret; int ret;
if( isMetric ) if( isMetric )
ret = KiROUND( aCoord * MILS_TO_IU_SCALAR / 0.00254 ); ret = KiROUND( aCoord * MILS_TO_IU_SCALING_FACTOR / 0.00254 );
else else
ret = KiROUND( aCoord * MILS_TO_IU_SCALAR ); ret = KiROUND( aCoord * MILS_TO_IU_SCALING_FACTOR );
return ret; return ret;
} }
...@@ -94,9 +94,9 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text ) ...@@ -94,9 +94,9 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
{ {
// When X or Y values are float numbers, they are given in mm or inches // When X or Y values are float numbers, they are given in mm or inches
if( m_GerbMetric ) // units are mm if( m_GerbMetric ) // units are mm
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 ); current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALING_FACTOR / 0.0254 );
else // units are inches else // units are inches
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 ); current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALING_FACTOR * 1000 );
} }
else else
{ {
...@@ -185,9 +185,9 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text ) ...@@ -185,9 +185,9 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
{ {
// When X or Y values are float numbers, they are given in mm or inches // When X or Y values are float numbers, they are given in mm or inches
if( m_GerbMetric ) // units are mm if( m_GerbMetric ) // units are mm
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 ); current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALING_FACTOR / 0.0254 );
else // units are inches else // units are inches
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 ); current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALING_FACTOR * 1000 );
} }
else else
{ {
......
...@@ -160,7 +160,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -160,7 +160,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
double fcoord; double fcoord;
// conv_scale = scaling factor from inch to Internal Unit // conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000; double conv_scale = MILS_TO_IU_SCALING_FACTOR * 1000;
if( m_GerbMetric ) if( m_GerbMetric )
conv_scale /= 25.4; conv_scale /= 25.4;
...@@ -294,7 +294,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -294,7 +294,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
m_GerbMetric = false; m_GerbMetric = false;
else if( code == MILLIMETER ) else if( code == MILLIMETER )
m_GerbMetric = true; m_GerbMetric = true;
conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT; conv_scale = m_GerbMetric ? MILS_TO_IU_SCALING_FACTOR / 25.4 : MILS_TO_IU_SCALING_FACTOR;
break; break;
case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset
...@@ -579,8 +579,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -579,8 +579,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
text += 2; // skip "C," for example text += 2; // skip "C," for example
dcode->m_Size.x = dcode->m_Size.y = dcode->m_Size.x = KiROUND( ReadDouble( text ) * conv_scale );
KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_Size.y = dcode->m_Size.x;
switch( stdAperture ) // Aperture desceiption has optional parameters. Read them switch( stdAperture ) // Aperture desceiption has optional parameters. Read them
{ {
...@@ -631,8 +631,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -631,8 +631,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( *text == 'X' ) if( *text == 'X' )
{ {
text++; text++;
dcode->m_Drill.x = dcode->m_Drill.y = dcode->m_Drill.x = KiROUND( ReadDouble( text ) * conv_scale );
KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_Drill.y = dcode->m_Drill.x;
dcode->m_DrillShape = APT_DEF_ROUND_HOLE; dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
} }
...@@ -679,8 +679,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -679,8 +679,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( *text == 'X' ) if( *text == 'X' )
{ {
text++; text++;
dcode->m_Drill.x = dcode->m_Drill.y = dcode->m_Drill.x = KiROUND( ReadDouble( text ) * conv_scale );
KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_Drill.y = dcode->m_Drill.x =
dcode->m_DrillShape = APT_DEF_ROUND_HOLE; dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
} }
...@@ -690,8 +690,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -690,8 +690,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( *text == 'X' ) if( *text == 'X' )
{ {
text++; text++;
dcode->m_Drill.y = dcode->m_Drill.y = KiROUND( ReadDouble( text ) * conv_scale );
KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = APT_DEF_RECT_HOLE; dcode->m_DrillShape = APT_DEF_RECT_HOLE;
} }
dcode->m_Defined = true; dcode->m_Defined = true;
......
...@@ -35,19 +35,7 @@ ...@@ -35,19 +35,7 @@
#include <common.h> #include <common.h>
#include <convert_to_biu.h>
/// Scalar to convert mils to internal units.
#if defined( PCBNEW )
#if defined( USE_PCBNEW_NANOMETRES )
#define MILS_TO_IU_SCALAR 25.4e3 // Pcbnew in nanometers.
#else
#define MILS_TO_IU_SCALAR 10.0 // Pcbnew in deci-mils.
#endif
#else
#define MILS_TO_IU_SCALAR 1.0 // Eeschema and anything else.
#endif
/** /**
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <wx/fileconf.h> #include <wx/fileconf.h>
#include <richio.h> #include <richio.h>
#include <convert_to_biu.h>
#if !wxUSE_PRINTING_ARCHITECTURE #if !wxUSE_PRINTING_ARCHITECTURE
# error "You must use '--enable-printarch' in your wx library configuration." # error "You must use '--enable-printarch' in your wx library configuration."
...@@ -296,18 +297,9 @@ public: ...@@ -296,18 +297,9 @@ public:
// Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA, // Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
// and either deci-mils or nanometers in PCBNew. // and either deci-mils or nanometers in PCBNew.
#if defined(PCBNEW) #if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW)
# if defined(KICAD_NANOMETRE) int GetWidthIU() const { return MILS_TO_IU_SCALING_FACTOR * GetWidthMils(); }
int GetWidthIU() const { return 25400 * GetWidthMils(); } int GetHeightIU() const { return MILS_TO_IU_SCALING_FACTOR * GetHeightMils(); }
int GetHeightIU() const { return 25400 * GetHeightMils(); }
# else
int GetWidthIU() const { return 10 * GetWidthMils(); }
int GetHeightIU() const { return 10 * GetHeightMils(); }
# endif
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
#elif defined(EESCHEMA)
int GetWidthIU() const { return GetWidthMils(); }
int GetHeightIU() const { return GetHeightMils(); }
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); } const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
#endif #endif
......
...@@ -9,20 +9,37 @@ ...@@ -9,20 +9,37 @@
/** /**
* @brief inline convert functions to convert a value in decimils (or mils) * @brief some define and functions to convert a value in mils, decimils or mm
* to the internal unit used in pcbnew or cvpcb(nanometer or decimil) * to the internal unit used in pcbnew, cvpcb or gerbview (nanometer or decimil)
* depending on compil option * depending on compil option
*/ */
#if defined(PCBNEW) || defined(CVPCB)
/// Scaling factor to convert mils to internal units.
#if defined(PCBNEW) || defined(CVPCB) || defined(GERBVIEW)
#if defined( USE_PCBNEW_NANOMETRES )
#if defined(GERBVIEW)
#define MM_TO_IU_SCALING_FACTOR 1e5 // Gerbview uses 10 micrometer.
#else
#define MM_TO_IU_SCALING_FACTOR 1e6 // Pcbnew uses nanometers.
#endif
#define MILS_TO_IU_SCALING_FACTOR ( MM_TO_IU_SCALING_FACTOR * 0.0254 )
#define DECIMILS_TO_IU_SCALING_FACTOR (MM_TO_IU_SCALING_FACTOR * 0.00254 )
#else // Pcbnew in deci-mils.
#define DECIMILS_TO_IU_SCALING_FACTOR 1
#define MILS_TO_IU_SCALING_FACTOR 10.0
#define MM_TO_IU_SCALING_FACTOR (1e4 / 25.4)
#endif
/// Convert mils to PCBNEW internal units (iu). /// Convert mils to PCBNEW internal units (iu).
inline int Mils2iu( int mils ) inline int Mils2iu( int mils )
{ {
#if defined( USE_PCBNEW_NANOMETRES ) #if defined( USE_PCBNEW_NANOMETRES )
double x = mils * 25.4e3; double x = mils * MILS_TO_IU_SCALING_FACTOR;
return int( x < 0 ? x - 0.5 : x + 0.5 ); return int( x < 0 ? x - 0.5 : x + 0.5 );
#else #else
return mils * 10; return mils * MILS_TO_IU_SCALING_FACTOR;
#endif #endif
} }
...@@ -30,14 +47,17 @@ inline int Mils2iu( int mils ) ...@@ -30,14 +47,17 @@ inline int Mils2iu( int mils )
inline int DMils2iu( int dmils ) inline int DMils2iu( int dmils )
{ {
#if defined( USE_PCBNEW_NANOMETRES ) #if defined( USE_PCBNEW_NANOMETRES )
double x = dmils * 25.4e2; double x = dmils * DECIMILS_TO_IU_SCALING_FACTOR;
return int( x < 0 ? x - 0.5 : x + 0.5 ); return int( x < 0 ? x - 0.5 : x + 0.5 );
#else #else
return dmils; return dmils;
#endif #endif
} }
#elif defined(EESCHEMA) #else // Eeschema and anything else.
#define MILS_TO_IU_SCALING_FACTOR 1.0
#define MM_TO_IU_SCALING_FACTOR (MILS_TO_IU_SCALING_FACTOR / 0.0254)
inline int Mils2iu( int mils ) inline int Mils2iu( int mils )
{ {
return mils; return mils;
......
...@@ -203,7 +203,10 @@ set(PCBNEW_SRCS ...@@ -203,7 +203,10 @@ set(PCBNEW_SRCS
### ###
# We need some extra sources from common # We need some extra sources from common
### ###
#set(PCBNEW_COMMON_SRCS ../common/dialogs/dialog_page_settings.cpp ) set(PCBNEW_COMMON_SRCS
../common/dialogs/dialog_page_settings.cpp
../common/base_units.cpp
)
### ###
......
...@@ -19,15 +19,11 @@ ...@@ -19,15 +19,11 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
#if defined( USE_PCBNEW_NANOMETRES ) #define ZOOM_FACTOR( x ) ( x * DECIMILS_TO_IU_SCALING_FACTOR )
#define ZOOM_FACTOR( x ) ( x * 25.4e2 ) #define DMIL_GRID( x ) wxRealPoint( x * DECIMILS_TO_IU_SCALING_FACTOR,\
#define DMIL_GRID( x ) wxRealPoint( x * 25.4e2, x * 25.4e2 ) x * DECIMILS_TO_IU_SCALING_FACTOR )
#define MM_GRID( x ) wxRealPoint( x * 1e6, x * 1e6 ) #define MM_GRID( x ) wxRealPoint( x * MM_TO_IU_SCALING_FACTOR,\
#else x * MM_TO_IU_SCALING_FACTOR )
#define ZOOM_FACTOR( x ) x
#define DMIL_GRID( x ) wxRealPoint( x , x )
#define MM_GRID( x ) wxRealPoint( x * 1e4 / 25.4, x * 1e4 / 25.4 )
#endif
/** /**
...@@ -110,7 +106,6 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) : ...@@ -110,7 +106,6 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) :
{ {
wxSize displayz = wxGetDisplaySize(); wxSize displayz = wxGetDisplaySize();
for( unsigned i = 0; i < DIM( pcbZoomList ); ++i ) for( unsigned i = 0; i < DIM( pcbZoomList ); ++i )
m_ZoomList.Add( pcbZoomList[i] ); m_ZoomList.Add( pcbZoomList[i] );
...@@ -124,7 +119,7 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) : ...@@ -124,7 +119,7 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) :
m_Route_Layer_TOP = LAYER_N_FRONT; // default layers pair for vias (bottom to top) m_Route_Layer_TOP = LAYER_N_FRONT; // default layers pair for vias (bottom to top)
m_Route_Layer_BOTTOM = LAYER_N_BACK; m_Route_Layer_BOTTOM = LAYER_N_BACK;
SetZoom( ZOOM_FACTOR( 150 ) ); // a default value for zoom SetZoom( ZOOM_FACTOR( 120 ) ); // a default value for zoom
InitDataPoints( aPageSizeIU ); InitDataPoints( aPageSizeIU );
} }
...@@ -138,11 +133,7 @@ PCB_SCREEN::~PCB_SCREEN() ...@@ -138,11 +133,7 @@ PCB_SCREEN::~PCB_SCREEN()
int PCB_SCREEN::MilsToIuScalar() int PCB_SCREEN::MilsToIuScalar()
{ {
#if defined( USE_PCBNEW_NANOMETRES ) return (int)MILS_TO_IU_SCALING_FACTOR;
return 25400;
#else
return 10;
#endif
} }
......
...@@ -271,7 +271,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, ...@@ -271,7 +271,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
g_DrawBgColor = WHITE; g_DrawBgColor = WHITE;
if( aPrint_Frame_Ref ) if( aPrint_Frame_Ref )
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, MILS_TO_IU_SCALAR ); m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, MILS_TO_IU_SCALING_FACTOR );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters); m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
......
...@@ -2682,7 +2682,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties ) ...@@ -2682,7 +2682,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// conversion factor for saving RAM BIUs to KICAD legacy file format. // conversion factor for saving RAM BIUs to KICAD legacy file format.
#if defined( USE_PCBNEW_NANOMETRES ) #if defined( USE_PCBNEW_NANOMETRES )
biuToDisk = 1/1000000.0; // BIUs are nanometers & file is mm biuToDisk = 1/MM_TO_IU_SCALING_FACTOR; // BIUs are nanometers & file is mm
#else #else
biuToDisk = 1.0; // BIUs are deci-mils biuToDisk = 1.0; // BIUs are deci-mils
#endif #endif
...@@ -2694,11 +2694,8 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties ) ...@@ -2694,11 +2694,8 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// then, during the file loading process, to start a conversion from // then, during the file loading process, to start a conversion from
// mm to nanometers. // mm to nanometers.
#if defined( USE_PCBNEW_NANOMETRES ) diskToBiu = DECIMILS_TO_IU_SCALING_FACTOR; // BIUs are nanometers if USE_PCBNEW_NANOMETRES
diskToBiu = 2540.0; // BIUs are nanometers // or BIUs are deci-mils
#else
diskToBiu = 1.0; // BIUs are deci-mils
#endif
} }
......
...@@ -180,12 +180,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -180,12 +180,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( userscale == 0 ) // fit in page if( userscale == 0 ) // fit in page
{ {
// Margin = 0.4 inch // Margin = 10mm
#if defined(KICAD_NANOMETRE) int extra_margin = int( 10 * MM_TO_IU_SCALING_FACTOR ); // deci-mils
int extra_margin = int( 0.4 * 25400 ); // nanometers
#else
int extra_margin = int( 0.4 * 1000 ); // deci-mils
#endif
pageSizeIU.x = bbbox.GetWidth() + extra_margin * 2; pageSizeIU.x = bbbox.GetWidth() + extra_margin * 2;
pageSizeIU.y = bbbox.GetHeight() + extra_margin * 2; pageSizeIU.y = bbbox.GetHeight() + extra_margin * 2;
...@@ -278,7 +274,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -278,7 +274,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
int bg_color = g_DrawBgColor; int bg_color = g_DrawBgColor;
if( m_PrintParams.m_Print_Sheet_Ref ) if( m_PrintParams.m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, MILS_TO_IU_SCALAR ); m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
MILS_TO_IU_SCALING_FACTOR );
if( printMirror ) if( printMirror )
{ {
......
...@@ -171,10 +171,10 @@ static inline double scale( int kicadDist ) ...@@ -171,10 +171,10 @@ static inline double scale( int kicadDist )
#if defined(USE_PCBNEW_NANOMETRES) #if defined(USE_PCBNEW_NANOMETRES)
// nanometers to um // nanometers to um
return kicadDist / 1000.0; return kicadDist / ( MM_TO_IU_SCALING_FACTOR / 1000.0 );
// nanometers to mils // nanometers to mils
// return kicadDist/25400.0; // return kicadDist/MILS_TO_IU_SCALING_FACTOR;
#else #else
// deci-mils to mils. // deci-mils to mils.
...@@ -185,11 +185,7 @@ static inline double scale( int kicadDist ) ...@@ -185,11 +185,7 @@ static inline double scale( int kicadDist )
/// Convert integer internal units to float um /// Convert integer internal units to float um
static inline double IU2um( int kicadDist ) static inline double IU2um( int kicadDist )
{ {
#if defined(USE_PCBNEW_NANOMETRES) return kicadDist * (1000.0 / MM_TO_IU_SCALING_FACTOR);
return kicadDist / 1000.0;
#else
return kicadDist * 25.4e-1;
#endif
} }
......
...@@ -67,7 +67,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -67,7 +67,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
m_canvas->DrawBackGround( DC ); m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR ); TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALING_FACTOR );
// Redraw the footprints // Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas->DrawBackGround( DC ); m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALING_FACTOR );
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST); GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST);
......
...@@ -357,9 +357,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector< ...@@ -357,9 +357,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
else else
{ {
// style is ARC_CW or ARC_CCW // style is ARC_CW or ARC_CCW
int n; // number of steps for arcs int n = CArc::ARC_STEPS;
n = ( abs( x2 - x1 ) + abs( y2 - y1 ) ) / (CArc::MAX_STEP);
n = MAX( n, CArc::MIN_STEPS ); // or at most 5 degrees of arc
n_vertices += n; n_vertices += n;
n_arcs++; n_arcs++;
} }
...@@ -392,8 +390,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector< ...@@ -392,8 +390,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
{ {
// style is arc_cw or arc_ccw // style is arc_cw or arc_ccw
int n; // number of steps for arcs int n; // number of steps for arcs
n = ( abs( x2 - x1 ) + abs( y2 - y1 ) ) / (CArc::MAX_STEP); n = CArc::ARC_STEPS;
n = MAX( n, CArc::MIN_STEPS ); // or at most 5 degrees of arc
double xo, yo, theta1, theta2, a, b; double xo, yo, theta1, theta2, a, b;
a = fabs( (double) (x1 - x2) ); a = fabs( (double) (x1 - x2) );
b = fabs( (double) (y1 - y2) ); b = fabs( (double) (y1 - y2) );
......
...@@ -77,8 +77,7 @@ public: ...@@ -77,8 +77,7 @@ public:
class CArc class CArc
{ {
public: public:
enum { MAX_STEP = 50 * 25400 }; // max step is 20 mils enum { ARC_STEPS = 16 }; // arc approximation step is 16 segm / 90 degres
enum { MIN_STEPS = 18 }; // min step is 5 degrees
int style; int style;
int xi, yi, xf, yf; int xi, yi, xf, yf;
int n_steps; // number of straight-line segments in gpc_poly int n_steps; // number of straight-line segments in gpc_poly
......
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