--- a/src/ldt/ldt/ldt_utils/projectserializer.py Tue May 27 17:28:39 2014 +0200
+++ b/src/ldt/ldt/ldt_utils/projectserializer.py Wed May 28 16:29:07 2014 +0200
@@ -690,7 +690,7 @@
self.content = content
self.projects = projects
- def get_merged_project(self, shot_by_shot=True):
+ def get_merged_project(self, shot_by_shot=True, only_visible=True):
# New project
contents = [ self.content, ]
@@ -718,25 +718,29 @@
# Parse all projects
for p in self.projects:
p_xml = lxml.etree.fromstring(p.ldt_encoded)
+ # We only keep the decoupages (cuttings) visible in the default view, which means the first display.
+ first_display = p_xml.xpath('/iri/displays/display')[0]
+ current_disp_node = first_display.xpath('content[@id="' + self.content.iri_id + '"]')[0]
# First version of ensemble
ens = p_xml.xpath('/iri/annotations/content[@id="' + self.content.iri_id + '"]/ensemble')
for e in ens:
content_node.append(e)
# Update display
for c in e.xpath('decoupage'):
- c_node = lxml.etree.SubElement(ctt_disp_node, 'decoupage')
- c_node.set(u'idens', e.get('id'))
- c_node.set(u'id', c.get('id'))
+ if not only_visible or (only_visible and len(current_disp_node.xpath('decoupage[@id="' + c.get('id') + '"]'))>0 ) :
+ c_node = lxml.etree.SubElement(ctt_disp_node, 'decoupage')
+ c_node.set(u'idens', e.get('id'))
+ c_node.set(u'id', c.get('id'))
# Second version of ensemble
ens = p_xml.xpath('/iri/annotations/content[@id="' + self.content.iri_id + '"]/ensembles/ensemble')
for e in ens:
content_node.append(e)
# Update display
for c in e.xpath('decoupage'):
- c_node = lxml.etree.SubElement(ctt_disp_node, 'decoupage')
- c_node.set(u'idens', e.get('id'))
- c_node.set(u'id', c.get('id'))
-
+ if not only_visible or (only_visible and len(current_disp_node.xpath('decoupage[@id="' + c.get('id') + '"]'))>0 ) :
+ c_node = lxml.etree.SubElement(ctt_disp_node, 'decoupage')
+ c_node.set(u'idens', e.get('id'))
+ c_node.set(u'id', c.get('id'))
proj.ldt = lxml.etree.tostring(doc, pretty_print=True)