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

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
...@@ -188,7 +188,7 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue ) ...@@ -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 ) ...@@ -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 );
} }
......
...@@ -1048,16 +1048,6 @@ public: ...@@ -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.
......
...@@ -48,7 +48,6 @@ class PCB_EDIT_FRAME; ...@@ -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
......
...@@ -39,8 +39,10 @@ ZONE_SETTINGS::ZONE_SETTINGS() ...@@ -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() ...@@ -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
......
///////////////////////////////////////////////////////////////////////////// /**
// 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 ...@@ -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 ...@@ -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 )
{ {
......
...@@ -479,6 +479,7 @@ void DIALOG_PAD_PROPERTIES::initValues() ...@@ -479,6 +479,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
wxCommandEvent cmd_event; wxCommandEvent cmd_event;
setPadLayersList( m_dummyPad->GetLayerMask() ); setPadLayersList( m_dummyPad->GetLayerMask() );
OnDrillShapeSelected( cmd_event ); OnDrillShapeSelected( cmd_event );
OnPadShapeSelection( cmd_event );
} }
......
...@@ -11,6 +11,17 @@ ...@@ -11,6 +11,17 @@
#define ZONE_NET_FILTER_STRING_KEY wxT( "Zone_Filter_Opt" ) #define ZONE_NET_FILTER_STRING_KEY wxT( "Zone_Filter_Opt" )
#define ZONE_THERMAL_RELIEF_GAP_STRING_KEY wxT( "Zone_TH_Gap" ) #define ZONE_THERMAL_RELIEF_GAP_STRING_KEY wxT( "Zone_TH_Gap" )
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY wxT( "Zone_TH_Copper_Width" ) #define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY wxT( "Zone_TH_Copper_Width" )
#define ZONE_CLEARANCE_WIDTH_STRING_KEY wxT( "Zone_Clearance" )
#define ZONE_MIN_THICKNESS_WIDTH_STRING_KEY wxT( "Zone_Thickness" )
// Default values in mils for parameters in ZONE_CONTAINER
#define ZONE_THERMAL_RELIEF_GAP_MIL 20 // default value for ZONE_SETTINGS::m_ThermalReliefGap
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL 20 // default value for ZONE_SETTINGS::m_ThermalReliefCopperBridge
#define ZONE_THICKNESS_MIL 10 // default value for ZONE_SETTINGS::m_ZoneMinThickness
#define ZONE_THICKNESS_MIN_VALUE_MIL 1 // minimum acceptable value for ZONE_SETTINGS::m_ZoneMinThickness
#define ZONE_CLEARANCE_MIL 20 // default value for ZONE_SETTINGS::m_ZoneClearance
#define ZONE_CLEARANCE_MAX_VALUE_MIL 500 // maximum acceptable value for ZONE_SETTINGS::m_ZoneClearance
/// Exit codes for zone editing dialogs /// Exit codes for zone editing dialogs
enum ZONE_EDIT_T { enum ZONE_EDIT_T {
......
...@@ -536,12 +536,24 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -536,12 +536,24 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
zone->SetNet( zoneInfo.m_NetcodeSelection ); zone->SetNet( zoneInfo.m_NetcodeSelection );
zone->SetNetNameFromNetCode( ); zone->SetNetNameFromNetCode( );
} }
double tmp = ZONE_THERMAL_RELIEF_GAP_MIL;
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, &tmp );
zoneInfo.m_ThermalReliefGap = KiROUND( tmp * IU_PER_MILS);
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, tmp = ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL;
&zoneInfo.m_ThermalReliefGap );
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&zoneInfo.m_ThermalReliefCopperBridge ); &tmp );
zoneInfo.m_ThermalReliefCopperBridge = KiROUND( tmp * IU_PER_MILS );
tmp = ZONE_CLEARANCE_MIL;
wxGetApp().GetSettings()->Read( ZONE_CLEARANCE_WIDTH_STRING_KEY,
&tmp );
zoneInfo.m_ZoneClearance = KiROUND( tmp * IU_PER_MILS );
tmp = ZONE_THICKNESS_MIL;
wxGetApp().GetSettings()->Read( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY,
&tmp );
zoneInfo.m_ZoneMinThickness = KiROUND( tmp * IU_PER_MILS );
zoneInfo.m_CurrentZone_Layer = zone->GetLayer(); zoneInfo.m_CurrentZone_Layer = zone->GetLayer();
......
...@@ -124,30 +124,6 @@ ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, int layer, int x, int ...@@ -124,30 +124,6 @@ ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, int layer, int x, int
} }
/**
* 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 BOARD::CompleteArea( ZONE_CONTAINER* area_to_complete, int style )
{
if( area_to_complete->m_Poly->GetNumCorners() > 2 )
{
area_to_complete->m_Poly->Close( style );
return 1;
}
else
{
Delete( area_to_complete );
}
return 0;
}
/** /**
* Function TestAreaPolygon * Function TestAreaPolygon
* Test an area for self-intersection. * Test an area for self-intersection.
......
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