mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-07 21:55:32 +00:00
Remove convert_to_biu.h, merge contents to base_units.h
This commit is contained in:
parent
66e8931405
commit
3d5913c825
3d-viewer/3d_canvas
bitmap2component
common
eeschema
gerbview
am_primitive.cppdcode.cppexport_to_pcbnew.hgerber_file_image.cppgerbview_frame.hgerbview_painter.cpp
include
libs/kimath/include/geometry
pcbnew
autorouter
board_stackup_manager
dialogs
drc
exporters
footprint.himport_gfx
pad.cpppad.hpcb_bitmap.cpppcb_plot_params.cpppcb_track.hpcbnew.hplugins
cadstar
fabmaster
kicad
legacy
pcad
python/swig
teardrop
tools
zone_filler.cppzone_settings.cppqa
qa_utils
unittests
@ -33,7 +33,6 @@
|
||||
#include <3d_math.h>
|
||||
#include "3d_fastmath.h"
|
||||
#include <geometry/geometry_utils.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <wx/log.h>
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <convert_to_biu.h>
|
||||
#include <layer_ids.h>
|
||||
|
||||
#include <locale_io.h>
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include <trigo.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include <eda_units.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <convert_to_biu.h>
|
||||
#include <macros.h>
|
||||
|
||||
bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit )
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <eda_units.h>
|
||||
#include <string_utils.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <common.h>
|
||||
#include <macros.h>
|
||||
#include <validators.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <eda_units.h>
|
||||
#include <property.h>
|
||||
#include <widgets/color_swatch.h>
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <settings/json_settings_internals.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <string_utils.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <base_units.h>
|
||||
|
||||
|
||||
// const int netSettingsSchemaVersion = 0;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <common.h>
|
||||
#include <eda_units.h>
|
||||
#include <layer_ids.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/app_settings.h>
|
||||
|
@ -96,7 +96,6 @@ principle should be easily implemented by adapting the current STL containers.
|
||||
#include <title_block.h>
|
||||
#include <marker_base.h>
|
||||
#include <eda_text.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <id.h>
|
||||
#include <build_version.h>
|
||||
#include <layer_ids.h>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <convert_to_biu.h>
|
||||
#include <base_units.h>
|
||||
#include <ki_exception.h>
|
||||
|
||||
#include <wx/log.h>
|
||||
|
@ -23,7 +23,7 @@
|
||||
* @brief Reads in a CADSTAR Schematic Archive (*.csa) file
|
||||
*/
|
||||
|
||||
#include <convert_to_biu.h> // SCH_IU_PER_MM
|
||||
#include <base_units.h>
|
||||
#include <macros.h>
|
||||
#include <sch_plugins/cadstar/cadstar_sch_archive_parser.h>
|
||||
#include <progress_reporter.h>
|
||||
|
@ -32,8 +32,6 @@
|
||||
#ifndef __SCH_SEXPR_PARSER_H__
|
||||
#define __SCH_SEXPR_PARSER_H__
|
||||
|
||||
#include <convert_to_biu.h> // IU_PER_MM
|
||||
|
||||
#include <symbol_library.h>
|
||||
#include <schematic_lexer.h>
|
||||
#include <sch_file_versions.h>
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <base_screen.h>
|
||||
#include <lib_symbol.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <default_values.h>
|
||||
#include <eeschema_settings.h>
|
||||
#include <kiface_base.h>
|
||||
|
@ -20,7 +20,6 @@
|
||||
#ifndef KICAD_SCHEMATIC_SETTINGS_H
|
||||
#define KICAD_SCHEMATIC_SETTINGS_H
|
||||
|
||||
#include <convert_to_biu.h>
|
||||
#include <default_values.h>
|
||||
#include <settings/nested_settings.h>
|
||||
#include <template_fieldnames.h>
|
||||
|
@ -28,7 +28,6 @@
|
||||
*/
|
||||
|
||||
#include <trigo.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <trigo.h>
|
||||
#include <gerbview_frame.h>
|
||||
#include <gerber_file_image.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <eda_units.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
|
||||
#define DCODE_DEFAULT_SIZE gerbIUScale.mmToIU( 0.1 )
|
||||
|
@ -22,7 +22,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <convert_to_biu.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
#include <layer_ids.h>
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <convert_to_biu.h>
|
||||
#include <gerbview.h>
|
||||
#include <gerbview_frame.h>
|
||||
#include <gerber_file_image.h>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <eda_draw_frame.h>
|
||||
#include <layer_ids.h>
|
||||
#include <gerbview.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <gbr_layout.h>
|
||||
#include <page_info.h>
|
||||
#include <gbr_display_options.h>
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <settings/color_settings.h>
|
||||
#include <gerbview_settings.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <gerbview.h>
|
||||
#include <trigo.h>
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 CERN
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2022 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
|
||||
@ -22,16 +22,102 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* @file base_units.h
|
||||
* @brief Implementation of conversion functions that require both schematic and board
|
||||
* internal units.
|
||||
*/
|
||||
|
||||
#ifndef _BASE_UNITS_H_
|
||||
#define _BASE_UNITS_H_
|
||||
|
||||
#include <eda_units.h>
|
||||
/* Note about internal units and max size for boards and items
|
||||
|
||||
The largest distance that we (and Kicad) can support is INT_MAX, since it represents
|
||||
distance often in a wxCoord or wxSize. As a scalar, a distance is always
|
||||
positive. Because int is 32 bits and INT_MAX is
|
||||
2147483647. The most difficult distance for a virtual (world) cartesian
|
||||
space is the hypotenuse, or diagonal measurement at a 45 degree angle. This
|
||||
puts the most stress on the distance magnitude within the bounded virtual
|
||||
space. So if we allow this distance to be our constraint of <= INT_MAX, this
|
||||
constraint then propagates to the maximum distance in X and in Y that can be
|
||||
supported on each axis. Remember that the hypotenuse of a 1x1 square is
|
||||
sqrt( 1x1 + 1x1 ) = sqrt(2) = 1.41421356.
|
||||
|
||||
hypotenuse of any square = sqrt(2) * deltaX;
|
||||
|
||||
Let maximum supported hypotenuse be INT_MAX, then:
|
||||
|
||||
MAX_AXIS = INT_MAX / sqrt(2) = 2147483647 / 1.41421356 = 1518500251
|
||||
|
||||
The next choice is what to use for internal units (IU), sometimes called
|
||||
world units. If nanometers, then the virtual space must be limited to
|
||||
about 1.5 x 1.5 meters square. This is 1518500251 divided by 1e9 nm/meter.
|
||||
|
||||
The maximum zoom factor then depends on the client window size. If we ask
|
||||
wx to handle something outside INT_MIN to INT_MAX, there are unreported
|
||||
problems in the non-Debug build because wxRound() goes silent.
|
||||
|
||||
Pcbnew uses nanometers because we need to convert coordinates and size between
|
||||
millimeters and inches. using a iu = 1 nm avoid rounding issues
|
||||
|
||||
Gerbview uses iu = 10 nm because we can have coordinates far from origin, and
|
||||
1 nm is too small to avoid int overflow.
|
||||
(Conversions between millimeters and inches are not critical)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief some define and functions to convert a value in mils, decimils or mm
|
||||
* to the internal unit used in pcbnew, cvpcb or gerbview (nanometer or deci-mil)
|
||||
* depending on compile time option
|
||||
*/
|
||||
|
||||
constexpr double GERB_IU_PER_MM = 1e5; // Gerbview IU is 10 nanometers.
|
||||
constexpr double PCB_IU_PER_MM = 1e6; // Pcbnew IU is 1 nanometer.
|
||||
constexpr double PL_IU_PER_MM = 1e3; // internal units in micron (should be enough)
|
||||
constexpr double SCH_IU_PER_MM = 1e4; // Schematic internal units 1=100nm
|
||||
|
||||
struct EDA_IU_SCALE
|
||||
{
|
||||
const double IU_PER_MM;
|
||||
const double IU_PER_MILS;
|
||||
const double MM_PER_IU;
|
||||
|
||||
|
||||
constexpr EDA_IU_SCALE( double aIUPerMM ) :
|
||||
IU_PER_MM( aIUPerMM ), IU_PER_MILS( aIUPerMM * 0.0254 ), MM_PER_IU( 1 / IU_PER_MM )
|
||||
{
|
||||
}
|
||||
|
||||
constexpr inline double IUTomm( int iu ) const { return iu / IU_PER_MM; }
|
||||
|
||||
constexpr inline int mmToIU( double mm ) const
|
||||
{
|
||||
return (int) ( mm < 0 ? ( mm * IU_PER_MM - 0.5 ) : ( mm * IU_PER_MM + 0.5 ) );
|
||||
}
|
||||
|
||||
constexpr inline int MilsToIU( int mils ) const
|
||||
{
|
||||
double x = mils * IU_PER_MILS;
|
||||
return int( x < 0 ? x - 0.5 : x + 0.5 );
|
||||
}
|
||||
|
||||
constexpr inline double IUToMils( int iu ) const
|
||||
{
|
||||
double mils = iu / IU_PER_MILS;
|
||||
|
||||
return static_cast<int>( mils < 0 ? mils - 0.5 : mils + 0.5 );
|
||||
}
|
||||
};
|
||||
|
||||
constexpr EDA_IU_SCALE gerbIUScale = EDA_IU_SCALE( GERB_IU_PER_MM );
|
||||
constexpr EDA_IU_SCALE pcbIUScale = EDA_IU_SCALE( PCB_IU_PER_MM );
|
||||
constexpr EDA_IU_SCALE drawSheetIUScale = EDA_IU_SCALE( PL_IU_PER_MM );
|
||||
constexpr EDA_IU_SCALE schIUScale = EDA_IU_SCALE( SCH_IU_PER_MM );
|
||||
|
||||
#ifndef SWIG
|
||||
// The max error is the distance between the middle of a segment, and the circle
|
||||
// for circle/arc to segment approximation.
|
||||
// Warning: too small values can create very long calculation time in zone filling
|
||||
// 0.05 to 0.005 mm are reasonable values
|
||||
|
||||
constexpr int ARC_LOW_DEF = pcbIUScale.mmToIU( 0.02 );
|
||||
constexpr int ARC_HIGH_DEF = pcbIUScale.mmToIU( 0.005 );
|
||||
#endif
|
||||
|
||||
#endif // _BASE_UNITS_H_
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include <eda_item.h>
|
||||
#include <eda_units.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <gr_basic.h>
|
||||
#include <layer_ids.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2020 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
/* Note about internal units and max size for boards and items
|
||||
|
||||
The largest distance that we (and Kicad) can support is INT_MAX, since it represents
|
||||
distance often in a wxCoord or wxSize. As a scalar, a distance is always
|
||||
positive. Because int is 32 bits and INT_MAX is
|
||||
2147483647. The most difficult distance for a virtual (world) cartesian
|
||||
space is the hypotenuse, or diagonal measurement at a 45 degree angle. This
|
||||
puts the most stress on the distance magnitude within the bounded virtual
|
||||
space. So if we allow this distance to be our constraint of <= INT_MAX, this
|
||||
constraint then propagates to the maximum distance in X and in Y that can be
|
||||
supported on each axis. Remember that the hypotenuse of a 1x1 square is
|
||||
sqrt( 1x1 + 1x1 ) = sqrt(2) = 1.41421356.
|
||||
|
||||
hypotenuse of any square = sqrt(2) * deltaX;
|
||||
|
||||
Let maximum supported hypotenuse be INT_MAX, then:
|
||||
|
||||
MAX_AXIS = INT_MAX / sqrt(2) = 2147483647 / 1.41421356 = 1518500251
|
||||
|
||||
The next choice is what to use for internal units (IU), sometimes called
|
||||
world units. If nanometers, then the virtual space must be limited to
|
||||
about 1.5 x 1.5 meters square. This is 1518500251 divided by 1e9 nm/meter.
|
||||
|
||||
The maximum zoom factor then depends on the client window size. If we ask
|
||||
wx to handle something outside INT_MIN to INT_MAX, there are unreported
|
||||
problems in the non-Debug build because wxRound() goes silent.
|
||||
|
||||
Pcbnew uses nanometers because we need to convert coordinates and size between
|
||||
millimeters and inches. using a iu = 1 nm avoid rounding issues
|
||||
|
||||
Gerbview uses iu = 10 nm because we can have coordinates far from origin, and
|
||||
1 nm is too small to avoid int overflow.
|
||||
(Conversions between millimeters and inches are not critical)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief some define and functions to convert a value in mils, decimils or mm
|
||||
* to the internal unit used in pcbnew, cvpcb or gerbview (nanometer or deci-mil)
|
||||
* depending on compile time option
|
||||
*/
|
||||
|
||||
constexpr double GERB_IU_PER_MM = 1e5; // Gerbview IU is 10 nanometers.
|
||||
constexpr double PCB_IU_PER_MM = 1e6; // Pcbnew IU is 1 nanometer.
|
||||
constexpr double PL_IU_PER_MM = 1e3; // internal units in micron (should be enough)
|
||||
constexpr double SCH_IU_PER_MM = 1e4; // Schematic internal units 1=100nm
|
||||
|
||||
|
||||
struct EDA_IU_SCALE
|
||||
{
|
||||
const double IU_PER_MM;
|
||||
const double IU_PER_MILS;
|
||||
const double MM_PER_IU;
|
||||
|
||||
|
||||
constexpr EDA_IU_SCALE( double aIUPerMM ) :
|
||||
IU_PER_MM( aIUPerMM ),
|
||||
IU_PER_MILS( aIUPerMM * 0.0254 ),
|
||||
MM_PER_IU( 1 / IU_PER_MM )
|
||||
{
|
||||
}
|
||||
|
||||
constexpr inline double IUTomm( int iu ) const { return iu / IU_PER_MM; }
|
||||
|
||||
constexpr inline int mmToIU( double mm ) const
|
||||
{
|
||||
return (int) ( mm < 0 ? ( mm * IU_PER_MM - 0.5 ) : ( mm * IU_PER_MM + 0.5 ) );
|
||||
}
|
||||
|
||||
constexpr inline int MilsToIU( int mils ) const
|
||||
{
|
||||
double x = mils * IU_PER_MILS;
|
||||
return int( x < 0 ? x - 0.5 : x + 0.5 );
|
||||
}
|
||||
|
||||
constexpr inline double IUToMils( int iu ) const
|
||||
{
|
||||
double mils = iu / IU_PER_MILS;
|
||||
|
||||
return static_cast<int>( mils < 0 ? mils - 0.5 : mils + 0.5 );
|
||||
}
|
||||
};
|
||||
|
||||
constexpr EDA_IU_SCALE gerbIUScale = EDA_IU_SCALE( GERB_IU_PER_MM );
|
||||
constexpr EDA_IU_SCALE pcbIUScale = EDA_IU_SCALE( PCB_IU_PER_MM );
|
||||
constexpr EDA_IU_SCALE drawSheetIUScale = EDA_IU_SCALE( PL_IU_PER_MM );
|
||||
constexpr EDA_IU_SCALE schIUScale = EDA_IU_SCALE( SCH_IU_PER_MM );
|
||||
|
||||
#ifndef SWIG
|
||||
// The max error is the distance between the middle of a segment, and the circle
|
||||
// for circle/arc to segment approximation.
|
||||
// Warning: too small values can create very long calculation time in zone filling
|
||||
// 0.05 to 0.005 mm are reasonable values
|
||||
|
||||
constexpr int ARC_LOW_DEF = pcbIUScale.mmToIU( 0.02 );
|
||||
constexpr int ARC_HIGH_DEF = pcbIUScale.mmToIU( 0.005 );
|
||||
#endif
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <geometry/eda_angle.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <base_units.h>
|
||||
|
||||
/**
|
||||
* The type of unit.
|
||||
|
@ -71,7 +71,7 @@ Supported units are millimeters (mm), Mil (mil) and inch (")
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <base_units.h>
|
||||
#include <eda_units.h>
|
||||
|
||||
// This namespace is used for the lemon parser
|
||||
namespace numEval
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user