From 87905b485aa39cf208414e4fd93ae5010683d43b Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 23 Jun 2021 10:26:54 +0200 Subject: [PATCH 1/7] reworked updater logic --- .../about_upgrade_mightyscape.py | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py b/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py index 3f0ef8c7..37e67e8f 100644 --- a/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py +++ b/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py @@ -33,33 +33,15 @@ class AboutUpgradeMightyScape(inkex.EffectExtension): try: localCommit = local_repo.head.commit remote_repo = git.remote.Remote(local_repo, 'origin') - remoteCommit = remote_repo.fetch()[0].commit + remoteCommit = remote_repo.fetch()[0].commit + self.msg("Latest remote commit is: " + str(remoteCommit)[:7]) + authors = [] # for every remote commit while remoteCommit.hexsha != localCommit.hexsha: authors.append(remoteCommit.author.email) remoteCommit = remoteCommit.parents[0] - #local_commits = list(local_repo.iter_commits("master", max_count=5)) - local_commits = list(local_repo.iter_commits("master")) - self.msg("Local commit id is: " + str(localCommit)[:7]) - self.msg("Latest remote commit is: " + str(remoteCommit)[:7]) - self.msg("There are {} local commits at the moment.".format(len(local_commits))) - localCommitList = [] - for local_commit in local_commits: - localCommitList.append(local_commit) - #localCommitList.reverse() - self.msg("*"*40) - self.msg("Latest 10 local commits are:") - for i in range(0, 10): - self.msg("{} | {} : {}".format( - datetime.utcfromtimestamp(localCommitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'), - localCommitList[i].name_rev[:7], - localCommitList[i].message.strip()) - ) - #self.msg(" - {}: {}".format(localCommitList[i].newhexsha[:7], localCommitList[i].message)) - self.msg("*"*40) - if localCommit.hexsha != remoteCommit.hexsha: ssh_executable = 'git' with local_repo.git.custom_environment(GIT_SSH=ssh_executable): @@ -126,6 +108,26 @@ class AboutUpgradeMightyScape(inkex.EffectExtension): remotes.append("https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X.git") #main remotes.append("https://github.com/vmario89/mightyscape-1.X.git") #copy/second remote + localCommit = local_repo.head.commit + #local_commits = list(local_repo.iter_commits("master", max_count=5)) + localCommits = list(local_repo.iter_commits("master")) + self.msg("Local commit id is: " + str(localCommit)[:7]) + self.msg("There are {} local commits at the moment.".format(len(localCommits))) + localCommitList = [] + for local_commit in localCommits: + localCommitList.append(localCommit) + #localCommitList.reverse() + self.msg("*"*40) + self.msg("Latest 10 local commits are:") + for i in range(0, 10): + self.msg("{} | {} : {}".format( + datetime.utcfromtimestamp(localCommitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'), + localCommitList[i].name_rev[:7], + localCommitList[i].message.strip()) + ) + #self.msg(" - {}: {}".format(localCommitList[i].newhexsha[:7], localCommitList[i].message)) + self.msg("*"*40) + #finally run the update success = self.update(local_repo, remotes[0]) if success is False: #try the second remote if first failed From 22f7860c2182d4e0625d087b278983fff3a7036d Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 23 Jun 2021 11:09:08 +0200 Subject: [PATCH 2/7] added option to remove original paths generally instead after trimming only; adjusted styling option to sub split lines --- .../contour_scanner_and_trimmer.inx | 9 ++-- .../contour_scanner_and_trimmer.py | 42 +++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx index 1b1e50be..5cff195f 100644 --- a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx +++ b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx @@ -14,6 +14,7 @@ 0.1 false true + false @@ -53,7 +54,6 @@ true false true - false true false @@ -93,9 +93,12 @@ 1.0 30 false - true + + + + + true - diff --git a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py index c4aabcf7..19dfee51 100644 --- a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py +++ b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py @@ -47,7 +47,7 @@ Extension for InkScape 1.0+ Author: Mario Voigt / FabLab Chemnitz Mail: mario.voigt@stadtfabrikanten.org Date: 09.08.2020 (extension originally called "Contour Scanner") -Last patch: 22.06.2021 +Last patch: 23.06.2021 License: GNU GPL v3 ''' @@ -376,7 +376,11 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): # collect segments, calculate their slopes, order their points left-to-right for line in lineArray: #csp = line.path.to_arrays() - csp = Path(line.path.transform(line.getparent().composed_transform())).to_arrays() + parent = line.getparent() + if parent is not None: + csp = Path(line.path.transform(parent.composed_transform())).to_arrays() + else: + csp = line.path.to_arrays() #self.msg("csp = {}".format(csp)) x1, y1, x2, y2 = csp[0][1][0], csp[0][1][1], csp[1][1][0], csp[1][1][1] # ensure p0 is left of p1 @@ -431,7 +435,7 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): #we finally build a list which contains all overlapping elements we want to drop dropped_ids = [] - for input_id in input_ids: #if the working id is not in the output id we are going to drop it + for input_id in input_ids: #if the input_id id is not in the output ids we are going to drop it if input_id not in output_ids: dropped_ids.append(input_id) @@ -587,8 +591,9 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): pars.add_argument("--snap_tolerance", type=float, default=0.1, help="Snap tolerance for intersection points") pars.add_argument("--draw_subsplit", type=inkex.Boolean, default=False, help="Draw sub split lines (polylines)") pars.add_argument("--remove_subsplit_collinear", type=inkex.Boolean, default=True, help="Removes any duplicates by merging (multiple) overlapping line segments into longer lines. Not possible to apply for original paths because this routine does not support bezier type paths.") + pars.add_argument("--keep_original_after_split_trim", type=inkex.Boolean, default=False, help="Keep original paths after sub splitting / trimming") - #Scanning - Removing + #Scanning - Removing of original paths pars.add_argument("--remove_relative", type=inkex.Boolean, default=False, help="relative cmd") pars.add_argument("--remove_absolute", type=inkex.Boolean, default=False, help="absolute cmd") pars.add_argument("--remove_mixed", type=inkex.Boolean, default=False, help="mixed cmd (relative + absolute)") @@ -598,7 +603,7 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): pars.add_argument("--remove_closed", type=inkex.Boolean, default=False, help="closed") pars.add_argument("--remove_self_intersecting", type=inkex.Boolean, default=False, help="self-intersecting") - #Scanning - Highlighting + #Scanning - Highlighting of original paths (and sub split lines) pars.add_argument("--highlight_relative", type=inkex.Boolean, default=False, help="relative cmd paths") pars.add_argument("--highlight_absolute", type=inkex.Boolean, default=False, help="absolute cmd paths") pars.add_argument("--highlight_mixed", type=inkex.Boolean, default=False, help="mixed cmd (relative + absolute) paths") @@ -610,12 +615,11 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): pars.add_argument("--visualize_self_intersections", type=inkex.Boolean, default=False, help="self-intersecting path points") pars.add_argument("--visualize_global_intersections", type=inkex.Boolean, default=False, help="global intersection points") - #Settings - Trimming + #Settings - Trimming of sub split lines pars.add_argument("--draw_trimmed", type=inkex.Boolean, default=False, help="Draw trimmed lines") pars.add_argument("--combine_nonintersects", type=inkex.Boolean, default=True, help="Combine non-intersected lines") pars.add_argument("--remove_duplicates", type=inkex.Boolean, default=True, help="Remove duplicate trim lines") pars.add_argument("--reverse_removal_order", type=inkex.Boolean, default=False, help="Reverses the order of removal. Relevant for keeping certain styles of elements") - pars.add_argument("--keep_original_after_trim", type=inkex.Boolean, default=False, help="Keep original paths after trimming") pars.add_argument("--bent_ott_use_ignore_segment_endings", type=inkex.Boolean, default=True, help="Whether to ignore intersections of line segments when both their end points form the intersection point") pars.add_argument("--bent_ott_use_debug", type=inkex.Boolean, default=False) @@ -629,10 +633,10 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): pars.add_argument("--dotsize_intersections", type=int, default=30, help="Dot size (px) for self-intersecting and global intersection points") pars.add_argument("--removefillsetstroke", type=inkex.Boolean, default=False, help="Remove fill and define stroke for original paths") pars.add_argument("--bezier_trimming", type=inkex.Boolean, default=False, help="If true we try to use the calculated t parameters from intersection points to receive splitted bezier curves") - pars.add_argument("--apply_style_to_subsplits", type=inkex.Boolean, default=True, help="Apply highlighting styles to sub split lines.") + pars.add_argument("--subsplit_style", default="default", help="Sub split line style") pars.add_argument("--apply_style_to_trimmed", type=inkex.Boolean, default=True, help="Apply original path style to trimmed lines") - #Style - Scanning Colors + #Style - Scanning Colors (Highlighting things) pars.add_argument("--color_subsplit", type=Color, default='1630897151', help="sub split lines") pars.add_argument("--color_relative", type=Color, default='3419879935', help="relative cmd paths") pars.add_argument("--color_absolute", type=Color, default='1592519679', help="absolute cmd paths") @@ -645,7 +649,7 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): pars.add_argument("--color_self_intersections", type=Color, default='6320383', help="self-intersecting path points") pars.add_argument("--color_global_intersections", type=Color, default='4239343359', help="global intersection points") - #Style - Trimming Color + #Style - Trimming Colors pars.add_argument("--color_trimmed", type=Color, default='1923076095', help="trimmed lines") pars.add_argument("--color_combined", type=Color, default='3227634687', help="non-intersected lines") pars.add_argument("--color_nonintersected", type=Color, default='3045284607', help="non-intersected paths") @@ -792,7 +796,7 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): line.attrib['originalPathStyle'] = str(pathElement.style) subSplitLineArray.append(line) - if so.apply_style_to_subsplits is True: + if so.subsplit_style == "apply_from_highlightings": if line.attrib['originalPathIsRelative'] == 'True': if so.highlight_relative is True: line.style = relativePathStyle @@ -818,6 +822,8 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): else: if so.highlight_opened is True: line.style = openPathStyle + elif so.subsplit_style == "apply_from_original": + line.style = line.attrib['originalPathStyle'] if so.draw_subsplit is True: subSplitLineGroup.add(line) @@ -997,12 +1003,6 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): if so.combine_nonintersects is True: if so.show_debug is True: self.msg("glueing together all non-intersected sub split lines to larger path structures again (cleaning up)") self. combine_nonintersects(allTrimGroups) - - #clean original paths if selected. This option is explicitely independent from remove_open, remove_closed - if so.keep_original_after_trim is False: - if so.show_debug is True: self.msg("cleaning original paths") - for pathElement in pathElements: - pathElement.delete() except AssertionError as e: self.msg("Error calculating global intersections.\n\ @@ -1010,7 +1010,13 @@ See https://github.com/ideasman42/isect_segments-bentley_ottmann.\n\n\ You can try to fix this by:\n\ - reduce or raise the 'decimals' setting (default is 3 but try to set to 6 for example)\n\ - reduce or raise the 'flatness' setting (if quantization option is used at all; default is 0.100).") - return + return + + #clean original paths if selected. + if so.keep_original_after_split_trim is False: + if so.show_debug is True: self.msg("cleaning original paths after sub splitting / trimming") + for pathElement in pathElements: + pathElement.delete() if __name__ == '__main__': ContourScannerAndTrimmer().run() \ No newline at end of file From a2c079d8c996d52ded61e691b49ca0600bb66a3f Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 23 Jun 2021 11:34:50 +0200 Subject: [PATCH 3/7] small refactorings in inx of contour scanner --- .../contour_scanner_and_trimmer.inx | 9 ++++++--- .../contour_scanner_and_trimmer.py | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx index 5cff195f..024e06fe 100644 --- a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx +++ b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx @@ -97,8 +97,11 @@ - - true + + + + + @@ -108,7 +111,7 @@ - Uses Bentley-Ottmann algorithm to detect intersections - Allows to separate different contour types by colors - Works with paths which have Live Path Effects (LPE) - - Does not find overlapping colinear lines (sweep line algorithm does not intersect them) + - Finds overlapping / collinear lines Tips: - If nothings is selected, the whole document will be processed, regardless of groups. In contrast, if you made a custom selection, check to handle or not to handle groups. diff --git a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py index 19dfee51..b5ccd3a8 100644 --- a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py +++ b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.py @@ -296,9 +296,9 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): #if trimGroupParentTransform is not None: # trimLine.path = trimLine.path.transform(-trimGroupParentTransform) - if self.options.apply_style_to_trimmed is False: + if self.options.trimmed_style == "apply_from_trimmed": trimLine.style = trimLineStyle - else: + elif self.options.trimmed_style == "apply_from_original": trimLine.style = subSplitLineArray[subSplitIndex].attrib['originalPathStyle'] trimGroup.add(trimLine) return trimGroup @@ -526,7 +526,7 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): self.msg("trim group {} has {} combinable segments:".format(trimGroup.get('id'), len(newPathData))) self.msg("{}".format(newPathData)) combinedPath.path = Path(newPathData) - if self.options.apply_style_to_trimmed is False: + if self.options.trimmed_style is False: combinedPath.style = trimNonIntersectedStyle if totalIntersectionsAtPath == 0: combinedPath.style = nonTrimLineStyle @@ -634,7 +634,7 @@ class ContourScannerAndTrimmer(inkex.EffectExtension): pars.add_argument("--removefillsetstroke", type=inkex.Boolean, default=False, help="Remove fill and define stroke for original paths") pars.add_argument("--bezier_trimming", type=inkex.Boolean, default=False, help="If true we try to use the calculated t parameters from intersection points to receive splitted bezier curves") pars.add_argument("--subsplit_style", default="default", help="Sub split line style") - pars.add_argument("--apply_style_to_trimmed", type=inkex.Boolean, default=True, help="Apply original path style to trimmed lines") + pars.add_argument("--trimmed_style", default="apply_from_trimmed", help="Trimmed line style") #Style - Scanning Colors (Highlighting things) pars.add_argument("--color_subsplit", type=Color, default='1630897151', help="sub split lines") From 0513eb888f64ed0f43074358e920fc6585387905 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 23 Jun 2021 23:52:13 +0200 Subject: [PATCH 4/7] massive efforts in contour scanner and trimmer --- .../contour_scanner_and_trimmer.inx | 207 +++++++++-------- .../contour_scanner_and_trimmer.py | 216 ++++++++++++------ 2 files changed, 262 insertions(+), 161 deletions(-) diff --git a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx index 024e06fe..670902ce 100644 --- a/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx +++ b/extensions/fablabchemnitz/contour_scanner_and_trimmer/contour_scanner_and_trimmer.inx @@ -2,96 +2,21 @@ Contour Scanner And Trimmer fablabchemnitz.de.contour_scanner_and_trimmer - - - - false - false - false - true - 0.100 - 3 - 0.1 - false - true - false - - - - - - false - false - false - false - false - false - false - false - - - false - false - false - false - false - false - false - false - false - false - - - - - - - - - - false - true - true - false - true - - true - false - false - false - true - - - - - - - - - - - - 1630897151 - 3419879935 - 1592519679 - 3351636735 - 4289703935 - 258744063 - 4012452351 - 2330080511 - 2593756927 - 6320383 - 4239343359 - - - - - 3227634687 - 1923076095 - 3045284607 - + + + + + + false + false + false + true + 0.100 + 3 + 0.1 + 1.0 - 30 + 30 false @@ -101,17 +26,105 @@ - - - + + + + + false + false + false + false + false + false + false + false + + true + + + + + + false + + + + false + false + false + false + false + false + false + false + + false + false + false + + false + false + + + + + + + + + false + true + true + false + true + + true + false + false + false + true + + + + + + + + + + 1630897151 + + 3419879935 + 1592519679 + 3351636735 + 4289703935 + 258744063 + 4012452351 + 2330080511 + + + + + 897901823 + 869366527 + + 2593756927 + 6320383 + 4239343359 + + 3227634687 + 1923076095 + 3045284607 + + + + -