本文整理汇总了Python中vtk.vtkInteractorStyleImage函数的典型用法代码示例。如果您正苦于以下问题:Python vtkInteractorStyleImage函数的具体用法?Python vtkInteractorStyleImage怎么用?Python vtkInteractorStyleImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkInteractorStyleImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createViewFrames
def _createViewFrames(self):
import modules.Insight.resources.python.register2DViewFrames
reload(modules.Insight.resources.python.register2DViewFrames)
viewerFrame = modules.Insight.resources.python.register2DViewFrames.\
viewerFrame
self.viewerFrame = module_utils.instantiate_module_view_frame(
self, self._module_manager, viewerFrame)
self._threedRenderer = vtk.vtkRenderer()
self._threedRenderer.SetBackground(0.5, 0.5, 0.5)
self.viewerFrame.threedRWI.GetRenderWindow().AddRenderer(
self._threedRenderer)
istyle = vtk.vtkInteractorStyleImage()
self.viewerFrame.threedRWI.SetInteractorStyle(istyle)
# controlFrame creation
controlFrame = modules.Insight.resources.python.\
register2DViewFrames.controlFrame
self.controlFrame = module_utils.instantiate_module_view_frame(
self, self._module_manager, controlFrame)
# display
self.viewerFrame.Show(True)
self.controlFrame.Show(True)
示例2: Start
def Start(self):
istyle = vtk.vtkInteractorStyleImage()
istyle.AddObserver("LeftButtonPressEvent",self.SelectRegion)
iren = Globals.renWin.GetInteractor()
iren.SetInteractorStyle(istyle)
self.UpdateObservers()
示例3: main
def main():
rwi = vtk.vtkRenderWindowInteractor()
istyle = vtk.vtkInteractorStyleImage()
rwi.SetInteractorStyle(istyle)
rw = vtk.vtkRenderWindow()
rwi.SetRenderWindow(rw)
ren = vtk.vtkRenderer()
ren.SetBackground(1, 1, 1)
ren.GetActiveCamera().SetParallelProjection(1)
rw.AddRenderer(ren)
rwi.Initialize()
# with the string "what gh", this will generate the following
# error at render:
# RuntimeError: ERROR: In ..\..\..\archive\VTK\Filtering\
# vtkStreamingDemandDrivenPipeline.cxx, line 698
# vtkStreamingDemandDrivenPipeline (017CF3C8): The update
# extent specified in the information for output port 0 on
# algorithm vtkTrivialProducer(017D2FF0) is 0 255
# 0 63 0 0, which is outside the whole extent 0 255 0 31 0 0.
# with the string "what h" (i.e. without the g and its downward
# stroke, there's no error)
ta2 = make_glyph(ren, (0, 0), "What h")
ren.ResetCamera()
rw.Render()
rwi.Start()
示例4: SetInteractorStyleToImage
def SetInteractorStyleToImage(self):
self.interactor = self.renWin.GetInteractor()
self.istyle = vtk.vtkInteractorStyleImage()
self.renWin.GetInteractor().SetInteractorStyle(self.istyle)
self.renderer.GetActiveCamera().ParallelProjectionOn()
# self.istyle.AddObserver("MouseMoveEvent", self.MouseMoveCallback)
self.istyle.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback)
self.istyle.AddObserver("LeftButtonReleaseEvent", self.LeftButtonReleaseCallback)
示例5: Start
def Start(self):
self.caller.imageObservers.append(self.UpdateObserver)
self.ResetSpline()
istyle = vtk.vtkInteractorStyleImage()
istyle.AddObserver("LeftButtonReleaseEvent", self.AddPoint)
istyle.AddObserver("RightButtonPressEvent", self.AddSpline)
iren = Globals.renWin.GetInteractor()
iren.SetInteractorStyle(istyle)
示例6: __init_vtk
def __init_vtk(self):
actor = vtk.vtkImageActor()
self.actor = actor
text_image_size = vtku.Text()
text_image_size.SetPosition(const.TEXT_POS_LEFT_UP)
text_image_size.SetValue("")
text_image_size.SetSize(const.TEXT_SIZE_SMALL)
self.text_image_size = text_image_size
text_image_location = vtku.Text()
text_image_location.SetVerticalJustificationToBottom()
text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN)
text_image_location.SetValue("")
text_image_location.SetSize(const.TEXT_SIZE_SMALL)
self.text_image_location = text_image_location
text_patient = vtku.Text()
text_patient.SetJustificationToRight()
text_patient.SetPosition(const.TEXT_POS_RIGHT_UP)
text_patient.SetValue("")
text_patient.SetSize(const.TEXT_SIZE_SMALL)
self.text_patient = text_patient
text_acquisition = vtku.Text()
text_acquisition.SetJustificationToRight()
text_acquisition.SetVerticalJustificationToBottom()
text_acquisition.SetPosition(const.TEXT_POS_RIGHT_DOWN)
text_acquisition.SetValue("")
text_acquisition.SetSize(const.TEXT_SIZE_SMALL)
self.text_acquisition = text_acquisition
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.AddActor(text_image_size.actor)
renderer.AddActor(text_image_location.actor)
renderer.AddActor(text_patient.actor)
renderer.AddActor(text_acquisition.actor)
self.renderer = renderer
style = vtk.vtkInteractorStyleImage()
interactor = wxVTKRenderWindowInteractor(self.panel, -1,
size=wx.Size(340,340))
interactor.GetRenderWindow().AddRenderer(renderer)
interactor.SetInteractorStyle(style)
interactor.Render()
self.interactor = interactor
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(interactor, 1, wx.GROW|wx.EXPAND)
sizer.Fit(self.panel)
self.panel.SetSizer(sizer)
self.Layout()
self.Update()
示例7: SetInteractorStyleToImage
def SetInteractorStyleToImage(self):
self.interactor = self.window.GetInteractor()
self.interactorStyle = vtk.vtkInteractorStyleImage()
self.window.GetInteractor().SetInteractorStyle(self.interactorStyle)
self.interactorStyle.AddObserver("MouseMoveEvent", self.MouseMoveCallback)
self.interactorStyle.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback)
self.interactorStyle.AddObserver("LeftButtonReleaseEvent", self.LeftButtonReleaseCallback)
self.sliderWidget.SetInteractor(self.interactor)
self.sliderWidget.SetRepresentation(self.sliderRep)
self.sliderWidget.SetAnimationModeToAnimate()
self.sliderWidget.EnabledOn()
self.sliderWidget.AddObserver("InteractionEvent", self.sliderCallback)
self.sliderWidget.AddObserver("EndInteractionEvent", self.endSliderCallback)
示例8: SetInteractor
def SetInteractor(self, interactor):
self.interactor = interactor
self.render = interactor.GetRenderWindow().GetRenderers().GetFirstRenderer()
istyle = vtk.vtkInteractorStyleImage()
istyle.SetInteractor(interactor)
istyle.AutoAdjustCameraClippingRangeOn()
interactor.SetInteractorStyle(istyle)
istyle.AddObserver("LeftButtonPressEvent", self.Click)
istyle.AddObserver("LeftButtonReleaseEvent", self.Release)
istyle.AddObserver("MouseMoveEvent",self.Moved)
pick = self.pick = vtk.vtkCellPicker()
示例9: __init__
def __init__(self, parent=None):
logging.debug("In VTKImageView::__init__()")
super(VTKImageView, self).__init__(parent)
self.setWindowTitle(constant.TITLE_PROGRAM)
self.actor = vtk.vtkImageActor()
self.textActors = []
self.render = vtk.vtkRenderer()
self.render.AddActor(self.actor)
self.interactorStyle = vtk.vtkInteractorStyleImage()
self.SetInteractorStyle(self.interactorStyle)
self.window = self.GetRenderWindow()
self.window.AddRenderer(self.render)
示例10: DisplayComponent
def DisplayComponent(source):
renderer = vtk.vtkRenderer()
win = vtk.vtkRenderWindow()
win.AddRenderer(renderer)
style = vtk.vtkInteractorStyleImage()
intact = vtk.vtkRenderWindowInteractor()
intact.SetInteractorStyle(style)
intact.SetRenderWindow(win)
planeX = vtk.vtkImagePlaneWidget()
planeY = vtk.vtkImagePlaneWidget()
planeZ = vtk.vtkImagePlaneWidget()
planeX.SetInteractor(intact)
planeY.SetInteractor(intact)
planeZ.SetInteractor(intact)
planeX.SetInputData(source)
planeY.SetInputData(source)
planeZ.SetInputData(source)
planeX.SetPlaneOrientationToXAxes()
planeY.SetPlaneOrientationToYAxes()
planeZ.SetPlaneOrientationToZAxes()
planeX.On()
planeY.On()
planeZ.On()
global pos
pos = 1
def myCallback(obj,event):
global pos
#print obj.__class__.__name__," called"
key = obj.GetKeySym()
if key=="Up":
pos = pos+1
planeX.SetSliceIndex(pos)
print pos
win.Render()
else:
pass
intact.AddObserver(vtk.vtkCommand.KeyPressEvent,myCallback)
intact.Start()
示例11: viewVtk
def viewVtk(mat):
import vtk
imageData = vtk.vtkImageData()
imageData.SetDimensions(mat.shape[0], mat.shape[1], 1)
imageData.SetScalarTypeToUnsignedShort()
imageData.SetNumberOfScalarComponents(1)
imageData.AllocateScalars()
viewer = vtk.vtkImageViewer()
viewer.SetInput(imageData)
viewer.SetZSlice(0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(viewer.GetRenderWindow())
iren.Initialize()
iren.Start()
imageData = vtk.vtkImageSinusoidSource()
imageData.SetWholeExtent(0, 300, 0, 300, 0, 10)
imageData.SetAmplitude(63)
imageData.SetDirection(1, 1, 0)
imageData.SetPeriod(25)
viewer = vtk.vtkImageViewer()
viewer.SetInput(imageData.GetOutput())
viewer.SetColorWindow(126)
viewer.SetColorLevel(0)
viewer.SetZSlice(0)
def hamschti(obj, event):
print "Haam:"
print obj
print event
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(viewer.GetRenderWindow())
iren.Initialize()
interactor = vtk.vtkInteractorStyleImage()
##interactor.AddObserver('LeftButtonPressEvent', hamschti)
iren.SetInteractorStyle(interactor)
iren.Start()
示例12: Display
def Display(self):
wholeExtent = self.Image.GetWholeExtent()
self.SliceVOI[0] = wholeExtent[0]
self.SliceVOI[1] = wholeExtent[1]
self.SliceVOI[2] = wholeExtent[2]
self.SliceVOI[3] = wholeExtent[3]
self.SliceVOI[4] = wholeExtent[4]
self.SliceVOI[5] = wholeExtent[5]
self.SliceVOI[self.Axis*2] = wholeExtent[self.Axis*2]
self.SliceVOI[self.Axis*2+1] = wholeExtent[self.Axis*2]
range = self.Image.GetScalarRange()
imageShifter = vtk.vtkImageShiftScale()
imageShifter.SetInput(self.Image)
imageShifter.SetShift(-1.0*range[0])
imageShifter.SetScale(255.0/(range[1]-range[0]))
imageShifter.SetOutputScalarTypeToUnsignedChar()
widgetImage = imageShifter.GetOutput()
self.ImageActor.SetInput(widgetImage)
self.ImageActor.SetDisplayExtent(self.SliceVOI)
self.vmtkRenderer.Renderer.AddActor(self.ImageActor)
self.ImageTracerWidget.SetCaptureRadius(1.5)
self.ImageTracerWidget.SetViewProp(self.ImageActor)
self.ImageTracerWidget.SetInput(widgetImage)
self.ImageTracerWidget.ProjectToPlaneOn()
self.ImageTracerWidget.SetProjectionNormal(self.Axis)
self.ImageTracerWidget.PlaceWidget()
self.ImageTracerWidget.SetAutoClose(self.AutoClose)
self.ImageTracerWidget.AddObserver("StartInteractionEvent",self.SetWidgetProjectionPosition)
self.ImageTracerWidget.AddObserver("EndInteractionEvent",self.GetLineFromWidget)
interactorStyle = vtk.vtkInteractorStyleImage()
self.vmtkRenderer.RenderWindowInteractor.SetInteractorStyle(interactorStyle)
self.vmtkRenderer.Render()
示例13: main
def main():
rwi = vtk.vtkRenderWindowInteractor()
istyle = vtk.vtkInteractorStyleImage()
rwi.SetInteractorStyle(istyle)
rw = vtk.vtkRenderWindow()
rwi.SetRenderWindow(rw)
ren = vtk.vtkRenderer()
ren.SetBackground(1,1,1)
ren.GetActiveCamera().SetParallelProjection(1)
rw.AddRenderer(ren)
rwi.Initialize()
ta1 = make_glyph(ren, (0,0), 'Hello thereTTT\nHoo you too')
ta2 = make_glyph(ren, (0,100), 'What ghte')
ta3 = make_glyph(ren, (-100, -100), 'To the left and below')
ren.ResetCamera()
rw.Render()
b = ta1.GetBounds()
b = [0,0,0,0]
ta1.GetBoundingBox(b)
print b
ss = vtk.vtkSphereSource()
ss.SetRadius(32)
sm = vtk.vtkPolyDataMapper()
sm.SetInput(ss.GetOutput())
sa = vtk.vtkActor()
sa.SetMapper(sm)
sa.SetPosition((b[1] - b[0],b[3] - b[2],0))
ren.AddActor(sa)
rwi.Start()
示例14: Visualize
def Visualize(self):
renderSize = 300;
numberOfImages = 1; #implement only one image visulization
# Setup the render window and interactor
renderWindow = vtk.vtkRenderWindow()
renderWindow.SetSize(renderSize * numberOfImages, renderSize)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
style = vtk.vtkInteractorStyleImage()
interactor.SetInteractorStyle(style)
# Render all of the images
background = [0.4,0.5,0.6]
sharedCamera = vtk.vtkCamera()
actor = vtk.vtkImageActor()
#connect itk image to vtk image
connector = self.i2vConnector.New()
connector.SetInput(self.m_Image)
actor.SetInput(connector.GetOutput())
renderer = vtk.vtkRenderer()
renderWindow.AddRenderer(renderer)
#renderer.SetViewpint()
renderer.SetBackground(background)
# start visualization
renderer.AddActor(actor)
renderer.ResetCamera()
renderWindow.Render()
# start interactor
interactor.Start()
示例15: createOrthoView
def createOrthoView(self):
"""Create an accompanying orthographic view of the sliceDirection
encapsulated by this object.
"""
# there can be only one orthoPipeline
if not self._orthoPipeline:
import modules.resources.python.slice3dVWRFrames
# import our wxGlade-generated frame
ovf = modules.resources.python.slice3dVWRFrames.orthoViewFrame
self._orthoViewFrame = ovf(
self.sliceDirections.slice3dVWR.threedFrame, id=-1,
title='dummy')
self._orthoViewFrame.SetIcon(module_utils.get_module_icon())
self._renderer = vtk.vtkRenderer()
self._renderer.SetBackground(0.5, 0.5, 0.5)
self._orthoViewFrame.RWI.GetRenderWindow().AddRenderer(
self._renderer)
istyle = vtk.vtkInteractorStyleImage()
self._orthoViewFrame.RWI.SetInteractorStyle(istyle)
wx.EVT_CLOSE(self._orthoViewFrame,
lambda e, s=self: s.destroyOrthoView)
wx.EVT_BUTTON(self._orthoViewFrame,
self._orthoViewFrame.closeButtonId,
lambda e, s=self: s.destroyOrthoView)
for ipw in self._ipws:
self._createOrthoPipelineForNewIPW(ipw)
if self._ipws:
self._resetOrthoView()
self._orthoViewFrame.Show(True)