summaryrefslogtreecommitdiff
path: root/pcbnew/dialogs/dialog_track_via_properties.h
blob: 08fb945a0e38135dfad6220dc0fd70cab874ed41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2015 CERN
 * @author Maciej Suminski <maciej.suminski@cern.ch>
 *
 * 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
 */

#include <dialogs/dialog_track_via_properties_base.h>
#include <wx_unit_binder.h>
#include <boost/optional.hpp>
#include <layers_id_colors_and_visibility.h>

struct SELECTION;
class PCB_BASE_FRAME;

class DIALOG_TRACK_VIA_PROPERTIES : public DIALOG_TRACK_VIA_PROPERTIES_BASE
{
public:
    DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems );

    ///> Applies values from the dialog to the selected items.
    bool Apply();

private:
    void onClose( wxCloseEvent& aEvent );
    void onTrackNetclassCheck( wxCommandEvent& aEvent );
    void onViaNetclassCheck( wxCommandEvent& aEvent );
    void onCancelClick( wxCommandEvent& aEvent );
    void onOkClick( wxCommandEvent& aEvent );

    ///> Checks if the dialog values are correct.
    bool check() const;

    ///> Sets wxTextCtrl to the value stored in boost::optional<T> or "<...>" if it is not available.
    template<typename T>
    void setCommonVal( const boost::optional<T>& aVal, wxTextCtrl* aTxtCtrl, WX_UNIT_BINDER& aBinder )
    {
        if( aVal )
            aBinder.SetValue( *aVal );
        else
            aTxtCtrl->SetValue( "<...>" );
    }

    ///> Selected items to be modified.
    const SELECTION& m_items;

    WX_UNIT_BINDER m_trackStartX, m_trackStartY;
    WX_UNIT_BINDER m_trackEndX, m_trackEndY;
    WX_UNIT_BINDER m_trackWidth;

    WX_UNIT_BINDER m_viaX, m_viaY;
    WX_UNIT_BINDER m_viaDiameter, m_viaDrill;

    ///> Flag that determines if the dialog displays track properties.
    bool m_tracks;

    ///> Flag that determines if the dialog displays via properties.
    bool m_vias;
};