Added dialog window with some help info about filters

main
Boris Sekachev 6 years ago
parent 9c443db5a1
commit a7f02df7d0

@ -441,7 +441,7 @@
* Returns the ranges of cached frames * Returns the ranges of cached frames
* @method ranges * @method ranges
* @memberof Session.frames * @memberof Session.frames
* @returns {Array{string}} * @returns {Array.<string[]>}
* @instance * @instance
* @async * @async
*/ */
@ -520,7 +520,8 @@
* @returns {HistoryActions} * @returns {HistoryActions}
* @throws {module:API.cvat.exceptions.PluginError} * @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError} * @throws {module:API.cvat.exceptions.ArgumentError}
* @returns {[string, number][]} array of pairs [action name, frame number] * @returns {Array.<Array.<string|number>>}
* array of pairs [action name, frame number]
* @instance * @instance
* @async * @async
*/ */

@ -2,9 +2,14 @@
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import React from 'react'; import React, { useState } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Select, { SelectValue, LabeledValue } from 'antd/lib/select'; import Select, { SelectValue, LabeledValue } from 'antd/lib/select';
import Title from 'antd/lib/typography/Title';
import Text from 'antd/lib/typography/Text';
import Paragraph from 'antd/lib/typography/Paragraph';
import Tooltip from 'antd/lib/tooltip';
import Modal from 'antd/lib/modal';
import Icon from 'antd/lib/icon'; import Icon from 'antd/lib/icon';
import { import {
@ -16,6 +21,8 @@ import { CombinedState } from 'reducers/interfaces';
interface StateToProps { interface StateToProps {
annotationsFilters: string[]; annotationsFilters: string[];
annotationsFiltersHistory: string[]; annotationsFiltersHistory: string[];
searchForwardShortcut: string;
searchBackwardShortcut: string;
} }
interface DispatchToProps { interface DispatchToProps {
@ -30,11 +37,16 @@ function mapStateToProps(state: CombinedState): StateToProps {
filtersHistory: annotationsFiltersHistory, filtersHistory: annotationsFiltersHistory,
}, },
}, },
shortcuts: {
normalizedKeyMap,
},
} = state; } = state;
return { return {
annotationsFilters, annotationsFilters,
annotationsFiltersHistory, annotationsFiltersHistory,
searchForwardShortcut: normalizedKeyMap.SEARCH_FORWARD,
searchBackwardShortcut: normalizedKeyMap.SEARCH_BACKWARD,
}; };
} }
@ -56,13 +68,74 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {
}; };
} }
function filtersHelpModalContent(
searchForwardShortcut: string,
searchBackwardShortcut: string,
): JSX.Element {
return (
<>
<Paragraph>
<Title level={3}>General</Title>
</Paragraph>
<Paragraph>
You can use filters to display only subset of objects on a frame
or to search objects that satisfy the filters using hotkeys
<Text strong>
{` ${searchForwardShortcut} `}
</Text>
and
<Text strong>
{` ${searchBackwardShortcut} `}
</Text>
</Paragraph>
<Paragraph>
<Text strong>Supported properties: </Text>
width, height, label, serverID, clientID, type, shape, occluded
<br />
<Text strong>Supported operators: </Text>
==, !=, &gt;, &gt;=, &lt;, &lt;=, ~=, (), &amp; and |
<br />
<Text strong>
If you have double quotes in your query string,
please escape them using back slash: \&quot; (see the latest example)
</Text>
<br />
All properties and values are case-sensitive.
CVAT uses json queries to perform search.
</Paragraph>
<Paragraph>
<Title level={3}>Examples</Title>
<ul>
<li>label==&quot;car&quot; | label==[&quot;road sign&quot;]</li>
<li>width &gt;= height</li>
<li>attr[&quot;Attribute 1&quot;] == attr[&quot;Attribute 2&quot;]</li>
<li>clientID == 50</li>
<li>
(label==&quot;car&quot; &amp; attr[&quot;parked&quot;]==true)
| (label==&quot;pedestrian&quot; &amp; width &gt; 150)
</li>
<li>
(( label==[&quot;car \&quot;mazda\&quot;&quot;])
&amp; (attr[&quot;sunglasses&quot;]==true
| (width &gt; 150 | height &gt; 150 &amp; (clientID == serverID)))))
</li>
</ul>
</Paragraph>
</>
);
}
function AnnotationsFiltersInput(props: StateToProps & DispatchToProps): JSX.Element { function AnnotationsFiltersInput(props: StateToProps & DispatchToProps): JSX.Element {
const { const {
annotationsFilters, annotationsFilters,
annotationsFiltersHistory, annotationsFiltersHistory,
searchForwardShortcut,
searchBackwardShortcut,
changeAnnotationsFilters, changeAnnotationsFilters,
} = props; } = props;
const [underCursor, setUnderCursor] = useState(false);
return ( return (
<Select <Select
className='cvat-annotations-filters-input' className='cvat-annotations-filters-input'
@ -70,13 +143,36 @@ function AnnotationsFiltersInput(props: StateToProps & DispatchToProps): JSX.Ele
value={annotationsFilters} value={annotationsFilters}
mode='tags' mode='tags'
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder={( placeholder={
<> underCursor ? (
<Icon type='filter' /> <>
<span style={{ marginLeft: 5 }}>Annotations filter</span> <Tooltip title='Click to open help'>
</> <Icon
)} type='filter'
onClick={(e: React.MouseEvent) => {
e.stopPropagation();
Modal.info({
width: 700,
title: 'How to use filters?',
content: filtersHelpModalContent(
searchForwardShortcut,
searchBackwardShortcut,
),
});
}}
/>
</Tooltip>
</>
) : (
<>
<Icon style={{ transform: 'scale(0.9)' }} type='filter' />
<span style={{ marginLeft: 5 }}>Annotations filters</span>
</>
)
}
onChange={changeAnnotationsFilters} onChange={changeAnnotationsFilters}
onMouseEnter={() => setUnderCursor(true)}
onMouseLeave={() => setUnderCursor(false)}
> >
{annotationsFiltersHistory.map((element: string): JSX.Element => ( {annotationsFiltersHistory.map((element: string): JSX.Element => (
<Select.Option key={element} value={element}>{element}</Select.Option> <Select.Option key={element} value={element}>{element}</Select.Option>

Loading…
Cancel
Save