Commit 8c0dc01f authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew nanometer internal unit fixes.

* Scale page reference border and title block, grid sizes, and zoom factors
  correctly for nanometers.
parent add53213
This diff is collapsed.
......@@ -237,7 +237,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
sheetSize.y/2) );
if( aPrint_Sheet_Ref )
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness );
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
screen->m_IsPrinting = false;
panel->SetClipBox( tmp );
......
......@@ -378,7 +378,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference )
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness );
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
g_DrawBgColor = bg_color;
aScreen->m_IsPrinting = false;
......
......@@ -31,6 +31,7 @@
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <class_library.h>
......@@ -70,7 +71,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
#ifdef USE_WX_OVERLAY
if( IsShown() )
......
......@@ -32,6 +32,7 @@
#include <class_drawpanel.h>
#include <gestfich.h>
#include <confirm.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -862,7 +863,7 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
{
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
}
......
......@@ -33,6 +33,7 @@
#include <common.h>
#include <class_drawpanel.h>
#include <drawtxt.h>
#include <base_units.h>
#include <gerbview.h>
#include <class_board_design_settings.h>
......@@ -106,7 +107,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsElementVisible( DCODES_VISIBLE ) )
DrawItemsDCodeID( DC, GR_COPY );
TraceWorkSheet( DC, screen, 0 );
TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......
......@@ -37,6 +37,19 @@
#include <common.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
/**
* Function To_User_Unit
* convert \a aValue in internal units to the appropriate user units defined by \a aUnit.
......
......@@ -667,7 +667,7 @@ public:
*/
double GetZoom();
void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth );
void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar );
/**
* Function TraceWorkSheet is a core function for drawing of the page layout with
......@@ -682,13 +682,14 @@ public:
* @param aNScr The number of screens (for basic inscriptions).
* @param aScr The screen number (for basic inscriptions).
* @param aLnW The line width for drawing.
* @param aScalar Scalar to convert from mils to internal units.
* @param aClr1 The color for drawing.
* @param aClr2 The colr for inscriptions.
*/
void TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoint& aRB,
wxString& aType, wxString& aFlNm, TITLE_BLOCK& aTb,
int aNScr, int aScr, int aLnW, EDA_COLOR_T aClr1 = RED,
EDA_COLOR_T aClr2 = RED );
int aNScr, int aScr, int aLnW, double aScalar,
EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED );
void PlotWorkSheet( PLOTTER* aPlotter, BASE_SCREEN* aScreen );
......
......@@ -10,6 +10,7 @@
#include <trigo.h>
#include <class_pcb_screen.h>
#include <eda_text.h> // FILLED
#include <base_units.h>
#include <pcbnew.h>
#include <class_board_design_settings.h>
......@@ -18,6 +19,19 @@
#include <pcbnew_id.h>
#if defined( USE_PCBNEW_NANOMETRES )
#define ZOOM_FACTOR( x ) ( x * 25.4e2 )
#define DMIL_GRID( x ) wxRealPoint( x * 25.4e2, x * 25.4e2 )
#define MM_GRID( x ) wxRealPoint( x * 1e6, x * 1e6 )
#else
#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
/* Default Pcbnew zoom values.
* Limited to 19 values to keep a decent size to menus
* 15 it better but does not allow a sufficient number of values
......@@ -30,42 +44,56 @@
*/
static const double pcbZoomList[] =
{
0.5, 1.0, 1.5, 2.0, 3.0, 4.5, 7.0,
10.0, 15.0, 22.0, 35.0, 50.0, 80.0, 120.0,
200.0, 350.0, 500.0, 1000.0, 2000.0
ZOOM_FACTOR( 0.5 ),
ZOOM_FACTOR( 1.0 ),
ZOOM_FACTOR( 1.5 ),
ZOOM_FACTOR( 2.0 ),
ZOOM_FACTOR( 3.0 ),
ZOOM_FACTOR( 4.5 ),
ZOOM_FACTOR( 7.0 ),
ZOOM_FACTOR( 10.0 ),
ZOOM_FACTOR( 15.0 ),
ZOOM_FACTOR( 22.0 ),
ZOOM_FACTOR( 35.0 ),
ZOOM_FACTOR( 50.0 ),
ZOOM_FACTOR( 80.0 ),
ZOOM_FACTOR( 120.0 ),
ZOOM_FACTOR( 200.0 ),
ZOOM_FACTOR( 350.0 ),
ZOOM_FACTOR( 500.0 ),
ZOOM_FACTOR( 1000.0 ),
ZOOM_FACTOR( 2000.0 )
};
#define MM_TO_PCB_UNITS (10000.0 / 25.4)
// Default grid sizes for PCB editor screens.
static GRID_TYPE pcbGridList[] =
{
// predefined grid list in 0.0001 inches
{ ID_POPUP_GRID_LEVEL_1000, wxRealPoint( 1000, 1000 ) },
{ ID_POPUP_GRID_LEVEL_500, wxRealPoint( 500, 500 ) },
{ ID_POPUP_GRID_LEVEL_250, wxRealPoint( 250, 250 ) },
{ ID_POPUP_GRID_LEVEL_200, wxRealPoint( 200, 200 ) },
{ ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
{ ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
{ ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
{ ID_POPUP_GRID_LEVEL_20, wxRealPoint( 20, 20 ) },
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
{ ID_POPUP_GRID_LEVEL_1000, DMIL_GRID( 1000 ) },
{ ID_POPUP_GRID_LEVEL_500, DMIL_GRID( 500 ) },
{ ID_POPUP_GRID_LEVEL_250, DMIL_GRID( 250 ) },
{ ID_POPUP_GRID_LEVEL_200, DMIL_GRID( 200 ) },
{ ID_POPUP_GRID_LEVEL_100, DMIL_GRID( 100 ) },
{ ID_POPUP_GRID_LEVEL_50, DMIL_GRID( 50 ) },
{ ID_POPUP_GRID_LEVEL_25, DMIL_GRID( 25 ) },
{ ID_POPUP_GRID_LEVEL_20, DMIL_GRID( 20 ) },
{ ID_POPUP_GRID_LEVEL_10, DMIL_GRID( 10 ) },
{ ID_POPUP_GRID_LEVEL_5, DMIL_GRID( 5 ) },
{ ID_POPUP_GRID_LEVEL_2, DMIL_GRID( 2 ) },
{ ID_POPUP_GRID_LEVEL_1, DMIL_GRID( 1 ) },
// predefined grid list in mm
{ ID_POPUP_GRID_LEVEL_5MM, wxRealPoint( MM_TO_PCB_UNITS * 5.0, MM_TO_PCB_UNITS * 5.0 ) },
{ ID_POPUP_GRID_LEVEL_2_5MM, wxRealPoint( MM_TO_PCB_UNITS * 2.5, MM_TO_PCB_UNITS * 2.5 ) },
{ ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_PCB_UNITS, MM_TO_PCB_UNITS ) },
{ ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.5, MM_TO_PCB_UNITS * 0.5 ) },
{ ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) },
{ ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) },
{ ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) },
{ ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) },
{ ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) },
{ ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) }
{ ID_POPUP_GRID_LEVEL_5MM, MM_GRID( 5.0 ) },
{ ID_POPUP_GRID_LEVEL_2_5MM, MM_GRID( 2.5 ) },
{ ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
{ ID_POPUP_GRID_LEVEL_0_5MM, MM_GRID( 0.5 ) },
{ ID_POPUP_GRID_LEVEL_0_25MM, MM_GRID( 0.25 ) },
{ ID_POPUP_GRID_LEVEL_0_2MM, MM_GRID( 0.2 ) },
{ ID_POPUP_GRID_LEVEL_0_1MM, MM_GRID( 0.1 ) },
{ ID_POPUP_GRID_LEVEL_0_0_5MM, MM_GRID( 0.05 ) },
{ ID_POPUP_GRID_LEVEL_0_0_25MM, MM_GRID( 0.025 ) },
{ ID_POPUP_GRID_LEVEL_0_0_1MM, MM_GRID( 0.01 ) }
};
......@@ -79,13 +107,13 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) :
AddGrid( pcbGridList[i] );
// Set the working grid size to a reasonnable value (in 1/10000 inch)
SetGrid( wxRealPoint( 500, 500 ) );
SetGrid( DMIL_GRID( 500 ) );
m_Active_Layer = LAYER_N_BACK; // default active layer = bottom layer
m_Route_Layer_TOP = LAYER_N_FRONT; // default layers pair for vias (bottom to top)
m_Route_Layer_BOTTOM = LAYER_N_BACK;
SetZoom( 150 ); // a default value for zoom
SetZoom( ZOOM_FACTOR( 150 ) ); // a default value for zoom
InitDataPoints( aPageSizeIU );
}
......
......@@ -265,7 +265,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
g_DrawBgColor = WHITE;
if( aPrint_Frame_Ref )
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize );
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, MILS_TO_IU_SCALAR );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color;
......
......@@ -35,9 +35,9 @@
#include <wxBasePcbFrame.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <base_units.h>
#include <class_board.h>
#include <pcbnew.h>
#include <protos.h>
......@@ -278,7 +278,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
int bg_color = g_DrawBgColor;
if( m_PrintParams.m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize );
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, MILS_TO_IU_SCALAR );
if( printMirror )
{
......
......@@ -31,6 +31,7 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <class_board.h>
#include <class_module.h>
......@@ -66,7 +67,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode( DC, GR_COPY );
m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0 );
TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR );
// Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
......@@ -104,7 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST);
......
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