Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add child elements category to models tree #1206

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

JonasDov
Copy link
Contributor

@JonasDov JonasDov commented Feb 19, 2025

closes #1100
This change, allows models tree to show category nodes of child elements, when their category differs from parent node's category.

PS. Don't review yet, visibility changes are still needed

@JonasDov JonasDov requested review from a team as code owners February 19, 2025 11:22
@JonasDov JonasDov marked this pull request as draft February 19, 2025 12:16
Copy link
Member

@grigasp grigasp left a comment

Choose a reason for hiding this comment

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

P.S. Don't review yet, as filtering doesn't work.

Please add tests for filtering

@JonasDov JonasDov marked this pull request as ready for review February 20, 2025 08:46
@JonasDov
Copy link
Contributor Author

JonasDov commented Feb 20, 2025

P.S. Don't review yet, as filtering doesn't work.

Please add tests for filtering

Added one test, and modified existing test a little bit.

Copy link
Member

@grigasp grigasp left a comment

Choose a reason for hiding this comment

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

There seem to be some issues with display states.

I understand you're going to update display states handling in a separate PR, and that's fine. But the screenshots show that display states of nodes above the new category nodes have changed. I don't understand why.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should move the mouse pointer away from nodes to avoid the hover effect.

Copy link
Member

Choose a reason for hiding this comment

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

Do you know why "Tag-Category" is in partial display state?

Copy link
Member

Choose a reason for hiding this comment

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

Do you know why display state of "Tag-Category" is "off"?

Copy link
Member

Choose a reason for hiding this comment

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

Do you know why display state of "E-101 [4-1F4]" is "partial"? Also, shouldn't its class grouping node also be in partial display state?

@JonasDov
Copy link
Contributor Author

There seem to be some issues with display states.

I understand you're going to update display states handling in a separate PR, and that's fine. But the screenshots show that display states of nodes above the new category nodes have changed. I don't understand why.

Display states of above elements are different, because I've adjusted idsCache (previously it returned only categories of elements that have no parents, now it returns categories of elements that have and don't have parents).

I've decided to add display states handling in this PR, since after adding categories, display states became more confusing.

@JonasDov JonasDov marked this pull request as draft February 20, 2025 09:32
@JonasDov JonasDov marked this pull request as ready for review March 13, 2025 13:59
Copy link
Member

@grigasp grigasp left a comment

Choose a reason for hiding this comment

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

I think this needs to be reviewed from the perspective of the executed queries.

E.g. when I open http://localhost:3000/?iTwinId=892aa2c9-5be8-4865-9f37-7d4c7e75ebbf&iModelId=77d710e9-83aa-4864-9248-23dfe4bc0047, I see 73 queryRows requests. Quite a few of them take around a second. One of them takes almost 2 second and returns ids of 82k elements.

const onVisibilityChange = new BeEvent<() => void>();
let pendingVisibilityChange: undefined | ReturnType<typeof setTimeout>;
let suppressChangeEvents: number = 0;
const handleVisibilityChange = () => {
if (pendingVisibilityChange || suppressChangeEvents > 0) {
return;
}
pendingVisibilityChange = setTimeout(() => {
pendingVisibilityChange = setTimeout(async () => {
await childrenVisibilityCache?.clearChangedValues();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it should be listener's responsibility to clear cache. Can this be moved to whoever creates the listener and owns the cache?

ctes: [
`
ElementInfo(elementId, modelId, categoryId, parentId) AS (
ecsql: `
Copy link
Member

Choose a reason for hiding this comment

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

why don't we need to select parents of these elements anymore?

Comment on lines +46 to +49
(() => {
using _ = new AlwaysAndNeverDrawnElementInfo(vp);
expect(event.numberOfListeners).to.eq(1);
});
await sinon.clock.runAllAsync();
})();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(() => {
using _ = new AlwaysAndNeverDrawnElementInfo(vp);
expect(event.numberOfListeners).to.eq(1);
});
await sinon.clock.runAllAsync();
})();
{
using _ = new AlwaysAndNeverDrawnElementInfo(vp);
expect(event.numberOfListeners).to.eq(1);
}

CategoryElements(id, modelId, categoryId) AS (
SELECT ECInstanceId, Model.Id, Category.Id
`
ElementsChildrenInfo(Id, CategoryId, ParentId, RootElementCategoryId, ParentHasParent) AS (
Copy link
Member

Choose a reason for hiding this comment

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

This CTE selects all elements of given model - that could be millions of elements. Did you check how this query performs in large datasets?

Comment on lines +416 to +421
SELECT 1
FROM (
SELECT ParentId FROM ElementsChildrenInfo
)
WHERE ParentId = this.Id
LIMIT 1
Copy link
Member

Choose a reason for hiding this comment

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

why not just SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Parent.Id = this.Id?

Comment on lines +474 to +476
* There can be two different cases:
* 1. If category is directly under model, then it returns only those elements that have children.
* 2. If category is under element, then it returns all child elements.
Copy link
Member

Choose a reason for hiding this comment

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

why not have two different functions for this?

@@ -90,7 +89,7 @@ interface ChangeGeometricElementsDisplayStateProps {
// (undocumented)
categoryId: Id64String;
// (undocumented)
elementIds: Id64Set;
elementIds: Map<Id64String, boolean>;
Copy link
Member

Choose a reason for hiding this comment

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

breaking change

@@ -179,6 +178,8 @@ interface GetCategoryVisibilityStatusProps {
categoryId: Id64String;
// (undocumented)
modelId: Id64String;
// (undocumented)
parentElementIds: Id64Array;
Copy link
Member

Choose a reason for hiding this comment

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

breaking change

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.

Tree widget: Incorrect category used for element visibility in filtered tree
2 participants