Commit Graph
6 Commits
Author SHA1 Message Date
Stefan Crooijmans dc95d81937 #15008 Python: Document that add_folder() raises on a leaf folder
RimPolygonFile and the RimPolygonCloudAddress, Folder and Source classes
are not scriptable and have no generated class. rips returns them as
RimPolygonContainer, which gets no typed override (abstract, not
instantiated), so they inherit PdmNestedCollectionBase.add_folder(),
declared as returning PdmNestedCollectionBase, not PolygonCollection.
The generator already emits nothing typed for them:
subCollectionClassKeyword() is empty for a container that cannot add
folders, and classKeywordReturnedTypeForSelf() then falls back to the
declared type. Checked in generated_classes.py from the rips wheel built
on cf72e83.

The call still raises "Cannot add subfolder" on these containers, so
the AddFolder description, used as the add_folder() docstring, now says
so.
2026-11-05 08:50:36 +01:00
Stefan Crooijmans ece73a749c #15008 Python: Return the displayed folder name from collection_name()
collection_name() returned the stored m_collectionName, which is empty
for a RimPolygonFile or RimPolygonCloudAddress without a name. Both
classes fall back to the file name or a default ("Polygon File", "Sumo
Polygon Address") in name().

PdmNestedCollectionBase::displayName() is a virtual that defaults to
collectionName(); RimPolygonFile and RimPolygonCloudAddress override it
with name(), and CollectionNameInternal returns displayName().
collectionName() itself is unchanged, since findSubCollectionByName()
and the name conflict policy compare stored names.

ResInsight-tests: RimcNestedCollectionBase-Test covers a polygon
collection, a polygon file (default, base name, file name fallback) and
a cloud polygon address.
2026-11-05 08:50:36 +01:00
Stefan Crooijmans c0dcb78824 #15008 Python: Typed add_folder() and collection_name() for nested collections
The Python generator emits add_folder() again on a concrete collection
class when the folder type narrows: SurfaceCollection.add_folder()
returns SurfaceCollection and PolygonCollection.add_folder() returns
PolygonCollection, while PdmNestedCollectionBase keeps the declared type.
PdmObjectMethod::classKeywordReturnedTypeForSelf() reports the narrowed
type, and the super class method check in the generator accepts such an
override (same arguments, subclass return type).

PdmNestedCollectionBase: subCollectionClassKeyword() names the folder
type without creating one, addNewSubCollection() is a template method
over createSubCollection() and returns PdmNestedCollectionBase*, and the
base virtuals are pure. The leaf polygon containers only override
canAddSubCollection().

collection_name() in rips returns the folder name for every nested
collection; the class specific name attributes are kept.
2026-11-05 08:50:36 +01:00
Magne Sjaastad ebf75c09a1 #14411 Enforce name uniqueness for surfaces, polygons and folders
* #14411 Enforce name uniqueness for surfaces, polygons and folders

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.

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.
2026-08-07 08:34:58 +02:00
Magne Sjaastad 3375e37ffc #13987 PDM: Make loadData() virtual on RimPolygonContainer
Replace the dynamic_cast dispatch in RimPolygonCollection::loadData() with a
virtual loadData() on RimPolygonContainer. The base recurses through
subCollections; RimPolygonFile overrides to load file data. The folder
RimPolygonCollection no longer needs its own loadData().

Move RimPolygonFile::canAddSubCollection() and RimPolygonInView::sourceItem()
implementations from headers to .cpp.

Simplify std::unexpected calls in RimcNestedCollectionBase by removing
redundant explicit QString construction.
2026-05-13 14:53:00 +02:00
Magne Sjaastad 1e0ba3cdec #13987 PDM: Add RicNewNestedCollectionFeature and RimcNestedCollectionBase
Generalise the per-domain "Add Folder" command and the scripting-side
add-folder method so they work against any container that exposes
caf::PdmNestedCollectionBase.

- RicNewNestedCollectionFeature: command feature that walks the
  selected PdmObject up to the nearest PdmNestedCollectionBase ancestor
  and calls addNewSubCollection(). Hidden via canAddSubCollection() for
  leaf containers.
- RimcNestedCollectionBase: scripting wrapper exposing the same
  add-sub-collection action through the Python interface, so generated
  Python bindings get the operation for free on every derived class.

Neither is wired to a concrete collection yet; the per-domain features
remain in place until the migration commit replaces them.
2026-05-13 14:53:00 +02:00