[ui] Add removeImage function in Python to check for intrinsic still used

This commit is contained in:
Aurore LAFAURIE 2024-05-10 11:19:03 +02:00
parent 561e9b806c
commit c50d3cc9e7
3 changed files with 33 additions and 25 deletions

View file

@ -816,6 +816,30 @@ class UIGraph(QObject):
def removeAttribute(self, attribute):
self.push(commands.ListAttributeRemoveCommand(self._graph, attribute))
@Slot(Attribute)
def removeImage(self, image):
with self.groupedGraphModification("Remove Image"):
# look if the viewpoint's intrinsic is used by another viewpoint
# if not, remove it
intrinsicId = image.intrinsicId.value
intrinsicUsed = False
for intrinsic in self.cameraInit.attribute("viewpoints").getExportValue():
if image.getExportValue() != intrinsic and intrinsic['intrinsicId'] == intrinsicId:
intrinsicUsed = True
break
if not intrinsicUsed:
#find the intrinsic and remove it
for x in range(len(self.cameraInit.attribute("intrinsics"))):
intrinsic = self.cameraInit.attribute("intrinsics").at(x)
if intrinsic.getExportValue()["intrinsicId"] == intrinsicId:
self.removeAttribute(intrinsic)
break
# After every check we finally remove the attribute
self.removeAttribute(image)
@Slot()
def removeAllImages(self):
with self.groupedGraphModification("Remove All Images"):