2021-08-25 23:14:36 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 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 <pcb_edit_frame.h>
|
|
|
|
#include <pcb_painter.h>
|
|
|
|
#include <board.h>
|
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <panel_setup_formatting.h>
|
2021-12-28 00:03:19 +00:00
|
|
|
#include <widgets/paged_dialog.h>
|
|
|
|
#include <wx/treebook.h>
|
2021-08-25 23:14:36 +00:00
|
|
|
|
|
|
|
|
2021-12-28 00:03:19 +00:00
|
|
|
PANEL_SETUP_FORMATTING::PANEL_SETUP_FORMATTING( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
|
|
|
|
PANEL_SETUP_FORMATTING_BASE( aParent->GetTreebook() ),
|
2021-08-25 23:14:36 +00:00
|
|
|
m_frame( aFrame )
|
|
|
|
{
|
2022-12-14 23:21:15 +00:00
|
|
|
wxSize minSize = m_dashLengthCtrl->GetMinSize();
|
|
|
|
int minWidth = m_dashLengthCtrl->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
|
|
|
|
|
|
|
|
m_dashLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
|
|
|
|
m_gapLengthCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
|
2021-12-28 00:03:19 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
bool PANEL_SETUP_FORMATTING::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
const PCB_PLOT_PARAMS& settings = m_frame->GetBoard()->GetPlotOptions();
|
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
|
|
|
settings.GetDashedLineDashRatio() ) );
|
2021-08-25 23:14:36 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
|
|
|
settings.GetDashedLineGapRatio() ) );
|
2021-08-25 23:14:36 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
PCB_PLOT_PARAMS settings = m_frame->GetBoard()->GetPlotOptions();
|
|
|
|
|
2022-09-16 04:38:10 +00:00
|
|
|
settings.SetDashedLineDashRatio( EDA_UNIT_UTILS::UI::DoubleValueFromString( m_dashLengthCtrl->GetValue() ) );
|
|
|
|
settings.SetDashedLineGapRatio( EDA_UNIT_UTILS::UI::DoubleValueFromString( m_gapLengthCtrl->GetValue() ) );
|
2021-08-25 23:14:36 +00:00
|
|
|
|
|
|
|
m_frame->GetBoard()->SetPlotOptions( settings );
|
|
|
|
|
|
|
|
KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView();
|
|
|
|
|
|
|
|
view->GetPainter()->GetSettings()->SetDashLengthRatio( settings.GetDashedLineDashRatio() );
|
|
|
|
view->GetPainter()->GetSettings()->SetGapLengthRatio( settings.GetDashedLineGapRatio() );
|
|
|
|
view->MarkDirty();
|
|
|
|
view->UpdateAllItems( KIGFX::REPAINT );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_FORMATTING::ImportSettingsFrom( BOARD* aBoard )
|
|
|
|
{
|
|
|
|
const PCB_PLOT_PARAMS& importedSettings = aBoard->GetPlotOptions();
|
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
|
|
|
importedSettings.GetDashedLineDashRatio() ) );
|
2021-08-25 23:14:36 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
|
|
|
importedSettings.GetDashedLineGapRatio() ) );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|