def __init__(self, interactor, box, configurator): self.box = box self.interactor = interactor self.configurator = configurator self.top_left = vtk_ui.Handle(self.interactor, (box.x1, box.y1), dragged=self.drag_handle, released=self.adjust, color=(0, 0, 0), normalize=True) self.top_right = vtk_ui.Handle(self.interactor, (box.x2, box.y1), dragged=self.drag_handle, released=self.adjust, color=(0, 0, 0), normalize=True) self.bottom_left = vtk_ui.Handle(self.interactor, (box.x1, box.y2), dragged=self.drag_handle, released=self.adjust, color=(0, 0, 0), normalize=True) self.bottom_right = vtk_ui.Handle(self.interactor, (box.x2, box.y2), dragged=self.drag_handle, released=self.adjust, color=(0, 0, 0), normalize=True) self.drag_buffer = 3 self.top_left.show() self.top_right.show() self.bottom_left.show() self.bottom_right.show() super(BoxEditor, self).__init__() self.register()
def click_release(self): x, y = self.event_position() if self.current_modifiers()["control"]: h = vtk_ui.Handle(self.interactor, (x, y), dragged=self.adjust, color=(0, 0, 0), normalize=True) h.show() self.handles.append(h) self.marker.x[self.index].append(x) self.marker.y[self.index].append(y) self.sync_positions()
def rebuild(self): for h in self.handles: h.detach() self.handles = [] points = zip(self.fill.x[self.index], self.fill.y[self.index]) for point in points: h = vtk_ui.Handle(self.interactor, point, released=self.adjust, color=(0, 0, 0), normalize=True) h.show() self.handles.append(h)
def __init__(self, interactor, marker, index, display, configurator): self.interactor = interactor self.marker = marker self.index = index self.configurator = configurator actors = display.backend["vtk_backend_marker_actors"][index] self.glyph, self.glyph_source, self.polydata, self.actor, self.geo = actors self.display = display self.handles = [] for ind, x in enumerate(marker.x[index]): y = marker.y[index][ind] h = vtk_ui.Handle(self.interactor, (x, y), dragged=self.adjust, color=(0, 0, 0), normalize=True) h.show() self.handles.append(h) self.toolbar = vtk_ui.toolbar.Toolbar(self.interactor, "Marker Options") self.toolbar.show() self.toolbar.add_button(["Change Color"], action=self.change_color) self.toolbar.add_slider_button(marker.size[index], 1, 300, "Marker Size", update=self.set_size) self.type_bar = self.toolbar.add_toolbar("Marker Type", open_label="Change") shapes = marker_shapes() shapes.insert(0, "Select Shape") self.shape_button = self.type_bar.add_button(shapes, action=self.change_shape) wmos = wmo_shapes() wmos.insert(0, "Select WMO Marker") self.wmo_button = self.type_bar.add_button(wmos, action=self.change_wmo) if self.marker.type[self.index] in shapes: self.shape_button.set_state( shapes.index(self.marker.type[self.index])) else: self.wmo_button.set_state(wmos.index(self.marker.type[self.index])) # Used to store the color picker when it's active self.picker = None prop = vtk.vtkTextProperty() prop.SetBackgroundColor(.87, .79, .55) prop.SetBackgroundOpacity(1) prop.SetColor(0, 0, 0) self.tooltip = vtk_ui.Label( self.interactor, "%s + Click to place new markers." % ("Cmd" if sys.platform == "darwin" else "Ctrl"), textproperty=prop) self.tooltip.left = 0 self.tooltip.top = self.interactor.GetRenderWindow().GetSize( )[1] - self.tooltip.get_dimensions()[1] self.tooltip.show() super(MarkerEditor, self).__init__() self.register()