diff --git a/src/QuiltiX/hotkeys/hotkey_functions.py b/src/QuiltiX/hotkeys/hotkey_functions.py index 5fe0bd4..316944c 100644 --- a/src/QuiltiX/hotkeys/hotkey_functions.py +++ b/src/QuiltiX/hotkeys/hotkey_functions.py @@ -42,48 +42,20 @@ def layout_v_mode(graph): graph.set_layout_direction(1) -def open_session(graph): - """ - Prompts a file open dialog to load a session. - """ - current = graph.current_session() - file_path = graph.load_dialog(current) - if file_path: - graph.load_session(file_path) +def load_mtlx_file(graph): + graph.get_root_graph().widget.parent().load_mx_file_triggered() -def import_session(graph): - """ - Prompts a file open dialog to load a session. - """ - current = graph.current_session() - file_path = graph.load_dialog(current) - if file_path: - graph.import_session(file_path) +def load_mtlx_data(graph): + graph.get_root_graph().widget.parent().load_mx_data_triggered() -def save_session(graph): - """ - Prompts a file save dialog to serialize a session if required. - """ - current = graph.current_session() - if current: - graph.save_session(current) - msg = 'Session layout saved:\n{}'.format(current) - viewer = graph.viewer() - viewer.message_dialog(msg, title='Session Saved') - else: - save_session_as(graph) +def save_mtlx(graph): + graph.get_root_graph().widget.parent().save_mx_file_triggered() -def save_session_as(graph): - """ - Prompts a file save dialog to serialize a session. - """ - current = graph.current_session() - file_path = graph.save_dialog(current) - if file_path: - graph.save_session(file_path) +def save_mtlx_as(graph): + graph.get_root_graph().widget.parent().save_mx_file_as_triggered() def new_session(graph): @@ -253,7 +225,8 @@ def toggle_node_search(graph): """ show/hide the node search widget. """ - graph.toggle_node_search() + graph._viewer.tab_search_set_nodes(graph._node_factory.names) + graph._viewer.tab_search_toggle() # custom functions diff --git a/src/QuiltiX/hotkeys/hotkeys.json b/src/QuiltiX/hotkeys/hotkeys.json index fa2f00f..b7f0161 100644 --- a/src/QuiltiX/hotkeys/hotkeys.json +++ b/src/QuiltiX/hotkeys/hotkeys.json @@ -5,30 +5,30 @@ "items":[ { "type":"command", - "label":"Open...", + "label":"Load MaterialX File...", "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"open_session", + "function_name":"load_mtlx_file", "shortcut":"QtGui.QKeySequence.Open" }, { "type":"command", - "label":"Import...", + "label":"Load MaterialX Data...", "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"import_session", + "function_name":"load_mtlx_data", "shortcut":"" }, { "type":"command", - "label":"Save...", + "label":"Save MaterialX", "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"save_session", + "function_name":"save_mtlx", "shortcut":"QtGui.QKeySequence.Save" }, { "type":"command", - "label":"Save As...", + "label":"Save MaterialX As...", "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"save_session_as", + "function_name":"save_mtlx_as", "shortcut":"Ctrl+Shift+S" } ] @@ -151,54 +151,28 @@ }, { "type":"menu", - "label":"&Graph", + "label":"&Background", "items":[ { - "type":"menu", - "label":"&Background", - "items":[ - { - "type":"command", - "label":"None", - "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"bg_grid_none", - "shortcut":"Alt+1" - }, - { - "type":"command", - "label":"Lines", - "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"bg_grid_lines", - "shortcut":"Alt+2" - }, - { - "type":"command", - "label":"Dots", - "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"bg_grid_dots", - "shortcut":"Alt+3" - } - ] + "type":"command", + "label":"None", + "file":"../examples/hotkeys/hotkey_functions.py", + "function_name":"bg_grid_none", + "shortcut":"Alt+1" + }, + { + "type":"command", + "label":"Lines", + "file":"../examples/hotkeys/hotkey_functions.py", + "function_name":"bg_grid_lines", + "shortcut":"Alt+2" }, { - "type":"menu", - "label":"&Layout", - "items":[ - { - "type":"command", - "label":"Horizontal", - "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"layout_h_mode", - "shortcut":"Shift+1" - }, - { - "type":"command", - "label":"Vertical", - "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"layout_v_mode", - "shortcut":"Shift+2" - } - ] + "type":"command", + "label":"Dots", + "file":"../examples/hotkeys/hotkey_functions.py", + "function_name":"bg_grid_dots", + "shortcut":"Alt+3" } ] }, @@ -229,16 +203,6 @@ "file":"../examples/hotkeys/hotkey_functions.py", "function_name":"layout_graph_down", "shortcut":"Ctrl+L" - }, - { - "type":"separator" - }, - { - "type":"command", - "label":"Expand Group Node", - "file":"../examples/hotkeys/hotkey_functions.py", - "function_name":"expand_group_node", - "shortcut":"Return" } ] }, diff --git a/src/QuiltiX/quiltix.py b/src/QuiltiX/quiltix.py index c768c24..7c2b566 100644 --- a/src/QuiltiX/quiltix.py +++ b/src/QuiltiX/quiltix.py @@ -140,6 +140,11 @@ def init_ui(self): lambda: self.apply_material("volume", selection=True), node_type="Material.Volumematerial", ) + self.expand_cmd = node_menu.add_command( + "Expand Nodegraph", + self.expand_selected_nodegraph, + node_type="Other.QxGroupNode", + ) self.save_def_cmd = node_menu.add_command( "Save as new definition...", self.save_as_definition, @@ -273,6 +278,11 @@ def apply_material(self, mat_type, selection=False): self.stage_ctrl.apply_material_to_prims(material_name, prims) + def expand_selected_nodegraph(self): + action = self.expand_cmd.qaction + node = self.qx_node_graph.get_node_by_id(action.node_id) + node.expand() + def save_as_definition(self): action = self.save_def_cmd.qaction node = self.qx_node_graph.get_node_by_id(action.node_id) @@ -296,11 +306,11 @@ def init_menu_bar(self): # endregion Tabs # region File - load_mx_file = QAction("Load MaterialX file...", self) + load_mx_file = QAction("Load MaterialX File...", self) load_mx_file.triggered.connect(self.load_mx_file_triggered) self.file_menu.addAction(load_mx_file) - load_mx_file = QAction("Load MaterialX data...", self) + load_mx_file = QAction("Load MaterialX Data...", self) load_mx_file.triggered.connect(self.load_mx_data_triggered) self.file_menu.addAction(load_mx_file) @@ -308,6 +318,10 @@ def init_menu_bar(self): save_mx_file.triggered.connect(self.save_mx_file_triggered) self.file_menu.addAction(save_mx_file) + save_mx_file_as = QAction("Save MaterialX As...", self) + save_mx_file_as.triggered.connect(self.save_mx_file_as_triggered) + self.file_menu.addAction(save_mx_file_as) + self.file_menu.addSeparator() load_geo = QAction("Load Geometry...", self) @@ -541,6 +555,12 @@ def load_mx_data_triggered(self): self.qx_node_graph.load_graph_from_mx_data(xml_str) def save_mx_file_triggered(self): + if os.path.exists(self.current_filepath): + self.qx_node_graph.save_graph_as_mx_file(self.current_filepath) + else: + self.save_mx_file_as_triggered() + + def save_mx_file_as_triggered(self): start_path = self.mx_selection_path if not start_path: start_path = self.geometry_selection_path