add sorting function to JSON tool; add reinstate option to CIS
This commit is contained in:
parent
6453b1aad4
commit
d6246133d8
|
@ -7,7 +7,7 @@
|
||||||
// configuration text
|
// configuration text
|
||||||
//
|
//
|
||||||
|
|
||||||
static std::string g_cis_cfg("{\"montage\":{\"cat\":\"cis\",\"group\":\"CIS\",\"title\":\"\\u56fe\\u50cf\\u62fc\\u63a5\",\"desc\":\"\\u5c06CIS\\u91c7\\u96c6\\u7684\\u539f\\u59cb\\u6570\\u636e\\u6062\\u590d\\u4e3a\\u6b63\\u5e38\\u7684\\u56fe\\u50cf\",\"ver\":1,\"pos\":10,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"fb-split\":{\"cat\":\"CIS\",\"group\":\"CIS\",\"title\":\"\\u62c6\\u5206\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u5c06\\u6b63\\u53cd\\u9762\\u5408\\u6210\\u7684\\u4e00\\u5f20\\u56fe\\u7247\\u62c6\\u5206\\u6210\\u6b63\\u9762\\u548c\\u53cd\\u9762\\u56fe\\u7247\",\"ver\":1,\"pos\":20,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"page\":{\"cat\":\"CIS\",\"group\":\"base\",\"title\":\"\\u9875\\u9762\",\"desc\":\"\\u83b7\\u53d6\\u7eb8\\u5f20\\u6307\\u5b9a\\u9762\\u7684\\u56fe\\u7247\",\"ver\":1,\"pos\":30,\"type\":\"string\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":30,\"cur\":\"\\u53cc\\u9762\",\"default\":\"\\u53cc\\u9762\",\"range\":[\"\\u6b63\\u9762\",\"\\u80cc\\u9762\",\"\\u53cc\\u9762\"],\"depend_or\":[\"fb-split==true\"]}}");
|
static std::string g_cis_cfg("{\"montage\":{\"cat\":\"cis\",\"group\":\"CIS\",\"title\":\"\\u56fe\\u50cf\\u62fc\\u63a5\",\"desc\":\"\\u5c06CIS\\u91c7\\u96c6\\u7684\\u539f\\u59cb\\u6570\\u636e\\u6062\\u590d\\u4e3a\\u6b63\\u5e38\\u7684\\u56fe\\u50cf\",\"ver\":1,\"pos\":10,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"reinstate\":{\"cat\":\"CIS\",\"group\":\"CIS\",\"title\":\"\\u786c\\u4ef6\\u590d\\u539f\",\"desc\":\"\\u6d88\\u9664CIS\\u786c\\u4ef6\\u62c9\\u4f38\\u56e0\\u7d20\\uff0c\\u6062\\u590d\\u56fe\\u7247\\u521d\\u59cb\\u72b6\\u6001\",\"ver\":1,\"pos\":20,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"fb-split\":{\"cat\":\"CIS\",\"group\":\"CIS\",\"title\":\"\\u62c6\\u5206\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u5c06\\u6b63\\u53cd\\u9762\\u5408\\u6210\\u7684\\u4e00\\u5f20\\u56fe\\u7247\\u62c6\\u5206\\u6210\\u6b63\\u9762\\u548c\\u53cd\\u9762\\u56fe\\u7247\",\"ver\":1,\"pos\":30,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"page\":{\"cat\":\"CIS\",\"group\":\"base\",\"title\":\"\\u9875\\u9762\",\"desc\":\"\\u83b7\\u53d6\\u7eb8\\u5f20\\u6307\\u5b9a\\u9762\\u7684\\u56fe\\u7247\",\"ver\":1,\"pos\":40,\"type\":\"string\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":30,\"cur\":\"\\u53cc\\u9762\",\"default\":\"\\u53cc\\u9762\",\"range\":[\"\\u6b63\\u9762\",\"\\u80cc\\u9762\",\"\\u53cc\\u9762\"],\"depend_or\":[\"fb-split==true\"]}}");
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -102,7 +102,7 @@ img_one_paper* cis_spliter(img_one_paper* in)
|
||||||
cis_pre_do::cis_pre_do(std::function<img_one_paper* (img_one_paper*)> montage
|
cis_pre_do::cis_pre_do(std::function<img_one_paper* (img_one_paper*)> montage
|
||||||
, std::function< img_one_paper* (img_one_paper*)> split)
|
, std::function< img_one_paper* (img_one_paper*)> split)
|
||||||
: montage_(montage), split_(split)
|
: montage_(montage), split_(split)
|
||||||
, cfg_(g_cis_cfg), is_montage_(true), is_split_(true), page_(PAGE_DUPLEX), cis_dpi_(200)
|
, cfg_(g_cis_cfg), is_montage_(true), is_split_(true), page_(PAGE_DUPLEX), cis_dpi_(200), reinstate_(true)
|
||||||
{
|
{
|
||||||
if (!montage_)
|
if (!montage_)
|
||||||
montage_ = cis_montager;
|
montage_ = cis_montager;
|
||||||
|
@ -143,6 +143,12 @@ void cis_pre_do::init_value(void)
|
||||||
is_montage_ = true;
|
is_montage_ = true;
|
||||||
child->release();
|
child->release();
|
||||||
}
|
}
|
||||||
|
if (jsn->get_value("reinstate", child) && child)
|
||||||
|
{
|
||||||
|
if (!child->get_value("cur", reinstate_))
|
||||||
|
reinstate_ = true;
|
||||||
|
child->release();
|
||||||
|
}
|
||||||
if (jsn->get_value("fb-split", child) && child)
|
if (jsn->get_value("fb-split", child) && child)
|
||||||
{
|
{
|
||||||
if (!child->get_value("cur", is_split_))
|
if (!child->get_value("cur", is_split_))
|
||||||
|
@ -280,11 +286,14 @@ img_one_paper* cis_pre_do::execute(img_one_paper* img)
|
||||||
img = mont;
|
img = mont;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& v: img->images_queue())
|
if(reinstate_)
|
||||||
{
|
{
|
||||||
resize(v.img, img->get_cis_ratio_h(), img->get_cis_ratio_v());
|
for(auto& v: img->images_queue())
|
||||||
v.head.width = v.img.cols;
|
{
|
||||||
v.head.height = v.img.rows;
|
resize(v.img, img->get_cis_ratio_h(), img->get_cis_ratio_v());
|
||||||
|
v.head.width = v.img.cols;
|
||||||
|
v.head.height = v.img.rows;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_split_)
|
if(is_split_)
|
||||||
|
|
|
@ -28,13 +28,30 @@ class gb_json;
|
||||||
// "cur": true,
|
// "cur": true,
|
||||||
// "default": true
|
// "default": true
|
||||||
// },
|
// },
|
||||||
|
// "reinstate": {
|
||||||
|
// "cat": "CIS",
|
||||||
|
// "group": "CIS",
|
||||||
|
// "title": "硬件复原",
|
||||||
|
// "desc": "消除CIS硬件拉伸因素,恢复图片初始状态",
|
||||||
|
// "ver": 1,
|
||||||
|
// "pos": 20,
|
||||||
|
// "type": "bool",
|
||||||
|
// "unit": "none",
|
||||||
|
// "affect": 0,
|
||||||
|
// "readonly": false,
|
||||||
|
// "visible": false,
|
||||||
|
// "enabled": true,
|
||||||
|
// "size": 4,
|
||||||
|
// "cur": true,
|
||||||
|
// "default": true
|
||||||
|
// },
|
||||||
// "fb-split": {
|
// "fb-split": {
|
||||||
// "cat": "CIS",
|
// "cat": "CIS",
|
||||||
// "group": "CIS",
|
// "group": "CIS",
|
||||||
// "title": "拆分正反面",
|
// "title": "拆分正反面",
|
||||||
// "desc": "将正反面合成的一张图片拆分成正面和反面图片",
|
// "desc": "将正反面合成的一张图片拆分成正面和反面图片",
|
||||||
// "ver": 1,
|
// "ver": 1,
|
||||||
// "pos": 20,
|
// "pos": 30,
|
||||||
// "type": "bool",
|
// "type": "bool",
|
||||||
// "unit": "none",
|
// "unit": "none",
|
||||||
// "affect": 2,
|
// "affect": 2,
|
||||||
|
@ -51,7 +68,7 @@ class gb_json;
|
||||||
// "title": "页面",
|
// "title": "页面",
|
||||||
// "desc": "获取纸张指定面的图片",
|
// "desc": "获取纸张指定面的图片",
|
||||||
// "ver": 1,
|
// "ver": 1,
|
||||||
// "pos": 30,
|
// "pos": 40,
|
||||||
// "type": "string",
|
// "type": "string",
|
||||||
// "unit": "none",
|
// "unit": "none",
|
||||||
// "affect": 2,
|
// "affect": 2,
|
||||||
|
@ -71,6 +88,8 @@ class cis_pre_do : public sane_cfg_provider
|
||||||
std::string cfg_;
|
std::string cfg_;
|
||||||
bool is_montage_;
|
bool is_montage_;
|
||||||
bool is_split_;
|
bool is_split_;
|
||||||
|
bool reinstate_;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PAGE_FRONT = 0,
|
PAGE_FRONT = 0,
|
||||||
|
|
|
@ -110,8 +110,8 @@ known_file_util::IJsonW* CDlgOptJson::SANEOPT::to_json(void)
|
||||||
|
|
||||||
if (type == L"bool")
|
if (type == L"bool")
|
||||||
{
|
{
|
||||||
jsn->set_value(L"cur", wcscmp((wchar_t*)def_val.c_str(), L"true") == 0);
|
jsn->set_value(L"cur", *(bool*)def_val.c_str());
|
||||||
jsn->set_value(L"default", wcscmp((wchar_t*)def_val.c_str(), L"true") == 0);
|
jsn->set_value(L"default", *(bool*)def_val.c_str());
|
||||||
}
|
}
|
||||||
else if (type == L"int")
|
else if (type == L"int")
|
||||||
{
|
{
|
||||||
|
@ -259,12 +259,10 @@ bool CDlgOptJson::SANEOPT::from_json(known_file_util::IJsonW* jsn)
|
||||||
if (type == L"bool")
|
if (type == L"bool")
|
||||||
{
|
{
|
||||||
bool v = false;
|
bool v = false;
|
||||||
std::wstring sv(L"");
|
|
||||||
|
|
||||||
if (!jsn->get_value(L"default", v))
|
if (!jsn->get_value(L"default", v))
|
||||||
jsn->get_value(L"cur", v);
|
jsn->get_value(L"cur", v);
|
||||||
sv = v ? L"true" : L"false";
|
def_val = std::string((char*)&v, sizeof(v));
|
||||||
def_val = std::string((char*)&sv[0], sv.length() * 2 + 2);
|
|
||||||
}
|
}
|
||||||
else if(type == L"int")
|
else if(type == L"int")
|
||||||
{
|
{
|
||||||
|
@ -586,7 +584,7 @@ void CDlgOptJson::to_ui(const SANEOPT& sop)
|
||||||
def_val_.ResetContent();
|
def_val_.ResetContent();
|
||||||
def_val_.AddString(L"false");
|
def_val_.AddString(L"false");
|
||||||
def_val_.AddString(L"true");
|
def_val_.AddString(L"true");
|
||||||
def_val_.SetCurSel(def_val_.FindStringExact(-1, (const wchar_t*)sop.def_val.c_str()));
|
def_val_.SetCurSel(def_val_.FindStringExact(-1, *(bool*)sop.def_val.c_str() ? L"true" : L"false"));
|
||||||
}
|
}
|
||||||
else if (sop.type == L"int")
|
else if (sop.type == L"int")
|
||||||
{
|
{
|
||||||
|
@ -884,6 +882,10 @@ BEGIN_MESSAGE_MAP(CDlgOptJson, CDialogEx)
|
||||||
ON_COMMAND(ID_TREE_DELITEM, &CDlgOptJson::OnTreeDelitem)
|
ON_COMMAND(ID_TREE_DELITEM, &CDlgOptJson::OnTreeDelitem)
|
||||||
ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CDlgOptJson::OnBnClickedButtonExport)
|
ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CDlgOptJson::OnBnClickedButtonExport)
|
||||||
ON_COMMAND(ID_TREE_MODIFYALLFIELD, &CDlgOptJson::OnTreeModifyallfield)
|
ON_COMMAND(ID_TREE_MODIFYALLFIELD, &CDlgOptJson::OnTreeModifyallfield)
|
||||||
|
ON_COMMAND(ID_SORT_NAME, &CDlgOptJson::OnSortName)
|
||||||
|
ON_COMMAND(ID_SORT_TITLE, &CDlgOptJson::OnSortTitle)
|
||||||
|
ON_COMMAND(ID_SORT_GROUP, &CDlgOptJson::OnSortGroup)
|
||||||
|
ON_COMMAND(ID_SORT_POSITION, &CDlgOptJson::OnSortPosition)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1680,3 +1682,87 @@ void CDlgOptJson::OnTreeModifyallfield()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDlgOptJson::OnSortName()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加命令处理程序代码
|
||||||
|
HTREEITEM sel = tree_.GetSelectedItem();
|
||||||
|
std::wstring name(L"");
|
||||||
|
std::vector<SANEOPT> all(std::move(opts_));
|
||||||
|
|
||||||
|
std::sort(all.begin(), all.end(), SANEOPT::compare_name);
|
||||||
|
if (sel)
|
||||||
|
{
|
||||||
|
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||||||
|
if (n)
|
||||||
|
name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_from_tree();
|
||||||
|
for (auto& v : all)
|
||||||
|
insert_new_item(v, v.name == name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDlgOptJson::OnSortTitle()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加命令处理程序代码
|
||||||
|
HTREEITEM sel = tree_.GetSelectedItem();
|
||||||
|
std::wstring name(L"");
|
||||||
|
std::vector<SANEOPT> all(std::move(opts_));
|
||||||
|
|
||||||
|
std::sort(all.begin(), all.end(), SANEOPT::compare_title);
|
||||||
|
if (sel)
|
||||||
|
{
|
||||||
|
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||||||
|
if (n)
|
||||||
|
name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_from_tree();
|
||||||
|
for (auto& v : all)
|
||||||
|
insert_new_item(v, v.name == name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDlgOptJson::OnSortGroup()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加命令处理程序代码
|
||||||
|
HTREEITEM sel = tree_.GetSelectedItem();
|
||||||
|
std::wstring name(L"");
|
||||||
|
std::vector<SANEOPT> all(std::move(opts_));
|
||||||
|
|
||||||
|
std::sort(all.begin(), all.end(), SANEOPT::compare_group);
|
||||||
|
if (sel)
|
||||||
|
{
|
||||||
|
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||||||
|
if (n)
|
||||||
|
name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_from_tree();
|
||||||
|
for (auto& v : all)
|
||||||
|
insert_new_item(v, v.name == name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDlgOptJson::OnSortPosition()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加命令处理程序代码
|
||||||
|
HTREEITEM sel = tree_.GetSelectedItem();
|
||||||
|
std::wstring name(L"");
|
||||||
|
std::vector<SANEOPT> all(std::move(opts_));
|
||||||
|
|
||||||
|
std::sort(all.begin(), all.end(), SANEOPT::compare_position);
|
||||||
|
if (sel)
|
||||||
|
{
|
||||||
|
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||||||
|
if (n)
|
||||||
|
name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_from_tree();
|
||||||
|
for (auto& v : all)
|
||||||
|
insert_new_item(v, v.name == name);
|
||||||
|
}
|
||||||
|
|
|
@ -134,6 +134,23 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool compare_name(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
|
||||||
|
{
|
||||||
|
return l.name < r.name;
|
||||||
|
}
|
||||||
|
static bool compare_title(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
|
||||||
|
{
|
||||||
|
return l.title < r.title;
|
||||||
|
}
|
||||||
|
static bool compare_group(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
|
||||||
|
{
|
||||||
|
return l.group < r.group;
|
||||||
|
}
|
||||||
|
static bool compare_position(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
|
||||||
|
{
|
||||||
|
return l.pos < r.pos;
|
||||||
|
}
|
||||||
|
|
||||||
known_file_util::IJsonW* to_json(void);
|
known_file_util::IJsonW* to_json(void);
|
||||||
bool from_json(known_file_util::IJsonW* jsn);
|
bool from_json(known_file_util::IJsonW* jsn);
|
||||||
}SANEOPT;
|
}SANEOPT;
|
||||||
|
@ -173,4 +190,8 @@ public:
|
||||||
afx_msg void OnTreeDelitem();
|
afx_msg void OnTreeDelitem();
|
||||||
afx_msg void OnBnClickedButtonExport();
|
afx_msg void OnBnClickedButtonExport();
|
||||||
afx_msg void OnTreeModifyallfield();
|
afx_msg void OnTreeModifyallfield();
|
||||||
|
afx_msg void OnSortName();
|
||||||
|
afx_msg void OnSortTitle();
|
||||||
|
afx_msg void OnSortGroup();
|
||||||
|
afx_msg void OnSortPosition();
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue