ADDED: Move Corner To... and Move Midpoint To...

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5012
This commit is contained in:
Jeff Young 2023-08-05 16:43:10 +01:00
parent ab614ef99f
commit 0413270012
18 changed files with 902 additions and 261 deletions

View File

@ -436,13 +436,13 @@ void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
BOARD_DESIGN_SETTINGS bds = m_dummyBoard->GetDesignSettings();
int thickness = bds.GetBoardThickness();
WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "Board thickness:" ),
_( "3D Preview Options" ), thickness );
WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "3D Preview Options" ), _( "Board thickness:" ),
thickness );
if( dlg.ShowModal() != wxID_OK )
return;
bds.SetBoardThickness( (int) dlg.GetValue() );
bds.SetBoardThickness( dlg.GetValue() );
BOARD_STACKUP& boardStackup = m_dummyBoard->GetDesignSettings().GetStackupDescriptor();
boardStackup.RemoveAll();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2023 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
@ -26,9 +26,8 @@
#include <dialogs/dialog_unit_entry.h>
WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aLabel,
const wxString& aCaption,
const long long& aDefaultValue ) :
WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption,
const wxString& aLabel, int aDefaultValue ) :
WX_UNIT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ),
m_unit_binder( aParent, m_label, m_textCtrl, m_unit_label, true )
{
@ -39,7 +38,29 @@ WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxStr
}
long long WX_UNIT_ENTRY_DIALOG::GetValue()
int WX_UNIT_ENTRY_DIALOG::GetValue()
{
return m_unit_binder.GetValue();
return m_unit_binder.GetIntValue();
}
WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption,
const wxString& aLabelX, const wxString& aLabelY,
const VECTOR2I& aDefaultValue ) :
WX_PT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ),
m_unit_binder_x( aParent, m_labelX, m_textCtrlX, m_unitsX, true ),
m_unit_binder_y( aParent, m_labelY, m_textCtrlY, m_unitsY, true )
{
m_labelX->SetLabel( aLabelX );
m_labelY->SetLabel( aLabelY );
m_unit_binder_x.SetValue( aDefaultValue.x );
m_unit_binder_y.SetValue( aDefaultValue.y );
SetupStandardButtons();
}
VECTOR2I WX_PT_ENTRY_DIALOG::GetValue()
{
return VECTOR2I( m_unit_binder_x.GetIntValue(), m_unit_binder_y.GetIntValue() );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -17,29 +17,23 @@ WX_UNIT_ENTRY_DIALOG_BASE::WX_UNIT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindow
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerContent;
bSizerContent = new wxBoxSizer( wxVERTICAL );
bSizerContent = new wxBoxSizer( wxHORIZONTAL );
m_label = new wxStaticText( this, wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
m_label->Wrap( -1 );
bSizerContent->Add( m_label, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizerTextAndUnit;
bSizerTextAndUnit = new wxBoxSizer( wxHORIZONTAL );
bSizerContent->Add( m_label, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrl->SetMinSize( wxSize( 300,-1 ) );
bSizerTextAndUnit->Add( m_textCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerContent->Add( m_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_unit_label = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_unit_label->Wrap( -1 );
bSizerTextAndUnit->Add( m_unit_label, 0, wxALL, 5 );
bSizerContent->Add( m_unit_label, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerContent->Add( bSizerTextAndUnit, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerContent, 1, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerContent, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
@ -61,3 +55,65 @@ WX_UNIT_ENTRY_DIALOG_BASE::WX_UNIT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindow
WX_UNIT_ENTRY_DIALOG_BASE::~WX_UNIT_ENTRY_DIALOG_BASE()
{
}
WX_PT_ENTRY_DIALOG_BASE::WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* fgSizer;
fgSizer = new wxFlexGridSizer( 0, 3, 5, 0 );
fgSizer->SetFlexibleDirection( wxBOTH );
fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_labelX = new wxStaticText( this, wxID_ANY, _("X label:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelX->Wrap( -1 );
fgSizer->Add( m_labelX, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_textCtrlX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlX->SetMinSize( wxSize( 300,-1 ) );
fgSizer->Add( m_textCtrlX, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_unitsX = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_unitsX->Wrap( -1 );
fgSizer->Add( m_unitsX, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_labelY = new wxStaticText( this, wxID_ANY, _("Y label:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelY->Wrap( -1 );
fgSizer->Add( m_labelY, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_textCtrlY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlY->SetMinSize( wxSize( 300,-1 ) );
fgSizer->Add( m_textCtrlY, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_unitsY = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_unitsY->Wrap( -1 );
fgSizer->Add( m_unitsY, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bSizerMain->Add( fgSizer, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxALL|wxALIGN_RIGHT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
}
WX_PT_ENTRY_DIALOG_BASE::~WX_PT_ENTRY_DIALOG_BASE()
{
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">dialog_unit_entry_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_unit_entry_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -48,8 +50,9 @@
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title"></property>
<property name="title">Title</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@ -60,16 +63,16 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerContent</property>
<property name="orient">wxVERTICAL</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -128,19 +131,10 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerTextAndUnit</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property>
<property name="proportion">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -203,7 +197,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -264,8 +258,6 @@
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_RIGHT</property>
@ -286,5 +278,447 @@
</object>
</object>
</object>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</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="extra_style"></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">WX_PT_ENTRY_DIALOG_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Move Point to Location</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">5</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" 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="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 label:</property>
<property name="markup">0</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_labelX</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="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" 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="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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">300,-1</property>
<property name="moveable">1</property>
<property name="name">m_textCtrlX</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="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></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="value"></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">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" 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="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">unit</property>
<property name="markup">0</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_unitsX</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="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" 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="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 label:</property>
<property name="markup">0</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_labelY</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="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" 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="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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">300,-1</property>
<property name="moveable">1</property>
<property name="name">m_textCtrlY</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="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></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="value"></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">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" 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="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">unit</property>
<property name="markup">0</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_unitsY</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="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -42,8 +42,35 @@ class WX_UNIT_ENTRY_DIALOG_BASE : public DIALOG_SHIM
public:
WX_UNIT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
WX_UNIT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Title"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~WX_UNIT_ENTRY_DIALOG_BASE();
};
///////////////////////////////////////////////////////////////////////////////
/// Class WX_PT_ENTRY_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
class WX_PT_ENTRY_DIALOG_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_labelX;
wxTextCtrl* m_textCtrlX;
wxStaticText* m_unitsX;
wxStaticText* m_labelY;
wxTextCtrl* m_textCtrlY;
wxStaticText* m_unitsY;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
public:
WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move Point to Location"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~WX_PT_ENTRY_DIALOG_BASE();
};

View File

@ -40,17 +40,33 @@
class WX_UNIT_ENTRY_DIALOG : public WX_UNIT_ENTRY_DIALOG_BASE
{
public:
WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aLabel, const wxString& aCaption,
const long long& aDefaultValue = 0 );
WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption, const wxString& aLabel,
int aDefaultValue );
/**
* Returns the value in internal units
*/
long long GetValue();
int GetValue();
private:
UNIT_BINDER m_unit_binder;
};
class WX_PT_ENTRY_DIALOG : public WX_PT_ENTRY_DIALOG_BASE
{
public:
WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption, const wxString& aLabelX,
const wxString& aLabelY, const VECTOR2I& aDefaultValue );
/**
* Returns the value in internal units
*/
VECTOR2I GetValue();
private:
UNIT_BINDER m_unit_binder_x;
UNIT_BINDER m_unit_binder_y;
};
#endif // _DIALOG_UNIT_ENTRY_H_

View File

@ -36,9 +36,9 @@
struct CHAMFER_PARAMS
{
/// Chamfer set-back distance along the first line
int m_chamfer_setback_a_IU;
int m_chamfer_setback_a;
/// Chamfer set-back distance along the second line
int m_chamfer_setback_b_IU;
int m_chamfer_setback_b;
};
struct CHAMFER_RESULT
@ -55,7 +55,7 @@ struct CHAMFER_RESULT
/**
* Compute the chamfer points for a given line pair and chamfer parameters.
*/
std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG aSegA, const SEG& aSegB,
std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG& aSegA, const SEG& aSegB,
const CHAMFER_PARAMS& aChamferParams );

View File

@ -23,11 +23,11 @@
#include <geometry/chamfer.h>
std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG aSegA, const SEG& aSegB,
std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG& aSegA, const SEG& aSegB,
const CHAMFER_PARAMS& aChamferParams )
{
const int line_a_setback = aChamferParams.m_chamfer_setback_a_IU;
const int line_b_setback = aChamferParams.m_chamfer_setback_b_IU;
const int line_a_setback = aChamferParams.m_chamfer_setback_a;
const int line_b_setback = aChamferParams.m_chamfer_setback_b;
if( line_a_setback == 0 && line_b_setback == 0 )
{
@ -92,16 +92,14 @@ std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG aSegA, const SEG&
// The adjusted segments go from the old end points to the chamfer ends
std::optional<SEG> new_a;
if( a_end_pt != chamfer.A )
{
new_a = SEG{ a_end_pt, chamfer.A };
}
std::optional<SEG> new_b;
if( b_end_pt != chamfer.B )
{
new_b = SEG{ b_end_pt, chamfer.B };
}
return CHAMFER_RESULT{ chamfer, new_a, new_b };
}

View File

@ -23,7 +23,7 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
m_xLabel = new wxStaticText( this, wxID_ANY, _("Move X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
m_xLabel->Wrap( -1 );
fgInputSizer->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgInputSizer->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_xEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgInputSizer->Add( m_xEntry, 0, wxEXPAND, 5 );
@ -37,7 +37,7 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
m_yLabel = new wxStaticText( this, wxID_ANY, _("Move Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_yLabel->Wrap( -1 );
fgInputSizer->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgInputSizer->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_yEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgInputSizer->Add( m_yEntry, 0, wxEXPAND, 5 );
@ -51,7 +51,7 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
m_rotLabel = new wxStaticText( this, wxID_ANY, _("Rotate:"), wxDefaultPosition, wxDefaultSize, 0 );
m_rotLabel->Wrap( -1 );
fgInputSizer->Add( m_rotLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgInputSizer->Add( m_rotLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_rotEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgInputSizer->Add( m_rotEntry, 0, wxEXPAND, 5 );
@ -79,7 +79,7 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
bBottomSizer = new wxBoxSizer( wxHORIZONTAL );
m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 );
bBottomSizer->Add( m_polarCoords, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
bBottomSizer->Add( m_polarCoords, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
m_stdButtons = new wxStdDialogButtonSizer();
m_stdButtonsOK = new wxButton( this, wxID_OK );

View File

@ -79,7 +79,7 @@
<property name="vgap">5</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -341,7 +341,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -603,7 +603,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -948,7 +948,7 @@
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">

View File

@ -43,16 +43,16 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent,
bSizerButtOpts->Add( m_select_anchor_button, 1, wxALL|wxEXPAND, 5 );
bUpperSizer->Add( bSizerButtOpts, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
bUpperSizer->Add( bSizerButtOpts, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizer6->Add( m_staticline2, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizer6->Add( m_staticline2, 0, wxEXPAND|wxBOTTOM, 10 );
bUpperSizer->Add( bSizer6, 0, wxEXPAND|wxTOP, 3 );
bUpperSizer->Add( bSizer6, 0, wxEXPAND, 5 );
bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxALL, 5 );
@ -65,7 +65,7 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent,
m_xLabel = new wxStaticText( this, wxID_ANY, _("Offset X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
m_xLabel->Wrap( -1 );
fgSizer2->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
fgSizer2->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_xEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_xEntry, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
@ -82,7 +82,7 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent,
m_yLabel = new wxStaticText( this, wxID_ANY, _("Offset Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_yLabel->Wrap( -1 );
fgSizer2->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
fgSizer2->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_yEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_yEntry, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
@ -98,14 +98,14 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent,
fgSizer2->Add( m_clearY, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
bMainSizer->Add( fgSizer2, 1, wxEXPAND|wxALL, 10 );
bMainSizer->Add( fgSizer2, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer* bSizerBottom;
bSizerBottom = new wxBoxSizer( wxHORIZONTAL );
m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 );
m_polarCoords->SetValue(true);
bSizerBottom->Add( m_polarCoords, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
bSizerBottom->Add( m_polarCoords, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
bSizerBottom->Add( 40, 0, 1, wxEXPAND, 5 );

View File

@ -144,7 +144,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -376,8 +376,8 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -385,8 +385,8 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="border">10</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
@ -447,7 +447,7 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
@ -464,7 +464,7 @@
<property name="vgap">5</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -735,7 +735,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -1016,7 +1016,7 @@
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">

View File

@ -47,6 +47,7 @@
#include <tools/edit_tool.h>
#include <tools/item_modification_routine.h>
#include <tools/pcb_picker_tool.h>
#include <tools/pcb_point_editor.h>
#include <tools/tool_event_utils.h>
#include <tools/pcb_grid_helper.h>
#include <tools/pad_tool.h>
@ -85,6 +86,7 @@ void EDIT_TOOL::Reset( RESET_REASON aReason )
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
}
static std::shared_ptr<CONDITIONAL_MENU> makePositioningToolsMenu( TOOL_INTERACTIVE* aTool )
{
auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
@ -106,6 +108,7 @@ static std::shared_ptr<CONDITIONAL_MENU> makePositioningToolsMenu( TOOL_INTERACT
return menu;
};
static std::shared_ptr<CONDITIONAL_MENU> makeShapeModificationMenu( TOOL_INTERACTIVE* aTool )
{
auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
@ -118,12 +121,31 @@ static std::shared_ptr<CONDITIONAL_MENU> makeShapeModificationMenu( TOOL_INTERAC
static std::vector<KICAD_T> lineExtendTypes = { PCB_SHAPE_LOCATE_SEGMENT_T };
auto hasCornerCondition =
[aTool]( const SELECTION& aSelection )
{
PCB_POINT_EDITOR *pt_tool = aTool->GetManager()->GetTool<PCB_POINT_EDITOR>();
return pt_tool && pt_tool->HasCorner();
};
auto hasMidpointCondition =
[aTool]( const SELECTION& aSelection )
{
PCB_POINT_EDITOR *pt_tool = aTool->GetManager()->GetTool<PCB_POINT_EDITOR>();
return pt_tool && pt_tool->HasMidpoint();
};
// clang-format off
menu->AddItem( PCB_ACTIONS::filletLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) );
menu->AddItem( PCB_ACTIONS::chamferLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) );
menu->AddItem( PCB_ACTIONS::extendLines, SELECTION_CONDITIONS::OnlyTypes( lineExtendTypes )
&& SELECTION_CONDITIONS::Count( 2 ) );
menu->AddItem( PCB_ACTIONS::pointEditorMoveCorner, hasCornerCondition );
menu->AddItem( PCB_ACTIONS::pointEditorMoveMidpoint, hasMidpointCondition );
// clang-format on
return menu;
};
@ -837,7 +859,7 @@ int EDIT_TOOL::ChangeTrackWidth( const TOOL_EVENT& aEvent )
int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
{
// Store last used fillet radius to allow pressing "enter" if repeat fillet is required
static long long filletRadiusIU = 0;
static int filletRadius = 0;
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
@ -859,15 +881,15 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
return 0;
}
WX_UNIT_ENTRY_DIALOG dia( frame(), _( "Enter fillet radius:" ), _( "Fillet Tracks" ),
filletRadiusIU );
WX_UNIT_ENTRY_DIALOG dlg( frame(), _( "Fillet Tracks" ), _( "Enter fillet radius:" ),
filletRadius );
if( dia.ShowModal() == wxID_CANCEL )
if( dlg.ShowModal() == wxID_CANCEL )
return 0;
filletRadiusIU = dia.GetValue();
filletRadius = dlg.GetValue();
if( filletRadiusIU == 0 )
if( filletRadius == 0 )
{
frame()->ShowInfoBarMsg( _( "A radius of zero was entered.\n"
"The fillet operation was not performed." ) );
@ -965,11 +987,11 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
if( t1Seg.ApproxCollinear( t2Seg ) )
continue;
SHAPE_ARC sArc( t1Seg, t2Seg, filletRadiusIU );
SHAPE_ARC sArc( t1Seg, t2Seg, filletRadius );
VECTOR2I t1newPoint, t2newPoint;
auto setIfPointOnSeg =
[]( VECTOR2I& aPointToSet, SEG aSegment, VECTOR2I aVecToTest )
[]( VECTOR2I& aPointToSet, const SEG& aSegment, const VECTOR2I& aVecToTest )
{
VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
@ -1049,24 +1071,24 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
static std::optional<int> GetFilletParams( PCB_BASE_EDIT_FRAME& aFrame, wxString& aErrorMsg )
{
// Store last used fillet radius to allow pressing "enter" if repeat fillet is required
static long long filletRadiusIU = 0;
static int filletRadius = 0;
WX_UNIT_ENTRY_DIALOG dia( &aFrame, _( "Enter fillet radius:" ), _( "Fillet Lines" ),
filletRadiusIU );
WX_UNIT_ENTRY_DIALOG dlg( &aFrame, _( "Fillet Lines" ), _( "Enter fillet radius:" ),
filletRadius );
if( dia.ShowModal() == wxID_CANCEL )
if( dlg.ShowModal() == wxID_CANCEL )
return std::nullopt;
filletRadiusIU = dia.GetValue();
filletRadius = dlg.GetValue();
if( filletRadiusIU == 0 )
if( filletRadius == 0 )
{
aErrorMsg = _( "A radius of zero was entered.\n"
"The fillet operation was not performed." );
return std::nullopt;
}
return filletRadiusIU;
return filletRadius;
}
/**
@ -1085,19 +1107,19 @@ static std::optional<CHAMFER_PARAMS> GetChamferParams( PCB_BASE_EDIT_FRAME& aFra
// Store last used setback to allow pressing "enter" if repeat chamfer is required
static CHAMFER_PARAMS params{ default_setback, default_setback };
WX_UNIT_ENTRY_DIALOG dia( &aFrame, _( "Enter chamfer setback:" ), _( "Chamfer Lines" ),
params.m_chamfer_setback_a_IU );
WX_UNIT_ENTRY_DIALOG dlg( &aFrame, _( "Chamfer Lines" ), _( "Enter chamfer setback:" ),
params.m_chamfer_setback_a );
if( dia.ShowModal() == wxID_CANCEL )
if( dlg.ShowModal() == wxID_CANCEL )
return std::nullopt;
params.m_chamfer_setback_a_IU = dia.GetValue();
params.m_chamfer_setback_a = dlg.GetValue();
// It's hard to easily specify an asymmetric chamfer (which line gets the longer
// setbeck?), so we just use the same setback for each
params.m_chamfer_setback_b_IU = params.m_chamfer_setback_a_IU;
params.m_chamfer_setback_b = params.m_chamfer_setback_a;
// Some technically-valid chamfers are not useful to actually do
if( params.m_chamfer_setback_a_IU == 0 )
if( params.m_chamfer_setback_a == 0 )
{
aErrorMsg = _( "A setback of zero was entered.\n"
"The chamfer operation was not performed." );

View File

@ -334,6 +334,20 @@ TOOL_ACTION PCB_ACTIONS::moveExact( "pcbnew.InteractiveEdit.moveExact",
_( "Move Exactly..." ), _( "Moves the selected item(s) by an exact amount" ),
BITMAPS::move_exactly );
TOOL_ACTION PCB_ACTIONS::pointEditorMoveCorner( TOOL_ACTION_ARGS()
.Name( "pcbnew.InteractiveEdit.moveCorner" )
.Scope( AS_GLOBAL )
.MenuText( _( "Move Corner To..." ) )
.Tooltip( _( "Move the active corner to an exact location" ) )
.Icon( BITMAPS::move_exactly ) );
TOOL_ACTION PCB_ACTIONS::pointEditorMoveMidpoint( TOOL_ACTION_ARGS()
.Name( "pcbnew.InteractiveEdit.moveMidpoint" )
.Scope( AS_GLOBAL )
.MenuText( _( "Move Midpoint To..." ) )
.Tooltip( _( "Move the active midpoint to an exact location" ) )
.Icon( BITMAPS::move_exactly ) );
TOOL_ACTION PCB_ACTIONS::createArray( "pcbnew.InteractiveEdit.createArray",
AS_GLOBAL,
MD_CTRL + 'T', LEGACY_HK_NAME( "Create Array" ),

View File

@ -263,6 +263,9 @@ public:
static TOOL_ACTION pointEditorArcKeepCenter;
static TOOL_ACTION pointEditorArcKeepEndpoint;
static TOOL_ACTION pointEditorMoveCorner;
static TOOL_ACTION pointEditorMoveMidpoint;
// Group Tool
static TOOL_ACTION groupProperties;

View File

@ -36,6 +36,7 @@ using namespace std::placeholders;
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_point_editor.h>
#include <tools/pcb_grid_helper.h>
#include <dialogs/dialog_unit_entry.h>
#include <board_commit.h>
#include <pcb_edit_frame.h>
#include <pcb_bitmap.h>
@ -621,7 +622,7 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
getViewControls()->SetAutoPan( false );
setAltConstraint( false );
commit.Push( _( "Drag a corner" ) );
commit.Push( _( "Drag Corner" ) );
inDrag = false;
frame()->UndoRedoBlock( false );
@ -663,6 +664,42 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
return 0;
}
int PCB_POINT_EDITOR::movePoint( const TOOL_EVENT& aEvent )
{
if( !m_editPoints || !m_editPoints->GetParent() || !HasPoint() )
return 0;
BOARD_COMMIT commit( frame() );
commit.Stage( m_editPoints->GetParent(), CHT_MODIFY );
wxString title;
wxString msg;
if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
{
title = _( "Move Midpoint to Location" );
msg = _( "Move Midpoint" );
}
else
{
title = _( "Move Corner to Location" );
msg = _( "Move Corner" );
}
WX_PT_ENTRY_DIALOG dlg( frame(), title, _( "X:" ), _( "Y:" ), m_editedPoint->GetPosition() );
if( dlg.ShowModal() == wxID_OK )
{
m_editedPoint->SetPosition( dlg.GetValue() );
updateItem();
commit.Push( msg );
}
return 0;
}
void PCB_POINT_EDITOR::editArcEndpointKeepTangent( PCB_SHAPE* aArc, const VECTOR2I& aCenter,
const VECTOR2I& aStart, const VECTOR2I& aMid,
const VECTOR2I& aEnd,
@ -2239,7 +2276,7 @@ int PCB_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
static_cast<ZONE*>( item )->HatchBorder();
commit.Push( _( "Add a zone corner" ) );
commit.Push( _( "Add Zone Corner" ) );
}
else if( graphicItem && graphicItem->GetShape() == SHAPE_T::SEGMENT )
{
@ -2259,7 +2296,7 @@ int PCB_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
newSegment->SetEnd( VECTOR2I( seg.B.x, seg.B.y ) );
commit.Add( newSegment );
commit.Push( _( "Split segment" ) );
commit.Push( _( "Split Segment" ) );
}
updatePoints();
@ -2330,7 +2367,10 @@ int PCB_POINT_EDITOR::removeCorner( const TOOL_EVENT& aEvent )
setEditedPoint( nullptr );
commit.Push( _( "Remove a zone/polygon corner" ) );
if( item->Type() == PCB_ZONE_T )
commit.Push( _( "Remove Zone Corner" ) );
else
commit.Push( _( "Remove Polygon Corner" ) );
// Refresh zone hatching
if( item->Type() == PCB_ZONE_T )
@ -2388,6 +2428,8 @@ int PCB_POINT_EDITOR::changeArcEditMode( const TOOL_EVENT& aEvent )
void PCB_POINT_EDITOR::setTransitions()
{
Go( &PCB_POINT_EDITOR::OnSelectionChange, ACTIONS::activatePointEditor.MakeEvent() );
Go( &PCB_POINT_EDITOR::movePoint, PCB_ACTIONS::pointEditorMoveCorner.MakeEvent() );
Go( &PCB_POINT_EDITOR::movePoint, PCB_ACTIONS::pointEditorMoveMidpoint.MakeEvent() );
Go( &PCB_POINT_EDITOR::addCorner, PCB_ACTIONS::pointEditorAddCorner.MakeEvent() );
Go( &PCB_POINT_EDITOR::removeCorner, PCB_ACTIONS::pointEditorRemoveCorner.MakeEvent() );
Go( &PCB_POINT_EDITOR::changeArcEditMode, PCB_ACTIONS::pointEditorArcKeepCenter.MakeEvent() );

View File

@ -63,6 +63,8 @@ public:
* Used to coordinate cursor shapes with other tools.
*/
bool HasPoint() { return m_editedPoint != nullptr; }
bool HasMidpoint() { return HasPoint() && dynamic_cast<EDIT_LINE*>( m_editedPoint ); }
bool HasCorner() { return HasPoint() && !HasMidpoint(); }
private:
///< Set up handlers for various events.
@ -129,6 +131,7 @@ private:
bool removeCornerCondition( const SELECTION& aSelection );
/// TOOL_ACTION handlers
int movePoint( const TOOL_EVENT& aEvent );
int addCorner( const TOOL_EVENT& aEvent );
int removeCorner( const TOOL_EVENT& aEvent );
int modifiedSelection( const TOOL_EVENT& aEvent );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2018-2023 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
@ -23,8 +23,6 @@
#include <boost/test/unit_test.hpp>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <geometry/chamfer.h>
#include "geom_test_utils.h"
@ -49,8 +47,9 @@ struct TWO_LINE_CHAMFER_TEST_CASE
static void DoChamferTestChecks( const TWO_LINE_CHAMFER_TEST_CASE& aTestCase )
{
// Actally do the chamfer
const std::optional<CHAMFER_RESULT> chamfer_result =
ComputeChamferPoints( aTestCase.m_seg_a, aTestCase.m_seg_b, aTestCase.m_params );
const std::optional<CHAMFER_RESULT> chamfer_result = ComputeChamferPoints( aTestCase.m_seg_a,
aTestCase.m_seg_b,
aTestCase.m_params );
BOOST_REQUIRE_EQUAL( chamfer_result.has_value(), aTestCase.m_expected_result.has_value() );
@ -66,6 +65,7 @@ static void DoChamferTestChecks( const TWO_LINE_CHAMFER_TEST_CASE& aTestCase )
[&]( const std::optional<SEG>& updated_seg, const std::optional<SEG>& expected_seg )
{
BOOST_REQUIRE_EQUAL( updated_seg.has_value(), expected_seg.has_value() );
if( updated_seg.has_value() )
{
BOOST_CHECK_PREDICATE( GEOM_TEST::SegmentsHaveSameEndPoints,
@ -89,7 +89,8 @@ BOOST_AUTO_TEST_CASE( SimpleChamferAtOrigin )
* v 1000
* */
const TWO_LINE_CHAMFER_TEST_CASE testcase{
const TWO_LINE_CHAMFER_TEST_CASE testcase
{
{ VECTOR2I( 0, 0 ), VECTOR2I( 1000, 0 ) },
{ VECTOR2I( 0, 0 ), VECTOR2I( 0, 1000 ) },
{ 10, 10 },
@ -106,7 +107,8 @@ BOOST_AUTO_TEST_CASE( SimpleChamferAtOrigin )
BOOST_AUTO_TEST_CASE( SimpleChamferNotAtOrigin )
{
// Same as above but the intersection is not at the origin
const TWO_LINE_CHAMFER_TEST_CASE testcase{
const TWO_LINE_CHAMFER_TEST_CASE testcase
{
{ VECTOR2I( 1000, 1000 ), VECTOR2I( 2000, 1000 ) },
{ VECTOR2I( 1000, 1000 ), VECTOR2I( 1000, 2000 ) },
{ 10, 10 },
@ -123,7 +125,8 @@ BOOST_AUTO_TEST_CASE( SimpleChamferNotAtOrigin )
BOOST_AUTO_TEST_CASE( AsymmetricChamfer )
{
// Same as above but the intersection is not at the origin
const TWO_LINE_CHAMFER_TEST_CASE testcase{
const TWO_LINE_CHAMFER_TEST_CASE testcase
{
{ VECTOR2I( 0, 0 ), VECTOR2I( 1000, 0 ) },
{ VECTOR2I( 0, 0 ), VECTOR2I( 0, 1000 ) },
{ 10, 100 },
@ -140,7 +143,8 @@ BOOST_AUTO_TEST_CASE( AsymmetricChamfer )
BOOST_AUTO_TEST_CASE( ChamferFullLength )
{
// Chamfer consumes the entire length of a line
const TWO_LINE_CHAMFER_TEST_CASE testcase{
const TWO_LINE_CHAMFER_TEST_CASE testcase
{
{ VECTOR2I( 0, 0 ), VECTOR2I( 1000, 0 ) },
{ VECTOR2I( 0, 0 ), VECTOR2I( 0, 100 ) },
{ 100, 100 },
@ -157,7 +161,8 @@ BOOST_AUTO_TEST_CASE( ChamferFullLength )
BOOST_AUTO_TEST_CASE( ChamferOverFullLength )
{
// Chamfer consumes the entire length of a line
const TWO_LINE_CHAMFER_TEST_CASE testcase{
const TWO_LINE_CHAMFER_TEST_CASE testcase
{
{ VECTOR2I( 0, 0 ), VECTOR2I( 1000, 0 ) },
{ VECTOR2I( 0, 0 ), VECTOR2I( 0, 100 ) },
{ 150, 150 }, // > 100