mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-04 01:08:26 +02:00
Merge pull request #2395 from alicevision/dev/updateIntrinsicsWhileRemovingImages
[ui] Remove intrinsic if not used by any viewpoint
This commit is contained in:
commit
958f2edc99
4 changed files with 36 additions and 8 deletions
|
@ -479,6 +479,9 @@ class ListAttribute(Attribute):
|
|||
def __len__(self):
|
||||
return len(self._value)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._value)
|
||||
|
||||
def getBaseType(self):
|
||||
return self.attributeDesc.elementDesc.__class__.__name__
|
||||
|
||||
|
|
|
@ -816,6 +816,29 @@ 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 intrinsic in self.cameraInit.attribute("intrinsics"):
|
||||
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"):
|
||||
|
|
|
@ -291,12 +291,14 @@ Panel {
|
|||
}
|
||||
|
||||
function sendRemoveRequest() {
|
||||
if (!readOnly) {
|
||||
removeImageRequest(object)
|
||||
// If the last image has been removed, make sure the viewpoints and intrinsics are reset
|
||||
if (m.viewpoints.count === 0)
|
||||
allViewpointsCleared()
|
||||
}
|
||||
if (readOnly)
|
||||
return
|
||||
|
||||
removeImageRequest(object)
|
||||
|
||||
// If the last image has been removed, make sure the viewpoints and intrinsics are reset
|
||||
if (m.viewpoints.count === 0)
|
||||
allViewpointsCleared()
|
||||
}
|
||||
|
||||
function removeAllImages() {
|
||||
|
|
|
@ -78,8 +78,8 @@ Item {
|
|||
cameraInit: reconstruction ? reconstruction.cameraInit : null
|
||||
tempCameraInit: reconstruction ? reconstruction.tempCameraInit : null
|
||||
cameraInitIndex: reconstruction ? reconstruction.cameraInitIndex : -1
|
||||
onRemoveImageRequest: reconstruction.removeAttribute(attribute)
|
||||
onAllViewpointsCleared: { reconstruction.removeAllImages(); reconstruction.selectedViewId = "-1" }
|
||||
onRemoveImageRequest: reconstruction.removeImage(attribute)
|
||||
onAllViewpointsCleared: { reconstruction.selectedViewId = "-1" }
|
||||
onFilesDropped: {
|
||||
if (drop["meshroomScenes"].length == 1) {
|
||||
ensureSaved(function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue