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

Merged to testing, needs some fixes

parents 42fad8a7 a9d1f478
......@@ -362,9 +362,9 @@ void EDA_3D_FRAME::Set3DBgColor()
S3D_Color color;
wxColour newcolor, oldcolor;
oldcolor.Set( wxRound( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
wxRound( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
newcolor = wxGetColourFromUser( this, oldcolor );
......
......@@ -23,8 +23,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option(USE_PCBNEW_SEXPR_FILE_FORMAT
"Use s-expression Pcbnew file format support (default OFF)." )
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" ON)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" ON)
option(USE_PCBNEW_NANOMETRES
"Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).")
......
......@@ -55,8 +55,6 @@
#cmakedefine USE_IMAGES_IN_MENUS 1
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANOMETRES
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT
......
......@@ -62,16 +62,11 @@ Dick's Peronal TODO Items (Last Update: 5-April-2012)
*) 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.
A problem remain with BASE_SCREEN
One final problem remains with BASE_SCREEN's grid origin, easy solution is to
move just that one field into the BOARD.
2) Extend PLUGIN API to facillitate loading and saving of modules.
3) Switch to PLUGIN, kill off ioascii.cpp and item_io.cpp, deleting them.
4) Check back with Vladimir about finishing the nanometer work.
5) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
2) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
This is PLUGIN::Load() and maybe PLUGIN::Save().
6) Get back to the SWEET work.
3) Get back to the SWEET work.
......@@ -116,21 +116,13 @@ set(PCB_COMMON_SRCS
../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.cpp
dialogs/dialog_page_settings.cpp
)
if( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
set( PCB_COMMON_SRCS
${PCB_COMMON_SRCS}
../pcbnew/item_io.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
)
else()
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp )
endif()
# add -DPCBNEW to compilation of these PCBNEW sources
set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
......
......@@ -33,6 +33,7 @@
#include <base_struct.h>
#include <class_base_screen.h>
#include <id.h>
#include <base_units.h>
#define CURSOR_SIZE 12 /// size of the cross cursor.
......@@ -86,12 +87,6 @@ void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
}
int BASE_SCREEN::GetInternalUnits( void )
{
return EESCHEMA_INTERNAL_UNIT;
}
double BASE_SCREEN::GetScalingFactor() const
{
double scale = 1.0 / GetZoom();
......@@ -99,7 +94,7 @@ double BASE_SCREEN::GetScalingFactor() const
}
void BASE_SCREEN::SetScalingFactor(double aScale )
void BASE_SCREEN::SetScalingFactor( double aScale )
{
double zoom = aScale;
......@@ -116,15 +111,6 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
}
void BASE_SCREEN::SetZoomList( const wxArrayDouble& zoomlist )
{
if( !m_ZoomList.IsEmpty() )
m_ZoomList.Empty();
m_ZoomList = zoomlist;
}
bool BASE_SCREEN::SetFirstZoom()
{
if( m_ZoomList.IsEmpty() )
......@@ -164,12 +150,10 @@ bool BASE_SCREEN::SetZoom( double coeff )
bool BASE_SCREEN::SetNextZoom()
{
size_t i;
if( m_ZoomList.IsEmpty() || m_Zoom >= m_ZoomList.Last() )
return false;
for( i = 0; i < m_ZoomList.GetCount(); i++ )
for( unsigned i = 0; i < m_ZoomList.GetCount(); i++ )
{
if( m_Zoom < m_ZoomList[i] )
{
......@@ -320,30 +304,14 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id )
{
double x, y;
wxRealPoint new_size;
GRID_TYPE new_grid;
switch( aUnit )
{
case MILLIMETRES:
x = size.x / 25.4;
y = size.y / 25.4;
break;
default:
case INCHES:
case UNSCALED_UNITS:
x = size.x;
y = size.y;
break;
}
new_size.x = x * GetInternalUnits();
new_size.y = y * GetInternalUnits();
new_size.x = From_User_Unit( aUnit, size.x );
new_size.y = From_User_Unit( aUnit, size.y );
new_grid.m_Id = id;
new_grid.m_Size = new_size;
AddGrid( new_grid );
}
......@@ -394,12 +362,12 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoi
wxPoint gridOrigin = m_GridOrigin;
double offset = fmod( gridOrigin.x, gridSize.x );
int x = wxRound( (aPosition.x - offset) / gridSize.x );
pt.x = wxRound( x * gridSize.x + offset );
int x = KiROUND( (aPosition.x - offset) / gridSize.x );
pt.x = KiROUND( x * gridSize.x + offset );
offset = fmod( gridOrigin.y, gridSize.y );
int y = wxRound( (aPosition.y - offset) / gridSize.y );
pt.y = wxRound ( y * gridSize.y + offset );
int y = KiROUND( (aPosition.y - offset) / gridSize.y );
pt.y = KiROUND ( y * gridSize.y + offset );
return pt;
}
......@@ -419,8 +387,8 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
wxPoint pos = m_crossHairPosition - m_DrawOrg;
double scalar = GetScalingFactor();
pos.x = wxRound( (double) pos.x * scalar );
pos.y = wxRound( (double) pos.y * scalar );
pos.x = KiROUND( (double) pos.x * scalar );
pos.y = KiROUND( (double) pos.y * scalar );
return pos;
}
......
......@@ -344,11 +344,11 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const
// calculate the left common area coordinate:
int left = MAX( me.m_Pos.x, rect.m_Pos.x );
// calculate the right common area coordinate:
int right = MIN( me.m_Pos.x + m_Size.x, rect.m_Pos.x + rect.m_Size.x );
int right = MIN( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
// calculate the upper common area coordinate:
int top = MAX( me.m_Pos.y, aRect.m_Pos.y );
// calculate the lower common area coordinate:
int bottom = MIN( me.m_Pos.y + m_Size.y, rect.m_Pos.y + rect.m_Size.y );
int bottom = MIN( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
// if a common area exists, it must have a positive (null accepted) size
if( left <= right && top <= bottom )
......
......@@ -44,13 +44,19 @@
#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 )
#else
#error "Cannot resolve internal units due to no definition of EESCHEMA or PCBNEW."
#endif
......@@ -159,3 +165,99 @@ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue )
aTextCtr.SetValue( msg );
}
double From_User_Unit( EDA_UNITS_T aUnit, double aValue )
{
double value;
switch( aUnit )
{
case MILLIMETRES:
value = MM_TO_IU( aValue );
break;
case INCHES:
value = IN_TO_IU( aValue );
break;
default:
case UNSCALED_UNITS:
value = aValue;
}
return value;
}
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
int Value;
double dtmp = 0;
// Acquire the 'right' decimal point separator
const struct lconv* lc = localeconv();
wxChar decimal_point = lc->decimal_point[0];
wxString buf( aTextValue.Strip( wxString::both ) );
// Convert the period in decimal point
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
// back to a point as separator, although the separator is the comma
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
// Find the end of the numeric part
unsigned brk_point = 0;
while( brk_point < buf.Len() )
{
wxChar ch = buf[brk_point];
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
{
break;
}
++brk_point;
}
// Extract the numeric part
buf.Left( brk_point ).ToDouble( &dtmp );
// Check the optional unit designator (2 ch significant)
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnits = INCHES;
}
else if( unit == wxT( "mm" ) )
{
aUnits = MILLIMETRES;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
{
aUnits = INCHES;
dtmp /= 1000;
}
Value = From_User_Unit( aUnits, dtmp );
return Value;
}
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
{
int value;
wxString msg = aTextCtr.GetValue();
value = ReturnValueFromString( g_UserUnit, msg );
return value;
}
......@@ -197,8 +197,8 @@ void BITMAP_BASE::DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(),
logicalOriginY / GetScalingFactor() );
aDC->DrawBitmap( *m_bitmap,
wxRound( pos.x / GetScalingFactor() ),
wxRound( pos.y / GetScalingFactor() ),
KiROUND( pos.x / GetScalingFactor() ),
KiROUND( pos.y / GetScalingFactor() ),
true );
aDC->SetUserScale( scale, scale );
aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
......@@ -217,8 +217,8 @@ wxSize BITMAP_BASE::GetSize() const
size.x = m_bitmap->GetWidth();
size.y = m_bitmap->GetHeight();
size.x = wxRound( size.x * GetScalingFactor() );
size.y = wxRound( size.y * GetScalingFactor() );
size.x = KiROUND( size.x * GetScalingFactor() );
size.y = KiROUND( size.y * GetScalingFactor() );
}
return size;
......
......@@ -98,7 +98,7 @@ double PLOTTER::user_to_device_size( double size )
void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill )
{
int radius = wxRound( diametre / 2.8284 );
int radius = KiROUND( diametre / 2.8284 );
static std::vector< wxPoint > corner_list;
corner_list.clear();
wxPoint corner;
......
......@@ -120,15 +120,17 @@ StructColors ColorRefs[NBCOLOR] =
bool g_DisableFloatingPointLocalNotation = false;
void SetLocaleTo_C_standard( void )
int LOCALE_IO::C_count;
void SetLocaleTo_C_standard()
{
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
}
void SetLocaleTo_Default( void )
void SetLocaleTo_Default()
{
if( ! g_DisableFloatingPointLocalNotation )
if( !g_DisableFloatingPointLocalNotation )
setlocale( LC_NUMERIC, "" ); // revert to the current locale
}
......@@ -253,76 +255,6 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
}
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
{
int value;
wxString msg = TextCtr.GetValue();
value = ReturnValueFromString( g_UserUnit, msg, Internal_Unit );
return value;
}
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit )
{
int Value;
double dtmp = 0;
// Acquire the 'right' decimal point separator
const struct lconv* lc = localeconv();
wxChar decimal_point = lc->decimal_point[0];
wxString buf( TextValue.Strip( wxString::both ) );
// Convert the period in decimal point
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
// back to a point as separator, although the separator is the comma
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
// Find the end of the numeric part
unsigned brk_point = 0;
while( brk_point < buf.Len() )
{
wxChar ch = buf[brk_point];
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
{
break;
}
++brk_point;
}
// Extract the numeric part
buf.Left( brk_point ).ToDouble( &dtmp );
// Check the optional unit designator (2 ch significant)
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnit = INCHES;
}
else if( unit == wxT( "mm" ) )
{
aUnit = MILLIMETRES;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
{
aUnit = INCHES;
dtmp /= 1000;
}
Value = From_User_Unit( aUnit, dtmp, Internal_Unit );
return Value;
}
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
{
wxArrayString* list = new wxArrayString();
......@@ -349,33 +281,6 @@ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
}
/*
* Return in internal units the value "val" given in inch or mm
*/
int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value )
{
double value;
switch( aUnit )
{
case MILLIMETRES:
value = val * internal_unit_value / 25.4;
break;
case INCHES:
value = val * internal_unit_value;
break;
default:
case UNSCALED_UNITS:
value = val;
}
return wxRound( value );
}
/*
* Return the string date "day month year" like "23 jun 2005"
*/
......@@ -466,7 +371,7 @@ double RoundTo0( double x, double precision )
{
assert( precision != 0 );
long long ix = wxRound( x * precision );
long long ix = KiROUND( x * precision );
if ( x < 0.0 )
NEGATE( ix );
......
......@@ -155,8 +155,8 @@ void DXF_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor
size.x = aImage.GetWidth();
size.y = aImage.GetHeight();
size.x = wxRound( size.x * aScaleFactor );
size.y = wxRound( size.y * aScaleFactor );
size.x = KiROUND( size.x * aScaleFactor );
size.y = KiROUND( size.y * aScaleFactor );
wxPoint start = aPos;
start.x -= size.x / 2;
......@@ -241,7 +241,7 @@ void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
return;
user_to_device_coordinates( centre );
radius = wxRound( user_to_device_size( radius ) );
radius = KiROUND( user_to_device_size( radius ) );
/* DXF ARC */
wxString cname = ColorRefs[current_color].m_Name;
......
......@@ -284,7 +284,7 @@ void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int a
double radius = aDiameter / 2;
const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
start.x = aCentre.x + wxRound( radius );
start.x = aCentre.x + KiROUND( radius );
start.y = aCentre.y;
set_current_line_width( aWidth );
move_to( start );
......@@ -351,8 +351,8 @@ void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFac
size.x = aImage.GetWidth();
size.y = aImage.GetHeight();
size.x = wxRound( size.x * aScaleFactor );
size.y = wxRound( size.y * aScaleFactor );
size.x = KiROUND( size.x * aScaleFactor );
size.y = KiROUND( size.y * aScaleFactor );
wxPoint start = aPos;
start.x -= size.x / 2;
......
......@@ -112,8 +112,8 @@ void HPGL_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFacto
size.x = aImage.GetWidth();
size.y = aImage.GetHeight();
size.x = wxRound( size.x * aScaleFactor );
size.y = wxRound( size.y * aScaleFactor );
size.x = KiROUND( size.x * aScaleFactor );
size.y = KiROUND( size.y * aScaleFactor );
wxPoint start = aPos;
start.x -= size.x / 2;
......@@ -285,7 +285,7 @@ void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
if( trace_mode == FILLED )
{
flash_pad_rect( pos, wxSize( size.x, deltaxy + wxRound( pen_diameter ) ),
flash_pad_rect( pos, wxSize( size.x, deltaxy + KiROUND( pen_diameter ) ),
orient, trace_mode );
cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
......@@ -298,7 +298,7 @@ void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
}
else // Plot in SKETCH mode.
{
sketch_oval( pos, size, orient, wxRound( pen_diameter ) );
sketch_oval( pos, size, orient, KiROUND( pen_diameter ) );
}
}
......@@ -313,12 +313,12 @@ void HPGL_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
user_to_device_coordinates( pos );
delta = wxRound( pen_diameter - pen_overlap );
delta = KiROUND( pen_diameter - pen_overlap );
rayon = diametre / 2;
if( trace_mode != LINE )
{
rayon = ( diametre - wxRound( pen_diameter ) ) / 2;
rayon = ( diametre - KiROUND( pen_diameter ) ) / 2;
}
if( rayon < 0 )
......@@ -483,7 +483,7 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
wxPoint coord[4]; // absolute coordinates of corners (coordinates in plotter space)
int move;
move = wxRound( pen_diameter );
move = KiROUND( pen_diameter );
for( int ii = 0; ii < 4; ii++ )
polygone[ii] = aCorners[ii];
......@@ -512,7 +512,7 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
// TODO: replace this par the HPGL plot polygon.
int jj;
// Fill the shape
move = wxRound( pen_diameter - pen_overlap );
move = KiROUND( pen_diameter - pen_overlap );
// Calculate fill height.
if( polygone[0].y == polygone[3].y ) // Horizontal
......
......@@ -160,7 +160,7 @@ void PS_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
// Calculate start point.
user_to_device_coordinates( centre );
radius = wxRound( user_to_device_size( radius ) );
radius = KiROUND( user_to_device_size( radius ) );
if( plotMirror )
fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
radius, (double) -EndAngle / 10, (double) -StAngle / 10,
......@@ -216,8 +216,8 @@ void PS_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor
pix_size.x = aImage.GetWidth();
pix_size.y = aImage.GetHeight();
wxSize drawsize; // requested size of image
drawsize.x = wxRound( aScaleFactor * pix_size.x );
drawsize.y = wxRound( aScaleFactor * pix_size.y );
drawsize.x = KiROUND( aScaleFactor * pix_size.x );
drawsize.y = KiROUND( aScaleFactor * pix_size.y );
// calculate the bottom left corner position of bitmap
wxPoint start = aPos;
......@@ -405,14 +405,14 @@ bool PS_PLOTTER::start_plot( FILE* fout )
if( pageInfo.IsCustom() )
fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
wxRound( psPageSize.x * 10 * CONV_SCALE ),
wxRound( psPageSize.y * 10 * CONV_SCALE ) );
KiROUND( psPageSize.x * 10 * CONV_SCALE ),
KiROUND( psPageSize.y * 10 * CONV_SCALE ) );
else // a standard paper size
fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
TO_UTF8( pageInfo.GetType() ),
wxRound( psPageSize.x * 10 * CONV_SCALE ),
wxRound( psPageSize.y * 10 * CONV_SCALE ) );
KiROUND( psPageSize.x * 10 * CONV_SCALE ),
KiROUND( psPageSize.y * 10 * CONV_SCALE ) );
if( pageInfo.IsPortrait() )
fprintf( output_file, "%%%%Orientation: Portrait\n" );
......
......@@ -30,9 +30,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
wxPoint pos, ref;
EDA_COLOR_T color;
// paper is sized in mils. Here is a conversion factor to
// scale mils to internal units.
int conv_unit = screen->GetInternalUnits() / 1000;
// Paper is sized in mils. Here is a conversion factor to scale mils to internal units.
int conv_unit = screen->MilsToIuScalar();
wxString msg;
wxSize text_size;
......
......@@ -72,7 +72,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
/* scale is the ratio resolution/internal units */
float scale = 82.0 / aFrame->GetInternalUnits();
float scale = 82.0 / 1000.0 / (double) screen->MilsToIuScalar();
if( screen->IsBlockActive() )
{
......
......@@ -24,6 +24,7 @@
#include <wx/filename.h>
#include <wx/image.h>
#include <macros.h>
#include <common.h>
#if wxCHECK_VERSION( 2, 9, 0 )
......@@ -186,15 +187,15 @@ KicadSVGFileDCImpl::~KicadSVGFileDCImpl()
void KicadSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const
{
if (width)
*width = wxRound( (double)m_width / m_mm_to_pix_x );
*width = KiROUND( (double)m_width / m_mm_to_pix_x );
if (height)
*height = wxRound( (double)m_height / m_mm_to_pix_y );
*height = KiROUND( (double)m_height / m_mm_to_pix_y );
}
wxSize KicadSVGFileDCImpl::GetPPI() const
{
return wxSize( wxRound(m_dpi), wxRound(m_dpi) );
return wxSize( KiROUND(m_dpi), KiROUND(m_dpi) );
}
void KicadSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
......
......@@ -26,7 +26,7 @@
*/
#include <fctsys.h>
#include <macros.h> // DIM()
#include <macros.h> // DIM()
#include <common.h>
#include <gr_basic.h>
#include <base_struct.h>
......@@ -34,6 +34,7 @@
#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>
......@@ -118,10 +119,12 @@ void DIALOG_PAGES_SETTINGS::initDialog()
// initalize page format choice box and page format list.
// The first shows translated strings, the second contains not tralated strings
m_paperSizeComboBox->Clear();
for( unsigned ii = 0; ; ii++ )
{
if( pageFmts[ii].IsEmpty() )
break;
m_pageFmt.Add( pageFmts[ii] );
m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) );
}
......@@ -137,8 +140,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()
msg.Printf( format, m_Screen->m_ScreenNumber );
m_TextSheetNumber->SetLabel( msg );
#else
m_TextSheetCount->Show(false);
m_TextSheetNumber->Show(false);
m_TextSheetCount->Show( false );
m_TextSheetNumber->Show( false );
#endif
m_pageInfo = m_Parent->GetPageSettings();
......@@ -251,10 +254,11 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
{
m_save_flag = false;
SavePageSettings( event );
if( m_save_flag )
{
m_modified = true;
Close( true );
m_modified = true;
Close( true );
}
}
......@@ -268,9 +272,12 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event )
void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
{
int idx = m_paperSizeComboBox->GetSelection();
if( idx < 0 )
idx = 0;
const wxString paperType = m_pageFmt[idx];
if( paperType.Contains( PAGE_INFO::Custom ) )
{
m_orientationComboBox->Enable( false );
......@@ -280,14 +287,17 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
else
{
m_orientationComboBox->Enable( true );
if( paperType.Contains( wxT( "A4" ) ) && IsGOST() )
{
m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
m_orientationComboBox->Enable( false );
}
}
m_TextUserSizeX->Enable( false );
m_TextUserSizeY->Enable( false );
}
GetPageLayoutInfoFromDialog();
UpdatePageLayoutExample();
}
......@@ -407,8 +417,10 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
m_save_flag = true;
int idx = m_paperSizeComboBox->GetSelection();
if( idx < 0 )
idx = 0;
const wxString paperType = m_pageFmt[idx];
if( paperType.Contains( PAGE_INFO::Custom ) )
......@@ -416,6 +428,7 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
GetCustomSizeMilsFromDialog();
retSuccess = m_pageInfo.SetType( PAGE_INFO::Custom );
if( retSuccess )
{
if( m_layout_size.x < MIN_PAGE_SIZE || m_layout_size.y < MIN_PAGE_SIZE ||
......@@ -432,6 +445,7 @@ limits\n%.1f - %.1f %s!\nSelect another custom paper size?" ),
m_save_flag = false;
return;
}
m_layout_size.x = Clamp( MIN_PAGE_SIZE, m_layout_size.x, MAX_PAGE_SIZE );
m_layout_size.y = Clamp( MIN_PAGE_SIZE, m_layout_size.y, MAX_PAGE_SIZE );
}
......@@ -580,12 +594,12 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
if( clamped_layout_size.x < clamped_layout_size.y )
{
lyHeight = MAX_PAGE_EXAMPLE_SIZE;
lyWidth = wxRound( (double) lyHeight / lyRatio );
lyWidth = KiROUND( (double) lyHeight / lyRatio );
}
else
{
lyWidth = MAX_PAGE_EXAMPLE_SIZE;
lyHeight = wxRound( (double) lyWidth / lyRatio );
lyHeight = KiROUND( (double) lyWidth / lyRatio );
}
if( m_page_bitmap )
......@@ -595,6 +609,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
}
m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
if( m_page_bitmap->IsOk() )
{
// Save current clip box and temporary expand it.
......@@ -602,7 +617,8 @@ 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 = m_Parent->GetInternalUnits() / 1000;
int appScale = MILS_TO_IU_SCALAR;
double scaleW = (double) lyWidth / clamped_layout_size.x / appScale;
double scaleH = (double) lyHeight / clamped_layout_size.y / appScale;
......@@ -630,7 +646,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
m_Parent->TraceWorkSheet( (wxDC*) &memDC, dummySize, pointLeftTop, pointRightBottom,
emptyString, emptyString, m_tb, m_Screen->m_NumberOfScreen,
m_Screen->m_ScreenNumber, 1, LIGHTGRAY, RED );
m_Screen->m_ScreenNumber, 1, appScale, LIGHTGRAY, RED );
memDC.SelectObject( wxNullBitmap );
m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap );
......@@ -648,14 +664,17 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
{
int idx = m_paperSizeComboBox->GetSelection();
if( idx < 0 )
idx = 0;
const wxString paperType = m_pageFmt[idx];
// here we assume translators will keep original paper size spellings
if( paperType.Contains( PAGE_INFO::Custom ) )
{
GetCustomSizeMilsFromDialog();
if( m_layout_size.x && m_layout_size.y )
{
if( m_layout_size.x < m_layout_size.y )
......@@ -687,6 +706,7 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
};
unsigned i;
for( i=0; i < DIM( papers ); ++i )
{
if( paperType.Contains( *papers[i] ) )
......@@ -740,5 +760,5 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog()
// Prepare to painless double -> int conversion.
customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );
customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) );
m_layout_size = wxSize( wxRound( customSizeX ), wxRound( customSizeY ) );
m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) );
}
......@@ -110,7 +110,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
m_snapToGrid = true;
// Internal units per inch: = 1000 for schema, = 10000 for PCB
m_internalUnits = EESCHEMA_INTERNAL_UNIT;
minsize.x = 470;
minsize.y = 350 + m_MsgFrameHeight;
......@@ -369,7 +368,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
else
{
id--;
int selectedZoom = GetScreen()->m_ZoomList[id];
double selectedZoom = GetScreen()->m_ZoomList[id];
if( GetScreen()->GetZoom() == selectedZoom )
return;
......@@ -516,8 +515,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
clientSize = m_canvas->GetClientSize();
// The logical size of the client window.
logicalClientSize.x = wxRound( (double) clientSize.x / scalar );
logicalClientSize.y = wxRound( (double) clientSize.y / scalar );
logicalClientSize.x = KiROUND( (double) clientSize.x / scalar );
logicalClientSize.y = KiROUND( (double) clientSize.y / scalar );
// A corner of the drawing in internal units.
wxSize corner = GetPageSizeIU();
......@@ -532,14 +531,14 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
drawingRect.GetTop(), drawingRect.GetBottom() );
// The size of the client rectangle in logical units.
int x = wxRound( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) );
int y = wxRound( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) );
int x = KiROUND( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) );
int y = KiROUND( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) );
// If drawn around the center, adjust the client rectangle accordingly.
if( screen->m_Center )
{
x += wxRound( (double) drawingRect.width / 2.0 );
y += wxRound( (double) drawingRect.height / 2.0 );
x += KiROUND( (double) drawingRect.width / 2.0 );
y += KiROUND( (double) drawingRect.height / 2.0 );
}
wxRect logicalClientRect( wxPoint( x, y ), logicalClientSize );
......@@ -575,7 +574,7 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
else
virtualSize.x = logicalClientRect.width;
}
else if( logicalClientRect.width < drawingRect.width )
else
{
if( drawingCenterX > clientCenterX )
virtualSize.x = drawingRect.width +
......@@ -586,10 +585,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
else
virtualSize.x = drawingRect.width;
}
else
{
virtualSize.x = drawingRect.width;
}
}
if( drawingRect.GetTop() < logicalClientRect.GetTop() && drawingRect.GetBottom() > logicalClientRect.GetBottom() )
......@@ -610,7 +605,7 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
else
virtualSize.y = logicalClientRect.height;
}
else if( logicalClientRect.height < drawingRect.height )
else
{
if( drawingCenterY > clientCenterY )
virtualSize.y = drawingRect.height +
......@@ -621,23 +616,19 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
else
virtualSize.y = drawingRect.height;
}
else
{
virtualSize.y = drawingRect.height;
}
}
}
if( screen->m_Center )
{
screen->m_DrawOrg.x = -( wxRound( (double) virtualSize.x / 2.0 ) );
screen->m_DrawOrg.y = -( wxRound( (double) virtualSize.y / 2.0 ) );
screen->m_DrawOrg.x = -( KiROUND( (double) virtualSize.x / 2.0 ) );
screen->m_DrawOrg.y = -( KiROUND( (double) virtualSize.y / 2.0 ) );
}
else
{
screen->m_DrawOrg.x = -( wxRound( (double) (virtualSize.x - drawingRect.width) / 2.0 ) );
screen->m_DrawOrg.y = -( wxRound( (double) (virtualSize.y - drawingRect.height) / 2.0 ) );
screen->m_DrawOrg.x = -( KiROUND( (double) (virtualSize.x - drawingRect.width) / 2.0 ) );
screen->m_DrawOrg.y = -( KiROUND( (double) (virtualSize.y - drawingRect.height) / 2.0 ) );
}
/* Always set scrollbar pixels per unit to 1 unless you want the zoom
......@@ -649,20 +640,20 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
// Calculate the number of scroll bar units for the given zoom level in device units.
unitsX = wxRound( (double) virtualSize.x * scalar );
unitsY = wxRound( (double) virtualSize.y * scalar );
unitsX = KiROUND( (double) virtualSize.x * scalar );
unitsY = KiROUND( (double) virtualSize.y * scalar );
// Calculate the scroll bar position in logical units to place the center position at
// the center of client rectangle.
screen->SetScrollCenterPosition( aCenterPosition );
posX = aCenterPosition.x - wxRound( (double) logicalClientRect.width / 2.0 ) -
posX = aCenterPosition.x - KiROUND( (double) logicalClientRect.width / 2.0 ) -
screen->m_DrawOrg.x;
posY = aCenterPosition.y - wxRound( (double) logicalClientRect.height / 2.0 ) -
posY = aCenterPosition.y - KiROUND( (double) logicalClientRect.height / 2.0 ) -
screen->m_DrawOrg.y;
// Convert scroll bar position to device units.
posX = wxRound( (double) posX * scalar );
posY = wxRound( (double) posY * scalar );
posX = KiROUND( (double) posX * scalar );
posY = KiROUND( (double) posY * scalar );
if( posX < 0 )
{
......
......@@ -405,8 +405,8 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
double scale = GetParent()->GetScreen()->GetScalingFactor();
wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
center.x += wxRound( (double) ( x - tmpX ) / scale );
center.y += wxRound( (double) ( y - tmpY ) / scale );
center.x += KiROUND( (double) ( x - tmpX ) / scale );
center.y += KiROUND( (double) ( y - tmpY ) / scale );
GetParent()->GetScreen()->SetScrollCenterPosition( center );
Scroll( x, y );
......@@ -432,8 +432,8 @@ void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect )
int scrollX, scrollY;
double scalar = Screen->GetScalingFactor();
scrollX = wxRound( Screen->GetGridSize().x * scalar );
scrollY = wxRound( Screen->GetGridSize().y * scalar );
scrollX = KiROUND( Screen->GetGridSize().x * scalar );
scrollY = KiROUND( Screen->GetGridSize().y * scalar );
m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
......@@ -599,8 +599,8 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
screenSize = GetClientSize();
screenGridSize.x = aDC->LogicalToDeviceXRel( wxRound( gridSize.x ) );
screenGridSize.y = aDC->LogicalToDeviceYRel( wxRound( gridSize.y ) );
screenGridSize.x = aDC->LogicalToDeviceXRel( KiROUND( gridSize.x ) );
screenGridSize.y = aDC->LogicalToDeviceYRel( KiROUND( gridSize.y ) );
org = m_ClipBox.GetPosition();
......@@ -621,10 +621,10 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
// Incrementing the start point by one grid step should prevent drawing grid points
// outside the clip box.
if( org.x < m_ClipBox.GetX() )
org.x += wxRound( gridSize.x );
org.x += KiROUND( gridSize.x );
if( org.y < m_ClipBox.GetY() )
org.y += wxRound( gridSize.y );
org.y += KiROUND( gridSize.y );
#if ( defined( __WXMAC__ ) || 1 )
// Use a pixel based draw to display grid. There are a lot of calls, so the cost is
......@@ -643,11 +643,11 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
for( double x = (double) org.x; x <= right; x += gridSize.x )
{
xpos = wxRound( x );
xpos = KiROUND( x );
for( double y = (double) org.y; y <= bottom; y += gridSize.y )
{
aDC->DrawPoint( xpos, wxRound( y ) );
aDC->DrawPoint( xpos, KiROUND( y ) );
}
}
#else
......@@ -684,7 +684,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
// Draw a column of grid points.
for( double y = (double) org.y; y <= bottom; y += gridSize.y )
{
tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( wxRound( y ) ) );
tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( KiROUND( y ) ) );
}
// Reset the device context scale and origin and restore on exit.
......@@ -700,7 +700,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
// Blit the column for each row of the damaged region.
for( double x = (double) org.x; x <= right; x += gridSize.x )
{
aDC->Blit( scaleDC.LogicalToDeviceX( wxRound( x ) ),
aDC->Blit( scaleDC.LogicalToDeviceX( KiROUND( x ) ),
scaleDC.LogicalToDeviceY( m_ClipBox.GetY() ),
1, tmpBM.GetHeight(), &tmpDC, 0, 0, wxCOPY, true );
}
......@@ -1072,8 +1072,8 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
double scale = GetParent()->GetScreen()->GetScalingFactor();
wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
center.x += wxRound( (double) ( x - tmpX ) / scale ) / ppux;
center.y += wxRound( (double) ( y - tmpY ) / scale ) / ppuy;
center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux;
center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy;
GetParent()->GetScreen()->SetScrollCenterPosition( center );
Refresh();
......@@ -1083,9 +1083,9 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
double scale = GetParent()->GetScreen()->GetScalingFactor();
int x = m_PanStartCenter.x +
wxRound( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
int y = m_PanStartCenter.y +
wxRound( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
GetParent()->RedrawScreen( wxPoint( x, y ), false );
}
......
......@@ -35,7 +35,7 @@ double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR;
*/
int GetPenSizeForBold( int aTextSize )
{
return wxRound( aTextSize / 5.0 );
return KiROUND( aTextSize / 5.0 );
}
......@@ -55,7 +55,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
{
int penSize = aPenSize;
double scale = aBold ? 4.0 : 6.0;
int maxWidth = wxRound( ABS( aSize ) / scale );
int maxWidth = KiROUND( ABS( aSize ) / scale );
if( penSize > maxWidth )
penSize = maxWidth;
......@@ -138,13 +138,13 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, boo
/* Get metrics */
int xsta = *ptcar++ - 'R';
int xsto = *ptcar++ - 'R';
tally += wxRound( aXSize * (xsto - xsta) * s_HerscheyScaleFactor );
tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor );
}
/* Italic correction, 1/8em */
if( aItalic )
{
tally += wxRound( aXSize * 0.125 );
tally += KiROUND( aXSize * 0.125 );
}
return tally;
}
......@@ -196,7 +196,7 @@ static void DrawGraphicTextPline(
*/
static int overbar_position( int size_v, int thickness )
{
return wxRound( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) );
return KiROUND( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) );
}
......@@ -460,12 +460,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
{
wxPoint currpoint;
hc1 -= xsta; hc2 -= 11; /* Align the midpoint */
hc1 = wxRound( hc1 * size_h * s_HerscheyScaleFactor );
hc2 = wxRound( hc2 * size_v * s_HerscheyScaleFactor );
hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor );
hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor );
// To simulate an italic font, add a x offset depending on the y offset
if( aItalic )
hc1 -= wxRound( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 );
hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 );
currpoint.x = hc1 + current_char_pos.x;
currpoint.y = hc2 + current_char_pos.y;
......@@ -481,7 +481,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
ptr++;
// Apply the advance width
current_char_pos.x += wxRound( size_h * (xsto - xsta) * s_HerscheyScaleFactor );
current_char_pos.x += KiROUND( size_h * (xsto - xsta) * s_HerscheyScaleFactor );
}
if( overbars % 2 )
......
......@@ -16,9 +16,8 @@
#include <pcbcommon.h>
#include <pcbstruct.h>
#include <richio.h>
#include <filter_reader.h>
#include <footprint_info.h>
#include <io_mgr.h>
#include <class_pad.h>
#include <class_module.h>
......@@ -39,109 +38,68 @@
* ...... other data (pads, outlines ..)
* $Endmodule
*/
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
{
FILE* file;
wxFileName filename;
wxString libname;
// Clear data before reading files
m_filesNotFound.Empty();
m_filesInvalid.Empty();
m_List.clear();
/* Parse Libraries Listed */
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
// try
{
filename = aFootprintsLibNames[ii];
filename.SetExt( FootprintLibFileExtension );
libname = wxGetApp().FindLibraryPath( filename );
if( libname.IsEmpty() )
{
m_filesNotFound << filename.GetFullName() << wxT("\n");
continue;
}
/* Open library file */
file = wxFopen( libname, wxT( "rt" ) );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
if( file == NULL )
// Parse Libraries Listed
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
{
m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n");
continue;
}
FILE_LINE_READER fileReader( file, libname );
FILTER_READER reader( fileReader );
wxFileName filename = aFootprintsLibNames[ii];
/* Read header. */
reader.ReadLine();
char * line = reader.Line();
StrPurge( line );
filename.SetExt( FootprintLibFileExtension );
if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
{
wxString msg;
msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library." ),
GetChars( libname ) );
m_filesInvalid << msg << wxT("\n");
continue;
}
wxString libPath = wxGetApp().FindLibraryPath( filename );
// Read library
bool end = false;
while( !end && reader.ReadLine() )
{
line = reader.Line();
StrPurge( line );
if( strnicmp( line, "$EndLIBRARY", 11 ) == 0 )
if( !libPath )
{
end = true;
break;
m_filesNotFound << filename.GetFullName() << wxT("\n");
continue;
}
if( strnicmp( line, "$MODULE", 7 ) == 0 )
{
line += 7;
FOOTPRINT_INFO* ItemLib = new FOOTPRINT_INFO();
ItemLib->m_Module = FROM_UTF8( StrPurge( line ) );
ItemLib->m_LibName = libname;
AddItem( ItemLib );
try
{
wxArrayString fpnames = pi->FootprintEnumerate( libPath );
while( reader.ReadLine() )
for( unsigned i=0; i<fpnames.GetCount(); ++i )
{
line = reader.Line();
StrPurge( line );
if( strnicmp( line, "$EndMODULE", 10 ) == 0 )
break;
if( strnicmp( line, "$PAD", 4 ) == 0 )
ItemLib->m_padCount++;
int id = ((line[0] & 0xFF) << 8) + (line[1] & 0xFF);
switch( id )
{
/* KeyWords */
case (('K'<<8) + 'w'):
ItemLib->m_KeyWord = FROM_UTF8( StrPurge( line + 3 ) );
break;
/* Doc */
case (('C'<<8) + 'd'):
ItemLib->m_Doc = FROM_UTF8( StrPurge( line + 3 ) );
break;
}
auto_ptr<MODULE> m( pi->FootprintLoad( libPath, fpnames[i] ) );
// we're loading what we enumerated, all must be there.
wxASSERT( m.get() );
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
fpinfo->m_Module = fpnames[i];
fpinfo->m_LibName = libPath;
fpinfo->m_padCount = m->GetPadCount();
fpinfo->m_KeyWord = m->GetKeywords();
fpinfo->m_Doc = m->GetDescription();
AddItem( fpinfo );
}
}
catch( IO_ERROR ioe )
{
m_filesInvalid << ioe.errorText << wxT("\n");
}
}
}
if( !end )
{
m_filesInvalid << libname << _(" (Unexpected end of file)") << wxT("\n");
}
/* caller should catch this, UI seems not wanted here.
catch( IO_ERROR ioe )
{
DisplayError( NULL, ioe.errorText );
return false;
}
*/
m_List.sort();
......
......@@ -1410,7 +1410,7 @@ void ClipAndDrawFilledPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], in
for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
{
clippedPolygon.push_back( wxPoint( wxRound( cit->X ), wxRound( cit->Y ) ) );
clippedPolygon.push_back( wxPoint( KiROUND( cit->X ), KiROUND( cit->Y ) ) );
}
if( clippedPolygon.size() )
......
......@@ -6,7 +6,7 @@
#include <fctsys.h>
#include <macros.h>
#include <trigo.h>
#include <common.h>
bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist )
{
......@@ -140,7 +140,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY )
*/
int angle;
angle = wxRound( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) );
angle = KiROUND( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) );
cXrot = pointX;
cYrot = pointY;
......@@ -211,7 +211,7 @@ int ArcTangente( int dy, int dx )
}
fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800;
return wxRound( fangle );
return KiROUND( fangle );
}
......@@ -253,8 +253,8 @@ void RotatePoint( int* pX, int* pY, double angle )
double cosinus = cos( fangle );
double fpx = (*pY * sinus ) + (*pX * cosinus );
double fpy = (*pY * cosinus ) - (*pX * sinus );
*pX = wxRound( fpx );
*pY = wxRound( fpy );
*pX = KiROUND( fpx );
*pY = KiROUND( fpy );
}
}
......
This diff is collapsed.
......@@ -41,17 +41,14 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent,
int textsize,
EDA_UNITS_T user_unit,
wxBoxSizer* BoxSizer,
int framelen,
int internal_unit )
int framelen )
{
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
m_Title = NULL;
m_Title = new wxStaticText( parent, -1, Title );
BoxSizer->Add( m_Title, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit );
......@@ -62,14 +59,12 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent,
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_UserUnit );
wxStaticText* text = new wxStaticText( parent, -1, msg );
BoxSizer->Add( text, 0,
wxGROW | wxLEFT | wxRIGHT, 5 );
BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
}
wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textsize );
wxString value = FormatSize( m_UserUnit, textsize );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition,
wxSize( 70, -1 ) );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) );
BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
......@@ -84,11 +79,8 @@ EDA_GRAPHIC_TEXT_CTRL::~EDA_GRAPHIC_TEXT_CTRL()
}
wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit,
int textSize )
wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( EDA_UNITS_T aUnit, int textSize )
{
wxString value;
// Limiting the size of the text of reasonable values.
if( textSize < 10 )
textSize = 10;
......@@ -96,10 +88,7 @@ wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit,
if( textSize > 3000 )
textSize = 3000;
value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
To_User_Unit( aUnit, textSize ) );
return value;
return ReturnStringFromValue( aUnit, textSize );
}
......@@ -117,7 +106,7 @@ void EDA_GRAPHIC_TEXT_CTRL::SetValue( const wxString& value )
void EDA_GRAPHIC_TEXT_CTRL::SetValue( int textSize )
{
wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textSize );
wxString value = FormatSize( m_UserUnit, textSize );
m_FrameSize->SetValue( value );
}
......@@ -129,12 +118,11 @@ const wxString EDA_GRAPHIC_TEXT_CTRL::GetText() const
}
int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText,
int internalUnit, EDA_UNITS_T aUnit )
int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUnit )
{
int textsize;
textsize = ReturnValueFromString( aUnit, sizeText, internalUnit );
textsize = ReturnValueFromString( aUnit, sizeText );
// Limit to reasonable size
if( textsize < 10 )
......@@ -149,7 +137,7 @@ int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText,
int EDA_GRAPHIC_TEXT_CTRL::GetTextSize()
{
return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_UserUnit );
return ParseSize( m_FrameSize->GetValue(), m_UserUnit );
}
......@@ -166,13 +154,11 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
const wxString& title,
const wxPoint& pos_to_edit,
EDA_UNITS_T user_unit,
wxBoxSizer* BoxSizer,
int internal_unit )
wxBoxSizer* BoxSizer )
{
wxString text;
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() )
text = _( "Pos " );
......@@ -182,10 +168,8 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
text += _( "X" ) + ReturnUnitSymbol( m_UserUnit );
m_TextX = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextX, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString,
wxDefaultPosition );
BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition );
BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
......@@ -198,8 +182,7 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
m_TextY = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextY, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString );
......@@ -224,8 +207,8 @@ wxPoint EDA_POSITION_CTRL::GetValue()
{
wxPoint coord;
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue(), m_Internal_Unit );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue(), m_Internal_Unit );
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue() );
return coord;
}
......@@ -259,12 +242,10 @@ void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
/* EDA_SIZE_CTRL */
/*******************/
EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit,
EDA_UNITS_T aUnit, wxBoxSizer* aBoxSizer,
int internal_unit ) :
EDA_POSITION_CTRL( parent, title,
wxPoint( size_to_edit.x, size_to_edit.y ),
aUnit, aBoxSizer, internal_unit )
const wxSize& size_to_edit, EDA_UNITS_T aUnit,
wxBoxSizer* aBoxSizer ) :
EDA_POSITION_CTRL( parent, title, wxPoint( size_to_edit.x, size_to_edit.y ),
aUnit, aBoxSizer )
{
}
......@@ -284,23 +265,20 @@ wxSize EDA_SIZE_CTRL::GetValue()
/* Class to display and edit a dimension INCHES, MM, or other */
/**************************************************************/
EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title,
int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
int internal_unit )
int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer )
{
wxString label = title;
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
m_Value = value;
label += ReturnUnitSymbol( m_UserUnit );
m_Text = new wxStaticText( parent, -1, label );
BoxSizer->Add( m_Text, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl,
0,
......@@ -321,7 +299,7 @@ int EDA_VALUE_CTRL::GetValue()
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ReturnValueFromString( m_UserUnit, txtvalue, m_Internal_Unit );
coord = ReturnValueFromString( m_UserUnit, txtvalue );
return coord;
}
......
......@@ -380,25 +380,25 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
case WXK_NUMPAD8: /* cursor moved up */
case WXK_UP:
pos.y -= wxRound( gridSize.y );
pos.y -= KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD2: /* cursor moved down */
case WXK_DOWN:
pos.y += wxRound( gridSize.y );
pos.y += KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD4: /* cursor moved left */
case WXK_LEFT:
pos.x -= wxRound( gridSize.x );
pos.x -= KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD6: /* cursor moved right */
case WXK_RIGHT:
pos.x += wxRound( gridSize.x );
pos.x += KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
}
......
......@@ -17,8 +17,7 @@
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
#include <richio.h>
#include <filter_reader.h>
#include <io_mgr.h>
#include <wildcards_and_files_ext.h>
......@@ -29,122 +28,50 @@
* @param CmpName - Module name
* @return - a pointer to the loaded module or NULL.
*/
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& CmpName )
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
int Found = 0;
unsigned ii;
char* Line;
char Name[255];
wxString tmp, msg;
wxFileName fn;
MODULE* Module = NULL;
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
for( ii = 0; ii < parent->m_ModuleLibNames.GetCount(); ii++ )
try
{
fn = parent->m_ModuleLibNames[ii];
fn.SetExt( FootprintLibFileExtension );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
tmp = wxGetApp().FindLibraryPath( fn );
if( !tmp )
{
msg.Printf( _( "PCB foot print library file <%s> could not be \
found in the default search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
FILE* file = wxFopen( tmp, wxT( "rt" ) );
if( file == NULL )
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
{
msg.Printf( _( "Could not open PCB foot print library file <%s>." ),
GetChars( tmp ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
wxFileName fn = parent->m_ModuleLibNames[i];
FILE_LINE_READER fileReader( file, tmp );
fn.SetExt( FootprintLibFileExtension );
FILTER_READER reader( fileReader );
wxString libPath = wxGetApp().FindLibraryPath( fn );
/* Read header. */
reader.ReadLine();
Line = reader.Line();
StrPurge( Line );
if( strnicmp( Line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
{
msg.Printf( _( "<%s> is not a valid KiCad PCB foot print library." ),
GetChars( tmp ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
fclose( file );
return NULL;
}
Found = 0;
while( !Found && reader.ReadLine() )
{
Line = reader.Line();
if( strncmp( Line, "$MODULE", 6 ) == 0 )
break;
if( strnicmp( Line, "$INDEX", 6 ) == 0 )
if( !libPath )
{
while( reader.ReadLine() )
{
Line = reader.Line();
if( strnicmp( Line, "$EndINDEX", 9 ) == 0 )
break;
StrPurge( Line );
wxString msg = wxString::Format(
_("PCB foot print library file <%s> could not be found in the default search paths." ),
fn.GetFullName().GetData() );
if( stricmp( Line, TO_UTF8( CmpName ) ) == 0 )
{
Found = 1;
break;
}
}
}
}
while( Found && reader.ReadLine() )
{
Line = reader.Line();
if( Line[0] != '$' )
continue;
if( Line[1] != 'M' )
continue;
if( strnicmp( Line, "$MODULE", 7 ) != 0 )
// @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
/* Read component name. */
sscanf( Line + 7, " %s", Name );
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
if( stricmp( Name, TO_UTF8( CmpName ) ) == 0 )
if( footprint )
{
Module = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print floating
// point numbers like 1.3)
SetLocaleTo_C_standard();
Module->ReadDescr( &reader );
SetLocaleTo_Default(); // revert to the current locale
Module->SetPosition( wxPoint( 0, 0 ) );
return Module;
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
}
file = NULL;
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
msg.Printf( _( "Module %s not found" ), CmpName.GetData() );
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
......@@ -208,25 +208,25 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
case WXK_NUMPAD8:
case WXK_UP:
pos.y -= wxRound( gridSize.y );
pos.y -= KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
pos.y += wxRound( gridSize.y );
pos.y += KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
pos.x -= wxRound( gridSize.x );
pos.x -= KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
pos.x += wxRound( gridSize.x );
pos.x += KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
......@@ -293,25 +293,25 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
case WXK_NUMPAD8:
case WXK_UP:
pos.y -= wxRound( gridSize.y );
pos.y -= KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
pos.y += wxRound( gridSize.y );
pos.y += KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
pos.x -= wxRound( gridSize.x );
pos.x -= KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
pos.x += wxRound( gridSize.x );
pos.x += KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
......@@ -375,25 +375,25 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
case WXK_NUMPAD8:
case WXK_UP:
pos.y -= wxRound( gridSize.y );
pos.y -= KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
pos.y += wxRound( gridSize.y );
pos.y += KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
pos.x -= wxRound( gridSize.x );
pos.x -= KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
pos.x += wxRound( gridSize.x );
pos.x += KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
......
......@@ -92,8 +92,7 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
void DIALOG_SVG_PRINT::SetPenWidth()
{
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->GetInternalUnits() );
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DialogPenWidth );
if( g_DrawDefaultLineThickness > WIDTH_MAX_VALUE )
{
......@@ -118,7 +117,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
SetPenWidth();
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->GetInternalUnits() );
ReturnValueFromTextCtrl( *m_DialogPenWidth );
SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen();
......@@ -216,7 +215,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
LOCALE_IO toggle;
float dpi = (float) frame->GetInternalUnits();
float dpi = 1000.0;
KicadSVGFileDC dc( FullFileName, sheetSize.x, sheetSize.y, dpi );
EDA_RECT tmp = *panel->GetClipBox();
......@@ -228,6 +227,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
screen->m_IsPrinting = true;
if( frame->IsType( SCHEMATIC_FRAME ) )
screen->Draw( panel, &dc, GR_COPY );
......@@ -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 );
......
......@@ -39,7 +39,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY()
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
{
SetFocus();
m_AliasLocation = -1;
LIB_COMPONENT* component = m_Parent->GetComponent();
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
......@@ -50,6 +50,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_OptionsBoxSizer->Add( m_PinsNameInsideButt, 0, wxALL, 5 );
bSizerBasicPanel->Add( m_OptionsBoxSizer, 0, 0, 5 );
m_staticline3 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
......@@ -70,6 +71,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_SelNumberOfUnits = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 26, 1 );
bSizernbunits->Add( m_SelNumberOfUnits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerMidBasicPanel->Add( bSizernbunits, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer17;
......@@ -84,8 +86,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_SetSkew = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 );
bSizer17->Add( m_SetSkew, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMidBasicPanel->Add( bSizer17, 1, wxEXPAND, 5 );
bSizerBasicPanel->Add( bSizerMidBasicPanel, 0, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
......@@ -101,6 +105,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bSizerBasicPanel->Add( m_OptionPartsLocked, 0, wxALL, 5 );
m_PanelBasic->SetSizer( bSizerBasicPanel );
m_PanelBasic->Layout();
bSizerBasicPanel->Fit( m_PanelBasic );
......@@ -145,8 +150,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_buttonBrowseDocFiles = new wxButton( m_PanelDoc, ID_BROWSE_DOC_FILES, _("Browse DocFiles"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerPaneldocbutts->Add( m_buttonBrowseDocFiles, 0, wxALL, 5 );
m_PanelDocBoxSizer->Add( bSizerPaneldocbutts, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_PanelDoc->SetSizer( m_PanelDocBoxSizer );
m_PanelDoc->Layout();
m_PanelDocBoxSizer->Fit( m_PanelDoc );
......@@ -167,6 +174,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PartAliasListCtrl = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bLeftBoxSizerPanelAlias->Add( m_PartAliasListCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 1, wxEXPAND, 5 );
wxBoxSizer* bRightBoxSizerPanelAlias;
......@@ -181,8 +189,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_ButtonDeleteAllAlias = new wxButton( m_PanelAlias, ID_DELETE_ALL_ALIAS, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 );
bRightBoxSizerPanelAlias->Add( m_ButtonDeleteAllAlias, 0, wxALL, 5 );
bSizerMainPanelAlias->Add( bRightBoxSizerPanelAlias, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_PanelAlias->SetSizer( bSizerMainPanelAlias );
m_PanelAlias->Layout();
bSizerMainPanelAlias->Fit( m_PanelAlias );
......@@ -203,6 +213,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bFpFilterRightBoxSizer;
......@@ -217,8 +228,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_ButtonDeleteAllFootprintFilter = new wxButton( m_PanelFootprintFilter, ID_DELETE_ALL_FOOTPRINT_FILTER, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 );
bFpFilterRightBoxSizer->Add( m_ButtonDeleteAllFootprintFilter, 0, wxALL|wxEXPAND, 5 );
bPanelFpFilterBoxSizer->Add( bFpFilterRightBoxSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer );
m_PanelFootprintFilter->Layout();
bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter );
......@@ -226,6 +239,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bUpperSizer->Add( m_NoteBook, 1, wxEXPAND, 5 );
bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
m_stdSizerButton = new wxStdDialogButtonSizer();
......@@ -234,10 +248,13 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_stdSizerButtonCancel = new wxButton( this, wxID_CANCEL );
m_stdSizerButton->AddButton( m_stdSizerButtonCancel );
m_stdSizerButton->Realize();
bMainSizer->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
// Connect Events
m_ButtonCopyDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::CopyDocToAlias ), NULL, this );
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
......@@ -47,7 +48,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog
class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public DIALOG_SHIM
{
private:
......@@ -106,7 +107,7 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog
public:
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 465,384 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE();
};
......
......@@ -631,8 +631,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
else
fieldValueTextCtrl->Enable( true );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT,
g_UserUnit, field.m_Size.x ) );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.m_Size.x ) );
wxPoint coord = field.m_Pos;
wxPoint zero = -m_Cmp->m_Pos; // relative zero
......@@ -711,11 +710,11 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT, g_UserUnit );
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.m_Size.y = field.m_Size.x;
int style = m_StyleRadioBox->GetSelection();
if( (style & 1 ) != 0 )
field.m_Italic = true;
else
......@@ -726,10 +725,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
else
field.m_Bold = false;
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
return true;
}
......
......@@ -261,7 +261,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UserUnit, text, m_Parent->GetInternalUnits() );
value = ReturnValueFromString( g_UserUnit, text );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
......
......@@ -658,8 +658,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
fieldValueTextCtrl->SetValue( field.m_Text );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT,
g_UserUnit, field.m_Size.x ) );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.m_Size.x ) );
wxPoint coord = field.m_Pos;
wxPoint zero;
......@@ -745,8 +744,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT, g_UserUnit );
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.m_Size.y = field.m_Size.x;
......@@ -761,10 +759,8 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
else
field.m_Bold = false;
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
// Note: the Y axis for components in lib is from bottom to top
// and the screen axis is top to bottom: we must change the y coord sign for editing
......
......@@ -133,7 +133,7 @@ void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
{
m_textorient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
m_textsize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
m_textsize = ReturnValueFromString( g_UserUnit, msg );
switch( m_TextHJustificationOpt->GetSelection() )
{
......
......@@ -145,9 +145,13 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
bSizer2->Add( m_checkShowHiddenPins, 0, wxALL|wxEXPAND, 3 );
m_checkEnableMiddleButtonPan = new wxCheckBox( m_panel1, xwID_ANY, _("Enable middle mouse button panning"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkEnableMiddleButtonPan->SetToolTip( _("Use middle mouse button dragging to pan") );
bSizer2->Add( m_checkEnableMiddleButtonPan, 0, wxALL, 3 );
m_checkMiddleButtonPanLimited = new wxCheckBox( m_panel1, wxID_ANY, _("Middle mouse button panning limited by current toolbar panning"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkMiddleButtonPanLimited = new wxCheckBox( m_panel1, wxID_ANY, _("Middle mouse button panning limited"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkMiddleButtonPanLimited->SetToolTip( _("Middle mouse button panning limited by current scrollbar size") );
bSizer2->Add( m_checkMiddleButtonPanLimited, 0, wxALL, 3 );
m_checkAutoPan = new wxCheckBox( m_panel1, wxID_ANY, _("Enable automatic &panning"), wxDefaultPosition, wxDefaultSize, 0 );
......
......@@ -2533,7 +2533,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Use middle mouse button dragging to pan</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -2600,7 +2600,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Middle mouse button panning limited by current toolbar panning</property>
<property name="label">Middle mouse button panning limited</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
......@@ -2621,7 +2621,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Middle mouse button panning limited by current scrollbar size</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......
#include <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <base_units.h>
#include <libeditframe.h>
#include <class_libentry.h>
#include <lib_pin.h>
......@@ -91,11 +93,11 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
{
if( ! IsShown() ) // do nothing at init time
return;
int units = ((LIB_EDIT_FRAME*)GetParent())->GetInternalUnits();
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize(), units );
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize(), units);
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize() );
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize());
int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
int pinLength = ReturnValueFromString( g_UserUnit, GetLength(), units );
int pinLength = ReturnValueFromString( g_UserUnit, GetLength() );
int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
int pinType = GetElectricalType();
......
......@@ -148,7 +148,7 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
Line = m_TextValue->GetValue();
m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg );
m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
m_parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true;
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_lib_new_component_base__
#define __dialog_lib_new_component_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/spinctrl.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_LIB_NEW_COMPONENT_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIB_NEW_COMPONENT_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticText6;
wxStaticText* m_staticText2;
wxTextCtrl* m_textName;
wxStaticText* m_staticText3;
wxTextCtrl* m_textReference;
wxStaticText* m_staticText4;
wxSpinCtrl* m_spinPartCount;
wxCheckBox* m_checkHasConversion;
wxCheckBox* m_checkIsPowerSymbol;
wxCheckBox* m_checkLockItems;
wxStaticText* m_staticText7;
wxStaticText* m_staticText41;
wxSpinCtrl* m_spinPinTextPosition;
wxStaticText* m_staticText5;
wxCheckBox* m_checkShowPinNumber;
wxCheckBox* m_checkShowPinName;
wxCheckBox* m_checkShowPinNameInside;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
public:
DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIB_NEW_COMPONENT_BASE();
};
#endif //__dialog_lib_new_component_base__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_LIB_NEW_COMPONENT_BASE_H__
#define __DIALOG_LIB_NEW_COMPONENT_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/spinctrl.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_LIB_NEW_COMPONENT_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIB_NEW_COMPONENT_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticText6;
wxStaticText* m_staticText2;
wxTextCtrl* m_textName;
wxStaticText* m_staticText3;
wxTextCtrl* m_textReference;
wxStaticText* m_staticText4;
wxSpinCtrl* m_spinPartCount;
wxCheckBox* m_checkHasConversion;
wxCheckBox* m_checkIsPowerSymbol;
wxCheckBox* m_checkLockItems;
wxStaticText* m_staticText7;
wxStaticText* m_staticText41;
wxSpinCtrl* m_spinPinTextPosition;
wxStaticText* m_staticText5;
wxCheckBox* m_checkShowPinNumber;
wxCheckBox* m_checkShowPinName;
wxCheckBox* m_checkShowPinNameInside;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
public:
DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIB_NEW_COMPONENT_BASE();
};
#endif //__DIALOG_LIB_NEW_COMPONENT_BASE_H__
......@@ -207,19 +207,19 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptPlotOffset( wxCommandEvent& event )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_PlotOrgPosition_Y->GetValue();
s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.y = ReturnValueFromString( g_UserUnit, msg );
}
}
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( )
{
g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penWidthCtrl,
EESCHEMA_INTERNAL_UNIT);
g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penWidthCtrl );
if( g_HPGL_Pen_Descr.m_Pen_Diam > 100 )
g_HPGL_Pen_Descr.m_Pen_Diam = 100;
......@@ -262,11 +262,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_PlotOrgPosition_Y->GetValue();
s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.y = ReturnValueFromString( g_UserUnit, msg );
}
Plot_Schematic_HPGL( aPlotAll );
......
......@@ -164,8 +164,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::initOptVars()
m_plot_Sheet_Ref = m_Plot_Sheet_Ref_Ctrl->GetValue();
m_plotColorOpt = m_PlotPSColorOption->GetSelection();
m_pageSizeSelect = m_SizeOption->GetSelection();
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl,
EESCHEMA_INTERNAL_UNIT );
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl );
if( g_DrawDefaultLineThickness < 1 )
g_DrawDefaultLineThickness = 1;
}
......
......@@ -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() )
......
......@@ -188,7 +188,7 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran
NEGATE( relativePosition.y ); // reverse Y axis
int distance = wxRound( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) );
int distance = KiROUND( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) );
if( abs( distance - m_Radius ) > aThreshold )
return false;
......@@ -738,7 +738,7 @@ void LIB_ARC::calcRadiusAngles()
wxPoint centerStartVector = TwoPointVector( m_Pos, m_ArcStart );
wxPoint centerEndVector = TwoPointVector( m_Pos, m_ArcEnd );
m_Radius = wxRound( EuclideanNorm( centerStartVector ) );
m_Radius = KiROUND( EuclideanNorm( centerStartVector ) );
m_t1 = (int) ( atan2( (double) centerStartVector.y,
(double) centerStartVector.x ) * 1800 / M_PI );
......
......@@ -106,7 +106,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
wxPoint relpos = aPosRef - aTransform.TransformCoordinate( m_Pos );
int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) +
int dist = KiROUND( sqrt( ( (double) relpos.x * relpos.x ) +
( (double) relpos.y * relpos.y ) ) );
if( abs( dist - m_Radius ) <= aThreshold )
......@@ -346,7 +346,7 @@ void LIB_CIRCLE::calcEdit( const wxPoint& aPosition )
int dx = m_Pos.x - aPosition.x;
int dy = m_Pos.y - aPosition.y;
m_Radius = wxRound( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) );
m_Radius = KiROUND( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) );
}
else
{
......
......@@ -1889,7 +1889,7 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
int numberTextLength = showNum ? m_numTextSize * GetNumberString().Len() : 0;
// Actual text height is bigger than text size
int numberTextHeight = showNum ? wxRound( m_numTextSize * 1.1 ) : 0;
int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
if( m_shape & INVERT )
minsizeV = MAX( TARGET_PIN_RADIUS, INVERT_PIN_RADIUS );
......@@ -1914,7 +1914,7 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
// Actual text height are bigger than text size
nameTextHeight = wxRound( m_nameTextSize * 1.1 ) + TXTMARGE;
nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + TXTMARGE;
}
if( nameTextOffset ) // for values > 0, pin name is inside the body
......
......@@ -50,7 +50,7 @@
#include <dialogs/dialog_edit_component_in_lib.h>
#include <dialogs/dialog_libedit_dimensions.h>
#include <dialog_helpers.h>
//#include <dialog_helpers.h>
#include <menus_helpers.h>
#include <boost/foreach.hpp>
......
......@@ -91,7 +91,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
dlg.SetPadNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNumberTextSize() ) );
dlg.SetPadNameTextSizeUnits( units );
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength(), m_internalUnits ) );
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength() ) );
dlg.SetLengthUnits( units );
dlg.SetAddToAllParts( pin->GetUnit() == 0 );
dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 );
......@@ -119,10 +119,10 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
}
// Save the pin properties to use for the next new pin.
LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize(), m_internalUnits );
LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize(), m_internalUnits );
LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize() );
LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize() );
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_internalUnits );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength() );
LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
LastPinType = dlg.GetElectricalType();
LastPinCommonConvert = dlg.GetAddToAllBodyStyles();
......
......@@ -169,7 +169,7 @@ int SCH_BUS_ENTRY::GetPenSize() const
if( m_Layer == LAYER_BUS && m_width == 0 )
{
pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = KiROUND( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = MAX( pensize, 3 );
}
......
......@@ -214,7 +214,7 @@ int SCH_LINE::GetPenSize() const
if( m_Layer == LAYER_BUS && m_width == 0 )
{
pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = KiROUND( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = MAX( pensize, 3 );
}
......
......@@ -651,8 +651,8 @@ EDA_RECT SCH_SHEET::GetBoundingBox() const
end += m_pos;
// Move upper and lower limits to include texts:
box.SetY( box.GetY() - ( wxRound( m_sheetNameSize * 1.3 ) + 8 ) );
end.y += wxRound( m_fileNameSize * 1.3 ) + 8;
box.SetY( box.GetY() - ( KiROUND( m_sheetNameSize * 1.3 ) + 8 ) );
end.y += KiROUND( m_fileNameSize * 1.3 ) + 8;
box.SetEnd( end );
box.Inflate( lineWidth / 2 );
......
......@@ -1242,7 +1242,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
int x = symb_len + linewidth + 3;
// 50% more for negation bar
int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
int y = KiROUND( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
// Starting point(anchor)
aPoints.push_back( wxPoint( 0, 0 ) );
......
......@@ -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 );
}
......
......@@ -189,13 +189,9 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
else if( loadFromFile )
aSheet->Load( this );
aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit,
dlg.GetFileNameTextSize(),
m_internalUnits ) );
aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit, dlg.GetFileNameTextSize() ) );
aSheet->SetName( dlg.GetSheetName() );
aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit,
dlg.GetSheetNameTextSize(),
m_internalUnits ) );
aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit, dlg.GetSheetNameTextSize() ) );
if( aSheet->GetName().IsEmpty() )
aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), aSheet->GetTimeStamp() ) );
......@@ -235,8 +231,8 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( sheet->HasPins() )
{
int gridSizeX = wxRound( screen->GetGridSize().x );
int gridSizeY = wxRound( screen->GetGridSize().y );
int gridSizeX = KiROUND( screen->GetGridSize().x );
int gridSizeY = KiROUND( screen->GetGridSize().y );
// If the sheet has pins, use the pin positions to clamp the minimum height.
height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
......
......@@ -85,8 +85,8 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
}
aSheetPin->m_Text = dlg.GetLabelName();
aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_internalUnits );
aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_internalUnits );
aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight() );
aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth() );
aSheetPin->SetShape( dlg.GetConnectionType() );
if( aDC )
......
......@@ -82,7 +82,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
return;
val = dialog.GetWidth();
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val, m_internalUnits );
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val );
m_drawSpecificConvert = !dialog.GetApplyToAllConversions();
m_drawSpecificUnit = !dialog.GetApplyToAllUnits();
......
......@@ -38,10 +38,10 @@
/**
* Function scale
* converts a distance given in floating point to our deci-mils
* Function scaletoIU
* converts a distance given in floating point to our internal units
*/
extern int scale( double aCoord, bool isMetric ); // defined it rs274d.cpp
extern int scaletoIU( double aCoord, bool isMetric ); // defined it rs274d_read_XY_and_IJ_coordiantes.cpp
/* Format Gerber: NOTES:
* Tools and D_CODES
......@@ -301,9 +301,9 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
continue;
GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem );
wxPoint move_vector;
move_vector.x = scale( ii * GetLayerParams().m_StepForRepeat.x,
move_vector.x = scaletoIU( ii * GetLayerParams().m_StepForRepeat.x,
GetLayerParams().m_StepForRepeatMetric );
move_vector.y = scale( jj * GetLayerParams().m_StepForRepeat.y,
move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y,
GetLayerParams().m_StepForRepeatMetric );
dupItem->MoveXY( move_vector );
m_Parent->GetBoard()->m_Drawings.Append( dupItem );
......
This diff is collapsed.
......@@ -115,9 +115,9 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
EXCHG( abPos.x, abPos.y );
abPos += m_layerOffset + m_imageParams->m_ImageOffset;
abPos.x = wxRound( abPos.x * m_drawScale.x );
abPos.y = wxRound( abPos.y * m_drawScale.y );
int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
abPos.x = KiROUND( abPos.x * m_drawScale.x );
abPos.y = KiROUND( abPos.y * m_drawScale.y );
int rotation = KiROUND(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
if( rotation )
RotatePoint( &abPos, -rotation );
......@@ -144,13 +144,13 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition )
if( !m_mirrorB )
NEGATE( xyPos.y );
int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
int rotation = KiROUND(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
if( rotation )
RotatePoint( &xyPos, rotation );
xyPos.x = wxRound( xyPos.x / m_drawScale.x );
xyPos.y = wxRound( xyPos.y / m_drawScale.y );
xyPos.x = KiROUND( xyPos.x / m_drawScale.x );
xyPos.y = KiROUND( xyPos.y / m_drawScale.y );
xyPos -= m_layerOffset + m_imageParams->m_ImageOffset;
if( m_swapAxis )
......@@ -368,7 +368,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
break;
case GBR_CIRCLE:
radius = wxRound(hypot( (double) ( m_End.x - m_Start.x ),
radius = KiROUND(hypot( (double) ( m_End.x - m_Start.x ),
(double) ( m_End.y - m_Start.y ) ));
halfPenWidth = m_Size.x >> 1;
......
......@@ -47,25 +47,25 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
{
case WXK_NUMPAD8:
case WXK_UP:
pos.y -= wxRound( gridSize.y );
pos.y -= KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
pos.y += wxRound( gridSize.y );
pos.y += KiROUND( gridSize.y );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
pos.x -= wxRound( gridSize.x );
pos.x -= KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
pos.x += wxRound( gridSize.x );
pos.x += KiROUND( gridSize.x );
m_canvas->MoveCursor( pos );
break;
......
......@@ -35,6 +35,7 @@
#include <macros.h>
#include <trigo.h>
#include <gr_basic.h>
#include <base_units.h>
#include <gerbview.h>
#include <class_gerber_draw_item.h>
......@@ -155,7 +156,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName )
{
int current_Dcode, ii, dcode_scale;
int current_Dcode, ii;
char* ptcar;
int dimH, dimV, drill, dummy;
float fdimH, fdimV, fdrill;
......@@ -174,8 +175,7 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
/* Updating gerber scale: */
dcode_scale = 10; /* By uniting dCode = mil, internal unit = 0.1 mil
* -> 1 unite dcode = 10 unit PCB */
double dcode_scale = MILS_TO_IU_SCALAR; // By uniting dCode = mil, internal unit = MILS_TO_IU_SCALAR
current_Dcode = 0;
if( D_Code_FullFileName.IsEmpty() )
......@@ -215,9 +215,9 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
&dimH, &dimV, &drill, &dummy, &dummy, &type_outil );
dimH = wxRound( dimH * dcode_scale );
dimV = wxRound( dimV * dcode_scale );
drill = wxRound( drill * dcode_scale );
dimH = KiROUND( dimH * dcode_scale );
dimV = KiROUND( dimV * dcode_scale );
drill = KiROUND( drill * dcode_scale );
if( ii < 1 )
ii = 1;
......@@ -245,9 +245,9 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
}
}
dimH = wxRound( fdimH * dcode_scale * 1000 );
dimV = wxRound( fdimV * dcode_scale * 1000 );
drill = wxRound( fdrill * dcode_scale * 1000 );
dimH = KiROUND( fdimH * dcode_scale * 1000 );
dimV = KiROUND( fdimV * dcode_scale * 1000 );
drill = KiROUND( fdrill * dcode_scale * 1000 );
if( strchr( "CLROP", c_type_outil[0] ) )
{
......@@ -600,7 +600,7 @@ void D_CODE::ConvertShapeToPolygon()
if( m_Rotation ) // vertical oval, rotate polygon.
{
int angle = wxRound( m_Rotation * 10 );
int angle = KiROUND( m_Rotation * 10 );
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
{
......
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="10" />
<FileVersion major="1" minor="11" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
......@@ -19,66 +20,33 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_managed">0</property>
<property name="aui_name"></property>
<property name="best_size"></property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center"></property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="layer"></property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">DIALOG_PAGE_SHOW_PAGE_BORDERS_BASE</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size">263,254</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Page Borders</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
......@@ -150,7 +118,10 @@
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
......@@ -172,7 +143,6 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show Page Limits:</property>
<property name="layer"></property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
......@@ -188,9 +158,7 @@
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
......@@ -244,7 +212,10 @@
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
......@@ -264,7 +235,6 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="layer"></property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
......@@ -279,19 +249,13 @@
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
......
......@@ -25,62 +25,28 @@
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_managed">0</property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center"></property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">DIALOG_DISPLAY_OPTIONS_BASE</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size">446,330</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Gerbview Options</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
......@@ -1140,10 +1106,6 @@
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
......
......@@ -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 );
......
......@@ -63,6 +63,7 @@
#include <gerbview.h>
#include <trigo.h>
#include <macros.h>
#include <base_units.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <class_excellon.h>
......@@ -430,8 +431,12 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
dcode = GetDCODE( iprm + FIRST_DCODE ); // Remember: dcodes are >= FIRST_DCODE
if( dcode == NULL )
break;
double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT;
dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale );
// conv_scale = scaling factor from inch to Internal Unit
double conv_scale = MILS_TO_IU_SCALAR*1000;
if( m_GerbMetric )
conv_scale /= 25.4;
dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale );
dcode->m_Shape = APT_CIRCLE;
break;
}
......
This diff is collapsed.
......@@ -3,6 +3,29 @@
* @brief GERBVIEW main file.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <class_drawpanel.h>
......
......@@ -32,6 +32,7 @@
#include <class_drawpanel.h>
#include <build_version.h>
#include <macros.h>
#include <base_units.h>
#include <class_layer_box_selector.h>
#include <gerbview.h>
......@@ -407,7 +408,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
D_CODE* pt_D_code;
wxString Line;
wxArrayString list;
int scale = 10000;
double scale = MILS_TO_IU_SCALAR * 1000;
int curr_layer = getActiveLayer();
for( int layer = 0; layer < 32; layer++ )
......
......@@ -345,8 +345,8 @@ static void fillArcPOLY( BOARD* aPcb, GERBER_DRAW_ITEM* aGbrItem,
* angle is trigonometrical (counter-clockwise),
* and axis is the X,Y gerber coordinates
*/
int start_angle = wxRound(atan2( (double) start.y, (double) start.x ) * 1800 / M_PI);
int end_angle = wxRound(atan2( (double) end.y, (double) end.x ) * 1800 / M_PI);
int start_angle = KiROUND(atan2( (double) start.y, (double) start.x ) * 1800 / M_PI);
int end_angle = KiROUND(atan2( (double) end.y, (double) end.x ) * 1800 / M_PI);
// dummyTrack has right geometric parameters, but
// fillArcGBRITEM calculates arc parameters for a draw function that expects
......@@ -543,23 +543,6 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
}
/**
* Function scale
* converts a distance given in floating point to our deci-mils
*/
int scale( double aCoord, bool isMetric )
{
int ret;
if( isMetric )
ret = wxRound( aCoord / 0.00254 );
else
ret = wxRound( aCoord * PCB_INTERNAL_UNIT );
return ret;
}
bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
{
wxSize size( 15, 15 );
......
This diff is collapsed.
......@@ -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.
......@@ -80,4 +93,25 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb
*/
void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue );
/**
* Return in internal units the value "val" given in inch or mm
*/
double From_User_Unit( EDA_UNITS_T aUnit, double aValue );
/**
* Function ReturnValueFromeString
* converts \a aTextValue in \a aUnits to internal units used by the application.
*
* @param aUnits The units of \a aTextValue.
* @param aTextValue A reference to a wxString object containing the string to convert.
* @return The string from Value, according to units (inch, mm ...) for display,
*/
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue );
/**
* Convert the number Value in a string according to the internal units
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
*/
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr );
#endif // _BASE_UNITS_H_
This diff is collapsed.
This diff is collapsed.
......@@ -37,7 +37,7 @@ public:
void SetPreviousZoom();
void SetLastZoom();
virtual int GetInternalUnits();
virtual int MilsToIuScalar();
/**
* Function GetCurItem
......@@ -57,7 +57,6 @@ public:
*/
void SetCurItem( BOARD_ITEM* aItem ) { BASE_SCREEN::SetCurItem( (EDA_ITEM*)aItem ); }
/* full undo redo management : */
// use BASE_SCREEN::ClearUndoRedoList()
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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