Skip to content

Commit

Permalink
added pytfm gui
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerum committed Dec 5, 2023
1 parent 42cc4da commit 1b81aeb
Show file tree
Hide file tree
Showing 21 changed files with 2,275 additions and 5 deletions.
26 changes: 25 additions & 1 deletion saenopy/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def download_files(url, target_folder=None, progress_callback=None):
def load_example(name, target_folder=None, progress_callback=None, evaluated=False):
if target_folder is None:
target_folder = appdirs.user_data_dir("saenopy", "rgerum")
example = get_examples()[name]
try:
example = get_examples()[name]
except KeyError:
example = get_examples_2D()[name]
url = example["url"]
download_files(url, target_folder, progress_callback=progress_callback)

Expand Down Expand Up @@ -124,3 +127,24 @@ def get_examples():
"url_evaluated_file": ["2023_02_14_12_0920_stack.saenopy"],
},
}


def get_examples_2D():
example_path = Path(appdirs.user_data_dir("saenopy", "rgerum"))
image_path = Path(resource_path("thumbnails"))
return {
"WTKO": {
"desc": "TODO",
"img": image_path / "liver_fibroblast_icon.png",
"pixel_size": 0.201,
"bf": example_path / 'WTKO/*/*_bf_before.tif',
"reference": example_path / 'WTKO/*/*_after.tif',
"deformed": example_path / 'WTKO/*/[0-9][0-9]_before.tif',
"output_path": example_path / 'WTKO/example_output',
"piv_parameters": {'window_size': 100, 'overlap': 60, 'std_factor': 15},
"force_parameters": {'young': 49000, 'sigma': 0.49, 'h': 300},
"url": "https://github.com/rgerum/saenopy/releases/download/v0.7.4/WTKO.zip",
"url_evaluated": "https://github.com/rgerum/saenopy/releases/download/v0.7.4/WTKO_evaluated.zip",
"url_evaluated_file": ["KO/04_bf_before.saenopy2D", "KO/05_bf_before.saenopy2D", "WT/03_bf_before.saenopy2D", "WT/10_bf_before.saenopy2D"],
},
}
29 changes: 29 additions & 0 deletions saenopy/gui/common/QtShortCuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,35 @@ def __exit__(self, exc_type, exc_val, exc_tb):
pass


class QTabBarWidget(QtWidgets.QTabBar):

def __init__(self, layout, *args, **kwargs):
super().__init__(*args, **kwargs)
if layout is None and current_layout is not None:
layout = current_layout
layout.addWidget(self)
self.widgets = []


def createTab(self, name):
tab_stack = QtWidgets.QWidget()
self.widgets.append(tab_stack)
self.addTab(name)
v_layout = QVBoxLayout(tab_stack)
return v_layout

def currentWidget(self):
return self.widgets[self.currentIndex()]

def widget(self, i):
return self.widgets[i]

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
pass

class EnterableLayout:
def __enter__(self):
global current_layout
Expand Down
Empty file added saenopy/gui/tfm2d/__init__.py
Empty file.
42 changes: 42 additions & 0 deletions saenopy/gui/tfm2d/gui_2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sys
from qtpy import QtCore, QtWidgets

from saenopy.gui.common import QtShortCuts
from saenopy.gui.common.resources import resource_icon
from saenopy.gui.tfm2d.modules.BatchEvaluate import BatchEvaluate

class MainWindowSolver(QtWidgets.QWidget):

def __init__(self, parent=None):
super().__init__(parent)

# QSettings
self.settings = QtCore.QSettings("Saenopy", "Saenopy")

main_layout = QtWidgets.QHBoxLayout(self)

with QtShortCuts.QTabWidget(main_layout) as self.tabs:
with self.tabs.createTab("Analyse Measurements"):
with QtShortCuts.QHBoxLayout():
self.deformations = BatchEvaluate(self)
QtShortCuts.current_layout.addWidget(self.deformations)

#with self.tabs.createTab("Data Analysis"):
# with QtShortCuts.QHBoxLayout():
# self.plotting_window = PlottingWindow(self).addToLayout()


if __name__ == '__main__': # pragma: no cover
app = QtWidgets.QApplication(sys.argv)
if sys.platform.startswith('win'):
import ctypes
myappid = 'fabrylab.saenopy.master' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
print(sys.argv)
window = MainWindowSolver()
window.setMinimumWidth(1600)
window.setMinimumHeight(900)
window.setWindowTitle("Saenopy Viewer")
window.setWindowIcon(resource_icon("Icon.ico"))
window.show()
sys.exit(app.exec_())
Loading

0 comments on commit 1b81aeb

Please sign in to comment.