diff --git a/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.cpp b/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.cpp index 03fd19f..84b51d3 100644 --- a/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.cpp +++ b/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.cpp @@ -7,7 +7,7 @@ // 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 montage , std::function< img_one_paper* (img_one_paper*)> 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_) montage_ = cis_montager; @@ -143,6 +143,12 @@ void cis_pre_do::init_value(void) is_montage_ = true; 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 (!child->get_value("cur", is_split_)) @@ -280,11 +286,14 @@ img_one_paper* cis_pre_do::execute(img_one_paper* img) img = mont; } - for(auto& v: img->images_queue()) + if(reinstate_) { - 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; + for(auto& v: img->images_queue()) + { + 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_) diff --git a/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.h b/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.h index 6d28b68..c0f6a3d 100644 --- a/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.h +++ b/device/gxx-linux/usb/src/async_model/img_process/cis_preproc.h @@ -28,13 +28,30 @@ class gb_json; // "cur": 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": { // "cat": "CIS", // "group": "CIS", // "title": "拆分正反面", // "desc": "将正反面合成的一张图片拆分成正面和反面图片", // "ver": 1, -// "pos": 20, +// "pos": 30, // "type": "bool", // "unit": "none", // "affect": 2, @@ -51,7 +68,7 @@ class gb_json; // "title": "页面", // "desc": "获取纸张指定面的图片", // "ver": 1, -// "pos": 30, +// "pos": 40, // "type": "string", // "unit": "none", // "affect": 2, @@ -71,6 +88,8 @@ class cis_pre_do : public sane_cfg_provider std::string cfg_; bool is_montage_; bool is_split_; + bool reinstate_; + enum { PAGE_FRONT = 0, diff --git a/pc/code_twain/sln/hgjson/DlgOptJson.cpp b/pc/code_twain/sln/hgjson/DlgOptJson.cpp index dbfc36a..ea01603 100644 --- a/pc/code_twain/sln/hgjson/DlgOptJson.cpp +++ b/pc/code_twain/sln/hgjson/DlgOptJson.cpp @@ -110,8 +110,8 @@ known_file_util::IJsonW* CDlgOptJson::SANEOPT::to_json(void) if (type == L"bool") { - jsn->set_value(L"cur", wcscmp((wchar_t*)def_val.c_str(), L"true") == 0); - jsn->set_value(L"default", 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", *(bool*)def_val.c_str()); } else if (type == L"int") { @@ -259,12 +259,10 @@ bool CDlgOptJson::SANEOPT::from_json(known_file_util::IJsonW* jsn) if (type == L"bool") { bool v = false; - std::wstring sv(L""); if (!jsn->get_value(L"default", v)) jsn->get_value(L"cur", v); - sv = v ? L"true" : L"false"; - def_val = std::string((char*)&sv[0], sv.length() * 2 + 2); + def_val = std::string((char*)&v, sizeof(v)); } else if(type == L"int") { @@ -586,7 +584,7 @@ void CDlgOptJson::to_ui(const SANEOPT& sop) def_val_.ResetContent(); def_val_.AddString(L"false"); 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") { @@ -884,6 +882,10 @@ BEGIN_MESSAGE_MAP(CDlgOptJson, CDialogEx) ON_COMMAND(ID_TREE_DELITEM, &CDlgOptJson::OnTreeDelitem) ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CDlgOptJson::OnBnClickedButtonExport) 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() @@ -1680,3 +1682,87 @@ void CDlgOptJson::OnTreeModifyallfield() } } } + + +void CDlgOptJson::OnSortName() +{ + // TODO: ڴ + HTREEITEM sel = tree_.GetSelectedItem(); + std::wstring name(L""); + std::vector 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 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 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 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); +} diff --git a/pc/code_twain/sln/hgjson/DlgOptJson.h b/pc/code_twain/sln/hgjson/DlgOptJson.h index 7c30b66..422c6ab 100644 --- a/pc/code_twain/sln/hgjson/DlgOptJson.h +++ b/pc/code_twain/sln/hgjson/DlgOptJson.h @@ -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); bool from_json(known_file_util::IJsonW* jsn); }SANEOPT; @@ -173,4 +190,8 @@ public: afx_msg void OnTreeDelitem(); afx_msg void OnBnClickedButtonExport(); afx_msg void OnTreeModifyallfield(); + afx_msg void OnSortName(); + afx_msg void OnSortTitle(); + afx_msg void OnSortGroup(); + afx_msg void OnSortPosition(); }; diff --git a/pc/code_twain/sln/hgjson/hgjson.rc b/pc/code_twain/sln/hgjson/hgjson.rc index 6a00bf7..d24c344 100644 Binary files a/pc/code_twain/sln/hgjson/hgjson.rc and b/pc/code_twain/sln/hgjson/hgjson.rc differ diff --git a/pc/code_twain/sln/hgjson/resource.h b/pc/code_twain/sln/hgjson/resource.h index f18620e..6aa6be0 100644 Binary files a/pc/code_twain/sln/hgjson/resource.h and b/pc/code_twain/sln/hgjson/resource.h differ diff --git a/pc/code_twain/sln/usb_tools/Debug/hgjson.exe b/pc/code_twain/sln/usb_tools/Debug/hgjson.exe index a49be12..b21f70d 100644 Binary files a/pc/code_twain/sln/usb_tools/Debug/hgjson.exe and b/pc/code_twain/sln/usb_tools/Debug/hgjson.exe differ