Page MenuHome

Spreadsheet Editor: Row filters
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Apr 12 2021, 10:12 PM.

Details

Summary

This patch adds support for filtering out rows based on rules and values.
Filters will work for any attribute data source, they are a property of
the spreadsheet rather than of the attribute system. The properties
displayed in the row filter can depend on data type of the currently
visible column with that name. If the name is no longer visible, the row
filter will remember its data type until a column with that name is
visible again.

Implementation Questions

  • The comments in screen.c combined with tagging the sidebar for redraw after the main region point to a lack of understanding or some technical debt, not sure.

Future Improvements

  • This patch doesn't contain a search of visible columns when adding a new filter. That's separate enough that I think it makes sense to push that with a separate patch later.

This patch is available in the temp-spreadsheet-row-filter branch.

Diff Detail

Repository
rB Blender
Branch
temp-spreadsheet-row-filter
Build Status
Buildable 14080
Build 14080: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Very nice!
I think the design of the filters themselves works super well.

Couple of remarks:

  • I do like the idea of the popover, as I'm also not a huge fan of adding a sidebar for this. But I can definitely see Jacques' problem with it.
  • Changing the domain results in attributes not being found and data-types reverting to float in cases where it doesn't make sense (you also mentioned this in your further questions). I think this brings up a design question that we haven't considered in general. I can see two different approaches working:
    • We have separate filters per domain. They can't share names throughout domains anyways.
    • A filter can search through attributes of all domains and the row mask propagates based on topology the same way as it does when changing select modes in the edit mode. (E.g. filter that returns a single face propagates to its corner vertices)
  • We still have the same issue with attributes that are missing when the context changes. Would it be possible to remember the type of a known attribute and not revert to default, when it's not found anymore?
  • In line with that, it would also be great if, in the future, we could add a viewport overlay to highlight the data of the shown rows. Same thing for making rows selectable and highlighting the selected ones. (Way out of scope, I know. It's just something this made me think about and I'm not sure we talked about something like this before.)

