Commit f3503723 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

merged to testing, fixed some scripting imports

parents b939f3bc b322a885
......@@ -70,7 +70,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices )
RotatePoint( &aVertices[ii].x, &aVertices[ii].y, (int) (m_MatRotation.z * 10) );
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
#define SCALE_3D_CONV (PCB_INTERNAL_UNIT / UNITS3D_TO_UNITSPCB)
#define SCALE_3D_CONV ((IU_PER_MILS * 1000) / UNITS3D_TO_UNITSPCB)
aVertices[ii].x += m_MatPosition.x * SCALE_3D_CONV;
aVertices[ii].y += m_MatPosition.y * SCALE_3D_CONV;
aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV;
......
......@@ -52,21 +52,33 @@ PCBNew
See the @todos in class_zone.cpp
Dick's Peronal TODO Items (Last Update: 5-April-2012)
Dick's Peronal TODO Items (Last Update: 24-April-2012)
-----------------------------------------------------
0) Check that the new load visibility BOARD settings is properly setting the toolbar
1) Work through some scroll, pan, zoom overflows in PCBNEW's nanometer build mode.
It is thought that if we can constrain the virtual IU space to within
INT_MIN to INT_MAX then a whole host of other problems will go away. Most
of the evil is in EDA_DRAW_FRAME::AdjustScrollBars() which assumes the
virtual IU space is infinite. This function triggers a movement of the
viewport within the virtual IU space and also a change in size of the virtual
IU space. Once this happens, you can end up thinking there are problems in
functions like EDA_DRAW_PANE::DrawCrossHair(), but this may be an artifact
of having traveled outside a limited virtual IU space.
2) Check that the new load visibility BOARD settings is properly setting the toolbar
buttons like show grid or ratsnest. Add PCB_EDIT_FRAME::SetVisibleElements() so
toolbar crap is not known to a BOARD.
1) Finish removing global access requirements from KICAD_PLUGIN, so that:
*) a BOARD is a fully self contained document description.
*) plugin developers do not have to access globals, since a plugin could
3) Finish removing global access requirements from KICAD_PLUGIN, so that:
*) a BOARD is a fully self contained document description.
*) plugin developers do not have to access globals, since a plugin could
very well be a dynamically loaded DLL/DSO.
One final problem remains with BASE_SCREEN's grid origin, easy solution is to
move just that one field into the BOARD.
One final problem remains with BASE_SCREEN's grid origin, easy solution is to
move just that one field into the BOARD.
2) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
4) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
This is PLUGIN::Load() and maybe PLUGIN::Save().
3) Get back to the SWEET work.
5) Get back to the SWEET work.
......@@ -83,7 +83,6 @@ add_library(common STATIC ${COMMON_SRCS})
set(PCB_COMMON_SRCS
base_screen.cpp
base_units.cpp
eda_text.cpp
class_page_info.cpp
pcbcommon.cpp
......@@ -120,7 +119,6 @@ set(PCB_COMMON_SRCS
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.cpp
dialogs/dialog_page_settings.cpp
)
......
......@@ -70,17 +70,19 @@ void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
{
if( m_Center )
{
m_crossHairPosition.x = m_crossHairPosition.y = 0;
m_crossHairPosition.x = 0;
m_crossHairPosition.y = 0;
m_DrawOrg.x = -aPageSizeIU.x / 2;
m_DrawOrg.y = -aPageSizeIU.y / 2;
}
else
{
m_DrawOrg.x = m_DrawOrg.y = 0;
m_crossHairPosition.x = aPageSizeIU.x / 2;
m_crossHairPosition.y = aPageSizeIU.y / 2;
m_DrawOrg.x = 0;
m_DrawOrg.y = 0;
}
m_O_Curseur.x = m_O_Curseur.y = 0;
......@@ -142,6 +144,8 @@ bool BASE_SCREEN::SetZoom( double coeff )
if( coeff == m_Zoom )
return false;
wxLogDebug( "Zoom:%16g 1/Zoom:%16g", coeff, 1/coeff );
m_Zoom = coeff;
return true;
......@@ -168,12 +172,10 @@ bool BASE_SCREEN::SetNextZoom()
bool BASE_SCREEN::SetPreviousZoom()
{
size_t i;
if( m_ZoomList.IsEmpty() || m_Zoom <= m_ZoomList[0] )
return false;
for( i = m_ZoomList.GetCount(); i != 0; i-- )
for( unsigned i = m_ZoomList.GetCount(); i != 0; i-- )
{
if( m_Zoom > m_ZoomList[i - 1] )
{
......@@ -191,8 +193,7 @@ bool BASE_SCREEN::SetLastZoom()
if( m_ZoomList.IsEmpty() || m_Zoom == m_ZoomList.Last() )
return false;
SetZoom( m_ZoomList.Last() );
return true;
return SetZoom( m_ZoomList.Last() );
}
......@@ -216,11 +217,9 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
{
wxASSERT( !m_grids.empty() );
size_t i;
GRID_TYPE nearest_grid = m_grids[0];
for( i = 0; i < m_grids.size(); i++ )
for( unsigned i = 0; i < m_grids.size(); i++ )
{
if( m_grids[i].m_Size == size )
{
......@@ -228,7 +227,7 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
return;
}
// keep trace of the nearest grill size, if the exact size is not found
// keep track of the nearest larger grid size, if the exact size is not found
if ( size.x < m_grids[i].m_Size.x )
nearest_grid = m_grids[i];
}
......@@ -245,9 +244,7 @@ void BASE_SCREEN::SetGrid( int id )
{
wxASSERT( !m_grids.empty() );
size_t i;
for( i = 0; i < m_grids.size(); i++ )
for( unsigned i = 0; i < m_grids.size(); i++ )
{
if( m_grids[i].m_Id == id )
{
......@@ -266,9 +263,7 @@ void BASE_SCREEN::SetGrid( int id )
void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
{
size_t i;
for( i = 0; i < m_grids.size(); i++ )
for( unsigned i = 0; i < m_grids.size(); i++ )
{
if( m_grids[i].m_Size == grid.m_Size && grid.m_Id != ID_POPUP_GRID_USER )
{
......
......@@ -40,25 +40,13 @@
#include <base_units.h>
#if defined( PCBNEW )
#if defined( USE_PCBNEW_NANOMETRES )
#define IU_TO_MM( x ) ( x * 1e-6 )
#define IU_TO_IN( x ) ( ( x * 1e-6 ) / 25.4 )
#define MM_TO_IU( x ) ( x * 1e6 )
#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 )
#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA )
#define IU_TO_MM( x ) ( x / IU_PER_MM )
#define IU_TO_IN( x ) ( x / IU_PER_MILS / 1000 )
#define MM_TO_IU( x ) ( x * IU_PER_MM )
#define IN_TO_IU( x ) ( x * IU_PER_MILS * 1000 )
#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
......@@ -79,6 +67,11 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue )
wxString CoordinateToString( int aValue, bool aConvertToMils )
{
return LengthDoubleToString( (double) aValue, aConvertToMils );
}
wxString LengthDoubleToString( double aValue, bool aConvertToMils )
{
wxString text;
const wxChar* format;
......@@ -261,3 +254,14 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
return value;
}
wxString& operator <<( wxString& aString, const wxPoint& aPos )
{
aString << wxT( "@ (" ) << CoordinateToString( aPos.x );
aString << wxT( "," ) << CoordinateToString( aPos.y );
aString << wxT( ")" );
return aString;
}
......@@ -334,39 +334,6 @@ unsigned long GetNewTimeStamp()
}
const wxString& valeur_param( int valeur, wxString& buf_texte )
{
switch( g_UserUnit )
{
case MILLIMETRES:
buf_texte.Printf( _( "%3.3f mm" ), valeur * 0.00254 );
break;
case INCHES:
buf_texte.Printf( wxT( "%2.4f \"" ), valeur * 0.0001 );
break;
case UNSCALED_UNITS:
buf_texte.Printf( wxT( "%d" ), valeur );
break;
}
return buf_texte;
}
wxString& operator <<( wxString& aString, const wxPoint& aPos )
{
wxString temp;
aString << wxT( "@ (" ) << valeur_param( aPos.x, temp );
aString << wxT( "," ) << valeur_param( aPos.y, temp );
aString << wxT( ")" );
return aString;
}
double RoundTo0( double x, double precision )
{
assert( precision != 0 );
......
......@@ -34,7 +34,6 @@
#include <class_title_block.h>
#include <wxstruct.h>
#include <class_base_screen.h>
#include <base_units.h> // MILS_TO_IU_SCALAR
#include <wx/valgen.h>
#include <wx/tokenzr.h>
......@@ -617,7 +616,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
m_Parent->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ),
wxSize( INT_MAX / 2, INT_MAX / 2 ) ) );
// 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 scaleH = (double) lyHeight / clamped_layout_size.y / appScale;
......
This diff is collapsed.
......@@ -158,28 +158,34 @@ void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, int aColor )
if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
return;
wxPoint Cursor = GetScreen()->GetCrossHairPosition();
wxPoint cursor = GetScreen()->GetCrossHairPosition();
GRSetDrawMode( aDC, GR_XOR );
if( GetParent()->m_cursorShape != 0 ) /* Draws full screen crosshair. */
if( GetParent()->m_cursorShape != 0 ) // Draws full screen crosshair.
{
wxSize clientSize = GetClientSize();
wxPoint lineStart = wxPoint( Cursor.x, aDC->DeviceToLogicalY( 0 ) );
wxPoint lineEnd = wxPoint( Cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // Y axis
lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), Cursor.y );
lineEnd = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), Cursor.y );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // X axis
wxSize clientSize = GetClientSize();
// Y axis
wxPoint lineStart( cursor.x, aDC->DeviceToLogicalY( 0 ) );
wxPoint lineEnd( cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
// X axis
lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), cursor.y );
lineEnd = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), cursor.y );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
}
else
{
int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );
GRLine( &m_ClipBox, aDC, Cursor.x - len, Cursor.y,
Cursor.x + len, Cursor.y, 0, aColor );
GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - len,
Cursor.x, Cursor.y + len, 0, aColor );
GRLine( &m_ClipBox, aDC, cursor.x - len, cursor.y,
cursor.x + len, cursor.y, 0, aColor );
GRLine( &m_ClipBox, aDC, cursor.x, cursor.y - len,
cursor.x, cursor.y + len, 0, aColor );
}
}
......@@ -469,7 +475,7 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, g_DrawBgColor, g_DrawBgColor );
/* Set to one (1) to draw bounding box validate bounding box calculation. */
// Set to one (1) to draw bounding box validate bounding box calculation.
#if DEBUG_SHOW_CLIP_RECT
EDA_RECT bBox = m_ClipBox;
GRRect( NULL, DC, bBox.GetOrigin().x, bBox.GetOrigin().y,
......@@ -823,7 +829,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
wxRect rect = wxRect( wxPoint( 0, 0 ), GetClientSize() );
/* Ignore scroll events if the cursor is outside the drawing area. */
// Ignore scroll events if the cursor is outside the drawing area.
if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled()
|| !rect.Contains( event.GetPosition() ) )
{
......@@ -937,12 +943,12 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( event.MiddleDown() )
localbutt = GR_M_MIDDLE_DOWN;
localrealbutt |= localbutt; /* compensation default wxGTK */
localrealbutt |= localbutt; // compensation default wxGTK
INSTALL_UNBUFFERED_DC( DC, this );
DC.SetBackground( *wxBLACK_BRUSH );
/* Compute the cursor position in drawing (logical) units. */
// Compute the cursor position in drawing (logical) units.
screen->SetMousePosition( event.GetLogicalPosition( DC ) );
int kbstat = 0;
......@@ -1101,7 +1107,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
GetEventHandler()->ProcessEvent( cmd );
}
/* Calling the general function on mouse changes (and pseudo key commands) */
// Calling the general function on mouse changes (and pseudo key commands)
GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 );
/*******************************/
......@@ -1165,17 +1171,16 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( !m_enableMiddleButtonPan && event.MiddleIsDown() )
cmd_type |= MOUSE_MIDDLE;
/* A block command is started if the drag is enough. A small
* drag is ignored (it is certainly a little mouse move when
* clicking) not really a drag mouse
*/
// A block command is started if the drag is enough. A small
// drag is ignored (it is certainly a little mouse move when
// clicking) not really a drag mouse
if( MinDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
MinDragEventCount++;
else
{
if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos ) )
{
// should not occurs: error
// should not occur: error
GetParent()->DisplayToolMsg(
wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
}
......@@ -1264,8 +1269,8 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
switch( localkey )
{
default:
break;
default:
break;
case WXK_ESCAPE:
m_abortRequest = true;
......
......@@ -37,11 +37,7 @@
// Conversion to application internal units defined at build time.
#if defined( PCBNEW )
#include <class_board_item.h>
#if defined( USE_PCBNEW_NANOMETRES )
#define MILS_TO_IU( x ) ( x * 25400 );
#else
#define MILS_TO_IU( x ) ( x * 10 )
#endif
#define MILS_TO_IU( x ) ( x * IU_PER_MILS );
#elif defined( EESCHEMA )
#include <sch_item_struct.h>
#define MILS_TO_IU( x ) ( x )
......
......@@ -52,15 +52,13 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
m_canvas->Refresh();
m_canvas->Update();
}
}
/** Redraw the screen with best zoom level and the best centering
* that shows all the page or the board
*/
void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
{
BASE_SCREEN * screen = GetScreen();
BASE_SCREEN* screen = GetScreen();
screen->SetZoom( BestZoom() ); // Set the best zoom and get center point.
if( screen->m_FirstRedraw )
......@@ -76,16 +74,15 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
*/
void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect )
{
double scalex, bestscale;
wxSize size;
/* Compute the best zoom */
// Compute the best zoom
Rect.Normalize();
size = m_canvas->GetClientSize();
wxSize size = m_canvas->GetClientSize();
// Use ceil to at least show the full rect
scalex = (double) Rect.GetSize().x / size.x;
bestscale = (double) Rect.GetSize().y / size.y;
double scalex = (double) Rect.GetSize().x / size.x;
double bestscale = (double) Rect.GetSize().y / size.y;
bestscale = MAX( bestscale, scalex );
GetScreen()->SetScalingFactor( bestscale );
......@@ -102,7 +99,6 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( m_canvas == NULL )
return;
int i;
int id = event.GetId();
bool zoom_at_cursor = false;
BASE_SCREEN* screen = GetScreen();
......@@ -151,9 +147,11 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break;
default:
unsigned i;
i = id - ID_POPUP_ZOOM_LEVEL_START;
if( ( i < 0 ) || ( (size_t) i >= screen->m_ZoomList.GetCount() ) )
if( i >= screen->m_ZoomList.GetCount() )
{
wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ),
__TFILE__, __LINE__, i );
......@@ -175,7 +173,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
int maxZoomIds;
int zoom;
wxString msg;
BASE_SCREEN * screen = m_canvas->GetScreen();
BASE_SCREEN* screen = m_canvas->GetScreen();
msg = AddHotkeyName( _( "Center" ), m_HotkeysZoomAndGridList, HK_ZOOM_CENTER );
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
......@@ -199,7 +197,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.GetCount() ) ?
maxZoomIds : screen->m_ZoomList.GetCount();
/* Populate zoom submenu. */
// Populate zoom submenu.
for( int i = 0; i < maxZoomIds; i++ )
{
msg.Printf( wxT( "%g" ), screen->m_ZoomList[i] );
......@@ -210,7 +208,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
}
/* Create grid submenu as required. */
// Create grid submenu as required.
if( screen->GetGridCount() )
{
wxMenu* gridMenu = new wxMenu;
......
......@@ -26,6 +26,7 @@ set(CVPCB_DIALOGS
)
set(CVPCB_SRCS
../common/base_units.cpp
../pcbnew/netlist_reader_common.cpp
../pcbnew/netlist_reader_kicad.cpp
../pcbnew/netlist_reader_firstformat.cpp
......
......@@ -30,6 +30,7 @@
#include <class_drc_item.h>
#include <erc.h>
#include <base_units.h>
wxString DRC_ITEM::GetErrorText() const
{
......@@ -57,14 +58,9 @@ wxString DRC_ITEM::GetErrorText() const
}
}
wxString DRC_ITEM::ShowCoord( const wxPoint& aPos )
{
wxString ret;
wxPoint pos_in_pcb_units = aPos;
pos_in_pcb_units.x *= 10;
pos_in_pcb_units.y *= 10;
ret << pos_in_pcb_units;
ret << aPos;
return ret;
}
This diff is collapsed.
......@@ -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, MILS_TO_IU_SCALAR );
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, IU_PER_MILS );
g_DrawBgColor = bg_color;
aScreen->m_IsPrinting = false;
......
......@@ -71,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, MILS_TO_IU_SCALAR );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS );
#ifdef USE_WX_OVERLAY
if( IsShown() )
......
......@@ -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 )
{
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS );
}
......
......@@ -33,6 +33,7 @@ set(GERBVIEW_SRCS
class_am_param.cpp
class_aperture_macro.cpp
class_DCodeSelectionbox.cpp
class_gbr_screen.cpp
class_GERBER.cpp
class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp
......@@ -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
../common/base_units.cpp
../pcbnew/layer_widget.cpp
../pcbnew/printout_controler.cpp
../pcbnew/class_drc_item.cpp
......
/**
* @file classpcb.cpp
* @brief Member functions of classes used in Pcbnew (see pcbstruct.h)
* except for tracks (see class_track.cpp).
*/
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <class_gbr_screen.h>
#include <base_units.h>
#include <pcbnew.h>
#include <class_board_design_settings.h>
#include <layers_id_colors_and_visibility.h>
#include <pcbnew_id.h>
#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\
x * IU_PER_DECIMILS )
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
x * IU_PER_MM )
/**
Default Pcbnew zoom values.
Limited to 19 values to keep a decent size to menus.
Roughly a 1.5 progression.
The last 2 values are handy when somebody uses a library import of a module
(or foreign data) which has a bad coordinate.
Also useful in GerbView for this reason.
Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic
functions )
*/
static const double gbrZoomList[] =
{
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 )
};
// Default grid sizes for PCB editor screens.
static GRID_TYPE gbrGridList[] =
{
// predefined grid list in 0.0001 inches
{ 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, 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 ) }
};
GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
PCB_SCREEN( aPageSizeIU )
{
// Replace zoom and grid lists already set by PCB_SCREEN ctor
m_ZoomList.Clear();
for( unsigned i = 0; i < DIM( gbrZoomList ); ++i )
m_ZoomList.Add( gbrZoomList[i] );
GRIDS gridlist;
for( unsigned i = 0; i < DIM( gbrGridList ); ++i )
gridlist.push_back( gbrGridList[i] );
SetGridList( gridlist );
// Set the working grid size to a reasonnable value (in 1/10000 inch)
SetGrid( DMIL_GRID( 500 ) );
m_Active_Layer = LAYER_N_BACK; // default active layer = bottom layer
SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom
}
GBR_SCREEN::~GBR_SCREEN()
{
}
// virtual function
int GBR_SCREEN::MilsToIuScalar()
{
return (int)IU_PER_MILS;
}
/**
* @file class_gbr_screen.h
*/
#ifndef CLASS_GBR_SCREEN_H_
#define CLASS_GBR_SCREEN_H_
#include <base_units.h>
#include <class_pcb_screen.h>
#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS )
/* Handle info to display a board */
class GBR_SCREEN : public PCB_SCREEN
{
public:
/**
* Constructor
* @param aPageSizeIU is the size of the initial paper page in internal units.
*/
GBR_SCREEN( const wxSize& aPageSizeIU );
~GBR_SCREEN();
GBR_SCREEN* Next() { return (GBR_SCREEN*) Pnext; }
virtual int MilsToIuScalar();
};
#endif // CLASS_GBR_SCREEN_H_
/*
* 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) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
......@@ -175,7 +175,8 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
/* Updating gerber scale: */
double dcode_scale = MILS_TO_IU_SCALAR; // By uniting dCode = mil, internal unit = MILS_TO_IU_SCALAR
double dcode_scale = IU_PER_MILS; // By uniting dCode = mil,
// internal unit = IU_PER_MILS
current_Dcode = 0;
if( D_Code_FullFileName.IsEmpty() )
......
......@@ -107,7 +107,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsElementVisible( DCODES_VISIBLE ) )
DrawItemsDCodeID( DC, GR_COPY );
TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......
......@@ -432,7 +432,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
if( dcode == NULL )
break;
// conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000;
double conv_scale = IU_PER_MILS * 1000;
if( m_GerbMetric )
conv_scale /= 25.4;
......
......@@ -44,6 +44,7 @@
#include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h>
#include <class_gerbview_layer_widget.h>
#include <class_gbr_screen.h>
......@@ -93,7 +94,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
PAGE_INFO pageInfo( wxT( "GERBER" ) );
GetBoard()->SetPageSettings( pageInfo );
SetScreen( new PCB_SCREEN( pageInfo.GetSizeIU() ) );
SetScreen( new GBR_SCREEN( pageInfo.GetSizeIU() ) );
// Create the PCB_LAYER_WIDGET *after* SetBoard():
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
......@@ -179,7 +180,7 @@ double GERBVIEW_FRAME::BestZoom()
{
// gives a minimal value to zoom, if no item in list
if( GetBoard()->m_Drawings == NULL )
return 160.0;
return ZOOM_FACTOR( 160.0 );
EDA_RECT bbox;
BOARD_ITEM* item = GetBoard()->m_Drawings;
......@@ -210,7 +211,8 @@ void GERBVIEW_FRAME::LoadSettings()
if( config == NULL )
return;
PCB_BASE_FRAME::LoadSettings();
// PCB_BASE_FRAME::LoadSettings();
EDA_DRAW_FRAME::LoadSettings();
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
......@@ -255,7 +257,8 @@ void GERBVIEW_FRAME::SaveSettings()
if( config == NULL )
return;
PCB_BASE_FRAME::SaveSettings();
// PCB_BASE_FRAME::SaveSettings();
EDA_DRAW_FRAME::SaveSettings();
wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
......@@ -408,7 +411,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
D_CODE* pt_D_code;
wxString Line;
wxArrayString list;
double scale = MILS_TO_IU_SCALAR * 1000;
double scale = IU_PER_MILS * 1000;
int curr_layer = getActiveLayer();
for( int layer = 0; layer < 32; layer++ )
......
......@@ -35,6 +35,7 @@
#include <wxBasePcbFrame.h>
#include <../pcbnew/class_board.h>
#include <class_gbr_screen.h>
class DCODE_SELECTION_BOX;
......@@ -53,7 +54,6 @@ class GERBER_DRAW_ITEM;
class GERBVIEW_FRAME : public PCB_BASE_FRAME
{
friend class PCB_LAYER_WIDGET;
protected:
GERBER_LAYER_WIDGET* m_LayersManager;
......@@ -62,7 +62,7 @@ protected:
wxFileHistory m_drillFileHistory;
public:
LAYER_BOX_SELECTOR* m_SelLayerBox;
LAYER_BOX_SELECTOR* m_SelLayerBox;
DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about
// gerber data (format..)
......@@ -84,7 +84,7 @@ private:
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;
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 )
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
if( doLayerWidgetUpdate )
syncLayerWidget();
......@@ -239,7 +239,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/
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,
*/
void Block_Duplicate( wxDC* DC );
void ToPostProcess( wxCommandEvent& event );
/**
* Function ToPlotter
* Open a dialog frame to create plot and drill files
......
......@@ -21,7 +21,7 @@
*/
void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg;
if( GetToolId() == ID_NO_TOOL_SELECTED )
......@@ -36,7 +36,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
else
{
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
GetScreen()->SetCurItem( DrawStruct );
GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
if( DrawStruct == NULL )
{
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ];
......
......@@ -16,7 +16,7 @@
*/
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg;
bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
bool busy = DrawStruct && DrawStruct->GetFlags();
......@@ -71,7 +71,7 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true;
if( DrawStruct )
GetScreen()->SetCurItem( DrawStruct );
GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
return true;
}
......@@ -36,28 +36,20 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
if( state )
{
DisplayOpt.DisplayPadFill = m_DisplayPadFill = false;
}
DisplayOpt.DisplayPadFill = false;
else
{
DisplayOpt.DisplayPadFill = m_DisplayPadFill = true;
}
DisplayOpt.DisplayPadFill = true;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
if(state )
{
m_DisplayPcbTrackFill = false;
DisplayOpt.DisplayPcbTrackFill = false;
}
else
{
m_DisplayPcbTrackFill = true;
DisplayOpt.DisplayPcbTrackFill = true;
}
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_canvas->Refresh( true );
break;
......
......@@ -21,16 +21,16 @@
// 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
1000.0 * IU_PER_MILS,
100.0 * IU_PER_MILS,
10.0 * IU_PER_MILS,
1.0 * IU_PER_MILS,
0.1 * IU_PER_MILS,
0.01 * IU_PER_MILS,
0.001 * IU_PER_MILS,
0.0001 * IU_PER_MILS,
0.00001 * IU_PER_MILS,
0.000001 * IU_PER_MILS
};
......@@ -44,9 +44,9 @@ int scaletoIU( double aCoord, bool isMetric )
int ret;
if( isMetric )
ret = KiROUND( aCoord * MILS_TO_IU_SCALAR / 0.00254 );
ret = KiROUND( aCoord * IU_PER_MILS / 0.00254 );
else
ret = KiROUND( aCoord * MILS_TO_IU_SCALAR );
ret = KiROUND( aCoord * IU_PER_MILS );
return ret;
}
......@@ -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
if( m_GerbMetric ) // units are mm
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
current_coord = KiROUND( atof( line ) * IU_PER_MILS / 0.0254 );
else // units are inches
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
current_coord = KiROUND( atof( line ) * IU_PER_MILS * 1000 );
}
else
{
......@@ -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
if( m_GerbMetric ) // units are mm
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 );
current_coord = KiROUND( atof( line ) * IU_PER_MILS / 0.0254 );
else // units are inches
current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 );
current_coord = KiROUND( atof( line ) * IU_PER_MILS * 1000 );
}
else
{
......
......@@ -160,7 +160,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
double fcoord;
// conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000;
double conv_scale = IU_PER_MILS * 1000;
if( m_GerbMetric )
conv_scale /= 25.4;
......@@ -294,7 +294,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
m_GerbMetric = false;
else if( code == MILLIMETER )
m_GerbMetric = true;
conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT;
conv_scale = m_GerbMetric ? IU_PER_MILS / 25.4 : IU_PER_MILS;
break;
case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset
......@@ -579,8 +579,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
text += 2; // skip "C," for example
dcode->m_Size.x = dcode->m_Size.y =
KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Size.x = KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Size.y = dcode->m_Size.x;
switch( stdAperture ) // Aperture desceiption has optional parameters. Read them
{
......@@ -631,8 +631,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( *text == 'X' )
{
text++;
dcode->m_Drill.x = dcode->m_Drill.y =
KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Drill.x = KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Drill.y = dcode->m_Drill.x;
dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
}
......@@ -679,8 +679,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( *text == 'X' )
{
text++;
dcode->m_Drill.x = dcode->m_Drill.y =
KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Drill.x = KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Drill.y = dcode->m_Drill.x =
dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
}
......@@ -690,8 +690,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( *text == 'X' )
{
text++;
dcode->m_Drill.y =
KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_Drill.y = KiROUND( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = APT_DEF_RECT_HOLE;
}
dcode->m_Defined = true;
......
......@@ -35,19 +35,7 @@
#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
#include <convert_to_biu.h>
/**
......@@ -62,16 +50,27 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue );
/**
* Function CoordinateToString
* is a helper to convert the integer coordinate \a aValue to a string in inches,
* is a helper to convert the \a integer coordinate \a aValue to a string in inches,
* millimeters, or unscaled units according to the current user units setting.
*
* @param aValue The coordinate to convert.
* @param aValue The integer coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters.
* @return The converted string for display in user interface elements.
*/
wxString CoordinateToString( int aValue, bool aConvertToMils = false );
/**
* Function LenghtDoubleToString
* is a helper to convert the \a double length \a aValue to a string in inches,
* millimeters, or unscaled units according to the current user units setting.
*
* @param aValue The double value to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters.
* @return The converted string for display in user interface elements.
*/
wxString LengthDoubleToString( double aValue, bool aConvertToMils = false );
/**
* Function ReturnStringFromValue
......@@ -84,6 +83,16 @@ wxString CoordinateToString( int aValue, bool aConvertToMils = false );
*/
wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol = false );
/**
* Operator << overload
* outputs a point to the argument string in a format resembling
* "@ (x,y)
* @param aString Where to put the text describing the point value
* @param aPoint The point to output.
* @return wxString& - the input string
*/
wxString& operator <<( wxString& aString, const wxPoint& aPoint );
/**
* Function PutValueInLocalUnits
* converts \a aValue from internal units to user units and append the units notation
......
......@@ -276,16 +276,22 @@ public:
/**
* Function SetScalingFactor
* @param aScale = the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor()
* sets the scaling factor of "device units per logical unit".
* If the output device is a screen, then "device units" are pixels. The
* "logical unit" is wx terminology, and corresponds to KiCad's "Internal Unit (IU)".
*
* Another way of thinking of scaling factor, when applied to a screen,
* is "pixelsPerIU".
* @param aScale = the the current scale used to draw items onto the device context wxDC.
* device coordinates (pixels) = IU coordinates * GetScalingFactor()
*/
void SetScalingFactor( double aScale );
/**
* Function GetZoom
* returns the
* @return the current zoom factor
* Note: the zoom factor is NOT the scaling factor
* the scaling factor is m_ZoomScalar * GetZoom()
*/
double GetZoom() const;
......@@ -420,7 +426,7 @@ public:
void ClearBlockCommand() { m_BlockLocate.Clear(); }
wxPoint GetScrollCenterPosition() const { return m_scrollCenter; }
const wxPoint& GetScrollCenterPosition() const { return m_scrollCenter; }
void SetScrollCenterPosition( const wxPoint& aCenterPosition )
{
m_scrollCenter = aCenterPosition;
......
......@@ -39,6 +39,7 @@
#include <wx/fileconf.h>
#include <richio.h>
#include <convert_to_biu.h>
#if !wxUSE_PRINTING_ARCHITECTURE && !SWIG
# error "You must use '--enable-printarch' in your wx library configuration."
......@@ -127,11 +128,24 @@ enum pseudokeys {
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
#if !defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
/// KiROUND: a function so v is not evaluated twice. Unfortunately, compiler
/// is unable to pre-compute constants using this.
static inline int KiROUND( double v )
{
return int( v < 0 ? v - 0.5 : v + 0.5 );
}
/// KIROUND: a macro so compiler can pre-compute constants. Use this with compile
/// time constants rather than the inline function above.
#define KIROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#else
static inline int KiRound( double v, int line, const char* filename )
// DEBUG: KiROUND() is a macro to capture line and file, then calls this inline
static inline int kiRound_( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
......@@ -145,13 +159,10 @@ static inline int KiRound( double v, int line, const char* filename )
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) kiRound_( v, __LINE__, __FILE__ )
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
// in Debug build, use the overflow catcher since code size is immaterial
#define KIROUND( v ) KiROUND( v )
#endif
......@@ -286,18 +297,9 @@ public:
// Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
// and either deci-mils or nanometers in PCBNew.
#if defined(PCBNEW)
# if defined(KICAD_NANOMETRE)
int GetWidthIU() const { return 25400 * GetWidthMils(); }
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(); }
#if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW)
int GetWidthIU() const { return IU_PER_MILS * GetWidthMils(); }
int GetHeightIU() const { return IU_PER_MILS * GetHeightMils(); }
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
#endif
......@@ -539,17 +541,6 @@ private:
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
/**
* Operator << overload
* outputs a point to the argument string in a format resembling
* "@ (x,y)
* @param aString Where to put the text describing the point value
* @param aPoint The point to output.
* @return wxString& - the input string
*/
wxString& operator <<( wxString& aString, const wxPoint& aPoint );
/**
* Function ProcessExecute
* runs a child process.
......@@ -581,14 +572,6 @@ int GetCommandOptions( const int argc, const char** argv,
const char* stringtst, const char** optarg,
int* optind );
/* Returns to display the value of a parameter, by type of units selected
* Input: value in mils, buffer text
* Returns to buffer: text: value expressed in inches or millimeters
* Followed by " or mm
*/
const wxString& valeur_param( int valeur, wxString& buf_texte );
/**
* Returns the units symbol.
*
......
......@@ -9,20 +9,37 @@
/**
* @brief inline convert functions to convert a value in decimils (or mils)
* to the internal unit used in pcbnew or cvpcb(nanometer or decimil)
* @brief some define and functions to convert a value in mils, decimils or mm
* to the internal unit used in pcbnew, cvpcb or gerbview (nanometer or decimil)
* 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 IU_PER_MM 1e5 // Gerbview uses 10 micrometer.
#else
#define IU_PER_MM 1e6 // Pcbnew uses nanometers.
#endif
#define IU_PER_MILS ( IU_PER_MM * 0.0254 )
#define IU_PER_DECIMILS (IU_PER_MM * 0.00254 )
#else // Pcbnew in deci-mils.
#define IU_PER_DECIMILS 1
#define IU_PER_MILS 10.0
#define IU_PER_MM (1e4 / 25.4)
#endif
/// Convert mils to PCBNEW internal units (iu).
inline int Mils2iu( int mils )
{
#if defined( USE_PCBNEW_NANOMETRES )
double x = mils * 25.4e3;
double x = mils * IU_PER_MILS;
return int( x < 0 ? x - 0.5 : x + 0.5 );
#else
return mils * 10;
return mils * IU_PER_MILS;
#endif
}
......@@ -30,14 +47,17 @@ inline int Mils2iu( int mils )
inline int DMils2iu( int dmils )
{
#if defined( USE_PCBNEW_NANOMETRES )
double x = dmils * 25.4e2;
double x = dmils * IU_PER_DECIMILS;
return int( x < 0 ? x - 0.5 : x + 0.5 );
#else
return dmils;
#endif
}
#elif defined(EESCHEMA)
#else // Eeschema and anything else.
#define IU_PER_MILS 1.0
#define IU_PER_MM (IU_PER_MILS / 0.0254)
inline int Mils2iu( int mils )
{
return mils;
......
......@@ -29,9 +29,6 @@
#define M_PI 3.141592653
#endif
#define PCB_INTERNAL_UNIT 10000 // PCBNEW internal unit = 1/10000 inch
#define EESCHEMA_INTERNAL_UNIT 1000 // EESCHEMA internal unit = 1/1000 inch
#ifdef __WINDOWS__
#define DIR_SEP '\\'
#define STRING_DIR_SEP wxT( "\\" )
......
This diff is collapsed.
......@@ -647,6 +647,11 @@ public:
*/
void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
/**
* Function Zoom_Automatique
* redraws the screen with best zoom level and the best centering
* that shows all the page or the board
*/
void Zoom_Automatique( bool aWarpPointer );
/* Set the zoom level to show the area Rect */
......@@ -836,7 +841,7 @@ public:
/**
* Function CoordinateToString
* is a helper to convert the integer coordinate \a aValue to a string in inches or mm
* is a helper to convert the \a integer coordinate \a aValue to a string in inches or mm
* according to the current user units setting.
* @param aValue The coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
......@@ -845,6 +850,17 @@ public:
*/
wxString CoordinateToString( int aValue, bool aConvertToMils = false );
/**
* Function LengthDoubleToString
* is a helper to convert the \a double value \a aValue to a string in inches or mm
* according to the current user units setting.
* @param aValue The coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters.
* @return The converted string for display in user interface elements.
*/
wxString LengthDoubleToString( double aValue, bool aConvertToMils = false );
DECLARE_EVENT_TABLE()
};
......
......@@ -222,7 +222,10 @@ set(PCBNEW_SRCS ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS})
###
# 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
)
##
# Scripting sources
......@@ -299,7 +302,7 @@ if (KICAD_SCRIPTING_MODULES)
SET(CMAKE_SWIG_FLAGS ${SWIG_FLAGS})
SET_SOURCE_FILES_PROPERTIES(scripting/pcbnew.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_MODULE(pcbnew python scripting/pcbnew.i ${PCBNEW_SCRIPTING_PYTHON_HELPERS} ${PCBNEW_SRCS})
SWIG_ADD_MODULE(pcbnew python scripting/pcbnew.i ${PCBNEW_SCRIPTING_PYTHON_HELPERS} ${PCBNEW_SRCS} ${PCBNEW_COMMON_SRCS})
SWIG_LINK_LIBRARIES(pcbnew
3d-viewer
pcbcommon
......
......@@ -810,8 +810,12 @@ void PCB_BASE_FRAME::updateZoomSelectBox()
{
msg = _( "Zoom " );
wxString value;
value.Printf( wxT( "%g" ), GetScreen()->m_ZoomList[i]);
wxString value = wxString::Format( wxT( "%g" ),
// @todo could do scaling here and show a "percentage"
GetScreen()->m_ZoomList[i]
);
msg += value;
m_zoomSelectBox->Append( msg );
......@@ -821,6 +825,7 @@ void PCB_BASE_FRAME::updateZoomSelectBox()
}
}
/* Function GetActiveViewerFrame
* return a reference to the current Module Viewer Frame if exists
* if called from the PCB editor, this is the m_ModuleViewerFrame
......
......@@ -41,6 +41,7 @@
#include <class_board.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <base_units.h>
DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
......@@ -344,7 +345,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
if( !aDoNotChangeText )
{
m_Value = mesure;
valeur_param( m_Value, msg );
msg = ::CoordinateToString( m_Value );
SetText( msg );
}
}
......
......@@ -47,6 +47,7 @@
#include <class_board.h>
#include <class_module.h>
#include <class_drawsegment.h>
#include <base_units.h>
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) :
......@@ -373,7 +374,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Layer" ), board->GetLayerName( m_Layer ), DARKBROWN );
valeur_param( (unsigned) m_Width, msg );
msg = frame->CoordinateToString( m_Width );
frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN );
}
......@@ -527,12 +528,11 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect ) const
wxString DRAWSEGMENT::GetSelectMenuText() const
{
wxString text;
wxString temp;
wxString temp = ::LengthDoubleToString( GetLength() );
text.Printf( _( "Pcb Graphic: %s length: %s on %s" ),
GetChars( ShowShape( (STROKE_T) m_Shape ) ),
GetChars( valeur_param( GetLength(), temp ) ),
GetChars( GetLayerName() ) );
GetChars( temp ), GetChars( GetLayerName() ) );
return text;
}
......
......@@ -32,6 +32,7 @@
#include <pcbnew.h>
#include <drc_stuff.h>
#include <class_drc_item.h>
#include <base_units.h>
wxString DRC_ITEM::GetErrorText() const
......
......@@ -255,7 +255,7 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ), RED );
frame->AppendMsgPanel( _( "Seg Layer" ), board->GetLayerName( GetLayer() ), RED );
valeur_param( m_Width, msg );
msg = frame->CoordinateToString( m_Width );
frame->AppendMsgPanel( _( "Width" ), msg, BLUE );
}
......
......@@ -42,6 +42,7 @@
#include <class_board.h>
#include <class_mire.h>
#include <base_units.h>
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
......@@ -210,7 +211,7 @@ wxString PCB_TARGET::GetSelectMenuText() const
wxString text;
wxString msg;
valeur_param( m_Size, msg );
msg = ::CoordinateToString( m_Size );
text.Printf( _( "Target on %s size %s" ),
GetChars( GetLayerName() ), GetChars( msg ) );
......
......@@ -612,13 +612,13 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( ShowPadShape(), ShowPadAttr(), DARKGREEN );
valeur_param( m_Size.x, Line );
Line = frame->CoordinateToString( m_Size.x );
frame->AppendMsgPanel( _( "H Size" ), Line, RED );
valeur_param( m_Size.y, Line );
Line = frame->CoordinateToString( m_Size.y );
frame->AppendMsgPanel( _( "V Size" ), Line, RED );
valeur_param( (unsigned) m_Drill.x, Line );
Line = frame->CoordinateToString( (unsigned) m_Drill.x );
if( m_DrillShape == PAD_CIRCLE )
{
......@@ -626,9 +626,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
}
else
{
valeur_param( (unsigned) m_Drill.x, Line );
Line = frame->CoordinateToString( (unsigned) m_Drill.x );
wxString msg;
valeur_param( (unsigned) m_Drill.y, msg );
Line = frame->CoordinateToString( (unsigned) m_Drill.y );
Line += wxT( " / " ) + msg;
frame->AppendMsgPanel( _( "Drill X / Y" ), Line, RED );
}
......@@ -644,15 +644,15 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Orient" ), Line, LIGHTBLUE );
valeur_param( m_Pos.x, Line );
Line = frame->CoordinateToString( m_Pos.x );
frame->AppendMsgPanel( _( "X Pos" ), Line, LIGHTBLUE );
valeur_param( m_Pos.y, Line );
Line = frame->CoordinateToString( m_Pos.y );
frame->AppendMsgPanel( _( "Y pos" ), Line, LIGHTBLUE );
if( GetDieLength() )
{
valeur_param( GetDieLength(), Line );
Line = frame->CoordinateToString( GetDieLength() );
frame->AppendMsgPanel( _( "Length on die" ), Line, CYAN );
}
}
......
......@@ -138,13 +138,13 @@ void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame )
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 );
frame->AppendMsgPanel( _( "Orientation" ), msg, DARKGREEN );
valeur_param( m_Thickness, msg );
msg = frame->CoordinateToString( m_Thickness );
frame->AppendMsgPanel( _( "Thickness" ), msg, MAGENTA );
valeur_param( m_Size.x, msg );
msg = frame->CoordinateToString( m_Size.x );
frame->AppendMsgPanel( _( "Size X" ), msg, RED );
valeur_param( m_Size.y, msg );
msg = frame->CoordinateToString( m_Size.y );
frame->AppendMsgPanel( _( "Size Y" ), msg, RED );
}
......
......@@ -405,13 +405,13 @@ void TEXTE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 );
frame->AppendMsgPanel( _( "Orient" ), msg, DARKGREEN );
valeur_param( m_Thickness, msg );
msg = frame->CoordinateToString( m_Thickness );
frame->AppendMsgPanel( _( "Thickness" ), msg, DARKGREEN );
valeur_param( m_Size.x, msg );
msg = frame->CoordinateToString( m_Size.x );
frame->AppendMsgPanel( _( "H Size" ), msg, RED );
valeur_param( m_Size.y, msg );
msg = frame->CoordinateToString( m_Size.y );
frame->AppendMsgPanel( _( "V Size" ), msg, RED );
}
......
......@@ -46,6 +46,7 @@
#include <pcbnew.h>
#include <protos.h>
#include <base_units.h>
/**
* Function ShowClearance
......@@ -138,10 +139,7 @@ EDA_ITEM* TRACK::Clone() const
wxString TRACK::ShowWidth() const
{
wxString msg;
valeur_param( m_Width, msg );
wxString msg = ::CoordinateToString( m_Width );
return msg;
}
......@@ -1173,7 +1171,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
// Display segment length
if( Type() != PCB_VIA_T ) // Display Diam and Drill values
{
msg = frame->CoordinateToString( KiROUND( GetLength() ) );
msg = frame->LengthDoubleToString( GetLength() );
frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN );
}
}
......@@ -1553,7 +1551,7 @@ wxString TRACK::GetSelectMenuText() const
}
text << _( " on " ) << GetLayerName() << wxT(" ") << _("Net:") << GetNet()
<< wxT(" ") << _("Length:") << valeur_param( GetLength(), temp );
<< wxT(" ") << _("Length:") << ::LengthDoubleToString( GetLength() );
return text;
}
......
......@@ -19,15 +19,11 @@
#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
#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS )
#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\
x * IU_PER_DECIMILS )
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
x * IU_PER_MM )
/**
......@@ -42,6 +38,12 @@
*/
static const double pcbZoomList[] =
{
#if defined( USE_PCBNEW_NANOMETRES )
ZOOM_FACTOR( 0.1 ),
ZOOM_FACTOR( 0.2 ),
ZOOM_FACTOR( 0.3 ),
#endif
ZOOM_FACTOR( 0.5 ),
ZOOM_FACTOR( 1.0 ),
ZOOM_FACTOR( 1.5 ),
......@@ -57,10 +59,14 @@ static const double pcbZoomList[] =
ZOOM_FACTOR( 80.0 ),
ZOOM_FACTOR( 120.0 ),
ZOOM_FACTOR( 200.0 ),
ZOOM_FACTOR( 350.0 ),
ZOOM_FACTOR( 300.0 ),
#if !defined( USE_PCBNEW_NANOMETRES )
ZOOM_FACTOR( 500.0 ),
ZOOM_FACTOR( 1000.0 ),
ZOOM_FACTOR( 2000.0 )
#endif
};
......@@ -98,6 +104,8 @@ static GRID_TYPE pcbGridList[] =
PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) :
BASE_SCREEN( SCREEN_T )
{
wxSize displayz = wxGetDisplaySize();
for( unsigned i = 0; i < DIM( pcbZoomList ); ++i )
m_ZoomList.Add( pcbZoomList[i] );
......@@ -111,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_BOTTOM = LAYER_N_BACK;
SetZoom( ZOOM_FACTOR( 150 ) ); // a default value for zoom
SetZoom( ZOOM_FACTOR( 120 ) ); // a default value for zoom
InitDataPoints( aPageSizeIU );
}
......@@ -125,11 +133,7 @@ PCB_SCREEN::~PCB_SCREEN()
int PCB_SCREEN::MilsToIuScalar()
{
#if defined( USE_PCBNEW_NANOMETRES )
return 25400;
#else
return 10;
#endif
return (int)IU_PER_MILS;
}
......
......@@ -271,7 +271,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, MILS_TO_IU_SCALAR );
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, IU_PER_MILS );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color;
......
......@@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
trackLen += track->GetLength();
valeur_param( KiROUND( trackLen ), msg );
msg = frame->LengthDoubleToString( trackLen );
frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
if( lenDie != 0 ) // display the track len on board and the actual track len
{
frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
valeur_param( KiROUND( trackLen+lenDie ), msg );
msg = frame->LengthDoubleToString( trackLen+lenDie );
frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN );
}
......
......@@ -2682,7 +2682,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// conversion factor for saving RAM BIUs to KICAD legacy file format.
#if defined( USE_PCBNEW_NANOMETRES )
biuToDisk = 1/1000000.0; // BIUs are nanometers & file is mm
biuToDisk = 1/IU_PER_MM; // BIUs are nanometers & file is mm
#else
biuToDisk = 1.0; // BIUs are deci-mils
#endif
......@@ -2694,11 +2694,8 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// then, during the file loading process, to start a conversion from
// mm to nanometers.
#if defined( USE_PCBNEW_NANOMETRES )
diskToBiu = 2540.0; // BIUs are nanometers
#else
diskToBiu = 1.0; // BIUs are deci-mils
#endif
diskToBiu = IU_PER_DECIMILS; // BIUs are nanometers if USE_PCBNEW_NANOMETRES
// or BIUs are deci-mils
}
......
/*
* 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@ujf-grenoble.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -180,12 +180,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( userscale == 0 ) // fit in page
{
// Margin = 0.4 inch
#if defined(KICAD_NANOMETRE)
int extra_margin = int( 0.4 * 25400 ); // nanometers
#else
int extra_margin = int( 0.4 * 1000 ); // deci-mils
#endif
// Margin = 10mm
int extra_margin = int( 10 * IU_PER_MM ); // deci-mils
pageSizeIU.x = bbbox.GetWidth() + extra_margin * 2;
pageSizeIU.y = bbbox.GetHeight() + extra_margin * 2;
......@@ -216,8 +212,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
MapScreenSizeToPaper();
int w, h;
GetPPIPrinter( &w, &h );
double accurate_Xscale = ( (double) ( DrawZoom * w ) ) / (double) PCB_INTERNAL_UNIT;
double accurate_Yscale = ( (double) ( DrawZoom * h ) ) / (double) PCB_INTERNAL_UNIT;
double accurate_Xscale = ( (double) ( DrawZoom * w ) ) / (IU_PER_MILS*1000);
double accurate_Yscale = ( (double) ( DrawZoom * h ) ) / (IU_PER_MILS*1000);
if( IsPreview() ) // Scale must take in account the DC size in Preview
{
......@@ -278,7 +274,8 @@ 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, MILS_TO_IU_SCALAR );
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS );
if( printMirror )
{
......@@ -320,7 +317,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
/* when printing in color mode, we use the graphic OR mode that gives the same look as the screen
* But because the background is white when printing, we must use a trick:
* In order to plot on a white background in OR mode we must:
* 1 - Plot all items in black, this creates a local black backgroud
* 1 - Plot all items in black, this creates a local black background
* 2 - Plot in OR mode on black "local" background
*/
if( !m_PrintParams.m_Print_Black_and_White )
......
......@@ -52,7 +52,7 @@
if type(itemC) is D_PAD:
item.thisown=0
self.m_Pads.PushBack(itemC)
elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE, DRAWSEGMENT]:
elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE, DRAWSEGMENT,EDGE_MODULE]:
item.thisown = 0
self.m_Drawings.PushBack(item)
}
......
......@@ -73,7 +73,9 @@
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <layers_id_colors_and_visibility.h>
#include <class_pad.h>
#include <pad_shapes.h>
#include <class_netinfo.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
......@@ -85,7 +87,6 @@
#include <class_zone_settings.h>
#include <class_netclass.h>
#include <class_netinfo.h>
#include <layers_id_colors_and_visibility.h>
#include <pcbnew_scripting_helpers.h>
......@@ -104,7 +105,9 @@
%include <class_board.h>
%include <class_module.h>
%include <class_track.h>
%include <layers_id_colors_and_visibility.h>
%include <class_pad.h>
%include <pad_shapes.h>
%include <class_netinfo.h>
%include <class_pcb_text.h>
%include <class_dimension.h>
......@@ -116,7 +119,6 @@
%include <class_zone_settings.h>
%include <class_netclass.h>
%include <class_netinfo.h>
%include <layers_id_colors_and_visibility.h>
%include "board_item.i"
......
......@@ -48,6 +48,7 @@
#include <class_track.h>
#include <class_zone.h>
#include <class_drawsegment.h>
#include <base_units.h>
#include <collectors.h>
......@@ -99,7 +100,7 @@ void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event )
wxString errorText;
BASE_SCREEN* screen = GetScreen();
bool wasModified = screen->IsModify() && !screen->IsSave();
bool wasModified = screen->IsModify();
db.SetPCB( SPECCTRA_DB::MakePCB() );
......@@ -171,10 +172,10 @@ static inline double scale( int kicadDist )
#if defined(USE_PCBNEW_NANOMETRES)
// nanometers to um
return kicadDist / 1000.0;
return kicadDist / ( IU_PER_MM / 1000.0 );
// nanometers to mils
// return kicadDist/25400.0;
// return kicadDist/IU_PER_MILS;
#else
// deci-mils to mils.
......@@ -185,11 +186,7 @@ static inline double scale( int kicadDist )
/// Convert integer internal units to float um
static inline double IU2um( int kicadDist )
{
#if defined(USE_PCBNEW_NANOMETRES)
return kicadDist / 1000.0;
#else
return kicadDist * 25.4e-1;
#endif
return kicadDist * (1000.0 / IU_PER_MM);
}
......
......@@ -67,7 +67,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode( DC, GR_COPY );
m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0, MILS_TO_IU_SCALAR );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS );
// Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
......@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, MILS_TO_IU_SCALAR );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS );
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<
else
{
// style is ARC_CW or ARC_CCW
int n; // number of steps for arcs
n = ( abs( x2 - x1 ) + abs( y2 - y1 ) ) / (CArc::MAX_STEP);
n = MAX( n, CArc::MIN_STEPS ); // or at most 5 degrees of arc
int n = CArc::ARC_STEPS;
n_vertices += n;
n_arcs++;
}
......@@ -392,8 +390,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
{
// style is arc_cw or arc_ccw
int n; // number of steps for arcs
n = ( abs( x2 - x1 ) + abs( y2 - y1 ) ) / (CArc::MAX_STEP);
n = MAX( n, CArc::MIN_STEPS ); // or at most 5 degrees of arc
n = CArc::ARC_STEPS;
double xo, yo, theta1, theta2, a, b;
a = fabs( (double) (x1 - x2) );
b = fabs( (double) (y1 - y2) );
......
......@@ -77,8 +77,7 @@ public:
class CArc
{
public:
enum { MAX_STEP = 50 * 25400 }; // max step is 20 mils
enum { MIN_STEPS = 18 }; // min step is 5 degrees
enum { ARC_STEPS = 16 }; // arc approximation step is 16 segm / 90 degres
int style;
int xi, yi, xf, yf;
int n_steps; // number of straight-line segments in gpc_poly
......
......@@ -12,6 +12,14 @@
#define NM_PER_MIL 25400
double Distance( double x1, double y1, double x2, double y2 )
{
double dx = x1 - x2;
double dy = y1 - y2;
double d = sqrt( dx * dx + dy * dy );
return d;
}
/**
* Function TestLineHit
......@@ -1031,7 +1039,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
y2 = el2.Center.Y + el2.yrad* sin( s2 );
}
double d = Distance( (int) x, (int) y, (int) x2, (int) y2 );
double d = Distance( x, y, x2, y2 );
if( d < dmin )
{
......@@ -1101,7 +1109,7 @@ double GetPointToLineDistance( double a, double b, int x, int y, double* xpp, do
}
// find distance
return Distance( x, y, (int) xp, (int) yp );
return Distance( x, y, xp, yp );
}
......@@ -1151,7 +1159,7 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
// find distance
if( InRange( xp, xi, xf ) && InRange( yp, yi, yf ) )
return Distance( x, y, (int) xp, (int) yp );
return Distance( x, y, xp, yp );
else
return min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
}
......@@ -1177,26 +1185,6 @@ bool InRange( double x, double xi, double xf )
}
// Get distance between 2 points
//
double Distance( int x1, int y1, int x2, int y2 )
{
double dx = x1 - x2;
double dy = y1 - y2;
double d = sqrt( dx * dx + dy * dy );
if( d > INT_MAX || d < INT_MIN )
{
wxASSERT( 0 );
}
// wxASSERT( d <= INT_MAX && d >= INT_MIN );
return int( d );
}
// this finds approximate solutions
// note: this works best if el2 is smaller than el1
//
......@@ -1368,7 +1356,7 @@ double GetArcClearance( EllipseKH* el1, EllipseKH* el2,
double x2 = el2->Center.X + el2->xrad * cos( theta2 );
double y2 = el2->Center.Y + el2->yrad * sin( theta2 );
double d = Distance( (int) x, (int) y, (int) x2, (int) y2 );
double d = Distance( x, y, x2, y2 );
if( d < dmin )
{
......
......@@ -71,7 +71,9 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
double GetPointToLineDistance( double a, double b, int x, int y, double * xp=NULL, double * yp=NULL );
bool InRange( double x, double xi, double xf );
double Distance( int x1, int y1, int x2, int y2 );
double Distance( double x1, double y1, double x2, double y2 );
int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
double * x1=NULL, double * y1=NULL,
double * x2=NULL, double * y2=NULL );
......
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