if ( aRegion.IsNull() )
continue;
- QString aRegionName = aRegion->GetName();
- if ( aRegionName.startsWith( anOldCaseName ) )
- {
- aRegionName.replace( anOldCaseName, theName );
- aRegion->SetName( aRegionName );
- }
+ HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegion );
HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
HYDROData_SequenceOfObjects::Iterator anIter( aZones );
if ( aRegZone.IsNull() )
continue;
- QString aRegionZoneName = aRegZone->GetName();
- if ( aRegionZoneName.startsWith( anOldCaseName ) )
- {
- aRegionZoneName.replace( anOldCaseName, theName );
- aRegZone->SetName( aRegionZoneName );
- }
+ HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegZone );
}
}
if ( aGroup.IsNull() )
continue;
- QString aGroupName = aGroup->GetName();
- if ( aGroupName.startsWith( anOldCaseName ) )
- {
- aGroupName.replace( anOldCaseName, theName );
- aGroup->SetName( aGroupName );
- }
+ HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aGroup );
}
}
theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) );
}
+void HYDROData_Tool::UpdateChildObjectName( const QString& theOldStr,
+ const QString& theNewStr,
+ const Handle(HYDROData_Entity)& theObject )
+{
+ if ( theObject.IsNull() )
+ return;
+
+ QString anObjName = theObject->GetName();
+ if ( theOldStr.isEmpty() )
+ {
+ while ( anObjName.startsWith( '_' ) )
+ anObjName.remove( 0, 1 );
+
+ anObjName.prepend( theNewStr + "_" );
+ }
+ else if ( anObjName.startsWith( theOldStr ) )
+ {
+ anObjName.replace( 0, theOldStr.length(), theNewStr );
+ }
+ else
+ return;
+
+ theObject->SetName( anObjName );
+}
+
*/
static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
+ /**
+ * \brief Updates the child object name.
+ * \param theOldStr old father object name
+ * \param theNewStr new father object name
+ * \param theObject object to update
+ */
+ static void UpdateChildObjectName( const QString& theOldStr,
+ const QString& theNewStr,
+ const Handle(HYDROData_Entity)& theObject );
+
};
inline bool ValuesEquals( const double& theFirst, const double& theSecond )