2018-05-14 17:34:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2019-01-29 14:04:12 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-05-14 17:34:18 +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 <board_design_settings.h>
|
|
|
|
#include <class_board.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <fctsys.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <panel_pcbnew_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2018-07-01 08:24:57 +00:00
|
|
|
#include <pcb_painter.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcb_view.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_settings.h>
|
|
|
|
#include <widgets/paged_dialog.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2018-07-15 23:15:48 +00:00
|
|
|
PANEL_PCBNEW_SETTINGS::PANEL_PCBNEW_SETTINGS( PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ) :
|
|
|
|
PANEL_PCBNEW_SETTINGS_BASE( aParent->GetTreebook() ),
|
2018-05-14 17:34:18 +00:00
|
|
|
m_Frame( aFrame )
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow()
|
|
|
|
{
|
2019-11-07 14:23:09 +00:00
|
|
|
const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
|
2020-01-13 01:44:19 +00:00
|
|
|
const PCBNEW_SETTINGS& general_opts = m_Frame->Settings();
|
2019-06-13 00:32:47 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
/* Set display options */
|
2019-05-17 11:52:38 +00:00
|
|
|
m_PolarDisplay->SetSelection( m_Frame->GetShowPolarCoords() ? 1 : 0 );
|
2019-12-20 14:11:39 +00:00
|
|
|
m_UnitsSelection->SetSelection( m_Frame->GetUserUnits() == EDA_UNITS::INCHES ? 0 : 1 );
|
2019-11-07 14:23:09 +00:00
|
|
|
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts.m_DisplayRatsnestLinesCurved );
|
|
|
|
m_showGlobalRatsnest->SetValue( displ_opts.m_ShowGlobalRatsnest );
|
|
|
|
m_showSelectedRatsnest->SetValue( displ_opts.m_ShowModuleRatsnest );
|
|
|
|
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts.m_DisplayRatsnestLinesCurved );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
wxString rotationAngle;
|
|
|
|
rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
|
|
|
|
m_RotationAngle->SetValue( rotationAngle );
|
|
|
|
|
2019-06-26 12:12:32 +00:00
|
|
|
m_Segments_45_Only_Ctrl->SetValue( general_opts.m_Use45DegreeGraphicSegments );
|
2020-01-13 01:44:19 +00:00
|
|
|
m_magneticPadChoice->SetSelection( static_cast<int>( general_opts.m_MagneticPads ) );
|
|
|
|
m_magneticTrackChoice->SetSelection( static_cast<int>( general_opts.m_MagneticTracks ) );
|
2019-06-26 12:12:32 +00:00
|
|
|
m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticGraphics );
|
2019-07-12 21:02:10 +00:00
|
|
|
m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
m_Show_Page_Limits->SetValue( m_Frame->ShowPageLimits() );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow()
|
|
|
|
{
|
2019-05-17 11:52:38 +00:00
|
|
|
m_Frame->SetShowPolarCoords( m_PolarDisplay->GetSelection() != 0 );
|
2019-12-20 14:11:39 +00:00
|
|
|
m_Frame->SetUserUnits(
|
|
|
|
m_UnitsSelection->GetSelection() == 0 ? EDA_UNITS::INCHES : EDA_UNITS::MILLIMETRES );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
m_Frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
|
|
|
|
|
|
|
|
/* Updating the combobox to display the active layer. */
|
|
|
|
|
2019-06-26 12:12:32 +00:00
|
|
|
m_Frame->Settings().m_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
|
|
|
m_Frame->Settings().m_MagneticPads = (MAGNETIC_OPTIONS) m_magneticPadChoice->GetSelection();
|
|
|
|
m_Frame->Settings().m_MagneticTracks = (MAGNETIC_OPTIONS) m_magneticTrackChoice->GetSelection();
|
|
|
|
m_Frame->Settings().m_MagneticGraphics = !m_magneticGraphicsChoice->GetSelection();
|
2019-07-12 21:02:10 +00:00
|
|
|
m_Frame->Settings().m_FlipLeftRight = m_FlipLeftRight->GetValue();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
|
|
|
|
|
2018-07-01 08:24:57 +00:00
|
|
|
// Apply changes to the GAL
|
2019-11-07 14:23:09 +00:00
|
|
|
PCB_DISPLAY_OPTIONS displ_opts = m_Frame->GetDisplayOptions();
|
2019-06-13 17:28:55 +00:00
|
|
|
KIGFX::VIEW* view = m_Frame->GetCanvas()->GetView();
|
2019-05-17 11:52:38 +00:00
|
|
|
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
|
2018-07-01 08:24:57 +00:00
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
|
2019-06-01 10:39:39 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
displ_opts.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
|
|
|
|
displ_opts.m_ShowGlobalRatsnest = m_showGlobalRatsnest->GetValue();
|
|
|
|
displ_opts.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
|
2019-06-13 00:32:47 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
m_Frame->SetDisplayOptions( displ_opts );
|
2018-07-01 08:24:57 +00:00
|
|
|
settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() );
|
2019-06-13 00:32:47 +00:00
|
|
|
view->RecacheAllItems();
|
|
|
|
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
m_Frame->GetCanvas()->Refresh();
|
2018-07-01 08:24:57 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|