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
*/

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!
@ -213,9 +213,13 @@ DIALOG_CREATE_ARRAY_BASE::DIALOG_CREATE_ARRAY_BASE( wxWindow* parent, wxWindowID
m_labelCircRadius->Wrap( -1 );
gbSizer2->Add( m_labelCircRadius, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_labelCircRadiusValue = new wxStaticText( m_circularPanel, wxID_ANY, _("0 mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelCircRadiusValue->Wrap( -1 );
gbSizer2->Add( m_labelCircRadiusValue, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
m_valueCircRadius = new wxStaticText( m_circularPanel, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
m_valueCircRadius->Wrap( -1 );
gbSizer2->Add( m_valueCircRadius, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
m_unitLabelCircRadius = new wxStaticText( m_circularPanel, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_unitLabelCircRadius->Wrap( -1 );
gbSizer2->Add( m_unitLabelCircRadius, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_labelCircAngle = new wxStaticText( m_circularPanel, wxID_ANY, _("Angle:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelCircAngle->Wrap( -1 );

View File

@ -14,7 +14,6 @@
<property name="file">dialog_create_array_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">DIALOG_CREATE_ARRAY_BASE</property>
<property name="namespace"></property>
@ -3724,7 +3723,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">0 mm</property>
<property name="label">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -3732,7 +3731,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_labelCircRadiusValue</property>
<property name="name">m_valueCircRadius</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -3775,6 +3774,92 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">2</property>
<property name="flag">wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="row">2</property>
<property name="rowspan">1</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">mm</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_unitLabelCircRadius</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>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="gbsizeritem" expanded="0">
<property name="border">5</property>
<property name="colspan">1</property>

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!
@ -88,7 +88,8 @@ class DIALOG_CREATE_ARRAY_BASE : public DIALOG_SHIM
TEXT_CTRL_EVAL* m_entryCentreY;
wxStaticText* m_unitLabelCentreY;
wxStaticText* m_labelCircRadius;
wxStaticText* m_labelCircRadiusValue;
wxStaticText* m_valueCircRadius;
wxStaticText* m_unitLabelCircRadius;
wxStaticText* m_labelCircAngle;
TEXT_CTRL_EVAL* m_entryCircAngle;
wxStaticText* m_unitLabelCircAngle;

View File

@ -28,14 +28,10 @@
#include <pcb_edit_frame.h>
#include <pcbplot.h>
#include <gerber_jobfile_writer.h>
#include <base_units.h>
#include <macros.h>
#include <reporter.h>
#include <wildcards_and_files_ext.h>
#include <bitmaps.h>
#include <class_board.h>
#include <wx/ffile.h>
#include <dialog_plot.h>
#include <wx_html_report_panel.h>
#include <drc.h>

View File

@ -1,15 +1,15 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 21 2016)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_target_properties_base.h"
///////////////////////////////////////////////////////////////////////////
TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
DIALOG_TARGET_PROPERTIES_BASE::DIALOG_TARGET_PROPERTIES_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 );
@ -25,27 +25,27 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi
fgSizer->SetFlexibleDirection( wxBOTH );
fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextSize = new wxStaticText( this, wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSize->Wrap( -1 );
fgSizer->Add( m_staticTextSize, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_sizeLabel = new wxStaticText( this, wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_sizeLabel->Wrap( -1 );
fgSizer->Add( m_sizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_TargetSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer->Add( m_TargetSizeCtrl, 0, wxALL|wxEXPAND, 5 );
m_sizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer->Add( m_sizeCtrl, 0, wxALL|wxEXPAND, 5 );
m_staticTextSizeUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeUnits->Wrap( -1 );
fgSizer->Add( m_staticTextSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_sizeUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_sizeUnits->Wrap( -1 );
fgSizer->Add( m_sizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_staticTextThickness = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextThickness->Wrap( -1 );
fgSizer->Add( m_staticTextThickness, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_thicknessLabel = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_thicknessLabel->Wrap( -1 );
fgSizer->Add( m_thicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_TargetThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer->Add( m_TargetThicknessCtrl, 0, wxEXPAND|wxALL, 5 );
m_thicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer->Add( m_thicknessCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextThicknessUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextThicknessUnits->Wrap( -1 );
fgSizer->Add( m_staticTextThicknessUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_thicknessUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_thicknessUnits->Wrap( -1 );
fgSizer->Add( m_thicknessUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_staticTextShape = new wxStaticText( this, wxID_ANY, _("Shape:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextShape->Wrap( -1 );
@ -64,10 +64,10 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi
bSizerUpper->Add( fgSizer, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxALL|wxEXPAND, 5 );
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline, 0, wxEXPAND | wxALL, 5 );
bSizerMain->Add( m_staticline, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
m_sdbSizerButts = new wxStdDialogButtonSizer();
m_sdbSizerButtsOK = new wxButton( this, wxID_OK );
@ -76,7 +76,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi
m_sdbSizerButts->AddButton( m_sdbSizerButtsCancel );
m_sdbSizerButts->Realize();
bSizerMain->Add( m_sdbSizerButts, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizerMain->Add( m_sdbSizerButts, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
@ -84,16 +84,8 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi
bSizerMain->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_sdbSizerButtsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerButtsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnOkClick ), NULL, this );
}
TARGET_PROPERTIES_DIALOG_EDITOR_BASE::~TARGET_PROPERTIES_DIALOG_EDITOR_BASE()
DIALOG_TARGET_PROPERTIES_BASE::~DIALOG_TARGET_PROPERTIES_BASE()
{
// Disconnect Events
m_sdbSizerButtsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerButtsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnOkClick ), NULL, this );
}

View File

@ -42,7 +42,7 @@
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">TARGET_PROPERTIES_DIALOG_EDITOR_BASE</property>
<property name="name">DIALOG_TARGET_PROPERTIES_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
@ -95,7 +95,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -120,7 +120,7 @@
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -158,7 +158,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextSize</property>
<property name="name">m_sizeLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -241,7 +241,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_TargetSizeCtrl</property>
<property name="name">m_sizeCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -332,7 +332,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextSizeUnits</property>
<property name="name">m_sizeUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -377,7 +377,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -415,7 +415,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextThickness</property>
<property name="name">m_thicknessLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -460,7 +460,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
@ -498,7 +498,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_TargetThicknessCtrl</property>
<property name="name">m_thicknessCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -551,7 +551,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -589,7 +589,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextThicknessUnits</property>
<property name="name">m_thicknessUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -818,8 +818,8 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="border">10</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
@ -900,7 +900,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
@ -915,11 +915,11 @@
<property name="name">m_sdbSizerButts</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 21 2016)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_TARGET_PROPERTIES_BASE_H__
@ -11,8 +11,6 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
@ -31,35 +29,30 @@ class DIALOG_SHIM;
///////////////////////////////////////////////////////////////////////////////
/// Class TARGET_PROPERTIES_DIALOG_EDITOR_BASE
/// Class DIALOG_TARGET_PROPERTIES_BASE
///////////////////////////////////////////////////////////////////////////////
class TARGET_PROPERTIES_DIALOG_EDITOR_BASE : public DIALOG_SHIM
class DIALOG_TARGET_PROPERTIES_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticTextSize;
wxTextCtrl* m_TargetSizeCtrl;
wxStaticText* m_staticTextSizeUnits;
wxStaticText* m_staticTextThickness;
wxTextCtrl* m_TargetThicknessCtrl;
wxStaticText* m_staticTextThicknessUnits;
wxStaticText* m_sizeLabel;
wxTextCtrl* m_sizeCtrl;
wxStaticText* m_sizeUnits;
wxStaticText* m_thicknessLabel;
wxTextCtrl* m_thicknessCtrl;
wxStaticText* m_thicknessUnits;
wxStaticText* m_staticTextShape;
wxChoice* m_TargetShape;
wxStaticLine* m_staticline;
wxStdDialogButtonSizer* m_sdbSizerButts;
wxButton* m_sdbSizerButtsOK;
wxButton* m_sdbSizerButtsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Target Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~TARGET_PROPERTIES_DIALOG_EDITOR_BASE();
DIALOG_TARGET_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Target Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_TARGET_PROPERTIES_BASE();
};

View File

@ -116,8 +116,8 @@ bool FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos
break;
case HK_SWITCH_UNITS:
cmd.SetId( (g_UserUnit == INCHES) ?
ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH );
cmd.SetId( (GetUserUnits() == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM
: ID_TB_OPTIONS_SELECT_UNIT_INCH );
GetEventHandler()->ProcessEvent( cmd );
break;

View File

@ -856,7 +856,7 @@ void PCB_BASE_FRAME::UpdateStatusBar()
ro = hypot( dx, dy );
wxString formatter;
switch( g_UserUnit )
switch( GetUserUnits() )
{
case INCHES:
formatter = wxT( "r %.6f theta %.1f" );
@ -875,19 +875,19 @@ void PCB_BASE_FRAME::UpdateStatusBar()
break;
}
line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
SetStatusText( line, 3 );
}
// Display absolute coordinates:
dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );
dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
// The following sadly is an if Eeschema/if Pcbnew
wxString absformatter;
switch( g_UserUnit )
switch( GetUserUnits() )
{
case INCHES:
absformatter = wxT( "X %.6f Y %.6f" );
@ -917,8 +917,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
// Display relative coordinates:
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx );
dYpos = To_User_Unit( g_UserUnit, dy );
dXpos = To_User_Unit( GetUserUnits(), dx );
dYpos = To_User_Unit( GetUserUnits(), dy );
// We already decided the formatter above
line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
@ -979,7 +979,7 @@ void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( baseCfgName + UserGridSizeXEntry, To_User_Unit( m_UserUnits, m_UserGridSize.x ) );
aCfg->Write( baseCfgName + UserGridSizeYEntry, To_User_Unit( m_UserUnits, m_UserGridSize.y ) );
aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )g_UserUnit );
aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )m_UserUnits );
aCfg->Write( baseCfgName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill );
aCfg->Write( baseCfgName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill );
aCfg->Write( baseCfgName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum );
@ -1020,7 +1020,7 @@ void PCB_BASE_FRAME::updateGridSelectBox()
// Update grid values with the current units setting.
m_gridSelectBox->Clear();
wxArrayString gridsList;
int icurr = GetScreen()->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES );
int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{

View File

@ -41,7 +41,7 @@
#include <pcbnew.h>
#include <dialog_target_properties_base.h>
#include <widgets/unit_binder.h>
// Routines Locales
static void AbortMoveAndEditTarget( EDA_DRAW_PANEL* Panel, wxDC* DC );
@ -59,73 +59,68 @@ static PCB_TARGET s_TargetCopy( NULL ); /* Used to store "old" values of the
* cancel operations)
*/
/*****************************************/
/* class TARGET_PROPERTIES_DIALOG_EDITOR */
/*****************************************/
/**********************************/
/* class DIALOG_TARGET_PROPERTIES */
/**********************************/
class TARGET_PROPERTIES_DIALOG_EDITOR : public TARGET_PROPERTIES_DIALOG_EDITOR_BASE
class DIALOG_TARGET_PROPERTIES : public DIALOG_TARGET_PROPERTIES_BASE
{
private:
PCB_EDIT_FRAME* m_Parent;
wxDC* m_DC;
PCB_TARGET* m_Target;
UNIT_BINDER m_Size;
UNIT_BINDER m_Thickness;
public:
TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent, PCB_TARGET* Mire, wxDC* DC );
~TARGET_PROPERTIES_DIALOG_EDITOR() { }
DIALOG_TARGET_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB_TARGET* aTarget, wxDC* aDC );
~DIALOG_TARGET_PROPERTIES() { }
private:
void OnOkClick( wxCommandEvent& event ) override;
void OnCancelClick( wxCommandEvent& event ) override;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
};
void PCB_EDIT_FRAME::ShowTargetOptionsDialog( PCB_TARGET* aTarget, wxDC* DC )
{
TARGET_PROPERTIES_DIALOG_EDITOR* frame =
new TARGET_PROPERTIES_DIALOG_EDITOR( this, aTarget, DC );
DIALOG_TARGET_PROPERTIES dialog( this, aTarget, DC );
frame->ShowModal();
frame->Destroy();
dialog.ShowModal();
}
TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent,
PCB_TARGET* aTarget, wxDC* DC ) :
TARGET_PROPERTIES_DIALOG_EDITOR_BASE( parent )
DIALOG_TARGET_PROPERTIES::DIALOG_TARGET_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB_TARGET* aTarget,
wxDC* aDC ) :
DIALOG_TARGET_PROPERTIES_BASE( aParent ),
m_Parent( aParent ),
m_DC( aDC ),
m_Target( aTarget ),
m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits, true, 0 ),
m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true, 0 )
{
m_Parent = parent;
m_DC = DC;
m_Target = aTarget;
m_sdbSizerButtsOK->SetDefault();
// Size:
m_staticTextSizeUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_TargetSizeCtrl->SetValue( StringFromValue( g_UserUnit, m_Target->GetSize() ) );
// Thickness:
m_staticTextThicknessUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_TargetThicknessCtrl->SetValue( StringFromValue( g_UserUnit, m_Target->GetWidth() ) );
// Shape
m_TargetShape->SetSelection( m_Target->GetShape() ? 1 : 0 );
// OK button on return key.
SetDefaultItem( m_sdbSizerButtsOK );
SetInitialFocus( m_sizeCtrl );
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event )
bool DIALOG_TARGET_PROPERTIES::TransferDataToWindow()
{
EndModal( -1 );
m_Size.SetValue( m_Target->GetSize() );
m_Thickness.SetValue( m_Target->GetWidth() );
m_TargetShape->SetSelection( m_Target->GetShape() ? 1 : 0 );
return true;
}
/* Updates the different parameters for the component being edited
*/
void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
bool DIALOG_TARGET_PROPERTIES::TransferDataFromWindow()
{
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_Target );
@ -138,14 +133,10 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
if( m_Target->GetFlags() != 0 ) // other edition in progress (MOVE, NEW ..)
m_Target->SetFlags( IN_EDIT ); // set flag in edit to force
// undo/redo/abort proper operation
int tmp = ValueFromString( g_UserUnit, m_TargetThicknessCtrl->GetValue() );
m_Target->SetWidth( tmp );
MireDefaultSize = ValueFromString( g_UserUnit, m_TargetSizeCtrl->GetValue() );
m_Target->SetSize( MireDefaultSize );
// undo/redo/abort proper operation
m_Target->SetWidth( m_Thickness.GetValue() );
m_Target->SetSize( m_Size.GetValue() );
m_Target->SetShape( m_TargetShape->GetSelection() ? 1 : 0 );
if( m_DC )
@ -154,7 +145,7 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
if( pushCommit )
commit.Push( _( "Modified alignment target" ) );
EndModal( 1 );
return true;
}

View File

@ -1179,7 +1179,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
KIGFX::PREVIEW::ARC_GEOM_MANAGER arcManager;
// Arc drawing assistant overlay
KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager );
KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
// Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview;

View File

@ -21,7 +21,9 @@
#include "size_menu.h"
#include <tool/tool_manager.h>
#include <class_board.h>
#include <pcb_base_frame.h>
#include <pcbnew_id.h>
#include <bitmaps.h>
@ -124,7 +126,9 @@ void TRACK_VIA_SIZE_MENU::update()
wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const
{
wxString desc;
wxString desc;
auto frame = dynamic_cast<PCB_BASE_FRAME*>( getToolManager()->GetEditFrame() );
EDA_UNITS_T userUnits = frame->GetUserUnits();
if( m_vias ) // == if( m_tracks && m_vias )
desc = _( "Track ");
@ -132,7 +136,7 @@ wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const
if( aIndex == 0 )
desc << _( "net class width" );
else
desc << StringFromValue( g_UserUnit, m_designSettings->m_TrackWidthList[aIndex], true );
desc << StringFromValue( userUnits, m_designSettings->m_TrackWidthList[aIndex], true );
return desc;
}
@ -140,7 +144,10 @@ wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const
wxString TRACK_VIA_SIZE_MENU::getViaDescription( unsigned int aIndex ) const
{
wxString desc;
wxString desc;
auto frame = dynamic_cast<PCB_BASE_FRAME*>( getToolManager()->GetEditFrame() );
EDA_UNITS_T userUnits = frame->GetUserUnits();
VIA_DIMENSION viaDimension = m_designSettings->m_ViasDimensionsList[ aIndex ];
if( m_tracks ) // == if( m_tracks && m_vias )
desc = _( "Via " );
@ -151,18 +158,12 @@ wxString TRACK_VIA_SIZE_MENU::getViaDescription( unsigned int aIndex ) const
}
else
{
desc << StringFromValue( g_UserUnit,
m_designSettings->m_ViasDimensionsList[aIndex].m_Diameter, true );
desc << StringFromValue( userUnits, viaDimension.m_Diameter, true );
if( m_designSettings->m_ViasDimensionsList[aIndex].m_Drill <= 0 )
{
desc << _( ", drill: default" );
}
else
{
desc << _( ", drill: " ) << StringFromValue( g_UserUnit,
m_designSettings->m_ViasDimensionsList[aIndex].m_Drill, true );
}
desc << _( ", drill: " ) << StringFromValue( userUnits, viaDimension.m_Drill, true );
}
return desc;