Skip to content

Commit 93eaaf7

Browse files
bsekachevnmanovic
authored andcommitted
Ability to change an opacity for selected shapes (#77)
* Feature has been implemented: ability to change selected opacity for shapes * Floats used in ranges
1 parent 64962ab commit 93eaaf7

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

cvat/apps/engine/static/engine/js/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ $.ajaxSetup({
216216

217217
$(document).ready(function(){
218218
$('body').css({
219-
width: window.screen.width * 0.95 + 'px',
219+
width: window.screen.width + 'px',
220220
height: window.screen.height * 0.95 + 'px'
221221
});
222222
});

cvat/apps/engine/static/engine/js/shapeCollection.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ class ShapeCollectionView {
999999
this._labelsContent = $('#labelsContent');
10001000
this._showAllInterpolationBox = $('#showAllInterBox');
10011001
this._fillOpacityRange = $('#fillOpacityRange');
1002+
this._selectedFillOpacityRange = $('#selectedFillOpacityRange');
10021003
this._blackStrokeCheckbox = $('#blackStrokeCheckbox');
10031004
this._colorByInstanceRadio = $('#colorByInstanceRadio');
10041005
this._colorByGroupRadio = $('#colorByGroupRadio');
@@ -1020,7 +1021,7 @@ class ShapeCollectionView {
10201021
let value = Math.clamp(+e.target.value, +e.target.min, +e.target.max);
10211022
e.target.value = value;
10221023
if (value >= 0) {
1023-
this._colorSettings["fill-opacity"] = value / 5;
1024+
this._colorSettings["fill-opacity"] = value;
10241025
delete this._colorSettings['white-opacity'];
10251026

10261027
for (let view of this._currentViews) {
@@ -1029,14 +1030,24 @@ class ShapeCollectionView {
10291030
}
10301031
else {
10311032
value *= -1;
1032-
this._colorSettings["white-opacity"] = value / 5;
1033+
this._colorSettings["white-opacity"] = value;
10331034

10341035
for (let view of this._currentViews) {
10351036
view.updateColorSettings(this._colorSettings);
10361037
}
10371038
}
10381039
});
10391040

1041+
this._selectedFillOpacityRange.on('input', (e) => {
1042+
let value = Math.clamp(+e.target.value, +e.target.min, +e.target.max);
1043+
e.target.value = value;
1044+
this._colorSettings["selected-fill-opacity"] = value;
1045+
1046+
for (let view of this._currentViews) {
1047+
view.updateColorSettings(this._colorSettings);
1048+
}
1049+
});
1050+
10401051
this._blackStrokeCheckbox.on('click', (e) => {
10411052
this._colorSettings["black-stroke"] = e.target.checked;
10421053

cvat/apps/engine/static/engine/js/shapeFilter.js

-8
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ class FilterModel {
7070
this._update();
7171
}
7272
}
73-
74-
get filterRow() {
75-
return this._filter;
76-
}
7773
}
7874

7975
class FilterController {
@@ -102,10 +98,6 @@ class FilterController {
10298
deactivate() {
10399
this._model.active = false;
104100
}
105-
106-
get filterRow() {
107-
return this._model.filterRow;
108-
}
109101
}
110102

111103

cvat/apps/engine/static/engine/js/shapes.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ class ShapeView extends Listener {
14001400
this._appearance = {
14011401
colors: shapeModel.color,
14021402
fillOpacity: 0,
1403-
selectedFillOpacity: 0.1,
1403+
selectedFillOpacity: 0.2,
14041404
};
14051405

14061406
this._flags = {
@@ -2645,6 +2645,10 @@ class ShapeView extends Listener {
26452645
}
26462646
}
26472647

2648+
if ('selected-fill-opacity' in settings) {
2649+
this._appearance.selectedFillOpacity = settings['selected-fill-opacity'];
2650+
}
2651+
26482652
if (settings['black-stroke']) {
26492653
this._appearance['stroke'] = 'black';
26502654
}

cvat/apps/engine/templates/engine/annotation.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,17 @@
142142
<hr>
143143
<table class="regular" cellpadding="20">
144144
<tr>
145-
<td>
145+
<td style="width: auto;">
146146
<div style="float: left;"> <label class="semiBold"> Fill Opacity: </label> </div>
147-
<div style="float: left; margin-left: 1em;"> <input type="range" min="-5" max="5" value="0" id="fillOpacityRange"/> </div>
147+
<div style="float: left; margin-left: 1em;"> <input type="range" min="-1" max="1" step="0.2" value="0" id="fillOpacityRange"/> </div>
148148
</td>
149149
<td style="width: auto;">
150-
<div style="float: left;"> <label class="semiBold"> Black Stroke: </label> </div>
151-
<div style="float: left; margin-left: 1em;"> <input type="checkbox" id="blackStrokeCheckbox" class="settingsBox"/> </div>
150+
<div style="float: left;"> <label class="semiBold"> Selected Fill Opacity: </label> </div>
151+
<div style="float: left; margin-left: 1em;"> <input type="range" min="0" max="1" value="0.2" step="0.2" id="selectedFillOpacityRange"/> </div>
152152
</td>
153153
<td style="width: auto;">
154-
154+
<div style="float: left;"> <label class="semiBold"> Black Stroke: </label> </div>
155+
<div style="float: left; margin-left: 1em;"> <input type="checkbox" id="blackStrokeCheckbox" class="settingsBox"/> </div>
155156
</td>
156157
<td style="width: auto;">
157158
<div style="float: left;"> <label class="semiBold"> Color by: </label> </div>

0 commit comments

Comments
 (0)