Just a thought about UI : I think it makes sense to have filter options both inside the popover and in a sidebar, akin to tool/brush options in the 3D view that are both accessible through the header as popovers and in the sidebar (so they're always visible).

Hans Goudey (HooglyBoogly) marked 6 inline comments as done.
  • Address small review comments from Jacques
  • New implementation of the UI in a sidebar
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
190

Oops, I didn't mean to do that, thanks.

source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
96

Sure, works for me.

99

I usually try to do that too, I thought each section here was doing slightly different types of operations though. I'll see if I can remove some new lines, since I mostly agree.

  • Cleanup: Whitespace and unused includes
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
  • Use nullptr instead of NULL
  • Compare display names instead of the column ID

@Hans Goudey (HooglyBoogly) can you rebase this with latest master? I'm running into some bugs when trying "only selected" + nodes which I'm not sure are from the patch or not.

My proposal on the UI: mantain it as a popover but add the pin option to stick it on place to not hide it if you click outside

  • Merge branch 'master' into temp-spreadsheet-row-filter

@Hans Goudey (HooglyBoogly) can you rebase this with latest master? I'm running into some bugs when trying "only selected" + nodes which I'm not sure are from the patch or not.

Done. Some issues with "Only Selected" are expected for generative modifiers, especially ones where we can't maintain the original indices, that's not related to this patch though.

  • Remember the last data type when a column is no longer visible
  • Completely gray out row filters with no corresponding visible column
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

I'm honestly not a big fan of combining the Selected Only option with the filters under one toggle.
To me the selection works on a separate level as it's strongly and globally connected to the viewport and should be a separate toggle from the filters that are local per editor.

Would you keep it in the header then? I think that toggle in the header is still a bit weird too.

I don't know if it's been mentioned already, but all the animation editors (except timeline) have a selected only option. In those cases it's in the header, and it's an icon


Maybe this could use the same?

Jacques Lucke (JacquesLucke) requested changes to this revision.Apr 19 2021, 12:34 PM

I wonder if the filters should be turned on automatically when adding a new filter. I forget this a couple of times and wondered why it's not working.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
3007

Why are you adding the toolbar key here already (same in the other keymap)?

source/blender/editors/space_spreadsheet/space_spreadsheet.cc
349

Move this into the loop in spreadsheet_main_region_draw, otherwise this data might not be updated correctly.

399

remove comment?

source/blender/editors/space_spreadsheet/spreadsheet_column.cc
65

Use StringRefNull and display_name.c_str.

source/blender/editors/space_spreadsheet/spreadsheet_intern.hh
27

commented code

source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
82

I'd probably make these names a bit more specific, like SPREADSHEET_OT_remove_row_filter_rule. I don't really see a downside to being more specific here.

source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
88

Not sure why you marked this as unreachable, it's perfectly reachable currently when using Name as filter when viewing instances.

205

Feels like the proper solution would be to not create the data source during drawing but to have some new callback in SpaceType that is run before any of the regions are drawn. That does not have to be part of this patch though.

source/blender/makesrna/RNA_access.h
618

Sort alphabetically.

This revision now requires changes to proceed.Apr 19 2021, 12:34 PM

I don't know if it's been mentioned already, but all the animation editors (except timeline) have a selected only option. In those cases it's in the header, and it's an icon


Maybe this could use the same?

We have to see how well this would work in combination with expanding the use of the spreadsheet for other data than geometry, but generally I'd be in favor of separating it like this.

Hans Goudey (HooglyBoogly) marked 9 inline comments as done.
  • Don't gray out filter panels when their string is empty
  • Remove "T" keymap item
  • Move assigning column runtime data to the main draw function
  • Use StringRefNull
  • Give operators more specific names
  • Don't mark unreachable code incorrectly
  • Sort RNA definition automatically
  • Remove commented code / always display "Only Selected" option
release/scripts/presets/keyconfig/keymap_data/blender_default.py
3007

Mostly because this was copy-pasty code and we'll be getting the data source region soon, which would open with T I guess. But you're right, it shouldn't be in this patch.

source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
82

Yeah, good point.

source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
205

Okay, I'll leave that out of this patch then, I'll just always display the option.

Jacques Lucke (JacquesLucke) accepted this revision.EditedApr 22 2021, 1:32 PM

The code is looking good to me now. Not sure if there is still a design discussion going on.

Might be a good idea to wait with the merge until vector/color columns are combined in 2.93. Otherwise the merge will be nasty.

source/blender/editors/interface/interface_panel.c
677

Why this change?

source/blender/editors/space_spreadsheet/space_spreadsheet.cc
380

Outdated comment.

source/blender/makesrna/intern/rna_space.c
7397

Replace all SpreadSheet with Spreadsheet.

This revision is now accepted and ready to land.Apr 22 2021, 1:32 PM
source/blender/editors/space_spreadsheet/spreadsheet_column.cc
65

Need to free the old display name here.

Hans Goudey (HooglyBoogly) marked 3 inline comments as done.
  • Merge branch 'master' into temp-spreadsheet-row-filter
  • Fix memory leak
  • Remove unecessary comment
  • Use "Spreadsheet" instead of "SpreadSheet"
source/blender/editors/interface/interface_panel.c
677

I'll split that out when committing, it's so the reordering works in the side panel when there are no categories visible, just a case this code didn't get tested with yet.

  • Add support for float2, float3, color, and instance columns

One thing I'm not happy with is the headers for the row filter panels
when with vector types, the text always ends up getting cut off.

The code looks fine still. Filtering vectors and colors is quite inconvenient now unfortunately. However, I'm fine if this gets improved in a separate patch. Not sure what the other think.

  • Merge branch 'master' into temp-spreadsheet-row-filter
  • Fix build error after merging master
Hans Goudey (HooglyBoogly) planned changes to this revision.EditedJun 11 2021, 6:36 PM

The results of our latest discussion about this patch:

  • Separate "Selection Only" from other filters.
  • Turning off filters should not deactivate the selection filter.
  • Grey out filters when all filters are turned off.
  • Move "Selection Only" to an icon like the graph editor
  • Don't show settings for filters that don't correspond to a visible column (including empty names)
  • Split selection filter and row filters (filter flag no longer applies to selection filter)
  • Gray out row filters if the flag is turned off
  • Move "Selection Only" to the editor header
  • Remove "Last Data Type" hack
This revision is now accepted and ready to land.Jun 16 2021, 5:14 AM
  • Filtering should be on by default (for old files as well - doversion).
  • Suggest using "=" instead of "==" for the labels showing equality.
  • I think I'm running into an issue with 2D Vector filters:

In this case (default cube) I would expect to see some of the values. It seems that it doesn't matter what I do with the Smaller or Greater Than, I only get to hide the elements 0 and 1 of the cube.

  • Use "=" for equality instead of "=="
  • Add versioning code to enable fitlering (will subversion bump when committing)
  • Fix using 3D vector values for 2D row filter

Patch is good to go (I didn't test the latest iteration, but if the remarks were addressed +1).

Non-blocking extra thoughts:
I would still be curious to see the range idea working - as the default mode with the range filled once you pick the column - that would means things don't disappear right away, but you get to gradually get rid of lines while adjusting the range). But nothing blocking anyways (the same behaviour could be applied for the greater and smaller than too, where data don't just disappear once you pick the column. It does only when you start to slide the values away from the initial smartly filled values

This revision was automatically updated to reflect the committed changes.