Skip to content

Commit

Permalink
Merge pull request #313 from OCR4all/fix/simplifyWithActions
Browse files Browse the repository at this point in the history
version/0.7.2
  • Loading branch information
maxnth authored Mar 31, 2022
2 parents 9751cef + 577b5c5 commit 1dce929
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.uniwue</groupId>
<artifactId>Larex</artifactId>
<version>0.7.1</version>
<version>0.7.2</version>
<packaging>war</packaging>

<name>Larex</name>
Expand Down
17 changes: 13 additions & 4 deletions src/main/webapp/resources/js/viewer/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,8 @@ function Controller(bookID, accessible_modes, canvasID, regionColors, colors, gl

if(selected.length > 0 && (selectType === ElementType.SEGMENT || selectType === ElementType.TEXTLINE)){
const segments = [];
const actions = [];

for (let i = 0, selectedlength = selected.length; i < selectedlength; i++) {
let segment = null;
if (selectType === ElementType.SEGMENT) {
Expand All @@ -1209,12 +1211,15 @@ function Controller(bookID, accessible_modes, canvasID, regionColors, colors, gl
const simplified = data;
if(Array.isArray(simplified) && simplified.length > 0){
for (let i = 0, simplifiedLength = simplified.length; i < simplifiedLength; i++) {
let simp_id = simplified[i].id;
let simp_coords = simplified[i].coords;
let id = simplified[i].id;
let coords = simplified[i].coords;
if(_mode === Mode.SEGMENT) {
_segmentation[_currentPage].segments[simp_id].coords = simp_coords;
actions.push(new ActionTransformSegment(id, coords.points, _editor,
_segmentation, _currentPage, this));
console.log("Action pushed");
} else if(_mode === Mode.LINES) {
_segmentation[_currentPage].segments[this.textlineRegister[simp_id]].textlines[simp_id].coords = simp_coords;
actions.push(new ActionTransformTextLine(id, coords.points, _editor,
_textViewer, _segmentation, _currentPage, this));
} else {
console.log("MODE was unspecified. Doing Nothing");
}
Expand All @@ -1223,6 +1228,10 @@ function Controller(bookID, accessible_modes, canvasID, regionColors, colors, gl
} else {
_gui.displayWarning("Simplification of segments returned no segments.");
}
if(actions){
let simplificationAction = new ActionMultiple(actions);
_actionController.addAndExecuteAction(simplificationAction, _currentPage);
}
});
}
}
Expand Down

0 comments on commit 1dce929

Please sign in to comment.