def draw_text(plotter, text, location, size, color): textActor = vtk.vtkBillboardTextActor3D() textActor.SetInput(text) textActor.SetPosition(*location) textActor.GetTextProperty().SetFontSize(size) textActor.GetTextProperty().SetColor(*color) plotter.renderer.AddActor(textActor)
def ActorCallback(caller, eventId_unuseD, clientData, callData_unused): text_actor = vtk.vtkBillboardTextActor3D(clientData) #actor = vtkActor *(caller) xyz = actor.GetPosition() label = '.3f, %.3f, %.3f' % (xyz[0], xyz[1], xyz[2]) text_actor.SetPosition(xyz) text_actor.SetInput(label)
def addActorsToRender(self): # set up neighbor text actor self.neighborTextActor = vtk.vtkBillboardTextActor3D() self.neighborTextActor.GetTextProperty().SetFontSize(int(50*72/self.logicalDpiX())) self.neighborTextActor.GetTextProperty().SetColor(1.0,1.0,0) self.neighborTextActor.GetTextProperty().SetJustificationToCentered() self.textOn = False for actor in self.modelActors: self.renderer.AddActor(actor)
def create_annotation(gui, text, x, y, z): """ Creates the actual annotation and appends it to slot Parameters ---------- gui : MainWindow has access to the settings text : str the text to display x, y, z : float the position of the label Returns ------- annotation : vtkBillboardTextActor3D the annotation object """ # http://nullege.com/codes/show/src%40p%40y%40pymatgen-2.9.6%40pymatgen%40vis%40structure_vtk.py/395/vtk.vtkVectorText/python #self.convert_units(icase, result_value, x, y, z) settings = gui.settings text_actor = vtk.vtkBillboardTextActor3D() text_actor.SetPosition(x, y, z) text_actor.SetInput(text) text_actor.PickableOff() text_actor.DragableOff() #text_actor.SetPickable(False) #text_actor.SetPosition(actor.GetPosition()) text_prop = text_actor.GetTextProperty() text_prop.SetFontSize(settings.annotation_size) text_prop.SetFontFamilyToArial() text_prop.BoldOn() text_prop.ShadowOn() text_prop.SetColor(settings.annotation_color) text_prop.SetJustificationToCentered() # finish adding the actor gui.rend.AddActor(text_actor) #self.label_actors[icase].append(text_actor) #print('added label actor %r; icase=%s' % (text, icase)) #print(self.label_actors) #self.picker_textMapper.SetInput("(%.6f, %.6f, %.6f)"% pickPos) #camera.GetPosition() #camera.GetClippingRange() #camera.GetFocalPoint() return text_actor
def make_billboard(renderer, xyz): text_actor = vtk.vtkBillboardTextActor3D() #actor = vtkActor *(caller) #print(xyz) label = '%.3f, %.3f, %.3f' % xyz text_actor.SetPosition(xyz) text_actor.SetInput(label) #text_actor.SetPosition (actor.GetPosition()) text_actor.GetTextProperty().SetFontSize(15) #text_actor.GetTextProperty().SetColor(1.0, 1.0, 0.4) text_actor.GetTextProperty().SetColor(0.0, 0.0, 0.0) text_actor.GetTextProperty().SetJustificationToCentered() renderer.AddActor(text_actor)
def addSlices(self, slices): r""" Adds slices into the AmpActor which can then be rendered Parameters ---------- slices: array_like The values in the z-axis of which to make the slices """ self.planes = [] self.cutters = [] self.pMapper = [] self.pActors = [] self.lActors = [] self.labels = [] self.hier = [] self.lMapper = [] for s in slices: p = vtk.vtkPlane() p.SetOrigin(0, 0, s) p.SetNormal(0, 0, 1) c = vtk.vtkCutter() c.SetCutFunction(p) c.SetInputData(self.mesh) c.Update() cM=vtk.vtkPolyDataMapper() cM.SetInputConnection(c.GetOutputPort()) pA=vtk.vtkActor() pA.GetProperty().SetColor(31.0/255.0, 73.0/255.0, 125.0/255.0) pA.GetProperty().SetLineWidth(5) pA.GetProperty().SetInterpolationToFlat() pA.GetProperty().EdgeVisibilityOn() pA.GetProperty().SetRenderLinesAsTubes(True) pA.SetMapper(cM) text = vtk.vtkBillboardTextActor3D() text.SetInput('test') text.SetPosition(0,0,s) text.GetTextProperty().SetColor(0, 0, 0) self.planes.append(p) self.cutters.append(c) self.pMapper.append(cM) self.pActors.append(pA) self.lActors.append(text) self.setOpacity(0.1)
def Line(renderer, p1, p2, name): X = vtk.vtkLineSource() X.SetPoint1(*p1) X.SetPoint2(*p2) X.Update() XMapper = vtk.vtkPolyDataMapper() XMapper.SetInputConnection(X.GetOutputPort()) XActor = vtk.vtkActor() XActor.SetMapper(XMapper) XActor.GetProperty().SetColor(0, 0, 0) textActor = vtk.vtkBillboardTextActor3D() textActor.SetInput(name) textActor.GetTextProperty().SetFontSize(20) textActor.GetTextProperty().SetColor(0, 0, 0) textActor.SetPosition(*p2) renderer.AddActor(XActor) renderer.AddActor(textActor)
def create_annotation(self, text, slot, x, y, z): """ Creates the actual annotation and appends it to slot Parameters ---------- text : str the text to display label_actors[icase] : List[annotation] where to place the annotation icase : int the key in label_actors to slot the result into annotation : vtkBillboardTextActor3D the annotation object x, y, z : float the position of the label """ if not isinstance(slot, list): msg = 'slot=%r type=%s' % (slot, type(slot)) raise TypeError(msg) # http://nullege.com/codes/show/src%40p%40y%40pymatgen-2.9.6%40pymatgen%40vis%40structure_vtk.py/395/vtk.vtkVectorText/python #self.convert_units(icase, result_value, x, y, z) text_actor = vtk.vtkBillboardTextActor3D() text_actor.SetPosition(x, y, z) text_actor.SetInput(text) text_actor.PickableOff() text_actor.DragableOff() #text_actor.SetPickable(False) #text_actor.SetPosition(actor.GetPosition()) text_prop = text_actor.GetTextProperty() text_prop.SetFontSize(self.gui.settings.annotation_size) text_prop.SetFontFamilyToArial() text_prop.BoldOn() text_prop.ShadowOn() text_prop.SetColor(self.gui.settings.annotation_color) text_prop.SetJustificationToCentered() # finish adding the actor self.gui.rend.AddActor(text_actor) #self.label_actors[icase].append(text_actor) slot.append(text_actor)