Skip to content

Commit

Permalink
fixup various bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnie committed Jan 11, 2024
1 parent 2ddd2fd commit 7aa3438
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def save_image(self, img, modifier=''):
modifier = '_' + modifier
now = datetime.datetime.now()
cv2.imwrite(f'{self.save_name}{modifier}_{now.strftime("%m%d%Y_%H%M%S")}.{self.save_type}', img)
with open(Path(f'db_{self.save_name}{modifier}_{now.strftime("%m%d%Y_%H%M%S")}.json'), 'w+') as config:
with open(Path(f'{self.save_name}{modifier}_{now.strftime("%m%d%Y_%H%M%S")}.json'), 'w+') as config:
config.write(json.dumps(self.schema, indent=2))

def read(self, path, max_x=None, max_y=None):
Expand Down Expand Up @@ -130,6 +130,9 @@ def read(self, path, max_x=None, max_y=None):
self.schema['version'] = '1.0.1'
elif self.schema['version'] == '1.0.1':
self.schema['version'] = '1.1.0'
self.schema['undo'] = []
if 'overlaps' in self.schema:
del self.schema['overlaps']

# finalize extents
self.finalize()
Expand Down
14 changes: 14 additions & 0 deletions stitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def __init__(self):
self.trackbar_created = False
self.select_pt1 = None
self.select_pt2 = None
self.zoom_window_opened = False

def on_autostitch_button(self):
# undo is handled inside the restitch routine
Expand All @@ -180,6 +181,8 @@ def on_autostitch_button(self):

# redraw the main window preview
self.redraw_overview()
if self.zoom_window_opened:
self.update_zoom_window()

def on_flag_restitch_button(self):
# undo is handled inside the restitch routine
Expand All @@ -197,6 +200,8 @@ def on_flag_restitch_button(self):
else:
self.stitch_auto_template_linear(stitch_list=restitch_list)
self.redraw_overview()
if self.zoom_window_opened:
self.update_zoom_window()

def on_flag_retitch_selection(self):
self.schema.set_undo_checkpoint()
Expand All @@ -207,19 +212,27 @@ def on_flag_retitch_selection(self):
self.schema.flag_restitch(layer)
else:
logging.warning("No region selected, doing nothing")
if self.zoom_window_opened:
self.update_zoom_window()

def on_remove_selected(self):
self.schema.set_undo_checkpoint()
(layer, _tile) = self.schema.get_tile_by_coordinate(self.cached_image_centroid)
self.schema.remove_tile(layer)
self.redraw_overview()
if self.zoom_window_opened:
self.update_zoom_window()

def on_redraw_button(self):
self.redraw_overview()
if self.zoom_window_opened:
self.update_zoom_window()

def on_undo_button(self):
self.schema.undo_to_checkpoint()
self.redraw_overview()
if self.zoom_window_opened:
self.update_zoom_window()
logging.info("Undo to last checkpoint!")

def on_preview_selection(self):
Expand Down Expand Up @@ -327,6 +340,7 @@ def overview_clicked(self, event):

elif event.button() == Qt.RightButton:
self.update_zoom_window()
self.zoom_window_opened = True

def keyPressEvent(self, event):
if event.key() == Qt.Key.Key_1:
Expand Down

0 comments on commit 7aa3438

Please sign in to comment.