Commit 0c946870 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

All: fix a truncation issue in ReturnValueFromString that creates sometimes a...

All: fix a truncation issue in ReturnValueFromString that creates sometimes a small error for values entered in dialogs.
Pcbnew: fix a compatibility issue with nano version for zones parameters.
parent f94a95ab
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -188,7 +188,7 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue )


int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
{
    int    Value;
    double value;
    double dtmp = 0;
    double dtmp = 0;


    // Acquire the 'right' decimal point separator
    // Acquire the 'right' decimal point separator
@@ -239,9 +239,9 @@ int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
        dtmp /= 1000;
        dtmp /= 1000;
    }
    }


    Value = From_User_Unit( aUnits, dtmp );
    value = From_User_Unit( aUnits, dtmp );


    return Value;
    return KiROUND( value );
}
}




+0 −10
Original line number Original line Diff line number Diff line
@@ -1048,16 +1048,6 @@ public:
     */
     */
    ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch );
    ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch );


    /**
     *  Function CompleteArea
     * complete copper area contour by adding a line from last to first corner
     * if there is only 1 or 2 corners, remove (delete) the area
     * @param area_to_complete = area to complete or remove
     * @param style = style of last corner
     * @return 1 if Ok, 0 if area removed
     */
    int CompleteArea( ZONE_CONTAINER* area_to_complete, int style );

    /**
    /**
     * Function TestAreaPolygon
     * Function TestAreaPolygon
     * Test an area for self-intersection.
     * Test an area for self-intersection.
+0 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,6 @@ class PCB_EDIT_FRAME;
class BOARD;
class BOARD;
class ZONE_CONTAINER;
class ZONE_CONTAINER;



/**
/**
 * Struct SEGMENT
 * Struct SEGMENT
 * is a simple container used when filling areas with segments
 * is a simple container used when filling areas with segments
+8 −4
Original line number Original line Diff line number Diff line
@@ -39,8 +39,10 @@ ZONE_SETTINGS::ZONE_SETTINGS()
{
{
    m_ZonePriority = 0;
    m_ZonePriority = 0;
    m_FillMode = 0;                                            // Mode for filling zone : 1 use segments, 0 use polygons
    m_FillMode = 0;                                            // Mode for filling zone : 1 use segments, 0 use polygons
    m_ZoneClearance      = 200;                                // Clearance value
    // Clearance value
    m_ZoneMinThickness   = 100;                                // Min thickness value in filled areas
    m_ZoneClearance      = Mils2iu( ZONE_CLEARANCE_MIL );
    // Min thickness value in filled areas (this is the minimum width of copper to fill solid areas) :
    m_ZoneMinThickness   = Mils2iu( ZONE_THICKNESS_MIL );
    m_NetcodeSelection   = 0;                                  // Net code selection for the current zone
    m_NetcodeSelection   = 0;                                  // Net code selection for the current zone
    m_CurrentZone_Layer  = 0;                                  // Layer used to create the current zone
    m_CurrentZone_Layer  = 0;                                  // Layer used to create the current zone
    m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;           // Option to show the zone area (outlines only, short hatches or full hatches
    m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;           // Option to show the zone area (outlines only, short hatches or full hatches
@@ -49,8 +51,10 @@ ZONE_SETTINGS::ZONE_SETTINGS()
                                                               // ARC_APPROX_SEGMENTS_COUNT_LOW_DEF
                                                               // ARC_APPROX_SEGMENTS_COUNT_LOW_DEF
                                                               // or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF segments
                                                               // or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF segments


    m_ThermalReliefGap = 200;                                  // tickness of the gap in thermal reliefs
    // tickness of the gap in thermal reliefs:
    m_ThermalReliefCopperBridge = 200;                         // tickness of the copper bridge in thermal reliefs
    m_ThermalReliefGap = Mils2iu( ZONE_THERMAL_RELIEF_GAP_MIL );
    // tickness of the copper bridge in thermal reliefs:
    m_ThermalReliefCopperBridge = Mils2iu( ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL );


    m_PadConnection = THERMAL_PAD;                             // How pads are covered by copper in zone
    m_PadConnection = THERMAL_PAD;                             // How pads are covered by copper in zone


+51 −15
Original line number Original line Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
/**
// Name:        dialog_copper_zones.cpp
 * @file dialog_copper_zones.cpp
// Author:      jean-pierre Charras
 */
// Created:     09/oct/2008

// Licence:     GNU License
/*
/////////////////////////////////////////////////////////////////////////////
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 <wx/wx.h>
#include <wx/wx.h>
#include <wx/imaglist.h>
#include <fctsys.h>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <appl_wxstruct.h>
#include <confirm.h>
#include <confirm.h>
#include <PolyLine.h>
#include <PolyLine.h>
#include <pcbnew.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <wxPcbStruct.h>
#include <trigo.h>
#include <zones.h>
#include <zones.h>
#include <base_units.h>
#include <base_units.h>


@@ -370,20 +390,25 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab


    // Test if this is a reasonable value for this parameter
    // Test if this is a reasonable value for this parameter
    // A too large value can hang Pcbnew
    // A too large value can hang Pcbnew
    #define CLEARANCE_MAX_VALUE 100*IU_PER_MILS
    #define CLEARANCE_MAX_VALUE ZONE_CLEARANCE_MAX_VALUE_MIL*IU_PER_MILS
    if( m_settings.m_ZoneClearance > CLEARANCE_MAX_VALUE )
    if( m_settings.m_ZoneClearance > CLEARANCE_MAX_VALUE )
    {
    {
        DisplayError( this, _( "Clearance must be smaller than 0.5\" / 12.7 mm." ) );
        wxString msg;
        msg.Printf( _( "Clearance must be smaller than %f\" / %f mm." ),
            ZONE_CLEARANCE_MAX_VALUE_MIL / 1000.0, ZONE_CLEARANCE_MAX_VALUE_MIL * 0.0254 );
        DisplayError( this, msg );
        return false;
        return false;
    }
    }


    txtvalue = m_ZoneMinThicknessCtrl->GetValue();
    txtvalue = m_ZoneMinThicknessCtrl->GetValue();
    m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue );
    m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue );


    if( m_settings.m_ZoneMinThickness < (1*IU_PER_MILS) )
    if( m_settings.m_ZoneMinThickness < (ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS) )
    {
    {
        DisplayError( this,
        wxString msg;
                      _( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) );
        msg.Printf( _( "Minimum width must be larger than %f\" / %f mm." ),
            ZONE_THICKNESS_MIN_VALUE_MIL / 1000.0, ZONE_THICKNESS_MIN_VALUE_MIL * 0.0254 );
        DisplayError( this, msg );
        return false;
        return false;
    }
    }


@@ -402,9 +427,20 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab


    m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue );
    m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue );


    m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (long) m_settings.m_ThermalReliefGap );
    if( m_Config )
    {
        m_Config->Write( ZONE_CLEARANCE_WIDTH_STRING_KEY,
            (double) m_settings.m_ZoneClearance / IU_PER_MILS );

        m_Config->Write( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY,
            (double) m_settings.m_ZoneMinThickness / IU_PER_MILS );

        m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
            (double) m_settings.m_ThermalReliefGap / IU_PER_MILS );


    m_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, (long) m_settings.m_ThermalReliefCopperBridge );
        m_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
            (double) m_settings.m_ThermalReliefCopperBridge / IU_PER_MILS );
    }


    if( m_settings.m_ThermalReliefCopperBridge <= m_settings.m_ZoneMinThickness )
    if( m_settings.m_ThermalReliefCopperBridge <= m_settings.m_ZoneMinThickness )
    {
    {
Loading