Skip to content

Commit

Permalink
Bug Fix to reposition additional text at the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Feb 27, 2024
1 parent b16738c commit 0629734
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions markimg/markimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ def run(self, options):
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, totalRightInfo, color='white', fontsize=options.textSize, rotation=90)

totalLeftInfo = 'Total left: ' + str(self.getSum(d_lengths['Left femur'], d_lengths['Left tibia'])) + f' {unit}'
totalLeftInfo = 'Total left: ' + str(
self.getSum(d_lengths['Left femur'], d_lengths['Left tibia'])) + f' {unit}'
d_total['Total left'] = str(self.getSum(d_lengths['Left femur'], d_lengths['Left tibia'])) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, totalLeftInfo, color='white', fontsize=options.textSize, rotation=90)
Expand All @@ -551,11 +552,16 @@ def run(self, options):
plt.text(x_pos, y_pos, totalDiffText, color='white', fontsize=options.textSize, rotation=90)

# Print some blank lines
for i in range(0, 3):
for i in range(0, 2):
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, '', color='white', fontsize=options.textSize, rotation=90)
rotation = 0
plt.text(x_pos, y_pos, msg, color='cyan', fontsize=options.textSize, rotation=90)
for i in range(0, 2):
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, '', color='white', fontsize=options.textSize, rotation=90)
plt.text(x_pos, y_pos, options.addText, color=options.addTextColor, fontsize=options.addTextSize,
rotation=90)

"""
Need to rewrite logic for directions.
Expand Down Expand Up @@ -584,8 +590,8 @@ def run(self, options):

# y_pos = y_pos - line_gap

plt.text(x_pos, y_pos, options.addText, color=options.addTextColor, fontsize=options.addTextSize,
rotation=rotation)
# plt.text(x_pos, y_pos, options.addText, color=options.addTextColor, fontsize=options.addTextSize,
# rotation=rotation)

# Clean up all matplotlib stuff and save as PNG
plt.tick_params(left=False, right=False, labelleft=False,
Expand Down Expand Up @@ -654,10 +660,13 @@ def getSum(self, val1, val2):

def compareLength(self, left, right):
compareText = "equal"
if left > right:
compareText = f'left longer ({round(((left-right)/right)*100, 1)}%)'
elif right > left:
compareText = f'right longer ({round(((right-left)/left)*100, 1)}%)'
try:
if left > right:
compareText = f'left longer ({round(((left - right) / right) * 100, 1)}%)'
elif right > left:
compareText = f'right longer ({round(((right - left) / left) * 100, 1)}%)'
except ZeroDivisionError:
compareText = "Error: ZeroDivisionError"

return compareText + ' '

Expand All @@ -666,7 +675,7 @@ def measureXDist(self, line, color, size, max_y, scale, unit='cm'):
P2 = line[1]
pixel_distance = round(abs(P1[0] - P2[0]))
actual_distance = round((pixel_distance * scale) / 10, 1)
if scale==0:
if scale == 0:
return pixel_distance, pixel_distance
return pixel_distance, actual_distance

Expand Down

0 comments on commit 0629734

Please sign in to comment.