Skip to content

Annotation UILayer and Tooltips#1004

Merged
BryonLewis merged 16 commits into
mainfrom
client/ui-layer-tooltip
Nov 4, 2021
Merged

Annotation UILayer and Tooltips#1004
BryonLewis merged 16 commits into
mainfrom
client/ui-layer-tooltip

Conversation

@BryonLewis
Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis commented Oct 20, 2021

resolves #1000

  • Moved TextLayer.ts inside of AnnotationLayers folder. I believe it belongs there because that text is directly related to the annotations.
  • Created UILayers folder and UILayer.ts class which currently allows for the generation of GeoJS DOMWidgets. The widgets are added with a key name and will allow for multiple DOMWidgets to be bound to a single UI Layer in case we add more items in the future. This where there we would include z-ordering and some other functions that related to DOMWidgets and the layer if they are needed.
  • Added the necessary items to include a 'tooltip' icon in the visibile modes, this includes modifying EditorMenu.vue and layers type definition for VisibleAnnotationTypes
  • rectangleLayer.ts was modified to include mouseover and mouseoff events. I didn't want these on all the time doing pointSearch if it wasn't necessary, so I connected them to a toggle so the events could be added and removed as the user changes them in the VisbleModesRef in LayerManager.vue. if the rectangleLayer.hoverOn is true it will emit signals when the user enters or leaves an annotation. These are computed into a list and fed into the ToolTipWidget for displaying. The position of the tool tip is relative to the enter or exit area. I didn't want to constantly move the item in the DOM.
  • ToolTipWidget.vue was created to represent the tooltip. It requires the typeStyling color function, stateStyles, selectedTrackIdRef and a reactive list of the [typeName, confidence, trackID] that are to be displayed. It takes these data and creates a simple v-card to display it.

Stuff I'm not happy with and open to suggestions:

  • If the main logic should reside in LayerManager.vue?
  • If there is a better way than using refs and .value inside of the Vue component. Would reactive be better?
  • Alternative tooltip icons?
  • Since I don't import the vuetify plugin settings I need to specify dark within the component. Maybe I should just make a rounded div with css instead of relying on v-card.

@BryonLewis BryonLewis force-pushed the client/ui-layer-tooltip branch from 318090b to 51188da Compare October 27, 2021 19:53
@BryonLewis BryonLewis marked this pull request as ready for review October 28, 2021 11:31
@subdavis
Copy link
Copy Markdown
Contributor

subdavis commented Nov 2, 2021

Reviewing now. Should this also work for polygons when rectangles are turned off?

@BryonLewis
Copy link
Copy Markdown
Collaborator Author

Reviewing now. Should this also work for polygons when rectangles are turned off?

Nope that's an oversight on my part. That's probably something I should add in.

Comment thread client/src/components/LayerManager.vue Outdated
.search([frame, frame])
.map((str: string) => parseInt(str, 10));

rectAnnotationLayer.setHoverAnnotations(visibleModesRef.value.includes('tooltip'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't access visibleModesRef here, visibleModes is already dereferenced as a parameter to this function.

Copy link
Copy Markdown
Contributor

@subdavis subdavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More thorough review this time.

Comment thread client/src/layers/AnnotationLayers/PolygonLayer.ts
import {
defineComponent, PropType, Ref,
} from '@vue/composition-api';
import { StateStyles } from 'vue-media-annotator/use/useStyling';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use relative imports. Cannot use aliases here.

Comment thread client/src/layers/UILayers/UILayer.ts Outdated
@@ -0,0 +1,46 @@
import { createApp } from '@vue/composition-api';
import { MediaController } from 'vue-media-annotator/components/annotators/mediaControllerType';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a relative import. In the published lib, this alias doesn't exist.

Comment on lines +22 to +25
dataList: {
type: Object as PropType<Ref<[string, number, number][]>>,
default: () => [],
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a descriptive tuple. Could it be an object instead? { x, y, type } or something like that?

If you don't want to change it, can you document what it is here?

default: () => [],
},
selected: {
type: Object as PropType<Ref<number|null>>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropType<Ref<...>> is a bit of a hack. Props shouldn't be refs, they should be normal values.

I understand that because this component is being mounted as the root of the application, there's no parent to drive changes in its props, but it took me a little bit of code reading to figure that out.

Could the UILayer class have a description comment block to describe this design choice, how it works, and what the special requirements of its widget components are?

Comment thread client/src/layers/UILayers/UILayer.ts Outdated
Comment on lines +34 to +39
const element = parent.appendChild(div);
let id = element.getAttribute('id');
if (id === null) {
id = 'default_name';
element.setAttribute('id', id);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this block. Why are you checking to see if a DOM element you just created has an attribute you didn't set? Won't id always be null?

Comment thread client/src/layers/UILayers/UILayer.ts Outdated
element.setAttribute('id', id);
}
const elementId = id;
createApp(component, props).mount(`#${elementId}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, why do we need to give the new element an ID at all? Mount takes an element or a selector, so you can just pass it element directly.

https://vuejs.org/v2/api/#vm-mount

@subdavis subdavis self-requested a review November 4, 2021 16:38
Copy link
Copy Markdown
Contributor

@subdavis subdavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled and tested again. Thanks for these revisions.

@BryonLewis BryonLewis merged commit 3b9e288 into main Nov 4, 2021
@BryonLewis BryonLewis deleted the client/ui-layer-tooltip branch November 4, 2021 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do "collision detection" on activity labels

2 participants