Add support for ordered BCF viewpoint snapshot images

This commit is contained in:
Dion Moult
2020-03-30 18:27:28 +11:00
parent c4cd6ef710
commit fe633d9698
3 changed files with 16 additions and 5 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
class BcfStore():
topics = []
viewpoints = []
comments = []
+13 -2
View File
@@ -428,16 +428,27 @@ class ActivateBcfViewpoint(bpy.types.Operator):
if not topics:
return {'FINISHED'}
topic = topics[bpy.context.scene.BCFProperties.active_topic_index][1]
viewpoints = bcfplugin.getViewpoints(topic)
viewpoints = bcf.BcfStore.viewpoints
if not viewpoints:
return {'FINISHED'}
viewpoint = viewpoints[int(bpy.context.scene.BCFProperties.viewpoints)][1]
viewpoint_reference = viewpoints[int(bpy.context.scene.BCFProperties.viewpoints)][1]
viewpoint = viewpoint_reference.viewpoint
obj = bpy.data.objects.get('Viewpoint')
if not obj:
obj = bpy.data.objects.new('Viewpoint', bpy.data.cameras.new('Viewpoint'))
bpy.context.scene.collection.objects.link(obj)
bpy.context.scene.camera = obj
if viewpoint_reference.snapshot:
obj.data.show_background_images = True
while len(obj.data.background_images) > 0:
obj.data.background_images.remove(obj.data.background_images[0])
background = obj.data.background_images.new()
background.image = bpy.data.images.load(os.path.join(
bcfplugin.util.getBcfDir(),
str(topic.xmlId),
viewpoint_reference.snapshot.uri
))
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'
+2 -2
View File
@@ -479,8 +479,8 @@ def refreshBcfTopic(self, context):
# Load viewpoints
bcfviewpoints_enum.clear()
viewpoints = bcfplugin.getViewpoints(topic)
for i, viewpoint in enumerate(viewpoints):
bcf.BcfStore.viewpoints = bcfplugin.getViewpoints(topic, realViewpoint=False)
for i, viewpoint in enumerate(bcf.BcfStore.viewpoints):
bcfviewpoints_enum.append((str(i), 'View {}'.format(i+1), ''))
# Load comments