Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eScriptorium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scripta
eScriptorium
Commits
2ceb9c74
Commit
2ceb9c74
authored
4 years ago
by
Robin Tissot
Browse files
Options
Downloads
Patches
Plain Diff
Adds a new mode for line visualisation.
parent
9c12f16c
No related branches found
No related tags found
1 merge request
!51
Adds a new mode for line visualisation.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/escriptorium/static/js/baseline.editor.js
+75
-12
75 additions, 12 deletions
app/escriptorium/static/js/baseline.editor.js
app/escriptorium/templates/core/document_part_edit.html
+2
-2
2 additions, 2 deletions
app/escriptorium/templates/core/document_part_edit.html
with
77 additions
and
14 deletions
app/escriptorium/static/js/baseline.editor.js
+
75
−
12
View file @
2ceb9c74
/*
/*
Baseline editor
Baseline editor
a javascript based baseline segmentation editor,
a javascript based baseline segmentation editor,
requires paper.js
and colorThief is optional
.
requires paper.js.
Usage:
Usage:
var segmenter = new Segmenter(img, options);
var segmenter = new Segmenter(img, options);
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
deletePointBtn=null,
deletePointBtn=null,
deleteSelectionBtn=null,
deleteSelectionBtn=null,
toggleMasksBtn=null,
toggleMasksBtn=null,
toggleLineModeBtn=null,
splitBtn=null,
splitBtn=null,
mergeBtn=null,
mergeBtn=null,
...
@@ -155,7 +156,7 @@ class SegmenterLine {
...
@@ -155,7 +156,7 @@ class SegmenterLine {
this
.
baseline
=
baseline
.
map
(
pt
=>
[
Math
.
round
(
pt
[
0
]),
Math
.
round
(
pt
[
1
])]);
this
.
baseline
=
baseline
.
map
(
pt
=>
[
Math
.
round
(
pt
[
0
]),
Math
.
round
(
pt
[
1
])]);
this
.
baselinePath
=
new
Path
({
this
.
baselinePath
=
new
Path
({
strokeColor
:
this
.
segmenter
.
baselinesColor
,
strokeColor
:
this
.
segmenter
.
baselinesColor
,
strokeWidth
:
5
/
this
.
segmenter
.
getRatio
(),
//
strokeWidth: 5/this.segmenter.getRatio(),
strokeCap
:
'
butt
'
,
strokeCap
:
'
butt
'
,
selectedColor
:
'
black
'
,
selectedColor
:
'
black
'
,
opacity
:
0.5
,
opacity
:
0.5
,
...
@@ -187,9 +188,20 @@ class SegmenterLine {
...
@@ -187,9 +188,20 @@ class SegmenterLine {
this
.
showOrdering
();
this
.
showOrdering
();
this
.
showDirection
();
this
.
showDirection
();
if
(
this
.
baselinePath
)
{
if
(
this
.
baselinePath
)
{
this
.
baselinePath
.
strokeWidth
=
5
/
this
.
segmenter
.
getRatio
();
if
(
this
.
segmenter
.
wideLineStrokes
)
{
this
.
baselinePath
.
strokeWidth
=
5
/
this
.
segmenter
.
getRatio
();
}
else
{
this
.
baselinePath
.
strokeWidth
=
1
;
}
}
if
(
this
.
directionHint
)
{
if
(
this
.
segmenter
.
showDirectionHint
)
{
this
.
directionHint
.
visible
=
true
;
this
.
directionHint
.
strokeColor
=
this
.
hintColor
;
}
else
{
this
.
directionHint
.
visible
=
false
;
}
}
}
if
(
this
.
directionHint
)
this
.
directionHint
.
strokeColor
=
this
.
hintColor
;
}
}
getMaskColor
()
{
getMaskColor
()
{
...
@@ -471,6 +483,7 @@ class Segmenter {
...
@@ -471,6 +483,7 @@ class Segmenter {
regionTypes
=
[
'
Title
'
,
'
Main
'
,
'
Marginal
'
,
'
Illustration
'
,
'
Numbering
'
],
regionTypes
=
[
'
Title
'
,
'
Main
'
,
'
Marginal
'
,
'
Illustration
'
,
'
Numbering
'
],
lineTypes
=
[
'
Main
'
,
'
Interlinear
'
],
lineTypes
=
[
'
Main
'
,
'
Interlinear
'
],
wideLineStrokes
=
true
,
// todo: choose keyboard shortcuts
// todo: choose keyboard shortcuts
inactiveLayerOpacity
=
0.5
,
inactiveLayerOpacity
=
0.5
,
...
@@ -527,6 +540,8 @@ class Segmenter {
...
@@ -527,6 +540,8 @@ class Segmenter {
this
.
regionAreaThreshold
=
regionAreaThreshold
;
this
.
regionAreaThreshold
=
regionAreaThreshold
;
this
.
showMasks
=
false
;
this
.
showMasks
=
false
;
this
.
showLineNumbers
=
false
;
this
.
showLineNumbers
=
false
;
this
.
showDirectionHint
=
true
;
this
.
wideLineStrokes
=
wideLineStrokes
;
this
.
selecting
=
null
;
this
.
selecting
=
null
;
this
.
spliting
=
false
;
this
.
spliting
=
false
;
...
@@ -534,6 +549,7 @@ class Segmenter {
...
@@ -534,6 +549,7 @@ class Segmenter {
// menu btns
// menu btns
this
.
toggleMasksBtn
=
document
.
getElementById
(
'
be-toggle-masks
'
);
this
.
toggleMasksBtn
=
document
.
getElementById
(
'
be-toggle-masks
'
);
this
.
toggleLineModeBtn
=
document
.
getElementById
(
'
be-toggle-line-mode
'
);
this
.
toggleOrderingBtn
=
document
.
getElementById
(
'
be-toggle-order
'
);
this
.
toggleOrderingBtn
=
document
.
getElementById
(
'
be-toggle-order
'
);
this
.
toggleRegionModeBtn
=
document
.
getElementById
(
'
be-toggle-regions
'
);
this
.
toggleRegionModeBtn
=
document
.
getElementById
(
'
be-toggle-regions
'
);
this
.
splitBtn
=
document
.
getElementById
(
'
be-split-lines
'
);
this
.
splitBtn
=
document
.
getElementById
(
'
be-split-lines
'
);
...
@@ -641,6 +657,11 @@ class Segmenter {
...
@@ -641,6 +657,11 @@ class Segmenter {
this
.
toggleMasks
();
this
.
toggleMasks
();
}.
bind
(
this
));
}.
bind
(
this
));
}
}
if
(
this
.
toggleLineModeBtn
)
{
this
.
toggleLineModeBtn
.
addEventListener
(
'
click
'
,
function
(
event
)
{
this
.
toggleLineMode
();
}.
bind
(
this
));
}
if
(
this
.
splitBtn
)
this
.
splitBtn
.
addEventListener
(
'
click
'
,
function
(
event
)
{
if
(
this
.
splitBtn
)
this
.
splitBtn
.
addEventListener
(
'
click
'
,
function
(
event
)
{
this
.
spliting
=
!
this
.
spliting
;
this
.
spliting
=
!
this
.
spliting
;
...
@@ -734,7 +755,7 @@ class Segmenter {
...
@@ -734,7 +755,7 @@ class Segmenter {
}
else
if
(
event
.
keyCode
==
74
)
{
// J (for join)
}
else
if
(
event
.
keyCode
==
74
)
{
// J (for join)
this
.
mergeSelection
();
this
.
mergeSelection
();
}
else
if
(
event
.
keyCode
==
77
)
{
// M
}
else
if
(
event
.
keyCode
==
77
)
{
// M
this
.
toggle
Masks
();
this
.
toggle
LineMode
();
}
else
if
(
event
.
keyCode
==
76
)
{
// L
}
else
if
(
event
.
keyCode
==
76
)
{
// L
this
.
toggleOrdering
();
this
.
toggleOrdering
();
}
else
if
(
event
.
keyCode
==
82
)
{
// R
}
else
if
(
event
.
keyCode
==
82
)
{
// R
...
@@ -1499,14 +1520,56 @@ class Segmenter {
...
@@ -1499,14 +1520,56 @@ class Segmenter {
}
}
}
}
toggleMasks
(
force
)
{
toggleLineMode
()
{
this
.
showMasks
=
force
||
!
this
.
showMasks
;
// wide: default mode
if
(
this
.
showMasks
)
{
// mask: show the boundary of the line
this
.
toggleMasksBtn
.
classList
.
add
(
'
btn-success
'
);
// slim: set the strokeWidth at 1px
this
.
toggleMasksBtn
.
classList
.
remove
(
'
btn-info
'
);
if
(
this
.
showMasks
)
{
// mask -> slim
this
.
toggleMasks
(
false
);
this
.
toggleLineStrokes
(
false
);
this
.
toggleLineModeBtn
.
classList
.
add
(
'
btn-secondary
'
);
this
.
toggleLineModeBtn
.
classList
.
remove
(
'
btn-success
'
);
}
else
{
}
else
{
this
.
toggleMasksBtn
.
classList
.
add
(
'
btn-info
'
);
if
(
!
this
.
wideLineStrokes
)
{
// slim -> wide
this
.
toggleMasksBtn
.
classList
.
remove
(
'
btn-success
'
);
this
.
toggleMasks
(
false
);
this
.
toggleLineStrokes
(
true
);
this
.
toggleLineModeBtn
.
classList
.
add
(
'
btn-info
'
);
this
.
toggleLineModeBtn
.
classList
.
remove
(
'
btn-secondary
'
);
}
else
{
// wide -> mask
this
.
toggleMasks
(
true
);
this
.
toggleLineStrokes
(
true
);
this
.
toggleLineModeBtn
.
classList
.
add
(
'
btn-success
'
);
this
.
toggleLineModeBtn
.
classList
.
remove
(
'
btn-info
'
);
}
}
}
toggleLineStrokes
(
force
)
{
// wide / slim
if
(
force
!=
undefined
)
this
.
wideLineStrokes
=
force
;
else
this
.
wideLineStrokes
=
!
this
.
wideLineStrokes
;
this
.
showDirectionHint
=
this
.
wideLineStrokes
;
for
(
let
i
in
this
.
lines
)
{
this
.
lines
[
i
].
refresh
();
}
}
toggleMasks
(
force
)
{
if
(
force
!==
undefined
)
this
.
showMasks
=
force
;
else
this
.
showMasks
=
!
this
.
showMasks
;
if
(
this
.
toggleMasksBtn
)
{
if
(
this
.
showMasks
)
{
this
.
toggleMasksBtn
.
classList
.
add
(
'
btn-success
'
);
this
.
toggleMasksBtn
.
classList
.
remove
(
'
btn-info
'
);
}
else
{
this
.
toggleMasksBtn
.
classList
.
add
(
'
btn-info
'
);
this
.
toggleMasksBtn
.
classList
.
remove
(
'
btn-success
'
);
}
}
}
for
(
let
i
in
this
.
lines
)
{
for
(
let
i
in
this
.
lines
)
{
let
poly
=
this
.
lines
[
i
].
maskPath
;
let
poly
=
this
.
lines
[
i
].
maskPath
;
...
...
This diff is collapsed.
Click to expand it.
app/escriptorium/templates/core/document_part_edit.html
+
2
−
2
View file @
2ceb9c74
...
@@ -248,8 +248,8 @@
...
@@ -248,8 +248,8 @@
title=
"{% trans "
Toggle
ordering
display.
(
L
)"
%}"
title=
"{% trans "
Toggle
ordering
display.
(
L
)"
%}"
class=
"btn btn-sm btn-info fas fa-sort-numeric-down"
class=
"btn btn-sm btn-info fas fa-sort-numeric-down"
autocomplete=
"off"
></button>
autocomplete=
"off"
></button>
<button
id=
"be-toggle-
masks
"
<button
id=
"be-toggle-
line-mode
"
title=
"{% trans "
Show
line
masks.
(
M
)"
%}"
title=
"{% trans "
Toggle
line
masks
and
stroke
width
.
(
M
)"
%}"
class=
"btn btn-sm btn-info fas fa-mask"
></button>
class=
"btn btn-sm btn-info fas fa-mask"
></button>
</div>
</div>
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment