2020-07-07 01:33:03 +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
|
2023-10-25 12:59:12 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-07-07 01:33:03 +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
|
|
|
|
*/
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <pcbnew_settings.h>
|
2023-10-25 12:59:12 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
2020-07-07 01:33:03 +00:00
|
|
|
#include <panel_pcbnew_display_origin.h>
|
|
|
|
|
2021-06-03 15:41:26 +00:00
|
|
|
|
2023-10-25 12:59:12 +00:00
|
|
|
PANEL_PCBNEW_DISPLAY_ORIGIN::PANEL_PCBNEW_DISPLAY_ORIGIN( wxWindow* aParent,
|
|
|
|
APP_SETTINGS_BASE* aCfg,
|
|
|
|
FRAME_T aFrameType ) :
|
|
|
|
PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent ),
|
|
|
|
m_cfg( aCfg ),
|
|
|
|
m_frameType( aFrameType )
|
2020-07-07 01:33:03 +00:00
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
m_DisplayOrigin->Show( m_frameType == FRAME_PCB_EDITOR );
|
2020-07-07 01:33:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-25 12:59:12 +00:00
|
|
|
void PANEL_PCBNEW_DISPLAY_ORIGIN::loadSettings( APP_SETTINGS_BASE* aCfg )
|
2020-07-07 01:33:03 +00:00
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
if( m_frameType == FRAME_FOOTPRINT_EDITOR )
|
|
|
|
{
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = static_cast<FOOTPRINT_EDITOR_SETTINGS*>( aCfg );
|
2020-07-07 01:33:03 +00:00
|
|
|
|
2023-10-25 12:59:12 +00:00
|
|
|
m_XAxisDirection->SetSelection( cfg->m_DisplayInvertXAxis ? 1 : 0 );
|
|
|
|
m_YAxisDirection->SetSelection( cfg->m_DisplayInvertYAxis ? 0 : 1 );
|
|
|
|
}
|
|
|
|
else
|
2020-07-07 01:33:03 +00:00
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = static_cast<PCBNEW_SETTINGS*>( aCfg );
|
|
|
|
int origin = 0;
|
|
|
|
|
|
|
|
switch( cfg->m_Display.m_DisplayOrigin )
|
|
|
|
{
|
|
|
|
case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE: origin = 0; break;
|
|
|
|
case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = 1; break;
|
|
|
|
case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID: origin = 2; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_DisplayOrigin->SetSelection( origin );
|
|
|
|
m_XAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertXAxis ? 1 : 0 );
|
|
|
|
m_YAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertYAxis ? 0 : 1 );
|
2020-07-07 01:33:03 +00:00
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow()
|
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
loadSettings( m_cfg );
|
2020-07-07 01:33:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataFromWindow()
|
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
if( m_frameType == FRAME_FOOTPRINT_EDITOR )
|
2020-07-07 01:33:03 +00:00
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = static_cast<FOOTPRINT_EDITOR_SETTINGS*>( m_cfg );
|
|
|
|
|
|
|
|
cfg->m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0;
|
|
|
|
cfg->m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0;
|
2020-07-07 01:33:03 +00:00
|
|
|
}
|
2023-10-25 12:59:12 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS* cfg = static_cast<PCBNEW_SETTINGS*>( m_cfg );
|
2020-07-07 01:33:03 +00:00
|
|
|
|
2023-10-25 12:59:12 +00:00
|
|
|
switch( m_DisplayOrigin->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE; break;
|
|
|
|
case 1: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX; break;
|
|
|
|
case 2: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg->m_Display.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0;
|
|
|
|
cfg->m_Display.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0;
|
|
|
|
}
|
2020-07-07 01:33:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PANEL_PCBNEW_DISPLAY_ORIGIN::ResetPanel()
|
|
|
|
{
|
2023-10-25 12:59:12 +00:00
|
|
|
if( m_frameType == FRAME_FOOTPRINT_EDITOR )
|
|
|
|
{
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
2021-11-01 11:20:13 +00:00
|
|
|
|
2023-10-25 12:59:12 +00:00
|
|
|
loadSettings( &cfg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
|
|
|
|
|
|
|
loadSettings( &cfg );
|
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|