2014-06-20 11:13:04 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-02 08:06:39 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
|
2018-01-08 04:05:03 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-06-20 11:13:04 +00:00
|
|
|
*
|
2018-01-08 04:05: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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2014-06-20 11:13:04 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* 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.
|
2014-06-20 11:13:04 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-06-20 11:13:04 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
/* functions relatives to the dialog opened from the main menu :
|
2014-06-20 11:13:04 +00:00
|
|
|
Preferences/display
|
2009-06-18 17:32:27 +00:00
|
|
|
*/
|
2014-06-20 11:13:04 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2017-10-30 17:21:07 +00:00
|
|
|
#include <pcb_display_options.h>
|
2017-02-16 05:03:26 +00:00
|
|
|
#include <config_map.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
|
|
|
|
#include <dialog_display_options.h>
|
|
|
|
#include <dialog_display_options_base.h>
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2014-04-04 09:56:04 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2017-10-30 19:17:23 +00:00
|
|
|
#include <pcb_view.h>
|
2013-07-17 11:38:56 +00:00
|
|
|
#include <pcb_painter.h>
|
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
#include <widgets/gal_options_panel.h>
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2011-09-30 08:24:10 +00:00
|
|
|
|
2017-10-30 17:21:07 +00:00
|
|
|
static const UTIL::CFG_MAP<PCB_DISPLAY_OPTIONS::TRACE_CLEARANCE_DISPLAY_MODE_T> traceClearanceSelectMap =
|
2017-02-14 05:16:47 +00:00
|
|
|
{
|
2017-10-30 17:21:07 +00:00
|
|
|
{ PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS, 2 }, // Default
|
|
|
|
{ PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE, 0 },
|
|
|
|
{ PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS, 1 },
|
|
|
|
{ PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS, 3 },
|
|
|
|
{ PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS, 4 },
|
2017-02-16 05:03:26 +00:00
|
|
|
};
|
2017-01-11 15:19:58 +00:00
|
|
|
|
2017-02-14 05:16:47 +00:00
|
|
|
|
|
|
|
void PCB_EDIT_FRAME::InstallDisplayOptionsDialog( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
DIALOG_DISPLAY_OPTIONS dlg( this );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) :
|
2017-03-13 16:13:04 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS_BASE( parent ),
|
2018-02-16 16:57:18 +00:00
|
|
|
m_parent( parent )
|
2017-02-14 05:16:47 +00:00
|
|
|
{
|
2017-03-13 16:13:04 +00:00
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& galOptions = m_parent->GetGalDisplayOptions();
|
2017-03-13 09:42:12 +00:00
|
|
|
m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
|
2017-02-14 15:31:21 +00:00
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
sLeftSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
|
2017-02-13 03:47:50 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
SetFocus();
|
2017-02-14 15:31:21 +00:00
|
|
|
|
2017-02-14 05:16:47 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
|
|
|
|
2017-02-14 10:03:08 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
bool DIALOG_DISPLAY_OPTIONS::TransferDataToWindow()
|
2017-02-14 05:16:47 +00:00
|
|
|
{
|
2017-10-30 17:21:07 +00:00
|
|
|
const PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_parent->GetDisplayOptions();
|
2017-02-14 05:16:47 +00:00
|
|
|
|
2017-02-16 05:03:26 +00:00
|
|
|
m_OptDisplayTracksClearance->SetSelection( UTIL::GetConfigForVal(
|
|
|
|
traceClearanceSelectMap, displ_opts->m_ShowTrackClearanceMode ) );
|
2017-02-14 05:16:47 +00:00
|
|
|
|
|
|
|
m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol );
|
|
|
|
m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_OptDisplayPadNoConn->SetValue( m_parent->IsElementVisible( LAYER_NO_CONNECTS ) );
|
2017-02-14 05:16:47 +00:00
|
|
|
m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode );
|
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
m_galOptsPanel->TransferDataToWindow();
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
return true;
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2017-02-16 05:03:26 +00:00
|
|
|
/*
|
|
|
|
* Update variables with new options
|
|
|
|
*/
|
2017-03-13 16:13:04 +00:00
|
|
|
bool DIALOG_DISPLAY_OPTIONS::TransferDataFromWindow()
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2017-10-30 17:21:07 +00:00
|
|
|
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_parent->GetDisplayOptions();
|
2015-01-10 10:27:49 +00:00
|
|
|
|
2017-02-16 05:03:26 +00:00
|
|
|
displ_opts->m_ShowTrackClearanceMode = UTIL::GetValFromConfig(
|
|
|
|
traceClearanceSelectMap, m_OptDisplayTracksClearance->GetSelection() );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
m_parent->SetElementVisibility( LAYER_NO_CONNECTS,
|
2011-09-24 18:33:28 +00:00
|
|
|
m_OptDisplayPadNoConn->GetValue() );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
m_galOptsPanel->TransferDataFromWindow();
|
2016-12-23 15:21:00 +00:00
|
|
|
|
2013-07-17 11:38:56 +00:00
|
|
|
// Apply changes to the GAL
|
2017-03-13 16:13:04 +00:00
|
|
|
KIGFX::VIEW* view = m_parent->GetGalCanvas()->GetView();
|
2013-10-14 14:13:35 +00:00
|
|
|
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
2015-01-10 10:27:49 +00:00
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2016-05-09 15:23:01 +00:00
|
|
|
view->RecacheAllItems();
|
2017-02-13 11:53:58 +00:00
|
|
|
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
2013-07-17 11:38:56 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
return true;
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
|
|
|
|
|