forked from jpt13653903/FreePCB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DlgMoveOrigin.cpp
124 lines (109 loc) · 2.4 KB
/
DlgMoveOrigin.cpp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// DlgMoveOrigin.cpp : implementation file
//
#include "stdafx.h"
#include "FreePcb.h"
#include "DlgMoveOrigin.h"
#include ".\dlgmoveorigin.h"
// CDlgMoveOrigin dialog
IMPLEMENT_DYNAMIC(CDlgMoveOrigin, CDialog)
CDlgMoveOrigin::CDlgMoveOrigin(CWnd* pParent /*=NULL*/)
: CDialog(CDlgMoveOrigin::IDD, pParent)
{
}
CDlgMoveOrigin::~CDlgMoveOrigin()
{
}
void CDlgMoveOrigin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RADIO1, m_radio_drag);
DDX_Control(pDX, IDC_RADIO2, m_radio_set);
DDX_Control(pDX, IDC_COMBO1, m_combo_units);
DDX_Control(pDX, IDC_EDIT1, m_edit_x);
DDX_Control(pDX, IDC_EDIT2, m_edit_y);
if( !pDX->m_bSaveAndValidate )
{
// incoming
m_combo_units.AddString( "MIL" );
m_combo_units.AddString( "MM" );
m_combo_units.SetCurSel(0);
m_radio_drag.SetCheck(1);
SetFields();
}
else
{
// outgoing
GetFields();
}
}
BEGIN_MESSAGE_MAP(CDlgMoveOrigin, CDialog)
ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeUnits)
ON_BN_CLICKED(IDC_RADIO1, OnBnClickedDrag)
ON_BN_CLICKED(IDC_RADIO2, OnBnClickedSet)
END_MESSAGE_MAP()
void CDlgMoveOrigin::Initialize( int units )
{
m_units = units;
m_x = m_y = 0;
}
void CDlgMoveOrigin::GetFields()
{
CString str;
if( m_radio_drag.GetCheck() )
m_drag = TRUE;
else
m_drag = FALSE;
m_edit_x.GetWindowText( str );
m_x = atof( str ) * m_mult;
m_edit_y.GetWindowText( str );
m_y = atof( str ) * m_mult;
}
void CDlgMoveOrigin::SetFields()
{
CString str;
if( m_combo_units.GetCurSel() == 0 )
{
m_units = MIL;
m_mult = NM_PER_MIL;
}
else
{
m_units = MM;
m_mult = 1000000.0;
}
if( m_radio_drag.GetCheck() )
{
m_combo_units.EnableWindow(0);
m_edit_x.EnableWindow(0);
m_edit_y.EnableWindow(0);
m_x = m_y = 0;
m_edit_x.SetWindowText( "" );
m_edit_y.SetWindowText( "" );
}
else
{
m_combo_units.EnableWindow(1);
m_edit_x.EnableWindow(1);
m_edit_y.EnableWindow(1);
MakeCStringFromDouble( &str, m_x/m_mult );
m_edit_x.SetWindowText( str );
MakeCStringFromDouble( &str, m_y/m_mult );
m_edit_y.SetWindowText( str );
}
}
// CDlgMoveOrigin message handlers
void CDlgMoveOrigin::OnCbnSelchangeUnits()
{
GetFields();
SetFields();
}
void CDlgMoveOrigin::OnBnClickedDrag()
{
GetFields();
SetFields();
}
void CDlgMoveOrigin::OnBnClickedSet()
{
GetFields();
SetFields();
}