ms.rename(name, exclude=ms.getObject().name()) finally: ms.end_writing() ms.cancel_reservation() micromenu.addItem( oofmenu.OOFMenuItem( 'Rename', callback=renameMicrostructure, params=[ parameter.StringParameter('microstructure', '', tip='Old name for the microstructure.'), whoville.WhoNameParameter('name', value='', tip='New name for the microstructure.') ], help="Rename a Microstructure.", discussion="""<para> Change the name of an existing µ. </para>""")) ############################ def copyMicrostructure(menuitem, microstructure, name): if parallel_enable.enabled(): microstructureIPC.msmenu.Copy(microstructure=microstructure, name=name) return
immidge.rename(name, exclude=immidge.getObject().name()) finally: immidge.end_writing() immidge.cancel_reservation() imagemenu.addItem( oofmenu.OOFMenuItem( 'Rename', callback=renameImage, params=[ whoville.WhoParameter('image', whoville.getClass('Image'), tip=parameter.emptyTipString), whoville.WhoNameParameter('name', value='', tip='New name for the image') ], help="Rename an Image.", discussion=xmlmenudump.loadFile( 'DISCUSSIONS/image/menu/renameimage.xml'))) ################################## def deleteImage(menuitem, image): immidge = imagecontext.imageContexts[image] immidge.reserve() immidge.begin_writing() try: immidge.getMicrostructure().removeImage(immidge)
finally: subprob.end_writing() subprob.cancel_reservation() subproblemMenu.addItem( oofmenu.OOFMenuItem( 'Rename', callback=_rename_subproblem, threadable=oofmenu.THREADABLE, params=[ whoville.WhoParameter('subproblem', ooflib.engine.subproblemcontext.subproblems, tip=parameter.emptyTipString), whoville.WhoNameParameter('name', value='', tip='New name for the subproblem.') ], help='Rename a Subproblem.', discussion="<para> Assign a new name to a &subproblem;</para>")) ############# def _delete_subproblem(menuitem, subproblem): if parallel_enable.enabled(): ipcsubpmenu.Delete(subproblem=subproblem) return subpctxt = ooflib.engine.subproblemcontext.subproblems[subproblem] if subpctxt.name() == ooflib.engine.mesh.defaultSubProblemName: raise ooferror.ErrUserError("You can't delete the default Subproblem!")