Save pre-eval values for Move Exactly dialog.

Fixes https://gitlab.com/kicad/code/kicad/issues/4088
This commit is contained in:
Jeff Young 2020-04-03 21:47:02 +01:00
parent 082944ad06
commit 78dfbca9a3
4 changed files with 37 additions and 15 deletions

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -296,6 +297,19 @@ bool UNIT_BINDER::IsIndeterminate() const
}
wxString UNIT_BINDER::GetOriginalText() const
{
if( m_allowEval )
return m_eval.OriginalText();
else if( dynamic_cast<wxTextEntry*>( m_value ) )
return dynamic_cast<wxTextEntry*>( m_value )->GetValue();
else if( dynamic_cast<wxStaticText*>( m_value ) )
return dynamic_cast<wxStaticText*>( m_value )->GetLabel();
else
return wxEmptyString;
}
void UNIT_BINDER::SetLabel( const wxString& aLabel )
{
m_label->SetLabel( aLabel );

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -107,6 +108,13 @@ public:
*/
bool IsIndeterminate() const;
/**
* Function GetOriginalText
* Returns the pre-evaluated text (or the current text if evaluation is not supported).
* Used primarily to remember values between dialog invocations.
*/
wxString GetOriginalText() const;
/**
* Function Validate
* Validates the control against the given range, informing the user of any errors found.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 John Beard, john.j.beard@gmail.com
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2020 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
@ -70,8 +70,8 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, wxPoint& aTransla
// and set up the entries according to the saved options
m_polarCoords->SetValue( m_options.polarCoords );
m_moveX.SetDoubleValue( m_options.entry1 );
m_moveY.SetDoubleValue( m_options.entry2 );
m_moveX.SetValue( m_options.entry1 );
m_moveY.SetValue( m_options.entry2 );
m_rotate.SetUnits( EDA_UNITS::DEGREES );
m_rotate.SetValue( m_options.entryRotation );
@ -246,9 +246,9 @@ bool DIALOG_MOVE_EXACT::TransferDataFromWindow()
{
// save the settings
m_options.polarCoords = m_polarCoords->GetValue();
m_options.entry1 = m_moveX.GetDoubleValue();
m_options.entry2 = m_moveY.GetDoubleValue();
m_options.entryRotation = m_rotate.GetValue();
m_options.entry1 = m_moveX.GetOriginalText();
m_options.entry2 = m_moveY.GetOriginalText();
m_options.entryRotation = m_rotate.GetOriginalText();
m_options.entryAnchorSelection = (size_t) std::max( m_anchorOptions->GetSelection(), 0 );
return true;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 John Beard, john.j.beard@gmail.com
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2020 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
@ -110,17 +110,17 @@ private:
*/
struct MOVE_EXACT_OPTIONS
{
bool polarCoords;
double entry1;
double entry2;
double entryRotation;
size_t entryAnchorSelection;
bool polarCoords;
wxString entry1;
wxString entry2;
wxString entryRotation;
size_t entryAnchorSelection;
MOVE_EXACT_OPTIONS():
polarCoords( false ),
entry1( 0 ),
entry2( 0 ),
entryRotation( 0 ),
entry1( wxT( "0" ) ),
entry2( wxT( "0" ) ),
entryRotation( wxT( "0" ) ),
entryAnchorSelection( 0 )
{
}