def on_bu_apply_opt_clicked(self, button): action = CustomAction("Apply connection and optimize springs") old_selection = list(context.application.cache.nodes) self.apply_normal() self.optimize() context.application.main.select_nodes(old_selection) action.finish()
def fn(): context.application.model.file_open("test/input/precursor.zml") context.application.main.select_nodes(context.application.model.universe.children) ScanForConnections = context.application.plugins.get_action("ScanForConnections") parameters = ScanForConnections.default_parameters() parameters.connect_description1 = ( Expression("isinstance(node, Atom) and node.number == 8 and node.num_bonds() == 1"), Expression("node.get_radius()"), ) parameters.repulse_description1 = ( Expression("isinstance(node, Atom) and (node.number == 8 or node.number == 14)"), Expression("node.get_radius()*1.5"), ) parameters.action_radius = 4*angstrom parameters.hit_tolerance = 0.1*angstrom parameters.allow_inversions = True parameters.minimum_triangle_size = 0.1*angstrom parameters.rotation2 = Undefined() assert ScanForConnections.analyze_selection(parameters) ScanForConnections(parameters) # Try to save the result to file an open it again. context.application.model.file_save("test/output/tmp.zml") FileNew = context.application.plugins.get_action("FileNew") FileNew() context.application.model.file_open("test/output/tmp.zml") # Do some consistency tests on the connection scanner results: scan_results = context.application.model.folder.children[0] for quality, transformation, pairs, inverse_pairs in scan_results.get_connections(): assert len(pairs) >= 3 if len(inverse_pairs) > 0: assert len(pairs) == len(inverse_pairs) # Test for the first case that the indicated atom pairs are indeed # overlapping. context.application.main.select_nodes([scan_results]) ShowConscanResultsWindow = context.application.plugins.get_action("ShowConscanResultsWindow") assert ShowConscanResultsWindow.analyze_selection() ShowConscanResultsWindow() csrw = ShowConscanResultsWindow.conscan_results_window csrw.tree_selection.select_path(0) action = CustomAction("Apply connection") csrw.apply_normal() action.finish() quality, transformation, pairs, inverse_pairs = scan_results.connections[0] for atom1, atom2 in pairs: f1 = atom1().get_absolute_frame() f2 = atom2().get_absolute_frame() d = numpy.linalg.norm(f1.t - f2.t) assert d < 1e-5 csrw.window.hide()
def on_bu_apply_clicked(self, button): action = CustomAction("Apply connection") self.apply_normal() action.finish()
def auto_apply(self): if self.cb_auto_apply.get_active() and \ self.tree_selection.get_selected()[1] is not None: action = CustomAction("Auto apply connection") self.apply_normal() action.finish()
def fn(): context.application.model.file_open("test/input/precursor.zml") context.application.main.select_nodes( context.application.model.universe.children) ScanForConnections = context.application.plugins.get_action( "ScanForConnections") parameters = ScanForConnections.default_parameters() parameters.connect_description1 = ( Expression( "isinstance(node, Atom) and node.number == 8 and node.num_bonds() == 1" ), Expression("node.get_radius()"), ) parameters.repulse_description1 = ( Expression( "isinstance(node, Atom) and (node.number == 8 or node.number == 14)" ), Expression("node.get_radius()*1.5"), ) parameters.action_radius = 4 * angstrom parameters.hit_tolerance = 0.1 * angstrom parameters.allow_inversions = True parameters.minimum_triangle_size = 0.1 * angstrom parameters.rotation2 = Undefined() assert ScanForConnections.analyze_selection(parameters) ScanForConnections(parameters) # Try to save the result to file an open it again. context.application.model.file_save("test/output/tmp.zml") FileNew = context.application.plugins.get_action("FileNew") FileNew() context.application.model.file_open("test/output/tmp.zml") # Do some consistency tests on the connection scanner results: scan_results = context.application.model.folder.children[0] for quality, transformation, pairs, inverse_pairs in scan_results.get_connections( ): assert len(pairs) >= 3 if len(inverse_pairs) > 0: assert len(pairs) == len(inverse_pairs) # Test for the first case that the indicated atom pairs are indeed # overlapping. context.application.main.select_nodes([scan_results]) ShowConscanResultsWindow = context.application.plugins.get_action( "ShowConscanResultsWindow") assert ShowConscanResultsWindow.analyze_selection() ShowConscanResultsWindow() csrw = ShowConscanResultsWindow.conscan_results_window csrw.tree_selection.select_path(0) action = CustomAction("Apply connection") csrw.apply_normal() action.finish() quality, transformation, pairs, inverse_pairs = scan_results.connections[ 0] for atom1, atom2 in pairs: f1 = atom1().get_absolute_frame() f2 = atom2().get_absolute_frame() d = numpy.linalg.norm(f1.t - f2.t) assert d < 1e-5 csrw.window.hide()