本文整理汇总了Python中vtk.vtkTextProperty函数的典型用法代码示例。如果您正苦于以下问题:Python vtkTextProperty函数的具体用法?Python vtkTextProperty怎么用?Python vtkTextProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkTextProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
# Skip the parent constructor
# super(Axes, self).__init__(renderer)
text_property_x = vtk.vtkTextProperty()
text_property_x.ItalicOn()
text_property_x.ShadowOn()
text_property_x.BoldOn()
text_property_x.SetFontFamilyToTimes()
text_property_x.SetColor(1, 0, 0)
text_property_y = vtk.vtkTextProperty()
text_property_y.ShallowCopy(text_property_x)
text_property_y.SetColor(0, 1, 0)
text_property_z = vtk.vtkTextProperty()
text_property_z.ShallowCopy(text_property_x)
text_property_z.SetColor(0, 0, 1)
self.axes = vtk.vtkAxesActor()
self.axes.SetShaftTypeToCylinder()
self.axes.SetCylinderRadius(0.05)
self.axes.SetTotalLength(3 * [1.5])
self.axes.GetXAxisCaptionActor2D().SetCaptionTextProperty(
text_property_x)
self.axes.GetYAxisCaptionActor2D().SetCaptionTextProperty(
text_property_y)
self.axes.GetZAxisCaptionActor2D().SetCaptionTextProperty(
text_property_z)
示例2: createActor
def createActor( self, **args ):
if self.colorBarActor == None:
pos = args.get( 'pos', [ 0.9, 0.2 ] )
title = args.get( 'title', '' )
self.colorBarActor = vtk.vtkScalarBarActor()
# self.colorBarActor.SetMaximumWidthInPixels( 50 )
self.colorBarActor.SetNumberOfLabels(9)
labelFormat = vtk.vtkTextProperty()
labelFormat.SetFontSize( 160 )
labelFormat.SetColor( VTK_FOREGROUND_COLOR[0], VTK_FOREGROUND_COLOR[1], VTK_FOREGROUND_COLOR[2] )
titleFormat = vtk.vtkTextProperty()
titleFormat.SetFontSize( 160 )
titleFormat.SetColor( VTK_FOREGROUND_COLOR[0], VTK_FOREGROUND_COLOR[1], VTK_FOREGROUND_COLOR[2] )
# titleFormat.SetVerticalJustificationToTop ()
# titleFormat.BoldOn()
self.colorBarActor.SetPosition( pos[0], pos[1] )
self.colorBarActor.SetLabelTextProperty( labelFormat )
self.colorBarActor.SetTitleTextProperty( titleFormat )
self.colorBarActor.SetTitle( title )
self.colorBarActor.SetLookupTable( self.getDisplayLookupTable() )
self.colorBarActor.SetVisibility(0)
self.colorBarActor.SetMaximumWidthInPixels(75)
else:
self.colorBarActor.SetLookupTable( self.getDisplayLookupTable() )
self.colorBarActor.Modified()
return self.colorBarActor
示例3: build_axes
def build_axes(self, noZaxis = False):
if self.axes is None:
self.axes = vtk.vtkAxesActor()
# self.axes.SetShaftTypeToCylinder()
if not noZaxis:
self.axes.SetTotalLength( self.data.shape[0] - 1, self.data.shape[1] - 1, self.data.shape[2] - 1)
else:
self.axes.SetTotalLength( self.data.shape[0] - 1, self.data.shape[1] - 1, 0 )
self.axes.SetNormalizedShaftLength( 1, 1, 1 )
self.axes.SetNormalizedTipLength( 0, 0, 0 )
# self.axes.SetNormalizedShaftLength( 0.85, 0.85, 0.85 )
# self.axes.SetNormalizedTipLength( 0.15, 0.15, 0.15 )
self.axes.AxisLabelsOn()
self.axes.GetXAxisTipProperty().SetColor( 0, 0, 1)
self.axes.GetXAxisShaftProperty().SetColor( 0, 0, 1)
self.axes.GetXAxisShaftProperty().SetLineWidth (2)
self.axes.SetXAxisLabelText('x')
txtprop = vtk.vtkTextProperty()
txtprop.SetColor(0, 0, 0)
txtprop.SetFontFamilyToArial()
txtprop.SetFontSize(12)
txtprop.SetOpacity(0.5)
self.axes.GetXAxisCaptionActor2D().SetCaptionTextProperty(txtprop)
self.axes.GetYAxisTipProperty().SetColor( 0, 1, 0)
self.axes.GetYAxisShaftProperty().SetColor( 0, 1, 0)
self.axes.GetYAxisShaftProperty().SetLineWidth (2)
self.axes.SetYAxisLabelText('y')
txtprop = vtk.vtkTextProperty()
txtprop.SetColor(0, 0, 0)
txtprop.SetFontFamilyToArial()
txtprop.SetFontSize(12)
txtprop.SetOpacity(0.5)
self.axes.GetYAxisCaptionActor2D().SetCaptionTextProperty(txtprop)
self.axes.GetZAxisTipProperty().SetColor( 1, 0, 0 )
self.axes.GetZAxisShaftProperty().SetColor( 1, 0, 0)
self.axes.GetZAxisShaftProperty().SetLineWidth (2)
self.axes.SetZAxisLabelText('z')
txtprop = vtk.vtkTextProperty()
txtprop.SetColor(0, 0, 0)
txtprop.SetFontFamilyToArial()
txtprop.SetFontSize(12)
txtprop.SetOpacity(0.5)
self.axes.GetZAxisCaptionActor2D().SetCaptionTextProperty(txtprop)
self.renderer.AddActor(self.axes)
self.iren.Render()
else :
if self.axes.GetVisibility():
self.axes.VisibilityOff()
else:
self.axes.VisibilityOn()
self.iren.Render()
示例4: buildLookupTable
def buildLookupTable(self):
self.colorFunction = vtk.vtkColorTransferFunction()
self.colorFunction.SetColorSpaceToHSV()
self.colorFunction.HSVWrapOff()
drange = [10., 20.]
self.colorFunction.AddRGBPoint(drange[0], 0.0, 0.0, 1.0)
self.colorFunction.AddRGBPoint(drange[1], 1.0, 0.0, 0.0)
self.scalarBar.SetTitle("Title1")
self.scalarBar.SetLookupTable(self.colorFunction)
self.scalarBar.SetOrientationToVertical()
#self.scalarBar.GetLabelTextProperty().SetFontSize(8)
self.scalarBar.SetHeight(0.9)
self.scalarBar.SetWidth(0.20) # the width is set first
# after the width is set, this is adjusted
self.scalarBar.SetPosition(0.77, 0.1)
#self.scalarBar.SetPosition2(0.1, 0.3)
#print self.scalarBar.GetPosition()
propTitle = vtk.vtkTextProperty()
propTitle.SetFontFamilyToArial()
#propTitle.ItalicOff()
propTitle.BoldOn()
propTitle.ShadowOn()
propLabel = vtk.vtkTextProperty()
propLabel.BoldOff()
propLabel.ShadowOn()
#propLabel.SetFontSize(8)
scalar_range = self.grid.GetScalarRange()
self.aQuadMapper.SetScalarRange(scalar_range)
self.aQuadMapper.SetLookupTable(self.colorFunction)
#self.scalarBar.SetTitleTextProperty(propTitle);
#self.scalarBar.SetLabelTextProperty(propLabel);
self.scalarBar.SetLabelFormat("%i")
# allows 0-1 to be nice number when ranging values (gotta pick something)
self.scalarBar.SetNumberOfLabels(11)
self.scalarBar.SetMaximumNumberOfColors(11)
#self.scalarBar.VisibilityOff() # first load -> scalar bar off
#self.scalarBar.ShadowOn()
#self.scalarBar.RepositionableOn()
self.rend.AddActor(self.scalarBar)
示例5: __create_time_legend
def __create_time_legend(self):
time_legend = vtk.vtkLegendBoxActor()
# Create legend actor
time_legend.SetNumberOfEntries(1)
time_legend.SetPosition(
self.__get_legend_position(
self.settings.time_legend_location,
self.settings.time_legend_height,
self.settings.time_legend_width,
self.settings.time_legend_offset,
)
)
time_legend.SetWidth(self.settings.time_legend_width)
time_legend.SetHeight(self.settings.time_legend_height)
tprop = vtk.vtkTextProperty()
tprop.SetColor(rgb_colors.RGB_WHITE)
tprop.SetVerticalJustificationToCentered()
time_legend.SetEntryTextProperty(tprop)
if self.settings.time_legend_border_display:
time_legend.BorderOn()
else:
time_legend.BorderOff()
return time_legend
示例6: __init__
def __init__(self, cell):
assert isinstance(cell, vtkUnitCellModule)
self.cell = cell
l0 = self.cell.get_characteristic_length()
# Create VTK axes actor (not really a VTK actor though)
self.vtk_ax = vtkAxesActor()
self.vtk_ax.SetTipTypeToCone()
self.vtk_ax.SetConeRadius(5e-2*l0)
self.vtk_ax.SetShaftTypeToCylinder()
self.vtk_ax.SetCylinderRadius(5e-3*l0)
# Create VTK two-dimensional property
p2d = vtkProperty2D()
p2d.SetDisplayLocationToBackground()
vtkModule.__init__(self, self.vtk_ax, p2d)
# Create VTK text property and apply to axes
vtk_textproperty = vtkTextProperty()
vtk_textproperty.SetFontSize(14)
vtk_textproperty.SetBold(True)
vtk_textproperty.SetItalic(True)
vtk_textproperty.SetShadow(True)
vtk_textproperty.SetJustificationToRight()
vtk_textproperty.SetVerticalJustificationToCentered()
self.set_text_property(vtk_textproperty)
示例7: do_test
def do_test(self):
prop = vtk.vtkTextProperty()
set_font("Arial", prop)
if prop.GetFontFamily() != vtk.VTK_ARIAL:
print "Font was not set to Arial"
return
set_font("Courier", prop)
if prop.GetFontFamily() != vtk.VTK_COURIER:
print "Font was not set to Courier"
return
set_font("Times", prop)
if prop.GetFontFamily() != vtk.VTK_TIMES:
print "Font was not set to Times"
return
path = os.path.abspath("blex.ttf")
set_font(path, prop)
if prop.GetFontFamily() == vtk.VTK_FONT_FILE:
if path != prop.GetFontFile():
print "Set path incorrectly"
return
else:
print "Did not set Font File correctly"
return
self.passed = 0
示例8: addText
def addText(self, text, x=0.03, y=0.97, size=12, orientation="left"):
property = vtk.vtkTextProperty()
property.SetFontSize(size)
property.SetFontFamilyToArial()
property.BoldOff()
property.ItalicOff()
# property.ShadowOn()
if orientation == "left":
property.SetJustificationToLeft()
elif orientation == "right":
property.SetJustificationToRight()
elif orientation == "center":
property.SetJustificationToCenter()
property.SetVerticalJustificationToTop()
property.SetColor(1, 1, 1)
mapper = vtk.vtkTextMapper()
mapper.SetTextProperty(property)
mapper.SetInput(str(text))
textActor = vtk.vtkActor2D()
self.textActors.append(textActor)
textActor.SetMapper(mapper)
textActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
textActor.GetPositionCoordinate().SetValue(x, y)
textActor.VisibilityOn()
self.render.AddActor(textActor)
self.Render()
示例9: addT2transvisualize
def addT2transvisualize(self, T2images, image_pos_pat, image_ori_pat, T2dims, T2spacing, sideBreast, interact):
'''Added to build second reference frame and display T2 overlayed into T1 reference frame'''
# Proceed to build reference frame for display objects based on DICOM coords
[transformed_T2image, transform_cube] = self.dicomTransform(T2images, image_pos_pat, image_ori_pat)
#alignR = int(raw_input('\nAlign right? Yes:1 No:0 : '))
#if alignR:
if(sideBreast=="Right"):
zf1 = self.T1spacing[2]*self.T1extent[5] + self.T1origin[2]
self.T2origin[2] = zf1 - T2spacing[2]*self.T2extent[5] # this is z-span
else:
self.T2origin[2] = self.T1origin[2]
# Change info origin
translated_T2image = vtk.vtkImageChangeInformation()
translated_T2image.SetInput( transformed_T2image )
translated_T2image.SetOutputOrigin(self.T2origin)
translated_T2image.Update()
# Set up ortogonal planes
self.xImagePlaneWidget.SetInput( translated_T2image.GetOutput() )
self.xImagePlaneWidget.SetSliceIndex(0)
self.yImagePlaneWidget.SetInput( translated_T2image.GetOutput() )
self.yImagePlaneWidget.SetSliceIndex(0)
self.zImagePlaneWidget.SetInput( translated_T2image.GetOutput() )
self.zImagePlaneWidget.SetSliceIndex(0)
# Create a text property for both cube axes
tprop = vtk.vtkTextProperty()
tprop.SetColor(0.5, 0.5, 0)
tprop.ShadowOff()
# Update the reneder window to receive new image !Important*****
self.renderer1.Modified()
self.renWin1.Modified()
# Create a vtkCubeAxesActor2D. Use the outer edges of the bounding box to
# draw the axes. Add the actor to the renderer.
axesT2 = vtk.vtkCubeAxesActor2D()
axesT2.SetInput(translated_T2image.GetOutput())
axesT2.SetCamera(self.renderer1.GetActiveCamera())
axesT2.SetLabelFormat("%6.4g")
axesT2.SetFlyModeToOuterEdges()
axesT2.SetFontFactor(1.2)
axesT2.SetAxisTitleTextProperty(tprop)
axesT2.SetAxisLabelTextProperty(tprop)
self.renderer1.AddViewProp(axesT2)
### Update T2Images
t_T2images = vtk.vtkImageChangeInformation()
t_T2images.SetInput( T2images )
t_T2images.SetOutputOrigin(self.T2origin)
t_T2images.Update()
############
if(interact==True):
interactor = self.renWin1.GetInteractor()
interactor.Start()
return
示例10: __init__
def __init__(self):
self.layer = 99
self.children = []
property = vtk.vtkTextProperty()
property.SetFontSize(const.TEXT_SIZE)
property.SetFontFamilyToArial()
property.BoldOff()
property.ItalicOff()
property.ShadowOn()
property.SetJustificationToLeft()
property.SetVerticalJustificationToTop()
property.SetColor(const.TEXT_COLOUR)
self.property = property
mapper = vtk.vtkTextMapper()
mapper.SetTextProperty(property)
self.mapper = mapper
actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
actor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
actor.PickableOff()
self.actor = actor
self.SetPosition(const.TEXT_POS_LEFT_UP)
示例11: do_test
def do_test(self):
text_property = vtk.vtkTextProperty()
text_property.SetFontFamilyToArial()
text_property.SetFontSize(24)
dpi = self.win.GetDPI()
w, h = vcs.vtk_ui.text.text_dimensions("no descenders", text_property,
dpi)
if w != 174 or h != 23:
print "no descenders width/height changed (%d,%d)"%(w,h)
return
w, h = vcs.vtk_ui.text.text_dimensions("couple good descenders",
text_property, dpi)
if w != 298 or h != 23:
print "couple good descenders width/height changed (%d, %d)"%(w,h)
return
w, h = vcs.vtk_ui.text.text_dimensions(
"This one\nis on\nmultiple lines", text_property, dpi)
if w != 150 or h != 73:
print "Multi-line width/height changed (%d,%d)"%(w,h)
return
self.passed = 0
示例12: __init__
def __init__(self):
self.IsProcessed = False
self.Interaction = True
self.ShowAnnotations = True
self.ShowDirections = True
self.AboutDataVisibility = True
self.LinkRender = True
self.LinkCameraFocalAndPosition = False
self.Renderer = None
self.RenderWindow = None
self.RenderWindowInteractor = None
self.Children = []
self.InteractorStyle = None
# Initilize Annotations
self.CornerAnnotation = vtk.vtkCornerAnnotation()
self.CornerAnnotation.SetNonlinearFontScaleFactor(0.3)
self.TextProperty = vtk.vtkTextProperty()
self.CornerAnnotation.SetTextProperty(self.TextProperty)
#self.OrientationAnnotation = vtkOrientationAnnotation()
#self.OrientationAnnotation.SetNonlinearFontScaleFactor(0.25)
#self.InteractorStyle = vtk.vtkInteractorStyleSwitch()
self.Parent = None
self.downRightAnnotation = ""
self.upLeftAnnotation = ""
self.upRightAnnotation = ""
self.downLeftAnnotation = ""
self.AboutData = ""
self.InternalMTime = 0
示例13: __init__
def __init__(self, interactor, text, index, dp, configurator):
self.interactor = interactor
self.text = text
self.display = dp
self.actors = dp.backend["vtk_backend_text_actors"]
self.index = index
self.configurator = configurator
for actor in self.actors:
actor.SetVisibility(0)
self.textboxes = None
self.toolbar = Toolbar(self.interactor, "Text Options")
self.toolbar.add_slider_button(
text.height,
1,
100,
"Height",
update=self.update_height)
halign = self.toolbar.add_button(
["Left Align", "Center Align", "Right Align"], action=self.halign)
valign = self.toolbar.add_button(
["Top Align", "Half Align", "Bottom Align"], action=self.valign)
halign.set_state(self.text.halign)
valign.set_state(__valign_map__[self.text.valign])
self.toolbar.add_slider_button(
text.angle,
0,
360,
"Angle",
update=self.update_angle)
self.picker = None
self.toolbar.add_button(["Change Color"], action=self.change_color)
self.toolbar.show()
prop = vtkTextProperty()
prop.SetBackgroundColor(.87, .79, .55)
prop.SetBackgroundOpacity(1)
prop.SetColor(0, 0, 0)
prop.SetVerticalJustificationToTop()
self.tooltip = Label(
self.interactor,
"%s + Click to place new text." %
("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(TextEditor, self).__init__()
self.register()
self.update()
示例14: __init__
def __init__(self):
'''
Constructor
'''
self.__OrientationMatrix = vtk.vtkMatrix4x4()
self.__CornerAnnotation = vtk.vtkCornerAnnotation()
self.__TextProperty = vtk.vtkTextProperty()
self.__LookupTable = vtk.vtkLookupTable()
self.__ScalarBarActor = vtk.vtkScalarBarActor()
self.__Prop3DCollection = vtk.vtkProp3DCollection()
self.__DataSetCollection = vtk.vtkDataSetCollection()
self.__OrientationTransform = vtk.vtkMatrixToLinearTransform()
self.__OrientationMatrix.Identity()
self.__CornerAnnotation.SetNonlinearFontScaleFactor(0.30)
self.__CornerAnnotation.SetText(0, "Jolly - (c) summit 2009 ref vtkINRIA3D")
self.__CornerAnnotation.SetMaximumFontSize(46)
self.__ScalarBarActor.SetLabelTextProperty(self.__TextProperty)
self.__ScalarBarActor.GetLabelTextProperty().BoldOff()
self.__ScalarBarActor.GetLabelTextProperty().ItalicOff()
self.__ScalarBarActor.SetNumberOfLabels(3)
self.__ScalarBarActor.SetWidth(0.1)
self.__ScalarBarActor.SetHeight(0.5)
self.__ScalarBarActor.SetPosition(0.9, 0.3)
self.__LookupTable.SetTableRange(0, 1)
self.__LookupTable.SetSaturationRange(0, 0)
self.__LookupTable.SetHueRange(0, 0)
self.__LookupTable.SetValueRange(0, 1)
self.__LookupTable.Build()
self.__ShowAnnotations = True
self.__ShowScalarBar = True
self.__OrientationTransform.SetInput(self.__OrientationMatrix)
self.__WindowLevel = self.GetWindowLevel()
self.__WindowLevel.SetLookupTable( self.__LookupTable )
self.__ScalarBarActor.SetLookupTable(self.__LookupTable)
self.__Renderer = self.GetRenderer()
self.__Renderer.AddViewProp(self.__CornerAnnotation)
self.__Renderer.AddViewProp(self.__ScalarBarActor)
self.__ImageActor = self.GetImageActor()
self.__RenderWindow = self.GetRenderWindow ()
self.__InteractorStyle = self.GetInteractorStyle()
self.__Interactor = None
self.__CornerAnnotation.SetWindowLevel(self.__WindowLevel)
self.__CornerAnnotation.SetImageActor(self.__ImageActor)
self.__CornerAnnotation.ShowSliceAndImageOn()
# Sometime we would want to set the default window/level value instead
# of the ImageData's ScalarRange
self.__RefWindow = None
self.__RefLevel = None
示例15: text_dimensions
def text_dimensions(text, text_prop, dpi, at_angle=0):
ren = vtkTextRenderer()
bounds = [0, 0, 0, 0]
p = vtkTextProperty()
p.ShallowCopy(text_prop)
p.SetOrientation(at_angle)
ren.GetBoundingBox(p, text, bounds, dpi)
return bounds[1] - bounds[0] + 1, bounds[3] - bounds[2] + 1