本文整理汇总了Python中vtk.vtkCoordinate函数的典型用法代码示例。如果您正苦于以下问题:Python vtkCoordinate函数的具体用法?Python vtkCoordinate怎么用?Python vtkCoordinate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkCoordinate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__( self, name, interactor, **args ):
self.vtk_coord = vtk.vtkCoordinate()
self.vtk_coord.SetCoordinateSystemToNormalizedDisplay()
self.StateChangedSignal = SIGNAL('StateChanged')
self.process_mode = ProcessMode.Default
self.currentSliders = {}
self.slider_postions = [ [ [ 0.25, 0.75 ] ], [ [0.01,0.48], [0.52, 0.99 ] ], [ [0.01,0.3], [0.35,0.7], [0.75, 0.99 ] ], [ [0.01,0.24], [0.26,0.49], [0.51,0.74], [0.76, 0.99 ] ] ]
self.slidersVisible = [ True, False, False, False ]
self.interactor = interactor
self.InteractionState = None
self.LastInteractionState = None
self.activeSliceIndex = 0
self.name = name
self.groups = {}
self.origin = args.get( 'origin', OriginPosition.Upper_Left )
self.orientation = args.get( 'orientation', Orientation.Vertical )
self.position = args.get( 'position', ( 0.0, 1.0 ) )
self.buffer = args.get( 'buffer', ( 3, 3 ) )
self.windowSizeRange = [ 200, 1200 ]
self.minScale = 0.3
self.buttons = []
self.visible = False
self.configurableFunctions = collections.OrderedDict()
ButtonBarWidget.button_bars[ name ] = self
self.updateWindowSize()
开发者ID:ThomasMaxwell,项目名称:UVIS_DV3D,代码行数:25,代码来源:ButtonBarWidget.py
示例2: _draw_line
def _draw_line(self):
line1 = vtk.vtkLineSource()
line1.SetPoint1(self.points[0])
line1.SetPoint2(self.points[1])
line2 = vtk.vtkLineSource()
line2.SetPoint1(self.points[1])
line2.SetPoint2(self.points[2])
arc = self.DrawArc()
line = vtk.vtkAppendPolyData()
line.AddInput(line1.GetOutput())
line.AddInput(line2.GetOutput())
line.AddInput(arc.GetOutput())
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
m = vtk.vtkPolyDataMapper2D()
m.SetInputConnection(line.GetOutputPort())
m.SetTransformCoordinate(c)
a = vtk.vtkActor2D()
a.SetMapper(m)
a.GetProperty().SetColor(self.colour)
self.line_actor = a
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:27,代码来源:measures.py
示例3: __build_cross_lines
def __build_cross_lines(self):
renderer = self.slice_data.overlay_renderer
cross = vtk.vtkCursor3D()
cross.AllOff()
cross.AxesOn()
self.cross = cross
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
cross_mapper = vtk.vtkPolyDataMapper()
cross_mapper.SetInput(cross.GetOutput())
#cross_mapper.SetTransformCoordinate(c)
p = vtk.vtkProperty()
p.SetColor(1, 0, 0)
cross_actor = vtk.vtkActor()
cross_actor.SetMapper(cross_mapper)
cross_actor.SetProperty(p)
cross_actor.VisibilityOff()
# Only the slices are pickable
cross_actor.PickableOff()
self.cross_actor = cross_actor
renderer.AddActor(cross_actor)
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:27,代码来源:viewer_slice.py
示例4: Coord3DtoDisplay
def Coord3DtoDisplay(self, x, y, z, canvas):
coord = vtk.vtkCoordinate()
coord.SetValue(x, y, z)
cx, cy = coord.GetComputedDisplayValue(canvas.evt_renderer)
return (cx, cy)
开发者ID:invesalius,项目名称:invesalius3,代码行数:7,代码来源:geometry.py
示例5: CreateViewportBox
def CreateViewportBox(colorfg,linewidth=3) :
pts = vtk.vtkPoints()
pts.SetNumberOfPoints(4)
pts.SetPoint(0, 0.0, 0.0, 0.0)
pts.SetPoint(1, 0.0, 1.0, 0.0)
pts.SetPoint(2, 1.0, 1.0, 0.0)
pts.SetPoint(3, 1.0, 0.0, 0.0)
lines = vtk.vtkCellArray()
lines.InsertNextCell(5)
lines.InsertCellPoint(0)
lines.InsertCellPoint(1)
lines.InsertCellPoint(2)
lines.InsertCellPoint(3)
lines.InsertCellPoint(0)
box = vtk.vtkPolyData()
box.SetPoints(pts)
box.SetLines(lines)
coords = vtk.vtkCoordinate()
coords.SetCoordinateSystemToNormalizedViewport()
boxmapper = vtk.vtkPolyDataMapper2D()
boxmapper.SetInputData(box)
boxmapper.SetTransformCoordinate(coords)
boxactor = vtk.vtkActor2D()
boxactor.SetMapper(boxmapper)
boxactor.GetProperty().SetLineWidth(linewidth)
boxactor.GetProperty().SetColor(colorfg)
return boxactor
开发者ID:PBrockmann,项目名称:VTK_Mapper,代码行数:31,代码来源:mylib_axis.py
示例6: draw_to_canvas
def draw_to_canvas(self, gc, canvas):
"""
Draws to an wx.GraphicsContext.
Parameters:
gc: is a wx.GraphicsContext
canvas: the canvas it's being drawn.
"""
coord = vtk.vtkCoordinate()
points = []
for p in self.points:
coord.SetValue(p)
cx, cy = coord.GetComputedDoubleDisplayValue(canvas.evt_renderer)
print cx, cy
# canvas.draw_circle((cx, cy), 2.5)
points.append((cx, cy))
if len(points) > 1:
for (p0, p1) in zip(points[:-1:], points[1::]):
r, g, b = self.colour
canvas.draw_line(p0, p1, colour=(r*255, g*255, b*255, 255))
if len(points) == 3:
txt = u"%.3f° / %.3f°" % (self.GetValue(), 360.0 - self.GetValue())
r, g, b = self.colour
canvas.draw_arc(points[1], points[0], points[2], line_colour=(r*255, g*255, b*255, 255))
canvas.draw_text_box(txt, (points[1][0], points[1][1]), txt_colour=MEASURE_TEXT_COLOUR, bg_colour=MEASURE_TEXTBOX_COLOUR)
开发者ID:151706061,项目名称:invesalius3,代码行数:28,代码来源:measures.py
示例7: draw_to_canvas
def draw_to_canvas(self, gc, canvas):
coord = vtk.vtkCoordinate()
coord.SetCoordinateSystemToNormalizedDisplay()
coord.SetValue(*self.position)
x, y = coord.GetComputedDisplayValue(canvas.evt_renderer)
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
# font.SetWeight(wx.FONTWEIGHT_BOLD)
font.SetSymbolicSize(self.symbolic_syze)
canvas.draw_text(self.text, (x, y), font=font)
开发者ID:invesalius,项目名称:invesalius3,代码行数:10,代码来源:vtk_utils.py
示例8: computeBounds
def computeBounds( renderer, normalized_display_position, size ):
upperRight = vtk.vtkCoordinate()
upperRight.SetCoordinateSystemToNormalizedDisplay()
upperRight.SetValue( normalized_display_position[0], normalized_display_position[1] )
bds = [0.0]*6
bds[0] = upperRight.GetComputedDisplayValue(renderer)[0] - size[0]
bds[1] = bds[0] + size[0]
bds[2] = upperRight.GetComputedDisplayValue(renderer)[1] - size[1]
bds[3] = bds[2] + size[1]
return bds
开发者ID:NESII,项目名称:uvcdat,代码行数:10,代码来源:WidgetTest.py
示例9: OnPaint
def OnPaint(self, evt, obj):
size = self.canvas_renderer.GetSize()
w, h = size
if self._size != size:
self._size = size
self._resize_canvas(w, h)
cam_modif_time = self.evt_renderer.GetActiveCamera().GetMTime()
if (not self.modified) and cam_modif_time == self.last_cam_modif_time:
return
self.last_cam_modif_time = cam_modif_time
self._array[:] = 0
coord = vtk.vtkCoordinate()
self.image.SetDataBuffer(self.rgb)
self.image.SetAlphaBuffer(self.alpha)
self.image.Clear()
gc = wx.GraphicsContext.Create(self.image)
if sys.platform != 'darwin':
gc.SetAntialiasMode(0)
self.gc = gc
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
# font.SetWeight(wx.BOLD)
font = gc.CreateFont(font, (0, 0, 255))
gc.SetFont(font)
pen = wx.Pen(wx.Colour(255, 0, 0, 128), 2, wx.SOLID)
brush = wx.Brush(wx.Colour(0, 255, 0, 128))
gc.SetPen(pen)
gc.SetBrush(brush)
gc.Scale(1, -1)
self._ordered_draw_list = sorted(self._follow_draw_list(), key=lambda x: x[0])
for l, d in self._ordered_draw_list: #sorted(self.draw_list, key=lambda x: x.layer if hasattr(x, 'layer') else 0):
d.draw_to_canvas(gc, self)
gc.Destroy()
self.gc = None
if self._drawn:
self.bitmap = self.image.ConvertToBitmap()
self.bitmap.CopyToBuffer(self._array, wx.BitmapBufferFormat_RGBA)
self._cv_image.Modified()
self.modified = False
self._drawn = False
开发者ID:paulojamorim,项目名称:invesalius3,代码行数:52,代码来源:canvas_renderer.py
示例10: GetRepresentation
def GetRepresentation(self, x, y, z):
pc = self.camera.GetPosition() # camera position
pf = self.camera.GetFocalPoint() # focal position
pp = (x, y, z) # point where the user clicked
# Vector from camera position to user clicked point
vcp = [j-i for i,j in zip(pc, pp)]
# Vector from camera position to camera focal point
vcf = [j-i for i,j in zip(pc, pf)]
# the vector where the perpendicular vector will be given
n = [0,0,0]
# The cross, or vectorial product, give a vector perpendicular to vcp
# and vcf, in this case this vector will be in horizontal, this vector
# will be stored in the variable "n"
vtk.vtkMath.Cross(vcp, vcf, n)
# then normalize n to only indicate the direction of this vector
vtk.vtkMath.Normalize(n)
# then
p1 = [i*self.size + j for i,j in zip(n, pp)]
p2 = [i*-self.size + j for i,j in zip(n, pp)]
sh = vtk.vtkLineSource()
sh.SetPoint1(p1)
sh.SetPoint2(p2)
n = [0,0,0]
vcn = [j-i for i,j in zip(p1, pc)]
vtk.vtkMath.Cross(vcp, vcn, n)
vtk.vtkMath.Normalize(n)
p3 = [i*self.size + j for i,j in zip(n, pp)]
p4 = [i*-self.size +j for i,j in zip(n, pp)]
sv = vtk.vtkLineSource()
sv.SetPoint1(p3)
sv.SetPoint2(p4)
cruz = vtk.vtkAppendPolyData()
cruz.AddInput(sv.GetOutput())
cruz.AddInput(sh.GetOutput())
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
m = vtk.vtkPolyDataMapper2D()
m.SetInputConnection(cruz.GetOutputPort())
m.SetTransformCoordinate(c)
a = vtk.vtkActor2D()
a.SetMapper(m)
a.GetProperty().SetColor(self.colour)
return a
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:51,代码来源:measures.py
示例11: convert_world_to_display
def convert_world_to_display(self, viewpoint, x, y, z):
"""Converts world coordinates x, y, z to display coordinates.
Used in 2D affine alignment model to get shape feature coordinates
in image.
"""
self.vtkrenderer.SetActiveCamera(self.vtkcamera)
self._setup_camera(viewpoint)
vtkcoordinate = vtk.vtkCoordinate()
vtkcoordinate.SetCoordinateSystemToWorld()
vtkcoordinate.SetValue(x, y, z)
# x and y are flipped in render method.
y, x = vtkcoordinate.GetComputedDisplayValue(self.vtkrenderer)
return x, y
开发者ID:gokererdogan,项目名称:Infer3DShape,代码行数:15,代码来源:vision_forward_model.py
示例12: CreateAxisTickActor
def CreateAxisTickActor(xstart,ystart,xend,yend,colorfg) :
line=vtk.vtkLineSource()
line.SetPoint1(xstart,ystart,0.0)
line.SetPoint2(xend,yend,0.0)
coords = vtk.vtkCoordinate()
coords.SetCoordinateSystemToNormalizedViewport()
linemapper = vtk.vtkPolyDataMapper2D()
linemapper.SetInputConnection(line.GetOutputPort())
linemapper.SetTransformCoordinate(coords)
tick = vtk.vtkActor2D()
tick.SetMapper(linemapper)
tick.GetProperty().SetLineWidth(1)
tick.GetProperty().SetColor(colorfg)
tick.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
return tick
开发者ID:PBrockmann,项目名称:VTK_Mapper,代码行数:15,代码来源:mylib_axis.py
示例13: __init__
def __init__( self, name, interactor, **args ):
self.name = name
self.interactor = interactor
self.buttons = []
self.updateWindowSize()
self.visible = False
self.position = args.get( 'position', ( 0.0, 1.0 ) )
self.vtk_coord = vtk.vtkCoordinate()
self.vtk_coord.SetCoordinateSystemToNormalizedDisplay()
self.StateChangedSignal = SIGNAL('StateChanged')
self.process_mode = ProcessMode.Default
self.origin = args.get( 'origin', OriginPosition.Upper_Left )
self.orientation = args.get( 'orientation', Orientation.Vertical )
# print " ButtonBar[%s]: %s" % ( name, str(self.position) )
self.buffer = args.get( 'buffer', ( 3, 3 ) )
self.fullButtonWindowSize = 1300
self.magnification = args.get( 'mag', 1.0 )
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:17,代码来源:ButtonBarWidget.py
示例14: set_options
def set_options(vtkchart, vtkrenderer, opt):
"""
A method for updating the legend options.
"""
legend = vtkchart.GetLegend()
if opt.isOptionValid('visible'):
vtkchart.SetShowLegend(opt['visible'])
else:
vtkchart.SetShowLegend(True)
if opt.isOptionValid('background'):
legend.GetBrush().SetColorF(opt['background'])
else:
legend.GetBrush().SetColorF(vtkrenderer.GetBackground())
legend.GetLabelProperties().SetColor(opt['label_color'])
legend.GetBrush().SetOpacityF(opt['opacity'])
if opt.isOptionValid('label_font_size'):
legend.SetLabelSize(opt['label_font_size'])
if opt.isOptionValid('point'):
pt = opt['point']
legend.SetVerticalAlignment(vtk.vtkChartLegend.CUSTOM)
legend.SetHorizontalAlignment(vtk.vtkChartLegend.CUSTOM)
coord = vtk.vtkCoordinate()
coord.SetCoordinateSystemToNormalizedViewport()
coord.SetValue(pt[0], pt[1], 0)
loc = coord.GetComputedDisplayValue(vtkrenderer)
legend.SetPoint(*loc)
else:
legend.SetVerticalAlignment(eval('vtk.vtkChartLegend.' +
opt['vertical_alignment'].upper()))
legend.SetHorizontalAlignment(eval('vtk.vtkChartLegend.' +
opt['horizontal_alignment'].upper()))
if opt.isOptionValid('border'):
legend.GetPen().SetOpacity(opt['border_opacity'])
legend.GetPen().SetColorF(opt['border_color'])
if opt.isOptionValid('border_width'):
legend.GetPen().SetWidth(opt['border_width'])
else:
legend.GetPen().SetOpacity(0)
开发者ID:aeslaughter,项目名称:moose,代码行数:46,代码来源:LegendOptions.py
示例15: startEvent
def startEvent(self):
logging.debug("In TextWidget::startEvent()")
if not self._started:
self._started = True
self.setText(self.text)
coord = vtk.vtkCoordinate()
coord.SetCoordinateSystemToNormalizedDisplay()
coord.SetValue(self.position[0], self.position[1])
pos = coord.GetComputedDisplayValue(self.scene.renderer)
x = self.position[0]/pos[0]
y = self.position[1]/pos[1]
pos = self.scene.interactor.GetEventPosition()
self.position[0] = pos[0]*x
self.position[1] = pos[1]*y
self.rep.GetPositionCoordinate().SetValue(self.position[0], self.position[1])
self.setText(self.text)
self.On()
开发者ID:aevum,项目名称:moonstone,代码行数:18,代码来源:textwidget.py
示例16: __init__
def __init__(self, font_size=14, color=(0.0, 0.0, 0.0), relative_position=(0, 1), absolute_offset=(10, -10), text="", **kwargs):
kwargs["text"] = text
kwargs['color'] = color
kwargs["absolute_offset"] = absolute_offset
kwargs["relative_position"] = relative_position
kwargs["font_size"] = font_size
self.actor = vtk.vtkTextActor()
self.text_property = self.actor.GetTextProperty()
self.text_property.SetFontFamilyToCourier()
self.text_property.SetVerticalJustificationToTop()
self.relpos_coord = vtk.vtkCoordinate()
self.relpos_coord.SetCoordinateSystemToNormalizedViewport()
self.actor.GetPositionCoordinate().SetCoordinateSystemToViewport()
self.actor.GetPositionCoordinate().SetReferenceCoordinate(self.relpos_coord)
self._process_kwargs(**kwargs)
开发者ID:gbaydin,项目名称:autodiff,代码行数:19,代码来源:troupe.py
示例17: OnRenderEvent
def OnRenderEvent(self, renderer, evt):
w = self._TextMapper.GetWidth(renderer)
h = self._TextMapper.GetHeight(renderer)
p = self._TextActor.GetPosition()
if self._Text.strip() == "":
self._RectanglePoints.InsertPoint(0, 0, 0, 0)
self._RectanglePoints.InsertPoint(1, 0, 0, 0)
self._RectanglePoints.InsertPoint(2, 0, 0, 0)
self._RectanglePoints.InsertPoint(3, 0, 0, 0)
return
coord = vtk.vtkCoordinate()
coord.SetCoordinateSystemToNormalizedViewport()
coord.SetValue(p[0], p[1])
p = coord.GetComputedViewportValue(renderer)
x = p[0]
y = p[1]
if self._Position[1] == "E":
x += 5
else:
x -= 5
if self._Position[0] == "N":
y += 5
else:
y -= 5
# pad
w += 10
h += 10
if self._Position == "SE":
self._RectanglePoints.InsertPoint(0, x - w, y, 0)
self._RectanglePoints.InsertPoint(1, x - w, y + h, 0)
self._RectanglePoints.InsertPoint(2, x, y + h, 0)
self._RectanglePoints.InsertPoint(3, x, y, 0)
elif self._Position == "NW":
self._RectanglePoints.InsertPoint(0, x, y, 0)
self._RectanglePoints.InsertPoint(1, x, y - h, 0)
self._RectanglePoints.InsertPoint(2, x + w, y - h, 0)
self._RectanglePoints.InsertPoint(3, x + w, y, 0)
开发者ID:parallaxinnovations,项目名称:vtkEVS,代码行数:43,代码来源:AnnotateFactory.py
示例18: HandleVisibilityLonAxisTextAndTicks
def HandleVisibilityLonAxisTextAndTicks(renwin,ren0,ren1,text,tickb,ticku,xpos) :
xsize,ysize=renwin.GetSize()
ren1xstart,ren1ystart,ren1xend,ren1yend=ren1.GetViewport()
coords = vtk.vtkCoordinate()
coords.SetCoordinateSystemToWorld()
coords.SetValue(xpos,0.0,0.0)
x1,y1 = coords.GetComputedDoubleViewportValue(ren1)
renxpos=x1/xsize+ren1xstart
if renxpos > ren1xstart and renxpos < ren1xend :
ren0.AddActor(text)
text.SetPosition(renxpos,ren1ystart-axisxoffset)
ren0.AddActor(tickb)
tickb.SetPosition(renxpos,ren1ystart-axisxticksize)
ren0.AddActor(ticku)
ticku.SetPosition(renxpos,ren1yend)
visibility=1
else :
ren0.RemoveActor(text)
ren0.RemoveActor(tickb)
ren0.RemoveActor(ticku)
visibility=0
return visibility
开发者ID:PBrockmann,项目名称:VTK_Mapper,代码行数:22,代码来源:mylib_axis.py
示例19: HandleVisibilityLatAxisTextAndTicks
def HandleVisibilityLatAxisTextAndTicks(renwin,ren0,ren1,text,tickl,tickr,ypos) :
xsize,ysize=renwin.GetSize()
ren1xstart,ren1ystart,ren1xend,ren1yend=ren1.GetViewport()
coords = vtk.vtkCoordinate()
coords.SetCoordinateSystemToWorld()
coords.SetValue(0.0,ypos,0.0)
x1,y1 = coords.GetComputedDoubleViewportValue(ren1)
renypos=y1/ysize+ren1ystart
if renypos > ren1ystart and renypos < ren1yend :
ren0.AddActor(text)
text.SetPosition(ren1xstart-axisyoffset,renypos)
ren0.AddActor(tickl)
tickl.SetPosition(ren1xstart-axisyticksize,renypos)
ren0.AddActor(tickr)
tickr.SetPosition(ren1xend,renypos)
visibility=1
else :
ren0.RemoveActor(text)
ren0.RemoveActor(tickl)
ren0.RemoveActor(tickr)
visibility=0
return visibility
开发者ID:PBrockmann,项目名称:VTK_Mapper,代码行数:22,代码来源:mylib_axis.py
示例20: GetImagedataCoordinates
def GetImagedataCoordinates(self, picker_position):
x, y, z = picker_position
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
c.SetValue(bounds[::2])
xi, yi = c.GetComputedViewportValue(self.render)
c.SetValue(bounds[1::2])
xf, yf = c.GetComputedViewportValue(self.render)
c.SetValue(x, y, z)
wx, wy = c.GetComputedViewportValue(self.render)
wx = wx - xi
wy = wy - yi
xf = xf - xi
yf = yf - yi
wx = (wx * self.imagedata_dimensions[0]) / xf
wy = (wy * self.imagedata_dimensions[1]) / yf
return wx, wy
开发者ID:151706061,项目名称:invesalius,代码行数:24,代码来源:styles.py
注:本文中的vtk.vtkCoordinate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论