Commit a2ad4ba3 authored by limingzhe's avatar limingzhe

fix: 符号修正

parent 0ed45c26
...@@ -1129,6 +1129,7 @@ cc.Class({ ...@@ -1129,6 +1129,7 @@ cc.Class({
// case "4": // case "4":
// // 符号 // // 符号
// this.curCheckGroup = this.CHECK_TYPE_SIGN; // this.curCheckGroup = this.CHECK_TYPE_SIGN;
// this.signRegions = signRegions ;
// this.initItemCombineGroup(); // this.initItemCombineGroup();
// break; // break;
...@@ -1231,6 +1232,7 @@ cc.Class({ ...@@ -1231,6 +1232,7 @@ cc.Class({
case "4": case "4":
// 符号 // 符号
para.sign_regions = signRegions; para.sign_regions = signRegions;
this.signRegions = signRegions;
this.curCheckGroup = this.CHECK_TYPE_SIGN; this.curCheckGroup = this.CHECK_TYPE_SIGN;
this.initItemCombineGroup(); this.initItemCombineGroup();
break; break;
...@@ -2191,10 +2193,20 @@ cc.Class({ ...@@ -2191,10 +2193,20 @@ cc.Class({
return; return;
} }
const symbol = textArr[0]?.symbol let symbol = textArr[0]?.symbol
if (!symbol) { if (!symbol) {
return; return;
} }
const poly = textArr[0]?.poly
if (poly) {
symbol = this.resetSymbolData(symbol, poly);
}
if (symbol.length != this.signRegions.length) {
// 正常经过处理不会出现这种情况 没poly可能会出现这种情况
return;
}
// return // return
const answerData = {}; const answerData = {};
...@@ -2205,8 +2217,8 @@ cc.Class({ ...@@ -2205,8 +2217,8 @@ cc.Class({
const signDebugItem = this.signRectCheckArr[i]; const signDebugItem = this.signRectCheckArr[i];
const dropDownItem = signDebugItem.data.dropDownItem; const dropDownItem = signDebugItem.data.dropDownItem;
if (!symbol[i]) { if (symbol[i] == -1) {
break; continue;
} }
const curSignKey = symbol[i].toString(); const curSignKey = symbol[i].toString();
...@@ -2263,6 +2275,67 @@ cc.Class({ ...@@ -2263,6 +2275,67 @@ cc.Class({
// this.showCircleAnswer(answerData); // this.showCircleAnswer(answerData);
},
resetSymbolData(symbol, poly) {
if (symbol.length == this.signRegions.length) {
return symbol;
}
if (!this.signRegionRectArr) {
this.signRegionRectArr = [];
for (let i=0; i<this.signRegions.length; i++) {
const oneRegin = this.signRegions[i];
const reginRect = new cc.Rect();
reginRect.x = oneRegin.left;
reginRect.y = oneRegin.bottom;
reginRect.width = oneRegin.right - oneRegin.left;
reginRect.height = oneRegin.bottom - oneRegin.top;
this.signRegionRectArr.push(reginRect);
}
}
let signRegionRectArr = this.signRegionRectArr
const newSymbol = [];
for (let j=0; j<signRegionRectArr.length; j++) {
const reginRect = signRegionRectArr[j];
newSymbol[i] = -1;
for(let i=0; i<poly.length; i++) {
const oneSymbol = symbol[i];
const onePoly = poly[i];
const polyRect = new cc.Rect();
polyRect.x = onePoly.left;
polyRect.y = onePoly.bottom;
polyRect.width = onePoly.right - onePoly.left;
polyRect.height = onePoly.bottom - onePoly.top;
if (reginRect.intersects(polyRect)) {
newSymbol[i] = oneSymbol
break;
}
}
}
console.log('newSymbol: ' + JSON.stringify(newSymbol));
return newSymbol;
}, },
showSignAnswer(answerData) { showSignAnswer(answerData) {
...@@ -2299,6 +2372,7 @@ cc.Class({ ...@@ -2299,6 +2372,7 @@ cc.Class({
} }
}, },
showSign(node, isRight = true) { showSign(node, isRight = true) {
...@@ -5261,7 +5335,7 @@ cc.Class({ ...@@ -5261,7 +5335,7 @@ cc.Class({
getPhotoData(cb) { getPhotoData(cb) {
cb ({"result":{"text":[{"left":0.7829999923706055,"right":0.8629999756813049,"top":0.23106646537780762,"bottom":0.2905718684196472,"score":1,"content":"3","characters":[{"character":"3","centerLoc":[0.82299995,0.26081917],"poly":[0.783,0.23106647,0.863,0.29057187]}]},{"left":0.574999988079071,"right":0.6470000147819519,"top":0.23724883794784546,"bottom":0.2905718684196472,"score":1,"content":"1","characters":[{"character":"1","centerLoc":[0.611,0.26391035],"poly":[0.575,0.23724884,0.647,0.29057187]}]},{"left":0.35899999737739563,"right":0.43700000643730164,"top":0.23724883794784546,"bottom":0.2982998490333557,"score":1,"content":"4","characters":[{"character":"4","centerLoc":[0.398,0.26777434],"poly":[0.359,0.23724884,0.437,0.29829985]}]},{"left":0.14499999582767487,"right":0.2199999988079071,"top":0.24188563227653503,"bottom":0.299845427274704,"score":1,"content":"2","characters":[{"character":"2","centerLoc":[0.1825,0.27086553],"poly":[0.145,0.24188563,0.22,0.29984543]}]}]}}) cb ({"result":{"text":[{"symbol":[4,2,4,0,2,4],"poly":[{"left":0.2070000022649765,"right":0.27000001072883606,"top":0.2789798974990845,"bottom":0.3338485360145569},{"left":0.4860000014305115,"right":0.5490000247955322,"top":0.2751159071922302,"bottom":0.3338485062122345},{"left":0.7710000276565552,"right":0.8360000252723694,"top":0.27588871121406555,"bottom":0.3338485360145569},{"left":0.2070000022649765,"right":0.27000001072883606,"top":0.4459041655063629,"bottom":0.5038639903068542},{"left":0.4860000014305115,"right":0.550000011920929,"top":0.4459041655063629,"bottom":0.5054095983505249},{"left":0.7689999938011169,"right":0.8370000123977661,"top":0.442812979221344,"bottom":0.5046367645263672}]}]}})
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment