7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 16:13:44 +00:00

More g_UserUnit erradication.

(cherry picked from commit 3f08780)
This commit is contained in:
Jeff Young 2018-06-14 09:26:11 +01:00
parent 0358aee89e
commit 5f3ee1e7ce
37 changed files with 1224 additions and 1896 deletions

View File

@ -92,7 +92,11 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) :
DIALOG_PAGES_SETTINGS_BASE( parent ),
m_initialized( false )
m_initialized( false ),
m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false,
MIN_PAGE_SIZE * IU_PER_MILS, MAX_PAGE_SIZE * IU_PER_MILS ),
m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false,
MIN_PAGE_SIZE * IU_PER_MILS, MAX_PAGE_SIZE * IU_PER_MILS )
{
m_parent = parent;
m_screen = m_parent->GetScreen();
@ -122,8 +126,6 @@ DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS()
void DIALOG_PAGES_SETTINGS::initDialog()
{
wxString msg;
double customSizeX;
double customSizeY;
// initialize page format choice box and page format list.
// The first shows translated strings, the second contains not translated strings
@ -160,41 +162,15 @@ void DIALOG_PAGES_SETTINGS::initDialog()
wxCommandEvent dummy;
OnPaperSizeChoice( dummy );
if( m_customFmt) // The custom value is defined by the page size
if( m_customFmt )
{
customSizeX = m_pageInfo.GetWidthMils();
customSizeY = m_pageInfo.GetHeightMils();
m_customSizeX.SetValue( m_pageInfo.GetWidthMils() * IU_PER_MILS );
m_customSizeY.SetValue( m_pageInfo.GetHeightMils() * IU_PER_MILS );
}
else // The custom value is set to a default value, or the last defined value
else
{
customSizeX = m_pageInfo.GetCustomWidthMils();
customSizeY = m_pageInfo.GetCustomHeightMils();
}
switch( g_UserUnit )
{
case MILLIMETRES:
customSizeX *= 25.4e-3;
customSizeY *= 25.4e-3;
msg.Printf( wxT( "%.2f" ), customSizeX );
m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%.2f" ), customSizeY );
m_TextUserSizeY->SetValue( msg );
break;
default:
case INCHES:
customSizeX /= 1000.0;
customSizeY /= 1000.0;
msg.Printf( wxT( "%.3f" ), customSizeX );
m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%.3f" ), customSizeY );
m_TextUserSizeY->SetValue( msg );
break;
m_customSizeX.SetValue( m_pageInfo.GetCustomWidthMils() * IU_PER_MILS );
m_customSizeY.SetValue( m_pageInfo.GetCustomHeightMils() * IU_PER_MILS );
}
m_TextRevision->SetValue( m_tb.GetRevision() );
@ -255,8 +231,8 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
if( paperType.Contains( PAGE_INFO::Custom ) )
{
m_orientationComboBox->Enable( false );
m_TextUserSizeX->Enable( true );
m_TextUserSizeY->Enable( true );
m_customSizeX.Enable( true );
m_customSizeY.Enable( true );
m_customFmt = true;
}
else
@ -272,8 +248,8 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
m_orientationComboBox->Enable( false );
}
#endif
m_TextUserSizeX->Enable( false );
m_TextUserSizeY->Enable( false );
m_customSizeX.Enable( false );
m_customSizeY.Enable( false );
m_customFmt = false;
}
@ -284,7 +260,7 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
void DIALOG_PAGES_SETTINGS::OnUserPageSizeXTextUpdated( wxCommandEvent& event )
{
if( m_initialized && m_TextUserSizeX->IsModified() )
if( m_initialized )
{
GetPageLayoutInfoFromDialog();
UpdatePageLayoutExample();
@ -294,7 +270,7 @@ void DIALOG_PAGES_SETTINGS::OnUserPageSizeXTextUpdated( wxCommandEvent& event )
void DIALOG_PAGES_SETTINGS::OnUserPageSizeYTextUpdated( wxCommandEvent& event )
{
if( m_initialized && m_TextUserSizeY->IsModified() )
if( m_initialized )
{
GetPageLayoutInfoFromDialog();
UpdatePageLayoutExample();
@ -423,20 +399,15 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName )
{
wxString fullFileName =
WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath );
wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath );
if( !fullFileName.IsEmpty() )
if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
{
if( !wxFileExists( fullFileName ) )
{
wxString msg;
msg.Printf( _("Page layout description file \"%s\" not found. Abort"),
GetChars( fullFileName ) );
wxMessageBox( msg );
return false;
}
wxString msg;
msg.Printf( _( "Page layout description file \"%s\" not found." ),
GetChars( fullFileName ) );
wxMessageBox( msg );
return false;
}
BASE_SCREEN::m_PageLayoutDescrFileName = fileName;
@ -445,11 +416,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
m_localPrjConfigChanged = true;
}
int idx = m_paperSizeComboBox->GetSelection();
if( idx < 0 )
idx = 0;
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
const wxString paperType = m_pageFmt[idx];
if( paperType.Contains( PAGE_INFO::Custom ) )
@ -460,26 +427,8 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
if( retSuccess )
{
if( m_layout_size.x < MIN_PAGE_SIZE || m_layout_size.y < MIN_PAGE_SIZE ||
m_layout_size.x > MAX_PAGE_SIZE || m_layout_size.y > MAX_PAGE_SIZE )
{
wxString msg = wxString::Format( _( "Selected custom paper size\n"
"is out of the permissible limits\n"
"%.1f - %.1f %s!\nSelect another custom "
"paper size?" ),
g_UserUnit == INCHES ? MIN_PAGE_SIZE / 1000. : MIN_PAGE_SIZE * 25.4 / 1000,
g_UserUnit == INCHES ? MAX_PAGE_SIZE / 1000. : MAX_PAGE_SIZE * 25.4 / 1000,
g_UserUnit == INCHES ? _( "inches" ) : _( "mm" ) );
if( wxMessageBox( msg, _( "Warning!" ),
wxYES_NO | wxICON_EXCLAMATION, this ) == wxYES )
{
return false;
}
m_layout_size.x = Clamp( MIN_PAGE_SIZE, m_layout_size.x, MAX_PAGE_SIZE );
m_layout_size.y = Clamp( MIN_PAGE_SIZE, m_layout_size.y, MAX_PAGE_SIZE );
}
if( !m_customSizeX.Validate( true ) || !m_customSizeY.Validate( true ) )
return false;
PAGE_INFO::SetCustomWidthMils( m_layout_size.x );
PAGE_INFO::SetCustomHeightMils( m_layout_size.y );
@ -702,11 +651,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
{
int idx = m_paperSizeComboBox->GetSelection();
if( idx < 0 )
idx = 0;
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
const wxString paperType = m_pageFmt[idx];
// here we assume translators will keep original paper size spellings
@ -772,28 +717,8 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog()
{
double customSizeX;
double customSizeY;
wxString msg;
msg = m_TextUserSizeX->GetValue();
msg.ToDouble( &customSizeX );
msg = m_TextUserSizeY->GetValue();
msg.ToDouble( &customSizeY );
switch( g_UserUnit )
{
case MILLIMETRES:
customSizeX *= 1000. / 25.4;
customSizeY *= 1000. / 25.4;
break;
default:
case INCHES:
customSizeX *= 1000.;
customSizeY *= 1000.;
}
double customSizeX = (double) m_customSizeX.GetValue() / IU_PER_MILS;
double customSizeY = (double) m_customSizeY.GetValue() / IU_PER_MILS;
// Prepare to painless double -> int conversion.
customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );

View File

@ -24,6 +24,8 @@
#ifndef _DIALOG_PAGES_SETTINGS_H_
#define _DIALOG_PAGES_SETTINGS_H_
#include <widgets/unit_binder.h>
#include <dialog_page_settings_base.h>
#define MAX_PAGE_EXAMPLE_SIZE 200
@ -48,6 +50,8 @@ private:
TITLE_BLOCK m_tb; /// Temporary title block (basic inscriptions).
WORKSHEET_LAYOUT *m_pagelayout; // the alternate and temporary page layout shown by the dialog
// when the initial one is replaced by a new one
UNIT_BINDER m_customSizeX;
UNIT_BINDER m_customSizeY;
public:
DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -49,65 +49,63 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
m_orientationComboBox->SetSelection( 0 );
bleftSizer->Add( m_orientationComboBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextCustSize = new wxStaticText( this, wxID_ANY, _("Custom Size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextCustSize = new wxStaticText( this, wxID_ANY, _("Custom paper size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextCustSize->Wrap( -1 );
bleftSizer->Add( m_staticTextCustSize, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerCustSize;
bSizerCustSize = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxBoxSizer* bSizercustHeight;
bSizercustHeight = new wxBoxSizer( wxVERTICAL );
m_userSizeYLabel = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_userSizeYLabel->Wrap( -1 );
fgSizer1->Add( m_userSizeYLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_staticTextHeight = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextHeight->Wrap( -1 );
bSizercustHeight->Add( m_staticTextHeight, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextUserSizeY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT );
m_userSizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT );
#ifdef __WXGTK__
if ( !m_TextUserSizeY->HasFlag( wxTE_MULTILINE ) )
if ( !m_userSizeYCtrl->HasFlag( wxTE_MULTILINE ) )
{
m_TextUserSizeY->SetMaxLength( 6 );
m_userSizeYCtrl->SetMaxLength( -1 );
}
#else
m_TextUserSizeY->SetMaxLength( 6 );
m_userSizeYCtrl->SetMaxLength( -1 );
#endif
m_TextUserSizeY->SetToolTip( _("Custom paper height.") );
m_userSizeYCtrl->SetToolTip( _("Custom paper height.") );
bSizercustHeight->Add( m_TextUserSizeY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_userSizeYCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_userSizeYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_userSizeYUnits->Wrap( -1 );
fgSizer1->Add( m_userSizeYUnits, 0, wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerCustSize->Add( bSizercustHeight, 1, wxEXPAND, 5 );
m_userSizeXLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_userSizeXLabel->Wrap( -1 );
fgSizer1->Add( m_userSizeXLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bSizercustWidth;
bSizercustWidth = new wxBoxSizer( wxVERTICAL );
m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextWidth->Wrap( -1 );
bSizercustWidth->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextUserSizeX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT );
m_userSizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT );
#ifdef __WXGTK__
if ( !m_TextUserSizeX->HasFlag( wxTE_MULTILINE ) )
if ( !m_userSizeXCtrl->HasFlag( wxTE_MULTILINE ) )
{
m_TextUserSizeX->SetMaxLength( 6 );
m_userSizeXCtrl->SetMaxLength( -1 );
}
#else
m_TextUserSizeX->SetMaxLength( 6 );
m_userSizeXCtrl->SetMaxLength( -1 );
#endif
m_TextUserSizeX->SetToolTip( _("Custom paper width.") );
m_userSizeXCtrl->SetToolTip( _("Custom paper width.") );
bSizercustWidth->Add( m_TextUserSizeX, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_userSizeXCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_userSizeXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_userSizeXUnits->Wrap( -1 );
fgSizer1->Add( m_userSizeXUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
bSizerCustSize->Add( bSizercustWidth, 1, wxEXPAND, 5 );
bleftSizer->Add( bSizerCustSize, 0, wxEXPAND, 5 );
bleftSizer->Add( fgSizer1, 0, wxEXPAND|wxBOTTOM, 5 );
m_staticTextPreview = new wxStaticText( this, wxID_ANY, _("Layout Preview"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPreview->Wrap( -1 );
bleftSizer->Add( m_staticTextPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bleftSizer->Add( m_staticTextPreview, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 10 );
m_PageLayoutExampleBitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxFULL_REPAINT_ON_RESIZE|wxSIMPLE_BORDER );
m_PageLayoutExampleBitmap->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
@ -116,10 +114,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
bleftSizer->Add( m_PageLayoutExampleBitmap, 1, wxALL|wxEXPAND, 5 );
bUpperSizerH->Add( bleftSizer, 0, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
bUpperSizerH->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
bUpperSizerH->Add( bleftSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
@ -146,7 +141,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
SheetInfoSizer->Add( m_TextSheetNumber, 0, wxALL, 5 );
bSizerRight->Add( SheetInfoSizer, 0, 0, 5 );
bSizerRight->Add( SheetInfoSizer, 0, wxLEFT, 5 );
wxBoxSizer* bSizerDate;
bSizerDate = new wxBoxSizer( wxVERTICAL );
@ -359,7 +354,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
m_textCtrlFilePicker = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerfileSelection->Add( m_textCtrlFilePicker, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
bSizerfileSelection->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
@ -369,10 +364,10 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
bSizerRight->Add( bSizerFilename, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bUpperSizerH->Add( bSizerRight, 1, wxEXPAND, 5 );
bUpperSizerH->Add( bSizerRight, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( bUpperSizerH, 1, wxEXPAND, 5 );
bMainSizer->Add( bUpperSizerH, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
@ -391,8 +386,8 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
// Connect Events
m_paperSizeComboBox->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPaperSizeChoice ), NULL, this );
m_orientationComboBox->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPageOrientationChoice ), NULL, this );
m_TextUserSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this );
m_TextUserSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this );
m_userSizeYCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this );
m_userSizeXCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this );
m_TextDate->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateTextUpdated ), NULL, this );
m_ApplyDate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateApplyClick ), NULL, this );
m_TextRevision->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnRevisionTextUpdated ), NULL, this );
@ -412,8 +407,8 @@ DIALOG_PAGES_SETTINGS_BASE::~DIALOG_PAGES_SETTINGS_BASE()
// Disconnect Events
m_paperSizeComboBox->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPaperSizeChoice ), NULL, this );
m_orientationComboBox->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPageOrientationChoice ), NULL, this );
m_TextUserSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this );
m_TextUserSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this );
m_userSizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this );
m_userSizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this );
m_TextDate->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateTextUpdated ), NULL, this );
m_ApplyDate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateApplyClick ), NULL, this );
m_TextRevision->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnRevisionTextUpdated ), NULL, this );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -21,8 +21,8 @@
#include <wx/statline.h>
#include <wx/choice.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/valtext.h>
#include <wx/sizer.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
@ -51,13 +51,14 @@ class DIALOG_PAGES_SETTINGS_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextOrient;
wxChoice* m_orientationComboBox;
wxStaticText* m_staticTextCustSize;
wxStaticText* m_staticTextHeight;
wxTextCtrl* m_TextUserSizeY;
wxStaticText* m_staticTextWidth;
wxTextCtrl* m_TextUserSizeX;
wxStaticText* m_userSizeYLabel;
wxTextCtrl* m_userSizeYCtrl;
wxStaticText* m_userSizeYUnits;
wxStaticText* m_userSizeXLabel;
wxTextCtrl* m_userSizeXCtrl;
wxStaticText* m_userSizeXUnits;
wxStaticText* m_staticTextPreview;
wxStaticBitmap* m_PageLayoutExampleBitmap;
wxStaticLine* m_staticline1;
wxStaticText* m_staticTexttbprm;
wxStaticLine* m_staticline3;
wxStaticText* m_TextSheetCount;

