def on_show(self): """show the highlight""" passed = self.on_validate() self.parent().mouse_actions.get_grid_selected(self.model_name) if passed and self.win_parent is not None: nodes, unused_flag1 = check_patran_syntax(self.nodes_edit, pound=self._nodes_pound) elements, unused_flag2 = check_patran_syntax( self.elements_edit, pound=self._elements_pound) if len(nodes) == 0 and len(elements) == 0: return False nodes_filtered = np.intersect1d(self.nodes, nodes) elements_filtered = np.intersect1d(self.elements, elements) nnodes = len(nodes_filtered) nelements = len(elements_filtered) if nnodes == 0 and nelements == 0: return False self.on_remove_actors() gui = self.parent() mouse_actions = gui.mouse_actions grid = mouse_actions.get_grid_selected(self.model_name) actors = create_highlighted_actors( gui, grid, all_nodes=self.nodes, nodes=nodes_filtered, all_elements=self.elements, elements=elements_filtered) if actors: add_actors_to_gui(gui, actors, render=True) self.actors = actors return passed
def on_validate(self): """makes sure that all attributes are valid before doing any actions""" unused_nodes, flag1 = check_patran_syntax(self.nodes_edit, pound=self._nodes_pound) unused_elements, flag2 = check_patran_syntax(self.elements_edit, pound=self._elements_pound) if all([flag1, flag2]): self.out_data['clicked_ok'] = True return True return False
def on_validate(self): nodes, flag1 = check_patran_syntax(self.nodes_edit, pound=self._nodes_pound) elements, flag2 = check_patran_syntax(self.elements_edit, pound=self._elements_pound) print('%s nodes=%s' % (flag1, nodes)) print('%s elements=%s' % (flag2, elements)) if all([flag1, flag2]): self.out_data['clicked_ok'] = True return True return False
def on_show(self): """show the highlight""" passed = self.on_validate() if not passed or self.win_parent is None: return passed self.parent().mouse_actions.get_grid_selected(self.model_name) nodes, unused_flag1 = check_patran_syntax(self.nodes_edit, pound=self._nodes_pound) elements, unused_flag2 = check_patran_syntax( self.elements_edit, pound=self._elements_pound) if len(nodes) == 0 and len(elements) == 0: return False nodes_filtered = np.intersect1d(self.nodes, nodes) elements_filtered = np.intersect1d(self.elements, elements) nnodes = len(nodes_filtered) nelements = len(elements_filtered) if nnodes == 0 and nelements == 0: return False self.on_remove_actors() gui = self.parent() mouse_actions = gui.mouse_actions grid = mouse_actions.get_grid_selected(self.model_name) actors = create_highlighted_actors(gui, grid, all_nodes=self.nodes, nodes=nodes_filtered, set_node_scalars=True, all_elements=self.elements, elements=elements_filtered, set_element_scalars=True, add_actors=False) #make_highlight = self.menu_type == 'highlight' make_labels = self.menu_type == 'mark' make_element_labels = True make_node_labels = True if make_labels: actors = self._save_mark_actors(gui, make_node_labels, make_element_labels, nnodes, nelements, actors) if actors: add_actors_to_gui(gui, actors, render=True) self.actors = actors gui.Render() return passed
def on_highlight_remove(self): """highlights the elements to remove""" eids, is_valid = check_patran_syntax(self.remove_edit) if not is_valid: #self.remove_edit.setStyleSheet("QLineEdit{background: red;}") return self.on_highlight(eids=eids)
def on_highlight_add(self): """highlights the elements to add""" eids, is_valid = check_patran_syntax(self.add_edit, pound=self.elements_pound) if not is_valid: #self.add_edit.setStyleSheet("QLineEdit{background: red;}") return self.on_highlight(eids=eids)
def on_show(self): passed = self.on_validate() if passed and self.win_parent is not None: nodes, flag1 = check_patran_syntax(self.nodes_edit, pound=self._nodes_pound) elements, flag2 = check_patran_syntax(self.elements_edit, pound=self._elements_pound) import numpy as np nodes_filtered = np.union1d(self.nodes, nodes) elements_filtered = np.union1d(self.elements, elements) point_ids = np.searchsorted(self.nodes, nodes_filtered) cell_ids = np.searchsorted(self.elements, elements_filtered) selection_node_cells = create_vtk_selecion_node_by_cell_ids(cell_ids) selection_node_points = create_vtk_selecion_node_by_cell_ids(cell_ids) self.actor = actor self.parent.vtk_interactor.Render() return passed
def on_validate(self): name, flag0 = self.check_name(self.name_edit) elements, flag1 = check_patran_syntax(self.elements_edit, pound=self.elements_pound) #coords_value, flag2 = check_patran_syntax(self.coords_edit, #pound=self.coords_pound) if all([flag0, flag1]): self._default_name = name self._default_elements = self.eids self.out_data['clicked_ok'] = True self.out_data['close'] = True return True return False
def on_remove(self): eids, is_valid = check_patran_syntax(self.remove_edit) #adict, is_valid = check_patran_syntax_dict(self.remove_edit) if not is_valid: #self.remove_edit.setStyleSheet("QLineEdit{background: red;}") return #self.eids = _remove(adict, ['e', 'elem', 'element'], self.eids) #self.cids = _remove(adict, ['c', 'cid', 'coord'], self.cids) self.eids = setdiff1d(self.eids, eids) self._apply_cids_eids() self.remove_edit.clear() self.remove_edit.setStyleSheet("QLineEdit{background: white;}") self.on_update_main()
def on_add(self): eids, is_valid = check_patran_syntax(self.add_edit, pound=self.elements_pound) #adict, is_valid = check_patran_syntax_dict(self.add_edit) if not is_valid: #self.add_edit.setStyleSheet("QLineEdit{background: red;}") return self.eids = unique(hstack([self.eids, eids])) #self.eids = _add(adict, ['e', 'elem', 'element'], self.eids) #self.cids = _add(adict, ['c', 'cid', 'coord'], self.cids) self._apply_cids_eids() self.add_edit.clear() self.add_edit.setStyleSheet("QLineEdit{background: white;}") self.on_update_main()
def on_show(self): """show the highlight""" passed = self.on_validate() self.parent().mouse_actions.get_grid_selected(self.model_name) if passed and self.win_parent is not None: nodes, unused_flag1 = check_patran_syntax(self.nodes_edit, pound=self._nodes_pound) elements, unused_flag2 = check_patran_syntax( self.elements_edit, pound=self._elements_pound) if len(nodes) == 0 and len(elements) == 0: return False nodes_filtered = np.intersect1d(self.nodes, nodes) elements_filtered = np.intersect1d(self.elements, elements) nnodes = len(nodes_filtered) nelements = len(elements_filtered) if nnodes == 0 and nelements == 0: return False self.on_remove_actors() gui = self.parent() mouse_actions = gui.mouse_actions grid = mouse_actions.get_grid_selected(self.model_name) actors = create_highlighted_actors(gui, grid, all_nodes=self.nodes, nodes=nodes_filtered, set_node_scalars=True, all_elements=self.elements, elements=elements_filtered, set_element_scalars=True) iactor = 0 make_element_labels = True make_node_labels = True if make_node_labels and nnodes: mapper = actors[iactor].GetMapper() mygrid = mapper.GetInput() point_id_filter = get_ids_filter(mygrid, idsname='Ids_points', is_nids=True, is_eids=False) point_id_filter.SetFieldData(1) point_id_filter.SetPointIds(0) point_id_filter.FieldDataOn() label_actor = create_node_labels(point_id_filter, mygrid, gui.rend, label_size=self._label_size) actors.append(label_actor) iactor += 1 if make_element_labels and nelements: mapper = actors[iactor].GetMapper() mygrid = mapper.GetInput() element_id_filter = get_ids_filter(mygrid, idsname='Ids_cells', is_nids=False, is_eids=True) element_id_filter.SetFieldData(1) element_id_filter.SetCellIds(0) element_id_filter.FieldDataOn() # Create labels for cells cell_centers = vtk.vtkCellCenters() cell_centers.SetInputConnection( element_id_filter.GetOutputPort()) cell_mapper = vtk.vtkLabeledDataMapper() cell_mapper.SetInputConnection(cell_centers.GetOutputPort()) cell_mapper.SetLabelModeToLabelScalars() label_actor = vtk.vtkActor2D() label_actor.SetMapper(cell_mapper) actors.append(label_actor) iactor += 1 if actors: add_actors_to_gui(gui, actors, render=True) self.actors = actors return passed