React UI: ZOrder implementation (#1176)
* Drawn z-order switcher * Z layer was added to state * Added ZLayer API method cvat-canvas * Added sorting by Z * Displaying points in top * Removed old code * Improved sort function * Drawn a couple of icons * Send to foreground / send to background * Updated unit tests * Added unit tests for filter parser * Removed extra code * Updated README.mdmain
parent
f329e14fe4
commit
9850094773
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* global
|
||||
require:false
|
||||
jest:false
|
||||
describe:false
|
||||
*/
|
||||
|
||||
// Setup mock for a server
|
||||
jest.mock('../../src/server-proxy', () => {
|
||||
const mock = require('../mocks/server-proxy.mock');
|
||||
return mock;
|
||||
});
|
||||
|
||||
const AnnotationsFilter = require('../../src/annotations-filter');
|
||||
// Initialize api
|
||||
window.cvat = require('../../src/api');
|
||||
|
||||
// Test cases
|
||||
describe('Feature: toJSONQuery', () => {
|
||||
test('convert filters to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [groups, query] = annotationsFilter.toJSONQuery([]);
|
||||
expect(Array.isArray(groups)).toBeTruthy();
|
||||
expect(typeof (query)).toBe('string');
|
||||
});
|
||||
|
||||
test('convert empty fitlers to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [, query] = annotationsFilter.toJSONQuery([]);
|
||||
expect(query).toBe('$.objects[*].clientID');
|
||||
});
|
||||
|
||||
test('convert wrong fitlers (empty string) to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
expect(() => {
|
||||
annotationsFilter.toJSONQuery(['']);
|
||||
}).toThrow(window.cvat.exceptions.ArgumentError);
|
||||
});
|
||||
|
||||
test('convert wrong fitlers (wrong number argument) to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
expect(() => {
|
||||
annotationsFilter.toJSONQuery(1);
|
||||
}).toThrow(window.cvat.exceptions.ArgumentError);
|
||||
});
|
||||
|
||||
test('convert wrong fitlers (wrong array argument) to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
expect(() => {
|
||||
annotationsFilter.toJSONQuery(['clientID ==6', 1]);
|
||||
}).toThrow(window.cvat.exceptions.ArgumentError);
|
||||
});
|
||||
|
||||
test('convert wrong filters (wrong expression) to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
expect(() => {
|
||||
annotationsFilter.toJSONQuery(['clientID=5']);
|
||||
}).toThrow(window.cvat.exceptions.ArgumentError);
|
||||
});
|
||||
|
||||
test('convert filters to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [groups, query] = annotationsFilter
|
||||
.toJSONQuery(['clientID==5 & shape=="rectangle" & label==["car"]']);
|
||||
expect(groups).toEqual([
|
||||
['clientID==5', '&', 'shape=="rectangle"', '&', 'label==["car"]'],
|
||||
]);
|
||||
expect(query).toBe('$.objects[?((@.clientID==5&@.shape=="rectangle"&@.label==["car"]))].clientID');
|
||||
});
|
||||
|
||||
test('convert filters to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [groups, query] = annotationsFilter
|
||||
.toJSONQuery(['label=="car" | width >= height & type=="track"']);
|
||||
expect(groups).toEqual([
|
||||
['label=="car"', '|', 'width >= height', '&', 'type=="track"'],
|
||||
]);
|
||||
expect(query).toBe('$.objects[?((@.label=="car"|@.width>=@.height&@.type=="track"))].clientID');
|
||||
});
|
||||
|
||||
test('convert filters to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [groups, query] = annotationsFilter
|
||||
.toJSONQuery(['label=="person" & attr["Attribute 1"] ==attr["Attribute 2"]']);
|
||||
expect(groups).toEqual([
|
||||
['label=="person"', '&', 'attr["Attribute 1"] ==attr["Attribute 2"]'],
|
||||
]);
|
||||
expect(query).toBe('$.objects[?((@.label=="person"&@.attr["Attribute 1"]==@.attr["Attribute 2"]))].clientID');
|
||||
});
|
||||
|
||||
test('convert filters to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [groups, query] = annotationsFilter
|
||||
.toJSONQuery(['label=="car" & attr["parked"]==true', 'label=="pedestrian" & width > 150']);
|
||||
expect(groups).toEqual([
|
||||
['label=="car"', '&', 'attr["parked"]==true'],
|
||||
'|',
|
||||
['label=="pedestrian"', '&', 'width > 150'],
|
||||
]);
|
||||
expect(query).toBe('$.objects[?((@.label=="car"&@.attr["parked"]==true)|(@.label=="pedestrian"&@.width>150))].clientID');
|
||||
});
|
||||
|
||||
test('convert filters to a json query', () => {
|
||||
const annotationsFilter = new AnnotationsFilter();
|
||||
const [groups, query] = annotationsFilter
|
||||
.toJSONQuery(['(( label==["car \\"mazda\\""]) & (attr["sunglass ( help ) es"]==true | (width > 150 | height > 150 & (clientID == serverID))))) ']);
|
||||
expect(groups).toEqual([[[
|
||||
['label==["car `mazda`"]'],
|
||||
'&',
|
||||
['attr["sunglass ( help ) es"]==true', '|',
|
||||
['width > 150', '|', 'height > 150', '&',
|
||||
[
|
||||
'clientID == serverID',
|
||||
],
|
||||
],
|
||||
],
|
||||
]]]);
|
||||
expect(query).toBe('$.objects[?((((@.label==["car `mazda`"])&(@.attr["sunglass ( help ) es"]==true|(@.width>150|@.height>150&(@.clientID==serverID))))))].clientID');
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
Copyright (C) 2020 Intel Corporation
|
||||
SPDX-License-Identifier: MIT
|
||||
-->
|
||||
|
||||
<svg height="1em" width="1em" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect rx="12" height="166" width="167" y="25" x="25" stroke-width="15" stroke="#000" fill="none" stroke-dasharray="35" />
|
||||
<rect rx="12" height="166" width="167" y="70" x="70" stroke-width="15" stroke="#000" fill="none" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 434 B |
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
Copyright (C) 2020 Intel Corporation
|
||||
SPDX-License-Identifier: MIT
|
||||
-->
|
||||
|
||||
<svg height="1em" width="1em" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect rx="12" height="166" width="167" y="25" x="25" stroke-width="15" stroke="#000" fill="none" />
|
||||
<rect rx="12" height="166" width="167" y="70" x="70" stroke-width="15" stroke="#000" fill="none" stroke-dasharray="35" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 434 B |
Loading…
Reference in New Issue