2017-03-13 09:42:12 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-07-02 15:32:11 +00:00
|
|
|
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-03-13 09:42:12 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/checkbox.h>
|
2020-09-11 03:07:56 +00:00
|
|
|
#include <wx/choice.h>
|
2019-05-15 22:17:37 +00:00
|
|
|
#include <wx/radiobox.h>
|
|
|
|
#include <wx/spinctrl.h>
|
|
|
|
#include <wx/stattext.h>
|
2020-10-01 08:52:03 +00:00
|
|
|
#include <wx/statbox.h>
|
2019-05-15 22:17:37 +00:00
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
#include <widgets/gal_options_panel.h>
|
2021-02-21 20:11:44 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2017-03-13 09:42:12 +00:00
|
|
|
|
|
|
|
#include <config_map.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Spin control parameters
|
|
|
|
*/
|
2019-02-24 03:26:04 +00:00
|
|
|
static const double gridThicknessMin = 1.0;
|
2017-03-13 09:42:12 +00:00
|
|
|
static const double gridThicknessMax = 10.0;
|
2019-05-15 22:17:37 +00:00
|
|
|
static const double gridThicknessStep = 0.5;
|
2017-03-13 09:42:12 +00:00
|
|
|
|
|
|
|
static const double gridMinSpacingMin = 5;
|
|
|
|
static const double gridMinSpacingMax = 200;
|
|
|
|
static const double gridMinSpacingStep = 5;
|
|
|
|
|
2021-07-02 15:32:11 +00:00
|
|
|
|
2020-09-11 03:07:56 +00:00
|
|
|
///TODO: These are duplicated in gal_display_options - Unify!
|
2017-03-13 09:42:12 +00:00
|
|
|
static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleSelectMap =
|
|
|
|
{
|
|
|
|
{ KIGFX::GRID_STYLE::DOTS, 0 }, // Default
|
|
|
|
{ KIGFX::GRID_STYLE::LINES, 1 },
|
|
|
|
{ KIGFX::GRID_STYLE::SMALL_CROSS, 2 },
|
|
|
|
};
|
|
|
|
|
2021-07-02 15:32:11 +00:00
|
|
|
|
2020-09-11 03:07:56 +00:00
|
|
|
static const UTIL::CFG_MAP<KIGFX::GRID_SNAPPING> gridSnapConfigVals =
|
|
|
|
{
|
|
|
|
{ KIGFX::GRID_SNAPPING::ALWAYS, 0 },
|
|
|
|
{ KIGFX::GRID_SNAPPING::WITH_GRID, 1 },
|
|
|
|
{ KIGFX::GRID_SNAPPING::NEVER, 2 }
|
|
|
|
};
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2021-07-02 15:32:11 +00:00
|
|
|
|
2021-02-21 20:11:44 +00:00
|
|
|
GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ) :
|
2017-03-13 09:42:12 +00:00
|
|
|
wxPanel( aParent, wxID_ANY ),
|
2021-02-21 20:11:44 +00:00
|
|
|
m_drawFrame( aDrawFrame ),
|
|
|
|
m_galOptions( aDrawFrame->GetGalDisplayOptions() )
|
2017-03-13 09:42:12 +00:00
|
|
|
{
|
|
|
|
// the main sizer that holds "columns" of settings
|
|
|
|
m_mainSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
SetSizer( m_mainSizer );
|
|
|
|
|
|
|
|
// second-level sizers that are one "column" of settings each
|
|
|
|
wxBoxSizer* sLeftSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
m_mainSizer->Add( sLeftSizer, 1, wxALL | wxEXPAND, 0 );
|
|
|
|
|
2021-02-21 20:11:44 +00:00
|
|
|
/*
|
|
|
|
* Rendering engine
|
|
|
|
*/
|
|
|
|
#ifndef __WXMAC__
|
|
|
|
{
|
|
|
|
wxString engineChoices[] = { _( "Accelerated graphics" ), _( "Fallback graphics" ) };
|
|
|
|
m_renderingEngine = new wxRadioBox( this, wxID_ANY, _( "Rendering Engine" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
sizeof( engineChoices ) / sizeof( wxString ),
|
|
|
|
engineChoices, 1, wxRA_SPECIFY_COLS );
|
|
|
|
m_renderingEngine->SetItemToolTip( 0, _( "Hardware-accelerated graphics (recommended)" ) );
|
|
|
|
m_renderingEngine->SetItemToolTip( 1, _( "Software graphics (for computers which do not "
|
|
|
|
"support KiCad's hardware acceleration "
|
|
|
|
"requirements)" ) );
|
|
|
|
|
|
|
|
sLeftSizer->Add( m_renderingEngine, 0, wxTOP | wxBOTTOM | wxRIGHT | wxEXPAND, 5 );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
/*
|
2018-09-04 00:00:17 +00:00
|
|
|
* Grid settings subpanel
|
2017-03-13 09:42:12 +00:00
|
|
|
*/
|
|
|
|
{
|
2019-05-31 23:24:38 +00:00
|
|
|
wxStaticBox* sGridOpts = new wxStaticBox( this, wxID_ANY, _( "Grid Options" ) );
|
2017-03-13 09:42:12 +00:00
|
|
|
wxStaticBoxSizer* sGridSettings;
|
2019-05-31 23:24:38 +00:00
|
|
|
sGridSettings = new wxStaticBoxSizer( sGridOpts, wxVERTICAL );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
|
|
|
wxString m_gridStyleChoices[] = {
|
2017-03-19 01:39:38 +00:00
|
|
|
_( "Dots" ),
|
|
|
|
_( "Lines" ),
|
|
|
|
_( "Small crosses" )
|
2017-03-13 09:42:12 +00:00
|
|
|
};
|
2021-07-02 15:32:11 +00:00
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
int m_gridStyleNChoices = sizeof( m_gridStyleChoices ) / sizeof( wxString );
|
2021-03-12 23:59:17 +00:00
|
|
|
m_gridStyle = new wxRadioBox( sGridSettings->GetStaticBox(), wxID_ANY, _( "Grid Style" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, m_gridStyleNChoices,
|
|
|
|
m_gridStyleChoices, 1, wxRA_SPECIFY_COLS );
|
2021-07-02 15:32:11 +00:00
|
|
|
sGridSettings->Add( m_gridStyle, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
|
|
|
wxFlexGridSizer* sGridSettingsGrid;
|
2019-05-15 22:17:37 +00:00
|
|
|
sGridSettingsGrid = new wxFlexGridSizer( 0, 3, 0, 0 );
|
2017-03-13 09:42:12 +00:00
|
|
|
sGridSettingsGrid->AddGrowableCol( 1 );
|
|
|
|
sGridSettingsGrid->SetFlexibleDirection( wxBOTH );
|
|
|
|
sGridSettingsGrid->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
|
|
|
2021-03-12 23:59:17 +00:00
|
|
|
l_gridLineWidth = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "Grid thickness:" ) );
|
2017-03-13 09:42:12 +00:00
|
|
|
l_gridLineWidth->Wrap( -1 );
|
2021-07-02 15:32:11 +00:00
|
|
|
sGridSettingsGrid->Add( l_gridLineWidth, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
m_gridLineWidth = new wxSpinCtrlDouble( sGridSettings->GetStaticBox(), wxID_ANY );
|
|
|
|
m_gridLineWidth->SetRange( gridThicknessMin, gridThicknessMax );
|
|
|
|
m_gridLineWidth->SetIncrement( gridThicknessStep );
|
|
|
|
m_gridLineWidth->SetDigits( 1 );
|
2018-05-14 17:34:18 +00:00
|
|
|
sGridSettingsGrid->Add( m_gridLineWidth, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2021-03-12 23:59:17 +00:00
|
|
|
l_gridLineWidthUnits = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "px" ) );
|
2017-03-13 09:42:12 +00:00
|
|
|
l_gridLineWidthUnits->Wrap( -1 );
|
2019-05-15 18:58:47 +00:00
|
|
|
sGridSettingsGrid->Add( l_gridLineWidthUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2021-03-12 23:59:17 +00:00
|
|
|
l_gridMinSpacing = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "Min grid spacing:" ) );
|
2017-03-13 09:42:12 +00:00
|
|
|
l_gridMinSpacing->Wrap( -1 );
|
2021-07-02 15:32:11 +00:00
|
|
|
sGridSettingsGrid->Add( l_gridMinSpacing, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
m_gridMinSpacing = new wxSpinCtrlDouble( sGridSettings->GetStaticBox(), wxID_ANY);
|
|
|
|
m_gridMinSpacing->SetRange( gridMinSpacingMin, gridMinSpacingMax );
|
|
|
|
m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
|
|
|
|
m_gridMinSpacing->SetDigits( 0 );
|
2018-05-14 17:34:18 +00:00
|
|
|
sGridSettingsGrid->Add( m_gridMinSpacing, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2021-03-12 23:59:17 +00:00
|
|
|
l_gridMinSpacingUnits = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "px" ) );
|
2017-03-13 09:42:12 +00:00
|
|
|
l_gridMinSpacingUnits->Wrap( -1 );
|
2019-05-15 18:58:47 +00:00
|
|
|
sGridSettingsGrid->Add( l_gridMinSpacingUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2021-03-12 23:59:17 +00:00
|
|
|
l_gridSnapOptions = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "Snap to Grid:" ) );
|
2020-09-11 03:07:56 +00:00
|
|
|
l_gridSnapOptions->Wrap( -1 );
|
|
|
|
sGridSettingsGrid->Add( l_gridSnapOptions, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
2021-07-02 15:32:11 +00:00
|
|
|
wxString gridSnapChoices[] = { _( "Always" ), _( "When grid shown" ), _( "Never" ) };
|
2020-09-11 03:07:56 +00:00
|
|
|
int gridSnapNChoices = sizeof( gridSnapChoices ) / sizeof( wxString );
|
|
|
|
m_gridSnapOptions = new wxChoice( sGridSettings->GetStaticBox(), wxID_ANY,
|
2021-03-12 23:59:17 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, gridSnapNChoices,
|
|
|
|
gridSnapChoices );
|
2020-09-11 03:07:56 +00:00
|
|
|
m_gridSnapOptions->Select( 0 );
|
2021-07-02 15:32:11 +00:00
|
|
|
sGridSettingsGrid->Add( m_gridSnapOptions, 0,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxEXPAND | wxTOP | wxBOTTOM, 5 );
|
2020-09-11 03:07:56 +00:00
|
|
|
|
2021-03-12 23:59:17 +00:00
|
|
|
l_gridSnapSpace = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY, _( "px" ) );
|
2020-09-11 03:07:56 +00:00
|
|
|
l_gridSnapSpace->Wrap( -1 );
|
|
|
|
l_gridSnapSpace->Hide();
|
|
|
|
sGridSettingsGrid->Add( l_gridSnapSpace, 0,
|
2021-03-12 23:59:17 +00:00
|
|
|
wxALIGN_CENTER_VERTICAL | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN,
|
|
|
|
5 );
|
2020-09-11 03:07:56 +00:00
|
|
|
|
|
|
|
|
2019-05-15 18:58:47 +00:00
|
|
|
sGridSettings->Add( sGridSettingsGrid, 1, wxALL | wxEXPAND, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2018-07-16 06:25:27 +00:00
|
|
|
sLeftSizer->Add( sGridSettings, 0, wxTOP | wxBOTTOM | wxRIGHT | wxEXPAND, 5 );
|
2017-03-13 09:42:12 +00:00
|
|
|
}
|
2017-03-18 20:03:24 +00:00
|
|
|
|
2018-09-04 00:00:17 +00:00
|
|
|
/*
|
|
|
|
* Cursor settings subpanel
|
|
|
|
*/
|
2017-03-18 20:03:24 +00:00
|
|
|
{
|
2021-03-12 23:59:17 +00:00
|
|
|
wxStaticBox* sbCursorSettings = new wxStaticBox( this, wxID_ANY, _( "Cursor Options" ) );
|
|
|
|
wxStaticBoxSizer* sCursorSettings = new wxStaticBoxSizer( sbCursorSettings, wxVERTICAL );
|
2017-03-18 20:03:24 +00:00
|
|
|
|
2018-07-16 06:25:27 +00:00
|
|
|
sLeftSizer->Add( sCursorSettings, 1, wxTOP | wxRIGHT | wxEXPAND, 5 );
|
2017-03-18 20:03:24 +00:00
|
|
|
|
2017-03-19 20:51:59 +00:00
|
|
|
wxString m_CursorShapeChoices[] = {
|
2018-01-24 12:07:05 +00:00
|
|
|
_( "Small crosshair" ),
|
|
|
|
_( "Full window crosshair" )
|
2017-03-19 20:51:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int m_CursorShapeNChoices = sizeof( m_CursorShapeChoices ) / sizeof( wxString );
|
|
|
|
m_cursorShape = new wxRadioBox( this, wxID_ANY,
|
2019-06-01 13:46:30 +00:00
|
|
|
_( "Cursor Shape" ), wxDefaultPosition, wxDefaultSize,
|
2018-07-16 06:25:27 +00:00
|
|
|
m_CursorShapeNChoices, m_CursorShapeChoices, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
2017-03-19 20:51:59 +00:00
|
|
|
|
|
|
|
m_cursorShape->SetSelection( 0 );
|
2018-01-24 12:07:05 +00:00
|
|
|
m_cursorShape->SetToolTip( _( "Cursor shape for drawing, placement and movement tools" ) );
|
2021-07-02 15:32:11 +00:00
|
|
|
sCursorSettings->Add( m_cursorShape, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5 );
|
2017-03-19 20:51:59 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
m_forceCursorDisplay = new wxCheckBox( this, wxID_ANY, _( "Always show crosshairs" ) );
|
2017-03-18 20:03:24 +00:00
|
|
|
sCursorSettings->Add( m_forceCursorDisplay, 0, wxALL | wxEXPAND, 5 );
|
|
|
|
}
|
2017-03-13 09:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GAL_OPTIONS_PANEL::TransferDataToWindow()
|
|
|
|
{
|
2021-02-22 10:42:13 +00:00
|
|
|
#ifndef __WXMAC__
|
2021-02-21 20:11:44 +00:00
|
|
|
if( m_drawFrame->GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
|
|
|
|
m_renderingEngine->SetSelection( 0 );
|
|
|
|
else
|
|
|
|
m_renderingEngine->SetSelection( 1 );
|
2021-02-22 10:42:13 +00:00
|
|
|
#endif
|
2021-02-21 20:11:44 +00:00
|
|
|
|
|
|
|
m_gridSnapOptions->SetSelection( UTIL::GetConfigForVal( gridSnapConfigVals,
|
|
|
|
m_galOptions.m_gridSnapping ) );
|
2020-09-11 03:07:56 +00:00
|
|
|
|
2021-02-21 20:11:44 +00:00
|
|
|
m_gridStyle->SetSelection( UTIL::GetConfigForVal( gridStyleSelectMap,
|
|
|
|
m_galOptions.m_gridStyle ) );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
m_gridLineWidth->SetValue( m_galOptions.m_gridLineWidth );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
m_gridMinSpacing->SetValue( m_galOptions.m_gridMinSpacing );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2017-03-19 20:51:59 +00:00
|
|
|
m_cursorShape->SetSelection( m_galOptions.m_fullscreenCursor );
|
|
|
|
|
2017-03-18 20:03:24 +00:00
|
|
|
m_forceCursorDisplay->SetValue( m_galOptions.m_forceDisplayCursor );
|
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GAL_OPTIONS_PANEL::TransferDataFromWindow()
|
|
|
|
{
|
2020-09-11 03:07:56 +00:00
|
|
|
m_galOptions.m_gridSnapping = UTIL::GetValFromConfig( gridSnapConfigVals,
|
2021-02-21 20:11:44 +00:00
|
|
|
m_gridSnapOptions->GetSelection() );
|
2020-09-11 03:07:56 +00:00
|
|
|
|
2021-02-21 20:11:44 +00:00
|
|
|
m_galOptions.m_gridStyle = UTIL::GetValFromConfig( gridStyleSelectMap,
|
|
|
|
m_gridStyle->GetSelection() );
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
m_galOptions.m_gridLineWidth = m_gridLineWidth->GetValue();
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2019-05-15 22:17:37 +00:00
|
|
|
m_galOptions.m_gridMinSpacing = m_gridMinSpacing->GetValue();
|
2017-03-13 09:42:12 +00:00
|
|
|
|
2017-03-19 20:51:59 +00:00
|
|
|
m_galOptions.m_fullscreenCursor = m_cursorShape->GetSelection();
|
|
|
|
|
2017-03-18 20:03:24 +00:00
|
|
|
m_galOptions.m_forceDisplayCursor = m_forceCursorDisplay->GetValue();
|
|
|
|
|
2021-02-22 10:42:13 +00:00
|
|
|
#ifndef __WXMAC__
|
2021-02-21 20:11:44 +00:00
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE wantedType = m_renderingEngine->GetSelection() == 0 ?
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL :
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE currentType = m_drawFrame->GetCanvas()->GetBackend();
|
|
|
|
|
|
|
|
if( wantedType != currentType )
|
|
|
|
m_drawFrame->GetCanvas()->SwitchBackend( wantedType );
|
2021-02-22 10:42:13 +00:00
|
|
|
#endif
|
2021-02-21 20:11:44 +00:00
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
return true;
|
|
|
|
}
|