2020-03-10 18:46:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-02-09 17:18:56 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-03-10 18:46:57 +00:00
|
|
|
*
|
|
|
|
* 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 <sch_edit_frame.h>
|
2020-04-04 20:32:14 +00:00
|
|
|
#include <sch_painter.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
#include <panel_setup_formatting.h>
|
|
|
|
#include <sch_junction.h>
|
2020-05-23 15:50:08 +00:00
|
|
|
#include <schematic.h>
|
2020-05-20 03:34:55 +00:00
|
|
|
#include <schematic_settings.h>
|
2021-09-01 18:05:46 +00:00
|
|
|
#include <project/project_file.h>
|
|
|
|
#include <project/net_settings.h>
|
2020-05-20 03:34:55 +00:00
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
PANEL_SETUP_FORMATTING::PANEL_SETUP_FORMATTING( wxWindow* aWindow, SCH_EDIT_FRAME* aFrame ) :
|
|
|
|
PANEL_SETUP_FORMATTING_BASE( aWindow ),
|
|
|
|
m_frame( aFrame ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_textSize( aFrame, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ),
|
|
|
|
m_lineWidth( aFrame, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
|
2023-10-14 19:46:39 +00:00
|
|
|
m_pinSymbolSize( aFrame, m_pinSymbolSizeLabel, m_pinSymbolSizeCtrl, m_pinSymbolSizeUnits ),
|
|
|
|
m_connectionGridSize( aFrame, m_connectionGridLabel, m_connectionGridCtrl, m_connectionGridUnits )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
2022-12-14 15:10:25 +00:00
|
|
|
wxSize minSize = m_dashLengthCtrl->GetMinSize();
|
2022-12-14 23:21:15 +00:00
|
|
|
int minWidth = m_dashLengthCtrl->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
|
2022-12-14 15:10:25 +00:00
|
|
|
|
|
|
|
m_dashLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
|
|
|
|
m_gapLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
|
|
|
|
|
2021-12-24 17:23:41 +00:00
|
|
|
m_dashedLineHelp->SetFont( KIUI::GetInfoFont( this ).Italic() );
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 23:05:01 +00:00
|
|
|
|
2021-03-04 21:29:41 +00:00
|
|
|
void PANEL_SETUP_FORMATTING::onCheckBoxIref( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
bool enabled = m_showIntersheetsReferences->GetValue();
|
|
|
|
|
|
|
|
m_radioFormatStandard->Enable( enabled );
|
|
|
|
m_radioFormatAbbreviated->Enable( enabled );
|
2022-08-21 11:26:47 +00:00
|
|
|
m_prefixLabel->Enable( enabled );
|
2021-03-04 21:29:41 +00:00
|
|
|
m_prefixCtrl->Enable( enabled );
|
2022-08-21 11:26:47 +00:00
|
|
|
m_suffixLabel->Enable( enabled );
|
2021-03-04 21:29:41 +00:00
|
|
|
m_suffixCtrl->Enable( enabled );
|
|
|
|
m_listOwnPage->Enable( enabled );
|
|
|
|
}
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
bool PANEL_SETUP_FORMATTING::TransferDataToWindow()
|
|
|
|
{
|
2020-05-23 15:50:08 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = m_frame->Schematic().Settings();
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
// Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
|
|
|
|
int refStyleSelection;
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
switch( LIB_SYMBOL::GetSubpartIdSeparator() )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: refStyleSelection = 0; break;
|
2021-06-10 18:51:46 +00:00
|
|
|
case '.': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 4 : 1; break;
|
|
|
|
case '-': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 5 : 2; break;
|
|
|
|
case '_': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 6 : 3; break;
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_choiceSeparatorRefId->SetSelection( refStyleSelection );
|
|
|
|
|
2020-10-02 22:04:16 +00:00
|
|
|
m_textSize.SetUnits( EDA_UNITS::MILS );
|
|
|
|
m_lineWidth.SetUnits( EDA_UNITS::MILS );
|
|
|
|
m_pinSymbolSize.SetUnits( EDA_UNITS::MILS );
|
2023-10-14 19:46:39 +00:00
|
|
|
m_connectionGridSize.SetUnits( EDA_UNITS::MILS );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-05-23 15:50:08 +00:00
|
|
|
m_textSize.SetValue( settings.m_DefaultTextSize );
|
|
|
|
m_lineWidth.SetValue( settings.m_DefaultLineWidth );
|
|
|
|
m_pinSymbolSize.SetValue( settings.m_PinSymbolSize );
|
2020-10-08 17:04:53 +00:00
|
|
|
m_choiceJunctionDotSize->SetSelection( settings.m_JunctionSizeChoice );
|
2023-10-14 19:46:39 +00:00
|
|
|
m_connectionGridSize.SetValue( settings.m_ConnectionGridSize );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
m_showIntersheetsReferences->SetValue( settings.m_IntersheetRefsShow );
|
2021-03-04 21:29:41 +00:00
|
|
|
|
|
|
|
m_radioFormatStandard->Enable( settings.m_IntersheetRefsShow );
|
|
|
|
m_radioFormatAbbreviated->Enable( settings.m_IntersheetRefsShow );
|
2022-08-21 11:26:47 +00:00
|
|
|
m_prefixLabel->Enable( settings.m_IntersheetRefsShow );
|
2021-03-04 21:29:41 +00:00
|
|
|
m_prefixCtrl->Enable( settings.m_IntersheetRefsShow );
|
2022-08-21 11:26:47 +00:00
|
|
|
m_suffixLabel->Enable( settings.m_IntersheetRefsShow );
|
2021-03-04 21:29:41 +00:00
|
|
|
m_suffixCtrl->Enable( settings.m_IntersheetRefsShow );
|
|
|
|
m_listOwnPage->Enable( settings.m_IntersheetRefsShow );
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
m_radioFormatStandard->SetValue( !settings.m_IntersheetRefsFormatShort );
|
|
|
|
m_radioFormatAbbreviated->SetValue( settings.m_IntersheetRefsFormatShort );
|
|
|
|
m_prefixCtrl->ChangeValue( settings.m_IntersheetRefsPrefix );
|
|
|
|
m_suffixCtrl->ChangeValue( settings.m_IntersheetRefsSuffix );
|
2021-03-04 21:29:41 +00:00
|
|
|
m_listOwnPage->SetValue( settings.m_IntersheetRefsListOwnPage );
|
2020-08-31 14:11:54 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
#define SET_VALUE( ctrl, units, value ) \
|
|
|
|
ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
|
2020-03-17 12:49:49 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, settings.m_TextOffsetRatio * 100.0 );
|
2023-08-06 19:20:53 +00:00
|
|
|
SET_VALUE( m_overbarHeightCtrl, EDA_UNITS::PERCENT, settings.m_FontMetrics.m_OverbarHeight * 100.0 );
|
2022-09-19 09:25:20 +00:00
|
|
|
SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineDashRatio );
|
|
|
|
SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineGapRatio );
|
|
|
|
SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, settings.m_LabelSizeRatio * 100.0 );
|
2021-07-22 23:05:01 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
#undef SET_VALUE
|
2021-07-25 11:42:19 +00:00
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
m_vPrecisionCtrl->SetValue( settings.m_OPO_VPrecision );
|
|
|
|
m_vRangeCtrl->SetStringSelection( settings.m_OPO_VRange );
|
|
|
|
m_iPrecisionCtrl->SetValue( settings.m_OPO_IPrecision );
|
|
|
|
m_iRangeCtrl->SetStringSelection( settings.m_OPO_IRange );
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
|
|
|
|
{
|
2023-10-14 19:46:39 +00:00
|
|
|
if( !m_connectionGridSize.Validate( MIN_CONNECTION_GRID_MILS, 10000, EDA_UNITS::MILS ) )
|
|
|
|
return false;
|
|
|
|
|
2020-05-23 15:50:08 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = m_frame->Schematic().Settings();
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
// Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1"
|
|
|
|
int firstRefId, refSeparator;
|
|
|
|
|
|
|
|
switch( m_choiceSeparatorRefId->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: firstRefId = 'A'; refSeparator = 0; break;
|
|
|
|
case 1: firstRefId = 'A'; refSeparator = '.'; break;
|
|
|
|
case 2: firstRefId = 'A'; refSeparator = '-'; break;
|
|
|
|
case 3: firstRefId = 'A'; refSeparator = '_'; break;
|
|
|
|
case 4: firstRefId = '1'; refSeparator = '.'; break;
|
|
|
|
case 5: firstRefId = '1'; refSeparator = '-'; break;
|
|
|
|
case 6: firstRefId = '1'; refSeparator = '_'; break;
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( refSeparator != LIB_SYMBOL::GetSubpartIdSeparator() ||
|
|
|
|
firstRefId != LIB_SYMBOL::GetSubpartFirstId() )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL::SetSubpartIdNotation( refSeparator, firstRefId );
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
2023-10-14 19:46:39 +00:00
|
|
|
settings.m_DefaultTextSize = m_textSize.GetIntValue();
|
|
|
|
settings.m_DefaultLineWidth = m_lineWidth.GetIntValue();
|
|
|
|
settings.m_PinSymbolSize = m_pinSymbolSize.GetIntValue();
|
|
|
|
settings.m_ConnectionGridSize = m_connectionGridSize.GetIntValue();
|
2020-11-10 13:50:16 +00:00
|
|
|
|
2021-09-01 18:05:46 +00:00
|
|
|
if( m_choiceJunctionDotSize->GetSelection() != wxNOT_FOUND )
|
|
|
|
settings.m_JunctionSizeChoice = m_choiceJunctionDotSize->GetSelection();
|
2020-05-20 03:34:55 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
settings.m_IntersheetRefsShow = m_showIntersheetsReferences->GetValue();
|
|
|
|
settings.m_IntersheetRefsFormatShort = !m_radioFormatStandard->GetValue();
|
|
|
|
settings.m_IntersheetRefsPrefix = m_prefixCtrl->GetValue();
|
|
|
|
settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue();
|
2021-03-04 21:29:41 +00:00
|
|
|
settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue();
|
2020-08-31 14:11:54 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
#define GET_VALUE( units, str ) EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, units, str )
|
2021-07-22 23:05:01 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
settings.m_TextOffsetRatio = GET_VALUE( EDA_UNITS::PERCENT, m_textOffsetRatioCtrl->GetValue() ) / 100.0;
|
2023-08-06 19:20:53 +00:00
|
|
|
settings.m_FontMetrics.m_OverbarHeight = GET_VALUE( EDA_UNITS::PERCENT, m_overbarHeightCtrl->GetValue() ) / 100.0;
|
2022-09-19 09:25:20 +00:00
|
|
|
settings.m_DashedLineDashRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() );
|
|
|
|
settings.m_DashedLineGapRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() );
|
|
|
|
settings.m_LabelSizeRatio = GET_VALUE( EDA_UNITS::PERCENT, m_labelSizeRatioCtrl->GetValue() ) / 100.0;
|
2020-05-23 15:50:08 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
#undef GET_VALUE
|
2021-07-25 11:42:19 +00:00
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
settings.m_OPO_VPrecision = m_vPrecisionCtrl->GetValue();
|
|
|
|
|
|
|
|
if( m_vRangeCtrl->GetSelection() == 0 )
|
|
|
|
settings.m_OPO_VRange = wxS( "~V" );
|
|
|
|
else
|
|
|
|
settings.m_OPO_VRange = m_vRangeCtrl->GetStringSelection();
|
|
|
|
|
|
|
|
settings.m_OPO_IPrecision = m_iPrecisionCtrl->GetValue();
|
|
|
|
|
|
|
|
if( m_iRangeCtrl->GetSelection() == 0 )
|
|
|
|
settings.m_OPO_IRange = wxS( "~A" );
|
|
|
|
else
|
|
|
|
settings.m_OPO_IRange = m_iRangeCtrl->GetStringSelection();
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
void PANEL_SETUP_FORMATTING::ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings )
|
|
|
|
{
|
|
|
|
m_textSize.SetValue( aSettings.m_DefaultTextSize );
|
|
|
|
m_lineWidth.SetValue( aSettings.m_DefaultLineWidth );
|
|
|
|
m_pinSymbolSize.SetValue( aSettings.m_PinSymbolSize );
|
2023-10-14 19:46:39 +00:00
|
|
|
m_connectionGridSize.SetValue( aSettings.m_ConnectionGridSize );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
m_showIntersheetsReferences->SetValue( aSettings.m_IntersheetRefsShow );
|
|
|
|
m_radioFormatStandard->SetValue( aSettings.m_IntersheetRefsFormatShort );
|
|
|
|
m_radioFormatAbbreviated->SetValue( !aSettings.m_IntersheetRefsFormatShort );
|
|
|
|
m_prefixCtrl->ChangeValue( aSettings.m_IntersheetRefsPrefix );
|
|
|
|
m_suffixCtrl->ChangeValue( aSettings.m_IntersheetRefsSuffix );
|
2021-03-04 21:29:41 +00:00
|
|
|
m_listOwnPage->SetValue( aSettings.m_IntersheetRefsListOwnPage );
|
2020-08-31 14:11:54 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
#define SET_VALUE( ctrl, units, value ) \
|
|
|
|
ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
|
2021-08-25 23:14:36 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_TextOffsetRatio * 100.0 );
|
|
|
|
SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineDashRatio );
|
|
|
|
SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineGapRatio );
|
|
|
|
SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_LabelSizeRatio * 100.0 );
|
2021-08-25 23:14:36 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
#undef SET_VALUE
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|