diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index bd4eec67b2..230a2ee6cc 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -156,6 +156,8 @@ set( PCBNEW_DIALOGS dialogs/panel_modedit_defaults.cpp dialogs/panel_modedit_defaults_base.cpp dialogs/panel_pcbnew_color_settings.cpp + dialogs/panel_pcbnew_display_origin.cpp + dialogs/panel_pcbnew_display_origin_base.cpp dialogs/panel_setup_mask_and_paste.cpp dialogs/panel_setup_mask_and_paste_base.cpp dialogs/panel_setup_feature_constraints.cpp diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin.cpp b/pcbnew/dialogs/panel_pcbnew_display_origin.cpp new file mode 100644 index 0000000000..3914f664f8 --- /dev/null +++ b/pcbnew/dialogs/panel_pcbnew_display_origin.cpp @@ -0,0 +1,82 @@ +/* + * 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 + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +PANEL_PCBNEW_DISPLAY_ORIGIN::PANEL_PCBNEW_DISPLAY_ORIGIN( + PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ) + : PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent->GetTreebook() ), + m_Frame( aFrame ) +{ +} + + +bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() +{ + const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions(); + + int origin = 0; + + switch( displ_opts.m_DisplayOrigin ) + { + case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE: origin = 0; break; + case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = 1; break; + case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = 2; break; + } + + m_DisplayOrigin->SetSelection( origin ); + m_XAxisDirection->SetSelection( displ_opts.m_DisplayInvertXAxis ? 1 : 0 ); + m_YAxisDirection->SetSelection( displ_opts.m_DisplayInvertYAxis ? 0 : 1 ); + + return true; +} + + +bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataFromWindow() +{ + PCB_DISPLAY_OPTIONS displ_opts = m_Frame->GetDisplayOptions(); + + switch( m_DisplayOrigin->GetSelection() ) + { + case 0: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE; break; + case 1: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX; break; + case 2: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID; break; + } + + displ_opts.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0; + displ_opts.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0; + + m_Frame->SetDisplayOptions( displ_opts ); + + return true; +} diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin.h b/pcbnew/dialogs/panel_pcbnew_display_origin.h new file mode 100644 index 0000000000..2519e28a0f --- /dev/null +++ b/pcbnew/dialogs/panel_pcbnew_display_origin.h @@ -0,0 +1,47 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2010-2014 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 + */ + +#ifndef PANEL_PCBNEW_DISPLAY_ORIGIN_H +#define PANEL_PCBNEW_DISPLAY_ORIGIN_H 1 + +#include "panel_pcbnew_display_origin_base.h" + +class PAGED_DIALOG; + + +class PANEL_PCBNEW_DISPLAY_ORIGIN : public PANEL_PCBNEW_DISPLAY_ORIGIN_BASE +{ +private: + PCB_EDIT_FRAME* m_Frame; + +public: + PANEL_PCBNEW_DISPLAY_ORIGIN( PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aWindow ); + +protected: + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; +}; + + +#endif // PANEL_PCBNEW_DISPLAY_ORIGIN_H diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp b/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp new file mode 100644 index 0000000000..f99c89d77a --- /dev/null +++ b/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_pcbnew_display_origin_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_PCBNEW_DISPLAY_ORIGIN_BASE::PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* bPanelSizer; + bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bMargins; + bMargins = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bLeftSizer; + bLeftSizer = new wxBoxSizer( wxVERTICAL ); + + wxString m_DisplayOriginChoices[] = { _("Page Origin"), _("Drill/Place Origin"), _("Grid Origin") }; + int m_DisplayOriginNChoices = sizeof( m_DisplayOriginChoices ) / sizeof( wxString ); + m_DisplayOrigin = new wxRadioBox( this, wxID_ANY, _("Display Origin"), wxDefaultPosition, wxDefaultSize, m_DisplayOriginNChoices, m_DisplayOriginChoices, 1, wxRA_SPECIFY_COLS ); + m_DisplayOrigin->SetSelection( 0 ); + m_DisplayOrigin->SetToolTip( _("Select which origin is used for X,Y coordinate display.") ); + + bLeftSizer->Add( m_DisplayOrigin, 0, wxALL|wxEXPAND, 5 ); + + + bMargins->Add( bLeftSizer, 1, wxEXPAND|wxRIGHT, 5 ); + + wxBoxSizer* bRightSizer; + bRightSizer = new wxBoxSizer( wxVERTICAL ); + + wxString m_XAxisDirectionChoices[] = { _("Increases Right"), _("Increases Left") }; + int m_XAxisDirectionNChoices = sizeof( m_XAxisDirectionChoices ) / sizeof( wxString ); + m_XAxisDirection = new wxRadioBox( this, wxID_ANY, _("X Axis"), wxDefaultPosition, wxDefaultSize, m_XAxisDirectionNChoices, m_XAxisDirectionChoices, 1, wxRA_SPECIFY_COLS ); + m_XAxisDirection->SetSelection( 0 ); + m_XAxisDirection->SetToolTip( _("Select which the direction on the screen in which the X axis increases.") ); + + bRightSizer->Add( m_XAxisDirection, 0, wxALL|wxEXPAND, 5 ); + + wxString m_YAxisDirectionChoices[] = { _("Increases Up"), _("Increases Down") }; + int m_YAxisDirectionNChoices = sizeof( m_YAxisDirectionChoices ) / sizeof( wxString ); + m_YAxisDirection = new wxRadioBox( this, wxID_ANY, _("Y Axis"), wxDefaultPosition, wxDefaultSize, m_YAxisDirectionNChoices, m_YAxisDirectionChoices, 1, wxRA_SPECIFY_COLS ); + m_YAxisDirection->SetSelection( 0 ); + m_YAxisDirection->SetToolTip( _("Select which the direction on the screen in which the Y axis increases.") ); + + bRightSizer->Add( m_YAxisDirection, 0, wxALL|wxEXPAND, 5 ); + + + bMargins->Add( bRightSizer, 1, wxEXPAND|wxRIGHT, 5 ); + + + bPanelSizer->Add( bMargins, 1, wxRIGHT, 5 ); + + + this->SetSizer( bPanelSizer ); + this->Layout(); +} + +PANEL_PCBNEW_DISPLAY_ORIGIN_BASE::~PANEL_PCBNEW_DISPLAY_ORIGIN_BASE() +{ +} diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp b/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp new file mode 100644 index 0000000000..9377d69e68 --- /dev/null +++ b/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp @@ -0,0 +1,291 @@ + + + + + ; + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_pcbnew_display_origin_base + 1000 + none + + 1 + PanelPcbnewDisplayOrigin + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_PCBNEW_DISPLAY_ORIGIN_BASE + + 500,300 + ; ; forward_declare + + + + wxTAB_TRAVERSAL + + + bPanelSizer + wxHORIZONTAL + none + + 5 + wxRIGHT + 1 + + + bMargins + wxHORIZONTAL + none + + 5 + wxEXPAND|wxRIGHT + 1 + + + bLeftSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Page Origin" "Drill/Place Origin" "Grid Origin" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Display Origin + 1 + + 0 + + + 0 + + 1 + m_DisplayOrigin + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; ; forward_declare + 0 + Select which origin is used for X,Y coordinate display. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND|wxRIGHT + 1 + + + bRightSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Increases Right" "Increases Left" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + X Axis + 1 + + 0 + + + 0 + + 1 + m_XAxisDirection + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; ; forward_declare + 0 + Select which the direction on the screen in which the X axis increases. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Increases Up" "Increases Down" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Y Axis + 1 + + 0 + + + 0 + + 1 + m_YAxisDirection + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; ; forward_declare + 0 + Select which the direction on the screen in which the Y axis increases. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin_base.h b/pcbnew/dialogs/panel_pcbnew_display_origin_base.h new file mode 100644 index 0000000000..4996161975 --- /dev/null +++ b/pcbnew/dialogs/panel_pcbnew_display_origin_base.h @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE : public wxPanel +{ + private: + + protected: + wxRadioBox* m_DisplayOrigin; + wxRadioBox* m_XAxisDirection; + wxRadioBox* m_YAxisDirection; + + public: + + PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_PCBNEW_DISPLAY_ORIGIN_BASE(); + +}; + diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 25f1c3a2c8..3f3b4acd4c 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) ); #endif + book->AddSubPage( new PANEL_PCBNEW_DISPLAY_ORIGIN( this, aParent ), _( "Origins & Axes" ) ); aHotkeysPanel->AddHotKeys( GetToolManager() ); }