KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_target_properties.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <pcb_edit_frame.h>
27#include <base_units.h>
28#include <board_commit.h>
29#include <pcb_target.h>
31#include <widgets/unit_binder.h>
32
33
35{
36private:
39
42
43public:
46
47private:
48 bool TransferDataToWindow() override;
49 bool TransferDataFromWindow() override;
50};
51
52
54{
55 DIALOG_TARGET_PROPERTIES dialog( this, aTarget );
56
57 dialog.ShowModal();
58}
59
60
63 m_Parent( aParent ),
64 m_Target( aTarget ),
65 m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits ),
66 m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits )
67{
69
71
72 // Now all widgets have the size fixed, call FinishDialogSettings
74}
75
76
78{
81
82 m_TargetShape->SetSelection( m_Target->GetShape() ? 1 : 0 );
83
84 return true;
85}
86
87
89{
90 // Zero-size targets are hard to see/select.
91 if( !m_Size.Validate( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 1 ), INT_MAX ) )
92 return false;
93
94 BOARD_COMMIT commit( m_Parent );
95 commit.Modify( m_Target );
96
97 // Save old item in undo list, if it's not currently edited (will be later if so)
98 bool pushCommit = ( m_Target->GetEditFlags() == 0 );
99
100 if( m_Target->GetEditFlags() != 0 ) // other edit in progress (MOVE, NEW ..)
101 m_Target->SetFlags( IN_EDIT ); // set flag IN_EDIT to force
102 // undo/redo/abort proper operation
103
106 m_Target->SetShape( m_TargetShape->GetSelection() ? 1 : 0 );
107
108 if( pushCommit )
109 commit.Push( _( "Edit Alignment Target" ) );
110
111 return true;
112}
113
114
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:102
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
int ShowModal() override
Class DIALOG_TARGET_PROPERTIES_BASE.
DIALOG_TARGET_PROPERTIES(PCB_EDIT_FRAME *aParent, PCB_TARGET *aTarget)
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:133
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
The main frame for Pcbnew.
void ShowTargetOptionsDialog(PCB_TARGET *aTarget)
int GetShape() const
Definition: pcb_target.h:58
int GetWidth() const
Definition: pcb_target.h:64
void SetWidth(int aWidth)
Definition: pcb_target.h:63
void SetSize(int aSize)
Definition: pcb_target.h:60
void SetShape(int aShape)
Definition: pcb_target.h:57
int GetSize() const
Definition: pcb_target.h:61
int GetIntValue()
Definition: unit_binder.h:129
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
#define _(s)
#define IN_EDIT
Item currently edited.
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
Definition: eda_units.h:157