设置区间参数的步长

This commit is contained in:
gb 2022-12-31 15:45:49 +08:00
parent 425730e615
commit 6ffad229e8
5 changed files with 26 additions and 1 deletions

Binary file not shown.

View File

@ -6301,6 +6301,8 @@ void ChgjsonDlg::set_control_status(const HGITEM& item)
GetDlgItem(IDC_STATIC_DEFAULT)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_COMBO_DEFAULT)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_STEP)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_STEP)->ShowWindow(SW_HIDE);
constraint_.SetCurSel(item.range.type);
if (item.range.type == RANGE_TYPE_NONE)
{
@ -6326,11 +6328,14 @@ void ChgjsonDlg::set_control_status(const HGITEM& item)
GetDlgItem(IDC_STATIC_TO)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_FROM)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_TO)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_STEP)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_STEP)->ShowWindow(SW_SHOW);
if (item.type == L"int")
{
SetDlgItemInt(IDC_EDIT_FROM, item.range.lower);
SetDlgItemInt(IDC_EDIT_TO, item.range.upper);
SetDlgItemInt(IDC_EDIT_STEP, item.range.step);
}
else
{
@ -6341,6 +6346,9 @@ void ChgjsonDlg::set_control_status(const HGITEM& item)
swprintf_s(buf, _countof(buf) - 1, L"%f", item.range.upper);
::SetDlgItemTextW(m_hWnd, IDC_EDIT_TO, buf);
swprintf_s(buf, _countof(buf) - 1, L"%f", item.range.step);
::SetDlgItemTextW(m_hWnd, IDC_EDIT_STEP, buf);
}
}
else // list
@ -6449,11 +6457,13 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h, std::wstring*
{
r->set_value(L"min", (int)hg_items_[item].range.lower);
r->set_value(L"max", (int)hg_items_[item].range.upper);
r->set_value(L"step", (int)hg_items_[item].range.step);
}
else
{
r->set_value(L"min", hg_items_[item].range.lower);
r->set_value(L"max", hg_items_[item].range.upper);
r->set_value(L"step", hg_items_[item].range.step);
}
jsn->set_value(L"range", r);
r->release();
@ -6745,12 +6755,16 @@ void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent, bool
{
if (item.type == L"int")
{
int l = 0, u = 0;
int l = 0, u = 0, s = 0;
if (child->get_value(L"min", l))
{
child->get_value(L"max", u);
item.range.lower = l;
item.range.upper = u;
if (child->get_value(L"step", s))
item.range.step = s;
else
item.range.step = 1;
item.range.type = RANGE_TYPE_RANGE;
}
else
@ -6775,6 +6789,8 @@ void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent, bool
if (child->get_value(L"min", item.range.lower))
{
child->get_value(L"max", item.range.upper);
if (!child->get_value(L"step", item.range.step))
item.range.step = (item.range.upper - item.range.lower) / 10.0f;
item.range.type = RANGE_TYPE_RANGE;
}
else
@ -7385,6 +7401,8 @@ void ChgjsonDlg::OnCbnSelchangeConstraintType()
GetDlgItem(IDC_STATIC_TO)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_FROM)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_TO)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_STEP)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_STEP)->ShowWindow(SW_HIDE);
constraint_list_.ShowWindow(SW_HIDE);
if (sel == 0)
@ -7406,6 +7424,8 @@ void ChgjsonDlg::OnCbnSelchangeConstraintType()
GetDlgItem(IDC_EDIT_TO)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_DEFAULT)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_STEP)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_STEP)->ShowWindow(SW_SHOW);
}
else // if( sel == 2)
{
@ -7741,6 +7761,10 @@ void ChgjsonDlg::OnBnClickedButton4()
it->range.lower = _wtof(str);
::GetDlgItemTextW(m_hWnd, IDC_EDIT_TO, str, _countof(str) - 1);
it->range.upper = _wtof(str);
::GetDlgItemTextW(m_hWnd, IDC_EDIT_STEP, str, _countof(str) - 1);
it->range.step = _wtof(str);
if (fabs(it->range.step) < .000001f)
it->range.step = (it->range.upper - it->range.lower) / 10.0f;
}
}

View File

@ -50,6 +50,7 @@ public:
int type;
double lower;
double upper;
double step;
std::vector<std::wstring> queue;
}RANGE;
typedef struct _hg_item

Binary file not shown.

Binary file not shown.