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
|
2016-05-10 20:47:37 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-06-20 11:13:04 +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
|
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <pcbstruct.h>
|
|
|
|
|
|
|
|
#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>
|
2013-07-17 11:38:56 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <pcb_painter.h>
|
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallDisplayOptionsDialog( wxCommandEvent& aEvent )
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2011-03-03 19:08:13 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS dlg( this );
|
|
|
|
dlg.ShowModal();
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) :
|
2011-03-14 15:17:18 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS_BASE( parent )
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
|
|
|
m_Parent = parent;
|
|
|
|
|
|
|
|
init();
|
2011-03-03 19:08:13 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2011-03-03 19:08:13 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
void DIALOG_DISPLAY_OPTIONS::init()
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
|
|
|
SetFocus();
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
m_OptDisplayTracks->SetValue( displ_opts->m_DisplayPcbTrackFill == SKETCH );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
switch ( displ_opts->m_ShowTrackClearanceMode )
|
2009-06-18 20:51:01 +00:00
|
|
|
{
|
|
|
|
case DO_NOT_SHOW_CLEARANCE:
|
2011-09-24 18:33:28 +00:00
|
|
|
m_OptDisplayTracksClearance->SetSelection( 0 );
|
2009-06-18 20:51:01 +00:00
|
|
|
break;
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
case SHOW_CLEARANCE_NEW_TRACKS:
|
2011-09-24 18:33:28 +00:00
|
|
|
m_OptDisplayTracksClearance->SetSelection( 1 );
|
2009-06-18 20:51:01 +00:00
|
|
|
break;
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2011-09-30 08:24:10 +00:00
|
|
|
case SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS:
|
|
|
|
m_OptDisplayTracksClearance->SetSelection( 3 );
|
|
|
|
break;
|
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
default:
|
|
|
|
case SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS:
|
2011-09-30 08:24:10 +00:00
|
|
|
m_OptDisplayTracksClearance->SetSelection( 2 );
|
2009-06-18 20:51:01 +00:00
|
|
|
break;
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
case SHOW_CLEARANCE_ALWAYS:
|
2011-09-30 08:24:10 +00:00
|
|
|
m_OptDisplayTracksClearance->SetSelection( 4 );
|
2009-06-18 20:51:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
m_OptDisplayPads->SetValue( displ_opts->m_DisplayPadFill == SKETCH );
|
|
|
|
m_OptDisplayVias->SetValue( displ_opts->m_DisplayViaFill == SKETCH );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
m_Show_Page_Limits->SetValue( m_Parent->ShowPageLimits() );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
m_OptDisplayModTexts->SetValue( displ_opts->m_DisplayModTextFill == SKETCH );
|
|
|
|
m_OptDisplayModOutlines->SetValue( displ_opts->m_DisplayModEdgeFill == SKETCH );
|
2015-01-10 10:27:49 +00:00
|
|
|
m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol );
|
|
|
|
m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum );
|
2011-09-24 18:33:28 +00:00
|
|
|
m_OptDisplayPadNoConn->SetValue( m_Parent->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) ) );
|
2015-02-02 08:06:39 +00:00
|
|
|
m_OptDisplayDrawings->SetValue( displ_opts->m_DisplayDrawItemsFill == SKETCH );
|
2015-01-10 10:27:49 +00:00
|
|
|
m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode );
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
void DIALOG_DISPLAY_OPTIONS::OnCancelClick( wxCommandEvent& event )
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2011-09-24 18:33:28 +00:00
|
|
|
EndModal( 0 );
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
/* Update variables with new options
|
|
|
|
*/
|
2011-09-24 18:33:28 +00:00
|
|
|
void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions();
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
m_Parent->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayPcbTrackFill = not m_OptDisplayTracks->GetValue();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
|
|
|
switch ( m_OptDisplayTracksClearance->GetSelection() )
|
|
|
|
{
|
2009-06-18 20:51:01 +00:00
|
|
|
case 0:
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;
|
2009-06-18 17:32:27 +00:00
|
|
|
break;
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
case 1:
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS;
|
2009-06-18 17:32:27 +00:00
|
|
|
break;
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
case 2:
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS;
|
2009-06-18 17:32:27 +00:00
|
|
|
break;
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
case 3:
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS;
|
2011-09-30 08:24:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS;
|
2009-06-18 17:32:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayModTextFill = not m_OptDisplayModTexts->GetValue();
|
|
|
|
displ_opts->m_DisplayModEdgeFill = not m_OptDisplayModOutlines->GetValue();
|
2009-09-29 04:44:35 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayPadFill = not m_OptDisplayPads->GetValue();
|
|
|
|
displ_opts->m_DisplayViaFill = not m_OptDisplayVias->GetValue();
|
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
|
|
|
|
2010-01-30 20:17:56 +00:00
|
|
|
m_Parent->SetElementVisibility( PCB_VISIBLE(NO_CONNECTS_VISIBLE),
|
2011-09-24 18:33:28 +00:00
|
|
|
m_OptDisplayPadNoConn->GetValue() );
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayDrawItemsFill = not m_OptDisplayDrawings->GetValue();
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2013-07-17 11:38:56 +00:00
|
|
|
// Apply changes to the GAL
|
2013-10-14 14:13:35 +00:00
|
|
|
KIGFX::VIEW* view = m_Parent->GetGalCanvas()->GetView();
|
|
|
|
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();
|
2013-07-17 11:38:56 +00:00
|
|
|
|
2014-02-25 13:28:09 +00:00
|
|
|
m_Parent->GetCanvas()->Refresh();
|
2009-06-18 17:32:27 +00:00
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
EndModal( 1 );
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|