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>
|
2020-06-17 20:45:03 +00:00
|
|
|
#include <panel_edit_options.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>
|
2020-06-17 20:45:03 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( PCB_BASE_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ) :
|
|
|
|
PANEL_EDIT_OPTIONS_BASE( aParent->GetTreebook() ),
|
2018-05-14 17:34:18 +00:00
|
|
|
m_Frame( aFrame )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
|
|
|
m_MagneticPads->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_Frame ) != nullptr );
|
|
|
|
m_FlipLeftRight->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) != nullptr );\
|
|
|
|
|
|
|
|
m_optionsBook->SetSelection( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) ? 1 : 0 );
|
|
|
|
}
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
bool PANEL_EDIT_OPTIONS::TransferDataToWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2020-06-17 20:45:03 +00:00
|
|
|
const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
|
|
|
|
const PCBNEW_SETTINGS& general_opts = m_Frame->Settings();
|
2019-06-13 00:32:47 +00:00
|
|
|
|
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 );
|
2020-06-17 20:45:03 +00:00
|
|
|
|
|
|
|
m_Segments_45_Only_Ctrl->SetValue( general_opts.m_Use45DegreeGraphicSegments );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
wxString rotationAngle;
|
|
|
|
rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
|
|
|
|
m_RotationAngle->SetValue( rotationAngle );
|
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
if( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) )
|
|
|
|
{
|
|
|
|
/* Set display options */
|
|
|
|
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 );
|
|
|
|
|
|
|
|
m_magneticPadChoice->SetSelection( static_cast<int>( general_opts.m_MagneticItems.pads ) );
|
|
|
|
m_magneticTrackChoice->SetSelection( static_cast<int>( general_opts.m_MagneticItems.tracks ) );
|
|
|
|
m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticItems.graphics );
|
|
|
|
m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
m_Show_Page_Limits->SetValue( m_Frame->ShowPageLimits() );
|
2020-06-21 19:39:27 +00:00
|
|
|
|
|
|
|
switch( general_opts.m_TrackDragAction )
|
|
|
|
{
|
|
|
|
case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break;
|
|
|
|
case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break;
|
|
|
|
case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break;
|
|
|
|
}
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
|
|
|
else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_Frame ) )
|
|
|
|
{
|
|
|
|
m_MagneticPads->SetValue(
|
|
|
|
m_Frame->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
|
|
|
|
}
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
bool PANEL_EDIT_OPTIONS::TransferDataFromWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
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() ) ) );
|
|
|
|
|
2019-06-26 12:12:32 +00:00
|
|
|
m_Frame->Settings().m_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
2020-05-22 18:27:05 +00:00
|
|
|
|
|
|
|
m_Frame->Settings().m_MagneticItems.pads =
|
|
|
|
static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
|
|
|
|
m_Frame->Settings().m_MagneticItems.tracks =
|
|
|
|
static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
|
|
|
|
m_Frame->Settings().m_MagneticItems.graphics = !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() );
|
|
|
|
|
2020-06-21 19:39:27 +00:00
|
|
|
if( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) )
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS& settings = m_Frame->Settings();
|
|
|
|
|
|
|
|
if( m_rbTrackDragMove->GetValue() )
|
|
|
|
settings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE;
|
|
|
|
else if( m_rbTrackDrag45->GetValue() )
|
|
|
|
settings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG;
|
|
|
|
else if( m_rbTrackDragFree->GetValue() )
|
|
|
|
settings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG_FREE_ANGLE;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|