mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-19 22:51:40 +00:00
Split EDA_UNITS out from common.
This commit is contained in:
parent
7674d2ba91
commit
e928b2d8fd
common
CMakeLists.txtcommon.cpp
dialogs
eda_draw_frame.cppeda_units.cppfootprint_info.cpplib_table_base.cppnetclass.cpppage_layout
plotters
swig
tool
widgets
eeschema
dialogs
lib_field.cpplib_text.cpppin_type.cppsch_bitmap.cppsch_junction.cppsch_no_connect.cppsch_plugins/cadstar
gerbview
dialogs
excellon_read_drill_file.cppgerber_draw_item.cppgerber_file_image.cppjob_file_reader.cpprs274x.cppinclude
base_units.hcommon.heda_base_frame.heda_units.hfootprint_info.h
libeval_compiler
page_layout
plotter.hpreview_items
property_mgr.hreporter.hkicad
pcbnew
@ -325,6 +325,7 @@ set( COMMON_SRCS
|
||||
eda_pattern_match.cpp
|
||||
eda_rect.cpp
|
||||
eda_size_ctrl.cpp
|
||||
eda_units.cpp
|
||||
env_paths.cpp
|
||||
env_vars.cpp
|
||||
exceptions.cpp
|
||||
|
@ -37,37 +37,6 @@
|
||||
#include <wx/wx.h>
|
||||
|
||||
|
||||
bool IsImperialUnit( EDA_UNITS aUnit )
|
||||
{
|
||||
switch( aUnit )
|
||||
{
|
||||
case EDA_UNITS::INCHES:
|
||||
case EDA_UNITS::MILS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool IsMetricUnit( EDA_UNITS aUnit )
|
||||
{
|
||||
switch( aUnit )
|
||||
{
|
||||
case EDA_UNITS::MILLIMETRES:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow )
|
||||
{
|
||||
wxCoord width;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <reporter.h>
|
||||
#include <vector>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <eda_units.h>
|
||||
|
||||
/**
|
||||
* WX_HTML_REPORT_BOX
|
||||
|
@ -973,7 +973,7 @@ void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondary
|
||||
aPrimaryUnit = GetUserUnits();
|
||||
aSecondaryUnits = EDA_UNITS::MILS;
|
||||
|
||||
if( IsImperialUnit( aPrimaryUnit ) )
|
||||
if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
|
||||
{
|
||||
if( cmnTool )
|
||||
aSecondaryUnits = cmnTool->GetLastMetricUnits();
|
||||
|
54
common/eda_units.cpp
Normal file
54
common/eda_units.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <eda_units.h>
|
||||
|
||||
bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit )
|
||||
{
|
||||
switch( aUnit )
|
||||
{
|
||||
case EDA_UNITS::INCHES:
|
||||
case EDA_UNITS::MILS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool EDA_UNIT_UTILS::IsMetricUnit( EDA_UNITS aUnit )
|
||||
{
|
||||
switch( aUnit )
|
||||
{
|
||||
case EDA_UNITS::MILLIMETRES:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -40,6 +40,7 @@
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx/textfile.h>
|
||||
|
||||
|
||||
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aLibNickname,
|
||||
|
@ -29,9 +29,11 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <common.h>
|
||||
#include <kiface_i.h>
|
||||
#include <lib_table_base.h>
|
||||
#include <lib_table_lexer.h>
|
||||
#include <macros.h>
|
||||
#include <settings/app_settings.h>
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <netclass.h>
|
||||
#include <macros.h>
|
||||
#include <base_units.h>
|
||||
|
||||
// This will get mapped to "kicad_default" in the specctra_export.
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
#include <kiface_i.h>
|
||||
#include <title_block.h>
|
||||
#include <common.h>
|
||||
#include <eda_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <eda_item.h>
|
||||
#include <locale_io.h>
|
||||
#include <macros.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <project.h>
|
||||
#include <view/view.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <fill_type.h>
|
||||
#include <kicad_string.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <macros.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <render_settings.h>
|
||||
#include <trigo.h>
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <eda_item.h>
|
||||
#include <wx/zstream.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <macros.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <render_settings.h>
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <eda_base_frame.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <macros.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <render_settings.h>
|
||||
#include <trigo.h>
|
||||
|
@ -86,6 +86,7 @@ principle should be easily implemented by adapting the current STL containers.
|
||||
#include <cstddef>
|
||||
#include <eda_item.h>
|
||||
#include <eda_rect.h>
|
||||
#include <eda_units.h>
|
||||
#include <common.h>
|
||||
#include <richio.h>
|
||||
#include <wx_python_helpers.h>
|
||||
@ -116,6 +117,7 @@ principle should be easily implemented by adapting the current STL containers.
|
||||
%include core/typeinfo.h
|
||||
%include eda_item.h
|
||||
%include eda_rect.h
|
||||
%include eda_units.h
|
||||
%include common.h
|
||||
%include richio.h
|
||||
%include title_block.h
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include <common.h>
|
||||
#include <eda_units.h>
|
||||
#include <frame_type.h>
|
||||
#include <tool/actions.h>
|
||||
|
||||
|
@ -72,9 +72,9 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason )
|
||||
|
||||
void COMMON_TOOLS::SetLastUnits( EDA_UNITS aUnit )
|
||||
{
|
||||
if( IsImperialUnit( aUnit ) )
|
||||
if( EDA_UNIT_UTILS::IsImperialUnit( aUnit ) )
|
||||
m_imperialUnit = aUnit;
|
||||
else if( IsMetricUnit( aUnit ) )
|
||||
else if( EDA_UNIT_UTILS::IsMetricUnit( aUnit ) )
|
||||
m_metricUnit = aUnit;
|
||||
else
|
||||
wxASSERT_MSG( false, "Invalid unit" );
|
||||
@ -514,9 +514,9 @@ int COMMON_TOOLS::SwitchUnits( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
|
||||
|
||||
if( IsMetricUnit( newUnit ) )
|
||||
if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
|
||||
m_metricUnit = newUnit;
|
||||
else if( IsImperialUnit( newUnit ) )
|
||||
else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
|
||||
m_imperialUnit = newUnit;
|
||||
else
|
||||
wxASSERT_MSG( false, "Invalid unit for the frame" );
|
||||
@ -528,7 +528,7 @@ int COMMON_TOOLS::SwitchUnits( const TOOL_EVENT& aEvent )
|
||||
|
||||
int COMMON_TOOLS::ToggleUnits( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->ChangeUserUnits( IsImperialUnit( m_frame->GetUserUnits() ) ?
|
||||
m_frame->ChangeUserUnits( EDA_UNIT_UTILS::IsImperialUnit( m_frame->GetUserUnits() ) ?
|
||||
m_metricUnit :
|
||||
m_imperialUnit );
|
||||
return 0;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <kiway.h>
|
||||
#include <kiway_player.h>
|
||||
#include <dialog_shim.h>
|
||||
#include <common.h>
|
||||
#include <env_paths.h>
|
||||
|
||||
#include <widgets/grid_text_button_helpers.h>
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <confirm.h>
|
||||
#include <project.h>
|
||||
|
||||
#include <wx/textfile.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <common.h>
|
||||
#include <eda_item.h>
|
||||
#include <gr_text.h>
|
||||
#include <kicad_string.h>
|
||||
|
@ -25,6 +25,7 @@
|
||||
* @file lib_text.cpp
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <gr_text.h>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <pin_type.h>
|
||||
#include <lib_pin.h>
|
||||
#include <base_units.h>
|
||||
#include <macros.h>
|
||||
|
||||
|
||||
// These are true singletons so it's OK for them to be globals.
|
||||
|
@ -31,7 +31,9 @@
|
||||
#include <settings/color_settings.h>
|
||||
#include <bitmaps.h>
|
||||
#include <base_units.h>
|
||||
#include <common.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <macros.h>
|
||||
#include <sch_bitmap.h>
|
||||
#include <trigo.h>
|
||||
|
||||
|
@ -28,8 +28,10 @@
|
||||
|
||||
#include <sch_draw_panel.h>
|
||||
#include <trigo.h>
|
||||
#include <common.h>
|
||||
#include <plotter.h>
|
||||
#include <bitmaps.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <sch_painter.h>
|
||||
#include <sch_junction.h>
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <sch_no_connect.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <default_values.h> // For some default values
|
||||
#include <macros.h>
|
||||
#include <trigo.h>
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user