KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_angle_variant.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) 2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22
24 wxVariantData()
25{}
26
27
29 wxVariantData(),
30 m_angle( aAngleDegrees, DEGREES_T )
31{}
32
33
35 wxVariantData(),
36 m_angle( aAngle )
37{}
38
39
40bool EDA_ANGLE_VARIANT_DATA::Eq( wxVariantData& aOther ) const
41{
42 try
43 {
44 EDA_ANGLE_VARIANT_DATA& evd = dynamic_cast<EDA_ANGLE_VARIANT_DATA&>( aOther );
45
46 return evd.m_angle == m_angle;
47 }
48 catch( std::bad_cast& )
49 {
50 return false;
51 }
52}
53
54
55bool EDA_ANGLE_VARIANT_DATA::Read( wxString& aString )
56{
57 double val;
58
59 if( !aString.ToDouble( &val ) )
60 return false;
61
62 m_angle = EDA_ANGLE( val, DEGREES_T );
63 return true;
64}
65
66
67bool EDA_ANGLE_VARIANT_DATA::Write( wxString& aString ) const
68{
69 aString = wxString::Format( wxT("%g\u00B0"), m_angle.AsDegrees() );
70 return true;
71}
72
73
74bool EDA_ANGLE_VARIANT_DATA::GetAsAny( wxAny* aAny ) const
75{
76 *aAny = m_angle.AsDegrees();
77 return true;
78}
79
80
81wxVariantData* EDA_ANGLE_VARIANT_DATA::VariantDataFactory( const wxAny& aAny )
82{
83 return new EDA_ANGLE_VARIANT_DATA( aAny.As<EDA_ANGLE>() );
84}
85
86
bool Read(wxString &aString) override
static wxVariantData * VariantDataFactory(const wxAny &aAny)
bool Eq(wxVariantData &aOther) const override
bool GetAsAny(wxAny *aAny) const override
bool Write(wxString &aString) const override
double AsDegrees() const
Definition: eda_angle.h:113
@ DEGREES_T
Definition: eda_angle.h:31