View File

@ -33,9 +33,10 @@
using namespace KIGFX::PREVIEW;
ARC_ASSISTANT::ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager ) :
ARC_ASSISTANT::ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, EDA_UNITS_T aUnits ) :
EDA_ITEM( NOT_USED ),
m_constructMan( aManager )
m_constructMan( aManager ),
m_units( aUnits )
{
}
@ -49,8 +50,8 @@ const BOX2I ARC_ASSISTANT::ViewBBox() const
return tmp;
// just enclose the whle circular area
auto origin = m_constructMan.GetOrigin();
auto radius = m_constructMan.GetRadius();
auto origin = m_constructMan.GetOrigin();
auto radius = m_constructMan.GetRadius();
VECTOR2D rVec( radius, radius );
tmp.SetOrigin( origin + rVec );
@ -172,7 +173,7 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
double degs = getNormDeciDegFromRad( initAngle );
cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), g_UserUnit ) );
cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), m_units ) );
cursorStrings.push_back( DimensionLabel( "θ", degs, DEGREES ) );
}
else
@ -197,8 +198,7 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// FIXME: spaces choke OpenGL lp:1668455
for( auto& str : cursorStrings )
{
str.erase( std::remove( str.begin(), str.end(), ' ' ),
str.end() );
str.erase( std::remove( str.begin(), str.end(), ' ' ), str.end() );
}
// place the text next to cursor, on opposite side from radius

