Skip to content

Commit

Permalink
Added the feature 'create stereo image'
Browse files Browse the repository at this point in the history
  • Loading branch information
Inbal Paz committed Sep 1, 2022
1 parent 5db469e commit e1c5ec2
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 99 deletions.
69 changes: 50 additions & 19 deletions clans/clans/GUI/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ def __init__(self):
self.save_image_connections_backwards_action.setEnabled(False)
self.save_image_connections_backwards_action.triggered.connect(self.save_image_connections_backwards)

#self.save_stereo_image_action = QAction("Create stereo image", self)
#if cfg.run_params['dimensions_num_for_clustering'] == 2:
#self.save_stereo_image_action.setEnabled(False)
#self.save_stereo_image_action.triggered.connect(self.create_stereo_image)
self.save_stereo_image_action = QAction("Create stereo image", self)
if cfg.run_params['dimensions_num_for_clustering'] == 2:
self.save_stereo_image_action.setEnabled(False)
self.save_stereo_image_action.triggered.connect(self.create_stereo_image)

self.save_image_submenu.addAction(self.save_image_action)
self.save_image_submenu.addAction(self.save_image_connections_backwards_action)
#self.save_image_submenu.addAction(self.save_stereo_image_action)
self.save_image_submenu.addAction(self.save_stereo_image_action)

self.quit_action = QAction("Quit", self)
self.quit_action.triggered.connect(qApp.quit)
Expand Down Expand Up @@ -565,7 +565,7 @@ def __init__(self):
self.select_by_groups_window = windows.SelectByGroupsWindow(self, self.network_plot)

# Create a window for the stereo presentation
#self.stereo_window = windows.StereoImageWindow(self)
self.stereo_window = windows.StereoImageWindow(self)

# Create a text visual to display the 'loading file' message
self.load_file_label = scene.widgets.Label("Loading the input file - please wait", bold=True,
Expand Down Expand Up @@ -640,6 +640,7 @@ def reset_window(self):
self.selected_seq_window.close_window()
self.select_by_groups_window.close_window()
self.search_window.close_window()
self.stereo_window.close_window()

self.is_init = 0

Expand Down Expand Up @@ -883,12 +884,12 @@ def receive_load_status(self, status):
self.dimensions_clustering_combo.setCurrentIndex(1)

# Init the plots in the stereo window
#try:
#self.stereo_window.init_plot()
#except Exception as err:
#error_msg = "An error occurred: cannot initialize the data in the stereo window.\n"
#error_occurred(self.stereo_window.init_plot, 'init_plot', err, error_msg)
#return
try:
self.stereo_window.init_plot()
except Exception as err:
error_msg = "An error occurred: cannot initialize the data in the stereo window.\n"
error_occurred(self.stereo_window.init_plot, 'init_plot', err, error_msg)
return

else:
# Remove the 'loading file' message from the scene and put an error message instead
Expand Down Expand Up @@ -919,6 +920,15 @@ def load_clans_file(self):
error_occurred(self.network_plot.reset_data, 'reset_data', err, error_msg)
return

# Clear the canvas of the stereo window
try:
self.stereo_window.left_plot.reset_data()
self.stereo_window.right_plot.reset_data()
except Exception as err:
error_msg = "An error occurred: cannot reset the stereo canvas"
error_occurred(self.stereo_window.left_plot.reset_data, 'reset_data', err, error_msg)
return

# Initialize all the global data-structures
self.reset_variables()

Expand Down Expand Up @@ -948,6 +958,15 @@ def load_delimited_file(self):
error_occurred(self.network_plot.reset_data, 'reset_data', err, error_msg)
return

# Clear the canvas of the stereo window
try:
self.stereo_window.left_plot.reset_data()
self.stereo_window.right_plot.reset_data()
except Exception as err:
error_msg = "An error occurred: cannot reset the stereo canvas"
error_occurred(self.stereo_window.left_plot.reset_data, 'reset_data', err, error_msg)
return

# Initialize all the global data-structures
self.reset_variables()

Expand Down Expand Up @@ -1505,17 +1524,19 @@ def save_image_connections_backwards(self):

# Move view to 2D in order to display the connections at the back
self.dim_num = 2
#self.z_indexing_mode = 'groups'
self.change_dimensions_view()

self.save_image()

# Move view back to 3D
self.dim_num = 3
#self.z_indexing_mode = 'auto'
self.change_dimensions_view()

#def create_stereo_image(self):
def create_stereo_image(self):

#self.stereo_window.open_window()
self.stereo_window.open_window()

def conf_FR_layout(self):

Expand Down Expand Up @@ -1625,11 +1646,12 @@ def change_dimensions_num_for_clustering(self):

if self.is_show_connections:
self.save_image_connections_backwards_action.setEnabled(True)
#self.save_stereo_image_action.setEnabled(True)

# Update the coordinates in the Fruchterman-Reingold object
# Full data mode
if self.is_subset_mode == 0:
self.save_stereo_image_action.setEnabled(True)

try:
self.fr_object.init_coordinates(cfg.sequences_array['x_coor'],
cfg.sequences_array['y_coor'],
Expand All @@ -1653,7 +1675,7 @@ def change_dimensions_num_for_clustering(self):
cfg.run_params['dimensions_num_for_clustering'] = 2

self.save_image_connections_backwards_action.setEnabled(False)
#self.save_stereo_image_action.setEnabled(False)
self.save_stereo_image_action.setEnabled(False)

# Update the effective dim_num parameter if found in interactive mode
if self.mode == 'interactive':
Expand Down Expand Up @@ -1715,11 +1737,13 @@ def change_mode(self):

if self.is_show_connections:
self.save_image_connections_backwards_action.setEnabled(True)
#self.save_stereo_image_action.setEnabled(True)

if self.is_subset_mode == 0:
self.save_stereo_image_action.setEnabled(True)

else:
self.save_image_connections_backwards_action.setEnabled(False)
#self.save_stereo_image_action.setEnabled(False)
self.save_stereo_image_action.setEnabled(False)

# Disconnect the selection-special special mouse-events and connect back the default behaviour of the
# viewbox when the mouse moves
Expand All @@ -1736,7 +1760,7 @@ def change_mode(self):
self.dim_num = 2

self.save_image_connections_backwards_action.setEnabled(False)
#self.save_stereo_image_action.setEnabled(False)
self.save_stereo_image_action.setEnabled(False)

# Selection mode
if self.mode_combo.currentIndex() == 1:
Expand Down Expand Up @@ -2168,6 +2192,9 @@ def manage_subset_presentation(self):
self.z_index_mode_combo.setEnabled(False)
self.z_index_mode_label.setStyleSheet("color: " + cfg.inactive_color + ";")

# Disable save as stereo
self.save_stereo_image_action.setEnabled(False)

try:
self.network_plot.set_subset_view(self.dim_num, self.color_by, self.group_by,
self.z_indexing_mode)
Expand Down Expand Up @@ -2202,6 +2229,10 @@ def manage_subset_presentation(self):
self.select_by_text_button.setEnabled(True)
self.select_by_groups_button.setEnabled(True)

# Enable save as stereo
if cfg.run_params['dimensions_num_for_clustering'] == 3:
self.save_stereo_image_action.setEnabled(True)

if self.dim_num == 2 and len(cfg.groups_by_categories[self.group_by]['groups']) > 0:
self.z_index_mode_combo.setEnabled(True)
self.z_index_mode_label.setStyleSheet("color: black;")
Expand Down
Loading

0 comments on commit e1c5ec2

Please sign in to comment.