2020-07-06 21:33:03 -04: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
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2020-07-06 21:33:03 -04: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-30 00:33:08 +01:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <pcbnew_settings.h>
|
2023-10-25 13:59:12 +01:00
|
|
|
#include <footprint_editor_settings.h>
|
2020-07-06 21:33:03 -04:00
|
|
|
#include <panel_pcbnew_display_origin.h>
|
|
|
|
|
2021-06-03 11:41:26 -04:00
|
|
|
|
2025-06-09 11:58:54 +01:00
|
|
|
PANEL_PCBNEW_DISPLAY_ORIGIN::PANEL_PCBNEW_DISPLAY_ORIGIN( wxWindow* aParent, APP_SETTINGS_BASE* aCfg,
|
2023-10-25 13:59:12 +01:00
|
|
|
FRAME_T aFrameType ) :
|
|
|
|
PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent ),
|
|
|
|
m_cfg( aCfg ),
|
|
|
|
m_frameType( aFrameType )
|
2020-07-06 21:33:03 -04:00
|
|
|
{
|
2025-06-09 11:58:54 +01:00
|
|
|
m_displayOrigin->Show( m_frameType == FRAME_PCB_EDITOR );
|
2020-07-06 21:33:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-25 13:59:12 +01:00
|
|
|
void PANEL_PCBNEW_DISPLAY_ORIGIN::loadSettings( APP_SETTINGS_BASE* aCfg )
|
2020-07-06 21:33:03 -04:00
|
|
|
{
|
2023-10-25 13:59:12 +01:00
|
|
|
if( m_frameType == FRAME_FOOTPRINT_EDITOR )
|
|
|
|
{
|
2025-07-18 11:48:54 +01:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" );
|
2020-07-06 21:33:03 -04:00
|
|
|
|
2025-07-18 11:48:54 +01:00
|
|
|
if( cfg && cfg->m_DisplayInvertXAxis )
|
2025-06-09 11:58:54 +01:00
|
|
|
m_xIncreasesLeft->SetValue( true );
|
|
|
|
else
|
|
|
|
m_xIncreasesRight->SetValue( true );
|
|
|
|
|
2025-07-18 11:48:54 +01:00
|
|
|
if( cfg && cfg->m_DisplayInvertYAxis )
|
2025-06-09 11:58:54 +01:00
|
|
|
m_yIncreasesUp->SetValue( true );
|
|
|
|
else
|
|
|
|
m_yIncreasesDown->SetValue( true );
|
2023-10-25 13:59:12 +01:00
|
|
|
}
|
|
|
|
else
|
2020-07-06 21:33:03 -04:00
|
|
|
{
|
2025-07-18 11:48:54 +01:00
|
|
|
PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
|
2025-06-09 11:58:54 +01:00
|
|
|
|
2025-07-18 11:48:54 +01:00
|
|
|
if( cfg && cfg->m_Display.m_DisplayOrigin == PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE )
|
2025-06-09 11:58:54 +01:00
|
|
|
m_pageOrigin->SetValue( true );
|
2025-07-18 11:48:54 +01:00
|
|
|
else if( cfg && cfg->m_Display.m_DisplayOrigin == PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID )
|
2025-06-09 11:58:54 +01:00
|
|
|
m_gridOrigin->SetValue( true );
|
|
|
|
else
|
|
|
|
m_drillPlaceOrigin->SetValue( true );
|
|
|
|
|
2025-07-18 11:48:54 +01:00
|
|
|
if( cfg &&cfg->m_Display.m_DisplayInvertXAxis )
|
2025-06-09 11:58:54 +01:00
|
|
|
m_xIncreasesLeft->SetValue( true );
|
|
|
|
else
|
|
|
|
m_xIncreasesRight->SetValue( true );
|
|
|
|
|
2025-07-18 11:48:54 +01:00
|
|
|
if( cfg && cfg->m_Display.m_DisplayInvertYAxis )
|
2025-06-09 11:58:54 +01:00
|
|
|
m_yIncreasesUp->SetValue( true );
|
|
|
|
else
|
|
|
|
m_yIncreasesDown->SetValue( true );
|
2020-07-06 21:33:03 -04:00
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow()
|
|
|
|
{
|
2023-10-25 13:59:12 +01:00
|
|
|
loadSettings( m_cfg );
|
2020-07-06 21:33:03 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataFromWindow()
|
|
|
|
{
|
2023-10-25 13:59:12 +01:00
|
|
|
if( m_frameType == FRAME_FOOTPRINT_EDITOR )
|
2020-07-06 21:33:03 -04:00
|
|
|
{
|
2025-07-18 11:48:54 +01:00
|
|
|
if( FOOTPRINT_EDITOR_SETTINGS* cfg = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" ) )
|
|
|
|
{
|
2025-06-09 11:58:54 +01:00
|
|
|
cfg->m_DisplayInvertXAxis = m_xIncreasesLeft->GetValue();
|
|
|
|
cfg->m_DisplayInvertYAxis = m_yIncreasesUp->GetValue();
|
2025-07-18 11:48:54 +01:00
|
|
|
}
|
2020-07-06 21:33:03 -04:00
|
|
|
}
|
2023-10-25 13:59:12 +01:00
|
|
|
else
|
|
|
|
{
|
2025-07-18 11:48:54 +01:00
|
|
|
if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
|
|
|
|
{
|
|
|
|
if( m_pageOrigin->GetValue() )
|
|
|
|
cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE;
|
|
|
|
else if( m_gridOrigin->GetValue() )
|
|
|
|
cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID;
|
|
|
|
else
|
|
|
|
cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX;
|
|
|
|
|
|
|
|
cfg->m_Display.m_DisplayInvertXAxis = m_xIncreasesLeft->GetValue();
|
|
|
|
cfg->m_Display.m_DisplayInvertYAxis = m_yIncreasesUp->GetValue();
|
|
|
|
}
|
2023-10-25 13:59:12 +01:00
|
|
|
}
|
2020-07-06 21:33:03 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PANEL_PCBNEW_DISPLAY_ORIGIN::ResetPanel()
|
|
|
|
{
|
2023-10-25 13:59:12 +01: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 13:59:12 +01: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
|
|
|
}
|
|
|
|
|
|
|
|
|