Commit 0975e3e5 authored by jean-pierre charras's avatar jean-pierre charras

Move exact dialog: make all messages translatable. Fix minor issues (some can...

Move exact dialog: make all messages translatable. Fix minor issues (some can be Windows specific). Remove useless declarations. Fix coding style issues
Fix minor warnings from cppcheck.
parent c1978b32
......@@ -206,7 +206,11 @@ wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit )
break;
case DEGREES:
wxASSERT( false );
label = _( "deg" );
break;
default:
label = wxT( "??" );
break;
}
......
......@@ -182,7 +182,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DIALOG_MOVE_EXACT dialog( this, translation, rotation );
int ret = dialog.ShowModal();
if( ret == DIALOG_MOVE_EXACT::MOVE_OK )
if( ret == wxID_OK )
{
SaveCopyInUndoList( currentModule, UR_MODEDIT );
const wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre();
......
......@@ -24,6 +24,7 @@
#include <wxPcbStruct.h>
#include <base_units.h>
#include <macros.h>
#include <module_editor_frame.h>
......@@ -42,8 +43,6 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME* aParent,
// set the unit labels
m_xUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) );
// rotation is always degrees
m_rotUnit->SetLabelText( _( "deg" ) );
// tabbing goes through the entries in sequence
m_yEntry->MoveAfterInTabOrder( m_xEntry );
......@@ -54,8 +53,11 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME* aParent,
m_xEntry->SetValue( wxString::FromDouble( m_options.entry1 ) );
m_yEntry->SetValue( wxString::FromDouble( m_options.entry2 ) );
m_rotEntry->SetValue( wxString::FromDouble( m_options.entryRotation ) );
updateDlgTexts( m_polarCoords->IsChecked() );
Fit();
m_stdButtonsOK->SetDefault();
GetSizer()->SetSizeHints(this);
}
......@@ -64,12 +66,6 @@ DIALOG_MOVE_EXACT::~DIALOG_MOVE_EXACT()
}
/*!
* Convert a given Cartesian point into a polar representation.
*
* Linear units are not considered, the answer is in the same units as given
* Angle is returned in degrees
*/
void DIALOG_MOVE_EXACT::ToPolarDeg( double x, double y, double& r, double& q )
{
// convert to polar coordinates
......@@ -79,12 +75,6 @@ void DIALOG_MOVE_EXACT::ToPolarDeg( double x, double y, double& r, double& q )
}
/*!
* Get the (Cartesian) translation described by the text entries
* @param val output translation vector
* @param polar interpret as polar coords
* @return false if error (though the text conversion functions don't report errors)
*/
bool DIALOG_MOVE_EXACT::GetTranslationInIU ( wxPoint& val, bool polar )
{
if( polar )
......@@ -110,6 +100,7 @@ bool DIALOG_MOVE_EXACT::GetTranslationInIU ( wxPoint& val, bool polar )
void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event )
{
bool newPolar = m_polarCoords->IsChecked();
updateDlgTexts( newPolar );
wxPoint val;
// get the value as previously stored
......@@ -122,25 +113,34 @@ void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event )
ToPolarDeg( val.x, val.y, r, q);
PutValueInLocalUnits( *m_xEntry, round( r / 10.0) * 10 );
m_xLabel->SetLabelText( wxT( "r:" ) );
m_yEntry->SetValue( wxString::FromDouble( q ) );
m_yLabel->SetLabelText( wxT( "\u03b8:" ) ); // theta
m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( DEGREES ) );
}
else
{
// vector is already in Cartesian, so just render out
// note - round off the last decimal place (10nm) to prevent
// (some) rounding causing errors when round-tripping
// you can never eliminate entirely, however
PutValueInLocalUnits( *m_xEntry, round( val.x / 10.0) * 10 );
m_xLabel->SetLabelText( wxT( "x:" ) );
PutValueInLocalUnits( *m_xEntry, KiROUND( val.x / 10.0) * 10 );
PutValueInLocalUnits( *m_yEntry, KiROUND( val.y / 10.0) * 10 );
}
Layout();
}
PutValueInLocalUnits( *m_yEntry, round( val.y / 10.0) * 10 );
m_yLabel->SetLabelText( wxT( "y:" ) );
void DIALOG_MOVE_EXACT::updateDlgTexts( bool aPolar )
{
if( aPolar )
{
m_xLabel->SetLabelText( _( "Distance:" ) ); // Polar radius
m_yLabel->SetLabelText( _( "Angle:" ) ); // Polar theta or angle
m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( DEGREES ) );
}
else
{
m_xLabel->SetLabelText( _( "Move vector X:" ) );
m_yLabel->SetLabelText( _( "Move vector Y:" ) );
m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) );
}
......@@ -172,7 +172,7 @@ void DIALOG_MOVE_EXACT::OnClear( wxCommandEvent& event )
void DIALOG_MOVE_EXACT::OnCancelClick( wxCommandEvent& event )
{
EndModal( MOVE_ABORT );
EndModal( wxID_ABORT );
}
......@@ -191,14 +191,11 @@ void DIALOG_MOVE_EXACT::OnOkClick( wxCommandEvent& event )
m_yEntry->GetValue().ToDouble( &m_options.entry2 );
m_rotEntry->GetValue().ToDouble( &m_options.entryRotation );
EndModal( MOVE_OK );
EndModal( wxID_OK);
}
}
/*!
* Reset a text field to be 0 if it was exited while blank
*/
void DIALOG_MOVE_EXACT::OnTextFocusLost( wxFocusEvent& event )
{
wxTextCtrl* obj = static_cast<wxTextCtrl*>( event.GetEventObject() );
......
This diff is collapsed.
......@@ -37,13 +37,6 @@ private:
double& m_rotation;
public:
enum MOVE_EDIT_T
{
MOVE_ABORT, ///< if not changed or error
MOVE_OK, ///< if successfully changed
};
// Constructor and destructor
DIALOG_MOVE_EXACT( PCB_BASE_FRAME* aParent, wxPoint& translation,
double& rotation );
......@@ -51,16 +44,36 @@ public:
private:
/*!
* Reset a text field to be 0 if it was exited while blank
*/
void OnTextFocusLost( wxFocusEvent& event );
void OnPolarChanged( wxCommandEvent& event );
void OnClear( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
/**
* Convert a given Cartesian point into a polar representation.
*
* Linear units are not considered, the answer is in the same units as given
* Angle is returned in degrees
*/
void ToPolarDeg( double x, double y, double& r, double& q );
/**
* Get the (Cartesian) translation described by the text entries
* @param val output translation vector
* @param polar interpret as polar coords
* @return false if error (though the text conversion functions don't report errors)
*/
bool GetTranslationInIU ( wxPoint& val, bool polar );
// Update texts (comments) after changing the coordinates type (polar/cartesian)
void updateDlgTexts( bool aPolar );
/**
* Persistent dialog options
*/
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 6 2014)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -16,7 +16,7 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 );
m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 );
bMainSizer->Add( m_polarCoords, 0, wxALL|wxEXPAND, 5 );
wxFlexGridSizer* fgSizer2;
......@@ -30,46 +30,49 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
fgSizer2->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_xEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_xEntry, 0, wxALL|wxEXPAND, 5 );
fgSizer2->Add( m_xEntry, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_xUnit = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_xUnit->Wrap( -1 );
fgSizer2->Add( m_xUnit, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
m_clearX = new wxBitmapButton( this, wxID_CLEAR, wxArtProvider::GetBitmap( wxART_DELETE, wxART_BUTTON ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
fgSizer2->Add( m_clearX, 0, wxALL, 5 );
fgSizer2->Add( m_clearX, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_yLabel = new wxStaticText( this, wxID_ANY, _("y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_yLabel->Wrap( -1 );
fgSizer2->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_yEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_yEntry, 0, wxALL|wxEXPAND, 5 );
fgSizer2->Add( m_yEntry, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_yUnit = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_yUnit->Wrap( -1 );
fgSizer2->Add( m_yUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_clearY = new wxBitmapButton( this, wxID_CLEAR, wxArtProvider::GetBitmap( wxART_DELETE, wxART_BUTTON ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
fgSizer2->Add( m_clearY, 0, wxALL, 5 );
fgSizer2->Add( m_clearY, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_rotLabel = new wxStaticText( this, wxID_ANY, _("Rotate:"), wxDefaultPosition, wxDefaultSize, 0 );
m_rotLabel = new wxStaticText( this, wxID_ANY, _("Item rotation:"), wxDefaultPosition, wxDefaultSize, 0 );
m_rotLabel->Wrap( -1 );
fgSizer2->Add( m_rotLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_rotEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_rotEntry, 0, wxALL|wxEXPAND, 5 );
fgSizer2->Add( m_rotEntry, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_rotUnit = new wxStaticText( this, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 );
m_rotUnit->Wrap( -1 );
fgSizer2->Add( m_rotUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_clearRot = new wxBitmapButton( this, wxID_CLEAR, wxArtProvider::GetBitmap( wxART_DELETE, wxART_BUTTON ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
fgSizer2->Add( m_clearRot, 0, wxALL, 5 );
fgSizer2->Add( m_clearRot, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( fgSizer2, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_stdButtons = new wxStdDialogButtonSizer();
m_stdButtonsOK = new wxButton( this, wxID_OK );
m_stdButtons->AddButton( m_stdButtonsOK );
......@@ -82,7 +85,6 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id,
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_MOVE_EXACT_BASE::OnClose ) );
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 6 2014)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -28,6 +28,7 @@ class DIALOG_SHIM;
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -54,6 +55,7 @@ class DIALOG_MOVE_EXACT_BASE : public DIALOG_SHIM
wxTextCtrl* m_rotEntry;
wxStaticText* m_rotUnit;
wxBitmapButton* m_clearRot;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_stdButtons;
wxButton* m_stdButtonsOK;
wxButton* m_stdButtonsCancel;
......@@ -69,7 +71,7 @@ class DIALOG_MOVE_EXACT_BASE : public DIALOG_SHIM
public:
DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move item"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move item"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 331,200 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_MOVE_EXACT_BASE();
};
......
......@@ -372,7 +372,7 @@ EVIA::EVIA( CPTREE& aVia )
string ext = attribs.get<string>( "extent" );
sscanf( ext.c_str(), "%u-%u", &layer_front_most, &layer_back_most );
sscanf( ext.c_str(), "%d-%d", &layer_front_most, &layer_back_most );
drill = attribs.get<double>( "drill" );
diam = attribs.get_optional<double>( "diameter" );
......@@ -951,6 +951,7 @@ ELAYER::ELAYER( CPTREE& aLayer )
number = attribs.get<int>( "number" );
name = attribs.get<string>( "name" );
color = attribs.get<int>( "color" );
fill = 1; // Temporary value.
visible = parseOptionalBool( attribs, "visible" );
active = parseOptionalBool( attribs, "active" );
}
......@@ -992,6 +993,7 @@ struct ERULES
ERULES() :
psElongationLong ( 100 ),
psElongationOffset ( 0 ),
rvPadTop ( 0.25 ),
// rvPadBottom ( 0.25 ),
rlMinPadTop ( Mils2iu( 10 ) ),
......
......@@ -1512,7 +1512,7 @@ void PCB_EDIT_FRAME::moveExact()
DIALOG_MOVE_EXACT dialog( this, translation, rotation );
int ret = dialog.ShowModal();
if( ret == DIALOG_MOVE_EXACT::MOVE_OK )
if( ret == wxID_OK )
{
BOARD_ITEM* item = GetScreen()->GetCurItem();
......
......@@ -595,7 +595,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
D_PAD* pad = padstacks[i];
// Straight padstack
fprintf( aFile, "PADSTACK PAD%d %g\n", i, pad->GetDrillSize().x / SCALE_FACTOR );
fprintf( aFile, "PADSTACK PAD%u %g\n", i, pad->GetDrillSize().x / SCALE_FACTOR );
LSET pad_set = pad->GetLayerSet() & master_layermask;
......@@ -604,18 +604,18 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
{
LAYER_ID layer = *seq;
fprintf( aFile, "PAD P%d %s 0 0\n", i, GenCADLayerName( cu_count, layer ).c_str() );
fprintf( aFile, "PAD P%u %s 0 0\n", i, GenCADLayerName( cu_count, layer ).c_str() );
}
// Flipped padstack
fprintf( aFile, "PADSTACK PAD%dF %g\n", i, pad->GetDrillSize().x / SCALE_FACTOR );
fprintf( aFile, "PADSTACK PAD%uF %g\n", i, pad->GetDrillSize().x / SCALE_FACTOR );
// the normal LAYER_ID sequence is inverted from gc_seq[]
for( LSEQ seq = pad_set.Seq(); seq; ++seq )
{
LAYER_ID layer = *seq;
fprintf( aFile, "PAD P%d %s 0 0\n", i, GenCADLayerNameFlipped( cu_count, layer ).c_str() );
fprintf( aFile, "PAD P%u %s 0 0\n", i, GenCADLayerNameFlipped( cu_count, layer ).c_str() );
}
}
......
......@@ -848,7 +848,7 @@ void FOOTPRINT_EDIT_FRAME::moveExact()
DIALOG_MOVE_EXACT dialog( this, translation, rotation );
int ret = dialog.ShowModal();
if( ret == DIALOG_MOVE_EXACT::MOVE_OK )
if( ret == wxID_OK )
{
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
......@@ -926,7 +926,7 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
DIALOG_MOVE_EXACT dialog( this, translation, rotation );
int ret = dialog.ShowModal();
if( ret == DIALOG_MOVE_EXACT::MOVE_OK )
if( ret == wxID_OK )
{
MoveMarkedItemsExactly( module, wxPoint(0, 0),
translation, rotation, true );
......
......@@ -610,7 +610,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation );
int ret = dialog.ShowModal();
if( ret == DIALOG_MOVE_EXACT::MOVE_OK )
if( ret == wxID_OK )
{
if( !isUndoInhibited() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment