2015-02-12 03:22:24 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 John Beard, john.j.beard@gmail.com
|
2020-04-03 20:47:02 +00:00
|
|
|
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-12 03:22:24 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DIALOG_MOVE_EXACT__
|
|
|
|
#define __DIALOG_MOVE_EXACT__
|
|
|
|
|
|
|
|
#include <vector>
|
2018-06-12 07:36:35 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2017-04-22 20:07:29 +00:00
|
|
|
|
2019-02-23 13:58:57 +00:00
|
|
|
#include <dialogs/dialog_move_exact_base.h>
|
|
|
|
|
|
|
|
|
|
|
|
class PCB_BASE_FRAME;
|
2017-04-22 20:07:29 +00:00
|
|
|
|
|
|
|
|
2018-06-12 07:36:35 +00:00
|
|
|
enum ROTATION_ANCHOR
|
2017-04-22 20:07:29 +00:00
|
|
|
{
|
2018-06-12 07:36:35 +00:00
|
|
|
ROTATE_AROUND_ITEM_ANCHOR,
|
|
|
|
ROTATE_AROUND_SEL_CENTER,
|
|
|
|
ROTATE_AROUND_USER_ORIGIN,
|
|
|
|
ROTATE_AROUND_AUX_ORIGIN
|
2017-04-22 20:07:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
class DIALOG_MOVE_EXACT : public DIALOG_MOVE_EXACT_BASE
|
|
|
|
{
|
|
|
|
private:
|
2018-06-12 07:36:35 +00:00
|
|
|
wxPoint& m_translation;
|
|
|
|
double& m_rotation;
|
|
|
|
ROTATION_ANCHOR& m_rotationAnchor;
|
2019-06-20 13:28:51 +00:00
|
|
|
const EDA_RECT& m_bbox;
|
2018-06-12 07:36:35 +00:00
|
|
|
|
|
|
|
UNIT_BINDER m_moveX;
|
|
|
|
UNIT_BINDER m_moveY;
|
|
|
|
UNIT_BINDER m_rotate;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-06-12 07:36:35 +00:00
|
|
|
std::vector<ROTATION_ANCHOR> m_menuIDs;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2020-02-29 02:21:18 +00:00
|
|
|
double m_stateX;
|
|
|
|
double m_stateY;
|
|
|
|
double m_stateRadius;
|
|
|
|
double m_stateTheta;
|
|
|
|
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
public:
|
|
|
|
// Constructor and destructor
|
2018-06-12 07:36:35 +00:00
|
|
|
DIALOG_MOVE_EXACT(PCB_BASE_FRAME *aParent, wxPoint& aTranslate,
|
2019-06-20 13:28:51 +00:00
|
|
|
double& aRotate, ROTATION_ANCHOR& aAnchor,
|
|
|
|
const EDA_RECT& aBbox);
|
2018-06-12 07:36:35 +00:00
|
|
|
~DIALOG_MOVE_EXACT() { };
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-02-22 14:43:44 +00:00
|
|
|
/*!
|
|
|
|
* Reset a text field to be 0 if it was exited while blank
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnTextFocusLost( wxFocusEvent& event ) override;
|
2015-02-22 14:43:44 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnPolarChanged( wxCommandEvent& event ) override;
|
|
|
|
void OnClear( wxCommandEvent& event ) override;
|
2019-06-20 13:28:51 +00:00
|
|
|
void OnTextChanged( wxCommandEvent& event ) override;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-02-08 09:51:05 +00:00
|
|
|
// Automatically called when clicking on the OK button
|
|
|
|
bool TransferDataFromWindow() override;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2015-02-22 14:43:44 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2015-02-12 03:22:24 +00:00
|
|
|
void ToPolarDeg( double x, double y, double& r, double& q );
|
2015-02-22 14:43:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
2020-02-29 02:21:18 +00:00
|
|
|
bool GetTranslationInIU( wxRealPoint& val, bool polar );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-06-12 07:36:35 +00:00
|
|
|
void buildRotationAnchorMenu();
|
|
|
|
|
|
|
|
// Update controls and their labels after changing the coordinates type (polar/cartesian)
|
|
|
|
void updateDialogControls( bool aPolar );
|
2015-02-22 14:43:44 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
/**
|
|
|
|
* Persistent dialog options
|
|
|
|
*/
|
|
|
|
struct MOVE_EXACT_OPTIONS
|
|
|
|
{
|
2020-04-03 20:47:02 +00:00
|
|
|
bool polarCoords;
|
|
|
|
wxString entry1;
|
|
|
|
wxString entry2;
|
|
|
|
wxString entryRotation;
|
|
|
|
size_t entryAnchorSelection;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
MOVE_EXACT_OPTIONS():
|
2017-04-22 20:07:29 +00:00
|
|
|
polarCoords( false ),
|
2020-04-03 20:47:02 +00:00
|
|
|
entry1( wxT( "0" ) ),
|
|
|
|
entry2( wxT( "0" ) ),
|
|
|
|
entryRotation( wxT( "0" ) ),
|
2018-06-12 07:36:35 +00:00
|
|
|
entryAnchorSelection( 0 )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// persistent settings
|
|
|
|
static MOVE_EXACT_OPTIONS m_options;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __DIALOG_MOVE_EXACT__
|
2017-04-22 20:07:29 +00:00
|
|
|
|