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 _pick_depth_ids(self, xmin, ymin, xmax, ymax): """ Does an area pick of all the ids inside the box, even the ones behind the front elements """ area_picker = self.parent.area_picker #area_picker.Pick() # double pick? area_picker.AreaPick(xmin, ymin, xmax, ymax, self.parent.rend) gui = self.parent actors, eids, nids = get_actors_by_area_picker( gui, area_picker, self.name, is_nids=self.is_nids, is_eids=self.is_eids, representation=self.representation, add_actors=False) self.actors = actors add_actors_to_gui(gui, actors, render=False) if self.callback is not None: self.callback(eids, nids, self.name) self.area_pick_button.setChecked(False) # TODO: it would be nice if you could do a rotation without # destroying the highlighted actor if self.cleanup: self.cleanup_observer = self.parent.setup_mouse_buttons( mode='default', left_button_down_cleanup=self.cleanup_callback)
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(self, nids=None, eids=None): """highlights the nodes""" gui = self.win_parent unused_name = self.keys[self.active_key] if gui is not None: self.remove_highlight_actor() ## TODO: super strange; doesn't work... mouse_actions = gui.mouse_actions grid = mouse_actions.get_grid_selected(self.model_name) #all_nodes = mouse_actions.node_ids all_elements = mouse_actions.element_ids actors = create_highlighted_actors(gui, grid, all_nodes=None, nodes=nids, all_elements=all_elements, elements=eids, add_actors=False) if actors: add_actors_to_gui(gui, actors, render=True) self.actors = actors
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