Add Pcbnew Display Origin Transforms preferences panel

This commit adds support for the Display Origin Transforms preferences
selection panel. This panel allows the user to select the desired
coordinate origin, and the direction in which the axes increase.
This commit is contained in:
Reece R. Pollack 2020-07-06 21:33:03 -04:00 committed by Seth Hillbrand
parent b483fd32a6
commit 5a5d99b018
7 changed files with 532 additions and 0 deletions

View File

@ -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

View File

@ -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 <board_design_settings.h>
#include <class_board.h>
#include <fctsys.h>
#include <panel_pcbnew_display_origin.h>
#include <pcb_edit_frame.h>
#include <pcb_painter.h>
#include <pcb_view.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
#include <widgets/paged_dialog.h>
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;
}

View File

@ -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

View File

@ -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()
{
}

View File

@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">panel_pcbnew_display_origin_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">PanelPcbnewDisplayOrigin</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Panel" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">PANEL_PCBNEW_DISPLAY_ORIGIN_BASE</property>
<property name="pos"></property>
<property name="size">500,300</property>
<property name="subclass">; ; forward_declare</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bPanelSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMargins</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bLeftSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Page Origin&quot; &quot;Drill/Place Origin&quot; &quot;Grid Origin&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Display Origin</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_DisplayOrigin</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Select which origin is used for X,Y coordinate display.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bRightSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Increases Right&quot; &quot;Increases Left&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">X Axis</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_XAxisDirection</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Select which the direction on the screen in which the X axis increases.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Increases Up&quot; &quot;Increases Down&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Y Axis</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_YAxisDirection</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Select which the direction on the screen in which the Y axis increases.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};

View File

@ -31,6 +31,7 @@
#include <panel_pcbnew_color_settings.h>
#include <panel_display_options.h>
#include <panel_pcbnew_action_plugins.h>
#include <panel_pcbnew_display_origin.h>
#include <tool/tool_manager.h>
#include <tools/selection_tool.h>
#include <ws_data_model.h>
@ -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() );
}