2014-10-21 18:36:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2016-05-11 03:33:24 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-21 18:36:45 +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
|
|
|
|
*/
|
|
|
|
|
2011-10-16 08:02:36 +00:00
|
|
|
/**
|
|
|
|
* @file gerbview_dialog_display_options_frame.cpp
|
|
|
|
* Set some display options for GerbView
|
2009-11-22 20:55:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
|
|
|
|
#include <gerbview.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview_dialog_display_options_frame_base.h>
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************/
|
|
|
|
/* Dialog frame to select display options */
|
|
|
|
/*******************************************/
|
|
|
|
class DIALOG_DISPLAY_OPTIONS : public DIALOG_DISPLAY_OPTIONS_BASE
|
|
|
|
{
|
|
|
|
private:
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME* m_Parent;
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME* parent );
|
2009-11-22 20:55:05 +00:00
|
|
|
~DIALOG_DISPLAY_OPTIONS() {};
|
|
|
|
|
|
|
|
private:
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnOKBUttonClick( wxCommandEvent& event ) override;
|
|
|
|
void OnCancelButtonClick( wxCommandEvent& event ) override;
|
2010-10-09 11:03:03 +00:00
|
|
|
void initOptDialog( );
|
2009-11-22 20:55:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::InstallGerberOptionsDialog( wxCommandEvent& event )
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS dlg( this );
|
|
|
|
int opt = dlg.ShowModal();
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
if( opt > 0 )
|
|
|
|
m_canvas->Refresh();
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 19:53:02 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME *parent) :
|
2009-11-22 20:55:05 +00:00
|
|
|
DIALOG_DISPLAY_OPTIONS_BASE( parent, wxID_ANY )
|
|
|
|
{
|
|
|
|
m_Parent = parent;
|
|
|
|
SetFocus();
|
2010-10-09 11:03:03 +00:00
|
|
|
initOptDialog( );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2010-10-09 11:03:03 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Center();
|
2011-03-14 15:17:18 +00:00
|
|
|
m_sdbSizer1OK->SetDefault();
|
2010-10-09 11:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-18 18:47:58 +00:00
|
|
|
void DIALOG_DISPLAY_OPTIONS::OnCancelButtonClick( wxCommandEvent& event )
|
2010-10-09 11:03:03 +00:00
|
|
|
{
|
|
|
|
EndModal( 0 );
|
|
|
|
}
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2010-10-09 11:03:03 +00:00
|
|
|
void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_PolarDisplay->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolarCood ? 1 : 0 );
|
2010-10-09 11:03:03 +00:00
|
|
|
m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
|
2016-05-11 03:33:24 +00:00
|
|
|
|
2017-03-19 20:51:59 +00:00
|
|
|
// @todo: LEGACY: Cursor shape can be set using the GAL options
|
|
|
|
// widget, when that is added to gerbview. For now, access the
|
|
|
|
// setting via the frame's GAL options object directly
|
|
|
|
|
2016-05-11 03:33:24 +00:00
|
|
|
// Cursor shape cannot be implemented on OS X
|
|
|
|
#ifdef __APPLE__
|
|
|
|
m_CursorShape->Hide();
|
|
|
|
#else
|
2017-03-19 20:51:59 +00:00
|
|
|
{
|
|
|
|
auto& galOpts = m_Parent->GetGalDisplayOptions();
|
|
|
|
m_CursorShape->SetSelection( galOpts.m_fullscreenCursor ? 1 : 0 );
|
|
|
|
}
|
2016-05-11 03:33:24 +00:00
|
|
|
#endif // __APPLE__
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2010-10-09 11:03:03 +00:00
|
|
|
// Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
|
2012-05-04 17:44:42 +00:00
|
|
|
m_OptDisplayLines->SetSelection( m_Parent->m_DisplayOptions.m_DisplayLinesFill ? 1 : 0 );
|
|
|
|
m_OptDisplayFlashedItems->SetSelection( m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill ? 1 : 0);
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
// Show Option Draw polygons
|
2012-05-04 17:44:42 +00:00
|
|
|
m_OptDisplayPolygons->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolygonsFill ? 1 : 0 );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
m_ShowPageLimits->SetSelection(0);
|
2011-12-14 20:03:15 +00:00
|
|
|
|
|
|
|
if( m_Parent->GetShowBorderAndTitleBlock() )
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
wxString curPaperType = m_Parent->GetPageSettings().GetType();
|
|
|
|
|
|
|
|
for( unsigned i = 1; i < DIM( g_GerberPageSizeList ); ++i )
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
if( g_GerberPageSizeList[i] == curPaperType )
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
m_ShowPageLimits->SetSelection( i );
|
2009-11-22 20:55:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
m_OptDisplayDCodes->SetValue( m_Parent->IsElementVisible( LAYER_DCODES ) );
|
2012-04-11 18:54:20 +00:00
|
|
|
|
2013-02-02 19:10:48 +00:00
|
|
|
|
|
|
|
m_OptZoomNoCenter->SetValue( m_Parent->GetCanvas()->GetEnableZoomNoCenter() );
|
2016-02-24 19:53:02 +00:00
|
|
|
m_OptMousewheelPan->SetValue( m_Parent->GetCanvas()->GetEnableMousewheelPan() );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayPolarCood =
|
2011-12-14 20:03:15 +00:00
|
|
|
(m_PolarDisplay->GetSelection() == 0) ? false : true;
|
2010-10-09 11:03:03 +00:00
|
|
|
g_UserUnit = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
|
2016-05-11 03:33:24 +00:00
|
|
|
|
2017-03-19 20:51:59 +00:00
|
|
|
// @todo LEGACY: as above, this should be via the GAL display widget
|
2016-05-11 03:33:24 +00:00
|
|
|
#ifndef __APPLE__
|
2017-03-19 20:51:59 +00:00
|
|
|
{
|
|
|
|
auto& galOpts = m_Parent->GetGalDisplayOptions();
|
|
|
|
galOpts.m_fullscreenCursor = m_CursorShape->GetSelection();
|
|
|
|
}
|
2016-05-11 03:33:24 +00:00
|
|
|
#endif // !__APPLE__
|
2010-10-09 11:03:03 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
if( m_OptDisplayLines->GetSelection() == 1 )
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayLinesFill = true;
|
2009-11-22 20:55:05 +00:00
|
|
|
else
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayLinesFill = false;
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
if( m_OptDisplayFlashedItems->GetSelection() == 1 )
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = true;
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = false;
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( m_OptDisplayPolygons->GetSelection() == 0 )
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = false;
|
2009-11-22 20:55:05 +00:00
|
|
|
else
|
2012-05-04 17:44:42 +00:00
|
|
|
m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = true;
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
m_Parent->SetElementVisibility( LAYER_DCODES, m_OptDisplayDCodes->GetValue() );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
int idx = m_ShowPageLimits->GetSelection();
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
m_Parent->SetShowBorderAndTitleBlock( idx > 0 ? true : false );
|
|
|
|
|
|
|
|
PAGE_INFO pageInfo( g_GerberPageSizeList[idx] );
|
|
|
|
|
|
|
|
m_Parent->SetPageSettings( pageInfo );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2013-02-12 03:56:46 +00:00
|
|
|
m_Parent->GetCanvas()->SetEnableZoomNoCenter( m_OptZoomNoCenter->GetValue() );
|
2016-02-24 19:53:02 +00:00
|
|
|
m_Parent->GetCanvas()->SetEnableMousewheelPan( m_OptMousewheelPan->GetValue() );
|
2012-04-11 18:54:20 +00:00
|
|
|
|
|
|
|
m_Parent->GetCanvas()->Refresh();
|
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
EndModal( 1 );
|
|
|
|
}
|
|
|
|
|