#14411 Enforce name uniqueness for surfaces, polygons and folders - #14425
Open
magnesj wants to merge 2 commits into
Open
#14411 Enforce name uniqueness for surfaces, polygons and folders#14425magnesj wants to merge 2 commits into
magnesj wants to merge 2 commits into
Conversation
Names must be unique among siblings sharing the same parent folder. Items in different folders may keep identical names, and comparison is case sensitive. Siblings are the objects held by the same caf::PdmChildArrayField. Items and folders live in two distinct child arrays in caf::PdmNestedCollection, so a folder and an item may share a name under the same parent. Renaming from the tree or the property editor asks the user to accept an auto-generated unique name, and reverts on cancel. Without a GUI the unique name is applied directly, so console runs and regression tests never block. Creation, import, copy, duplicate and drag and drop between folders auto-rename. The Python API gets an OnNameConflict flag on AddFolder, CreatePolygon, ImportSurface and NewRegularSurface, supporting FAIL (default), AUTO_RENAME and OVERWRITE. NewSurface is left out, as grid case surfaces derive their tree label from the case and K index and carry no name of their own. Objects with an empty name are exempt, as they derive their label from other properties. Existing projects are not migrated. Duplicates already stored in a project file are resolved as the user touches them.
The polygon fixture creates a polygon named "Test Polygon" for every test in the class, but the project was never reset, so all tests after the first collided on the name. This passed while duplicate names were allowed, and now fails on the default FAIL conflict policy. Depend on the initialize_test fixture, as the other test modules do, so each test starts from a clean polygon collection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14411
Names must be unique among siblings sharing the same parent folder. Items in different folders may keep identical names, and comparison is case sensitive.
Approach
Both trees now sit on
caf::PdmNestedCollection<SelfT, ItemT>, which keeps items inm_itemsand folders inm_subCollections.RiaNameUniquenessToolsbuilds on that: siblings are simply the other objects in the samecaf::PdmChildArrayField, reached throughparentField(). That makes one generic helper enough for surfaces, polygons and folders, and it gives two properties for free — folders and items are separate namespaces, and names in different folders never collide.Rename
Hooked in
fieldChangedByUionRimSurface,RimPolygon,RimSurfaceCollectionandRimPolygonContainer, the last covering polygon folders andRimPolygonFile. Tree-view and property-editor renames both funnel through there, and it is the only place with the old value available for the cancel path.On a collision
RiuNameConflictTools::resolveRenameConflictoffers the auto-generated name:Cancel restores the previous name. When no GUI is running, the unique name is applied without prompting, so console mode, regression tests and gRPC-driven field writes never block on a modal dialog.
Auto-rename
Applied where no user is present to decide: manual creation, Add Folder, surface and polygon file import, polygons generated from one file, create-copy, duplicate, and drag and drop between folders. Drag and drop needed no change in
RiuDragDrop, as it routes throughaddSurfacesAtIndex.Python API
RiaDefines::NameConflictPolicywithFAIL(default),AUTO_RENAMEandOVERWRITE, exposed ason_name_conflictonAddFolder,CreatePolygon,ImportSurfaceandNewRegularSurface:NewSurfaceis deliberately left out. Grid case surfaces derive their tree label from the case and K index and carry no name of their own, so a flag there would never fire.Notes
Objects with an empty name are exempt from numbering, for the same reason — otherwise six grid case surfaces would render as
_1 - K:3.Existing projects are not migrated. Project load deserializes straight into the child arrays, so duplicates already stored in a project file survive and are resolved as the user touches them. All in-project references to surfaces and polygons are
PdmPtrField, so adding a migration pass later stays safe.caf::PdmNestedCollectionBase::subCollectionsField()is added so the genericAddFoldercan inspect sibling folders without knowing the concrete collection type.Verification
Full build clean. 960/960 C++ unit tests pass, including 7 new ones for the suffix rule, case sensitivity, per-folder scoping, separate namespaces and the conflict policy. 10/10 rips tests pass, including 3 new ones covering the Python flag across all three modes.