Commit 2a69ffb4 authored by Vladimir Ur's avatar Vladimir Ur
Browse files

Nanometric work

- D_PAD members converted;
- style improved;
- GetPosition made returning value, added SetPosition;
- highly experimental, test it please!
parents 69f8b30b 959e3386
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -884,7 +884,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
    }
    }
}
}



/** @TODO: move D_PAD method to appropriate file */
/* Draw 3D pads. */
/* Draw 3D pads. */
void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
{
{
@@ -903,8 +903,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
    int     color;
    int     color;


    scale = g_Parm_3D_Visu.m_BoardScale;
    scale = g_Parm_3D_Visu.m_BoardScale;
    holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x ) * scale / 2;
    holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x() ) * scale / 2;
    holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y ) * scale / 2;
    holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y() ) * scale / 2;
    hole  = MIN( holeX, holeY );
    hole  = MIN( holeX, holeY );


    /* Calculate the center of the pad. */
    /* Calculate the center of the pad. */
@@ -914,12 +914,12 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
    xc  = ux0;
    xc  = ux0;
    yc  = uy0;
    yc  = uy0;


    dx = dx0 = TO_LEGACY_LU( m_Size.x ) >> 1;
    dx = dx0 = TO_LEGACY_LU( m_Size.x() ) >> 1;
    dy = dy0 = TO_LEGACY_LU( m_Size.y ) >> 1;
    dy = dy0 = TO_LEGACY_LU( m_Size.y() ) >> 1;


    angle  = m_Orient;
    angle  = m_Orient;
    drillx = m_Pos.x * scale;
    drillx = TO_LEGACY_LU( m_Pos.x() ) * scale;
    drilly = m_Pos.y * scale;
    drilly = TO_LEGACY_LU( m_Pos.y() ) * scale;


    /* Draw the pad hole (TODO: draw OBLONG hole) */
    /* Draw the pad hole (TODO: draw OBLONG hole) */
    if( holeX && holeY )
    if( holeX && holeY )
@@ -980,13 +980,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
        {
        {
            delta_cx = dx - dy;
            delta_cx = dx - dy;
            delta_cy = 0;
            delta_cy = 0;
            w = TO_LEGACY_LU( m_Size.y ) * scale;
            w = TO_LEGACY_LU( m_Size.y() ) * scale;
        }
        }
        else /* Vertical ellipse */
        else /* Vertical ellipse */
        {
        {
            delta_cx = 0;
            delta_cx = 0;
            delta_cy = dy - dx;
            delta_cy = dy - dx;
            w = TO_LEGACY_LU( m_Size.x ) * scale;
            w = TO_LEGACY_LU( m_Size.x() ) * scale;
        }
        }


        RotatePoint( &delta_cx, &delta_cy, angle );
        RotatePoint( &delta_cx, &delta_cy, angle );
+1 −8
Original line number Original line Diff line number Diff line
@@ -37,13 +37,6 @@
#include "auxiliary.h"
#include "auxiliary.h"




#ifndef max
    #define max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
#endif
#ifndef min
    #define min( a, b ) ( ( (a) < (b) ) ? (a) : (b) )
#endif

// Define some types used here from boost::polygon
// Define some types used here from boost::polygon
namespace bpl = boost::polygon;         // bpl = boost polygon library
namespace bpl = boost::polygon;         // bpl = boost polygon library
using namespace bpl::operators;         // +, -, =, ...
using namespace bpl::operators;         // +, -, =, ...
@@ -476,7 +469,7 @@ void BezierToPolyline( std::vector <potrace_dpoint_t>& aCornersBuffer,
     *  occur at an endpoint. */
     *  occur at an endpoint. */
    dd0     = sq( p1.x - 2 * p2.x + p3.x ) + sq( p1.y - 2 * p2.y + p3.y );
    dd0     = sq( p1.x - 2 * p2.x + p3.x ) + sq( p1.y - 2 * p2.y + p3.y );
    dd1     = sq( p2.x - 2 * p3.x + p4.x ) + sq( p2.y - 2 * p3.y + p4.y );
    dd1     = sq( p2.x - 2 * p3.x + p4.x ) + sq( p2.y - 2 * p3.y + p4.y );
    dd      = 6 * sqrt( max( dd0, dd1 ) );
    dd      = 6 * sqrt( fmax( dd0, dd1 ) );
    e2      = 8 * delta <= dd ? 8 * delta / dd : 1;
    e2      = 8 * delta <= dd ? 8 * delta / dd : 1;
    epsilon = sqrt( e2 ); /* necessary interval size */
    epsilon = sqrt( e2 ); /* necessary interval size */


+12 −12
Original line number Original line Diff line number Diff line
@@ -418,7 +418,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int


const LENGTH_UNIT_DESC MillimetreDesc =
const LENGTH_UNIT_DESC MillimetreDesc =
{
{
    LENGTH_UNITS<LENGTH_DEF>::millimetre(),
    LENGTH_UNITS<LENGTH_PCB>::millimetre(),
    wxT( "mm" ),
    wxT( "mm" ),
    6
    6
};
};
@@ -426,7 +426,7 @@ const LENGTH_UNIT_DESC MillimetreDesc =


const LENGTH_UNIT_DESC InchDesc =
const LENGTH_UNIT_DESC InchDesc =
{
{
    LENGTH_UNITS<LENGTH_DEF>::inch(),
    LENGTH_UNITS<LENGTH_PCB>::inch(),
    wxT( "\"" ),
    wxT( "\"" ),
    7
    7
};
};
@@ -434,7 +434,7 @@ const LENGTH_UNIT_DESC InchDesc =


const LENGTH_UNIT_DESC MilDesc =
const LENGTH_UNIT_DESC MilDesc =
{
{
    LENGTH_UNITS<LENGTH_DEF>::mil(),
    LENGTH_UNITS<LENGTH_PCB>::mil(),
    wxT( "mil" ),
    wxT( "mil" ),
    5
    5
};
};
@@ -442,7 +442,7 @@ const LENGTH_UNIT_DESC MilDesc =


const LENGTH_UNIT_DESC UnscaledDesc = /* stub */
const LENGTH_UNIT_DESC UnscaledDesc = /* stub */
{
{
    LENGTH_DEF::quantum(),
    LENGTH_PCB::quantum(),
    wxT( "" ),
    wxT( "" ),
    4
    4
};
};
@@ -461,7 +461,7 @@ const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) {




/* TODO: localisation */
/* TODO: localisation */
wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue,
wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_PCB aValue,
                         bool aAdd_unit_symbol ) {
                         bool aAdd_unit_symbol ) {
    wxString StringValue;
    wxString StringValue;
    double   value_to_print;
    double   value_to_print;
@@ -490,10 +490,10 @@ wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue,
    return StringValue;
    return StringValue;
}
}


LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue )
LENGTH_PCB StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue )
{
{


    LENGTH_DEF    Value;
    LENGTH_PCB  Value;
    double      dtmp = 0;
    double      dtmp = 0;


    /* Acquire the 'right' decimal point separator */
    /* Acquire the 'right' decimal point separator */
@@ -544,21 +544,21 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
        aUnit = &MilDesc;
        aUnit = &MilDesc;
    }
    }


    Value = LENGTH_DEF( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) );
    Value = LENGTH_PCB( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) );


    return Value;
    return Value;
}
}


void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value )
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_PCB Value )
{
{
    wxString msg = LengthToString( UnitDescription( g_UserUnit ), Value );
    wxString msg = LengthToString( UnitDescription( g_UserUnit ), Value );


    TextCtr.SetValue( msg );
    TextCtr.SetValue( msg );
}
}


LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr )
LENGTH_PCB LengthFromTextCtrl( const wxTextCtrl& TextCtr )
{
{
    LENGTH_DEF value;
    LENGTH_PCB value;
    wxString msg = TextCtr.GetValue();
    wxString msg = TextCtr.GetValue();


    value = StringToLength( UnitDescription( g_UserUnit ), msg );
    value = StringToLength( UnitDescription( g_UserUnit ), msg );
+82 −0
Original line number Original line Diff line number Diff line
@@ -802,3 +802,85 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig )
        aConfig->Write( configkey, libname );
        aConfig->Write( configkey, libname );
    }
    }
}
}

/*
 * LENGTH_PCB
 */

PARAM_CFG_LENGTH_PCB::PARAM_CFG_LENGTH_PCB( const wxChar* ident,
                                            LENGTH_PCB*   ptparam,
                                            LENGTH_PCB    default_val,
                                            LENGTH_PCB    min,
                                            LENGTH_PCB    max,
                                            const wxChar* group ) :
    PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
{
    m_Pt_param = ptparam;
    m_Default  = default_val;
    m_Min = min;
    m_Max = max;
}


PARAM_CFG_LENGTH_PCB::PARAM_CFG_LENGTH_PCB( bool          Insetup,
                                            const wxChar* ident,
                                            LENGTH_PCB*   ptparam,
                                            LENGTH_PCB    default_val,
                                            LENGTH_PCB    min,
                                            LENGTH_PCB    max,
                                            const wxChar* group ) :
    PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
{
    m_Pt_param = ptparam;
    m_Default  = default_val;
    m_Min   = min;
    m_Max   = max;
    m_Setup = Insetup;
}


/** ReadParam
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_LENGTH_PCB::ReadParam( wxConfigBase* aConfig )
{
    if( m_Pt_param == NULL || aConfig == NULL )
        return;

    LENGTH_PCB ftmp;
    wxString msg;
    msg = aConfig->Read( m_Ident, wxT( "" ) );

    if( msg.IsEmpty() )
    {
        ftmp = m_Default;
    }
    else
    {
        double t;
        msg.ToDouble( &t );
        ftmp = FROM_LEGACY_LU( t );

        if( (ftmp < m_Min) || (ftmp > m_Max) )
            ftmp = m_Default;
    }

    *m_Pt_param = ftmp;
}


/** SaveParam
 * save the the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_LENGTH_PCB::SaveParam( wxConfigBase* aConfig )
{
    if( m_Pt_param == NULL || aConfig == NULL )
        return;
#ifdef KICAD_NANOMETRE
    aConfig->Write( m_Ident, TO_LEGACY_LU_DBL( *m_Pt_param ) );
#else // save it as int to mantain compatibility while in transition to nanoscale
    aConfig->Write( m_Ident, TO_LEGACY_LU( *m_Pt_param ) );
#endif
}
+5 −1
Original line number Original line Diff line number Diff line
@@ -167,11 +167,15 @@ public:
     * @return const wxPoint& - The position of this object.
     * @return const wxPoint& - The position of this object.
     * This function exists mainly to satisfy the virtual GetPosition() in parent class
     * This function exists mainly to satisfy the virtual GetPosition() in parent class
     */
     */
    wxPoint& GetPosition()
    const wxPoint GetPosition() const
    {
    {
        return m_Start;  // it had to be start or end.
        return m_Start;  // it had to be start or end.
    }
    }


    void SetPosition( const wxPoint& pos ) {
        m_Start = pos;
    }

    /**
    /**
     * Function GetABPosition
     * Function GetABPosition
     * returns the image position of aPosition for this object.
     * returns the image position of aPosition for this object.
Loading