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
|
2020-12-19 00:19:47 +00:00
|
|
|
* Copyright (C) 1992-2020 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>
|
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_settings.h>
|
2021-03-14 15:29:24 +00:00
|
|
|
#include <ratsnest/ratsnest_view_item.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#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 ) :
|
2020-12-19 00:19:47 +00:00
|
|
|
PANEL_EDIT_OPTIONS_BASE( aParent->GetTreebook() ), m_frame( aFrame )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
2020-12-19 00:19:47 +00:00
|
|
|
m_magneticPads->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) != nullptr );
|
|
|
|
m_magneticGraphics->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) != nullptr );
|
|
|
|
m_flipLeftRight->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) != nullptr );
|
2021-01-19 13:16:26 +00:00
|
|
|
m_autoLockPads->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) != nullptr );
|
2020-12-05 15:04:42 +00:00
|
|
|
|
|
|
|
#ifdef __WXOSX_MAC__
|
2020-12-19 00:19:47 +00:00
|
|
|
m_mouseCmdsOSX->Show( true );
|
|
|
|
m_mouseCmdsWinLin->Show( false );
|
2020-12-05 15:04:42 +00:00
|
|
|
#else
|
2020-12-19 00:19:47 +00:00
|
|
|
m_mouseCmdsWinLin->Show( true );
|
|
|
|
m_mouseCmdsOSX->Show( false );
|
2020-12-05 15:04:42 +00:00
|
|
|
#endif
|
2020-06-17 20:45:03 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_optionsBook->SetSelection( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) ? 1 : 0 );
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
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-12-19 00:19:47 +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
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_segments45OnlyCtrl->SetValue( general_opts.m_Use45DegreeGraphicSegments );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
wxString rotationAngle;
|
2020-12-19 00:19:47 +00:00
|
|
|
rotationAngle = AngleToStringDegrees( (double) m_frame->GetRotationAngle() );
|
|
|
|
m_rotationAngle->SetValue( rotationAngle );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
if( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
|
|
|
/* Set display options */
|
|
|
|
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts.m_DisplayRatsnestLinesCurved );
|
|
|
|
m_showSelectedRatsnest->SetValue( displ_opts.m_ShowModuleRatsnest );
|
|
|
|
|
|
|
|
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 );
|
2020-12-19 00:19:47 +00:00
|
|
|
m_flipLeftRight->SetValue( general_opts.m_FlipLeftRight );
|
2021-01-19 13:16:26 +00:00
|
|
|
m_autoLockPads->SetValue( !general_opts.m_AddUnlockedPads );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-12-19 00:19:47 +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
|
|
|
}
|
2020-12-19 00:19:47 +00:00
|
|
|
else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
2020-12-19 00:19:47 +00:00
|
|
|
m_magneticPads->SetValue( m_frame->GetMagneticItemsSettings()->pads
|
|
|
|
== MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
|
|
|
|
m_magneticGraphics->SetValue( m_frame->GetMagneticItemsSettings()->graphics );
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
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
|
|
|
{
|
2020-12-19 00:19:47 +00:00
|
|
|
PCB_DISPLAY_OPTIONS displ_opts = m_frame->GetDisplayOptions();
|
2020-08-15 00:04:52 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_rotationAngle->GetValue() ) ) );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->Settings().m_Use45DegreeGraphicSegments = m_segments45OnlyCtrl->GetValue();
|
2020-05-22 18:27:05 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
if( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) )
|
2020-08-15 00:04:52 +00:00
|
|
|
{
|
2020-12-19 00:19:47 +00:00
|
|
|
PCBNEW_SETTINGS& pcbnewSettings = m_frame->Settings();
|
2020-05-22 18:27:05 +00:00
|
|
|
|
2020-08-15 00:04:52 +00:00
|
|
|
displ_opts.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
|
|
|
|
displ_opts.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->Settings().m_MagneticItems.pads =
|
2020-08-15 00:04:52 +00:00
|
|
|
static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->Settings().m_MagneticItems.tracks =
|
2020-08-15 00:04:52 +00:00
|
|
|
static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->Settings().m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->Settings().m_FlipLeftRight = m_flipLeftRight->GetValue();
|
|
|
|
m_frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
|
2021-01-19 13:16:26 +00:00
|
|
|
m_frame->Settings().m_AddUnlockedPads = !m_autoLockPads->GetValue();
|
2020-06-21 19:39:27 +00:00
|
|
|
|
|
|
|
if( m_rbTrackDragMove->GetValue() )
|
2020-08-15 00:04:52 +00:00
|
|
|
pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE;
|
2020-06-21 19:39:27 +00:00
|
|
|
else if( m_rbTrackDrag45->GetValue() )
|
2020-08-15 00:04:52 +00:00
|
|
|
pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG;
|
2020-06-21 19:39:27 +00:00
|
|
|
else if( m_rbTrackDragFree->GetValue() )
|
2020-08-15 00:04:52 +00:00
|
|
|
pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG_FREE_ANGLE;
|
|
|
|
}
|
2020-12-19 00:19:47 +00:00
|
|
|
else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
|
2020-08-15 00:04:52 +00:00
|
|
|
{
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->GetMagneticItemsSettings()->pads = m_magneticPads->GetValue()
|
|
|
|
? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
|
|
|
|
: MAGNETIC_OPTIONS::NO_EFFECT;
|
|
|
|
|
|
|
|
m_frame->GetMagneticItemsSettings()->graphics = m_magneticGraphics->GetValue();
|
2020-06-21 19:39:27 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 08:24:57 +00:00
|
|
|
// Apply changes to the GAL
|
2020-12-19 00:19:47 +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
|
|
|
|
2021-03-14 15:29:24 +00:00
|
|
|
m_frame->SetDisplayOptions( displ_opts, false );
|
2020-12-19 00:19:47 +00:00
|
|
|
settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() );
|
2021-03-14 15:29:24 +00:00
|
|
|
|
|
|
|
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
|
|
|
[]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
|
|
|
{
|
|
|
|
return dynamic_cast<RATSNEST_VIEW_ITEM*>( aItem );
|
|
|
|
} );
|
2019-06-13 00:32:47 +00:00
|
|
|
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
|
|
|
2020-12-19 00:19:47 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2018-07-01 08:24:57 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|