startApp.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout, QFileDialog, QComboBox, QCheckBox
  2. import sys
  3. # sys.path.append("C:/Users/iuliia/recoUI/serv")
  4. from jsonSelectionWindow import JsonSelectionWindow
  5. from reconsrtuctionApp import ReconstructionApp
  6. class StartApp(QWidget):
  7. def __init__(self):
  8. super().__init__()
  9. # print("TUT")
  10. self.path_np_data_json = None
  11. self.path_raw_data = None
  12. self.path_seq_json = None
  13. self.path_order_json = None
  14. self.reconstruction_app = None
  15. # print("Инициализация окна...")
  16. self.initUI()
  17. # print("Окно инициализировано.")
  18. def initUI(self):
  19. self.setWindowTitle('Реконструкция')
  20. layout = QVBoxLayout()
  21. self.digit_label = QLabel("Выберите (2d или 3d)")
  22. layout.addWidget(self.digit_label)
  23. self.digit_input = QComboBox(self)
  24. self.digit_input.addItems(['2d', '3d'])
  25. self.digit_input.currentTextChanged.connect(self.update_sequence_options)
  26. layout.addWidget(self.digit_input)
  27. self.sequence_label = QLabel("Имя последовательности")
  28. layout.addWidget(self.sequence_label)
  29. self.sequence_input = QComboBox(self)
  30. layout.addWidget(self.sequence_input)
  31. self.update_sequence_options(self.digit_input.currentText())
  32. # print(self.sequence_input.currentText(),self.digit_input.currentText())
  33. self.mat_file_button = QPushButton("Загрузить .mat файл", self)
  34. self.mat_file_button.clicked.connect(self.load_mat_file)
  35. layout.addWidget(self.mat_file_button)
  36. self.mat_file_label = QLabel("Файл .mat не выбран", self)
  37. layout.addWidget(self.mat_file_label)
  38. self.json_file_button = QPushButton("Загрузить .json файл", self)
  39. self.json_file_button.clicked.connect(self.load_json_file)
  40. layout.addWidget(self.json_file_button)
  41. self.json_file_label = QLabel("Файл .json не выбран", self)
  42. layout.addWidget(self.json_file_label)
  43. ####################################################
  44. self.open_order_json = QPushButton("Открыть окно выбора JSON", self)
  45. self.open_order_json.clicked.connect(self.open_json_selection_window)
  46. layout.addWidget(self.open_order_json)
  47. # print(self.sequence_input.currentText(),self.digit_input.currentText())
  48. # self.reconstruction_app = ReconstructionApp(self.sequence_input.currentText(), self.digit_input.currentText())
  49. # self.path_order_json = self.json_window.path_order_json
  50. self.phase_shift_checkbox = QCheckBox("Сдвиг по фазе (on/off)", self)
  51. self.phase_shift_checkbox.setChecked(False) # По умолчанию отключен
  52. layout.addWidget(self.phase_shift_checkbox)
  53. self.start_reco = QPushButton("Начать реконструкцию", self)
  54. self.start_reco.clicked.connect(self.init_reconstruction)
  55. layout.addWidget(self.start_reco)
  56. self.setGeometry(300, 300, 600, 500)
  57. self.setLayout(layout)
  58. def update_sequence_options(self, dimension):
  59. self.sequence_input.clear()
  60. if dimension == '2d':
  61. self.sequence_input.addItems([
  62. 'linear_decart',
  63. 'nonlinear_decart(tse)',
  64. 'linear_epi',
  65. 'radial_propeller',
  66. 'linear_decat_readout'
  67. ])
  68. elif dimension == '3d':
  69. self.sequence_input.addItems([
  70. 'linear_decart',
  71. 'nonlinear_decart(tse)'
  72. ])
  73. def load_mat_file(self):
  74. mat_file, _ = QFileDialog.getOpenFileName(self, "Выбрать .mat файл", "", "MAT Files (*.mat)")
  75. if mat_file:
  76. self.mat_file_label.setText(f"Загружен .mat файл: {mat_file}")
  77. else:
  78. self.mat_file_label.setText("Файл .mat не выбран")
  79. self.path_raw_data = mat_file
  80. def load_json_file(self):
  81. json_file, _ = QFileDialog.getOpenFileName(self, "Выбрать .json файл", "", "JSON Files (*.json)")
  82. if json_file:
  83. self.json_file_label.setText(f"Загружен .json файл: {json_file}")
  84. else:
  85. self.json_file_label.setText("Файл .json не выбран")
  86. self.path_np_data_json = json_file
  87. def open_json_selection_window(self):
  88. self.json_window = JsonSelectionWindow(
  89. self.path_np_data_json, self.path_raw_data,
  90. self.sequence_input.currentText(), self.digit_input.currentText())
  91. self.path_order_json = self.json_window.path_order_json
  92. # print(self.path_order_json)
  93. self.json_window.show()
  94. self.json_window.closeEvent = lambda event: self.update_order_json_path()
  95. # print(f"Изначальный путь JSON порядка: {self.path_order_json}")
  96. def update_order_json_path(self):
  97. self.path_order_json = self.json_window.path_order_json
  98. # print(f"Путь к JSON файлу порядка после выбора: {self.path_order_json}")
  99. # def start_reconstruction(self):
  100. def init_reconstruction(self):
  101. if self.phase_shift_checkbox.isChecked():
  102. # print("Флажок установлен: включён сдвиг по фазе.")
  103. # Добавьте действия, если флажок установлен
  104. phase_shift_enabled = True
  105. else:
  106. # print("Флажок не установлен: сдвиг по фазе выключен.")
  107. # Добавьте действия, если флажок не установлен
  108. phase_shift_enabled = False
  109. self.reconstruction_app = ReconstructionApp(
  110. self.sequence_input.currentText(),
  111. self.digit_input.currentText(),
  112. phase_shift_enabled
  113. )
  114. self.reconstruction_app.start_reconstruction(
  115. self.path_raw_data, self.path_np_data_json, self.path_order_json
  116. )