View File

@ -275,7 +275,7 @@ CONTEXT_MENU* CONTEXT_MENU::create() const
}
TOOL_MANAGER* CONTEXT_MENU::getToolManager()
TOOL_MANAGER* CONTEXT_MENU::getToolManager() const
{
wxASSERT( m_tool );
return m_tool ? m_tool->GetManager() : nullptr;

View File

@ -140,7 +140,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
m_cmp = aComponent;
m_part = GetParent()->GetLibPart( m_cmp->GetLibId(), true );
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( false, g_UserUnit, m_part );
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( false, GetUserUnits(), m_part );
m_delayedFocusRow = REFERENCE;
m_delayedFocusColumn = FDC_VALUE;

View File

@ -123,7 +123,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT
m_parent = aParent;
m_libEntry = aLibEntry;
m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( true, g_UserUnit, m_libEntry );
m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( true, GetUserUnits(), m_libEntry );
m_delayedFocusRow = REFERENCE;
m_delayedFocusColumn = FDC_VALUE;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Seth Hillbrand <hillbrand@ucdavis.edu>
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2014-2018 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,31 +23,45 @@
*/
#include <cassert>
#include <sch_edit_frame.h>
#include <sch_line.h>
#include <widgets/color4Dpickerdlg.h>
#include <dialog_edit_line_style.h>
const int BUTT_COLOR_MINSIZE_X = 32;
const int BUTT_COLOR_MINSIZE_Y = 20;
DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( wxWindow* parent ) :
DIALOG_EDIT_LINE_STYLE_BASE( parent )
DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( SCH_EDIT_FRAME* aParent, SCH_LINE* aLine ) :
DIALOG_EDIT_LINE_STYLE_BASE( aParent ),
m_frame( aParent ),
m_line( aLine ),
m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true, 0 )
{
m_sdbSizerApply->SetLabel( _( "Default" ) );
m_lineStyle->SetSelection( 0 );
m_lineWidth->SetFocus();
m_defaultStyle = 0;
wxBitmap bitmap( std::max( m_colorButton->GetSize().x, BUTT_COLOR_MINSIZE_X ),
std::max( m_colorButton->GetSize().y, BUTT_COLOR_MINSIZE_Y ) );
m_colorButton->SetBitmap( bitmap );
SetInitialFocus( m_lineWidth );
m_sdbSizerOK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
bool DIALOG_EDIT_LINE_STYLE::TransferDataToWindow()
{
m_width.SetValue( m_line->GetPenSize() );
setColor( m_line->GetLineColor() );
m_lineStyle->SetSelection( m_line->GetLineStyle() );
return true;
}
void DIALOG_EDIT_LINE_STYLE::onColorButtonClicked( wxCommandEvent& event )
{
COLOR4D newColor = COLOR4D::UNSPECIFIED;
@ -59,7 +73,7 @@ void DIALOG_EDIT_LINE_STYLE::onColorButtonClicked( wxCommandEvent& event )
if( newColor == COLOR4D::UNSPECIFIED || m_selectedColor == newColor )
return;
SetColor( newColor, true );
setColor( newColor );
}
@ -87,37 +101,29 @@ void DIALOG_EDIT_LINE_STYLE::updateColorButton( COLOR4D& aColor )
void DIALOG_EDIT_LINE_STYLE::resetDefaults( wxCommandEvent& event )
{
SetStyle( m_defaultStyle );
SetWidth( m_defaultWidth );
SetColor( m_defaultColor, true );
m_width.SetValue( m_line->GetDefaultWidth() );
setColor( m_line->GetDefaultColor() );
m_lineStyle->SetSelection( m_line->GetDefaultStyle() );
Refresh();
}
void DIALOG_EDIT_LINE_STYLE::SetColor( const COLOR4D& aColor, bool aRefresh )
void DIALOG_EDIT_LINE_STYLE::setColor( const COLOR4D& aColor )
{
m_selectedColor = aColor;
if( aRefresh )
updateColorButton( m_selectedColor );
updateColorButton( m_selectedColor );
}
void DIALOG_EDIT_LINE_STYLE::SetDefaultColor( const COLOR4D& aColor )
bool DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow()
{
m_defaultColor = aColor;
}
m_frame->SaveCopyInUndoList( m_line, UR_CHANGED );
m_line->SetLineWidth( m_width.GetValue() );
m_line->SetLineStyle( m_lineStyle->GetSelection() );
m_line->SetLineColor( m_selectedColor );
void DIALOG_EDIT_LINE_STYLE::SetStyle( const int aStyle )
{
wxASSERT( aStyle >= 0 && aStyle < 4 );
m_frame->OnModify();
m_lineStyle->SetSelection( aStyle );
}
int DIALOG_EDIT_LINE_STYLE::GetStyle()
{
return m_lineStyle->GetSelection();
}
return true;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Seth Hillbrand <hillbrand@ucdavis.edu>
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2014-2018 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
@ -25,45 +25,33 @@
#ifndef __dialog_edit_line_style__
#define __dialog_edit_line_style__
/**
* @file dialog_edit_line_style.h
* @brief Subclass of DIALOG_EDIT_LINE_STYLE_BASE, which is generated by wxFormBuilder.
*/
#include <dialog_edit_line_style_base.h>
#include <sch_line.h>
#include <widgets/unit_binder.h>
class SCH_EDIT_FRAME;
class SCH_LINE;
class DIALOG_EDIT_LINE_STYLE : public DIALOG_EDIT_LINE_STYLE_BASE
{
public:
DIALOG_EDIT_LINE_STYLE( wxWindow* parent );
DIALOG_EDIT_LINE_STYLE( SCH_EDIT_FRAME* aParent, SCH_LINE* aLine );
void SetWidth( const wxString& aWidth ) { m_lineWidth->SetValue( aWidth ); }
void SetDefaultWidth( const wxString& aWidth ) { m_defaultWidth = aWidth; }
wxString GetWidth() const { return m_lineWidth->GetValue(); }
COLOR4D GetColor() const { return m_selectedColor; }
void SetColor( const COLOR4D& aColor, bool aRefresh );
void SetDefaultColor( const COLOR4D& aColor );
void SetStyle( const int aStyle );
void SetDefaultStyle( const int aStyle ) { m_defaultStyle = aStyle; }
int GetStyle();
void SetLineWidthUnits(const wxString& aUnits)
{
m_staticWidthUnits->SetLabel( aUnits );
}
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
private:
int m_defaultStyle;
wxString m_defaultWidth;
COLOR4D m_defaultColor;
COLOR4D m_selectedColor;
SCH_EDIT_FRAME* m_frame;
SCH_LINE* m_line;
UNIT_BINDER m_width;
COLOR4D m_selectedColor;
void resetDefaults( wxCommandEvent& event ) override;
void onColorButtonClicked( wxCommandEvent& aEvent ) override;
void setColor( const COLOR4D& aColor );
void updateColorButton( COLOR4D& aColor );
};

View File

@ -25,14 +25,20 @@
* @file dialog_lib_edit_draw_item.cpp
*/
#include <lib_draw_item.h>
#include <dialog_lib_edit_draw_item.h>
#include <lib_edit_frame.h>
DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent,
const wxString& itemName ) :
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( parent )
DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( LIB_EDIT_FRAME* aParent, LIB_ITEM* aItem ) :
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ),
m_frame( aParent ),
m_item( aItem ),
m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true, 0 )
{
SetTitle( itemName + wxT( " " ) + GetTitle() );
SetTitle( aItem->GetTypeName() + wxT( " " ) + GetTitle() );
SetInitialFocus( m_widthCtrl );
// Required under wxGTK if we want to dismiss the dialog with the ESC key
SetFocus();
@ -43,87 +49,52 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent,
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetWidth( const wxString& width )
bool DIALOG_LIB_EDIT_DRAW_ITEM::TransferDataToWindow()
{
m_textWidth->SetValue( width );
LIB_PART* symbol = m_item->GetParent();
m_lineWidth.SetValue( m_item->GetWidth() );
m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 );
m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 );
m_checkApplyToAllConversions->SetValue( symbol && symbol->HasConversion() );
bool enblConvOptStyle = symbol && symbol->HasConversion();
// if a symbol contains no graphic items, symbol->HasConversion() returns false.
// but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions
// must be enabled even if symbol->HasConversion() returns false in order to be able
// to create graphic items shared by all body styles
if( m_frame->GetShowDeMorgan() )
enblConvOptStyle = true;
m_checkApplyToAllConversions->Enable( enblConvOptStyle );
m_fillCtrl->SetSelection( m_item->GetFillMode() );
m_fillCtrl->Enable( m_item->IsFillable() );
return true;
}
wxString DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth( void )
int DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth()
{
return m_textWidth->GetValue();
return m_lineWidth.GetValue();
}
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions( void )
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions()
{
return m_checkApplyToAllConversions->IsChecked();
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetApplyToAllConversions( bool applyToAll )
{
m_checkApplyToAllConversions->SetValue( applyToAll );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::EnableApplyToAllConversions( bool enable )
{
m_checkApplyToAllConversions->Enable( enable );
}
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits( void )
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits()
{
return m_checkApplyToAllUnits->IsChecked();
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetApplyToAllUnits( bool applyToAll )
{
m_checkApplyToAllUnits->SetValue( applyToAll );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::EnableApplyToAllUnits( bool enable )
{
m_checkApplyToAllUnits->Enable( enable );
}
int DIALOG_LIB_EDIT_DRAW_ITEM::GetFillStyle( void )
{
if( m_radioFillNone->GetValue() )
return 0;
if( m_radioFillForeground->GetValue() )
return 1;
if( m_radioFillBackground->GetValue() )
return 2;
return 0;
return std::max( m_fillCtrl->GetSelection(), 0 );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetFillStyle( int fillStyle )
{
if( fillStyle == 1 )
m_radioFillForeground->SetValue( true );
else if( fillStyle == 2 )
m_radioFillBackground->SetValue( true );
else
m_radioFillNone->SetValue( true );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::EnableFillStyle( bool enable )
{
m_radioFillNone->Enable( enable );
m_radioFillForeground->Enable( enable );
m_radioFillBackground->Enable( enable );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetWidthUnits( const wxString& units )
{
m_staticWidthUnits->SetLabel( units );
}

File diff suppressed because it is too large Load Diff

View File

@ -25,17 +25,13 @@
#ifndef __dialog_lib_edit_draw_item__
#define __dialog_lib_edit_draw_item__
/**
* @file
* Subclass of DIALOG_LIB_EDIT_DRAW_ITEM_BASE, which is generated by
* wxFormBuilder.
*/
class LIB_DRAW_ITEM;
class LIB_ITEM;
class LIB_EDIT_FRAME;
#include <dialog_lib_edit_draw_item_base.h>
#include <widgets/unit_binder.h>
/**
* Dialog to edit library component graphic items.
@ -44,24 +40,19 @@ class DIALOG_LIB_EDIT_DRAW_ITEM : public DIALOG_LIB_EDIT_DRAW_ITEM_BASE
{
public:
/** Constructor */
DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent, const wxString& itemName );
DIALOG_LIB_EDIT_DRAW_ITEM( LIB_EDIT_FRAME* parent, LIB_ITEM* aItem );
wxString GetWidth( void );
void SetWidth( const wxString& width );
bool TransferDataToWindow() override;
bool GetApplyToAllConversions( void );
void SetApplyToAllConversions( bool applyToAll );
void EnableApplyToAllConversions( bool enable = true );
int GetWidth();
bool GetApplyToAllConversions();
bool GetApplyToAllUnits();
int GetFillStyle();
bool GetApplyToAllUnits( void );
void SetApplyToAllUnits( bool applyToAll );
void EnableApplyToAllUnits( bool enable = true );
int GetFillStyle( void );
void SetFillStyle( int fillStyle );
void EnableFillStyle( bool enable = true );
void SetWidthUnits( const wxString& units );
private:
LIB_EDIT_FRAME* m_frame;
LIB_ITEM* m_item;
UNIT_BINDER m_lineWidth;
};
#endif // __dialog_lib_edit_draw_item__

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -19,101 +19,37 @@ DIALOG_LIB_EDIT_DRAW_ITEM_BASE::DIALOG_LIB_EDIT_DRAW_ITEM_BASE( wxWindow* parent
wxBoxSizer* dlgBorderSizer;
dlgBorderSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("General:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
m_staticText1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
dlgBorderSizer->Add( m_staticText1, 0, wxALIGN_LEFT, 3 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
m_widthLabel = new wxStaticText( this, wxID_ANY, _("Line Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_widthLabel->Wrap( -1 );
bSizer3->Add( m_widthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer3->Add( 12, 0, 0, wxEXPAND, 3 );
m_widthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_widthCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticWidth = new wxStaticText( this, wxID_ANY, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidth->Wrap( -1 );
bSizer3->Add( m_staticWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_widthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_widthUnits->Wrap( -1 );
bSizer3->Add( m_widthUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 3 );
bSizer3->Add( 0, 0, 1, wxEXPAND, 3 );
m_textWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_textWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidthUnits->Wrap( -1 );
bSizer3->Add( m_staticWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( bSizer3, 0, wxALL|wxEXPAND, 0 );
m_staticTextSharing = new wxStaticText( this, ID_M_STATICTEXTSHARING, _("Sharing:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSharing->Wrap( -1 );
m_staticTextSharing->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
dlgBorderSizer->Add( m_staticTextSharing, 0, wxTOP|wxBOTTOM, 5 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
bSizer4->Add( 12, 0, 0, wxEXPAND, 3 );
dlgBorderSizer->Add( bSizer3, 0, wxEXPAND|wxBOTTOM, 10 );
m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all &units in component"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_checkApplyToAllUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( bSizer4, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( 12, 0, 0, wxEXPAND, 3 );
dlgBorderSizer->Add( m_checkApplyToAllUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_checkApplyToAllConversions = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( m_checkApplyToAllConversions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( m_checkApplyToAllConversions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( bSizer5, 0, wxEXPAND, 3 );
dlgBorderSizer->Add( 0, 0, 0, wxEXPAND|wxTOP, 5 );
dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 10 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Fill Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
m_staticText4->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
dlgBorderSizer->Add( m_staticText4, 0, wxALIGN_LEFT|wxBOTTOM, 3 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxHORIZONTAL );
bSizer6->Add( 12, 0, 0, wxEXPAND, 3 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxVERTICAL );
m_radioFillNone = new wxRadioButton( this, wxID_ANY, _("Do &not fill"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_radioFillNone->SetValue( true );
bSizer7->Add( m_radioFillNone, 0, wxALL, 3 );
m_radioFillForeground = new wxRadioButton( this, wxID_ANY, _("Fill &foreground"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( m_radioFillForeground, 0, wxALL, 3 );
m_radioFillBackground = new wxRadioButton( this, wxID_ANY, _("Fill &background"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( m_radioFillBackground, 0, wxALL, 3 );
bSizer6->Add( bSizer7, 0, wxEXPAND, 0 );
dlgBorderSizer->Add( bSizer6, 1, wxALL|wxEXPAND, 0 );
dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 10 );
wxString m_fillCtrlChoices[] = { _("Do not fill"), _("Fill foreground"), _("Fill background") };
int m_fillCtrlNChoices = sizeof( m_fillCtrlChoices ) / sizeof( wxString );
m_fillCtrl = new wxRadioBox( this, wxID_ANY, _("Fill Style"), wxDefaultPosition, wxDefaultSize, m_fillCtrlNChoices, m_fillCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_fillCtrl->SetSelection( 0 );
dlgBorderSizer->Add( m_fillCtrl, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
@ -125,7 +61,7 @@ DIALOG_LIB_EDIT_DRAW_ITEM_BASE::DIALOG_LIB_EDIT_DRAW_ITEM_BASE( wxWindow* parent
dlgBorderSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 0 );
mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 12 );
mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 10 );
this->SetSizer( mainSizer );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -21,7 +21,7 @@
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/radiobut.h>
#include <wx/radiobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -35,22 +35,12 @@ class DIALOG_LIB_EDIT_DRAW_ITEM_BASE : public DIALOG_SHIM
private:
protected:
enum
{
ID_M_STATICTEXTSHARING = 1000
};
wxStaticText* m_staticText1;
wxStaticText* m_staticWidth;
wxTextCtrl* m_textWidth;
wxStaticText* m_staticWidthUnits;
wxStaticText* m_staticTextSharing;
wxStaticText* m_widthLabel;
wxTextCtrl* m_widthCtrl;
wxStaticText* m_widthUnits;
wxCheckBox* m_checkApplyToAllUnits;
wxCheckBox* m_checkApplyToAllConversions;
wxStaticText* m_staticText4;
wxRadioButton* m_radioFillNone;
wxRadioButton* m_radioFillForeground;
wxRadioButton* m_radioFillBackground;
wxRadioBox* m_fillCtrl;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;

View File

@ -789,42 +789,13 @@ int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
if( aLine->GetLayer() != LAYER_NOTES )
return wxID_CANCEL;
DIALOG_EDIT_LINE_STYLE dlg( this );
wxString units = GetAbbreviatedUnitsLabel( g_UserUnit );
int old_style = aLine->GetLineStyle();
int old_width = aLine->GetPenSize();
COLOR4D old_color = aLine->GetLineColor();
DIALOG_EDIT_LINE_STYLE dlg( this, aLine );
dlg.SetDefaultStyle( aLine->GetDefaultStyle() );
dlg.SetDefaultWidth( StringFromValue( g_UserUnit, aLine->GetDefaultWidth(), false ) );
dlg.SetDefaultColor( aLine->GetDefaultColor() );
dlg.SetWidth( StringFromValue( g_UserUnit, old_width, false ) );
dlg.SetStyle( old_style );
dlg.SetLineWidthUnits( units );
dlg.SetColor( old_color, true );
dlg.Layout();
dlg.Fit();
dlg.SetMinSize( dlg.GetSize() );
if( dlg.ShowModal() == wxID_CANCEL )
return wxID_CANCEL;
int new_width = std::max( 1, ValueFromString( m_UserUnits, dlg.GetWidth() ) );
int new_style = dlg.GetStyle();
COLOR4D new_color = dlg.GetColor();
if( new_width != old_width || new_style != old_style || new_color != old_color )
{
SaveCopyInUndoList( (SCH_ITEM*) aLine, UR_CHANGED );
aLine->SetLineWidth( new_width );
aLine->SetLineStyle( new_style );
aLine->SetLineColor( new_color );
OnModify();
if( aRedraw )
m_canvas->Refresh();
}
if( aRedraw )
m_canvas->Refresh();
return wxID_OK;
}

View File

@ -57,35 +57,13 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
if( DrawItem == NULL )
return;
LIB_PART* symbol = DrawItem->GetParent();
DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->GetTypeName() );
dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) );
wxString val = StringFromValue( g_UserUnit, DrawItem->GetWidth() );
dialog.SetWidth( val );
dialog.SetApplyToAllUnits( DrawItem->GetUnit() == 0 );
dialog.EnableApplyToAllUnits( symbol && symbol->GetUnitCount() > 1 );
dialog.SetApplyToAllConversions( DrawItem->GetConvert() == 0 );
bool enblConvOptStyle = symbol && symbol->HasConversion();
// if a symbol contains no graphic items, symbol->HasConversion() returns false.
// but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions
// must be enabled even if symbol->HasConversion() returns false in order to be able
// to create graphic items shared by all body styles
if( GetShowDeMorgan() )
enblConvOptStyle = true;
dialog.EnableApplyToAllConversions( enblConvOptStyle );
dialog.SetFillStyle( DrawItem->GetFillMode() );
dialog.EnableFillStyle( DrawItem->IsFillable() );
DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem );
if( dialog.ShowModal() == wxID_CANCEL )
return;
// Init default values (used to create a new draw item)
val = dialog.GetWidth();
m_drawLineWidth = ValueFromString( g_UserUnit, val );
m_drawLineWidth = dialog.GetWidth();
m_drawSpecificConvert = !dialog.GetApplyToAllConversions();
m_drawSpecificUnit = !dialog.GetApplyToAllUnits();

View File

@ -238,7 +238,7 @@ int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
// TODO: Refactor to share with pcbnew
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
if( g_UserUnit == INCHES )
if( m_frame->GetUserUnits() == INCHES )
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
else
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );

View File

@ -39,7 +39,7 @@ class ARC_ASSISTANT : public EDA_ITEM
{
public:
ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager );
ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, EDA_UNITS_T aUnits );
const BOX2I ViewBBox() const override;
@ -52,7 +52,6 @@ public:
void Show( int x, std::ostream& st ) const override
{
}
#endif
/**
@ -67,6 +66,7 @@ public:
private:
const ARC_GEOM_MANAGER& m_constructMan;
EDA_UNITS_T m_units;
};
} // PREVIEW
} // KIGFX

View File

@ -149,7 +149,7 @@ protected:
virtual CONTEXT_MENU* create() const;
///> Returns an instance of TOOL_MANAGER class.
TOOL_MANAGER* getToolManager();
TOOL_MANAGER* getToolManager() const;
///> Returns the corresponding wxMenuItem identifier for a TOOL_ACTION object.
static inline int getMenuId( const TOOL_ACTION& aAction )

View File

@ -124,8 +124,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// display the real hotkeys in menus or tool tips
ReadHotkeyConfig( PL_EDITOR_FRAME_NAME, PlEditorHokeysDescr );
g_UserUnit = MILLIMETRES;
return true;
}
@ -150,8 +148,6 @@ bool MYFACE::OnKifaceStart( PGM_BASE* aProgram )
return false;
}
g_UserUnit = MILLIMETRES;
// read current setup and reopen last directory if no filename to open in
// command line
bool reopenLastUsedDirectory = argc == 1;

View File

@ -56,6 +56,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
{
m_UserUnits = MILLIMETRES;
m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
// when the screen shows a 1:1 image
// obviously depends on the monitor,
@ -438,14 +439,14 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
// Display absolute coordinates:
wxPoint coord = GetCrossHairPosition() - originCoord;
double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign );
double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign );
double dXpos = To_User_Unit( GetUserUnits(), coord.x*Xsign );
double dYpos = To_User_Unit( GetUserUnits(), coord.y*Ysign );
wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
wxString absformatter = wxT( "X %.4g Y %.4g" );
wxString locformatter = wxT( "dx %.4g dy %.4g" );
switch( g_UserUnit )
switch( GetUserUnits() )
{
case INCHES: // Should not be used in page layout editor
SetStatusText( _("inches"), 5 );
@ -480,8 +481,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
// Display relative coordinates:
int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx * Xsign );
dYpos = To_User_Unit( g_UserUnit, dy * Ysign );
dXpos = To_User_Unit( GetUserUnits(), dx * Xsign );
dYpos = To_User_Unit( GetUserUnits(), dy * Ysign );
line.Printf( locformatter, dXpos, dYpos );
SetStatusText( line, 3 );

View File

@ -24,11 +24,8 @@
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <macros.h>
#include <boost/algorithm/string/join.hpp>
#include <widgets/text_ctrl_eval.h>
#include <class_drawpanel.h>
#include <class_board.h>
#include <class_module.h>
@ -39,19 +36,25 @@
DIALOG_CREATE_ARRAY::CREATE_ARRAY_DIALOG_ENTRIES DIALOG_CREATE_ARRAY::m_options;
DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent,
bool enableNumbering,
DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent, bool enableNumbering,
wxPoint aOrigPos ) :
DIALOG_CREATE_ARRAY_BASE( aParent ),
CONFIG_SAVE_RESTORE_WINDOW( m_options.m_optionsSet ),
m_settings( NULL ),
m_hSpacing( aParent, m_labelDx, m_entryDx, m_unitLabelDx, true ),
m_vSpacing( aParent, m_labelDy, m_entryDy, m_unitLabelDy, true ),
m_hOffset( aParent, m_labelOffsetX, m_entryOffsetX, m_unitLabelOffsetX, true ),
m_vOffset( aParent, m_labelOffsetY, m_entryOffsetY, m_unitLabelOffsetY, true ),
m_hCentre( aParent, m_labelCentreX, m_entryCentreX, m_unitLabelCentreX, true ),
m_vCentre( aParent, m_labelCentreY, m_entryCentreY, m_unitLabelCentreY, true ),
m_circRadius( aParent, m_labelCircRadius, m_valueCircRadius, m_unitLabelCircRadius, true ),
m_originalItemPosition( aOrigPos ),
m_numberingEnabled(enableNumbering)
{
// Set up numbering scheme drop downs
//
// character set
// NOTE: do not change the order of this relative to the ARRAY_NUMBERING_TYPE_T enum
// NOTE: do not change the order of this relative to the NUMBERING_TYPE_T enum
const wxString charSetDescriptions[] =
{
_( "Numerals (0,1,2,...,9,10)" ),
@ -97,18 +100,6 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent,
RestoreConfigToControls();
// Load units into labels
{
const wxString lengthUnit = GetAbbreviatedUnitsLabel( g_UserUnit );
m_unitLabelCentreX->SetLabelText( lengthUnit );
m_unitLabelCentreY->SetLabelText( lengthUnit );
m_unitLabelDx->SetLabelText( lengthUnit );
m_unitLabelDy->SetLabelText( lengthUnit );
m_unitLabelOffsetX->SetLabelText( lengthUnit );
m_unitLabelOffsetY->SetLabelText( lengthUnit );
}
// Run the callbacks once to process the dialog contents
setControlEnablement();
calculateCircularArrayProperties();
@ -133,8 +124,7 @@ void DIALOG_CREATE_ARRAY::OnParameterChanged( wxCommandEvent& event )
}
static const wxString& alphabetFromNumberingScheme(
DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type )
static const wxString& alphabetFromNumberingScheme( DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type )
{
static const wxString alphaNumeric = "0123456789";
static const wxString alphaHex = "0123456789ABCDEF";
@ -144,20 +134,11 @@ static const wxString& alphabetFromNumberingScheme(
switch( type )
{
default:
case DIALOG_CREATE_ARRAY::NUMBERING_NUMERIC:
break;
case DIALOG_CREATE_ARRAY::NUMBERING_HEX:
return alphaHex;
case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_NO_IOSQXZ:
return alphaNoIOSQXZ;
case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_FULL:
return alphaFull;
case DIALOG_CREATE_ARRAY::NUMBERING_NUMERIC: return alphaNumeric;
case DIALOG_CREATE_ARRAY::NUMBERING_HEX: return alphaHex;
case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_NO_IOSQXZ: return alphaNoIOSQXZ;
case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_FULL: return alphaFull;
}
return alphaNumeric;
}
@ -165,16 +146,15 @@ static const wxString& alphabetFromNumberingScheme(
* @return False for schemes like 0,1...9,10
* True for schemes like A,B..Z,AA (where the tens column starts with char 0)
*/
static bool schemeNonUnitColsStartAt0( DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type )
static bool schemeNonUnitColsStartAt0( DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type )
{
return type == DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_FULL
|| type == DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_NO_IOSQXZ;
}
static bool getNumberingOffset( const wxString& str,
DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type,
int& offsetToFill )
static bool getNumberingOffset( const wxString& str, DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type,
int& offsetToFill )
{
const wxString& alphabet = alphabetFromNumberingScheme( type );
@ -215,9 +195,8 @@ static bool getNumberingOffset( const wxString& str,
*/
static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry,
const wxChoice& typeEntry,
DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T& type,
int& offset,
wxArrayString& errors )
DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T& type,
int& offset, wxArrayString& errors )
{
const int typeVal = typeEntry.GetSelection();
// mind undefined casts to enums (should not be able to happen)
@ -225,7 +204,7 @@ static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry,
if( ok )
{
type = (DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T) typeVal;
type = (DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T) typeVal;
}
else
{
@ -263,10 +242,8 @@ static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry,
* @param errors a list of errors to add any error to
* @return valid
*/
static bool validateLongEntry( const wxTextEntry& entry,
long& dest,
const wxString& description,
wxArrayString& errors )
static bool validateLongEntry( const wxTextEntry& entry, long& dest, const wxString& description,
wxArrayString& errors )
{
bool ok = true;
@ -284,10 +261,8 @@ static bool validateLongEntry( const wxTextEntry& entry,
bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
{
ARRAY_OPTIONS* newSettings = NULL;
wxArrayString errorStrs;
ARRAY_OPTIONS* newSettings = NULL;
wxArrayString errors;
const wxWindow* page = m_gridTypeNotebook->GetCurrentPage();
if( page == m_gridPanel )
@ -296,20 +271,16 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
bool ok = true;
// ints
ok = ok && validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"),
errorStrs);
ok = ok && validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"),
errorStrs);
ok = ok && validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"), errors);
ok = ok && validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"), errors);
newGrid->m_delta.x = m_hSpacing.GetValue();
newGrid->m_delta.y = m_vSpacing.GetValue();
newGrid->m_delta.x = DoubleValueFromString( g_UserUnit, m_entryDx->GetValue() );
newGrid->m_delta.y = DoubleValueFromString( g_UserUnit, m_entryDy->GetValue() );
newGrid->m_offset.x = m_hOffset.GetValue();
newGrid->m_offset.y = m_vOffset.GetValue();
newGrid->m_offset.x = DoubleValueFromString( g_UserUnit, m_entryOffsetX->GetValue() );
newGrid->m_offset.y = DoubleValueFromString( g_UserUnit, m_entryOffsetY->GetValue() );
ok = ok && validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"),
errorStrs);
ok = ok && validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"), errors);
newGrid->m_stagger_rows = m_radioBoxGridStaggerType->GetSelection() == 0;
@ -323,16 +294,16 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
newGrid->m_2dArrayNumbering = m_radioBoxGridNumberingScheme->GetSelection() != 0;
bool numOk = validateNumberingTypeAndOffset(
*m_entryGridPriNumberingOffset, *m_choicePriAxisNumbering,
newGrid->m_priAxisNumType, newGrid->m_numberingOffsetX,
errorStrs );
*m_entryGridPriNumberingOffset, *m_choicePriAxisNumbering,
newGrid->m_priAxisNumType, newGrid->m_numberingOffsetX,
errors );
if( newGrid->m_2dArrayNumbering )
{
numOk = validateNumberingTypeAndOffset(
*m_entryGridSecNumberingOffset, *m_choiceSecAxisNumbering,
newGrid->m_secAxisNumType, newGrid->m_numberingOffsetY,
errorStrs ) && numOk;
*m_entryGridSecNumberingOffset, *m_choiceSecAxisNumbering,
newGrid->m_secAxisNumType, newGrid->m_numberingOffsetY,
errors ) && numOk;
}
ok = ok && numOk;
@ -351,16 +322,13 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
ARRAY_CIRCULAR_OPTIONS* newCirc = new ARRAY_CIRCULAR_OPTIONS();
bool ok = true;
newCirc->m_centre.x = DoubleValueFromString( g_UserUnit, m_entryCentreX->GetValue() );
newCirc->m_centre.y = DoubleValueFromString( g_UserUnit, m_entryCentreY->GetValue() );
newCirc->m_centre.x = m_hCentre.GetValue();
newCirc->m_centre.y = m_vCentre.GetValue();
newCirc->m_angle = DoubleValueFromString( DEGREES, m_entryCircAngle->GetValue() );
ok = ok && validateLongEntry(*m_entryCircCount, newCirc->m_nPts,
_("point count"), errorStrs);
ok = ok && validateLongEntry(*m_entryCircCount, newCirc->m_nPts, _("point count"), errors);
newCirc->m_rotateItems = m_entryRotateItemsCb->GetValue();
newCirc->m_shouldNumber = m_numberingEnabled;
if ( m_numberingEnabled )
@ -368,9 +336,8 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
newCirc->m_numberingStartIsSpecified = m_rbCircStartNumberingOpt->GetSelection() == 1;
newCirc->m_numberingType = NUMBERING_NUMERIC;
ok = ok && validateLongEntry(*m_entryCircNumberingStart,
newCirc->m_numberingOffset,
_("numbering start"), errorStrs);
ok = ok && validateLongEntry(*m_entryCircNumberingStart, newCirc->m_numberingOffset,
_("numbering start"), errors);
}
// Only use settings if all values are good
@ -395,10 +362,10 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
{
wxString errorStr;
if( errorStrs.IsEmpty() )
if( errors.IsEmpty() )
errorStr = _("Bad parameters");
else
errorStr = boost::algorithm::join( errorStrs, "\n" );
errorStr = boost::algorithm::join( errors, "\n" );
wxMessageBox( errorStr );
return false;
@ -453,23 +420,20 @@ void DIALOG_CREATE_ARRAY::setControlEnablement()
void DIALOG_CREATE_ARRAY::calculateCircularArrayProperties()
{
wxPoint centre;
centre.x = DoubleValueFromString( g_UserUnit, m_entryCentreX->GetValue() );
centre.y = DoubleValueFromString( g_UserUnit, m_entryCentreY->GetValue() );
wxPoint centre( m_hCentre.GetValue(), m_vCentre.GetValue() );
// Find the radius, etc of the circle
centre -= m_originalItemPosition;
const double radius = VECTOR2I(centre.x, centre.y).EuclideanNorm();
m_labelCircRadiusValue->SetLabelText( StringFromValue( g_UserUnit, int(radius), true ) );
m_circRadius.SetValue( int( radius ) );
}
// ARRAY OPTION implementation functions --------------------------------------
wxString DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::getCoordinateNumber( int n,
ARRAY_NUMBERING_TYPE_T type )
NUMBERING_TYPE_T type )
{
wxString itemNum;
const wxString& alphabet = alphabetFromNumberingScheme( type );

View File

@ -32,6 +32,7 @@
#include <pcb_base_frame.h>
#include <boost/bimap.hpp>
#include <widgets/unit_binder.h>
class CONFIG_SAVE_RESTORE_WINDOW
{
@ -182,7 +183,7 @@ public:
};
// NOTE: do not change order relative to charSetDescriptions
enum ARRAY_NUMBERING_TYPE_T
enum NUMBERING_TYPE_T
{
NUMBERING_NUMERIC = 0, ///< Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...
NUMBERING_HEX,
@ -245,7 +246,7 @@ public:
}
protected:
static wxString getCoordinateNumber( int n, ARRAY_NUMBERING_TYPE_T type );
static wxString getCoordinateNumber( int n, NUMBERING_TYPE_T type );
// allow the dialog to set directly
friend class DIALOG_CREATE_ARRAY;
@ -282,7 +283,7 @@ public:
bool m_stagger_rows;
bool m_2dArrayNumbering;
int m_numberingOffsetX, m_numberingOffsetY;
ARRAY_NUMBERING_TYPE_T m_priAxisNumType, m_secAxisNumType;
NUMBERING_TYPE_T m_priAxisNumType, m_secAxisNumType;
void TransformItem( int n, BOARD_ITEM* item, const wxPoint& rotPoint ) const override;
int GetArraySize() const override;
@ -307,7 +308,7 @@ private:
double m_angle;
wxPoint m_centre;
bool m_rotateItems;
ARRAY_NUMBERING_TYPE_T m_numberingType;
NUMBERING_TYPE_T m_numberingType;
long m_numberingOffset;
void TransformItem( int n, BOARD_ITEM* item, const wxPoint& rotPoint ) const override;
@ -338,6 +339,11 @@ private:
*/
ARRAY_OPTIONS* m_settings;
UNIT_BINDER m_hSpacing, m_vSpacing;
UNIT_BINDER m_hOffset, m_vOffset;
UNIT_BINDER m_hCentre, m_vCentre;
UNIT_BINDER m_circRadius;
/*
* The position of the original item(s), used for finding radius, etc
*/

Some files were not shown because too many files have changed in this diff Show More