diff --git a/ocrd_models/ocrd_models/ocrd_page_generateds.py b/ocrd_models/ocrd_models/ocrd_page_generateds.py index 3a7845171d..6208e34499 100644 --- a/ocrd_models/ocrd_models/ocrd_page_generateds.py +++ b/ocrd_models/ocrd_models/ocrd_page_generateds.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # -# Generated Sat Oct 31 00:32:57 2020 by generateDS.py version 2.35.20. +# Generated Sat Oct 31 00:47:39 2020 by generateDS.py version 2.35.20. # Python 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] # # Command line options: @@ -3067,6 +3067,17 @@ def invalidate_AlternativeImage(self, feature_selector=None): for image in removed_images: self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % ( image.get_comments() or '', name)) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class PageType @@ -3218,6 +3229,22 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_points(self, points): + """ + Set coordinate polygon by given string. + Moreover, invalidate the parent's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'parent_object_'): + parent = self.parent_object_ + if hasattr(parent, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + parent.invalidate_AlternativeImage() + elif hasattr(parent, 'parent_object_') and hasattr(parent.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + parent.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.points = points # end class CoordsType @@ -3695,6 +3722,20 @@ def invalidate_AlternativeImage(self, feature_selector=None): for image in removed_images: self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % ( image.get_comments() or '', name)) + def set_Coords(self, Coords): + """ + Set coordinate polygon by given object. + Moreover, invalidate self's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + self.invalidate_AlternativeImage() + elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.Coords = Coords # end class TextLineType @@ -4140,6 +4181,20 @@ def invalidate_AlternativeImage(self, feature_selector=None): for image in removed_images: self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % ( image.get_comments() or '', name)) + def set_Coords(self, Coords): + """ + Set coordinate polygon by given object. + Moreover, invalidate self's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + self.invalidate_AlternativeImage() + elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.Coords = Coords # end class WordType @@ -4538,6 +4593,20 @@ def invalidate_AlternativeImage(self, feature_selector=None): for image in removed_images: self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % ( image.get_comments() or '', name)) + def set_Coords(self, Coords): + """ + Set coordinate polygon by given object. + Moreover, invalidate self's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + self.invalidate_AlternativeImage() + elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.Coords = Coords # end class GlyphType @@ -7153,6 +7222,20 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_Coords(self, Coords): + """ + Set coordinate polygon by given object. + Moreover, invalidate self's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + self.invalidate_AlternativeImage() + elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.Coords = Coords # end class BorderType @@ -9022,6 +9105,20 @@ def invalidate_AlternativeImage(self, feature_selector=None): for image in removed_images: self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % ( image.get_comments() or '', name)) + def set_Coords(self, Coords): + """ + Set coordinate polygon by given object. + Moreover, invalidate self's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + self.invalidate_AlternativeImage() + elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.Coords = Coords # end class RegionType @@ -10877,6 +10974,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class AdvertRegionType @@ -11018,6 +11126,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class MusicRegionType @@ -11131,6 +11250,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class MapRegionType @@ -11273,6 +11403,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class ChemRegionType @@ -11415,6 +11556,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class MathsRegionType @@ -11558,6 +11710,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class SeparatorRegionType @@ -11766,6 +11929,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class ChartRegionType @@ -12015,6 +12189,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class TableRegionType @@ -12194,6 +12379,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class GraphicRegionType @@ -12373,6 +12569,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class LineDrawingRegionType @@ -12565,6 +12772,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class ImageRegionType @@ -13045,6 +13263,17 @@ def __hash__(self): else: raise ValueError("Cannot hash %s" % self) return hash(val) + def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation # end class TextRegionType diff --git a/ocrd_models/ocrd_page_user_methods.py b/ocrd_models/ocrd_page_user_methods.py index 655cfb5006..a9fe643398 100644 --- a/ocrd_models/ocrd_page_user_methods.py +++ b/ocrd_models/ocrd_page_user_methods.py @@ -110,6 +110,10 @@ def _add_method(class_re, method_name, file_name=None): _add_method(r'^(PcGtsType)$', 'get_AllAlternativeImagePaths'), _add_method(r'^(PcGtsType)$', 'prune_ReadingOrder'), _add_method(r'^(PageType|RegionType|TextLineType|WordType|GlyphType)$', 'invalidate_AlternativeImage'), + _add_method(r'^(BorderType|RegionType|TextLineType|WordType|GlyphType)$', 'set_Coords'), + _add_method(r'^(CoordsType)$', 'set_points'), + # for some reason, pagecontent.xsd does not declare @orientation at the abstract/base RegionType: + _add_method(r'^(PageType|AdvertRegionType|MusicRegionType|MapRegionType|ChemRegionType|MathsRegionType|SeparatorRegionType|ChartRegionType|TableRegionType|GraphicRegionType|LineDrawingRegionType|ImageRegionType|TextRegionType)$', 'set_orientation'), ) diff --git a/ocrd_models/ocrd_page_user_methods/set_Coords.py b/ocrd_models/ocrd_page_user_methods/set_Coords.py new file mode 100644 index 0000000000..ce16f76fbf --- /dev/null +++ b/ocrd_models/ocrd_page_user_methods/set_Coords.py @@ -0,0 +1,14 @@ +def set_Coords(self, Coords): + """ + Set coordinate polygon by given object. + Moreover, invalidate self's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + self.invalidate_AlternativeImage() + elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.Coords = Coords diff --git a/ocrd_models/ocrd_page_user_methods/set_orientation.py b/ocrd_models/ocrd_page_user_methods/set_orientation.py new file mode 100644 index 0000000000..d9beaad07b --- /dev/null +++ b/ocrd_models/ocrd_page_user_methods/set_orientation.py @@ -0,0 +1,11 @@ +def set_orientation(self, orientation): + """ + Set deskewing angle to given number. + Moreover, invalidate self's AlternativeImages + (because they will have been rotated and enlarged + with the angle of the previous value). + """ + if hasattr(self, 'invalidate_AlternativeImage'): + # PageType, RegionType: + self.invalidate_AlternativeImage(feature_selector='deskewed') + self.orientation = orientation diff --git a/ocrd_models/ocrd_page_user_methods/set_points.py b/ocrd_models/ocrd_page_user_methods/set_points.py new file mode 100644 index 0000000000..bad9873305 --- /dev/null +++ b/ocrd_models/ocrd_page_user_methods/set_points.py @@ -0,0 +1,16 @@ +def set_points(self, points): + """ + Set coordinate polygon by given string. + Moreover, invalidate the parent's AlternativeImages + (because they will have been cropped with a bbox + of the previous polygon). + """ + if hasattr(self, 'parent_object_'): + parent = self.parent_object_ + if hasattr(parent, 'invalidate_AlternativeImage'): + # RegionType, TextLineType, WordType, GlyphType: + parent.invalidate_AlternativeImage() + elif hasattr(parent, 'parent_object_') and hasattr(parent.parent_object_, 'invalidate_AlternativeImage'): + # BorderType: + parent.parent_object_.invalidate_AlternativeImage(feature_selector='cropped') + self.points = points